@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.
- package/.babelrc +12 -0
- package/.eslintrc.json +22 -0
- package/README.md +7 -0
- package/index.ts +3 -0
- package/jest.config.js +9 -0
- package/package.json +21 -0
- package/project.json +69 -0
- package/rollup.config.js +135 -0
- package/src/interfaces/common.ts +12 -0
- package/src/interfaces/definition.ts +143 -0
- package/src/interfaces/index.ts +3 -0
- package/src/interfaces/ui.ts +35 -0
- package/src/lib/Alert/Alert.tsx +108 -0
- package/src/lib/Alert/index.ts +1 -0
- package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +74 -0
- package/src/lib/Definition/CreateDefinition/index.ts +1 -0
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +85 -0
- package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.tsx +96 -0
- package/src/lib/Definition/DefinitionFiller/index.ts +2 -0
- package/src/lib/Definition/index.ts +2 -0
- package/src/lib/DemPropertyField/DemPropertyField.tsx +93 -0
- package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.tsx +44 -0
- package/src/lib/DemPropertyField/DemPropertyView/index.ts +1 -0
- package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.tsx +293 -0
- package/src/lib/DemPropertyField/MultipleDemField/index.tsx +1 -0
- package/src/lib/DemPropertyField/RestrictedValuesEditor.tsx +63 -0
- package/src/lib/DemPropertyField/SingleDemField/SingleDemField.tsx +156 -0
- package/src/lib/DemPropertyField/SingleDemField/index.ts +1 -0
- package/src/lib/DemPropertyField/index.ts +2 -0
- package/src/lib/DemPropertyField/styles.ts +50 -0
- package/src/lib/DemPropertyField/widgets/DemBooleanWidget.tsx +26 -0
- package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.tsx +34 -0
- package/src/lib/DemPropertyField/widgets/DemDateWidget.tsx +33 -0
- package/src/lib/DemPropertyField/widgets/DemFieldWidget.tsx +67 -0
- package/src/lib/DemPropertyField/widgets/DemFloatWidget.tsx +49 -0
- package/src/lib/DemPropertyField/widgets/DemIntegerWidget.tsx +63 -0
- package/src/lib/DemPropertyField/widgets/DemJsonWidget.tsx +33 -0
- package/src/lib/DemPropertyField/widgets/DemStringWidget.tsx +35 -0
- package/src/lib/DemPropertyField/widgets/DemTimeWidget.tsx +46 -0
- package/src/lib/DemPropertyField/widgets/index.ts +1 -0
- package/src/lib/Forms/BackButton.tsx +45 -0
- package/src/lib/Forms/ControlAceEditor.tsx +103 -0
- package/src/lib/Forms/ControlAutocomplete.tsx +134 -0
- package/src/lib/Forms/ControlCheckbox.tsx +57 -0
- package/src/lib/Forms/ControlDebouncedInput.tsx +69 -0
- package/src/lib/Forms/ControlInput.tsx +102 -0
- package/src/lib/Forms/ControlNumberInput.tsx +144 -0
- package/src/lib/Forms/ControlRadioBtn.tsx +46 -0
- package/src/lib/Forms/ControlSelect.tsx +135 -0
- package/src/lib/Forms/CopyButton.tsx +49 -0
- package/src/lib/Forms/index.ts +10 -0
- package/src/lib/InfoItem/InfoItem.tsx +39 -0
- package/src/lib/InfoItem/index.ts +1 -0
- package/src/lib/InfoItem/styles.ts +17 -0
- package/src/lib/JsonPathPicker/JsonPathPicker.tsx +71 -0
- package/src/lib/JsonPathPicker/PropertyStep.tsx +74 -0
- package/src/lib/JsonPathPicker/index.ts +1 -0
- package/src/lib/JsonView/JsonView.tsx +43 -0
- package/src/lib/JsonView/index.ts +1 -0
- package/src/lib/Loader/Loader.tsx +41 -0
- package/src/lib/Loader/index.ts +1 -0
- package/src/lib/Modals/JsonModalView.tsx +52 -0
- package/src/lib/Modals/index.ts +1 -0
- package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +41 -0
- package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +59 -0
- package/src/lib/Property/PropertyValueField/DateValueField.tsx +59 -0
- package/src/lib/Property/PropertyValueField/EntityValueField.tsx +33 -0
- package/src/lib/Property/PropertyValueField/JsonValueField.tsx +64 -0
- package/src/lib/Property/PropertyValueField/PropertyValue.tsx +97 -0
- package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +86 -0
- package/src/lib/Property/PropertyValueField/StringValueField.tsx +21 -0
- package/src/lib/Property/PropertyValueField/TimeValueField.tsx +68 -0
- package/src/lib/Property/PropertyValueField/ValueComponent.tsx +63 -0
- package/src/lib/Property/PropertyValueField/index.ts +1 -0
- package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +167 -0
- package/src/lib/Property/PropertyWidget/index.ts +1 -0
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +131 -0
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +147 -0
- package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +40 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +41 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +27 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +133 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +46 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +52 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +98 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/index.ts +1 -0
- package/src/lib/Property/UpsertProperty/index.ts +2 -0
- package/src/lib/Property/UpsertProperty/useCustomFields.ts +22 -0
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +50 -0
- package/src/lib/Property/ViewPropertiesList/index.ts +1 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +41 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +48 -0
- package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +139 -0
- package/src/lib/Property/ViewProperty/PropertyItem.tsx +46 -0
- package/src/lib/Property/ViewProperty/ViewProperty.tsx +52 -0
- package/src/lib/Property/ViewProperty/index.ts +1 -0
- package/src/lib/Property/index.ts +4 -0
- package/src/lib/Status/Status.tsx +15 -0
- package/src/lib/Status/index.ts +1 -0
- package/src/lib/Status/styles.ts +14 -0
- package/src/lib/Table/Table.tsx +116 -0
- package/src/lib/Table/TableColumnMenu.tsx +12 -0
- package/src/lib/Table/TablePagination.tsx +42 -0
- package/src/lib/Table/index.ts +1 -0
- package/src/lib/Table/styles.ts +59 -0
- package/src/lib/Table/usePagination.ts +15 -0
- package/src/lib/Table/useTableQueryPagination.ts +49 -0
- package/src/lib/Table/useTableQuerySorting.ts +52 -0
- package/src/lib/Tabs/RouteTabs.tsx +54 -0
- package/src/lib/Tabs/TabPanel.tsx +42 -0
- package/src/lib/Tabs/index.ts +2 -0
- package/src/lib/TemplateContent/ExpressionDecorator.tsx +7 -0
- package/src/lib/TemplateContent/TemplateContentEditor.tsx +144 -0
- package/src/lib/TemplateContent/index.ts +1 -0
- package/src/lib/index.ts +14 -0
- package/src/utils/common.ts +68 -0
- package/src/utils/dem.ts +78 -0
- package/src/utils/hooks.ts +41 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/ui-utils.tsx +71 -0
- package/src/utils/validators.ts +130 -0
- package/tsconfig.json +24 -0
- package/tsconfig.lib.json +22 -0
- 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
|
+
}
|