@micromerce/formbuilder-react 1.0.658 → 1.0.661
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/assets/icons/error/Error.js +6 -0
- package/dist/assets/icons/error/Error.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +37 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.module.scss +10 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/ControlWrapper/ControlWrapper.js +37 -0
- package/dist/components/ControlWrapper/ControlWrapper.js.map +1 -0
- package/dist/components/ControlWrapper/index.js +2 -0
- package/dist/components/ControlWrapper/index.js.map +1 -0
- package/dist/components/DateRangeGroup/DateRangeGroup.js +69 -0
- package/dist/components/DateRangeGroup/DateRangeGroup.js.map +1 -0
- package/dist/components/DateRangeGroup/DateRangeGroup.styles.js +59 -0
- package/dist/components/DateRangeGroup/DateRangeGroup.styles.js.map +1 -0
- package/dist/components/DateRangeGroup/components/CalendarModal.js +90 -0
- package/dist/components/DateRangeGroup/components/CalendarModal.js.map +1 -0
- package/dist/components/DateRangeGroup/index.js +2 -0
- package/dist/components/DateRangeGroup/index.js.map +1 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js +22 -0
- package/dist/components/ErrorBoundary/ErrorBoundary.js.map +1 -0
- package/dist/components/FileUploader/FileUploader.js +30 -0
- package/dist/components/FileUploader/FileUploader.js.map +1 -0
- package/dist/components/FileUploader/index.js +2 -0
- package/dist/components/FileUploader/index.js.map +1 -0
- package/dist/components/FormBuilder/FormBuilder.js +74 -0
- package/dist/components/FormBuilder/FormBuilder.js.map +1 -0
- package/dist/components/FormBuilder/FormBuilder.module.scss +94 -0
- package/dist/components/FormBuilder/index.js +2 -0
- package/dist/components/FormBuilder/index.js.map +1 -0
- package/dist/components/FormBuilder/utils/extractFormControlValues/extractFormControlValues.js +50 -0
- package/dist/components/FormBuilder/utils/extractFormControlValues/extractFormControlValues.js.map +1 -0
- package/dist/components/FormBuilder/utils/extractFormControlValues/index.js +2 -0
- package/dist/components/FormBuilder/utils/extractFormControlValues/index.js.map +1 -0
- package/dist/components/FormBuilder/utils/jsonToUrlEncoded/index.js +2 -0
- package/dist/components/FormBuilder/utils/jsonToUrlEncoded/index.js.map +1 -0
- package/dist/components/FormBuilder/utils/jsonToUrlEncoded/jsonToUrlEncoded.js +15 -0
- package/dist/components/FormBuilder/utils/jsonToUrlEncoded/jsonToUrlEncoded.js.map +1 -0
- package/dist/components/FormFooter/FormFooter.js +46 -0
- package/dist/components/FormFooter/FormFooter.js.map +1 -0
- package/dist/components/FormFooter/FormFooter.module.scss +65 -0
- package/dist/components/FormFooter/components/Switch.js +15 -0
- package/dist/components/FormFooter/components/Switch.js.map +1 -0
- package/dist/components/FormFooter/index.js +2 -0
- package/dist/components/FormFooter/index.js.map +1 -0
- package/dist/components/FormGroup/FormGroup.js +18 -0
- package/dist/components/FormGroup/FormGroup.js.map +1 -0
- package/dist/components/FormGroup/FormGroup.module.scss +69 -0
- package/dist/components/FormGroup/index.js +2 -0
- package/dist/components/FormGroup/index.js.map +1 -0
- package/dist/components/FormList/FormList.js +66 -0
- package/dist/components/FormList/FormList.js.map +1 -0
- package/dist/components/FormList/FormList.module.scss +173 -0
- package/dist/components/FormList/index.js +2 -0
- package/dist/components/FormList/index.js.map +1 -0
- package/dist/components/GeneralFormGroup/GeneralFormGroup.js +4 -0
- package/dist/components/GeneralFormGroup/GeneralFormGroup.js.map +1 -0
- package/dist/components/GeneralFormGroup/index.js +2 -0
- package/dist/components/GeneralFormGroup/index.js.map +1 -0
- package/dist/components/Group/Group.js +32 -0
- package/dist/components/Group/Group.js.map +1 -0
- package/dist/components/Group/Group.module.scss +28 -0
- package/dist/components/Group/index.js +2 -0
- package/dist/components/Group/index.js.map +1 -0
- package/dist/components/Input/Input.js +57 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/Input.module.scss +3 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Input/index.js.map +1 -0
- package/dist/components/Input/input.styles.js +24 -0
- package/dist/components/Input/input.styles.js.map +1 -0
- package/dist/components/InputFreeSolo/InputFreeSolo.js +67 -0
- package/dist/components/InputFreeSolo/InputFreeSolo.js.map +1 -0
- package/dist/components/InputFreeSolo/InputFreeSolo.module.scss +29 -0
- package/dist/components/InputFreeSolo/index.js +2 -0
- package/dist/components/InputFreeSolo/index.js.map +1 -0
- package/dist/components/MrnInput/MrnInput.js +64 -0
- package/dist/components/MrnInput/MrnInput.js.map +1 -0
- package/dist/components/MrnInput/MrnInput.module.scss +31 -0
- package/dist/components/MrnInput/hooks/useMrn.js +92 -0
- package/dist/components/MrnInput/hooks/useMrn.js.map +1 -0
- package/dist/components/MrnInput/index.js +2 -0
- package/dist/components/MrnInput/index.js.map +1 -0
- package/dist/components/MrnInput/services/fetchMrn.js +30 -0
- package/dist/components/MrnInput/services/fetchMrn.js.map +1 -0
- package/dist/components/MrnInput/ui-helper/Link/Link.js +15 -0
- package/dist/components/MrnInput/ui-helper/Link/Link.js.map +1 -0
- package/dist/components/MrnInput/utils/mrnUtils/mrnUtils.js +35 -0
- package/dist/components/MrnInput/utils/mrnUtils/mrnUtils.js.map +1 -0
- package/dist/components/MrnInput/utils/resolveMrnLinks/resolveMrnLink.js +11 -0
- package/dist/components/MrnInput/utils/resolveMrnLinks/resolveMrnLink.js.map +1 -0
- package/dist/components/MrnInput/utils/resolveNestedQueryLink/resolveNestedQueryLink.js +19 -0
- package/dist/components/MrnInput/utils/resolveNestedQueryLink/resolveNestedQueryLink.js.map +1 -0
- package/dist/components/MrnInput/utils/urlSearchParam/urlSearchParam.js +8 -0
- package/dist/components/MrnInput/utils/urlSearchParam/urlSearchParam.js.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.js +61 -0
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.module.scss +13 -0
- package/dist/components/MultiSelect/index.js +2 -0
- package/dist/components/MultiSelect/index.js.map +1 -0
- package/dist/components/MultiSelect/utils/extractSelectedOptionValues/extractSelectedOptionValues.js +21 -0
- package/dist/components/MultiSelect/utils/extractSelectedOptionValues/extractSelectedOptionValues.js.map +1 -0
- package/dist/components/MultiSelect/utils/extractSelectedOptionValues/index.js +2 -0
- package/dist/components/MultiSelect/utils/extractSelectedOptionValues/index.js.map +1 -0
- package/dist/components/PasswordInput/PasswordInput.js +21 -0
- package/dist/components/PasswordInput/PasswordInput.js.map +1 -0
- package/dist/components/PasswordInput/PasswordInput.module.scss +26 -0
- package/dist/components/PasswordInput/index.js +2 -0
- package/dist/components/PasswordInput/index.js.map +1 -0
- package/dist/components/QueryControl/QueryControl.js +95 -0
- package/dist/components/QueryControl/QueryControl.js.map +1 -0
- package/dist/components/QueryControl/data/defaultControls.js +95 -0
- package/dist/components/QueryControl/data/defaultControls.js.map +1 -0
- package/dist/components/QueryControl/index.js +2 -0
- package/dist/components/QueryControl/index.js.map +1 -0
- package/dist/components/QueryControl/ui-helper/Wrapper/QueryControlWrapper.js +8 -0
- package/dist/components/QueryControl/ui-helper/Wrapper/QueryControlWrapper.js.map +1 -0
- package/dist/components/QueryControl/ui-helper/Wrapper/QueryControlWrapper.styles.js +14 -0
- package/dist/components/QueryControl/ui-helper/Wrapper/QueryControlWrapper.styles.js.map +1 -0
- package/dist/components/QueryControl/ui-helper/Wrapper/index.js +2 -0
- package/dist/components/QueryControl/ui-helper/Wrapper/index.js.map +1 -0
- package/dist/components/QueryControl/utils/allControlsHidden/allControlsHidden.js +39 -0
- package/dist/components/QueryControl/utils/allControlsHidden/allControlsHidden.js.map +1 -0
- package/dist/components/QueryControl/utils/allControlsHidden/index.js +2 -0
- package/dist/components/QueryControl/utils/allControlsHidden/index.js.map +1 -0
- package/dist/components/QueryControl/utils/getMatchingControls.js +19 -0
- package/dist/components/QueryControl/utils/getMatchingControls.js.map +1 -0
- package/dist/components/QueryControl/utils/hasExpertControl/hasExpertControl.js +38 -0
- package/dist/components/QueryControl/utils/hasExpertControl/hasExpertControl.js.map +1 -0
- package/dist/components/QueryControl/utils/hasExpertControl/index.js +2 -0
- package/dist/components/QueryControl/utils/hasExpertControl/index.js.map +1 -0
- package/dist/components/QueryControl/utils/hideGroup/hideGroup.js +9 -0
- package/dist/components/QueryControl/utils/hideGroup/hideGroup.js.map +1 -0
- package/dist/components/QueryControl/utils/hideGroup/index.js +2 -0
- package/dist/components/QueryControl/utils/hideGroup/index.js.map +1 -0
- package/dist/components/Select/Select.js +67 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Select/Select.module.scss +15 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Select/utils/getSelectedOption.js +8 -0
- package/dist/components/Select/utils/getSelectedOption.js.map +1 -0
- package/dist/components/Textarea/Textarea.js +55 -0
- package/dist/components/Textarea/Textarea.js.map +1 -0
- package/dist/components/Textarea/Textarea.module.scss +14 -0
- package/dist/components/Textarea/Textarea.types.js +2 -0
- package/dist/components/Textarea/Textarea.types.js.map +1 -0
- package/dist/components/Textarea/aiWrapper/aiAction.js +21 -0
- package/dist/components/Textarea/aiWrapper/aiAction.js.map +1 -0
- package/dist/components/Textarea/aiWrapper/aiLayout.js +21 -0
- package/dist/components/Textarea/aiWrapper/aiLayout.js.map +1 -0
- package/dist/components/Textarea/aiWrapper/index.js +29 -0
- package/dist/components/Textarea/aiWrapper/index.js.map +1 -0
- package/dist/components/Textarea/aiWrapper/useAi.js +74 -0
- package/dist/components/Textarea/aiWrapper/useAi.js.map +1 -0
- package/dist/components/Textarea/editors/Default.js +26 -0
- package/dist/components/Textarea/editors/Default.js.map +1 -0
- package/dist/components/Textarea/editors/Html.js +9 -0
- package/dist/components/Textarea/editors/Html.js.map +1 -0
- package/dist/components/Textarea/editors/Json.js +9 -0
- package/dist/components/Textarea/editors/Json.js.map +1 -0
- package/dist/components/Textarea/editors/Markdown.js +20 -0
- package/dist/components/Textarea/editors/Markdown.js.map +1 -0
- package/dist/components/Textarea/editors/Richtext.js +13 -0
- package/dist/components/Textarea/editors/Richtext.js.map +1 -0
- package/dist/components/Textarea/index.js +2 -0
- package/dist/components/Textarea/index.js.map +1 -0
- package/dist/components/addressGroup/AddressGroup.js +39 -0
- package/dist/components/addressGroup/AddressGroup.js.map +1 -0
- package/dist/components/addressGroup/AddressGroup.module.scss +72 -0
- package/dist/components/addressGroup/index.js +2 -0
- package/dist/components/addressGroup/index.js.map +1 -0
- package/dist/components/addressGroup/utils/Countries.js +1249 -0
- package/dist/components/addressGroup/utils/Countries.js.map +1 -0
- package/dist/components/states/error/index.js +15 -0
- package/dist/components/states/error/index.js.map +1 -0
- package/dist/context/FormData.js +109 -0
- package/dist/context/FormData.js.map +1 -0
- package/dist/hooks/useDependent/enhanced/useInputDependent/useInputDependent.js +36 -0
- package/dist/hooks/useDependent/enhanced/useInputDependent/useInputDependent.js.map +1 -0
- package/dist/hooks/useDependent/enhanced/useOptionsGenerator/useOptionsGenerator.js +16 -0
- package/dist/hooks/useDependent/enhanced/useOptionsGenerator/useOptionsGenerator.js.map +1 -0
- package/dist/hooks/useDependent/useDependent.js +86 -0
- package/dist/hooks/useDependent/useDependent.js.map +1 -0
- package/dist/hooks/useValueGenerator/useValueGenerator.js +99 -0
- package/dist/hooks/useValueGenerator/useValueGenerator.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/Hidden.styles.js +16 -0
- package/dist/styles/Hidden.styles.js.map +1 -0
- package/dist/styles/Skeleton.js +40 -0
- package/dist/styles/Skeleton.js.map +1 -0
- package/dist/styles/Textfield.styles.js +34 -0
- package/dist/styles/Textfield.styles.js.map +1 -0
- package/dist/styles/formControl.module.scss +59 -0
- package/dist/testutils.js +22 -0
- package/dist/testutils.js.map +1 -0
- package/dist/types/controlProps.js +2 -0
- package/dist/types/controlProps.js.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/menu/hooks/useMenu.js +41 -0
- package/dist/ui/menu/hooks/useMenu.js.map +1 -0
- package/dist/ui/menu/index.js +13 -0
- package/dist/ui/menu/index.js.map +1 -0
- package/dist/ui/menu/test/createControl.js +30 -0
- package/dist/ui/menu/test/createControl.js.map +1 -0
- package/dist/ui/menu/utils/detemineSubmenuTabs/index.js +82 -0
- package/dist/ui/menu/utils/detemineSubmenuTabs/index.js.map +1 -0
- package/dist/ui-helper/HeaderCollapseButton/index.js +9 -0
- package/dist/ui-helper/HeaderCollapseButton/index.js.map +1 -0
- package/dist/ui-helper/notifications/Error.js +77 -0
- package/dist/ui-helper/notifications/Error.js.map +1 -0
- package/dist/ui-helper/notifications/images/background.js +7 -0
- package/dist/ui-helper/notifications/images/background.js.map +1 -0
- package/dist/ui-helper/notifications/images/spinner.js +6 -0
- package/dist/ui-helper/notifications/images/spinner.js.map +1 -0
- package/dist/ui-helper/notifications/images/under-improvement.js +6 -0
- package/dist/ui-helper/notifications/images/under-improvement.js.map +1 -0
- package/dist/utils/findFormControlError/index.js +24 -0
- package/dist/utils/findFormControlError/index.js.map +1 -0
- package/dist/utils/hasGroupRequiredFieldsWithValues/index.js +22 -0
- package/dist/utils/hasGroupRequiredFieldsWithValues/index.js.map +1 -0
- package/package.json +2 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import allControlsHidden from "../allControlsHidden";
|
|
2
|
+
import hasExpertControl from "../hasExpertControl";
|
|
3
|
+
const hideGroup = (controls, isExpertMode) => {
|
|
4
|
+
const controlsHidden = allControlsHidden(controls);
|
|
5
|
+
const expertControl = hasExpertControl(controls);
|
|
6
|
+
return expertControl ? !isExpertMode && controlsHidden : controlsHidden;
|
|
7
|
+
};
|
|
8
|
+
export default hideGroup;
|
|
9
|
+
//# sourceMappingURL=hideGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hideGroup.js","sourceRoot":"","sources":["../../../../../src/components/QueryControl/utils/hideGroup/hideGroup.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,MAAM,SAAS,GAAG,CAAC,QAAsB,EAAE,YAAqB,EAAE,EAAE;IAClE,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACjD,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;AAC1E,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/QueryControl/utils/hideGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Autocomplete from "@mui/material/Autocomplete";
|
|
3
|
+
import { useEffect, useState, } from "react";
|
|
4
|
+
import useOptionsGenerator from "../../hooks/useDependent/enhanced/useOptionsGenerator/useOptionsGenerator";
|
|
5
|
+
import TextField from "../../styles/Textfield.styles";
|
|
6
|
+
import * as styles from "./Select.module.scss";
|
|
7
|
+
import getSelectedOption from "./utils/getSelectedOption";
|
|
8
|
+
const Select = ({ onChangeValue, controlProps, ...props }) => {
|
|
9
|
+
const { id, control, objectPathId } = props;
|
|
10
|
+
const { error, options, placeholder, required, value, "custom-attributes": customAttributes, } = control;
|
|
11
|
+
const errorClass = error ? "error" : "";
|
|
12
|
+
const defaultOptions = getSelectedOption(options, value);
|
|
13
|
+
const requiredPlaceholder = placeholder
|
|
14
|
+
? required
|
|
15
|
+
? placeholder + " *"
|
|
16
|
+
: placeholder
|
|
17
|
+
: "";
|
|
18
|
+
const { options: generatedOptions } = useOptionsGenerator({
|
|
19
|
+
controlKey: id,
|
|
20
|
+
objectPathId,
|
|
21
|
+
options,
|
|
22
|
+
query: customAttributes?.optionsGenerator,
|
|
23
|
+
});
|
|
24
|
+
const [selectedOption, setSelectedOption] = useState(defaultOptions);
|
|
25
|
+
const [inputValue, setInputValue] = useState("");
|
|
26
|
+
const currObjectPathId = objectPathId || id;
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!value) {
|
|
29
|
+
//* value is undefinded in backend
|
|
30
|
+
const selectedOpt = getSelectedOption(options, value);
|
|
31
|
+
determineSelectedOption({ option: selectedOpt });
|
|
32
|
+
}
|
|
33
|
+
if (value !== selectedOption?.value) {
|
|
34
|
+
const selectedOpt = getSelectedOption(options, value);
|
|
35
|
+
determineSelectedOption({ option: selectedOpt, hasChanged: false });
|
|
36
|
+
}
|
|
37
|
+
}, [value]);
|
|
38
|
+
const determineSelectedOption = ({ option, hasChanged = true, }) => {
|
|
39
|
+
setSelectedOption(option);
|
|
40
|
+
onChangeValue({
|
|
41
|
+
value: option?.value || "",
|
|
42
|
+
options: [
|
|
43
|
+
...options?.map((opt) => ({
|
|
44
|
+
...opt,
|
|
45
|
+
selected: opt.value === option?.value,
|
|
46
|
+
})),
|
|
47
|
+
],
|
|
48
|
+
hasChanged,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
return (_jsx(Autocomplete, { className: styles["select-container"], id: currObjectPathId, "data-testid": `select-container ${id}`, disableClearable: true, size: "small", sx: controlProps?.selectProps?.sx, value: selectedOption, readOnly: customAttributes?.readOnly, onChange: (e, option) => determineSelectedOption({ option }), isOptionEqualToValue: (option, value) => option.value === value.value, inputValue: inputValue, onInputChange: (e, newInputValue) => setInputValue(newInputValue), options: generatedOptions, getOptionLabel: (option) => option.text, ListboxProps: {
|
|
52
|
+
sx: {
|
|
53
|
+
"& .MuiAutocomplete-option": {
|
|
54
|
+
minHeight: "40px",
|
|
55
|
+
},
|
|
56
|
+
...controlProps?.selectProps?.listBox?.sx,
|
|
57
|
+
},
|
|
58
|
+
}, renderInput: (params) => (_jsx(TextField, { ...params, className: styles[errorClass], placeholder: requiredPlaceholder, required: required, sx: {
|
|
59
|
+
"& > div": { minWidth: "0 !important" },
|
|
60
|
+
"& .MuiInputBase-root": {
|
|
61
|
+
height: "40px",
|
|
62
|
+
},
|
|
63
|
+
...controlProps?.selectProps?.textField?.sx,
|
|
64
|
+
} })) }));
|
|
65
|
+
};
|
|
66
|
+
export default Select;
|
|
67
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,4BAA4B,CAAC;AACtD,OAAc,EAGZ,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,mBAAmB,MAAM,2EAA2E,CAAC;AAC5G,OAAO,SAAS,MAAM,+BAA+B,CAAC;AAOtD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAC/C,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAc1D,MAAM,MAAM,GAAG,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,EAAU,EAAE,EAAE;IACnE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC5C,MAAM,EACJ,KAAK,EACL,OAAO,EACP,WAAW,EACX,QAAQ,EACR,KAAK,EACL,mBAAmB,EAAE,gBAAgB,GACtC,GAAG,OAAO,CAAC;IACZ,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,WAAW;QACrC,CAAC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AE,QAAQ,EAAE,cAAc,EAAE;gBACvC,sBAAsB,EAAE;oBACtB,MAAM,EAAE,MAAM;iBACf;gBACD,GAAG,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;aAC5C,GACD,CACH,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.select-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
background-color: white;
|
|
5
|
+
|
|
6
|
+
input {
|
|
7
|
+
color: rgba(0, 0, 0, 0.54) !important;
|
|
8
|
+
font-weight: 400 !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&:has(input[readonly]) {
|
|
12
|
+
background-color: #e0e0e033;
|
|
13
|
+
cursor: not-allowed;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const getSelectedOption = (options, value) => {
|
|
2
|
+
const selectedOption = options
|
|
3
|
+
.map((option) => (option.selected && !value) || option.value === value ? option : null)
|
|
4
|
+
.filter((x) => !!x);
|
|
5
|
+
return selectedOption[0] || options[0];
|
|
6
|
+
};
|
|
7
|
+
export default getSelectedOption;
|
|
8
|
+
//# sourceMappingURL=getSelectedOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectedOption.js","sourceRoot":"","sources":["../../../../src/components/Select/utils/getSelectedOption.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,CACxB,OAAkC,EAClC,KAAa,EACY,EAAE;IAC3B,MAAM,cAAc,GAAG,OAAO;SAC3B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACd,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CACtE;SACA,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect, } from "react";
|
|
3
|
+
import { FormDataContext } from "../../context/FormData";
|
|
4
|
+
import useInputDependent from "../../hooks/useDependent/enhanced/useInputDependent/useInputDependent";
|
|
5
|
+
import * as styles from "./Textarea.module.scss";
|
|
6
|
+
import AiWrapper from "./aiWrapper";
|
|
7
|
+
import DefaultEditor from "./editors/Default";
|
|
8
|
+
import HtmlEditor from "./editors/Html";
|
|
9
|
+
import JsonEditor from "./editors/Json";
|
|
10
|
+
import MarkdownEditor from "./editors/Markdown";
|
|
11
|
+
import RichTextEditor from "./editors/Richtext";
|
|
12
|
+
const Textarea = ({ onChangeValue, ...props }) => {
|
|
13
|
+
const { control, id, objectPathId } = props;
|
|
14
|
+
const { value = "", "custom-attributes": customAttributes, error, hasEdited, } = control;
|
|
15
|
+
const currObjectPathId = objectPathId || id;
|
|
16
|
+
const errorClass = error ? "error" : "";
|
|
17
|
+
const query = customAttributes?.defaultValue;
|
|
18
|
+
const { textColor } = useInputDependent({
|
|
19
|
+
onChangeValue,
|
|
20
|
+
query,
|
|
21
|
+
objectPathId,
|
|
22
|
+
value,
|
|
23
|
+
hasEdited,
|
|
24
|
+
});
|
|
25
|
+
const genAiPrompts = customAttributes?.genAiPrompts;
|
|
26
|
+
const { toggleRerendered } = useContext(FormDataContext);
|
|
27
|
+
const TYPE = control.type;
|
|
28
|
+
const EDITOR_TYPE = customAttributes?.editor;
|
|
29
|
+
const readOnly = customAttributes?.readOnly;
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
onChangeValue({ value: value || "" });
|
|
32
|
+
}, [toggleRerendered]);
|
|
33
|
+
const renderEditor = () => {
|
|
34
|
+
switch (EDITOR_TYPE) {
|
|
35
|
+
case "richtext":
|
|
36
|
+
return RichTextEditor;
|
|
37
|
+
case "markdown":
|
|
38
|
+
return MarkdownEditor;
|
|
39
|
+
default:
|
|
40
|
+
if (TYPE === "html") {
|
|
41
|
+
return HtmlEditor;
|
|
42
|
+
}
|
|
43
|
+
else if (TYPE === "json") {
|
|
44
|
+
return JsonEditor;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return DefaultEditor;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const TextareaControl = renderEditor();
|
|
52
|
+
return (_jsx("div", { className: `${styles.textarea} textarea-control`, "data-testid": `textarea-${currObjectPathId}`, children: _jsx("div", { className: styles.textareaWithBorder, children: _jsx(AiWrapper, { aiActions: genAiPrompts, inputControl: _jsx(TextareaControl, { control: control, errorClass: errorClass, textColor: textColor, value: value, onChangeValue: onChangeValue, onChange: onChangeValue, id: currObjectPathId, readOnly: readOnly }), AiResponseControl: TextareaControl, onAcceptAiResponse: onChangeValue, objectPathId: currObjectPathId }) }) }));
|
|
53
|
+
};
|
|
54
|
+
export default Textarea;
|
|
55
|
+
//# sourceMappingURL=Textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../../src/components/Textarea/Textarea.tsx"],"names":[],"mappings":";AAAA,OAAc,EAGZ,UAAU,EACV,SAAS,GACV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,iBAAiB,MAAM,uEAAuE,CAAC;AAEtG,OAAO,KAAK,MAAM,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B,CAAC,CAAC,CAAC;IAEvB,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,UAAU;gBACb,OAAO,cAAc,CAAC;YACxB,KAAK,UAAU;gBACb,OAAO,cAAc,CAAC;YACxB;gBACE,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;oBACpB,OAAO,UAAU,CAAC;gBACpB,CAAC;qBAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;oBAC3B,OAAO,UAAU,CAAC;gBACpB,CAAC;qBAAM,CAAC;oBACN,OAAO,aAAa,CAAC;gBACvB,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,YAAY,EAAS,CAAC;IAE9C,OAAO,CACL,cACE,SAAS,EAAE,GAAG,MAAM,CAAC,QAAQ,mBAAmB,iBACnC,YAAY,gBAAgB,EAAE,YAE3C,cAAK,SAAS,EAAE,MAAM,CAAC,kBAAkB,YACvC,KAAC,SAAS,IACR,SAAS,EAAE,YAAY,EACvB,YAAY,EACV,KAAC,eAAe,IACd,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,aAAa,EACvB,EAAE,EAAE,gBAAgB,EACpB,QAAQ,EAAE,QAAQ,GAClB,EAEJ,iBAAiB,EAAE,eAAe,EAClC,kBAAkB,EAAE,aAAa,EACjC,YAAY,EAAE,gBAAgB,GAC9B,GACE,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.types.js","sourceRoot":"","sources":["../../../src/components/Textarea/Textarea.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// styles
|
|
3
|
+
import "./global-ai-wrapper.css";
|
|
4
|
+
import * as styles from "./index.module.scss";
|
|
5
|
+
import useDependent from "../../../hooks/useDependent/useDependent";
|
|
6
|
+
// components
|
|
7
|
+
import Spinner from "../../../ui-helper/notifications/images/spinner";
|
|
8
|
+
const AiAction = ({ action, objectPathId, isLoading, isDisabled, index, onClick, }) => {
|
|
9
|
+
const { resolvedQuery: resolvedPromptTemplate } = useDependent({
|
|
10
|
+
query: action.promptTemplate,
|
|
11
|
+
objectPathId,
|
|
12
|
+
});
|
|
13
|
+
const handleOnClick = () => {
|
|
14
|
+
if (isLoading)
|
|
15
|
+
return;
|
|
16
|
+
onClick(resolvedPromptTemplate, action.profile, index);
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs("button", { onClick: handleOnClick, className: `${styles.actionButton} ${isLoading ? styles.actionButtonLoading : ""}`, disabled: isDisabled, "data-testid": "textarea-ai-wrapper-action-button", type: "button", children: [_jsx("p", { children: action.displayValue }), isLoading && _jsx(Spinner, {})] }));
|
|
19
|
+
};
|
|
20
|
+
export default AiAction;
|
|
21
|
+
//# sourceMappingURL=aiAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiAction.js","sourceRoot":"","sources":["../../../../src/components/Textarea/aiWrapper/aiAction.tsx"],"names":[],"mappings":";AAGA,SAAS;AACT,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAI9C,OAAO,YAAY,MAAM,0CAA0C,CAAC;AAEpE,aAAa;AACb,OAAO,OAAO,MAAM,iDAAiD,CAAC;AAWtE,MAAM,QAAQ,GAAG,CAAC,EAChB,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,EACV,KAAK,EACL,OAAO,GACO,EAAE,EAAE;IAClB,MAAM,EAAE,aAAa,EAAE,sBAAsB,EAAE,GAAG,YAAY,CAAC;QAC7D,KAAK,EAAE,MAAM,CAAC,cAAc;QAC5B,YAAY;KACb,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,IAAI,SAAS;YAAE,OAAO;QAEtB,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC;IAEF,OAAO,CACL,kBACE,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,GAAG,MAAM,CAAC,YAAY,IAC/B,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAC3C,EAAE,EACF,QAAQ,EAAE,UAAU,iBACR,mCAAmC,EAC/C,IAAI,EAAC,QAAQ,aAEb,sBAAI,MAAM,CAAC,YAAY,GAAK,EAC3B,SAAS,IAAI,KAAC,OAAO,KAAG,IAClB,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// styles
|
|
3
|
+
import "./global-ai-wrapper.css";
|
|
4
|
+
import * as styles from "./index.module.scss";
|
|
5
|
+
// components
|
|
6
|
+
import { Tooltip } from "@mui/material";
|
|
7
|
+
import { FaCompressAlt } from "@react-icons/all-files/fa/FaCompressAlt";
|
|
8
|
+
import { FaExpandAlt } from "@react-icons/all-files/fa/FaExpandAlt";
|
|
9
|
+
import cx from "classnames";
|
|
10
|
+
import ErrorNotification from "../../../ui-helper/notifications/Error";
|
|
11
|
+
import AiAction from "./aiAction";
|
|
12
|
+
const AiLayout = ({ AiResponseControl, aiActions, inputControl, objectPathId, aiResponse, isError, isLoading, loadingActionIndex, modalOpen, onModalToggle, handleAccept, handleAiActionClick, handleDiscard, handleBack, handleRetry, }) => {
|
|
13
|
+
return (_jsxs("div", { className: cx(styles.aiWrapperContainer, {
|
|
14
|
+
[styles.expanded]: modalOpen,
|
|
15
|
+
}), "data-testid": "textarea-ai-wrapper", children: [_jsxs("div", { className: styles.aiWrapperContentContainer, children: [_jsx("div", { className: `${styles.aiWrapperContentWrapper} aiWrapperContentWrapper`, children: isError.state ? (_jsx(ErrorNotification, { onBack: handleBack, onRetry: handleRetry })) : (_jsxs(_Fragment, { children: [inputControl, aiResponse && (_jsx("div", { className: styles.aiResponseInputControlContainer, "data-testid": "textarea-ai-response-container", children: _jsx(AiResponseControl, { value: aiResponse.message, readonly: true }) }))] })) }), aiResponse && (_jsxs("div", { className: styles.aiWrapperActionsContainer, "data-testid": "textarea-ai-wrapper-response-actions", children: [_jsxs("button", { onClick: handleDiscard, className: styles.discardButton, "data-testid": "textarea-ai-wrapper-discard-button", type: "button", children: [_jsx("p", { children: "Discard Changes" }), _jsx("i", { className: "fas fa-times" })] }), _jsxs("button", { onClick: handleAccept, className: styles.acceptButton, "data-testid": "textarea-ai-wrapper-accept-button", type: "button", children: [_jsx("p", { children: "Accept Changes" }), _jsx("i", { className: "fas fa-check" })] })] }))] }), _jsxs("div", { className: styles.aiWrapperFooterContainer, "data-testid": "textarea-ai-wrapper-footer", children: [_jsx("div", { className: styles.footerAiIcon, children: aiActions?.length > 0 && (_jsx(Tooltip, { title: "Powered by Artificial Intelligence", arrow: true, componentsProps: {
|
|
16
|
+
arrow: { sx: { color: "#333" } },
|
|
17
|
+
tooltip: { sx: { backgroundColor: "#333", color: "white" } },
|
|
18
|
+
}, children: _jsx("i", { className: "fas fa-sparkles fa-lg" }) })) }), _jsxs("div", { className: styles.aiActionsRightContainer, children: [_jsx("div", { className: styles.aiActionsContainer, "data-testid": "textarea-ai-wrapper-actions", children: aiActions?.map((action, index) => (_jsx(AiAction, { onClick: handleAiActionClick, action: action, objectPathId: objectPathId, isLoading: isLoading && loadingActionIndex === index, isDisabled: isLoading && loadingActionIndex !== index, index: index }, index))) }), !modalOpen && (_jsx(FaExpandAlt, { size: 18, className: styles.expandButton, "data-testid": "textarea-ai-wrapper-expand-button", onClick: onModalToggle })), modalOpen && (_jsx(FaCompressAlt, { size: 18, className: styles.expandButton, "data-testid": "textarea-ai-wrapper-close-button", onClick: onModalToggle }))] })] })] }));
|
|
19
|
+
};
|
|
20
|
+
export default AiLayout;
|
|
21
|
+
//# sourceMappingURL=aiLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aiLayout.js","sourceRoot":"","sources":["../../../../src/components/Textarea/aiWrapper/aiLayout.tsx"],"names":[],"mappings":";AAIA,SAAS;AACT,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAM9C,aAAa;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,QAAQ,MAAM,YAAY,CAAC;AASlC,MAAM,QAAQ,GAAG,CAAC,EAChB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,WAAW,GACG,EAAE,EAAE;IAClB,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,kBAAkB,EAAE;YACvC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS;SAC7B,CAAC,iBACU,qBAAqB,aAEjC,eAAK,SAAS,EAAE,MAAM,CAAC,yBAAyB,aAC9C,cACE,SAAS,EAAE,GAAG,MAAM,CAAC,uBAAuB,0BAA0B,YAErE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CACf,KAAC,iBAAiB,IAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAA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,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CACjC,KAAC,QAAQ,IAEP,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,IAAI,kBAAkB,KAAK,KAAK,EACpD,UAAU,EAAE,SAAS,IAAI,kBAAkB,KAAK,KAAK,EACrD,KAAK,EAAE,KAAK,IANP,KAAK,CAOV,CACH,CAAC,GACE,EACL,CAAC,SAAS,IAAI,CACb,KAAC,WAAW,IACV,IAAI,EAAE,EAAE,EACR,SAAS,EAAE,MAAM,CAAC,YAAY,iBAClB,mCAAmC,EAC/C,OAAO,EAAE,aAAa,GACtB,CACH,EACA,SAAS,IAAI,CACZ,KAAC,aAAa,IACZ,IAAI,EAAE,EAAE,EACR,SAAS,EAAE,MAAM,CAAC,YAAY,iBAClB,kCAAkC,EAC9C,OAAO,EAAE,aAAa,GACtB,CACH,IACG,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// hooks
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import useAi from "./useAi";
|
|
5
|
+
// components
|
|
6
|
+
import AiLayout from "./aiLayout";
|
|
7
|
+
import Box from "@mui/material/Box";
|
|
8
|
+
import Modal from "@mui/material/Modal";
|
|
9
|
+
const modalBoxStyle = {
|
|
10
|
+
position: "fixed",
|
|
11
|
+
display: "flex",
|
|
12
|
+
top: "50%",
|
|
13
|
+
left: "50%",
|
|
14
|
+
transform: "translate(-50%, -50%)",
|
|
15
|
+
width: "calc(100% - 32px)",
|
|
16
|
+
height: "calc(100% - 32px)",
|
|
17
|
+
bgcolor: "background.paper",
|
|
18
|
+
borderRadius: "4px",
|
|
19
|
+
};
|
|
20
|
+
const AiWrapper = ({ ...props }) => {
|
|
21
|
+
const { onAcceptAiResponse } = props;
|
|
22
|
+
const useAiProps = useAi({ onAcceptAiResponse });
|
|
23
|
+
const aiLayoutProps = { ...useAiProps, ...props };
|
|
24
|
+
const [open, setOpen] = useState(false);
|
|
25
|
+
const handleToggle = () => setOpen((t) => !t);
|
|
26
|
+
return (_jsxs(_Fragment, { children: [!open && (_jsx(AiLayout, { ...aiLayoutProps, modalOpen: open, onModalToggle: handleToggle })), _jsx(Modal, { open: open, children: _jsx(Box, { sx: modalBoxStyle, children: _jsx(AiLayout, { ...aiLayoutProps, modalOpen: open, onModalToggle: handleToggle }) }) })] }));
|
|
27
|
+
};
|
|
28
|
+
export default AiWrapper;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Textarea/aiWrapper/index.tsx"],"names":[],"mappings":";AAGA,QAAQ;AACR,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,aAAa;AACb,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,MAAM,aAAa,GAAG;IACpB,QAAQ,EAAE,OAAO;IACjB,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,uBAAuB;IAClC,KAAK,EAAE,mBAAmB;IAC1B,MAAM,EAAE,mBAAmB;IAC3B,OAAO,EAAE,kBAAkB;IAC3B,YAAY,EAAE,KAAK;CACpB,CAAC;AAUF,MAAM,SAAS,GAAG,CAAC,EAAE,GAAG,KAAK,EAAkB,EAAE,EAAE;IACjD,MAAM,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,CAAC;IAElD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9C,OAAO,CACL,8BACG,CAAC,IAAI,IAAI,CACR,KAAC,QAAQ,OACH,aAAa,EACjB,SAAS,EAAE,IAAI,EACf,aAAa,EAAE,YAAY,GAC3B,CACH,EACD,KAAC,KAAK,IAAC,IAAI,EAAE,IAAI,YACf,KAAC,GAAG,IAAC,EAAE,EAAE,aAAa,YACpB,KAAC,QAAQ,OACH,aAAa,EACjB,SAAS,EAAE,IAAI,EACf,aAAa,EAAE,YAAY,GAC3B,GACE,GACA,IACP,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// hooks
|
|
2
|
+
import { useContext, useState } from "react";
|
|
3
|
+
// context
|
|
4
|
+
import { FormDataContext } from "../../../context/FormData";
|
|
5
|
+
const useAi = ({ onAcceptAiResponse }) => {
|
|
6
|
+
const [aiResponse, setAiResponse] = useState(null);
|
|
7
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
8
|
+
const [isError, setIsError] = useState({
|
|
9
|
+
state: false,
|
|
10
|
+
message: "",
|
|
11
|
+
prompt: "",
|
|
12
|
+
profile: "",
|
|
13
|
+
});
|
|
14
|
+
const [loadingActionIndex, setLoadingActionIndex] = useState(null);
|
|
15
|
+
const { postGenAiMessage } = useContext(FormDataContext);
|
|
16
|
+
const handleAiActionClick = async (prompt, profile, index) => {
|
|
17
|
+
setIsLoading(true);
|
|
18
|
+
setLoadingActionIndex(index);
|
|
19
|
+
const response = await postGenAiMessage?.({ message: prompt, profile });
|
|
20
|
+
if (response.status === "success") {
|
|
21
|
+
setAiResponse(response);
|
|
22
|
+
setIsError({
|
|
23
|
+
state: false,
|
|
24
|
+
message: "",
|
|
25
|
+
prompt: "",
|
|
26
|
+
profile: "",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setIsError({
|
|
31
|
+
state: true,
|
|
32
|
+
message: response.message,
|
|
33
|
+
profile,
|
|
34
|
+
prompt,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
setIsLoading(false);
|
|
38
|
+
setLoadingActionIndex(null);
|
|
39
|
+
};
|
|
40
|
+
const handleAccept = () => {
|
|
41
|
+
onAcceptAiResponse({ value: aiResponse.message });
|
|
42
|
+
setAiResponse(null);
|
|
43
|
+
};
|
|
44
|
+
const handleDiscard = () => {
|
|
45
|
+
setAiResponse(null);
|
|
46
|
+
};
|
|
47
|
+
const handleBack = () => {
|
|
48
|
+
setAiResponse(null);
|
|
49
|
+
setIsError({
|
|
50
|
+
state: false,
|
|
51
|
+
message: "",
|
|
52
|
+
prompt: "",
|
|
53
|
+
profile: "",
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const handleRetry = async () => {
|
|
57
|
+
if (isError.prompt) {
|
|
58
|
+
await handleAiActionClick(isError.prompt, isError.profile, loadingActionIndex);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
aiResponse,
|
|
63
|
+
isLoading,
|
|
64
|
+
isError,
|
|
65
|
+
loadingActionIndex,
|
|
66
|
+
handleAiActionClick,
|
|
67
|
+
handleAccept,
|
|
68
|
+
handleDiscard,
|
|
69
|
+
handleBack,
|
|
70
|
+
handleRetry,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export default useAi;
|
|
74
|
+
//# sourceMappingURL=useAi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAi.js","sourceRoot":"","sources":["../../../../src/components/Textarea/ai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UAAU,CAAC;gBACT,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,OAAO;gBACP,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QAED,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,kBAAkB,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QAClD,aAAa,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,aAAa,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,UAAU,CAAC;YACT,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,mBAAmB,CACvB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,OAAO,EACf,kBAAkB,CACnB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,UAAU;QACV,SAAS;QACT,OAAO;QACP,kBAAkB;QAClB,mBAAmB;QACnB,YAAY;QACZ,aAAa;QACb,UAAU;QACV,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import TextareaAutosize from "@mui/material/TextareaAutosize";
|
|
3
|
+
import omit from "lodash/omit";
|
|
4
|
+
import * as styles from "../../../styles/formControl.module.scss";
|
|
5
|
+
import * as textareaStyles from "../Textarea.module.scss";
|
|
6
|
+
const DefaultEditor = ({ value, onChange, id, readOnly, control, errorClass, textColor, }) => {
|
|
7
|
+
const { "custom-attributes": customAttributes, error, ...restControl } = control ?? {};
|
|
8
|
+
const handleOnChange = (e) => {
|
|
9
|
+
onChange?.({ value: e.target.value, hasEdited: "edited" });
|
|
10
|
+
};
|
|
11
|
+
return (_jsx(TextareaAutosize, { role: "textbox", "data-testid": `textarea-control-${id}`, className: `${styles["form-control"]} ${textareaStyles[errorClass]}`, id: id, name: id, style: {
|
|
12
|
+
flex: "1",
|
|
13
|
+
maxHeight: 400,
|
|
14
|
+
resize: "vertical",
|
|
15
|
+
overflow: "auto",
|
|
16
|
+
color: textColor,
|
|
17
|
+
width: "100%",
|
|
18
|
+
}, value: value, readOnly: readOnly, onChange: handleOnChange, ...omit(customAttributes, ["defaultValue"]), ...omit(restControl, [
|
|
19
|
+
"displayName",
|
|
20
|
+
"control",
|
|
21
|
+
"error",
|
|
22
|
+
"defaultValue",
|
|
23
|
+
]) }));
|
|
24
|
+
};
|
|
25
|
+
export default DefaultEditor;
|
|
26
|
+
//# sourceMappingURL=Default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Default.js","sourceRoot":"","sources":["../../../../src/components/Textarea/editors/Default.tsx"],"names":[],"mappings":";AAAA,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAC9D,OAAO,IAAI,MAAM,aAAa,CAAC;AAM/B,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;AAElE,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAgB1D,MAAM,aAAa,GAAG,CAAC,EACrB,KAAK,EACL,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,OAAO,EACP,UAAU,EACV,SAAS,GACF,EAAE,EAAE;IACX,MAAM,EACJ,mBAAmB,EAAE,gBAAgB,EACrC,KAAK,EACL,GAAG,WAAW,EACf,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,MAAM,cAAc,GAAG,CAAC,CAAmC,EAAE,EAAE;QAC7D,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,gBAAgB,IACf,IAAI,EAAC,SAAS,iBACD,oBAAoB,EAAE,EAAE,EACrC,SAAS,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE,EACpE,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,EAAE,EACR,KAAK,EAAE;YACL,IAAI,EAAE,GAAG;YACT,SAAS,EAAE,GAAG;YACd,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,MAAM;SACd,EACD,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,cAAc,KACpB,IAAI,CAAC,gBAAgB,EAAE,CAAC,cAAc,CAAC,CAAC,KACxC,IAAI,CAAC,WAAW,EAAE;YACpB,aAAa;YACb,SAAS;YACT,OAAO;YACP,cAAc;SACf,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { html } from "@codemirror/lang-html";
|
|
3
|
+
import { EditorView } from "@codemirror/view";
|
|
4
|
+
import CodeMirror from "@uiw/react-codemirror";
|
|
5
|
+
const HtmlEditor = ({ value, onChange, id, readOnly, }) => {
|
|
6
|
+
return (_jsx(CodeMirror, { readOnly: readOnly, value: value, extensions: [html(), EditorView.lineWrapping], onChange: (value) => onChange?.({ value }), id: id, role: "textbox", "data-testid": "code-editor", height: "300px", width: "100%" }));
|
|
7
|
+
};
|
|
8
|
+
export default HtmlEditor;
|
|
9
|
+
//# sourceMappingURL=Html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Html.js","sourceRoot":"","sources":["../../../../src/components/Textarea/editors/Html.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAW/C,MAAM,UAAU,GAA+B,CAAC,EAC9C,KAAK,EACL,QAAQ,EACR,EAAE,EACF,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,UAAU,IACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,YAAY,CAAC,EAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAC1C,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,SAAS,iBACF,aAAa,EACzB,MAAM,EAAC,OAAO,EACd,KAAK,EAAC,MAAM,GACZ,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { json } from "@codemirror/lang-json";
|
|
3
|
+
import { EditorView } from "@codemirror/view";
|
|
4
|
+
import CodeMirror from "@uiw/react-codemirror";
|
|
5
|
+
const CodeEditor = ({ value, onChange, id, readOnly, }) => {
|
|
6
|
+
return (_jsx(CodeMirror, { readOnly: readOnly, value: value, extensions: [json(), EditorView.lineWrapping], onChange: (value) => onChange?.({ value }), id: id, role: "textbox", "data-testid": "code-editor", height: "300px", width: "100%" }));
|
|
7
|
+
};
|
|
8
|
+
export default CodeEditor;
|
|
9
|
+
//# sourceMappingURL=Json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Json.js","sourceRoot":"","sources":["../../../../src/components/Textarea/editors/Json.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAW/C,MAAM,UAAU,GAA+B,CAAC,EAC9C,KAAK,EACL,QAAQ,EACR,EAAE,EACF,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,UAAU,IACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,YAAY,CAAC,EAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAC1C,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,SAAS,iBACF,aAAa,EACzB,MAAM,EAAC,OAAO,EACd,KAAK,EAAC,MAAM,GACZ,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { markdown, markdownLanguage } from "@codemirror/lang-markdown";
|
|
3
|
+
import { HighlightStyle, defaultHighlightStyle, syntaxHighlighting, } from "@codemirror/language";
|
|
4
|
+
import { EditorView } from "@codemirror/view";
|
|
5
|
+
import { tags } from "@lezer/highlight";
|
|
6
|
+
import CodeMirror from "@uiw/react-codemirror";
|
|
7
|
+
const MarkdownEditor = ({ value, onChange, id, readOnly, }) => {
|
|
8
|
+
return (_jsx(CodeMirror, { readOnly: readOnly, value: value, onChange: (value) => onChange?.({ value }), extensions: [
|
|
9
|
+
markdown({ base: markdownLanguage }),
|
|
10
|
+
syntaxHighlighting(defaultHighlightStyle),
|
|
11
|
+
syntaxHighlighting(HighlightStyle.define([
|
|
12
|
+
{ tag: tags.heading1, fontSize: "24px" },
|
|
13
|
+
{ tag: tags.heading2, fontSize: "20px" },
|
|
14
|
+
{ tag: tags.heading3, fontSize: "16px" },
|
|
15
|
+
])),
|
|
16
|
+
EditorView.lineWrapping,
|
|
17
|
+
], id: id, role: "textbox", "data-testid": "markdown-editor", height: "300px", width: "100%" }));
|
|
18
|
+
};
|
|
19
|
+
export default MarkdownEditor;
|
|
20
|
+
//# sourceMappingURL=Markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../../src/components/Textarea/editors/Markdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAW/C,MAAM,cAAc,GAAmC,CAAC,EACtD,KAAK,EACL,QAAQ,EACR,EAAE,EACF,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,UAAU,IACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAC1C,UAAU,EAAE;YACV,QAAQ,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;YACpC,kBAAkB,CAAC,qBAAqB,CAAC;YACzC,kBAAkB,CAChB,cAAc,CAAC,MAAM,CAAC;gBACpB,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE;gBACxC,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE;gBACxC,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE;aACzC,CAAC,CACH;YACD,UAAU,CAAC,YAAY;SACxB,EACD,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,SAAS,iBACF,iBAAiB,EAC7B,MAAM,EAAC,OAAO,EACd,KAAK,EAAC,MAAM,GACZ,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ReactQuill from "react-quill";
|
|
3
|
+
import "react-quill/dist/quill.snow.css";
|
|
4
|
+
import "./Richtext.css";
|
|
5
|
+
const RichTextEditor = ({ value, onChange, id, readOnly, }) => {
|
|
6
|
+
return (_jsx(ReactQuill, { readOnly: readOnly, theme: "snow", value: value, onChange: (value) => onChange?.({ value }), style: { height: "300px", paddingBottom: "41px", width: "100%" }, id: id, modules: {
|
|
7
|
+
clipboard: {
|
|
8
|
+
matchVisual: false, //* prevent injection of extra <p><br></p> between headers
|
|
9
|
+
},
|
|
10
|
+
}, "data-testid": "richtext-editor" }));
|
|
11
|
+
};
|
|
12
|
+
export default RichTextEditor;
|
|
13
|
+
//# sourceMappingURL=Richtext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Richtext.js","sourceRoot":"","sources":["../../../../src/components/Textarea/editors/Richtext.tsx"],"names":[],"mappings":";AACA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,iCAAiC,CAAC;AAEzC,OAAO,gBAAgB,CAAC;AASxB,MAAM,cAAc,GAAmC,CAAC,EACtD,KAAK,EACL,QAAQ,EACR,EAAE,EACF,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,UAAU,IACT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAC,MAAM,EACZ,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAChE,EAAE,EAAE,EAAE,EACN,OAAO,EAAE;YACP,SAAS,EAAE;gBACT,WAAW,EAAE,KAAK,EAAE,0DAA0D;aAC/E;SACF,iBACW,iBAAiB,GAC7B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Textarea/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { isGroupRequired } from "../../utils/hasGroupRequiredFieldsWithValues";
|
|
4
|
+
import * as listStyles from "../FormList/FormList.module.scss";
|
|
5
|
+
import * as groupStyles from "../Group/Group.module.scss";
|
|
6
|
+
import QueryControl from "../QueryControl";
|
|
7
|
+
import * as styles from "./AddressGroup.module.scss";
|
|
8
|
+
import Countries from "./utils/Countries";
|
|
9
|
+
const AddressGroup = ({ ...props }) => {
|
|
10
|
+
const { id, control, objectPathId, groupIsRequired, isInGroup, controlProps, } = props;
|
|
11
|
+
const { displayName, controls, required } = control;
|
|
12
|
+
const countryValue = typeof controls.country?.value === "string" &&
|
|
13
|
+
controls.country?.value.toLowerCase();
|
|
14
|
+
const groupClassName = `${groupStyles["form-group-container"]} ${styles["address-group-container"]}`;
|
|
15
|
+
let addressClassName = `${styles.address} ${listStyles.address}`;
|
|
16
|
+
addressClassName =
|
|
17
|
+
countryValue && styles[countryValue]
|
|
18
|
+
? `${addressClassName} ${styles[countryValue]}`
|
|
19
|
+
: `${addressClassName} ${styles["address-default"]}`;
|
|
20
|
+
const currObjectPathId = objectPathId || id;
|
|
21
|
+
const isRequired = isInGroup
|
|
22
|
+
? required || groupIsRequired
|
|
23
|
+
: required || isGroupRequired({ controls });
|
|
24
|
+
const renderAddressControl = (idx, control) => {
|
|
25
|
+
const groupObjectPathId = `${currObjectPathId}.controls.${idx}`;
|
|
26
|
+
control.placeholder = control.placeholder || control.displayName;
|
|
27
|
+
if (idx === "country" && control) {
|
|
28
|
+
control.control = "select";
|
|
29
|
+
control.options = Countries;
|
|
30
|
+
}
|
|
31
|
+
return (_jsx(React.Fragment, { children: _jsx(QueryControl, { formControl: control, hideLabel: true, id: id, objectPathId: groupObjectPathId, groupIsRequired: isRequired, isInGroup: true, controlProps: controlProps }, id) }, groupObjectPathId));
|
|
32
|
+
};
|
|
33
|
+
const addressStyle = controlProps?.addressProps?.style ?? {};
|
|
34
|
+
const addressLabelStyle = controlProps?.addressProps?.label?.style ?? {};
|
|
35
|
+
const addressContainerStyle = controlProps?.addressProps?.container?.style ?? {};
|
|
36
|
+
return (_jsxs("div", { className: groupClassName, id: id, "data-testid": id, style: addressStyle, children: [_jsx("h3", { className: `${styles["control-label-group"]} ${listStyles["control-label-group"]}`, style: addressLabelStyle, children: displayName }), _jsxs("div", { className: addressClassName, style: addressContainerStyle, children: [renderAddressControl("streetName", controls.streetName), renderAddressControl("houseNumber", controls.houseNumber), renderAddressControl("postalCode", controls.postalCode), renderAddressControl("locality", controls.locality), renderAddressControl("country", controls.country)] })] }));
|
|
37
|
+
};
|
|
38
|
+
export default AddressGroup;
|
|
39
|
+
//# sourceMappingURL=AddressGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressGroup.js","sourceRoot":"","sources":["../../../src/components/addressGro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