oa-componentbook 0.17.95 → 0.17.97
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/build/components/oa-component-bar-chart/BarChart.js +63 -28
- package/build/components/oa-component-drawer/CustomDrawer.js +11 -3
- package/build/components/oa-component-icons/MaterialIcon.js +16 -4
- package/build/components/oa-component-notification/CustomNotification.js +7 -6
- package/build/components/oa-component-select/CustomSelect.js +32 -11
- package/build/widgets/oa-widget-stage-timeline/styles.js +9 -11
- package/package.json +3 -3
|
@@ -6,25 +6,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = BarChart;
|
|
9
|
+
require("core-js/modules/es.array.reduce.js");
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var ReactDOMServer = _interopRequireWildcard(require("react-dom/server"));
|
|
10
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
13
|
var d3 = _interopRequireWildcard(require("d3"));
|
|
12
14
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
var _ExpandLess = _interopRequireDefault(require("@material-ui/icons/ExpandLess"));
|
|
13
16
|
var _colorOptions = require("../../global-css/color-options");
|
|
14
17
|
var _ColorVariablesMap = _interopRequireDefault(require("../../global-css/ColorVariablesMap"));
|
|
18
|
+
var _TypographiesMap = _interopRequireDefault(require("../../global-css/TypographiesMap"));
|
|
15
19
|
var _utils = require("../../utils");
|
|
20
|
+
var _MaterialIcon = _interopRequireDefault(require("../oa-component-icons/MaterialIcon"));
|
|
16
21
|
var _templateObject;
|
|
17
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
19
24
|
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 && Object.prototype.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; }
|
|
20
25
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
21
|
-
const
|
|
26
|
+
const iconHtml = ReactDOMServer.renderToString( /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
|
|
27
|
+
icon: _ExpandLess.default,
|
|
28
|
+
size: 20
|
|
29
|
+
}));
|
|
30
|
+
const FullSizeContainer = _styledComponents.default.section(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n\n .black {\n color: var(--color-primary-content);\n }\n"])));
|
|
22
31
|
function BarChart(_ref) {
|
|
23
32
|
var _barsConfig$length, _barsConfig$length2;
|
|
24
33
|
let {
|
|
25
34
|
barsConfig,
|
|
35
|
+
showPercentage,
|
|
26
36
|
yStart,
|
|
27
|
-
yEnd
|
|
37
|
+
yEnd,
|
|
38
|
+
yLabel,
|
|
39
|
+
xLabel
|
|
28
40
|
} = _ref;
|
|
29
41
|
const height = 420;
|
|
30
42
|
const width = 600;
|
|
@@ -33,9 +45,12 @@ function BarChart(_ref) {
|
|
|
33
45
|
const marginTop = 32;
|
|
34
46
|
const marginLeft = 44;
|
|
35
47
|
const marginRight = 44;
|
|
48
|
+
const totalForPercentages = barsConfig === null || barsConfig === void 0 ? void 0 : barsConfig.reduce((accumulator, currentValue) => currentValue.value + accumulator, 0);
|
|
49
|
+
|
|
50
|
+
// n + 1 bar spacing for n bars.
|
|
51
|
+
const numberOfSpacesPresentInGraph = ((_barsConfig$length = barsConfig === null || barsConfig === void 0 ? void 0 : barsConfig.length) !== null && _barsConfig$length !== void 0 ? _barsConfig$length : 0) + 1;
|
|
36
52
|
const widthOfEachBar = (width - marginLeft - marginRight // Removed left and right margin.
|
|
37
|
-
- barSpacing * ((_barsConfig$
|
|
38
|
-
) / ((_barsConfig$length2 = barsConfig === null || barsConfig === void 0 ? void 0 : barsConfig.length) !== null && _barsConfig$length2 !== void 0 ? _barsConfig$length2 : 1); // Divided by the number of bars.
|
|
53
|
+
- barSpacing * numberOfSpacesPresentInGraph) / ((_barsConfig$length2 = barsConfig === null || barsConfig === void 0 ? void 0 : barsConfig.length) !== null && _barsConfig$length2 !== void 0 ? _barsConfig$length2 : 1); // Divided by the number of bars.
|
|
39
54
|
|
|
40
55
|
// Got the spacing in percentage of the width of the bar.
|
|
41
56
|
const barSpacingInPercentage = barSpacing / (widthOfEachBar + barSpacing);
|
|
@@ -45,17 +60,18 @@ function BarChart(_ref) {
|
|
|
45
60
|
const availableHeight = height - marginTop - marginBottom;
|
|
46
61
|
const availableWidth = width - marginRight - marginLeft;
|
|
47
62
|
|
|
48
|
-
// Scale for the values on the Y-axis
|
|
49
|
-
const yScale = d3.scaleLinear().domain([yStart, yEnd])
|
|
50
63
|
/*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
Scale for the values on the Y-axis
|
|
65
|
+
Minimum value of scale is at bottom.
|
|
66
|
+
The scale goes from 0 to reduced value of height (remove upper and lower margin from height)
|
|
67
|
+
*/
|
|
68
|
+
const yScale = d3.scaleLinear().domain([yStart, yEnd]).range([availableHeight, 0]);
|
|
54
69
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
/*
|
|
71
|
+
Scale for the bars on the X axis.
|
|
72
|
+
The scale goes from 0 to reduced value of width (remove left and right margin from height)
|
|
73
|
+
*/
|
|
74
|
+
const xScale = d3.scaleBand().domain(barsConfig.map(barConfig => barConfig.label)).range([0, availableWidth]).padding(barSpacingInPercentage); // Inner and outer paddings are equal for symmmetry
|
|
59
75
|
|
|
60
76
|
(0, _react.useEffect)(() => {
|
|
61
77
|
// Adding the svg element on first render.
|
|
@@ -66,33 +82,46 @@ function BarChart(_ref) {
|
|
|
66
82
|
// Adding the X axis.
|
|
67
83
|
const xAxis = barChartSvg.append('g').attr('id', 'x-axis').attr('transform', "translate(".concat(marginLeft, ", ").concat(height - marginBottom, ")"));
|
|
68
84
|
const yAxis = barChartSvg.append('g').attr('id', 'y-axis').attr('transform', "translate(".concat(marginLeft, ", ").concat(marginTop, ")"));
|
|
85
|
+
const yAxisLabel = barChartSvg.append('text').classed('type-b2-400', true).style('fill', _ColorVariablesMap.default['--color-primary-content']).attr('transform', "translate(".concat(marginLeft, ", ").concat(marginTop - _TypographiesMap.default['type-b2-400']['line-height'], ")")).text(yLabel);
|
|
69
86
|
// Removing the svg element, as a cleanup operation, before dismount.
|
|
70
87
|
return () => {
|
|
71
88
|
barChartSvg.remove();
|
|
72
89
|
};
|
|
73
90
|
});
|
|
74
|
-
|
|
75
|
-
// D3 code to create the graph
|
|
76
|
-
const barChartSvg = d3.select(barChartRef.current).select('svg');
|
|
91
|
+
const updateBars = barChartSvg => {
|
|
77
92
|
barChartSvg.selectAll('rect').data(barsConfig) // Performing a data join for an array of objects.
|
|
78
93
|
.join('rect').attr('x', (d, i) => marginRight + xScale(d.label)).attr('y', (d, i) => marginBottom + yScale(d.value)).attr('height', d => availableHeight - yScale(d.value)).attr('width', widthOfEachBar).style('fill', d => {
|
|
79
94
|
var _d$color;
|
|
80
95
|
return _ColorVariablesMap.default["--color-".concat((_d$color = d === null || d === void 0 ? void 0 : d.color) !== null && _d$color !== void 0 ? _d$color : 'warning')];
|
|
81
96
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/.tickSize(0).tickPadding(16).tickFormat(_utils.rupeeShorthandFormatter);
|
|
88
|
-
const yAxis = d3.select('#y-axis').call(yAxisConfiguration);
|
|
89
|
-
const xAxisConfiguration = d3.axisBottom(xScale)
|
|
97
|
+
};
|
|
98
|
+
const updateAxes = () => {
|
|
99
|
+
const xAxisRef = d3.select('#x-axis');
|
|
100
|
+
const yAxisRef = d3.select('#y-axis');
|
|
101
|
+
|
|
90
102
|
/*
|
|
91
103
|
tickSizeOuter is used to control the sizes of the ticks on the outer ends of the axes.
|
|
92
104
|
tickSizeInnr is for controlling the size of the remaining ticks.
|
|
93
105
|
tickSize sets both at once
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
const yAxisConfiguration = d3.axisLeft(yScale).tickSize(0).tickPadding(16).tickFormat(_utils.rupeeShorthandFormatter);
|
|
109
|
+
const yAxis = yAxisRef.call(yAxisConfiguration);
|
|
110
|
+
const yAxisSymbol = yAxisRef.append('g').html(iconHtml);
|
|
111
|
+
// .attr("y", 0 – margin.left)
|
|
112
|
+
// .attr("x",0 - (height / 2))
|
|
113
|
+
// .attr("dy", "1em")
|
|
114
|
+
// .style("text-anchor", "middle")
|
|
115
|
+
// .text("Value");
|
|
116
|
+
|
|
117
|
+
const xAxisConfiguration = d3.axisBottom(xScale).tickSize(0).tickPadding(12);
|
|
118
|
+
const xAxis = xAxisRef.call(xAxisConfiguration);
|
|
119
|
+
};
|
|
120
|
+
(0, _react.useEffect)(() => {
|
|
121
|
+
// D3 code to create the graph
|
|
122
|
+
const barChartSvg = d3.select(barChartRef.current).select('svg');
|
|
123
|
+
updateBars(barChartSvg);
|
|
124
|
+
updateAxes();
|
|
96
125
|
}, [barsConfig]); // Empty dependency array so that this code is called on every re-render
|
|
97
126
|
|
|
98
127
|
return /*#__PURE__*/_react.default.createElement(FullSizeContainer, {
|
|
@@ -104,11 +133,17 @@ BarChart.propTypes = {
|
|
|
104
133
|
value: _propTypes.default.number,
|
|
105
134
|
color: _propTypes.default.oneOf(_colorOptions.colorOptions)
|
|
106
135
|
})),
|
|
136
|
+
showPercentage: _propTypes.default.bool,
|
|
107
137
|
yStart: _propTypes.default.number,
|
|
108
|
-
yEnd: _propTypes.default.number
|
|
138
|
+
yEnd: _propTypes.default.number,
|
|
139
|
+
yLabel: _propTypes.default.string,
|
|
140
|
+
xLabel: _propTypes.default.string
|
|
109
141
|
};
|
|
110
142
|
BarChart.defaultProps = {
|
|
111
143
|
barsConfig: [],
|
|
144
|
+
showPercentage: false,
|
|
112
145
|
yStart: 0,
|
|
113
|
-
yEnd: 100
|
|
146
|
+
yEnd: 100,
|
|
147
|
+
yLabel: 'Y',
|
|
148
|
+
xLabel: 'X'
|
|
114
149
|
};
|
|
@@ -8,11 +8,13 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _antd = require("antd");
|
|
11
|
-
var
|
|
11
|
+
var _CloseRounded = _interopRequireDefault(require("@material-ui/icons/CloseRounded"));
|
|
12
|
+
var _ArrowBackIosRounded = _interopRequireDefault(require("@material-ui/icons/ArrowBackIosRounded"));
|
|
12
13
|
var _utils = require("../../utils");
|
|
13
14
|
var _CustomButton = _interopRequireDefault(require("../oa-component-button/CustomButton"));
|
|
14
15
|
var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
|
|
15
16
|
var _styles = require("./styles");
|
|
17
|
+
var _MaterialIcon = _interopRequireDefault(require("../oa-component-icons/MaterialIcon"));
|
|
16
18
|
const _excluded = ["buttonConfig", "children", "isBaseDrawer", "onClose", "open", "placement", "title", "height", "width", "data-test"];
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -73,11 +75,17 @@ function CustomDrawer(_ref) {
|
|
|
73
75
|
open: open,
|
|
74
76
|
placement: placement,
|
|
75
77
|
push: false,
|
|
76
|
-
title: isBaseDrawer ? /*#__PURE__*/_react.default.createElement(_styles.BaseDrawerTitle, null, DrawerTitle(title), /*#__PURE__*/_react.default.createElement(
|
|
78
|
+
title: isBaseDrawer ? /*#__PURE__*/_react.default.createElement(_styles.BaseDrawerTitle, null, DrawerTitle(title), /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
|
|
79
|
+
color: "primary-content",
|
|
80
|
+
icon: _CloseRounded.default,
|
|
77
81
|
onClick: handleClose,
|
|
82
|
+
size: 20,
|
|
78
83
|
"data-test": dataTest ? "".concat(dataTest, "--close-drawer-button") : undefined
|
|
79
|
-
})) : /*#__PURE__*/_react.default.createElement(_styles.LayeredDrawerTitle, null, /*#__PURE__*/_react.default.createElement(
|
|
84
|
+
})) : /*#__PURE__*/_react.default.createElement(_styles.LayeredDrawerTitle, null, /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
|
|
85
|
+
color: "primary-content",
|
|
86
|
+
icon: _ArrowBackIosRounded.default,
|
|
80
87
|
onClick: handleClose,
|
|
88
|
+
size: 20,
|
|
81
89
|
"data-test": dataTest ? "".concat(dataTest, "--close-drawer-button") : undefined
|
|
82
90
|
}), DrawerTitle(title)),
|
|
83
91
|
height: height,
|
|
@@ -8,9 +8,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = MaterialIcon;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
12
|
var _ColorVariablesMap = _interopRequireDefault(require("../../global-css/ColorVariablesMap"));
|
|
12
13
|
var _colorOptions = require("../../global-css/color-options");
|
|
13
|
-
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
const _excluded = ["color", "icon", "onClick", "rotate", "size", "style"];
|
|
16
|
+
var _templateObject;
|
|
14
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
18
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -20,17 +23,20 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
20
23
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
21
24
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
25
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
26
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
27
|
+
const UnstyledButton = _styledComponents.default.button(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: none;\n color: inherit;\n border: none;\n padding: 0;\n font: inherit;\n cursor: pointer;\n outline: inherit;\n height: ", "px;\n"])), props => props.size);
|
|
23
28
|
function MaterialIcon(_ref) {
|
|
24
29
|
let {
|
|
25
|
-
icon: Icon,
|
|
26
|
-
size,
|
|
27
30
|
color,
|
|
28
31
|
// By default, material icons inherit font color
|
|
32
|
+
icon: Icon,
|
|
33
|
+
onClick,
|
|
29
34
|
rotate,
|
|
35
|
+
size,
|
|
30
36
|
style
|
|
31
37
|
} = _ref,
|
|
32
38
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
-
|
|
39
|
+
const renderedIcon = /*#__PURE__*/_react.default.createElement(Icon, _extends({
|
|
34
40
|
style: _objectSpread({
|
|
35
41
|
color: color ? _ColorVariablesMap.default["--color-".concat(color)] : undefined,
|
|
36
42
|
fontSize: size ? "".concat(size, "px") : 'inherit',
|
|
@@ -38,16 +44,22 @@ function MaterialIcon(_ref) {
|
|
|
38
44
|
transform: "rotate(".concat(rotate, "deg)")
|
|
39
45
|
}, style)
|
|
40
46
|
}, props));
|
|
47
|
+
return (0, _utils.isFunction)(onClick) ? /*#__PURE__*/_react.default.createElement(UnstyledButton, _extends({
|
|
48
|
+
onClick: onClick,
|
|
49
|
+
size: size
|
|
50
|
+
}, props), renderedIcon) : renderedIcon;
|
|
41
51
|
}
|
|
42
52
|
MaterialIcon.propTypes = {
|
|
43
53
|
color: _propTypes.default.oneOf(_colorOptions.colorOptions),
|
|
44
54
|
icon: _propTypes.default.element.isRequired,
|
|
55
|
+
onClick: _propTypes.default.func,
|
|
45
56
|
rotate: _propTypes.default.number,
|
|
46
57
|
size: _propTypes.default.number,
|
|
47
58
|
style: _propTypes.default.objectOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]))
|
|
48
59
|
};
|
|
49
60
|
MaterialIcon.defaultProps = {
|
|
50
61
|
color: null,
|
|
62
|
+
onClick: null,
|
|
51
63
|
rotate: 0,
|
|
52
64
|
size: null,
|
|
53
65
|
style: {}
|
|
@@ -10,8 +10,9 @@ require("core-js/modules/es.symbol.description.js");
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _antd = require("antd");
|
|
13
|
-
var
|
|
13
|
+
var _CloseRounded = _interopRequireDefault(require("@material-ui/icons/CloseRounded"));
|
|
14
14
|
var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
|
|
15
|
+
var _MaterialIcon = _interopRequireDefault(require("../oa-component-icons/MaterialIcon"));
|
|
15
16
|
var _typographyOptions = require("../../global-css/typography-options");
|
|
16
17
|
var _styles = require("./styles");
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -71,11 +72,11 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
71
72
|
borderLeft: "4px solid ".concat(borderColor),
|
|
72
73
|
boxShadow: '0px 2px 8px 0px rgba(0, 0, 0, 0.12)'
|
|
73
74
|
},
|
|
74
|
-
closeIcon: /*#__PURE__*/_react.default.createElement(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
closeIcon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
|
|
76
|
+
color: "primary-content",
|
|
77
|
+
icon: _CloseRounded.default,
|
|
78
|
+
onClick: handleClose,
|
|
79
|
+
size: 20
|
|
79
80
|
}),
|
|
80
81
|
onClick: handleClick,
|
|
81
82
|
onClose: handleClose
|
|
@@ -22,7 +22,7 @@ var _Typography = _interopRequireDefault(require("../oa-component-typography/Typ
|
|
|
22
22
|
var _ColorVariablesMap = _interopRequireDefault(require("../../global-css/ColorVariablesMap"));
|
|
23
23
|
require("antd/dist/reset.css");
|
|
24
24
|
var _Elevation = require("../../global-css/Elevation");
|
|
25
|
-
const _excluded = ["allText", "children", "defaultValue", "data-test", "onSelectionChange", "options"],
|
|
25
|
+
const _excluded = ["allText", "children", "defaultValue", "data-test", "mode", "onSelectionChange", "options"],
|
|
26
26
|
_excluded2 = ["label", "disabled", "value"];
|
|
27
27
|
var _templateObject;
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -51,13 +51,15 @@ function CustomSelect(_ref) {
|
|
|
51
51
|
children,
|
|
52
52
|
defaultValue,
|
|
53
53
|
'data-test': dataTest,
|
|
54
|
+
mode,
|
|
54
55
|
onSelectionChange,
|
|
55
56
|
options
|
|
56
57
|
} = _ref,
|
|
57
58
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
58
59
|
// If allText is present in default values, we select all the options manually.
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
const actualDefaultValue = mode === 'multiple' ? [...defaultValue] : defaultValue;
|
|
62
|
+
if (mode === 'multiple' && allText && defaultValue !== null && defaultValue !== void 0 && defaultValue.includes(allText)) {
|
|
61
63
|
var _options$filter$map, _options$filter;
|
|
62
64
|
// Emptying the array first.
|
|
63
65
|
actualDefaultValue.length = 0;
|
|
@@ -66,7 +68,10 @@ function CustomSelect(_ref) {
|
|
|
66
68
|
actualDefaultValue === null || actualDefaultValue === void 0 || actualDefaultValue.push(allText);
|
|
67
69
|
|
|
68
70
|
// Pushing the enabled options.
|
|
69
|
-
actualDefaultValue.push(...((_options$filter$map = options === null || options === void 0 || (_options$filter = options.filter(option =>
|
|
71
|
+
actualDefaultValue.push(...((_options$filter$map = options === null || options === void 0 || (_options$filter = options.filter(option => {
|
|
72
|
+
var _option$disabled;
|
|
73
|
+
return !((_option$disabled = option === null || option === void 0 ? void 0 : option.disabled) !== null && _option$disabled !== void 0 ? _option$disabled : false);
|
|
74
|
+
})) === null || _options$filter === void 0 ? void 0 : _options$filter.map(option => option.value)) !== null && _options$filter$map !== void 0 ? _options$filter$map : []));
|
|
70
75
|
}
|
|
71
76
|
const valueLabelMap = options.reduce((accumulator, option) => {
|
|
72
77
|
var _option$label;
|
|
@@ -136,7 +141,14 @@ function CustomSelect(_ref) {
|
|
|
136
141
|
}
|
|
137
142
|
});
|
|
138
143
|
};
|
|
139
|
-
const
|
|
144
|
+
const onOptionsChangeForSingle = (select, value) => {
|
|
145
|
+
if (select) {
|
|
146
|
+
setSelectedOptions(value);
|
|
147
|
+
} else {
|
|
148
|
+
setSelectedOptions(null);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const onOptionsChangeForMultiple = (select, value) => {
|
|
140
152
|
const newlySelectedOptions = selectedOptions.slice(0);
|
|
141
153
|
const allIndex = newlySelectedOptions.indexOf(allText);
|
|
142
154
|
if (allIndex !== -1) {
|
|
@@ -150,7 +162,11 @@ function CustomSelect(_ref) {
|
|
|
150
162
|
addAllOptions(options, newlySelectedOptions);
|
|
151
163
|
} else {
|
|
152
164
|
safePush(newlySelectedOptions, value);
|
|
153
|
-
|
|
165
|
+
const enabledOptions = options.filter(option => {
|
|
166
|
+
var _option$disabled2;
|
|
167
|
+
return !((_option$disabled2 = option === null || option === void 0 ? void 0 : option.disabled) !== null && _option$disabled2 !== void 0 ? _option$disabled2 : false);
|
|
168
|
+
});
|
|
169
|
+
if (newlySelectedOptions.length === enabledOptions.length && allText) {
|
|
154
170
|
newlySelectedOptions.unshift(allText);
|
|
155
171
|
}
|
|
156
172
|
}
|
|
@@ -165,6 +181,7 @@ function CustomSelect(_ref) {
|
|
|
165
181
|
onSelectionChange(valuesArrayToOptionArray(optionsWithoutAllText, valueLabelMap));
|
|
166
182
|
setSelectedOptions(newlySelectedOptions);
|
|
167
183
|
};
|
|
184
|
+
const onOptionsChange = mode === 'multiple' ? onOptionsChangeForMultiple : onOptionsChangeForSingle;
|
|
168
185
|
return /*#__PURE__*/_react.default.createElement(_antd.ConfigProvider, {
|
|
169
186
|
theme: {
|
|
170
187
|
components: {
|
|
@@ -233,15 +250,17 @@ function CustomSelect(_ref) {
|
|
|
233
250
|
dropdownStyle: {
|
|
234
251
|
padding: '0px'
|
|
235
252
|
},
|
|
253
|
+
mode: mode,
|
|
236
254
|
maxTagCount: selectedOptions.indexOf(allText) === -1 ? 'responsive' : 1,
|
|
237
255
|
maxTagPlaceholder: getMaxTagPlaceholder,
|
|
238
|
-
onDeselect: value => onOptionsChange(false, value),
|
|
239
|
-
onSelect: value => onOptionsChange(true, value),
|
|
256
|
+
onDeselect: (0, _utils.isFunction)(onSelectionChange) ? value => onOptionsChange(false, value) : undefined,
|
|
257
|
+
onSelect: (0, _utils.isFunction)(onSelectionChange) ? value => onOptionsChange(true, value) : undefined,
|
|
240
258
|
suffixIcon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
|
|
241
259
|
icon: _KeyboardArrowDown.default,
|
|
242
260
|
size: 20
|
|
243
261
|
}),
|
|
244
|
-
value: (
|
|
262
|
+
value: (0, _utils.isFunction)(onSelectionChange) ? selectedOptions : undefined,
|
|
263
|
+
defaultValue: defaultValue,
|
|
245
264
|
virtual: false
|
|
246
265
|
}, props), allText && /*#__PURE__*/_react.default.createElement(Option, {
|
|
247
266
|
value: allText
|
|
@@ -258,8 +277,9 @@ CustomSelect.Option = _antd.Select.Option;
|
|
|
258
277
|
CustomSelect.propTypes = {
|
|
259
278
|
allText: _propTypes.default.string,
|
|
260
279
|
children: _propTypes.default.node,
|
|
261
|
-
defaultValue: _propTypes.default.array,
|
|
280
|
+
defaultValue: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.string, _propTypes.default.number]),
|
|
262
281
|
'data-test': _propTypes.default.string,
|
|
282
|
+
mode: _propTypes.default.oneOf(['multiple', 'tags']),
|
|
263
283
|
onSelectionChange: _propTypes.default.func,
|
|
264
284
|
options: _propTypes.default.arrayOf(
|
|
265
285
|
// Checked from antd's github
|
|
@@ -274,7 +294,8 @@ CustomSelect.defaultProps = {
|
|
|
274
294
|
children: null,
|
|
275
295
|
defaultValue: [],
|
|
276
296
|
'data-test': null,
|
|
277
|
-
|
|
297
|
+
mode: null,
|
|
298
|
+
onSelectionChange: null,
|
|
278
299
|
options: [],
|
|
279
300
|
size: 'middle'
|
|
280
301
|
};
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SubStageContainer = exports.SubStage = exports.StaticStage = exports.StagesList = exports.StageDetails = exports.DotIcon = exports.CollapsibleStage =
|
|
7
|
-
var _icons = require("@ant-design/icons");
|
|
6
|
+
exports.SubStageContainer = exports.SubStage = exports.StaticStage = exports.StagesList = exports.StageDetails = exports.DotIcon = exports.CollapsibleStage = void 0;
|
|
8
7
|
var _antd = require("antd");
|
|
9
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7
|
|
9
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const DotIcon = exports.DotIcon = _styledComponents.default.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 12px;\n height: 12px;\n \n \n border-radius: 50px;\n\n display: flex;\n\n background: ", ";\n"])), props => {
|
|
12
|
+
const CollapsibleStage = exports.CollapsibleStage = (0, _styledComponents.default)(_antd.Collapse)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n \n /* Removes default ant design font */\n font-family: inherit;\n\n border-radius: 28px 28px 0px 0px !important;\n\n \n\n &.notstarted .ant-collapse-header .ant-collapse-arrow {\n color: var(--color-disabled-button);\n }\n \n &.inprogress--active .ant-collapse-header .ant-collapse-arrow {\n color: var(--color-primary);\n }\n\n // This is for the arrow\n &.completed .ant-collapse-header .ant-collapse-arrow, \n &.inprogress .ant-collapse-header .ant-collapse-arrow, \n &.completed--active .ant-collapse-header .ant-collapse-arrow {\n color: var(--color-secondary-content);\n }\n\n & .ant-collapse-header {\n /* !important needed to override pre-existing ant design styles */\n padding: 12px 24px 12px 24px !important;\n border-radius: 28px !important;\n border: 1px solid transparent;\n cursor: pointer;\n } \n\n &.notstarted .ant-collapse-header {\n cursor: not-allowed;\n }\n\n &.inprogress .ant-collapse-header, \n &.completed .ant-collapse-header {\n border: 1px solid var(--color-divider);\n background: var(--color-primary-background);\n }\n\n\n &.inprogress--active .ant-collapse-header, \n &.completed--active .ant-collapse-header {\n background: var(--color-background-info);\n border: 1px solid var(--color-background-info);\n }\n"])));
|
|
13
|
+
const DotIcon = exports.DotIcon = _styledComponents.default.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 12px;\n height: 12px;\n \n \n border-radius: 50px;\n\n display: flex;\n\n background: ", ";\n"])), props => {
|
|
16
14
|
switch (props.className) {
|
|
17
15
|
case 'inprogress--active':
|
|
18
16
|
return 'var(--color-primary)';
|
|
@@ -24,8 +22,8 @@ const DotIcon = exports.DotIcon = _styledComponents.default.span(_templateObject
|
|
|
24
22
|
return '';
|
|
25
23
|
}
|
|
26
24
|
});
|
|
27
|
-
const StageDetails = exports.StageDetails = _styledComponents.default.div(
|
|
28
|
-
const StaticStage = exports.StaticStage = _styledComponents.default.a(
|
|
29
|
-
const StagesList = exports.StagesList = _styledComponents.default.ul(
|
|
30
|
-
const SubStage = exports.SubStage = _styledComponents.default.button(
|
|
31
|
-
const SubStageContainer = exports.SubStageContainer = _styledComponents.default.section(
|
|
25
|
+
const StageDetails = exports.StageDetails = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n gap: 8px;\n \n &.notstarted {\n color: var(--color-disabled-button);\n }\n\n &.inprogress--active {\n color: var(--color-primary);\n }\n\n &.completed, &.inprogress, &.completed--active {\n color: var(--color-secondary-content);\n }\n"])));
|
|
26
|
+
const StaticStage = exports.StaticStage = _styledComponents.default.a(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n padding: 16px 24px 16px 24px; \n cursor: not-allowed;\n border: 1px solid transparent;\n color: var(--color-disabled-button); \n text-decoration: none;\n border-radius: 28px;\n\n \n \n &.completed, &.inprogress {\n border-color: var(--color-divider);\n background: var(--color-primary-background);\n cursor: pointer;\n }\n \n &.completed--active {\n color: var(--color-secondary-content);\n background: var(--color-background-info);\n border-color: var(--color-background-info);\n \n }\n\n &.inprogress--active {\n color: var(--color-primary);\n background: var(--color-background-info);\n border-color: var(--color-background-info);\n cursor: pointer;\n }\n"])));
|
|
27
|
+
const StagesList = exports.StagesList = _styledComponents.default.ul(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 12px;\n list-style-type: none;\n \n /* Since width is 100%, it'll take up all of its container */\n /* width: 100%; */\n"])));
|
|
28
|
+
const SubStage = exports.SubStage = _styledComponents.default.button(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n width: 100%;\n padding: 4px 1px 4px calc(12px + 12px + 10px);\n \n background: inherit;\n border: none;\n text-align: left;\n \n cursor: pointer;\n \n &.active {\n color: var(--color-primary-content);\n } \n \n &.inactive {\n color: var(--color-secondary-content);\n }\n \n &.disabled {\n cursor: not-allowed;\n color: var(--color-disabled-button);\n }\n"])));
|
|
29
|
+
const SubStageContainer = exports.SubStageContainer = _styledComponents.default.section(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 12px;\n\n /* &.notstarted {\n cursor: not-allowed;\n pointer-events: none;\n } */\n"])));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oa-componentbook",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.97",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Reusable components",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"react-scripts": "^5.0.1",
|
|
42
42
|
"storybook": "^7.6.3",
|
|
43
43
|
"webpack": "^5.88.2",
|
|
44
|
-
"webpack-cli": "^5.1.4"
|
|
44
|
+
"webpack-cli": "^5.1.4",
|
|
45
|
+
"d3": "^7.8.5"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
48
|
"@material-ui/core": "^4.12.4",
|
|
48
49
|
"@material-ui/icons": "^4.11.3",
|
|
49
|
-
"d3": "^7.8.5",
|
|
50
50
|
"prop-types": "^15.8.1",
|
|
51
51
|
"react": "^16.9.0",
|
|
52
52
|
"react-dom": "^16.9.0",
|