@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
@@ -1,197 +0,0 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
2
- import TextField from '@mui/material/TextField';
3
- import Autocomplete from '@mui/material/Autocomplete';
4
- import CircularProgress from '@mui/material/CircularProgress';
5
-
6
- import { useController, useWatch } from 'react-hook-form';
7
- import { useQuery } from '@tanstack/react-query';
8
- import qs from 'qs';
9
- import { useDebounce } from '../../utils/hooks';
10
- import useAutocomplete from './useAutocomplete';
11
-
12
- import { ControlAutocompleteProps } from './ControlAutocomplete';
13
- import { PaginateData } from '../../interfaces';
14
-
15
- type PaginateParams = {
16
- page: string;
17
- size: string;
18
- [key: string]: string;
19
- };
20
-
21
- type ControlQueryAutocompleteProps<T> = Omit<ControlAutocompleteProps, 'options'> & {
22
- searchBy: string;
23
- sortBy?: string;
24
- queryFunction: (params: PaginateParams) => Promise<PaginateData<T>>;
25
- itemQueryFunction?: (valueKey: string) => Promise<T>;
26
- };
27
-
28
- export function ControlQueryAutocomplete<T>({
29
- name,
30
- label,
31
- control,
32
- required = false,
33
- searchBy,
34
- labelKey,
35
- multiple = false,
36
- disabled,
37
- valueKey,
38
- sortBy = '',
39
- hideErrorMessage,
40
- disableCloseOnSelect,
41
- textFieldProps,
42
- onChange,
43
- queryFunction,
44
- validate,
45
- itemQueryFunction,
46
- ...autocompleteProps
47
- }: ControlQueryAutocompleteProps<T>) {
48
- const {
49
- field: { ref, onChange: setFieldValue },
50
- fieldState: { error, isDirty },
51
- } = useController({ control, name, rules: { required: required && 'Please, fill this field', validate } });
52
- const formValue = useWatch({ control, name, defaultValue: multiple ? [] : null });
53
-
54
- const { getOptionLabel, isOptionEqualToValue, renderOption } = useAutocomplete({ valueKey, labelKey });
55
-
56
- const [open, setOpen] = useState(false);
57
- const [inputValue, setInputValue] = useState('');
58
- const [searchValue, setSearchValue] = useState('');
59
- const [totalItems, setTotalItems] = useState(0);
60
- const [page, setPage] = useState(0);
61
- const [options, setOptions] = useState<unknown[]>([]);
62
-
63
- const debouncedChange = useDebounce((val) => {
64
- setPage(0);
65
- setSearchValue(val);
66
- setOptions([]);
67
- }, 500);
68
-
69
- const handleInputChange = useCallback(
70
- (_, value) => {
71
- setInputValue(value);
72
- debouncedChange(value);
73
- },
74
- [debouncedChange]
75
- );
76
-
77
- const handleValueChange = useCallback(
78
- (event, value) => {
79
- setFieldValue(value);
80
- if (onChange) {
81
- onChange(event, value);
82
- }
83
- },
84
- [setFieldValue, onChange]
85
- );
86
-
87
- useEffect(() => {
88
- if (!isDirty && formValue && itemQueryFunction) {
89
- let requestValue = formValue;
90
-
91
- if (typeof formValue === 'object' && valueKey in formValue) {
92
- requestValue = formValue[valueKey];
93
- }
94
-
95
- itemQueryFunction(requestValue)
96
- .then((item) => {
97
- setFieldValue(item);
98
- setInputValue(item[labelKey]);
99
- })
100
- .catch();
101
- }
102
- }, [formValue, isDirty, valueKey, labelKey, itemQueryFunction, setFieldValue]);
103
-
104
- const handleOnScroll = useCallback(
105
- (event: React.SyntheticEvent) => {
106
- const listboxNode = event.currentTarget;
107
- if (
108
- listboxNode.scrollHeight - listboxNode.scrollTop - listboxNode.clientHeight <= 1 &&
109
- options.length < totalItems
110
- ) {
111
- setPage((page) => page + 1);
112
- }
113
- },
114
- [totalItems, options]
115
- );
116
-
117
- const handleOpen = () => {
118
- setOpen(true);
119
- };
120
-
121
- const handleClose = () => {
122
- setOpen(false);
123
- setSearchValue('');
124
- };
125
-
126
- const { data, isFetching } = useQuery(['options', page, searchValue], () => {
127
- const params = qs.parse(
128
- {
129
- page: `${page}`,
130
- size: '20',
131
- sort: sortBy,
132
- ...(searchValue ? { [searchBy]: searchValue } : {}),
133
- },
134
- { ignoreQueryPrefix: true }
135
- );
136
- return queryFunction(params as PaginateParams);
137
- });
138
-
139
- useEffect(() => {
140
- if (data) {
141
- setOptions((prevOptions) => [...prevOptions, ...data.collection]);
142
- setTotalItems(data.totalItems);
143
- }
144
- }, [data]);
145
-
146
- return (
147
- <Autocomplete
148
- fullWidth
149
- disablePortal
150
- size="small"
151
- readOnly={disabled}
152
- options={options}
153
- multiple={multiple}
154
- getOptionLabel={getOptionLabel}
155
- isOptionEqualToValue={isOptionEqualToValue}
156
- disableCloseOnSelect={disableCloseOnSelect || multiple}
157
- filterSelectedOptions={multiple}
158
- inputValue={inputValue}
159
- value={formValue}
160
- onChange={handleValueChange}
161
- loading={isFetching}
162
- clearOnBlur={false}
163
- open={open}
164
- filterOptions={(x) => x}
165
- onOpen={handleOpen}
166
- onClose={handleClose}
167
- onInputChange={handleInputChange}
168
- ListboxProps={{
169
- onScroll: handleOnScroll,
170
- }}
171
- renderOption={renderOption}
172
- renderInput={(params) => (
173
- <TextField
174
- {...params}
175
- label={label}
176
- variant="outlined"
177
- error={!!error}
178
- inputRef={ref}
179
- helperText={!hideErrorMessage && error?.message}
180
- InputProps={{
181
- ...params.InputProps,
182
- endAdornment: (
183
- <React.Fragment>
184
- {isFetching ? <CircularProgress color="inherit" size={20} /> : null}
185
- {params.InputProps.endAdornment}
186
- </React.Fragment>
187
- ),
188
- }}
189
- {...textFieldProps}
190
- />
191
- )}
192
- {...autocompleteProps}
193
- />
194
- );
195
- }
196
-
197
- export default ControlQueryAutocomplete;
@@ -1,136 +0,0 @@
1
- import Radio from '@mui/material/Radio';
2
- import RadioGroup from '@mui/material/RadioGroup';
3
- import FormControlLabel from '@mui/material/FormControlLabel';
4
- import FormControl from '@mui/material/FormControl';
5
- import FormLabel from '@mui/material/FormLabel';
6
-
7
- import { Control, useController, useWatch } from 'react-hook-form';
8
- import { ValidateFunc } from '../../interfaces';
9
- import { useCallback } from 'react';
10
- import FormHelperText from '@mui/material/FormHelperText';
11
-
12
- /**
13
- * This interface is referencing the [[ControlRadioBtn]] component props.
14
- * @category Forms
15
- */
16
- export interface ControlRadioProps {
17
- /**
18
- * React Hook Form `control`
19
- */
20
- control: Control<any>;
21
- /**
22
- * React Hook Form control `name` propery
23
- */
24
- name: string;
25
- /**
26
- * Label for component
27
- */
28
- label?: string;
29
- /**
30
- * Radio group values
31
- */
32
- values: string[] | unknown[];
33
- /**
34
- * Is input required flag
35
- */
36
- required?: boolean;
37
- /**
38
- * React Hook Form `defaultValue`
39
- */
40
- defaultValue?: unknown;
41
- /**
42
- * Is disabled input flag
43
- */
44
- disabled?: boolean;
45
- /**
46
- * Hide error message flag
47
- */
48
- hideErrorMessage?: boolean;
49
- /**
50
- * Custom onChange functionƒ
51
- */
52
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
53
- /**
54
- * React Hook Form validate function
55
- * ```typescript
56
- * type ValidateFunc = (value: string) => boolean | string;
57
- * ```
58
- */
59
- validate?: ValidateFunc | Record<string, ValidateFunc>;
60
- /**
61
- * Key for option label
62
- */
63
- labelKey?: string;
64
- /**
65
- * Key for option value
66
- */
67
- valueKey?: string;
68
- }
69
-
70
- /**
71
- * Material UI `Radio` controlled component. Used with react-hook-form
72
- * @category Forms
73
- */
74
- export const ControlRadio = ({
75
- name,
76
- label,
77
- values = [],
78
- control,
79
- required,
80
- defaultValue,
81
- disabled,
82
- hideErrorMessage,
83
- labelKey,
84
- valueKey,
85
- validate,
86
- onChange: customOnChange,
87
- }: ControlRadioProps) => {
88
- const {
89
- field: { ref, onChange },
90
- fieldState: { error },
91
- } = useController({
92
- name,
93
- control,
94
- defaultValue,
95
- rules: {
96
- required: required && 'Please, fill this field',
97
- validate,
98
- },
99
- });
100
- const value = useWatch({ control, name });
101
-
102
- const getValue = useCallback(
103
- (option) => {
104
- if (typeof option === 'string') return option;
105
- return valueKey ? option[valueKey] : option.value;
106
- },
107
- [valueKey]
108
- );
109
- const getLabel = useCallback(
110
- (option) => {
111
- if (typeof option === 'string') return option;
112
- return labelKey ? option[labelKey] : option.label;
113
- },
114
- [labelKey]
115
- );
116
-
117
- return (
118
- <FormControl disabled={disabled} error={!!error}>
119
- <FormLabel id="radio-buttons-group">{label}</FormLabel>
120
- <RadioGroup
121
- aria-labelledby="radio-buttons-group"
122
- ref={ref}
123
- name={name}
124
- value={value}
125
- onChange={customOnChange ? customOnChange : onChange}
126
- >
127
- {values.map((item) => (
128
- <FormControlLabel value={getValue(item)} control={<Radio />} label={getLabel(item)} />
129
- ))}
130
- </RadioGroup>
131
- {!hideErrorMessage && error?.message && <FormHelperText>{error.message}</FormHelperText>}
132
- </FormControl>
133
- );
134
- };
135
-
136
- export default ControlRadio;
@@ -1,164 +0,0 @@
1
- import TextField, { TextFieldProps } from '@mui/material/TextField';
2
- import MenuItem from '@mui/material/MenuItem';
3
- import ClearIcon from '@mui/icons-material/Clear';
4
-
5
- import { useCallback } from 'react';
6
- import { useController, Control, useWatch } from 'react-hook-form';
7
- import { ValidateFunc } from '../../interfaces';
8
- import IconButton from '@mui/material/IconButton';
9
- import InputAdornment from '@mui/material/InputAdornment';
10
-
11
- /**
12
- * This interface is referencing the [[ControlSelect]] component props.
13
- * @category Forms
14
- */
15
- export type ControlSelectProps = TextFieldProps & {
16
- /**
17
- * React Hook Form control `name` propery
18
- */
19
- name: string;
20
- /**
21
- * Label for MUI TextField select component
22
- */
23
- label?: string;
24
- /**
25
- * React Hook Form `control`
26
- */
27
- control: Control<any>;
28
- /**
29
- * Is input required flag
30
- */
31
- required?: boolean;
32
- /**
33
- * React Hook Form `defaultValue`
34
- */
35
- defaultValue?: unknown;
36
- /**
37
- * Is disabled input flag
38
- */
39
- disabled?: boolean;
40
- /**
41
- * React Hook Form validate function
42
- * ```typescript
43
- * type ValidateFunc = (value: string) => boolean | string;
44
- * ```
45
- */
46
- validate?: ValidateFunc | Record<string, ValidateFunc>;
47
- /**
48
- * Hide error message flag
49
- */
50
- hideErrorMessage?: boolean;
51
- /**
52
- * Custom onChange functionƒ
53
- */
54
- onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
55
- /**
56
- * Key for option label
57
- */
58
- labelKey?: string;
59
- /**
60
- * Key for option value
61
- */
62
- valueKey?: string;
63
- /**
64
- * Select options
65
- */
66
- options: string[] | unknown[];
67
- };
68
-
69
- /**
70
- * Material UI `Select` controlled component. Used with react-hook-form
71
- * @category Forms
72
- */
73
- export const ControlSelect = ({
74
- control,
75
- validate,
76
- name = '',
77
- label = '',
78
- required = false,
79
- defaultValue = '',
80
- disabled = false,
81
- hideErrorMessage = false,
82
- onChange: customOnChange,
83
- labelKey,
84
- valueKey,
85
- options = [],
86
- ...textFieldProps
87
- }: ControlSelectProps) => {
88
- const {
89
- field: { ref, onChange },
90
- fieldState: { error },
91
- } = useController({
92
- name,
93
- control,
94
- defaultValue,
95
- rules: {
96
- required: required && 'Please, fill this field',
97
- validate,
98
- },
99
- });
100
- const value = useWatch({ control, name });
101
-
102
- const getValue = useCallback(
103
- (option) => {
104
- if (typeof option === 'string') return option;
105
- return valueKey ? option[valueKey] : option.value;
106
- },
107
- [valueKey]
108
- );
109
- const getLabel = useCallback(
110
- (option) => {
111
- if (typeof option === 'string') return option;
112
- return labelKey ? option[labelKey] : option.label;
113
- },
114
- [labelKey]
115
- );
116
-
117
- const handleClear = useCallback(() => {
118
- if (customOnChange) {
119
- customOnChange(null);
120
- } else onChange(null);
121
- }, [onChange, customOnChange]);
122
-
123
- return (
124
- <TextField
125
- select
126
- fullWidth
127
- size="small"
128
- variant="outlined"
129
- type="text"
130
- inputRef={ref}
131
- name={name}
132
- label={label}
133
- error={!!error}
134
- helperText={!hideErrorMessage && error?.message}
135
- disabled={disabled}
136
- value={value ?? ''}
137
- onChange={customOnChange ? customOnChange : onChange}
138
- {...textFieldProps}
139
- inputProps={{
140
- ...(textFieldProps?.inputProps ?? {}),
141
- value: value ?? '',
142
- }}
143
- InputProps={{
144
- endAdornment:
145
- !required && value ? (
146
- <InputAdornment position="end" sx={{ mr: 2 }}>
147
- <IconButton onClick={handleClear} size="small">
148
- <ClearIcon fontSize="small" />
149
- </IconButton>
150
- </InputAdornment>
151
- ) : null,
152
- ...textFieldProps?.InputProps,
153
- }}
154
- >
155
- {options.map((option, index) => (
156
- <MenuItem key={index} value={getValue(option)}>
157
- {getLabel(option)}
158
- </MenuItem>
159
- ))}
160
- </TextField>
161
- );
162
- };
163
-
164
- export default ControlSelect;
@@ -1,71 +0,0 @@
1
- import Switch, { SwitchProps } from '@mui/material/Switch';
2
- import FormControlLabel from '@mui/material/FormControlLabel';
3
- import { Control, useController, useWatch } from 'react-hook-form';
4
- import { useEffect, useMemo } from 'react';
5
-
6
- type Props = SwitchProps & {
7
- /**
8
- * React Hook Form `control`
9
- */
10
- control: Control<any>;
11
- /**
12
- * React Hook Form control `name` propery
13
- */
14
- name: string;
15
- /**
16
- * Material-UI FormControlLabel `label` prop
17
- */
18
- label?: string;
19
- };
20
-
21
- export const ControlSwitch = ({ control, name, label, ...switchProps }: Props) => {
22
- const {
23
- field: { ref, onChange },
24
- } = useController({ control, name });
25
- const value = useWatch({ control, name });
26
-
27
- const checked = useMemo(() => {
28
- if (typeof value === 'boolean') {
29
- return value;
30
- } else if (typeof value === 'string') {
31
- if (value === 'false') {
32
- onChange(false);
33
- return false;
34
- } else if (value === 'true') {
35
- onChange(true);
36
- return true;
37
- }
38
- }
39
- return false;
40
- }, [value, onChange]);
41
-
42
- useEffect(() => {
43
- if (value === null) {
44
- onChange(false);
45
- }
46
- }, [value, onChange]);
47
-
48
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
49
- const { checked } = event.target;
50
- onChange(checked);
51
- };
52
-
53
- return (
54
- <FormControlLabel
55
- label={label}
56
- name={name}
57
- control={
58
- <Switch
59
- color="primary"
60
- size="small"
61
- inputRef={ref}
62
- onChange={handleChange}
63
- checked={checked}
64
- {...switchProps}
65
- />
66
- }
67
- />
68
- );
69
- };
70
-
71
- export default ControlSwitch;
@@ -1,93 +0,0 @@
1
- import TextField from '@mui/material/TextField';
2
- import { TimePicker } from '@mui/x-date-pickers/TimePicker';
3
-
4
- import { parse, format as dateFnsFormat, isMatch, isValid } from 'date-fns';
5
- import { useEffect, useState } from 'react';
6
- import { Control, useController, useWatch } from 'react-hook-form';
7
- import { TIME_DEFAULT_FORMAT } from '../../interfaces';
8
-
9
- type Props = {
10
- /**
11
- * React Hook Form `control`
12
- */
13
- control: Control<any>;
14
- /**
15
- * Is input required flag
16
- */
17
- required?: boolean;
18
- name: string;
19
- label?: string;
20
- format?: string;
21
- hideErrorMessage?: boolean;
22
- };
23
-
24
- export const ControlTime = ({
25
- control,
26
- name,
27
- required,
28
- label,
29
- format = TIME_DEFAULT_FORMAT,
30
- hideErrorMessage = false,
31
- }: Props) => {
32
- const {
33
- field: { onChange, ref },
34
- fieldState: { error },
35
- } = useController({
36
- control,
37
- name,
38
- rules: {
39
- required: required && 'Please, fill this field',
40
- validate: (val) => {
41
- if (isMatch(val, format)) {
42
- return true;
43
- }
44
- return 'Incorrect date format';
45
- },
46
- },
47
- });
48
- const value = useWatch({ control, name });
49
-
50
- const [fieldValue, setFieldValue] = useState(null);
51
-
52
- const handleChange = (date: Date) => {
53
- setFieldValue(date);
54
- onChange(isValid(date) ? dateFnsFormat(date, format) : date);
55
- };
56
-
57
- useEffect(() => {
58
- if (value && format) {
59
- let parsedValue = parse(value, format, new Date());
60
-
61
- if (!isValid(parsedValue)) {
62
- parsedValue = parse(value, 'HH:mm:ss.SSS', new Date());
63
- }
64
-
65
- setFieldValue(parsedValue);
66
- }
67
- }, [value, format]);
68
-
69
- return (
70
- <TimePicker
71
- mask=""
72
- inputRef={ref}
73
- label={label}
74
- ampm={false}
75
- value={fieldValue}
76
- inputFormat={format}
77
- onChange={handleChange}
78
- renderInput={(props) => (
79
- <TextField
80
- {...props}
81
- fullWidth
82
- size="small"
83
- variant="outlined"
84
- name={name}
85
- error={!!error}
86
- helperText={!hideErrorMessage && error?.message}
87
- />
88
- )}
89
- />
90
- );
91
- };
92
-
93
- export default ControlTime;
@@ -1,46 +0,0 @@
1
- import { useState } from 'react';
2
- // import FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined';
3
- import Tooltip from '@mui/material/Tooltip';
4
- import IconButton from '@mui/material/IconButton';
5
- import SvgIcon from '@mui/material/SvgIcon';
6
- /**
7
- * This interface is referencing the [[CopyButton]] component props.
8
- * @category Forms
9
- */
10
- export interface CopyButtonProps {
11
- /**
12
- * Text to copy
13
- */
14
- copyText: string;
15
- /**
16
- * Tooltip help text
17
- */
18
- helpText?: string;
19
- }
20
-
21
- /**
22
- * Copy value button
23
- * @category Forms
24
- */
25
- export const CopyButton = ({ copyText, helpText = 'Copy' }: CopyButtonProps) => {
26
- const [tooltipText, setTooltipText] = useState(helpText);
27
-
28
- const onCopy = () => {
29
- navigator.clipboard.writeText(copyText);
30
- setTooltipText('Copied!');
31
-
32
- setTimeout(() => {
33
- setTooltipText(helpText);
34
- }, 1000);
35
- };
36
-
37
- return tooltipText ? (
38
- <Tooltip title={tooltipText} placement="top">
39
- <IconButton onClick={onCopy}>
40
- <SvgIcon fontSize="small">
41
- <path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4 6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"></path>
42
- </SvgIcon>
43
- </IconButton>
44
- </Tooltip>
45
- ) : null;
46
- };