@dartech/arsenal-ui 0.0.1 → 0.0.3

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 (214) hide show
  1. package/{index.ts → index.d.ts} +3 -3
  2. package/index.esm.js +1 -0
  3. package/index.umd.js +1 -0
  4. package/package.json +5 -2
  5. package/src/interfaces/common.d.ts +10 -0
  6. package/src/interfaces/definition.d.ts +117 -0
  7. package/src/interfaces/{index.ts → index.d.ts} +3 -3
  8. package/src/interfaces/ui.d.ts +33 -0
  9. package/src/lib/Alert/Alert.d.ts +53 -0
  10. package/src/lib/Alert/index.d.ts +1 -0
  11. package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +11 -0
  12. package/src/lib/Definition/CreateDefinition/{index.ts → index.d.ts} +1 -1
  13. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +8 -0
  14. package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.d.ts +9 -0
  15. package/src/lib/Definition/DefinitionFiller/{index.ts → index.d.ts} +2 -2
  16. package/src/lib/Definition/{index.ts → index.d.ts} +2 -2
  17. package/src/lib/DemPropertyField/DemPropertyField.d.ts +59 -0
  18. package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.d.ts +8 -0
  19. package/src/lib/DemPropertyField/DemPropertyView/{index.ts → index.d.ts} +1 -1
  20. package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.d.ts +9 -0
  21. package/src/lib/DemPropertyField/MultipleDemField/{index.tsx → index.d.ts} +1 -1
  22. package/src/lib/DemPropertyField/RestrictedValuesEditor.d.ts +6 -0
  23. package/src/lib/DemPropertyField/SingleDemField/SingleDemField.d.ts +9 -0
  24. package/src/lib/DemPropertyField/SingleDemField/{index.ts → index.d.ts} +1 -1
  25. package/src/lib/DemPropertyField/{index.ts → index.d.ts} +2 -2
  26. package/src/lib/DemPropertyField/styles.d.ts +2 -0
  27. package/src/lib/DemPropertyField/widgets/DemBooleanWidget.d.ts +7 -0
  28. package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.d.ts +9 -0
  29. package/src/lib/DemPropertyField/widgets/DemDateWidget.d.ts +9 -0
  30. package/src/lib/DemPropertyField/widgets/DemFieldWidget.d.ts +11 -0
  31. package/src/lib/DemPropertyField/widgets/DemFloatWidget.d.ts +10 -0
  32. package/src/lib/DemPropertyField/widgets/DemIntegerWidget.d.ts +10 -0
  33. package/src/lib/DemPropertyField/widgets/DemJsonWidget.d.ts +9 -0
  34. package/src/lib/DemPropertyField/widgets/DemStringWidget.d.ts +10 -0
  35. package/src/lib/DemPropertyField/widgets/DemTimeWidget.d.ts +9 -0
  36. package/src/lib/DemPropertyField/widgets/{index.ts → index.d.ts} +1 -1
  37. package/src/lib/Forms/BackButton.d.ts +7 -0
  38. package/src/lib/Forms/ControlAceEditor.d.ts +20 -0
  39. package/src/lib/Forms/ControlAutocomplete.d.ts +49 -0
  40. package/src/lib/Forms/ControlCheckbox.d.ts +30 -0
  41. package/src/lib/Forms/ControlDebouncedInput.d.ts +4 -0
  42. package/src/lib/Forms/ControlInput.d.ts +54 -0
  43. package/src/lib/Forms/ControlNumberInput.d.ts +43 -0
  44. package/src/lib/Forms/ControlQueryAutocomplete.d.ts +7 -0
  45. package/src/lib/Forms/ControlRadioBtn.d.ts +26 -0
  46. package/src/lib/Forms/ControlSelect.d.ts +66 -0
  47. package/src/lib/Forms/CopyButton.d.ts +21 -0
  48. package/src/lib/Forms/{index.ts → index.d.ts} +11 -10
  49. package/src/lib/InfoItem/InfoItem.d.ts +10 -0
  50. package/src/lib/InfoItem/{index.ts → index.d.ts} +1 -1
  51. package/src/lib/InfoItem/styles.d.ts +2 -0
  52. package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +10 -0
  53. package/src/lib/JsonPathPicker/PropertyStep.d.ts +11 -0
  54. package/src/lib/JsonPathPicker/{index.ts → index.d.ts} +1 -1
  55. package/src/lib/JsonView/JsonView.d.ts +9 -0
  56. package/src/lib/JsonView/{index.ts → index.d.ts} +1 -1
  57. package/src/lib/Loader/Loader.d.ts +21 -0
  58. package/src/lib/Loader/{index.ts → index.d.ts} +1 -1
  59. package/src/lib/Modals/JsonModalView.d.ts +10 -0
  60. package/src/lib/Modals/{index.ts → index.d.ts} +1 -1
  61. package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +7 -0
  62. package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +9 -0
  63. package/src/lib/Property/PropertyValueField/DateValueField.d.ts +9 -0
  64. package/src/lib/Property/PropertyValueField/EntityValueField.d.ts +9 -0
  65. package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +10 -0
  66. package/src/lib/Property/PropertyValueField/PropertyValue.d.ts +10 -0
  67. package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +9 -0
  68. package/src/lib/Property/PropertyValueField/StringValueField.d.ts +9 -0
  69. package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +9 -0
  70. package/src/lib/Property/PropertyValueField/ValueComponent.d.ts +15 -0
  71. package/src/lib/Property/PropertyValueField/{index.ts → index.d.ts} +2 -1
  72. package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +9 -0
  73. package/src/lib/Property/PropertyWidget/{index.ts → index.d.ts} +1 -1
  74. package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +13 -0
  75. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +10 -0
  76. package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +7 -0
  77. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +6 -0
  78. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +7 -0
  79. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +8 -0
  80. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +6 -0
  81. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +10 -0
  82. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +6 -0
  83. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.ts → index.d.ts} +1 -1
  84. package/src/lib/Property/UpsertProperty/{index.ts → index.d.ts} +2 -2
  85. package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +6 -0
  86. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +8 -0
  87. package/src/lib/Property/ViewPropertiesList/{index.ts → index.d.ts} +1 -1
  88. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +9 -0
  89. package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +8 -0
  90. package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +7 -0
  91. package/src/lib/Property/ViewProperty/PropertyItem.d.ts +9 -0
  92. package/src/lib/Property/ViewProperty/ViewProperty.d.ts +9 -0
  93. package/src/lib/Property/ViewProperty/{index.ts → index.d.ts} +1 -1
  94. package/src/lib/Property/{index.ts → index.d.ts} +4 -4
  95. package/src/lib/Status/Status.d.ts +7 -0
  96. package/src/lib/Status/{index.ts → index.d.ts} +1 -1
  97. package/src/lib/Status/styles.d.ts +2 -0
  98. package/src/lib/StepperView/StepperView.d.ts +10 -0
  99. package/src/lib/StepperView/index.d.ts +1 -0
  100. package/src/lib/Table/Table.d.ts +49 -0
  101. package/src/lib/Table/TableColumnMenu.d.ts +3 -0
  102. package/src/lib/Table/TablePagination.d.ts +3 -0
  103. package/src/lib/Table/index.d.ts +1 -0
  104. package/src/lib/Table/styles.d.ts +2 -0
  105. package/src/lib/Table/usePagination.d.ts +5 -0
  106. package/src/lib/Table/useTableQueryPagination.d.ts +11 -0
  107. package/src/lib/Table/useTableQuerySorting.d.ts +6 -0
  108. package/src/lib/Tabs/RouteTabs.d.ts +11 -0
  109. package/src/lib/Tabs/TabPanel.d.ts +25 -0
  110. package/src/lib/Tabs/{index.ts → index.d.ts} +2 -2
  111. package/src/lib/TemplateContent/ExpressionDecorator.d.ts +5 -0
  112. package/src/lib/TemplateContent/TemplateContentEditor.d.ts +9 -0
  113. package/src/lib/TemplateContent/{index.ts → index.d.ts} +1 -1
  114. package/src/lib/{index.ts → index.d.ts} +15 -14
  115. package/src/utils/common.d.ts +7 -0
  116. package/src/utils/dem.d.ts +7 -0
  117. package/src/utils/hooks.d.ts +7 -0
  118. package/src/utils/{index.ts → index.d.ts} +5 -5
  119. package/src/utils/ui-utils.d.ts +7 -0
  120. package/src/utils/validators.d.ts +12 -0
  121. package/.babelrc +0 -12
  122. package/.eslintrc.json +0 -22
  123. package/jest.config.js +0 -9
  124. package/project.json +0 -69
  125. package/rollup.config.js +0 -135
  126. package/src/interfaces/common.ts +0 -12
  127. package/src/interfaces/definition.ts +0 -143
  128. package/src/interfaces/ui.ts +0 -35
  129. package/src/lib/Alert/Alert.tsx +0 -108
  130. package/src/lib/Alert/index.ts +0 -1
  131. package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +0 -74
  132. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +0 -85
  133. package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.tsx +0 -96
  134. package/src/lib/DemPropertyField/DemPropertyField.tsx +0 -93
  135. package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.tsx +0 -44
  136. package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.tsx +0 -293
  137. package/src/lib/DemPropertyField/RestrictedValuesEditor.tsx +0 -63
  138. package/src/lib/DemPropertyField/SingleDemField/SingleDemField.tsx +0 -156
  139. package/src/lib/DemPropertyField/styles.ts +0 -50
  140. package/src/lib/DemPropertyField/widgets/DemBooleanWidget.tsx +0 -26
  141. package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.tsx +0 -34
  142. package/src/lib/DemPropertyField/widgets/DemDateWidget.tsx +0 -33
  143. package/src/lib/DemPropertyField/widgets/DemFieldWidget.tsx +0 -67
  144. package/src/lib/DemPropertyField/widgets/DemFloatWidget.tsx +0 -49
  145. package/src/lib/DemPropertyField/widgets/DemIntegerWidget.tsx +0 -63
  146. package/src/lib/DemPropertyField/widgets/DemJsonWidget.tsx +0 -33
  147. package/src/lib/DemPropertyField/widgets/DemStringWidget.tsx +0 -35
  148. package/src/lib/DemPropertyField/widgets/DemTimeWidget.tsx +0 -46
  149. package/src/lib/Forms/BackButton.tsx +0 -45
  150. package/src/lib/Forms/ControlAceEditor.tsx +0 -103
  151. package/src/lib/Forms/ControlAutocomplete.tsx +0 -134
  152. package/src/lib/Forms/ControlCheckbox.tsx +0 -57
  153. package/src/lib/Forms/ControlDebouncedInput.tsx +0 -69
  154. package/src/lib/Forms/ControlInput.tsx +0 -102
  155. package/src/lib/Forms/ControlNumberInput.tsx +0 -144
  156. package/src/lib/Forms/ControlRadioBtn.tsx +0 -46
  157. package/src/lib/Forms/ControlSelect.tsx +0 -135
  158. package/src/lib/Forms/CopyButton.tsx +0 -49
  159. package/src/lib/InfoItem/InfoItem.tsx +0 -39
  160. package/src/lib/InfoItem/styles.ts +0 -17
  161. package/src/lib/JsonPathPicker/JsonPathPicker.tsx +0 -71
  162. package/src/lib/JsonPathPicker/PropertyStep.tsx +0 -74
  163. package/src/lib/JsonView/JsonView.tsx +0 -43
  164. package/src/lib/Loader/Loader.tsx +0 -41
  165. package/src/lib/Modals/JsonModalView.tsx +0 -52
  166. package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +0 -41
  167. package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +0 -59
  168. package/src/lib/Property/PropertyValueField/DateValueField.tsx +0 -59
  169. package/src/lib/Property/PropertyValueField/EntityValueField.tsx +0 -33
  170. package/src/lib/Property/PropertyValueField/JsonValueField.tsx +0 -64
  171. package/src/lib/Property/PropertyValueField/PropertyValue.tsx +0 -97
  172. package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +0 -86
  173. package/src/lib/Property/PropertyValueField/StringValueField.tsx +0 -21
  174. package/src/lib/Property/PropertyValueField/TimeValueField.tsx +0 -68
  175. package/src/lib/Property/PropertyValueField/ValueComponent.tsx +0 -63
  176. package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +0 -167
  177. package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +0 -131
  178. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +0 -147
  179. package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +0 -40
  180. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +0 -41
  181. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +0 -27
  182. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +0 -133
  183. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +0 -46
  184. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +0 -52
  185. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +0 -98
  186. package/src/lib/Property/UpsertProperty/useCustomFields.ts +0 -22
  187. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +0 -50
  188. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +0 -41
  189. package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +0 -48
  190. package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +0 -139
  191. package/src/lib/Property/ViewProperty/PropertyItem.tsx +0 -46
  192. package/src/lib/Property/ViewProperty/ViewProperty.tsx +0 -52
  193. package/src/lib/Status/Status.tsx +0 -15
  194. package/src/lib/Status/styles.ts +0 -14
  195. package/src/lib/Table/Table.tsx +0 -116
  196. package/src/lib/Table/TableColumnMenu.tsx +0 -12
  197. package/src/lib/Table/TablePagination.tsx +0 -42
  198. package/src/lib/Table/index.ts +0 -1
  199. package/src/lib/Table/styles.ts +0 -59
  200. package/src/lib/Table/usePagination.ts +0 -15
  201. package/src/lib/Table/useTableQueryPagination.ts +0 -49
  202. package/src/lib/Table/useTableQuerySorting.ts +0 -52
  203. package/src/lib/Tabs/RouteTabs.tsx +0 -54
  204. package/src/lib/Tabs/TabPanel.tsx +0 -42
  205. package/src/lib/TemplateContent/ExpressionDecorator.tsx +0 -7
  206. package/src/lib/TemplateContent/TemplateContentEditor.tsx +0 -144
  207. package/src/utils/common.ts +0 -68
  208. package/src/utils/dem.ts +0 -78
  209. package/src/utils/hooks.ts +0 -41
  210. package/src/utils/ui-utils.tsx +0 -71
  211. package/src/utils/validators.ts +0 -130
  212. package/tsconfig.json +0 -24
  213. package/tsconfig.lib.json +0 -22
  214. package/tsconfig.spec.json +0 -19
@@ -1,68 +0,0 @@
1
- export const removeArrayItem = (arr: Array<unknown>, index: number) => {
2
- const newArr = [...arr];
3
- newArr.splice(index, 1);
4
- return newArr;
5
- };
6
-
7
- export const validateJson = (value: string): boolean => {
8
- try {
9
- JSON.parse(value);
10
- } catch (error) {
11
- return false;
12
- }
13
- return true;
14
- };
15
-
16
- export function capitalize(str: string): string {
17
- return str.replace(/(^\w)|([-\s]\w)/g, (c) => c.toUpperCase());
18
- }
19
-
20
- export const sortArrayOfObjects = (a: any, b: any, key: string, order = 'asc') => {
21
- const valueA = a[key];
22
- const valueB = b[key];
23
-
24
- if (valueA < valueB) return order === 'asc' ? -1 : 1;
25
- if (valueA > valueB) return order === 'asc' ? 1 : -1;
26
- return 0;
27
- };
28
-
29
- export const getJsonStringValue = (value: unknown): string => {
30
- if (!value) return '';
31
- if (typeof value !== 'string') {
32
- try {
33
- return JSON.stringify(value, null, '\t');
34
- } catch (error) {
35
- return 'Failed to stringify JSON';
36
- }
37
- }
38
- return value;
39
- };
40
-
41
- export const safeParseJson = (value: string) => {
42
- try {
43
- return JSON.parse(value);
44
- } catch (error) {
45
- return null;
46
- }
47
- };
48
-
49
- export const deepParseJson = (value: string) => {
50
- try {
51
- const parsedValue = JSON.parse(value);
52
- Object.keys(parsedValue).forEach((key) => {
53
- parsedValue[key] = deepParseJson(parsedValue[key]);
54
- });
55
- return parsedValue;
56
- } catch (error) {
57
- return value;
58
- }
59
- };
60
-
61
- // export const convertArrayToObjectByKey = (array: { [key: string]: string }[], key: string) => {
62
- // const obj = {};
63
- // array.forEach((el) => {
64
- // obj[el[key]] = { ...el };
65
- // delete obj[el[key]][key];
66
- // });
67
- // return obj;
68
- // };
package/src/utils/dem.ts DELETED
@@ -1,78 +0,0 @@
1
- import { PropertyType, EntityTypeProperty, PropertiesArrayType } from '../interfaces';
2
- import { sortArrayOfObjects } from './common';
3
- import { format } from 'date-fns';
4
-
5
- export const isExpression = (value: unknown): boolean => {
6
- return typeof value === 'string' ? value.startsWith('$') : false;
7
- };
8
-
9
- export function propertiesObjectToArray(properties, fields?: { [key: string]: unknown }) {
10
- return Object.keys(properties)
11
- .map((key) => {
12
- const propObj = { key, ...properties[key], ...(fields ? fields : {}) };
13
- if (propObj['propertyType'] === PropertyType.ENTITY) {
14
- propObj['properties'] = propertiesObjectToArray(propObj['properties'], fields);
15
- }
16
-
17
- if (propObj['propertyType'] === PropertyType.JSON) {
18
- try {
19
- propObj.defaultValue = JSON.stringify(propObj.defaultValue);
20
- } catch (error) {
21
- propObj.defaultValue = '';
22
- }
23
- }
24
-
25
- if (propObj['uiSettings']) {
26
- try {
27
- propObj.uiSettings = JSON.stringify(propObj.uiSettings);
28
- } catch (error) {
29
- propObj.uiSettings = '';
30
- }
31
- }
32
-
33
- if (propObj['isMultiple']) {
34
- if ('defaultValues' in propObj) {
35
- propObj['defaultValue'] = propObj.defaultValues;
36
- }
37
- if ('values' in propObj) {
38
- propObj['value'] = propObj.values;
39
- }
40
- }
41
-
42
- return propObj;
43
- })
44
- .sort((a, b) => sortArrayOfObjects(a, b, 'sortOrder'));
45
- }
46
-
47
- export const getDemPropertyDateFormat = (defaultFormat: string, propertyFormat: string) => {
48
- if (propertyFormat) {
49
- try {
50
- const correctFormat = propertyFormat.replace(/Z/g, 'XXX');
51
- format(new Date(), correctFormat);
52
- return correctFormat;
53
- } catch (e) {
54
- console.error('Incorrect format', e);
55
- return defaultFormat;
56
- }
57
- }
58
- return defaultFormat;
59
- };
60
-
61
- export const getEntityStarterValue = (property: EntityTypeProperty) => {
62
- let properties: PropertiesArrayType = [];
63
- if (Array.isArray(property.properties)) {
64
- properties = property.properties;
65
- } else {
66
- properties = propertiesObjectToArray(property.properties);
67
- }
68
-
69
- return properties.reduce((value, property) => {
70
- const result = JSON.parse(JSON.stringify(value));
71
- if (property.propertyType === PropertyType.ENTITY) {
72
- result[property.key] = getEntityStarterValue(property);
73
- } else {
74
- result[property.key] = property.propertyType;
75
- }
76
- return result;
77
- }, {});
78
- };
@@ -1,41 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
-
3
- export function useDebounce(func: (args?: any) => void, delay: number) {
4
- const timer = useRef<NodeJS.Timeout>();
5
-
6
- useEffect(() => {
7
- return () => {
8
- if (!timer.current) return;
9
- clearTimeout(timer.current);
10
- };
11
- }, []);
12
-
13
- const debounceFunction = (...args) => {
14
- clearTimeout(timer.current);
15
- timer.current = setTimeout(() => {
16
- func(...args);
17
- }, delay);
18
- };
19
-
20
- return debounceFunction;
21
- }
22
-
23
-
24
- export const useToggle = () => {
25
- const [open, setOpen] = useState(false);
26
-
27
- const toggle = () => {
28
- setOpen((prevState) => !prevState);
29
- };
30
-
31
- const onClose = () => {
32
- setOpen(false);
33
- };
34
-
35
- const onOpen = () => {
36
- setOpen(true);
37
- };
38
-
39
- return { open, toggle, onClose, onOpen };
40
- };
41
-
@@ -1,71 +0,0 @@
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
- };
@@ -1,130 +0,0 @@
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 DELETED
@@ -1,24 +0,0 @@
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
- }
package/tsconfig.lib.json DELETED
@@ -1,22 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }