@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,69 +0,0 @@
1
- import TextField from '@material-ui/core/TextField';
2
- import { useCallback, useMemo, useState } from 'react';
3
- import { Controller, useFormContext } from 'react-hook-form';
4
- import { ControlInputProps } from './ControlInput';
5
- import { useDebounce } from '../../utils';
6
-
7
- export const ControlDebouncedInput = ({
8
- inputProps,
9
- name,
10
- required,
11
- validate,
12
- label = '',
13
- variant = 'outlined',
14
- type = 'text',
15
- defaultValue = '',
16
- disabled,
17
- InputLabelProps,
18
- textarea,
19
- }: ControlInputProps) => {
20
- const { setValue, control, getValues } = useFormContext();
21
- const [fieldValue, setFieldValue] = useState('');
22
-
23
- const debouncedChange = useDebounce((e) => {
24
- setValue(name, e.target.value);
25
- }, 350);
26
-
27
- useMemo(() => {
28
- const value = getValues(name);
29
- setFieldValue(value);
30
- }, [getValues, name]);
31
-
32
- const handleChange = useCallback((e) => {
33
- setFieldValue(e.target.value);
34
- debouncedChange(e);
35
- }, [debouncedChange]);
36
-
37
-
38
-
39
- return (
40
- <Controller
41
- name={name}
42
- control={control}
43
- defaultValue={defaultValue}
44
- rules={{ required: required && 'Required field', validate }}
45
- render={({ field: { ref, value, ...restProps }, fieldState: { error } }) => (
46
- <TextField
47
- fullWidth
48
- size="small"
49
- inputRef={ref}
50
- type={type}
51
- label={label}
52
- error={!!error}
53
- helperText={error?.message}
54
- disabled={disabled}
55
- variant={variant}
56
- InputLabelProps={InputLabelProps}
57
- inputProps={inputProps}
58
- multiline={textarea}
59
- minRows={textarea ? 3 : 1}
60
- {...restProps}
61
- onChange={handleChange}
62
- value={fieldValue}
63
- />
64
- )}
65
- />
66
- );
67
- };
68
-
69
- export default ControlDebouncedInput;
@@ -1,102 +0,0 @@
1
- import { useController, Control } from 'react-hook-form';
2
- import TextField from '@material-ui/core/TextField';
3
-
4
- type ValidateFunc = (value: string) => boolean | string;
5
- type onChangeCallback = (e: any) => void;
6
-
7
- /**
8
- * This interface is referencing the [[ControlInput]] component props.
9
- * @category Forms
10
- */
11
- export interface ControlInputProps {
12
- /**
13
- * Props for MUI TextField component
14
- */
15
- inputProps?: Record<string, string | number | boolean | onChangeCallback | { [key: string]: any }>;
16
- /**
17
- * React Hook Form control `name` propery
18
- */
19
- name: string;
20
- label?: string;
21
- type?: 'text' | 'date' | 'password' | 'search' | 'number' | 'email' | 'datetime-local';
22
- /**
23
- * React Hook Form `control`
24
- */
25
- control: Control<any>;
26
- /**
27
- * Is input required flag
28
- */
29
- required?: boolean;
30
- defaultValue?: any;
31
- /**
32
- * Is disabled input flag
33
- */
34
- disabled?: boolean;
35
- /**
36
- * Material-UI TextField `variant` prop
37
- */
38
- variant?: 'filled' | 'outlined' | 'standard';
39
- /**
40
- * React Hook Form validate function
41
- * ```typescript
42
- * type ValidateFunc = (value: string) => boolean | string;
43
- * ```
44
- */
45
- validate?: ValidateFunc | Record<string, ValidateFunc>;
46
- InputLabelProps?: any;
47
- textarea?: boolean;
48
- }
49
-
50
- /**
51
- * Material UI `TextField` controlled component. Used with react-hook-form
52
- * @category Forms
53
- */
54
- export const ControlInput = ({
55
- inputProps,
56
- name,
57
- control,
58
- required,
59
- validate,
60
- label = '',
61
- variant = 'outlined',
62
- type = 'text',
63
- defaultValue = '',
64
- disabled,
65
- InputLabelProps,
66
- textarea,
67
- }: ControlInputProps) => {
68
- const {
69
- field: { ref, value, ...restProps },
70
- fieldState: { error },
71
- } = useController({
72
- name,
73
- control,
74
- defaultValue,
75
- rules: {
76
- required: required && 'Required field',
77
- validate,
78
- },
79
- });
80
-
81
- return (
82
- <TextField
83
- fullWidth
84
- size="small"
85
- inputRef={ref}
86
- type={type}
87
- label={label}
88
- error={!!error}
89
- helperText={error?.message}
90
- disabled={disabled}
91
- variant={variant}
92
- InputLabelProps={InputLabelProps}
93
- inputProps={inputProps}
94
- multiline={textarea}
95
- minRows={textarea ? 3 : 1}
96
- value={value || ''}
97
- {...restProps}
98
- />
99
- );
100
- };
101
-
102
- export default ControlInput;
@@ -1,144 +0,0 @@
1
- import { PropertyType } from '../../interfaces';
2
- import TextField from '@material-ui/core/TextField';
3
- import { useCallback } from 'react';
4
- import { useController, Control, useFormContext } from 'react-hook-form';
5
- import { validateFloat, validateInteger } from '../../utils';
6
-
7
- type onChangeCallback = (e: any) => void;
8
-
9
- type Props = {
10
- /**
11
- * Props for MUI TextField component
12
- */
13
- inputProps?: Record<string, string | number | boolean | onChangeCallback | { [key: string]: any }>;
14
- /**
15
- * React Hook Form control `name` propery
16
- */
17
- name: string;
18
- label?: string;
19
- /**
20
- * React Hook Form `control`
21
- */
22
- control: Control<any>;
23
- /**
24
- * Is input required flag
25
- */
26
- required?: boolean;
27
- defaultValue?: number;
28
- /**
29
- * Is disabled input flag
30
- */
31
- disabled?: boolean;
32
- /**
33
- * Material-UI TextField `variant` prop
34
- */
35
- variant?: 'filled' | 'outlined' | 'standard';
36
- /**
37
- * React Hook Form validate function
38
- * ```typescript
39
- * type ValidateFunc = (value: string) => boolean | string;
40
- * ```
41
- */
42
- InputLabelProps?: any;
43
- decimal?: boolean;
44
- };
45
-
46
- export const ControlNumberInput = ({
47
- inputProps,
48
- name,
49
- label = '',
50
- control,
51
- required,
52
- defaultValue,
53
- disabled,
54
- variant = 'outlined',
55
- InputLabelProps,
56
- decimal = false,
57
- }: Props) => {
58
- const { setError, clearErrors } = useFormContext();
59
- const {
60
- field: { ref, onChange, value, ...restProps },
61
- fieldState: { error },
62
- } = useController({
63
- name,
64
- control,
65
- defaultValue,
66
- rules: {
67
- required: required && 'Required field',
68
- },
69
- });
70
-
71
- const handleChange = useCallback(
72
- (e) => {
73
- let { value: inputValue } = e.target;
74
-
75
- if (inputValue.length >= 2 && inputValue.startsWith('0')) {
76
- inputValue = inputValue.slice(1);
77
- }
78
-
79
- if (inputValue.length >= 2 && inputValue.startsWith('-') && inputValue[1] === '0') {
80
- inputValue = '-' + inputValue.slice(2);
81
- }
82
-
83
- if (!inputValue || (inputValue.length < 2 && inputValue[0] === '-')) {
84
- onChange(inputValue);
85
- return;
86
- }
87
-
88
- if (decimal) {
89
- const { valid, continuable, message, displayOnChange } = validateFloat(inputValue);
90
-
91
- if (continuable) {
92
- onChange(inputValue);
93
- }
94
-
95
- if (!valid && displayOnChange && message) {
96
- setError(name, { type: 'custom', message });
97
- } else {
98
- clearErrors(name);
99
- }
100
-
101
- if (valid) {
102
- onChange(Number(inputValue));
103
- }
104
- } else {
105
- const { valid, continuable, message } = validateInteger(inputValue, PropertyType.INTEGER);
106
-
107
- if (continuable) {
108
- onChange(inputValue);
109
- }
110
-
111
- if (!valid && message) {
112
- setError(name, { type: 'custom', message });
113
- } else {
114
- clearErrors(name);
115
- }
116
-
117
- if (valid) {
118
- onChange(Number(inputValue));
119
- }
120
- }
121
- },
122
- [decimal]
123
- );
124
-
125
- return (
126
- <TextField
127
- fullWidth
128
- size="small"
129
- inputRef={ref}
130
- label={label}
131
- error={!!error}
132
- helperText={error?.message}
133
- disabled={disabled}
134
- variant={variant}
135
- InputLabelProps={InputLabelProps}
136
- inputProps={inputProps}
137
- onChange={handleChange}
138
- value={value || ''}
139
- {...restProps}
140
- />
141
- );
142
- };
143
-
144
- export default ControlNumberInput;
@@ -1,46 +0,0 @@
1
- import FormControlLabel from '@material-ui/core/FormControlLabel';
2
- import Radio from '@material-ui/core/Radio';
3
- import RadioGroup from '@material-ui/core/RadioGroup';
4
- import { Controller, Control } from 'react-hook-form';
5
-
6
- /**
7
- * This interface is referencing the [[ControlRadioBtn]] component props.
8
- * @category Forms
9
- */
10
- export interface ControlRadioBtnProps {
11
- /**
12
- * React Hook Form `control`
13
- */
14
- control: Control<any>;
15
- /**
16
- * React Hook Form control `name` propery
17
- */
18
- name: string;
19
- /**
20
- * Radio group values
21
- */
22
- values: any[];
23
- }
24
-
25
- /**
26
- * Material UI `Radio` controlled component. Used with react-hook-form
27
- * @category Forms
28
- */
29
- export const ControlRadioBtn = ({ name, values, control }: ControlRadioBtnProps) => {
30
-
31
- return (
32
- <Controller
33
- control={control}
34
- name={name}
35
- render={({ field }) => (
36
- <RadioGroup row {...field}>
37
- {values.map((item) => (
38
- <FormControlLabel value={item} control={<Radio />} label={item} />
39
- ))}
40
- </RadioGroup>
41
- )}
42
- />
43
- )
44
- }
45
-
46
- export default ControlRadioBtn;
@@ -1,135 +0,0 @@
1
- import { useCallback } from 'react';
2
- import { useController, Control } from 'react-hook-form';
3
- import TextField from '@material-ui/core/TextField';
4
- import MenuItem from '@material-ui/core/MenuItem';
5
-
6
- type ValidateFunc = (value: string) => boolean | string;
7
-
8
- type onChangeCallback = (e: any) => void;
9
-
10
- /**
11
- * This interface is referencing the [[ControlSelect]] component props.
12
- * @category Forms
13
- */
14
- export interface ControlSelectProps {
15
- /**
16
- * Props for MUI TextField component
17
- */
18
- inputProps?: Record<string, string | number | boolean | onChangeCallback | { [key: string]: any }>;
19
- /**
20
- * Props for MUI SelectProps component
21
- */
22
- selectProps?: Record<string, string | number | boolean | onChangeCallback | { [key: string]: any }>;
23
- /**
24
- * React Hook Form control `name` propery
25
- */
26
- name: string;
27
- /**
28
- * React Hook Form `control`
29
- */
30
- control: Control<any>;
31
- defaultValue?: any;
32
- /**
33
- * Is field required flag
34
- */
35
- required?: boolean;
36
- /**
37
- * Select options
38
- */
39
- options: any[];
40
- /**
41
- * Key for option label
42
- */
43
- labelKey?: string;
44
- /**
45
- * Key for option value
46
- */
47
- valueKey?: string;
48
- /**
49
- * Material-UI TextField `variant` prop
50
- */
51
- variant?: 'filled' | 'outlined' | 'standard';
52
- /**
53
- * React Hook Form validate function
54
- * ```typescript
55
- * type ValidateFunc = (value: string) => boolean | string;
56
- * ```
57
- */
58
- validate?: ValidateFunc | Record<string, ValidateFunc>;
59
- label?: string;
60
- disabled?: boolean;
61
- }
62
-
63
- /**
64
- * Material UI `Select` controlled component. Used with react-hook-form
65
- * @category Forms
66
- */
67
- export const ControlSelect = ({
68
- inputProps,
69
- selectProps,
70
- name,
71
- control,
72
- required,
73
- defaultValue,
74
- options,
75
- variant = 'outlined',
76
- validate,
77
- labelKey,
78
- valueKey,
79
- label = '',
80
- disabled = false,
81
- }: ControlSelectProps) => {
82
- const {
83
- field: { ref, value, ...restProps },
84
- fieldState: { error },
85
- } = useController({
86
- name,
87
- defaultValue,
88
- control,
89
- rules: {
90
- required: required && 'Required field',
91
- validate,
92
- },
93
- });
94
- const getValue = useCallback(
95
- (item) => {
96
- if (typeof item === 'string') return item;
97
- return valueKey ? item[valueKey] : item.value;
98
- },
99
- [valueKey]
100
- );
101
- const getLabel = useCallback(
102
- (item) => {
103
- if (typeof item === 'string') return item;
104
- return labelKey ? item[labelKey] : item.label;
105
- },
106
- [labelKey]
107
- );
108
-
109
- return (
110
- <TextField
111
- size="small"
112
- select
113
- fullWidth
114
- error={!!error}
115
- inputRef={ref}
116
- ref={ref}
117
- helperText={error?.message}
118
- SelectProps={selectProps}
119
- variant={variant}
120
- label={label}
121
- disabled={disabled}
122
- inputProps={{ ...inputProps }}
123
- value={value || ''}
124
- {...restProps}
125
- >
126
- {options?.map((el) => (
127
- <MenuItem key={getValue(el)} value={getValue(el)}>
128
- {getLabel(el)}
129
- </MenuItem>
130
- ))}
131
- </TextField>
132
- );
133
- };
134
-
135
- export default ControlSelect;
@@ -1,49 +0,0 @@
1
- import { useState, Fragment } from 'react';
2
- import FileCopyOutlinedIcon from '@material-ui/icons/FileCopyOutlined';
3
- import Tooltip from '@material-ui/core/Tooltip';
4
- import IconButton from '@material-ui/core/IconButton';
5
-
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 (
38
- tooltipText ? (
39
- <Tooltip title={tooltipText} placement="top">
40
- <IconButton onClick={onCopy}>
41
- <FileCopyOutlinedIcon fontSize="small" />
42
- </IconButton>
43
- </Tooltip>
44
- ) : null
45
-
46
- );
47
- };
48
-
49
- export default CopyButton;
@@ -1,39 +0,0 @@
1
- import AceEditor from 'react-ace';
2
- import useStyles from './styles';
3
- import 'ace-builds/src-noconflict/ace';
4
- import 'ace-builds/src-noconflict/mode-json';
5
-
6
- type Props = {
7
- title: string;
8
- text?: string;
9
- json?: any;
10
- };
11
-
12
- export const InfoItem = ({ title, text, json }: Props) => {
13
- const classes = useStyles();
14
-
15
- return (
16
- <div className={classes.container}>
17
- <div className={classes.title}>{title}</div>
18
- {text && <div className={classes.text}>{text}</div>}
19
- {json && (
20
- <AceEditor
21
- readOnly
22
- value={json}
23
- mode="json"
24
- height="300px"
25
- width="100%"
26
- fontSize="16"
27
- setOptions={{
28
- enableSnippets: false,
29
- copyWithEmptySelection: true,
30
- showLineNumbers: true,
31
- tabSize: 2,
32
- }}
33
- />
34
- )}
35
- </div>
36
- );
37
- };
38
-
39
- export default InfoItem;
@@ -1,17 +0,0 @@
1
- import { makeStyles } from '@material-ui/core/styles';
2
-
3
- export default makeStyles(() => ({
4
- container: {
5
- borderBottom: '1px solid #ccc',
6
- paddingBottom: '8px',
7
- },
8
- title: {
9
- fontSize: '14px',
10
- fontWeight: 600,
11
- color: '#536DFE',
12
- },
13
- text: {
14
- fontSize: '18px',
15
- wordWrap: 'break-word',
16
- },
17
- }));
@@ -1,71 +0,0 @@
1
- import Button from '@material-ui/core/Button';
2
- import Dialog from '@material-ui/core/Dialog';
3
- import DialogTitle from '@material-ui/core/DialogTitle';
4
- import DialogContent from '@material-ui/core/DialogContent';
5
- import DialogActions from '@material-ui/core/DialogActions';
6
- import Typography from '@material-ui/core/Typography';
7
- import PropertyStep from './PropertyStep';
8
-
9
- import { useState } from 'react';
10
- import { toast } from 'react-toastify';
11
- import { JsonPathPickerProperties } from '../../interfaces';
12
-
13
- type Props = {
14
- properties: JsonPathPickerProperties;
15
- open: boolean;
16
- onClose: () => void;
17
- onPaste: (path: string) => void;
18
- };
19
-
20
- export const JsonPathPicker = ({ open = false, onClose, onPaste, properties }: Props) => {
21
- const [selectedPropertyPath, setSelectedPropertyPath] = useState<string>('');
22
-
23
- const onCopy = () => {
24
- navigator.clipboard.writeText(`$(${selectedPropertyPath})`);
25
- toast.success('Copied!');
26
- };
27
-
28
- const handlePaste = () => {
29
- toast.success('Pasted!');
30
- onPaste(`$(${selectedPropertyPath})`);
31
- };
32
-
33
- return (
34
- <Dialog open={open} onClose={onClose} fullWidth maxWidth="md">
35
- <DialogTitle>JSON path picker</DialogTitle>
36
- <DialogContent>
37
- <Typography variant="h6" gutterBottom>
38
- Path : $({selectedPropertyPath})
39
- </Typography>
40
- {properties?.length ? (
41
- properties.map((propEl, index) => (
42
- <div key={index}>
43
- <Typography variant="h6">{propEl.title}</Typography>
44
- <PropertyStep
45
- properties={propEl.properties}
46
- prefix={propEl.pathPrefix}
47
- onClick={setSelectedPropertyPath}
48
- activePath={selectedPropertyPath}
49
- />
50
- </div>
51
- ))
52
- ) : (
53
- <Typography>Please, add properties</Typography>
54
- )}
55
- </DialogContent>
56
- <DialogActions>
57
- <Button variant="contained" color="primary" onClick={onCopy}>
58
- Copy
59
- </Button>
60
- <Button variant="contained" color="primary" onClick={handlePaste}>
61
- Paste
62
- </Button>
63
- <Button variant="contained" color="secondary" onClick={onClose}>
64
- Close
65
- </Button>
66
- </DialogActions>
67
- </Dialog>
68
- );
69
- };
70
-
71
- export default JsonPathPicker;