@canonical/react-components 1.4.0 → 1.5.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/components/Stepper/Step/Step.d.ts +47 -0
- package/dist/components/Stepper/Step/Step.js +65 -0
- package/dist/components/Stepper/Step/Step.scss +113 -0
- package/dist/components/Stepper/Step/index.d.ts +2 -0
- package/dist/components/Stepper/Step/index.js +13 -0
- package/dist/components/Stepper/Stepper.d.ts +17 -0
- package/dist/components/Stepper/Stepper.js +34 -0
- package/dist/components/Stepper/index.d.ts +2 -0
- package/dist/components/Stepper/index.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LinkProps } from "../../Link";
|
|
2
|
+
import { ClassName } from "../../../types";
|
|
3
|
+
import "./Step.scss";
|
|
4
|
+
export type Props = {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the step has a darkened progress line.
|
|
7
|
+
*/
|
|
8
|
+
hasProgressLine: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Index of the step.
|
|
11
|
+
*/
|
|
12
|
+
index: number;
|
|
13
|
+
/**
|
|
14
|
+
* Title of the step.
|
|
15
|
+
*/
|
|
16
|
+
title: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional label for the step.
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional props to configure the `Link` component.
|
|
23
|
+
*/
|
|
24
|
+
linkProps?: LinkProps;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the step is clickable. If set to false, the step is not clickable and the text is muted with a light-dark colour.
|
|
27
|
+
*/
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optional value to highlight the selected step.
|
|
31
|
+
*/
|
|
32
|
+
selected?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Icon to display in the step. Specify "number" if the index should be displayed.
|
|
35
|
+
*/
|
|
36
|
+
iconName: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional class(es) to pass to the Icon component.
|
|
39
|
+
*/
|
|
40
|
+
iconClassName?: ClassName;
|
|
41
|
+
/**
|
|
42
|
+
* Function that is called when the step is clicked.
|
|
43
|
+
*/
|
|
44
|
+
handleClick: () => void;
|
|
45
|
+
};
|
|
46
|
+
declare const Step: ({ hasProgressLine, index, title, label, linkProps, enabled, selected, iconName, iconClassName, handleClick, ...props }: Props) => JSX.Element;
|
|
47
|
+
export default Step;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _Icon = _interopRequireDefault(require("../../Icon"));
|
|
11
|
+
var _Link = _interopRequireDefault(require("../../Link"));
|
|
12
|
+
require("./Step.scss");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
const Step = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
hasProgressLine,
|
|
18
|
+
index,
|
|
19
|
+
title,
|
|
20
|
+
label,
|
|
21
|
+
linkProps,
|
|
22
|
+
enabled,
|
|
23
|
+
selected = false,
|
|
24
|
+
iconName,
|
|
25
|
+
iconClassName,
|
|
26
|
+
handleClick,
|
|
27
|
+
...props
|
|
28
|
+
} = _ref;
|
|
29
|
+
const stepStatusClass = enabled ? "step-enabled" : "step-disabled";
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
31
|
+
className: (0, _classnames.default)("step", {
|
|
32
|
+
"progress-line": hasProgressLine,
|
|
33
|
+
"step-selected": selected
|
|
34
|
+
})
|
|
35
|
+
}, props), iconName === "number" ? /*#__PURE__*/_react.default.createElement("span", {
|
|
36
|
+
className: (0, _classnames.default)("step-number", {
|
|
37
|
+
"step-number-disabled": !enabled
|
|
38
|
+
})
|
|
39
|
+
}, index) : /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
40
|
+
name: iconName,
|
|
41
|
+
className: (0, _classnames.default)("step-status-icon", iconClassName)
|
|
42
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
className: "step-content"
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
45
|
+
className: (0, _classnames.default)(stepStatusClass),
|
|
46
|
+
onClick: handleClick
|
|
47
|
+
}, title), label && /*#__PURE__*/_react.default.createElement("span", {
|
|
48
|
+
className: (0, _classnames.default)("step-optional-content", "u-no-margin--bottom", {
|
|
49
|
+
"step-disabled": !enabled
|
|
50
|
+
})
|
|
51
|
+
}, label), linkProps && /*#__PURE__*/_react.default.createElement(_Link.default, _extends({
|
|
52
|
+
className: "p-text--small u-no-margin--bottom step-optional-content"
|
|
53
|
+
}, linkProps), linkProps.children)));
|
|
54
|
+
};
|
|
55
|
+
Step.propTypes = {
|
|
56
|
+
hasProgressLine: _propTypes.default.bool.isRequired,
|
|
57
|
+
index: _propTypes.default.number.isRequired,
|
|
58
|
+
title: _propTypes.default.string.isRequired,
|
|
59
|
+
label: _propTypes.default.string,
|
|
60
|
+
enabled: _propTypes.default.bool.isRequired,
|
|
61
|
+
selected: _propTypes.default.bool,
|
|
62
|
+
iconName: _propTypes.default.string.isRequired,
|
|
63
|
+
handleClick: _propTypes.default.func.isRequired
|
|
64
|
+
};
|
|
65
|
+
var _default = exports.default = Step;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
@import "vanilla-framework";
|
|
2
|
+
|
|
3
|
+
.step-number {
|
|
4
|
+
border: 0.08rem solid black;
|
|
5
|
+
border-radius: 1rem;
|
|
6
|
+
height: 1.4rem;
|
|
7
|
+
line-height: 1.3;
|
|
8
|
+
margin-left: $sph--small;
|
|
9
|
+
margin-right: 0.1rem;
|
|
10
|
+
margin-top: 0.1rem;
|
|
11
|
+
text-align: center;
|
|
12
|
+
width: 1.4rem;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.step-number-disabled {
|
|
16
|
+
border: 0.08rem solid #757575;
|
|
17
|
+
color: #757575;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.step-content {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex: 1;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
margin-left: $sph--small;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.step-enabled:hover {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
text-decoration: underline;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.step-disabled {
|
|
33
|
+
color: #757575;
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.step-status-icon {
|
|
38
|
+
height: 1.6rem;
|
|
39
|
+
margin-left: 0.4rem;
|
|
40
|
+
width: 1.6rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.step-selected {
|
|
44
|
+
background-color: var(--vf-color-background-alt);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.step-optional-content {
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
max-width: 10rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.stepper-horizontal {
|
|
53
|
+
display: flex;
|
|
54
|
+
|
|
55
|
+
.p-inline-list__item {
|
|
56
|
+
margin: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.step {
|
|
60
|
+
border-top: 0.2rem solid var(--vf-color-border-default);
|
|
61
|
+
display: flex;
|
|
62
|
+
height: 100%;
|
|
63
|
+
padding: 0.4rem $spv--medium;
|
|
64
|
+
width: fit-content;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.step-status-icon {
|
|
68
|
+
margin-left: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.step-number {
|
|
72
|
+
margin-left: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.step-content {
|
|
76
|
+
max-width: 10rem;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.progress-line {
|
|
80
|
+
border-top: 0.2rem solid black;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:first-child .step {
|
|
84
|
+
padding-left: 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.stepper-vertical {
|
|
89
|
+
.p-list__item {
|
|
90
|
+
padding-bottom: 0;
|
|
91
|
+
padding-top: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.step {
|
|
95
|
+
border-left: 0.2rem solid var(--vf-color-border-default);
|
|
96
|
+
display: flex;
|
|
97
|
+
padding: $spv--medium 0;
|
|
98
|
+
padding-right: 0.5rem;
|
|
99
|
+
width: fit-content;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.progress-line {
|
|
103
|
+
border-left: 0.2rem solid black;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
:first-child .step {
|
|
107
|
+
padding-top: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:last-child .step {
|
|
111
|
+
padding-bottom: 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Step.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Step = _interopRequireDefault(require("./Step"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StepProps } from "./Step";
|
|
3
|
+
export type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Optional value that defines the orientation of the stepper. Can either be "horizontal" or "vertical". If not specified, it defaults to "vertical".
|
|
6
|
+
*/
|
|
7
|
+
variant?: "horizontal" | "vertical";
|
|
8
|
+
/**
|
|
9
|
+
* A list of steps.
|
|
10
|
+
*/
|
|
11
|
+
steps: React.ReactElement<StepProps>[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* This is a stepper component that is used to guide users through a series of sequential steps, providing a clear start and end point. It helps users understand their current position in the process and anticipate upcoming actions. The stepper component should accept a list of Step components for the steps.
|
|
15
|
+
*/
|
|
16
|
+
declare const Stepper: ({ variant, steps }: Props) => JSX.Element;
|
|
17
|
+
export default Stepper;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _List = _interopRequireDefault(require("../List"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/**
|
|
13
|
+
* This is a stepper component that is used to guide users through a series of sequential steps, providing a clear start and end point. It helps users understand their current position in the process and anticipate upcoming actions. The stepper component should accept a list of Step components for the steps.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const Stepper = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
variant = "vertical",
|
|
19
|
+
steps
|
|
20
|
+
} = _ref;
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_List.default, {
|
|
22
|
+
items: steps,
|
|
23
|
+
inline: variant === "horizontal",
|
|
24
|
+
className: (0, _classnames.default)({
|
|
25
|
+
"stepper-horizontal": variant === "horizontal",
|
|
26
|
+
"stepper-vertical": variant === "vertical"
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Stepper.propTypes = {
|
|
31
|
+
variant: _propTypes.default.oneOf(["horizontal", "vertical"]),
|
|
32
|
+
steps: _propTypes.default.arrayOf(_propTypes.default.element).isRequired
|
|
33
|
+
};
|
|
34
|
+
var _default = exports.default = Stepper;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Step", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Step.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "default", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Stepper.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _Stepper = _interopRequireDefault(require("./Stepper"));
|
|
19
|
+
var _Step = _interopRequireDefault(require("./Step"));
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { default as Slider } from "./components/Slider";
|
|
|
54
54
|
export { default as Switch } from "./components/Switch";
|
|
55
55
|
export { default as Spinner } from "./components/Spinner";
|
|
56
56
|
export { default as StatusLabel, StatusLabelAppearance, } from "./components/StatusLabel";
|
|
57
|
+
export { default as Stepper, Step } from "./components/Stepper";
|
|
57
58
|
export { default as Strip } from "./components/Strip";
|
|
58
59
|
export { default as SummaryButton } from "./components/SummaryButton";
|
|
59
60
|
export { default as Table } from "./components/Table";
|
|
@@ -117,6 +118,7 @@ export type { SkipLinkProps } from "./components/SkipLink";
|
|
|
117
118
|
export type { SliderProps } from "./components/Slider";
|
|
118
119
|
export type { SpinnerProps } from "./components/Spinner";
|
|
119
120
|
export type { StatusLabelProps } from "./components/StatusLabel";
|
|
121
|
+
export type { StepperProps, StepProps } from "./components/Stepper";
|
|
120
122
|
export type { StripProps } from "./components/Strip";
|
|
121
123
|
export type { SummaryButtonProps } from "./components/SummaryButton";
|
|
122
124
|
export type { TableProps } from "./components/Table";
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,8 @@ var _exportNames = {
|
|
|
70
70
|
Spinner: true,
|
|
71
71
|
StatusLabel: true,
|
|
72
72
|
StatusLabelAppearance: true,
|
|
73
|
+
Stepper: true,
|
|
74
|
+
Step: true,
|
|
73
75
|
Strip: true,
|
|
74
76
|
SummaryButton: true,
|
|
75
77
|
Table: true,
|
|
@@ -454,6 +456,18 @@ Object.defineProperty(exports, "StatusLabelAppearance", {
|
|
|
454
456
|
return _StatusLabel.StatusLabelAppearance;
|
|
455
457
|
}
|
|
456
458
|
});
|
|
459
|
+
Object.defineProperty(exports, "Step", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get: function () {
|
|
462
|
+
return _Stepper.Step;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
Object.defineProperty(exports, "Stepper", {
|
|
466
|
+
enumerable: true,
|
|
467
|
+
get: function () {
|
|
468
|
+
return _Stepper.default;
|
|
469
|
+
}
|
|
470
|
+
});
|
|
457
471
|
Object.defineProperty(exports, "Strip", {
|
|
458
472
|
enumerable: true,
|
|
459
473
|
get: function () {
|
|
@@ -695,6 +709,7 @@ var _Slider = _interopRequireDefault(require("./components/Slider"));
|
|
|
695
709
|
var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
696
710
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|
|
697
711
|
var _StatusLabel = _interopRequireWildcard(require("./components/StatusLabel"));
|
|
712
|
+
var _Stepper = _interopRequireWildcard(require("./components/Stepper"));
|
|
698
713
|
var _Strip = _interopRequireDefault(require("./components/Strip"));
|
|
699
714
|
var _SummaryButton = _interopRequireDefault(require("./components/SummaryButton"));
|
|
700
715
|
var _Table = _interopRequireDefault(require("./components/Table"));
|