asab_webui_components 25.2.6 → 25.2.7-alpha.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/Authz/Credentials.js +18 -3
- package/dist/components/DateTime/DateTime.js +58 -2
- package/dist/components/DateTime/DateTime.jsx +61 -2
- package/dist/components/DateTime/splDatetimeToIso.js +48 -0
- package/dist/index.js +6 -0
- package/dist/styles/constants/colors.scss +8 -11
- package/package.json +1 -1
|
@@ -9,18 +9,20 @@ exports.Credentials = Credentials;
|
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
var
|
|
13
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
14
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
14
|
var _reactI18next = require("react-i18next");
|
|
16
15
|
var _reactRedux = require("react-redux");
|
|
17
16
|
var _LinkWithAuthz = require("./LinkWithAuthz");
|
|
18
17
|
require("./Credentials.scss");
|
|
18
|
+
var _excluded = ["isPlainCredentials"];
|
|
19
19
|
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); }
|
|
20
20
|
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; }
|
|
21
21
|
function Credentials(_ref) {
|
|
22
22
|
var _props$apiPath, _props$cleanupTime, _props$app;
|
|
23
|
-
var
|
|
23
|
+
var _ref$isPlainCredentia = _ref.isPlainCredentials,
|
|
24
|
+
isPlainCredentials = _ref$isPlainCredentia === void 0 ? false : _ref$isPlainCredentia,
|
|
25
|
+
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
24
26
|
// Validation on undefined credentials_ids
|
|
25
27
|
if (props.credentials_ids == undefined) {
|
|
26
28
|
return '';
|
|
@@ -124,6 +126,9 @@ function Credentials(_ref) {
|
|
|
124
126
|
}
|
|
125
127
|
setCredentials(usernamesToRender);
|
|
126
128
|
};
|
|
129
|
+
if (isPlainCredentials === true && credentials && credentials.length !== 0) {
|
|
130
|
+
return renderPlainUsername();
|
|
131
|
+
}
|
|
127
132
|
function renderPlainCredentials(credentials_ids) {
|
|
128
133
|
return credentials_ids.map(function (credentials_id, i) {
|
|
129
134
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -136,6 +141,16 @@ function Credentials(_ref) {
|
|
|
136
141
|
}, credentials_id));
|
|
137
142
|
});
|
|
138
143
|
}
|
|
144
|
+
function renderPlainUsername() {
|
|
145
|
+
return credentials.map(function (credentialObj, i) {
|
|
146
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
147
|
+
key: i,
|
|
148
|
+
title: credentialObj.username || credentialObj.id
|
|
149
|
+
}, /*#__PURE__*/_react["default"].createElement("i", {
|
|
150
|
+
className: "bi bi-person pe-1"
|
|
151
|
+
}), /*#__PURE__*/_react["default"].createElement("span", null, credentialObj.username || credentialObj.id));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
139
154
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, credentials && credentials.length !== 0 ? credentials.map(function (credentialObj, i) {
|
|
140
155
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
141
156
|
key: i,
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _timeToString = _interopRequireDefault(require("./timeToString.js"));
|
|
10
10
|
var _useDateFNSLocale = _interopRequireDefault(require("./useDateFNSLocale.js"));
|
|
11
11
|
var _InvalidDate = require("./InvalidDate.js");
|
|
12
|
+
var _splDatetimeToIso = require("./splDatetimeToIso");
|
|
12
13
|
// Component that displays the absolute time and shows the relative time on hover
|
|
13
14
|
function DateTime(props) {
|
|
14
15
|
if (props.value == undefined) {
|
|
@@ -19,10 +20,11 @@ function DateTime(props) {
|
|
|
19
20
|
|
|
20
21
|
// Declaration of locale must be below span returned for `undefined` values to avoid bad react state handling in useDateFNSLocale
|
|
21
22
|
var locale = (0, _useDateFNSLocale["default"])();
|
|
22
|
-
|
|
23
|
+
var datetime = validateDateTime(props.value);
|
|
24
|
+
if (datetime.toString() === 'Invalid Date') {
|
|
23
25
|
return /*#__PURE__*/_react["default"].createElement(_InvalidDate.InvalidDate, null);
|
|
24
26
|
}
|
|
25
|
-
var date = (0, _timeToString["default"])(
|
|
27
|
+
var date = (0, _timeToString["default"])(datetime, props.dateTimeFormat, locale);
|
|
26
28
|
|
|
27
29
|
// Check for invalid date from timeToString method
|
|
28
30
|
if (date === 'Invalid Date') {
|
|
@@ -34,4 +36,58 @@ function DateTime(props) {
|
|
|
34
36
|
}, /*#__PURE__*/_react["default"].createElement("i", {
|
|
35
37
|
className: "bi bi-clock pe-1"
|
|
36
38
|
}), date.date);
|
|
39
|
+
}
|
|
40
|
+
function validateDateTime(value) {
|
|
41
|
+
// Return 'Invalid Date' if the input is null or undefined
|
|
42
|
+
if (value == null) {
|
|
43
|
+
return 'Invalid Date';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Handle BigInt values explicitly
|
|
47
|
+
if (typeof value === 'bigint') {
|
|
48
|
+
// SP-Lang datetime format is represented as BigInt
|
|
49
|
+
return (0, _splDatetimeToIso.splDatetimeToIso)(value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Handle string values
|
|
53
|
+
if (typeof value === 'string') {
|
|
54
|
+
var parsed = new Date(value); // Try to parse the string into a Date object
|
|
55
|
+
// If the parsed date is invalid, return 'Invalid Date'; otherwise, return the date
|
|
56
|
+
return isNaN(parsed.getTime()) ? 'Invalid Date' : parsed;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Handle number values
|
|
60
|
+
if (typeof value === 'number') {
|
|
61
|
+
// Reject infinite, NaN, or negative numbers
|
|
62
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
63
|
+
return 'Invalid Date';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Consider numbers ≥ 1e17 as SP-Lang datetime format
|
|
67
|
+
if (value >= 1e17) {
|
|
68
|
+
// Convert number to BigInt and parse as SP-Lang datetime
|
|
69
|
+
return (0, _splDatetimeToIso.splDatetimeToIso)(BigInt(value));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Handle Unix timestamp in seconds (less than 1e10)
|
|
73
|
+
if (value < 1e10) {
|
|
74
|
+
return new Date(value * 1000); // Convert seconds to milliseconds
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Handle timestamps in milliseconds (less than 1e13)
|
|
78
|
+
if (value < 1e13) {
|
|
79
|
+
return new Date(value); // Already in milliseconds
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Handle timestamps in microseconds (less than 1e16)
|
|
83
|
+
if (value < 1e16) {
|
|
84
|
+
return new Date(value / 1000); // Convert microseconds to milliseconds
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Numbers that don't fall into any known range are considered invalid
|
|
88
|
+
return 'Invalid Date';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// All other types are unsupported and result in 'Invalid Date'
|
|
92
|
+
return 'Invalid Date';
|
|
37
93
|
}
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import timeToString from './timeToString.js';
|
|
4
4
|
import useDateFNSLocale from './useDateFNSLocale.js';
|
|
5
5
|
import { InvalidDate } from './InvalidDate.jsx';
|
|
6
|
+
import { splDatetimeToIso } from './splDatetimeToIso';
|
|
6
7
|
|
|
7
8
|
// Component that displays the absolute time and shows the relative time on hover
|
|
8
9
|
export function DateTime(props) {
|
|
@@ -14,13 +15,16 @@ export function DateTime(props) {
|
|
|
14
15
|
|
|
15
16
|
// Declaration of locale must be below span returned for `undefined` values to avoid bad react state handling in useDateFNSLocale
|
|
16
17
|
const locale = useDateFNSLocale();
|
|
17
|
-
|
|
18
|
+
|
|
19
|
+
const datetime = validateDateTime(props.value);
|
|
20
|
+
|
|
21
|
+
if (datetime.toString() === 'Invalid Date') {
|
|
18
22
|
return (
|
|
19
23
|
<InvalidDate />
|
|
20
24
|
);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
|
-
const date = timeToString(
|
|
27
|
+
const date = timeToString(datetime, props.dateTimeFormat, locale);
|
|
24
28
|
|
|
25
29
|
// Check for invalid date from timeToString method
|
|
26
30
|
if (date === 'Invalid Date') {
|
|
@@ -39,3 +43,58 @@ export function DateTime(props) {
|
|
|
39
43
|
</span>
|
|
40
44
|
);
|
|
41
45
|
}
|
|
46
|
+
|
|
47
|
+
function validateDateTime(value) {
|
|
48
|
+
// Return 'Invalid Date' if the input is null or undefined
|
|
49
|
+
if (value == null) {
|
|
50
|
+
return 'Invalid Date';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle BigInt values explicitly
|
|
54
|
+
if (typeof value === 'bigint') {
|
|
55
|
+
// SP-Lang datetime format is represented as BigInt
|
|
56
|
+
return splDatetimeToIso(value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Handle string values
|
|
60
|
+
if (typeof value === 'string') {
|
|
61
|
+
const parsed = new Date(value); // Try to parse the string into a Date object
|
|
62
|
+
// If the parsed date is invalid, return 'Invalid Date'; otherwise, return the date
|
|
63
|
+
return isNaN(parsed.getTime()) ? 'Invalid Date' : parsed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Handle number values
|
|
67
|
+
if (typeof value === 'number') {
|
|
68
|
+
// Reject infinite, NaN, or negative numbers
|
|
69
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
70
|
+
return 'Invalid Date';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Consider numbers ≥ 1e17 as SP-Lang datetime format
|
|
74
|
+
if (value >= 1e17) {
|
|
75
|
+
// Convert number to BigInt and parse as SP-Lang datetime
|
|
76
|
+
return splDatetimeToIso(BigInt(value));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Handle Unix timestamp in seconds (less than 1e10)
|
|
80
|
+
if (value < 1e10) {
|
|
81
|
+
return new Date(value * 1000); // Convert seconds to milliseconds
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Handle timestamps in milliseconds (less than 1e13)
|
|
85
|
+
if (value < 1e13) {
|
|
86
|
+
return new Date(value); // Already in milliseconds
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Handle timestamps in microseconds (less than 1e16)
|
|
90
|
+
if (value < 1e16) {
|
|
91
|
+
return new Date(value / 1000); // Convert microseconds to milliseconds
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Numbers that don't fall into any known range are considered invalid
|
|
95
|
+
return 'Invalid Date';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// All other types are unsupported and result in 'Invalid Date'
|
|
99
|
+
return 'Invalid Date';
|
|
100
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.splDatetimeToIso = splDatetimeToIso;
|
|
7
|
+
function splDatetimeToIso(datetime) {
|
|
8
|
+
// Check if datetime is a number or BigInt
|
|
9
|
+
if (typeof datetime !== 'bigint' && typeof datetime !== 'number') {
|
|
10
|
+
return 'Invalid Date';
|
|
11
|
+
}
|
|
12
|
+
var BigIntDatetime = BigInt(datetime); // Convert to BigInt for correct bitwise operations
|
|
13
|
+
|
|
14
|
+
// Year extraction (bits 46-60)
|
|
15
|
+
var year = Number(BigIntDatetime >> BigInt(46) & BigInt(4095)); // 14 bits
|
|
16
|
+
if (year >= 8192) {
|
|
17
|
+
year -= 8192; // Adjust for sign bit if necessary
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Month extraction (bits 42-46)
|
|
21
|
+
var month = Number(BigIntDatetime >> BigInt(42) & BigInt(15)); // 4 bits
|
|
22
|
+
|
|
23
|
+
// Day extraction (bits 37-42)
|
|
24
|
+
var day = Number(BigIntDatetime >> BigInt(37) & BigInt(31)); // 5 bits
|
|
25
|
+
|
|
26
|
+
// Hour extraction (bits 32-37)
|
|
27
|
+
var hour = Number(BigIntDatetime >> BigInt(32) & BigInt(31)); // 5 bits
|
|
28
|
+
|
|
29
|
+
// Minute extraction (bits 26-32)
|
|
30
|
+
var minute = Number(BigIntDatetime >> BigInt(26) & BigInt(63)); // 6 bits
|
|
31
|
+
|
|
32
|
+
// Second extraction (bits 20-26)
|
|
33
|
+
var second = Number(BigIntDatetime >> BigInt(20) & BigInt(63)); // 6 bits
|
|
34
|
+
|
|
35
|
+
// Microsecond extraction (bits 0-20)
|
|
36
|
+
var microsecond = Number(BigIntDatetime & BigInt(2097151)); // 20 bits
|
|
37
|
+
|
|
38
|
+
// Adjust for zero-based month
|
|
39
|
+
month += 1;
|
|
40
|
+
|
|
41
|
+
// Check if the values are correct
|
|
42
|
+
if (year < 0 || month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || minute > 59 || second > 59) {
|
|
43
|
+
return 'Invalid Date';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Format date string
|
|
47
|
+
return "".concat(year.toString().padStart(4, '0'), "-").concat(month.toString().padStart(2, '0'), "-").concat(day.toString().padStart(2, '0'), "T").concat(hour.toString().padStart(2, '0'), ":").concat(minute.toString().padStart(2, '0'), ":").concat(second.toString().padStart(2, '0'), ".").concat(microsecond.toString().padStart(6, '0'), "Z");
|
|
48
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -208,6 +208,12 @@ Object.defineProperty(exports, "UncontrolledSwitchWithAuthz", {
|
|
|
208
208
|
return _UncontrolledSwitchWithAuthz.UncontrolledSwitchWithAuthz;
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
+
Object.defineProperty(exports, "credentialsToString", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function get() {
|
|
214
|
+
return _Credentials.credentialsToString;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
211
217
|
Object.defineProperty(exports, "deepMerge", {
|
|
212
218
|
enumerable: true,
|
|
213
219
|
get: function get() {
|
|
@@ -46,11 +46,14 @@
|
|
|
46
46
|
--slate-smoke: #6a6a6a8f; // The color of the disabled item text in the TreeMenu
|
|
47
47
|
--slate-smoke-rgb: 106, 106, 106;
|
|
48
48
|
|
|
49
|
-
--
|
|
50
|
-
--
|
|
49
|
+
--light-honey: #ffe082; // The color of the lowest Alert severity
|
|
50
|
+
--light-honey-rgb: 255, 224, 130;
|
|
51
51
|
|
|
52
|
-
--
|
|
53
|
-
--
|
|
52
|
+
--bright-orange: #ff9800; // The color of the medium Alert severity
|
|
53
|
+
--bright-orange-rgb: 255, 125, 0;
|
|
54
|
+
|
|
55
|
+
--fiery-sunset: #ff5722; // The color of the high Alert severity
|
|
56
|
+
--fiery-sunset-rgb: 255, 87, 34;
|
|
54
57
|
|
|
55
58
|
--charcoal: #494949; // Console background dark theme
|
|
56
59
|
--charcoal-rgb: 0, 43, 54;
|
|
@@ -63,10 +66,4 @@
|
|
|
63
66
|
|
|
64
67
|
--moody-blues: #586E75; // Console font color for light theme
|
|
65
68
|
--moody-blues-rgb: rgb(88, 110, 117);
|
|
66
|
-
|
|
67
|
-
--soft-gray: #e1e2e7; // Emulate table hover row color for light theme
|
|
68
|
-
--soft-gray-rgb: rgb(225, 226, 231);
|
|
69
|
-
|
|
70
|
-
--charcoal-blue: #202636; // Emulate table hover row color for dark theme
|
|
71
|
-
--charcoal-blue-rgb: rgb(32, 38, 54);
|
|
72
|
-
}
|
|
69
|
+
}
|