@evoke-platform/ui-components 1.5.0-testing.12 → 1.5.0-testing.13
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.
- package/dist/published/components/custom/Form/Common/FormComponentWrapper.d.ts +1 -1
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.d.ts +1 -1
- package/dist/published/components/custom/Form/FormComponents/ViewOnlyComponent.js +5 -2
- package/dist/published/components/custom/Form/types.d.ts +2 -0
- package/dist/published/components/custom/Form/utils.js +4 -2
- package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js +2 -2
- package/dist/published/components/custom/FormField/BooleanSelect/BooleanSelect.js +1 -1
- package/dist/published/components/custom/FormField/DatePickerSelect/DatePickerSelect.js +1 -1
- package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js +1 -1
- package/dist/published/components/custom/FormField/FileUpload/FileUpload.js +2 -2
- package/dist/published/components/custom/FormField/FormField.d.ts +1 -1
- package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js +2 -2
- package/dist/published/components/custom/FormField/Select/Select.js +3 -2
- package/dist/published/components/custom/FormField/TimePickerSelect/TimePickerSelect.js +2 -2
- package/package.json +1 -1
@@ -18,7 +18,7 @@ type FormComponentWrapperProps = {
|
|
18
18
|
viewOnly: boolean;
|
19
19
|
children: React.ReactNode;
|
20
20
|
key: string;
|
21
|
-
displayOption?: 'radioButton' | 'dropdown' | 'dialogBox';
|
21
|
+
displayOption?: 'radioButton' | 'dropdown' | 'dialogBox' | 'switch' | 'checkbox';
|
22
22
|
onChange?: (key: string, value: unknown) => void;
|
23
23
|
property?: ObjectProperty;
|
24
24
|
readOnly?: boolean;
|
@@ -15,6 +15,6 @@ export declare class ViewOnlyComponent extends ReactComponent {
|
|
15
15
|
* @param data - The contextual data object (model) used for this component.
|
16
16
|
*/
|
17
17
|
constructor(component: BaseFormComponentProps, options: any, data: any);
|
18
|
-
showValue(value: unknown):
|
18
|
+
showValue(value: unknown): unknown;
|
19
19
|
attachReact(element: Element): void;
|
20
20
|
}
|
@@ -4,6 +4,7 @@ import { DateTime } from 'luxon';
|
|
4
4
|
import React from 'react';
|
5
5
|
import ReactDOM from 'react-dom';
|
6
6
|
import { Link, Typography } from '../../../core';
|
7
|
+
import BooleanSelect from '../../FormField/BooleanSelect/BooleanSelect';
|
7
8
|
import { FormComponentWrapper } from '../Common/FormComponentWrapper';
|
8
9
|
export class ViewOnlyComponent extends ReactComponent {
|
9
10
|
/**
|
@@ -25,7 +26,7 @@ export class ViewOnlyComponent extends ReactComponent {
|
|
25
26
|
this.showValue = this.showValue.bind(this);
|
26
27
|
}
|
27
28
|
showValue(value) {
|
28
|
-
if (value === null || value === undefined)
|
29
|
+
if ((value === null || value === undefined) && this.component.type !== 'ViewOnlyBoolean')
|
29
30
|
return React.createElement("span", null, "\u00A0");
|
30
31
|
switch (this.component.type) {
|
31
32
|
case 'ViewOnlyObject':
|
@@ -63,7 +64,9 @@ export class ViewOnlyComponent extends ReactComponent {
|
|
63
64
|
case 'ViewOnlyTime':
|
64
65
|
return DateTime.fromISO(DateTime.now().toISODate() + 'T' + value).toFormat('hh:mm a');
|
65
66
|
case 'ViewOnlyBoolean':
|
66
|
-
return
|
67
|
+
return (React.createElement(BooleanSelect, { id: this.component.key, readOnly: true, label: this.component.label, required: this.component.validate?.required, description: this.component.description, property: this.component.property, defaultValue: this.component.instance
|
68
|
+
? get(this.component.instance, this.component.key)
|
69
|
+
: this.component.defaultValue, size: this.component.fieldHeight, displayOption: this.component.displayOption }));
|
67
70
|
default:
|
68
71
|
return value;
|
69
72
|
}
|
@@ -50,6 +50,8 @@ export type BaseFormComponentProps = {
|
|
50
50
|
autoSave?: (update: Record<string, unknown>) => void;
|
51
51
|
baseUrl: string;
|
52
52
|
apiServices: ApiServices;
|
53
|
+
description?: string;
|
54
|
+
displayOption?: 'radioButton' | 'dropdown' | 'dialogBox' | 'switch' | 'checkbox';
|
53
55
|
};
|
54
56
|
export type ObjectPropertyInputProps = {
|
55
57
|
id: string;
|
@@ -189,7 +189,7 @@ 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
|
192
|
+
: (parameter.type === 'string' && parameter.enum) || parameter.type === 'boolean'
|
193
193
|
? displayOptions?.choicesDisplay?.type
|
194
194
|
: undefined,
|
195
195
|
labelPosition: 'top',
|
@@ -789,7 +789,9 @@ formComponents, allCriteriaInputs, instance, objectPropertyInputProps, associate
|
|
789
789
|
];
|
790
790
|
}
|
791
791
|
export function getDefaultValue(initialValue, selectOptions) {
|
792
|
-
if (
|
792
|
+
if (typeof initialValue === 'boolean' ||
|
793
|
+
!isEmpty(initialValue) ||
|
794
|
+
(initialValue !== undefined && typeof initialValue === 'number')) {
|
793
795
|
if (Array.isArray(initialValue)) {
|
794
796
|
return initialValue
|
795
797
|
.map((option) => {
|
package/dist/published/components/custom/FormField/AddressFieldComponent/addressFieldComponent.js
CHANGED
@@ -34,12 +34,12 @@ const AddressFieldComponent = (props) => {
|
|
34
34
|
return { label, sublabel, value: address.address };
|
35
35
|
}));
|
36
36
|
});
|
37
|
-
props.onChange(property.id, inputValue, property, undefined);
|
37
|
+
props.onChange && props.onChange(property.id, inputValue, property, undefined);
|
38
38
|
};
|
39
39
|
const handleClick = (option) => {
|
40
40
|
setAnchorEl(null);
|
41
41
|
setValue(option.value.line1);
|
42
|
-
props.onChange(property.id, option.value, property, undefined);
|
42
|
+
props.onChange && props.onChange(property.id, option.value, property, undefined);
|
43
43
|
};
|
44
44
|
const handleClose = () => {
|
45
45
|
setAnchorEl(null);
|
@@ -17,7 +17,7 @@ const BooleanSelect = (props) => {
|
|
17
17
|
}, [defaultValue]);
|
18
18
|
const handleChange = (value) => {
|
19
19
|
setValue(value);
|
20
|
-
props.onChange(property.id, value, property);
|
20
|
+
props.onChange && props.onChange(property.id, value, property);
|
21
21
|
};
|
22
22
|
const booleanOptions = [
|
23
23
|
{
|
@@ -33,7 +33,7 @@ const DatePickerSelect = (props) => {
|
|
33
33
|
}, [defaultValue]);
|
34
34
|
const handleChange = (date) => {
|
35
35
|
setValue(date);
|
36
|
-
onChange(property.id, date, property);
|
36
|
+
onChange && onChange(property.id, date, property);
|
37
37
|
};
|
38
38
|
return readOnly ? (React.createElement(InputFieldComponent, { ...{ ...props, defaultValue: asMonthDayYearFormat(value) } })) : (React.createElement(LocalizationProvider, null,
|
39
39
|
React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, { ...params, id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size ?? 'medium', ...(additionalProps ?? {}) })) })));
|
package/dist/published/components/custom/FormField/DateTimePickerSelect/DateTimePickerSelect.js
CHANGED
@@ -40,7 +40,7 @@ const DateTimePickerSelect = (props) => {
|
|
40
40
|
date = LocalDateTime.of(date, LocalTime.of(0));
|
41
41
|
}
|
42
42
|
setValue(date);
|
43
|
-
props.onChange(property.id, date, property);
|
43
|
+
props.onChange && props.onChange(property.id, date, property);
|
44
44
|
};
|
45
45
|
return readOnly ? (React.createElement(InputFieldComponent, { ...{ ...props, defaultValue: formatDateTime(value) } })) : (React.createElement(LocalizationProvider, null,
|
46
46
|
React.createElement(DateTimePicker, { value: value, onChange: handleChange, renderInput: (params) => (React.createElement(TextField, { ...params, id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size ?? 'medium', ...(additionalProps ?? {}) })) })));
|
@@ -30,13 +30,13 @@ const FileUploadControl = (props) => {
|
|
30
30
|
};
|
31
31
|
useEffect(() => {
|
32
32
|
if (uploadedFile) {
|
33
|
-
props.onChange(property.id, uploadedFile, property);
|
33
|
+
props.onChange && props.onChange(property.id, uploadedFile, property);
|
34
34
|
}
|
35
35
|
}, [uploadedFile]);
|
36
36
|
const handleSelectFile = () => {
|
37
37
|
if (uploadedFile) {
|
38
38
|
setUploadedFile(undefined);
|
39
|
-
props.onChange(property.id, undefined, property);
|
39
|
+
props.onChange && props.onChange(property.id, undefined, property);
|
40
40
|
}
|
41
41
|
};
|
42
42
|
const onDrop = useCallback(
|
@@ -6,7 +6,7 @@ import { Address } from './AddressFieldComponent/addressFieldComponent';
|
|
6
6
|
export type FormFieldProps = {
|
7
7
|
id?: string;
|
8
8
|
property: ObjectProperty;
|
9
|
-
onChange
|
9
|
+
onChange?: Function;
|
10
10
|
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
11
11
|
defaultValue?: unknown;
|
12
12
|
error?: boolean;
|
package/dist/published/components/custom/FormField/InputFieldComponent/InputFieldComponent.js
CHANGED
@@ -26,11 +26,11 @@ const InputFieldComponent = (props) => {
|
|
26
26
|
? parseInt(e.target.value, 10)
|
27
27
|
: e.target.value;
|
28
28
|
setValue(inputValue);
|
29
|
-
props.onChange(property.id, inputValue, property);
|
29
|
+
props.onChange && props.onChange(property.id, inputValue, property);
|
30
30
|
};
|
31
31
|
const handleSelectChange = (e, selected) => {
|
32
32
|
setValue(selected.label);
|
33
|
-
props.onChange(property.id, selected.label, property);
|
33
|
+
props.onChange && props.onChange(property.id, selected.label, property);
|
34
34
|
};
|
35
35
|
const handleInputValueChange = (event, selectValue) => {
|
36
36
|
setInputValue(selectValue);
|
@@ -12,11 +12,12 @@ const Select = (props) => {
|
|
12
12
|
const handleChange = (event, selected) => {
|
13
13
|
if (Array.isArray(selected)) {
|
14
14
|
setValue(selected.map((option) => option.value ?? option));
|
15
|
-
props.onChange
|
15
|
+
props.onChange &&
|
16
|
+
props.onChange(property.id, selected.map((option) => option.value ?? option), property);
|
16
17
|
}
|
17
18
|
else {
|
18
19
|
setValue(selected);
|
19
|
-
props.onChange(property.id, selected, property);
|
20
|
+
props.onChange && props.onChange(property.id, selected, property);
|
20
21
|
}
|
21
22
|
};
|
22
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -32,11 +32,11 @@ const TimePickerSelect = (props) => {
|
|
32
32
|
const hour = padStart(date?.hour().toString(), 2, '0');
|
33
33
|
const minute = padStart(date?.minute().toString(), 2, '0');
|
34
34
|
const second = padStart(date?.second().toString(), 2, '0');
|
35
|
-
props.onChange(property.id, `${hour}:${minute}:${second}`, property);
|
35
|
+
props.onChange && props.onChange(property.id, `${hour}:${minute}:${second}`, property);
|
36
36
|
}
|
37
37
|
else {
|
38
38
|
setValue(null);
|
39
|
-
props.onChange(property.id, date, property);
|
39
|
+
props.onChange && props.onChange(property.id, date, property);
|
40
40
|
}
|
41
41
|
};
|
42
42
|
return (React.createElement(LocalizationProvider, null,
|