@gridsuite/commons-ui 0.55.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 (157) 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 +13 -3
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +14 -10
  6. package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
  7. package/dist/components/dialogs/custom-mui-dialog.js +87 -0
  8. package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
  9. package/dist/components/dialogs/description-modification-dialog.js +71 -0
  10. package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
  11. package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
  12. package/dist/components/filter/constants/equipment-types.d.ts +72 -0
  13. package/dist/components/filter/constants/equipment-types.js +63 -0
  14. package/dist/components/filter/constants/expert-filter-constants.d.ts +546 -0
  15. package/dist/components/filter/constants/expert-filter-constants.js +663 -0
  16. package/dist/components/filter/constants/field-constants.d.ts +45 -0
  17. package/dist/components/filter/constants/field-constants.js +43 -0
  18. package/dist/components/filter/constants/filter-constants.d.ts +21 -0
  19. package/dist/components/filter/constants/filter-constants.js +10 -0
  20. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
  21. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
  22. package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
  23. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
  24. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
  25. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
  26. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
  27. package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
  28. package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
  29. package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
  30. package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
  31. package/dist/components/filter/criteria-based/filter-properties.js +19 -0
  32. package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
  33. package/dist/components/filter/criteria-based/filter-property.js +67 -0
  34. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
  35. package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
  36. package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
  37. package/dist/components/filter/expert/expert-filter-form.js +22 -0
  38. package/dist/components/filter/expert/expert-filter-utils.d.ts +19 -0
  39. package/dist/components/filter/expert/expert-filter-utils.js +302 -0
  40. package/dist/components/filter/expert/expert-filter.type.d.ts +113 -0
  41. package/dist/components/filter/expert/expert-filter.type.js +103 -0
  42. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
  43. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
  44. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
  45. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
  46. package/dist/components/filter/filter-context.d.ts +12 -0
  47. package/dist/components/filter/filter-context.js +10 -0
  48. package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
  49. package/dist/components/filter/filter-creation-dialog.js +17 -0
  50. package/dist/components/filter/filter-form.d.ts +11 -0
  51. package/dist/components/filter/filter-form.js +14 -0
  52. package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
  53. package/dist/components/filter/utils/criteria-based-utils.js +197 -0
  54. package/dist/components/filter/utils/filters-utils.d.ts +5 -0
  55. package/dist/components/filter/utils/filters-utils.js +99 -0
  56. package/dist/components/inputs/select-clearable.d.ts +14 -0
  57. package/dist/components/inputs/select-clearable.js +40 -0
  58. package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
  59. package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
  60. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
  61. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
  62. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
  63. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
  64. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
  65. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
  66. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
  67. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
  68. package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
  69. package/dist/components/react-hook-form/autocomplete-input.js +4 -15
  70. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
  71. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
  72. package/dist/components/react-hook-form/directory-items-input.d.ts +0 -3
  73. package/dist/components/react-hook-form/directory-items-input.js +5 -6
  74. package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
  75. package/dist/components/react-hook-form/error-management/error-input.js +7 -7
  76. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
  77. package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
  78. package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
  79. package/dist/components/react-hook-form/numbers/float-input.js +3 -5
  80. package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
  81. package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
  82. package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
  83. package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
  84. package/dist/components/react-hook-form/radio-input.d.ts +14 -17
  85. package/dist/components/react-hook-form/radio-input.js +7 -9
  86. package/dist/components/react-hook-form/range-input.d.ts +54 -0
  87. package/dist/components/react-hook-form/range-input.js +118 -0
  88. package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
  89. package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
  90. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
  91. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
  92. package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
  93. package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
  94. package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
  95. package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
  96. package/dist/components/react-hook-form/text-input.d.ts +23 -32
  97. package/dist/components/react-hook-form/text-input.js +6 -20
  98. package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
  99. package/dist/components/react-hook-form/unique-name-input.js +129 -0
  100. package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
  101. package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
  102. package/dist/components/react-hook-form/utils/field-label.js +5 -1
  103. package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
  104. package/dist/components/react-hook-form/utils/functions.js +21 -1
  105. package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
  106. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
  107. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
  108. package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
  109. package/dist/components/react-query-builder-inputs/add-button.js +17 -0
  110. package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
  111. package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
  112. package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
  113. package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
  114. package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
  115. package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
  116. package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
  117. package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
  118. package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
  119. package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
  120. package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
  121. package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
  122. package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
  123. package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
  124. package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
  125. package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
  126. package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
  127. package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
  128. package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
  129. package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
  130. package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
  131. package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
  132. package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
  133. package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
  134. package/dist/hooks/localized-countries-hook.d.ts +6 -0
  135. package/dist/hooks/localized-countries-hook.js +45 -0
  136. package/dist/hooks/predefined-properties-hook.d.ts +18 -0
  137. package/dist/hooks/predefined-properties-hook.js +43 -0
  138. package/dist/hooks/useDebounce.d.ts +7 -1
  139. package/dist/hooks/useSnackMessage.d.ts +23 -5
  140. package/dist/hooks/useSnackMessage.js +14 -12
  141. package/dist/index.d.ts +87 -142
  142. package/dist/index.js +168 -91
  143. package/dist/utils/FetchStatus.d.ts +12 -0
  144. package/dist/utils/FetchStatus.js +9 -0
  145. package/dist/utils/conversion-utils.d.ts +12 -0
  146. package/dist/utils/conversion-utils.js +22 -0
  147. package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
  148. package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
  149. package/dist/utils/functions.d.ts +14 -0
  150. package/dist/utils/functions.js +16 -0
  151. package/dist/utils/types.d.ts +21 -0
  152. package/dist/utils/types.js +1 -0
  153. package/dist/utils/yup-config.d.ts +8 -0
  154. package/dist/utils/yup-config.js +16 -0
  155. package/package.json +15 -2
  156. package/dist/components/react-hook-form/select-input.d.ts +0 -17
  157. package/dist/components/react-hook-form/select-input.js +0 -30
@@ -0,0 +1,43 @@
1
+ var FieldConstants = /* @__PURE__ */ ((FieldConstants2) => {
2
+ FieldConstants2["ID"] = "id";
3
+ FieldConstants2["NAME"] = "name";
4
+ FieldConstants2["FILTER_TYPE"] = "filterType";
5
+ FieldConstants2["EQUIPMENT_TYPE"] = "equipmentType";
6
+ FieldConstants2["EQUIPMENT_TABLE"] = "equipmentTable";
7
+ FieldConstants2["EQUIPMENT_ID"] = "equipmentID";
8
+ FieldConstants2["EQUIPMENT_IDS"] = "equipmentIDs";
9
+ FieldConstants2["CONTINGENCY_NAME"] = "contingencyName";
10
+ FieldConstants2["COUNTRIES"] = "countries";
11
+ FieldConstants2["COUNTRIES_1"] = "countries1";
12
+ FieldConstants2["COUNTRIES_2"] = "countries2";
13
+ FieldConstants2["VALUE_1"] = "value1";
14
+ FieldConstants2["VALUE_2"] = "value2";
15
+ FieldConstants2["OPERATION_TYPE"] = "type";
16
+ FieldConstants2["CONTINGENCY_LIST_TYPE"] = "contingencyListType";
17
+ FieldConstants2["NOMINAL_VOLTAGE"] = "nominalVoltage";
18
+ FieldConstants2["NOMINAL_VOLTAGE_1"] = "nominalVoltage1";
19
+ FieldConstants2["NOMINAL_VOLTAGE_2"] = "nominalVoltage2";
20
+ FieldConstants2["NOMINAL_VOLTAGE_3"] = "nominalVoltage3";
21
+ FieldConstants2["ENERGY_SOURCE"] = "energySource";
22
+ FieldConstants2["SCRIPT"] = "script";
23
+ FieldConstants2["AG_GRID_ROW_UUID"] = "agGridRowUuid";
24
+ FieldConstants2["CRITERIA_BASED"] = "criteriaBased";
25
+ FieldConstants2["STUDY_NAME"] = "studyName";
26
+ FieldConstants2["DESCRIPTION"] = "description";
27
+ FieldConstants2["CASE_FILE"] = "caseFile";
28
+ FieldConstants2["CASE_UUID"] = "caseUuid";
29
+ FieldConstants2["FORMATTED_CASE_PARAMETERS"] = "formattedCaseParameters";
30
+ FieldConstants2["CURRENT_PARAMETERS"] = "currentParameters";
31
+ FieldConstants2["CASE_FORMAT"] = "caseFormat";
32
+ FieldConstants2["API_CALL"] = "apiCall";
33
+ FieldConstants2["CASE_NAME"] = "caseName";
34
+ FieldConstants2["DIRECTORY"] = "directory";
35
+ FieldConstants2["PROPERTY"] = "PROPERTY";
36
+ FieldConstants2["PROPERTY_NAME"] = "propertyName";
37
+ FieldConstants2["PROPERTY_VALUES"] = "propertyValues";
38
+ FieldConstants2["PROPERTY_OPERATOR"] = "propertyOperator";
39
+ return FieldConstants2;
40
+ })(FieldConstants || {});
41
+ export {
42
+ FieldConstants
43
+ };
@@ -0,0 +1,21 @@
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 DISTRIBUTION_KEY = "distributionKey";
8
+ export declare const FilterType: {
9
+ CRITERIA_BASED: {
10
+ id: string;
11
+ label: string;
12
+ };
13
+ EXPLICIT_NAMING: {
14
+ id: string;
15
+ label: string;
16
+ };
17
+ EXPERT: {
18
+ id: string;
19
+ label: string;
20
+ };
21
+ };
@@ -0,0 +1,10 @@
1
+ const DISTRIBUTION_KEY = "distributionKey";
2
+ const FilterType = {
3
+ CRITERIA_BASED: { id: "CRITERIA", label: "filter.criteriaBased" },
4
+ EXPLICIT_NAMING: { id: "IDENTIFIER_LIST", label: "filter.explicitNaming" },
5
+ EXPERT: { id: "EXPERT", label: "filter.expert" }
6
+ };
7
+ export {
8
+ DISTRIBUTION_KEY,
9
+ FilterType
10
+ };
@@ -0,0 +1,29 @@
1
+ import { ElementType } from '../../../utils/ElementType.ts';
2
+ import { UUID } from 'crypto';
3
+ import { Dispatch, FunctionComponent, SetStateAction } from 'react';
4
+
5
+ export type SelectionCopy = {
6
+ sourceItemUuid: UUID | null;
7
+ name: string | null;
8
+ description: string | null;
9
+ parentDirectoryUuid: UUID | null;
10
+ };
11
+ export type elementExistsType = (directory: UUID, value: string, elementType: ElementType) => Promise<boolean>;
12
+ export declare const noSelectionForCopy: SelectionCopy;
13
+ interface CriteriaBasedFilterEditionDialogProps {
14
+ id: string;
15
+ name: string;
16
+ titleId: string;
17
+ open: boolean;
18
+ onClose: () => void;
19
+ broadcastChannel: BroadcastChannel;
20
+ getFilterById: (id: string) => Promise<any>;
21
+ saveFilter: (value: any, t: Record<string, any>) => Promise<void>;
22
+ selectionForCopy: SelectionCopy;
23
+ setSelelectionForCopy: (selection: SelectionCopy) => Dispatch<SetStateAction<SelectionCopy>>;
24
+ activeDirectory?: UUID;
25
+ elementExists?: elementExistsType;
26
+ language?: string;
27
+ }
28
+ export declare const CriteriaBasedFilterEditionDialog: FunctionComponent<CriteriaBasedFilterEditionDialogProps>;
29
+ export default CriteriaBasedFilterEditionDialog;
@@ -0,0 +1,19 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "../constants/field-constants.js";
4
+ import "./criteria-based-filter-utils.js";
5
+ import "../../dialogs/custom-mui-dialog.js";
6
+ import "../../../hooks/useSnackMessage.js";
7
+ import "react-hook-form";
8
+ import "@hookform/resolvers/yup";
9
+ import "./criteria-based-filter-form.js";
10
+ import "../../../utils/yup-config.js";
11
+ import { b, b as b2, p } from "../../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
12
+ import "../constants/filter-constants.js";
13
+ import "../../../utils/FetchStatus.js";
14
+ import "yup";
15
+ export {
16
+ b as CriteriaBasedFilterEditionDialog,
17
+ b2 as default,
18
+ p as noSelectionForCopy
19
+ };
@@ -0,0 +1,15 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { default as yup } from '../../../utils/yup-config';
3
+
4
+ export declare const criteriaBasedFilterSchema: {
5
+ criteriaBased: yup.ObjectSchema<{
6
+ [x: string]: any;
7
+ }, yup.AnyObject, {
8
+ [x: string]: any;
9
+ }, "">;
10
+ };
11
+ export declare const criteriaBasedFilterEmptyFormData: {
12
+ criteriaBased: any;
13
+ };
14
+ declare const CriteriaBasedFilterForm: FunctionComponent;
15
+ export default CriteriaBasedFilterForm;
@@ -0,0 +1,33 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { f as filterPropertiesYupSchema, F as FreePropertiesTypes, a as FilterProperties } from "../../../chunks/filter-properties.GRon8-ML.js";
3
+ import { FieldConstants } from "../constants/field-constants.js";
4
+ import "../../../utils/yup-config.js";
5
+ import CriteriaBasedForm from "./criteria-based-form.js";
6
+ import Grid from "@mui/material/Grid";
7
+ import { getCriteriaBasedSchema, getCriteriaBasedFormData } from "../utils/criteria-based-utils.js";
8
+ import * as yup from "yup";
9
+ const criteriaBasedFilterSchema = getCriteriaBasedSchema({
10
+ [FieldConstants.ENERGY_SOURCE]: yup.string().nullable(),
11
+ ...filterPropertiesYupSchema
12
+ });
13
+ const criteriaBasedFilterEmptyFormData = getCriteriaBasedFormData(null, {
14
+ [FieldConstants.ENERGY_SOURCE]: null,
15
+ [FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES]: [],
16
+ [FreePropertiesTypes.FREE_FILTER_PROPERTIES]: []
17
+ });
18
+ const CriteriaBasedFilterForm = () => {
19
+ return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, spacing: 1, children: [
20
+ /* @__PURE__ */ jsx(
21
+ CriteriaBasedForm,
22
+ {
23
+ defaultValues: criteriaBasedFilterEmptyFormData[FieldConstants.CRITERIA_BASED]
24
+ }
25
+ ),
26
+ /* @__PURE__ */ jsx(FilterProperties, {})
27
+ ] });
28
+ };
29
+ export {
30
+ criteriaBasedFilterEmptyFormData,
31
+ criteriaBasedFilterSchema,
32
+ CriteriaBasedFilterForm as default
33
+ };
@@ -0,0 +1,37 @@
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
+ /**
8
+ * Transform
9
+ * from obj.equipmentFilterForm.{
10
+ * freeProperties.{nameB:valuesB},
11
+ * freeProperties1.{nameA:valuesA},
12
+ * freeProperties2.{nameA:valuesC}}
13
+ * to a obj.criteriaBased.freeProperties.[
14
+ * {name_property:nameA, prop_values1:valuesA, prop_values2:valuesC},
15
+ * {name_property:namesB, prop_values:valuesB}]
16
+ * @author Laurent LAUGARN modified by Florent MILLOT
17
+ */
18
+ export declare const backToFrontTweak: (response: any) => {
19
+ criteriaBased: any;
20
+ equipmentType: any;
21
+ };
22
+ /**
23
+ * Transform
24
+ * from obj.criteriaBased.freeProperties.[
25
+ * {name_property:nameA, prop_values1:valuesA, prop_values2:valuesC},
26
+ * {name_property:namesB, prop_values:valuesB}]
27
+ * to obj.equipmentFilterForm.{
28
+ * freeProperties.{nameB:valuesB},
29
+ * freeProperties1.{nameA:valuesA},
30
+ * freeProperties2.{nameA:valuesC}}
31
+ * @author Laurent LAUGARN modified by Florent MILLOT
32
+ */
33
+ export declare const frontToBackTweak: (id?: string, filter?: any) => {
34
+ id: string | undefined;
35
+ type: string;
36
+ equipmentFilterForm: undefined;
37
+ };
@@ -0,0 +1,127 @@
1
+ import { FieldConstants } from "../constants/field-constants.js";
2
+ import { F as FreePropertiesTypes } from "../../../chunks/filter-properties.GRon8-ML.js";
3
+ import { PROPERTY_VALUES, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_NAME } from "./filter-property.js";
4
+ import { getCriteriaBasedFormData } from "../utils/criteria-based-utils.js";
5
+ import { FilterType } from "../constants/filter-constants.js";
6
+ const backToFrontTweak = (response) => {
7
+ const subProps = response.equipmentFilterForm.substationFreeProperties;
8
+ const freeProps = response.equipmentFilterForm.freeProperties;
9
+ const props1 = response.equipmentFilterForm.freeProperties1;
10
+ const props2 = response.equipmentFilterForm.freeProperties2;
11
+ const allKeys = /* @__PURE__ */ new Set();
12
+ if (subProps) {
13
+ Object.keys(subProps).forEach((k) => allKeys.add(k));
14
+ }
15
+ if (props1) {
16
+ Object.keys(props1).forEach((k) => allKeys.add(k));
17
+ }
18
+ if (props2) {
19
+ Object.keys(props2).forEach((k) => allKeys.add(k));
20
+ }
21
+ const filterSubstationProperties = [];
22
+ const filterFreeProperties = [];
23
+ allKeys.forEach((k) => {
24
+ const prop = { [PROPERTY_NAME]: k };
25
+ const values = subProps == null ? void 0 : subProps[k];
26
+ if (values) {
27
+ prop[PROPERTY_VALUES] = values;
28
+ }
29
+ const values1 = props1 == null ? void 0 : props1[k];
30
+ if (values1) {
31
+ prop[PROPERTY_VALUES_1] = values1;
32
+ }
33
+ const values2 = props2 == null ? void 0 : props2[k];
34
+ if (values2) {
35
+ prop[PROPERTY_VALUES_2] = values2;
36
+ }
37
+ filterSubstationProperties.push(prop);
38
+ });
39
+ allKeys.clear();
40
+ if (freeProps) {
41
+ Object.keys(freeProps).forEach((k) => allKeys.add(k));
42
+ }
43
+ allKeys.forEach((k) => {
44
+ const prop = { [PROPERTY_NAME]: k };
45
+ const values = freeProps == null ? void 0 : freeProps[k];
46
+ if (values) {
47
+ prop[PROPERTY_VALUES] = values;
48
+ }
49
+ filterFreeProperties.push(prop);
50
+ });
51
+ const ret = {
52
+ [FieldConstants.EQUIPMENT_TYPE]: response[FieldConstants.EQUIPMENT_TYPE],
53
+ ...getCriteriaBasedFormData(response.equipmentFilterForm, {
54
+ [FieldConstants.ENERGY_SOURCE]: response.equipmentFilterForm[FieldConstants.ENERGY_SOURCE],
55
+ [FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES]: filterSubstationProperties,
56
+ [FreePropertiesTypes.FREE_FILTER_PROPERTIES]: filterFreeProperties
57
+ })
58
+ };
59
+ return ret;
60
+ };
61
+ const frontToBackTweak = (id, filter) => {
62
+ const filterSubstationProperties = filter[FieldConstants.CRITERIA_BASED][FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES];
63
+ const ret = {
64
+ id,
65
+ type: FilterType.CRITERIA_BASED.id,
66
+ equipmentFilterForm: void 0
67
+ };
68
+ const eff = {
69
+ [FieldConstants.EQUIPMENT_TYPE]: filter[FieldConstants.EQUIPMENT_TYPE],
70
+ ...cleanNominalVoltages(filter[FieldConstants.CRITERIA_BASED])
71
+ };
72
+ ret.equipmentFilterForm = eff;
73
+ delete eff[FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES];
74
+ const props = {};
75
+ const props1 = {};
76
+ const props2 = {};
77
+ filterSubstationProperties.forEach((prop) => {
78
+ const values = prop[PROPERTY_VALUES];
79
+ const values1 = prop[PROPERTY_VALUES_1];
80
+ const values2 = prop[PROPERTY_VALUES_2];
81
+ if (values) {
82
+ props[prop[PROPERTY_NAME]] = values;
83
+ }
84
+ if (values1) {
85
+ props1[prop[PROPERTY_NAME]] = values1;
86
+ }
87
+ if (values2) {
88
+ props2[prop[PROPERTY_NAME]] = values2;
89
+ }
90
+ });
91
+ eff.substationFreeProperties = props;
92
+ eff.freeProperties1 = props1;
93
+ eff.freeProperties2 = props2;
94
+ const filterFreeProperties = filter[FieldConstants.CRITERIA_BASED][FreePropertiesTypes.FREE_FILTER_PROPERTIES];
95
+ delete eff[FreePropertiesTypes.FREE_FILTER_PROPERTIES];
96
+ const freeProps = {};
97
+ filterFreeProperties.forEach((prop) => {
98
+ const values = prop[PROPERTY_VALUES];
99
+ if (values) {
100
+ freeProps[prop[PROPERTY_NAME]] = values;
101
+ }
102
+ });
103
+ eff.freeProperties = freeProps;
104
+ return ret;
105
+ };
106
+ function cleanNominalVoltages(formValues) {
107
+ if (isNominalVoltageEmpty(formValues[FieldConstants.NOMINAL_VOLTAGE])) {
108
+ formValues[FieldConstants.NOMINAL_VOLTAGE] = null;
109
+ }
110
+ if (isNominalVoltageEmpty(formValues[FieldConstants.NOMINAL_VOLTAGE_1])) {
111
+ formValues[FieldConstants.NOMINAL_VOLTAGE_1] = null;
112
+ }
113
+ if (isNominalVoltageEmpty(formValues[FieldConstants.NOMINAL_VOLTAGE_2])) {
114
+ formValues[FieldConstants.NOMINAL_VOLTAGE_2] = null;
115
+ }
116
+ if (isNominalVoltageEmpty(formValues[FieldConstants.NOMINAL_VOLTAGE_3])) {
117
+ formValues[FieldConstants.NOMINAL_VOLTAGE_3] = null;
118
+ }
119
+ return formValues;
120
+ }
121
+ function isNominalVoltageEmpty(nominalVoltage) {
122
+ return nominalVoltage[FieldConstants.VALUE_1] === null && nominalVoltage[FieldConstants.VALUE_2] === null;
123
+ }
124
+ export {
125
+ backToFrontTweak,
126
+ frontToBackTweak
127
+ };
@@ -0,0 +1,7 @@
1
+ import { FunctionComponent } from 'react';
2
+
3
+ export interface CriteriaBasedFormProps {
4
+ defaultValues: Record<string, any>;
5
+ }
6
+ declare const CriteriaBasedForm: FunctionComponent<CriteriaBasedFormProps>;
7
+ export default CriteriaBasedForm;
@@ -0,0 +1,50 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { FieldConstants } from "../constants/field-constants.js";
3
+ import { useFormContext, useWatch } from "react-hook-form";
4
+ import { Grid } from "@mui/material";
5
+ import SelectInput from "../../react-hook-form/select-inputs/select-input.js";
6
+ import InputWithPopupConfirmation from "../../react-hook-form/select-inputs/input-with-popup-confirmation.js";
7
+ import { FILTER_EQUIPMENTS } from "../utils/criteria-based-utils.js";
8
+ const CriteriaBasedForm = ({
9
+ defaultValues
10
+ }) => {
11
+ const { getValues, setValue } = useFormContext();
12
+ const watchEquipmentType = useWatch({
13
+ name: FieldConstants.EQUIPMENT_TYPE
14
+ });
15
+ const openConfirmationPopup = () => {
16
+ return JSON.stringify(getValues(FieldConstants.CRITERIA_BASED)) !== JSON.stringify(defaultValues);
17
+ };
18
+ const handleResetOnConfirmation = () => {
19
+ Object.keys(defaultValues).forEach(
20
+ (field) => setValue(
21
+ `${FieldConstants.CRITERIA_BASED}.${field}`,
22
+ defaultValues[field]
23
+ )
24
+ );
25
+ };
26
+ return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, spacing: 2, children: [
27
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(
28
+ InputWithPopupConfirmation,
29
+ {
30
+ Input: SelectInput,
31
+ name: FieldConstants.EQUIPMENT_TYPE,
32
+ options: Object.values(FILTER_EQUIPMENTS),
33
+ label: "equipmentType",
34
+ shouldOpenPopup: openConfirmationPopup,
35
+ resetOnConfirmation: handleResetOnConfirmation,
36
+ message: "changeTypeMessage",
37
+ validateButtonLabel: "button.changeType"
38
+ }
39
+ ) }),
40
+ watchEquipmentType && FILTER_EQUIPMENTS[watchEquipmentType].fields.map(
41
+ (equipment, index) => {
42
+ const EquipmentForm = equipment.renderer;
43
+ return /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, flexGrow: 1, children: /* @__PURE__ */ jsx(EquipmentForm, { ...equipment.props }) }, index);
44
+ }
45
+ )
46
+ ] });
47
+ };
48
+ export {
49
+ CriteriaBasedForm as default
50
+ };
@@ -0,0 +1,10 @@
1
+ import { PredefinedProperties } from '../../../utils/types.ts';
2
+ import { FunctionComponent } from 'react';
3
+ import { FreePropertiesTypes } from './filter-properties';
4
+
5
+ interface FilterFreePropertiesProps {
6
+ freePropertiesType: FreePropertiesTypes;
7
+ predefined: PredefinedProperties;
8
+ }
9
+ declare const FilterFreeProperties: FunctionComponent<FilterFreePropertiesProps>;
10
+ export default FilterFreeProperties;
@@ -0,0 +1,15 @@
1
+ import "react/jsx-runtime";
2
+ import "../../react-hook-form/error-management/error-input.js";
3
+ import "../../react-hook-form/error-management/field-error-alert.js";
4
+ import "@mui/material";
5
+ import "../constants/field-constants.js";
6
+ import "react-hook-form";
7
+ import "react-intl";
8
+ import { b } from "../../../chunks/filter-properties.GRon8-ML.js";
9
+ import "./filter-property.js";
10
+ import "@mui/icons-material/Add";
11
+ import "react";
12
+ import "../constants/equipment-types.js";
13
+ export {
14
+ b as default
15
+ };
@@ -0,0 +1,21 @@
1
+ import { default as yup } from '../../../utils/yup-config';
2
+ import { FunctionComponent } from 'react';
3
+
4
+ export declare enum FreePropertiesTypes {
5
+ SUBSTATION_FILTER_PROPERTIES = "substationFreeProperties",
6
+ FREE_FILTER_PROPERTIES = "freeProperties"
7
+ }
8
+ export declare const filterPropertiesYupSchema: {
9
+ substationFreeProperties: yup.ArraySchema<{
10
+ prop_values?: (string | undefined)[] | undefined;
11
+ prop_values1?: (string | undefined)[] | undefined;
12
+ prop_values2?: (string | undefined)[] | undefined;
13
+ name_property: string;
14
+ }[] | undefined, yup.AnyObject, "", "">;
15
+ freeProperties: yup.ArraySchema<{
16
+ prop_values?: (string | undefined)[] | undefined;
17
+ name_property: string;
18
+ }[] | undefined, yup.AnyObject, "", "">;
19
+ };
20
+ declare const FilterProperties: FunctionComponent;
21
+ export default FilterProperties;
@@ -0,0 +1,19 @@
1
+ import "react/jsx-runtime";
2
+ import "@mui/material/Grid";
3
+ import "react";
4
+ import "react-hook-form";
5
+ import "react-intl";
6
+ import "../constants/equipment-types.js";
7
+ import "../../../utils/functions.js";
8
+ import "../constants/field-constants.js";
9
+ import "../../../utils/yup-config.js";
10
+ import { F, a, f } from "../../../chunks/filter-properties.GRon8-ML.js";
11
+ import "./filter-property.js";
12
+ import "../../../hooks/predefined-properties-hook.js";
13
+ import "../constants/filter-constants.js";
14
+ import "yup";
15
+ export {
16
+ F as FreePropertiesTypes,
17
+ a as default,
18
+ f as filterPropertiesYupSchema
19
+ };
@@ -0,0 +1,19 @@
1
+ import { PredefinedProperties } from '../../../utils/types.ts';
2
+ import { FunctionComponent } from 'react';
3
+
4
+ export declare const PROPERTY_NAME = "name_property";
5
+ export declare const PROPERTY_VALUES = "prop_values";
6
+ export declare const PROPERTY_VALUES_1 = "prop_values1";
7
+ export declare const PROPERTY_VALUES_2 = "prop_values2";
8
+ interface FilterPropertyProps {
9
+ index: number;
10
+ valuesFields: Array<{
11
+ name: string;
12
+ label: string;
13
+ }>;
14
+ handleDelete: (index: number) => void;
15
+ predefined: PredefinedProperties;
16
+ propertyType: string;
17
+ }
18
+ declare const FilterProperty: FunctionComponent<FilterPropertyProps>;
19
+ export default FilterProperty;
@@ -0,0 +1,67 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useMemo, useCallback } from "react";
3
+ import DeleteIcon from "@mui/icons-material/Delete";
4
+ import IconButton from "@mui/material/IconButton";
5
+ import Grid from "@mui/material/Grid";
6
+ import { useFormContext, useWatch } from "react-hook-form";
7
+ import AutocompleteInput from "../../react-hook-form/autocomplete-input.js";
8
+ import MultipleAutocompleteInput from "../../react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js";
9
+ import { FieldConstants } from "../constants/field-constants.js";
10
+ const PROPERTY_NAME = "name_property";
11
+ const PROPERTY_VALUES = "prop_values";
12
+ const PROPERTY_VALUES_1 = "prop_values1";
13
+ const PROPERTY_VALUES_2 = "prop_values2";
14
+ const FilterProperty = (props) => {
15
+ const { setValue } = useFormContext();
16
+ const watchName = useWatch({
17
+ name: `${FieldConstants.CRITERIA_BASED}.${props.propertyType}[${props.index}].${PROPERTY_NAME}`
18
+ });
19
+ const predefinedNames = useMemo(() => {
20
+ return Object.keys(props.predefined ?? []).sort();
21
+ }, [props.predefined]);
22
+ const predefinedValues = useMemo(() => {
23
+ var _a;
24
+ const predefinedForName = (_a = props.predefined) == null ? void 0 : _a[watchName];
25
+ if (!predefinedForName) {
26
+ return [];
27
+ }
28
+ return [...new Set(predefinedForName)].sort();
29
+ }, [watchName, props.predefined]);
30
+ const onNameChange = useCallback(() => {
31
+ props.valuesFields.forEach(
32
+ (valuesField) => setValue(
33
+ `${FieldConstants.CRITERIA_BASED}.${props.propertyType}[${props.index}].${valuesField.name}`,
34
+ []
35
+ )
36
+ );
37
+ }, [setValue, props.index, props.valuesFields, props.propertyType]);
38
+ return /* @__PURE__ */ jsxs(Grid, { container: true, item: true, spacing: 1, columns: 21, children: [
39
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, children: /* @__PURE__ */ jsx(
40
+ AutocompleteInput,
41
+ {
42
+ name: `${FieldConstants.CRITERIA_BASED}.${props.propertyType}[${props.index}].${PROPERTY_NAME}`,
43
+ label: "PropertyName",
44
+ options: predefinedNames,
45
+ autoSelect: true,
46
+ forcePopupIcon: true,
47
+ onChangeCallback: onNameChange
48
+ }
49
+ ) }),
50
+ props.valuesFields.map((valuesField) => /* @__PURE__ */ jsx(Grid, { item: true, xs: true, children: /* @__PURE__ */ jsx(
51
+ MultipleAutocompleteInput,
52
+ {
53
+ name: `${FieldConstants.CRITERIA_BASED}.${props.propertyType}[${props.index}].${valuesField.name}`,
54
+ label: valuesField.label,
55
+ options: predefinedValues
56
+ }
57
+ ) }, valuesField.name)),
58
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 1, alignSelf: "center", children: /* @__PURE__ */ jsx(IconButton, { onClick: () => props.handleDelete(props.index), children: /* @__PURE__ */ jsx(DeleteIcon, {}) }) })
59
+ ] });
60
+ };
61
+ export {
62
+ PROPERTY_NAME,
63
+ PROPERTY_VALUES,
64
+ PROPERTY_VALUES_1,
65
+ PROPERTY_VALUES_2,
66
+ FilterProperty as default
67
+ };
@@ -0,0 +1,28 @@
1
+ import { ElementAttributes } from '../../../utils/types.ts';
2
+ import { elementExistsType } from '../criteria-based/criteria-based-filter-edition-dialog';
3
+ import { UUID } from 'crypto';
4
+ import { FunctionComponent } from 'react';
5
+
6
+ export interface ExpertFilterEditionDialogProps {
7
+ id: string;
8
+ name: string;
9
+ titleId: string;
10
+ open: boolean;
11
+ onClose: () => void;
12
+ broadcastChannel: BroadcastChannel;
13
+ selectionForCopy: any;
14
+ getFilterById: (id: string) => Promise<{
15
+ [prop: string]: any;
16
+ }>;
17
+ setSelectionForCopy: (selection: any) => void;
18
+ createFilter: (filter: any, name: string, description: string, activeDirectory: any) => Promise<void>;
19
+ saveFilter: (filter: any, name: string) => Promise<void>;
20
+ activeDirectory?: UUID;
21
+ elementExists?: elementExistsType;
22
+ language?: string;
23
+ fetchDirectoryContent: (directoryUuid: UUID, elementTypes: string[]) => Promise<ElementAttributes[]>;
24
+ fetchRootFolders: (types: string[]) => Promise<ElementAttributes[]>;
25
+ fetchElementsInfos: (ids: UUID[], elementTypes?: string[], equipmentTypes?: string[]) => Promise<ElementAttributes[]>;
26
+ }
27
+ export declare const ExpertFilterEditionDialog: FunctionComponent<ExpertFilterEditionDialogProps>;
28
+ export default ExpertFilterEditionDialog;
@@ -0,0 +1,20 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "../constants/field-constants.js";
4
+ import "../constants/equipment-types.js";
5
+ import "react-hook-form";
6
+ import "@hookform/resolvers/yup";
7
+ import "../../../hooks/useSnackMessage.js";
8
+ import "../../dialogs/custom-mui-dialog.js";
9
+ import "../../../utils/yup-config.js";
10
+ import { E, E as E2 } from "../../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
11
+ import "../utils/filters-utils.js";
12
+ import "./expert-filter-utils.js";
13
+ import "../filter-context.js";
14
+ import "../constants/filter-constants.js";
15
+ import "../../../utils/FetchStatus.js";
16
+ import "yup";
17
+ export {
18
+ E as ExpertFilterEditionDialog,
19
+ E2 as default
20
+ };
@@ -0,0 +1,21 @@
1
+ import { FieldType } from './expert-filter.type';
2
+ import { FunctionComponent } from 'react';
3
+
4
+ import * as yup from 'yup';
5
+ export declare const EXPERT_FILTER_QUERY = "rules";
6
+ export declare const expertFilterSchema: {
7
+ rules: yup.ObjectSchema<{}, yup.AnyObject, {}, "">;
8
+ };
9
+ export declare function getExpertFilterEmptyFormData(): {
10
+ rules: {
11
+ combinator: import('./expert-filter.type').CombinatorType;
12
+ rules: {
13
+ id: string;
14
+ field: FieldType;
15
+ operator: string;
16
+ value: string;
17
+ }[];
18
+ };
19
+ };
20
+ declare const ExpertFilterForm: FunctionComponent;
21
+ export default ExpertFilterForm;
@@ -0,0 +1,22 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "@mui/material/Grid";
4
+ import "react-querybuilder";
5
+ import { k, n, l, m } from "../../../chunks/criteria-based-filter-edition-dialog.DxqH-mLe.js";
6
+ import "react-hook-form";
7
+ import "./expert-filter-utils.js";
8
+ import "../constants/expert-filter-constants.js";
9
+ import "yup";
10
+ import "./expert-filter.type.js";
11
+ import "uuid";
12
+ import "react-intl";
13
+ import "../constants/field-constants.js";
14
+ import "../../react-hook-form/select-inputs/input-with-popup-confirmation.js";
15
+ import "../../react-hook-form/select-inputs/select-input.js";
16
+ import "../constants/filter-constants.js";
17
+ export {
18
+ k as EXPERT_FILTER_QUERY,
19
+ n as default,
20
+ l as expertFilterSchema,
21
+ m as getExpertFilterEmptyFormData
22
+ };