@gridsuite/commons-ui 0.55.0 → 0.57.0
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/criteria-based-filter-edition-dialog.css +168 -0
- package/dist/chunks/criteria-based-filter-edition-dialog.BEXoNmzz.js +1673 -0
- package/dist/chunks/filter-properties.GRon8-ML.js +195 -0
- package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +13 -3
- package/dist/components/DirectoryItemSelector/directory-item-selector.js +14 -10
- package/dist/components/TopBar/TopBar.js +371 -429
- package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
- package/dist/components/dialogs/custom-mui-dialog.js +87 -0
- package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
- package/dist/components/dialogs/description-modification-dialog.js +71 -0
- package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
- package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
- package/dist/components/filter/constants/equipment-types.d.ts +72 -0
- package/dist/components/filter/constants/equipment-types.js +63 -0
- package/dist/components/filter/constants/expert-filter-constants.d.ts +551 -0
- package/dist/components/filter/constants/expert-filter-constants.js +668 -0
- package/dist/components/filter/constants/field-constants.d.ts +45 -0
- package/dist/components/filter/constants/field-constants.js +43 -0
- package/dist/components/filter/constants/filter-constants.d.ts +21 -0
- package/dist/components/filter/constants/filter-constants.js +10 -0
- package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
- package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
- package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
- package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
- package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
- package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
- package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
- package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
- package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
- package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
- package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
- package/dist/components/filter/criteria-based/filter-properties.js +19 -0
- package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
- package/dist/components/filter/criteria-based/filter-property.js +67 -0
- package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
- package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
- package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
- package/dist/components/filter/expert/expert-filter-form.js +22 -0
- package/dist/components/filter/expert/expert-filter-utils.d.ts +91 -0
- package/dist/components/filter/expert/expert-filter-utils.js +304 -0
- package/dist/components/filter/expert/expert-filter.type.d.ts +114 -0
- package/dist/components/filter/expert/expert-filter.type.js +104 -0
- package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
- package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
- package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
- package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
- package/dist/components/filter/filter-context.d.ts +12 -0
- package/dist/components/filter/filter-context.js +10 -0
- package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
- package/dist/components/filter/filter-creation-dialog.js +17 -0
- package/dist/components/filter/filter-form.d.ts +11 -0
- package/dist/components/filter/filter-form.js +14 -0
- package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
- package/dist/components/filter/utils/criteria-based-utils.js +197 -0
- package/dist/components/filter/utils/filters-utils.d.ts +5 -0
- package/dist/components/filter/utils/filters-utils.js +99 -0
- package/dist/components/inputs/select-clearable.d.ts +14 -0
- package/dist/components/inputs/select-clearable.js +40 -0
- package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
- package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
- package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
- package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
- package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
- package/dist/components/react-hook-form/autocomplete-input.js +4 -15
- package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
- package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
- package/dist/components/react-hook-form/directory-items-input.d.ts +0 -3
- package/dist/components/react-hook-form/directory-items-input.js +5 -6
- package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
- package/dist/components/react-hook-form/error-management/error-input.js +7 -7
- package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
- package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
- package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
- package/dist/components/react-hook-form/numbers/float-input.js +3 -5
- package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
- package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
- package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
- package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
- package/dist/components/react-hook-form/radio-input.d.ts +14 -17
- package/dist/components/react-hook-form/radio-input.js +7 -9
- package/dist/components/react-hook-form/range-input.d.ts +54 -0
- package/dist/components/react-hook-form/range-input.js +118 -0
- package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
- package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
- package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
- package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
- package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
- package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
- package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
- package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
- package/dist/components/react-hook-form/text-input.d.ts +23 -32
- package/dist/components/react-hook-form/text-input.js +6 -20
- package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
- package/dist/components/react-hook-form/unique-name-input.js +129 -0
- package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
- package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
- package/dist/components/react-hook-form/utils/field-label.js +5 -1
- package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
- package/dist/components/react-hook-form/utils/functions.js +21 -1
- package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
- package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
- package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
- package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
- package/dist/components/react-query-builder-inputs/add-button.js +17 -0
- package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
- package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
- package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
- package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
- package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
- package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
- package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
- package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
- package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
- package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
- package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
- package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
- package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
- package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
- package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
- package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
- package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
- package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
- package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
- package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
- package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
- package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
- package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
- package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
- package/dist/components/translations/filter-en.d.ts +22 -0
- package/dist/components/translations/filter-en.js +23 -0
- package/dist/components/translations/filter-fr.d.ts +22 -0
- package/dist/components/translations/filter-fr.js +23 -0
- package/dist/hooks/localized-countries-hook.d.ts +6 -0
- package/dist/hooks/localized-countries-hook.js +45 -0
- package/dist/hooks/predefined-properties-hook.d.ts +18 -0
- package/dist/hooks/predefined-properties-hook.js +43 -0
- package/dist/hooks/useDebounce.d.ts +7 -1
- package/dist/hooks/useSnackMessage.d.ts +23 -5
- package/dist/hooks/useSnackMessage.js +14 -12
- package/dist/index.d.ts +89 -142
- package/dist/index.js +172 -91
- package/dist/utils/FetchStatus.d.ts +12 -0
- package/dist/utils/FetchStatus.js +9 -0
- package/dist/utils/conversion-utils.d.ts +12 -0
- package/dist/utils/conversion-utils.js +22 -0
- package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
- package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
- package/dist/utils/functions.d.ts +14 -0
- package/dist/utils/functions.js +16 -0
- package/dist/utils/types.d.ts +21 -0
- package/dist/utils/types.js +1 -0
- package/dist/utils/yup-config.d.ts +8 -0
- package/dist/utils/yup-config.js +16 -0
- package/package.json +15 -3
- package/dist/components/react-hook-form/select-input.d.ts +0 -17
- package/dist/components/react-hook-form/select-input.js +0 -30
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { FormControl, FormLabel, RadioGroup, FormControlLabel, Radio } from "@mui/material";
|
|
4
3
|
import { FormattedMessage } from "react-intl";
|
|
5
4
|
import { useController } from "react-hook-form";
|
|
6
5
|
import FieldLabel from "./utils/field-label.js";
|
|
7
|
-
const RadioInput = ({
|
|
6
|
+
const RadioInput = ({
|
|
7
|
+
name,
|
|
8
|
+
label,
|
|
9
|
+
id,
|
|
10
|
+
options,
|
|
11
|
+
formProps
|
|
12
|
+
}) => {
|
|
8
13
|
const {
|
|
9
14
|
field: { onChange, value }
|
|
10
15
|
} = useController({ name });
|
|
@@ -31,13 +36,6 @@ const RadioInput = ({ name, label, id, options, formProps }) => {
|
|
|
31
36
|
)
|
|
32
37
|
] });
|
|
33
38
|
};
|
|
34
|
-
RadioInput.propTypes = {
|
|
35
|
-
name: PropTypes.string.isRequired,
|
|
36
|
-
label: PropTypes.string,
|
|
37
|
-
id: PropTypes.string,
|
|
38
|
-
options: PropTypes.array.isRequired,
|
|
39
|
-
formProps: PropTypes.object
|
|
40
|
-
};
|
|
41
39
|
export {
|
|
42
40
|
RadioInput as default
|
|
43
41
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { default as yup } from '../../utils/yup-config.ts';
|
|
3
|
+
|
|
4
|
+
export declare const RangeType: {
|
|
5
|
+
EQUALITY: {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
GREATER_THAN: {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
13
|
+
GREATER_OR_EQUAL: {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
LESS_THAN: {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
LESS_OR_EQUAL: {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
RANGE: {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare const DEFAULT_RANGE_VALUE: {
|
|
31
|
+
type: string;
|
|
32
|
+
value1: null;
|
|
33
|
+
value2: null;
|
|
34
|
+
};
|
|
35
|
+
export declare const getRangeInputDataForm: (name: string, rangeValue: unknown) => {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
export declare const getRangeInputSchema: (name: string) => {
|
|
39
|
+
[x: string]: yup.ObjectSchema<{
|
|
40
|
+
type: string | undefined;
|
|
41
|
+
value1: number | undefined;
|
|
42
|
+
value2: number | undefined;
|
|
43
|
+
}, yup.AnyObject, {
|
|
44
|
+
type: undefined;
|
|
45
|
+
value1: undefined;
|
|
46
|
+
value2: undefined;
|
|
47
|
+
}, "">;
|
|
48
|
+
};
|
|
49
|
+
interface RangeInputProps {
|
|
50
|
+
name: string;
|
|
51
|
+
label: string;
|
|
52
|
+
}
|
|
53
|
+
declare const RangeInput: FunctionComponent<RangeInputProps>;
|
|
54
|
+
export default RangeInput;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useWatch } from "react-hook-form";
|
|
3
|
+
import FloatInput from "./numbers/float-input.js";
|
|
4
|
+
import "../../utils/yup-config.js";
|
|
5
|
+
import { FormattedMessage } from "react-intl";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import InputLabel from "@mui/material/InputLabel";
|
|
8
|
+
import { Grid } from "@mui/material";
|
|
9
|
+
import FormControl from "@mui/material/FormControl";
|
|
10
|
+
import MuiSelectInput from "./select-inputs/mui-select-input.js";
|
|
11
|
+
import { FieldConstants } from "../filter/constants/field-constants.js";
|
|
12
|
+
import * as yup from "yup";
|
|
13
|
+
const style = {
|
|
14
|
+
inputLegend: (theme) => ({
|
|
15
|
+
backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16))",
|
|
16
|
+
backgroundColor: theme.palette.background.paper,
|
|
17
|
+
padding: "0 8px 0 8px"
|
|
18
|
+
})
|
|
19
|
+
};
|
|
20
|
+
const RangeType = {
|
|
21
|
+
EQUALITY: { id: "EQUALITY", label: "equality" },
|
|
22
|
+
GREATER_THAN: { id: "GREATER_THAN", label: "greaterThan" },
|
|
23
|
+
GREATER_OR_EQUAL: { id: "GREATER_OR_EQUAL", label: "greaterOrEqual" },
|
|
24
|
+
LESS_THAN: { id: "LESS_THAN", label: "lessThan" },
|
|
25
|
+
LESS_OR_EQUAL: { id: "LESS_OR_EQUAL", label: "lessOrEqual" },
|
|
26
|
+
RANGE: { id: "RANGE", label: "range" }
|
|
27
|
+
};
|
|
28
|
+
const DEFAULT_RANGE_VALUE = {
|
|
29
|
+
[FieldConstants.OPERATION_TYPE]: RangeType.EQUALITY.id,
|
|
30
|
+
[FieldConstants.VALUE_1]: null,
|
|
31
|
+
[FieldConstants.VALUE_2]: null
|
|
32
|
+
};
|
|
33
|
+
const getRangeInputDataForm = (name, rangeValue) => ({
|
|
34
|
+
[name]: rangeValue
|
|
35
|
+
});
|
|
36
|
+
const getRangeInputSchema = (name) => ({
|
|
37
|
+
[name]: yup.object().shape(
|
|
38
|
+
{
|
|
39
|
+
[FieldConstants.OPERATION_TYPE]: yup.string(),
|
|
40
|
+
[FieldConstants.VALUE_1]: yup.number().when([FieldConstants.OPERATION_TYPE, FieldConstants.VALUE_2], {
|
|
41
|
+
is: (operationType, value2) => operationType === RangeType.RANGE.id && value2 !== null,
|
|
42
|
+
then: (schema) => schema.required(),
|
|
43
|
+
otherwise: (schema) => schema.nullable()
|
|
44
|
+
}),
|
|
45
|
+
[FieldConstants.VALUE_2]: yup.number().when([FieldConstants.OPERATION_TYPE, FieldConstants.VALUE_1], {
|
|
46
|
+
is: (operationType, value1) => operationType === RangeType.RANGE.id && value1 !== null,
|
|
47
|
+
then: (schema) => schema.required(),
|
|
48
|
+
otherwise: (schema) => schema.nullable()
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
[[FieldConstants.VALUE_1, FieldConstants.VALUE_2]]
|
|
52
|
+
)
|
|
53
|
+
});
|
|
54
|
+
const RangeInput = ({ name, label }) => {
|
|
55
|
+
const watchOperationType = useWatch({
|
|
56
|
+
name: `${name}.${FieldConstants.OPERATION_TYPE}`
|
|
57
|
+
});
|
|
58
|
+
const isOperationTypeRange = useMemo(
|
|
59
|
+
() => watchOperationType === RangeType.RANGE.id,
|
|
60
|
+
[watchOperationType]
|
|
61
|
+
);
|
|
62
|
+
const firstValueField = /* @__PURE__ */ jsx(
|
|
63
|
+
FloatInput,
|
|
64
|
+
{
|
|
65
|
+
label: "",
|
|
66
|
+
name: `${name}.${FieldConstants.VALUE_1}`,
|
|
67
|
+
clearable: false,
|
|
68
|
+
formProps: {
|
|
69
|
+
size: "medium",
|
|
70
|
+
placeholder: isOperationTypeRange ? "Min" : ""
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
const secondValueField = /* @__PURE__ */ jsx(
|
|
75
|
+
FloatInput,
|
|
76
|
+
{
|
|
77
|
+
name: `${name}.${FieldConstants.VALUE_2}`,
|
|
78
|
+
clearable: false,
|
|
79
|
+
label: "",
|
|
80
|
+
formProps: {
|
|
81
|
+
size: "medium",
|
|
82
|
+
placeholder: "Max"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
const operationTypeField = /* @__PURE__ */ jsx(
|
|
87
|
+
MuiSelectInput,
|
|
88
|
+
{
|
|
89
|
+
name: `${name}.${FieldConstants.OPERATION_TYPE}`,
|
|
90
|
+
options: Object.values(RangeType),
|
|
91
|
+
fullWidth: true
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
return /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, children: [
|
|
95
|
+
/* @__PURE__ */ jsx(InputLabel, { sx: style.inputLegend, shrink: true, children: /* @__PURE__ */ jsx(FormattedMessage, { id: label }) }),
|
|
96
|
+
/* @__PURE__ */ jsxs(Grid, { container: true, spacing: 0, children: [
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
Grid,
|
|
99
|
+
{
|
|
100
|
+
item: true,
|
|
101
|
+
style: isOperationTypeRange ? {
|
|
102
|
+
flex: "min-content"
|
|
103
|
+
} : {},
|
|
104
|
+
children: operationTypeField
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: firstValueField }),
|
|
108
|
+
isOperationTypeRange && /* @__PURE__ */ jsx(Grid, { item: true, children: secondValueField })
|
|
109
|
+
] })
|
|
110
|
+
] });
|
|
111
|
+
};
|
|
112
|
+
export {
|
|
113
|
+
DEFAULT_RANGE_VALUE,
|
|
114
|
+
RangeType,
|
|
115
|
+
RangeInput as default,
|
|
116
|
+
getRangeInputDataForm,
|
|
117
|
+
getRangeInputSchema
|
|
118
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip } from "@mui/material";
|
|
3
|
+
import AutocompleteInput from "../autocomplete-input.js";
|
|
4
|
+
import { useLocalizedCountries } from "../../../hooks/localized-countries-hook.js";
|
|
5
|
+
import { useCustomFormContext } from "../provider/use-custom-form-context.js";
|
|
6
|
+
const CountriesInput = ({
|
|
7
|
+
name,
|
|
8
|
+
label
|
|
9
|
+
}) => {
|
|
10
|
+
const { language } = useCustomFormContext();
|
|
11
|
+
const { translate, countryCodes } = useLocalizedCountries(language);
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
AutocompleteInput,
|
|
14
|
+
{
|
|
15
|
+
name,
|
|
16
|
+
label,
|
|
17
|
+
options: countryCodes,
|
|
18
|
+
getOptionLabel: translate,
|
|
19
|
+
fullWidth: true,
|
|
20
|
+
multiple: true,
|
|
21
|
+
renderTags: (val, getTagsProps) => val.map((code, index) => /* @__PURE__ */ jsx(
|
|
22
|
+
Chip,
|
|
23
|
+
{
|
|
24
|
+
size: "small",
|
|
25
|
+
label: translate(code),
|
|
26
|
+
...getTagsProps({ index })
|
|
27
|
+
},
|
|
28
|
+
code
|
|
29
|
+
))
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
CountriesInput,
|
|
35
|
+
CountriesInput as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useController } from "react-hook-form";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import PopupConfirmationDialog from "../../dialogs/popup-confirmation-dialog.js";
|
|
5
|
+
const InputWithPopupConfirmation = ({
|
|
6
|
+
Input,
|
|
7
|
+
name,
|
|
8
|
+
shouldOpenPopup,
|
|
9
|
+
// condition to open popup confirmation
|
|
10
|
+
resetOnConfirmation,
|
|
11
|
+
// function to reset values in your form on confirmation,
|
|
12
|
+
message,
|
|
13
|
+
validateButtonLabel,
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
const [newValue, setNewValue] = useState(null);
|
|
17
|
+
const [openPopup, setOpenPopup] = useState(false);
|
|
18
|
+
const {
|
|
19
|
+
field: { onChange }
|
|
20
|
+
} = useController({
|
|
21
|
+
name
|
|
22
|
+
});
|
|
23
|
+
const handleOnChange = (_event, value) => {
|
|
24
|
+
if (shouldOpenPopup()) {
|
|
25
|
+
setOpenPopup(true);
|
|
26
|
+
setNewValue(value);
|
|
27
|
+
} else {
|
|
28
|
+
onChange(value);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const handlePopupConfirmation = () => {
|
|
32
|
+
resetOnConfirmation && resetOnConfirmation();
|
|
33
|
+
onChange(newValue);
|
|
34
|
+
setOpenPopup(false);
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
Input,
|
|
39
|
+
{
|
|
40
|
+
name,
|
|
41
|
+
...props,
|
|
42
|
+
onChange: (e, value) => {
|
|
43
|
+
handleOnChange(e, (value == null ? void 0 : value.id) ?? value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
PopupConfirmationDialog,
|
|
49
|
+
{
|
|
50
|
+
message,
|
|
51
|
+
openConfirmationPopup: openPopup,
|
|
52
|
+
setOpenConfirmationPopup: setOpenPopup,
|
|
53
|
+
handlePopupConfirmation,
|
|
54
|
+
validateButtonLabel
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] });
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
InputWithPopupConfirmation as default
|
|
61
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { SelectProps } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
interface MuiSelectInputProps {
|
|
5
|
+
name: string;
|
|
6
|
+
options: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
declare const MuiSelectInput: FunctionComponent<MuiSelectInputProps & SelectProps>;
|
|
12
|
+
export default MuiSelectInput;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import { Select, MenuItem } from "@mui/material";
|
|
5
|
+
import { useController } from "react-hook-form";
|
|
6
|
+
const MuiSelectInput = ({
|
|
7
|
+
name,
|
|
8
|
+
options,
|
|
9
|
+
...props
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
field: { value, onChange }
|
|
13
|
+
} = useController({
|
|
14
|
+
name
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsx(Select, { value, onChange, ...props, children: options.map((option, index) => /* @__PURE__ */ jsx(MenuItem, { value: option.id ?? option, children: /* @__PURE__ */ jsx(FormattedMessage, { id: option.label ?? option }) }, index)) });
|
|
17
|
+
};
|
|
18
|
+
MuiSelectInput.propTypes = {
|
|
19
|
+
name: PropTypes.string.isRequired,
|
|
20
|
+
label: PropTypes.string,
|
|
21
|
+
options: PropTypes.array.isRequired
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
MuiSelectInput as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Option } from '../../../utils/types.ts';
|
|
2
|
+
import { FunctionComponent } from 'react';
|
|
3
|
+
import { AutocompleteInputProps } from '../autocomplete-input';
|
|
4
|
+
|
|
5
|
+
export interface SelectInputProps extends Omit<AutocompleteInputProps, 'outputTransform' | 'inputTransform' | 'readOnly' | 'getOptionLabel'> {
|
|
6
|
+
options: Option[];
|
|
7
|
+
}
|
|
8
|
+
declare const SelectInput: FunctionComponent<SelectInputProps>;
|
|
9
|
+
export default SelectInput;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import AutocompleteInput from "../autocomplete-input.js";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
const SelectInput = (props) => {
|
|
5
|
+
const intl = useIntl();
|
|
6
|
+
const inputTransform = (value) => {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
return props.options.find(
|
|
9
|
+
(option) => typeof option !== "string" && (option == null ? void 0 : option.id) === value
|
|
10
|
+
) || null;
|
|
11
|
+
}
|
|
12
|
+
return props.options.find(
|
|
13
|
+
(option) => typeof option !== "string" && (option == null ? void 0 : option.id) === value.id
|
|
14
|
+
) || null;
|
|
15
|
+
};
|
|
16
|
+
const outputTransform = (value) => {
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return (value == null ? void 0 : value.id) ?? null;
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
AutocompleteInput,
|
|
24
|
+
{
|
|
25
|
+
getOptionLabel: (option) => {
|
|
26
|
+
return typeof option !== "string" ? (option == null ? void 0 : option.label) ? intl.formatMessage({ id: option == null ? void 0 : option.label }) : option == null ? void 0 : option.id : option;
|
|
27
|
+
},
|
|
28
|
+
inputTransform,
|
|
29
|
+
outputTransform,
|
|
30
|
+
readOnly: true,
|
|
31
|
+
...props
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
SelectInput as default
|
|
37
|
+
};
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let labelValues: PropTypes.Requireable<object>;
|
|
23
|
-
let id: PropTypes.Requireable<string>;
|
|
24
|
-
let adornment: PropTypes.Requireable<object>;
|
|
25
|
-
let customAdornment: PropTypes.Requireable<object>;
|
|
26
|
-
let outputTransform: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
let inputTransform: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
-
let acceptValue: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
|
-
let previousValue: PropTypes.Requireable<any>;
|
|
30
|
-
let clearable: PropTypes.Requireable<boolean>;
|
|
31
|
-
let formProps: PropTypes.Requireable<object>;
|
|
32
|
-
}
|
|
1
|
+
import { Input } from '../../utils/types.ts';
|
|
2
|
+
import { TextFieldWithAdornmentProps } from './utils/text-field-with-adornment';
|
|
3
|
+
import { TextFieldProps } from '@mui/material';
|
|
4
|
+
import { FunctionComponent, ReactElement } from 'react';
|
|
5
|
+
|
|
6
|
+
export interface TextInputProps {
|
|
7
|
+
name: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
labelValues?: any;
|
|
10
|
+
id?: string;
|
|
11
|
+
adornment?: {
|
|
12
|
+
position: string;
|
|
13
|
+
text: string;
|
|
14
|
+
};
|
|
15
|
+
customAdornment?: ReactElement | null;
|
|
16
|
+
outputTransform?: (value: string) => Input | null;
|
|
17
|
+
inputTransform?: (value: Input) => string;
|
|
18
|
+
acceptValue?: (value: string) => boolean;
|
|
19
|
+
previousValue?: Input;
|
|
20
|
+
clearable?: boolean;
|
|
21
|
+
formProps?: Omit<TextFieldWithAdornmentProps | TextFieldProps, 'value' | 'onChange' | 'inputRef' | 'inputProps' | 'InputProps'>;
|
|
33
22
|
}
|
|
23
|
+
declare const TextInput: FunctionComponent<TextInputProps>;
|
|
24
|
+
export default TextInput;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { InputAdornment, IconButton, TextField } from "@mui/material";
|
|
4
3
|
import { Clear } from "@mui/icons-material";
|
|
5
4
|
import { useController } from "react-hook-form";
|
|
@@ -31,6 +30,10 @@ const TextInput = ({
|
|
|
31
30
|
fieldState: { error }
|
|
32
31
|
} = useController({ name });
|
|
33
32
|
const Field = adornment ? TextFieldWithAdornment : TextField;
|
|
33
|
+
const finalAdornment = {
|
|
34
|
+
adornmentPosition: (adornment == null ? void 0 : adornment.position) ?? "",
|
|
35
|
+
adornmentText: (adornment == null ? void 0 : adornment.text) ?? ""
|
|
36
|
+
};
|
|
34
37
|
const handleClearValue = () => {
|
|
35
38
|
onChange(outputTransform(""));
|
|
36
39
|
};
|
|
@@ -52,10 +55,6 @@ const TextInput = ({
|
|
|
52
55
|
fullWidth: true,
|
|
53
56
|
id: id ? id : label,
|
|
54
57
|
label: fieldLabel,
|
|
55
|
-
...adornment && {
|
|
56
|
-
adornmentPosition: adornment.position,
|
|
57
|
-
adornmentText: adornment == null ? void 0 : adornment.text
|
|
58
|
-
},
|
|
59
58
|
value: transformedValue,
|
|
60
59
|
onChange: handleValueChanged,
|
|
61
60
|
InputProps: {
|
|
@@ -70,25 +69,12 @@ const TextInput = ({
|
|
|
70
69
|
},
|
|
71
70
|
...genHelperPreviousValue(previousValue, adornment),
|
|
72
71
|
...genHelperError(error == null ? void 0 : error.message),
|
|
73
|
-
...formProps
|
|
72
|
+
...formProps,
|
|
73
|
+
...finalAdornment
|
|
74
74
|
},
|
|
75
75
|
id ? id : label
|
|
76
76
|
);
|
|
77
77
|
};
|
|
78
|
-
TextInput.propTypes = {
|
|
79
|
-
name: PropTypes.string,
|
|
80
|
-
label: PropTypes.string,
|
|
81
|
-
labelValues: PropTypes.object,
|
|
82
|
-
id: PropTypes.string,
|
|
83
|
-
adornment: PropTypes.object,
|
|
84
|
-
customAdornment: PropTypes.object,
|
|
85
|
-
outputTransform: PropTypes.func,
|
|
86
|
-
inputTransform: PropTypes.func,
|
|
87
|
-
acceptValue: PropTypes.func,
|
|
88
|
-
previousValue: PropTypes.any,
|
|
89
|
-
clearable: PropTypes.bool,
|
|
90
|
-
formProps: PropTypes.object
|
|
91
|
-
};
|
|
92
78
|
export {
|
|
93
79
|
TextInput as default
|
|
94
80
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { elementExistsType } from '../filter/criteria-based/criteria-based-filter-edition-dialog';
|
|
2
|
+
import { UUID } from 'crypto';
|
|
3
|
+
import { ElementType } from '../../utils/ElementType.ts';
|
|
4
|
+
import { TextFieldProps } from '@mui/material';
|
|
5
|
+
import { FunctionComponent } from 'react';
|
|
6
|
+
|
|
7
|
+
interface UniqueNameInputProps {
|
|
8
|
+
name: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
elementType: ElementType;
|
|
11
|
+
autoFocus?: boolean;
|
|
12
|
+
onManualChangeCallback?: () => void;
|
|
13
|
+
formProps?: Omit<TextFieldProps, 'value' | 'onChange' | 'name' | 'label' | 'inputRef' | 'inputProps' | 'InputProps'>;
|
|
14
|
+
activeDirectory?: UUID;
|
|
15
|
+
elementExists?: elementExistsType;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Input component that constantly check if the field's value is available or not
|
|
19
|
+
*/
|
|
20
|
+
export declare const UniqueNameInput: FunctionComponent<UniqueNameInputProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
|
+
import { useDebounce } from "../../hooks/useDebounce.js";
|
|
4
|
+
import { FormattedMessage } from "react-intl";
|
|
5
|
+
import { InputAdornment } from "@mui/material";
|
|
6
|
+
import CheckIcon from "@mui/icons-material/Check";
|
|
7
|
+
import { useController, useFormContext } from "react-hook-form";
|
|
8
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
9
|
+
import TextField from "@mui/material/TextField";
|
|
10
|
+
import { FieldConstants } from "../filter/constants/field-constants.js";
|
|
11
|
+
const UniqueNameInput = ({
|
|
12
|
+
name,
|
|
13
|
+
label,
|
|
14
|
+
elementType,
|
|
15
|
+
autoFocus,
|
|
16
|
+
onManualChangeCallback,
|
|
17
|
+
formProps,
|
|
18
|
+
activeDirectory,
|
|
19
|
+
elementExists
|
|
20
|
+
}) => {
|
|
21
|
+
var _a;
|
|
22
|
+
const {
|
|
23
|
+
field: { onChange, onBlur, value, ref },
|
|
24
|
+
fieldState: { error, isDirty }
|
|
25
|
+
} = useController({
|
|
26
|
+
name
|
|
27
|
+
});
|
|
28
|
+
const {
|
|
29
|
+
field: { value: selectedDirectory }
|
|
30
|
+
} = useController({
|
|
31
|
+
name: FieldConstants.DIRECTORY
|
|
32
|
+
});
|
|
33
|
+
const {
|
|
34
|
+
setError,
|
|
35
|
+
clearErrors,
|
|
36
|
+
formState: { errors }
|
|
37
|
+
} = useFormContext();
|
|
38
|
+
const isValidating = (_a = errors.root) == null ? void 0 : _a.isValidating;
|
|
39
|
+
const directory = selectedDirectory || activeDirectory;
|
|
40
|
+
const handleCheckName = useCallback(
|
|
41
|
+
(value2) => {
|
|
42
|
+
if (value2) {
|
|
43
|
+
elementExists && elementExists(directory, value2, elementType).then((alreadyExist) => {
|
|
44
|
+
if (alreadyExist) {
|
|
45
|
+
setError(name, {
|
|
46
|
+
type: "validate",
|
|
47
|
+
message: "nameAlreadyUsed"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}).catch((error2) => {
|
|
51
|
+
setError(name, {
|
|
52
|
+
type: "validate",
|
|
53
|
+
message: "nameValidityCheckErrorMsg"
|
|
54
|
+
});
|
|
55
|
+
console.error(error2 == null ? void 0 : error2.message);
|
|
56
|
+
}).finally(() => {
|
|
57
|
+
clearErrors("root.isValidating");
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
[setError, clearErrors, name, elementType, elementExists, directory]
|
|
62
|
+
);
|
|
63
|
+
const debouncedHandleCheckName = useDebounce(handleCheckName, 700);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const trimmedValue = value.trim();
|
|
66
|
+
if (selectedDirectory) {
|
|
67
|
+
debouncedHandleCheckName(trimmedValue);
|
|
68
|
+
}
|
|
69
|
+
if (!isDirty) {
|
|
70
|
+
clearErrors(name);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (trimmedValue) {
|
|
74
|
+
clearErrors(name);
|
|
75
|
+
setError("root.isValidating", {
|
|
76
|
+
type: "validate",
|
|
77
|
+
message: "cantSubmitWhileValidating"
|
|
78
|
+
});
|
|
79
|
+
debouncedHandleCheckName(trimmedValue);
|
|
80
|
+
} else {
|
|
81
|
+
clearErrors("root.isValidating");
|
|
82
|
+
setError(name, {
|
|
83
|
+
type: "validate",
|
|
84
|
+
message: "nameEmpty"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
debouncedHandleCheckName,
|
|
89
|
+
setError,
|
|
90
|
+
clearErrors,
|
|
91
|
+
name,
|
|
92
|
+
value,
|
|
93
|
+
isDirty,
|
|
94
|
+
selectedDirectory
|
|
95
|
+
]);
|
|
96
|
+
const handleManualChange = (e) => {
|
|
97
|
+
onChange(e.target.value);
|
|
98
|
+
onManualChangeCallback && onManualChangeCallback();
|
|
99
|
+
};
|
|
100
|
+
const translatedLabel = /* @__PURE__ */ jsx(FormattedMessage, { id: label });
|
|
101
|
+
const translatedError = error && /* @__PURE__ */ jsx(FormattedMessage, { id: error.message });
|
|
102
|
+
const showOk = (value == null ? void 0 : value.trim()) && !isValidating && !error;
|
|
103
|
+
const endAdornment = /* @__PURE__ */ jsxs(InputAdornment, { position: "end", children: [
|
|
104
|
+
isValidating && /* @__PURE__ */ jsx(CircularProgress, { size: "1rem" }),
|
|
105
|
+
showOk && /* @__PURE__ */ jsx(CheckIcon, { style: { color: "green" } })
|
|
106
|
+
] });
|
|
107
|
+
return /* @__PURE__ */ jsx(
|
|
108
|
+
TextField,
|
|
109
|
+
{
|
|
110
|
+
onChange: handleManualChange,
|
|
111
|
+
onBlur,
|
|
112
|
+
value,
|
|
113
|
+
name,
|
|
114
|
+
inputRef: ref,
|
|
115
|
+
label: translatedLabel,
|
|
116
|
+
type: "text",
|
|
117
|
+
autoFocus,
|
|
118
|
+
margin: "dense",
|
|
119
|
+
fullWidth: true,
|
|
120
|
+
error: !!error,
|
|
121
|
+
helperText: translatedError,
|
|
122
|
+
InputProps: { endAdornment },
|
|
123
|
+
...formProps
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
UniqueNameInput
|
|
129
|
+
};
|