@hortiview/shared-components 2.6.1 → 2.8.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/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 c } from "./components/DeleteModal/DeleteModal.js";
9
+ import { DetailContentWrapper as _ } from "./components/DetailContentWrapper/DetailContentWrapper.js";
10
+ import { Disclaimer as s } 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,83 @@ 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 Sr } from "./components/FormComponents/FormCheckBox/FormCheckBox.js";
35
+ import { FormDatePicker as Lr } from "./components/FormComponents/FormDatePicker/FormDatePicker.js";
36
+ import { FormNumber as Fr } 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 { SafeForm as br } from "./components/SafeForm/SafeForm.js";
43
+ import { AvailableCustomIcons as Rr } from "./enums/AvailableCustomIcons.js";
44
+ import { ThemeColor as Ur } from "./enums/ThemeColor.js";
45
+ import { u as hr } from "./useBreakpoints-MzTZ0tCT.js";
46
+ import { capitalizeFirstLetters as kr, getFormattedDateTime as wr, getNumberAsLocaleString as vr, trimLeadingAndTrailingSpaces as yr } from "./services/UtilService.js";
47
+ import { DATE_FORMAT as Kr, DATE_TIME_FORMAT as zr, TIME_FORMAT as Wr } from "./types/Time.js";
48
+ import { AVAILABLE_COUNTRY_KEYS as jr, AVAILABLE_LOCALES as qr, ENGLISH_LANGUAGE_ID as Jr, GERMAN_LANGUAGE_ID as Qr, LANGUAGE_CODES_MAPPER as Zr, LANGUAGE_ID_MAPPER as $r, SPANISH_LANGUAGE_ID as ro, TURKISH_LANGUAGE_ID as oo } from "./types/Languages.js";
47
49
  export {
48
- vr as AVAILABLE_COUNTRY_KEYS,
49
- yr as AVAILABLE_LOCALES,
50
+ jr as AVAILABLE_COUNTRY_KEYS,
51
+ qr as AVAILABLE_LOCALES,
50
52
  e as AlertBanner,
51
- Hr as AvailableCustomIcons,
53
+ Rr as AvailableCustomIcons,
52
54
  f as BaseView,
53
55
  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,
56
+ A as BlockView,
57
+ n as ChipCard,
58
+ E as ContextMenu,
59
+ Kr as DATE_FORMAT,
60
+ zr as DATE_TIME_FORMAT,
61
+ c as DeleteModal,
62
+ _ as DetailContentWrapper,
63
+ s as Disclaimer,
64
+ Jr as ENGLISH_LANGUAGE_ID,
65
+ G as EmptyView,
62
66
  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,
67
+ Sr as FormCheckBox,
68
+ Lr as FormDatePicker,
69
+ Fr as FormNumber,
70
+ Tr as FormRadio,
71
+ Ir as FormSelect,
72
+ Nr as FormSlider,
69
73
  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,
74
+ Cr as FormToggle,
75
+ M as FormattedNumberDisplay,
76
+ Qr as GERMAN_LANGUAGE_ID,
77
+ B as GenericTable,
78
+ O as HashTabView,
79
+ u as HeaderFilter,
80
+ H as HealthCheckFailed,
81
+ V as Iconify,
82
+ P as InfoGroup,
83
+ Zr as LANGUAGE_CODES_MAPPER,
84
+ $r as LANGUAGE_ID_MAPPER,
81
85
  m as LinkBanner,
82
- R as ListArea,
86
+ w as ListArea,
83
87
  y as LoadingSpinner,
84
88
  K as Modal,
85
89
  W as ModulePadding,
86
90
  j as OfflineView,
87
91
  J as OnboardingBanner,
88
92
  Z as OverflowTooltip,
89
- Xr as SPANISH_LANGUAGE_ID,
93
+ ro as SPANISH_LANGUAGE_ID,
94
+ br as SafeForm,
90
95
  rr as ScrollbarX,
91
96
  or as ScrollbarY,
92
97
  tr as SearchBar,
93
98
  pr as Select,
94
- nr as Stepper,
99
+ lr as Stepper,
95
100
  xr as StepperHeader,
96
101
  ir as StepperIndicator,
97
- jr as TURKISH_LANGUAGE_ID,
98
- Vr as ThemeColor,
99
- cr as VerticalDivider,
100
- Pr as capitalizeFirstLetters,
101
- kr as getNumberAsLocaleString,
102
- wr as trimLeadingAndTrailingSpaces,
103
- Mr as useBreakpoints
102
+ Wr as TIME_FORMAT,
103
+ oo as TURKISH_LANGUAGE_ID,
104
+ Ur as ThemeColor,
105
+ dr as VerticalDivider,
106
+ kr as capitalizeFirstLetters,
107
+ wr as getFormattedDateTime,
108
+ vr as getNumberAsLocaleString,
109
+ yr as trimLeadingAndTrailingSpaces,
110
+ hr as useBreakpoints
104
111
  };
@@ -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.8.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>",