@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,195 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import Grid$1 from "@mui/material/Grid";
3
+ import { useMemo, useEffect } from "react";
4
+ import { useWatch, useFieldArray } from "react-hook-form";
5
+ import { FormattedMessage } from "react-intl";
6
+ import { Line, Hvdc, Substation, Load, Generator, TwoWindingTransfo, Battery, ShuntCompensator, VoltageLevel } from "../components/filter/constants/equipment-types.js";
7
+ import { areArrayElementsUnique } from "../utils/functions.js";
8
+ import { FieldConstants } from "../components/filter/constants/field-constants.js";
9
+ import "../utils/yup-config.js";
10
+ import ErrorInput from "../components/react-hook-form/error-management/error-input.js";
11
+ import FieldErrorAlert from "../components/react-hook-form/error-management/field-error-alert.js";
12
+ import { Grid, ListItem, Button } from "@mui/material";
13
+ import FilterProperty, { PROPERTY_NAME, PROPERTY_VALUES_1, PROPERTY_VALUES_2, PROPERTY_VALUES } from "../components/filter/criteria-based/filter-property.js";
14
+ import { usePredefinedProperties } from "../hooks/predefined-properties-hook.js";
15
+ import { FilterType } from "../components/filter/constants/filter-constants.js";
16
+ import * as yup from "yup";
17
+ import AddIcon from "@mui/icons-material/Add";
18
+ const FilterFreeProperties = ({
19
+ freePropertiesType,
20
+ predefined
21
+ }) => {
22
+ const watchEquipmentType = useWatch({
23
+ name: FieldConstants.EQUIPMENT_TYPE
24
+ });
25
+ const isForLineOrHvdcLineSubstation = (watchEquipmentType === Line.type || watchEquipmentType === Hvdc.type) && freePropertiesType === FreePropertiesTypes.SUBSTATION_FILTER_PROPERTIES;
26
+ const fieldName = `${FieldConstants.CRITERIA_BASED}.${freePropertiesType}`;
27
+ const {
28
+ fields: filterProperties,
29
+ // don't use it to access form data ! check doc,
30
+ append,
31
+ remove
32
+ } = useFieldArray({
33
+ name: fieldName
34
+ });
35
+ function addNewProp() {
36
+ if (isForLineOrHvdcLineSubstation) {
37
+ append({
38
+ [PROPERTY_NAME]: null,
39
+ [PROPERTY_VALUES_1]: [],
40
+ [PROPERTY_VALUES_2]: []
41
+ });
42
+ } else {
43
+ append({ [PROPERTY_NAME]: null, [PROPERTY_VALUES]: [] });
44
+ }
45
+ }
46
+ const valuesFields = isForLineOrHvdcLineSubstation ? [
47
+ { name: PROPERTY_VALUES_1, label: "PropertyValues1" },
48
+ { name: PROPERTY_VALUES_2, label: "PropertyValues2" }
49
+ ] : [{ name: PROPERTY_VALUES, label: "PropertyValues" }];
50
+ const title = useMemo(() => {
51
+ return freePropertiesType === FreePropertiesTypes.FREE_FILTER_PROPERTIES ? "FreeProps" : "SubstationFreeProps";
52
+ }, [freePropertiesType]);
53
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
54
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(FormattedMessage, { id: title, children: (title2) => /* @__PURE__ */ jsx("h4", { children: title2 }) }) }),
55
+ filterProperties.map((prop, index) => /* @__PURE__ */ jsx(ListItem, { children: /* @__PURE__ */ jsx(
56
+ FilterProperty,
57
+ {
58
+ index,
59
+ valuesFields,
60
+ predefined,
61
+ handleDelete: remove,
62
+ propertyType: freePropertiesType
63
+ }
64
+ ) }, prop.id)),
65
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(AddIcon, {}), onClick: addNewProp, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "AddFreePropCrit" }) }) }),
66
+ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(ErrorInput, { name: fieldName, InputField: FieldErrorAlert }) })
67
+ ] });
68
+ };
69
+ var FreePropertiesTypes = /* @__PURE__ */ ((FreePropertiesTypes2) => {
70
+ FreePropertiesTypes2["SUBSTATION_FILTER_PROPERTIES"] = "substationFreeProperties";
71
+ FreePropertiesTypes2["FREE_FILTER_PROPERTIES"] = "freeProperties";
72
+ return FreePropertiesTypes2;
73
+ })(FreePropertiesTypes || {});
74
+ function propertyValuesTest(values, context, doublePropertyValues) {
75
+ const rootLevelForm = context.from[context.from.length - 1];
76
+ const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
77
+ if (filterType !== FilterType.CRITERIA_BASED.id) {
78
+ return true;
79
+ }
80
+ const equipmentType = rootLevelForm.value[FieldConstants.EQUIPMENT_TYPE];
81
+ const isForLineOrHvdcLine = equipmentType === Line.type || equipmentType === Hvdc.type;
82
+ if (doublePropertyValues) {
83
+ return isForLineOrHvdcLine ? (values == null ? void 0 : values.length) > 0 : true;
84
+ } else {
85
+ return isForLineOrHvdcLine ? true : (values == null ? void 0 : values.length) > 0;
86
+ }
87
+ }
88
+ const filterPropertiesYupSchema = {
89
+ [
90
+ "substationFreeProperties"
91
+ /* SUBSTATION_FILTER_PROPERTIES */
92
+ ]: yup.array().of(
93
+ yup.object().shape({
94
+ [PROPERTY_NAME]: yup.string().required(),
95
+ [PROPERTY_VALUES]: yup.array().of(yup.string()).test(
96
+ "can not be empty if not line",
97
+ "YupRequired",
98
+ (values, context) => propertyValuesTest(values, context, false)
99
+ ),
100
+ [PROPERTY_VALUES_1]: yup.array().of(yup.string()).test(
101
+ "can not be empty if line",
102
+ "YupRequired",
103
+ (values, context) => propertyValuesTest(values, context, true)
104
+ ),
105
+ [PROPERTY_VALUES_2]: yup.array().of(yup.string()).test(
106
+ "can not be empty if line",
107
+ "YupRequired",
108
+ (values, context) => propertyValuesTest(values, context, true)
109
+ )
110
+ })
111
+ ).test(
112
+ "distinct names",
113
+ "filterPropertiesNameUniquenessError",
114
+ (properties, context) => {
115
+ const rootLevelForm = context.from[context.from.length - 1];
116
+ const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
117
+ if (filterType !== FilterType.CRITERIA_BASED.id) {
118
+ return true;
119
+ }
120
+ const names = properties.filter((prop) => !!prop[PROPERTY_NAME]).map((prop) => prop[PROPERTY_NAME]);
121
+ return areArrayElementsUnique(names);
122
+ }
123
+ ),
124
+ [
125
+ "freeProperties"
126
+ /* FREE_FILTER_PROPERTIES */
127
+ ]: yup.array().of(
128
+ yup.object().shape({
129
+ [PROPERTY_NAME]: yup.string().required(),
130
+ [PROPERTY_VALUES]: yup.array().of(yup.string()).test(
131
+ "can not be empty if not line",
132
+ "YupRequired",
133
+ (values, context) => propertyValuesTest(values, context, false)
134
+ )
135
+ })
136
+ ).test(
137
+ "distinct names",
138
+ "filterPropertiesNameUniquenessError",
139
+ (properties, context) => {
140
+ const rootLevelForm = context.from[context.from.length - 1];
141
+ const filterType = rootLevelForm.value[FieldConstants.FILTER_TYPE];
142
+ if (filterType !== FilterType.CRITERIA_BASED.id) {
143
+ return true;
144
+ }
145
+ const names = properties.filter((prop) => !!prop[PROPERTY_NAME]).map((prop) => prop[PROPERTY_NAME]);
146
+ return areArrayElementsUnique(names);
147
+ }
148
+ )
149
+ };
150
+ const FilterProperties = () => {
151
+ const watchEquipmentType = useWatch({
152
+ name: FieldConstants.EQUIPMENT_TYPE
153
+ });
154
+ const [equipmentPredefinedProps, setEquipmentType] = usePredefinedProperties(watchEquipmentType);
155
+ const [substationPredefinedProps, setSubstationType] = usePredefinedProperties(null);
156
+ const displayEquipmentProperties = useMemo(() => {
157
+ return watchEquipmentType === Substation.type || watchEquipmentType === Load.type || watchEquipmentType === Generator.type || watchEquipmentType === Line.type || watchEquipmentType === TwoWindingTransfo.type || watchEquipmentType === Battery.type || watchEquipmentType === ShuntCompensator.type || watchEquipmentType === VoltageLevel.type;
158
+ }, [watchEquipmentType]);
159
+ const displaySubstationProperties = useMemo(() => {
160
+ return watchEquipmentType !== Substation.type && watchEquipmentType !== null;
161
+ }, [watchEquipmentType]);
162
+ useEffect(() => {
163
+ if (displayEquipmentProperties) {
164
+ setEquipmentType(watchEquipmentType);
165
+ }
166
+ }, [displayEquipmentProperties, watchEquipmentType, setEquipmentType]);
167
+ useEffect(() => {
168
+ if (displaySubstationProperties) {
169
+ setSubstationType(Substation.type);
170
+ }
171
+ }, [displaySubstationProperties, setSubstationType]);
172
+ return watchEquipmentType && /* @__PURE__ */ jsx(Grid$1, { item: true, container: true, spacing: 1, children: /* @__PURE__ */ jsxs(Grid$1, { item: true, xs: 12, children: [
173
+ /* @__PURE__ */ jsx(FormattedMessage, { id: "FreePropsCrit", children: (txt) => /* @__PURE__ */ jsx("h3", { children: txt }) }),
174
+ displayEquipmentProperties && /* @__PURE__ */ jsx(
175
+ FilterFreeProperties,
176
+ {
177
+ freePropertiesType: "freeProperties",
178
+ predefined: equipmentPredefinedProps
179
+ }
180
+ ),
181
+ displaySubstationProperties && /* @__PURE__ */ jsx(
182
+ FilterFreeProperties,
183
+ {
184
+ freePropertiesType: "substationFreeProperties",
185
+ predefined: substationPredefinedProps
186
+ }
187
+ )
188
+ ] }) });
189
+ };
190
+ export {
191
+ FreePropertiesTypes as F,
192
+ FilterProperties as a,
193
+ FilterFreeProperties as b,
194
+ filterPropertiesYupSchema as f
195
+ };
@@ -1,16 +1,16 @@
1
+ import { ElementAttributes } from '../../utils/types.ts';
1
2
  import { UUID } from 'crypto';
3
+ import { TreeViewFinderProps } from '../TreeViewFinder/TreeViewFinder';
2
4
  import { FunctionComponent } from 'react';
3
5
 
4
- interface DirectoryItemSelectorProps {
6
+ interface DirectoryItemSelectorProps extends TreeViewFinderProps {
5
7
  open: boolean;
6
- onClose: any;
7
8
  types: string[];
8
9
  equipmentTypes?: string[];
9
- title: string;
10
10
  itemFilter?: any;
11
- fetchDirectoryContent: (directoryUuid: UUID, elementTypes: string[]) => Promise<any>;
12
- fetchRootFolders: (types: string[]) => Promise<any>;
13
- fetchElementsInfos: (ids: UUID[], elementTypes: string[], equipmentTypes: string[]) => Promise<any>;
11
+ fetchDirectoryContent?: (directoryUuid: UUID, elementTypes: string[]) => Promise<ElementAttributes[]>;
12
+ fetchRootFolders?: (types: string[]) => Promise<ElementAttributes[]>;
13
+ fetchElementsInfos?: (ids: UUID[], elementTypes: string[], equipmentTypes: string[]) => Promise<ElementAttributes[]>;
14
14
  classes?: any;
15
15
  contentText?: string;
16
16
  defaultExpanded?: string[];
@@ -20,6 +20,7 @@ interface DirectoryItemSelectorProps {
20
20
  cancelButtonProps?: any;
21
21
  onlyLeaves?: boolean;
22
22
  multiselect?: boolean;
23
+ expanded?: UUID[];
23
24
  }
24
25
  declare const DirectoryItemSelector: FunctionComponent<DirectoryItemSelectorProps>;
25
26
  export default DirectoryItemSelector;
@@ -1,9 +1,9 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useRef, useCallback, useEffect } from "react";
3
3
  import { getFileIcon } from "../../utils/ElementIcon.js";
4
4
  import { ElementType } from "../../utils/ElementType.js";
5
- import { useSnackMessage } from "../../hooks/useSnackMessage.js";
6
5
  import TreeViewFinder from "../TreeViewFinder/TreeViewFinder.js";
6
+ import { useSnackMessage } from "../../hooks/useSnackMessage.js";
7
7
  const styles = {
8
8
  icon: (theme) => ({
9
9
  marginRight: theme.spacing(1),
@@ -13,23 +13,14 @@ const styles = {
13
13
  };
14
14
  const DirectoryItemSelector = ({
15
15
  open,
16
- onClose,
17
16
  types,
18
17
  equipmentTypes,
19
- title,
20
18
  itemFilter,
21
19
  fetchDirectoryContent,
22
20
  fetchRootFolders,
23
21
  fetchElementsInfos,
24
- classes,
25
- contentText,
26
- defaultExpanded,
27
- defaultSelected,
28
- validationButtonText,
29
- className,
30
- cancelButtonProps,
31
- onlyLeaves = true,
32
- multiselect = true
22
+ expanded,
23
+ ...otherTreeViewFinderProps
33
24
  }) => {
34
25
  const [data, setData] = useState([]);
35
26
  const [rootDirectories, setRootDirectories] = useState([]);
@@ -39,8 +30,6 @@ const DirectoryItemSelector = ({
39
30
  const rootsRef = useRef([]);
40
31
  rootsRef.current = rootDirectories;
41
32
  const { snackError } = useSnackMessage();
42
- const openRef = useRef();
43
- openRef.current = open;
44
33
  const contentFilter = useCallback(
45
34
  () => /* @__PURE__ */ new Set([ElementType.DIRECTORY, ...types]),
46
35
  [types]
@@ -88,7 +77,7 @@ const DirectoryItemSelector = ({
88
77
  [convertRoots]
89
78
  );
90
79
  const updateRootDirectories = useCallback(() => {
91
- fetchRootFolders(types).then((data2) => {
80
+ fetchRootFolders && fetchRootFolders(types).then((data2) => {
92
81
  let [nrs, mdr] = updatedTree(
93
82
  rootsRef.current,
94
83
  nodeMap.current,
@@ -105,29 +94,28 @@ const DirectoryItemSelector = ({
105
94
  });
106
95
  });
107
96
  }, [convertRoots, types, snackError, fetchRootFolders]);
108
- useEffect(() => {
109
- if (open) {
110
- updateRootDirectories();
111
- }
112
- }, [open, updateRootDirectories]);
113
97
  const fetchDirectory = useCallback(
114
98
  (nodeId) => {
115
- fetchDirectoryContent(nodeId, types).then((children) => {
99
+ fetchDirectoryContent && fetchDirectoryContent(nodeId, types).then((children) => {
116
100
  const childrenMatchedTypes = children.filter(
117
101
  (item) => contentFilter().has(item.type)
118
102
  );
119
103
  if (childrenMatchedTypes.length > 0 && equipmentTypes && equipmentTypes.length > 0) {
120
- fetchElementsInfos(
121
- childrenMatchedTypes.map((e) => e.elementUuid),
104
+ fetchElementsInfos && fetchElementsInfos(
105
+ childrenMatchedTypes.map(
106
+ (e) => e.elementUuid
107
+ ),
122
108
  types,
123
109
  equipmentTypes
124
110
  ).then((childrenWithMetadata) => {
125
- const children2 = itemFilter ? childrenWithMetadata.filter((val) => {
126
- if (val.type === ElementType.DIRECTORY) {
127
- return true;
111
+ const children2 = itemFilter ? childrenWithMetadata.filter(
112
+ (val) => {
113
+ if (val.type === ElementType.DIRECTORY) {
114
+ return true;
115
+ }
116
+ return itemFilter(val);
128
117
  }
129
- return itemFilter(val);
130
- }) : childrenWithMetadata;
118
+ ) : childrenWithMetadata;
131
119
  addToDirectory(nodeId, children2);
132
120
  });
133
121
  } else {
@@ -149,6 +137,16 @@ const DirectoryItemSelector = ({
149
137
  fetchElementsInfos
150
138
  ]
151
139
  );
140
+ useEffect(() => {
141
+ if (open) {
142
+ updateRootDirectories();
143
+ if (expanded) {
144
+ expanded.forEach((nodeId) => {
145
+ fetchDirectory(nodeId);
146
+ });
147
+ }
148
+ }
149
+ }, [open, updateRootDirectories, expanded, fetchDirectory]);
152
150
  function sortHandlingDirectories(a, b) {
153
151
  if (a.children && !b.children) {
154
152
  return -1;
@@ -157,26 +155,19 @@ const DirectoryItemSelector = ({
157
155
  }
158
156
  return a.name.localeCompare(b.name);
159
157
  }
160
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
158
+ return /* @__PURE__ */ jsx(
161
159
  TreeViewFinder,
162
160
  {
163
- multiselect,
164
161
  onTreeBrowse: fetchDirectory,
165
- data,
166
- onlyLeaves,
167
162
  sortMethod: sortHandlingDirectories,
168
- title,
169
- onClose,
163
+ multiSelect: true,
170
164
  open,
171
- classes,
172
- contentText,
173
- defaultExpanded,
174
- defaultSelected,
175
- validationButtonText,
176
- className,
177
- cancelButtonProps
165
+ expanded,
166
+ onlyLeaves: true,
167
+ ...otherTreeViewFinderProps,
168
+ data
178
169
  }
179
- ) });
170
+ );
180
171
  };
181
172
  function updatedTree(prevRoots, prevMap, nodeId, children) {
182
173
  var _a;
@@ -159,6 +159,9 @@ const FlatParameters = ({
159
159
  if (param.name === inEditionParam && uncommitted !== null) {
160
160
  return uncommitted;
161
161
  } else if (initValues && initValues.hasOwnProperty(param.name)) {
162
+ if (param.type === "BOOLEAN") {
163
+ return initValues[param.name] === "false" ? false : initValues[param.name];
164
+ }
162
165
  if (param.type !== "STRING_LIST") {
163
166
  return initValues[param.name];
164
167
  }
@@ -1,12 +1,12 @@
1
1
  export default class LogReport {
2
2
  constructor(jsonReporter: any, parentReportId: any);
3
- id: any;
3
+ id: string;
4
4
  key: any;
5
5
  title: any;
6
6
  subReports: any[];
7
7
  logs: any[];
8
8
  parentReportId: any;
9
- getId(): any;
9
+ getId(): string;
10
10
  getTitle(): any;
11
11
  getSubReports(): any[];
12
12
  getLogs(): any[];
@@ -1,59 +1,33 @@
1
- import { default as PropTypes } from 'prop-types';
2
- export function generateTreeViewFinderClass(className: any): string;
3
- declare const _default: import('@emotion/styled').StyledComponent<Pick<PropTypes.InferProps<{
4
- open: PropTypes.Validator<boolean>;
5
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
6
- data: PropTypes.Validator<(PropTypes.InferProps<{
7
- id: PropTypes.Validator<string>;
8
- name: PropTypes.Validator<string>;
9
- children: PropTypes.Requireable<any[]>;
10
- }> | null | undefined)[]>;
11
- onTreeBrowse: PropTypes.Requireable<(...args: any[]) => any>;
12
- classes: PropTypes.Requireable<object>;
13
- title: PropTypes.Requireable<string>;
14
- contentText: PropTypes.Requireable<string>;
15
- validationButtonText: PropTypes.Requireable<string>;
16
- defaultSelected: PropTypes.Requireable<(string | null | undefined)[]>;
17
- defaultExpanded: PropTypes.Requireable<(string | null | undefined)[]>;
18
- onlyLeaves: PropTypes.Requireable<boolean>;
19
- multiselect: PropTypes.Requireable<boolean>;
20
- sortMethod: PropTypes.Requireable<(...args: any[]) => any>;
21
- cancelButtonProps: PropTypes.Requireable<object>;
22
- className: PropTypes.Requireable<string>;
23
- }>, "className" | "title" | "onClose" | "onTreeBrowse" | "contentText" | "validationButtonText" | "cancelButtonProps" | PropTypes.RequiredKeys<{
24
- open: PropTypes.Validator<boolean>;
25
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
26
- data: PropTypes.Validator<(PropTypes.InferProps<{
27
- id: PropTypes.Validator<string>;
28
- name: PropTypes.Validator<string>;
29
- children: PropTypes.Requireable<any[]>;
30
- }> | null | undefined)[]>;
31
- onTreeBrowse: PropTypes.Requireable<(...args: any[]) => any>;
32
- classes: PropTypes.Requireable<object>;
33
- title: PropTypes.Requireable<string>;
34
- contentText: PropTypes.Requireable<string>;
35
- validationButtonText: PropTypes.Requireable<string>;
36
- defaultSelected: PropTypes.Requireable<(string | null | undefined)[]>;
37
- defaultExpanded: PropTypes.Requireable<(string | null | undefined)[]>;
38
- onlyLeaves: PropTypes.Requireable<boolean>;
39
- multiselect: PropTypes.Requireable<boolean>;
40
- sortMethod: PropTypes.Requireable<(...args: any[]) => any>;
41
- cancelButtonProps: PropTypes.Requireable<object>;
42
- className: PropTypes.Requireable<string>;
43
- }>> & {
44
- classes?: object | null | undefined;
45
- defaultSelected?: (string | null | undefined)[] | null | undefined;
46
- defaultExpanded?: (string | null | undefined)[] | null | undefined;
47
- onlyLeaves?: boolean | null | undefined;
48
- multiselect?: boolean | null | undefined;
49
- sortMethod?: ((...args: any[]) => any) | null | undefined;
50
- } & {} & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
1
+ import { TreeViewClasses } from '@mui/x-tree-view';
2
+ import { ButtonProps, ModalProps } from '@mui/material';
3
+ import { ReactElement } from 'react';
4
+
5
+ export declare const generateTreeViewFinderClass: (className: string) => string;
6
+ export interface TreeViewFinderNodeProps {
7
+ id: string;
8
+ name: string;
9
+ icon?: ReactElement;
10
+ childrenCount?: number;
11
+ children?: TreeViewFinderNodeProps[];
12
+ }
13
+ export interface TreeViewFinderProps {
14
+ defaultExpanded?: string[];
15
+ defaultSelected?: string[];
16
+ selected?: string[];
17
+ expanded?: string[];
18
+ multiSelect?: boolean;
19
+ classes?: Partial<TreeViewClasses>;
20
+ className?: string;
21
+ contentText?: string;
22
+ open: ModalProps['open'];
23
+ onClose: (nodes: TreeViewFinderNodeProps[]) => void;
24
+ validationButtonText?: string;
25
+ cancelButtonProps?: ButtonProps;
26
+ title?: string;
27
+ onlyLeaves?: boolean;
28
+ data?: TreeViewFinderNodeProps[];
29
+ onTreeBrowse?: (nodeId: string) => void;
30
+ sortMethod?: (a: TreeViewFinderNodeProps, b: TreeViewFinderNodeProps) => number;
31
+ }
32
+ declare const _default: import('@emotion/styled').StyledComponent<TreeViewFinderProps & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
51
33
  export default _default;
52
- /**
53
- * This callback type is called `onTreeBrowseCallback` and is displayed as a global symbol.
54
- */
55
- export type onTreeBrowseCallback = (nodeId: string) => any;
56
- /**
57
- * - callback to update data prop when walk into Tree
58
- */
59
- export type onTreeBrowse = (defaultSelected?: any[] | undefined, defaultExpanded?: any[] | undefined, validationButtonText?: string | undefined, onlyLeaves?: boolean | undefined, multiselect?: boolean | undefined, cancelButtonProps?: Object | undefined) => any;