@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,52 +0,0 @@
1
- import Box from '@material-ui/core/Box';
2
- import Typography from '@material-ui/core/Typography';
3
- import Accordion from '@material-ui/core/Accordion';
4
- import AccordionSummary from '@material-ui/core/AccordionSummary';
5
- import AccordionDetails from '@material-ui/core/AccordionDetails';
6
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
7
- import PropertyDataTable from './PropertyDataTable';
8
- import EntityPropertiesView from './EntityPropertiesView';
9
-
10
- import { useEffect, useState } from 'react';
11
- import { propertiesObjectToArray } from '../../../utils';
12
- import { PropertiesObjectType, PropertyType, PropertyUnion } from '../../../interfaces';
13
-
14
- type Props = {
15
- property: PropertyUnion;
16
- parentNames?: string[];
17
- defaultExpanded?: boolean;
18
- };
19
-
20
- export const ViewProperty = ({ property, parentNames = [], defaultExpanded = true }: Props) => {
21
- const [expanded, setExpanded] = useState(true);
22
-
23
- useEffect(() => {
24
- setExpanded(defaultExpanded);
25
- }, [defaultExpanded]);
26
-
27
- return (
28
- <Accordion
29
- elevation={3}
30
- style={{ backgroundColor: parentNames.length % 2 === 1 ? '#f1f1f1' : '#fff' }}
31
- expanded={expanded}
32
- onChange={() => setExpanded((prevState) => !prevState)}
33
- >
34
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
35
- <Typography style={{ wordBreak: 'break-word', fontWeight: '600' }}>{property.name}</Typography>
36
- </AccordionSummary>
37
- <AccordionDetails>
38
- <Box width="100%">
39
- <PropertyDataTable property={property} />
40
- {property.propertyType === PropertyType.ENTITY && (
41
- <EntityPropertiesView
42
- properties={propertiesObjectToArray(property.properties as PropertiesObjectType)}
43
- parentNames={[...parentNames, property.name]}
44
- />
45
- )}
46
- </Box>
47
- </AccordionDetails>
48
- </Accordion>
49
- );
50
- };
51
-
52
- export default ViewProperty;
@@ -1,15 +0,0 @@
1
- import useStyles from './styles';
2
- import cn from 'classnames';
3
-
4
- type Props = {
5
- text: string;
6
- status?: 'default' | 'success';
7
- };
8
-
9
- export const Status = ({ text, status = 'default' }: Props) => {
10
- const classes = useStyles();
11
-
12
- return <div className={cn(classes.root, { [status]: true })}>{text}</div>;
13
- };
14
-
15
- export default Status;
@@ -1,14 +0,0 @@
1
- import { makeStyles } from '@material-ui/core';
2
-
3
- export default makeStyles({
4
- root: {
5
- backgroundColor: '#eee',
6
- fontSize: '14px',
7
- padding: '0 4px',
8
- borderRadius: '10px',
9
-
10
- '&.success': {
11
- backgroundColor: '#a9dfa9',
12
- },
13
- },
14
- });
@@ -1,116 +0,0 @@
1
- import React from 'react';
2
- import TablePagination from './TablePagination';
3
- import TableColumnMenu from './TableColumnMenu';
4
-
5
- import useTableQueryPagination from './useTableQueryPagination';
6
- import useTableQuerySorting from './useTableQuerySorting';
7
- import usePagination from './usePagination';
8
- import { DataGrid, GridCellParams, GridColumns, GridFeatureMode, GridRowsProp } from '@mui/x-data-grid';
9
- import useStyles from './styles';
10
- import Box from '@material-ui/core/Box';
11
-
12
- /**
13
- * This interface is referencing the [[Table]] component props.
14
- * @category Common UI components
15
- */
16
- export interface TableProps {
17
- /**
18
- * Data loading state
19
- */
20
- loading?: boolean;
21
- /**
22
- * Table columns
23
- */
24
- columns: GridColumns;
25
- /**
26
- * Table rows
27
- */
28
- rows: GridRowsProp;
29
- /**
30
- * Rows count to display
31
- */
32
- rowCount: number;
33
- disableMargin?: boolean;
34
- /**
35
- * Data display mode.
36
- * Values: `client` | `server`;
37
- * Default: `server`
38
- */
39
- mode?: GridFeatureMode;
40
- /**
41
- * Page size. Default `10`
42
- */
43
- initialPageSize?: number;
44
- /**
45
- * On cell click handler function
46
- * ```typescript
47
- * (params: GridCellParams, event: React.MouseEvent) => void;
48
- * ```
49
- */
50
- onCellClick?: (params: GridCellParams, event: React.MouseEvent) => void;
51
- pagination?: boolean;
52
- }
53
-
54
- /**
55
- * Main data display component. MUI DataGrid used
56
- * @category Common UI components
57
- */
58
- export const Table = ({
59
- columns,
60
- rows,
61
- rowCount,
62
- loading,
63
- disableMargin,
64
- mode = 'server',
65
- initialPageSize = 10,
66
- pagination = true,
67
- onCellClick,
68
- }: TableProps) => {
69
- const classes = useStyles();
70
-
71
- const { page, size, onPageChange, onSizeChange } = useTableQueryPagination({ mode });
72
- const { onColumnHeaderClick, getSortedColumns } = useTableQuerySorting();
73
-
74
- const { pageSize, handlePageSizeChange } = usePagination(initialPageSize);
75
-
76
- const tableProps = {
77
- sortingMode: mode,
78
- paginationMode: mode,
79
- pageSize: mode === 'server' ? size : pagination ? pageSize : rowCount,
80
- onPageSizeChange: mode === 'server' ? onSizeChange : handlePageSizeChange,
81
- components: {
82
- Pagination: TablePagination,
83
- },
84
- };
85
-
86
- if (mode === 'server') {
87
- tableProps['sortModel'] = [];
88
- tableProps['onColumnHeaderClick'] = onColumnHeaderClick;
89
- tableProps['page'] = page;
90
- tableProps['onPageChange'] = onPageChange;
91
- tableProps.components['ColumnMenu'] = TableColumnMenu;
92
- }
93
-
94
- return (
95
- <Box mt={disableMargin ? 0 : 2}>
96
- <DataGrid
97
- autoHeight
98
- hideFooterPagination={!pagination}
99
- hideFooter={!pagination}
100
- disableSelectionOnClick
101
- showColumnRightBorder
102
- showCellRightBorder
103
- className={classes.root}
104
- loading={loading}
105
- rows={rows}
106
- columns={getSortedColumns(columns)}
107
- rowCount={rowCount}
108
- rowsPerPageOptions={[10, 20, 50, 100]}
109
- onCellClick={onCellClick}
110
- {...tableProps}
111
- />
112
- </Box>
113
- );
114
- };
115
-
116
- export default Table;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { GridColumnMenuContainer, GridFilterMenuItem } from '@mui/x-data-grid';
3
-
4
- const TableColumnMenu = ({ hideMenu, currentColumn, onUnsort, ...rest }: any) => {
5
- return (
6
- <GridColumnMenuContainer hideMenu={hideMenu} currentColumn={currentColumn} {...rest}>
7
- <GridFilterMenuItem onClick={hideMenu} column={currentColumn} />
8
- </GridColumnMenuContainer>
9
- );
10
- };
11
-
12
- export default TableColumnMenu;
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import Box from '@material-ui/core/Box';
3
- import Pagination from '@material-ui/lab/Pagination';
4
- import MuiTablePagination from '@material-ui/core/TablePagination';
5
- import {
6
- gridPageCountSelector,
7
- gridPageSelector,
8
- gridRowCountSelector,
9
- gridPageSizeSelector,
10
- useGridApiContext,
11
- useGridSelector,
12
- } from '@mui/x-data-grid';
13
-
14
- const TablePagination = () => {
15
- const apiRef = useGridApiContext();
16
- const page = useGridSelector(apiRef, gridPageSelector);
17
- const pageCount = useGridSelector(apiRef, gridPageCountSelector);
18
- const rowCount = useGridSelector(apiRef, gridRowCountSelector);
19
- const pageSize = useGridSelector(apiRef, gridPageSizeSelector);
20
-
21
- const onPageChange = (value) => apiRef.current.setPage(value);
22
- const onRowsPerPageChange = (event: React.ChangeEvent<HTMLInputElement>) =>
23
- apiRef.current.setPageSize(parseInt(event.target.value, 10));
24
-
25
- return (
26
- <Box px={2} display="flex" alignItems="center">
27
- <MuiTablePagination
28
- component="div"
29
- page={page}
30
- count={rowCount}
31
- rowsPerPage={pageSize}
32
- rowsPerPageOptions={[10, 20, 50, 100]}
33
- onPageChange={(event, value) => onPageChange(value)}
34
- onRowsPerPageChange={onRowsPerPageChange}
35
- ActionsComponent={() => <></>}
36
- />
37
- <Pagination count={pageCount} page={page + 1} onChange={(event, value) => onPageChange(value - 1)} />
38
- </Box>
39
- );
40
- };
41
-
42
- export default TablePagination;
@@ -1 +0,0 @@
1
- export * from './Table';
@@ -1,59 +0,0 @@
1
- import { makeStyles } from '@material-ui/core/styles';
2
-
3
- export default makeStyles({
4
- root: {
5
- width: '100%',
6
-
7
- '& .MuiDataGrid-virtualScrollerContent': {
8
- height: 'auto !important',
9
- minHeight: '56px !important',
10
- },
11
-
12
- '& .MuiDataGrid-virtualScrollerRenderZone': {
13
- position: 'static',
14
- },
15
-
16
- '& .MuiDataGrid-renderingZone': {
17
- maxHeight: 'none !important',
18
- },
19
-
20
- '& .MuiDataGrid-cell': {
21
- maxHeight: 'none !important',
22
- lineHeight: 'unset !important',
23
- whiteSpace: 'normal !important',
24
- textOverflow: 'ellipsis',
25
- wordBreak: 'break-all',
26
-
27
- '& .MuiDataGrid-actionsCell': {
28
- width: '100%',
29
- gridGap: '4px',
30
- flexWrap: 'wrap',
31
-
32
- '& > button[aria-label="more"]': {
33
- marginLeft: 'auto',
34
- },
35
- },
36
- },
37
-
38
- '& .MuiDataGrid-row': {
39
- maxHeight: 'none !important',
40
- },
41
-
42
- '& .Sorted': {
43
- '& .MuiDataGrid-iconButtonContainer': {
44
- visibility: 'visible',
45
- width: 'auto',
46
-
47
- '& svg': {
48
- opacity: '1 !important',
49
- },
50
- },
51
-
52
- '&.--desc': {
53
- '& svg': {
54
- transform: 'rotate(180deg)',
55
- },
56
- },
57
- },
58
- },
59
- });
@@ -1,15 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- const usePagination = (initialPageSize?: number) => {
4
- const [pageSize, setPageSize] = useState(10);
5
-
6
- useEffect(() => {
7
- setPageSize(initialPageSize);
8
- }, [initialPageSize]);
9
-
10
- const handlePageSizeChange = (size) => setPageSize(size);
11
-
12
- return { pageSize, handlePageSizeChange };
13
- };
14
-
15
- export default usePagination;
@@ -1,49 +0,0 @@
1
- import { useEffect, useMemo } from 'react';
2
- import { useLocation, useHistory } from 'react-router-dom';
3
- import { GridFeatureMode } from '@mui/x-data-grid';
4
-
5
- interface Props {
6
- mode: GridFeatureMode;
7
- }
8
-
9
- export const useTableQueryPagination = ({ mode }: Props) => {
10
- const history = useHistory();
11
- const { search, state } = useLocation();
12
- const queryParams = useMemo(() => new URLSearchParams(search), [search]);
13
-
14
- const page = +queryParams.get('page') || 0;
15
- const size = +queryParams.get('size') || 10;
16
-
17
- const onPageChange = (newPage: number) => {
18
- queryParams.set('page', `${newPage}`);
19
- history.replace({ pathname: history.location.pathname, search: queryParams.toString() });
20
- };
21
-
22
- const onSizeChange = (count: number) => {
23
- queryParams.set('size', `${count}`);
24
- history.replace({ pathname: history.location.pathname, search: queryParams.toString() });
25
- };
26
-
27
- useEffect(() => {
28
- if (mode === 'server') {
29
- if (!queryParams.has('page')) {
30
- queryParams.set('page', '0');
31
- }
32
-
33
- if (!queryParams.has('size')) {
34
- queryParams.set('size', `10`);
35
- }
36
-
37
- history.replace({ pathname: history.location.pathname, search: queryParams.toString() }, state);
38
- }
39
- }, [search, mode]);
40
-
41
- return {
42
- page,
43
- size,
44
- onPageChange,
45
- onSizeChange,
46
- };
47
- };
48
-
49
- export default useTableQueryPagination;
@@ -1,52 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { useHistory, useLocation } from 'react-router-dom';
3
- import { GridColumnHeaderParams, GridColumns } from '@mui/x-data-grid';
4
-
5
- export const useTableQuerySorting = () => {
6
- const history = useHistory();
7
- const { search, state } = useLocation();
8
-
9
- const queryParams = useMemo(() => new URLSearchParams(search), [search]);
10
- const sortParams = queryParams.getAll('sort').map((param) => param.split(','));
11
-
12
- const onColumnHeaderClick = ({ field }: GridColumnHeaderParams) => {
13
- let keyFound = false;
14
-
15
- const sortValues = queryParams.getAll('sort');
16
- queryParams.delete('sort');
17
-
18
- sortValues.forEach((sortValue) => {
19
- const [key, sort] = sortValue.split(',');
20
- if (key === field) {
21
- keyFound = true;
22
- if (sort === 'asc') {
23
- queryParams.append('sort', `${key},desc`);
24
- }
25
- } else {
26
- queryParams.append('sort', `${key},${sort}`);
27
- }
28
- });
29
-
30
- if (!keyFound) {
31
- queryParams.append('sort', `${field},asc`);
32
- }
33
-
34
- history.replace({ pathname: history.location.pathname, search: queryParams.toString() }, state);
35
- };
36
-
37
- const getSortedColumns = (columns: GridColumns): GridColumns => {
38
- return columns.map((column) => {
39
- const columnSort = sortParams.find((param) => param[0] === column.field);
40
- if (columnSort) {
41
- column.headerClassName = `Sorted --${columnSort[1]} `;
42
- } else {
43
- column.headerClassName = '';
44
- }
45
- return column;
46
- });
47
- };
48
-
49
- return { onColumnHeaderClick, getSortedColumns };
50
- };
51
-
52
- export default useTableQuerySorting;
@@ -1,54 +0,0 @@
1
- import { useMemo } from 'react';
2
- import Box from '@material-ui/core/Box';
3
- import Paper from '@material-ui/core/Paper';
4
- import Tab from '@material-ui/core/Tab';
5
- import Tabs from '@material-ui/core/Tabs';
6
- import TabPanel from './TabPanel';
7
-
8
- import { useHistory, useLocation } from 'react-router-dom';
9
-
10
- interface RouteTab {
11
- name: string;
12
- label: string;
13
- component: React.ReactElement;
14
- }
15
-
16
- interface Props {
17
- tabs: RouteTab[];
18
- }
19
-
20
- export const RouteTabs = (props: Props) => {
21
- const { tabs } = props;
22
-
23
- const history = useHistory();
24
- const location = useLocation();
25
-
26
- const queryParams = useMemo(() => new URLSearchParams(location.search), [location.search]);
27
- const value = queryParams.get('tab');
28
-
29
- const handleChange = (event, newValue: string) => {
30
- queryParams.set('tab', newValue);
31
- history.replace({ pathname: history.location.pathname, search: queryParams.toString() });
32
- };
33
-
34
- return (
35
- <Box>
36
- <Paper>
37
- <Tabs value={value || tabs[0]?.name} indicatorColor="primary" textColor="primary" onChange={handleChange}>
38
- {tabs.map((tab) => (
39
- <Tab key={tab.name} value={tab.name} label={tab.label} />
40
- ))}
41
- </Tabs>
42
- </Paper>
43
- <Box mt={2}>
44
- {tabs.map((tab) => (
45
- <TabPanel key={tab.name} value={value || tabs[0]?.name} index={tab.name}>
46
- {tab.component}
47
- </TabPanel>
48
- ))}
49
- </Box>
50
- </Box>
51
- );
52
- };
53
-
54
- export default RouteTabs;
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
-
3
- /**
4
- * This interface is referencing the [[TabPanel]] component props.
5
- * @category Common UI components
6
- */
7
- export interface TabPanelProps {
8
- /**
9
- * Active tab value
10
- */
11
- value: number | string;
12
- /**
13
- * Index of current panel
14
- */
15
- index: number | string;
16
- /**
17
- * Rendered children component
18
- */
19
- children: React.ReactElement;
20
- }
21
-
22
- /**
23
- * Tab panel component. Used with tabs component
24
- * @category Common UI components
25
- */
26
- export const TabPanel = (props: TabPanelProps) => {
27
- const { children, value, index, ...other } = props;
28
-
29
- return (
30
- <div
31
- role="tabpanel"
32
- hidden={value !== index}
33
- id={`simple-tabpanel-${index}`}
34
- aria-labelledby={`simple-tab-${index}`}
35
- {...other}
36
- >
37
- {value === index ? children : null}
38
- </div>
39
- );
40
- };
41
-
42
- export default TabPanel;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
-
3
- const ExpressionDecorator = ({ children }) => {
4
- return <span style={{ backgroundColor: '#e4ecff' }}>{children}</span>;
5
- };
6
-
7
- export default ExpressionDecorator;
@@ -1,144 +0,0 @@
1
- import MUIRichTextEditor from 'mui-rte';
2
- import { createTheme, ThemeProvider } from '@material-ui/core/styles';
3
- import { ContentState, EditorState, Modifier, convertFromHTML, convertToRaw } from 'draft-js';
4
- import FunctionsIcon from '@material-ui/icons/Functions';
5
- import Typography from '@material-ui/core/Typography';
6
- import ExpressionDecorator from './ExpressionDecorator';
7
- import { JsonPathPicker } from '../JsonPathPicker';
8
-
9
- import { useEffect, useState } from 'react';
10
- // import { stateToHTML } from 'draft-js-export-html';
11
- import { useToggle } from '../../utils';
12
- import { JsonPathPickerProperties, PropertiesArrayType } from '../../interfaces';
13
- import { useController, useFormContext } from 'react-hook-form';
14
-
15
- type Props = {
16
- fieldName: string;
17
- getProperties?: () => JsonPathPickerProperties;
18
- initialText?: string;
19
- };
20
-
21
- const defaultTheme = createTheme();
22
-
23
- Object.assign(defaultTheme, {
24
- overrides: {
25
- MUIRichTextEditor: {
26
- root: {
27
- marginTop: 20,
28
- width: '100%',
29
- border: '1px solid gray',
30
- padding: '8px',
31
- },
32
- editor: {
33
- minHeight: '300px',
34
- },
35
- toolbar: {
36
- backgroundColor: '#eee',
37
- },
38
- },
39
- },
40
- });
41
-
42
- export const TemplateContentEditor = ({ fieldName, getProperties, initialText }: Props) => {
43
- const { control, setValue, clearErrors } = useFormContext();
44
- const {
45
- fieldState: { error },
46
- } = useController({
47
- control,
48
- name: fieldName,
49
- rules: {
50
- required: 'Please, fill content',
51
- },
52
- });
53
-
54
- const defaultContent = convertToRaw(EditorState.createEmpty().getCurrentContent());
55
- const { open: jsonPathPickerOpen, onOpen: onJsonPathPickerOpen, onClose: onJsonPathPickerClose } = useToggle();
56
-
57
- const [content, setContent] = useState(JSON.stringify(defaultContent));
58
- const [properties, setProperties] = useState<
59
- {
60
- properties: PropertiesArrayType;
61
- pathPrefix: string;
62
- title: string;
63
- }[]
64
- >([]);
65
- const [editorState, setEditorState] = useState<EditorState>(null);
66
-
67
- useEffect(() => {
68
- if (initialText) {
69
- const contentState = convertFromHTML(initialText);
70
- const state =
71
- contentState && ContentState.createFromBlockArray(contentState.contentBlocks, contentState.entityMap);
72
- setContent(JSON.stringify(convertToRaw(state)));
73
- }
74
- }, [initialText]);
75
-
76
- const handleChange = (state: EditorState) => {
77
- const currentContentState = state.getCurrentContent();
78
- const selectionState = state.getSelection();
79
- EditorState.push(state, Modifier.replaceText(currentContentState, selectionState, ''), 'remove-range');
80
-
81
- const isEmpty = !state.getCurrentContent().hasText();
82
- const content = currentContentState.getPlainText();
83
- // stateToHTML(currentContentState);
84
-
85
- setValue(fieldName, !isEmpty ? content : '');
86
- clearErrors(fieldName);
87
- };
88
-
89
- const handleJsonPathPickerClick = (eState) => {
90
- setEditorState(eState);
91
- setProperties(getProperties());
92
- onJsonPathPickerOpen();
93
- };
94
-
95
- const handleJsonPathPaste = (jsonPath: string) => {
96
- const currentContentState = editorState.getCurrentContent();
97
- const selectionState = editorState.getSelection();
98
-
99
- const state = EditorState.push(
100
- editorState,
101
- Modifier.insertText(currentContentState, selectionState, jsonPath),
102
- 'insert-characters'
103
- ).getCurrentContent();
104
-
105
- setContent(JSON.stringify(convertToRaw(state)));
106
- onJsonPathPickerClose();
107
- };
108
-
109
- return (
110
- <ThemeProvider theme={defaultTheme}>
111
- <MUIRichTextEditor
112
- defaultValue={content}
113
- label="Start here..."
114
- controls={['title', 'bold', 'italic', 'strikethrough', 'numberList', 'bulletList', 'code', 'jsonPathPicker']}
115
- onChange={handleChange}
116
- customControls={[
117
- {
118
- name: 'jsonPathPicker',
119
- icon: <FunctionsIcon />,
120
- type: 'callback',
121
- onClick: handleJsonPathPickerClick,
122
- },
123
- ]}
124
- decorators={[
125
- {
126
- component: ExpressionDecorator,
127
- regex: /\$\([^\s]*\)/g,
128
- },
129
- ]}
130
- />
131
- <Typography color="secondary">{error?.message}</Typography>
132
- {jsonPathPickerOpen && (
133
- <JsonPathPicker
134
- open={jsonPathPickerOpen}
135
- properties={properties}
136
- onClose={onJsonPathPickerClose}
137
- onPaste={handleJsonPathPaste}
138
- />
139
- )}
140
- </ThemeProvider>
141
- );
142
- };
143
-
144
- export default TemplateContentEditor;