@gridsuite/commons-ui 0.54.0 → 0.56.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 (165) hide show
  1. package/dist/assets/criteria-based-filter-edition-dialog.css +168 -0
  2. package/dist/chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js +1673 -0
  3. package/dist/chunks/filter-properties.GRon8-ML.js +195 -0
  4. package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +7 -6
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +34 -43
  6. package/dist/components/FlatParameters/FlatParameters.js +3 -0
  7. package/dist/components/ReportViewer/log-report.d.ts +2 -2
  8. package/dist/components/TreeViewFinder/TreeViewFinder.d.ts +32 -58
  9. package/dist/components/TreeViewFinder/TreeViewFinder.js +126 -82
  10. package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
  11. package/dist/components/dialogs/custom-mui-dialog.js +87 -0
  12. package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
  13. package/dist/components/dialogs/description-modification-dialog.js +71 -0
  14. package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
  15. package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
  16. package/dist/components/filter/constants/equipment-types.d.ts +72 -0
  17. package/dist/components/filter/constants/equipment-types.js +63 -0
  18. package/dist/components/filter/constants/expert-filter-constants.d.ts +546 -0
  19. package/dist/components/filter/constants/expert-filter-constants.js +663 -0
  20. package/dist/components/filter/constants/field-constants.d.ts +45 -0
  21. package/dist/components/filter/constants/field-constants.js +43 -0
  22. package/dist/components/filter/constants/filter-constants.d.ts +21 -0
  23. package/dist/components/filter/constants/filter-constants.js +10 -0
  24. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
  25. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
  26. package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
  27. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
  28. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
  29. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
  30. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
  31. package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
  32. package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
  33. package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
  34. package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
  35. package/dist/components/filter/criteria-based/filter-properties.js +19 -0
  36. package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
  37. package/dist/components/filter/criteria-based/filter-property.js +67 -0
  38. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
  39. package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
  40. package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
  41. package/dist/components/filter/expert/expert-filter-form.js +22 -0
  42. package/dist/components/filter/expert/expert-filter-utils.d.ts +19 -0
  43. package/dist/components/filter/expert/expert-filter-utils.js +302 -0
  44. package/dist/components/filter/expert/expert-filter.type.d.ts +113 -0
  45. package/dist/components/filter/expert/expert-filter.type.js +103 -0
  46. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
  47. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
  48. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
  49. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
  50. package/dist/components/filter/filter-context.d.ts +12 -0
  51. package/dist/components/filter/filter-context.js +10 -0
  52. package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
  53. package/dist/components/filter/filter-creation-dialog.js +17 -0
  54. package/dist/components/filter/filter-form.d.ts +11 -0
  55. package/dist/components/filter/filter-form.js +14 -0
  56. package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
  57. package/dist/components/filter/utils/criteria-based-utils.js +197 -0
  58. package/dist/components/filter/utils/filters-utils.d.ts +5 -0
  59. package/dist/components/filter/utils/filters-utils.js +99 -0
  60. package/dist/components/inputs/select-clearable.d.ts +14 -0
  61. package/dist/components/inputs/select-clearable.js +40 -0
  62. package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
  63. package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
  64. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
  65. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
  66. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
  67. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
  68. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
  69. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
  70. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
  71. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
  72. package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
  73. package/dist/components/react-hook-form/autocomplete-input.js +4 -15
  74. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
  75. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
  76. package/dist/components/react-hook-form/directory-items-input.d.ts +2 -4
  77. package/dist/components/react-hook-form/directory-items-input.js +61 -12
  78. package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
  79. package/dist/components/react-hook-form/error-management/error-input.js +7 -7
  80. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
  81. package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
  82. package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
  83. package/dist/components/react-hook-form/numbers/float-input.js +3 -5
  84. package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
  85. package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
  86. package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
  87. package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
  88. package/dist/components/react-hook-form/radio-input.d.ts +14 -17
  89. package/dist/components/react-hook-form/radio-input.js +7 -9
  90. package/dist/components/react-hook-form/range-input.d.ts +54 -0
  91. package/dist/components/react-hook-form/range-input.js +118 -0
  92. package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
  93. package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
  94. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
  95. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
  96. package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
  97. package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
  98. package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
  99. package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
  100. package/dist/components/react-hook-form/text-input.d.ts +23 -32
  101. package/dist/components/react-hook-form/text-input.js +6 -20
  102. package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
  103. package/dist/components/react-hook-form/unique-name-input.js +129 -0
  104. package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
  105. package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
  106. package/dist/components/react-hook-form/utils/field-label.js +5 -1
  107. package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
  108. package/dist/components/react-hook-form/utils/functions.js +21 -1
  109. package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
  110. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
  111. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
  112. package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
  113. package/dist/components/react-query-builder-inputs/add-button.js +17 -0
  114. package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
  115. package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
  116. package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
  117. package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
  118. package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
  119. package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
  120. package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
  121. package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
  122. package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
  123. package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
  124. package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
  125. package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
  126. package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
  127. package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
  128. package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
  129. package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
  130. package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
  131. package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
  132. package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
  133. package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
  134. package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
  135. package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
  136. package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
  137. package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
  138. package/dist/components/translations/treeview-finder-en.d.ts +1 -0
  139. package/dist/components/translations/treeview-finder-en.js +4 -3
  140. package/dist/components/translations/treeview-finder-fr.d.ts +1 -0
  141. package/dist/components/translations/treeview-finder-fr.js +4 -3
  142. package/dist/hooks/localized-countries-hook.d.ts +6 -0
  143. package/dist/hooks/localized-countries-hook.js +45 -0
  144. package/dist/hooks/predefined-properties-hook.d.ts +18 -0
  145. package/dist/hooks/predefined-properties-hook.js +43 -0
  146. package/dist/hooks/useDebounce.d.ts +7 -1
  147. package/dist/hooks/useSnackMessage.d.ts +23 -5
  148. package/dist/hooks/useSnackMessage.js +14 -12
  149. package/dist/index.d.ts +92 -143
  150. package/dist/index.js +168 -91
  151. package/dist/utils/FetchStatus.d.ts +12 -0
  152. package/dist/utils/FetchStatus.js +9 -0
  153. package/dist/utils/conversion-utils.d.ts +12 -0
  154. package/dist/utils/conversion-utils.js +22 -0
  155. package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
  156. package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
  157. package/dist/utils/functions.d.ts +14 -0
  158. package/dist/utils/functions.js +16 -0
  159. package/dist/utils/types.d.ts +21 -0
  160. package/dist/utils/types.js +1 -0
  161. package/dist/utils/yup-config.d.ts +8 -0
  162. package/dist/utils/yup-config.js +16 -0
  163. package/package.json +27 -4
  164. package/dist/components/react-hook-form/select-input.d.ts +0 -17
  165. package/dist/components/react-hook-form/select-input.js +0 -30
@@ -0,0 +1,69 @@
1
+ import "react/jsx-runtime";
2
+ import "@mui/material/Dialog";
3
+ import "@mui/material/DialogTitle";
4
+ import "@mui/material/DialogContent";
5
+ import "@mui/material/DialogActions";
6
+ import "react-papaparse";
7
+ import "@mui/material/Button";
8
+ import "react";
9
+ import "@mui/material/Grid";
10
+ import "react-intl";
11
+ import "react-csv-downloader";
12
+ import "@mui/material/Alert";
13
+ import "@mui/material";
14
+ import "react-hook-form";
15
+ import "../../../TreeViewFinder/TreeViewFinder.js";
16
+ import "../../../TopBar/TopBar.js";
17
+ import "../../../TopBar/GridLogo.js";
18
+ import "../../../TopBar/AboutDialog.js";
19
+ import "../../../SnackbarProvider/SnackbarProvider.js";
20
+ import "react-router-dom";
21
+ import "../../../../utils/AuthService.js";
22
+ import "@mui/icons-material";
23
+ import "../../../MuiVirtualizedTable/MuiVirtualizedTable.js";
24
+ import "../../../ReportViewer/report-item.js";
25
+ import "uuid";
26
+ import "../../../ReportViewer/log-table.js";
27
+ import "../../../ReportViewer/report-tree-view-context.js";
28
+ import "@mui/x-tree-view";
29
+ import "../../../OverflowableText/overflowable-text.js";
30
+ import "../../../ElementSearchDialog/element-search-dialog.js";
31
+ import "../../../ElementSearchDialog/tag-renderer.js";
32
+ import "../../utils/submit-button.js";
33
+ import "../../utils/cancel-button.js";
34
+ import "../../provider/custom-form-provider.js";
35
+ import "../../../dialogs/description-modification-dialog.js";
36
+ import "../../../filter/constants/field-constants.js";
37
+ import "yup";
38
+ import "../../../dialogs/popup-confirmation-dialog.js";
39
+ import "../../../filter/utils/criteria-based-utils.js";
40
+ import { c } from "../../../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
41
+ import "ag-grid-react";
42
+ import "ag-grid-community/styles/ag-grid.css";
43
+ import "ag-grid-community/styles/ag-theme-alpine.css";
44
+ import "autosuggest-highlight/match";
45
+ import "autosuggest-highlight/parse";
46
+ import "clsx";
47
+ import "../../../CardErrorBoundary/card-error-boundary.js";
48
+ import "notistack";
49
+ import "../../slider-input.js";
50
+ import "../../numbers/integer-input.js";
51
+ import "../../booleans/checkbox-input.js";
52
+ import "../../booleans/switch-input.js";
53
+ import "@mui/icons-material/Folder";
54
+ import "../../../filter/filter-context.js";
55
+ import "../../../../chunks/filter-properties.GRon8-ML.js";
56
+ import "@mui/icons-material/Delete";
57
+ import "@mui/material/IconButton";
58
+ import "../../../filter/expert/expert-filter-utils.js";
59
+ import "../../range-input.js";
60
+ import "../../select-inputs/mui-select-input.js";
61
+ import "localized-countries";
62
+ import "localized-countries/data/fr";
63
+ import "localized-countries/data/en";
64
+ import "@mui/icons-material/Check";
65
+ import "@mui/material/CircularProgress";
66
+ import "@mui/material/TextField";
67
+ export {
68
+ c as default
69
+ };
@@ -0,0 +1,23 @@
1
+ import { FunctionComponent } from 'react';
2
+
3
+ export declare const ROW_DRAGGING_SELECTION_COLUMN_DEF: {
4
+ rowDrag: boolean;
5
+ headerCheckboxSelection: boolean;
6
+ checkboxSelection: boolean;
7
+ maxWidth: number;
8
+ }[];
9
+ export interface CustomAgGridTableProps {
10
+ name: string;
11
+ columnDefs: any;
12
+ makeDefaultRowData: any;
13
+ csvProps: unknown;
14
+ cssProps: unknown;
15
+ defaultColDef: unknown;
16
+ pagination: boolean;
17
+ paginationPageSize: number;
18
+ suppressRowClickSelection: boolean;
19
+ alwaysShowVerticalScroll: boolean;
20
+ stopEditingWhenCellsLoseFocus: boolean;
21
+ }
22
+ export declare const CustomAgGridTable: FunctionComponent<CustomAgGridTableProps>;
23
+ export default CustomAgGridTable;
@@ -0,0 +1,15 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "react-hook-form";
4
+ import "ag-grid-react";
5
+ import "ag-grid-community/styles/ag-grid.css";
6
+ import "ag-grid-community/styles/ag-theme-alpine.css";
7
+ import "@mui/material";
8
+ import { C, R, C as C2 } from "../../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
9
+ import "react-intl";
10
+ import "../../filter/constants/field-constants.js";
11
+ export {
12
+ C as CustomAgGridTable,
13
+ R as ROW_DRAGGING_SELECTION_COLUMN_DEF,
14
+ C2 as default
15
+ };
@@ -1,30 +1,18 @@
1
- import { default as PropTypes } from 'prop-types';
2
- import { identity } from './utils/functions';
3
- export default AutocompleteInput;
4
- declare function AutocompleteInput({ name, label, options, outputTransform, inputTransform, readOnly, previousValue, allowNewValue, onChangeCallback, formProps, ...props }: {
5
- [x: string]: any;
6
- name: any;
7
- label: any;
8
- options: any;
9
- outputTransform?: typeof identity | undefined;
10
- inputTransform?: typeof identity | undefined;
11
- readOnly?: boolean | undefined;
12
- previousValue: any;
13
- allowNewValue: any;
14
- onChangeCallback: any;
15
- formProps: any;
16
- }): import("react/jsx-runtime").JSX.Element;
17
- declare namespace AutocompleteInput {
18
- namespace propTypes {
19
- let name: PropTypes.Validator<string>;
20
- let label: PropTypes.Requireable<string>;
21
- let options: PropTypes.Validator<any[]>;
22
- let outputTransform: PropTypes.Requireable<(...args: any[]) => any>;
23
- let inputTransform: PropTypes.Requireable<(...args: any[]) => any>;
24
- let readOnly: PropTypes.Requireable<boolean>;
25
- let previousValue: PropTypes.Requireable<any>;
26
- let allowNewValue: PropTypes.Requireable<boolean>;
27
- let onChangeCallback: PropTypes.Requireable<(...args: any[]) => any>;
28
- let formProps: PropTypes.Requireable<object>;
29
- }
1
+ import { Option } from '../../utils/types.ts';
2
+ import { FunctionComponent } from 'react';
3
+ import { AutocompleteProps, TextFieldProps } from '@mui/material';
4
+
5
+ export interface AutocompleteInputProps extends Omit<AutocompleteProps<Option, boolean | undefined, boolean | undefined, boolean | undefined>, 'value' | 'onChange' | 'renderInput'> {
6
+ name: string;
7
+ options: Option[];
8
+ label?: string;
9
+ outputTransform?: (value: Option) => Option;
10
+ inputTransform?: (value: Option | any) => Option | null;
11
+ readOnly?: boolean;
12
+ previousValue?: string;
13
+ allowNewValue?: boolean;
14
+ onChangeCallback?: () => void;
15
+ formProps?: Omit<TextFieldProps, 'value' | 'onChange' | 'inputRef' | 'inputProps' | 'InputProps'>;
30
16
  }
17
+ declare const AutocompleteInput: FunctionComponent<AutocompleteInputProps>;
18
+ export default AutocompleteInput;
@@ -1,5 +1,4 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import PropTypes from "prop-types";
3
2
  import { Autocomplete, TextField } from "@mui/material";
4
3
  import { useController } from "react-hook-form";
5
4
  import { isFieldRequired, genHelperPreviousValue, genHelperError, identity } from "./utils/functions.js";
@@ -32,7 +31,9 @@ const AutocompleteInput = ({
32
31
  onChange(outputTransform(value2));
33
32
  return;
34
33
  }
35
- const matchingOption = options.find((option) => option.id === value2);
34
+ const matchingOption = options.find(
35
+ (option) => typeof option !== "string" && option.id === value2
36
+ );
36
37
  if (matchingOption) {
37
38
  onChange(outputTransform(matchingOption));
38
39
  return;
@@ -42,7 +43,7 @@ const AutocompleteInput = ({
42
43
  return /* @__PURE__ */ jsx(
43
44
  Autocomplete,
44
45
  {
45
- value: inputTransform(value),
46
+ value: inputTransform(value || ""),
46
47
  onChange: (_, data) => handleChange(data),
47
48
  ...allowNewValue && {
48
49
  freeSolo: true,
@@ -79,18 +80,6 @@ const AutocompleteInput = ({
79
80
  }
80
81
  );
81
82
  };
82
- AutocompleteInput.propTypes = {
83
- name: PropTypes.string.isRequired,
84
- label: PropTypes.string,
85
- options: PropTypes.array.isRequired,
86
- outputTransform: PropTypes.func,
87
- inputTransform: PropTypes.func,
88
- readOnly: PropTypes.bool,
89
- previousValue: PropTypes.any,
90
- allowNewValue: PropTypes.bool,
91
- onChangeCallback: PropTypes.func,
92
- formProps: PropTypes.object
93
- };
94
83
  export {
95
84
  AutocompleteInput as default
96
85
  };
@@ -0,0 +1,2 @@
1
+ declare const MultipleAutocompleteInput: ({ name, ...props }: any) => import("react/jsx-runtime").JSX.Element;
2
+ export default MultipleAutocompleteInput;
@@ -0,0 +1,46 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useWatch, useFieldArray } from "react-hook-form";
4
+ import AutocompleteInput from "../autocomplete-input.js";
5
+ const MultipleAutocompleteInput = ({ name, ...props }) => {
6
+ const [unsavedInput, setUnsavedInput] = useState("");
7
+ const watchAutocompleteValues = useWatch({
8
+ name
9
+ });
10
+ const { append } = useFieldArray({
11
+ name
12
+ });
13
+ const handleOnBlur = () => {
14
+ if (unsavedInput && !watchAutocompleteValues.includes(unsavedInput)) {
15
+ append(unsavedInput);
16
+ }
17
+ setUnsavedInput("");
18
+ };
19
+ const outputTransform = (values) => {
20
+ const newValues = values.map((val) => val.trim());
21
+ return newValues.filter(
22
+ (val, index) => newValues.indexOf(val) === index
23
+ );
24
+ };
25
+ return /* @__PURE__ */ jsx(
26
+ AutocompleteInput,
27
+ {
28
+ name,
29
+ fullWidth: true,
30
+ options: [],
31
+ allowNewValue: true,
32
+ clearOnBlur: true,
33
+ disableClearable: true,
34
+ outputTransform,
35
+ onInputChange: (_, val) => setUnsavedInput(val.trim() ?? ""),
36
+ onBlur: handleOnBlur,
37
+ blurOnSelect: false,
38
+ multiple: true,
39
+ ChipProps: { size: "small" },
40
+ ...props
41
+ }
42
+ );
43
+ };
44
+ export {
45
+ MultipleAutocompleteInput as default
46
+ };
@@ -2,7 +2,7 @@ import { UUID } from 'crypto';
2
2
  import { FunctionComponent } from 'react';
3
3
 
4
4
  export declare const NAME = "name";
5
- interface DirectoryItemsInputProps {
5
+ export interface DirectoryItemsInputProps {
6
6
  label: string | undefined;
7
7
  name: string;
8
8
  elementType: string;
@@ -13,10 +13,8 @@ interface DirectoryItemsInputProps {
13
13
  onRowChanged?: (a: boolean) => void;
14
14
  onChange?: (e: any) => void;
15
15
  disable?: boolean;
16
- fetchDirectoryContent: (directoryUuid: UUID, elementTypes: string[]) => Promise<any>;
17
- fetchRootFolders: (types: string[]) => Promise<any>;
18
- fetchElementsInfos: (ids: UUID[], elementTypes: string[], equipmentTypes?: string[]) => Promise<any>;
19
16
  labelRequiredFromContext?: boolean;
17
+ fetchDirectoryElementPath?: (id: UUID) => Promise<any[]>;
20
18
  }
21
19
  declare const DirectoryItemsInput: FunctionComponent<DirectoryItemsInputProps>;
22
20
  export default DirectoryItemsInput;
@@ -1,19 +1,20 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { FormControl, Chip, Grid, Tooltip, IconButton } from "@mui/material";
3
3
  import { OverflowableText } from "../OverflowableText/overflowable-text.js";
4
- import { useSnackMessage } from "../../hooks/useSnackMessage.js";
5
4
  import FieldLabel from "./utils/field-label.js";
6
5
  import FolderIcon from "@mui/icons-material/Folder";
7
- import { useMemo, useState, useCallback } from "react";
6
+ import { useState, useMemo, useContext, useCallback } from "react";
8
7
  import { useFieldArray, useController } from "react-hook-form";
9
8
  import { useIntl } from "react-intl";
10
- import ErrorInput from "./error-management/error-input.js";
11
9
  import MidFormError from "./error-management/mid-form-error.js";
12
10
  import { RawReadOnlyInput } from "./raw-read-only-input.js";
13
11
  import { mergeSx } from "../../utils/styles.js";
14
12
  import DirectoryItemSelector from "../DirectoryItemSelector/directory-item-selector.js";
15
13
  import { useCustomFormContext } from "./provider/use-custom-form-context.js";
16
14
  import { isFieldRequired } from "./utils/functions.js";
15
+ import ErrorInput from "./error-management/error-input.js";
16
+ import { useSnackMessage } from "../../hooks/useSnackMessage.js";
17
+ import { FilterContext } from "../filter/filter-context.js";
17
18
  const NAME = "name";
18
19
  const styles = {
19
20
  formDirectoryElements1: {
@@ -57,13 +58,14 @@ const DirectoryItemsInput = ({
57
58
  onRowChanged,
58
59
  onChange,
59
60
  disable = false,
60
- fetchDirectoryContent,
61
- fetchRootFolders,
62
- fetchElementsInfos,
63
- labelRequiredFromContext = true
61
+ labelRequiredFromContext = true,
62
+ fetchDirectoryElementPath
64
63
  }) => {
65
64
  const { snackError } = useSnackMessage();
66
65
  const intl = useIntl();
66
+ const [selected, setSelected] = useState([]);
67
+ const [expanded, setExpanded] = useState([]);
68
+ const [multiSelect, setMultiSelect] = useState(true);
67
69
  const types = useMemo(() => [elementType], [elementType]);
68
70
  const [directoryItemSelectorOpen, setDirectoryItemSelectorOpen] = useState(false);
69
71
  const {
@@ -75,6 +77,7 @@ const DirectoryItemsInput = ({
75
77
  });
76
78
  const formContext = useCustomFormContext();
77
79
  const { getValues, validationSchema } = formContext;
80
+ const { fetchDirectoryContent, fetchRootFolders, fetchElementsInfos } = useContext(FilterContext);
78
81
  const {
79
82
  fieldState: { error }
80
83
  } = useController({
@@ -82,6 +85,18 @@ const DirectoryItemsInput = ({
82
85
  });
83
86
  const addElements = useCallback(
84
87
  (values) => {
88
+ if (!values) {
89
+ return;
90
+ }
91
+ if ((selected == null ? void 0 : selected.length) > 0 && (values == null ? void 0 : values.length) > 0) {
92
+ selected.forEach((chip) => {
93
+ remove(
94
+ getValues(name).findIndex(
95
+ (item) => item.id === chip
96
+ )
97
+ );
98
+ });
99
+ }
85
100
  values.forEach((value) => {
86
101
  const { icon, children, ...otherElementAttributes } = value;
87
102
  if (getValues(name).find(
@@ -98,8 +113,18 @@ const DirectoryItemsInput = ({
98
113
  }
99
114
  });
100
115
  setDirectoryItemSelectorOpen(false);
116
+ setSelected([]);
101
117
  },
102
- [append, getValues, snackError, name, onRowChanged, onChange]
118
+ [
119
+ append,
120
+ getValues,
121
+ snackError,
122
+ name,
123
+ onRowChanged,
124
+ onChange,
125
+ selected,
126
+ remove
127
+ ]
103
128
  );
104
129
  const removeElements = useCallback(
105
130
  (index) => {
@@ -109,6 +134,23 @@ const DirectoryItemsInput = ({
109
134
  },
110
135
  [onRowChanged, remove, getValues, name, onChange]
111
136
  );
137
+ const handleChipClick = useCallback(
138
+ (index) => {
139
+ var _a;
140
+ const chips = getValues(name);
141
+ const chip = (_a = chips.at(index)) == null ? void 0 : _a.id;
142
+ if (chip && fetchDirectoryElementPath) {
143
+ fetchDirectoryElementPath(chip).then((response) => {
144
+ const path = response.reverse().filter((e) => e.elementUuid !== chip).map((e) => e.elementUuid);
145
+ setExpanded(path);
146
+ setSelected([chip]);
147
+ setDirectoryItemSelectorOpen(true);
148
+ setMultiSelect(false);
149
+ });
150
+ }
151
+ },
152
+ [getValues, name, fetchDirectoryElementPath]
153
+ );
112
154
  return /* @__PURE__ */ jsxs(Fragment, { children: [
113
155
  /* @__PURE__ */ jsxs(
114
156
  FormControl,
@@ -135,6 +177,7 @@ const DirectoryItemsInput = ({
135
177
  {
136
178
  size: "small",
137
179
  onDelete: () => removeElements(index),
180
+ onClick: () => handleChipClick(index),
138
181
  label: /* @__PURE__ */ jsx(
139
182
  OverflowableText,
140
183
  {
@@ -150,16 +193,19 @@ const DirectoryItemsInput = ({
150
193
  },
151
194
  item.id
152
195
  )) }),
153
- /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(Grid, { container: true, direction: "row-reverse", children: /* @__PURE__ */ jsx(Tooltip, { title: intl.formatMessage({ id: titleId }), children: /* @__PURE__ */ jsx(
196
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(Grid, { container: true, direction: "row-reverse", children: /* @__PURE__ */ jsx(Tooltip, { title: intl.formatMessage({ id: titleId }), children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
154
197
  IconButton,
155
198
  {
156
199
  sx: styles.addDirectoryElements,
157
200
  size: "small",
158
201
  disabled: disable,
159
- onClick: () => setDirectoryItemSelectorOpen(true),
202
+ onClick: () => {
203
+ setDirectoryItemSelectorOpen(true);
204
+ setMultiSelect(true);
205
+ },
160
206
  children: /* @__PURE__ */ jsx(FolderIcon, {})
161
207
  }
162
- ) }) }) })
208
+ ) }) }) }) })
163
209
  ]
164
210
  }
165
211
  ),
@@ -175,7 +221,10 @@ const DirectoryItemsInput = ({
175
221
  itemFilter,
176
222
  fetchDirectoryContent,
177
223
  fetchRootFolders,
178
- fetchElementsInfos
224
+ fetchElementsInfos,
225
+ selected,
226
+ expanded,
227
+ multiSelect
179
228
  }
180
229
  )
181
230
  ] });
@@ -1,5 +1,14 @@
1
+ import { default as React, FunctionComponent } from 'react';
2
+
3
+ export type ErrorMessage = {
4
+ id: string;
5
+ value: string;
6
+ } | string;
7
+ export interface ErrorInputProps {
8
+ name: string;
9
+ InputField: ({ message, }: {
10
+ message: string | React.ReactNode;
11
+ }) => React.ReactNode;
12
+ }
13
+ declare const ErrorInput: FunctionComponent<ErrorInputProps>;
1
14
  export default ErrorInput;
2
- declare function ErrorInput({ name, InputField }: {
3
- name: any;
4
- InputField: any;
5
- }): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,10 @@ import { jsx, Fragment } from "react/jsx-runtime";
2
2
  import { useRef, useEffect } from "react";
3
3
  import { FormattedMessage } from "react-intl";
4
4
  import { useController } from "react-hook-form";
5
- const ErrorInput = ({ name, InputField }) => {
5
+ const ErrorInput = ({
6
+ name,
7
+ InputField
8
+ }) => {
6
9
  const {
7
10
  fieldState: { error },
8
11
  formState: { isSubmitting }
@@ -30,12 +33,9 @@ const ErrorInput = ({ name, InputField }) => {
30
33
  errorRef.current.scrollIntoView({ behavior: "smooth" });
31
34
  }
32
35
  }, [isSubmitting]);
33
- return /* @__PURE__ */ jsx(Fragment, { children: (error == null ? void 0 : error.message) && /* @__PURE__ */ jsx("div", { ref: errorRef, children: /* @__PURE__ */ jsx(
34
- InputField,
35
- {
36
- message: /* @__PURE__ */ jsx(FormattedMessage, { ...errorProps(error == null ? void 0 : error.message) })
37
- }
38
- ) }) });
36
+ return /* @__PURE__ */ jsx(Fragment, { children: (error == null ? void 0 : error.message) && /* @__PURE__ */ jsx("div", { ref: errorRef, children: InputField({
37
+ message: /* @__PURE__ */ jsx(FormattedMessage, { ...errorProps(error == null ? void 0 : error.message) })
38
+ }) }) });
39
39
  };
40
40
  export {
41
41
  ErrorInput as default
@@ -1,4 +1,7 @@
1
+ import { default as React, FunctionComponent } from 'react';
2
+
3
+ interface FieldErrorAlertProps {
4
+ message: string | React.ReactNode;
5
+ }
6
+ declare const FieldErrorAlert: FunctionComponent<FieldErrorAlertProps>;
1
7
  export default FieldErrorAlert;
2
- declare function FieldErrorAlert({ message }: {
3
- message: any;
4
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Grid, Alert } from "@mui/material";
3
- const FieldErrorAlert = ({ message }) => {
3
+ const FieldErrorAlert = ({
4
+ message
5
+ }) => {
4
6
  return /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Alert, { severity: "error", children: message }) });
5
7
  };
6
8
  export {
@@ -1,18 +1,6 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { TextInputProps } from '../text-input';
3
+
4
+ export type FloatInputProps = Omit<TextInputProps, 'outputTransform' | 'inputTransform' | 'acceptValue'>;
5
+ declare const FloatInput: FunctionComponent<FloatInputProps>;
1
6
  export default FloatInput;
2
- declare function FloatInput(props: any): import("react/jsx-runtime").JSX.Element;
3
- declare namespace FloatInput {
4
- let propTypes: {
5
- name: import('prop-types').Requireable<string>;
6
- label: import('prop-types').Requireable<string>;
7
- labelValues: import('prop-types').Requireable<object>;
8
- id: import('prop-types').Requireable<string>;
9
- adornment: import('prop-types').Requireable<object>;
10
- customAdornment: import('prop-types').Requireable<object>;
11
- outputTransform: import('prop-types').Requireable<(...args: any[]) => any>;
12
- inputTransform: import('prop-types').Requireable<(...args: any[]) => any>;
13
- acceptValue: import('prop-types').Requireable<(...args: any[]) => any>;
14
- previousValue: import('prop-types').Requireable<any>;
15
- clearable: import('prop-types').Requireable<boolean>;
16
- formProps: import('prop-types').Requireable<object>;
17
- };
18
- }
@@ -11,12 +11,13 @@ const FloatInput = (props) => {
11
11
  const inputTransform = (value) => {
12
12
  if (typeof value == "number" && !isNaN(value)) {
13
13
  return normalizeFixed(value);
14
- } else {
14
+ } else if (typeof value == "string") {
15
15
  if (["-", "."].includes(value)) {
16
16
  return value;
17
17
  }
18
- return value === null || isNaN(value) ? "" : value;
18
+ return Number.isNaN(value) ? "" : value;
19
19
  }
20
+ return "";
20
21
  };
21
22
  const outputTransform = (value) => {
22
23
  if (value === "-") {
@@ -42,9 +43,6 @@ const FloatInput = (props) => {
42
43
  }
43
44
  );
44
45
  };
45
- FloatInput.propTypes = {
46
- ...TextInput.propTypes
47
- };
48
46
  export {
49
47
  FloatInput as default
50
48
  };
@@ -2,17 +2,20 @@ export default IntegerInput;
2
2
  declare function IntegerInput(props: any): import("react/jsx-runtime").JSX.Element;
3
3
  declare namespace IntegerInput {
4
4
  let propTypes: {
5
- name: import('prop-types').Requireable<string>;
6
- label: import('prop-types').Requireable<string>;
7
- labelValues: import('prop-types').Requireable<object>;
8
- id: import('prop-types').Requireable<string>;
9
- adornment: import('prop-types').Requireable<object>;
10
- customAdornment: import('prop-types').Requireable<object>;
11
- outputTransform: import('prop-types').Requireable<(...args: any[]) => any>;
12
- inputTransform: import('prop-types').Requireable<(...args: any[]) => any>;
13
- acceptValue: import('prop-types').Requireable<(...args: any[]) => any>;
14
- previousValue: import('prop-types').Requireable<any>;
15
- clearable: import('prop-types').Requireable<boolean>;
16
- formProps: import('prop-types').Requireable<object>;
5
+ name?: import('react').Validator<string> | undefined;
6
+ label?: import('react').Validator<string | null | undefined> | undefined;
7
+ labelValues?: import('react').Validator<any> | undefined;
8
+ id?: import('react').Validator<string | null | undefined> | undefined;
9
+ adornment?: import('react').Validator<{
10
+ position: string;
11
+ text: string;
12
+ } | null | undefined> | undefined;
13
+ customAdornment?: import('react').Validator<import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null | undefined> | undefined;
14
+ outputTransform?: import('react').Validator<((value: string) => import("../../../utils/types").Input | null) | null | undefined> | undefined;
15
+ inputTransform?: import('react').Validator<((value: import("../../../utils/types").Input) => string) | null | undefined> | undefined;
16
+ acceptValue?: import('react').Validator<((value: string) => boolean) | null | undefined> | undefined;
17
+ previousValue?: import('react').Validator<import("../../../utils/types").Input | null | undefined> | undefined;
18
+ clearable?: import('react').Validator<boolean | null | undefined> | undefined;
19
+ formProps?: import('react').Validator<Omit<import("@mui/material").TextFieldProps | import("../utils/text-field-with-adornment").TextFieldWithAdornmentProps, "onChange" | "value" | "InputProps" | "inputProps" | "inputRef"> | null | undefined> | undefined;
17
20
  };
18
21
  }
@@ -1,2 +1,8 @@
1
- export function isIntegerNumber(val: any): boolean;
2
- export function isFloatNumber(val: any): boolean;
1
+ /**
2
+ * Copyright (c) 2024, RTE (http://www.rte-france.com)
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
+ */
7
+ export declare const isIntegerNumber: (val: string) => boolean;
8
+ export declare const isFloatNumber: (val: string) => boolean;
@@ -5,6 +5,7 @@ import * as yup from 'yup';
5
5
  type CustomFormContextProps = {
6
6
  removeOptional?: boolean;
7
7
  validationSchema: yup.AnySchema;
8
+ language?: string;
8
9
  };
9
10
  export type MergedFormContextProps = UseFormReturn<any> & CustomFormContextProps;
10
11
  type CustomFormProviderProps = PropsWithChildren<MergedFormContextProps>;
@@ -2,18 +2,27 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { createContext } from "react";
3
3
  import { FormProvider } from "react-hook-form";
4
4
  import * as yup from "yup";
5
+ import { getSystemLanguage } from "../../../hooks/localized-countries-hook.js";
5
6
  const CustomFormContext = createContext({
6
7
  removeOptional: false,
7
- validationSchema: yup.object()
8
+ validationSchema: yup.object(),
9
+ language: getSystemLanguage()
8
10
  });
9
11
  const CustomFormProvider = (props) => {
10
- const { validationSchema, removeOptional, children, ...formMethods } = props;
12
+ const {
13
+ validationSchema,
14
+ removeOptional,
15
+ language,
16
+ children,
17
+ ...formMethods
18
+ } = props;
11
19
  return /* @__PURE__ */ jsx(FormProvider, { ...formMethods, children: /* @__PURE__ */ jsx(
12
20
  CustomFormContext.Provider,
13
21
  {
14
22
  value: {
15
23
  validationSchema,
16
- removeOptional
24
+ removeOptional,
25
+ language
17
26
  },
18
27
  children
19
28
  }