asab_webui_components 25.3.2 → 25.3.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.
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.DateTime = DateTime;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _timeToString = _interopRequireDefault(require("./timeToString.js"));
9
+ var _getFormattedTime = _interopRequireDefault(require("./getFormattedTime.js"));
10
10
  var _useDateFNSLocale = _interopRequireDefault(require("../utils/useDateFNSLocale.js"));
11
11
  var _InvalidDate = require("../components/InvalidDate.js");
12
12
  // Component that displays the absolute time and shows the relative time on hover
@@ -19,9 +19,9 @@ function DateTime(props) {
19
19
 
20
20
  // Declaration of locale must be below span returned for `undefined` values to avoid bad react state handling in useDateFNSLocale
21
21
  var locale = (0, _useDateFNSLocale.default)();
22
- var date = (0, _timeToString.default)(props.value, props.dateTimeFormat, locale);
22
+ var date = (0, _getFormattedTime.default)(props.value, props.dateTimeFormat, locale);
23
23
 
24
- // Check for invalid date from timeToString method
24
+ // Check for invalid date from getFormattedTime method
25
25
  if (date.date === 'Invalid Date') {
26
26
  return /*#__PURE__*/_react.default.createElement(_InvalidDate.InvalidDate, {
27
27
  value: props.value
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import timeToString from './timeToString.js';
3
+ import getFormattedTime from './getFormattedTime.js';
4
4
  import useDateFNSLocale from '../utils/useDateFNSLocale.js';
5
5
  import { InvalidDate } from '../components/InvalidDate.jsx';
6
6
 
@@ -15,9 +15,9 @@ export function DateTime(props) {
15
15
  // Declaration of locale must be below span returned for `undefined` values to avoid bad react state handling in useDateFNSLocale
16
16
  const locale = useDateFNSLocale();
17
17
 
18
- const date = timeToString(props.value, props.dateTimeFormat, locale);
18
+ const date = getFormattedTime(props.value, props.dateTimeFormat, locale);
19
19
 
20
- // Check for invalid date from timeToString method
20
+ // Check for invalid date from getFormattedTime method
21
21
  if (date.date === 'Invalid Date') {
22
22
  return (
23
23
  <InvalidDate value={props.value} />
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFormattedTime = exports.default = void 0;
7
+ var _timeToStringCommon = require("../utils/timeToStringCommon.js");
8
+ var _timeFormatDefaults = require("../utils/timeFormatDefaults.js");
9
+ // Absolute time formatting with 'ago'
10
+ var getFormattedTime = exports.getFormattedTime = function getFormattedTime(value) {
11
+ var dateTimeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _timeFormatDefaults.DEFAULT_DATE_FORMAT;
12
+ var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _timeFormatDefaults.DEFAULT_LOCALE;
13
+ var {
14
+ date,
15
+ distanceToNow
16
+ } = (0, _timeToStringCommon.timeToStringCommon)(value, dateTimeFormat, locale, true); // addSuffix = true
17
+ if (date === 'Invalid Date') {
18
+ return {
19
+ date
20
+ };
21
+ }
22
+ return {
23
+ date,
24
+ distanceToNow
25
+ };
26
+ };
27
+ var _default = exports.default = getFormattedTime;
@@ -1,26 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.timeToString = exports.default = void 0;
7
- var _timeToStringCommon = require("../utils/timeToStringCommon.js");
8
- // Absolute time formatting with "ago"
8
+ var _getFormattedTime = _interopRequireDefault(require("./getFormattedTime.js"));
9
+ var _timeFormatDefaults = require("../utils/timeFormatDefaults.js");
10
+ // Simplifies original timeToString
9
11
  var timeToString = exports.timeToString = function timeToString(value) {
10
- var dateTimeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "medium";
11
- var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
12
- var {
13
- date,
14
- distanceToNow
15
- } = (0, _timeToStringCommon.timeToStringCommon)(value, dateTimeFormat, locale, true); // addSuffix = true
16
- if (date === 'Invalid Date') {
17
- return {
18
- date
19
- };
20
- }
21
- return {
22
- date,
23
- distanceToNow
24
- };
12
+ var dateTimeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _timeFormatDefaults.DEFAULT_DATE_FORMAT;
13
+ var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _timeFormatDefaults.DEFAULT_LOCALE;
14
+ var result = (0, _getFormattedTime.default)(value, dateTimeFormat, locale);
15
+ return result.date;
25
16
  };
26
17
  var _default = exports.default = timeToString;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.DateTimeRelative = DateTimeRelative;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _timeToStringRelative = require("./timeToStringRelative.js");
9
+ var _getFormattedTimeRelative = require("./getFormattedTimeRelative.js");
10
10
  var _useDateFNSLocale = _interopRequireDefault(require("../utils/useDateFNSLocale"));
11
11
  var _InvalidDate = require("../components/InvalidDate.js");
12
12
  // Component that displays the relative time and shows the absolute time on hover
@@ -19,9 +19,9 @@ function DateTimeRelative(props) {
19
19
 
20
20
  // Declaration of locale must be below span returned for `undefined` values to avoid bad react state handling in useDateFNSLocale
21
21
  var locale = (0, _useDateFNSLocale.default)();
22
- var date = (0, _timeToStringRelative.timeToStringRelative)(props.value, props.dateTimeFormat, props.addSuffix, locale);
22
+ var date = (0, _getFormattedTimeRelative.getFormattedTimeRelative)(props.value, props.dateTimeFormat, props.addSuffix, locale);
23
23
 
24
- // Check for invalid date from timeToString method
24
+ // Check for invalid date from getFormattedTimeRelative method
25
25
  if (date.date === 'Invalid Date') {
26
26
  return /*#__PURE__*/_react.default.createElement(_InvalidDate.InvalidDate, {
27
27
  value: props.value
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { timeToStringRelative } from './timeToStringRelative.jsx';
3
+ import { getFormattedTimeRelative } from './getFormattedTimeRelative.jsx';
4
4
  import useDateFNSLocale from '../utils/useDateFNSLocale';
5
5
  import { InvalidDate } from '../components/InvalidDate.jsx';
6
6
 
@@ -15,9 +15,9 @@ export function DateTimeRelative(props) {
15
15
  // Declaration of locale must be below span returned for `undefined` values to avoid bad react state handling in useDateFNSLocale
16
16
  const locale = useDateFNSLocale();
17
17
 
18
- const date = timeToStringRelative(props.value, props.dateTimeFormat, props.addSuffix, locale);
18
+ const date = getFormattedTimeRelative(props.value, props.dateTimeFormat, props.addSuffix, locale);
19
19
 
20
- // Check for invalid date from timeToString method
20
+ // Check for invalid date from getFormattedTimeRelative method
21
21
  if (date.date === 'Invalid Date') {
22
22
  return (
23
23
  <InvalidDate value={props.value} />
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFormattedTimeRelative = void 0;
7
+ var _timeToStringCommon = require("../utils/timeToStringCommon.js");
8
+ var _timeFormatDefaults = require("../utils/timeFormatDefaults.js");
9
+ // Relative time formatting without 'ago'
10
+ var getFormattedTimeRelative = exports.getFormattedTimeRelative = function getFormattedTimeRelative(value) {
11
+ var dateTimeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _timeFormatDefaults.DEFAULT_DATE_FORMAT;
12
+ var addSuffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
13
+ var locale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _timeFormatDefaults.DEFAULT_LOCALE;
14
+ // TODO: add addSuffix = true for values which are to the future from now (we can use of isAfter from date-fns)
15
+ var {
16
+ date,
17
+ distanceToNow
18
+ } = (0, _timeToStringCommon.timeToStringCommon)(value, dateTimeFormat, locale, addSuffix);
19
+ if (date === 'Invalid Date') {
20
+ return {
21
+ date
22
+ };
23
+ }
24
+ return {
25
+ date: distanceToNow,
26
+ absoluteTime: date
27
+ };
28
+ };
@@ -0,0 +1,12 @@
1
+ import { timeToStringCommon } from '../utils/timeToStringCommon.jsx';
2
+ import { DEFAULT_DATE_FORMAT, DEFAULT_LOCALE } from '../utils/timeFormatDefaults.js'
3
+
4
+ // Relative time formatting without 'ago'
5
+ export const getFormattedTimeRelative = (value, dateTimeFormat = DEFAULT_DATE_FORMAT, addSuffix = false, locale = DEFAULT_LOCALE) => {
6
+ // TODO: add addSuffix = true for values which are to the future from now (we can use of isAfter from date-fns)
7
+ const { date, distanceToNow } = timeToStringCommon(value, dateTimeFormat, locale, addSuffix);
8
+ if (date === 'Invalid Date') {
9
+ return { date };
10
+ }
11
+ return { date: distanceToNow, absoluteTime: date };
12
+ }
@@ -4,24 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.timeToStringRelative = void 0;
7
- var _timeToStringCommon = require("../utils/timeToStringCommon.js");
8
- // Relative time formatting without "ago"
7
+ var _getFormattedTimeRelative = require("./getFormattedTimeRelative.js");
8
+ var _timeFormatDefaults = require("../utils/timeFormatDefaults.js");
9
+ // Simplifies original timeToStringRelative
9
10
  var timeToStringRelative = exports.timeToStringRelative = function timeToStringRelative(value) {
10
- var dateTimeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "medium";
11
+ var dateTimeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _timeFormatDefaults.DEFAULT_DATE_FORMAT;
11
12
  var addSuffix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
12
- var locale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
13
- // TODO: add addSuffix = true for values which are to the future from now (we can use of isAfter from date-fns)
14
- var {
15
- date,
16
- distanceToNow
17
- } = (0, _timeToStringCommon.timeToStringCommon)(value, dateTimeFormat, locale, addSuffix);
18
- if (date === 'Invalid Date') {
19
- return {
20
- date
21
- };
22
- }
23
- return {
24
- date: distanceToNow,
25
- absoluteTime: date
26
- };
13
+ var locale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _timeFormatDefaults.DEFAULT_LOCALE;
14
+ var result = (0, _getFormattedTimeRelative.getFormattedTimeRelative)(value, dateTimeFormat, addSuffix, locale);
15
+ return result.date;
27
16
  };
@@ -1,11 +1,8 @@
1
- import { timeToStringCommon } from '../utils/timeToStringCommon.jsx';
1
+ import { getFormattedTimeRelative } from './getFormattedTimeRelative.jsx';
2
+ import { DEFAULT_DATE_FORMAT, DEFAULT_LOCALE } from '../utils/timeFormatDefaults.js'
2
3
 
3
- // Relative time formatting without "ago"
4
- export const timeToStringRelative = (value, dateTimeFormat = "medium", addSuffix = false, locale = undefined) => {
5
- // TODO: add addSuffix = true for values which are to the future from now (we can use of isAfter from date-fns)
6
- const { date, distanceToNow } = timeToStringCommon(value, dateTimeFormat, locale, addSuffix);
7
- if (date === 'Invalid Date') {
8
- return { date };
9
- }
10
- return { date: distanceToNow, absoluteTime: date };
4
+ // Simplifies original timeToStringRelative
5
+ export const timeToStringRelative = (value, dateTimeFormat = DEFAULT_DATE_FORMAT, addSuffix = false, locale = DEFAULT_LOCALE) => {
6
+ const result = getFormattedTimeRelative(value, dateTimeFormat, addSuffix, locale);
7
+ return result.date;
11
8
  }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_LOCALE = exports.DEFAULT_DATE_FORMAT = void 0;
7
+ var DEFAULT_DATE_FORMAT = exports.DEFAULT_DATE_FORMAT = 'medium';
8
+ var DEFAULT_LOCALE = exports.DEFAULT_LOCALE = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asab_webui_components",
3
- "version": "25.3.2",
3
+ "version": "25.3.3",
4
4
  "license": "BSD-3-Clause",
5
5
  "description": "TeskaLabs ASAB WebUI Components Library",
6
6
  "contributors": [