@terraware/web-components 5.1.4 → 5.1.5

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.
@@ -1,7 +1,12 @@
1
- import { type JSX } from 'react';
1
+ import { type JSX, type ReactNode } from 'react';
2
2
  import { SxProps, Theme } from '@mui/material';
3
3
  export type StepperStep = {
4
- label: string;
4
+ /**
5
+ * Shown below the step label in horizontal steppers, and below both the step icon and label in vertical ones. Strings
6
+ * get the default caption styling; elements are rendered as-is.
7
+ */
8
+ description?: ReactNode;
9
+ label: ReactNode;
5
10
  /**
6
11
  * Marks the step as optional. Whether an optional step shows as completed comes from `completed` here rather than
7
12
  * from `completedSteps` or the active step, since the user may have skipped it.
@@ -12,6 +17,8 @@ export type StepperStep = {
12
17
  };
13
18
  export type StepperProps = {
14
19
  activeStep: number;
20
+ /** Shows every step's description instead of only the active step's. */
21
+ alwaysShowDescriptions?: boolean;
15
22
  className?: string;
16
23
  /**
17
24
  * Indexes of the steps that are completed. When provided, only these steps show as completed, so a step stays
@@ -19,6 +26,10 @@ export type StepperProps = {
19
26
  * in this list. When omitted, every step before the active one shows as completed.
20
27
  */
21
28
  completedSteps?: number[];
29
+ /** Whether the "Optional" text for optional steps goes below the step label or beside it. Defaults to below. */
30
+ optionalPlacement?: 'below' | 'inline';
31
+ /** Defaults to horizontal. */
32
+ orientation?: 'horizontal' | 'vertical';
22
33
  /**
23
34
  * Styles applied to each step label, after the defaults. MUI styles active and completed labels with a more specific
24
35
  * selector, so label text overrides should target `.MuiStepLabel-label.Mui-active` and
@@ -28,6 +39,6 @@ export type StepperProps = {
28
39
  steps: (string | StepperStep)[];
29
40
  sx?: SxProps<Theme>;
30
41
  };
31
- declare const Stepper: ({ activeStep, className, completedSteps, stepLabelSx, steps, sx }: StepperProps) => JSX.Element;
42
+ declare const Stepper: ({ activeStep, alwaysShowDescriptions, className, completedSteps, optionalPlacement, orientation, stepLabelSx, steps, sx, }: StepperProps) => JSX.Element;
32
43
  export default Stepper;
33
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAA0C,OAAO,EAAE,KAAK,EAAwB,MAAM,eAAe,CAAC;AAI7G,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB,CAAC;AAIF,QAAA,MAAM,OAAO,GAAI,mEAAmE,YAAY,KAAG,GAAG,CAAC,OAwDtG,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stepper/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAML,OAAO,EACP,KAAK,EAGN,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,gHAAgH;IAChH,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACvC,8BAA8B;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACxC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB,CAAC;AAIF,QAAA,MAAM,OAAO,GAAI,4HAUd,YAAY,KAAG,GAAG,CAAC,OAwFrB,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,9 +1,9 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import "react";
3
- import { Step, StepLabel, Stepper, Typography, useTheme } from "@mui/material";
3
+ import { Box, Step, StepContent, StepLabel, Stepper, Typography, useTheme } from "@mui/material";
4
4
  import { useStrings } from "../../strings/index.js";
5
5
  const LABEL_SELECTOR = '.MuiStepLabel-label, .MuiStepLabel-label.Mui-active, .MuiStepLabel-label.Mui-completed';
6
- const Stepper_Stepper = ({ activeStep, className, completedSteps, stepLabelSx, steps, sx })=>{
6
+ const Stepper_Stepper = ({ activeStep, alwaysShowDescriptions = false, className, completedSteps, optionalPlacement = 'below', orientation = 'horizontal', stepLabelSx, steps, sx })=>{
7
7
  const theme = useTheme();
8
8
  const strings = useStrings();
9
9
  const isCompleted = (step, index)=>{
@@ -32,12 +32,44 @@ const Stepper_Stepper = ({ activeStep, className, completedSteps, stepLabelSx, s
32
32
  stepLabelSx
33
33
  ]
34
34
  ];
35
+ const renderCaption = (content)=>/*#__PURE__*/ jsx(Typography, {
36
+ variant: "caption",
37
+ color: theme.palette.TwClrTxtSecondary,
38
+ children: content
39
+ });
40
+ const renderDescription = (description)=>'string' == typeof description ? renderCaption(description) : description;
41
+ const renderBelowLabel = (step, index)=>{
42
+ const showOptional = step.optional && 'below' === optionalPlacement;
43
+ const showDescription = step.description && 'horizontal' === orientation && (alwaysShowDescriptions || index === activeStep);
44
+ if (!showOptional && !showDescription) return;
45
+ return /*#__PURE__*/ jsxs(Box, {
46
+ display: "flex",
47
+ flexDirection: "column",
48
+ children: [
49
+ showOptional && renderCaption(strings.OPTIONAL),
50
+ showDescription && renderDescription(step.description)
51
+ ]
52
+ });
53
+ };
54
+ const renderLabel = (step)=>step.optional && 'inline' === optionalPlacement ? /*#__PURE__*/ jsxs(Box, {
55
+ component: "span",
56
+ display: "inline-flex",
57
+ alignItems: "baseline",
58
+ gap: 1,
59
+ children: [
60
+ /*#__PURE__*/ jsx("span", {
61
+ children: step.label
62
+ }),
63
+ renderCaption(strings.OPTIONAL)
64
+ ]
65
+ }) : step.label;
35
66
  return /*#__PURE__*/ jsx(Stepper, {
36
67
  activeStep: activeStep,
37
68
  className: className,
69
+ orientation: orientation,
38
70
  sx: [
39
71
  {
40
- margin: theme.spacing(1, 0, 3)
72
+ margin: theme.spacing(1, 0, 1)
41
73
  },
42
74
  ...Array.isArray(sx) ? sx : [
43
75
  sx
@@ -47,17 +79,24 @@ const Stepper_Stepper = ({ activeStep, className, completedSteps, stepLabelSx, s
47
79
  const step = 'string' == typeof stepOrLabel ? {
48
80
  label: stepOrLabel
49
81
  } : stepOrLabel;
50
- return /*#__PURE__*/ jsx(Step, {
82
+ return /*#__PURE__*/ jsxs(Step, {
51
83
  completed: isCompleted(step, index),
52
- children: /*#__PURE__*/ jsx(StepLabel, {
53
- optional: step.optional && /*#__PURE__*/ jsx(Typography, {
54
- variant: "caption",
55
- color: theme.palette.TwClrTxtSecondary,
56
- children: strings.OPTIONAL
84
+ expanded: alwaysShowDescriptions,
85
+ children: [
86
+ /*#__PURE__*/ jsx(StepLabel, {
87
+ optional: renderBelowLabel(step, index),
88
+ sx: getStepLabelStyles(index),
89
+ children: renderLabel(step)
57
90
  }),
58
- sx: getStepLabelStyles(index),
59
- children: step.label
60
- })
91
+ 'vertical' === orientation && step.description && /*#__PURE__*/ jsx(StepContent, {
92
+ sx: {
93
+ margin: 0,
94
+ padding: 0,
95
+ border: 'none'
96
+ },
97
+ children: renderDescription(step.description)
98
+ })
99
+ ]
61
100
  }, index);
62
101
  })
63
102
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terraware/web-components",
3
- "version": "5.1.4",
3
+ "version": "5.1.5",
4
4
  "author": "Terraformation Inc.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {