@leapdevuk/component-toolbox 0.0.130 → 0.0.132
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/README.md +3 -0
- package/dist/CHANGELOG.md +12 -0
- package/dist/components/datagrid/DataGrid.d.ts +1 -0
- package/dist/components/datepicker/DatePicker.d.ts +52 -0
- package/dist/components/datepicker/utils.d.ts +220 -209
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +5 -6
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.132 (2025-10-16)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Update DataGrid add params to allow setting of hideFooter, defaults to true
|
|
8
|
+
|
|
9
|
+
## 0.0.131 (2025-08-13)
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- AppBar 'help' link to access the application's help content is now centered within the parent bar.
|
|
14
|
+
|
|
3
15
|
## 0.0.130 (2025-07-17)
|
|
4
16
|
|
|
5
17
|
### Features
|
|
@@ -22,6 +22,7 @@ interface IDataGridProps {
|
|
|
22
22
|
keepNonExistentRowsSelected?: boolean;
|
|
23
23
|
onRowSelectionModelChange?: (rowSelectionModel: GridRowSelectionModel, details: GridCallbackDetails) => void;
|
|
24
24
|
noRowsOverlay?: React.JSXElementConstructor<GridSlotProps["noRowsOverlay"]>;
|
|
25
|
+
hideFooter?: boolean;
|
|
25
26
|
}
|
|
26
27
|
declare const LCTDataGrid: import('@emotion/styled').StyledComponent<IDataGridProps & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
27
28
|
export default LCTDataGrid;
|
|
@@ -31,5 +31,57 @@ interface IDatePickerProps {
|
|
|
31
31
|
locale?: Locale;
|
|
32
32
|
sdk?: Api;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Leap Component for DatePicker
|
|
36
|
+
* @param disabled - If true, the date picker is disabled.
|
|
37
|
+
* @param fullWidth - If true, the date picker will take the full width of its container.
|
|
38
|
+
* @param isUTC - If true, the date will be treated as UTC.
|
|
39
|
+
* @param startOfDate - If true, the date will be set to the start of the day.
|
|
40
|
+
* @param endOfDate - If true, the date will be set to the end of the day.
|
|
41
|
+
* @param dateOnly - If true, the time part will be ignored.
|
|
42
|
+
* @param onUpdate - Callback function to update the date value.
|
|
43
|
+
* @param additionalActions - Additional actions to be displayed in the date picker.
|
|
44
|
+
* @param size - Size of the date picker, can be "small" or "medium".
|
|
45
|
+
* @param validate30Days - If true, it will validate that the selected date is not more than 30 days in the future.
|
|
46
|
+
* @param validate - Custom validation function that returns an error if the date is invalid.
|
|
47
|
+
* @param value - The current value of the date picker.
|
|
48
|
+
* @param locale - Locale for date formatting.
|
|
49
|
+
* @param sdk - The Leap SDK instance for API interactions.
|
|
50
|
+
* @returns A DatePicker component that allows users to select a date with optional validation and additional actions.
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <LCTDatePicker
|
|
54
|
+
* disabled={false}
|
|
55
|
+
* fullWidth={true}
|
|
56
|
+
* isUTC={false}
|
|
57
|
+
* startOfDate={true}
|
|
58
|
+
* endOfDate={false}
|
|
59
|
+
* dateOnly={false}
|
|
60
|
+
* onUpdate={(value) => console.log(value)}
|
|
61
|
+
* additionalActions={{
|
|
62
|
+
* showToday: true,
|
|
63
|
+
* showClear: true,
|
|
64
|
+
* customActions: [
|
|
65
|
+
* { label: "Last 7 Days", value: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) },
|
|
66
|
+
* { label: "Last 30 Days", value: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) },
|
|
67
|
+
* ],
|
|
68
|
+
* }}
|
|
69
|
+
* size="small"
|
|
70
|
+
* validate30Days={true}
|
|
71
|
+
* validate={(value) => {
|
|
72
|
+
* if (value && new Date(value) > new Date(Date.now() + 30 * 24 * 60 * 60 * 1000)) {
|
|
73
|
+
* return { keepButton: true, message: "Date cannot be more than 30 days in the future." };
|
|
74
|
+
* }
|
|
75
|
+
* return null;
|
|
76
|
+
* }}
|
|
77
|
+
* value={null}
|
|
78
|
+
* locale={enGB} // or any other locale
|
|
79
|
+
* sdk={leapSdkInstance} // Leap SDK instance
|
|
80
|
+
* />
|
|
81
|
+
*
|
|
82
|
+
* This component provides a user-friendly date selection interface with validation and additional actions like "Today" and "Clear".
|
|
83
|
+
* It supports both date and datetime formats, and can be customized with locale settings.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
34
86
|
declare const LCTDatePicker: FC<IDatePickerProps>;
|
|
35
87
|
export default LCTDatePicker;
|
|
@@ -1,204 +1,213 @@
|
|
|
1
1
|
import { Api, LeapContext } from '@leapdev/leap-host';
|
|
2
2
|
import { Locale } from 'date-fns';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
4
|
+
* This constant defines the string used to represent an invalid date.
|
|
5
|
+
* It is used to indicate that a date value is not valid or cannot be parsed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const invalidDate = "Invalid date";
|
|
8
|
+
/**
|
|
9
|
+
* This constant defines the date format used for database storage.
|
|
10
|
+
* It is used to ensure consistent date formatting across the application,
|
|
11
|
+
* especially when interacting with databases or APIs that require a specific date format.
|
|
7
12
|
*/
|
|
8
13
|
export declare const dbDateOnlyFormat = "yyyy-MM-dd";
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
15
|
+
* This constant defines the default date format used in the application.
|
|
16
|
+
* It is used for displaying dates in the user interface and for formatting dates in various components.
|
|
12
17
|
*/
|
|
13
18
|
export declare const defaultDateFormat = "dd/MM/yyyy";
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
20
|
+
* This constant defines the default date and time format used in the application.
|
|
21
|
+
* It is used for displaying both date and time in the user interface and for formatting datetime values
|
|
17
22
|
*/
|
|
18
23
|
export declare const defaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
|
19
24
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* This constant defines the minimum date that can be used in the application.
|
|
26
|
+
* It is set to January 1, 1900, and is used to ensure that date inputs do not go below this value.
|
|
27
|
+
* It is useful for setting a minimum date in date pickers or other date-related components.
|
|
23
28
|
*/
|
|
24
29
|
export declare const minDateAsObject: Date;
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* This constant defines the timezone used in the application.
|
|
32
|
+
* It is derived from the user's system settings and is used for formatting dates and times in the user's local timezone.
|
|
33
|
+
* It ensures that date and time values are displayed correctly based on the user's timezone.
|
|
29
34
|
*/
|
|
30
35
|
export declare const timezone: string;
|
|
31
36
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
37
|
+
* This constant defines the UTC format used for date and time values in the application.
|
|
38
|
+
* It is used to ensure that date and time values are stored and displayed in a consistent UTC format.
|
|
34
39
|
*/
|
|
35
40
|
export declare const utcFormat = "yyyy-MM-dd HH:mm:ss";
|
|
36
41
|
/**
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* This constant defines the UTC timezone used in the application.
|
|
43
|
+
*/
|
|
44
|
+
export declare const utcTimeZone = "Etc/UTC";
|
|
45
|
+
/**
|
|
46
|
+
* This function returns the minimum date as a string formatted in the default date format.
|
|
47
|
+
* It is useful for setting a minimum date in date pickers or other date-related components.
|
|
48
|
+
* @returns (string): The minimum date formatted as a string in the default date format.
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const minDateValue = minDate; // Returns "01/01/1900"
|
|
52
|
+
* ```
|
|
44
53
|
*/
|
|
45
54
|
export declare const minDate: string;
|
|
46
55
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
+
* This function returns a date that is one week from today, formatted as a string.
|
|
57
|
+
* It is useful for scenarios where you need to calculate a date one week in the future,
|
|
58
|
+
* such as setting deadlines or reminders.
|
|
59
|
+
* @returns (string): A formatted date string representing one week from today.
|
|
60
|
+
* It can be used in various contexts, such as displaying future dates in a user interface or calculating due dates.
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const oneWeekFromToday = oneWeek; // Returns "dd/MM/yyyy" format of the date one week from today
|
|
64
|
+
* ```
|
|
56
65
|
*/
|
|
57
66
|
export declare const oneWeek: string;
|
|
58
67
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
68
|
+
* This function returns today's date formatted as a string in the default date format.
|
|
69
|
+
* It is useful for displaying the current date in a user interface or for date calculations.
|
|
70
|
+
* @returns (string): Today's date formatted as a string in the default date format.
|
|
71
|
+
* It can be used in various contexts, such as displaying the current date in a user interface or calculating date differences.
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const todayDate = today; // Returns "dd/MM/yyyy" format of today's date
|
|
75
|
+
* ```
|
|
67
76
|
*/
|
|
68
77
|
export declare const today: string;
|
|
69
78
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
+
* This function returns a date that is one day from today, formatted as a string.
|
|
80
|
+
* It is useful for scenarios where you need to calculate a date one day in the future,
|
|
81
|
+
* such as setting deadlines or reminders.
|
|
82
|
+
* @returns (string): A formatted date string representing tomorrow's date.
|
|
83
|
+
* It can be used in various contexts, such as displaying future dates in a user interface or calculating due dates.
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const tomorrowDate = tomorrow; // Returns "dd/MM/yyyy" format of the date tomorrow
|
|
87
|
+
* ```
|
|
79
88
|
*/
|
|
80
89
|
export declare const tomorrow: string;
|
|
81
90
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
+
* This function returns a date that is two weeks from today, formatted as a string.
|
|
92
|
+
* It is useful for scenarios where you need to calculate a date two weeks in the future,
|
|
93
|
+
* such as setting deadlines or reminders.
|
|
94
|
+
* @returns (string): A formatted date string representing two weeks from today.
|
|
95
|
+
* It can be used in various contexts, such as displaying future dates in a user interface or calculating due dates.
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const twoWeeksFromToday = twoWeeks; // Returns "dd/MM/yyyy" format of the date two weeks from today
|
|
99
|
+
* ```
|
|
91
100
|
*/
|
|
92
101
|
export declare const twoWeeks: string;
|
|
93
102
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
103
|
+
* This function returns the current date formatted as a string based on the provided format.
|
|
104
|
+
* @param formatString (optional) The format string to use for the date. Defaults to "dd/MM/yyyy".
|
|
105
|
+
* It is useful for getting the current date in a specific format, such as "dd/MM/yyyy" or "MM/dd/yyyy".
|
|
106
|
+
* If no format string is provided, it defaults to "dd/MM/yyyy".
|
|
107
|
+
* @returns (string): The current date formatted as a string.
|
|
108
|
+
* It can be used in various contexts, such as displaying the current date in a user interface or storing it in a database.
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const formattedDate = defaultDate(); // Returns the current date in "dd/MM/yyyy" format
|
|
112
|
+
* const formattedDateUS = defaultDate("MM/dd/yyyy"); // Returns the current date in "MM/dd/yyyy" format
|
|
113
|
+
* ```
|
|
105
114
|
*/
|
|
106
115
|
export declare const defaultDate: (formatString?: string) => string;
|
|
107
116
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
117
|
+
* This function formats a date based on the provided parameters.
|
|
118
|
+
* It can format the date to the start or end of the day, handle UTC dates,
|
|
119
|
+
* and format it as a date-only string.
|
|
120
|
+
* It is useful for displaying dates in a specific format,
|
|
121
|
+
* such as in a date picker or when saving dates to a database.
|
|
122
|
+
* @param date (Date | null | undefined): The date to format. If null or undefined, it returns null.
|
|
123
|
+
* @param startOfDate (boolean): If true, formats the date to the start of the day.
|
|
124
|
+
* @param endOfDate (boolean): If true, formats the date to the end of the day.
|
|
125
|
+
* @param isUTC (boolean): If true, formats the date in UTC format.
|
|
126
|
+
* @param dateOnly (boolean): If true, formats the date as a date-only string (e.g., "yyyy-MM-dd").
|
|
127
|
+
* This is useful for scenarios where you need to display or store only the date part without the time.
|
|
128
|
+
* It can be used in various contexts, such as displaying dates in a user interface or saving them to a database.
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const formattedDate = formatDate(new Date(), true, false, false, true); // Formats the current date to the start of the day as a date-only string
|
|
132
|
+
* const formattedUTCDate = formatDate(new Date(), false, false, true); // Formats the current date in UTC format
|
|
133
|
+
* const formattedEndDate = formatDate(new Date(), false, true); // Formats the current date to the end of the day
|
|
134
|
+
* ```
|
|
135
|
+
* @returns (string | null): A formatted date string based on the provided parameters. If the input date is null or undefined, it returns null.
|
|
127
136
|
*/
|
|
128
137
|
export declare const formatDate: (date?: Date | null, startOfDate?: boolean, endOfDate?: boolean, isUTC?: boolean, dateOnly?: boolean) => string | null;
|
|
129
138
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
139
|
+
* This function parses a date string into a Date object based on the provided format.
|
|
140
|
+
* It splits the date string into parts (day, month, year) and constructs a Date object.
|
|
141
|
+
* If the date string is invalid or cannot be parsed, it returns null.
|
|
142
|
+
* It also handles two-digit years by converting them to four-digit years.
|
|
143
|
+
* @param date (any): The date string to parse. It can be in various formats (e.g., "dd/MM/yyyy", "MM/dd/yyyy").
|
|
144
|
+
* @param formatString (string): The format string to use for parsing the date.
|
|
145
|
+
* @param localDateformat (string): The local date format to use for parsing. It should match the format of the input date string.
|
|
146
|
+
* @param parseKeyboardVal (boolean): Whether to parse the date from a keyboard input. Defaults to false.
|
|
147
|
+
* @returns (string | null): Returns a formatted date string if parsing is successful, or null if the input is invalid.
|
|
148
|
+
* This function is useful for converting user input or string representations of dates into a Date object.
|
|
149
|
+
* It can handle various date formats and ensures that the resulting Date object is valid.
|
|
150
|
+
* If the input date string is invalid or cannot be parsed, it returns null.
|
|
151
|
+
* It also includes logic to handle two-digit years by converting them to four-digit years.
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const parsedDate = parseDate("25/12/2023", "dd/MM/yyyy", "dd/MM/yyyy");
|
|
155
|
+
* console.log(parsedDate); // Returns "2023-12-25" in the "yyyy-MM-dd" format
|
|
156
|
+
* const parsedDateUS = parseDate("12/25/23", "MM/dd/yyyy", "MM/dd/yyyy");
|
|
157
|
+
* console.log(parsedDateUS); // Returns "2023-12-25" in the "yyyy-MM-dd" format
|
|
158
|
+
* const parsedInvalidDate = parseDate("31/02/2023", "dd/MM/yyyy", "dd/MM/yyyy");
|
|
159
|
+
* console.log(parsedInvalidDate); // Returns null, as February 31st is invalid
|
|
160
|
+
* ```
|
|
152
161
|
*/
|
|
153
162
|
export declare const parseDate: (date: any, formatString: string | undefined, localDateformat: string, parseKeyboardVal?: boolean) => string | null;
|
|
154
163
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
164
|
+
* This function returns a locale object based on the provided LeapContext.
|
|
165
|
+
* It checks the hostInfo.region and returns the corresponding locale with weekStartsOn set to 1.
|
|
166
|
+
* If the region is not recognized, it returns undefined.
|
|
167
|
+
* @param leapContext (LeapContext | undefined): The LeapContext object containing hostInfo with region information.
|
|
168
|
+
* @returns The function supports UK, US, AU (including NZ), and CA regions. If the region is not recognized, it returns undefined.
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const locale = getLocale(leapContext); // Returns the appropriate locale based on the region
|
|
172
|
+
* const localeUS = getLocale({ hostInfo: { region: "us" } }); // Returns enUS locale
|
|
173
|
+
* const localeUK = getLocale({ hostInfo: { region: "uk" } }); // Returns enGB locale
|
|
174
|
+
* const localeAU = getLocale({ hostInfo: { region: "au" } }); // Returns enAU locale
|
|
175
|
+
* const localeCA = getLocale({ hostInfo: { region: "ca" } }); // Returns enGB locale
|
|
176
|
+
* ```
|
|
168
177
|
*/
|
|
169
178
|
export declare const getLocale: (leapContext?: LeapContext) => Locale | undefined;
|
|
170
179
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
180
|
+
* This function formats a date or datetime value into a string based on the provided locale.
|
|
181
|
+
* It supports both date-only and datetime formats, and can handle UTC dates.
|
|
182
|
+
* @param inputValue (string | Date | undefined): The date or datetime value to format.
|
|
183
|
+
* @param locale (Locale | undefined): The locale to use for formatting. If undefined, it will not format the date.
|
|
184
|
+
* @param outputAsUtc (boolean): Whether the date is in UTC format. Defaults to true.
|
|
185
|
+
* @param outputAsDateOnly (boolean): Whether to format the value as a date only.
|
|
186
|
+
* @param outputAs24H (boolean): Whether to show the time in 24-hour format. Defaults to false.
|
|
187
|
+
* @returns (string): A formatted date or datetime string. If the input value is invalid or locale is undefined, it returns an empty string.
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const formattedDate = lctFormatDateTime(new Date(), enGB, true, false, true); // Returns "01/01/2023 14:30"
|
|
191
|
+
* const formattedDateTime = lctFormatDateTime("2023-01-01T14:30:00Z", enUS, true, false, false); // Returns "01/01/2023 02:30 PM"
|
|
192
|
+
* const formattedDateOnly = lctFormatDateTime("2023-01-01", enAU, false, true); // Returns "01/01/2023"
|
|
193
|
+
* const formattedInvalid = lctFormatDateTime(undefined, enGB); // Returns ""
|
|
194
|
+
* ```
|
|
186
195
|
*/
|
|
187
196
|
export declare const formatDateTime: (inputValue?: string | Date, locale?: Locale, outputAsUtc?: boolean, outputAsDateOnly?: boolean, outputAs24H?: boolean) => string;
|
|
188
197
|
/**
|
|
189
|
-
*
|
|
190
|
-
*
|
|
198
|
+
* This function formats a date string into a report-friendly format based on the provided locale.
|
|
199
|
+
* It handles both ISO date strings and strings in the format "yyyy-MM-dd".
|
|
191
200
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
201
|
+
* @param date (string | null): The date string to format. It can be in ISO format or "yyyy-MM-dd".
|
|
202
|
+
* @param locale (Locale | undefined): The locale to use for formatting. If undefined, it will not format the date.
|
|
203
|
+
* @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.
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const formattedReportDate = formatReportDate("2023-12-25", enGB); // Returns "25-12-2023"
|
|
207
|
+
* const formattedReportDateISO = formatReportDate("2023-12-25T00:00:00Z", enUS); // Returns "12-25-2023"
|
|
208
|
+
* const formattedReportDateInvalid = formatReportDate("31-02-2023", enGB); // Returns "", logs warning
|
|
209
|
+
* const formattedReportDateNull = formatReportDate(null, enGB); // Returns "", logs warning
|
|
210
|
+
* ```
|
|
202
211
|
*/
|
|
203
212
|
export declare const formatReportDate: (date: string | null, locale?: Locale) => string;
|
|
204
213
|
/**
|
|
@@ -206,52 +215,54 @@ export declare const formatReportDate: (date: string | null, locale?: Locale) =>
|
|
|
206
215
|
*/
|
|
207
216
|
export declare const getDateTimeWithOffset: (date: string) => Date;
|
|
208
217
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
218
|
+
* This function checks if a string is null or undefined.
|
|
219
|
+
* It returns true if the string is null, undefined, or an empty string.
|
|
220
|
+
* @param value (string | null | undefined): The string to check.
|
|
221
|
+
* @returns (boolean): Returns true if the string is null, undefined, or empty; otherwise, false.
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const isNullOrUndefined = isStringNullOrUndefined(null); // Returns true
|
|
225
|
+
* const isEmptyString = isStringNullOrUndefined(""); // Returns true
|
|
226
|
+
* const isValidString = isStringNullOrUndefined("Hello"); // Returns false
|
|
227
|
+
* ```
|
|
219
228
|
*/
|
|
220
229
|
export declare const isStringNullOrUndefined: (value?: string | null) => boolean;
|
|
221
230
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
+
* This function formats a date as a string in the "yyyy-MM-dd" format, suitable for database storage.
|
|
232
|
+
* It takes a Date object as input and returns the formatted string.
|
|
233
|
+
* @param date (Date): The date to format.
|
|
234
|
+
* @returns (string): A formatted date string in the "yyyy-MM-dd" format.
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const dbFormattedDate = formatAsDBDate(new Date()); // Returns "2023-12-25"
|
|
238
|
+
* const dbFormattedDateInvalid = formatAsDBDate(new Date("Invalid Date")); // Returns "Invalid date"
|
|
239
|
+
* ```
|
|
231
240
|
*/
|
|
232
241
|
export declare const formatAsDBDate: (date: Date) => string;
|
|
233
242
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
243
|
+
* This function converts a local date to a UTC date and time string.
|
|
244
|
+
* It can output the date as the start or end of the day, or as a regular date.
|
|
245
|
+
* It is useful for converting local date inputs to a standardized UTC format for storage or processing.
|
|
246
|
+
* @param inputValue (string | Date | undefined): The local date to convert. It can be a string or a Date object.
|
|
247
|
+
* @param outputAsStartOfDay (boolean): If true, the output will be the start of the day in UTC format.
|
|
248
|
+
* @param outputAsEndOfDay (boolean): If true, the output will be the end of the day in UTC format.
|
|
249
|
+
* If both outputAsStartOfDay and outputAsEndOfDay are false,
|
|
250
|
+
* the output will be the date in UTC format without any time adjustments.
|
|
251
|
+
* If inputValue is null or undefined, the function returns an empty string.
|
|
252
|
+
* @returns
|
|
253
|
+
* (string): A UTC date and time string. If inputValue is null or undefined, it returns an empty string.
|
|
254
|
+
* @example
|
|
255
|
+
* ```typescript
|
|
256
|
+
* const utcDateStart = convertLocalDateToUTCDateTime("2023-12-25", true, false); // Returns "2023-12-25T00:00:00.000Z"
|
|
257
|
+
* const utcDateEnd = convertLocalDateToUTCDateTime("2023-12-25", false, true); // Returns "2023-12-25T23:59:59.999Z"
|
|
258
|
+
* const utcDateRegular = convertLocalDateToUTCDateTime("2023-12-25", false, false); // Returns "2023-12-25T00:00:00.000Z"
|
|
259
|
+
* const utcDateInvalid = convertLocalDateToUTCDateTime(undefined, true, false ); // Returns ""
|
|
260
|
+
* ```
|
|
250
261
|
*/
|
|
251
262
|
export declare const convertLocalDateToUTCDateTime: (inputValue?: string | Date, outputAsStartOfDay?: boolean, outputAsEndOfDay?: boolean) => string;
|
|
252
263
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
264
|
+
* This enum defines the types of buttons available in the dialog.
|
|
265
|
+
* It is used to identify which button was clicked by the user.
|
|
255
266
|
*/
|
|
256
267
|
export declare enum DialogButtonType {
|
|
257
268
|
Confirm = 1,
|
|
@@ -259,28 +270,28 @@ export declare enum DialogButtonType {
|
|
|
259
270
|
Cancel = 3
|
|
260
271
|
}
|
|
261
272
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
273
|
+
* This function shows a 3-button alert dialog using the Leap SDK.
|
|
274
|
+
* It allows the user to confirm, refuse, or cancel an action.
|
|
275
|
+
* It takes a message, button texts, and callbacks for each action.
|
|
276
|
+
* @param message (string): The message to display in the dialog.
|
|
277
|
+
* @param confirmButtonText (string): The text for the confirm button.
|
|
278
|
+
* @param confirmCallback (function): The callback function to execute when the confirm button is clicked.
|
|
279
|
+
* @param refuseButtonText (string): The text for the refuse button. Optional.
|
|
280
|
+
* @param refuseCallback (function): The callback function to execute when the refuse button is clicked. Optional.
|
|
281
|
+
* @param cancelButtonText (string): The text for the cancel button. Optional.
|
|
282
|
+
* @param sdkApi (Api): The Leap SDK API instance to use for showing the dialog.
|
|
283
|
+
* @returns A promise that resolves when the dialog is closed.
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* show3buttonAlert(
|
|
287
|
+
* "Are you sure you want to proceed?",
|
|
288
|
+
* "Yes",
|
|
289
|
+
* () => console.log("Confirmed"),
|
|
290
|
+
* "No",
|
|
291
|
+
* () => console.log("Refused"),
|
|
292
|
+
* "Cancel",
|
|
293
|
+
* sdkApi
|
|
294
|
+
* );
|
|
295
|
+
* ```
|
|
285
296
|
*/
|
|
286
297
|
export declare const show3buttonAlert: (message: string, confirmButtonText: string, confirmCallback: () => void, refuseButtonText?: string, refuseCallback?: () => void, cancelButtonText?: string, sdkApi?: Api) => Promise<void> | undefined;
|