ish-ui 1.0.19 → 1.0.21
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/actions/FieldProcessing.d.ts +10 -0
- package/dist/actions/FieldProcessing.js +17 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +8 -0
- package/dist/appBar/AppBarHelpMenu.d.ts +3 -0
- package/dist/appBar/AppBarHelpMenu.js +77 -0
- package/dist/appBar/index.d.ts +2 -0
- package/dist/appBar/index.js +9 -0
- package/dist/buttons/AddButton.d.ts +14 -0
- package/dist/buttons/AddButton.js +9 -0
- package/dist/buttons/TimetableButton.d.ts +3 -0
- package/dist/buttons/TimetableButton.js +12 -0
- package/dist/buttons/index.d.ts +4 -0
- package/dist/buttons/index.js +11 -0
- package/dist/colorPicker/ColorPicker.d.ts +4 -0
- package/dist/colorPicker/ColorPicker.js +138 -0
- package/dist/colorPicker/index.d.ts +2 -0
- package/dist/colorPicker/index.js +9 -0
- package/dist/dialog/BrowserWarning.d.ts +3 -0
- package/dist/dialog/BrowserWarning.js +16 -0
- package/dist/dialog/confirm/ConfirmBase.d.ts +7 -0
- package/dist/dialog/confirm/ConfirmBase.js +29 -0
- package/dist/dialog/index.d.ts +5 -0
- package/dist/dialog/index.js +12 -0
- package/dist/dialog/message/Message.d.ts +3 -0
- package/dist/dialog/message/Message.js +91 -0
- package/dist/documents/DocumentIconsChooser.d.ts +3 -0
- package/dist/documents/DocumentIconsChooser.js +51 -0
- package/dist/documents/index.d.ts +3 -0
- package/dist/documents/index.js +10 -0
- package/dist/documents/utils/index.d.ts +7 -0
- package/dist/documents/utils/index.js +61 -0
- package/dist/dynamicSizeList/DynamicSizeList.d.ts +17 -0
- package/dist/dynamicSizeList/DynamicSizeList.js +167 -0
- package/dist/dynamicSizeList/index.d.ts +2 -0
- package/dist/dynamicSizeList/index.js +9 -0
- package/dist/fieldMessage/ErrorMessage.d.ts +8 -0
- package/dist/fieldMessage/ErrorMessage.js +14 -0
- package/dist/fieldMessage/WarningMessage.d.ts +8 -0
- package/dist/fieldMessage/WarningMessage.js +14 -0
- package/dist/fieldMessage/index.d.ts +6 -0
- package/dist/fieldMessage/index.js +13 -0
- package/dist/fieldMessage/styles.d.ts +3 -0
- package/dist/fieldMessage/styles.js +18 -0
- package/dist/fileUploader/FileUploaderDialog.d.ts +15 -0
- package/dist/fileUploader/FileUploaderDialog.js +99 -0
- package/dist/fileUploader/index.d.ts +2 -0
- package/dist/fileUploader/index.js +9 -0
- package/dist/formFields/CheckboxField.d.ts +7 -0
- package/dist/formFields/CheckboxField.js +67 -0
- package/dist/formFields/CodeEditorField.d.ts +6 -0
- package/dist/formFields/CodeEditorField.js +69 -0
- package/dist/formFields/ColoredCheckBox.d.ts +3 -0
- package/dist/formFields/ColoredCheckBox.js +41 -0
- package/dist/formFields/DateTimeField.d.ts +2 -0
- package/dist/formFields/DateTimeField.js +27 -0
- package/dist/formFields/EditInPlaceDateTimeField.d.ts +10 -0
- package/dist/formFields/EditInPlaceDateTimeField.js +188 -0
- package/dist/formFields/EditInPlaceDurationField.d.ts +4 -0
- package/dist/formFields/EditInPlaceDurationField.js +63 -0
- package/dist/formFields/EditInPlaceField.d.ts +10 -0
- package/dist/formFields/EditInPlaceField.js +58 -0
- package/dist/formFields/EditInPlaceFieldBase.d.ts +28 -0
- package/dist/formFields/EditInPlaceFieldBase.js +123 -0
- package/dist/formFields/EditInPlaceFileField.d.ts +7 -0
- package/dist/formFields/EditInPlaceFileField.js +60 -0
- package/dist/formFields/EditInPlaceMoneyField.d.ts +9 -0
- package/dist/formFields/EditInPlaceMoneyField.js +37 -0
- package/dist/formFields/EditInPlacePhoneField.d.ts +4 -0
- package/dist/formFields/EditInPlacePhoneField.js +69 -0
- package/dist/formFields/EditInPlaceSearchSelect.d.ts +4 -0
- package/dist/formFields/EditInPlaceSearchSelect.js +321 -0
- package/dist/formFields/FieldAdornments.d.ts +13 -0
- package/dist/formFields/FieldAdornments.js +27 -0
- package/dist/formFields/FilePreview.d.ts +17 -0
- package/dist/formFields/FilePreview.js +77 -0
- package/dist/formFields/FormRadioButtons.d.ts +3 -0
- package/dist/formFields/FormRadioButtons.js +27 -0
- package/dist/formFields/SelectCustomComponents.d.ts +5 -0
- package/dist/formFields/SelectCustomComponents.js +182 -0
- package/dist/formFields/Switch.d.ts +7 -0
- package/dist/formFields/Switch.js +116 -0
- package/dist/formFields/TextField.d.ts +6 -0
- package/dist/formFields/TextField.js +42 -0
- package/dist/formFields/UneditableBase.d.ts +17 -0
- package/dist/formFields/UneditableBase.js +48 -0
- package/dist/formFields/index.d.ts +31 -0
- package/dist/formFields/index.js +38 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +25 -0
- package/dist/layout/InfoPill.d.ts +7 -0
- package/dist/layout/InfoPill.js +26 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +11 -0
- package/dist/layout/resizable/ResizableWrapper.d.ts +14 -0
- package/dist/layout/resizable/ResizableWrapper.js +42 -0
- package/dist/markdownEditor/HtmlEditor.d.ts +15 -0
- package/dist/markdownEditor/HtmlEditor.js +18 -0
- package/dist/markdownEditor/WysiwygEditor.d.ts +8 -0
- package/dist/markdownEditor/WysiwygEditor.js +98 -0
- package/dist/markdownEditor/index.d.ts +5 -0
- package/dist/markdownEditor/index.js +12 -0
- package/dist/markdownEditor/utils/index.d.ts +9 -0
- package/dist/markdownEditor/utils/index.js +38 -0
- package/dist/model/AppBar.d.ts +11 -0
- package/dist/model/AppBar.js +8 -0
- package/dist/model/CommomObjects.d.ts +5 -0
- package/dist/model/CommomObjects.js +1 -0
- package/dist/model/CommonFunctions.d.ts +8 -0
- package/dist/model/CommonFunctions.js +5 -0
- package/dist/model/Confirm.d.ts +16 -0
- package/dist/model/Confirm.js +8 -0
- package/dist/model/Fields.d.ts +258 -0
- package/dist/model/Fields.js +8 -0
- package/dist/model/NestedEntity.d.ts +9 -0
- package/dist/model/NestedEntity.js +5 -0
- package/dist/model/Theme.d.ts +34 -0
- package/dist/model/Theme.js +18 -0
- package/dist/model/index.d.ts +7 -0
- package/dist/model/index.js +14 -0
- package/dist/styles/GlobalStylesProvider.d.ts +3 -0
- package/dist/styles/GlobalStylesProvider.js +417 -0
- package/dist/styles/StylesProviderCustom.d.ts +3 -0
- package/dist/styles/StylesProviderCustom.js +6 -0
- package/dist/styles/animateStyles.d.ts +3 -0
- package/dist/styles/animateStyles.js +33 -0
- package/dist/styles/bootstrap.d.ts +491 -0
- package/dist/styles/bootstrap.js +496 -0
- package/dist/styles/hooks.d.ts +6 -0
- package/dist/styles/hooks.js +38 -0
- package/dist/styles/index.d.ts +11 -0
- package/dist/styles/index.js +18 -0
- package/dist/styles/makeStyles.d.ts +3 -0
- package/dist/styles/makeStyles.js +9 -0
- package/dist/styles/mixins/common.d.ts +8 -0
- package/dist/styles/mixins/common.js +32 -0
- package/dist/styles/mixins/keyframes.d.ts +3 -0
- package/dist/styles/mixins/keyframes.js +9 -0
- package/dist/styles/mixins/prefixer.d.ts +1 -0
- package/dist/styles/mixins/prefixer.js +23 -0
- package/dist/tagsInput/AddTagMenu.d.ts +12 -0
- package/dist/tagsInput/AddTagMenu.js +36 -0
- package/dist/tagsInput/AddTagMenuItem.d.ts +11 -0
- package/dist/tagsInput/AddTagMenuItem.js +29 -0
- package/dist/tagsInput/TagInputList.d.ts +4 -0
- package/dist/tagsInput/TagInputList.js +273 -0
- package/dist/tagsInput/index.d.ts +6 -0
- package/dist/tagsInput/index.js +6 -0
- package/dist/themes/appTheme.d.ts +4 -0
- package/dist/themes/appTheme.js +322 -0
- package/dist/themes/index.d.ts +2 -0
- package/dist/themes/index.js +9 -0
- package/dist/themes/ishTheme.d.ts +8 -0
- package/dist/themes/ishTheme.js +351 -0
- package/dist/timetable/datePeriodFilter/DayPeriodIcons.d.ts +8 -0
- package/dist/timetable/datePeriodFilter/DayPeriodIcons.js +27 -0
- package/dist/timetable/datePeriodFilter/index.d.ts +1 -0
- package/dist/timetable/datePeriodFilter/index.js +8 -0
- package/dist/timetable/index.d.ts +2 -0
- package/dist/timetable/index.js +9 -0
- package/dist/timetable/miniCalendar/CalendarDay.d.ts +15 -0
- package/dist/timetable/miniCalendar/CalendarDay.js +64 -0
- package/dist/timetable/miniCalendar/CalendarHeader.d.ts +10 -0
- package/dist/timetable/miniCalendar/CalendarHeader.js +22 -0
- package/dist/timetable/miniCalendar/CalendarWeekPanel.d.ts +8 -0
- package/dist/timetable/miniCalendar/CalendarWeekPanel.js +18 -0
- package/dist/timetable/miniCalendar/WeekDay.d.ts +10 -0
- package/dist/timetable/miniCalendar/WeekDay.js +25 -0
- package/dist/timetable/miniCalendar/index.d.ts +8 -0
- package/dist/timetable/miniCalendar/index.js +15 -0
- package/dist/utils/DOM/Links.d.ts +1 -0
- package/dist/utils/DOM/Links.js +12 -0
- package/dist/utils/DOM/getCaretCoordinates.d.ts +6 -0
- package/dist/utils/DOM/getCaretCoordinates.js +109 -0
- package/dist/utils/DOM/getOS.d.ts +2 -0
- package/dist/utils/DOM/getOS.js +32 -0
- package/dist/utils/DOM/index.d.ts +5 -0
- package/dist/utils/DOM/index.js +32 -0
- package/dist/utils/dates/datesNormalizing.d.ts +1 -0
- package/dist/utils/dates/datesNormalizing.js +3 -0
- package/dist/utils/dates/format.d.ts +24 -0
- package/dist/utils/dates/format.js +28 -0
- package/dist/utils/dates/formatRelative.d.ts +1 -0
- package/dist/utils/dates/formatRelative.js +14 -0
- package/dist/utils/dates/formatString.d.ts +2 -0
- package/dist/utils/dates/formatString.js +195 -0
- package/dist/utils/dates/formatTimezone.d.ts +2 -0
- package/dist/utils/dates/formatTimezone.js +35 -0
- package/dist/utils/dates/index.d.ts +6 -0
- package/dist/utils/dates/index.js +13 -0
- package/dist/utils/dates/timetable.d.ts +5 -0
- package/dist/utils/dates/timetable.js +38 -0
- package/dist/utils/events/index.d.ts +2 -0
- package/dist/utils/events/index.js +6 -0
- package/dist/utils/fields/index.d.ts +1 -0
- package/dist/utils/fields/index.js +20 -0
- package/dist/utils/formatting/PhoneMasks.d.ts +304 -0
- package/dist/utils/formatting/PhoneMasks.js +318 -0
- package/dist/utils/formatting/index.d.ts +2 -0
- package/dist/utils/formatting/index.js +10 -0
- package/dist/utils/hooks/index.d.ts +1 -0
- package/dist/utils/hooks/index.js +15 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/numbers/decimalCalculation.d.ts +4 -0
- package/dist/utils/numbers/decimalCalculation.js +21 -0
- package/dist/utils/numbers/index.d.ts +2 -0
- package/dist/utils/numbers/index.js +9 -0
- package/dist/utils/numbers/numbersNormalizing.d.ts +10 -0
- package/dist/utils/numbers/numbersNormalizing.js +44 -0
- package/dist/utils/stubs/index.d.ts +3 -0
- package/dist/utils/stubs/index.js +10 -0
- package/dist/utils/tags/index.d.ts +3 -0
- package/dist/utils/tags/index.js +42 -0
- package/package.json +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd. All rights reserved. https://www.ish.com.au
|
|
3
|
+
* No copying or use of this code is allowed without permission in writing from ish.
|
|
4
|
+
*/
|
|
5
|
+
import { parse, addWeeks, addDays, subDays, addMonths, addYears, setHours, setMinutes } from 'date-fns';
|
|
6
|
+
import { DD_MMM_YYYY, DD_MMM_YYYY_HH_MM, HH_MM_COLONED } from './format';
|
|
7
|
+
const transitionDate = new Date(2000, 0, 1);
|
|
8
|
+
const formatsWithLetters = [
|
|
9
|
+
'dMMMyy',
|
|
10
|
+
'dMMMMyy',
|
|
11
|
+
'ddMMMyy',
|
|
12
|
+
'ddMMMMyy',
|
|
13
|
+
'dMMMyyyy',
|
|
14
|
+
'dMMMMyyyy',
|
|
15
|
+
'ddMMMMyyyy',
|
|
16
|
+
'ddMMMyyyy'
|
|
17
|
+
];
|
|
18
|
+
const specialOptions = ['tm', 'yd', 'tomorrow', 'yesterday'];
|
|
19
|
+
const operatorsRegexp = /\s*[-+]\s*[0-9][0-9]?[dDmMyYwW]?/g;
|
|
20
|
+
const dividersRegexp = /[.\/\-]/g;
|
|
21
|
+
const timeRegexp = /(\s|^)[0-9][0-9]?:[0-9][0-9]?/;
|
|
22
|
+
const manageDatePart = (date, part) => {
|
|
23
|
+
const numberPart = parseInt(part, 10);
|
|
24
|
+
switch (true) {
|
|
25
|
+
case /[mM]/.test(part): {
|
|
26
|
+
return addMonths(date, numberPart);
|
|
27
|
+
}
|
|
28
|
+
case /[yY]/.test(part): {
|
|
29
|
+
return addYears(date, numberPart);
|
|
30
|
+
}
|
|
31
|
+
case /[wW]/.test(part): {
|
|
32
|
+
return addWeeks(date, numberPart);
|
|
33
|
+
}
|
|
34
|
+
case /[dD]/.test(part):
|
|
35
|
+
default: {
|
|
36
|
+
return addDays(date, numberPart);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const checkInvalidDate = (date) => date.toString() !== 'Invalid Date';
|
|
41
|
+
export const formatStringDate = (dateString, type, baseDate, customFormat) => {
|
|
42
|
+
let result;
|
|
43
|
+
let parsed;
|
|
44
|
+
let formatted = dateString;
|
|
45
|
+
if (type === 'date') {
|
|
46
|
+
baseDate.setHours(0, 0, 0, 0);
|
|
47
|
+
}
|
|
48
|
+
if (customFormat) {
|
|
49
|
+
parsed = parse(dateString.replace(/^\w{3}/, '').trim(), customFormat, baseDate);
|
|
50
|
+
if (checkInvalidDate(parsed)) {
|
|
51
|
+
return parsed;
|
|
52
|
+
}
|
|
53
|
+
parsed = null;
|
|
54
|
+
}
|
|
55
|
+
if (type === 'date') {
|
|
56
|
+
parsed = parse(dateString.replace(/^\w{3}/, '').trim(), DD_MMM_YYYY, baseDate);
|
|
57
|
+
if (checkInvalidDate(parsed)) {
|
|
58
|
+
return parsed;
|
|
59
|
+
}
|
|
60
|
+
parsed = null;
|
|
61
|
+
}
|
|
62
|
+
if (type === 'datetime') {
|
|
63
|
+
parsed = parse(dateString.replace(/^\w{3}/, '').trim(), DD_MMM_YYYY_HH_MM, baseDate);
|
|
64
|
+
if (checkInvalidDate(parsed)) {
|
|
65
|
+
return parsed;
|
|
66
|
+
}
|
|
67
|
+
parsed = null;
|
|
68
|
+
}
|
|
69
|
+
if (type === 'time') {
|
|
70
|
+
parsed = parse(dateString, HH_MM_COLONED, baseDate);
|
|
71
|
+
if (checkInvalidDate(parsed)) {
|
|
72
|
+
return parsed;
|
|
73
|
+
}
|
|
74
|
+
parsed = parse(dateString, 'HH', baseDate);
|
|
75
|
+
if (checkInvalidDate(parsed)) {
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
parsed = null;
|
|
79
|
+
}
|
|
80
|
+
const dividers = dateString.match(dividersRegexp);
|
|
81
|
+
const operators = dateString.match(operatorsRegexp);
|
|
82
|
+
const time = dateString.match(timeRegexp);
|
|
83
|
+
if (time) {
|
|
84
|
+
formatted = formatted.replace(timeRegexp, '');
|
|
85
|
+
}
|
|
86
|
+
if (operators) {
|
|
87
|
+
formatted = formatted.replace(operatorsRegexp, '');
|
|
88
|
+
}
|
|
89
|
+
const hasLetters = formatted.match(/[a-zA-Z]/);
|
|
90
|
+
if (hasLetters) {
|
|
91
|
+
for (const format of formatsWithLetters) {
|
|
92
|
+
parsed = parse(formatted.replace(/\s/g, ''), format, baseDate);
|
|
93
|
+
if (checkInvalidDate(parsed)) {
|
|
94
|
+
result = parsed;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (dividers && !hasLetters) {
|
|
100
|
+
const dateParts = formatted.trim().split(dividersRegexp);
|
|
101
|
+
formatted = formatted.replace(dividersRegexp, ' ');
|
|
102
|
+
let formatString = `${dateParts[0] ? dateParts[0].replace(/./g, 'd') : ''} ${dateParts[1] ? dateParts[1].replace(/./g, 'M') : ''} ${dateParts[2] ? dateParts[2].replace(/./g, 'y') : ''}`;
|
|
103
|
+
if (dateParts[2] && dateParts[2].length === 1) {
|
|
104
|
+
formatted = formatted.replace(new RegExp(dateParts[2] + '$'), `0${dateParts[2]}`);
|
|
105
|
+
formatString = formatString.replace(new RegExp('y$'), 'yy');
|
|
106
|
+
}
|
|
107
|
+
parsed = parse(formatted, formatString.trim(), baseDate);
|
|
108
|
+
if (checkInvalidDate(parsed)) {
|
|
109
|
+
result = parsed;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!dividers && !hasLetters) {
|
|
113
|
+
switch (formatted.length) {
|
|
114
|
+
case 1:
|
|
115
|
+
case 2: {
|
|
116
|
+
parsed = parse(formatted, 'dd', baseDate);
|
|
117
|
+
if (checkInvalidDate(parsed)) {
|
|
118
|
+
result = parsed;
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 3: {
|
|
123
|
+
parsed = parse(formatted, 'ddM', baseDate);
|
|
124
|
+
if (checkInvalidDate(parsed)) {
|
|
125
|
+
result = parsed;
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case 4: {
|
|
130
|
+
parsed = parse(`${formatted[0]} ${formatted[1]} ${formatted[2] + formatted[3]}`, 'd M yy', transitionDate);
|
|
131
|
+
if (checkInvalidDate(parsed)) {
|
|
132
|
+
result = parsed;
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case 5: {
|
|
137
|
+
parsed = parse(formatted, 'ddMyy', transitionDate);
|
|
138
|
+
if (checkInvalidDate(parsed)) {
|
|
139
|
+
result = parsed;
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case 6: {
|
|
144
|
+
parsed = parse(formatted, 'ddMMyy', transitionDate);
|
|
145
|
+
if (checkInvalidDate(parsed)) {
|
|
146
|
+
result = parsed;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 8: {
|
|
152
|
+
parsed = parse(formatted, 'ddMMyyyy', transitionDate);
|
|
153
|
+
if (checkInvalidDate(parsed)) {
|
|
154
|
+
result = parsed;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!(result instanceof Date)) {
|
|
160
|
+
result = baseDate;
|
|
161
|
+
for (const option of specialOptions) {
|
|
162
|
+
if (formatted === option) {
|
|
163
|
+
switch (option) {
|
|
164
|
+
case 'tomorrow':
|
|
165
|
+
case 'tm': {
|
|
166
|
+
result = addDays(result, 1);
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case 'yesterday':
|
|
170
|
+
case 'yd': {
|
|
171
|
+
result = subDays(result, 1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (operators) {
|
|
179
|
+
operators.forEach(op => {
|
|
180
|
+
result = manageDatePart(result, op.trim());
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (time && (type === 'time' || type === 'datetime')) {
|
|
184
|
+
parsed = parse(time[0].trim(), 'HH:mm', baseDate);
|
|
185
|
+
if (checkInvalidDate(parsed)) {
|
|
186
|
+
result = setHours(result, parsed.getHours());
|
|
187
|
+
result = setMinutes(result, parsed.getMinutes());
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
};
|
|
192
|
+
export const formatDurationMinutes = (minutes) => {
|
|
193
|
+
const duration = (minutes / 60).toString().split('.');
|
|
194
|
+
return `${duration[0] === '0' ? '' : duration[0] + 'h'} ${duration[1] ? (parseFloat('0.' + duration[1]) * 60).toFixed() + 'min' : ''}`.trim();
|
|
195
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2020.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
|
5
|
+
* GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
6
|
+
*
|
|
7
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
8
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
* See the GNU Affero General Public License for more details.
|
|
10
|
+
*/
|
|
11
|
+
import { utcToZonedTime, zonedTimeToUtc } from 'date-fns-tz';
|
|
12
|
+
export const appendTimezone = (date, timezone) => {
|
|
13
|
+
let result = date;
|
|
14
|
+
try {
|
|
15
|
+
result = utcToZonedTime(date, timezone);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.warn(e);
|
|
20
|
+
return date;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
export const prependTimezone = (date, timezone) => {
|
|
25
|
+
let result = date;
|
|
26
|
+
try {
|
|
27
|
+
result = zonedTimeToUtc(date, timezone);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.warn(e);
|
|
32
|
+
return date;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
export * from './datesNormalizing';
|
|
9
|
+
export * from './format';
|
|
10
|
+
export * from './formatRelative';
|
|
11
|
+
export * from './formatString';
|
|
12
|
+
export * from './formatTimezone';
|
|
13
|
+
export * from './timetable';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
import { getDay, getDaysInMonth, lastDayOfMonth } from 'date-fns';
|
|
9
|
+
const generateOneMonth = (today, status) => Array(getDaysInMonth(today))
|
|
10
|
+
.fill(null)
|
|
11
|
+
.map((el, id) => ({
|
|
12
|
+
day: id + 1,
|
|
13
|
+
date: new Date(today.getFullYear(), today.getMonth(), id + 1),
|
|
14
|
+
status
|
|
15
|
+
}));
|
|
16
|
+
export const getCalendarDays = today => {
|
|
17
|
+
const currentMonth = generateOneMonth(today, 'current');
|
|
18
|
+
const previousMonth = generateOneMonth(new Date(today.getFullYear(), today.getMonth() - 1), 'previous');
|
|
19
|
+
const nextMonth = generateOneMonth(new Date(today.getFullYear(), today.getMonth() + 1), 'next');
|
|
20
|
+
const firstDayIndex = getDay(new Date(today.getFullYear(), today.getMonth(), 1));
|
|
21
|
+
const lastDayIndex = getDay(lastDayOfMonth(today));
|
|
22
|
+
const binaryCalendarState = (firstDayIndex, lastDayIndex) => parseInt(String(+!!firstDayIndex) + +(lastDayIndex < 6), 2);
|
|
23
|
+
switch (binaryCalendarState(firstDayIndex, lastDayIndex)) {
|
|
24
|
+
case 0:
|
|
25
|
+
return currentMonth;
|
|
26
|
+
case 1:
|
|
27
|
+
return currentMonth.concat(nextMonth.slice(0, 6 - lastDayIndex));
|
|
28
|
+
case 2:
|
|
29
|
+
return previousMonth.slice(previousMonth.length - firstDayIndex).concat(currentMonth);
|
|
30
|
+
case 3:
|
|
31
|
+
return previousMonth
|
|
32
|
+
.slice(previousMonth.length - firstDayIndex)
|
|
33
|
+
.concat(currentMonth)
|
|
34
|
+
.concat(nextMonth.slice(0, 6 - lastDayIndex));
|
|
35
|
+
default:
|
|
36
|
+
return currentMonth;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd. All rights reserved. https://www.ish.com.au
|
|
3
|
+
* No copying or use of this code is allowed without permission in writing from ish.
|
|
4
|
+
*/
|
|
5
|
+
export const stopEventPropagation = e => e.stopPropagation();
|
|
6
|
+
export const preventEventDefault = e => e.preventDefault();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCheckboxValue: (value: any, stringValue: any) => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
export const getCheckboxValue = (value, stringValue) => {
|
|
9
|
+
if (!stringValue) {
|
|
10
|
+
return !!value;
|
|
11
|
+
}
|
|
12
|
+
switch (value) {
|
|
13
|
+
case 'false':
|
|
14
|
+
return false;
|
|
15
|
+
case 'true':
|
|
16
|
+
return true;
|
|
17
|
+
default:
|
|
18
|
+
return Boolean(value);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
export declare const phoneMasks: {
|
|
2
|
+
AC: string;
|
|
3
|
+
AD: string;
|
|
4
|
+
AE: string;
|
|
5
|
+
AE1: string;
|
|
6
|
+
AF: string;
|
|
7
|
+
AG: string;
|
|
8
|
+
AI: string;
|
|
9
|
+
AL: string;
|
|
10
|
+
AM: string;
|
|
11
|
+
AN: string;
|
|
12
|
+
AN1: string;
|
|
13
|
+
AN2: string;
|
|
14
|
+
AO: string;
|
|
15
|
+
AQ: string;
|
|
16
|
+
AR: string;
|
|
17
|
+
AS: string;
|
|
18
|
+
AT: string;
|
|
19
|
+
AU: string;
|
|
20
|
+
AU1: string;
|
|
21
|
+
AU2: string;
|
|
22
|
+
AU3: string;
|
|
23
|
+
AU4: string;
|
|
24
|
+
AU5: string;
|
|
25
|
+
AU6: string;
|
|
26
|
+
AW: string;
|
|
27
|
+
AZ: string;
|
|
28
|
+
BA: string;
|
|
29
|
+
BA1: string;
|
|
30
|
+
BB: string;
|
|
31
|
+
BD: string;
|
|
32
|
+
BE: string;
|
|
33
|
+
BF: string;
|
|
34
|
+
BG: string;
|
|
35
|
+
BH: string;
|
|
36
|
+
BI: string;
|
|
37
|
+
BJ: string;
|
|
38
|
+
BM: string;
|
|
39
|
+
BN: string;
|
|
40
|
+
BO: string;
|
|
41
|
+
BR: string;
|
|
42
|
+
BR1: string;
|
|
43
|
+
BR2: string;
|
|
44
|
+
BS: string;
|
|
45
|
+
BT: string;
|
|
46
|
+
BT1: string;
|
|
47
|
+
BW: string;
|
|
48
|
+
BY: string;
|
|
49
|
+
BZ: string;
|
|
50
|
+
CA: string;
|
|
51
|
+
CD: string;
|
|
52
|
+
CF: string;
|
|
53
|
+
CG: string;
|
|
54
|
+
CH: string;
|
|
55
|
+
CI: string;
|
|
56
|
+
CK: string;
|
|
57
|
+
CL: string;
|
|
58
|
+
CM: string;
|
|
59
|
+
CN: string;
|
|
60
|
+
CN1: string;
|
|
61
|
+
CN2: string;
|
|
62
|
+
CO: string;
|
|
63
|
+
CR: string;
|
|
64
|
+
CU: string;
|
|
65
|
+
CV: string;
|
|
66
|
+
CW: string;
|
|
67
|
+
CY: string;
|
|
68
|
+
CZ: string;
|
|
69
|
+
DE: string;
|
|
70
|
+
DE1: string;
|
|
71
|
+
DE2: string;
|
|
72
|
+
DE3: string;
|
|
73
|
+
DE4: string;
|
|
74
|
+
DE5: string;
|
|
75
|
+
DJ: string;
|
|
76
|
+
DK: string;
|
|
77
|
+
DM: string;
|
|
78
|
+
DO: string;
|
|
79
|
+
DO1: string;
|
|
80
|
+
DO2: string;
|
|
81
|
+
DZ: string;
|
|
82
|
+
EC: string;
|
|
83
|
+
EC1: string;
|
|
84
|
+
EE: string;
|
|
85
|
+
EE1: string;
|
|
86
|
+
EG: string;
|
|
87
|
+
ER: string;
|
|
88
|
+
ES: string;
|
|
89
|
+
ET: string;
|
|
90
|
+
FI: string;
|
|
91
|
+
FJ: string;
|
|
92
|
+
FK: string;
|
|
93
|
+
FM: string;
|
|
94
|
+
FO: string;
|
|
95
|
+
FR: string;
|
|
96
|
+
FR1: string;
|
|
97
|
+
FR2: string;
|
|
98
|
+
FR3: string;
|
|
99
|
+
GA: string;
|
|
100
|
+
GD: string;
|
|
101
|
+
GE: string;
|
|
102
|
+
GF: string;
|
|
103
|
+
GH: string;
|
|
104
|
+
GI: string;
|
|
105
|
+
GL: string;
|
|
106
|
+
GM: string;
|
|
107
|
+
GN: string;
|
|
108
|
+
GQ: string;
|
|
109
|
+
GR: string;
|
|
110
|
+
GT: string;
|
|
111
|
+
GU: string;
|
|
112
|
+
GW: string;
|
|
113
|
+
GY: string;
|
|
114
|
+
HK: string;
|
|
115
|
+
HN: string;
|
|
116
|
+
HR: string;
|
|
117
|
+
HT: string;
|
|
118
|
+
HU: string;
|
|
119
|
+
ID: string;
|
|
120
|
+
ID1: string;
|
|
121
|
+
ID2: string;
|
|
122
|
+
ID3: string;
|
|
123
|
+
ID4: string;
|
|
124
|
+
ID5: string;
|
|
125
|
+
IE: string;
|
|
126
|
+
IL: string;
|
|
127
|
+
IL1: string;
|
|
128
|
+
IN: string;
|
|
129
|
+
IO: string;
|
|
130
|
+
IQ: string;
|
|
131
|
+
IR: string;
|
|
132
|
+
IS: string;
|
|
133
|
+
IT: string;
|
|
134
|
+
JM: string;
|
|
135
|
+
JO: string;
|
|
136
|
+
JP: string;
|
|
137
|
+
JP1: string;
|
|
138
|
+
KE: string;
|
|
139
|
+
KG: string;
|
|
140
|
+
KH: string;
|
|
141
|
+
KI: string;
|
|
142
|
+
KM: string;
|
|
143
|
+
KN: string;
|
|
144
|
+
KP: string;
|
|
145
|
+
KP1: string;
|
|
146
|
+
KP2: string;
|
|
147
|
+
KP3: string;
|
|
148
|
+
KP4: string;
|
|
149
|
+
KP5: string;
|
|
150
|
+
KR: string;
|
|
151
|
+
KW: string;
|
|
152
|
+
KY: string;
|
|
153
|
+
KZ: string;
|
|
154
|
+
KZ1: string;
|
|
155
|
+
LA: string;
|
|
156
|
+
LA1: string;
|
|
157
|
+
LB: string;
|
|
158
|
+
LB1: string;
|
|
159
|
+
LC: string;
|
|
160
|
+
LI: string;
|
|
161
|
+
LK: string;
|
|
162
|
+
LR: string;
|
|
163
|
+
LS: string;
|
|
164
|
+
LT: string;
|
|
165
|
+
LU: string;
|
|
166
|
+
LV: string;
|
|
167
|
+
LY: string;
|
|
168
|
+
LY1: string;
|
|
169
|
+
MA: string;
|
|
170
|
+
MC: string;
|
|
171
|
+
MC1: string;
|
|
172
|
+
MD: string;
|
|
173
|
+
ME: string;
|
|
174
|
+
MG: string;
|
|
175
|
+
MH: string;
|
|
176
|
+
MK: string;
|
|
177
|
+
ML: string;
|
|
178
|
+
MM: string;
|
|
179
|
+
MM1: string;
|
|
180
|
+
MN: string;
|
|
181
|
+
MO: string;
|
|
182
|
+
MP: string;
|
|
183
|
+
MQ: string;
|
|
184
|
+
MR: string;
|
|
185
|
+
MS: string;
|
|
186
|
+
MT: string;
|
|
187
|
+
MU: string;
|
|
188
|
+
MV: string;
|
|
189
|
+
MW: string;
|
|
190
|
+
MW1: string;
|
|
191
|
+
MX: string;
|
|
192
|
+
MX1: string;
|
|
193
|
+
MY: string;
|
|
194
|
+
MY1: string;
|
|
195
|
+
MY2: string;
|
|
196
|
+
MY3: string;
|
|
197
|
+
MZ: string;
|
|
198
|
+
NA: string;
|
|
199
|
+
NC: string;
|
|
200
|
+
NE: string;
|
|
201
|
+
NF: string;
|
|
202
|
+
NG: string;
|
|
203
|
+
NG1: string;
|
|
204
|
+
NG2: string;
|
|
205
|
+
NG3: string;
|
|
206
|
+
NI: string;
|
|
207
|
+
NL: string;
|
|
208
|
+
NO: string;
|
|
209
|
+
NP: string;
|
|
210
|
+
NR: string;
|
|
211
|
+
NU: string;
|
|
212
|
+
NZ: string;
|
|
213
|
+
NZ1: string;
|
|
214
|
+
NZ2: string;
|
|
215
|
+
OM: string;
|
|
216
|
+
PA: string;
|
|
217
|
+
PE: string;
|
|
218
|
+
PF: string;
|
|
219
|
+
PG: string;
|
|
220
|
+
PH: string;
|
|
221
|
+
PK: string;
|
|
222
|
+
PL: string;
|
|
223
|
+
PS: string;
|
|
224
|
+
PT: string;
|
|
225
|
+
PW: string;
|
|
226
|
+
PY: string;
|
|
227
|
+
QA: string;
|
|
228
|
+
RE: string;
|
|
229
|
+
RO: string;
|
|
230
|
+
RS: string;
|
|
231
|
+
RU: string;
|
|
232
|
+
RW: string;
|
|
233
|
+
SA: string;
|
|
234
|
+
SA1: string;
|
|
235
|
+
SB: string;
|
|
236
|
+
SB1: string;
|
|
237
|
+
SC: string;
|
|
238
|
+
SD: string;
|
|
239
|
+
SE: string;
|
|
240
|
+
SG: string;
|
|
241
|
+
SH: string;
|
|
242
|
+
SH1: string;
|
|
243
|
+
SI: string;
|
|
244
|
+
SK: string;
|
|
245
|
+
SL: string;
|
|
246
|
+
SM: string;
|
|
247
|
+
SN: string;
|
|
248
|
+
SO: string;
|
|
249
|
+
SO1: string;
|
|
250
|
+
SO2: string;
|
|
251
|
+
SR: string;
|
|
252
|
+
SR1: string;
|
|
253
|
+
SS: string;
|
|
254
|
+
ST: string;
|
|
255
|
+
SV: string;
|
|
256
|
+
SX: string;
|
|
257
|
+
SY: string;
|
|
258
|
+
SZ: string;
|
|
259
|
+
TC: string;
|
|
260
|
+
TD: string;
|
|
261
|
+
TG: string;
|
|
262
|
+
TH: string;
|
|
263
|
+
TH1: string;
|
|
264
|
+
TJ: string;
|
|
265
|
+
TK: string;
|
|
266
|
+
TL: string;
|
|
267
|
+
TL1: string;
|
|
268
|
+
TL2: string;
|
|
269
|
+
TM: string;
|
|
270
|
+
TN: string;
|
|
271
|
+
TO: string;
|
|
272
|
+
TR: string;
|
|
273
|
+
TT: string;
|
|
274
|
+
TV: string;
|
|
275
|
+
TV1: string;
|
|
276
|
+
TW: string;
|
|
277
|
+
TW1: string;
|
|
278
|
+
TZ: string;
|
|
279
|
+
UA: string;
|
|
280
|
+
UG: string;
|
|
281
|
+
UK: string;
|
|
282
|
+
US: string;
|
|
283
|
+
UY: string;
|
|
284
|
+
UZ: string;
|
|
285
|
+
VA: string;
|
|
286
|
+
VC: string;
|
|
287
|
+
VE: string;
|
|
288
|
+
VG: string;
|
|
289
|
+
VI: string;
|
|
290
|
+
VN: string;
|
|
291
|
+
VN1: string;
|
|
292
|
+
VU: string;
|
|
293
|
+
VU1: string;
|
|
294
|
+
WF: string;
|
|
295
|
+
WS: string;
|
|
296
|
+
YE: string;
|
|
297
|
+
YE1: string;
|
|
298
|
+
YE2: string;
|
|
299
|
+
ZA: string;
|
|
300
|
+
ZM: string;
|
|
301
|
+
ZW: string;
|
|
302
|
+
DEFAULT: string;
|
|
303
|
+
};
|
|
304
|
+
export declare const getPhoneMask: (value: string) => any;
|