@longline/aqua-ui 1.0.300 → 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/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
|
@@ -13,11 +13,33 @@ interface ICountryFormatterProps {
|
|
|
13
13
|
type?: 'flag' | 'name' | 'both';
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Displays a country as an emoji flag, name, or both.
|
|
17
|
+
*
|
|
18
|
+
* Accepts either an ISO 3166-1 alpha-2 country code (e.g., `"FR"`, `"US"`)
|
|
19
|
+
* or a country name (e.g., `"France"`, `"United States"`). The formatter
|
|
20
|
+
* will look up the corresponding flag and/or name.
|
|
21
|
+
*
|
|
22
|
+
* Flags are rendered using the "Twemoji Country Flags" font for consistent
|
|
23
|
+
* cross-platform appearance.
|
|
24
|
+
*
|
|
25
|
+
* ## Output Types
|
|
26
|
+
*
|
|
27
|
+
* | Type | Input | Output |
|
|
28
|
+
* |------|-------|--------|
|
|
29
|
+
* | `both` (default) | `"FR"` | 🇫🇷 France |
|
|
30
|
+
* | `flag` | `"FR"` | 🇫🇷 |
|
|
31
|
+
* | `name` | `"FR"` | France |
|
|
32
|
+
*
|
|
33
|
+
* ## Usage
|
|
34
|
+
*
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <CountryFormatter value="FR" />
|
|
37
|
+
* <CountryFormatter value="France" type="flag" />
|
|
38
|
+
* <CountryFormatter value="US" type="name" />
|
|
39
|
+
* ```
|
|
18
40
|
*/
|
|
19
41
|
declare const CountryFormatter: {
|
|
20
42
|
({ value, type }: ICountryFormatterProps): React.JSX.Element;
|
|
21
43
|
displayName: string;
|
|
22
44
|
};
|
|
23
|
-
export { CountryFormatter };
|
|
45
|
+
export { CountryFormatter, ICountryFormatterProps };
|
|
@@ -6,8 +6,30 @@ import * as React from 'react';
|
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import { CountryUtil } from './CountryUtil';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Displays a country as an emoji flag, name, or both.
|
|
10
|
+
*
|
|
11
|
+
* Accepts either an ISO 3166-1 alpha-2 country code (e.g., `"FR"`, `"US"`)
|
|
12
|
+
* or a country name (e.g., `"France"`, `"United States"`). The formatter
|
|
13
|
+
* will look up the corresponding flag and/or name.
|
|
14
|
+
*
|
|
15
|
+
* Flags are rendered using the "Twemoji Country Flags" font for consistent
|
|
16
|
+
* cross-platform appearance.
|
|
17
|
+
*
|
|
18
|
+
* ## Output Types
|
|
19
|
+
*
|
|
20
|
+
* | Type | Input | Output |
|
|
21
|
+
* |------|-------|--------|
|
|
22
|
+
* | `both` (default) | `"FR"` | 🇫🇷 France |
|
|
23
|
+
* | `flag` | `"FR"` | 🇫🇷 |
|
|
24
|
+
* | `name` | `"FR"` | France |
|
|
25
|
+
*
|
|
26
|
+
* ## Usage
|
|
27
|
+
*
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <CountryFormatter value="FR" />
|
|
30
|
+
* <CountryFormatter value="France" type="flag" />
|
|
31
|
+
* <CountryFormatter value="US" type="name" />
|
|
32
|
+
* ```
|
|
11
33
|
*/
|
|
12
34
|
var CountryFormatter = function (_a) {
|
|
13
35
|
var value = _a.value, _b = _a.type, type = _b === void 0 ? 'both' : _b;
|
|
@@ -25,22 +25,51 @@ interface IProps extends IDateTimeFormatterProps, IDateTimeFormatterAnimateProps
|
|
|
25
25
|
type?: 'longdate' | 'shortdate' | 'longdatetime' | 'shortdatetime' | 'longtime' | 'shorttime' | 'distance' | 'month' | Intl.DateTimeFormatOptions;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Formats dates and times using locale-aware preset formats or custom options.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* date/time. An input of `null` is not rendered at all.
|
|
30
|
+
* Accepts `Date` objects or ISO 8601 strings (e.g., `"2025-09-22T10:05:41Z"`).
|
|
31
|
+
* Invalid dates fall back to the current date/time; `null` renders nothing.
|
|
33
32
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* ## Preset Formats
|
|
34
|
+
*
|
|
35
|
+
* | Type | Example Output (en-US) |
|
|
36
|
+
* |------|------------------------|
|
|
37
|
+
* | `longdate` | September 22, 2025 |
|
|
38
|
+
* | `shortdate` | 9/22/2025 |
|
|
39
|
+
* | `longdatetime` | September 22, 2025 at 10:05 AM |
|
|
40
|
+
* | `shortdatetime` | 9/22/2025, 10:05 AM |
|
|
41
|
+
* | `longtime` | 10:05:41 AM |
|
|
42
|
+
* | `shorttime` | 10:05 AM |
|
|
43
|
+
* | `month` | September |
|
|
44
|
+
* | `distance` | 3 hours ago |
|
|
45
|
+
*
|
|
46
|
+
* ## Custom Formatting
|
|
47
|
+
*
|
|
48
|
+
* Pass an `Intl.DateTimeFormatOptions` object for full control:
|
|
36
49
|
*
|
|
37
50
|
* ```tsx
|
|
38
|
-
* <DateTimeFormatter
|
|
51
|
+
* <DateTimeFormatter
|
|
52
|
+
* value="2025-09-22"
|
|
53
|
+
* type={{ weekday: 'long', year: 'numeric' }}
|
|
54
|
+
* />
|
|
39
55
|
* ```
|
|
40
56
|
*
|
|
41
|
-
*
|
|
57
|
+
* ## Static Members
|
|
58
|
+
*
|
|
59
|
+
* For convenience, each format type is also available as a static component:
|
|
60
|
+
*
|
|
61
|
+
* ```tsx
|
|
62
|
+
* <DateTimeFormatter.LongDate value="2025-09-22" />
|
|
63
|
+
* <DateTimeFormatter.ShortTime value={new Date()} />
|
|
64
|
+
* <DateTimeFormatter.DistanceDate value={timestamp} animated />
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* ## Usage
|
|
68
|
+
*
|
|
42
69
|
* ```tsx
|
|
43
|
-
* <DateTimeFormatter
|
|
70
|
+
* <DateTimeFormatter type="longdate" value="1992-03-08" />
|
|
71
|
+
* <DateTimeFormatter type="shortdatetime" value={new Date()} locale="de-DE" />
|
|
72
|
+
* <DateTimeFormatter type="distance" value={timestamp} animated />
|
|
44
73
|
* ```
|
|
45
74
|
*/
|
|
46
75
|
declare const DateTimeFormatter: {
|
|
@@ -23,22 +23,51 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import * as React from 'react';
|
|
24
24
|
import { DistanceDate, LongDate, LongDateTime, LongTime, ShortDate, ShortDateTime, ShortTime, Month, Custom, } from './elements';
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Formats dates and times using locale-aware preset formats or custom options.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* date/time. An input of `null` is not rendered at all.
|
|
28
|
+
* Accepts `Date` objects or ISO 8601 strings (e.g., `"2025-09-22T10:05:41Z"`).
|
|
29
|
+
* Invalid dates fall back to the current date/time; `null` renders nothing.
|
|
31
30
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* ## Preset Formats
|
|
32
|
+
*
|
|
33
|
+
* | Type | Example Output (en-US) |
|
|
34
|
+
* |------|------------------------|
|
|
35
|
+
* | `longdate` | September 22, 2025 |
|
|
36
|
+
* | `shortdate` | 9/22/2025 |
|
|
37
|
+
* | `longdatetime` | September 22, 2025 at 10:05 AM |
|
|
38
|
+
* | `shortdatetime` | 9/22/2025, 10:05 AM |
|
|
39
|
+
* | `longtime` | 10:05:41 AM |
|
|
40
|
+
* | `shorttime` | 10:05 AM |
|
|
41
|
+
* | `month` | September |
|
|
42
|
+
* | `distance` | 3 hours ago |
|
|
43
|
+
*
|
|
44
|
+
* ## Custom Formatting
|
|
45
|
+
*
|
|
46
|
+
* Pass an `Intl.DateTimeFormatOptions` object for full control:
|
|
34
47
|
*
|
|
35
48
|
* ```tsx
|
|
36
|
-
* <DateTimeFormatter
|
|
49
|
+
* <DateTimeFormatter
|
|
50
|
+
* value="2025-09-22"
|
|
51
|
+
* type={{ weekday: 'long', year: 'numeric' }}
|
|
52
|
+
* />
|
|
37
53
|
* ```
|
|
38
54
|
*
|
|
39
|
-
*
|
|
55
|
+
* ## Static Members
|
|
56
|
+
*
|
|
57
|
+
* For convenience, each format type is also available as a static component:
|
|
58
|
+
*
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <DateTimeFormatter.LongDate value="2025-09-22" />
|
|
61
|
+
* <DateTimeFormatter.ShortTime value={new Date()} />
|
|
62
|
+
* <DateTimeFormatter.DistanceDate value={timestamp} animated />
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* ## Usage
|
|
66
|
+
*
|
|
40
67
|
* ```tsx
|
|
41
|
-
* <DateTimeFormatter
|
|
68
|
+
* <DateTimeFormatter type="longdate" value="1992-03-08" />
|
|
69
|
+
* <DateTimeFormatter type="shortdatetime" value={new Date()} locale="de-DE" />
|
|
70
|
+
* <DateTimeFormatter type="distance" value={timestamp} animated />
|
|
42
71
|
* ```
|
|
43
72
|
*/
|
|
44
73
|
var DateTimeFormatter = function (_a) {
|
|
@@ -6,8 +6,32 @@ interface IDivisionFormatterProps {
|
|
|
6
6
|
value: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Displays the full name of a country subdivision (state, province, region).
|
|
10
|
+
*
|
|
11
|
+
* Accepts an ISO 3166-2 subdivision code in the format `"XX-YY"` where `XX`
|
|
12
|
+
* is the country code and `YY` is the subdivision code. Returns the full
|
|
13
|
+
* name of the subdivision.
|
|
14
|
+
*
|
|
15
|
+
* ## Output Examples
|
|
16
|
+
*
|
|
17
|
+
* | Input | Output |
|
|
18
|
+
* |-------|--------|
|
|
19
|
+
* | `"US-CA"` | California |
|
|
20
|
+
* | `"US-NY"` | New York |
|
|
21
|
+
* | `"CA-NS"` | Nova Scotia |
|
|
22
|
+
* | `"CA-BC"` | British Columbia |
|
|
23
|
+
* | `"GB-ENG"` | England |
|
|
24
|
+
* | `"AU-NSW"` | New South Wales |
|
|
25
|
+
*
|
|
26
|
+
* ## Usage
|
|
27
|
+
*
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <DivisionFormatter value="US-CA" />
|
|
30
|
+
* <DivisionFormatter value="CA-NS" />
|
|
31
|
+
* ```
|
|
11
32
|
*/
|
|
12
|
-
declare const DivisionFormatter:
|
|
13
|
-
|
|
33
|
+
declare const DivisionFormatter: {
|
|
34
|
+
({ value }: IDivisionFormatterProps): React.JSX.Element;
|
|
35
|
+
displayName: string;
|
|
36
|
+
};
|
|
37
|
+
export { DivisionFormatter, IDivisionFormatterProps };
|
|
@@ -6,13 +6,35 @@ import * as React from 'react';
|
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import { DivisionUtil } from './DivisionUtil';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Displays the full name of a country subdivision (state, province, region).
|
|
10
|
+
*
|
|
11
|
+
* Accepts an ISO 3166-2 subdivision code in the format `"XX-YY"` where `XX`
|
|
12
|
+
* is the country code and `YY` is the subdivision code. Returns the full
|
|
13
|
+
* name of the subdivision.
|
|
14
|
+
*
|
|
15
|
+
* ## Output Examples
|
|
16
|
+
*
|
|
17
|
+
* | Input | Output |
|
|
18
|
+
* |-------|--------|
|
|
19
|
+
* | `"US-CA"` | California |
|
|
20
|
+
* | `"US-NY"` | New York |
|
|
21
|
+
* | `"CA-NS"` | Nova Scotia |
|
|
22
|
+
* | `"CA-BC"` | British Columbia |
|
|
23
|
+
* | `"GB-ENG"` | England |
|
|
24
|
+
* | `"AU-NSW"` | New South Wales |
|
|
25
|
+
*
|
|
26
|
+
* ## Usage
|
|
27
|
+
*
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <DivisionFormatter value="US-CA" />
|
|
30
|
+
* <DivisionFormatter value="CA-NS" />
|
|
31
|
+
* ```
|
|
11
32
|
*/
|
|
12
33
|
var DivisionFormatter = function (_a) {
|
|
13
34
|
var value = _a.value;
|
|
14
35
|
return React.createElement(Name, null, DivisionUtil.getDivisionName(value));
|
|
15
36
|
};
|
|
16
|
-
var Name = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n text-overflow: ellipsis;\n overflow: hidden
|
|
37
|
+
var Name = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n text-overflow: ellipsis;\n overflow: hidden;\n"], ["\n text-overflow: ellipsis;\n overflow: hidden;\n"])));
|
|
38
|
+
DivisionFormatter.displayName = 'DivisionFormatter';
|
|
17
39
|
export { DivisionFormatter };
|
|
18
40
|
var templateObject_1;
|
|
@@ -22,21 +22,37 @@ interface IFilesizeFormatterProps {
|
|
|
22
22
|
decimals?: number;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* Converts a byte count into a human-readable file size string with
|
|
26
|
+
* appropriate unit suffix.
|
|
27
27
|
*
|
|
28
|
-
* Supports
|
|
28
|
+
* Supports two unit systems:
|
|
29
|
+
* - **SI (default)**: Base 1000 (kB, MB, GB, TB, ...)
|
|
30
|
+
* - **Binary**: Base 1024 (KiB, MiB, GiB, TiB, ...)
|
|
29
31
|
*
|
|
30
|
-
*
|
|
32
|
+
* Use SI units for user-facing displays (matches how most operating systems
|
|
33
|
+
* report disk space). Use binary units for technical contexts where precise
|
|
34
|
+
* power-of-two values matter (e.g., RAM, disk sectors).
|
|
35
|
+
*
|
|
36
|
+
* ## Output Examples
|
|
37
|
+
*
|
|
38
|
+
* | Input | Props | Output |
|
|
39
|
+
* |-------|-------|--------|
|
|
40
|
+
* | `500` | (default) | `500 B` |
|
|
41
|
+
* | `10000` | (default) | `10 kB` |
|
|
42
|
+
* | `1048576` | `unit="binary"` | `1 MiB` |
|
|
43
|
+
* | `1500000000` | (default) | `1.5 GB` |
|
|
44
|
+
* | `1500000000` | `locale="de-DE"` | `1,5 GB` |
|
|
45
|
+
*
|
|
46
|
+
* ## Usage
|
|
31
47
|
*
|
|
32
48
|
* ```tsx
|
|
33
|
-
* <FilesizeFormatter value={10000}
|
|
34
|
-
* <FilesizeFormatter value={1048576} unit="binary" />
|
|
35
|
-
* <FilesizeFormatter value=
|
|
49
|
+
* <FilesizeFormatter value={10000} />
|
|
50
|
+
* <FilesizeFormatter value={1048576} unit="binary" />
|
|
51
|
+
* <FilesizeFormatter value={2048000} locale="de-DE" />
|
|
36
52
|
* ```
|
|
37
53
|
*/
|
|
38
54
|
declare const FilesizeFormatter: {
|
|
39
|
-
({ value, unit, locale, decimals, }: IFilesizeFormatterProps):
|
|
55
|
+
({ value, unit, locale, decimals, }: IFilesizeFormatterProps): React.JSX.Element;
|
|
40
56
|
displayName: string;
|
|
41
57
|
};
|
|
42
58
|
export { FilesizeFormatter, IFilesizeFormatterProps };
|
|
@@ -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