@ews-admin/global-design-system 1.19.0 → 1.22.1

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.
@@ -25,7 +25,22 @@ export declare function formatCurrency(amount: number, currency?: string): strin
25
25
  export interface FormatDateOptions extends Intl.DateTimeFormatOptions {
26
26
  locale?: string | string[];
27
27
  }
28
- export declare function formatDate(date: Date | string | number, options?: FormatDateOptions): string;
28
+ /**
29
+ * Parses a date value the way every date coming from these platforms'
30
+ * Java/Kotlin backends actually shows up, without the classic off-by-one
31
+ * timezone bug.
32
+ *
33
+ * A bare "YYYY-MM-DD" string is parsed by `new Date(...)` as UTC midnight
34
+ * (per the ECMAScript spec), which then shifts a day earlier once formatted
35
+ * in any timezone behind UTC. This function parses date-only strings (and
36
+ * Jackson's `[year, month, day, ...]` LocalDate/LocalDateTime array
37
+ * serialization) as local calendar components instead. Full ISO datetime
38
+ * strings (with a time and/or timezone), Date objects, and numeric
39
+ * timestamps are unaffected and still go through the normal `new Date(...)`
40
+ * parse.
41
+ */
42
+ export declare function parseDateSafe(date: Date | string | number | number[]): Date;
43
+ export declare function formatDate(date: Date | string | number | number[], options?: FormatDateOptions): string;
29
44
  /**
30
45
  * Utility function to debounce function calls
31
46
  * @param func - Function to debounce
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,aAAa,EACb,iCAAiC,EACjC,gCAAgC,EAChC,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,sBAAsB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G,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EAChE,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAMlC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAQ,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAE7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMzD;AAED;;GAEG;AACH,oBAAY,SAAS;IACnB,UAAU,OAAO;IACjB,UAAU,OAAO;IACjB,UAAU,OAAO;IACjB,UAAU,OAAO;IACjB,WAAW,QAAQ;IACnB,WAAW,QAAQ;IACnB,UAAU,OAAO;IACjB,UAAU,OAAO;IACjB,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,EAUlC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ews-admin/global-design-system",
3
- "version": "1.19.0",
3
+ "version": "1.22.1",
4
4
  "description": "EWS Global Design System - Reusable components for EWS applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -0,0 +1,77 @@
1
+ import React from "react";
2
+ import { AlertTriangle, X } from "lucide-react";
3
+
4
+ /**
5
+ * The banner is purely presentational: the caller decides when to render it
6
+ * (e.g. due date within 7 days or overdue) and provides already-translated
7
+ * labels.
8
+ */
9
+ export interface PaymentDueBannerProps {
10
+ title: string;
11
+ subtitle?: string;
12
+ /** Extra warning line shown under the subtitle (e.g. discount loss). */
13
+ warning?: string;
14
+ ctaLabel: string;
15
+ onCtaClick: () => void;
16
+ /** When omitted, the dismiss button is not rendered. */
17
+ onDismiss?: () => void;
18
+ dismissLabel?: string;
19
+ }
20
+
21
+ /**
22
+ * Full-width payment reminder banner (red gradient) used above the app
23
+ * content when a licence payment is due soon or overdue.
24
+ */
25
+ const PaymentDueBanner: React.FC<PaymentDueBannerProps> = ({
26
+ title,
27
+ subtitle,
28
+ warning,
29
+ ctaLabel,
30
+ onCtaClick,
31
+ onDismiss,
32
+ dismissLabel = "Close",
33
+ }) => (
34
+ <div
35
+ data-testid="payment-banner"
36
+ className="overflow-hidden bg-gradient-to-r from-red-600 to-red-700 shadow-lg"
37
+ >
38
+ <div className="px-6 py-8 sm:px-8">
39
+ <div className="flex flex-col space-y-6 sm:flex-row sm:items-center sm:justify-between sm:space-y-0">
40
+ {/* Left: icon + text */}
41
+ <div className="flex items-center space-x-4">
42
+ <AlertTriangle className="w-8 h-8 text-white shrink-0" />
43
+ <div className="flex-1 min-w-0">
44
+ <h3 className="text-2xl font-bold text-white">{title}</h3>
45
+ {subtitle && (
46
+ <p className="mt-2 text-base text-red-100">{subtitle}</p>
47
+ )}
48
+ {warning && (
49
+ <p className="mt-1 text-sm font-medium text-red-200">{warning}</p>
50
+ )}
51
+ </div>
52
+ </div>
53
+
54
+ {/* Right: actions */}
55
+ <div className="flex flex-col flex-shrink-0 gap-3 sm:flex-row sm:gap-4 sm:items-center">
56
+ <button
57
+ onClick={onCtaClick}
58
+ className="w-full px-8 py-3 text-base font-semibold text-red-600 bg-white rounded-lg shadow-sm transition-all duration-200 sm:w-auto hover:bg-red-50 hover:shadow-md"
59
+ >
60
+ {ctaLabel}
61
+ </button>
62
+ {onDismiss && (
63
+ <button
64
+ onClick={onDismiss}
65
+ className="self-start p-2 rounded-full transition-colors bg-white/10 hover:bg-white/20 sm:self-auto"
66
+ aria-label={dismissLabel}
67
+ >
68
+ <X className="w-5 h-5 text-white" />
69
+ </button>
70
+ )}
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ );
76
+
77
+ export { PaymentDueBanner };
@@ -0,0 +1,2 @@
1
+ export { PaymentDueBanner } from "./PaymentDueBanner";
2
+ export type { PaymentDueBannerProps } from "./PaymentDueBanner";
package/src/index.ts CHANGED
@@ -49,6 +49,9 @@ export type { TagProps } from "./components/Tag";
49
49
  export { TagList } from "./components/TagList";
50
50
  export type { TagListProps } from "./components/TagList";
51
51
 
52
+ export { PaymentDueBanner } from "./components/PaymentDueBanner";
53
+ export type { PaymentDueBannerProps } from "./components/PaymentDueBanner";
54
+
52
55
  // Molecules
53
56
  export { SpecialtySearchAutocomplete } from "./molecules";
54
57
  export type { Specialty, SpecialtySearchAutocompleteProps } from "./molecules";
@@ -76,6 +79,7 @@ export {
76
79
  getRegionOptions,
77
80
  getRegionsByCountry,
78
81
  isValidPhoneNumber,
82
+ parseDateSafe,
79
83
  SupportedCountry,
80
84
  } from "./utils";
81
85
  export type {
@@ -51,12 +51,46 @@ export interface FormatDateOptions extends Intl.DateTimeFormatOptions {
51
51
  locale?: string | string[];
52
52
  }
53
53
 
54
+ /**
55
+ * Parses a date value the way every date coming from these platforms'
56
+ * Java/Kotlin backends actually shows up, without the classic off-by-one
57
+ * timezone bug.
58
+ *
59
+ * A bare "YYYY-MM-DD" string is parsed by `new Date(...)` as UTC midnight
60
+ * (per the ECMAScript spec), which then shifts a day earlier once formatted
61
+ * in any timezone behind UTC. This function parses date-only strings (and
62
+ * Jackson's `[year, month, day, ...]` LocalDate/LocalDateTime array
63
+ * serialization) as local calendar components instead. Full ISO datetime
64
+ * strings (with a time and/or timezone), Date objects, and numeric
65
+ * timestamps are unaffected and still go through the normal `new Date(...)`
66
+ * parse.
67
+ */
68
+ export function parseDateSafe(
69
+ date: Date | string | number | number[]
70
+ ): Date {
71
+ if (Array.isArray(date)) {
72
+ const [y, m, d, h = 0, min = 0, s = 0] = date;
73
+ return new Date(y, m - 1, d, h, min, s);
74
+ }
75
+ if (typeof date === "string") {
76
+ const dateOnlyMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(date);
77
+ if (dateOnlyMatch) {
78
+ return new Date(
79
+ Number(dateOnlyMatch[1]),
80
+ Number(dateOnlyMatch[2]) - 1,
81
+ Number(dateOnlyMatch[3])
82
+ );
83
+ }
84
+ }
85
+ return new Date(date);
86
+ }
87
+
54
88
  export function formatDate(
55
- date: Date | string | number,
89
+ date: Date | string | number | number[],
56
90
  options?: FormatDateOptions
57
91
  ): string {
58
92
  const { locale = "en-US", ...intlOptions } = options ?? {};
59
- const dateObj = new Date(date);
93
+ const dateObj = parseDateSafe(date);
60
94
  return new Intl.DateTimeFormat(locale, {
61
95
  year: "numeric",
62
96
  month: "long",