@dartech/arsenal-ui 1.3.0 → 1.3.2

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 (269) hide show
  1. package/{index.ts → index.d.ts} +5 -5
  2. package/index.js +1 -0
  3. package/package.json +10 -3
  4. package/src/consts/index.d.ts +12 -0
  5. package/src/interfaces/common.d.ts +17 -0
  6. package/src/interfaces/definition.d.ts +107 -0
  7. package/src/interfaces/{index.ts → index.d.ts} +3 -3
  8. package/src/interfaces/ui.d.ts +70 -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/Breadcrumbs/Breadcrumbs.d.ts +9 -0
  12. package/src/lib/Breadcrumbs/Breadcrumbs.styled.d.ts +2 -0
  13. package/src/lib/Breadcrumbs/{index.ts → index.d.ts} +1 -1
  14. package/src/lib/ContentLayout/ContentLayout.d.ts +9 -0
  15. package/src/lib/ContentLayout/index.d.ts +1 -0
  16. package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +11 -0
  17. package/src/lib/Definition/CreateDefinition/{index.ts → index.d.ts} +1 -1
  18. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +10 -0
  19. package/src/lib/Definition/DefinitionFiller/{index.ts → index.d.ts} +1 -1
  20. package/src/lib/Definition/DefinitionValueView/DefinitionValueView.d.ts +8 -0
  21. package/src/lib/Definition/DefinitionValueView/PropertyDataView.d.ts +9 -0
  22. package/src/lib/Definition/DefinitionValueView/{index.ts → index.d.ts} +1 -1
  23. package/src/lib/Definition/{index.ts → index.d.ts} +3 -3
  24. package/src/lib/Forms/BackButton.d.ts +7 -0
  25. package/src/lib/Forms/ControlAceEditor.d.ts +24 -0
  26. package/src/lib/Forms/ControlAutocomplete.d.ts +69 -0
  27. package/src/lib/Forms/ControlCheckbox.d.ts +51 -0
  28. package/src/lib/Forms/ControlDate.d.ts +18 -0
  29. package/src/lib/Forms/ControlDateTime.d.ts +18 -0
  30. package/src/lib/Forms/ControlDebouncedInput.d.ts +4 -0
  31. package/src/lib/Forms/ControlInput.d.ts +59 -0
  32. package/src/lib/Forms/ControlNumberInput.d.ts +51 -0
  33. package/src/lib/Forms/ControlQueryAutocomplete.d.ts +16 -0
  34. package/src/lib/Forms/ControlRadio.d.ts +66 -0
  35. package/src/lib/Forms/ControlSelect.d.ts +67 -0
  36. package/src/lib/Forms/ControlSwitch.d.ts +19 -0
  37. package/src/lib/Forms/ControlTime.d.ts +18 -0
  38. package/src/lib/Forms/CopyButton.d.ts +20 -0
  39. package/src/lib/Forms/{index.ts → index.d.ts} +15 -15
  40. package/src/lib/Forms/useAutocomplete.d.ts +10 -0
  41. package/src/lib/InfoItem/InfoItem.d.ts +10 -0
  42. package/src/lib/InfoItem/{index.ts → index.d.ts} +1 -1
  43. package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +10 -0
  44. package/src/lib/JsonPathPicker/PropertyStep.d.ts +11 -0
  45. package/src/lib/JsonPathPicker/{index.ts → index.d.ts} +1 -1
  46. package/src/lib/JsonView/JsonView.d.ts +7 -0
  47. package/src/lib/JsonView/{index.ts → index.d.ts} +1 -1
  48. package/src/lib/Loader/Loader.d.ts +21 -0
  49. package/src/lib/Loader/{index.ts → index.d.ts} +1 -1
  50. package/src/lib/Modals/JsonModalView.d.ts +10 -0
  51. package/src/lib/Modals/{index.ts → index.d.ts} +1 -1
  52. package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +10 -0
  53. package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.d.ts +12 -0
  54. package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.d.ts +11 -0
  55. package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +12 -0
  56. package/src/lib/Property/PropertyFiller/{index.ts → index.d.ts} +2 -2
  57. package/src/lib/Property/PropertyFiller/styled.d.ts +18 -0
  58. package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +24 -0
  59. package/src/lib/Property/PropertyValidator/NodeValidator.d.ts +6 -0
  60. package/src/lib/Property/PropertyValidator/NodesList.d.ts +6 -0
  61. package/src/lib/Property/PropertyValidator/NumericTypeValidator.d.ts +8 -0
  62. package/src/lib/Property/PropertyValidator/PropertyValidator.d.ts +6 -0
  63. package/src/lib/Property/PropertyValidator/PropertyValidatorContext.d.ts +3 -0
  64. package/src/lib/Property/PropertyValidator/StringTypeValidator.d.ts +8 -0
  65. package/src/lib/Property/PropertyValidator/ValidationNodeSelector.d.ts +7 -0
  66. package/src/lib/Property/PropertyValidator/index.d.ts +1 -0
  67. package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +7 -0
  68. package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +9 -0
  69. package/src/lib/Property/PropertyValueField/DateValueField.d.ts +9 -0
  70. package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +10 -0
  71. package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +9 -0
  72. package/src/lib/Property/PropertyValueField/StringValueField.d.ts +9 -0
  73. package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +9 -0
  74. package/src/lib/Property/PropertyValueField/{index.ts → index.d.ts} +1 -1
  75. package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +13 -0
  76. package/src/lib/Property/PropertyWidget/{index.ts → index.d.ts} +1 -1
  77. package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +13 -0
  78. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +10 -0
  79. package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +7 -0
  80. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +6 -0
  81. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +7 -0
  82. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +8 -0
  83. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +6 -0
  84. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +10 -0
  85. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +6 -0
  86. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.ts → index.d.ts} +1 -1
  87. package/src/lib/Property/UpsertProperty/{index.ts → index.d.ts} +2 -2
  88. package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +6 -0
  89. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +8 -0
  90. package/src/lib/Property/ViewPropertiesList/{index.ts → index.d.ts} +1 -1
  91. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +7 -0
  92. package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +8 -0
  93. package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +7 -0
  94. package/src/lib/Property/ViewProperty/PropertyItem.d.ts +9 -0
  95. package/src/lib/Property/ViewProperty/ViewProperty.d.ts +9 -0
  96. package/src/lib/Property/ViewProperty/{index.ts → index.d.ts} +1 -1
  97. package/src/lib/Property/{index.ts → index.d.ts} +5 -5
  98. package/src/lib/Sidebar/Sidebar.d.ts +10 -0
  99. package/src/lib/Sidebar/Sidebar.styled.d.ts +117 -0
  100. package/src/lib/Sidebar/SidebarContext.d.ts +11 -0
  101. package/src/lib/Sidebar/SidebarDrawer.d.ts +9 -0
  102. package/src/lib/Sidebar/SidebarLink/MenuIcon.d.ts +7 -0
  103. package/src/lib/Sidebar/SidebarLink/SidebarLink.d.ts +7 -0
  104. package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.d.ts +8 -0
  105. package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.d.ts +10 -0
  106. package/src/lib/Sidebar/SidebarLink/{index.ts → index.d.ts} +2 -2
  107. package/src/lib/Sidebar/index.d.ts +2 -0
  108. package/src/lib/Status/Status.d.ts +8 -0
  109. package/src/lib/Status/{index.ts → index.d.ts} +1 -1
  110. package/src/lib/StepperView/StepperView.d.ts +11 -0
  111. package/src/lib/StepperView/{index.ts → index.d.ts} +1 -1
  112. package/src/lib/Table/DataGrid/JsonTypeCell.d.ts +7 -0
  113. package/src/lib/Table/DataGrid/Table.d.ts +49 -0
  114. package/src/lib/Table/DataGrid/TableAction.d.ts +13 -0
  115. package/src/lib/Table/DataGrid/TableColumnMenu.d.ts +3 -0
  116. package/src/lib/Table/DataGrid/TablePagination.d.ts +3 -0
  117. package/src/lib/Table/DataGrid/index.d.ts +2 -0
  118. package/src/lib/Table/DataGrid/styles.d.ts +44 -0
  119. package/src/lib/Table/DataGrid/usePagination.d.ts +5 -0
  120. package/src/lib/Table/DataGrid/useTableQueryPagination.d.ts +11 -0
  121. package/src/lib/Table/DataGrid/useTableQuerySorting.d.ts +6 -0
  122. package/src/lib/Table/SimpleTable/SimpleTable.d.ts +17 -0
  123. package/src/lib/Table/SimpleTable/TableActionCell.d.ts +10 -0
  124. package/src/lib/Table/SimpleTable/index.d.ts +2 -0
  125. package/src/lib/Table/SimpleTable/useTablePagination.d.ts +7 -0
  126. package/src/lib/Table/SimpleTable/useTableSorting.d.ts +6 -0
  127. package/src/lib/Table/index.d.ts +2 -0
  128. package/src/lib/Tabs/RouteTabs.d.ts +11 -0
  129. package/src/lib/Tabs/TabPanel.d.ts +25 -0
  130. package/src/lib/Tabs/{index.ts → index.d.ts} +2 -2
  131. package/src/lib/{index.ts → index.d.ts} +16 -16
  132. package/src/theme/baseTheme.d.ts +2 -0
  133. package/src/theme/index.d.ts +1 -0
  134. package/src/theme/inputThemeOptions.d.ts +117 -0
  135. package/src/theme/stepperThemeOptions.d.ts +16 -0
  136. package/src/theme/tableThemeOptions.d.ts +47 -0
  137. package/src/theme/typographyThemeOptions.d.ts +29 -0
  138. package/src/utils/common.d.ts +7 -0
  139. package/src/utils/dem.d.ts +27 -0
  140. package/src/utils/hooks.d.ts +7 -0
  141. package/src/utils/{index.ts → index.d.ts} +5 -5
  142. package/src/utils/ui-utils.d.ts +16 -0
  143. package/src/utils/validators.d.ts +5 -0
  144. package/.babelrc +0 -13
  145. package/.eslintrc.json +0 -22
  146. package/jest.config.ts +0 -11
  147. package/project.json +0 -89
  148. package/rollup.config.js +0 -146
  149. package/src/assets/chevron_left_gray.svg +0 -3
  150. package/src/consts/index.ts +0 -13
  151. package/src/interfaces/common.ts +0 -18
  152. package/src/interfaces/definition.ts +0 -143
  153. package/src/interfaces/ui.ts +0 -80
  154. package/src/lib/Alert/Alert.tsx +0 -108
  155. package/src/lib/Alert/index.ts +0 -1
  156. package/src/lib/Breadcrumbs/Breadcrumbs.styled.tsx +0 -16
  157. package/src/lib/Breadcrumbs/Breadcrumbs.tsx +0 -40
  158. package/src/lib/ContentLayout/ContentLayout.tsx +0 -31
  159. package/src/lib/ContentLayout/index.ts +0 -1
  160. package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +0 -78
  161. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +0 -71
  162. package/src/lib/Definition/DefinitionValueView/DefinitionValueView.tsx +0 -54
  163. package/src/lib/Definition/DefinitionValueView/PropertyDataView.tsx +0 -67
  164. package/src/lib/Forms/BackButton.tsx +0 -46
  165. package/src/lib/Forms/ControlAceEditor.tsx +0 -125
  166. package/src/lib/Forms/ControlAutocomplete.tsx +0 -145
  167. package/src/lib/Forms/ControlCheckbox.tsx +0 -113
  168. package/src/lib/Forms/ControlDate.tsx +0 -75
  169. package/src/lib/Forms/ControlDateTime.tsx +0 -77
  170. package/src/lib/Forms/ControlDebouncedInput.tsx +0 -80
  171. package/src/lib/Forms/ControlInput.tsx +0 -111
  172. package/src/lib/Forms/ControlNumberInput.tsx +0 -121
  173. package/src/lib/Forms/ControlQueryAutocomplete.tsx +0 -197
  174. package/src/lib/Forms/ControlRadio.tsx +0 -136
  175. package/src/lib/Forms/ControlSelect.tsx +0 -164
  176. package/src/lib/Forms/ControlSwitch.tsx +0 -71
  177. package/src/lib/Forms/ControlTime.tsx +0 -93
  178. package/src/lib/Forms/CopyButton.tsx +0 -46
  179. package/src/lib/Forms/useAutocomplete.tsx +0 -47
  180. package/src/lib/InfoItem/InfoItem.tsx +0 -40
  181. package/src/lib/InfoItem/styles.ts +0 -17
  182. package/src/lib/JsonPathPicker/JsonPathPicker.tsx +0 -73
  183. package/src/lib/JsonPathPicker/PropertyStep.tsx +0 -70
  184. package/src/lib/JsonView/JsonView.tsx +0 -41
  185. package/src/lib/Loader/Loader.tsx +0 -41
  186. package/src/lib/Modals/JsonModalView.tsx +0 -53
  187. package/src/lib/Property/PropertyFiller/JsonEditor.tsx +0 -58
  188. package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.tsx +0 -129
  189. package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.tsx +0 -85
  190. package/src/lib/Property/PropertyFiller/PropertyFiller.tsx +0 -199
  191. package/src/lib/Property/PropertyFiller/usePropertyFiller.ts +0 -72
  192. package/src/lib/Property/PropertyFiller/useStyles.ts +0 -12
  193. package/src/lib/Property/PropertyValidator/NodeValidator.tsx +0 -92
  194. package/src/lib/Property/PropertyValidator/NodesList.tsx +0 -26
  195. package/src/lib/Property/PropertyValidator/NumericTypeValidator.tsx +0 -59
  196. package/src/lib/Property/PropertyValidator/PropertyValidator.tsx +0 -42
  197. package/src/lib/Property/PropertyValidator/PropertyValidatorContext.tsx +0 -4
  198. package/src/lib/Property/PropertyValidator/StringTypeValidator.tsx +0 -36
  199. package/src/lib/Property/PropertyValidator/ValidationNodeSelector.tsx +0 -62
  200. package/src/lib/Property/PropertyValidator/index.ts +0 -1
  201. package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +0 -49
  202. package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +0 -58
  203. package/src/lib/Property/PropertyValueField/DateValueField.tsx +0 -58
  204. package/src/lib/Property/PropertyValueField/JsonValueField.tsx +0 -65
  205. package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +0 -49
  206. package/src/lib/Property/PropertyValueField/StringValueField.tsx +0 -50
  207. package/src/lib/Property/PropertyValueField/TimeValueField.tsx +0 -67
  208. package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +0 -115
  209. package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +0 -148
  210. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +0 -158
  211. package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +0 -40
  212. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +0 -41
  213. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +0 -27
  214. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +0 -133
  215. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +0 -46
  216. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +0 -52
  217. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +0 -103
  218. package/src/lib/Property/UpsertProperty/useCustomFields.ts +0 -22
  219. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +0 -37
  220. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +0 -40
  221. package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +0 -48
  222. package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +0 -148
  223. package/src/lib/Property/ViewProperty/PropertyItem.tsx +0 -43
  224. package/src/lib/Property/ViewProperty/ViewProperty.tsx +0 -52
  225. package/src/lib/Sidebar/Sidebar.styled.tsx +0 -157
  226. package/src/lib/Sidebar/Sidebar.tsx +0 -27
  227. package/src/lib/Sidebar/SidebarContext.tsx +0 -37
  228. package/src/lib/Sidebar/SidebarDrawer.tsx +0 -50
  229. package/src/lib/Sidebar/SidebarLink/MenuIcon.tsx +0 -16
  230. package/src/lib/Sidebar/SidebarLink/SidebarLink.tsx +0 -54
  231. package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.tsx +0 -54
  232. package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.tsx +0 -62
  233. package/src/lib/Sidebar/index.ts +0 -2
  234. package/src/lib/Status/Status.tsx +0 -16
  235. package/src/lib/Status/styles.ts +0 -21
  236. package/src/lib/StepperView/StepperView.tsx +0 -73
  237. package/src/lib/Table/DataGrid/JsonTypeCell.tsx +0 -51
  238. package/src/lib/Table/DataGrid/Table.tsx +0 -117
  239. package/src/lib/Table/DataGrid/TableAction.tsx +0 -43
  240. package/src/lib/Table/DataGrid/TableColumnMenu.tsx +0 -12
  241. package/src/lib/Table/DataGrid/TablePagination.tsx +0 -42
  242. package/src/lib/Table/DataGrid/index.ts +0 -2
  243. package/src/lib/Table/DataGrid/styles.ts +0 -59
  244. package/src/lib/Table/DataGrid/usePagination.ts +0 -15
  245. package/src/lib/Table/DataGrid/useTableQueryPagination.ts +0 -47
  246. package/src/lib/Table/DataGrid/useTableQuerySorting.ts +0 -47
  247. package/src/lib/Table/SimpleTable/SimpleTable.tsx +0 -138
  248. package/src/lib/Table/SimpleTable/TableActionCell.tsx +0 -67
  249. package/src/lib/Table/SimpleTable/index.ts +0 -2
  250. package/src/lib/Table/SimpleTable/useTablePagination.ts +0 -54
  251. package/src/lib/Table/SimpleTable/useTableSorting.ts +0 -50
  252. package/src/lib/Table/index.ts +0 -2
  253. package/src/lib/Tabs/RouteTabs.tsx +0 -54
  254. package/src/lib/Tabs/TabPanel.tsx +0 -42
  255. package/src/theme/baseTheme.ts +0 -41
  256. package/src/theme/fonts.d.ts +0 -2
  257. package/src/theme/index.ts +0 -126
  258. package/src/theme/inputThemeOptions.ts +0 -126
  259. package/src/theme/stepperThemeOptions.ts +0 -20
  260. package/src/theme/tableThemeOptions.ts +0 -50
  261. package/src/theme/typographyThemeOptions.ts +0 -32
  262. package/src/utils/common.ts +0 -73
  263. package/src/utils/dem.ts +0 -431
  264. package/src/utils/hooks.ts +0 -41
  265. package/src/utils/ui-utils.tsx +0 -134
  266. package/src/utils/validators.ts +0 -14
  267. package/tsconfig.json +0 -25
  268. package/tsconfig.lib.json +0 -23
  269. package/tsconfig.spec.json +0 -20
package/src/utils/dem.ts DELETED
@@ -1,431 +0,0 @@
1
- import {
2
- PropertyType,
3
- EntityTypeProperty,
4
- PropertiesArrayType,
5
- PropertyUnion,
6
- PropertiesObjectType,
7
- PropertyFillType,
8
- } from '../interfaces';
9
- import { sortArrayOfObjects } from './common';
10
- import { format } from 'date-fns';
11
-
12
- export const isPropertyValueEmpty = (value: unknown): boolean => {
13
- if (value || value === 0 || value === false) {
14
- return false;
15
- }
16
- return true;
17
- };
18
-
19
- const formatPropertyValue = (
20
- propertyType: PropertyType,
21
- value: unknown,
22
- params?: {
23
- formatText?: string;
24
- properties?: PropertiesArrayType;
25
- }
26
- ) => {
27
- if ((value === null || value === undefined) && propertyType !== PropertyType.BOOLEAN) {
28
- return null;
29
- }
30
- let parsedValue: unknown = value;
31
-
32
- switch (propertyType) {
33
- case PropertyType.BOOLEAN:
34
- if (value) {
35
- parsedValue = true;
36
- } else {
37
- parsedValue = false;
38
- }
39
- break;
40
- case PropertyType.INTEGER:
41
- case PropertyType.BIG_INTEGER:
42
- case PropertyType.BIG_DECIMAL:
43
- case PropertyType.FLOAT:
44
- case PropertyType.LONG:
45
- case PropertyType.DOUBLE:
46
- parsedValue = Number(value);
47
- break;
48
- case PropertyType.DATE:
49
- case PropertyType.DATE_TIME:
50
- case PropertyType.TIME:
51
- parsedValue = format(new Date(value.toString()), params.formatText);
52
- break;
53
- case PropertyType.JSON:
54
- case PropertyType.ANY:
55
- try {
56
- if (typeof value !== 'string') {
57
- parsedValue = JSON.stringify(value);
58
- }
59
- parsedValue = JSON.parse(parsedValue as string);
60
- } catch (e) {
61
- console.log(e);
62
- parsedValue = null;
63
- }
64
- break;
65
- case PropertyType.ENTITY:
66
- parsedValue = formatDefinitionData(params.properties, value);
67
- break;
68
- default:
69
- break;
70
- }
71
-
72
- return parsedValue;
73
- };
74
-
75
- export const formatDefinitionData = (properties: PropertiesArrayType<unknown>, data: unknown) => {
76
- if (data) {
77
- const formattedData = {};
78
-
79
- properties.forEach((property) => {
80
- const { key, propertyType } = property;
81
- const value = data[key];
82
-
83
- if (Array.isArray(value)) {
84
- formattedData[key] = value.map((val) =>
85
- formatPropertyValue(propertyType, val, {
86
- formatText: property['format'],
87
- properties: property['properties'],
88
- })
89
- );
90
- } else {
91
- formattedData[key] = formatPropertyValue(propertyType, value, {
92
- formatText: property['format'],
93
- properties: property['properties'],
94
- });
95
- }
96
- });
97
-
98
- return formattedData;
99
- }
100
- return null;
101
- };
102
-
103
- const getPropertyValue = (property: PropertyUnion & { [key: string]: unknown }, isGlobalParameter: boolean) => {
104
- const valueObject = {};
105
- let value;
106
- let key = '';
107
-
108
- if (isGlobalParameter) {
109
- if (property.isMultiple) {
110
- key = 'values';
111
- value = property['value'];
112
- } else {
113
- key = 'value';
114
- value = property['value'];
115
- }
116
- } else {
117
- if (property.isMultiple) {
118
- key = 'defaultValues';
119
- value = property['defaultValue'];
120
- } else {
121
- key = 'defaultValue';
122
- value = property['defaultValue'];
123
- }
124
- }
125
-
126
- if (Array.isArray(value)) {
127
- valueObject[key] = value.map((val) =>
128
- formatPropertyValue(property.propertyType, val, {
129
- formatText: property['format'] as string,
130
- properties: property['properties'] as PropertiesArrayType,
131
- })
132
- );
133
- } else {
134
- valueObject[key] = formatPropertyValue(property.propertyType, value, {
135
- formatText: property['format'] as string,
136
- properties: property['properties'] as PropertiesArrayType,
137
- });
138
- }
139
-
140
- return valueObject;
141
- };
142
-
143
- export const propertiesArrayToObject = (properties, isGlobalParameter?: boolean): PropertiesObjectType<any> => {
144
- const propertiesObject = {};
145
-
146
- properties.forEach((property) => {
147
- const { key, name, isRequired, isMultiple, sortOrder, isEnabled, uiSettings, validationNode } = property;
148
- const propertyType =
149
- typeof property.propertyType === 'string' ? property.propertyType : property.propertyType.value;
150
-
151
- const resultProperty = {
152
- name,
153
- propertyType,
154
- isRequired,
155
- isMultiple,
156
- sortOrder,
157
- isEnabled,
158
- validationNode,
159
- uiSettings,
160
- ...getPropertyValue({ ...property, propertyType }, isGlobalParameter),
161
- };
162
-
163
- if ('isViewableInList' in property) {
164
- resultProperty['isViewableInList'] = property.isViewableInList;
165
- }
166
-
167
- if (uiSettings) {
168
- try {
169
- resultProperty.uiSettings = JSON.parse(uiSettings);
170
- } catch (e) {
171
- console.log(e);
172
- }
173
- } else {
174
- resultProperty.uiSettings = null;
175
- }
176
-
177
- if (propertyType === PropertyType.BIG_DECIMAL) {
178
- resultProperty['precisionScale'] = property.precisionScale;
179
- resultProperty['roundingMode'] = property.roundingMode;
180
- }
181
-
182
- if (
183
- propertyType === PropertyType.DATE ||
184
- propertyType === PropertyType.TIME ||
185
- propertyType === PropertyType.DATE_TIME
186
- ) {
187
- resultProperty['format'] = property.format;
188
- }
189
-
190
- if (propertyType === PropertyType.STRING) {
191
- resultProperty['restrictedValues'] = property.restrictedValues;
192
- }
193
-
194
- if (propertyType === PropertyType.ENTITY_REFERENCE) {
195
- resultProperty['definitionCode'] = property.definitionCode;
196
- resultProperty['definitionVersion'] = property.definitionVersion;
197
- resultProperty['labelPropertyCode'] = property.labelPropertyCode;
198
- resultProperty['valuePropertyCode'] = property.valuePropertyCode;
199
- }
200
-
201
- if (propertyType === PropertyType.ENTITY) {
202
- resultProperty['properties'] = propertiesArrayToObject(property.properties, isGlobalParameter);
203
- }
204
-
205
- propertiesObject[key] = resultProperty;
206
- });
207
-
208
- return propertiesObject;
209
- };
210
-
211
- export function propertiesObjectToArray(properties, fields?: { [key: string]: unknown }) {
212
- return Object.keys(properties)
213
- .map((key) => {
214
- const propObj = { key, ...properties[key], ...(fields ? fields : {}) };
215
- if (propObj['propertyType'] === PropertyType.ENTITY) {
216
- propObj['properties'] = propertiesObjectToArray(propObj['properties'], fields);
217
- }
218
-
219
- if (propObj['propertyType'] === PropertyType.JSON) {
220
- try {
221
- if (propObj.defaultValue == null) {
222
- propObj.defaultValue = '';
223
- } else {
224
- propObj.defaultValue = JSON.stringify(propObj.defaultValue, null, 2);
225
- }
226
- } catch (error) {
227
- propObj.defaultValue = '';
228
- }
229
- }
230
-
231
- if (propObj['uiSettings']) {
232
- try {
233
- propObj.uiSettings = JSON.stringify(propObj.uiSettings, null, 2);
234
- } catch (error) {
235
- propObj.uiSettings = '';
236
- }
237
- }
238
-
239
- if (propObj['isMultiple']) {
240
- if ('defaultValues' in propObj) {
241
- propObj['defaultValue'] = propObj.defaultValues;
242
- }
243
- if ('values' in propObj) {
244
- propObj['value'] = propObj.values;
245
- }
246
- }
247
-
248
- return propObj;
249
- })
250
- .sort((a, b) => sortArrayOfObjects(a, b, 'sortOrder'));
251
- }
252
-
253
- export const getDemPropertyDateFormat = (defaultFormat: string, propertyFormat: string) => {
254
- if (propertyFormat) {
255
- try {
256
- const correctFormat = propertyFormat.replace(/Z/g, 'XXX');
257
- format(new Date(), correctFormat);
258
- return correctFormat;
259
- } catch (e) {
260
- console.error('Incorrect format', e);
261
- return defaultFormat;
262
- }
263
- }
264
- return defaultFormat;
265
- };
266
-
267
- export const getEntityStarterValue = (property: EntityTypeProperty) => {
268
- let properties: PropertiesArrayType = [];
269
- if (Array.isArray(property.properties)) {
270
- properties = property.properties;
271
- } else {
272
- properties = propertiesObjectToArray(property.properties);
273
- }
274
-
275
- return properties.reduce((value, property) => {
276
- const result = JSON.parse(JSON.stringify(value));
277
- if (property.propertyType === PropertyType.ENTITY) {
278
- result[property.key] = getEntityStarterValue(property);
279
- } else {
280
- result[property.key] = property.propertyType;
281
- }
282
- return result;
283
- }, {});
284
- };
285
-
286
- export const getMultiplePropertyFillOptions = ({
287
- propertyType,
288
- useExpression,
289
- required,
290
- }: {
291
- propertyType: PropertyType;
292
- required: boolean;
293
- useExpression?: boolean;
294
- }): { value: PropertyFillType; label: string; sortOrder: number }[] => {
295
- let options: { value: PropertyFillType; label: string; sortOrder: number }[] = [
296
- {
297
- value: 'widget',
298
- label: 'Fill array (widget)',
299
- sortOrder: 1,
300
- },
301
- ];
302
-
303
- if (!required) {
304
- options.push({
305
- value: 'null',
306
- label: 'NULL',
307
- sortOrder: 0,
308
- });
309
- }
310
-
311
- if (useExpression) {
312
- if (
313
- propertyType === PropertyType.JSON ||
314
- propertyType === PropertyType.ENTITY ||
315
- propertyType === PropertyType.ANY
316
- ) {
317
- options.push({ value: 'expression', label: 'Expression (JSON editor)', sortOrder: 3 });
318
- } else {
319
- options.push({
320
- value: 'expression',
321
- label: 'Expression',
322
- sortOrder: 3,
323
- });
324
- }
325
- }
326
-
327
- if (propertyType === PropertyType.JSON || propertyType === PropertyType.ANY || propertyType === PropertyType.ENTITY) {
328
- options.push({
329
- value: 'json_valid',
330
- label: 'JSON editor',
331
- sortOrder: 2,
332
- });
333
- }
334
-
335
- options = options.sort((a, b) => sortArrayOfObjects(a, b, 'sortOrder'));
336
- return options;
337
- };
338
-
339
- export const getSinglePropertyFillOptions = ({
340
- propertyType,
341
- useExpression,
342
- required,
343
- }: {
344
- propertyType: PropertyType;
345
- required: boolean;
346
- useExpression?: boolean;
347
- }): { value: PropertyFillType; label: string; sortOrder: number }[] => {
348
- let options: { value: PropertyFillType; label: string; sortOrder: number }[] = [
349
- {
350
- value: 'widget',
351
- label: 'Widget',
352
- sortOrder: 1,
353
- },
354
- ];
355
-
356
- if (!required) {
357
- options.push({
358
- value: 'null',
359
- label: 'NULL',
360
- sortOrder: 0,
361
- });
362
- }
363
-
364
- if (useExpression) {
365
- if (
366
- propertyType === PropertyType.JSON ||
367
- propertyType === PropertyType.ENTITY ||
368
- propertyType === PropertyType.ANY
369
- ) {
370
- options.push({ value: 'expression', label: 'Expression (JSON editor)', sortOrder: 3 });
371
- } else {
372
- options.push({
373
- value: 'expression',
374
- label: 'Expression',
375
- sortOrder: 3,
376
- });
377
- }
378
- }
379
-
380
- if (propertyType === PropertyType.JSON) {
381
- options.push({
382
- value: 'dem_builder',
383
- label: 'DEM Builder',
384
- sortOrder: 2,
385
- });
386
- }
387
-
388
- // WIDGET LABEL SET
389
- switch (propertyType) {
390
- case PropertyType.STRING:
391
- options[0].label = 'Text input';
392
- break;
393
- case PropertyType.INTEGER:
394
- case PropertyType.BIG_INTEGER:
395
- case PropertyType.BIG_DECIMAL:
396
- case PropertyType.FLOAT:
397
- case PropertyType.LONG:
398
- case PropertyType.DOUBLE:
399
- options[0].label = 'Number input';
400
- break;
401
- case PropertyType.BOOLEAN:
402
- options[0].label = 'Switch';
403
- break;
404
- case PropertyType.ENTITY_REFERENCE:
405
- options[0].label = 'Entity reference fields';
406
- break;
407
- case PropertyType.JSON:
408
- options[0].label = 'JSON editor';
409
- break;
410
- case PropertyType.DATE:
411
- options[0].label = 'Date picker';
412
- options.push({ value: 'string', label: 'Text input', sortOrder: 2 });
413
- break;
414
- case PropertyType.DATE_TIME:
415
- options[0].label = 'Date & Time picker';
416
- options.push({ value: 'string', label: 'Text input', sortOrder: 2 });
417
- break;
418
- case PropertyType.TIME:
419
- options[0].label = 'Time picker';
420
- options.push({ value: 'string', label: 'Text input', sortOrder: 2 });
421
- break;
422
- case PropertyType.ANY:
423
- options[0].label = 'Textarea';
424
- break;
425
- default:
426
- break;
427
- }
428
-
429
- options = options.sort((a, b) => sortArrayOfObjects(a, b, 'sortOrder'));
430
- return options;
431
- };
@@ -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<any>();
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,134 +0,0 @@
1
- import Box from '@mui/material/Box';
2
- import SvgIcon from '@mui/material/SvgIcon';
3
- import Tooltip from '@mui/material/Tooltip';
4
- import { CopyButton, Status } from '../lib';
5
- import { format } from 'date-fns';
6
- import { StatusVariant } from '../interfaces';
7
- import JsonTypeCell from '../lib/Table/DataGrid/JsonTypeCell';
8
-
9
- type TableFormatProps = {
10
- value: any;
11
- canCopy?: boolean;
12
- copyValue?: string;
13
- shortId?: boolean;
14
- fullText?: boolean;
15
- textParams?: {
16
- displayAs?:
17
- | 'text'
18
- | 'boolean'
19
- | 'date'
20
- | 'status'
21
- | 'json_text'
22
- | 'json_code'
23
- | 'array'
24
- | 'number';
25
- dateFormat?: string[];
26
- statusVariant?: StatusVariant;
27
- };
28
- };
29
-
30
- export const formatTableRowValue = ({
31
- value,
32
- canCopy,
33
- copyValue,
34
- shortId,
35
- fullText,
36
- textParams: { displayAs = 'text', dateFormat, statusVariant },
37
- }: TableFormatProps) => {
38
- switch (displayAs) {
39
- case 'boolean':
40
- return value ? (
41
- <SvgIcon color="primary" fontSize="small">
42
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" />
43
- </SvgIcon>
44
- ) : (
45
- <SvgIcon fontSize="small">
46
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8 0-1.85.63-3.55 1.69-4.9L16.9 18.31C15.55 19.37 13.85 20 12 20zm6.31-3.1L7.1 5.69C8.45 4.63 10.15 4 12 4c4.42 0 8 3.58 8 8 0 1.85-.63 3.55-1.69 4.9z" />
47
- </SvgIcon>
48
- );
49
- case 'date':
50
- return value ? (
51
- dateFormat ? (
52
- <Box>
53
- {dateFormat.map((formatString) => (
54
- <Box>{format(new Date(value as string), formatString)}</Box>
55
- ))}
56
- </Box>
57
- ) : (
58
- <Box>
59
- <Box>{format(new Date(value as string), 'dd.MM.yyyy')}</Box>
60
- <Box>{format(new Date(value as string), 'HH:mm:ss')}</Box>
61
- </Box>
62
- )
63
- ) : (
64
- ''
65
- );
66
- case 'status':
67
- return (
68
- <Status
69
- text={value as string}
70
- status={statusVariant ? statusVariant : 'default'}
71
- />
72
- );
73
- case 'json_text':
74
- return <JsonTypeCell value={value} textField />;
75
- case 'json_code':
76
- return <JsonTypeCell value={value} copyButton />;
77
- case 'array':
78
- return (
79
- <Box>
80
- {(value as string[]).map((val, index) => (
81
- <Box key={index}>{val}</Box>
82
- ))}
83
- </Box>
84
- );
85
- case 'number':
86
- return (
87
- <Box display="flex" justifyContent="flex-end">
88
- <Box>
89
- {value.toLocaleString('ru-Ru', { minimumFractionDigits: 2 })}
90
- </Box>
91
- </Box>
92
- );
93
- case 'text':
94
- default:
95
- return value ? (
96
- <Box display="flex" alignItems="center" width="100%">
97
- {shortId ? (
98
- <Tooltip title={value}>
99
- <Box mr="auto">
100
- {value
101
- ? `${(value as string).slice(0, 6)}...${(
102
- value as string
103
- ).slice(-6)}`
104
- : '...'}
105
- </Box>
106
- </Tooltip>
107
- ) : fullText ? (
108
- <Box sx={{ whiteSpace: 'normal' }} title={value}>
109
- {typeof value === 'string' ? value : JSON.stringify(value)}
110
- </Box>
111
- ) : (
112
- <Tooltip title={value}>
113
- <Box className="MuiDataGrid-cellContent" title={value}>
114
- {typeof value === 'string' ? value : JSON.stringify(value)}
115
- </Box>
116
- </Tooltip>
117
- )}
118
- {canCopy && (
119
- <CopyButton
120
- copyText={
121
- copyValue
122
- ? typeof copyValue === 'string'
123
- ? copyValue
124
- : JSON.stringify(copyValue)
125
- : value
126
- }
127
- />
128
- )}
129
- </Box>
130
- ) : (
131
- ''
132
- );
133
- }
134
- };
@@ -1,14 +0,0 @@
1
- import { PropertyType } from '../interfaces';
2
-
3
- export const digitsOnly = new RegExp('^[-+]?[0-9]+$');
4
- export const floatsOnly = new RegExp(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/);
5
-
6
- export const isExpression = (value: unknown): boolean => {
7
- return typeof value === 'string' ? value.includes('$(') : false;
8
- };
9
-
10
- export const isDateType = (propertyType: PropertyType) => {
11
- return (
12
- propertyType === PropertyType.DATE || propertyType === PropertyType.DATE_TIME || propertyType === PropertyType.TIME
13
- );
14
- };
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "ESNext",
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
- "extends": "../../tsconfig.base.json"
25
- }
package/tsconfig.lib.json DELETED
@@ -1,23 +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
- "jest.config.ts",
13
- "src/**/*.spec.ts",
14
- "src/**/*.test.ts",
15
- "src/**/*.spec.tsx",
16
- "src/**/*.test.tsx",
17
- "src/**/*.spec.js",
18
- "src/**/*.test.js",
19
- "src/**/*.spec.jsx",
20
- "src/**/*.test.jsx"
21
- ],
22
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "src/**/*.d.ts"]
23
- }
@@ -1,20 +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
- "jest.config.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.ts",
12
- "src/**/*.test.tsx",
13
- "src/**/*.spec.tsx",
14
- "src/**/*.test.js",
15
- "src/**/*.spec.js",
16
- "src/**/*.test.jsx",
17
- "src/**/*.spec.jsx",
18
- "src/**/*.d.ts"
19
- ]
20
- }