@canonical/react-components 1.4.0 → 1.6.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/DoughnutChart/DoughnutChart.d.ts +58 -0
- package/dist/components/DoughnutChart/DoughnutChart.js +163 -0
- package/dist/components/DoughnutChart/DoughnutChart.scss +30 -0
- package/dist/components/DoughnutChart/index.d.ts +3 -0
- package/dist/components/DoughnutChart/index.js +13 -0
- 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 +4 -0
- package/dist/index.js +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import "./DoughnutChart.scss";
|
|
3
|
+
export type Segment = {
|
|
4
|
+
/**
|
|
5
|
+
* The colour of the segment.
|
|
6
|
+
*/
|
|
7
|
+
color: string;
|
|
8
|
+
/**
|
|
9
|
+
* The segment tooltip.
|
|
10
|
+
*/
|
|
11
|
+
tooltip?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The segment length.
|
|
14
|
+
*/
|
|
15
|
+
value: number;
|
|
16
|
+
};
|
|
17
|
+
export type Props = {
|
|
18
|
+
/**
|
|
19
|
+
* The label in the centre of the doughnut.
|
|
20
|
+
*/
|
|
21
|
+
label?: string;
|
|
22
|
+
/**
|
|
23
|
+
* An optional class name applied to the label.
|
|
24
|
+
*/
|
|
25
|
+
labelClassname?: string;
|
|
26
|
+
/**
|
|
27
|
+
* An optional class name applied to the wrapping element.
|
|
28
|
+
*/
|
|
29
|
+
className?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The width of the segments when hovered.
|
|
32
|
+
*/
|
|
33
|
+
segmentHoverWidth: number;
|
|
34
|
+
/**
|
|
35
|
+
* The width of the segments.
|
|
36
|
+
*/
|
|
37
|
+
segmentThickness: number;
|
|
38
|
+
/**
|
|
39
|
+
* The doughnut segments.
|
|
40
|
+
*/
|
|
41
|
+
segments: Segment[];
|
|
42
|
+
/**
|
|
43
|
+
* The size of the doughnut.
|
|
44
|
+
*/
|
|
45
|
+
size: number;
|
|
46
|
+
/**
|
|
47
|
+
* ID associated to the specific instance of a Chart.
|
|
48
|
+
*/
|
|
49
|
+
chartID: string;
|
|
50
|
+
};
|
|
51
|
+
export declare enum TestIds {
|
|
52
|
+
Label = "label",
|
|
53
|
+
Segment = "segment",
|
|
54
|
+
Chart = "chart",
|
|
55
|
+
Section = "Section"
|
|
56
|
+
}
|
|
57
|
+
declare const DoughnutChart: FC<Props>;
|
|
58
|
+
export default DoughnutChart;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.TestIds = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
|
|
11
|
+
require("./DoughnutChart.scss");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
let TestIds = exports.TestIds = /*#__PURE__*/function (TestIds) {
|
|
16
|
+
TestIds["Label"] = "label";
|
|
17
|
+
TestIds["Segment"] = "segment";
|
|
18
|
+
TestIds["Chart"] = "chart";
|
|
19
|
+
TestIds["Section"] = "Section";
|
|
20
|
+
return TestIds;
|
|
21
|
+
}({});
|
|
22
|
+
const DoughnutChart = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
className,
|
|
25
|
+
label,
|
|
26
|
+
labelClassname,
|
|
27
|
+
segmentHoverWidth,
|
|
28
|
+
segmentThickness,
|
|
29
|
+
segments,
|
|
30
|
+
size,
|
|
31
|
+
chartID
|
|
32
|
+
} = _ref;
|
|
33
|
+
const [tooltipMessage, setTooltipMessage] = (0, _react.useState)(null);
|
|
34
|
+
const id = (0, _react.useRef)("doughnut-chart-".concat(chartID));
|
|
35
|
+
const hoverIncrease = segmentHoverWidth - segmentThickness;
|
|
36
|
+
const adjustedHoverWidth = segmentHoverWidth + hoverIncrease;
|
|
37
|
+
// The canvas needs enough space so that the hover state does not get cut off.
|
|
38
|
+
const canvasSize = size + adjustedHoverWidth - segmentThickness;
|
|
39
|
+
const diameter = size - segmentThickness;
|
|
40
|
+
const radius = diameter / 2;
|
|
41
|
+
const circumference = Math.round(diameter * Math.PI);
|
|
42
|
+
// Calculate the total value of all segments.
|
|
43
|
+
const total = segments.reduce((totalValue, segment) => totalValue += segment.value, 0);
|
|
44
|
+
let accumulatedLength = 0;
|
|
45
|
+
const segmentNodes = segments.map((_ref2, i) => {
|
|
46
|
+
let {
|
|
47
|
+
color,
|
|
48
|
+
tooltip,
|
|
49
|
+
value
|
|
50
|
+
} = _ref2;
|
|
51
|
+
// The start position is the value of all previous segments.
|
|
52
|
+
const startPosition = accumulatedLength;
|
|
53
|
+
// The length of the segment (as a portion of the doughnut circumference)
|
|
54
|
+
const segmentLength = value / total * circumference;
|
|
55
|
+
// The space left until the end of the circle.
|
|
56
|
+
const remainingSpace = circumference - (segmentLength + startPosition);
|
|
57
|
+
// Add this segment length to the running tally.
|
|
58
|
+
accumulatedLength += segmentLength;
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement("circle", {
|
|
60
|
+
className: "doughnut-chart__segment",
|
|
61
|
+
cx: radius - segmentThickness / 2 - hoverIncrease,
|
|
62
|
+
cy: radius + segmentThickness / 2 + hoverIncrease,
|
|
63
|
+
"data-testid": TestIds.Segment,
|
|
64
|
+
key: i,
|
|
65
|
+
tabIndex: 0,
|
|
66
|
+
"aria-label": tooltip ? "".concat(tooltip, ": ").concat(value) : "".concat(value),
|
|
67
|
+
onMouseOut: tooltip ? () => {
|
|
68
|
+
// Hide the tooltip.
|
|
69
|
+
setTooltipMessage(null);
|
|
70
|
+
} : undefined,
|
|
71
|
+
onMouseOver: tooltip ? () => {
|
|
72
|
+
setTooltipMessage(tooltip);
|
|
73
|
+
} : undefined,
|
|
74
|
+
r: radius,
|
|
75
|
+
style: {
|
|
76
|
+
stroke: color,
|
|
77
|
+
strokeWidth: segmentThickness,
|
|
78
|
+
// The dash array used is:
|
|
79
|
+
// 1 - We want there to be a space before the first visible dash so
|
|
80
|
+
// by setting this to 0 we can use the next dash for the space.
|
|
81
|
+
// 2 - This gap is the distance of all previous segments
|
|
82
|
+
// so that the segment starts in the correct spot.
|
|
83
|
+
// 3 - A dash that is the length of the segment.
|
|
84
|
+
// 4 - A gap from the end of the segment to the start of the circle
|
|
85
|
+
// so that the dash array doesn't repeat and be visible.
|
|
86
|
+
strokeDasharray: "0 ".concat(startPosition.toFixed(2), " ").concat(segmentLength.toFixed(2), " ").concat(remainingSpace.toFixed(2))
|
|
87
|
+
}
|
|
88
|
+
// Rotate the segment so that the segments start at the top of
|
|
89
|
+
// the chart.
|
|
90
|
+
,
|
|
91
|
+
transform: "rotate(-90 ".concat(radius, ",").concat(radius, ")")
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
className: (0, _classnames.default)("doughnut-chart", className),
|
|
96
|
+
style: {
|
|
97
|
+
maxWidth: "".concat(canvasSize, "px")
|
|
98
|
+
},
|
|
99
|
+
"data-testid": TestIds.Chart
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
101
|
+
className: "doughnut-chart__tooltip",
|
|
102
|
+
followMouse: true,
|
|
103
|
+
message: tooltipMessage,
|
|
104
|
+
position: "right"
|
|
105
|
+
}, /*#__PURE__*/_react.default.createElement("style", null, "#".concat(id.current, " .doughnut-chart__segment:hover {\n stroke-width: ").concat(adjustedHoverWidth, " !important;\n }")), /*#__PURE__*/_react.default.createElement("svg", {
|
|
106
|
+
className: "doughnut-chart__chart",
|
|
107
|
+
id: id.current,
|
|
108
|
+
viewBox: "0 0 ".concat(canvasSize, " ").concat(canvasSize),
|
|
109
|
+
"data-testid": TestIds.Section,
|
|
110
|
+
"aria-labelledby": "".concat(id.current, "-chart-title ").concat(id.current, "-chart-desc")
|
|
111
|
+
}, label && /*#__PURE__*/_react.default.createElement("title", {
|
|
112
|
+
id: "".concat(id.current, "-chart-title")
|
|
113
|
+
}, label), /*#__PURE__*/_react.default.createElement("desc", {
|
|
114
|
+
id: "".concat(id.current, "-chart-desc")
|
|
115
|
+
}, segments.map(segment => {
|
|
116
|
+
let description = "";
|
|
117
|
+
if (segment.tooltip) description += "".concat(segment.tooltip, ": ");
|
|
118
|
+
description += segment.value;
|
|
119
|
+
return description;
|
|
120
|
+
}).join(",")), /*#__PURE__*/_react.default.createElement("mask", {
|
|
121
|
+
id: "canvasMask"
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement("rect", {
|
|
123
|
+
fill: "white",
|
|
124
|
+
height: canvasSize,
|
|
125
|
+
width: canvasSize,
|
|
126
|
+
x: "0",
|
|
127
|
+
y: "0"
|
|
128
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
129
|
+
cx: canvasSize / 2,
|
|
130
|
+
cy: canvasSize / 2,
|
|
131
|
+
fill: "black",
|
|
132
|
+
r: radius - segmentThickness / 2
|
|
133
|
+
})), /*#__PURE__*/_react.default.createElement("g", {
|
|
134
|
+
mask: "url(#canvasMask)"
|
|
135
|
+
}, /*#__PURE__*/_react.default.createElement("rect", {
|
|
136
|
+
fill: "transparent",
|
|
137
|
+
height: canvasSize,
|
|
138
|
+
width: canvasSize,
|
|
139
|
+
x: "0",
|
|
140
|
+
y: "0"
|
|
141
|
+
}), /*#__PURE__*/_react.default.createElement("g", null, segmentNodes)), label ? /*#__PURE__*/_react.default.createElement("text", {
|
|
142
|
+
x: radius + adjustedHoverWidth / 2,
|
|
143
|
+
y: radius + adjustedHoverWidth / 2
|
|
144
|
+
}, /*#__PURE__*/_react.default.createElement("tspan", {
|
|
145
|
+
className: (0, _classnames.default)("doughnut-chart__label", labelClassname),
|
|
146
|
+
"data-testid": TestIds.Label
|
|
147
|
+
}, label)) : null)));
|
|
148
|
+
};
|
|
149
|
+
DoughnutChart.propTypes = {
|
|
150
|
+
label: _propTypes.default.string,
|
|
151
|
+
labelClassname: _propTypes.default.string,
|
|
152
|
+
className: _propTypes.default.string,
|
|
153
|
+
segmentHoverWidth: _propTypes.default.number.isRequired,
|
|
154
|
+
segmentThickness: _propTypes.default.number.isRequired,
|
|
155
|
+
segments: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
156
|
+
color: _propTypes.default.string.isRequired,
|
|
157
|
+
tooltip: _propTypes.default.string,
|
|
158
|
+
value: _propTypes.default.number.isRequired
|
|
159
|
+
})).isRequired,
|
|
160
|
+
size: _propTypes.default.number.isRequired,
|
|
161
|
+
chartID: _propTypes.default.string.isRequired
|
|
162
|
+
};
|
|
163
|
+
var _default = exports.default = DoughnutChart;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@import "vanilla-framework";
|
|
2
|
+
|
|
3
|
+
.doughnut-chart {
|
|
4
|
+
width: 6.5rem;
|
|
5
|
+
|
|
6
|
+
.doughnut-chart__tooltip {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.doughnut-chart__tooltip > :only-child {
|
|
11
|
+
// Override the tooltip wrapper.
|
|
12
|
+
display: block !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.doughnut-chart__chart {
|
|
16
|
+
// Restrict hover areas to the strokes.
|
|
17
|
+
pointer-events: stroke;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.doughnut-chart__segment {
|
|
21
|
+
fill: transparent;
|
|
22
|
+
|
|
23
|
+
// Animate stroke size changes on hover.
|
|
24
|
+
transition: stroke-width 0.3s ease;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.doughnut-chart__legend {
|
|
29
|
+
list-style-type: none;
|
|
30
|
+
}
|
|
@@ -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 _DoughnutChart.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _DoughnutChart = _interopRequireDefault(require("./DoughnutChart"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -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
|
@@ -19,6 +19,7 @@ export { default as Col } from "./components/Col";
|
|
|
19
19
|
export { default as ConfirmationButton } from "./components/ConfirmationButton";
|
|
20
20
|
export { default as ConfirmationModal } from "./components/ConfirmationModal";
|
|
21
21
|
export { default as ContextualMenu } from "./components/ContextualMenu";
|
|
22
|
+
export { default as DoughnutChart } from "./components/DoughnutChart";
|
|
22
23
|
export { default as EmptyState } from "./components/EmptyState";
|
|
23
24
|
export { default as Field } from "./components/Field";
|
|
24
25
|
export { default as Form } from "./components/Form";
|
|
@@ -54,6 +55,7 @@ export { default as Slider } from "./components/Slider";
|
|
|
54
55
|
export { default as Switch } from "./components/Switch";
|
|
55
56
|
export { default as Spinner } from "./components/Spinner";
|
|
56
57
|
export { default as StatusLabel, StatusLabelAppearance, } from "./components/StatusLabel";
|
|
58
|
+
export { default as Stepper, Step } from "./components/Stepper";
|
|
57
59
|
export { default as Strip } from "./components/Strip";
|
|
58
60
|
export { default as SummaryButton } from "./components/SummaryButton";
|
|
59
61
|
export { default as Table } from "./components/Table";
|
|
@@ -86,6 +88,7 @@ export type { ColProps, ColSize } from "./components/Col";
|
|
|
86
88
|
export type { ConfirmationButtonProps } from "./components/ConfirmationButton";
|
|
87
89
|
export type { ConfirmationModalProps } from "./components/ConfirmationModal";
|
|
88
90
|
export type { ContextualMenuProps, ContextualMenuDropdownProps, MenuLink, Position, } from "./components/ContextualMenu";
|
|
91
|
+
export type { DoughnutChartProps, Segment } from "./components/DoughnutChart";
|
|
89
92
|
export type { EmptyStateProps } from "./components/EmptyState";
|
|
90
93
|
export type { FieldProps } from "./components/Field";
|
|
91
94
|
export type { FormProps } from "./components/Form";
|
|
@@ -117,6 +120,7 @@ export type { SkipLinkProps } from "./components/SkipLink";
|
|
|
117
120
|
export type { SliderProps } from "./components/Slider";
|
|
118
121
|
export type { SpinnerProps } from "./components/Spinner";
|
|
119
122
|
export type { StatusLabelProps } from "./components/StatusLabel";
|
|
123
|
+
export type { StepperProps, StepProps } from "./components/Stepper";
|
|
120
124
|
export type { StripProps } from "./components/Strip";
|
|
121
125
|
export type { SummaryButtonProps } from "./components/SummaryButton";
|
|
122
126
|
export type { TableProps } from "./components/Table";
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var _exportNames = {
|
|
|
27
27
|
ConfirmationButton: true,
|
|
28
28
|
ConfirmationModal: true,
|
|
29
29
|
ContextualMenu: true,
|
|
30
|
+
DoughnutChart: true,
|
|
30
31
|
EmptyState: true,
|
|
31
32
|
Field: true,
|
|
32
33
|
Form: true,
|
|
@@ -70,6 +71,8 @@ var _exportNames = {
|
|
|
70
71
|
Spinner: true,
|
|
71
72
|
StatusLabel: true,
|
|
72
73
|
StatusLabelAppearance: true,
|
|
74
|
+
Stepper: true,
|
|
75
|
+
Step: true,
|
|
73
76
|
Strip: true,
|
|
74
77
|
SummaryButton: true,
|
|
75
78
|
Table: true,
|
|
@@ -232,6 +235,12 @@ Object.defineProperty(exports, "ContextualMenu", {
|
|
|
232
235
|
return _ContextualMenu.default;
|
|
233
236
|
}
|
|
234
237
|
});
|
|
238
|
+
Object.defineProperty(exports, "DoughnutChart", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function () {
|
|
241
|
+
return _DoughnutChart.default;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
235
244
|
Object.defineProperty(exports, "EmptyState", {
|
|
236
245
|
enumerable: true,
|
|
237
246
|
get: function () {
|
|
@@ -454,6 +463,18 @@ Object.defineProperty(exports, "StatusLabelAppearance", {
|
|
|
454
463
|
return _StatusLabel.StatusLabelAppearance;
|
|
455
464
|
}
|
|
456
465
|
});
|
|
466
|
+
Object.defineProperty(exports, "Step", {
|
|
467
|
+
enumerable: true,
|
|
468
|
+
get: function () {
|
|
469
|
+
return _Stepper.Step;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
Object.defineProperty(exports, "Stepper", {
|
|
473
|
+
enumerable: true,
|
|
474
|
+
get: function () {
|
|
475
|
+
return _Stepper.default;
|
|
476
|
+
}
|
|
477
|
+
});
|
|
457
478
|
Object.defineProperty(exports, "Strip", {
|
|
458
479
|
enumerable: true,
|
|
459
480
|
get: function () {
|
|
@@ -649,6 +670,7 @@ var _Col = _interopRequireDefault(require("./components/Col"));
|
|
|
649
670
|
var _ConfirmationButton = _interopRequireDefault(require("./components/ConfirmationButton"));
|
|
650
671
|
var _ConfirmationModal = _interopRequireDefault(require("./components/ConfirmationModal"));
|
|
651
672
|
var _ContextualMenu = _interopRequireDefault(require("./components/ContextualMenu"));
|
|
673
|
+
var _DoughnutChart = _interopRequireDefault(require("./components/DoughnutChart"));
|
|
652
674
|
var _EmptyState = _interopRequireDefault(require("./components/EmptyState"));
|
|
653
675
|
var _Field = _interopRequireDefault(require("./components/Field"));
|
|
654
676
|
var _Form = _interopRequireDefault(require("./components/Form"));
|
|
@@ -695,6 +717,7 @@ var _Slider = _interopRequireDefault(require("./components/Slider"));
|
|
|
695
717
|
var _Switch = _interopRequireDefault(require("./components/Switch"));
|
|
696
718
|
var _Spinner = _interopRequireDefault(require("./components/Spinner"));
|
|
697
719
|
var _StatusLabel = _interopRequireWildcard(require("./components/StatusLabel"));
|
|
720
|
+
var _Stepper = _interopRequireWildcard(require("./components/Stepper"));
|
|
698
721
|
var _Strip = _interopRequireDefault(require("./components/Strip"));
|
|
699
722
|
var _SummaryButton = _interopRequireDefault(require("./components/SummaryButton"));
|
|
700
723
|
var _Table = _interopRequireDefault(require("./components/Table"));
|