asab_webui_components 27.2.4 → 27.3.2

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.
@@ -20,6 +20,10 @@ function PubSubProvider(_ref) {
20
20
  var eventsRef = (0, _react.useRef)({});
21
21
  // Subscribe to an event
22
22
  var subscribe = (0, _react.useCallback)((event, callback) => {
23
+ if (!event || typeof callback !== 'function') {
24
+ console.error('PubSub subscribe requires a valid event name and callback function');
25
+ return () => {}; // Return no-op unsubscribe
26
+ }
23
27
  if (!eventsRef.current[event]) {
24
28
  eventsRef.current[event] = [];
25
29
  }
@@ -27,21 +31,49 @@ function PubSubProvider(_ref) {
27
31
 
28
32
  // Return unsubscribe function
29
33
  return () => {
30
- eventsRef.current[event] = eventsRef.current[event].filter(cb => cb !== callback);
34
+ if (eventsRef.current[event]) {
35
+ eventsRef.current[event] = eventsRef.current[event].filter(cb => cb !== callback);
36
+ }
31
37
  };
32
38
  }, []);
33
39
 
34
40
  // Publish an event
35
41
  var publish = (0, _react.useCallback)((event, data) => {
36
42
  if (eventsRef.current[event]) {
37
- eventsRef.current[event].forEach(callback => callback(data));
43
+ eventsRef.current[event].forEach(callback => {
44
+ try {
45
+ callback(data);
46
+ } catch (error) {
47
+ console.error("Error in PubSub callback for event \"".concat(event, "\":"), error);
48
+ }
49
+ });
38
50
  }
39
51
  }, []);
40
- return /*#__PURE__*/_react.default.createElement(PubSubContext.Provider, {
41
- value: {
42
- app,
43
- subscribe,
44
- publish
52
+
53
+ // Assign a publish and subscribe methods to a app object (to obtain the publish/subscribe in non-react environments)
54
+ (0, _react.useLayoutEffect)(() => {
55
+ if (app) {
56
+ app.PubSub = {
57
+ publish,
58
+ subscribe
59
+ };
45
60
  }
61
+ return () => {
62
+ if (app) {
63
+ app.PubSub = undefined;
64
+ }
65
+ // Clear all subscriptions on unmount to prevent memory leaks
66
+ eventsRef.current = {};
67
+ };
68
+ }, [app, publish, subscribe]);
69
+
70
+ // Memoized pubsub values, to avoid unnecessary re-renders
71
+ var value = (0, _react.useMemo)(() => ({
72
+ app,
73
+ subscribe,
74
+ publish
75
+ }), [app, subscribe, publish]);
76
+ return /*#__PURE__*/_react.default.createElement(PubSubContext.Provider, {
77
+ value: value
46
78
  }, children);
47
79
  }
@@ -69,26 +69,26 @@ function splDatetimeToIso(datetime) {
69
69
  year -= 0b10000000000000; // Adjust for sign bit if necessary
70
70
  }
71
71
 
72
- // Month extraction (bits 42-46)
72
+ // Month extraction (bits 42-45)
73
73
  var month = Number(datetime >> BigInt(42) & BigInt(0b1111)); // 4 bits
74
74
 
75
- // Day extraction (bits 37-42)
75
+ // Day extraction (bits 37-41)
76
76
  var day = Number(datetime >> BigInt(37) & BigInt(0b11111)); // 5 bits
77
77
 
78
- // Hour extraction (bits 32-37)
78
+ // Hour extraction (bits 32-36)
79
79
  var hour = Number(datetime >> BigInt(32) & BigInt(0b11111)); // 5 bits
80
80
 
81
- // Minute extraction (bits 26-32)
81
+ // Minute extraction (bits 26-31)
82
82
  var minute = Number(datetime >> BigInt(26) & BigInt(0b111111)); // 6 bits
83
83
 
84
- // Second extraction (bits 20-26)
84
+ // Second extraction (bits 20-25)
85
85
  var second = Number(datetime >> BigInt(20) & BigInt(0b111111)); // 6 bits
86
86
 
87
- // Microsecond extraction (bits 0-20)
88
- var microsecond = Number(datetime & BigInt(0b111111111111111111111)); // 20 bits
87
+ // Microsecond extraction (bits 0-19)
88
+ var microsecond = Number(datetime & BigInt(0b11111111111111111111)); // 20 bits
89
89
 
90
90
  // Check if the values are correct
91
- if (year < 0 || month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || minute > 59 || second > 59) {
91
+ if (year < 0 || month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || minute > 59 || second > 59 || microsecond > 999999) {
92
92
  return 'Invalid Date';
93
93
  }
94
94
 
@@ -65,29 +65,29 @@ function splDatetimeToIso(datetime) {
65
65
  year -= 0b10_0000_0000_0000; // Adjust for sign bit if necessary
66
66
  }
67
67
 
68
- // Month extraction (bits 42-46)
69
- let month = Number((datetime >> BigInt(42)) & BigInt(0b1111)); // 4 bits
68
+ // Month extraction (bits 42-45)
69
+ const month = Number((datetime >> BigInt(42)) & BigInt(0b1111)); // 4 bits
70
70
 
71
- // Day extraction (bits 37-42)
71
+ // Day extraction (bits 37-41)
72
72
  const day = Number((datetime >> BigInt(37)) & BigInt(0b11111)); // 5 bits
73
73
 
74
- // Hour extraction (bits 32-37)
74
+ // Hour extraction (bits 32-36)
75
75
  const hour = Number((datetime >> BigInt(32)) & BigInt(0b11111)); // 5 bits
76
76
 
77
- // Minute extraction (bits 26-32)
77
+ // Minute extraction (bits 26-31)
78
78
  const minute = Number((datetime >> BigInt(26)) & BigInt(0b111111)); // 6 bits
79
79
 
80
- // Second extraction (bits 20-26)
80
+ // Second extraction (bits 20-25)
81
81
  const second = Number((datetime >> BigInt(20)) & BigInt(0b111111)); // 6 bits
82
82
 
83
- // Microsecond extraction (bits 0-20)
84
- const microsecond = Number(datetime & BigInt(0b111111111111111111111)); // 20 bits
83
+ // Microsecond extraction (bits 0-19)
84
+ const microsecond = Number(datetime & BigInt(0b11111111111111111111)); // 20 bits
85
85
 
86
86
  // Check if the values are correct
87
87
  if (
88
88
  year < 0 || month < 1 || month > 12 ||
89
89
  day < 1 || day > 31 || hour > 23 ||
90
- minute > 59 || second > 59
90
+ minute > 59 || second > 59 || microsecond > 999999
91
91
  ) {
92
92
  return 'Invalid Date';
93
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asab_webui_components",
3
- "version": "27.2.4",
3
+ "version": "27.3.2",
4
4
  "license": "BSD-3-Clause",
5
5
  "description": "TeskaLabs ASAB WebUI Components Library",
6
6
  "contributors": [
@@ -45,10 +45,10 @@
45
45
  "bootstrap": "^5.3.1",
46
46
  "bootstrap-icons": "^1.10.5",
47
47
  "date-fns": "^4.1.0",
48
- "i18next": "^25.4.2",
48
+ "i18next": "^25.5.2",
49
49
  "react": "^19.0.0",
50
50
  "react-dom": "^19.0.0",
51
- "react-i18next": "^15.7.3",
51
+ "react-i18next": "^16.0.0",
52
52
  "@microlink/react-json-view": "^1.26.2",
53
53
  "react-router": "^7.8.2",
54
54
  "reactstrap": "^9.2.0"