@longline/aqua-ui 1.0.183 → 1.0.186

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 (131) hide show
  1. package/containers/Dock/Dock.d.ts +7 -4
  2. package/containers/Dock/Dock.js +2 -1
  3. package/containers/Dock/Dockable.d.ts +14 -3
  4. package/containers/Dock/Dockable.js +45 -14
  5. package/containers/DragBar/DragBar.d.ts +4 -1
  6. package/containers/DragBar/DragBar.js +1 -0
  7. package/containers/GlassPane/GlassPane.d.ts +16 -4
  8. package/containers/GlassPane/GlassPane.js +41 -8
  9. package/containers/InfoBox/InfoBox.d.ts +23 -2
  10. package/containers/InfoBox/InfoBox.js +40 -2
  11. package/containers/InfoBox/elements/Content.d.ts +4 -1
  12. package/containers/InfoBox/elements/Content.js +1 -0
  13. package/containers/InfoBox/elements/Footer.d.ts +4 -1
  14. package/containers/InfoBox/elements/Footer.js +1 -0
  15. package/containers/InfoBox/elements/Header.d.ts +4 -1
  16. package/containers/InfoBox/elements/Header.js +2 -1
  17. package/containers/List/ListCell.d.ts +4 -1
  18. package/containers/List/ListCell.js +2 -1
  19. package/containers/List/ListRow.d.ts +4 -1
  20. package/containers/List/ListRow.js +2 -1
  21. package/containers/Message/Error.d.ts +4 -1
  22. package/containers/Message/Error.js +1 -0
  23. package/containers/Message/Message.d.ts +13 -3
  24. package/containers/Message/Message.js +2 -1
  25. package/containers/Message/NoData.d.ts +4 -1
  26. package/containers/Message/NoData.js +1 -0
  27. package/containers/Message/NoFilteredData.d.ts +4 -1
  28. package/containers/Message/NoFilteredData.js +1 -0
  29. package/controls/Chip/Chip.d.ts +7 -4
  30. package/controls/Chip/Chip.js +12 -12
  31. package/controls/Dropzone/Dropzone.d.ts +14 -10
  32. package/controls/Dropzone/Dropzone.js +88 -20
  33. package/controls/Fab/Fab.d.ts +7 -5
  34. package/controls/Fab/Fab.js +19 -18
  35. package/controls/FilterButton/FilterButton.d.ts +4 -5
  36. package/controls/FilterButton/FilterButton.js +11 -16
  37. package/controls/Gradient/Gradient.d.ts +8 -2
  38. package/controls/Gradient/Gradient.js +32 -6
  39. package/controls/Gradient/PresetGradients.d.ts +11 -4
  40. package/controls/Gradient/PresetGradients.js +7 -0
  41. package/controls/Icon/Icon.d.ts +7 -4
  42. package/controls/Icon/Icon.js +6 -5
  43. package/controls/Key/Key.d.ts +5 -2
  44. package/controls/Key/Key.js +36 -35
  45. package/controls/LinearChart/LinearChart.d.ts +4 -1
  46. package/controls/LinearChart/LinearChart.js +3 -2
  47. package/controls/ListView/ColumnsManager/ColumnsManager.js +1 -1
  48. package/controls/ListView/ListView.d.ts +2 -1
  49. package/controls/ListView/ListView.js +6 -5
  50. package/controls/ListView/NoData.d.ts +4 -1
  51. package/controls/ListView/NoData.js +1 -0
  52. package/controls/ListView/{Body.d.ts → elements/Body.d.ts} +2 -2
  53. package/controls/ListView/{Body.js → elements/Body.js} +1 -1
  54. package/controls/ListView/elements/Ghost.d.ts +12 -0
  55. package/controls/ListView/{Ghost.js → elements/Ghost.js} +4 -3
  56. package/controls/ListView/{Header.d.ts → elements/Header.d.ts} +2 -2
  57. package/controls/ListView/{Header.js → elements/Header.js} +3 -14
  58. package/controls/ListView/{HeaderButton.d.ts → elements/HeaderButton.d.ts} +4 -1
  59. package/controls/ListView/{HeaderButton.js → elements/HeaderButton.js} +1 -1
  60. package/controls/ListView/{HeaderCell.d.ts → elements/HeaderCell.d.ts} +7 -4
  61. package/controls/ListView/{HeaderCell.js → elements/HeaderCell.js} +5 -3
  62. package/controls/ListView/{SortButton.d.ts → elements/SortButton.d.ts} +1 -1
  63. package/controls/ListView/elements/SortButton.js +27 -0
  64. package/controls/ListView/{Table.d.ts → elements/Table.d.ts} +6 -3
  65. package/controls/ListView/{Table.js → elements/Table.js} +5 -4
  66. package/controls/ListView/{Total.d.ts → elements/Total.d.ts} +5 -1
  67. package/controls/ListView/{Total.js → elements/Total.js} +2 -1
  68. package/controls/Mouse/Mouse.d.ts +8 -3
  69. package/controls/Mouse/Mouse.js +21 -7
  70. package/controls/PrimaryButton/PrimaryButton.d.ts +6 -2
  71. package/controls/PrimaryButton/PrimaryButton.js +14 -9
  72. package/controls/Progress/Progress.d.ts +22 -6
  73. package/controls/Progress/Progress.js +38 -7
  74. package/controls/SecondaryButton/SecondaryButton.d.ts +12 -5
  75. package/controls/SecondaryButton/SecondaryButton.js +29 -19
  76. package/controls/TabBar/Tab.js +1 -1
  77. package/controls/TabBar/TabBar.d.ts +15 -4
  78. package/controls/TabBar/TabBar.js +105 -10
  79. package/controls/TabBar/Underliner.js +2 -1
  80. package/controls/TertiaryButton/TertiaryButton.d.ts +4 -1
  81. package/controls/TertiaryButton/TertiaryButton.js +3 -8
  82. package/controls/View/EllipsizedContent.d.ts +4 -1
  83. package/controls/View/EllipsizedContent.js +14 -1
  84. package/controls/View/ScrollingContent.d.ts +4 -1
  85. package/controls/View/ScrollingContent.js +14 -1
  86. package/controls/View/View.d.ts +6 -1
  87. package/controls/View/View.js +5 -4
  88. package/formatters/DateTime/DateTime.d.ts +46 -8
  89. package/formatters/DateTime/DateTime.js +14 -10
  90. package/formatters/DateTime/elements/Custom.d.ts +6 -17
  91. package/formatters/DateTime/elements/Custom.js +1 -0
  92. package/formatters/DateTime/elements/DistanceDate.d.ts +14 -0
  93. package/formatters/DateTime/elements/{Distance.js → DistanceDate.js} +1 -0
  94. package/formatters/DateTime/elements/LongDate.d.ts +23 -13
  95. package/formatters/DateTime/elements/LongDate.js +31 -5
  96. package/formatters/DateTime/elements/LongDateTime.d.ts +29 -13
  97. package/formatters/DateTime/elements/LongDateTime.js +28 -1
  98. package/formatters/DateTime/elements/LongTime.d.ts +25 -13
  99. package/formatters/DateTime/elements/LongTime.js +23 -1
  100. package/formatters/DateTime/elements/ShortDate.d.ts +27 -13
  101. package/formatters/DateTime/elements/ShortDate.js +28 -1
  102. package/formatters/DateTime/elements/ShortDateTime.d.ts +27 -13
  103. package/formatters/DateTime/elements/ShortDateTime.js +28 -1
  104. package/formatters/DateTime/elements/ShortTime.d.ts +13 -12
  105. package/formatters/DateTime/elements/ShortTime.js +19 -5
  106. package/formatters/DateTime/elements/index.d.ts +8 -0
  107. package/formatters/DateTime/elements/index.js +8 -0
  108. package/formatters/Filesize/Filesize.d.ts +23 -14
  109. package/formatters/Filesize/Filesize.js +33 -42
  110. package/formatters/GIS/Latitude.d.ts +11 -5
  111. package/formatters/GIS/Latitude.js +26 -3
  112. package/formatters/GIS/Longitude.d.ts +9 -5
  113. package/formatters/GIS/Longitude.js +24 -3
  114. package/formatters/Highlight/Highlight.d.ts +21 -6
  115. package/formatters/Highlight/Highlight.js +37 -19
  116. package/formatters/Human/Human.d.ts +18 -7
  117. package/formatters/Human/Human.js +17 -25
  118. package/formatters/Number/Number.d.ts +10 -2
  119. package/formatters/Number/Number.js +13 -7
  120. package/helper/DMS.d.ts +44 -6
  121. package/helper/DMS.js +86 -24
  122. package/package.json +1 -1
  123. package/controls/Dropzone/Dropbox.d.ts +0 -19
  124. package/controls/Dropzone/Dropbox.js +0 -47
  125. package/controls/ListView/Ghost.d.ts +0 -9
  126. package/controls/ListView/SortButton.js +0 -26
  127. package/formatters/DateTime/elements/Distance.d.ts +0 -24
  128. package/formatters/GIS/toDMS.d.ts +0 -2
  129. package/formatters/GIS/toDMS.js +0 -16
  130. /package/controls/ListView/{sortItems.d.ts → elements/sortItems.d.ts} +0 -0
  131. /package/controls/ListView/{sortItems.js → elements/sortItems.js} +0 -0
@@ -1,10 +1,37 @@
1
1
  import * as React from 'react';
2
2
  import { format } from 'date-fns';
3
3
  import { toDate } from './toDate';
4
+ /**
5
+ * `ShortDate` formats a date value into a short date string,
6
+ * using the format `dd-MM-yyyy` (e.g., `28-05-2025`).
7
+ *
8
+ * It shows a tooltip with the full date in a long, human-readable format,
9
+ * e.g., `"Wednesday, 28 May 2025"`.
10
+ *
11
+ * Accepts a `Date` object or a date string as `value`. Returns `null` if input
12
+ * is `null` or invalid.
13
+ *
14
+ * Optionally supports a `locale` prop that affects the date formatting and tooltip.
15
+ *
16
+ * The date is wrapped in a semantic `<time>` element with a machine-readable
17
+ * `dateTime` attribute.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <ShortDate value={new Date()} />
22
+ * <ShortDate value="2025-05-28" locale={someLocale} />
23
+ * ```
24
+ */
4
25
  var ShortDate = function (props) {
5
26
  if (props.value == null)
6
27
  return null;
7
28
  var date = toDate(props.value);
8
- return (React.createElement("span", { title: format(date, 'eeee, d MMMM yyyy', props.locale ? { locale: props.locale } : {}) }, format(date, 'dd-MM-yyyy', props.locale ? { locale: props.locale } : {})));
29
+ if (isNaN(date.getTime()))
30
+ return null;
31
+ var longDateFormat = 'eeee, d MMMM yyyy';
32
+ var shortDateFormat = 'dd-MM-yyyy';
33
+ var localeOption = props.locale ? { locale: props.locale } : {};
34
+ return (React.createElement("time", { dateTime: date.toISOString(), title: format(date, longDateFormat, localeOption) }, format(date, shortDateFormat, localeOption)));
9
35
  };
36
+ ShortDate.displayName = "DateTime.ShortDate";
10
37
  export { ShortDate };
@@ -1,14 +1,28 @@
1
1
  import * as React from 'react';
2
- import { Locale } from 'date-fns';
3
- interface IProps {
4
- /**
5
- * Date/time to format.
6
- */
7
- value: Date | string;
8
- /**
9
- * Optional locale.
10
- */
11
- locale?: Locale;
12
- }
13
- declare const ShortDateTime: (props: IProps) => React.JSX.Element;
14
- export { ShortDateTime, IProps };
2
+ import { IDateTimeProps } from '../DateTime';
3
+ /**
4
+ * `ShortDateTime` formats a date/time value as a short date and time string,
5
+ * using the format `dd-MM-yyyy HH:mm:ss` (e.g., `28-05-2025 14:30:45`).
6
+ *
7
+ * It displays a tooltip showing the full date/time in a long, human-readable format,
8
+ * e.g., `"Wednesday, 28 May 2025 14:30:45"`.
9
+ *
10
+ * Accepts a `Date` object or a date string as `value`. Returns `null` if input
11
+ * is `null` or invalid.
12
+ *
13
+ * Optionally supports a `locale` prop that affects the formatting and tooltip.
14
+ *
15
+ * The output is wrapped in a semantic `<time>` element with a machine-readable
16
+ * `dateTime` attribute.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * <ShortDateTime value={new Date()} />
21
+ * <ShortDateTime value="2025-05-28T14:30:45" locale={someLocale} />
22
+ * ```
23
+ */
24
+ declare const ShortDateTime: {
25
+ (props: IDateTimeProps): React.JSX.Element;
26
+ displayName: string;
27
+ };
28
+ export { ShortDateTime };
@@ -1,10 +1,37 @@
1
1
  import * as React from 'react';
2
2
  import { format } from 'date-fns';
3
3
  import { toDate } from './toDate';
4
+ /**
5
+ * `ShortDateTime` formats a date/time value as a short date and time string,
6
+ * using the format `dd-MM-yyyy HH:mm:ss` (e.g., `28-05-2025 14:30:45`).
7
+ *
8
+ * It displays a tooltip showing the full date/time in a long, human-readable format,
9
+ * e.g., `"Wednesday, 28 May 2025 14:30:45"`.
10
+ *
11
+ * Accepts a `Date` object or a date string as `value`. Returns `null` if input
12
+ * is `null` or invalid.
13
+ *
14
+ * Optionally supports a `locale` prop that affects the formatting and tooltip.
15
+ *
16
+ * The output is wrapped in a semantic `<time>` element with a machine-readable
17
+ * `dateTime` attribute.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <ShortDateTime value={new Date()} />
22
+ * <ShortDateTime value="2025-05-28T14:30:45" locale={someLocale} />
23
+ * ```
24
+ */
4
25
  var ShortDateTime = function (props) {
5
26
  if (props.value == null)
6
27
  return null;
7
28
  var date = toDate(props.value);
8
- return (React.createElement("span", { title: format(date, 'eeee, d MMMM yyyy HH:mm:ss', props.locale ? { locale: props.locale } : {}) }, format(date, 'dd-MM-yyyy HH:mm:ss', props.locale ? { locale: props.locale } : {})));
29
+ if (isNaN(date.getTime()))
30
+ return null;
31
+ var longDateTimeFormat = 'eeee, d MMMM yyyy HH:mm:ss';
32
+ var shortDateTimeFormat = 'dd-MM-yyyy HH:mm:ss';
33
+ var localeOption = props.locale ? { locale: props.locale } : {};
34
+ return (React.createElement("time", { dateTime: date.toISOString(), title: format(date, longDateTimeFormat, localeOption) }, format(date, shortDateTimeFormat, localeOption)));
9
35
  };
36
+ ShortDateTime.displayName = "DateTime.ShortDateTime";
10
37
  export { ShortDateTime };
@@ -1,18 +1,19 @@
1
1
  import * as React from 'react';
2
- import { Locale } from 'date-fns';
3
- interface IProps {
4
- /**
5
- * Time to format.
6
- */
7
- value: Date | string;
8
- /**
9
- * Optional locale.
10
- */
11
- locale?: Locale;
2
+ import { IDateTimeProps } from '../DateTime';
3
+ interface IShortTimeProps extends IDateTimeProps {
12
4
  /**
13
5
  * Seconds are shown if set.
14
6
  */
15
7
  seconds?: boolean;
16
8
  }
17
- declare const ShortTime: (props: IProps) => React.JSX.Element;
18
- export { ShortTime, IProps };
9
+ /**
10
+ * Formats a time value to a short string (HH:mm or HH:mm:ss).
11
+ * Supports optional locale and seconds display.
12
+ *
13
+ * ```tsx
14
+ * <ShortTime value={new Date()} />
15
+ * <ShortTime value="2023-05-28T14:30:00" seconds locale={someLocale} />
16
+ * ```
17
+ */
18
+ declare const ShortTime: React.MemoExoticComponent<({ value, locale, seconds }: IShortTimeProps) => React.JSX.Element>;
19
+ export { ShortTime, IShortTimeProps };
@@ -1,10 +1,24 @@
1
1
  import * as React from 'react';
2
2
  import { format } from 'date-fns';
3
3
  import { toDate } from './toDate';
4
- var ShortTime = function (props) {
5
- if (props.value == null)
4
+ /**
5
+ * Formats a time value to a short string (HH:mm or HH:mm:ss).
6
+ * Supports optional locale and seconds display.
7
+ *
8
+ * ```tsx
9
+ * <ShortTime value={new Date()} />
10
+ * <ShortTime value="2023-05-28T14:30:00" seconds locale={someLocale} />
11
+ * ```
12
+ */
13
+ var ShortTime = React.memo(function (_a) {
14
+ var value = _a.value, locale = _a.locale, _b = _a.seconds, seconds = _b === void 0 ? false : _b;
15
+ if (value == null)
6
16
  return null;
7
- var date = toDate(props.value);
8
- return (React.createElement("span", null, format(date, 'HH:mm')));
9
- };
17
+ var date = toDate(value);
18
+ if (isNaN(date.getTime()))
19
+ return null; // handle invalid dates gracefully
20
+ var formatString = seconds ? 'HH:mm:ss' : 'HH:mm';
21
+ return (React.createElement("span", null, format(date, formatString, { locale: locale })));
22
+ });
23
+ ShortTime.displayName = "DateTime.ShortTime";
10
24
  export { ShortTime };
@@ -0,0 +1,8 @@
1
+ export * from './ShortTime';
2
+ export * from './LongTime';
3
+ export * from './ShortDate';
4
+ export * from './LongDate';
5
+ export * from './ShortDateTime';
6
+ export * from './LongDateTime';
7
+ export * from './DistanceDate';
8
+ export * from './Custom';
@@ -0,0 +1,8 @@
1
+ export * from './ShortTime';
2
+ export * from './LongTime';
3
+ export * from './ShortDate';
4
+ export * from './LongDate';
5
+ export * from './ShortDateTime';
6
+ export * from './LongDateTime';
7
+ export * from './DistanceDate';
8
+ export * from './Custom';
@@ -1,29 +1,38 @@
1
1
  import * as React from 'react';
2
2
  interface IProps {
3
- /**
4
- * File size in bytes
5
- */
3
+ /** File size in bytes */
6
4
  value: number | string;
7
5
  /**
8
- * Unit type, `si` or `binary`
9
- * @default si
6
+ * Unit type, `si` (base 1000) or `binary` (base 1024)
7
+ * @default 'si'
10
8
  */
11
9
  unit?: 'si' | 'binary';
10
+ /**
11
+ * Optional locale string (e.g., 'en-US', 'fr-FR')
12
+ * @default 'en'
13
+ */
14
+ locale?: string;
15
+ /**
16
+ * Number of digits to show after decimal point
17
+ * @default 2
18
+ */
19
+ decimals?: number;
12
20
  }
13
21
  /**
14
- * Filesize takes a `value` prop (in bytes) and renders a human-readable filesize
15
- * string. If provided with a string, `Filesize` will convert it to a number
16
- * first.
22
+ * `Filesize` displays a human-readable file size string from a number of bytes.
17
23
  *
18
- * E.g. `10000` => `10.0 kB`
24
+ * Supports SI (base 1000) and binary (base 1024) unit systems.
19
25
  *
20
- * The `unit` type can optionally be specified, either `si` (International
21
- * System of Units, where 1 kilobyte is 1,000 byes), or `binary (where 1
22
- * kilobyte equals 1,024 bytes).
26
+ * Localized formatting via `Intl.NumberFormat`.
23
27
  *
24
28
  * ```tsx
25
- * <Filesize value={10000} unit='binary'/>
29
+ * <Filesize value={10000} unit="si" /> // "10.00 kB"
30
+ * <Filesize value={1048576} unit="binary" /> // "1.00 MiB"
31
+ * <Filesize value="2048000" locale="de-DE" /> // "2,05 MB"
26
32
  * ```
27
33
  */
28
- declare const Filesize: ({ unit, ...props }: IProps) => React.JSX.Element;
34
+ declare const Filesize: {
35
+ ({ value, unit, locale, decimals, }: IProps): string | React.JSX.Element;
36
+ displayName: string;
37
+ };
29
38
  export { Filesize, IProps };
@@ -1,54 +1,45 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import * as React from 'react';
13
2
  /**
14
- * Filesize takes a `value` prop (in bytes) and renders a human-readable filesize
15
- * string. If provided with a string, `Filesize` will convert it to a number
16
- * first.
3
+ * `Filesize` displays a human-readable file size string from a number of bytes.
17
4
  *
18
- * E.g. `10000` => `10.0 kB`
5
+ * Supports SI (base 1000) and binary (base 1024) unit systems.
19
6
  *
20
- * The `unit` type can optionally be specified, either `si` (International
21
- * System of Units, where 1 kilobyte is 1,000 byes), or `binary (where 1
22
- * kilobyte equals 1,024 bytes).
7
+ * Localized formatting via `Intl.NumberFormat`.
23
8
  *
24
9
  * ```tsx
25
- * <Filesize value={10000} unit='binary'/>
10
+ * <Filesize value={10000} unit="si" /> // "10.00 kB"
11
+ * <Filesize value={1048576} unit="binary" /> // "1.00 MiB"
12
+ * <Filesize value="2048000" locale="de-DE" /> // "2,05 MB"
26
13
  * ```
27
14
  */
28
15
  var Filesize = function (_a) {
29
- var _b = _a.unit, unit = _b === void 0 ? "si" : _b, props = __rest(_a, ["unit"]);
30
- /**
31
- * Convert bytes to size string (kB, MB, GB etc.)
32
- */
33
- var humanFileSize = function (bytes, unit) {
34
- var thresh = unit == 'si' ? 1000 : 1024;
35
- if (Math.abs(bytes) < thresh) {
36
- return bytes + ' B';
37
- }
38
- var units = unit == 'si'
39
- ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
40
- : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
41
- var u = -1;
42
- do {
43
- bytes /= thresh;
44
- ++u;
45
- } while (Math.abs(bytes) >= thresh && u < units.length - 1);
46
- return bytes.toFixed(2) + ' ' + units[u];
47
- };
48
- if (props.value == null)
16
+ 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;
17
+ if (value == null)
18
+ return null;
19
+ var num = typeof value === 'string' ? parseFloat(value) : value;
20
+ if (isNaN(num))
49
21
  return null;
50
- // Make sure value is a number.
51
- var val = (typeof props.value === 'string') ? parseFloat(props.value) : props.value;
52
- return (React.createElement(React.Fragment, null, humanFileSize(val, unit)));
22
+ var threshold = unit === 'si' ? 1000 : 1024;
23
+ var units = unit === 'si'
24
+ ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
25
+ : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
26
+ if (Math.abs(num) < threshold) {
27
+ return "".concat(num, " B");
28
+ }
29
+ var size = num;
30
+ var u = -1;
31
+ do {
32
+ size /= threshold;
33
+ ++u;
34
+ } while (Math.abs(size) >= threshold && u < units.length - 1);
35
+ var formatter = new Intl.NumberFormat(locale, {
36
+ maximumFractionDigits: decimals,
37
+ minimumFractionDigits: 0,
38
+ });
39
+ return (React.createElement(React.Fragment, null,
40
+ formatter.format(size),
41
+ " ",
42
+ units[u]));
53
43
  };
44
+ Filesize.displayName = 'Filesize';
54
45
  export { Filesize };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- interface IProps {
2
+ interface ILatitudeProps {
3
3
  /**
4
4
  * Value to format.
5
5
  */
@@ -8,16 +8,22 @@ interface IProps {
8
8
  * String to show if formatting fails.
9
9
  * @default "(no coordinates)"
10
10
  */
11
- default?: string;
11
+ defaultStr?: string;
12
12
  }
13
13
  /**
14
14
  * Formats a fractional latitude value as degrees, minutes and seconds (as a string).
15
15
  * If provided with a string, `Longitude` will convert it to a number first.
16
+ * Returns the fallback string if formatting fails or value is out of range.
17
+ *
18
+ * Latitude must be between -90 and 90 degrees.
16
19
  *
17
20
  * ```tsx
18
21
  * <Latitude value={34.2216}/>
19
- * <Latitude value={34.2216} default="Bad latitude"/>
22
+ * <Latitude value={null} defaultStr="Invalid latitude"/>
20
23
  * ```
21
24
  */
22
- declare const Latitude: (props: IProps) => React.JSX.Element;
23
- export { Latitude, IProps as ILatitudeProps };
25
+ declare const Latitude: {
26
+ ({ value, defaultStr, ...props }: ILatitudeProps): React.JSX.Element;
27
+ displayName: string;
28
+ };
29
+ export { Latitude, ILatitudeProps };
@@ -1,13 +1,36 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import * as React from 'react';
2
- import { toDMS } from "./toDMS";
13
+ import { DMS } from '../../helper/DMS';
3
14
  /**
4
15
  * Formats a fractional latitude value as degrees, minutes and seconds (as a string).
5
16
  * If provided with a string, `Longitude` will convert it to a number first.
17
+ * Returns the fallback string if formatting fails or value is out of range.
18
+ *
19
+ * Latitude must be between -90 and 90 degrees.
6
20
  *
7
21
  * ```tsx
8
22
  * <Latitude value={34.2216}/>
9
- * <Latitude value={34.2216} default="Bad latitude"/>
23
+ * <Latitude value={null} defaultStr="Invalid latitude"/>
10
24
  * ```
11
25
  */
12
- var Latitude = function (props) { return React.createElement(React.Fragment, null, toDMS(props.value, props.default, 90, "N", "S")); };
26
+ var Latitude = function (_a) {
27
+ var value = _a.value, _b = _a.defaultStr, defaultStr = _b === void 0 ? "(no coordinates)" : _b, props = __rest(_a, ["value", "defaultStr"]);
28
+ // Value and defaultStr and mostly stable. Memoize the formatted string to
29
+ // avoid unnecessary recalculations on every render.
30
+ var formatted = React.useMemo(function () {
31
+ return DMS.toDMSString(value, defaultStr, 90, "N", "S");
32
+ }, [value, defaultStr]);
33
+ return (React.createElement(React.Fragment, null, formatted));
34
+ };
35
+ Latitude.displayName = "Latitude";
13
36
  export { Latitude };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- interface IProps {
2
+ interface ILongitudeProps {
3
3
  /**
4
4
  * Value to format.
5
5
  */
@@ -8,16 +8,20 @@ interface IProps {
8
8
  * String to show if formatting fails.
9
9
  * @default "(no coordinates)"
10
10
  */
11
- default?: string;
11
+ defaultStr?: string;
12
12
  }
13
13
  /**
14
14
  * Formats a fractional longitude value as degrees, minutes and seconds (as a string).
15
15
  * If provided with a string, `Longitude` will convert it to a number first.
16
+ * Returns the fallback string if formatting fails or value is out of range.
16
17
  *
17
18
  * ```tsx
18
19
  * <Longitude value={34.2216}/>
19
- * <Longitude value={34.2216} default="Bad longitude"/>
20
+ * <Longitude value={null} defaultStr="Invalid longitude"/>
20
21
  * ```*
21
22
  */
22
- declare const Longitude: (props: IProps) => React.JSX.Element;
23
- export { Longitude, IProps as ILongitudeProps };
23
+ declare const Longitude: {
24
+ ({ value, defaultStr, ...props }: ILongitudeProps): React.JSX.Element;
25
+ displayName: string;
26
+ };
27
+ export { Longitude, ILongitudeProps };
@@ -1,13 +1,34 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import * as React from 'react';
2
- import { toDMS } from "./toDMS";
13
+ import { DMS } from '../../helper/DMS';
3
14
  /**
4
15
  * Formats a fractional longitude value as degrees, minutes and seconds (as a string).
5
16
  * If provided with a string, `Longitude` will convert it to a number first.
17
+ * Returns the fallback string if formatting fails or value is out of range.
6
18
  *
7
19
  * ```tsx
8
20
  * <Longitude value={34.2216}/>
9
- * <Longitude value={34.2216} default="Bad longitude"/>
21
+ * <Longitude value={null} defaultStr="Invalid longitude"/>
10
22
  * ```*
11
23
  */
12
- var Longitude = function (props) { return React.createElement(React.Fragment, null, toDMS(props.value, props.default, 180, "E", "W")); };
24
+ var Longitude = function (_a) {
25
+ var value = _a.value, _b = _a.defaultStr, defaultStr = _b === void 0 ? "(no coordinates)" : _b, props = __rest(_a, ["value", "defaultStr"]);
26
+ // Value and defaultStr and mostly stable. Memoize the formatted string to
27
+ // avoid unnecessary recalculations on every render.
28
+ var formatted = React.useMemo(function () {
29
+ return DMS.toDMSString(value, defaultStr, 180, "E", "W");
30
+ }, [value, defaultStr]);
31
+ return (React.createElement(React.Fragment, null, formatted));
32
+ };
33
+ Longitude.displayName = "Longitude";
13
34
  export { Longitude };
@@ -1,22 +1,37 @@
1
1
  import * as React from 'react';
2
2
  interface IProps {
3
- /** @ignore */
4
- className?: string;
5
3
  value: string;
6
4
  /**
7
- * String to search for. Only the first occurrence is highlighted.
5
+ * String to search for. Only the first occurrence is highlighted, unless
6
+ * `matchAll` is set.
8
7
  * Matching is case-insensitive.
9
8
  */
10
9
  q: string;
10
+ /**
11
+ * Whether the match should be case-sensitive.
12
+ * @default false
13
+ */
14
+ caseSensitive?: boolean;
15
+ /**
16
+ * Highlight all occurrences, not just the first.
17
+ */
18
+ matchAll?: boolean;
19
+ /**
20
+ * Color used for the highlight. If not provided, the theme's accent color
21
+ * is used.
22
+ */
23
+ color?: string;
11
24
  }
12
25
  /**
13
26
  * Given an input string and a search query, `Highlight` highlights the first
14
- * occurrence (if any) of the search query and returns a styled string (as a
15
- * `ReactNode`). String matching is case-insensitive.
27
+ * occurrence or all occurrences (if any) of the search query and returns a
28
+ * styled string (as a `ReactNode`). By default, matching is case-insensitive,
29
+ * but this can be changed with the `caseSensitive` prop.
16
30
  *
17
31
  * ```tsx
18
32
  * <Highlight value="Hello, world" q="hello"/>
33
+ * <Highlight value="Hello, world" q="Hello" caseSensitive />
19
34
  * ```
20
35
  */
21
- declare const Highlight: (props: IProps) => string | React.JSX.Element;
36
+ declare const Highlight: ({ value, q, caseSensitive, matchAll, color }: IProps) => React.ReactNode;
22
37
  export { Highlight };
@@ -2,31 +2,49 @@ import * as React from 'react';
2
2
  import { useTheme } from 'styled-components';
3
3
  /**
4
4
  * Given an input string and a search query, `Highlight` highlights the first
5
- * occurrence (if any) of the search query and returns a styled string (as a
6
- * `ReactNode`). String matching is case-insensitive.
5
+ * occurrence or all occurrences (if any) of the search query and returns a
6
+ * styled string (as a `ReactNode`). By default, matching is case-insensitive,
7
+ * but this can be changed with the `caseSensitive` prop.
7
8
  *
8
9
  * ```tsx
9
10
  * <Highlight value="Hello, world" q="hello"/>
11
+ * <Highlight value="Hello, world" q="Hello" caseSensitive />
10
12
  * ```
11
13
  */
12
- var Highlight = function (props) {
14
+ var Highlight = function (_a) {
15
+ var _b;
16
+ var value = _a.value, q = _a.q, _c = _a.caseSensitive, caseSensitive = _c === void 0 ? false : _c, _d = _a.matchAll, matchAll = _d === void 0 ? false : _d, color = _a.color;
13
17
  var theme = useTheme();
14
18
  // Is there a search string? If not, do not highlight.
15
- if (!props.q)
16
- return props.value;
17
- if (!props.value)
18
- return props.value;
19
- // Does q occur inside input string? If not, do not highlight.
20
- var pos = props.value.toLowerCase().indexOf(props.q.toLowerCase());
21
- if (pos == -1)
22
- return props.value;
23
- // Styling is done with inline styles so as not to generate too many styled-components classes.
24
- var left = props.value.substring(0, pos);
25
- var match = props.value.substring(pos, pos + props.q.length);
26
- var right = props.value.substring(pos + props.q.length);
27
- return React.createElement(React.Fragment, null,
28
- left,
29
- React.createElement("span", { style: { backgroundColor: theme.colors.accent } }, match),
30
- right);
19
+ if (!q || !value)
20
+ return (React.createElement(React.Fragment, null, value));
21
+ var escapedQ = q.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
22
+ var flags = 'g' + (caseSensitive ? '' : 'i');
23
+ var regex = new RegExp(escapedQ, flags);
24
+ var matches = Array.from(value.matchAll(regex));
25
+ // If there are no matches, return the original value.
26
+ if (matches.length === 0)
27
+ return (React.createElement(React.Fragment, null, value));
28
+ var parts = [];
29
+ var lastIndex = 0;
30
+ for (var i = 0; i < matches.length; i++) {
31
+ var match = matches[i];
32
+ var index = (_b = match.index) !== null && _b !== void 0 ? _b : 0;
33
+ if (index > lastIndex) {
34
+ parts.push(value.slice(lastIndex, index));
35
+ }
36
+ parts.push(
37
+ // Styling is done with inline styles so as not to generate too many
38
+ // styled-components classes.
39
+ React.createElement("mark", { key: "".concat(index, "-").concat(i), style: { backgroundColor: color !== null && color !== void 0 ? color : theme.colors.accent } }, value.slice(index, index + match[0].length)));
40
+ lastIndex = index + match[0].length;
41
+ // Unless matchAll, stop processing after the first match.
42
+ if (!matchAll)
43
+ break;
44
+ }
45
+ if (lastIndex < value.length) {
46
+ parts.push(value.slice(lastIndex));
47
+ }
48
+ return (React.createElement(React.Fragment, null, parts));
31
49
  };
32
50
  export { Highlight };
@@ -1,18 +1,29 @@
1
1
  import * as React from 'react';
2
2
  interface IProps {
3
+ /** Input value to be humanized (e.g., 10000 → 10K) */
4
+ value: number | string;
3
5
  /**
4
- * Input value
6
+ * Locale string (e.g., 'en-US', 'de-DE')
7
+ * @default 'en'
5
8
  */
6
- value: number | string;
9
+ locale?: string;
10
+ /**
11
+ * Number of decimal places to show (overrides default formatting)
12
+ * @default undefined
13
+ */
14
+ decimals?: number;
7
15
  }
8
16
  /**
9
- * `Human` takes a `value` prop and formats it in a human-readable way.
10
- *
11
- * E.g. `10000` => `10K`
17
+ * `Human` formats large numbers using `Intl.NumberFormat` for locale-aware
18
+ * output and optional compact display (e.g. "10K", "1.2M").
12
19
  *
13
20
  * ```tsx
14
- * <Human value={150000}/>
21
+ * <Human value={1200}/> // => "1.2K"
22
+ * <Human value={999999} locale="de-DE" /> // => "1 Mio."
15
23
  * ```
16
24
  */
17
- declare const Human: (props: IProps) => React.JSX.Element;
25
+ declare const Human: {
26
+ ({ value, locale, decimals }: IProps): React.JSX.Element;
27
+ displayName: string;
28
+ };
18
29
  export { Human, IProps };