@dartech/arsenal-ui 0.0.1

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 (124) hide show
  1. package/.babelrc +12 -0
  2. package/.eslintrc.json +22 -0
  3. package/README.md +7 -0
  4. package/index.ts +3 -0
  5. package/jest.config.js +9 -0
  6. package/package.json +21 -0
  7. package/project.json +69 -0
  8. package/rollup.config.js +135 -0
  9. package/src/interfaces/common.ts +12 -0
  10. package/src/interfaces/definition.ts +143 -0
  11. package/src/interfaces/index.ts +3 -0
  12. package/src/interfaces/ui.ts +35 -0
  13. package/src/lib/Alert/Alert.tsx +108 -0
  14. package/src/lib/Alert/index.ts +1 -0
  15. package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +74 -0
  16. package/src/lib/Definition/CreateDefinition/index.ts +1 -0
  17. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +85 -0
  18. package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.tsx +96 -0
  19. package/src/lib/Definition/DefinitionFiller/index.ts +2 -0
  20. package/src/lib/Definition/index.ts +2 -0
  21. package/src/lib/DemPropertyField/DemPropertyField.tsx +93 -0
  22. package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.tsx +44 -0
  23. package/src/lib/DemPropertyField/DemPropertyView/index.ts +1 -0
  24. package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.tsx +293 -0
  25. package/src/lib/DemPropertyField/MultipleDemField/index.tsx +1 -0
  26. package/src/lib/DemPropertyField/RestrictedValuesEditor.tsx +63 -0
  27. package/src/lib/DemPropertyField/SingleDemField/SingleDemField.tsx +156 -0
  28. package/src/lib/DemPropertyField/SingleDemField/index.ts +1 -0
  29. package/src/lib/DemPropertyField/index.ts +2 -0
  30. package/src/lib/DemPropertyField/styles.ts +50 -0
  31. package/src/lib/DemPropertyField/widgets/DemBooleanWidget.tsx +26 -0
  32. package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.tsx +34 -0
  33. package/src/lib/DemPropertyField/widgets/DemDateWidget.tsx +33 -0
  34. package/src/lib/DemPropertyField/widgets/DemFieldWidget.tsx +67 -0
  35. package/src/lib/DemPropertyField/widgets/DemFloatWidget.tsx +49 -0
  36. package/src/lib/DemPropertyField/widgets/DemIntegerWidget.tsx +63 -0
  37. package/src/lib/DemPropertyField/widgets/DemJsonWidget.tsx +33 -0
  38. package/src/lib/DemPropertyField/widgets/DemStringWidget.tsx +35 -0
  39. package/src/lib/DemPropertyField/widgets/DemTimeWidget.tsx +46 -0
  40. package/src/lib/DemPropertyField/widgets/index.ts +1 -0
  41. package/src/lib/Forms/BackButton.tsx +45 -0
  42. package/src/lib/Forms/ControlAceEditor.tsx +103 -0
  43. package/src/lib/Forms/ControlAutocomplete.tsx +134 -0
  44. package/src/lib/Forms/ControlCheckbox.tsx +57 -0
  45. package/src/lib/Forms/ControlDebouncedInput.tsx +69 -0
  46. package/src/lib/Forms/ControlInput.tsx +102 -0
  47. package/src/lib/Forms/ControlNumberInput.tsx +144 -0
  48. package/src/lib/Forms/ControlRadioBtn.tsx +46 -0
  49. package/src/lib/Forms/ControlSelect.tsx +135 -0
  50. package/src/lib/Forms/CopyButton.tsx +49 -0
  51. package/src/lib/Forms/index.ts +10 -0
  52. package/src/lib/InfoItem/InfoItem.tsx +39 -0
  53. package/src/lib/InfoItem/index.ts +1 -0
  54. package/src/lib/InfoItem/styles.ts +17 -0
  55. package/src/lib/JsonPathPicker/JsonPathPicker.tsx +71 -0
  56. package/src/lib/JsonPathPicker/PropertyStep.tsx +74 -0
  57. package/src/lib/JsonPathPicker/index.ts +1 -0
  58. package/src/lib/JsonView/JsonView.tsx +43 -0
  59. package/src/lib/JsonView/index.ts +1 -0
  60. package/src/lib/Loader/Loader.tsx +41 -0
  61. package/src/lib/Loader/index.ts +1 -0
  62. package/src/lib/Modals/JsonModalView.tsx +52 -0
  63. package/src/lib/Modals/index.ts +1 -0
  64. package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +41 -0
  65. package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +59 -0
  66. package/src/lib/Property/PropertyValueField/DateValueField.tsx +59 -0
  67. package/src/lib/Property/PropertyValueField/EntityValueField.tsx +33 -0
  68. package/src/lib/Property/PropertyValueField/JsonValueField.tsx +64 -0
  69. package/src/lib/Property/PropertyValueField/PropertyValue.tsx +97 -0
  70. package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +86 -0
  71. package/src/lib/Property/PropertyValueField/StringValueField.tsx +21 -0
  72. package/src/lib/Property/PropertyValueField/TimeValueField.tsx +68 -0
  73. package/src/lib/Property/PropertyValueField/ValueComponent.tsx +63 -0
  74. package/src/lib/Property/PropertyValueField/index.ts +1 -0
  75. package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +167 -0
  76. package/src/lib/Property/PropertyWidget/index.ts +1 -0
  77. package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +131 -0
  78. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +147 -0
  79. package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +40 -0
  80. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +41 -0
  81. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +27 -0
  82. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +133 -0
  83. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +46 -0
  84. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +52 -0
  85. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +98 -0
  86. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/index.ts +1 -0
  87. package/src/lib/Property/UpsertProperty/index.ts +2 -0
  88. package/src/lib/Property/UpsertProperty/useCustomFields.ts +22 -0
  89. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +50 -0
  90. package/src/lib/Property/ViewPropertiesList/index.ts +1 -0
  91. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +41 -0
  92. package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +48 -0
  93. package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +139 -0
  94. package/src/lib/Property/ViewProperty/PropertyItem.tsx +46 -0
  95. package/src/lib/Property/ViewProperty/ViewProperty.tsx +52 -0
  96. package/src/lib/Property/ViewProperty/index.ts +1 -0
  97. package/src/lib/Property/index.ts +4 -0
  98. package/src/lib/Status/Status.tsx +15 -0
  99. package/src/lib/Status/index.ts +1 -0
  100. package/src/lib/Status/styles.ts +14 -0
  101. package/src/lib/Table/Table.tsx +116 -0
  102. package/src/lib/Table/TableColumnMenu.tsx +12 -0
  103. package/src/lib/Table/TablePagination.tsx +42 -0
  104. package/src/lib/Table/index.ts +1 -0
  105. package/src/lib/Table/styles.ts +59 -0
  106. package/src/lib/Table/usePagination.ts +15 -0
  107. package/src/lib/Table/useTableQueryPagination.ts +49 -0
  108. package/src/lib/Table/useTableQuerySorting.ts +52 -0
  109. package/src/lib/Tabs/RouteTabs.tsx +54 -0
  110. package/src/lib/Tabs/TabPanel.tsx +42 -0
  111. package/src/lib/Tabs/index.ts +2 -0
  112. package/src/lib/TemplateContent/ExpressionDecorator.tsx +7 -0
  113. package/src/lib/TemplateContent/TemplateContentEditor.tsx +144 -0
  114. package/src/lib/TemplateContent/index.ts +1 -0
  115. package/src/lib/index.ts +14 -0
  116. package/src/utils/common.ts +68 -0
  117. package/src/utils/dem.ts +78 -0
  118. package/src/utils/hooks.ts +41 -0
  119. package/src/utils/index.ts +5 -0
  120. package/src/utils/ui-utils.tsx +71 -0
  121. package/src/utils/validators.ts +130 -0
  122. package/tsconfig.json +24 -0
  123. package/tsconfig.lib.json +22 -0
  124. package/tsconfig.spec.json +19 -0
@@ -0,0 +1,135 @@
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;
@@ -0,0 +1,49 @@
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;
@@ -0,0 +1,10 @@
1
+ export * from './ControlInput';
2
+ export * from './ControlDebouncedInput';
3
+ export * from './ControlSelect';
4
+ export * from './ControlCheckbox';
5
+ export * from './ControlRadioBtn';
6
+ export * from './ControlAutocomplete';
7
+ export * from './CopyButton';
8
+ export * from './BackButton';
9
+ export * from './ControlAceEditor';
10
+ export * from './ControlNumberInput';
@@ -0,0 +1,39 @@
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;
@@ -0,0 +1 @@
1
+ export * from './InfoItem';
@@ -0,0 +1,17 @@
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
+ }));
@@ -0,0 +1,71 @@
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;
@@ -0,0 +1,74 @@
1
+ import Stepper from '@material-ui/core/Stepper';
2
+ import Step from '@material-ui/core/Step';
3
+ import StepLabel from '@material-ui/core/StepLabel';
4
+ import StepContent from '@material-ui/core/StepContent';
5
+
6
+ import { EntityTypeProperty, PropertiesArrayType, PropertyType } from '../../interfaces';
7
+ import { makeStyles } from '@material-ui/core/styles';
8
+
9
+ type Props = {
10
+ properties: PropertiesArrayType;
11
+ parentKey?: string;
12
+ activePath: string;
13
+ prefix?: string;
14
+ onClick: (path: string) => void;
15
+ };
16
+
17
+ const useStyles = makeStyles(() => ({
18
+ propertyStepLabel: {
19
+ '&:hover': {
20
+ fontWeight: '600',
21
+ cursor: 'pointer',
22
+ },
23
+ },
24
+ }));
25
+
26
+ const PropertyStep = ({ properties, parentKey = '', activePath = '', prefix = '', onClick }: Props) => {
27
+ const classes = useStyles();
28
+
29
+ const handleClick = (path: string) => {
30
+ if (prefix) {
31
+ onClick(`${prefix}.${path}`);
32
+ } else {
33
+ onClick(path);
34
+ }
35
+ };
36
+
37
+ return (
38
+ <Stepper orientation="vertical" onClick={(event) => event.stopPropagation()}>
39
+ {properties.map((property) => {
40
+ const fullPropertyPath = parentKey ? `${parentKey}.${property.key}` : property.key;
41
+ let propertyType;
42
+ if (typeof property.propertyType === 'string') {
43
+ propertyType = property.propertyType;
44
+ } else {
45
+ propertyType = property.propertyType['value'];
46
+ }
47
+ return (
48
+ <Step expanded key={property.key} onClick={() => handleClick(fullPropertyPath)}>
49
+ <StepLabel StepIconProps={{ icon: '', completed: false, active: activePath === fullPropertyPath }}>
50
+ <div className={classes.propertyStepLabel}>
51
+ {property.name} - {property.key} - {propertyType}
52
+ </div>
53
+ </StepLabel>
54
+ <StepContent>
55
+ <div>
56
+ {propertyType === PropertyType.ENTITY && (
57
+ <PropertyStep
58
+ key={property.key}
59
+ onClick={onClick}
60
+ activePath={activePath}
61
+ properties={(property as EntityTypeProperty).properties as PropertiesArrayType}
62
+ parentKey={fullPropertyPath}
63
+ />
64
+ )}
65
+ </div>
66
+ </StepContent>
67
+ </Step>
68
+ );
69
+ })}
70
+ </Stepper>
71
+ );
72
+ };
73
+
74
+ export default PropertyStep;
@@ -0,0 +1 @@
1
+ export * from './JsonPathPicker';
@@ -0,0 +1,43 @@
1
+ import { useMemo } from 'react';
2
+ import AceEditor from 'react-ace';
3
+ import 'ace-builds/src-noconflict/ace';
4
+ import 'ace-builds/src-noconflict/mode-json';
5
+
6
+ type Props = {
7
+ value: unknown;
8
+ height?: string;
9
+ };
10
+
11
+ export const JsonView = ({ value, height = '200px' }: Props) => {
12
+ const stringValue = useMemo(() => {
13
+ if (typeof value === 'string') {
14
+ return value;
15
+ } else if (typeof value === 'object') {
16
+ try {
17
+ return JSON.stringify(value, null, '\t');
18
+ } catch (error) {
19
+ return 'Failed to parse JSON';
20
+ }
21
+ }
22
+ return null;
23
+ }, [value]);
24
+
25
+ return (
26
+ <AceEditor
27
+ readOnly
28
+ value={stringValue}
29
+ mode="json"
30
+ width="100%"
31
+ height={height}
32
+ fontSize="16"
33
+ setOptions={{
34
+ enableSnippets: false,
35
+ copyWithEmptySelection: true,
36
+ showLineNumbers: true,
37
+ tabSize: 2,
38
+ }}
39
+ />
40
+ );
41
+ };
42
+
43
+ export default JsonView;
@@ -0,0 +1 @@
1
+ export * from './JsonView';
@@ -0,0 +1,41 @@
1
+ import Box from "@material-ui/core/Box";
2
+ import CircularProgress from "@material-ui/core/CircularProgress";
3
+
4
+ /**
5
+ * This interface is referencing the [[Loader]] component props.
6
+ * @category Common UI components
7
+ */
8
+ export interface LoaderProps {
9
+ /**
10
+ * Background transparency flag. Default: `rgba(255, 255, 255, .3)`
11
+ */
12
+ transparent?: boolean;
13
+ /**
14
+ * CSS `position` property. Default: `absolute`
15
+ */
16
+ position?: string;
17
+ }
18
+ /**
19
+ * Loader screen component. Used in the data loading process
20
+ * @category Common UI components
21
+ */
22
+ export const Loader = ({ transparent, position }: LoaderProps) => {
23
+ return (
24
+ <Box
25
+ position={position ?? 'absolute'}
26
+ top={0}
27
+ left={0}
28
+ width="100%"
29
+ height="100%"
30
+ display="flex"
31
+ alignItems="center"
32
+ justifyContent="center"
33
+ bgcolor={transparent ? 'none' : 'rgba(255, 255, 255, .3)'}
34
+ zIndex={10}
35
+ >
36
+ <CircularProgress />
37
+ </Box>
38
+ )
39
+ }
40
+
41
+ export default Loader;
@@ -0,0 +1 @@
1
+ export * from './Loader';
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import AceEditor from 'react-ace';
3
+ import 'ace-builds/src-noconflict/ace';
4
+ import 'ace-builds/src-noconflict/mode-json';
5
+ import Dialog from '@material-ui/core/Dialog';
6
+ import DialogContent from '@material-ui/core/DialogContent';
7
+ import DialogActions from '@material-ui/core/DialogActions';
8
+ import Button from '@material-ui/core/Button';
9
+ import { CopyButton } from '../Forms';
10
+
11
+ type Props = {
12
+ open: boolean;
13
+ value: string;
14
+ onClose: () => void;
15
+ };
16
+
17
+ export const JsonModalView: React.FC<Props> = ({ open, onClose, value }) => {
18
+ return (
19
+ <Dialog
20
+ disableEscapeKeyDown
21
+ open={open}
22
+ onClose={onClose}
23
+ fullWidth
24
+ maxWidth="md"
25
+ style={{ width: 800, left: '30%' }}
26
+ >
27
+ <DialogContent>
28
+ <AceEditor
29
+ readOnly
30
+ value={value}
31
+ mode="json"
32
+ width="100%"
33
+ fontSize="16"
34
+ setOptions={{
35
+ enableSnippets: false,
36
+ copyWithEmptySelection: true,
37
+ showLineNumbers: true,
38
+ tabSize: 2,
39
+ }}
40
+ />
41
+ </DialogContent>
42
+ <DialogActions>
43
+ <CopyButton copyText={value} />
44
+ <Button onClick={onClose} variant="contained" color="secondary">
45
+ Close
46
+ </Button>
47
+ </DialogActions>
48
+ </Dialog>
49
+ );
50
+ };
51
+
52
+ export default JsonModalView;
@@ -0,0 +1 @@
1
+ export * from './JsonModalView';
@@ -0,0 +1,41 @@
1
+ import Switch from '@material-ui/core/Switch';
2
+ import Typography from '@material-ui/core/Typography';
3
+ import FormControlLabel from '@material-ui/core/FormControlLabel';
4
+ import { Controller, useFormContext } from 'react-hook-form';
5
+
6
+ type Props = {
7
+ name: string;
8
+ label?: string;
9
+ };
10
+
11
+ const BooleanValueField = ({ name, label = '' }: Props) => {
12
+ const { control } = useFormContext();
13
+
14
+ return (
15
+ <>
16
+ <Typography>{label}</Typography>
17
+ <Controller
18
+ control={control}
19
+ name={name}
20
+ render={({ field }) => (
21
+ <FormControlLabel
22
+ label={(!!field.value + '').toUpperCase()}
23
+ control={
24
+ <Switch
25
+ color="primary"
26
+ size="small"
27
+ onChange={(e) => {
28
+ const { checked } = e.target;
29
+ field.onChange(checked);
30
+ }}
31
+ checked={!!field.value + '' === 'true'}
32
+ />
33
+ }
34
+ />
35
+ )}
36
+ />
37
+ </>
38
+ );
39
+ };
40
+
41
+ export default BooleanValueField;
@@ -0,0 +1,59 @@
1
+ import TextField from '@mui/material/TextField';
2
+ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
3
+
4
+ import { format as dateFnsFormat, isValid } from 'date-fns';
5
+ import { Controller, useFormContext } from 'react-hook-form';
6
+ import { DATE_TIME_DEFAULT_FORMAT } from '../../../interfaces';
7
+
8
+ type Props = {
9
+ name: string;
10
+ label?: string;
11
+ required?: boolean;
12
+ format?: string;
13
+ };
14
+
15
+ const DateTimeValueField = ({ name, label, required = false, format = DATE_TIME_DEFAULT_FORMAT }: Props) => {
16
+ const { control, setError, clearErrors } = useFormContext();
17
+
18
+ const onError = (err) => {
19
+ if (err) {
20
+ setError(name, { type: 'custom', message: 'Incorrect date format' });
21
+ } else {
22
+ clearErrors(name);
23
+ }
24
+ };
25
+
26
+ return (
27
+ <Controller
28
+ control={control}
29
+ name={name}
30
+ rules={{ required: required && 'Required field' }}
31
+ render={({ field: { ref, value, onChange }, fieldState: { error } }) => (
32
+ <DateTimePicker
33
+ clearable
34
+ ampm={false}
35
+ inputRef={ref}
36
+ label={label}
37
+ value={value || null}
38
+ inputFormat={format}
39
+ onError={onError}
40
+ onChange={(date) => {
41
+ onChange(isValid(date) ? dateFnsFormat(date, format) : date);
42
+ }}
43
+ renderInput={(props) => (
44
+ <TextField
45
+ {...props}
46
+ fullWidth
47
+ size="small"
48
+ variant="outlined"
49
+ error={!!error}
50
+ helperText={error?.message}
51
+ />
52
+ )}
53
+ />
54
+ )}
55
+ />
56
+ );
57
+ };
58
+
59
+ export default DateTimeValueField;