@inriver/inri 1.13.0 → 1.15.0

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 (119) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.eslintrc.js +5 -5
  4. package/azure/pipelines/single-build-release.yml +6 -0
  5. package/azure/pipelines/templates/deployFramework.yml +50 -0
  6. package/componentProperties.d.ts +8 -8
  7. package/configs/base-eslint-config.js +36 -36
  8. package/configs/base-tailwind-config.js +149 -149
  9. package/i18n.ts +11 -11
  10. package/index.ts +29 -29
  11. package/package.json +7 -2
  12. package/src/components/CAutoBreadcrumbs.vue +72 -72
  13. package/src/components/CBtn.vue +98 -98
  14. package/src/components/CColorPicker.vue +55 -55
  15. package/src/components/CContextMenu.vue +29 -29
  16. package/src/components/CDatePicker.vue +51 -51
  17. package/src/components/CDeleteTileBtn.vue +52 -52
  18. package/src/components/CDialog.vue +253 -253
  19. package/src/components/CDialogCloseBtn.vue +9 -9
  20. package/src/components/CDirtyCheck.vue +68 -68
  21. package/src/components/CDrawer.vue +44 -44
  22. package/src/components/CDrawerButton.vue +91 -91
  23. package/src/components/CExpansionItem.vue +57 -57
  24. package/src/components/CExpansionItemWithCheckbox.vue +41 -41
  25. package/src/components/CFileDropzone.vue +114 -114
  26. package/src/components/CGrid.vue +101 -101
  27. package/src/components/CHeader.vue +10 -10
  28. package/src/components/CHeaderLinks.vue +61 -61
  29. package/src/components/CHeaderMenuLink.vue +51 -51
  30. package/src/components/CHeaderSearch.vue +142 -142
  31. package/src/components/CIconBtn.vue +70 -70
  32. package/src/components/CMenuItem.vue +66 -66
  33. package/src/components/CPageContainer.vue +11 -11
  34. package/src/components/CPageError.vue +24 -24
  35. package/src/components/CPageSpinner.vue +18 -18
  36. package/src/components/CSearch.vue +45 -45
  37. package/src/components/CSection.vue +29 -29
  38. package/src/components/CSectionTitle.vue +8 -8
  39. package/src/components/CSelect.vue +208 -208
  40. package/src/components/CSlideEffect.vue +62 -62
  41. package/src/components/CSpinner.vue +107 -107
  42. package/src/components/CTableActions.vue +16 -16
  43. package/src/components/CTileBtn.vue +178 -178
  44. package/src/components/CTimePicker.vue +42 -42
  45. package/src/components/CToggleGridView.vue +26 -26
  46. package/src/components/CToggleSidebarBtn.vue +19 -19
  47. package/src/components/CTooltip.vue +44 -44
  48. package/src/components/CTreeNode.vue +39 -39
  49. package/src/components/cards/CBannerCard.vue +103 -103
  50. package/src/components/cards/CSmallCard.vue +149 -149
  51. package/src/components/internal-components/ConfirmDialog.vue +78 -78
  52. package/src/composables/useDialog.ts +46 -46
  53. package/src/composables/useDirtyCheck.ts +25 -25
  54. package/src/composables/useDoubleClickListener.ts +28 -28
  55. package/src/composables/useSelectable.ts +62 -62
  56. package/src/composables/useTruncateChips.ts +46 -46
  57. package/src/i18n/de/index.ts +17 -17
  58. package/src/i18n/en/index.ts +84 -84
  59. package/src/i18n/es/index.ts +7 -7
  60. package/src/i18n/fr/index.ts +7 -7
  61. package/src/init/initInriFramework.ts +37 -37
  62. package/src/init/useInriApp.ts +55 -55
  63. package/src/layouts/CLayoutBlank.vue +7 -7
  64. package/src/layouts/CLayoutWithBackButton.vue +50 -50
  65. package/src/layouts/CLayoutWithSidebars.vue +46 -46
  66. package/src/layouts/layout-fragments/CPageAutoBreadcrumbs.vue +6 -6
  67. package/src/layouts/layout-fragments/CPageBackButton.vue +18 -18
  68. package/src/layouts/layout-fragments/CPageBlank.vue +20 -20
  69. package/src/layouts/layout-fragments/CPageFlexCol.vue +5 -5
  70. package/src/layouts/layout-fragments/CPageLeftSidebar.vue +5 -5
  71. package/src/layouts/layout-fragments/CPageMainContent.vue +5 -5
  72. package/src/layouts/layout-fragments/CPageOuterWrapper.vue +5 -5
  73. package/src/layouts/layout-fragments/CPageRightSidebar.vue +5 -5
  74. package/src/layouts/layout-fragments/CPageTitle.vue +34 -34
  75. package/src/plugins/dialog.ts +45 -45
  76. package/src/plugins/errors/ErrorFactories.ts +59 -59
  77. package/src/plugins/errors/Errors.ts +156 -156
  78. package/src/plugins/errors/Exception.ts +6 -6
  79. package/src/plugins/errors/globalErrorHandler.ts +21 -21
  80. package/src/plugins/errors/handleError.ts +34 -34
  81. package/src/plugins/errors/logger.ts +16 -16
  82. package/src/plugins/errors/vueErrorHandler.ts +26 -26
  83. package/src/plugins/globalAppConfig.ts +25 -25
  84. package/src/plugins/i18n.ts +46 -46
  85. package/src/plugins/inriIcons.ts +58 -58
  86. package/src/plugins/inriverQuasarComponentConfigurations.ts +67 -67
  87. package/src/plugins/library.ts +119 -119
  88. package/src/plugins/notify.ts +153 -153
  89. package/src/plugins/quasar-user-options.ts +19 -19
  90. package/src/plugins/validationRules.ts +292 -292
  91. package/src/shims-vue.d.ts +6 -6
  92. package/src/stores/inriStore.ts +54 -54
  93. package/src/stores/interfaceLanguageStore.ts +27 -27
  94. package/src/styles/_css-variables.scss +101 -101
  95. package/src/styles/_reset.scss +67 -67
  96. package/src/styles/_transitions.scss +9 -9
  97. package/src/styles/_utils.scss +15 -15
  98. package/src/styles/components/_breadcrumbs.scss +3 -3
  99. package/src/styles/components/_checkboxes.scss +17 -17
  100. package/src/styles/components/_chips.scss +17 -17
  101. package/src/styles/components/_forms.scss +203 -203
  102. package/src/styles/components/_menu.scss +12 -12
  103. package/src/styles/components/_notifications.scss +24 -24
  104. package/src/styles/components/_q-editor.scss +14 -14
  105. package/src/styles/components/_radio-buttons.scss +17 -17
  106. package/src/styles/components/_tables.scss +92 -92
  107. package/src/styles/components/_tooltips.scss +5 -5
  108. package/src/styles/components/_tree.scss +86 -86
  109. package/src/styles/components/_truncated-chips.scss +39 -39
  110. package/src/styles/main.scss +45 -45
  111. package/src/styles/quasar.variables.scss +50 -50
  112. package/src/styles/tailwind/index.css +2 -2
  113. package/src/typings.d.ts +70 -70
  114. package/src/utils/colorUtils.ts +73 -73
  115. package/src/utils/errorUtils.ts +37 -37
  116. package/src/utils/fileUtils.ts +57 -57
  117. package/src/utils/helpers.ts +6 -6
  118. package/src/utils/routeUtils.ts +23 -23
  119. package/tsconfig.json +34 -34
@@ -1,292 +1,292 @@
1
- import { i18n } from './i18n'
2
-
3
- const $t = i18n.global.t
4
-
5
- /**
6
- * The value is required.
7
- * @param {string} [msg] - Override the default error message
8
- */
9
- export function required (msg?: string) {
10
- return (value): true | string => {
11
- return !!value || msg || $t('inri.validation.required')
12
- }
13
- }
14
-
15
- /**
16
- * The value must have a minimum length.
17
- * @param {string | number} length - Min length
18
- * @param {string} [msg] - Override the default error message
19
- */
20
- export function minLength (length: string | number, msg?: string) {
21
- const parsedLength = typeof length === 'number' ? length : parseInt(length, 10)
22
- return (value): true | string => {
23
- if (!value) {
24
- return true
25
- }
26
-
27
- return value.length >= parsedLength || msg || $t('inri.validation.minLength', { parsedLength: parsedLength })
28
- }
29
- }
30
-
31
- /**
32
- * The value can not exceed maximum length.
33
- * @param {string | number} length - Max length
34
- * @param {string} [msg] - Override the default error message
35
- */
36
- export function maxLength (length: string | number, msg?: string) {
37
- const parsedLength = typeof length === 'number' ? length : parseInt(length, 10)
38
- return (value): true | string => {
39
- if (!value) {
40
- return true
41
- }
42
-
43
- return value.length <= parsedLength || msg || $t('inri.validation.maxLength', { parsedLength: parsedLength })
44
- }
45
- }
46
-
47
- /**
48
- * The value must be a valid email.
49
- * @param {string} [msg] - Override the default error message
50
- */
51
- export function email (msg?: string) {
52
- // eslint-disable-next-line no-useless-escape
53
- const regExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
54
- return (value): true | string => {
55
- if (!value) {
56
- return true
57
- }
58
-
59
- return regExp.test(String(value).toLowerCase()) || msg || $t('inri.validation.email')
60
- }
61
- }
62
-
63
- /**
64
- * The value must be a valid url.
65
- * @param {string} [msg] - Override the default error message
66
- */
67
- export function url (msg?: string) {
68
- // eslint-disable-next-line no-useless-escape
69
- const regExp = /^(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))$/
70
- return (value): true | string => {
71
- if (!value) {
72
- return true
73
- }
74
-
75
- return regExp.test(String(value).toLowerCase()) || msg || $t('inri.validation.url')
76
- }
77
- }
78
-
79
- /**
80
- * The value must be a valid url using https.
81
- * @param {string} [msg] - Override the default error message
82
- */
83
- export function https (msg?: string) {
84
- // eslint-disable-next-line no-useless-escape
85
- const regExp = /^(https:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))$/
86
- return (value): true | string => {
87
- if (!value) {
88
- return true
89
- }
90
-
91
- return regExp.test(String(value).toLowerCase()) || msg || $t('inri.validation.https')
92
- }
93
- }
94
-
95
- /**
96
- * Validate file extensions. Supports single and multiple files.
97
- * @param {string} fileExtensions - A string containing a single file extension, "jpg", or a comma separated string, "jpg,png".
98
- * @param {string} [msg] - Override the default error message
99
- */
100
- export function extension (fileExtensions: string, msg?: string) {
101
- // Extension string cleanup and convert to array
102
- const extensions = fileExtensions
103
- .toLowerCase()
104
- .replaceAll(' ', '')
105
- .replaceAll('.', '')
106
- .split(',')
107
-
108
- return (value): true | string => {
109
- if (!value) {
110
- return true
111
- }
112
-
113
- let files: any[] = []
114
- let isValid = true
115
-
116
- // If single file then push it into an array for consistency
117
- if (!value.length) {
118
- files.push(value)
119
- } else {
120
- files = value
121
- }
122
-
123
- for (const file of files) {
124
- const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase()
125
- if (!extensions.includes(fileExt)) {
126
- isValid = false
127
- break
128
- }
129
- }
130
-
131
- return isValid || msg || $t('inri.validation.extension', { extensions: extensions.join(', .') })
132
- }
133
- }
134
-
135
- /**
136
- * The value must contain all the strings in the array.
137
- * @param {string[]} arr - Array of strings.
138
- * @param {boolean} caseSensitive
139
- * @param {string} [msg] - Override the default error message
140
- */
141
- export function contains (arr: string[], caseSensitive = false, msg?: string) {
142
- return (value): true | string => {
143
- if (!value) {
144
- return true
145
- }
146
-
147
- let foundItems
148
-
149
- if (!caseSensitive) {
150
- foundItems = arr.filter(item => !value.toUpperCase().includes(('' + item).toUpperCase()))
151
- } else {
152
- foundItems = arr.filter(item => !value.includes('' + item))
153
- }
154
-
155
- if (!foundItems.length) {
156
- return true
157
- }
158
-
159
- return msg || $t('inri.validation.contains', { match: foundItems.join(', ') })
160
- }
161
- }
162
-
163
- /**
164
- * The value must not contain any of the strings in the array.
165
- * @param {string[]} arr - Array of strings.
166
- * @param {boolean} caseSensitive
167
- * @param {string} [msg] - Override the default error message
168
- */
169
- export function notContains (arr: string[], caseSensitive = false, msg?: string) {
170
- return (value): true | string => {
171
- if (!value) {
172
- return true
173
- }
174
-
175
- const comparisonValue = value instanceof File ? value.name : value
176
-
177
- let foundItems
178
-
179
- if (!caseSensitive) {
180
- foundItems = arr.filter(item => comparisonValue.toUpperCase().includes(('' + item).toUpperCase()))
181
- } else {
182
- foundItems = arr.filter(item => comparisonValue.includes('' + item))
183
- }
184
-
185
- if (!foundItems.length) {
186
- return true
187
- }
188
-
189
- return msg || $t('inri.validation.notContains', { match: foundItems.join(', ') })
190
- }
191
- }
192
-
193
- /**
194
- * The value must not begin with any of the strings in the array.
195
- * @param {string[]} arr - Array of strings.
196
- * @param {boolean} caseSensitive
197
- * @param {string} [msg] - Override the default error message
198
- */
199
- export function notBeginsWith (arr: string[], caseSensitive = false, msg?: string) {
200
- return (value): true | string => {
201
- if (!value) {
202
- return true
203
- }
204
-
205
- let foundItems
206
-
207
- if (!caseSensitive) {
208
- foundItems = arr.filter(item => value.toUpperCase().startsWith(('' + item).toUpperCase()))
209
- } else {
210
- foundItems = arr.filter(item => value.startsWith('' + item))
211
- }
212
-
213
- if (!foundItems.length) {
214
- return true
215
- }
216
-
217
- return msg || $t('inri.validation.notBeginsWith', { match: foundItems.join(', ') })
218
- }
219
- }
220
-
221
- /**
222
- * The value must not end with any of the strings in the array.
223
- * @param {string[]} arr - Array of strings.
224
- * @param {boolean} caseSensitive
225
- * @param {string} [msg] - Override the default error message
226
- */
227
- export function notEndsWith (arr: string[], caseSensitive = false, msg?: string) {
228
- return (value): true | string => {
229
- if (!value) {
230
- return true
231
- }
232
-
233
- let foundItems
234
-
235
- if (!caseSensitive) {
236
- foundItems = arr.filter(item => value.toUpperCase().endsWith(('' + item).toUpperCase()))
237
- } else {
238
- foundItems = arr.filter(item => value.endsWith('' + item))
239
- }
240
-
241
- if (!foundItems.length) {
242
- return true
243
- }
244
-
245
- return msg || $t('inri.validation.notEndsWith', { match: foundItems.join(', ') })
246
- }
247
- }
248
-
249
- /**
250
- * The file(s) cannot exceed max size
251
- * @param {string | number} size - Max size in bytes
252
- * @param {string} [type] - Only validate against files with this MIME type
253
- * @param {string} [msg] - Override the default error message
254
- */
255
- export function maxFileSize (size: string | number, type?: string, msg?: string) {
256
- const parsedFileSize = typeof size === 'number' ? size : parseInt(size, 10)
257
-
258
- return (value): true | string => {
259
- if (!value) {
260
- return true
261
- }
262
-
263
- let files: any[] = []
264
-
265
- if (!value.length) {
266
- files.push(value)
267
- } else {
268
- files = value
269
- }
270
-
271
- if (type) {
272
- files = files.filter(file => file.type.includes(type))
273
- }
274
-
275
- return files.every(file => file.size <= size) || msg || $t('inri.validation.maxFileSize', { parsedFileSize })
276
- }
277
- }
278
-
279
- export const rules = {
280
- required,
281
- maxLength,
282
- minLength,
283
- email,
284
- url,
285
- https,
286
- extension,
287
- contains,
288
- notContains,
289
- notBeginsWith,
290
- notEndsWith,
291
- maxFileSize,
292
- }
1
+ import { i18n } from './i18n'
2
+
3
+ const $t = i18n.global.t
4
+
5
+ /**
6
+ * The value is required.
7
+ * @param {string} [msg] - Override the default error message
8
+ */
9
+ export function required (msg?: string) {
10
+ return (value): true | string => {
11
+ return !!value || msg || $t('inri.validation.required')
12
+ }
13
+ }
14
+
15
+ /**
16
+ * The value must have a minimum length.
17
+ * @param {string | number} length - Min length
18
+ * @param {string} [msg] - Override the default error message
19
+ */
20
+ export function minLength (length: string | number, msg?: string) {
21
+ const parsedLength = typeof length === 'number' ? length : parseInt(length, 10)
22
+ return (value): true | string => {
23
+ if (!value) {
24
+ return true
25
+ }
26
+
27
+ return value.length >= parsedLength || msg || $t('inri.validation.minLength', { parsedLength: parsedLength })
28
+ }
29
+ }
30
+
31
+ /**
32
+ * The value can not exceed maximum length.
33
+ * @param {string | number} length - Max length
34
+ * @param {string} [msg] - Override the default error message
35
+ */
36
+ export function maxLength (length: string | number, msg?: string) {
37
+ const parsedLength = typeof length === 'number' ? length : parseInt(length, 10)
38
+ return (value): true | string => {
39
+ if (!value) {
40
+ return true
41
+ }
42
+
43
+ return value.length <= parsedLength || msg || $t('inri.validation.maxLength', { parsedLength: parsedLength })
44
+ }
45
+ }
46
+
47
+ /**
48
+ * The value must be a valid email.
49
+ * @param {string} [msg] - Override the default error message
50
+ */
51
+ export function email (msg?: string) {
52
+ // eslint-disable-next-line no-useless-escape
53
+ const regExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
54
+ return (value): true | string => {
55
+ if (!value) {
56
+ return true
57
+ }
58
+
59
+ return regExp.test(String(value).toLowerCase()) || msg || $t('inri.validation.email')
60
+ }
61
+ }
62
+
63
+ /**
64
+ * The value must be a valid url.
65
+ * @param {string} [msg] - Override the default error message
66
+ */
67
+ export function url (msg?: string) {
68
+ // eslint-disable-next-line no-useless-escape
69
+ const regExp = /^(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))$/
70
+ return (value): true | string => {
71
+ if (!value) {
72
+ return true
73
+ }
74
+
75
+ return regExp.test(String(value).toLowerCase()) || msg || $t('inri.validation.url')
76
+ }
77
+ }
78
+
79
+ /**
80
+ * The value must be a valid url using https.
81
+ * @param {string} [msg] - Override the default error message
82
+ */
83
+ export function https (msg?: string) {
84
+ // eslint-disable-next-line no-useless-escape
85
+ const regExp = /^(https:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))$/
86
+ return (value): true | string => {
87
+ if (!value) {
88
+ return true
89
+ }
90
+
91
+ return regExp.test(String(value).toLowerCase()) || msg || $t('inri.validation.https')
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Validate file extensions. Supports single and multiple files.
97
+ * @param {string} fileExtensions - A string containing a single file extension, "jpg", or a comma separated string, "jpg,png".
98
+ * @param {string} [msg] - Override the default error message
99
+ */
100
+ export function extension (fileExtensions: string, msg?: string) {
101
+ // Extension string cleanup and convert to array
102
+ const extensions = fileExtensions
103
+ .toLowerCase()
104
+ .replaceAll(' ', '')
105
+ .replaceAll('.', '')
106
+ .split(',')
107
+
108
+ return (value): true | string => {
109
+ if (!value) {
110
+ return true
111
+ }
112
+
113
+ let files: any[] = []
114
+ let isValid = true
115
+
116
+ // If single file then push it into an array for consistency
117
+ if (!value.length) {
118
+ files.push(value)
119
+ } else {
120
+ files = value
121
+ }
122
+
123
+ for (const file of files) {
124
+ const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase()
125
+ if (!extensions.includes(fileExt)) {
126
+ isValid = false
127
+ break
128
+ }
129
+ }
130
+
131
+ return isValid || msg || $t('inri.validation.extension', { extensions: extensions.join(', .') })
132
+ }
133
+ }
134
+
135
+ /**
136
+ * The value must contain all the strings in the array.
137
+ * @param {string[]} arr - Array of strings.
138
+ * @param {boolean} caseSensitive
139
+ * @param {string} [msg] - Override the default error message
140
+ */
141
+ export function contains (arr: string[], caseSensitive = false, msg?: string) {
142
+ return (value): true | string => {
143
+ if (!value) {
144
+ return true
145
+ }
146
+
147
+ let foundItems
148
+
149
+ if (!caseSensitive) {
150
+ foundItems = arr.filter(item => !value.toUpperCase().includes(('' + item).toUpperCase()))
151
+ } else {
152
+ foundItems = arr.filter(item => !value.includes('' + item))
153
+ }
154
+
155
+ if (!foundItems.length) {
156
+ return true
157
+ }
158
+
159
+ return msg || $t('inri.validation.contains', { match: foundItems.join(', ') })
160
+ }
161
+ }
162
+
163
+ /**
164
+ * The value must not contain any of the strings in the array.
165
+ * @param {string[]} arr - Array of strings.
166
+ * @param {boolean} caseSensitive
167
+ * @param {string} [msg] - Override the default error message
168
+ */
169
+ export function notContains (arr: string[], caseSensitive = false, msg?: string) {
170
+ return (value): true | string => {
171
+ if (!value) {
172
+ return true
173
+ }
174
+
175
+ const comparisonValue = value instanceof File ? value.name : value
176
+
177
+ let foundItems
178
+
179
+ if (!caseSensitive) {
180
+ foundItems = arr.filter(item => comparisonValue.toUpperCase().includes(('' + item).toUpperCase()))
181
+ } else {
182
+ foundItems = arr.filter(item => comparisonValue.includes('' + item))
183
+ }
184
+
185
+ if (!foundItems.length) {
186
+ return true
187
+ }
188
+
189
+ return msg || $t('inri.validation.notContains', { match: foundItems.join(', ') })
190
+ }
191
+ }
192
+
193
+ /**
194
+ * The value must not begin with any of the strings in the array.
195
+ * @param {string[]} arr - Array of strings.
196
+ * @param {boolean} caseSensitive
197
+ * @param {string} [msg] - Override the default error message
198
+ */
199
+ export function notBeginsWith (arr: string[], caseSensitive = false, msg?: string) {
200
+ return (value): true | string => {
201
+ if (!value) {
202
+ return true
203
+ }
204
+
205
+ let foundItems
206
+
207
+ if (!caseSensitive) {
208
+ foundItems = arr.filter(item => value.toUpperCase().startsWith(('' + item).toUpperCase()))
209
+ } else {
210
+ foundItems = arr.filter(item => value.startsWith('' + item))
211
+ }
212
+
213
+ if (!foundItems.length) {
214
+ return true
215
+ }
216
+
217
+ return msg || $t('inri.validation.notBeginsWith', { match: foundItems.join(', ') })
218
+ }
219
+ }
220
+
221
+ /**
222
+ * The value must not end with any of the strings in the array.
223
+ * @param {string[]} arr - Array of strings.
224
+ * @param {boolean} caseSensitive
225
+ * @param {string} [msg] - Override the default error message
226
+ */
227
+ export function notEndsWith (arr: string[], caseSensitive = false, msg?: string) {
228
+ return (value): true | string => {
229
+ if (!value) {
230
+ return true
231
+ }
232
+
233
+ let foundItems
234
+
235
+ if (!caseSensitive) {
236
+ foundItems = arr.filter(item => value.toUpperCase().endsWith(('' + item).toUpperCase()))
237
+ } else {
238
+ foundItems = arr.filter(item => value.endsWith('' + item))
239
+ }
240
+
241
+ if (!foundItems.length) {
242
+ return true
243
+ }
244
+
245
+ return msg || $t('inri.validation.notEndsWith', { match: foundItems.join(', ') })
246
+ }
247
+ }
248
+
249
+ /**
250
+ * The file(s) cannot exceed max size
251
+ * @param {string | number} size - Max size in bytes
252
+ * @param {string} [type] - Only validate against files with this MIME type
253
+ * @param {string} [msg] - Override the default error message
254
+ */
255
+ export function maxFileSize (size: string | number, type?: string, msg?: string) {
256
+ const parsedFileSize = typeof size === 'number' ? size : parseInt(size, 10)
257
+
258
+ return (value): true | string => {
259
+ if (!value) {
260
+ return true
261
+ }
262
+
263
+ let files: any[] = []
264
+
265
+ if (!value.length) {
266
+ files.push(value)
267
+ } else {
268
+ files = value
269
+ }
270
+
271
+ if (type) {
272
+ files = files.filter(file => file.type.includes(type))
273
+ }
274
+
275
+ return files.every(file => file.size <= size) || msg || $t('inri.validation.maxFileSize', { parsedFileSize })
276
+ }
277
+ }
278
+
279
+ export const rules = {
280
+ required,
281
+ maxLength,
282
+ minLength,
283
+ email,
284
+ url,
285
+ https,
286
+ extension,
287
+ contains,
288
+ notContains,
289
+ notBeginsWith,
290
+ notEndsWith,
291
+ maxFileSize,
292
+ }
@@ -1,6 +1,6 @@
1
- /* eslint-disable */
2
- declare module '*.vue' {
3
- import type { DefineComponent } from 'vue'
4
- const component: DefineComponent<{}, {}, any>
5
- export default component
6
- }
1
+ /* eslint-disable */
2
+ declare module '*.vue' {
3
+ import type { DefineComponent } from 'vue'
4
+ const component: DefineComponent<{}, {}, any>
5
+ export default component
6
+ }