@ultraviolet/plus 0.8.5 → 0.9.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/index.d.ts +49 -1
- package/dist/src/components/SteppedListCard/Step.js +53 -0
- package/dist/src/components/SteppedListCard/SteppedListContainer.js +96 -0
- package/dist/src/components/SteppedListCard/SteppedListContent.js +61 -0
- package/dist/src/components/SteppedListCard/helper.js +31 -0
- package/dist/src/index.js +1 -0
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -390,4 +390,52 @@ type FAQProps = {
|
|
|
390
390
|
};
|
|
391
391
|
declare const FAQ: ({ productIconName, illustrationText, title, description, notes, }: FAQProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
392
392
|
|
|
393
|
-
|
|
393
|
+
type SteppedListContainerProps = {
|
|
394
|
+
/**
|
|
395
|
+
* Title of the section, introduces the feature.
|
|
396
|
+
*/
|
|
397
|
+
header: ReactNode;
|
|
398
|
+
/**
|
|
399
|
+
* Text of the tooltip on the hide button
|
|
400
|
+
*/
|
|
401
|
+
hideTooltipText?: string;
|
|
402
|
+
/**
|
|
403
|
+
* Text of the "hide" button
|
|
404
|
+
*/
|
|
405
|
+
hideText?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Text of the "show" button
|
|
408
|
+
*/
|
|
409
|
+
showText?: string;
|
|
410
|
+
/**
|
|
411
|
+
* Text of tooltip on the "show" button
|
|
412
|
+
*/
|
|
413
|
+
showTooltipText?: string;
|
|
414
|
+
/**
|
|
415
|
+
* List of steps
|
|
416
|
+
*/
|
|
417
|
+
steps: string[];
|
|
418
|
+
/**
|
|
419
|
+
* Define here the content of each step
|
|
420
|
+
*/
|
|
421
|
+
children: ReactNode;
|
|
422
|
+
/**
|
|
423
|
+
* Function called when the component is closed. This function will overload the default behavior.
|
|
424
|
+
*/
|
|
425
|
+
onClickHide?: () => void;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* SteppedListContainer is a component created for guiding users through steps in a structured and linear manner.
|
|
429
|
+
* It can pass prop "nextStep" to its children.
|
|
430
|
+
*/
|
|
431
|
+
declare const SteppedListContainer: {
|
|
432
|
+
({ header, hideTooltipText, hideText, showText, showTooltipText, children, steps, onClickHide, }: SteppedListContainerProps): _emotion_react_jsx_runtime.JSX.Element;
|
|
433
|
+
Step: ({ subHeader, children, image, stepNumber, }: {
|
|
434
|
+
subHeader?: ReactNode;
|
|
435
|
+
children: ReactNode | ((nextStep: (completed: boolean) => void) => ReactNode);
|
|
436
|
+
image?: ReactNode;
|
|
437
|
+
stepNumber: number;
|
|
438
|
+
}) => _emotion_react_jsx_runtime.JSX.Element;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export { CodeEditor, ContentCard, ContentCardGroup, Conversation, CustomerSatisfaction, EstimateCost, FAQ, SteppedListContainer, _default as estimateCostDefaultLocales };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { Text, StepList } from '@ultraviolet/ui';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { Data } from './helper.js';
|
|
5
|
+
import { jsx, Fragment } from '@emotion/react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
8
|
+
const CustomText = /*#__PURE__*/_styled(Text, {
|
|
9
|
+
target: "ehxefxd0"
|
|
10
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
11
|
+
name: "1buwj38",
|
|
12
|
+
styles: "cursor:pointer;transition:text-decoration-color 250ms ease-out;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px;text-decoration-color:transparent;&:hover{text-decoration:underline;text-decoration-thickness:1px;}&:active{text-decoration-thickness:2px;}"
|
|
13
|
+
} : {
|
|
14
|
+
name: "1buwj38",
|
|
15
|
+
styles: "cursor:pointer;transition:text-decoration-color 250ms ease-out;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px;text-decoration-color:transparent;&:hover{text-decoration:underline;text-decoration-thickness:1px;}&:active{text-decoration-thickness:2px;}",
|
|
16
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
17
|
+
});
|
|
18
|
+
const SteppedList = ({
|
|
19
|
+
stepNumber,
|
|
20
|
+
stepTitle,
|
|
21
|
+
completed,
|
|
22
|
+
'data-testid': dataTestId
|
|
23
|
+
}) => {
|
|
24
|
+
const containerData = useContext(Data);
|
|
25
|
+
const active = containerData.currentStep === stepNumber;
|
|
26
|
+
return jsx(Fragment, {
|
|
27
|
+
children: completed ? jsx(StepList.Item, {
|
|
28
|
+
bulletIcon: "check",
|
|
29
|
+
prominence: active ? 'strong' : 'default',
|
|
30
|
+
sentiment: "primary",
|
|
31
|
+
onClick: () => containerData.setCurrentStep(stepNumber),
|
|
32
|
+
"data-testid": dataTestId,
|
|
33
|
+
children: jsx(CustomText, {
|
|
34
|
+
as: "h3",
|
|
35
|
+
variant: active ? 'bodyStrong' : 'body',
|
|
36
|
+
children: stepTitle
|
|
37
|
+
})
|
|
38
|
+
}) : jsx(StepList.Item, {
|
|
39
|
+
bulletText: String(stepNumber),
|
|
40
|
+
prominence: active ? 'strong' : undefined,
|
|
41
|
+
sentiment: active ? 'primary' : undefined,
|
|
42
|
+
onClick: () => containerData.setCurrentStep(stepNumber),
|
|
43
|
+
"data-testid": dataTestId,
|
|
44
|
+
children: jsx(CustomText, {
|
|
45
|
+
as: "h3",
|
|
46
|
+
variant: active ? 'bodyStrong' : 'body',
|
|
47
|
+
children: stepTitle
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { SteppedList };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { Card, Stack, Row, Text, Button, StepList } from '@ultraviolet/ui';
|
|
3
|
+
import { Children, useState, useMemo } from 'react';
|
|
4
|
+
import { SteppedList } from './Step.js';
|
|
5
|
+
import { SteppedListContent } from './SteppedListContent.js';
|
|
6
|
+
import { Data } from './helper.js';
|
|
7
|
+
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
10
|
+
const StyledCard = /*#__PURE__*/_styled(Card, {
|
|
11
|
+
target: "ebhkk9t1"
|
|
12
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
13
|
+
name: "1hcx8jb",
|
|
14
|
+
styles: "padding:0"
|
|
15
|
+
} : {
|
|
16
|
+
name: "1hcx8jb",
|
|
17
|
+
styles: "padding:0",
|
|
18
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
19
|
+
});
|
|
20
|
+
const ContentStack = /*#__PURE__*/_styled(Stack, {
|
|
21
|
+
target: "ebhkk9t0"
|
|
22
|
+
})("padding:", ({
|
|
23
|
+
theme
|
|
24
|
+
}) => theme.space['3'], ";border-right:solid ", ({
|
|
25
|
+
theme
|
|
26
|
+
}) => theme.colors.neutral.border, " 1px;");
|
|
27
|
+
/**
|
|
28
|
+
* SteppedListContainer is a component created for guiding users through steps in a structured and linear manner.
|
|
29
|
+
* It can pass prop "nextStep" to its children.
|
|
30
|
+
*/
|
|
31
|
+
const SteppedListContainer = ({
|
|
32
|
+
header,
|
|
33
|
+
hideTooltipText,
|
|
34
|
+
hideText = 'Hide',
|
|
35
|
+
showText = 'Show',
|
|
36
|
+
showTooltipText,
|
|
37
|
+
children,
|
|
38
|
+
steps,
|
|
39
|
+
onClickHide
|
|
40
|
+
}) => {
|
|
41
|
+
const numberOfSteps = Children.count(children);
|
|
42
|
+
const [currentStep, setCurrentStep] = useState(1);
|
|
43
|
+
const [hidden, setHidden] = useState(false);
|
|
44
|
+
const [done, setDone] = useState(Array(steps.length).fill(false));
|
|
45
|
+
const values = useMemo(() => ({
|
|
46
|
+
currentStep,
|
|
47
|
+
setCurrentStep,
|
|
48
|
+
numberOfSteps,
|
|
49
|
+
done,
|
|
50
|
+
setDone,
|
|
51
|
+
setHidden,
|
|
52
|
+
onClickHide
|
|
53
|
+
}), [currentStep, setCurrentStep, numberOfSteps, done, setDone, setHidden, onClickHide]);
|
|
54
|
+
const onClickHideButton = () => {
|
|
55
|
+
if (onClickHide) onClickHide();else setHidden(!hidden);
|
|
56
|
+
};
|
|
57
|
+
return jsx(Data.Provider, {
|
|
58
|
+
value: values,
|
|
59
|
+
children: jsxs(Stack, {
|
|
60
|
+
gap: 3,
|
|
61
|
+
children: [jsxs(Row, {
|
|
62
|
+
templateColumns: "9fr 1fr",
|
|
63
|
+
children: [typeof header === 'string' ? jsx(Text, {
|
|
64
|
+
as: "h3",
|
|
65
|
+
variant: "heading",
|
|
66
|
+
children: header
|
|
67
|
+
}) : header, jsx(Button, {
|
|
68
|
+
onClick: onClickHideButton,
|
|
69
|
+
variant: "ghost",
|
|
70
|
+
sentiment: "neutral",
|
|
71
|
+
size: "small",
|
|
72
|
+
tooltip: hidden ? showTooltipText : hideTooltipText,
|
|
73
|
+
children: hidden ? showText : hideText
|
|
74
|
+
})]
|
|
75
|
+
}), hidden ? null : jsx(StyledCard, {
|
|
76
|
+
children: jsxs(Row, {
|
|
77
|
+
templateColumns: "1fr 3fr",
|
|
78
|
+
children: [jsx(ContentStack, {
|
|
79
|
+
direction: "column",
|
|
80
|
+
gap: 4,
|
|
81
|
+
children: jsx(StepList, {
|
|
82
|
+
children: steps.map((step, index) => jsx(SteppedList, {
|
|
83
|
+
stepNumber: index + 1,
|
|
84
|
+
stepTitle: step,
|
|
85
|
+
completed: done[index]
|
|
86
|
+
}, step))
|
|
87
|
+
})
|
|
88
|
+
}), children]
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
SteppedListContainer.Step = SteppedListContent;
|
|
95
|
+
|
|
96
|
+
export { SteppedListContainer };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { Text, Stack } from '@ultraviolet/ui';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { Data, nextStep } from './helper.js';
|
|
5
|
+
import { jsx, Fragment, jsxs } from '@emotion/react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
8
|
+
const StyledContent = /*#__PURE__*/_styled(Stack, {
|
|
9
|
+
target: "erw7ck2"
|
|
10
|
+
})("padding:", ({
|
|
11
|
+
theme
|
|
12
|
+
}) => theme.space['3'], ";padding-top:", ({
|
|
13
|
+
theme
|
|
14
|
+
}) => theme.space['4'], ";");
|
|
15
|
+
const StyledImage = /*#__PURE__*/_styled("div", {
|
|
16
|
+
target: "erw7ck1"
|
|
17
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
18
|
+
name: "r4f2yk",
|
|
19
|
+
styles: "display:flex;justify-content:right"
|
|
20
|
+
} : {
|
|
21
|
+
name: "r4f2yk",
|
|
22
|
+
styles: "display:flex;justify-content:right",
|
|
23
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
24
|
+
});
|
|
25
|
+
const StyledSubHeader = /*#__PURE__*/_styled("div", {
|
|
26
|
+
target: "erw7ck0"
|
|
27
|
+
})("margin-bottom:", ({
|
|
28
|
+
theme
|
|
29
|
+
}) => theme.space['3'], ";");
|
|
30
|
+
const SteppedListContent = ({
|
|
31
|
+
subHeader,
|
|
32
|
+
children,
|
|
33
|
+
image,
|
|
34
|
+
stepNumber
|
|
35
|
+
}) => {
|
|
36
|
+
const containerData = useContext(Data);
|
|
37
|
+
return jsx(Fragment, {
|
|
38
|
+
children: stepNumber === containerData.currentStep ? jsxs(StyledContent, {
|
|
39
|
+
children: [jsx(StyledSubHeader, {
|
|
40
|
+
children: typeof subHeader === 'string' ? jsx(Text, {
|
|
41
|
+
as: "h3",
|
|
42
|
+
variant: "headingSmallStrong",
|
|
43
|
+
children: subHeader
|
|
44
|
+
}) : subHeader
|
|
45
|
+
}), typeof children === 'function' ? children(completed => nextStep({
|
|
46
|
+
completed,
|
|
47
|
+
setCompleted: containerData.setDone,
|
|
48
|
+
done: containerData.done,
|
|
49
|
+
stepNumber,
|
|
50
|
+
setCurrentStep: containerData.setCurrentStep,
|
|
51
|
+
numberOfSteps: containerData.numberOfSteps,
|
|
52
|
+
setHidden: containerData.setHidden,
|
|
53
|
+
onClickHide: containerData.onClickHide
|
|
54
|
+
})) : children, jsx(StyledImage, {
|
|
55
|
+
children: image
|
|
56
|
+
})]
|
|
57
|
+
}) : null
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { SteppedListContent };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const Data = /*#__PURE__*/createContext({
|
|
4
|
+
currentStep: 1,
|
|
5
|
+
setCurrentStep: () => {},
|
|
6
|
+
numberOfSteps: 1,
|
|
7
|
+
done: [false, false, false, false, false],
|
|
8
|
+
setDone: () => {},
|
|
9
|
+
setHidden: () => {},
|
|
10
|
+
onClickHide: () => {}
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Go to next step with or without validation of the current step
|
|
14
|
+
* Close the component for the last step
|
|
15
|
+
*/
|
|
16
|
+
const nextStep = ({
|
|
17
|
+
completed,
|
|
18
|
+
setCompleted,
|
|
19
|
+
stepNumber,
|
|
20
|
+
setCurrentStep,
|
|
21
|
+
numberOfSteps,
|
|
22
|
+
setHidden,
|
|
23
|
+
done,
|
|
24
|
+
onClickHide
|
|
25
|
+
}) => {
|
|
26
|
+
const tempDone = done.map((item, index) => index === stepNumber - 1 ? completed : item);
|
|
27
|
+
setCompleted(tempDone);
|
|
28
|
+
if (numberOfSteps > stepNumber) setCurrentStep(stepNumber + 1);else if (onClickHide) onClickHide();else setHidden(true);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { Data, nextStep };
|
package/dist/src/index.js
CHANGED
|
@@ -6,3 +6,4 @@ export { default as estimateCostDefaultLocales } from './components/EstimateCost
|
|
|
6
6
|
export { CustomerSatisfaction } from './components/CustomerSatisfaction/index.js';
|
|
7
7
|
export { Conversation } from './components/Conversation/index.js';
|
|
8
8
|
export { FAQ } from './components/FAQ/index.js';
|
|
9
|
+
export { SteppedListContainer } from './components/SteppedListCard/SteppedListContainer.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/plus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Ultraviolet Plus",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -39,15 +39,16 @@
|
|
|
39
39
|
"react-dom": "18.2.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@babel/core": "7.
|
|
42
|
+
"@babel/core": "7.24.0",
|
|
43
43
|
"@emotion/babel-plugin": "11.11.0",
|
|
44
44
|
"@emotion/react": "11.11.4",
|
|
45
45
|
"@emotion/styled": "11.11.0",
|
|
46
|
-
"@types/react": "18.2.
|
|
46
|
+
"@types/react": "18.2.61",
|
|
47
47
|
"@types/react-dom": "18.2.19",
|
|
48
48
|
"react": "18.2.0",
|
|
49
49
|
"react-dom": "18.2.0",
|
|
50
|
-
"@ultraviolet/icons": "2.9.
|
|
50
|
+
"@ultraviolet/icons": "2.9.3",
|
|
51
|
+
"@ultraviolet/illustrations": "1.6.1"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
54
|
"@uiw/codemirror-extensions-langs": "4.21.24",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"react-flatten-children": "1.1.2",
|
|
57
58
|
"react-intersection-observer": "9.8.1",
|
|
58
59
|
"@ultraviolet/themes": "1.9.0",
|
|
59
|
-
"@ultraviolet/ui": "1.
|
|
60
|
+
"@ultraviolet/ui": "1.41.0"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"build": "rollup -c ../../rollup.config.mjs",
|