@hortiview/shared-components 2.6.1 → 2.7.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [2.7.0](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/compare/v2.6.1...v2.7.0) (2025-10-24)
2
+
3
+ ### Features
4
+
5
+ * create getFormattedDateTime function ([2c0bee8](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/commit/2c0bee8ab990f28cf4d9cbc198863ca411070b6c))
6
+
7
+ ### Documentation
8
+
9
+ * mention using formats from Time.ts for consistency ([0026a3a](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/commit/0026a3acb5422cfdda722b69020c9cbc1521ebd8))
10
+ * update README ([846bca1](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/commit/846bca135f16d3f673ef1db3a8c37700371eb115))
11
+
12
+ ### Code Refactoring
13
+
14
+ * add Date prop ([f962c7c](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/commit/f962c7c106c66e0a55dcd7f49642233cf69344fe))
15
+ * create Time file and import/export date formats ([d7b6fd9](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/commit/d7b6fd974bf4634d8300426ece110881090e2653))
16
+
1
17
  ## [2.6.1](https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared/compare/v2.6.0...v2.6.1) (2025-10-02)
2
18
 
3
19
  ### Styles
package/README.md CHANGED
@@ -66,6 +66,7 @@ Additionally the library provides form components using [react-hook-form](https:
66
66
  1. [capitalizeFirstLetters](#capitalizefirstletters)
67
67
  1. [trimLeadingAndTrailingSpaces](#trimleadingandtrailingspaces)
68
68
  1. [getNumberAsLocaleString](#getnumberaslocalestring)
69
+ 1. [getFormattedDateTime](#getformatteddatetime)
69
70
 
70
71
  ## Available constants
71
72
 
@@ -1108,6 +1109,18 @@ const overlineTitle = `${getNumberAsLocaleString(userLocale, totalArea, 5)} ${t(
1108
1109
  )}`;
1109
1110
  ```
1110
1111
 
1112
+ ### getFormattedDateTime
1113
+
1114
+ Formats a date (string) with Intl.DateTimeFormat.
1115
+ If locale is a plain code ("en" | "es" | "tr"), it’s mapped to a regional tag ("en-US", "es-MX", "tr-TR").
1116
+
1117
+ For consistency, please use the date and time formats defined in `Time.ts`.
1118
+
1119
+ ```typescript
1120
+ getFormattedDateTime('2025-10-02T14:30:00Z', 'en-US', { dateStyle: 'medium' })
1121
+ // -> Oct 2, 2025
1122
+ ```
1123
+
1111
1124
  ## Available constants
1112
1125
 
1113
1126
  ### Languages and countries
@@ -18,12 +18,13 @@ import "../../get-B8c-T4F8.js";
18
18
  import "../../omit-1Eom1PmQ.js";
19
19
  import "../../isArray-Dub1wGJM.js";
20
20
  import "../../isString-BW9UHONv.js";
21
+ import "../../types/Time.js";
21
22
  import '../../assets/Filter.css';const K = "_filterButton_qtl7a_1", T = "_relativeParent_qtl7a_6", V = "_filterBadge_qtl7a_10", E = "_dense_qtl7a_17", u = {
22
23
  filterButton: K,
23
24
  relativeParent: T,
24
25
  filterBadge: V,
25
26
  dense: E
26
- }, ct = ({
27
+ }, ut = ({
27
28
  clearFilterText: m,
28
29
  closeCallback: s,
29
30
  currentFilter: i,
@@ -184,5 +185,5 @@ import '../../assets/Filter.css';const K = "_filterButton_qtl7a_1", T = "_relati
184
185
  );
185
186
  };
186
187
  export {
187
- ct as Filter
188
+ ut as Filter
188
189
  };
@@ -29,6 +29,7 @@ import "react-hook-form";
29
29
  import "../../get-B8c-T4F8.js";
30
30
  import "../../isArray-Dub1wGJM.js";
31
31
  import "../../isString-BW9UHONv.js";
32
+ import "../../types/Time.js";
32
33
  import { useGenerateColumns as yl, useGenerateTableData as bl } from "./GenericTableService.js";
33
34
  import { GenericCardList as wl } from "./Mobile/GenericCardList.js";
34
35
  import '../../assets/GenericTable.css';function Rl(r, o) {
@@ -10407,7 +10408,7 @@ const cd = "_topBar_1tmb3_1", fd = "_filterBar_1tmb3_5", pd = "_start_1tmb3_10",
10407
10408
  elevation: vd,
10408
10409
  table: hd,
10409
10410
  noBorder: md
10410
- }, Jd = ({
10411
+ }, Qd = ({
10411
10412
  data: r = [],
10412
10413
  hiddenColumns: o = [],
10413
10414
  order: e = [],
@@ -10527,5 +10528,5 @@ const cd = "_topBar_1tmb3_1", fd = "_filterBar_1tmb3_5", pd = "_start_1tmb3_10",
10527
10528
  );
10528
10529
  };
10529
10530
  export {
10530
- Jd as GenericTable
10531
+ Qd as GenericTable
10531
10532
  };
@@ -11,7 +11,8 @@ import "../../get-B8c-T4F8.js";
11
11
  import "../../omit-1Eom1PmQ.js";
12
12
  import "../../isArray-Dub1wGJM.js";
13
13
  import "../../isString-BW9UHONv.js";
14
- const x = ({ children: o }) => {
14
+ import "../../types/Time.js";
15
+ const j = ({ children: o }) => {
15
16
  const { isDesktop: t } = m();
16
17
  return /* @__PURE__ */ i(
17
18
  r,
@@ -24,5 +25,5 @@ const x = ({ children: o }) => {
24
25
  );
25
26
  };
26
27
  export {
27
- x as ModulePadding
28
+ j as ModulePadding
28
29
  };
package/dist/main.d.ts CHANGED
@@ -42,7 +42,7 @@ export { FormToggle } from './components/FormComponents/FormToggle/FormToggle';
42
42
  export { AvailableCustomIcons } from './enums/AvailableCustomIcons';
43
43
  export { ThemeColor } from './enums/ThemeColor';
44
44
  export { useBreakpoints } from './hooks/useBreakpoints';
45
- export { capitalizeFirstLetters, getNumberAsLocaleString, trimLeadingAndTrailingSpaces, } from './services/UtilService';
45
+ export { capitalizeFirstLetters, getFormattedDateTime, getNumberAsLocaleString, trimLeadingAndTrailingSpaces, } from './services/UtilService';
46
46
  export type { ActionProps } from './components/ContextMenu/ContextMenu';
47
47
  export type { FormSelectOption, FormSelectProps, } from './components/FormComponents/FormSelect/FormSelect';
48
48
  export type { FormTextProps } from './components/FormComponents/FormText/FormText';
@@ -54,5 +54,6 @@ export type { FilterData, FilterOption, FilterSelection } from './types/Filter';
54
54
  export type { CellTemplate, CellTemplateProps, TableLayoutProps } from './types/GenericTable';
55
55
  export type { HashTab } from './types/HashTab';
56
56
  export type { BaseListElement, ListElement } from './types/ListElement';
57
+ export { DATE_FORMAT, TIME_FORMAT, DATE_TIME_FORMAT } from './types/Time';
57
58
  export { AVAILABLE_COUNTRY_KEYS, AVAILABLE_LOCALES, ENGLISH_LANGUAGE_ID, GERMAN_LANGUAGE_ID, LANGUAGE_CODES_MAPPER, LANGUAGE_ID_MAPPER, SPANISH_LANGUAGE_ID, TURKISH_LANGUAGE_ID, } from './types/Languages';
58
59
  export type { AVAILABLE_LANGUAGE_CODES, LANGUAGE_COUNTRY_CODES } from './types/Languages';
package/dist/main.js CHANGED
@@ -2,22 +2,22 @@ import { A as e } from "./AlertBanner-JnX0tJGC.js";
2
2
  import { LinkBanner as m } from "./components/AlertBanner/LinkBanner.js";
3
3
  import { BaseView as f } from "./components/BaseView/BaseView.js";
4
4
  import { BasicHeading as a } from "./components/BasicHeading/BasicHeading.js";
5
- import { BlockView as l } from "./components/BlockView/BlockView.js";
6
- import { ChipCard as A } from "./components/ChipCard/ChipCard.js";
7
- import { ContextMenu as d } from "./components/ContextMenu/ContextMenu.js";
8
- import { DeleteModal as S } from "./components/DeleteModal/DeleteModal.js";
9
- import { DetailContentWrapper as E } from "./components/DetailContentWrapper/DetailContentWrapper.js";
10
- import { Disclaimer as _ } from "./components/Disclaimer/Disclaimer.js";
11
- import { EmptyView as F } from "./components/EmptyView/EmptyView.js";
5
+ import { BlockView as A } from "./components/BlockView/BlockView.js";
6
+ import { ChipCard as n } from "./components/ChipCard/ChipCard.js";
7
+ import { ContextMenu as E } from "./components/ContextMenu/ContextMenu.js";
8
+ import { DeleteModal as L } from "./components/DeleteModal/DeleteModal.js";
9
+ import { DetailContentWrapper as _ } from "./components/DetailContentWrapper/DetailContentWrapper.js";
10
+ import { Disclaimer as F } from "./components/Disclaimer/Disclaimer.js";
11
+ import { EmptyView as G } from "./components/EmptyView/EmptyView.js";
12
12
  import { Filter as D } from "./components/Filter/Filter.js";
13
- import { FormattedNumberDisplay as C } from "./components/FormattedNumberDisplay/FormattedNumberDisplay.js";
14
- import { GenericTable as b } from "./components/GenericTable/GenericTable.js";
15
- import { HashTabView as T } from "./components/HashTabView/HashTabView.js";
16
- import { HeaderFilter as U } from "./components/HeaderFilter/HeaderFilter.js";
17
- import { HealthCheckFailed as h } from "./components/HealthCheckFailed/HealthCheckFailed.js";
18
- import { Iconify as O } from "./components/Iconify/Iconify.js";
19
- import { InfoGroup as k } from "./components/InfoGroup/InfoGroup.js";
20
- import { ListArea as R } from "./components/ListArea/ListArea.js";
13
+ import { FormattedNumberDisplay as M } from "./components/FormattedNumberDisplay/FormattedNumberDisplay.js";
14
+ import { GenericTable as B } from "./components/GenericTable/GenericTable.js";
15
+ import { HashTabView as O } from "./components/HashTabView/HashTabView.js";
16
+ import { HeaderFilter as u } from "./components/HeaderFilter/HeaderFilter.js";
17
+ import { HealthCheckFailed as H } from "./components/HealthCheckFailed/HealthCheckFailed.js";
18
+ import { Iconify as V } from "./components/Iconify/Iconify.js";
19
+ import { InfoGroup as P } from "./components/InfoGroup/InfoGroup.js";
20
+ import { ListArea as w } from "./components/ListArea/ListArea.js";
21
21
  import { LoadingSpinner as y } from "./components/LoadingSpinner/Default/LoadingSpinner.js";
22
22
  import { Modal as K } from "./components/Modal/Modal.js";
23
23
  import { ModulePadding as W } from "./components/ModulePadding/ModulePadding.js";
@@ -29,76 +29,81 @@ import { SearchBar as tr } from "./components/SearchBar/SearchBar.js";
29
29
  import { Select as pr } from "./components/Select/Select.js";
30
30
  import { StepperHeader as xr } from "./components/Stepper/components/StepperHeader.js";
31
31
  import { StepperIndicator as ir } from "./components/Stepper/components/StepperIndicator.js";
32
- import { Stepper as nr } from "./components/Stepper/Stepper.js";
33
- import { VerticalDivider as cr } from "./components/VerticalDivider/VerticalDivider.js";
34
- import { FormCheckBox as Lr } from "./components/FormComponents/FormCheckBox/FormCheckBox.js";
35
- import { FormDatePicker as sr } from "./components/FormComponents/FormDatePicker/FormDatePicker.js";
36
- import { FormNumber as Gr } from "./components/FormComponents/FormNumber/FormNumber.js";
37
- import { FormRadio as Ir } from "./components/FormComponents/FormRadio/FormRadio.js";
38
- import { FormSelect as Nr } from "./components/FormComponents/FormSelect/FormSelect.js";
39
- import { FormSlider as Br } from "./components/FormComponents/FormSlider/FormSlider.js";
32
+ import { Stepper as lr } from "./components/Stepper/Stepper.js";
33
+ import { VerticalDivider as dr } from "./components/VerticalDivider/VerticalDivider.js";
34
+ import { FormCheckBox as cr } from "./components/FormComponents/FormCheckBox/FormCheckBox.js";
35
+ import { FormDatePicker as Sr } from "./components/FormComponents/FormDatePicker/FormDatePicker.js";
36
+ import { FormNumber as sr } from "./components/FormComponents/FormNumber/FormNumber.js";
37
+ import { FormRadio as Tr } from "./components/FormComponents/FormRadio/FormRadio.js";
38
+ import { FormSelect as Ir } from "./components/FormComponents/FormSelect/FormSelect.js";
39
+ import { FormSlider as Nr } from "./components/FormComponents/FormSlider/FormSlider.js";
40
40
  import { FormText as gr } from "./components/FormComponents/FormText/FormText.js";
41
- import { FormToggle as ur } from "./components/FormComponents/FormToggle/FormToggle.js";
42
- import { AvailableCustomIcons as Hr } from "./enums/AvailableCustomIcons.js";
43
- import { ThemeColor as Vr } from "./enums/ThemeColor.js";
44
- import { u as Mr } from "./useBreakpoints-MzTZ0tCT.js";
45
- import { capitalizeFirstLetters as Pr, getNumberAsLocaleString as kr, trimLeadingAndTrailingSpaces as wr } from "./services/UtilService.js";
46
- import { AVAILABLE_COUNTRY_KEYS as vr, AVAILABLE_LOCALES as yr, ENGLISH_LANGUAGE_ID as Yr, GERMAN_LANGUAGE_ID as Kr, LANGUAGE_CODES_MAPPER as zr, LANGUAGE_ID_MAPPER as Wr, SPANISH_LANGUAGE_ID as Xr, TURKISH_LANGUAGE_ID as jr } from "./types/Languages.js";
41
+ import { FormToggle as Cr } from "./components/FormComponents/FormToggle/FormToggle.js";
42
+ import { AvailableCustomIcons as br } from "./enums/AvailableCustomIcons.js";
43
+ import { ThemeColor as Rr } from "./enums/ThemeColor.js";
44
+ import { u as Ur } from "./useBreakpoints-MzTZ0tCT.js";
45
+ import { capitalizeFirstLetters as hr, getFormattedDateTime as Pr, getNumberAsLocaleString as kr, trimLeadingAndTrailingSpaces as wr } from "./services/UtilService.js";
46
+ import { DATE_FORMAT as yr, DATE_TIME_FORMAT as Yr, TIME_FORMAT as Kr } from "./types/Time.js";
47
+ import { AVAILABLE_COUNTRY_KEYS as Wr, AVAILABLE_LOCALES as Xr, ENGLISH_LANGUAGE_ID as jr, GERMAN_LANGUAGE_ID as qr, LANGUAGE_CODES_MAPPER as Jr, LANGUAGE_ID_MAPPER as Qr, SPANISH_LANGUAGE_ID as Zr, TURKISH_LANGUAGE_ID as $r } from "./types/Languages.js";
47
48
  export {
48
- vr as AVAILABLE_COUNTRY_KEYS,
49
- yr as AVAILABLE_LOCALES,
49
+ Wr as AVAILABLE_COUNTRY_KEYS,
50
+ Xr as AVAILABLE_LOCALES,
50
51
  e as AlertBanner,
51
- Hr as AvailableCustomIcons,
52
+ br as AvailableCustomIcons,
52
53
  f as BaseView,
53
54
  a as BasicHeading,
54
- l as BlockView,
55
- A as ChipCard,
56
- d as ContextMenu,
57
- S as DeleteModal,
58
- E as DetailContentWrapper,
59
- _ as Disclaimer,
60
- Yr as ENGLISH_LANGUAGE_ID,
61
- F as EmptyView,
55
+ A as BlockView,
56
+ n as ChipCard,
57
+ E as ContextMenu,
58
+ yr as DATE_FORMAT,
59
+ Yr as DATE_TIME_FORMAT,
60
+ L as DeleteModal,
61
+ _ as DetailContentWrapper,
62
+ F as Disclaimer,
63
+ jr as ENGLISH_LANGUAGE_ID,
64
+ G as EmptyView,
62
65
  D as Filter,
63
- Lr as FormCheckBox,
64
- sr as FormDatePicker,
65
- Gr as FormNumber,
66
- Ir as FormRadio,
67
- Nr as FormSelect,
68
- Br as FormSlider,
66
+ cr as FormCheckBox,
67
+ Sr as FormDatePicker,
68
+ sr as FormNumber,
69
+ Tr as FormRadio,
70
+ Ir as FormSelect,
71
+ Nr as FormSlider,
69
72
  gr as FormText,
70
- ur as FormToggle,
71
- C as FormattedNumberDisplay,
72
- Kr as GERMAN_LANGUAGE_ID,
73
- b as GenericTable,
74
- T as HashTabView,
75
- U as HeaderFilter,
76
- h as HealthCheckFailed,
77
- O as Iconify,
78
- k as InfoGroup,
79
- zr as LANGUAGE_CODES_MAPPER,
80
- Wr as LANGUAGE_ID_MAPPER,
73
+ Cr as FormToggle,
74
+ M as FormattedNumberDisplay,
75
+ qr as GERMAN_LANGUAGE_ID,
76
+ B as GenericTable,
77
+ O as HashTabView,
78
+ u as HeaderFilter,
79
+ H as HealthCheckFailed,
80
+ V as Iconify,
81
+ P as InfoGroup,
82
+ Jr as LANGUAGE_CODES_MAPPER,
83
+ Qr as LANGUAGE_ID_MAPPER,
81
84
  m as LinkBanner,
82
- R as ListArea,
85
+ w as ListArea,
83
86
  y as LoadingSpinner,
84
87
  K as Modal,
85
88
  W as ModulePadding,
86
89
  j as OfflineView,
87
90
  J as OnboardingBanner,
88
91
  Z as OverflowTooltip,
89
- Xr as SPANISH_LANGUAGE_ID,
92
+ Zr as SPANISH_LANGUAGE_ID,
90
93
  rr as ScrollbarX,
91
94
  or as ScrollbarY,
92
95
  tr as SearchBar,
93
96
  pr as Select,
94
- nr as Stepper,
97
+ lr as Stepper,
95
98
  xr as StepperHeader,
96
99
  ir as StepperIndicator,
97
- jr as TURKISH_LANGUAGE_ID,
98
- Vr as ThemeColor,
99
- cr as VerticalDivider,
100
- Pr as capitalizeFirstLetters,
100
+ Kr as TIME_FORMAT,
101
+ $r as TURKISH_LANGUAGE_ID,
102
+ Rr as ThemeColor,
103
+ dr as VerticalDivider,
104
+ hr as capitalizeFirstLetters,
105
+ Pr as getFormattedDateTime,
101
106
  kr as getNumberAsLocaleString,
102
107
  wr as trimLeadingAndTrailingSpaces,
103
- Mr as useBreakpoints
108
+ Ur as useBreakpoints
104
109
  };
@@ -23,3 +23,24 @@ export declare const trimLeadingAndTrailingSpaces: <T extends Record<string, unk
23
23
  * @returns The language-specific formatted number.
24
24
  */
25
25
  export declare const getNumberAsLocaleString: (locale: AVAILABLE_LANGUAGE_CODES, value?: number, maximumFractionDigits?: number) => string;
26
+ /**
27
+ * Formats a date using `Intl.DateTimeFormat`.
28
+ *
29
+ * @param date - The date to format (ISO string or any valid date string).
30
+ * @param locale - Locale to use. Defaults to `"en-US"`.
31
+ * - If it matches an entry in `AVAILABLE_LOCALES` (e.g. `"en"`, `"es"`, `"tr"`),
32
+ * it's mapped via `LANGUAGE_CODES_MAPPER` to a full tag (e.g. `"en-US"`).
33
+ * - Otherwise, used directly as a BCP-47 locale (e.g. `"fr-FR"`).
34
+ * @param options - Optional `Intl.DateTimeFormatOptions`.
35
+ * @returns The formatted date/time string.
36
+ *
37
+ * @example
38
+ * // Uses the default locale "en-US"
39
+ * getFormattedDateTime('2025-10-02T14:30:00Z', undefined, { dateStyle: 'medium' });
40
+ * // → "Oct 2, 2025"
41
+ *
42
+ * // Short code is mapped via LANGUAGE_CODES_MAPPER (e.g., "es" → "es-MX")
43
+ * getFormattedDateTime('2025-10-02', 'es', { dateStyle: 'long' });
44
+ * // → "2 de octubre de 2025"
45
+ */
46
+ export declare const getFormattedDateTime: (date: Date | string, locale?: string, options?: Intl.DateTimeFormatOptions) => string;
@@ -1,15 +1,19 @@
1
- import { i as o } from "../isArray-Dub1wGJM.js";
1
+ import { i as m } from "../isArray-Dub1wGJM.js";
2
2
  import { i as s, a } from "../isString-BW9UHONv.js";
3
- import { LANGUAGE_CODES_MAPPER as c } from "../types/Languages.js";
4
- const A = (r) => r.split(" ").map((t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()).join(" "), m = (r) => Object.fromEntries(
5
- Object.entries(r).map(([t, i]) => [t, n(i)])
6
- ), n = (r) => o(r) ? r.map(n) : s(r) ? m(r) : a(r) ? r.trim() : r, L = (r, t, i = 2) => {
7
- if (!t) return "0";
8
- const e = c[r];
9
- return t.toLocaleString(e, { maximumFractionDigits: i });
10
- };
3
+ import { AVAILABLE_LOCALES as c, LANGUAGE_CODES_MAPPER as n } from "../types/Languages.js";
4
+ const L = (t) => t.split(" ").map((r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()).join(" "), f = (t) => Object.fromEntries(
5
+ Object.entries(t).map(([r, e]) => [r, i(e)])
6
+ ), i = (t) => m(t) ? t.map(i) : s(t) ? f(t) : a(t) ? t.trim() : t, S = (t, r, e = 2) => {
7
+ if (!r) return "0";
8
+ const o = n[t];
9
+ return r.toLocaleString(o, { maximumFractionDigits: e });
10
+ }, u = (t, r = "en-US", e) => c.includes(r) ? new Intl.DateTimeFormat(
11
+ n[r],
12
+ e
13
+ ).format(new Date(t)) : new Intl.DateTimeFormat(r, e).format(new Date(t));
11
14
  export {
12
- A as capitalizeFirstLetters,
13
- L as getNumberAsLocaleString,
14
- m as trimLeadingAndTrailingSpaces
15
+ L as capitalizeFirstLetters,
16
+ u as getFormattedDateTime,
17
+ S as getNumberAsLocaleString,
18
+ f as trimLeadingAndTrailingSpaces
15
19
  };
@@ -1,47 +1,48 @@
1
- import { getBlockNumberByDto as r } from "./BlockService.js";
2
- import { capitalizeFirstLetters as a, trimLeadingAndTrailingSpaces as o } from "./UtilService.js";
3
- import { d as n, t as e, g as s } from "../vi.CjhMlMwf-CKxPQtd6.js";
4
- n("Services Test", () => {
5
- n("capitalizeFirstLetters", () => {
1
+ import { getBlockNumberByDto as i } from "./BlockService.js";
2
+ import { capitalizeFirstLetters as d, trimLeadingAndTrailingSpaces as a, getFormattedDateTime as r } from "./UtilService.js";
3
+ import { DATE_FORMAT as n, TIME_FORMAT as l } from "../types/Time.js";
4
+ import { d as c, t as e, g as o } from "../vi.CjhMlMwf-CKxPQtd6.js";
5
+ c("Services Test", () => {
6
+ c("capitalizeFirstLetters", () => {
6
7
  e("should capitalize first letters of a lower case string", () => {
7
- const t = a("farm location");
8
- s(t).toBe("Farm Location");
8
+ const t = d("farm location");
9
+ o(t).toBe("Farm Location");
9
10
  }), e("should turn other letters of an all caps string into lower case", () => {
10
- const t = a("FARM LOCATION");
11
- s(t).toBe("Farm Location");
11
+ const t = d("FARM LOCATION");
12
+ o(t).toBe("Farm Location");
12
13
  });
13
- }), n("getBlockNumberByDto", () => {
14
+ }), c("getBlockNumberByDto", () => {
14
15
  e("should get zero", () => {
15
- const t = r({ position: void 0 }, 3);
16
- s(t).toBe(0);
16
+ const t = i({ position: void 0 }, 3);
17
+ o(t).toBe(0);
17
18
  }), e("should get 3", () => {
18
- const t = r({ position: { row: 1, column: 3 } }, 3);
19
- s(t).toBe(3);
19
+ const t = i({ position: { row: 1, column: 3 } }, 3);
20
+ o(t).toBe(3);
20
21
  });
21
- }), n("Test trimLeadingAndTrailingSpaces", () => {
22
+ }), c("Test trimLeadingAndTrailingSpaces", () => {
22
23
  e("should remove leading spaces", () => {
23
- s(o({ test: " test-1" })).toEqual({ test: "test-1" });
24
+ o(a({ test: " test-1" })).toEqual({ test: "test-1" });
24
25
  }), e("should remove trailing spaces", () => {
25
- s(o({ test: "test-1 " })).toEqual({ test: "test-1" });
26
+ o(a({ test: "test-1 " })).toEqual({ test: "test-1" });
26
27
  }), e("should not remove other spaces than the leading and trailing once", () => {
27
- s(o({ test: " t e s t 1 " })).toEqual({ test: "t e s t 1" });
28
+ o(a({ test: " t e s t 1 " })).toEqual({ test: "t e s t 1" });
28
29
  }), e("should remove leading and trailing spaces", () => {
29
- s(o({ test1: " test-1 ", test2: "test-2 " })).toEqual({
30
+ o(a({ test1: " test-1 ", test2: "test-2 " })).toEqual({
30
31
  test1: "test-1",
31
32
  test2: "test-2"
32
33
  });
33
34
  }), e("should not change other values than strings", () => {
34
- s(o({ test1: " test-1 ", test2: 123456 })).toEqual({
35
+ o(a({ test1: " test-1 ", test2: 123456 })).toEqual({
35
36
  test1: "test-1",
36
37
  test2: 123456
37
38
  });
38
39
  }), e("should remove spaces from strings in an nested object", () => {
39
- s(o({ test1: " test-1 ", test2: { nestedObjectKey: "test-2 " } })).toEqual({
40
+ o(a({ test1: " test-1 ", test2: { nestedObjectKey: "test-2 " } })).toEqual({
40
41
  test1: "test-1",
41
42
  test2: { nestedObjectKey: "test-2" }
42
43
  });
43
44
  }), e("should remove spaces from strings of an array", () => {
44
- s(o({
45
+ o(a({
45
46
  test1: " test-1 ",
46
47
  test2: { nestedObjectKey: ["test-2 ", " test-3 ", 2345] }
47
48
  })).toEqual({
@@ -50,7 +51,53 @@ n("Services Test", () => {
50
51
  });
51
52
  }), e("should not trim date instances", () => {
52
53
  const t = { date: /* @__PURE__ */ new Date() };
53
- s(o(t)).toEqual(t);
54
+ o(a(t)).toEqual(t);
55
+ });
56
+ }), c("getFormattedDateTime", () => {
57
+ const t = "2025-01-20T16:01:50.097Z";
58
+ e('should format date correctly for locale "undefined"', () => {
59
+ const s = r(t, void 0, n);
60
+ o(s).toBe("01/20/2025");
61
+ }), e('should format date correctly for locale "de"', () => {
62
+ const s = r(t, "de", {
63
+ day: "2-digit",
64
+ month: "2-digit",
65
+ year: "numeric"
66
+ });
67
+ o(s).toBe("20.01.2025");
68
+ }), e('should format date correctly for locale "en"', () => {
69
+ const s = r(t, "en", n);
70
+ o(s).toBe("01/20/2025");
71
+ }), e('should format datetime correctly for local "en"', () => {
72
+ const s = r(t, "en", {
73
+ ...l,
74
+ timeZone: "America/New_York"
75
+ });
76
+ o(s).toBe("11:01 AM");
77
+ }), e('should format date correctly for locale "es', () => {
78
+ const s = r(t, "es", n);
79
+ o(s).toBe("20/01/2025");
80
+ }), e('should format datetime correctly for local "es"', () => {
81
+ const s = r(t, "es", {
82
+ ...l,
83
+ timeZone: "America/Mexico_City"
84
+ });
85
+ o(s).toBe("10:01 a.m.");
86
+ }), e('should format date correctly for locale "tr', () => {
87
+ const s = r(t, "tr", n);
88
+ o(s).toBe("20.01.2025");
89
+ }), e('should format datetime correctly for local "tr"', () => {
90
+ const s = r(t, "tr", {
91
+ ...l,
92
+ timeZone: "Europe/Istanbul"
93
+ });
94
+ o(s).toBe("ÖS 07:01");
95
+ }), e('should format date correctly for locale "gb', () => {
96
+ const s = r(t, "en-GB", n);
97
+ o(s).toBe("20/01/2025");
98
+ }), e('should format date correctly for locale "fr', () => {
99
+ const s = r(t, "fr", n);
100
+ o(s).toBe("20/01/2025");
54
101
  });
55
102
  });
56
103
  });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Date and time format options to be used in the {@link getFormattedDateTime} function.
3
+ */
4
+ export declare const DATE_FORMAT: {
5
+ readonly day: "2-digit";
6
+ readonly month: "2-digit";
7
+ readonly year: "numeric";
8
+ };
9
+ export declare const TIME_FORMAT: {
10
+ readonly hour: "2-digit";
11
+ readonly minute: "2-digit";
12
+ readonly hour12: true;
13
+ };
14
+ export declare const DATE_TIME_FORMAT: {
15
+ readonly hour: "2-digit";
16
+ readonly minute: "2-digit";
17
+ readonly hour12: true;
18
+ readonly day: "2-digit";
19
+ readonly month: "2-digit";
20
+ readonly year: "numeric";
21
+ };
@@ -0,0 +1,17 @@
1
+ const t = {
2
+ day: "2-digit",
3
+ month: "2-digit",
4
+ year: "numeric"
5
+ }, i = {
6
+ hour: "2-digit",
7
+ minute: "2-digit",
8
+ hour12: !0
9
+ }, o = {
10
+ ...t,
11
+ ...i
12
+ };
13
+ export {
14
+ t as DATE_FORMAT,
15
+ o as DATE_TIME_FORMAT,
16
+ i as TIME_FORMAT
17
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/shared-components",
3
3
  "description": "This is a shared component library. It should used in the HortiView platform and its modules.",
4
- "version": "2.6.1",
4
+ "version": "2.7.0",
5
5
  "type": "module",
6
6
  "repository": "https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared",
7
7
  "author": "Falk Menge <falk.menge.ext@bayer.com>",