@ultraviolet/plus 0.8.6 → 0.10.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 CHANGED
@@ -287,7 +287,7 @@ declare const EstimateCost: {
287
287
  theme?: _emotion_react.Theme | undefined;
288
288
  as?: react.ElementType<any, keyof react.JSX.IntrinsicElements> | undefined;
289
289
  }, react.DetailedHTMLProps<react.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
290
- Region: ({ label, image, shouldBeHidden, priceText, animated, isFirstElement, isLastElement, productsCallback, iteration, discount, noBorder, noPrice, }: {
290
+ Region: ({ label, image, shouldBeHidden, priceText, animated, isFirstElement, isLastElement, productsCallback, iteration, discount, noBorder, noPrice, hideFromOverlay, }: {
291
291
  shouldBeHidden?: boolean | undefined;
292
292
  priceText?: ReactNode;
293
293
  animated?: boolean | undefined;
@@ -303,7 +303,44 @@ declare const EstimateCost: {
303
303
  image: string;
304
304
  noBorder?: boolean | undefined;
305
305
  noPrice?: boolean | undefined;
306
- }) => _emotion_react_jsx_runtime.JSX.Element;
306
+ } & Pick<{
307
+ amount?: number | undefined;
308
+ amountFree?: number | undefined;
309
+ animated?: boolean | undefined;
310
+ children?: ReactNode;
311
+ discount?: number | undefined;
312
+ discountText?: string | undefined;
313
+ hideFromOverlay?: boolean | undefined;
314
+ isDefined?: boolean | undefined;
315
+ isFirstElement?: boolean | undefined;
316
+ isLastElement?: boolean | undefined;
317
+ isPrimaryBackground?: boolean | undefined;
318
+ iteration?: Iteration | undefined;
319
+ label?: ReactNode;
320
+ labelTextVariant?: "body" | "caption" | "code" | "heading" | "bodySmall" | "bodySmallStrong" | "bodySmallStronger" | "bodyStrong" | "bodyStronger" | "captionSmall" | "captionSmallStrong" | "captionSmallStronger" | "captionStrong" | "captionStronger" | "codeStrong" | "codeStronger" | "headingLarge" | "headingLargeStrong" | "headingLargeStronger" | "headingSmall" | "headingSmallStrong" | "headingSmallStronger" | "headingStrong" | "headingStronger" | undefined;
321
+ labelTextProminence?: "strong" | "weak" | "default" | "stronger" | undefined;
322
+ longFractionDigits?: boolean | undefined;
323
+ maxAmount?: number | undefined;
324
+ monthlyPrice?: number | undefined;
325
+ noBorder?: boolean | undefined;
326
+ noIteration?: boolean | undefined;
327
+ noIterationText?: string | undefined;
328
+ noPrice?: boolean | undefined;
329
+ notice?: string | undefined;
330
+ onAmountChange?: ((amount: number) => void) | undefined;
331
+ price?: number | undefined;
332
+ priceText?: ReactNode;
333
+ productsCallback?: {
334
+ add: (product: EstimateProduct) => void;
335
+ remove: (product: BareEstimateProduct) => void;
336
+ } | undefined;
337
+ shouldBeHidden?: boolean | undefined;
338
+ subLabel?: string | undefined;
339
+ tabulation?: number | undefined;
340
+ textNotDefined?: string | undefined;
341
+ tooltipInfo?: string | undefined;
342
+ unit?: (string & {}) | "seconds" | "minutes" | "hours" | "days" | "months" | "mb" | "gb" | "tb" | "years" | undefined;
343
+ }, "hideFromOverlay">) => _emotion_react_jsx_runtime.JSX.Element;
307
344
  Zone: ({ label, image, shouldBeHidden, priceText, animated, isFirstElement, isLastElement, productsCallback, iteration, discount, noBorder, noPrice, }: {
308
345
  shouldBeHidden?: boolean | undefined;
309
346
  priceText?: string | undefined;
@@ -390,4 +427,52 @@ type FAQProps = {
390
427
  };
391
428
  declare const FAQ: ({ productIconName, illustrationText, title, description, notes, }: FAQProps) => _emotion_react_jsx_runtime.JSX.Element;
392
429
 
393
- export { CodeEditor, ContentCard, ContentCardGroup, Conversation, CustomerSatisfaction, EstimateCost, FAQ, _default as estimateCostDefaultLocales };
430
+ type SteppedListContainerProps = {
431
+ /**
432
+ * Title of the section, introduces the feature.
433
+ */
434
+ header: ReactNode;
435
+ /**
436
+ * Text of the tooltip on the hide button
437
+ */
438
+ hideTooltipText?: string;
439
+ /**
440
+ * Text of the "hide" button
441
+ */
442
+ hideText?: string;
443
+ /**
444
+ * Text of the "show" button
445
+ */
446
+ showText?: string;
447
+ /**
448
+ * Text of tooltip on the "show" button
449
+ */
450
+ showTooltipText?: string;
451
+ /**
452
+ * List of steps
453
+ */
454
+ steps: string[];
455
+ /**
456
+ * Define here the content of each step
457
+ */
458
+ children: ReactNode;
459
+ /**
460
+ * Function called when the component is closed. This function will overload the default behavior.
461
+ */
462
+ onClickHide?: () => void;
463
+ };
464
+ /**
465
+ * SteppedListContainer is a component created for guiding users through steps in a structured and linear manner.
466
+ * It can pass prop "nextStep" to its children.
467
+ */
468
+ declare const SteppedListContainer: {
469
+ ({ header, hideTooltipText, hideText, showText, showTooltipText, children, steps, onClickHide, }: SteppedListContainerProps): _emotion_react_jsx_runtime.JSX.Element;
470
+ Step: ({ subHeader, children, image, stepNumber, }: {
471
+ subHeader?: ReactNode;
472
+ children: ReactNode | ((nextStep: (completed: boolean) => void) => ReactNode);
473
+ image?: ReactNode;
474
+ stepNumber: number;
475
+ }) => _emotion_react_jsx_runtime.JSX.Element;
476
+ };
477
+
478
+ export { CodeEditor, ContentCard, ContentCardGroup, Conversation, CustomerSatisfaction, EstimateCost, FAQ, SteppedListContainer, _default as estimateCostDefaultLocales };
@@ -21,7 +21,8 @@ const Region = ({
21
21
  iteration,
22
22
  discount,
23
23
  noBorder,
24
- noPrice
24
+ noPrice,
25
+ hideFromOverlay
25
26
  }) => {
26
27
  const {
27
28
  locales
@@ -38,6 +39,7 @@ const Region = ({
38
39
  discount: discount,
39
40
  noBorder: noBorder,
40
41
  noPrice: noPrice,
42
+ hideFromOverlay: hideFromOverlay,
41
43
  children: jsxs(Strong, {
42
44
  children: [jsx(StyledImage, {
43
45
  alt: label,
@@ -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.8.6",
3
+ "version": "0.10.0",
4
4
  "description": "Ultraviolet Plus",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -47,7 +47,8 @@
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.3"
50
+ "@ultraviolet/icons": "2.9.3",
51
+ "@ultraviolet/illustrations": "1.6.3"
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.40.1"
60
+ "@ultraviolet/ui": "1.41.0"
60
61
  },
61
62
  "scripts": {
62
63
  "build": "rollup -c ../../rollup.config.mjs",