oa-componentbook 0.18.2 → 0.18.3
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 +188 -55
- package/build/components/oa-component-form-item/CustomFormItem.js +35 -7
- package/build/components/oa-component-info/CustomInfo.js +23 -11
- package/build/components/oa-component-modal/CustomModal.js +18 -14
- package/build/components/oa-component-notification/CustomNotification.js +4 -6
- package/build/components/oa-component-table/CustomTable.js +5 -1
- package/build/utils/fix-decimal-places.js +17 -0
- package/build/utils/index.js +7 -0
- package/build/utils/rupee-formatters.js +9 -3
- package/build/widgets/oa-widget-add-spare-part/AddSparePartWidget.js +3 -3
- package/build/widgets/oa-widget-spare-part/SparePartsWidget.js +6 -11
- package/package.json +2 -6
|
@@ -1,51 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.weak-map.js");
|
|
4
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = BarChart;
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
9
|
require("core-js/modules/es.array.reduce.js");
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var ReactDOMServer = _interopRequireWildcard(require("react-dom/server"));
|
|
12
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
12
|
var d3 = _interopRequireWildcard(require("d3"));
|
|
14
13
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
var
|
|
14
|
+
var _antd = require("antd");
|
|
16
15
|
var _colorOptions = require("../../global-css/color-options");
|
|
17
16
|
var _ColorVariablesMap = _interopRequireDefault(require("../../global-css/ColorVariablesMap"));
|
|
18
17
|
var _TypographiesMap = _interopRequireDefault(require("../../global-css/TypographiesMap"));
|
|
19
18
|
var _utils = require("../../utils");
|
|
20
|
-
var _MaterialIcon = _interopRequireDefault(require("../oa-component-icons/MaterialIcon"));
|
|
21
19
|
var _templateObject;
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
21
|
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); }
|
|
24
22
|
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; }
|
|
25
23
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
24
|
+
const FullSizeContainer = _styledComponents.default.section(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n \n display: inline-block;\n position: relative;\n width: 100%;\n padding-bottom: ", "%;\n vertical-align: top;\n overflow: hidden;\n\n .bar-chart-svg {\n display: inline-block;\n position: absolute;\n top: 0;\n left: 0;\n }\n\n .empty-component-container {\n display: ", ";\n position: absolute;\n top: ", ";\n left: ", ";\n transform: translate(-50%, -50%) scale(1.2);\n }\n"])), props => 100 / props.$aspectRatio, props => props !== null && props !== void 0 && props.$showNoData ? 'block' : 'none', props => "calc(50% + (".concat(props.$marginTop, "px - ").concat(props.$marginBottom, "px) / 2)"), props => "calc(50% + (".concat(props.$marginLeft, "px - ").concat(props.$marginRight, "px) / 2)"));
|
|
25
|
+
function curvedBar(x, y, width, height, r) {
|
|
26
|
+
// x coordinates of top of arcs
|
|
27
|
+
const x0 = x + r;
|
|
28
|
+
const x1 = x + width - r;
|
|
29
|
+
// y coordinates of bottom of arcs
|
|
30
|
+
const y0 = y - height + r;
|
|
31
|
+
|
|
32
|
+
// assemble path:
|
|
33
|
+
const parts = ['M', x, y,
|
|
34
|
+
// step 1
|
|
35
|
+
'L', x, y0,
|
|
36
|
+
// step 2
|
|
37
|
+
'A', r, r, 0, 0, 1, x0, y - height,
|
|
38
|
+
// step 3
|
|
39
|
+
'L', x1, y - height,
|
|
40
|
+
// step 4
|
|
41
|
+
'A', r, r, 0, 0, 1, x + width, y0,
|
|
42
|
+
// step 5
|
|
43
|
+
'L', x + width, y,
|
|
44
|
+
// step 6
|
|
45
|
+
'Z' // step 7
|
|
46
|
+
];
|
|
47
|
+
return parts.join(' ');
|
|
48
|
+
}
|
|
31
49
|
function BarChart(_ref) {
|
|
32
50
|
var _barsConfig$length, _barsConfig$length2;
|
|
33
51
|
let {
|
|
34
52
|
barsConfig,
|
|
35
53
|
showPercentage,
|
|
36
|
-
yStart,
|
|
37
|
-
yEnd,
|
|
38
54
|
yLabel,
|
|
39
55
|
xLabel
|
|
40
56
|
} = _ref;
|
|
41
|
-
const height =
|
|
57
|
+
const height = 450;
|
|
42
58
|
const width = 600;
|
|
59
|
+
const aspectRatio = width / height;
|
|
43
60
|
const barSpacing = 32;
|
|
44
61
|
const marginBottom = 32;
|
|
45
62
|
const marginTop = 32;
|
|
46
|
-
const marginLeft =
|
|
47
|
-
const marginRight =
|
|
63
|
+
const marginLeft = 48;
|
|
64
|
+
const marginRight = 48;
|
|
65
|
+
const yMin = 0;
|
|
66
|
+
const yMax = showPercentage ? 100 : Math.max(...barsConfig.map(barConfig => barConfig.value));
|
|
67
|
+
const xLabelPlural = "".concat(xLabel, "s");
|
|
68
|
+
const yLabelPlural = "".concat(yLabel, "s");
|
|
48
69
|
const totalForPercentages = barsConfig === null || barsConfig === void 0 ? void 0 : barsConfig.reduce((accumulator, currentValue) => currentValue.value + accumulator, 0);
|
|
70
|
+
const showNoData = (() => {
|
|
71
|
+
if (totalForPercentages <= 0) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
})();
|
|
76
|
+
|
|
77
|
+
// This function gets the value for y-axis, based on whether `showPercentage` is true or not.
|
|
78
|
+
const getValueY = value => showPercentage ? (0, _utils.fixMaxDecimalPlaces)(100 * (value / totalForPercentages), 2) : value;
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
This function gets the labels placed above the bars,
|
|
82
|
+
based on whether `showPercentage` is true or not.
|
|
83
|
+
*/
|
|
84
|
+
const getBarLabel = value => "".concat(getValueY(value)).concat(showPercentage ? '%' : " ".concat(value === 1 ? yLabel : yLabelPlural));
|
|
49
85
|
|
|
50
86
|
// n + 1 bar spacing for n bars.
|
|
51
87
|
const numberOfSpacesPresentInGraph = ((_barsConfig$length = barsConfig === null || barsConfig === void 0 ? void 0 : barsConfig.length) !== null && _barsConfig$length !== void 0 ? _barsConfig$length : 0) + 1;
|
|
@@ -65,7 +101,7 @@ function BarChart(_ref) {
|
|
|
65
101
|
Minimum value of scale is at bottom.
|
|
66
102
|
The scale goes from 0 to reduced value of height (remove upper and lower margin from height)
|
|
67
103
|
*/
|
|
68
|
-
const yScale = d3.scaleLinear().domain([
|
|
104
|
+
const yScale = d3.scaleLinear().domain([yMin, yMax]).range([availableHeight, 0]).nice();
|
|
69
105
|
|
|
70
106
|
/*
|
|
71
107
|
Scale for the bars on the X axis.
|
|
@@ -73,29 +109,48 @@ function BarChart(_ref) {
|
|
|
73
109
|
*/
|
|
74
110
|
const xScale = d3.scaleBand().domain(barsConfig.map(barConfig => barConfig.label)).range([0, availableWidth]).padding(barSpacingInPercentage); // Inner and outer paddings are equal for symmmetry
|
|
75
111
|
|
|
76
|
-
|
|
112
|
+
const updateChartDimensions = barChartSvg => {
|
|
77
113
|
// Adding the svg element on first render.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
114
|
+
barChartSvg.attr('viewBox', "0 0 ".concat(width, " ").concat(height)).attr('preserveAspectRatio', 'xMidYMid meet');
|
|
115
|
+
};
|
|
116
|
+
const updateAxesPosition = barChartSvg => {
|
|
117
|
+
const xAxisRef = barChartSvg.select('#x-axis');
|
|
118
|
+
const yAxisRef = barChartSvg.select('#y-axis');
|
|
119
|
+
|
|
120
|
+
// Setting the position of X-axis
|
|
121
|
+
const xAxis = xAxisRef.attr('transform', "translate(".concat(marginLeft, ", ").concat(height - marginBottom, ")"));
|
|
122
|
+
const xAxisLabel = barChartSvg.selectAll('#x-axis-label').data([xLabelPlural]) // Singular data join
|
|
123
|
+
.join('text').attr('id', 'x-axis-label').classed('type-b3-400', true).style('fill', _ColorVariablesMap.default['--color-primary-content']).style('dominant-baseline', 'middle') // This CSS property aligns the <text> element, with the X-axis.
|
|
124
|
+
.attr('transform', "translate(".concat(width - marginRight + 12, ", ").concat(height - marginBottom, ")")).text(d => d);
|
|
125
|
+
|
|
126
|
+
// Setting the position of Y-axis
|
|
127
|
+
const yAxis = yAxisRef.attr('transform', "translate(".concat(marginLeft, ", ").concat(marginTop, ")"));
|
|
128
|
+
const yAxisLabel = barChartSvg.selectAll('#y-axis-label').data([yLabelPlural]) // Singular data join
|
|
129
|
+
.join('text').attr('id', 'y-axis-label').classed('type-b3-400', true).style('fill', _ColorVariablesMap.default['--color-primary-content']).attr('transform', "translate(".concat(marginLeft, ", ").concat(marginTop - _TypographiesMap.default['type-b2-400']['line-height'], ")")).attr('text-anchor', 'middle').text(d => d);
|
|
130
|
+
};
|
|
91
131
|
const updateBars = barChartSvg => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
132
|
+
if (showNoData) {
|
|
133
|
+
barChartSvg.selectAll('#bar').remove();
|
|
134
|
+
|
|
135
|
+
// barChartSvg
|
|
136
|
+
// .select('.bar-chart-svg')
|
|
137
|
+
// .select('#no-data-image')
|
|
138
|
+
// .join([true])
|
|
139
|
+
// .
|
|
140
|
+
} else {
|
|
141
|
+
barChartSvg.selectAll('#bar') // We select the id which we add just below, so that the existing bars are updated.
|
|
142
|
+
.data(barsConfig) // Performing a data join for an array of objects.
|
|
143
|
+
.join('path').filter(d => d.value !== 0).attr('d', (d, i) => curvedBar(marginRight + xScale(d.label), height - marginBottom, widthOfEachBar, availableHeight - yScale(getValueY(d.value)), 4)).attr('id', 'bar').style('fill', d => {
|
|
144
|
+
var _d$color;
|
|
145
|
+
return _ColorVariablesMap.default["--color-".concat((_d$color = d === null || d === void 0 ? void 0 : d.color) !== null && _d$color !== void 0 ? _d$color : 'warning')];
|
|
146
|
+
});
|
|
147
|
+
barChartSvg.selectAll('#bar-label') // We select the id which we add just below, so that the existing bars are updated.
|
|
148
|
+
.data(barsConfig).join('text').text('') // Resetting the text before filtering
|
|
149
|
+
.filter(d => d.value !== 0).attr('id', 'bar-label').style('width', widthOfEachBar).attr('text-anchor', 'middle').text((d, i) => getBarLabel(d.value)).attr('x', (d, i) => marginRight + widthOfEachBar / 2 + xScale(d.label)) // Center position
|
|
150
|
+
.attr('y', (d, i) => marginTop + yScale(getValueY(d.value)) - 12).classed('type-b3-400', true);
|
|
151
|
+
}
|
|
97
152
|
};
|
|
98
|
-
const
|
|
153
|
+
const updateAxesConfiguration = () => {
|
|
99
154
|
const xAxisRef = d3.select('#x-axis');
|
|
100
155
|
const yAxisRef = d3.select('#y-axis');
|
|
101
156
|
|
|
@@ -105,28 +160,110 @@ function BarChart(_ref) {
|
|
|
105
160
|
tickSize sets both at once
|
|
106
161
|
*/
|
|
107
162
|
|
|
108
|
-
const yAxisConfiguration = d3.axisLeft(yScale).
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
// .style("text-anchor", "middle")
|
|
115
|
-
// .text("Value");
|
|
163
|
+
const yAxisConfiguration = d3.axisLeft(yScale).ticks(5) // Controls the approximate number of ticks to be shown on Y-axis.
|
|
164
|
+
.tickSizeInner(-availableWidth) // This draws the grid lines out of the Y-axis.
|
|
165
|
+
.tickSizeOuter(0).tickPadding(16).tickFormat(showPercentage ? d => "".concat(d, "%") : _utils.rupeeShorthandFormatter);
|
|
166
|
+
|
|
167
|
+
// TODO: Add smooth transition
|
|
168
|
+
const yAxis = yAxisRef.transition().call(yAxisConfiguration);
|
|
116
169
|
|
|
170
|
+
// After calling the function for the drawing the Y-axis, we remove the tick with value 0.
|
|
171
|
+
yAxisRef.selectAll('.tick').filter(d => d === 0).remove();
|
|
117
172
|
const xAxisConfiguration = d3.axisBottom(xScale).tickSize(0).tickPadding(12);
|
|
118
|
-
|
|
173
|
+
|
|
174
|
+
// TODO: Add smooth transition
|
|
175
|
+
const xAxis = xAxisRef.transition().call(xAxisConfiguration);
|
|
176
|
+
|
|
177
|
+
// Adding typography class to text of all ticks
|
|
178
|
+
d3.selectAll('.tick text').classed('type-b2-400', true);
|
|
179
|
+
|
|
180
|
+
// Setting the color of Y-axis
|
|
181
|
+
yAxisRef.select('path').attr('stroke', _ColorVariablesMap.default['--color-placeholder-text']).attr('marker-end', 'url(#arrowhead-up)');
|
|
182
|
+
|
|
183
|
+
// Setting the color of the ticks (dashed grid of Y-axis)
|
|
184
|
+
yAxisRef.selectAll('.tick line').attr('stroke', _ColorVariablesMap.default['--color-placeholder-text']).style('stroke-dasharray', '3,6');
|
|
185
|
+
|
|
186
|
+
// Setting the color of X-axis
|
|
187
|
+
|
|
188
|
+
xAxisRef.select('path').attr('stroke', _ColorVariablesMap.default['--color-placeholder-text']).attr('marker-end', 'url(#arrowhead-right)');
|
|
119
189
|
};
|
|
120
190
|
(0, _react.useEffect)(() => {
|
|
121
|
-
//
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
191
|
+
// Selecting this bar chart svg, only after mount, so that it is present in the DOM.
|
|
192
|
+
const barChartSvgReference = d3.select(barChartRef.current).select('svg.bar-chart-svg');
|
|
193
|
+
updateChartDimensions(barChartSvgReference);
|
|
194
|
+
updateAxesPosition(barChartSvgReference);
|
|
195
|
+
updateAxesConfiguration();
|
|
196
|
+
updateBars(barChartSvgReference);
|
|
197
|
+
});
|
|
127
198
|
return /*#__PURE__*/_react.default.createElement(FullSizeContainer, {
|
|
199
|
+
$aspectRatio: aspectRatio,
|
|
200
|
+
$marginTop: marginTop,
|
|
201
|
+
$marginRight: marginRight,
|
|
202
|
+
$marginBottom: marginBottom,
|
|
203
|
+
$marginLeft: marginLeft,
|
|
204
|
+
$showNoData: showNoData,
|
|
128
205
|
ref: barChartRef
|
|
129
|
-
}
|
|
206
|
+
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
207
|
+
className: "bar-chart-svg"
|
|
208
|
+
}, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("svg", {
|
|
209
|
+
id: "no-data-svg-ref",
|
|
210
|
+
width: "64",
|
|
211
|
+
height: "41",
|
|
212
|
+
viewBox: "0 0 64 41",
|
|
213
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
214
|
+
}, /*#__PURE__*/_react.default.createElement("g", {
|
|
215
|
+
transform: "translate(0 1)",
|
|
216
|
+
fill: "none",
|
|
217
|
+
fillRule: "evenodd"
|
|
218
|
+
}, /*#__PURE__*/_react.default.createElement("ellipse", {
|
|
219
|
+
fill: "#f5f5f5",
|
|
220
|
+
cx: "32",
|
|
221
|
+
cy: "33",
|
|
222
|
+
rx: "32",
|
|
223
|
+
ry: "7"
|
|
224
|
+
}), /*#__PURE__*/_react.default.createElement("g", {
|
|
225
|
+
fillRule: "nonzero",
|
|
226
|
+
stroke: "#d9d9d9"
|
|
227
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
228
|
+
d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"
|
|
229
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
230
|
+
d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z",
|
|
231
|
+
fill: "#fafafa"
|
|
232
|
+
})))), /*#__PURE__*/_react.default.createElement("marker", {
|
|
233
|
+
id: "arrowhead-right",
|
|
234
|
+
refX: "1" // X-coordinate of the marker svg which has to matched with end of X-axis
|
|
235
|
+
,
|
|
236
|
+
refY: "5" // Y-coordinate of the marker svg which has to matched with end of X-axis
|
|
237
|
+
,
|
|
238
|
+
markerWidth: "16",
|
|
239
|
+
markerHeight: "13"
|
|
240
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
241
|
+
d: "M 1 0 L 6 5 L 1 10",
|
|
242
|
+
stroke: _ColorVariablesMap.default['--color-placeholder-text'],
|
|
243
|
+
strokeWidth: "1",
|
|
244
|
+
fill: "none"
|
|
245
|
+
})), /*#__PURE__*/_react.default.createElement("marker", {
|
|
246
|
+
id: "arrowhead-up",
|
|
247
|
+
refX: "5" // X-coordinate of the marker svg which has to matched with end of X-axis
|
|
248
|
+
,
|
|
249
|
+
refY: "14" // Y-coordinate of the marker svg which has to matched with end of X-axis
|
|
250
|
+
,
|
|
251
|
+
markerWidth: "11",
|
|
252
|
+
markerHeight: "14"
|
|
253
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
254
|
+
d: "M 0 5 L 5 0 L 10 5 M 5 6 L 5 14",
|
|
255
|
+
stroke: _ColorVariablesMap.default['--color-placeholder-text'],
|
|
256
|
+
strokeWidth: "1",
|
|
257
|
+
fill: "none"
|
|
258
|
+
}))), /*#__PURE__*/_react.default.createElement("g", {
|
|
259
|
+
id: "x-axis"
|
|
260
|
+
}), /*#__PURE__*/_react.default.createElement("g", {
|
|
261
|
+
id: "y-axis"
|
|
262
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
263
|
+
className: "empty-component-container"
|
|
264
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Empty, {
|
|
265
|
+
image: _antd.Empty.PRESENTED_IMAGE_SIMPLE
|
|
266
|
+
})));
|
|
130
267
|
}
|
|
131
268
|
BarChart.propTypes = {
|
|
132
269
|
barsConfig: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -134,16 +271,12 @@ BarChart.propTypes = {
|
|
|
134
271
|
color: _propTypes.default.oneOf(_colorOptions.colorOptions)
|
|
135
272
|
})),
|
|
136
273
|
showPercentage: _propTypes.default.bool,
|
|
137
|
-
yStart: _propTypes.default.number,
|
|
138
|
-
yEnd: _propTypes.default.number,
|
|
139
274
|
yLabel: _propTypes.default.string,
|
|
140
275
|
xLabel: _propTypes.default.string
|
|
141
276
|
};
|
|
142
277
|
BarChart.defaultProps = {
|
|
143
278
|
barsConfig: [],
|
|
144
279
|
showPercentage: false,
|
|
145
|
-
yStart: 0,
|
|
146
|
-
yEnd: 100,
|
|
147
280
|
yLabel: 'Y',
|
|
148
281
|
xLabel: 'X'
|
|
149
282
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
3
4
|
require("core-js/modules/es.object.assign.js");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
@@ -7,27 +8,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
8
|
exports.default = CustomFormItem;
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
12
|
var _antd = require("antd");
|
|
11
13
|
var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
|
|
12
|
-
const _excluded = ["label"];
|
|
14
|
+
const _excluded = ["label", "labelPosition", "name", "children"];
|
|
15
|
+
var _templateObject;
|
|
13
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
17
|
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); }
|
|
18
|
+
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; }
|
|
19
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
22
|
+
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); }
|
|
15
23
|
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; }
|
|
16
24
|
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; }
|
|
25
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
26
|
+
const StyledFormItem = (0, _styledComponents.default)(_antd.Form.Item)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n label{\n height: auto !important;\n color: var(--color-primary-content) !important;\n margin: 0 0 4px !important;\n }\n .ant-col-24.ant-form-item-label{\n padding: 0;\n }\n"])));
|
|
17
27
|
function CustomFormItem(_ref) {
|
|
18
28
|
let {
|
|
19
|
-
label
|
|
29
|
+
label,
|
|
30
|
+
labelPosition = 'left',
|
|
31
|
+
name,
|
|
32
|
+
children
|
|
20
33
|
} = _ref,
|
|
21
34
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
-
|
|
35
|
+
const labelCol = labelPosition === 'top' ? _objectSpread({
|
|
36
|
+
span: 24
|
|
37
|
+
}, props.labelCol) : props.labelCol;
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(StyledFormItem, _extends({
|
|
39
|
+
name: name,
|
|
23
40
|
label: label ? /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
24
41
|
typography: "type-b2-400"
|
|
25
|
-
}, label) : undefined
|
|
26
|
-
|
|
42
|
+
}, label) : undefined,
|
|
43
|
+
labelCol: _objectSpread({}, labelCol)
|
|
44
|
+
}, props), children);
|
|
27
45
|
}
|
|
28
46
|
CustomFormItem.propTypes = {
|
|
29
|
-
label: _propTypes.default.string
|
|
47
|
+
label: _propTypes.default.string,
|
|
48
|
+
name: _propTypes.default.string,
|
|
49
|
+
children: _propTypes.default.element,
|
|
50
|
+
labelPosition: _propTypes.default.oneOf(['left', 'top']),
|
|
51
|
+
initialValue: _propTypes.default.any,
|
|
52
|
+
labelCol: _propTypes.default.object
|
|
30
53
|
};
|
|
31
54
|
CustomFormItem.defaultProps = {
|
|
32
|
-
label: null
|
|
55
|
+
label: null,
|
|
56
|
+
name: '',
|
|
57
|
+
children: /*#__PURE__*/_react.default.createElement("input", null),
|
|
58
|
+
labelPosition: 'left',
|
|
59
|
+
initialValue: null,
|
|
60
|
+
labelCol: null
|
|
33
61
|
};
|
|
@@ -7,6 +7,7 @@ exports.default = CustomInfo;
|
|
|
7
7
|
require("core-js/modules/es.symbol.description.js");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _antd = require("antd");
|
|
10
11
|
var _styles = require("./styles");
|
|
11
12
|
var _CustomButton = _interopRequireDefault(require("../oa-component-button/CustomButton"));
|
|
12
13
|
var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
|
|
@@ -18,24 +19,32 @@ function CustomInfo(_ref) {
|
|
|
18
19
|
buttonConfig,
|
|
19
20
|
color,
|
|
20
21
|
description,
|
|
22
|
+
fontColor,
|
|
21
23
|
iconConfig,
|
|
22
24
|
title
|
|
23
25
|
} = _ref;
|
|
24
|
-
|
|
25
|
-
$color: color
|
|
26
|
-
}, /*#__PURE__*/_react.default.createElement(_styles.RowFlex, null, iconConfig.position === 'left' && (!title ? /*#__PURE__*/_react.default.isValidElement(iconConfig.icon) && /*#__PURE__*/_react.default.cloneElement(iconConfig.icon, {
|
|
26
|
+
const renderIcon = () => !title ? /*#__PURE__*/_react.default.isValidElement(iconConfig.icon) && /*#__PURE__*/_react.default.cloneElement(iconConfig.icon, {
|
|
27
27
|
size: 20
|
|
28
28
|
}) : /*#__PURE__*/_react.default.isValidElement(iconConfig.icon) && /*#__PURE__*/_react.default.cloneElement(iconConfig.icon, {
|
|
29
29
|
size: 24
|
|
30
|
-
})
|
|
30
|
+
});
|
|
31
|
+
const conditionallyAddTooltipToIcon = () => {
|
|
32
|
+
var _iconConfig$tooltipTe;
|
|
33
|
+
return (iconConfig === null || iconConfig === void 0 || (_iconConfig$tooltipTe = iconConfig.tooltipText) === null || _iconConfig$tooltipTe === void 0 ? void 0 : _iconConfig$tooltipTe.length) > 0 ? /*#__PURE__*/_react.default.createElement(_antd.Tooltip, {
|
|
34
|
+
title: iconConfig === null || iconConfig === void 0 ? void 0 : iconConfig.tooltipText
|
|
35
|
+
}, renderIcon()) : renderIcon();
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
|
|
38
|
+
$color: color
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.RowFlex, null, iconConfig.position === 'left' && conditionallyAddTooltipToIcon(), /*#__PURE__*/_react.default.createElement(_styles.ColFlex, null, title && /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
40
|
+
color: fontColor,
|
|
31
41
|
typography: "type-t2-700"
|
|
32
42
|
}, title), description && /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
-
className: "type-b2-400"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}))), (buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.label) && /*#__PURE__*/_react.default.createElement(_CustomButton.default, buttonConfig));
|
|
43
|
+
className: "type-b2-400",
|
|
44
|
+
style: {
|
|
45
|
+
color: "var(--color-".concat(fontColor, ")")
|
|
46
|
+
}
|
|
47
|
+
}, description)), iconConfig.position === 'right' && conditionallyAddTooltipToIcon()), (buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.label) && /*#__PURE__*/_react.default.createElement(_CustomButton.default, buttonConfig));
|
|
39
48
|
}
|
|
40
49
|
CustomInfo.propTypes = {
|
|
41
50
|
buttonConfig: _propTypes.default.shape({
|
|
@@ -51,9 +60,11 @@ CustomInfo.propTypes = {
|
|
|
51
60
|
}),
|
|
52
61
|
color: _propTypes.default.oneOf(_colorOptions.colorOptions),
|
|
53
62
|
description: _propTypes.default.string,
|
|
63
|
+
fontColor: _propTypes.default.oneOf(_colorOptions.colorOptions),
|
|
54
64
|
iconConfig: _propTypes.default.shape({
|
|
55
65
|
icon: _propTypes.default.node,
|
|
56
|
-
position: _propTypes.default.oneOf(['left', 'right'])
|
|
66
|
+
position: _propTypes.default.oneOf(['left', 'right']),
|
|
67
|
+
tooltipText: _propTypes.default.string
|
|
57
68
|
}),
|
|
58
69
|
title: _propTypes.default.string
|
|
59
70
|
};
|
|
@@ -67,6 +78,7 @@ CustomInfo.defaultProps = {
|
|
|
67
78
|
iconConfig: {
|
|
68
79
|
position: 'left'
|
|
69
80
|
},
|
|
81
|
+
fontColor: 'primary-content',
|
|
70
82
|
title: null,
|
|
71
83
|
description: null
|
|
72
84
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.object.assign.js");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
require("core-js/modules/es.object.assign.js");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _antd = require("antd");
|
|
@@ -13,21 +13,25 @@ var _Typography = _interopRequireDefault(require("../oa-component-typography/Typ
|
|
|
13
13
|
var _typographyOptions = require("../../global-css/typography-options");
|
|
14
14
|
var _utils = require("../../utils");
|
|
15
15
|
var _styles = require("./styles");
|
|
16
|
+
const _excluded = ["buttonConfig", "children", "data-test", "imgSrc", "onCancel", "open", "title", "typographies", "width"];
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
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); }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
18
21
|
function CustomModal(_ref) {
|
|
19
22
|
let {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
buttonConfig,
|
|
24
|
+
children,
|
|
25
|
+
'data-test': dataTest,
|
|
26
|
+
imgSrc,
|
|
27
|
+
// This callback function provided by parent is called upon clicking on the cancel button
|
|
28
|
+
onCancel,
|
|
29
|
+
open,
|
|
30
|
+
title,
|
|
31
|
+
typographies,
|
|
32
|
+
width
|
|
33
|
+
} = _ref,
|
|
34
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
31
35
|
/*
|
|
32
36
|
We make our own callback function, which makes a call to the `onCancel`
|
|
33
37
|
function given to use by the parent.
|
|
@@ -38,7 +42,7 @@ function CustomModal(_ref) {
|
|
|
38
42
|
onCancel();
|
|
39
43
|
// console.log('`handleCancel` callback of CustomModal component called.');
|
|
40
44
|
};
|
|
41
|
-
return /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Modal, _extends({
|
|
42
46
|
centered: true,
|
|
43
47
|
"data-test": dataTest,
|
|
44
48
|
footer: (buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.length) > 0 && /*#__PURE__*/_react.default.createElement(_styles.ButtonContainer, null, buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.map(button => /*#__PURE__*/_react.default.createElement(_CustomButton.default, _extends({
|
|
@@ -60,7 +64,7 @@ function CustomModal(_ref) {
|
|
|
60
64
|
typography: typographies.title
|
|
61
65
|
}, title)),
|
|
62
66
|
width: width
|
|
63
|
-
}, children && /*#__PURE__*/_react.default.createElement(_styles.DescriptionContainer, null,
|
|
67
|
+
}, props), children && /*#__PURE__*/_react.default.createElement(_styles.DescriptionContainer, null,
|
|
64
68
|
// The label is a string or a number
|
|
65
69
|
((0, _utils.isString)(children) || (0, _utils.isNumber)(children)) && /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
66
70
|
color: "secondary-content",
|
|
@@ -23,7 +23,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
23
23
|
const notificationOptions = exports.notificationOptions = ['positive', 'negative'];
|
|
24
24
|
const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
25
25
|
let {
|
|
26
|
-
duration,
|
|
27
26
|
storyConfig,
|
|
28
27
|
// Useful only for the purpose of displaying in storybook
|
|
29
28
|
onClick,
|
|
@@ -32,7 +31,6 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
32
31
|
typographies
|
|
33
32
|
} = _ref;
|
|
34
33
|
const [api, contextHolder] = _antd.notification.useNotification({
|
|
35
|
-
duration,
|
|
36
34
|
placement
|
|
37
35
|
});
|
|
38
36
|
const handleClick = (0, _react.useCallback)(() => {
|
|
@@ -51,7 +49,8 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
51
49
|
let {
|
|
52
50
|
description,
|
|
53
51
|
title,
|
|
54
|
-
type
|
|
52
|
+
type,
|
|
53
|
+
duration
|
|
55
54
|
} = _ref2;
|
|
56
55
|
// type can be success or failure
|
|
57
56
|
const titleColor = type === 'success' ? 'positive' : 'negative';
|
|
@@ -82,7 +81,8 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
82
81
|
size: 20
|
|
83
82
|
}),
|
|
84
83
|
onClick: handleClick,
|
|
85
|
-
onClose: handleClose
|
|
84
|
+
onClose: handleClose,
|
|
85
|
+
duration: duration !== null && duration !== void 0 ? duration : 4.5
|
|
86
86
|
});
|
|
87
87
|
}, [api, handleClick, handleClose, typographies]);
|
|
88
88
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
@@ -98,7 +98,6 @@ const Notification = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
98
98
|
return contextHolder;
|
|
99
99
|
});
|
|
100
100
|
Notification.propTypes = {
|
|
101
|
-
duration: _propTypes.default.number,
|
|
102
101
|
onClick: _propTypes.default.func,
|
|
103
102
|
onClose: _propTypes.default.func,
|
|
104
103
|
placement: _propTypes.default.oneOf(['topLeft', 'topRight', 'bottomLeft', 'bottomRight']),
|
|
@@ -114,7 +113,6 @@ Notification.propTypes = {
|
|
|
114
113
|
})
|
|
115
114
|
};
|
|
116
115
|
Notification.defaultProps = {
|
|
117
|
-
duration: null,
|
|
118
116
|
onClick: () => {},
|
|
119
117
|
onClose: () => {},
|
|
120
118
|
placement: 'topRight',
|
|
@@ -88,8 +88,12 @@ function CustomTable(_ref) {
|
|
|
88
88
|
cellFontSizeMD: "".concat(_TypographiesMap.default['type-b2-400']['font-size'], "px"),
|
|
89
89
|
cellFontSizeSM: "".concat(_TypographiesMap.default['type-b2-400']['font-size'], "px"),
|
|
90
90
|
selectionColumnWidth: '54px',
|
|
91
|
-
colorText: _ColorVariablesMap.default['--color-primary-content']
|
|
91
|
+
colorText: _ColorVariablesMap.default['--color-primary-content'],
|
|
92
|
+
rowSelectedHoverBg: _ColorVariablesMap.default['--color-secondary-background']
|
|
92
93
|
}
|
|
94
|
+
},
|
|
95
|
+
token: {
|
|
96
|
+
controlItemBgActive: _ColorVariablesMap.default['--color-secondary-background']
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
}, /*#__PURE__*/_react.default.createElement(StyledTable, _extends({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = fixMaxDecimalPlaces;
|
|
7
|
+
require("core-js/modules/es.parse-float.js");
|
|
8
|
+
require("core-js/modules/es.number.to-fixed.js");
|
|
9
|
+
function fixMaxDecimalPlaces(number, decimalPlaces) {
|
|
10
|
+
// Check if the input is a valid number
|
|
11
|
+
if (typeof number !== 'number' || Number.isNaN(number)) {
|
|
12
|
+
return number; // If not a number, return the same value
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Fix to two decimal places
|
|
16
|
+
return parseFloat(number.toFixed(decimalPlaces));
|
|
17
|
+
}
|
package/build/utils/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "fixMaxDecimalPlaces", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _fixDecimalPlaces.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "getUUID", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -60,5 +66,6 @@ Object.defineProperty(exports, "rupeeShorthandFormatter", {
|
|
|
60
66
|
var _getUuid = _interopRequireDefault(require("./get-uuid"));
|
|
61
67
|
var _hexToRgb = _interopRequireDefault(require("./hex-to-rgb"));
|
|
62
68
|
var _rupeeFormatters = require("./rupee-formatters");
|
|
69
|
+
var _fixDecimalPlaces = _interopRequireDefault(require("./fix-decimal-places"));
|
|
63
70
|
var _typeCheckers = require("./type-checkers");
|
|
64
71
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -4,18 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rupeeShorthandFormatter = exports.rupeeCommaFormatter = void 0;
|
|
7
|
+
var _fixDecimalPlaces = _interopRequireDefault(require("./fix-decimal-places"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
9
|
const thousand = 1000;
|
|
8
10
|
const lakh = 100 * thousand;
|
|
9
11
|
const crore = 100 * lakh;
|
|
10
12
|
const rupeeShorthandFormatter = value => {
|
|
13
|
+
/*
|
|
14
|
+
We multiply and divide by 10, so that decimal values are also visible.
|
|
15
|
+
1100 will be displayed as 1.1K
|
|
16
|
+
*/
|
|
11
17
|
if (value >= crore) {
|
|
12
|
-
return "".concat(
|
|
18
|
+
return "".concat((0, _fixDecimalPlaces.default)(value / crore, 1), "C");
|
|
13
19
|
}
|
|
14
20
|
if (value >= lakh) {
|
|
15
|
-
return "".concat(
|
|
21
|
+
return "".concat((0, _fixDecimalPlaces.default)(value / lakh, 1), "L");
|
|
16
22
|
}
|
|
17
23
|
if (value >= thousand) {
|
|
18
|
-
return "".concat(
|
|
24
|
+
return "".concat((0, _fixDecimalPlaces.default)(value / thousand, 1), "K");
|
|
19
25
|
}
|
|
20
26
|
return value;
|
|
21
27
|
};
|
|
@@ -129,7 +129,7 @@ function AddSparePartWidget(_ref) {
|
|
|
129
129
|
rules: [{
|
|
130
130
|
// This field is required only if the corresponding part is selected
|
|
131
131
|
required: selectedParts.includes(spare.scopeId),
|
|
132
|
-
message: ''
|
|
132
|
+
message: 'Required field'
|
|
133
133
|
// message: 'Enter the discount value.',
|
|
134
134
|
}],
|
|
135
135
|
initialValue: ""
|
|
@@ -145,7 +145,7 @@ function AddSparePartWidget(_ref) {
|
|
|
145
145
|
rules: [{
|
|
146
146
|
// This field is required only if the corresponding part is selected
|
|
147
147
|
required: selectedParts.includes(spare.scopeId),
|
|
148
|
-
message: ''
|
|
148
|
+
message: 'Required field'
|
|
149
149
|
// message: 'Enter the discount value.',
|
|
150
150
|
}],
|
|
151
151
|
initialValue: ""
|
|
@@ -161,7 +161,7 @@ function AddSparePartWidget(_ref) {
|
|
|
161
161
|
rules: [{
|
|
162
162
|
// This field is required only if the corresponding part is selected
|
|
163
163
|
required: selectedParts.includes(spare.scopeId),
|
|
164
|
-
message: ''
|
|
164
|
+
message: 'Required field'
|
|
165
165
|
// message: 'Enter the discount value.',
|
|
166
166
|
}],
|
|
167
167
|
initialValue: ""
|
|
@@ -76,16 +76,11 @@ function SparePartsWidget(_ref) {
|
|
|
76
76
|
showCostBreakdown,
|
|
77
77
|
coverageShow
|
|
78
78
|
} = _ref;
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var _sparePart$action;
|
|
85
|
-
return (sparePart === null || sparePart === void 0 || (_sparePart$action = sparePart.action) === null || _sparePart$action === void 0 ? void 0 : _sparePart$action.length) > 0;
|
|
86
|
-
}));
|
|
87
|
-
setSparePartList(tempSparePartsList);
|
|
88
|
-
}, [scopeDetails]);
|
|
79
|
+
const sparePartList = [...scopeDetails.unCoveredScope, ...scopeDetails.coveredScope];
|
|
80
|
+
const showActionList = sparePartList.some(sparePart => {
|
|
81
|
+
var _sparePart$action;
|
|
82
|
+
return (sparePart === null || sparePart === void 0 || (_sparePart$action = sparePart.action) === null || _sparePart$action === void 0 ? void 0 : _sparePart$action.length) > 0;
|
|
83
|
+
});
|
|
89
84
|
const columns = [{
|
|
90
85
|
title: 'Spare Part',
|
|
91
86
|
dataIndex: 'scopeName',
|
|
@@ -113,7 +108,7 @@ function SparePartsWidget(_ref) {
|
|
|
113
108
|
});
|
|
114
109
|
}
|
|
115
110
|
// check if there are any actions then create action column
|
|
116
|
-
if (
|
|
111
|
+
if (showActionList) {
|
|
117
112
|
columns.push({
|
|
118
113
|
title: 'Action',
|
|
119
114
|
width: '20%',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oa-componentbook",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Reusable components",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -56,15 +56,11 @@
|
|
|
56
56
|
"scripts": {
|
|
57
57
|
"start": "react-scripts start",
|
|
58
58
|
"build": "rm -rf build && NODE_ENV=production babel src/lib --out-dir build --copy-files",
|
|
59
|
-
"build-tracked": "git stash -u && npm run build && git stash pop",
|
|
60
59
|
"storybook": "storybook dev -p 6006",
|
|
61
60
|
"build-storybook": "storybook build",
|
|
62
61
|
"lint": "eslint src/** --ext .js,.jsx",
|
|
63
|
-
"lint-commit": "git add -u && git commit -m \"fix: Rectified auto-fixable lint errors for v$(npm show oa-componentbook version)\"",
|
|
64
62
|
"lint-fix": "npm run lint -- --fix",
|
|
65
|
-
"lint-fix-quiet": "npm run lint-fix -- --quiet"
|
|
66
|
-
"lint-fix-tracked": "git stash -u && npm run lint-fix-quiet && git stash pop",
|
|
67
|
-
"lint-fix-commit": "npm run lint-fix-tracked && npm run lint-commit"
|
|
63
|
+
"lint-fix-quiet": "npm run lint-fix -- --quiet"
|
|
68
64
|
},
|
|
69
65
|
"eslintConfig": {
|
|
70
66
|
"extends": [
|