@inriver/inri 1.0.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 (114) hide show
  1. package/.eslintrc.js +5 -0
  2. package/componentProperties.d.ts +8 -0
  3. package/configs/base-eslint-config.js +36 -0
  4. package/configs/base-tailwind-config.js +149 -0
  5. package/i18n.ts +11 -0
  6. package/index.ts +25 -0
  7. package/package.json +36 -0
  8. package/src/components/CAutoBreadcrumbs.vue +72 -0
  9. package/src/components/CBtn.vue +98 -0
  10. package/src/components/CColorPicker.vue +55 -0
  11. package/src/components/CContextMenu.vue +29 -0
  12. package/src/components/CDatePicker.vue +51 -0
  13. package/src/components/CDeleteTileBtn.vue +52 -0
  14. package/src/components/CDialog.vue +253 -0
  15. package/src/components/CDialogCloseBtn.vue +9 -0
  16. package/src/components/CDirtyCheck.vue +68 -0
  17. package/src/components/CDrawer.vue +44 -0
  18. package/src/components/CDrawerButton.vue +91 -0
  19. package/src/components/CExpansionItem.vue +57 -0
  20. package/src/components/CExpansionItemWithCheckbox.vue +41 -0
  21. package/src/components/CFileDropzone.vue +114 -0
  22. package/src/components/CGrid.vue +101 -0
  23. package/src/components/CHeader.vue +10 -0
  24. package/src/components/CHeaderLinks.vue +61 -0
  25. package/src/components/CHeaderMenuLink.vue +51 -0
  26. package/src/components/CHeaderSearch.vue +142 -0
  27. package/src/components/CIconBtn.vue +70 -0
  28. package/src/components/CMenuItem.vue +66 -0
  29. package/src/components/CPageContainer.vue +11 -0
  30. package/src/components/CPageError.vue +24 -0
  31. package/src/components/CPageSpinner.vue +18 -0
  32. package/src/components/CSearch.vue +45 -0
  33. package/src/components/CSection.vue +29 -0
  34. package/src/components/CSectionTitle.vue +8 -0
  35. package/src/components/CSelect.vue +208 -0
  36. package/src/components/CSlideEffect.vue +62 -0
  37. package/src/components/CSpinner.vue +107 -0
  38. package/src/components/CTableActions.vue +16 -0
  39. package/src/components/CTileBtn.vue +178 -0
  40. package/src/components/CTimePicker.vue +42 -0
  41. package/src/components/CToggleGridView.vue +26 -0
  42. package/src/components/CToggleSidebarBtn.vue +19 -0
  43. package/src/components/CTooltip.vue +44 -0
  44. package/src/components/CTreeNode.vue +39 -0
  45. package/src/components/cards/CBannerCard.vue +103 -0
  46. package/src/components/cards/CSmallCard.vue +149 -0
  47. package/src/components/internal-components/ConfirmDialog.vue +78 -0
  48. package/src/composables/useDialog.ts +47 -0
  49. package/src/composables/useDirtyCheck.ts +25 -0
  50. package/src/composables/useDoubleClickListener.ts +28 -0
  51. package/src/composables/useSelectable.ts +62 -0
  52. package/src/composables/useTruncateChips.ts +46 -0
  53. package/src/i18n/de/index.ts +17 -0
  54. package/src/i18n/en/index.ts +84 -0
  55. package/src/i18n/es/index.ts +7 -0
  56. package/src/i18n/fr/index.ts +7 -0
  57. package/src/init/initInriFramework.ts +25 -0
  58. package/src/init/useInriApp.ts +55 -0
  59. package/src/layouts/CLayoutBlank.vue +7 -0
  60. package/src/layouts/CLayoutWithBackButton.vue +50 -0
  61. package/src/layouts/CLayoutWithSidebars.vue +46 -0
  62. package/src/layouts/layout-fragments/CPageAutoBreadcrumbs.vue +6 -0
  63. package/src/layouts/layout-fragments/CPageBackButton.vue +18 -0
  64. package/src/layouts/layout-fragments/CPageBlank.vue +20 -0
  65. package/src/layouts/layout-fragments/CPageFlexCol.vue +5 -0
  66. package/src/layouts/layout-fragments/CPageLeftSidebar.vue +5 -0
  67. package/src/layouts/layout-fragments/CPageMainContent.vue +5 -0
  68. package/src/layouts/layout-fragments/CPageOuterWrapper.vue +5 -0
  69. package/src/layouts/layout-fragments/CPageRightSidebar.vue +5 -0
  70. package/src/layouts/layout-fragments/CPageTitle.vue +34 -0
  71. package/src/plugins/dialog.ts +45 -0
  72. package/src/plugins/errors/ErrorFactories.ts +59 -0
  73. package/src/plugins/errors/Errors.ts +156 -0
  74. package/src/plugins/errors/Exception.ts +6 -0
  75. package/src/plugins/errors/globalErrorHandler.ts +21 -0
  76. package/src/plugins/errors/handleError.ts +34 -0
  77. package/src/plugins/errors/logger.ts +16 -0
  78. package/src/plugins/errors/vueErrorHandler.ts +26 -0
  79. package/src/plugins/globalAppConfig.ts +25 -0
  80. package/src/plugins/i18n.ts +46 -0
  81. package/src/plugins/inriIcons.ts +58 -0
  82. package/src/plugins/inriverQuasarComponentConfigurations.ts +67 -0
  83. package/src/plugins/library.ts +119 -0
  84. package/src/plugins/notify.ts +153 -0
  85. package/src/plugins/quasar-user-options.ts +19 -0
  86. package/src/plugins/validationRules.ts +292 -0
  87. package/src/shims-vue.d.ts +6 -0
  88. package/src/stores/inriStore.ts +54 -0
  89. package/src/stores/interfaceLanguageStore.ts +27 -0
  90. package/src/styles/_css-variables.scss +101 -0
  91. package/src/styles/_reset.scss +67 -0
  92. package/src/styles/_transitions.scss +9 -0
  93. package/src/styles/_utils.scss +15 -0
  94. package/src/styles/components/_breadcrumbs.scss +3 -0
  95. package/src/styles/components/_checkboxes.scss +17 -0
  96. package/src/styles/components/_chips.scss +17 -0
  97. package/src/styles/components/_forms.scss +203 -0
  98. package/src/styles/components/_menu.scss +12 -0
  99. package/src/styles/components/_notifications.scss +24 -0
  100. package/src/styles/components/_q-editor.scss +14 -0
  101. package/src/styles/components/_radio-buttons.scss +17 -0
  102. package/src/styles/components/_tables.scss +92 -0
  103. package/src/styles/components/_tooltips.scss +5 -0
  104. package/src/styles/components/_tree.scss +86 -0
  105. package/src/styles/components/_truncated-chips.scss +39 -0
  106. package/src/styles/main.scss +45 -0
  107. package/src/styles/quasar.variables.scss +50 -0
  108. package/src/typings.d.ts +70 -0
  109. package/src/utils/colorUtils.ts +73 -0
  110. package/src/utils/errorUtils.ts +37 -0
  111. package/src/utils/fileUtils.ts +57 -0
  112. package/src/utils/helpers.ts +6 -0
  113. package/src/utils/routeUtils.ts +23 -0
  114. package/tsconfig.json +37 -0
@@ -0,0 +1,73 @@
1
+ interface RelatedColors {
2
+ onColor: string,
3
+ onAltColor?: string,
4
+ effectColor: string,
5
+ }
6
+
7
+ export const baseColors = ['primary', 'secondary', 'accent', 'surface']
8
+ export const blackAndWhiteColors = ['black', 'white']
9
+ export const spotColors = ['blue', 'purple', 'red', 'orange', 'yellow', 'green']
10
+ export const lightColors = ['blue-light', 'purple-light', 'red-light', 'orange-light', 'yellow-light', 'green-light']
11
+ export const greyColors = ['grey-darkest', 'grey-darker', 'grey-dark', 'grey', 'grey-light', 'grey-lighter']
12
+
13
+ export const colors = {
14
+ baseColors,
15
+ blackAndWhiteColors,
16
+ spotColors,
17
+ lightColors,
18
+ greyColors,
19
+ }
20
+
21
+ export const getRelatedColors = (color): RelatedColors | null => {
22
+ if (color === 'primary') {
23
+ return {
24
+ onColor: 'on-primary',
25
+ onAltColor: 'on-primary-alt',
26
+ effectColor: 'primary-effect',
27
+ } as RelatedColors
28
+ } else if (color === 'secondary') {
29
+ return {
30
+ onColor: 'on-secondary',
31
+ onAltColor: 'on-secondary-alt',
32
+ effectColor: 'secondary-effect',
33
+ } as RelatedColors
34
+ } else if (color === 'accent') {
35
+ return {
36
+ onColor: 'on-accent',
37
+ onAltColor: 'on-accent-alt',
38
+ effectColor: 'accent-effect',
39
+ } as RelatedColors
40
+ } else if (color === 'surface') {
41
+ return {
42
+ onColor: 'on-surface',
43
+ effectColor: 'surface-effect',
44
+ } as RelatedColors
45
+ } else if (spotColors.includes(color)) {
46
+ return {
47
+ onColor: 'grey-darkest',
48
+ effectColor: `${color}-light`,
49
+ } as RelatedColors
50
+ } else if (color === 'black') {
51
+ return {
52
+ onColor: 'white',
53
+ effectColor: 'grey-darker',
54
+ } as RelatedColors
55
+ } else if (color === 'white') {
56
+ return {
57
+ onColor: 'grey-darkest',
58
+ effectColor: 'grey-lighter',
59
+ } as RelatedColors
60
+ } else if (color === 'grey-lighter') {
61
+ return {
62
+ onColor: 'grey-darkest',
63
+ effectColor: 'grey-light',
64
+ } as RelatedColors
65
+ } else if (color.endsWith('-light')) {
66
+ return {
67
+ onColor: 'grey-darkest',
68
+ effectColor: color.replace('-light', ''),
69
+ } as RelatedColors
70
+ }
71
+
72
+ return null
73
+ }
@@ -0,0 +1,37 @@
1
+ import { i18n } from '../plugins/i18n'
2
+
3
+ /**
4
+ * Try to get an error message returned from the server. It could be a i18n key or just a normal error message.
5
+ * If a namespace is given then try to find the translation here. Fallback to the shared generic errors.
6
+ * @param [error] - Exception
7
+ * @param {string?} [namespace] - optional namespace where you want to find your i18n translation ('folders' will try to get from 'folders.foo_error')
8
+ */
9
+ export const getErrorMessage = (error: any, namespace: string | undefined = undefined) : string => {
10
+ const t = i18n.global.t
11
+ const te = i18n.global.te
12
+
13
+ const errorDescription = error.response?.data?.errorDescription ||
14
+ error.response?.data?.message ||
15
+ error.response?.data ||
16
+ error.request?.statusText ||
17
+ error?.message ||
18
+ error.toString()
19
+
20
+ if (!errorDescription) {
21
+ return t('inri.error.undefined_error')
22
+ }
23
+
24
+ let translatedError
25
+
26
+ // First try to get the translation from the given namespace
27
+ if (namespace) {
28
+ translatedError = te(`${namespace}.${errorDescription}`) ? t(`${namespace}.${errorDescription}`) : undefined
29
+ }
30
+
31
+ // If not found in namespace or namespace is not defined try to get it from the global errors
32
+ if (!translatedError) {
33
+ translatedError = te(`inri.error.${errorDescription}`) ? t(`inri.error.${errorDescription}`) : undefined
34
+ }
35
+
36
+ return translatedError || errorDescription || t('inri.error.undefined_error')
37
+ }
@@ -0,0 +1,57 @@
1
+ export const invalidFileChars = ['#', '%', '&', '{', '}', '\\', '<', '>', '*', '?', '/', '$', '!', "'", '"', ':', '@', '+', '`', '|', '=']
2
+
3
+ export const maxFileLength = 30
4
+
5
+ export const forbiddenFilePrefixAndSuffix = ['.', '-', '_']
6
+
7
+ export const invalidFileExtensions = ['.exe']
8
+
9
+ export function getFileExtension (fileName = '') {
10
+ if (fileName.includes('.')) {
11
+ return fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length)
12
+ }
13
+
14
+ return ''
15
+ }
16
+
17
+ /**
18
+ * Converts bytes to an appropriate size unit, outputted in a readable format
19
+ * @param {number} bytes - Value to be converted and formatted
20
+ * @param {number} [decimals] - Specifies how many decimals the result should contain, defaults to 0 (no decimals)
21
+ * @returns {string} The converted value in a readable format
22
+ */
23
+ export function bytesToReadableSize (bytes: number, decimals = 0) {
24
+ const sizes = ['Bytes', 'KB', 'MB', 'GB']
25
+
26
+ if (bytes === 0) {
27
+ return '0 Bytes'
28
+ }
29
+
30
+ const dm = decimals < 0 ? 0 : decimals
31
+ const i = Math.floor(Math.log(bytes) / Math.log(1024))
32
+
33
+ return (bytes / Math.pow(1024, i)).toFixed(dm) + ' ' + sizes[i]
34
+ }
35
+
36
+ /**
37
+ * Converts a file to a Base64 encoded string
38
+ * @param { File | any } file - File object
39
+ * @returns A promise that returns a Base64 encoded string when resolved
40
+ */
41
+ export function convertFileToBase64 (file) {
42
+ return new Promise<string>((resolve, reject) => {
43
+ const reader = new FileReader()
44
+ reader.onload = () => {
45
+ const result = reader.result as string
46
+ resolve(result.split(',').pop() as string)
47
+ }
48
+ reader.onerror = reject
49
+ reader.readAsDataURL(file)
50
+ })
51
+ }
52
+
53
+ export const textFileExtensionWhitelist = ['txt', 'md', 'xml']
54
+
55
+ export function isTextFile (filename: string) {
56
+ return textFileExtensionWhitelist.includes(getFileExtension(filename).toLowerCase())
57
+ }
@@ -0,0 +1,6 @@
1
+ // Helpful function if you want to generate different size images from eg. faker.js
2
+ export function getRandomInt (min: number, max: number) {
3
+ min = Math.ceil(min)
4
+ max = Math.floor(max)
5
+ return Math.floor(Math.random() * (max - min) + min)
6
+ }
@@ -0,0 +1,23 @@
1
+ import { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteRecordNormalized } from 'vue-router'
2
+
3
+ function isRouteLocation (arg): arg is RouteLocationNormalized | RouteLocationNormalizedLoaded {
4
+ return arg && arg.params
5
+ }
6
+
7
+ export const getRouteTitle = (
8
+ route: RouteLocationNormalized | RouteLocationNormalizedLoaded | RouteRecordNormalized | string,
9
+ to?: RouteLocationNormalized | RouteLocationNormalizedLoaded | RouteRecordNormalized | string,
10
+ ) => {
11
+ let title = typeof route !== 'string' ? route.meta.title as string : route
12
+
13
+ // If "to" is not passed as a parameter then use the current route as "to"
14
+ to = to || route
15
+
16
+ if (isRouteLocation(to)) {
17
+ for (const [key, value] of Object.entries(to.params)) {
18
+ title = title.replace(`:${key}`, value as string)
19
+ }
20
+ }
21
+
22
+ return title
23
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "noImplicitAny": false,
5
+ "target": "esnext",
6
+ "module": "esnext",
7
+ "strict": true,
8
+ "jsx": "preserve",
9
+ "importHelpers": true,
10
+ "moduleResolution": "node",
11
+ "skipLibCheck": true,
12
+ "esModuleInterop": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "sourceMap": true,
15
+ "baseUrl": ".",
16
+ "types": [
17
+ "webpack-env"
18
+ ],
19
+ "lib": [
20
+ "esnext",
21
+ "dom",
22
+ "dom.iterable",
23
+ "scripthost"
24
+ ]
25
+ },
26
+ "include": [
27
+ "src/**/*.ts",
28
+ "src/**/*.tsx",
29
+ "src/**/*.vue",
30
+ "tests/**/*.ts",
31
+ "tests/**/*.tsx",
32
+ "componentProperties.d.ts"
33
+ ],
34
+ "exclude": [
35
+ "node_modules"
36
+ ]
37
+ }