@gridsuite/commons-ui 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/assets/criteria-based-filter-edition-dialog.css +168 -0
  2. package/dist/chunks/criteria-based-filter-edition-dialog.BEXoNmzz.js +1673 -0
  3. package/dist/chunks/filter-properties.GRon8-ML.js +195 -0
  4. package/dist/components/DirectoryItemSelector/directory-item-selector.d.ts +13 -3
  5. package/dist/components/DirectoryItemSelector/directory-item-selector.js +14 -10
  6. package/dist/components/TopBar/TopBar.js +371 -429
  7. package/dist/components/dialogs/custom-mui-dialog.d.ts +21 -0
  8. package/dist/components/dialogs/custom-mui-dialog.js +87 -0
  9. package/dist/components/dialogs/description-modification-dialog.d.ts +11 -0
  10. package/dist/components/dialogs/description-modification-dialog.js +71 -0
  11. package/dist/components/dialogs/popup-confirmation-dialog.d.ts +11 -0
  12. package/dist/components/dialogs/popup-confirmation-dialog.js +38 -0
  13. package/dist/components/filter/constants/equipment-types.d.ts +72 -0
  14. package/dist/components/filter/constants/equipment-types.js +63 -0
  15. package/dist/components/filter/constants/expert-filter-constants.d.ts +551 -0
  16. package/dist/components/filter/constants/expert-filter-constants.js +668 -0
  17. package/dist/components/filter/constants/field-constants.d.ts +45 -0
  18. package/dist/components/filter/constants/field-constants.js +43 -0
  19. package/dist/components/filter/constants/filter-constants.d.ts +21 -0
  20. package/dist/components/filter/constants/filter-constants.js +10 -0
  21. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.d.ts +29 -0
  22. package/dist/components/filter/criteria-based/criteria-based-filter-edition-dialog.js +19 -0
  23. package/dist/components/filter/criteria-based/criteria-based-filter-form.d.ts +15 -0
  24. package/dist/components/filter/criteria-based/criteria-based-filter-form.js +33 -0
  25. package/dist/components/filter/criteria-based/criteria-based-filter-utils.d.ts +37 -0
  26. package/dist/components/filter/criteria-based/criteria-based-filter-utils.js +127 -0
  27. package/dist/components/filter/criteria-based/criteria-based-form.d.ts +7 -0
  28. package/dist/components/filter/criteria-based/criteria-based-form.js +50 -0
  29. package/dist/components/filter/criteria-based/filter-free-properties.d.ts +10 -0
  30. package/dist/components/filter/criteria-based/filter-free-properties.js +15 -0
  31. package/dist/components/filter/criteria-based/filter-properties.d.ts +21 -0
  32. package/dist/components/filter/criteria-based/filter-properties.js +19 -0
  33. package/dist/components/filter/criteria-based/filter-property.d.ts +19 -0
  34. package/dist/components/filter/criteria-based/filter-property.js +67 -0
  35. package/dist/components/filter/expert/expert-filter-edition-dialog.d.ts +28 -0
  36. package/dist/components/filter/expert/expert-filter-edition-dialog.js +20 -0
  37. package/dist/components/filter/expert/expert-filter-form.d.ts +21 -0
  38. package/dist/components/filter/expert/expert-filter-form.js +22 -0
  39. package/dist/components/filter/expert/expert-filter-utils.d.ts +91 -0
  40. package/dist/components/filter/expert/expert-filter-utils.js +304 -0
  41. package/dist/components/filter/expert/expert-filter.type.d.ts +114 -0
  42. package/dist/components/filter/expert/expert-filter.type.js +104 -0
  43. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.d.ts +22 -0
  44. package/dist/components/filter/explicit-naming/explicit-naming-filter-edition-dialog.js +19 -0
  45. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.d.ts +22 -0
  46. package/dist/components/filter/explicit-naming/explicit-naming-filter-form.js +23 -0
  47. package/dist/components/filter/filter-context.d.ts +12 -0
  48. package/dist/components/filter/filter-context.js +10 -0
  49. package/dist/components/filter/filter-creation-dialog.d.ts +21 -0
  50. package/dist/components/filter/filter-creation-dialog.js +17 -0
  51. package/dist/components/filter/filter-form.d.ts +11 -0
  52. package/dist/components/filter/filter-form.js +14 -0
  53. package/dist/components/filter/utils/criteria-based-utils.d.ts +28 -0
  54. package/dist/components/filter/utils/criteria-based-utils.js +197 -0
  55. package/dist/components/filter/utils/filters-utils.d.ts +5 -0
  56. package/dist/components/filter/utils/filters-utils.js +99 -0
  57. package/dist/components/inputs/select-clearable.d.ts +14 -0
  58. package/dist/components/inputs/select-clearable.js +40 -0
  59. package/dist/components/react-hook-form/ExpandingTextField.d.ts +1 -1
  60. package/dist/components/react-hook-form/ExpandingTextField.js +0 -37
  61. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.d.ts +17 -0
  62. package/dist/components/react-hook-form/ag-grid-table-rhf/bottom-right-buttons.js +15 -0
  63. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.d.ts +23 -0
  64. package/dist/components/react-hook-form/ag-grid-table-rhf/cell-editors/numericEditor.js +70 -0
  65. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.d.ts +16 -0
  66. package/dist/components/react-hook-form/ag-grid-table-rhf/csv-uploader/csv-uploader.js +69 -0
  67. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.d.ts +23 -0
  68. package/dist/components/react-hook-form/ag-grid-table-rhf/custom-ag-grid-table.js +15 -0
  69. package/dist/components/react-hook-form/autocomplete-input.d.ts +17 -29
  70. package/dist/components/react-hook-form/autocomplete-input.js +4 -15
  71. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.d.ts +2 -0
  72. package/dist/components/react-hook-form/autocomplete-inputs/multiple-autocomplete-input.js +46 -0
  73. package/dist/components/react-hook-form/directory-items-input.d.ts +0 -3
  74. package/dist/components/react-hook-form/directory-items-input.js +5 -6
  75. package/dist/components/react-hook-form/error-management/error-input.d.ts +13 -4
  76. package/dist/components/react-hook-form/error-management/error-input.js +7 -7
  77. package/dist/components/react-hook-form/error-management/field-error-alert.d.ts +6 -3
  78. package/dist/components/react-hook-form/error-management/field-error-alert.js +3 -1
  79. package/dist/components/react-hook-form/numbers/float-input.d.ts +5 -17
  80. package/dist/components/react-hook-form/numbers/float-input.js +3 -5
  81. package/dist/components/react-hook-form/numbers/integer-input.d.ts +15 -12
  82. package/dist/components/react-hook-form/numbers/utils.d.ts +8 -2
  83. package/dist/components/react-hook-form/provider/custom-form-provider.d.ts +1 -0
  84. package/dist/components/react-hook-form/provider/custom-form-provider.js +12 -3
  85. package/dist/components/react-hook-form/radio-input.d.ts +14 -17
  86. package/dist/components/react-hook-form/radio-input.js +7 -9
  87. package/dist/components/react-hook-form/range-input.d.ts +54 -0
  88. package/dist/components/react-hook-form/range-input.js +118 -0
  89. package/dist/components/react-hook-form/select-inputs/countries-input.d.ts +8 -0
  90. package/dist/components/react-hook-form/select-inputs/countries-input.js +36 -0
  91. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.d.ts +2 -0
  92. package/dist/components/react-hook-form/select-inputs/input-with-popup-confirmation.js +61 -0
  93. package/dist/components/react-hook-form/select-inputs/mui-select-input.d.ts +12 -0
  94. package/dist/components/react-hook-form/select-inputs/mui-select-input.js +25 -0
  95. package/dist/components/react-hook-form/select-inputs/select-input.d.ts +9 -0
  96. package/dist/components/react-hook-form/select-inputs/select-input.js +37 -0
  97. package/dist/components/react-hook-form/text-input.d.ts +23 -32
  98. package/dist/components/react-hook-form/text-input.js +6 -20
  99. package/dist/components/react-hook-form/unique-name-input.d.ts +21 -0
  100. package/dist/components/react-hook-form/unique-name-input.js +129 -0
  101. package/dist/components/react-hook-form/utils/cancel-button.d.ts +9 -8
  102. package/dist/components/react-hook-form/utils/field-label.d.ts +12 -5
  103. package/dist/components/react-hook-form/utils/field-label.js +5 -1
  104. package/dist/components/react-hook-form/utils/functions.d.ts +12 -4
  105. package/dist/components/react-hook-form/utils/functions.js +21 -1
  106. package/dist/components/react-hook-form/utils/submit-button.d.ts +9 -8
  107. package/dist/components/react-hook-form/utils/text-field-with-adornment.d.ts +11 -11
  108. package/dist/components/react-hook-form/utils/text-field-with-adornment.js +18 -23
  109. package/dist/components/react-query-builder-inputs/add-button.d.ts +8 -0
  110. package/dist/components/react-query-builder-inputs/add-button.js +17 -0
  111. package/dist/components/react-query-builder-inputs/combinator-selector.d.ts +5 -0
  112. package/dist/components/react-query-builder-inputs/combinator-selector.js +38 -0
  113. package/dist/components/react-query-builder-inputs/country-value-editor.d.ts +5 -0
  114. package/dist/components/react-query-builder-inputs/country-value-editor.js +46 -0
  115. package/dist/components/react-query-builder-inputs/custom-react-query-builder.d.ts +8 -0
  116. package/dist/components/react-query-builder-inputs/custom-react-query-builder.js +21 -0
  117. package/dist/components/react-query-builder-inputs/element-value-editor.d.ts +14 -0
  118. package/dist/components/react-query-builder-inputs/element-value-editor.js +69 -0
  119. package/dist/components/react-query-builder-inputs/property-value-editor.d.ts +9 -0
  120. package/dist/components/react-query-builder-inputs/property-value-editor.js +100 -0
  121. package/dist/components/react-query-builder-inputs/remove-button.d.ts +5 -0
  122. package/dist/components/react-query-builder-inputs/remove-button.js +9 -0
  123. package/dist/components/react-query-builder-inputs/text-value-editor.d.ts +5 -0
  124. package/dist/components/react-query-builder-inputs/text-value-editor.js +34 -0
  125. package/dist/components/react-query-builder-inputs/translated-value-editor.d.ts +5 -0
  126. package/dist/components/react-query-builder-inputs/translated-value-editor.js +58 -0
  127. package/dist/components/react-query-builder-inputs/use-convert-value.d.ts +9 -0
  128. package/dist/components/react-query-builder-inputs/use-convert-value.js +24 -0
  129. package/dist/components/react-query-builder-inputs/use-valid.d.ts +7 -0
  130. package/dist/components/react-query-builder-inputs/use-valid.js +13 -0
  131. package/dist/components/react-query-builder-inputs/value-editor.d.ts +5 -0
  132. package/dist/components/react-query-builder-inputs/value-editor.js +18 -0
  133. package/dist/components/react-query-builder-inputs/value-selector.d.ts +4 -0
  134. package/dist/components/react-query-builder-inputs/value-selector.js +14 -0
  135. package/dist/components/translations/filter-en.d.ts +22 -0
  136. package/dist/components/translations/filter-en.js +23 -0
  137. package/dist/components/translations/filter-fr.d.ts +22 -0
  138. package/dist/components/translations/filter-fr.js +23 -0
  139. package/dist/hooks/localized-countries-hook.d.ts +6 -0
  140. package/dist/hooks/localized-countries-hook.js +45 -0
  141. package/dist/hooks/predefined-properties-hook.d.ts +18 -0
  142. package/dist/hooks/predefined-properties-hook.js +43 -0
  143. package/dist/hooks/useDebounce.d.ts +7 -1
  144. package/dist/hooks/useSnackMessage.d.ts +23 -5
  145. package/dist/hooks/useSnackMessage.js +14 -12
  146. package/dist/index.d.ts +89 -142
  147. package/dist/index.js +172 -91
  148. package/dist/utils/FetchStatus.d.ts +12 -0
  149. package/dist/utils/FetchStatus.js +9 -0
  150. package/dist/utils/conversion-utils.d.ts +12 -0
  151. package/dist/utils/conversion-utils.js +22 -0
  152. package/dist/utils/equipment-types-for-predefined-properties-mapper.d.ts +3 -0
  153. package/dist/utils/equipment-types-for-predefined-properties-mapper.js +31 -0
  154. package/dist/utils/functions.d.ts +14 -0
  155. package/dist/utils/functions.js +16 -0
  156. package/dist/utils/types.d.ts +21 -0
  157. package/dist/utils/types.js +1 -0
  158. package/dist/utils/yup-config.d.ts +8 -0
  159. package/dist/utils/yup-config.js +16 -0
  160. package/package.json +15 -3
  161. package/dist/components/react-hook-form/select-input.d.ts +0 -17
  162. package/dist/components/react-hook-form/select-input.js +0 -30
@@ -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,3 +1,4 @@
1
+ import { ElementAttributes } from '../../utils/types.ts';
1
2
  import { UUID } from 'crypto';
2
3
  import { TreeViewFinderProps } from '../TreeViewFinder/TreeViewFinder';
3
4
  import { FunctionComponent } from 'react';
@@ -7,9 +8,18 @@ interface DirectoryItemSelectorProps extends TreeViewFinderProps {
7
8
  types: string[];
8
9
  equipmentTypes?: string[];
9
10
  itemFilter?: any;
10
- fetchDirectoryContent: (directoryUuid: UUID, elementTypes: string[]) => Promise<any>;
11
- fetchRootFolders: (types: string[]) => Promise<any>;
12
- 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
+ classes?: any;
15
+ contentText?: string;
16
+ defaultExpanded?: string[];
17
+ defaultSelected?: string[];
18
+ validationButtonText?: string;
19
+ className?: string;
20
+ cancelButtonProps?: any;
21
+ onlyLeaves?: boolean;
22
+ multiselect?: boolean;
13
23
  expanded?: UUID[];
14
24
  }
15
25
  declare const DirectoryItemSelector: FunctionComponent<DirectoryItemSelectorProps>;
@@ -2,8 +2,8 @@ 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),
@@ -77,7 +77,7 @@ const DirectoryItemSelector = ({
77
77
  [convertRoots]
78
78
  );
79
79
  const updateRootDirectories = useCallback(() => {
80
- fetchRootFolders(types).then((data2) => {
80
+ fetchRootFolders && fetchRootFolders(types).then((data2) => {
81
81
  let [nrs, mdr] = updatedTree(
82
82
  rootsRef.current,
83
83
  nodeMap.current,
@@ -96,22 +96,26 @@ const DirectoryItemSelector = ({
96
96
  }, [convertRoots, types, snackError, fetchRootFolders]);
97
97
  const fetchDirectory = useCallback(
98
98
  (nodeId) => {
99
- fetchDirectoryContent(nodeId, types).then((children) => {
99
+ fetchDirectoryContent && fetchDirectoryContent(nodeId, types).then((children) => {
100
100
  const childrenMatchedTypes = children.filter(
101
101
  (item) => contentFilter().has(item.type)
102
102
  );
103
103
  if (childrenMatchedTypes.length > 0 && equipmentTypes && equipmentTypes.length > 0) {
104
- fetchElementsInfos(
105
- childrenMatchedTypes.map((e) => e.elementUuid),
104
+ fetchElementsInfos && fetchElementsInfos(
105
+ childrenMatchedTypes.map(
106
+ (e) => e.elementUuid
107
+ ),
106
108
  types,
107
109
  equipmentTypes
108
110
  ).then((childrenWithMetadata) => {
109
- const children2 = itemFilter ? childrenWithMetadata.filter((val) => {
110
- if (val.type === ElementType.DIRECTORY) {
111
- return true;
111
+ const children2 = itemFilter ? childrenWithMetadata.filter(
112
+ (val) => {
113
+ if (val.type === ElementType.DIRECTORY) {
114
+ return true;
115
+ }
116
+ return itemFilter(val);
112
117
  }
113
- return itemFilter(val);
114
- }) : childrenWithMetadata;
118
+ ) : childrenWithMetadata;
115
119
  addToDirectory(nodeId, children2);
116
120
  });
117
121
  } else {