@longline/aqua-ui 1.0.299 → 1.0.302

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.
Files changed (52) hide show
  1. package/aquaui-sprites.svg +1 -1
  2. package/formatters/CountryFormatter/CountryFormatter.d.ts +25 -3
  3. package/formatters/CountryFormatter/CountryFormatter.js +24 -2
  4. package/formatters/DateTimeFormatter/DateTimeFormatter.d.ts +38 -9
  5. package/formatters/DateTimeFormatter/DateTimeFormatter.js +38 -9
  6. package/formatters/DivisionFormatter/DivisionFormatter.d.ts +28 -4
  7. package/formatters/DivisionFormatter/DivisionFormatter.js +25 -3
  8. package/formatters/FilesizeFormatter/FilesizeFormatter.d.ts +24 -8
  9. package/formatters/FilesizeFormatter/FilesizeFormatter.js +50 -31
  10. package/formatters/GIS/CoordinateFormatter.d.ts +58 -0
  11. package/formatters/GIS/CoordinateFormatter.js +51 -0
  12. package/formatters/GIS/LatitudeFormatter.d.ts +5 -4
  13. package/formatters/GIS/LatitudeFormatter.js +7 -11
  14. package/formatters/GIS/LongitudeFormatter.d.ts +9 -6
  15. package/formatters/GIS/LongitudeFormatter.js +11 -13
  16. package/formatters/GIS/index.d.ts +1 -0
  17. package/formatters/GIS/index.js +1 -0
  18. package/formatters/HighlightFormatter/HighlightFormatter.d.ts +26 -5
  19. package/formatters/HighlightFormatter/HighlightFormatter.js +26 -5
  20. package/formatters/HttpStatusFormatter/HttpStatusFormatter.d.ts +34 -14
  21. package/formatters/HttpStatusFormatter/HttpStatusFormatter.js +35 -16
  22. package/formatters/HumanFormatter/HumanFormatter.d.ts +24 -4
  23. package/formatters/HumanFormatter/HumanFormatter.js +37 -12
  24. package/formatters/NumberFormatter/NumberFormatter.d.ts +19 -6
  25. package/formatters/NumberFormatter/NumberFormatter.js +19 -6
  26. package/formatters/StringFormatter/StringFormatter.d.ts +22 -4
  27. package/formatters/StringFormatter/StringFormatter.js +21 -3
  28. package/map/layers/ParticlesLayer/ParticlesLayer.d.ts +97 -1
  29. package/map/layers/ParticlesLayer/ParticlesLayer.js +239 -38
  30. package/map/layers/ParticlesLayer/ParticlesVertexShader.d.ts +1 -1
  31. package/map/layers/ParticlesLayer/ParticlesVertexShader.js +1 -1
  32. package/map/layers/ParticlesLayer/PositionComputeFragmentShader.d.ts +2 -0
  33. package/map/layers/ParticlesLayer/PositionComputeFragmentShader.js +2 -0
  34. package/map/layers/ParticlesLayer/PositionComputeVertexShader.d.ts +2 -0
  35. package/map/layers/ParticlesLayer/PositionComputeVertexShader.js +2 -0
  36. package/package.json +1 -1
  37. package/services/Dialog/AlertDialog.d.ts +1 -1
  38. package/services/Dialog/ConfirmDialog.d.ts +5 -5
  39. package/services/Dialog/ConfirmDialog.js +1 -1
  40. package/services/Dialog/Dialog.d.ts +46 -16
  41. package/services/Dialog/Dialog.js +98 -16
  42. package/services/Dialog/DialogBackground.js +1 -0
  43. package/services/Dialog/DialogContent.d.ts +3 -3
  44. package/services/Dialog/DialogContent.js +1 -1
  45. package/services/Dialog/DialogFooter.d.ts +3 -3
  46. package/services/Dialog/DialogHeader.d.ts +3 -3
  47. package/services/Dialog/DialogWindow.d.ts +3 -4
  48. package/services/Dialog/DialogWindow.js +1 -0
  49. package/services/Dialog/XhrDialog.d.ts +1 -1
  50. package/services/Dialog/index.d.ts +7 -1
  51. package/svg/icons/index.d.ts +1 -0
  52. package/svg/icons/index.js +1 -0
@@ -1,46 +1,65 @@
1
1
  import * as React from 'react';
2
2
  /**
3
- * `FilesizeFormatter` displays a human-readable file size string from a
4
- * number of bytes.
3
+ * Converts a byte count into a human-readable file size string with
4
+ * appropriate unit suffix.
5
5
  *
6
- * Supports SI (base 1000) and binary (base 1024) unit systems.
6
+ * Supports two unit systems:
7
+ * - **SI (default)**: Base 1000 (kB, MB, GB, TB, ...)
8
+ * - **Binary**: Base 1024 (KiB, MiB, GiB, TiB, ...)
7
9
  *
8
- * Localized formatting via `Intl.NumberFormat`.
10
+ * Use SI units for user-facing displays (matches how most operating systems
11
+ * report disk space). Use binary units for technical contexts where precise
12
+ * power-of-two values matter (e.g., RAM, disk sectors).
13
+ *
14
+ * ## Output Examples
15
+ *
16
+ * | Input | Props | Output |
17
+ * |-------|-------|--------|
18
+ * | `500` | (default) | `500 B` |
19
+ * | `10000` | (default) | `10 kB` |
20
+ * | `1048576` | `unit="binary"` | `1 MiB` |
21
+ * | `1500000000` | (default) | `1.5 GB` |
22
+ * | `1500000000` | `locale="de-DE"` | `1,5 GB` |
23
+ *
24
+ * ## Usage
9
25
  *
10
26
  * ```tsx
11
- * <FilesizeFormatter value={10000} unit="si" /> // "10.00 kB"
12
- * <FilesizeFormatter value={1048576} unit="binary" /> // "1.00 MiB"
13
- * <FilesizeFormatter value="2048000" locale="de-DE" /> // "2,05 MB"
27
+ * <FilesizeFormatter value={10000} />
28
+ * <FilesizeFormatter value={1048576} unit="binary" />
29
+ * <FilesizeFormatter value={2048000} locale="de-DE" />
14
30
  * ```
15
31
  */
16
32
  var FilesizeFormatter = function (_a) {
17
33
  var value = _a.value, _b = _a.unit, unit = _b === void 0 ? 'si' : _b, _c = _a.locale, locale = _c === void 0 ? 'en' : _c, _d = _a.decimals, decimals = _d === void 0 ? 2 : _d;
18
- if (value == null)
19
- return null;
20
- var num = typeof value === 'string' ? parseFloat(value) : value;
21
- if (isNaN(num))
22
- return null;
23
- var threshold = unit === 'si' ? 1000 : 1024;
24
- var units = unit === 'si'
25
- ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
26
- : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
27
- if (Math.abs(num) < threshold) {
28
- return "".concat(num, " B");
29
- }
30
- var size = num;
31
- var u = -1;
32
- do {
33
- size /= threshold;
34
- ++u;
35
- } while (Math.abs(size) >= threshold && u < units.length - 1);
36
- var formatter = new Intl.NumberFormat(locale, {
34
+ // Memoize the formatter to avoid creating a new instance on every render
35
+ var formatter = React.useMemo(function () { return new Intl.NumberFormat(locale, {
37
36
  maximumFractionDigits: decimals,
38
37
  minimumFractionDigits: 0,
39
- });
40
- return (React.createElement(React.Fragment, null,
41
- formatter.format(size),
42
- " ",
43
- units[u]));
38
+ }); }, [locale, decimals]);
39
+ var formatted = React.useMemo(function () {
40
+ if (value == null)
41
+ return null;
42
+ var num = typeof value === 'string' ? parseFloat(value) : value;
43
+ if (isNaN(num))
44
+ return null;
45
+ var threshold = unit === 'si' ? 1000 : 1024;
46
+ var units = unit === 'si'
47
+ ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
48
+ : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
49
+ if (Math.abs(num) < threshold) {
50
+ return "".concat(num, " B");
51
+ }
52
+ var size = num;
53
+ var u = -1;
54
+ do {
55
+ size /= threshold;
56
+ ++u;
57
+ } while (Math.abs(size) >= threshold && u < units.length - 1);
58
+ return "".concat(formatter.format(size), " ").concat(units[u]);
59
+ }, [value, unit, formatter]);
60
+ if (formatted === null)
61
+ return null;
62
+ return React.createElement(React.Fragment, null, formatted);
44
63
  };
45
64
  FilesizeFormatter.displayName = 'FilesizeFormatter';
46
65
  export { FilesizeFormatter };
@@ -0,0 +1,58 @@
1
+ import * as React from 'react';
2
+ interface ICoordinateFormatterProps {
3
+ /**
4
+ * Value to format.
5
+ */
6
+ value: number | string;
7
+ /**
8
+ * Type of coordinate: 'latitude' or 'longitude'.
9
+ * Latitude values must be between -90 and 90 degrees.
10
+ * Longitude values must be between -180 and 180 degrees.
11
+ */
12
+ type: 'latitude' | 'longitude';
13
+ /**
14
+ * String to show if formatting fails.
15
+ * @default "(no coordinates)"
16
+ */
17
+ defaultStr?: string;
18
+ }
19
+ /**
20
+ * Formats decimal coordinates as degrees, minutes, and seconds (DMS).
21
+ *
22
+ * Converts fractional latitude/longitude values to the traditional DMS
23
+ * notation used in navigation and cartography (e.g., `34° 13′ 18″ N`).
24
+ *
25
+ * ## Valid Ranges
26
+ *
27
+ * - **Latitude**: -90 to 90 (negative = South, positive = North)
28
+ * - **Longitude**: -180 to 180 (negative = West, positive = East)
29
+ *
30
+ * Values outside these ranges return the fallback string.
31
+ *
32
+ * ## Output Examples
33
+ *
34
+ * | Value | Type | Output |
35
+ * |-------|------|--------|
36
+ * | `34.2216` | `latitude` | 34° 13′ 18″ N |
37
+ * | `-34.2216` | `latitude` | 34° 13′ 18″ S |
38
+ * | `-118.4848` | `longitude` | 118° 29′ 05″ W |
39
+ * | `139.6917` | `longitude` | 139° 41′ 30″ E |
40
+ * | `null` | any | (no coordinates) |
41
+ *
42
+ * ## Usage
43
+ *
44
+ * ```tsx
45
+ * <CoordinateFormatter type="latitude" value={34.2216} />
46
+ * <CoordinateFormatter type="longitude" value={-118.4848} />
47
+ * <CoordinateFormatter type="latitude" value={null} defaultStr="N/A" />
48
+ * ```
49
+ *
50
+ * For convenience, you can also use the specialized wrappers:
51
+ * - `<LatitudeFormatter value={34.2216} />`
52
+ * - `<LongitudeFormatter value={-118.4848} />`
53
+ */
54
+ declare const CoordinateFormatter: {
55
+ ({ value, type, defaultStr }: ICoordinateFormatterProps): React.JSX.Element;
56
+ displayName: string;
57
+ };
58
+ export { CoordinateFormatter, ICoordinateFormatterProps };
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import { DMS } from '../../helper/DMS';
3
+ var COORDINATE_CONFIG = {
4
+ latitude: { max: 90, positive: 'N', negative: 'S' },
5
+ longitude: { max: 180, positive: 'E', negative: 'W' }
6
+ };
7
+ /**
8
+ * Formats decimal coordinates as degrees, minutes, and seconds (DMS).
9
+ *
10
+ * Converts fractional latitude/longitude values to the traditional DMS
11
+ * notation used in navigation and cartography (e.g., `34° 13′ 18″ N`).
12
+ *
13
+ * ## Valid Ranges
14
+ *
15
+ * - **Latitude**: -90 to 90 (negative = South, positive = North)
16
+ * - **Longitude**: -180 to 180 (negative = West, positive = East)
17
+ *
18
+ * Values outside these ranges return the fallback string.
19
+ *
20
+ * ## Output Examples
21
+ *
22
+ * | Value | Type | Output |
23
+ * |-------|------|--------|
24
+ * | `34.2216` | `latitude` | 34° 13′ 18″ N |
25
+ * | `-34.2216` | `latitude` | 34° 13′ 18″ S |
26
+ * | `-118.4848` | `longitude` | 118° 29′ 05″ W |
27
+ * | `139.6917` | `longitude` | 139° 41′ 30″ E |
28
+ * | `null` | any | (no coordinates) |
29
+ *
30
+ * ## Usage
31
+ *
32
+ * ```tsx
33
+ * <CoordinateFormatter type="latitude" value={34.2216} />
34
+ * <CoordinateFormatter type="longitude" value={-118.4848} />
35
+ * <CoordinateFormatter type="latitude" value={null} defaultStr="N/A" />
36
+ * ```
37
+ *
38
+ * For convenience, you can also use the specialized wrappers:
39
+ * - `<LatitudeFormatter value={34.2216} />`
40
+ * - `<LongitudeFormatter value={-118.4848} />`
41
+ */
42
+ var CoordinateFormatter = function (_a) {
43
+ var value = _a.value, type = _a.type, _b = _a.defaultStr, defaultStr = _b === void 0 ? "(no coordinates)" : _b;
44
+ var config = COORDINATE_CONFIG[type];
45
+ var formatted = React.useMemo(function () {
46
+ return DMS.toDMSString(value, defaultStr, config.max, config.positive, config.negative);
47
+ }, [value, defaultStr, config]);
48
+ return React.createElement(React.Fragment, null, formatted);
49
+ };
50
+ CoordinateFormatter.displayName = "CoordinateFormatter";
51
+ export { CoordinateFormatter };
@@ -11,13 +11,14 @@ interface ILatitudeFormatterProps {
11
11
  defaultStr?: string;
12
12
  }
13
13
  /**
14
- * Formats a fractional latitude value as degrees, minutes and seconds (as a
15
- * string). If provided with a string, `LatitudeFormatter` will convert it to
16
- * a number first. Returns the fallback string if formatting fails or value
17
- * is out of range.
14
+ * Formats a fractional latitude value as degrees, minutes and seconds (DMS format).
15
+ * If provided with a string, `LatitudeFormatter` will convert it to a number first.
16
+ * Returns the fallback string if formatting fails or value is out of range.
18
17
  *
19
18
  * Latitude value must be between -90 and 90 degrees.
20
19
  *
20
+ * This is a convenience wrapper around `CoordinateFormatter` with `type="latitude"`.
21
+ *
21
22
  * ```tsx
22
23
  * <LatitudeFormatter value={34.2216}/>
23
24
  * <LatitudeFormatter value={null} defaultStr="Invalid latitude"/>
@@ -1,13 +1,14 @@
1
1
  import * as React from 'react';
2
- import { DMS } from '../../helper/DMS';
2
+ import { CoordinateFormatter } from './CoordinateFormatter';
3
3
  /**
4
- * Formats a fractional latitude value as degrees, minutes and seconds (as a
5
- * string). If provided with a string, `LatitudeFormatter` will convert it to
6
- * a number first. Returns the fallback string if formatting fails or value
7
- * is out of range.
4
+ * Formats a fractional latitude value as degrees, minutes and seconds (DMS format).
5
+ * If provided with a string, `LatitudeFormatter` will convert it to a number first.
6
+ * Returns the fallback string if formatting fails or value is out of range.
8
7
  *
9
8
  * Latitude value must be between -90 and 90 degrees.
10
9
  *
10
+ * This is a convenience wrapper around `CoordinateFormatter` with `type="latitude"`.
11
+ *
11
12
  * ```tsx
12
13
  * <LatitudeFormatter value={34.2216}/>
13
14
  * <LatitudeFormatter value={null} defaultStr="Invalid latitude"/>
@@ -15,12 +16,7 @@ import { DMS } from '../../helper/DMS';
15
16
  */
16
17
  var LatitudeFormatter = function (_a) {
17
18
  var value = _a.value, _b = _a.defaultStr, defaultStr = _b === void 0 ? "(no coordinates)" : _b;
18
- // Value and defaultStr and mostly stable. Memoize the formatted string to
19
- // avoid unnecessary recalculations on every render.
20
- var formatted = React.useMemo(function () {
21
- return DMS.toDMSString(value, defaultStr, 90, "N", "S");
22
- }, [value, defaultStr]);
23
- return (React.createElement(React.Fragment, null, formatted));
19
+ return (React.createElement(CoordinateFormatter, { type: "latitude", value: value, defaultStr: defaultStr }));
24
20
  };
25
21
  LatitudeFormatter.displayName = "LatitudeFormatter";
26
22
  export { LatitudeFormatter };
@@ -11,15 +11,18 @@ interface ILongitudeFormatterProps {
11
11
  defaultStr?: string;
12
12
  }
13
13
  /**
14
- * Formats a fractional longitude value as degrees, minutes and seconds (as a
15
- * string). If provided with a string, `LongitudeFormatter` will convert it to
16
- * a number first. Returns the fallback string if formatting fails or value is
17
- * out of range.
14
+ * Formats a fractional longitude value as degrees, minutes and seconds (DMS format).
15
+ * If provided with a string, `LongitudeFormatter` will convert it to a number first.
16
+ * Returns the fallback string if formatting fails or value is out of range.
17
+ *
18
+ * Longitude value must be between -180 and 180 degrees.
19
+ *
20
+ * This is a convenience wrapper around `CoordinateFormatter` with `type="longitude"`.
18
21
  *
19
22
  * ```tsx
20
- * <LongitudeFormatter value={34.2216}/>
23
+ * <LongitudeFormatter value={-118.4848}/>
21
24
  * <LongitudeFormatter value={null} defaultStr="Invalid longitude"/>
22
- * ```*
25
+ * ```
23
26
  */
24
27
  declare const LongitudeFormatter: {
25
28
  ({ value, defaultStr }: ILongitudeFormatterProps): React.JSX.Element;
@@ -1,24 +1,22 @@
1
1
  import * as React from 'react';
2
- import { DMS } from '../../helper/DMS';
2
+ import { CoordinateFormatter } from './CoordinateFormatter';
3
3
  /**
4
- * Formats a fractional longitude value as degrees, minutes and seconds (as a
5
- * string). If provided with a string, `LongitudeFormatter` will convert it to
6
- * a number first. Returns the fallback string if formatting fails or value is
7
- * out of range.
4
+ * Formats a fractional longitude value as degrees, minutes and seconds (DMS format).
5
+ * If provided with a string, `LongitudeFormatter` will convert it to a number first.
6
+ * Returns the fallback string if formatting fails or value is out of range.
7
+ *
8
+ * Longitude value must be between -180 and 180 degrees.
9
+ *
10
+ * This is a convenience wrapper around `CoordinateFormatter` with `type="longitude"`.
8
11
  *
9
12
  * ```tsx
10
- * <LongitudeFormatter value={34.2216}/>
13
+ * <LongitudeFormatter value={-118.4848}/>
11
14
  * <LongitudeFormatter value={null} defaultStr="Invalid longitude"/>
12
- * ```*
15
+ * ```
13
16
  */
14
17
  var LongitudeFormatter = function (_a) {
15
18
  var value = _a.value, _b = _a.defaultStr, defaultStr = _b === void 0 ? "(no coordinates)" : _b;
16
- // Value and defaultStr and mostly stable. Memoize the formatted string to
17
- // avoid unnecessary recalculations on every render.
18
- var formatted = React.useMemo(function () {
19
- return DMS.toDMSString(value, defaultStr, 180, "E", "W");
20
- }, [value, defaultStr]);
21
- return (React.createElement(React.Fragment, null, formatted));
19
+ return (React.createElement(CoordinateFormatter, { type: "longitude", value: value, defaultStr: defaultStr }));
22
20
  };
23
21
  LongitudeFormatter.displayName = "LongitudeFormatter";
24
22
  export { LongitudeFormatter };
@@ -1,2 +1,3 @@
1
+ export * from './CoordinateFormatter';
1
2
  export * from './LatitudeFormatter';
2
3
  export * from './LongitudeFormatter';
@@ -1,2 +1,3 @@
1
+ export * from './CoordinateFormatter';
1
2
  export * from './LatitudeFormatter';
2
3
  export * from './LongitudeFormatter';
@@ -23,14 +23,35 @@ interface IHighlightFormatterProps {
23
23
  color?: string;
24
24
  }
25
25
  /**
26
- * Given an input string and a search query, `HighlightFormatter` highlights
27
- * the first occurrence or all occurrences (if any) of the search query and
28
- * returns a styled string (as a `ReactNode`). By default, matching is
29
- * case-insensitive, but this can be changed with the `caseSensitive` prop.
26
+ * Highlights search query matches within a string using a `<mark>` element.
27
+ *
28
+ * Useful for search result displays, autocomplete suggestions, or any UI
29
+ * where users need to see where their search term appears in text.
30
+ *
31
+ * By default, only the first match is highlighted and matching is
32
+ * case-insensitive. Special regex characters in the query are escaped
33
+ * automatically.
34
+ *
35
+ * ## Behavior
36
+ *
37
+ * - **No match**: Returns the original string unchanged
38
+ * - **Empty query**: Returns the original string unchanged
39
+ * - **Default color**: Uses theme's accent color for highlighting
40
+ *
41
+ * ## Usage
30
42
  *
31
43
  * ```tsx
32
- * <HighlightFormatter value="Hello, world" q="hello"/>
44
+ * // Basic (case-insensitive, first match only)
45
+ * <HighlightFormatter value="Hello, world" q="hello" />
46
+ *
47
+ * // Case-sensitive matching
33
48
  * <HighlightFormatter value="Hello, world" q="Hello" caseSensitive />
49
+ *
50
+ * // Highlight all occurrences
51
+ * <HighlightFormatter value="foo bar foo" q="foo" matchAll />
52
+ *
53
+ * // Custom highlight color
54
+ * <HighlightFormatter value="Important text" q="important" color="#ffeb3b" />
34
55
  * ```
35
56
  */
36
57
  declare const HighlightFormatter: {
@@ -1,14 +1,35 @@
1
1
  import * as React from 'react';
2
2
  import { useTheme } from 'styled-components';
3
3
  /**
4
- * Given an input string and a search query, `HighlightFormatter` highlights
5
- * the first occurrence or all occurrences (if any) of the search query and
6
- * returns a styled string (as a `ReactNode`). By default, matching is
7
- * case-insensitive, but this can be changed with the `caseSensitive` prop.
4
+ * Highlights search query matches within a string using a `<mark>` element.
5
+ *
6
+ * Useful for search result displays, autocomplete suggestions, or any UI
7
+ * where users need to see where their search term appears in text.
8
+ *
9
+ * By default, only the first match is highlighted and matching is
10
+ * case-insensitive. Special regex characters in the query are escaped
11
+ * automatically.
12
+ *
13
+ * ## Behavior
14
+ *
15
+ * - **No match**: Returns the original string unchanged
16
+ * - **Empty query**: Returns the original string unchanged
17
+ * - **Default color**: Uses theme's accent color for highlighting
18
+ *
19
+ * ## Usage
8
20
  *
9
21
  * ```tsx
10
- * <HighlightFormatter value="Hello, world" q="hello"/>
22
+ * // Basic (case-insensitive, first match only)
23
+ * <HighlightFormatter value="Hello, world" q="hello" />
24
+ *
25
+ * // Case-sensitive matching
11
26
  * <HighlightFormatter value="Hello, world" q="Hello" caseSensitive />
27
+ *
28
+ * // Highlight all occurrences
29
+ * <HighlightFormatter value="foo bar foo" q="foo" matchAll />
30
+ *
31
+ * // Custom highlight color
32
+ * <HighlightFormatter value="Important text" q="important" color="#ffeb3b" />
12
33
  * ```
13
34
  */
14
35
  var HighlightFormatter = function (_a) {
@@ -1,4 +1,5 @@
1
- interface IProps {
1
+ import * as React from 'react';
2
+ interface IHttpStatusFormatterProps {
2
3
  /**
3
4
  * HTTP status code, e.g. 503
4
5
  */
@@ -11,17 +12,36 @@ interface IProps {
11
12
  type?: 'title' | 'description';
12
13
  }
13
14
  /**
14
- * This formatter converts a HTTP status code to either a short title
15
- * (e.g. status 503 would be "Service unavailable") or a long description
16
- * (e.g. status 503 would be "The server is not ready to handle the request.
17
- * Common causes are a server that is down for maintenance or that is
18
- * overloaded. Note that together with this response, a user-friendly page
19
- * explaining the problem should be sent. This response should be used for
20
- * temporary conditions and the Retry-After HTTP header should, if possible,
21
- * contain the estimated time before the recovery of the service. The
22
- * webmaster must also take care about the caching-related headers that are
23
- * sent along with this response, as these temporary condition responses
24
- * should usually not be cached.").
15
+ * Converts an HTTP status code to a human-readable title or description.
16
+ *
17
+ * Useful for displaying user-friendly error messages in API response
18
+ * handlers, error boundaries, or status dashboards.
19
+ *
20
+ * Supports all standard HTTP status codes (1xx-5xx). Unknown codes
21
+ * return "Unknown error".
22
+ *
23
+ * ## Output Examples
24
+ *
25
+ * | status | type | Output |
26
+ * |--------|------|--------|
27
+ * | `200` | `title` | OK |
28
+ * | `404` | `title` | Resource not found |
29
+ * | `404` | `description` | The requested resource could not be found on the server. |
30
+ * | `500` | `title` | Internal server error |
31
+ * | `503` | `title` | Service unavailable |
32
+ *
33
+ * ## Usage
34
+ *
35
+ * ```tsx
36
+ * // Short title (default)
37
+ * <HttpStatusFormatter status={404} />
38
+ *
39
+ * // Full description
40
+ * <HttpStatusFormatter status={503} type="description" />
41
+ * ```
25
42
  */
26
- declare const HttpStatusFormatter: (props: IProps) => string;
27
- export { HttpStatusFormatter };
43
+ declare const HttpStatusFormatter: {
44
+ ({ status, type }: IHttpStatusFormatterProps): React.JSX.Element;
45
+ displayName: string;
46
+ };
47
+ export { HttpStatusFormatter, IHttpStatusFormatterProps };
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  var HttpStatusCodes = {
2
3
  100: {
3
4
  header: "Continue",
@@ -253,22 +254,40 @@ var HttpStatusCodes = {
253
254
  }
254
255
  };
255
256
  /**
256
- * This formatter converts a HTTP status code to either a short title
257
- * (e.g. status 503 would be "Service unavailable") or a long description
258
- * (e.g. status 503 would be "The server is not ready to handle the request.
259
- * Common causes are a server that is down for maintenance or that is
260
- * overloaded. Note that together with this response, a user-friendly page
261
- * explaining the problem should be sent. This response should be used for
262
- * temporary conditions and the Retry-After HTTP header should, if possible,
263
- * contain the estimated time before the recovery of the service. The
264
- * webmaster must also take care about the caching-related headers that are
265
- * sent along with this response, as these temporary condition responses
266
- * should usually not be cached.").
257
+ * Converts an HTTP status code to a human-readable title or description.
258
+ *
259
+ * Useful for displaying user-friendly error messages in API response
260
+ * handlers, error boundaries, or status dashboards.
261
+ *
262
+ * Supports all standard HTTP status codes (1xx-5xx). Unknown codes
263
+ * return "Unknown error".
264
+ *
265
+ * ## Output Examples
266
+ *
267
+ * | status | type | Output |
268
+ * |--------|------|--------|
269
+ * | `200` | `title` | OK |
270
+ * | `404` | `title` | Resource not found |
271
+ * | `404` | `description` | The requested resource could not be found on the server. |
272
+ * | `500` | `title` | Internal server error |
273
+ * | `503` | `title` | Service unavailable |
274
+ *
275
+ * ## Usage
276
+ *
277
+ * ```tsx
278
+ * // Short title (default)
279
+ * <HttpStatusFormatter status={404} />
280
+ *
281
+ * // Full description
282
+ * <HttpStatusFormatter status={503} type="description" />
283
+ * ```
267
284
  */
268
- var HttpStatusFormatter = function (props) {
269
- var status = HttpStatusCodes[props.status];
270
- if (!status)
271
- return "Unknown error";
272
- return props.type === 'description' ? status.desc : status.header;
285
+ var HttpStatusFormatter = function (_a) {
286
+ var status = _a.status, _b = _a.type, type = _b === void 0 ? 'title' : _b;
287
+ var statusInfo = HttpStatusCodes[status];
288
+ if (!statusInfo)
289
+ return React.createElement(React.Fragment, null, "Unknown error");
290
+ return React.createElement(React.Fragment, null, type === 'description' ? statusInfo.desc : statusInfo.header);
273
291
  };
292
+ HttpStatusFormatter.displayName = 'HttpStatusFormatter';
274
293
  export { HttpStatusFormatter };
@@ -14,12 +14,32 @@ interface IHumanFormatterProps {
14
14
  decimals?: number;
15
15
  }
16
16
  /**
17
- * `HumanFormatter` formats large numbers using `Intl.NumberFormat` for
18
- * locale-aware output and optional compact display (e.g. "10K", "1.2M").
17
+ * Abbreviates large numbers using compact notation (K, M, B, etc.).
18
+ *
19
+ * Use `HumanFormatter` for dashboard metrics, social media counts, or any
20
+ * context where approximate magnitude matters more than precision. For
21
+ * exact values with thousands separators, use `NumberFormatter` instead.
22
+ *
23
+ * Compact notation is locale-aware: German uses "Mio." for millions,
24
+ * while English uses "M".
25
+ *
26
+ * ## Output Examples
27
+ *
28
+ * | Input | Props | Output |
29
+ * |-------|-------|--------|
30
+ * | `999` | (default) | `999` |
31
+ * | `1200` | (default) | `1K` |
32
+ * | `1200` | `decimals={1}` | `1.2K` |
33
+ * | `1500000` | (default) | `2M` |
34
+ * | `1500000` | `locale="de-DE"` | `2 Mio.` |
35
+ * | `2500000000` | (default) | `3B` |
36
+ *
37
+ * ## Usage
19
38
  *
20
39
  * ```tsx
21
- * <HumanFormatter value={1200}/> // => "1.2K"
22
- * <HumanFormatter value={999999} locale="de-DE" /> // => "1 Mio."
40
+ * <HumanFormatter value={1200} />
41
+ * <HumanFormatter value={1500000} decimals={1} />
42
+ * <HumanFormatter value={999999} locale="de-DE" />
23
43
  * ```
24
44
  */
25
45
  declare const HumanFormatter: {
@@ -1,25 +1,50 @@
1
1
  import * as React from 'react';
2
2
  /**
3
- * `HumanFormatter` formats large numbers using `Intl.NumberFormat` for
4
- * locale-aware output and optional compact display (e.g. "10K", "1.2M").
3
+ * Abbreviates large numbers using compact notation (K, M, B, etc.).
4
+ *
5
+ * Use `HumanFormatter` for dashboard metrics, social media counts, or any
6
+ * context where approximate magnitude matters more than precision. For
7
+ * exact values with thousands separators, use `NumberFormatter` instead.
8
+ *
9
+ * Compact notation is locale-aware: German uses "Mio." for millions,
10
+ * while English uses "M".
11
+ *
12
+ * ## Output Examples
13
+ *
14
+ * | Input | Props | Output |
15
+ * |-------|-------|--------|
16
+ * | `999` | (default) | `999` |
17
+ * | `1200` | (default) | `1K` |
18
+ * | `1200` | `decimals={1}` | `1.2K` |
19
+ * | `1500000` | (default) | `2M` |
20
+ * | `1500000` | `locale="de-DE"` | `2 Mio.` |
21
+ * | `2500000000` | (default) | `3B` |
22
+ *
23
+ * ## Usage
5
24
  *
6
25
  * ```tsx
7
- * <HumanFormatter value={1200}/> // => "1.2K"
8
- * <HumanFormatter value={999999} locale="de-DE" /> // => "1 Mio."
26
+ * <HumanFormatter value={1200} />
27
+ * <HumanFormatter value={1500000} decimals={1} />
28
+ * <HumanFormatter value={999999} locale="de-DE" />
9
29
  * ```
10
30
  */
11
31
  var HumanFormatter = function (_a) {
12
32
  var value = _a.value, _b = _a.locale, locale = _b === void 0 ? 'en' : _b, _c = _a.decimals, decimals = _c === void 0 ? 0 : _c;
13
- if (value == null)
14
- return null;
15
- var num = typeof value === 'string' ? parseFloat(value) : value;
16
- if (isNaN(num))
17
- return null;
18
- var formatOptions = {
33
+ // Memoize the formatter to avoid creating a new instance on every render
34
+ var formatter = React.useMemo(function () { return new Intl.NumberFormat(locale, {
19
35
  notation: 'compact',
20
36
  maximumFractionDigits: decimals
21
- };
22
- var formatted = new Intl.NumberFormat(locale, formatOptions).format(num);
37
+ }); }, [locale, decimals]);
38
+ var formatted = React.useMemo(function () {
39
+ if (value == null)
40
+ return null;
41
+ var num = typeof value === 'string' ? parseFloat(value) : value;
42
+ if (isNaN(num))
43
+ return null;
44
+ return formatter.format(num);
45
+ }, [value, formatter]);
46
+ if (formatted === null)
47
+ return null;
23
48
  return React.createElement(React.Fragment, null, formatted);
24
49
  };
25
50
  HumanFormatter.displayName = 'HumanFormatter';