@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,100 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useCallback } from "react";
3
+ import Grid from "@mui/material/Grid";
4
+ import { Autocomplete, TextField, Select, MenuItem } from "@mui/material";
5
+ import useValid from "./use-valid.js";
6
+ import { useIntl } from "react-intl";
7
+ import { FieldConstants } from "../filter/constants/field-constants.js";
8
+ import { OPERATOR_OPTIONS } from "../filter/constants/expert-filter-constants.js";
9
+ import { usePredefinedProperties } from "../../hooks/predefined-properties-hook.js";
10
+ const PROPERTY_VALUE_OPERATORS = [OPERATOR_OPTIONS.IN];
11
+ const PropertyValueEditor = (props) => {
12
+ const { equipmentType, valueEditorProps } = props;
13
+ const valid = useValid(valueEditorProps);
14
+ const intl = useIntl();
15
+ const { propertyName, propertyOperator, propertyValues } = (valueEditorProps == null ? void 0 : valueEditorProps.value) ?? {};
16
+ const [equipmentPredefinedProps, setEquipmentType] = usePredefinedProperties(equipmentType);
17
+ useEffect(() => {
18
+ setEquipmentType(equipmentType);
19
+ }, [equipmentType, setEquipmentType]);
20
+ const predefinedNames = useMemo(() => {
21
+ return Object.keys(equipmentPredefinedProps ?? {}).sort();
22
+ }, [equipmentPredefinedProps]);
23
+ const predefinedValues = useMemo(() => {
24
+ const predefinedForName = equipmentPredefinedProps == null ? void 0 : equipmentPredefinedProps[propertyName];
25
+ if (!predefinedForName) {
26
+ return [];
27
+ }
28
+ return [...new Set(predefinedForName)].sort();
29
+ }, [equipmentPredefinedProps, propertyName]);
30
+ const onChange = useCallback(
31
+ (field, value) => {
32
+ var _a, _b;
33
+ let updatedValue = {
34
+ ...valueEditorProps == null ? void 0 : valueEditorProps.value,
35
+ [FieldConstants.PROPERTY_OPERATOR]: ((_a = valueEditorProps == null ? void 0 : valueEditorProps.value) == null ? void 0 : _a.propertyOperator) ?? PROPERTY_VALUE_OPERATORS[0].customName,
36
+ [field]: value
37
+ };
38
+ if (field === FieldConstants.PROPERTY_NAME) {
39
+ updatedValue = {
40
+ ...updatedValue,
41
+ [FieldConstants.PROPERTY_VALUES]: []
42
+ };
43
+ }
44
+ (_b = valueEditorProps == null ? void 0 : valueEditorProps.handleOnChange) == null ? void 0 : _b.call(valueEditorProps, updatedValue);
45
+ },
46
+ [valueEditorProps]
47
+ );
48
+ return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, spacing: 1, children: [
49
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 5, children: /* @__PURE__ */ jsx(
50
+ Autocomplete,
51
+ {
52
+ value: propertyName ?? "",
53
+ options: predefinedNames,
54
+ freeSolo: true,
55
+ autoSelect: true,
56
+ forcePopupIcon: true,
57
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, error: !valid }),
58
+ onChange: (event, value) => {
59
+ onChange(FieldConstants.PROPERTY_NAME, value);
60
+ }
61
+ }
62
+ ) }),
63
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 2.5, children: /* @__PURE__ */ jsx(
64
+ Select,
65
+ {
66
+ value: propertyOperator ?? PROPERTY_VALUE_OPERATORS[0].customName,
67
+ size: "medium",
68
+ error: !valid,
69
+ onChange: (event, value) => {
70
+ onChange(FieldConstants.PROPERTY_OPERATOR, value);
71
+ },
72
+ children: PROPERTY_VALUE_OPERATORS.map((operator) => /* @__PURE__ */ jsx(
73
+ MenuItem,
74
+ {
75
+ value: operator.customName,
76
+ children: intl.formatMessage({ id: operator.label })
77
+ },
78
+ operator.customName
79
+ ))
80
+ }
81
+ ) }),
82
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 4.5, children: /* @__PURE__ */ jsx(
83
+ Autocomplete,
84
+ {
85
+ value: propertyValues ?? [],
86
+ options: predefinedValues ?? [],
87
+ multiple: true,
88
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, error: !valid }),
89
+ freeSolo: true,
90
+ autoSelect: true,
91
+ onChange: (event, value) => {
92
+ onChange(FieldConstants.PROPERTY_VALUES, value);
93
+ }
94
+ }
95
+ ) })
96
+ ] });
97
+ };
98
+ export {
99
+ PropertyValueEditor as default
100
+ };
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ActionWithRulesProps } from 'react-querybuilder';
3
+
4
+ declare const RemoveButton: FunctionComponent<ActionWithRulesProps>;
5
+ export default RemoveButton;
@@ -0,0 +1,9 @@
1
+ import "react/jsx-runtime";
2
+ import "@mui/material/IconButton";
3
+ import "@mui/icons-material/Delete";
4
+ import "react-hook-form";
5
+ import { h } from "../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
6
+ import "../filter/expert/expert-filter-utils.js";
7
+ export {
8
+ h as default
9
+ };
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ValueEditorProps } from 'react-querybuilder';
3
+
4
+ declare const TextValueEditor: FunctionComponent<ValueEditorProps>;
5
+ export default TextValueEditor;
@@ -0,0 +1,34 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { MaterialValueEditor } from "@react-querybuilder/material";
3
+ import useConvertValue from "./use-convert-value.js";
4
+ import { Autocomplete, TextField } from "@mui/material";
5
+ import useValid from "./use-valid.js";
6
+ const TextValueEditor = (props) => {
7
+ useConvertValue(props);
8
+ const valid = useValid(props);
9
+ if (!Array.isArray(props.value)) {
10
+ return /* @__PURE__ */ jsx(
11
+ MaterialValueEditor,
12
+ {
13
+ ...props,
14
+ title: void 0
15
+ }
16
+ );
17
+ } else {
18
+ return /* @__PURE__ */ jsx(
19
+ Autocomplete,
20
+ {
21
+ value: props.value,
22
+ freeSolo: true,
23
+ options: [],
24
+ onChange: (event, value) => props.handleOnChange(value),
25
+ multiple: true,
26
+ fullWidth: true,
27
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, error: !valid })
28
+ }
29
+ );
30
+ }
31
+ };
32
+ export {
33
+ TextValueEditor as default
34
+ };
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ValueEditorProps } from 'react-querybuilder';
3
+
4
+ declare const TranslatedValueEditor: FunctionComponent<ValueEditorProps>;
5
+ export default TranslatedValueEditor;
@@ -0,0 +1,58 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { MaterialValueEditor } from "@react-querybuilder/material";
4
+ import { useIntl } from "react-intl";
5
+ import useConvertValue from "./use-convert-value.js";
6
+ import { Autocomplete, TextField } from "@mui/material";
7
+ import useValid from "./use-valid.js";
8
+ const TranslatedValueEditor = (props) => {
9
+ const intl = useIntl();
10
+ const translatedValues = useMemo(() => {
11
+ var _a;
12
+ return (_a = props.values) == null ? void 0 : _a.map((v) => {
13
+ return {
14
+ name: v.name,
15
+ label: intl.formatMessage({ id: v.label })
16
+ };
17
+ });
18
+ }, [intl, props.values]);
19
+ const translatedValuesAutocomplete = useMemo(() => {
20
+ if (!props.values) {
21
+ return {};
22
+ }
23
+ return Object.fromEntries(
24
+ props.values.map((v) => [
25
+ v.name,
26
+ intl.formatMessage({ id: v.label })
27
+ ])
28
+ );
29
+ }, [intl, props.values]);
30
+ useConvertValue(props);
31
+ const valid = useValid(props);
32
+ if (!Array.isArray(props.value)) {
33
+ return /* @__PURE__ */ jsx(
34
+ MaterialValueEditor,
35
+ {
36
+ ...props,
37
+ values: translatedValues,
38
+ title: void 0
39
+ }
40
+ );
41
+ } else {
42
+ return /* @__PURE__ */ jsx(
43
+ Autocomplete,
44
+ {
45
+ value: props.value,
46
+ options: Object.keys(translatedValuesAutocomplete),
47
+ getOptionLabel: (code) => translatedValuesAutocomplete[code],
48
+ onChange: (event, value) => props.handleOnChange(value),
49
+ multiple: true,
50
+ fullWidth: true,
51
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, error: !valid })
52
+ }
53
+ );
54
+ }
55
+ };
56
+ export {
57
+ TranslatedValueEditor as default
58
+ };
@@ -0,0 +1,9 @@
1
+ import { ValueEditorProps } from 'react-querybuilder';
2
+
3
+ /**
4
+ * Hook that convert a value of RQB from any to any[] and vice versa when the operator changes
5
+ * PS : can be extended to manage more than the IN operator
6
+ * PS 2 : don't use this if the operator can be another array operator (like BETWEEN) or change a bit the conditions
7
+ */
8
+ declare const useConvertValue: ({ operator, value, fieldData: { defaultValue }, handleOnChange, }: ValueEditorProps) => void;
9
+ export default useConvertValue;
@@ -0,0 +1,24 @@
1
+ import { useEffect } from "react";
2
+ import { OPERATOR_OPTIONS } from "../filter/constants/expert-filter-constants.js";
3
+ const useConvertValue = ({
4
+ operator,
5
+ value,
6
+ fieldData: { defaultValue },
7
+ handleOnChange
8
+ }) => {
9
+ useEffect(
10
+ () => {
11
+ if (operator === OPERATOR_OPTIONS.IN.name && !Array.isArray(value)) {
12
+ handleOnChange(value ? [value] : []);
13
+ } else if (operator !== OPERATOR_OPTIONS.IN.name && Array.isArray(value)) {
14
+ handleOnChange(value.length ? value[0] : defaultValue);
15
+ }
16
+ },
17
+ // We want to trigger this useEffect only if the operator change
18
+ // eslint-disable-next-line
19
+ [operator]
20
+ );
21
+ };
22
+ export {
23
+ useConvertValue as default
24
+ };
@@ -0,0 +1,7 @@
1
+ import { ValueEditorProps } from 'react-querybuilder';
2
+
3
+ /**
4
+ * Hook that return if a field of RQB is valid or not
5
+ */
6
+ declare const useValid: ({ validation }: ValueEditorProps) => boolean;
7
+ export default useValid;
@@ -0,0 +1,13 @@
1
+ const useValid = ({ validation }) => {
2
+ if (validation === void 0 || validation === null) {
3
+ return true;
4
+ }
5
+ if (typeof validation === "boolean") {
6
+ return validation;
7
+ }
8
+ const convertedValidation = validation;
9
+ return convertedValidation.valid;
10
+ };
11
+ export {
12
+ useValid as default
13
+ };
@@ -0,0 +1,5 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ValueEditorProps } from 'react-querybuilder';
3
+
4
+ declare const ValueEditor: FunctionComponent<ValueEditorProps>;
5
+ export default ValueEditor;
@@ -0,0 +1,18 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "@react-querybuilder/material";
4
+ import "./country-value-editor.js";
5
+ import "./translated-value-editor.js";
6
+ import "./text-value-editor.js";
7
+ import "@mui/material/Box";
8
+ import "react-hook-form";
9
+ import "../filter/constants/field-constants.js";
10
+ import "../filter/expert/expert-filter.type.js";
11
+ import "../filter/constants/equipment-types.js";
12
+ import { V } from "../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
13
+ import "../../utils/ElementType.js";
14
+ import "./property-value-editor.js";
15
+ import "../filter/constants/filter-constants.js";
16
+ export {
17
+ V as default
18
+ };
@@ -0,0 +1,4 @@
1
+ import { ValueSelectorProps } from 'react-querybuilder';
2
+
3
+ declare const ValueSelector: (props: ValueSelectorProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default ValueSelector;
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { MaterialValueSelector } from "@react-querybuilder/material";
3
+ const ValueSelector = (props) => {
4
+ return /* @__PURE__ */ jsx(
5
+ MaterialValueSelector,
6
+ {
7
+ ...props,
8
+ title: void 0
9
+ }
10
+ );
11
+ };
12
+ export {
13
+ ValueSelector as default
14
+ };
@@ -13,4 +13,5 @@ declare const treeview_finder_en: {
13
13
  'treeview_finder/contentText': string;
14
14
  'treeview_finder/finderTitle': string;
15
15
  'treeview_finder/addElementsValidation': string;
16
+ 'treeview_finder/replaceElementsValidation': string;
16
17
  };
@@ -3,9 +3,10 @@ const treeview_finder_en = {
3
3
  "treeview_finder/validate": "Validate",
4
4
  "treeview_finder/add": "Add...",
5
5
  "treeview_finder/deleteSelection": "Delete selection",
6
- "treeview_finder/contentText": "{multiselect, select, true {Please choose one or more element(s).} false {Please choose one element.} other {}}",
7
- "treeview_finder/finderTitle": "{multiselect, select, true {Please choose one or more element(s).} false {Please choose one element.} other {}}",
8
- "treeview_finder/addElementsValidation": "{nbElements, plural, =0 {Please select an element} =1 {Add this element} other{Add # elements}}"
6
+ "treeview_finder/contentText": "{multiSelect, select, true {Please choose one or more element(s).} false {Please choose one element.} other {}}",
7
+ "treeview_finder/finderTitle": "{multiSelect, select, true {Please choose one or more element(s).} false {Please choose one element.} other {}}",
8
+ "treeview_finder/addElementsValidation": "{nbElements, plural, =0 {Please select an element} =1 {Add this element} other{Add # elements}}",
9
+ "treeview_finder/replaceElementsValidation": "{nbElements, plural, =0 {Please select an element} =1 {Replace with this element} other{Replace with # elements}}"
9
10
  };
10
11
  export {
11
12
  treeview_finder_en as default
@@ -13,4 +13,5 @@ declare const treeview_finder_fr: {
13
13
  'treeview_finder/contentText': string;
14
14
  'treeview_finder/finderTitle': string;
15
15
  'treeview_finder/addElementsValidation': string;
16
+ 'treeview_finder/replaceElementsValidation': string;
16
17
  };
@@ -3,9 +3,10 @@ const treeview_finder_fr = {
3
3
  "treeview_finder/validate": "Valider",
4
4
  "treeview_finder/add": "Ajouter...",
5
5
  "treeview_finder/deleteSelection": "Supprimer la selection",
6
- "treeview_finder/contentText": "{multiselect, select, true {Veuillez choisir un ou plusieurs éléments.} false {Veuillez choisir un élément.} other {}}",
7
- "treeview_finder/finderTitle": "{multiselect, select, true {Veuillez choisir un ou plusieurs éléments.} false {Veuillez choisir un élément.} other {}}",
8
- "treeview_finder/addElementsValidation": "{nbElements, plural, =0 {Veuillez sélectionner un élément} =1 {Ajouter cet élément} other {Ajouter # éléments}}"
6
+ "treeview_finder/contentText": "{multiSelect, select, true {Veuillez choisir un ou plusieurs éléments.} false {Veuillez choisir un élément.} other {}}",
7
+ "treeview_finder/finderTitle": "{multiSelect, select, true {Veuillez choisir un ou plusieurs éléments.} false {Veuillez choisir un élément.} other {}}",
8
+ "treeview_finder/addElementsValidation": "{nbElements, plural, =0 {Veuillez sélectionner un élément} =1 {Ajouter cet élément} other {Ajouter # éléments}}",
9
+ "treeview_finder/replaceElementsValidation": "{nbElements, plural, =0 {Veuillez sélectionner un élément} =1 {Remplacer par cet élément} other {Remplacer par # éléments}}"
9
10
  };
10
11
  export {
11
12
  treeview_finder_fr as default
@@ -0,0 +1,6 @@
1
+ export function getSystemLanguage(): string;
2
+ export function getComputedLanguage(language: any): any;
3
+ export function useLocalizedCountries(language: any): {
4
+ translate: (countryCode: any) => any;
5
+ countryCodes: string[];
6
+ };
@@ -0,0 +1,45 @@
1
+ import { useState, useEffect, useMemo, useCallback } from "react";
2
+ import localizedCountries from "localized-countries";
3
+ import countriesFr from "localized-countries/data/fr";
4
+ import countriesEn from "localized-countries/data/en";
5
+ import { LANG_ENGLISH, LANG_SYSTEM, LANG_FRENCH } from "../components/TopBar/TopBar.js";
6
+ const supportedLanguages = [LANG_FRENCH, LANG_ENGLISH];
7
+ const getSystemLanguage = () => {
8
+ const systemLanguage = navigator.language.split(/[-_]/)[0];
9
+ return supportedLanguages.includes(systemLanguage) ? systemLanguage : LANG_ENGLISH;
10
+ };
11
+ const getComputedLanguage = (language) => {
12
+ return language === LANG_SYSTEM ? getSystemLanguage() : language;
13
+ };
14
+ const useLocalizedCountries = (language) => {
15
+ const [localizedCountriesModule, setLocalizedCountriesModule] = useState();
16
+ useEffect(() => {
17
+ const lang = getComputedLanguage(language).substring(0, 2);
18
+ let localizedCountriesResult;
19
+ if (lang === "fr") {
20
+ localizedCountriesResult = localizedCountries(countriesFr);
21
+ } else if (lang === "en") {
22
+ localizedCountriesResult = localizedCountries(countriesEn);
23
+ } else {
24
+ console.warn(
25
+ 'Unsupported language "' + lang + '" for countries translation, we use english as default'
26
+ );
27
+ localizedCountriesResult = localizedCountries(countriesEn);
28
+ }
29
+ setLocalizedCountriesModule(localizedCountriesResult);
30
+ }, [language]);
31
+ const countryCodes = useMemo(
32
+ () => localizedCountriesModule ? Object.keys(localizedCountriesModule.object()) : [],
33
+ [localizedCountriesModule]
34
+ );
35
+ const translate = useCallback(
36
+ (countryCode) => localizedCountriesModule ? localizedCountriesModule.get(countryCode) : "",
37
+ [localizedCountriesModule]
38
+ );
39
+ return { translate, countryCodes };
40
+ };
41
+ export {
42
+ getComputedLanguage,
43
+ getSystemLanguage,
44
+ useLocalizedCountries
45
+ };
@@ -0,0 +1,18 @@
1
+ import { EquipmentType, PredefinedProperties } from '../utils/types.ts';
2
+ import { Dispatch, SetStateAction } from 'react';
3
+
4
+ interface Metadata {
5
+ name: string;
6
+ url: string;
7
+ appColor: string;
8
+ hiddenInAppsMenu: boolean;
9
+ resources: unknown;
10
+ }
11
+ export interface StudyMetadata extends Metadata {
12
+ name: 'Study';
13
+ predefinedEquipmentProperties: {
14
+ [networkElementType: string]: PredefinedProperties;
15
+ };
16
+ }
17
+ export declare const usePredefinedProperties: (initialType: EquipmentType | null) => [PredefinedProperties, Dispatch<SetStateAction<EquipmentType | null>>];
18
+ export {};
@@ -0,0 +1,43 @@
1
+ import { useState, useContext, useEffect } from "react";
2
+ import { mapEquipmentTypeForPredefinedProperties } from "../utils/equipment-types-for-predefined-properties-mapper.js";
3
+ import { useSnackMessage } from "./useSnackMessage.js";
4
+ import { FilterContext } from "../components/filter/filter-context.js";
5
+ const isStudyMetadata = (metadata) => {
6
+ return metadata.name === "Study";
7
+ };
8
+ const fetchPredefinedProperties = async (equipmentType, fetchAppsAndUrls) => {
9
+ var _a;
10
+ const networkEquipmentType = mapEquipmentTypeForPredefinedProperties(equipmentType);
11
+ if (networkEquipmentType === void 0) {
12
+ return Promise.resolve(void 0);
13
+ }
14
+ const res = await fetchAppsAndUrls();
15
+ const studyMetadata = res.filter(isStudyMetadata);
16
+ if (!studyMetadata) {
17
+ return Promise.reject("Study entry could not be found in metadata");
18
+ }
19
+ return (_a = studyMetadata[0].predefinedEquipmentProperties) == null ? void 0 : _a[networkEquipmentType];
20
+ };
21
+ const usePredefinedProperties = (initialType) => {
22
+ const [type, setType] = useState(initialType);
23
+ const [equipmentPredefinedProps, setEquipmentPredefinedProps] = useState({});
24
+ const { snackError } = useSnackMessage();
25
+ const { fetchAppsAndUrls } = useContext(FilterContext);
26
+ useEffect(() => {
27
+ if (fetchAppsAndUrls && type !== null) {
28
+ fetchPredefinedProperties(type, fetchAppsAndUrls).then((p) => {
29
+ if (p !== void 0) {
30
+ setEquipmentPredefinedProps(p);
31
+ }
32
+ }).catch((error) => {
33
+ snackError({
34
+ messageTxt: error.message ?? error
35
+ });
36
+ });
37
+ }
38
+ }, [type, setEquipmentPredefinedProps, snackError, fetchAppsAndUrls]);
39
+ return [equipmentPredefinedProps, setType];
40
+ };
41
+ export {
42
+ usePredefinedProperties
43
+ };
@@ -1 +1,7 @@
1
- export function useDebounce(func: any, delay?: number): any;
1
+ /**
2
+ * Copyright (c) 2023, 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 useDebounce: (func: (...args: any[]) => any, delay?: number) => ((...args: any[]) => any) & import('@mui/utils/debounce').Cancelable;
@@ -1,5 +1,23 @@
1
- export function useSnackMessage(): {
2
- snackError: (snackInputs: any) => void;
3
- snackInfo: (snackInputs: any) => void;
4
- snackWarning: (snackInputs: any) => void;
5
- };
1
+ /**
2
+ * Copyright (c) 2021, 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
+ interface SnackInputs {
8
+ messageTxt?: string;
9
+ messageId?: string;
10
+ messageValues?: {
11
+ [key: string]: string;
12
+ };
13
+ headerTxt?: string;
14
+ headerId?: string;
15
+ headerValues?: Record<string, string>;
16
+ }
17
+ export interface UseSnackMessageReturn {
18
+ snackError: (snackInputs: SnackInputs) => void;
19
+ snackWarning: (snackInputs: SnackInputs) => void;
20
+ snackInfo: (snackInputs: SnackInputs) => void;
21
+ }
22
+ export declare function useSnackMessage(): UseSnackMessageReturn;
23
+ export {};
@@ -26,26 +26,28 @@ function useSnackMessage() {
26
26
  }
27
27
  function makeSnackbar(snackInputs, intlRef, enqueueSnackbar, level, persistent) {
28
28
  const message = checkAndTranslateIfNecessary(
29
+ intlRef,
29
30
  snackInputs.messageTxt,
30
31
  snackInputs.messageId,
31
- snackInputs.messageValues,
32
- intlRef
32
+ snackInputs.messageValues
33
33
  );
34
34
  const header = checkAndTranslateIfNecessary(
35
+ intlRef,
35
36
  snackInputs.headerTxt,
36
37
  snackInputs.headerId,
37
- snackInputs.headerValues,
38
- intlRef
39
- );
40
- displayMessageWithSnackbar(
41
- message,
42
- header,
43
- enqueueSnackbar,
44
- level,
45
- persistent
38
+ snackInputs.headerValues
46
39
  );
40
+ if (message !== null && header !== null) {
41
+ displayMessageWithSnackbar(
42
+ message,
43
+ header,
44
+ enqueueSnackbar,
45
+ level,
46
+ persistent
47
+ );
48
+ }
47
49
  }
48
- function checkAndTranslateIfNecessary(txt, id, values, intlRef) {
50
+ function checkAndTranslateIfNecessary(intlRef, txt, id, values) {
49
51
  checkInputs(txt, id, values);
50
52
  return txt ?? (id ? intlRef.current.formatMessage(
51
53
  {