@evoke-platform/ui-components 1.5.0-testing.15 → 1.5.0-testing.17

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.
@@ -189,9 +189,11 @@ export function convertFormToComponents(entries, parameters, object) {
189
189
  tableView: false,
190
190
  displayOption: parameter.type === 'object'
191
191
  ? displayOptions?.relatedObjectDisplay
192
- : (parameter.type === 'string' && parameter.enum) || parameter.type === 'boolean'
192
+ : parameter.type === 'string' && parameter.enum
193
193
  ? displayOptions?.choicesDisplay?.type
194
- : undefined,
194
+ : parameter.type === 'boolean'
195
+ ? displayOptions?.booleanDisplay
196
+ : undefined,
195
197
  labelPosition: 'top',
196
198
  dataSrc: property.enum?.length ? 'values' : undefined,
197
199
  showCharCount: displayOptions?.charCount,
@@ -346,6 +348,7 @@ export function convertComponentsToForm(components) {
346
348
  ...((component.displayOption || component.sortBy) &&
347
349
  component.property?.enum &&
348
350
  component.property?.type !== 'array' &&
351
+ component?.property?.type !== 'boolean' &&
349
352
  component.property?.type !== 'object'
350
353
  ? {
351
354
  choicesDisplay: {
@@ -354,12 +357,17 @@ export function convertComponentsToForm(components) {
354
357
  },
355
358
  }
356
359
  : {}),
360
+ ...(component.displayOption && component?.property?.type === 'boolean'
361
+ ? { booleanDisplay: component.displayOption }
362
+ : {}),
357
363
  ...(component.displayOption && component?.property?.type === 'object'
358
364
  ? { relatedObjectDisplay: component.displayOption }
359
365
  : {}),
360
366
  ...(component.defaultToCurrentDate ||
361
367
  component.defaultToCurrentTime ||
362
368
  component.initialValue ||
369
+ (typeof component.initialValue === 'number' && Number.isFinite(component.initialValue)) ||
370
+ typeof component.initialValue === 'boolean' ||
363
371
  component.defaultValueCriteria
364
372
  ? {
365
373
  defaultValue: component.defaultToCurrentDate
@@ -35,7 +35,7 @@ const BooleanSelect = (props) => {
35
35
  tooltip && (React.createElement(Tooltip, { placement: "right", title: tooltip },
36
36
  React.createElement(IconButton, null,
37
37
  React.createElement(Help, { sx: { fontSize: '14px' } })))),
38
- required && (React.createElement(Typography, { variant: "body2", component: "span", color: "error", sx: { marginLeft: '4px', fontSize: '18px' } }, "*"))), control: displayOption === 'switch' ? (React.createElement(Switch, { id: id, "aria-checked": value, "aria-required": required, "aria-invalid": error, size: size ?? 'medium', name: property.id, checked: value, onChange: (e) => handleChange(e.target.checked), disabled: readOnly, sx: { alignSelf: 'start' } })) : (React.createElement(Checkbox, { id: id, "aria-checked": value, "aria-required": required, "aria-invalid": error, size: size ?? 'medium', checked: value, name: property.id, onChange: (e) => handleChange(e.target.checked), disabled: readOnly, sx: { alignSelf: 'start', padding: '4px 9px 9px 9px' } })) }),
38
+ required && (React.createElement(Typography, { variant: "body2", component: "span", color: "error", sx: { marginLeft: '4px', fontSize: '18px' } }, "*"))), control: displayOption === 'switch' ? (React.createElement(Switch, { id: id, "aria-required": required, "aria-invalid": error, size: size ?? 'medium', name: property.id, checked: value, onChange: (e) => handleChange(e.target.checked), disabled: readOnly, sx: { alignSelf: 'start' } })) : (React.createElement(Checkbox, { id: id, "aria-required": required, "aria-invalid": error, size: size ?? 'medium', checked: value, name: property.id, onChange: (e) => handleChange(e.target.checked), disabled: readOnly, sx: { alignSelf: 'start', padding: '4px 9px 9px 9px' } })) }),
39
39
  error && React.createElement(FormHelperText, { sx: { marginX: 0 } }, errorMessage),
40
40
  description && (React.createElement(FormHelperText, { sx: descriptionStyles, component: Typography }, parse(description)))));
41
41
  };
@@ -28,27 +28,31 @@ const FileUploadControl = (props) => {
28
28
  color: '#C7C7CD',
29
29
  },
30
30
  };
31
+ const onDrop = useCallback(
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ (acceptedFile) => {
34
+ setUploadedFile(acceptedFile[0]);
35
+ }, [setUploadedFile]);
36
+ const { getRootProps, getInputProps, isDragActive, open } = useDropzone({
37
+ onDrop,
38
+ multiple: false,
39
+ disabled: !!uploadedFile,
40
+ noClick: true,
41
+ });
31
42
  useEffect(() => {
32
43
  if (uploadedFile) {
33
44
  props.onChange && props.onChange(property.id, uploadedFile, property);
34
45
  }
35
46
  }, [uploadedFile]);
36
- const handleSelectFile = () => {
47
+ const handleFileSelectionOrRemoval = () => {
37
48
  if (uploadedFile) {
38
49
  setUploadedFile(undefined);
39
50
  props.onChange && props.onChange(property.id, undefined, property);
40
51
  }
52
+ else {
53
+ open();
54
+ }
41
55
  };
42
- const onDrop = useCallback(
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- (acceptedFile) => {
45
- setUploadedFile(acceptedFile[0]);
46
- }, [setUploadedFile]);
47
- const { getRootProps, getInputProps, isDragActive } = useDropzone({
48
- onDrop,
49
- multiple: false,
50
- disabled: !!uploadedFile,
51
- });
52
56
  return (React.createElement(Grid, { container: true, ...getRootProps({
53
57
  style: {
54
58
  border: error ? '1px solid red' : '1px solid #c4c4c4',
@@ -57,9 +61,9 @@ const FileUploadControl = (props) => {
57
61
  },
58
62
  }) },
59
63
  React.createElement(Grid, { item: true, flexGrow: 1 },
60
- React.createElement("input", { disabled: true, ...getInputProps() }),
64
+ React.createElement("input", { ...getInputProps() }),
61
65
  React.createElement(TextField, { id: id, sx: { '& fieldset': { border: 'none' } }, fullWidth: true, value: uploadedFile?.name ?? (isDragActive ? 'Drop your file here' : 'File'), error: error, errorMessage: errorMessage, required: required, ...(additionalProps ?? {}) })),
62
66
  React.createElement(Grid, { item: true },
63
- React.createElement(Button, { sx: { ...styles.button, ...styles.selectFileBtn }, onClick: () => handleSelectFile() }, uploadedFile ? 'Remove' : 'Select File'))));
67
+ React.createElement(Button, { sx: { ...styles.button, ...styles.selectFileBtn }, onClick: handleFileSelectionOrRemoval }, uploadedFile ? 'Remove' : 'Select File'))));
64
68
  };
65
69
  export default FileUploadControl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.5.0-testing.15",
3
+ "version": "1.5.0-testing.17",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",