@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.
- package/aquaui-sprites.svg +1 -1
- package/formatters/CountryFormatter/CountryFormatter.d.ts +25 -3
- package/formatters/CountryFormatter/CountryFormatter.js +24 -2
- package/formatters/DateTimeFormatter/DateTimeFormatter.d.ts +38 -9
- package/formatters/DateTimeFormatter/DateTimeFormatter.js +38 -9
- package/formatters/DivisionFormatter/DivisionFormatter.d.ts +28 -4
- package/formatters/DivisionFormatter/DivisionFormatter.js +25 -3
- package/formatters/FilesizeFormatter/FilesizeFormatter.d.ts +24 -8
- package/formatters/FilesizeFormatter/FilesizeFormatter.js +50 -31
- package/formatters/GIS/CoordinateFormatter.d.ts +58 -0
- package/formatters/GIS/CoordinateFormatter.js +51 -0
- package/formatters/GIS/LatitudeFormatter.d.ts +5 -4
- package/formatters/GIS/LatitudeFormatter.js +7 -11
- package/formatters/GIS/LongitudeFormatter.d.ts +9 -6
- package/formatters/GIS/LongitudeFormatter.js +11 -13
- package/formatters/GIS/index.d.ts +1 -0
- package/formatters/GIS/index.js +1 -0
- package/formatters/HighlightFormatter/HighlightFormatter.d.ts +26 -5
- package/formatters/HighlightFormatter/HighlightFormatter.js +26 -5
- package/formatters/HttpStatusFormatter/HttpStatusFormatter.d.ts +34 -14
- package/formatters/HttpStatusFormatter/HttpStatusFormatter.js +35 -16
- package/formatters/HumanFormatter/HumanFormatter.d.ts +24 -4
- package/formatters/HumanFormatter/HumanFormatter.js +37 -12
- package/formatters/NumberFormatter/NumberFormatter.d.ts +19 -6
- package/formatters/NumberFormatter/NumberFormatter.js +19 -6
- package/formatters/StringFormatter/StringFormatter.d.ts +22 -4
- package/formatters/StringFormatter/StringFormatter.js +21 -3
- package/map/layers/ParticlesLayer/ParticlesLayer.d.ts +97 -1
- package/map/layers/ParticlesLayer/ParticlesLayer.js +239 -38
- package/map/layers/ParticlesLayer/ParticlesVertexShader.d.ts +1 -1
- package/map/layers/ParticlesLayer/ParticlesVertexShader.js +1 -1
- package/map/layers/ParticlesLayer/PositionComputeFragmentShader.d.ts +2 -0
- package/map/layers/ParticlesLayer/PositionComputeFragmentShader.js +2 -0
- package/map/layers/ParticlesLayer/PositionComputeVertexShader.d.ts +2 -0
- package/map/layers/ParticlesLayer/PositionComputeVertexShader.js +2 -0
- package/package.json +1 -1
- package/services/Dialog/AlertDialog.d.ts +1 -1
- package/services/Dialog/ConfirmDialog.d.ts +5 -5
- package/services/Dialog/ConfirmDialog.js +1 -1
- package/services/Dialog/Dialog.d.ts +46 -16
- package/services/Dialog/Dialog.js +98 -16
- package/services/Dialog/DialogBackground.js +1 -0
- package/services/Dialog/DialogContent.d.ts +3 -3
- package/services/Dialog/DialogContent.js +1 -1
- package/services/Dialog/DialogFooter.d.ts +3 -3
- package/services/Dialog/DialogHeader.d.ts +3 -3
- package/services/Dialog/DialogWindow.d.ts +3 -4
- package/services/Dialog/DialogWindow.js +1 -0
- package/services/Dialog/XhrDialog.d.ts +1 -1
- package/services/Dialog/index.d.ts +7 -1
- package/svg/icons/index.d.ts +1 -0
- package/svg/icons/index.js +1 -0
|
@@ -1,46 +1,65 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Converts a byte count into a human-readable file size string with
|
|
4
|
+
* appropriate unit suffix.
|
|
5
5
|
*
|
|
6
|
-
* Supports
|
|
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
|
-
*
|
|
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}
|
|
12
|
-
* <FilesizeFormatter value={1048576} unit="binary" />
|
|
13
|
-
* <FilesizeFormatter value=
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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 (
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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 {
|
|
2
|
+
import { CoordinateFormatter } from './CoordinateFormatter';
|
|
3
3
|
/**
|
|
4
|
-
* Formats a fractional latitude value as degrees, minutes and seconds (
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
|
|
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 (
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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={
|
|
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 {
|
|
2
|
+
import { CoordinateFormatter } from './CoordinateFormatter';
|
|
3
3
|
/**
|
|
4
|
-
* Formats a fractional longitude value as degrees, minutes and seconds (
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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={
|
|
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
|
-
|
|
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 };
|
package/formatters/GIS/index.js
CHANGED
|
@@ -23,14 +23,35 @@ interface IHighlightFormatterProps {
|
|
|
23
23
|
color?: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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:
|
|
27
|
-
|
|
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
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
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 (
|
|
269
|
-
var status =
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
*
|
|
18
|
-
*
|
|
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}/>
|
|
22
|
-
* <HumanFormatter value={
|
|
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
|
-
*
|
|
4
|
-
*
|
|
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}/>
|
|
8
|
-
* <HumanFormatter value={
|
|
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
|
-
|
|
14
|
-
|
|
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 =
|
|
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';
|