@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.
Files changed (162) hide show
  1. package/dist/assets/criteria-based-filter-edition-dialog.css +168 -0
  2. package/dist/chunks/criteria-based-filter-edition-dialog.BEXoNmzz.js +1673 -0
  3. package/dist/chunks/filter-properties.GRon8-ML.js +195 -0
  4. package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +13 -3
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +14 -10
  6. package/dist/components/TopBar/TopBar.js +371 -429
  7. package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
  8. package/dist/components/dialogs/custom-mui-dialog.js +87 -0
  9. package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
  10. package/dist/components/dialogs/description-modification-dialog.js +71 -0
  11. package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
  12. package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
  13. package/dist/components/filter/constants/equipment-types.d.ts +72 -0
  14. package/dist/components/filter/constants/equipment-types.js +63 -0
  15. package/dist/components/filter/constants/expert-filter-constants.d.ts +551 -0
  16. package/dist/components/filter/constants/expert-filter-constants.js +668 -0
  17. package/dist/components/filter/constants/field-constants.d.ts +45 -0
  18. package/dist/components/filter/constants/field-constants.js +43 -0
  19. package/dist/components/filter/constants/filter-constants.d.ts +21 -0
  20. package/dist/components/filter/constants/filter-constants.js +10 -0
  21. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
  22. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
  23. package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
  24. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
  25. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
  26. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
  27. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
  28. package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
  29. package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
  30. package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
  31. package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
  32. package/dist/components/filter/criteria-based/filter-properties.js +19 -0
  33. package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
  34. package/dist/components/filter/criteria-based/filter-property.js +67 -0
  35. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
  36. package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
  37. package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
  38. package/dist/components/filter/expert/expert-filter-form.js +22 -0
  39. package/dist/components/filter/expert/expert-filter-utils.d.ts +91 -0
  40. package/dist/components/filter/expert/expert-filter-utils.js +304 -0
  41. package/dist/components/filter/expert/expert-filter.type.d.ts +114 -0
  42. package/dist/components/filter/expert/expert-filter.type.js +104 -0
  43. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
  44. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
  45. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
  46. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
  47. package/dist/components/filter/filter-context.d.ts +12 -0
  48. package/dist/components/filter/filter-context.js +10 -0
  49. package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
  50. package/dist/components/filter/filter-creation-dialog.js +17 -0
  51. package/dist/components/filter/filter-form.d.ts +11 -0
  52. package/dist/components/filter/filter-form.js +14 -0
  53. package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
  54. package/dist/components/filter/utils/criteria-based-utils.js +197 -0
  55. package/dist/components/filter/utils/filters-utils.d.ts +5 -0
  56. package/dist/components/filter/utils/filters-utils.js +99 -0
  57. package/dist/components/inputs/select-clearable.d.ts +14 -0
  58. package/dist/components/inputs/select-clearable.js +40 -0
  59. package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
  60. package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
  61. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
  62. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
  63. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
  64. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
  65. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
  66. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
  67. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
  68. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
  69. package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
  70. package/dist/components/react-hook-form/autocomplete-input.js +4 -15
  71. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
  72. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
  73. package/dist/components/react-hook-form/directory-items-input.d.ts +0 -3
  74. package/dist/components/react-hook-form/directory-items-input.js +5 -6
  75. package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
  76. package/dist/components/react-hook-form/error-management/error-input.js +7 -7
  77. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
  78. package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
  79. package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
  80. package/dist/components/react-hook-form/numbers/float-input.js +3 -5
  81. package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
  82. package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
  83. package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
  84. package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
  85. package/dist/components/react-hook-form/radio-input.d.ts +14 -17
  86. package/dist/components/react-hook-form/radio-input.js +7 -9
  87. package/dist/components/react-hook-form/range-input.d.ts +54 -0
  88. package/dist/components/react-hook-form/range-input.js +118 -0
  89. package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
  90. package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
  91. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
  92. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
  93. package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
  94. package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
  95. package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
  96. package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
  97. package/dist/components/react-hook-form/text-input.d.ts +23 -32
  98. package/dist/components/react-hook-form/text-input.js +6 -20
  99. package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
  100. package/dist/components/react-hook-form/unique-name-input.js +129 -0
  101. package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
  102. package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
  103. package/dist/components/react-hook-form/utils/field-label.js +5 -1
  104. package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
  105. package/dist/components/react-hook-form/utils/functions.js +21 -1
  106. package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
  107. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
  108. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
  109. package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
  110. package/dist/components/react-query-builder-inputs/add-button.js +17 -0
  111. package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
  112. package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
  113. package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
  114. package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
  115. package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
  116. package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
  117. package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
  118. package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
  119. package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
  120. package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
  121. package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
  122. package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
  123. package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
  124. package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
  125. package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
  126. package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
  127. package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
  128. package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
  129. package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
  130. package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
  131. package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
  132. package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
  133. package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
  134. package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
  135. package/dist/components/translations/filter-en.d.ts +22 -0
  136. package/dist/components/translations/filter-en.js +23 -0
  137. package/dist/components/translations/filter-fr.d.ts +22 -0
  138. package/dist/components/translations/filter-fr.js +23 -0
  139. package/dist/hooks/localized-countries-hook.d.ts +6 -0
  140. package/dist/hooks/localized-countries-hook.js +45 -0
  141. package/dist/hooks/predefined-properties-hook.d.ts +18 -0
  142. package/dist/hooks/predefined-properties-hook.js +43 -0
  143. package/dist/hooks/useDebounce.d.ts +7 -1
  144. package/dist/hooks/useSnackMessage.d.ts +23 -5
  145. package/dist/hooks/useSnackMessage.js +14 -12
  146. package/dist/index.d.ts +89 -142
  147. package/dist/index.js +172 -91
  148. package/dist/utils/FetchStatus.d.ts +12 -0
  149. package/dist/utils/FetchStatus.js +9 -0
  150. package/dist/utils/conversion-utils.d.ts +12 -0
  151. package/dist/utils/conversion-utils.js +22 -0
  152. package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
  153. package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
  154. package/dist/utils/functions.d.ts +14 -0
  155. package/dist/utils/functions.js +16 -0
  156. package/dist/utils/types.d.ts +21 -0
  157. package/dist/utils/types.js +1 -0
  158. package/dist/utils/yup-config.d.ts +8 -0
  159. package/dist/utils/yup-config.js +16 -0
  160. package/package.json +15 -3
  161. package/dist/components/react-hook-form/select-input.d.ts +0 -17
  162. 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 = ({ name, label, id, options, formProps }) => {
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,8 @@
1
+ import { FunctionComponent } from 'react';
2
+
3
+ interface CountryInputProps {
4
+ name: string;
5
+ label: string;
6
+ }
7
+ export declare const CountriesInput: FunctionComponent<CountryInputProps>;
8
+ export default CountriesInput;
@@ -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,2 @@
1
+ declare const InputWithPopupConfirmation: ({ Input, name, shouldOpenPopup, resetOnConfirmation, message, validateButtonLabel, ...props }: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default InputWithPopupConfirmation;
@@ -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 { default as PropTypes } from 'prop-types';
2
- import { identity } from './utils/functions';
3
- export default TextInput;
4
- declare function TextInput({ name, label, labelValues, id, adornment, customAdornment, outputTransform, inputTransform, acceptValue, previousValue, clearable, formProps, }: {
5
- name: any;
6
- label: any;
7
- labelValues: any;
8
- id: any;
9
- adornment: any;
10
- customAdornment: any;
11
- outputTransform?: typeof identity | undefined;
12
- inputTransform?: typeof identity | undefined;
13
- acceptValue?: (() => boolean) | undefined;
14
- previousValue: any;
15
- clearable: any;
16
- formProps: any;
17
- }): import("react/jsx-runtime").JSX.Element;
18
- declare namespace TextInput {
19
- namespace propTypes {
20
- let name: PropTypes.Requireable<string>;
21
- let label: PropTypes.Requireable<string>;
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
+ };