asab_webui_components 26.1.4 → 26.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ASABProgress = ASABProgress;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _reactstrap = require("reactstrap");
12
+ require("./ASABProgress.scss");
13
+ var _excluded = ["showLabel", "children"];
14
+ function ASABProgress(_ref) {
15
+ var {
16
+ showLabel = true,
17
+ children
18
+ } = _ref,
19
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
20
+ // Value has to be present and numeric
21
+ var progressValue = props === null || props === void 0 ? void 0 : props.value;
22
+
23
+ // Early return if not a number
24
+ if (!(typeof progressValue === 'number')) {
25
+ console.warn('ASABProgress not rendered due to an invalid value');
26
+ return null;
27
+ }
28
+
29
+ // Handle non-finite numbers (Infinity, -Infinity, NaN)
30
+ if (!Number.isFinite(progressValue)) {
31
+ progressValue = 0;
32
+ }
33
+
34
+ // Clamp between 0-100 & round to nearest integer
35
+ progressValue = Math.round(Math.min(Math.max(progressValue, 0), 100));
36
+ return /*#__PURE__*/_react.default.createElement("div", {
37
+ className: "d-flex align-items-center"
38
+ }, /*#__PURE__*/_react.default.createElement(_reactstrap.Progress, (0, _extends2.default)({}, props, {
39
+ className: "w-100 ".concat(showLabel && !children ? 'me-2' : '', " ").concat(props.className || ''),
40
+ value: progressValue
41
+ }), children), showLabel && !children && /*#__PURE__*/_react.default.createElement("span", {
42
+ className: "asab-progress-percentage text-end"
43
+ }, "".concat(progressValue, "%")));
44
+ }
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { Progress } from 'reactstrap';
3
+
4
+ import './ASABProgress.scss';
5
+
6
+ export function ASABProgress({
7
+ showLabel = true,
8
+ children,
9
+ ...props
10
+ }) {
11
+ // Value has to be present and numeric
12
+ let progressValue = props?.value;
13
+
14
+ // Early return if not a number
15
+ if (!(typeof progressValue === 'number')) {
16
+ console.warn('ASABProgress not rendered due to an invalid value');
17
+ return null;
18
+ }
19
+
20
+ // Handle non-finite numbers (Infinity, -Infinity, NaN)
21
+ if (!Number.isFinite(progressValue)) {
22
+ progressValue = 0;
23
+ }
24
+
25
+ // Clamp between 0-100 & round to nearest integer
26
+ progressValue = Math.round(Math.min(Math.max(progressValue, 0), 100));
27
+
28
+ return (
29
+ <div className='d-flex align-items-center'>
30
+ <Progress
31
+ {...props}
32
+ className={`w-100 ${showLabel && !children ? 'me-2' : ''} ${props.className || ''}`}
33
+ value={progressValue}
34
+ >
35
+ {children}
36
+ </Progress>
37
+ {/* show label only when there is no children */}
38
+ {showLabel && !children
39
+ && <span className='asab-progress-percentage text-end'>
40
+ {`${progressValue}%`}
41
+ </span>
42
+ }
43
+ </div>
44
+ );
45
+ }
@@ -0,0 +1,3 @@
1
+ .asab-progress-percentage {
2
+ width: 2.4rem;
3
+ }
package/dist/index.js CHANGED
@@ -4,6 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ Object.defineProperty(exports, "ASABProgress", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _ASABProgress.ASABProgress;
11
+ }
12
+ });
7
13
  Object.defineProperty(exports, "AdvancedCard", {
8
14
  enumerable: true,
9
15
  get: function get() {
@@ -342,6 +348,7 @@ var _AsabReactJson = require("./components/AsabReactJson/AsabReactJson.js");
342
348
  var _FullscreenButton = require("./components/FullscreenButton.js");
343
349
  var _AttentionRequiredBadge = require("./components/AttentionRequired/AttentionRequiredBadge.js");
344
350
  var _RendererWrapper = require("./components/RendererWrapper/RendererWrapper.js");
351
+ var _ASABProgress = require("./components/Progress/ASABProgress.js");
345
352
  var _FlowbiteIllustration = require("./components/FlowbiteIllustration.js");
346
353
  var _PubSubContext = require("./components/Context/PubSubContext");
347
354
  var _AppStore = require("./components/Context/store/AppStore.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asab_webui_components",
3
- "version": "26.1.4",
3
+ "version": "26.1.5",
4
4
  "license": "BSD-3-Clause",
5
5
  "description": "TeskaLabs ASAB WebUI Components Library",
6
6
  "contributors": [