ish-ui 1.0.2

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.
Files changed (126) hide show
  1. package/.eslintrc.json +39 -0
  2. package/.gitattributes +3 -0
  3. package/.github/workflows/release-package.yml +33 -0
  4. package/.prettierrc +5 -0
  5. package/README.md +80 -0
  6. package/assets/fonts/inter/Inter-Italic.var.woff2 +0 -0
  7. package/assets/fonts/inter/Inter-Roman.var.woff2 +0 -0
  8. package/assets/fonts/inter/LICENSE.txt +92 -0
  9. package/assets/fonts/inter/index.d.ts +10 -0
  10. package/assets/fonts/inter/inter.scss +17 -0
  11. package/package.json +108 -0
  12. package/src/actions/FieldProcessing.ts +21 -0
  13. package/src/actions/index.ts +10 -0
  14. package/src/appBar/AppBarHelpMenu.tsx +139 -0
  15. package/src/appBar/index.ts +9 -0
  16. package/src/buttons/AddButton.tsx +30 -0
  17. package/src/buttons/TimetableButton.tsx +19 -0
  18. package/src/buttons/index.ts +10 -0
  19. package/src/colorPicker/ColorPicker.tsx +223 -0
  20. package/src/colorPicker/index.ts +9 -0
  21. package/src/dialog/BrowserWarning.tsx +24 -0
  22. package/src/dialog/confirm/ConfirmBase.tsx +59 -0
  23. package/src/dialog/index.ts +11 -0
  24. package/src/dialog/message/Message.tsx +140 -0
  25. package/src/documents/DocumentIconsChooser.tsx +69 -0
  26. package/src/documents/index.ts +10 -0
  27. package/src/documents/utils/index.tsx +71 -0
  28. package/src/dynamicSizeList/DynamicSizeList.tsx +208 -0
  29. package/src/dynamicSizeList/index.ts +9 -0
  30. package/src/fieldMessage/ErrorMessage.tsx +28 -0
  31. package/src/fieldMessage/WarningMessage.tsx +28 -0
  32. package/src/fieldMessage/index.ts +11 -0
  33. package/src/fieldMessage/styles.ts +21 -0
  34. package/src/fileUploader/FileUploaderDialog.tsx +158 -0
  35. package/src/fileUploader/index.ts +9 -0
  36. package/src/formFields/CheckboxField.tsx +90 -0
  37. package/src/formFields/CodeEditorField.tsx +103 -0
  38. package/src/formFields/ColoredCheckBox.tsx +74 -0
  39. package/src/formFields/DateTimeField.tsx +61 -0
  40. package/src/formFields/EditInPlaceDateTimeField.tsx +285 -0
  41. package/src/formFields/EditInPlaceDurationField.tsx +79 -0
  42. package/src/formFields/EditInPlaceField.tsx +131 -0
  43. package/src/formFields/EditInPlaceFieldBase.tsx +241 -0
  44. package/src/formFields/EditInPlaceFileField.tsx +67 -0
  45. package/src/formFields/EditInPlaceMoneyField.tsx +64 -0
  46. package/src/formFields/EditInPlacePhoneField.tsx +97 -0
  47. package/src/formFields/EditInPlaceSearchSelect.tsx +562 -0
  48. package/src/formFields/FieldAdornments.tsx +70 -0
  49. package/src/formFields/FilePreview.tsx +149 -0
  50. package/src/formFields/FormRadioButtons.tsx +62 -0
  51. package/src/formFields/SelectCustomComponents.tsx +228 -0
  52. package/src/formFields/Switch.tsx +146 -0
  53. package/src/formFields/TextField.tsx +60 -0
  54. package/src/formFields/UneditableBase.tsx +101 -0
  55. package/src/formFields/index.ts +27 -0
  56. package/src/index.ts +26 -0
  57. package/src/layout/InfoPill.tsx +36 -0
  58. package/src/layout/index.ts +10 -0
  59. package/src/layout/resizable/ResizableWrapper.tsx +87 -0
  60. package/src/markdownEditor/HtmlEditor.tsx +44 -0
  61. package/src/markdownEditor/WysiwygEditor.tsx +137 -0
  62. package/src/markdownEditor/index.ts +12 -0
  63. package/src/markdownEditor/style.ts +188 -0
  64. package/src/markdownEditor/utils/index.ts +48 -0
  65. package/src/model/AppBar.ts +20 -0
  66. package/src/model/CommomObjects.ts +8 -0
  67. package/src/model/CommonFunctions.ts +20 -0
  68. package/src/model/Confirm.ts +27 -0
  69. package/src/model/Fields.ts +254 -0
  70. package/src/model/NestedEntity.ts +14 -0
  71. package/src/model/Theme.ts +42 -0
  72. package/src/model/index.ts +16 -0
  73. package/src/styles/GlobalStylesProvider.tsx +520 -0
  74. package/src/styles/StylesProviderCustom.tsx +8 -0
  75. package/src/styles/animateStyles.ts +94 -0
  76. package/src/styles/bootstrap.ts +503 -0
  77. package/src/styles/hooks.ts +44 -0
  78. package/src/styles/index.ts +18 -0
  79. package/src/styles/makeStyles.ts +21 -0
  80. package/src/styles/mixins/common.ts +40 -0
  81. package/src/styles/mixins/keyframes.ts +16 -0
  82. package/src/styles/mixins/prefixer.ts +21 -0
  83. package/src/tagsInput/AddTagMenu.tsx +74 -0
  84. package/src/tagsInput/AddTagMenuItem.tsx +50 -0
  85. package/src/tagsInput/TagInputList.tsx +428 -0
  86. package/src/tagsInput/index.ts +4 -0
  87. package/src/themes/appTheme.ts +324 -0
  88. package/src/themes/index.ts +10 -0
  89. package/src/themes/ishTheme.ts +401 -0
  90. package/src/timetable/datePeriodFilter/DayPeriodIcons.tsx +95 -0
  91. package/src/timetable/datePeriodFilter/index.ts +10 -0
  92. package/src/timetable/index.ts +11 -0
  93. package/src/timetable/miniCalendar/CalendarDay.tsx +109 -0
  94. package/src/timetable/miniCalendar/CalendarHeader.tsx +37 -0
  95. package/src/timetable/miniCalendar/CalendarWeekPanel.tsx +35 -0
  96. package/src/timetable/miniCalendar/WeekDay.tsx +49 -0
  97. package/src/timetable/miniCalendar/index.ts +13 -0
  98. package/src/utils/DOM/Links.ts +17 -0
  99. package/src/utils/DOM/getCaretCoordinates.ts +122 -0
  100. package/src/utils/DOM/getOS.ts +32 -0
  101. package/src/utils/DOM/index.ts +34 -0
  102. package/src/utils/dates/datesNormalizing.ts +4 -0
  103. package/src/utils/dates/format.ts +52 -0
  104. package/src/utils/dates/formatRelative.ts +22 -0
  105. package/src/utils/dates/formatString.ts +233 -0
  106. package/src/utils/dates/formatTimezone.ts +37 -0
  107. package/src/utils/dates/index.ts +15 -0
  108. package/src/utils/dates/timetable.ts +46 -0
  109. package/src/utils/events/index.ts +8 -0
  110. package/src/utils/fields/index.ts +23 -0
  111. package/src/utils/formatting/PhoneMasks.ts +320 -0
  112. package/src/utils/formatting/index.tsx +20 -0
  113. package/src/utils/hooks/index.ts +19 -0
  114. package/src/utils/index.ts +15 -0
  115. package/src/utils/numbers/decimalCalculation.ts +26 -0
  116. package/src/utils/numbers/index.ts +11 -0
  117. package/src/utils/numbers/numbersNormalizing.ts +52 -0
  118. package/src/utils/stubs/index.tsx +12 -0
  119. package/src/utils/tags/index.ts +53 -0
  120. package/tools/webpack/webpack.aliases.js +13 -0
  121. package/tools/webpack/webpack.config.dev.js +29 -0
  122. package/tools/webpack/webpack.config.prod.js +36 -0
  123. package/tools/webpack/webpack.helpers.js +26 -0
  124. package/tools/webpack/webpack.plugins.js +15 -0
  125. package/tools/webpack/webpack.rules.js +51 -0
  126. package/tsconfig.json +24 -0
@@ -0,0 +1,8 @@
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
+
6
+ export const stopEventPropagation = e => e.stopPropagation();
7
+
8
+ export const preventEventDefault = e => e.preventDefault();
@@ -0,0 +1,23 @@
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
+
9
+
10
+ export const getCheckboxValue = (value, stringValue) => {
11
+ if (!stringValue) {
12
+ return !!value;
13
+ }
14
+
15
+ switch (value) {
16
+ case 'false':
17
+ return false;
18
+ case 'true':
19
+ return true;
20
+ default:
21
+ return Boolean(value);
22
+ }
23
+ };
@@ -0,0 +1,320 @@
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
+
9
+ export const phoneMasks = {
10
+ 'AC': '+247-####',
11
+ 'AD': '+376-###-###',
12
+ 'AE': '+971-5#-###-####',
13
+ 'AE1': '+971-#-###-####',
14
+ 'AF': '+93-##-###-####',
15
+ 'AG': '+1 (268) ###-####',
16
+ 'AI': '+1 (264) ###-####',
17
+ 'AL': '+355 (###) ###-###',
18
+ 'AM': '+374-##-###-###',
19
+ 'AN': '+599-###-####',
20
+ 'AN1': '+599-###-####',
21
+ 'AN2': '+599-9###-####',
22
+ 'AO': '+244 (###) ###-###',
23
+ 'AQ': '+672-1##-###',
24
+ 'AR': '+54 (###) ###-####',
25
+ 'AS': '+1 (684) ###-####',
26
+ 'AT': '+43 (###) ###-####',
27
+ 'AU': '+61 4## ### ###',
28
+ 'AU1': '+61 # #### ####',
29
+ 'AU2': '(02) #### ####',
30
+ 'AU3': '(03) #### ####',
31
+ 'AU4': '04## ### ###',
32
+ 'AU5': '(07) #### ####',
33
+ 'AU6': '(08) #### ####',
34
+ 'AW': '+297-###-####',
35
+ 'AZ': '+994-##-###-##-##',
36
+ 'BA': '+387-##-#####',
37
+ 'BA1': '+387-##-####',
38
+ 'BB': '+1 (246) ###-####',
39
+ 'BD': '+880-##-###-###',
40
+ 'BE': '+32 (###) ###-###',
41
+ 'BF': '+226-##-##-####',
42
+ 'BG': '+359 (###) ###-###',
43
+ 'BH': '+973-####-####',
44
+ 'BI': '+257-##-##-####',
45
+ 'BJ': '+229-##-##-####',
46
+ 'BM': '+1 (441) ###-####',
47
+ 'BN': '+673-###-####',
48
+ 'BO': '+591-#-###-####',
49
+ 'BR': '+55 (##) ####-####',
50
+ 'BR1': '+55 (##) 7###-####',
51
+ 'BR2': '+55 (##) 9####-####',
52
+ 'BS': '+1 (242) ###-####',
53
+ 'BT': '+975-17-###-###',
54
+ 'BT1': '+975-#-###-###',
55
+ 'BW': '+267-##-###-###',
56
+ 'BY': '+375 (##) ###-##-##',
57
+ 'BZ': '+501-###-####',
58
+ 'CA': '+1 (###) ###-####',
59
+ 'CD': '+243 (###) ###-###',
60
+ 'CF': '+236-##-##-####',
61
+ 'CG': '+242-##-###-####',
62
+ 'CH': '+41-##-###-####',
63
+ 'CI': '+225-##-###-###',
64
+ 'CK': '+682-##-###',
65
+ 'CL': '+56-#-####-####',
66
+ 'CM': '+237-####-####',
67
+ 'CN': '+86 (###) ####-####',
68
+ 'CN1': '+86 (###) ####-###',
69
+ 'CN2': '+86-##-#####-#####',
70
+ 'CO': '+57 (###) ###-####',
71
+ 'CR': '+506-####-####',
72
+ 'CU': '+53-#-###-####',
73
+ 'CV': '+238 (###) ##-##',
74
+ 'CW': '+599-###-####',
75
+ 'CY': '+357-##-###-###',
76
+ 'CZ': '+420 (###) ###-###',
77
+ 'DE': '+49 (####) ###-####',
78
+ 'DE1': '+49 (###) ###-####',
79
+ 'DE2': '+49 (###) ##-####',
80
+ 'DE3': '+49 (###) ##-###',
81
+ 'DE4': '+49 (###) ##-##',
82
+ 'DE5': '+49-###-###',
83
+ 'DJ': '+253-##-##-##-##',
84
+ 'DK': '+45-##-##-##-##',
85
+ 'DM': '+1 (767) ###-####',
86
+ 'DO': '+1 (809) ###-####',
87
+ 'DO1': '+1 (829) ###-####',
88
+ 'DO2': '+1 (849) ###-####',
89
+ 'DZ': '+213-##-###-####',
90
+ 'EC': '+593-##-###-####',
91
+ 'EC1': '+593-#-###-####',
92
+ 'EE': '+372-####-####',
93
+ 'EE1': '+372-###-####',
94
+ 'EG': '+20 (###) ###-####',
95
+ 'ER': '+291-#-###-###',
96
+ 'ES': '+34 (###) ###-###',
97
+ 'ET': '+251-##-###-####',
98
+ 'FI': '+358 (###) ###-##-##',
99
+ 'FJ': '+679-##-#####',
100
+ 'FK': '+500-#####',
101
+ 'FM': '+691-###-####',
102
+ 'FO': '+298-###-###',
103
+ 'FR': '+262-#####-####',
104
+ 'FR1': '+33 (###) ###-###',
105
+ 'FR2': '+508-##-####',
106
+ 'FR3': '+590 (###) ###-###',
107
+ 'GA': '+241-#-##-##-##',
108
+ 'GD': '+1 (473) ###-####',
109
+ 'GE': '+995 (###) ###-###',
110
+ 'GF': '+594-#####-####',
111
+ 'GH': '+233 (###) ###-###',
112
+ 'GI': '+350-###-#####',
113
+ 'GL': '+299-##-##-##',
114
+ 'GM': '+220 (###) ##-##',
115
+ 'GN': '+224-##-###-###',
116
+ 'GQ': '+240-##-###-####',
117
+ 'GR': '+30 (###) ###-####',
118
+ 'GT': '+502-#-###-####',
119
+ 'GU': '+1 (671) ###-####',
120
+ 'GW': '+245-#-######',
121
+ 'GY': '+592-###-####',
122
+ 'HK': '+852-####-####',
123
+ 'HN': '+504-####-####',
124
+ 'HR': '+385-##-###-###',
125
+ 'HT': '+509-##-##-####',
126
+ 'HU': '+36 (###) ###-###',
127
+ 'ID': '+62 (8##) ###-####',
128
+ 'ID1': '+62-##-###-##',
129
+ 'ID2': '+62-##-###-###',
130
+ 'ID3': '+62-##-###-####',
131
+ 'ID4': '+62 (8##) ###-###',
132
+ 'ID5': '+62 (8##) ###-##-###',
133
+ 'IE': '+353 (###) ###-###',
134
+ 'IL': '+972-5#-###-####',
135
+ 'IL1': '+972-#-###-####',
136
+ 'IN': '+91 (####) ###-###',
137
+ 'IO': '+246-###-####',
138
+ 'IQ': '+964 (###) ###-####',
139
+ 'IR': '+98 (###) ###-####',
140
+ 'IS': '+354-###-####',
141
+ 'IT': '+39 (###) ####-###',
142
+ 'JM': '+1 (876) ###-####',
143
+ 'JO': '+962-#-####-####',
144
+ 'JP': '+81-##-####-####',
145
+ 'JP1': '+81 (###) ###-###',
146
+ 'KE': '+254-###-######',
147
+ 'KG': '+996 (###) ###-###',
148
+ 'KH': '+855-##-###-###',
149
+ 'KI': '+686-##-###',
150
+ 'KM': '+269-##-#####',
151
+ 'KN': '+1 (869) ###-####',
152
+ 'KP': '+850-191-###-####',
153
+ 'KP1': '+850-##-###-###',
154
+ 'KP2': '+850-###-####-###',
155
+ 'KP3': '+850-###-###',
156
+ 'KP4': '+850-####-####',
157
+ 'KP5': '+850-####-#############',
158
+ 'KR': '+82-##-###-####',
159
+ 'KW': '+965-####-####',
160
+ 'KY': '+1 (345) ###-####',
161
+ 'KZ': '+7 (6##) ###-##-##',
162
+ 'KZ1': '+7 (7##) ###-##-##',
163
+ 'LA': '+856 (20##) ###-###',
164
+ 'LA1': '+856-##-###-###',
165
+ 'LB': '+961-##-###-###',
166
+ 'LB1': '+961-#-###-###',
167
+ 'LC': '+1 (758) ###-####',
168
+ 'LI': '+423 (###) ###-####',
169
+ 'LK': '+94-##-###-####',
170
+ 'LR': '+231-##-###-###',
171
+ 'LS': '+266-#-###-####',
172
+ 'LT': '+370 (###) ##-###',
173
+ 'LU': '+352 (###) ###-###',
174
+ 'LV': '+371-##-###-###',
175
+ 'LY': '+218-##-###-###',
176
+ 'LY1': '+218-21-###-####',
177
+ 'MA': '+212-##-####-###',
178
+ 'MC': '+377 (###) ###-###',
179
+ 'MC1': '+377-##-###-###',
180
+ 'MD': '+373-####-####',
181
+ 'ME': '+382-##-###-###',
182
+ 'MG': '+261-##-##-#####',
183
+ 'MH': '+692-###-####',
184
+ 'MK': '+389-##-###-###',
185
+ 'ML': '+223-##-##-####',
186
+ 'MM': '+95-##-###-###',
187
+ 'MM1': '+95-#-###-###',
188
+ 'MN': '+976-##-##-####',
189
+ 'MO': '+853-####-####',
190
+ 'MP': '+1 (670) ###-####',
191
+ 'MQ': '+596 (###) ##-##-##',
192
+ 'MR': '+222-##-##-####',
193
+ 'MS': '+1 (664) ###-####',
194
+ 'MT': '+356-####-####',
195
+ 'MU': '+230-###-####',
196
+ 'MV': '+960-###-####',
197
+ 'MW': '+265-1-###-###',
198
+ 'MW1': '+265-#-####-####',
199
+ 'MX': '+52 (###) ###-####',
200
+ 'MX1': '+52-##-##-####',
201
+ 'MY': '+60-##-###-####',
202
+ 'MY1': '+60 (###) ###-###',
203
+ 'MY2': '+60-##-###-###',
204
+ 'MY3': '+60-#-###-###',
205
+ 'MZ': '+258-##-###-###',
206
+ 'NA': '+264-##-###-####',
207
+ 'NC': '+687-##-####',
208
+ 'NE': '+227-##-##-####',
209
+ 'NF': '+672-3##-###',
210
+ 'NG': '+234 (###) ###-####',
211
+ 'NG1': '+234-##-###-###',
212
+ 'NG2': '+234-##-###-##',
213
+ 'NG3': '+234 (###) ###-####',
214
+ 'NI': '+505-####-####',
215
+ 'NL': '+31-##-###-####',
216
+ 'NO': '+47 (###) ##-###',
217
+ 'NP': '+977-##-###-###',
218
+ 'NR': '+674-###-####',
219
+ 'NU': '+683-####',
220
+ 'NZ': '+64 (###) ###-###',
221
+ 'NZ1': '+64-##-###-###',
222
+ 'NZ2': '+64 (###) ###-####',
223
+ 'OM': '+968-##-###-###',
224
+ 'PA': '+507-###-####',
225
+ 'PE': '+51 (###) ###-###',
226
+ 'PF': '+689-##-##-##',
227
+ 'PG': '+675 (###) ##-###',
228
+ 'PH': '+63 (###) ###-####',
229
+ 'PK': '+92 (###) ###-####',
230
+ 'PL': '+48 (###) ###-###',
231
+ 'PS': '+970-##-###-####',
232
+ 'PT': '+351-##-###-####',
233
+ 'PW': '+680-###-####',
234
+ 'PY': '+595 (###) ###-###',
235
+ 'QA': '+974-####-####',
236
+ 'RE': '+262-#####-####',
237
+ 'RO': '+40-##-###-####',
238
+ 'RS': '+381-##-###-####',
239
+ 'RU': '+7 (###) ###-##-##',
240
+ 'RW': '+250 (###) ###-###',
241
+ 'SA': '+966-5-####-####',
242
+ 'SA1': '+966-#-###-####',
243
+ 'SB': '+677-###-####',
244
+ 'SB1': '+677-#####',
245
+ 'SC': '+248-#-###-###',
246
+ 'SD': '+249-##-###-####',
247
+ 'SE': '+46-##-###-####',
248
+ 'SG': '+65-####-####',
249
+ 'SH': '+290-####',
250
+ 'SH1': '+290-####',
251
+ 'SI': '+386-##-###-###',
252
+ 'SK': '+421 (###) ###-###',
253
+ 'SL': '+232-##-######',
254
+ 'SM': '+378-####-######',
255
+ 'SN': '+221-##-###-####',
256
+ 'SO': '+252-##-###-###',
257
+ 'SO1': '+252-#-###-###',
258
+ 'SO2': '+252-#-###-###',
259
+ 'SR': '+597-###-####',
260
+ 'SR1': '+597-###-###',
261
+ 'SS': '+211-##-###-####',
262
+ 'ST': '+239-##-#####',
263
+ 'SV': '+503-##-##-####',
264
+ 'SX': '+1 (721) ###-####',
265
+ 'SY': '+963-##-####-###',
266
+ 'SZ': '+268-##-##-####',
267
+ 'TC': '+1 (649) ###-####',
268
+ 'TD': '+235-##-##-##-##',
269
+ 'TG': '+228-##-###-###',
270
+ 'TH': '+66-##-###-####',
271
+ 'TH1': '+66-##-###-###',
272
+ 'TJ': '+992-##-###-####',
273
+ 'TK': '+690-####',
274
+ 'TL': '+670-###-####',
275
+ 'TL1': '+670-77#-#####',
276
+ 'TL2': '+670-78#-#####',
277
+ 'TM': '+993-#-###-####',
278
+ 'TN': '+216-##-###-###',
279
+ 'TO': '+676-#####',
280
+ 'TR': '+90 (###) ###-####',
281
+ 'TT': '+1 (868) ###-####',
282
+ 'TV': '+688-90####',
283
+ 'TV1': '+688-2####',
284
+ 'TW': '+886-#-####-####',
285
+ 'TW1': '+886-####-####',
286
+ 'TZ': '+255-##-###-####',
287
+ 'UA': '+380 (##) ###-##-##',
288
+ 'UG': '+256 (###) ###-###',
289
+ 'UK': '+44-##-####-####',
290
+ 'US': '+1 (###) ###-####',
291
+ 'UY': '+598-#-###-##-##',
292
+ 'UZ': '+998-##-###-####',
293
+ 'VA': '+39-6-698-#####',
294
+ 'VC': '+1 (784) ###-####',
295
+ 'VE': '+58 (###) ###-####',
296
+ 'VG': '+1 (284) ###-####',
297
+ 'VI': '+1 (340) ###-####',
298
+ 'VN': '+84-##-####-###',
299
+ 'VN1': '+84 (###) ####-###',
300
+ 'VU': '+678-##-#####',
301
+ 'VU1': '+678-#####',
302
+ 'WF': '+681-##-####',
303
+ 'WS': '+685-##-####',
304
+ 'YE': '+967-###-###-###',
305
+ 'YE1': '+967-#-###-###',
306
+ 'YE2': '+967-##-###-###',
307
+ 'ZA': '+27-##-###-####',
308
+ 'ZM': '+260-##-###-####',
309
+ 'ZW': '+263-#-######',
310
+ 'DEFAULT': '#### #### ###########'
311
+ };
312
+
313
+ export const getPhoneMask = (value: string) => {
314
+ const maskKey = Object.keys(phoneMasks).find(key => {
315
+ const mask = phoneMasks[key];
316
+ return value.startsWith(mask?.match(/\d/g)?.join('')) && value.length === mask?.match(/\d|#/g)?.length;
317
+ });
318
+
319
+ return phoneMasks[maskKey] ? phoneMasks[maskKey].replace(/\d/g, '#') : value.length === 8 ? phoneMasks['DEFAULT'] : null;
320
+ };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import parse from 'autosuggest-highlight/parse';
3
+ import match from 'autosuggest-highlight/match';
4
+
5
+ export const getHighlightedPartLabel = (label: string, highlighted: string, options?: any) => {
6
+ const matches = match(label, highlighted, { insideWords: true });
7
+ const parts = parse(label, matches);
8
+
9
+ const result = parts.map((part, index) => (
10
+ <span key={index}>{part.highlight ? <strong>{part.text}</strong> : part.text}</span>
11
+ ));
12
+
13
+ return options ? (
14
+ <div {...options || {}}>
15
+ {result}
16
+ </div>
17
+ ) : result;
18
+ };
19
+
20
+ export * from './PhoneMasks'
@@ -0,0 +1,19 @@
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
+
9
+ import { useEffect, useRef } from 'react';
10
+
11
+ export const usePrevious = <T = any>(value: any, initial?: any) => {
12
+ const ref = useRef<T>(initial);
13
+
14
+ useEffect(() => {
15
+ ref.current = value;
16
+ }, [value]);
17
+
18
+ return ref.current;
19
+ };
@@ -0,0 +1,15 @@
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
+
9
+ export * from './tags';
10
+ export * from './formatting';
11
+ export * from './stubs';
12
+ export * from './DOM';
13
+ export * from './numbers';
14
+ export * from './dates';
15
+ export * from './fields';
@@ -0,0 +1,26 @@
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
+
6
+ import { Decimal } from 'decimal.js-light';
7
+
8
+ export const decimalMul = (...args): number => args
9
+ .reduce((p, c) => p.mul(c || 0), new Decimal(1))
10
+ .toDecimalPlaces(2)
11
+ .toNumber();
12
+
13
+ export const decimalPlus = (...args): number => args
14
+ .reduce((p, c) => p.plus(c || 0), new Decimal(0))
15
+ .toDecimalPlaces(2)
16
+ .toNumber();
17
+
18
+ export const decimalMinus = (...args): number => args
19
+ .reduce((p, c) => new Decimal(p).minus(c))
20
+ .toDecimalPlaces(2)
21
+ .toNumber();
22
+
23
+ export const decimalDivide = (a: number, b: number): number => new Decimal(a)
24
+ .div(b)
25
+ .toDecimalPlaces(2)
26
+ .toNumber();
@@ -0,0 +1,11 @@
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
+
9
+
10
+ export * from './decimalCalculation';
11
+ export * from './numbersNormalizing';
@@ -0,0 +1,52 @@
1
+ import Decimal from 'decimal.js-light';
2
+
3
+ const currencyFormatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
4
+
5
+ export const normalizeNumber = v => (typeof v === 'number' ? v : typeof v === 'string' && v ? parseFloat(v) : v);
6
+
7
+ export const normalizeNumberToZero = v => (typeof v === 'number' ? v : typeof v === 'string' && v ? parseFloat(v) : 0);
8
+
9
+ export const normalizeNumberToPositive = v => {
10
+ const parsed = normalizeNumber(v);
11
+ return parsed < 0 ? Math.abs(parsed) : parsed;
12
+ };
13
+
14
+ export const formatCurrency = (v, cs: string) => {
15
+ const formatted = currencyFormatter.format(v);
16
+ let value = `${cs}0.00`;
17
+ if (formatted !== 'NaN') {
18
+ const formattedValue = parseFloat(v);
19
+ if (formattedValue < 0) value = `-${cs}${currencyFormatter.format(-formattedValue)}`;
20
+ else value = `${cs}${currencyFormatter.format(formattedValue)}`;
21
+ }
22
+ return value;
23
+ };
24
+
25
+ export const idsToString = (items: any[]): string => items
26
+ .filter(item => item.id)
27
+ .map(item => item.id)
28
+ .map(id => (Number(id) < 0 ? `'${id}'` : id))
29
+ .toString();
30
+
31
+ export const formatPercent = val => {
32
+ const result = Number(val);
33
+ if (isNaN(result)) {
34
+ return '';
35
+ }
36
+ return `${new Decimal(result * 100).toDecimalPlaces(2).toString()}%`;
37
+ };
38
+
39
+ export const formatFieldPercent = val => val && Math.round(+val * 10000) / 100;
40
+ export const parseFieldPercent = val => val ? Math.round(+val * 100) / 10000 : 0;
41
+
42
+ export const preventNegativeOrLogEnter = ev => {
43
+ if (ev.key === '-' || ev.key === 'e') {
44
+ ev.preventDefault();
45
+ }
46
+ };
47
+
48
+ export const preventDecimalEnter = ev => {
49
+ if (ev.key === '.') {
50
+ ev.preventDefault();
51
+ }
52
+ };
@@ -0,0 +1,12 @@
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 React from 'react';
9
+
10
+ export const stubFunction = () => undefined;
11
+
12
+ export const stubComponent = () => <div className="invisible" />;
@@ -0,0 +1,53 @@
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
+
9
+
10
+ import { MenuTag, TagLike } from '@src/model';
11
+
12
+ export const getAllMenuTags = (tags: MenuTag<TagLike>[], res?: MenuTag<TagLike>[], path = ''): MenuTag<TagLike>[] => {
13
+ const result = res || [];
14
+
15
+ for (let i = 0; i < tags.length; i++) {
16
+ const tag = tags[i];
17
+ tag.path = path;
18
+ result.push(tag);
19
+
20
+ if (tag.children.length) {
21
+ getAllMenuTags(tags[i].children, result, `${path ? `${path} / ` : ''}${(tag.tagBody && tag.tagBody.name) || ''}`);
22
+ }
23
+ }
24
+ return result;
25
+ };
26
+
27
+ export const getMenuTags = (allTags: TagLike[], addedTags: TagLike[], prefix?: string, queryPrefix?: string, entity?: string, path?: string, parent?: MenuTag<TagLike>): MenuTag<TagLike>[] => allTags.map(t => {
28
+ const active = addedTags.find(i => i.id === t.id);
29
+
30
+ const tag: MenuTag<TagLike> = {
31
+ active: Boolean(active),
32
+ tagBody: t,
33
+ parent,
34
+ children: []
35
+ };
36
+
37
+ tag.children = t.childTags.length ? getMenuTags(t.childTags, addedTags, prefix, queryPrefix, entity, path, tag) : [];
38
+
39
+ if (prefix) {
40
+ tag.prefix = prefix;
41
+ }
42
+ if (queryPrefix) {
43
+ tag.queryPrefix = queryPrefix;
44
+ }
45
+ if (entity) {
46
+ tag.entity = entity;
47
+ }
48
+ if (path) {
49
+ tag.path = path;
50
+ }
51
+
52
+ return tag;
53
+ });
@@ -0,0 +1,13 @@
1
+ const { createWebpackAliases } = require('./webpack.helpers');
2
+
3
+ /**
4
+ * Export Webpack Aliases
5
+ *
6
+ * Tip: Some text editors will show the errors or invalid intellisense reports
7
+ * based on these webpack aliases, make sure to update `tsconfig.json` file also
8
+ * to match the `paths` we using in here for aliases in project.
9
+ */
10
+ module.exports = createWebpackAliases({
11
+ '@assets': 'assets',
12
+ '@src': 'src',
13
+ });
@@ -0,0 +1,29 @@
1
+ module.exports = {
2
+ mode: 'development',
3
+ entry: ['./src/index.ts'],
4
+ module: {
5
+ rules: require('./webpack.rules'),
6
+ },
7
+ output: {
8
+ filename: '[name].js',
9
+ chunkFilename: '[name].chunk.js',
10
+ },
11
+ plugins: require('./webpack.plugins'),
12
+ resolve: {
13
+ extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
14
+ alias: require('./webpack.aliases'),
15
+ },
16
+ stats: 'errors-warnings',
17
+ devtool: 'cheap-module-source-map',
18
+ devServer: {
19
+ open: true,
20
+ },
21
+ optimization: {
22
+ splitChunks: {
23
+ chunks: 'all',
24
+ },
25
+ },
26
+ performance: {
27
+ hints: false,
28
+ },
29
+ };
@@ -0,0 +1,36 @@
1
+ const TerserPlugin = require("terser-webpack-plugin");
2
+ const path = require("path");
3
+
4
+ module.exports = {
5
+ mode: 'production',
6
+ entry: {
7
+ 'ish-ui': './src/index.ts'
8
+ },
9
+ output: {
10
+ path: path.resolve(__dirname, '_bundles'),
11
+ filename: '[name].js',
12
+ clean: true,
13
+ library: {
14
+ name: 'ish-ui',
15
+ type: 'umd',
16
+ umdNamedDefine: true
17
+ },
18
+ },
19
+ resolve: {
20
+ extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
21
+ alias: {
22
+ // Custom Aliases
23
+ ...require('./webpack.aliases'),
24
+ },
25
+ },
26
+ devtool: 'source-map',
27
+ module: {
28
+ rules: require('./webpack.rules'),
29
+ },
30
+ plugins: [...require('./webpack.plugins')],
31
+ stats: 'errors-warnings',
32
+ optimization: {
33
+ minimize: true,
34
+ minimizer: [new TerserPlugin()],
35
+ },
36
+ };
@@ -0,0 +1,26 @@
1
+ const path = require('path');
2
+ const cwd = process.cwd();
3
+
4
+ /**
5
+ * Are we in development mode?
6
+ */
7
+ function inDev() {
8
+ return process.env.NODE_ENV == 'development';
9
+ }
10
+
11
+ /**
12
+ * Create webpack aliases
13
+ */
14
+ function createWebpackAliases (aliases) {
15
+ const result = {};
16
+ for (const name in aliases) {
17
+ result[name] = path.join(cwd, aliases[name]);
18
+ }
19
+ return result;
20
+ }
21
+
22
+ // Export helpers
23
+ module.exports = {
24
+ inDev,
25
+ createWebpackAliases,
26
+ };