@leapdevuk/component-toolbox 0.0.125 → 0.0.127

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/CHANGELOG.md CHANGED
@@ -1,62 +1,69 @@
1
1
  # Changelog
2
2
 
3
- ## 0.0.125 (2025-07-09)
3
+ ## 0.0.127 (2025-07-16)
4
4
 
5
5
  ### Features
6
6
 
7
- - Utility function formatReportDate now accepts a locale object, replacing the previous locale code string
7
+ - Utility function to format date as regional local time getFormattedLocalDateTime
8
8
 
9
- ## 0.0.124 (2025-07-08)
9
+ ## 0.0.126 (2025-07-09)
10
10
 
11
11
  ### Features
12
12
 
13
- - Added utility function formatReportDate to regionally format dates for reporting
13
+ - Utility function formatReportDate now accepts an undefined locale object when creating state data objects when the locale is not yet available.
14
+ If not present, it will return a console warning and an empty string.
14
15
 
15
- ## 0.0.112 (2025-04-15)
16
+ ## 0.0.125 (2025-07-09)
16
17
 
17
- ### Release
18
+ ### Features
18
19
 
19
- - Test verions release 0.0.111-test.5
20
+ - Utility function formatReportDate now accepts a locale object, replacing the previous locale code string
20
21
 
21
- ## 0.0.111-test.5 (2025-04-15)
22
+ ## 0.0.124 (2025-07-08)
22
23
 
23
24
  ### Features
24
25
 
25
- - Added support for change log.
26
+ - Added utility function formatReportDate to regionally format dates for reporting
27
+
28
+ ## 0.0.122 (2025-06-20)
26
29
 
27
30
  ### Bug Fixes
28
31
 
29
- - DateRangePicker: Split update property to fromDate and toDate (was initially a combined function)
30
- - DateRangePicker: Fixed dateTime when region is summer/winter time (checking against local dateTime)
31
- - DatePicker: Fixed dateTime when region is summer/winter time (checking against local dateTime)
32
+ - Updated size of the preview icon
32
33
 
33
- ## 0.0.113 (2025-05-14)
34
+ ## 0.0.121 (2025-04-15)
34
35
 
35
- ### Features
36
+ ### Release 0.0.121
36
37
 
37
- - Added property on AccordionTable to support component props on grid (row: onMouseOver, onMouseLeave ect.)
38
+ - Release of Test verion 0.0.121-test.1
38
39
 
39
- ## 0.0.114 (2025-05-21)
40
+ ## 0.0.120 (2025-05-30)
40
41
 
41
42
  ### Features
42
43
 
43
- - Added parameter on getLocalDisplayFormattedDateTime to specify if time should be adjusted on local time zone
44
+ - Updated DateRangePicker to use sdk alerts for validation
44
45
 
45
- ## 0.0.115 (2025-05-22)
46
+ ## 0.0.120 (2025-05-29)
46
47
 
47
- ### Removed
48
+ ### Bug Fixes
48
49
 
49
- - getLocalDisplayFormattedDateTime
50
+ - Fixed issue with revert being called early on calendar selection
50
51
 
51
- ### Added
52
+ ## 0.0.119 (2025-05-29)
52
53
 
53
- - lctFormatDateTime supporting 24 hours, UTC & DateOnly
54
+ ### Bug Fixes
54
55
 
55
- ## 0.0.116 (2025-05-22)
56
+ - Fixed Calendar reverting to the original year instead of the selected one
56
57
 
57
58
  ### Features
58
59
 
59
- - Added property on NumberDisplay 'noValueText' to work alongside 'hideNoValue' to display an alternative character on zero values
60
+ - Updated DatePicker to use sdk alerts for validation
61
+
62
+ ## 0.0.118 (2025-05-23)
63
+
64
+ ### Bug Fixes
65
+
66
+ - Updated DatePicker to not show calendar icon when disabled
60
67
 
61
68
  ## 0.0.117 (2025-05-23)
62
69
 
@@ -64,42 +71,48 @@
64
71
 
65
72
  - Added formatAsDBDate for use in apps (accepts Date, returns string formatted "yyyy-MM-dd")
66
73
 
67
- ## 0.0.118 (2025-05-23)
74
+ ## 0.0.116 (2025-05-22)
68
75
 
69
- ### Bug Fixes
76
+ ### Features
70
77
 
71
- - Updated DatePicker to not show calendar icon when disabled
78
+ - Added property on NumberDisplay 'noValueText' to work alongside 'hideNoValue' to display an alternative character on zero values
72
79
 
73
- ## 0.0.119 (2025-05-29)
80
+ ## 0.0.115 (2025-05-22)
74
81
 
75
- ### Bug Fixes
82
+ ### Removed
76
83
 
77
- - Fixed Calendar reverting to the original year instead of the selected one
84
+ - getLocalDisplayFormattedDateTime
78
85
 
79
- ### Features
86
+ ### Added
80
87
 
81
- - Updated DatePicker to use sdk alerts for validation
88
+ - lctFormatDateTime supporting 24 hours, UTC & DateOnly
82
89
 
83
- ## 0.0.120 (2025-05-29)
90
+ ## 0.0.114 (2025-05-21)
84
91
 
85
- ### Bug Fixes
92
+ ### Features
86
93
 
87
- - Fixed issue with revert being called early on calendar selection
94
+ - Added parameter on getLocalDisplayFormattedDateTime to specify if time should be adjusted on local time zone
88
95
 
89
- ## 0.0.120 (2025-05-30)
96
+ ## 0.0.113 (2025-05-14)
90
97
 
91
98
  ### Features
92
99
 
93
- - Updated DateRangePicker to use sdk alerts for validation
100
+ - Added property on AccordionTable to support component props on grid (row: onMouseOver, onMouseLeave ect.)
94
101
 
95
- ## 0.0.121 (2025-04-15)
102
+ ## 0.0.112 (2025-04-15)
96
103
 
97
- ### Release 0.0.121
104
+ ### Release
98
105
 
99
- - Release of Test verion 0.0.121-test.1
106
+ - Test verions release 0.0.111-test.5
100
107
 
101
- ## 0.0.122 (2025-06-20)
108
+ ## 0.0.111-test.5 (2025-04-15)
109
+
110
+ ### Features
111
+
112
+ - Added support for change log.
102
113
 
103
114
  ### Bug Fixes
104
115
 
105
- - Updated size of the preview icon
116
+ - DateRangePicker: Split update property to fromDate and toDate (was initially a combined function)
117
+ - DateRangePicker: Fixed dateTime when region is summer/winter time (checking against local dateTime)
118
+ - DatePicker: Fixed dateTime when region is summer/winter time (checking against local dateTime)
@@ -7,3 +7,4 @@ export { parseDate as lctParseDate } from './utils';
7
7
  export { utcFormat as lctUTCFormat } from './utils';
8
8
  export { dbDateOnlyFormat as lctDbDateOnlyFormat } from './utils';
9
9
  export { formatAsDBDate as lctFormatAsDBDate } from './utils';
10
+ export { getFormattedLocalDateTime as lctGetFormattedLocalDateTime } from './utils';
@@ -6,26 +6,193 @@ export declare const minDateAsObject: Date;
6
6
  export declare const timezone: string;
7
7
  export declare const utcFormat = "yyyy-MM-dd HH:mm:ss";
8
8
  export declare const dbDateOnlyFormat = "yyyy-MM-dd";
9
+ /**
10
+ * This function returns the minimum date as a string formatted in the default date format.
11
+ * It is useful for setting a minimum date in date pickers or other date-related components.
12
+ * @returns (string): The minimum date formatted as a string in the default date format.
13
+ * @example
14
+ * ```typescript
15
+ * const minDate = getMinDate(); // Returns "01/01/1900"
16
+ * ```
17
+ */
9
18
  export declare const minDate: string;
10
19
  export declare const oneWeek: string;
11
20
  export declare const today: string;
12
21
  export declare const tomorrow: string;
13
22
  export declare const twoWeeks: string;
23
+ /**
24
+ * This function returns the current date formatted as a string based on the provided format.
25
+ * @param formatString (optional) The format string to use for the date. Defaults to "dd/MM/yyyy".
26
+ * It is useful for getting the current date in a specific format, such as "dd/MM/yyyy" or "MM/dd/yyyy".
27
+ * If no format string is provided, it defaults to "dd/MM/yyyy".
28
+ * @returns (string): The current date formatted as a string.
29
+ * It can be used in various contexts, such as displaying the current date in a user interface or storing it in a database.
30
+ * @example
31
+ * ```typescript
32
+ * const formattedDate = defaultDate(); // Returns the current date in "dd/MM/yyyy" format
33
+ * const formattedDateUS = defaultDate("MM/dd/yyyy"); // Returns the current date in "MM/dd/yyyy" format
34
+ * ```
35
+ */
14
36
  export declare const defaultDate: (formatString?: string) => string;
37
+ /**
38
+ * This function formats a date based on the provided parameters.
39
+ * It can format the date to the start or end of the day, handle UTC dates,
40
+ * and format it as a date-only string.
41
+ * It is useful for displaying dates in a specific format,
42
+ * such as in a date picker or when saving dates to a database.
43
+ * @param date (Date | null | undefined): The date to format. If null or undefined, it returns null.
44
+ * @param startOfDate (boolean): If true, formats the date to the start of the day.
45
+ * @param endOfDate (boolean): If true, formats the date to the end of the day.
46
+ * @param isUTC (boolean): If true, formats the date in UTC format.
47
+ * @param dateOnly (boolean): If true, formats the date as a date-only string (e.g., "yyyy-MM-dd").
48
+ * This is useful for scenarios where you need to display or store only the date part without the time.
49
+ * It can be used in various contexts, such as displaying dates in a user interface or saving them to a database.
50
+ * @example
51
+ * ```typescript
52
+ * const formattedDate = formatDate(new Date(), true, false, false, true); // Formats the current date to the start of the day as a date-only string
53
+ * const formattedUTCDate = formatDate(new Date(), false, false, true); // Formats the current date in UTC format
54
+ * const formattedEndDate = formatDate(new Date(), false, true); // Formats the current date to the end of the day
55
+ * ```
56
+ * @returns (string | null): A formatted date string based on the provided parameters. If the input date is null or undefined, it returns null.
57
+ */
15
58
  export declare const formatDate: (date?: Date | null, startOfDate?: boolean, endOfDate?: boolean, isUTC?: boolean, dateOnly?: boolean) => string | null;
59
+ /**
60
+ * This function parses a date string into a Date object based on the provided format.
61
+ * It splits the date string into parts (day, month, year) and constructs a Date object.
62
+ * If the date string is invalid or cannot be parsed, it returns null.
63
+ * It also handles two-digit years by converting them to four-digit years.
64
+ * @param date (any): The date string to parse. It can be in various formats (e.g., "dd/MM/yyyy", "MM/dd/yyyy").
65
+ * @param formatString (string): The format string to use for parsing the date.
66
+ * @param localDateformat (string): The local date format to use for parsing. It should match the format of the input date string.
67
+ * @param parseKeyboardVal (boolean): Whether to parse the date from a keyboard input. Defaults to false.
68
+ * @returns (string | null): Returns a formatted date string if parsing is successful, or null if the input is invalid.
69
+ * This function is useful for converting user input or string representations of dates into a Date object.
70
+ * It can handle various date formats and ensures that the resulting Date object is valid.
71
+ * If the input date string is invalid or cannot be parsed, it returns null.
72
+ * It also includes logic to handle two-digit years by converting them to four-digit years.
73
+ * @example
74
+ * ```typescript
75
+ * const parsedDate = parseDate("25/12/2023", "dd/MM/yyyy", "dd/MM/yyyy");
76
+ * console.log(parsedDate); // Returns "2023-12-25" in the "yyyy-MM-dd" format
77
+ * const parsedDateUS = parseDate("12/25/23", "MM/dd/yyyy", "MM/dd/yyyy");
78
+ * console.log(parsedDateUS); // Returns "2023-12-25" in the "yyyy-MM-dd" format
79
+ * const parsedInvalidDate = parseDate("31/02/2023", "dd/MM/yyyy", "dd/MM/yyyy");
80
+ * console.log(parsedInvalidDate); // Returns null, as February 31st is invalid
81
+ * ```
82
+ */
16
83
  export declare const parseDate: (date: any, formatString: string | undefined, localDateformat: string, parseKeyboardVal?: boolean) => string | null;
84
+ /**
85
+ * This function returns a locale object based on the provided LeapContext.
86
+ * It checks the hostInfo.region and returns the corresponding locale with weekStartsOn set to 1.
87
+ * If the region is not recognized, it returns undefined.
88
+ * @param leapContext (LeapContext | undefined): The LeapContext object containing hostInfo with region information.
89
+ * @returns The function supports UK, US, AU (including NZ), and CA regions. If the region is not recognized, it returns undefined.
90
+ * @example
91
+ * ```typescript
92
+ * const locale = getLocale(leapContext); // Returns the appropriate locale based on the region
93
+ * const localeUS = getLocale({ hostInfo: { region: "us" } }); // Returns enUS locale
94
+ * const localeUK = getLocale({ hostInfo: { region: "uk" } }); // Returns enGB locale
95
+ * const localeAU = getLocale({ hostInfo: { region: "au" } }); // Returns enAU locale
96
+ * const localeCA = getLocale({ hostInfo: { region: "ca" } }); // Returns enGB locale
97
+ * ```
98
+ */
17
99
  export declare const getLocale: (leapContext?: LeapContext) => Locale | undefined;
100
+ /**
101
+ * This function formats a date or datetime value into a string based on the provided locale.
102
+ * It supports both date-only and datetime formats, and can handle UTC dates.
103
+ * @param value (string | Date | undefined): The date or datetime value to format.
104
+ * @param locale (Locale | undefined): The locale to use for formatting. If undefined, it will not format the date.
105
+ * @param isUtc (boolean): Whether the date is in UTC format. Defaults to true.
106
+ * @param dateOnly (boolean): Whether to format the value as a date only.
107
+ * @param show24H (boolean): Whether to show the time in 24-hour format. Defaults to false.
108
+ * @returns (string): A formatted date or datetime string. If the input value is invalid or locale is undefined, it returns an empty string.
109
+ * @example
110
+ * ```typescript
111
+ * const formattedDate = lctFormatDateTime(new Date(), enGB, true, false, true); // Returns "01/01/2023 14:30"
112
+ * const formattedDateTime = lctFormatDateTime("2023-01-01T14:30:00Z", enUS, true, false, false); // Returns "01/01/2023 02:30 PM"
113
+ * const formattedDateOnly = lctFormatDateTime("2023-01-01", enAU, false, true); // Returns "01/01/2023"
114
+ * const formattedInvalid = lctFormatDateTime(undefined, enGB); // Returns ""
115
+ * ```
116
+ */
18
117
  export declare const lctFormatDateTime: (value?: string | Date, locale?: Locale, isUtc?: boolean, dateOnly?: boolean, show24H?: boolean) => string;
19
- export declare const formatReportDate: (date: string | null, locale: Locale) => string;
118
+ /**
119
+ * This function formats a date string into a report-friendly format based on the provided locale.
120
+ * It handles both ISO date strings and strings in the format "yyyy-MM-dd".
121
+ *
122
+ * @param date (string | null): The date string to format. It can be in ISO format or "yyyy-MM-dd".
123
+ * @param locale (Locale | undefined): The locale to use for formatting. If undefined, it will not format the date.
124
+ * @returns (string): A formatted date string. If the input date is invalid or locale is undefined, it returns an empty string and logs a warning.
125
+ * @example
126
+ * ```typescript
127
+ * const formattedReportDate = formatReportDate("2023-12-25", enGB); // Returns "25-12-2023"
128
+ * const formattedReportDateISO = formatReportDate("2023-12-25T00:00:00Z", enUS); // Returns "12-25-2023"
129
+ * const formattedReportDateInvalid = formatReportDate("31-02-2023", enGB); // Returns "", logs warning
130
+ * const formattedReportDateNull = formatReportDate(null, enGB); // Returns "", logs warning
131
+ * ```
132
+ */
133
+ export declare const formatReportDate: (date: string | null, locale?: Locale) => string;
20
134
  /**
21
135
  * @deprecated The method should not be used
22
136
  */
23
137
  export declare const getDateTimeWithOffset: (date: string) => Date;
138
+ /**
139
+ * This function checks if a string is null or undefined.
140
+ * It returns true if the string is null, undefined, or an empty string.
141
+ * @param value (string | null | undefined): The string to check.
142
+ * @returns (boolean): Returns true if the string is null, undefined, or empty; otherwise, false.
143
+ * @example
144
+ * ```typescript
145
+ * const isNullOrUndefined = isStringNullOrUndefined(null); // Returns true
146
+ * const isEmptyString = isStringNullOrUndefined(""); // Returns true
147
+ * const isValidString = isStringNullOrUndefined("Hello"); // Returns false
148
+ * ```
149
+ */
24
150
  export declare const isStringNullOrUndefined: (value?: string | null) => boolean;
151
+ /**
152
+ * This function formats a date as a string in the "yyyy-MM-dd" format, suitable for database storage.
153
+ * It takes a Date object as input and returns the formatted string.
154
+ * @param date (Date): The date to format.
155
+ * @returns (string): A formatted date string in the "yyyy-MM-dd" format.
156
+ * @example
157
+ * ```typescript
158
+ * const dbFormattedDate = formatAsDBDate(new Date()); // Returns "2023-12-25"
159
+ * const dbFormattedDateInvalid = formatAsDBDate(new Date("Invalid Date")); // Returns "Invalid date"
160
+ * ```
161
+ */
25
162
  export declare const formatAsDBDate: (date: Date) => string;
163
+ export declare const getFormattedLocalDateTime: (value?: string | Date, locale?: Locale, isUtc?: boolean, dateOnly?: boolean, show24H?: boolean, formatString?: string, formatStartOfDay?: boolean, formatEndOfDay?: boolean) => string;
164
+ /**
165
+ * This enum defines the types of buttons available in the dialog.
166
+ * It is used to identify which button was clicked by the user.
167
+ */
26
168
  export declare enum DialogButtonType {
27
169
  Confirm = 1,
28
170
  Refuse = 2,
29
171
  Cancel = 3
30
172
  }
173
+ /**
174
+ * This function shows a 3-button alert dialog using the Leap SDK.
175
+ * It allows the user to confirm, refuse, or cancel an action.
176
+ * It takes a message, button texts, and callbacks for each action.
177
+ * @param message (string): The message to display in the dialog.
178
+ * @param confirmButtonText (string): The text for the confirm button.
179
+ * @param confirmCallback (function): The callback function to execute when the confirm button is clicked.
180
+ * @param refuseButtonText (string): The text for the refuse button. Optional.
181
+ * @param refuseCallback (function): The callback function to execute when the refuse button is clicked. Optional.
182
+ * @param cancelButtonText (string): The text for the cancel button. Optional.
183
+ * @param sdkApi (Api): The Leap SDK API instance to use for showing the dialog.
184
+ * @returns A promise that resolves when the dialog is closed.
185
+ * @example
186
+ * ```typescript
187
+ * show3buttonAlert(
188
+ * "Are you sure you want to proceed?",
189
+ * "Yes",
190
+ * () => console.log("Confirmed"),
191
+ * "No",
192
+ * () => console.log("Refused"),
193
+ * "Cancel",
194
+ * sdkApi
195
+ * );
196
+ * ```
197
+ */
31
198
  export declare const show3buttonAlert: (message: string, confirmButtonText: string, confirmCallback: () => void, refuseButtonText?: string, refuseCallback?: () => void, cancelButtonText?: string, sdkApi?: Api) => Promise<void> | undefined;