@dartech/arsenal-ui 0.0.1

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 (124) hide show
  1. package/.babelrc +12 -0
  2. package/.eslintrc.json +22 -0
  3. package/README.md +7 -0
  4. package/index.ts +3 -0
  5. package/jest.config.js +9 -0
  6. package/package.json +21 -0
  7. package/project.json +69 -0
  8. package/rollup.config.js +135 -0
  9. package/src/interfaces/common.ts +12 -0
  10. package/src/interfaces/definition.ts +143 -0
  11. package/src/interfaces/index.ts +3 -0
  12. package/src/interfaces/ui.ts +35 -0
  13. package/src/lib/Alert/Alert.tsx +108 -0
  14. package/src/lib/Alert/index.ts +1 -0
  15. package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +74 -0
  16. package/src/lib/Definition/CreateDefinition/index.ts +1 -0
  17. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +85 -0
  18. package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.tsx +96 -0
  19. package/src/lib/Definition/DefinitionFiller/index.ts +2 -0
  20. package/src/lib/Definition/index.ts +2 -0
  21. package/src/lib/DemPropertyField/DemPropertyField.tsx +93 -0
  22. package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.tsx +44 -0
  23. package/src/lib/DemPropertyField/DemPropertyView/index.ts +1 -0
  24. package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.tsx +293 -0
  25. package/src/lib/DemPropertyField/MultipleDemField/index.tsx +1 -0
  26. package/src/lib/DemPropertyField/RestrictedValuesEditor.tsx +63 -0
  27. package/src/lib/DemPropertyField/SingleDemField/SingleDemField.tsx +156 -0
  28. package/src/lib/DemPropertyField/SingleDemField/index.ts +1 -0
  29. package/src/lib/DemPropertyField/index.ts +2 -0
  30. package/src/lib/DemPropertyField/styles.ts +50 -0
  31. package/src/lib/DemPropertyField/widgets/DemBooleanWidget.tsx +26 -0
  32. package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.tsx +34 -0
  33. package/src/lib/DemPropertyField/widgets/DemDateWidget.tsx +33 -0
  34. package/src/lib/DemPropertyField/widgets/DemFieldWidget.tsx +67 -0
  35. package/src/lib/DemPropertyField/widgets/DemFloatWidget.tsx +49 -0
  36. package/src/lib/DemPropertyField/widgets/DemIntegerWidget.tsx +63 -0
  37. package/src/lib/DemPropertyField/widgets/DemJsonWidget.tsx +33 -0
  38. package/src/lib/DemPropertyField/widgets/DemStringWidget.tsx +35 -0
  39. package/src/lib/DemPropertyField/widgets/DemTimeWidget.tsx +46 -0
  40. package/src/lib/DemPropertyField/widgets/index.ts +1 -0
  41. package/src/lib/Forms/BackButton.tsx +45 -0
  42. package/src/lib/Forms/ControlAceEditor.tsx +103 -0
  43. package/src/lib/Forms/ControlAutocomplete.tsx +134 -0
  44. package/src/lib/Forms/ControlCheckbox.tsx +57 -0
  45. package/src/lib/Forms/ControlDebouncedInput.tsx +69 -0
  46. package/src/lib/Forms/ControlInput.tsx +102 -0
  47. package/src/lib/Forms/ControlNumberInput.tsx +144 -0
  48. package/src/lib/Forms/ControlRadioBtn.tsx +46 -0
  49. package/src/lib/Forms/ControlSelect.tsx +135 -0
  50. package/src/lib/Forms/CopyButton.tsx +49 -0
  51. package/src/lib/Forms/index.ts +10 -0
  52. package/src/lib/InfoItem/InfoItem.tsx +39 -0
  53. package/src/lib/InfoItem/index.ts +1 -0
  54. package/src/lib/InfoItem/styles.ts +17 -0
  55. package/src/lib/JsonPathPicker/JsonPathPicker.tsx +71 -0
  56. package/src/lib/JsonPathPicker/PropertyStep.tsx +74 -0
  57. package/src/lib/JsonPathPicker/index.ts +1 -0
  58. package/src/lib/JsonView/JsonView.tsx +43 -0
  59. package/src/lib/JsonView/index.ts +1 -0
  60. package/src/lib/Loader/Loader.tsx +41 -0
  61. package/src/lib/Loader/index.ts +1 -0
  62. package/src/lib/Modals/JsonModalView.tsx +52 -0
  63. package/src/lib/Modals/index.ts +1 -0
  64. package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +41 -0
  65. package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +59 -0
  66. package/src/lib/Property/PropertyValueField/DateValueField.tsx +59 -0
  67. package/src/lib/Property/PropertyValueField/EntityValueField.tsx +33 -0
  68. package/src/lib/Property/PropertyValueField/JsonValueField.tsx +64 -0
  69. package/src/lib/Property/PropertyValueField/PropertyValue.tsx +97 -0
  70. package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +86 -0
  71. package/src/lib/Property/PropertyValueField/StringValueField.tsx +21 -0
  72. package/src/lib/Property/PropertyValueField/TimeValueField.tsx +68 -0
  73. package/src/lib/Property/PropertyValueField/ValueComponent.tsx +63 -0
  74. package/src/lib/Property/PropertyValueField/index.ts +1 -0
  75. package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +167 -0
  76. package/src/lib/Property/PropertyWidget/index.ts +1 -0
  77. package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +131 -0
  78. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +147 -0
  79. package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +40 -0
  80. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +41 -0
  81. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +27 -0
  82. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +133 -0
  83. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +46 -0
  84. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +52 -0
  85. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +98 -0
  86. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/index.ts +1 -0
  87. package/src/lib/Property/UpsertProperty/index.ts +2 -0
  88. package/src/lib/Property/UpsertProperty/useCustomFields.ts +22 -0
  89. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +50 -0
  90. package/src/lib/Property/ViewPropertiesList/index.ts +1 -0
  91. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +41 -0
  92. package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +48 -0
  93. package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +139 -0
  94. package/src/lib/Property/ViewProperty/PropertyItem.tsx +46 -0
  95. package/src/lib/Property/ViewProperty/ViewProperty.tsx +52 -0
  96. package/src/lib/Property/ViewProperty/index.ts +1 -0
  97. package/src/lib/Property/index.ts +4 -0
  98. package/src/lib/Status/Status.tsx +15 -0
  99. package/src/lib/Status/index.ts +1 -0
  100. package/src/lib/Status/styles.ts +14 -0
  101. package/src/lib/Table/Table.tsx +116 -0
  102. package/src/lib/Table/TableColumnMenu.tsx +12 -0
  103. package/src/lib/Table/TablePagination.tsx +42 -0
  104. package/src/lib/Table/index.ts +1 -0
  105. package/src/lib/Table/styles.ts +59 -0
  106. package/src/lib/Table/usePagination.ts +15 -0
  107. package/src/lib/Table/useTableQueryPagination.ts +49 -0
  108. package/src/lib/Table/useTableQuerySorting.ts +52 -0
  109. package/src/lib/Tabs/RouteTabs.tsx +54 -0
  110. package/src/lib/Tabs/TabPanel.tsx +42 -0
  111. package/src/lib/Tabs/index.ts +2 -0
  112. package/src/lib/TemplateContent/ExpressionDecorator.tsx +7 -0
  113. package/src/lib/TemplateContent/TemplateContentEditor.tsx +144 -0
  114. package/src/lib/TemplateContent/index.ts +1 -0
  115. package/src/lib/index.ts +14 -0
  116. package/src/utils/common.ts +68 -0
  117. package/src/utils/dem.ts +78 -0
  118. package/src/utils/hooks.ts +41 -0
  119. package/src/utils/index.ts +5 -0
  120. package/src/utils/ui-utils.tsx +71 -0
  121. package/src/utils/validators.ts +130 -0
  122. package/tsconfig.json +24 -0
  123. package/tsconfig.lib.json +22 -0
  124. package/tsconfig.spec.json +19 -0
@@ -0,0 +1,71 @@
1
+ import Box from '@material-ui/core/Box';
2
+ import CheckCircleIcon from '@material-ui/icons/CheckCircle';
3
+ import NotInterestedIcon from '@material-ui/icons/NotInterested';
4
+ import { JsonView, CopyButton, Status } from '../lib';
5
+ import { format } from 'date-fns';
6
+ import { getJsonStringValue } from './common';
7
+ import { TableDataType } from '../interfaces';
8
+
9
+ export const formatTableRowValue = ({
10
+ value,
11
+ type,
12
+ copyText,
13
+ }: {
14
+ value: unknown;
15
+ type?: TableDataType;
16
+ copyText?: string;
17
+ }) => {
18
+ switch (type) {
19
+ case 'JSON_copy':
20
+ return (
21
+ <Box width="100%">
22
+ <Box display="flex" alignItems="center" justifyContent="flex-end" pt={1} mb={2}>
23
+ <CopyButton copyText={getJsonStringValue(value)} />
24
+ </Box>
25
+ <JsonView value={value} />
26
+ </Box>
27
+ );
28
+ case 'JSON':
29
+ return <JsonView value={value} />;
30
+ case 'JSON_text':
31
+ return (
32
+ <Box width="100%">
33
+ <Box overflow="hidden" whiteSpace="nowrap">
34
+ {typeof value === 'object' ? JSON.stringify(value) : value}
35
+ </Box>
36
+ </Box>
37
+ );
38
+ case 'copy':
39
+ return (
40
+ <Box display="flex" alignItems="center" width="100%">
41
+ <Box mr="auto">{value}</Box>
42
+ <CopyButton copyText={(copyText ? copyText : value) as string} />
43
+ </Box>
44
+ );
45
+ case 'boolean':
46
+ return value ? <CheckCircleIcon color="primary" fontSize="small" /> : <NotInterestedIcon fontSize="small" />;
47
+ case 'date':
48
+ return value ? (
49
+ <div>
50
+ <div>{format(new Date(value as string), 'dd.MM.yyyy')}</div>
51
+ <div>{format(new Date(value as string), 'HH:mm:ss')}</div>
52
+ </div>
53
+ ) : (
54
+ ''
55
+ );
56
+ case 'status':
57
+ return (
58
+ <Status text={value as string} status={value === 'DEPLOYED' || value === 'ACTIVE' ? 'success' : 'default'} />
59
+ );
60
+ case 'array':
61
+ return (
62
+ <Box>
63
+ {(value as string[]).map((val, index) => (
64
+ <Box key={index}>{val}</Box>
65
+ ))}
66
+ </Box>
67
+ );
68
+ default:
69
+ return <div>{value}</div>;
70
+ }
71
+ };
@@ -0,0 +1,130 @@
1
+ import { PropertyType } from '../interfaces';
2
+
3
+ export const digitsOnly = new RegExp('^[0-9]+$');
4
+ export const floatsOnly = new RegExp(/^(?!0\d)\d*(\.(\d+)?)?$/);
5
+ // const numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
6
+
7
+ type ValidationResult = {
8
+ valid: boolean;
9
+ message?: string;
10
+ continuable?: boolean;
11
+ displayOnChange?: boolean;
12
+ };
13
+
14
+ const MAX_SAFE_LONG = BigInt('9223372036854775807');
15
+ const MIN_SAFE_LONG = BigInt('-9223372036854775808');
16
+
17
+ const MAX_SAFE_INTEGER = 2147483647;
18
+ const MIN_SAFE_INTEGER = -2147483648;
19
+
20
+ export function validateInteger(value: string, type: PropertyType): ValidationResult {
21
+ let transformValue = value + '';
22
+
23
+ const rangeValidatingValue = transformValue;
24
+
25
+ if (transformValue && transformValue.startsWith('-')) {
26
+ transformValue = value.substring(1);
27
+ }
28
+
29
+ if (value === '-') {
30
+ return {
31
+ valid: false,
32
+ message: 'Value cannot be -',
33
+ continuable: true,
34
+ };
35
+ }
36
+
37
+ if (!transformValue || !value) {
38
+ return {
39
+ valid: false,
40
+ message: 'Please, fill this field',
41
+ continuable: true,
42
+ displayOnChange: true,
43
+ };
44
+ }
45
+
46
+ if (!digitsOnly.test(transformValue)) {
47
+ return {
48
+ valid: false,
49
+ };
50
+ }
51
+
52
+ if (
53
+ type === PropertyType.LONG &&
54
+ (BigInt(rangeValidatingValue) > MAX_SAFE_LONG || BigInt(rangeValidatingValue) < MIN_SAFE_LONG)
55
+ ) {
56
+ return {
57
+ valid: false,
58
+ message: 'Out of Long value range',
59
+ continuable: true,
60
+ displayOnChange: true,
61
+ };
62
+ }
63
+
64
+ if (
65
+ type === PropertyType.INTEGER &&
66
+ (Number(rangeValidatingValue) > MAX_SAFE_INTEGER || Number(rangeValidatingValue) < MIN_SAFE_INTEGER)
67
+ ) {
68
+ return {
69
+ valid: false,
70
+ message: 'Out of Integer value range',
71
+ continuable: true,
72
+ displayOnChange: true,
73
+ };
74
+ }
75
+
76
+ return {
77
+ valid: true,
78
+ };
79
+ }
80
+
81
+ export function validateFloat(value: string): ValidationResult {
82
+ let transformValue = value + '';
83
+
84
+ if (transformValue && transformValue.startsWith('-')) {
85
+ transformValue = value.substring(1);
86
+ }
87
+
88
+ if (!floatsOnly.test(transformValue)) {
89
+ return {
90
+ valid: false,
91
+ };
92
+ }
93
+
94
+ if (value === '-') {
95
+ return {
96
+ valid: false,
97
+ message: 'Value cannot be -',
98
+ continuable: true,
99
+ };
100
+ }
101
+
102
+ if (transformValue === '.') {
103
+ return {
104
+ valid: false,
105
+ message: 'Value cannot be start with .',
106
+ continuable: false,
107
+ };
108
+ }
109
+
110
+ if (value.charAt(value.length - 1) === '.') {
111
+ return {
112
+ valid: false,
113
+ message: 'Value cannot end with .',
114
+ continuable: true,
115
+ };
116
+ }
117
+
118
+ if (!transformValue || !value) {
119
+ return {
120
+ valid: false,
121
+ message: 'Please, fill this field',
122
+ continuable: true,
123
+ displayOnChange: true,
124
+ };
125
+ }
126
+
127
+ return {
128
+ valid: true,
129
+ };
130
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "allowJs": true,
6
+ "esModuleInterop": true,
7
+ "allowSyntheticDefaultImports": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "noImplicitOverride": true,
10
+ "noPropertyAccessFromIndexSignature": true,
11
+ "noImplicitReturns": true,
12
+ "noFallthroughCasesInSwitch": true
13
+ },
14
+ "files": [],
15
+ "include": [],
16
+ "references": [
17
+ {
18
+ "path": "./tsconfig.lib.json"
19
+ },
20
+ {
21
+ "path": "./tsconfig.spec.json"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "types": ["node"]
6
+ },
7
+ "files": [
8
+ "../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
9
+ "../../node_modules/@nrwl/react/typings/image.d.ts"
10
+ ],
11
+ "exclude": [
12
+ "**/*.spec.ts",
13
+ "**/*.test.ts",
14
+ "**/*.spec.tsx",
15
+ "**/*.test.tsx",
16
+ "**/*.spec.js",
17
+ "**/*.test.js",
18
+ "**/*.spec.jsx",
19
+ "**/*.test.jsx"
20
+ ],
21
+ "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
22
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"]
7
+ },
8
+ "include": [
9
+ "**/*.test.ts",
10
+ "**/*.spec.ts",
11
+ "**/*.test.tsx",
12
+ "**/*.spec.tsx",
13
+ "**/*.test.js",
14
+ "**/*.spec.js",
15
+ "**/*.test.jsx",
16
+ "**/*.spec.jsx",
17
+ "**/*.d.ts"
18
+ ]
19
+ }