@stack-spot/portal-components 2.5.0 → 2.5.1
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 +7 -0
- package/dist/components/Stepper/Navigation.d.ts +6 -2
- package/dist/components/Stepper/Navigation.d.ts.map +1 -1
- package/dist/components/Stepper/Navigation.js +3 -3
- package/dist/components/Stepper/Navigation.js.map +1 -1
- package/dist/components/Stepper/Stepper.d.ts +3 -2
- package/dist/components/Stepper/Stepper.d.ts.map +1 -1
- package/dist/components/Stepper/Stepper.js +3 -2
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/Stepper/index.d.ts +1 -1
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Stepper/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Stepper/Navigation.tsx +10 -6
- package/src/components/Stepper/Stepper.tsx +4 -2
- package/src/components/Stepper/index.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.5.1](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.5.0...portal-components@v2.5.1) (2024-09-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* adjustments in stepper ([#356](https://github.com/stack-spot/portal-commons/issues/356)) ([c542fa4](https://github.com/stack-spot/portal-commons/commit/c542fa4bed4e54c853ff49c98a689089bea961e2))
|
|
9
|
+
|
|
3
10
|
## [2.5.0](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.4.0...portal-components@v2.5.0) (2024-09-02)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ButtonProps } from '@citric/core/dist/Button.js';
|
|
2
1
|
import { FC } from 'react';
|
|
2
|
+
import { ButtonProps } from '@citric/core/dist/Button.js';
|
|
3
3
|
export interface StepperNavigationProps extends ButtonProps {
|
|
4
4
|
/**
|
|
5
5
|
* Prop used to pass specific text to the next button.
|
|
@@ -21,11 +21,15 @@ export interface StepperNavigationProps extends ButtonProps {
|
|
|
21
21
|
* Function that is rendered when pressing the back button.
|
|
22
22
|
*/
|
|
23
23
|
onGoBack?: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Function that is rendered when pressing the next button.
|
|
26
|
+
*/
|
|
27
|
+
onSubmit?: () => void;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* Renders a component that represents the stepper component's navigation buttons, containing the button options (back, skip, and next).
|
|
27
31
|
*
|
|
28
32
|
* The component stepper wraps this component.
|
|
29
33
|
*/
|
|
30
|
-
export declare const StepperNavigation: FC<StepperNavigationProps
|
|
34
|
+
export declare const StepperNavigation: FC<Omit<StepperNavigationProps, 'children'>>;
|
|
31
35
|
//# sourceMappingURL=Navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/Navigation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/Navigation.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAc,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAItD,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAOD;;;;GAIG;AAEH,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAqCvE,CAAA"}
|
|
@@ -14,17 +14,17 @@ const Wrapper = styled(Flex) `
|
|
|
14
14
|
*
|
|
15
15
|
* The component stepper wraps this component.
|
|
16
16
|
*/
|
|
17
|
-
export const StepperNavigation = ({ nextButtonText, onSkip, onGoBack, canSkip = false, isLoading, disabled }) => {
|
|
17
|
+
export const StepperNavigation = ({ nextButtonText, onSkip, onGoBack, canSkip = false, isLoading, disabled, onSubmit }) => {
|
|
18
18
|
const t = useTranslate(dictionary);
|
|
19
19
|
const { goToNextStep, goToPreviousStep } = useContext(StepperContext);
|
|
20
20
|
const Loading = useLoadingComponent();
|
|
21
|
-
return (_jsxs(Wrapper, { children: [_jsx(Button, { appearance: "
|
|
21
|
+
return (_jsxs(Wrapper, { children: [_jsx(Button, { appearance: "contained", colorScheme: "inverse", onClick: () => {
|
|
22
22
|
onGoBack && onGoBack();
|
|
23
23
|
goToPreviousStep();
|
|
24
24
|
}, children: t.back }), _jsxs(Flex, { children: [canSkip && (_jsx(Button, { appearance: "text", colorScheme: "inverse", onClick: () => {
|
|
25
25
|
onSkip && onSkip();
|
|
26
26
|
goToNextStep();
|
|
27
|
-
}, children: t.skip })), _jsxs(Button, {
|
|
27
|
+
}, children: t.skip })), _jsxs(Button, { type: "submit", onClick: onSubmit, sx: { position: 'relative' }, disabled: isLoading || disabled, children: [_jsx(Text, { as: "span", sx: { visibility: isLoading ? 'hidden' : 'visible' }, children: nextButtonText ?? t.next }), isLoading && Loading] })] })] }));
|
|
28
28
|
};
|
|
29
29
|
const dictionary = {
|
|
30
30
|
en: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigation.js","sourceRoot":"","sources":["../../../src/components/Stepper/Navigation.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE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AE;4BACZ,MAAM,IAAI,MAAM,EAAE,CAAA;4BAClB,YAAY,EAAE,CAAA;wBAChB,CAAC,YAEA,CAAC,CAAC,IAAI,GACA,CACV,EACD,MAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,SAAS,IAAI,QAAQ,aACpG,KAAC,IAAI,IAAC,EAAE,EAAC,MAAM,EAAC,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,YAAG,cAAc,IAAI,CAAC,CAAC,IAAI,GAAQ,EACtG,SAAS,IAAI,OAAO,IACd,IACJ,IACC,CACX,CAAA;AAAA,CAAC,CAAA;AAEJ,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;KACb;IACD,EAAE,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,SAAS;KAChB;CACmB,CAAA"}
|
|
@@ -27,7 +27,7 @@ export interface StepperContextProps {
|
|
|
27
27
|
*/
|
|
28
28
|
goToPreviousStep: () => void;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
declare const StepperContext: import("react").Context<StepperContextProps>;
|
|
31
31
|
export interface StepperProps {
|
|
32
32
|
children: ReactElement<StepProps>[];
|
|
33
33
|
}
|
|
@@ -36,5 +36,6 @@ export interface StepperProps {
|
|
|
36
36
|
*
|
|
37
37
|
* The component wraps the Step component.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
declare const Stepper: FC<StepperProps>;
|
|
40
|
+
export { StepperContext, Stepper };
|
|
40
41
|
//# sourceMappingURL=Stepper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,YAAY,EAA2B,MAAM,OAAO,CAAA;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/C;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC;IACtD;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,
|
|
1
|
+
{"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,YAAY,EAA2B,MAAM,OAAO,CAAA;AAGjE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAElC,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/C;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC;IACtD;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,QAAA,MAAM,cAAc,8CAOlB,CAAA;AAEF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;CACrC;AAWD;;;;GAIG;AAEH,QAAA,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CA0C7B,CAAA;AACD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { Box, Flex } from '@citric/core';
|
|
|
3
3
|
import { createContext, useState } from 'react';
|
|
4
4
|
import { styled } from 'styled-components';
|
|
5
5
|
import { StepperHeaders } from './headers.js';
|
|
6
|
-
|
|
6
|
+
const StepperContext = createContext({
|
|
7
7
|
activeIndex: 0,
|
|
8
8
|
stepsData: {},
|
|
9
9
|
setStepData: () => { },
|
|
@@ -23,7 +23,7 @@ const ContentWrapper = styled(Flex) `
|
|
|
23
23
|
*
|
|
24
24
|
* The component wraps the Step component.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
const Stepper = ({ children }) => {
|
|
27
27
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
28
28
|
const [stepsData, setStepsData] = useState({});
|
|
29
29
|
const headers = children.map((child) => ({ title: child.props.title }));
|
|
@@ -51,4 +51,5 @@ export const Stepper = ({ children }) => {
|
|
|
51
51
|
};
|
|
52
52
|
return (_jsx(StepperContext.Provider, { value: contextValue, children: _jsxs(Wrapper, { children: [_jsx(StepperHeaders, { headers }), _jsx(ContentWrapper, { children: children[activeIndex] })] }) }));
|
|
53
53
|
};
|
|
54
|
+
export { StepperContext, Stepper };
|
|
54
55
|
//# sourceMappingURL=Stepper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.js","sourceRoot":"","sources":["../../../src/components/Stepper/Stepper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC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
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Stepper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Stepper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/portal-components",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"./ScrollView": "./dist/components/ScrollView.js",
|
|
18
18
|
"./svg": "./dist/svg/index.js",
|
|
19
19
|
"./anchor": "./dist/context/anchor.js",
|
|
20
|
+
"./loading": "./dist/context/loading.js",
|
|
20
21
|
"./error": "./dist/components/error/index.js",
|
|
21
22
|
"./AnimatedHeight": "./dist/components/AnimatedHeight.js",
|
|
22
23
|
"./SearchInput": "./dist/components/form/SearchInput.js",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Button, Flex, Text } from '@citric/core'
|
|
2
|
-
import { ButtonProps } from '@citric/core/dist/Button'
|
|
3
2
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
4
3
|
import { FC, useContext } from 'react'
|
|
5
4
|
import { styled } from 'styled-components'
|
|
5
|
+
import { ButtonProps } from '@citric/core/dist/Button'
|
|
6
6
|
import { useLoadingComponent } from '../../context/loading'
|
|
7
7
|
import { StepperContext } from './Stepper'
|
|
8
8
|
|
|
9
|
-
export interface StepperNavigationProps extends ButtonProps
|
|
9
|
+
export interface StepperNavigationProps extends ButtonProps{
|
|
10
10
|
/**
|
|
11
11
|
* Prop used to pass specific text to the next button.
|
|
12
12
|
*/
|
|
@@ -27,6 +27,10 @@ export interface StepperNavigationProps extends ButtonProps {
|
|
|
27
27
|
* Function that is rendered when pressing the back button.
|
|
28
28
|
*/
|
|
29
29
|
onGoBack?: () => void,
|
|
30
|
+
/**
|
|
31
|
+
* Function that is rendered when pressing the next button.
|
|
32
|
+
*/
|
|
33
|
+
onSubmit?: () => void,
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
const Wrapper = styled(Flex)`
|
|
@@ -40,8 +44,8 @@ const Wrapper = styled(Flex)`
|
|
|
40
44
|
* The component stepper wraps this component.
|
|
41
45
|
*/
|
|
42
46
|
|
|
43
|
-
export const StepperNavigation: FC<StepperNavigationProps
|
|
44
|
-
{ nextButtonText, onSkip, onGoBack, canSkip = false, isLoading, disabled }) => {
|
|
47
|
+
export const StepperNavigation: FC<Omit<StepperNavigationProps, 'children'>> = (
|
|
48
|
+
{ nextButtonText, onSkip, onGoBack, canSkip = false, isLoading, disabled, onSubmit }) => {
|
|
45
49
|
const t = useTranslate(dictionary)
|
|
46
50
|
const { goToNextStep, goToPreviousStep } = useContext(StepperContext)
|
|
47
51
|
const Loading = useLoadingComponent()
|
|
@@ -49,7 +53,7 @@ export const StepperNavigation: FC<StepperNavigationProps> = (
|
|
|
49
53
|
return (
|
|
50
54
|
<Wrapper>
|
|
51
55
|
<Button
|
|
52
|
-
appearance="
|
|
56
|
+
appearance="contained"
|
|
53
57
|
colorScheme="inverse"
|
|
54
58
|
onClick={() => {
|
|
55
59
|
onGoBack && onGoBack()
|
|
@@ -71,7 +75,7 @@ export const StepperNavigation: FC<StepperNavigationProps> = (
|
|
|
71
75
|
{t.skip}
|
|
72
76
|
</Button>
|
|
73
77
|
)}
|
|
74
|
-
<Button onClick={
|
|
78
|
+
<Button type="submit" onClick={onSubmit} sx={{ position: 'relative' }} disabled={isLoading || disabled}>
|
|
75
79
|
<Text as="span" sx={{ visibility: isLoading ? 'hidden' : 'visible' }}>{nextButtonText ?? t.next}</Text>
|
|
76
80
|
{isLoading && Loading}
|
|
77
81
|
</Button>
|
|
@@ -32,7 +32,7 @@ export interface StepperContextProps {
|
|
|
32
32
|
goToPreviousStep: () => void,
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
const StepperContext = createContext<StepperContextProps>({
|
|
36
36
|
activeIndex: 0,
|
|
37
37
|
stepsData: {},
|
|
38
38
|
setStepData: () => {},
|
|
@@ -60,7 +60,7 @@ const ContentWrapper = styled(Flex)`
|
|
|
60
60
|
* The component wraps the Step component.
|
|
61
61
|
*/
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const Stepper: FC<StepperProps> = ({ children }) => {
|
|
64
64
|
const [activeIndex, setActiveIndex] = useState<number>(0)
|
|
65
65
|
const [stepsData, setStepsData] = useState<Record<string, any>>({})
|
|
66
66
|
const headers = children.map((child) => ({ title: child.props.title }))
|
|
@@ -103,3 +103,5 @@ export const Stepper: FC<StepperProps> = ({ children }) => {
|
|
|
103
103
|
</StepperContext.Provider>
|
|
104
104
|
)
|
|
105
105
|
}
|
|
106
|
+
export { StepperContext, Stepper }
|
|
107
|
+
|