@gridsuite/commons-ui 0.65.3 → 0.66.1

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.
@@ -27,6 +27,7 @@ function AutocompleteWithFavorites({
27
27
  size: "small",
28
28
  value,
29
29
  options: optionsWithFavorites,
30
+ isOptionEqualToValue: (option, val) => option === val || val === "",
30
31
  ...otherProps,
31
32
  groupBy: (option) => favorites.includes(option) ? `fav` : "not_fav",
32
33
  multiple: Array.isArray(value),
@@ -17,6 +17,7 @@ import ErrorInput from "../reactHookForm/errorManagement/ErrorInput.js";
17
17
  import FieldErrorAlert from "../reactHookForm/errorManagement/FieldErrorAlert.js";
18
18
  import { countRules, getOperators, queryValidator } from "../../filter/expert/expertFilterUtils.js";
19
19
  import RemoveButton from "./RemoveButton.js";
20
+ import FieldSelector from "./FieldSelector.js";
20
21
  function RuleAddButton(props) {
21
22
  return /* @__PURE__ */ jsx(AddButton, { ...props, label: "rule" });
22
23
  }
@@ -74,7 +75,7 @@ function CustomReactQueryBuilder(props) {
74
75
  removeGroupAction: RemoveButton,
75
76
  valueEditor: ValueEditor,
76
77
  operatorSelector: ValueSelector,
77
- fieldSelector: ValueSelector,
78
+ fieldSelector: FieldSelector,
78
79
  valueSourceSelector: ValueSelector
79
80
  },
80
81
  listsAsArrays: true
@@ -0,0 +1,4 @@
1
+ import { ValueSelectorProps } from 'react-querybuilder';
2
+
3
+ declare function FieldSelector({ options, className, value, disabled, handleOnChange }: Readonly<ValueSelectorProps>): import("react/jsx-runtime").JSX.Element;
4
+ export default FieldSelector;
@@ -0,0 +1,28 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { toFlatOptionArray } from "react-querybuilder";
3
+ import { Autocomplete, TextField } from "@mui/material";
4
+ function FieldSelector({ options, className, value, disabled, handleOnChange }) {
5
+ const optionList = toFlatOptionArray(options);
6
+ return /* @__PURE__ */ jsx(
7
+ Autocomplete,
8
+ {
9
+ onChange: (event, newValue) => {
10
+ if (newValue) {
11
+ handleOnChange(newValue.name);
12
+ }
13
+ },
14
+ value: optionList.find((option) => option.name === value),
15
+ disabled,
16
+ className,
17
+ options: optionList,
18
+ disableClearable: true,
19
+ size: "small",
20
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, label: "", variant: "standard" }),
21
+ autoHighlight: true,
22
+ getOptionLabel: (option) => option.label
23
+ }
24
+ );
25
+ }
26
+ export {
27
+ FieldSelector as default
28
+ };
@@ -0,0 +1,11 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+
3
+ export type UseStateBooleanReturn = {
4
+ value: boolean;
5
+ setTrue: () => void;
6
+ setFalse: () => void;
7
+ invert: () => void;
8
+ setValue: Dispatch<SetStateAction<boolean>>;
9
+ };
10
+ declare const useStateBoolean: (initialState: boolean | (() => boolean)) => UseStateBooleanReturn;
11
+ export default useStateBoolean;
@@ -0,0 +1,11 @@
1
+ import { useState, useCallback } from "react";
2
+ const useStateBoolean = (initialState) => {
3
+ const [value, setValue] = useState(initialState);
4
+ const setTrue = useCallback(() => setValue(true), []);
5
+ const setFalse = useCallback(() => setValue(false), []);
6
+ const invert = useCallback(() => setValue((prevState) => !prevState), []);
7
+ return { value, setTrue, setFalse, invert, setValue };
8
+ };
9
+ export {
10
+ useStateBoolean as default
11
+ };
@@ -0,0 +1,11 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+
3
+ export type UseStateNumberReturn = {
4
+ value: number;
5
+ setValue: Dispatch<SetStateAction<number>>;
6
+ increment: (step?: number) => void;
7
+ decrement: (step?: number) => void;
8
+ reset: () => void;
9
+ };
10
+ declare const useStateNumber: (initialState?: number | (() => number)) => UseStateNumberReturn;
11
+ export default useStateNumber;
@@ -0,0 +1,11 @@
1
+ import { useState, useCallback } from "react";
2
+ const useStateNumber = (initialState = 0) => {
3
+ const [value, setValue] = useState(initialState);
4
+ const increment = useCallback((step = 1) => setValue((prevState) => prevState + step), []);
5
+ const decrement = useCallback((step = 1) => setValue((prevState) => prevState - step), []);
6
+ const reset = useCallback(() => setValue(initialState), [initialState]);
7
+ return { value, increment, decrement, reset, setValue };
8
+ };
9
+ export {
10
+ useStateNumber as default
11
+ };
package/dist/index.d.ts CHANGED
@@ -108,6 +108,10 @@ export { default as useDebounce } from './hooks/useDebounce';
108
108
  export { default as usePrevious } from './hooks/usePrevious';
109
109
  export { default as useConfidentialityWarning } from './hooks/useConfidentialityWarning';
110
110
  export { default as usePredefinedProperties } from './hooks/usePredefinedProperties';
111
+ export { default as useStateBoolean } from './hooks/customStates/useStateBoolean';
112
+ export type { UseStateBooleanReturn } from './hooks/customStates/useStateBoolean';
113
+ export { default as useStateNumber } from './hooks/customStates/useStateNumber';
114
+ export type { UseStateNumberReturn } from './hooks/customStates/useStateNumber';
111
115
  export { default as SelectClearable } from './components/inputs/SelectClearable';
112
116
  export type { SelectClearableProps } from './components/inputs/SelectClearable';
113
117
  export { default as useCustomFormContext } from './components/inputs/reactHookForm/provider/useCustomFormContext';
package/dist/index.js CHANGED
@@ -92,45 +92,47 @@ import { default as default64 } from "./hooks/useDebounce.js";
92
92
  import { usePrevious } from "./hooks/usePrevious.js";
93
93
  import { default as default65 } from "./hooks/useConfidentialityWarning.js";
94
94
  import { default as default66 } from "./hooks/usePredefinedProperties.js";
95
- import { default as default67 } from "./components/inputs/SelectClearable.js";
96
- import { default as default68 } from "./components/inputs/reactHookForm/provider/useCustomFormContext.js";
97
- import { default as default69 } from "./components/inputs/reactHookForm/provider/CustomFormProvider.js";
98
- import { default as default70 } from "./components/inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
99
- import { default as default71 } from "./components/inputs/reactHookForm/text/TextInput.js";
100
- import { default as default72 } from "./components/inputs/reactHookForm/text/ExpandingTextField.js";
101
- import { default as default73 } from "./components/inputs/reactHookForm/booleans/RadioInput.js";
102
- import { default as default74 } from "./components/inputs/reactHookForm/numbers/SliderInput.js";
103
- import { default as default75 } from "./components/inputs/reactHookForm/numbers/FloatInput.js";
104
- import { default as default76 } from "./components/inputs/reactHookForm/numbers/IntegerInput.js";
105
- import { default as default77 } from "./components/inputs/reactHookForm/selectInputs/SelectInput.js";
106
- import { default as default78 } from "./components/inputs/reactHookForm/booleans/CheckboxInput.js";
107
- import { default as default79 } from "./components/inputs/reactHookForm/booleans/SwitchInput.js";
108
- import { default as default80 } from "./components/inputs/reactHookForm/errorManagement/ErrorInput.js";
109
- import { default as default81 } from "./components/inputs/reactHookForm/errorManagement/FieldErrorAlert.js";
110
- import { default as default82 } from "./components/inputs/reactHookForm/errorManagement/MidFormError.js";
111
- import { default as default83 } from "./components/inputs/reactHookForm/utils/TextFieldWithAdornment.js";
112
- import { default as default84 } from "./components/inputs/reactHookForm/utils/FieldLabel.js";
113
- import { default as default85 } from "./components/inputs/reactHookForm/utils/SubmitButton.js";
114
- import { default as default86 } from "./components/inputs/reactHookForm/utils/CancelButton.js";
95
+ import { default as default67 } from "./hooks/customStates/useStateBoolean.js";
96
+ import { default as default68 } from "./hooks/customStates/useStateNumber.js";
97
+ import { default as default69 } from "./components/inputs/SelectClearable.js";
98
+ import { default as default70 } from "./components/inputs/reactHookForm/provider/useCustomFormContext.js";
99
+ import { default as default71 } from "./components/inputs/reactHookForm/provider/CustomFormProvider.js";
100
+ import { default as default72 } from "./components/inputs/reactHookForm/autocompleteInputs/AutocompleteInput.js";
101
+ import { default as default73 } from "./components/inputs/reactHookForm/text/TextInput.js";
102
+ import { default as default74 } from "./components/inputs/reactHookForm/text/ExpandingTextField.js";
103
+ import { default as default75 } from "./components/inputs/reactHookForm/booleans/RadioInput.js";
104
+ import { default as default76 } from "./components/inputs/reactHookForm/numbers/SliderInput.js";
105
+ import { default as default77 } from "./components/inputs/reactHookForm/numbers/FloatInput.js";
106
+ import { default as default78 } from "./components/inputs/reactHookForm/numbers/IntegerInput.js";
107
+ import { default as default79 } from "./components/inputs/reactHookForm/selectInputs/SelectInput.js";
108
+ import { default as default80 } from "./components/inputs/reactHookForm/booleans/CheckboxInput.js";
109
+ import { default as default81 } from "./components/inputs/reactHookForm/booleans/SwitchInput.js";
110
+ import { default as default82 } from "./components/inputs/reactHookForm/errorManagement/ErrorInput.js";
111
+ import { default as default83 } from "./components/inputs/reactHookForm/errorManagement/FieldErrorAlert.js";
112
+ import { default as default84 } from "./components/inputs/reactHookForm/errorManagement/MidFormError.js";
113
+ import { default as default85 } from "./components/inputs/reactHookForm/utils/TextFieldWithAdornment.js";
114
+ import { default as default86 } from "./components/inputs/reactHookForm/utils/FieldLabel.js";
115
+ import { default as default87 } from "./components/inputs/reactHookForm/utils/SubmitButton.js";
116
+ import { default as default88 } from "./components/inputs/reactHookForm/utils/CancelButton.js";
115
117
  import { genHelperError, genHelperPreviousValue, gridItem, identity, isFieldRequired, isFloatNumber, toFloatOrNullValue } from "./components/inputs/reactHookForm/utils/functions.js";
116
118
  import { areArrayElementsUnique, isObjectEmpty, keyGenerator } from "./utils/functions.js";
117
- import { default as default87 } from "./components/inputs/reactHookForm/DirectoryItemsInput.js";
118
- import { default as default88 } from "./components/directoryItemSelector/DirectoryItemSelector.js";
119
- import { default as default89 } from "./components/customAGGrid/customAggrid.js";
120
- import { default as default90 } from "./components/inputs/reactHookForm/RawReadOnlyInput.js";
121
- import { default as default91 } from "./components/filter/FilterCreationDialog.js";
122
- import { default as default92 } from "./components/filter/expert/ExpertFilterEditionDialog.js";
123
- import { default as default93 } from "./components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
124
- import { default as default94 } from "./components/filter/criteriaBased/CriteriaBasedFilterEditionDialog.js";
119
+ import { default as default89 } from "./components/inputs/reactHookForm/DirectoryItemsInput.js";
120
+ import { default as default90 } from "./components/directoryItemSelector/DirectoryItemSelector.js";
121
+ import { default as default91 } from "./components/customAGGrid/customAggrid.js";
122
+ import { default as default92 } from "./components/inputs/reactHookForm/RawReadOnlyInput.js";
123
+ import { default as default93 } from "./components/filter/FilterCreationDialog.js";
124
+ import { default as default94 } from "./components/filter/expert/ExpertFilterEditionDialog.js";
125
+ import { default as default95 } from "./components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.js";
126
+ import { default as default96 } from "./components/filter/criteriaBased/CriteriaBasedFilterEditionDialog.js";
125
127
  import { saveCriteriaBasedFilter, saveExpertFilter, saveExplicitNamingFilter } from "./components/filter/utils/filterApi.js";
126
- import { DEFAULT_RANGE_VALUE, default as default95, getRangeInputDataForm, getRangeInputSchema } from "./components/inputs/reactHookForm/numbers/RangeInput.js";
127
- import { default as default96 } from "./components/inputs/reactHookForm/selectInputs/InputWithPopupConfirmation.js";
128
- import { default as default97 } from "./components/inputs/reactHookForm/selectInputs/MuiSelectInput.js";
129
- import { default as default98 } from "./components/inputs/reactHookForm/selectInputs/CountriesInput.js";
128
+ import { DEFAULT_RANGE_VALUE, default as default97, getRangeInputDataForm, getRangeInputSchema } from "./components/inputs/reactHookForm/numbers/RangeInput.js";
129
+ import { default as default98 } from "./components/inputs/reactHookForm/selectInputs/InputWithPopupConfirmation.js";
130
+ import { default as default99 } from "./components/inputs/reactHookForm/selectInputs/MuiSelectInput.js";
131
+ import { default as default100 } from "./components/inputs/reactHookForm/selectInputs/CountriesInput.js";
130
132
  import { getComputedLanguage, getSystemLanguage, useLocalizedCountries } from "./hooks/useLocalizedCountries.js";
131
- import { default as default99 } from "./components/inputs/reactHookForm/autocompleteInputs/MultipleAutocompleteInput.js";
132
- import { default as default100 } from "./components/inputs/reactHookForm/agGridTable/csvUploader/CsvUploader.js";
133
- import { default as default101 } from "./components/inputs/reactHookForm/text/UniqueNameInput.js";
133
+ import { default as default101 } from "./components/inputs/reactHookForm/autocompleteInputs/MultipleAutocompleteInput.js";
134
+ import { default as default102 } from "./components/inputs/reactHookForm/agGridTable/csvUploader/CsvUploader.js";
135
+ import { default as default103 } from "./components/inputs/reactHookForm/text/UniqueNameInput.js";
134
136
  import { CONTINGENCY_LIST_EQUIPMENTS, FILTER_EQUIPMENTS } from "./components/filter/utils/filterFormUtils.js";
135
137
  import { getCriteriaBasedFormData, getCriteriaBasedSchema } from "./components/filter/criteriaBased/criteriaBasedFilterUtils.js";
136
138
  import { setCommonStore } from "./redux/commonStore.js";
@@ -144,23 +146,23 @@ export {
144
146
  default4 as AboutDialog,
145
147
  default6 as AuthenticationRouter,
146
148
  default7 as AuthenticationRouterErrorDisplay,
147
- default70 as AutocompleteInput,
149
+ default72 as AutocompleteInput,
148
150
  Battery,
149
151
  default23 as BottomRightButtons,
150
152
  BusBar,
151
153
  CONTINGENCY_LIST_EQUIPMENTS,
152
- default86 as CancelButton,
154
+ default88 as CancelButton,
153
155
  default62 as CardErrorBoundary,
154
156
  ChangeWays,
155
- default78 as CheckboxInput,
157
+ default80 as CheckboxInput,
156
158
  CheckBoxList as CheckboxList,
157
- default98 as CountriesInput,
158
- default94 as CriteriaBasedFilterEditionDialog,
159
+ default100 as CountriesInput,
160
+ default96 as CriteriaBasedFilterEditionDialog,
159
161
  default21 as CriteriaBasedForm,
160
- default100 as CsvUploader,
161
- default89 as CustomAGGrid,
162
+ default102 as CsvUploader,
163
+ default91 as CustomAGGrid,
162
164
  default24 as CustomAgGridTable,
163
- default69 as CustomFormProvider,
165
+ default71 as CustomFormProvider,
164
166
  default17 as CustomMuiDialog,
165
167
  default26 as CustomReactQueryBuilder,
166
168
  DARK_THEME,
@@ -171,8 +173,8 @@ export {
171
173
  DanglingLine,
172
174
  default19 as DescriptionField,
173
175
  default18 as DescriptionModificationDialog,
174
- default88 as DirectoryItemSelector,
175
- default87 as DirectoryItemsInput,
176
+ default90 as DirectoryItemSelector,
177
+ default89 as DirectoryItemsInput,
176
178
  EQUIPMENT_TYPE,
177
179
  fields as EXPERT_FILTER_FIELDS,
178
180
  EXPERT_FILTER_QUERY,
@@ -183,23 +185,23 @@ export {
183
185
  EquipmentType,
184
186
  ErrorInLogoutAlert,
185
187
  ErrorInUserValidationAlert,
186
- default80 as ErrorInput,
188
+ default82 as ErrorInput,
187
189
  default15 as ExpandableGroup,
188
- default72 as ExpandingTextField,
189
- default92 as ExpertFilterEditionDialog,
190
- default93 as ExplicitNamingFilterEditionDialog,
190
+ default74 as ExpandingTextField,
191
+ default94 as ExpertFilterEditionDialog,
192
+ default95 as ExplicitNamingFilterEditionDialog,
191
193
  FILTER_EQUIPMENTS,
192
194
  default25 as FieldConstants,
193
- default81 as FieldErrorAlert,
194
- default84 as FieldLabel,
195
- default91 as FilterCreationDialog,
195
+ default83 as FieldErrorAlert,
196
+ default86 as FieldLabel,
197
+ default93 as FilterCreationDialog,
196
198
  FlatParameters,
197
- default75 as FloatInput,
199
+ default77 as FloatInput,
198
200
  GRIDSUITE_DEFAULT_PRECISION,
199
201
  Generator,
200
202
  Hvdc,
201
- default96 as InputWithPopupConfirmation,
202
- default76 as IntegerInput,
203
+ default98 as InputWithPopupConfirmation,
204
+ default78 as IntegerInput,
203
205
  KeyedColumnsRowIndexer,
204
206
  LANG_ENGLISH,
205
207
  LANG_FRENCH,
@@ -211,35 +213,35 @@ export {
211
213
  Load,
212
214
  default8 as Login,
213
215
  default9 as Logout,
214
- default82 as MidFormError,
216
+ default84 as MidFormError,
215
217
  default20 as ModifyElementSelection,
216
- default97 as MuiSelectInput,
218
+ default99 as MuiSelectInput,
217
219
  default12 as MuiVirtualizedTable,
218
- default99 as MultipleAutocompleteInput,
220
+ default101 as MultipleAutocompleteInput,
219
221
  default16 as MultipleSelectionDialog,
220
222
  OverflowableText,
221
223
  default22 as PopupConfirmationDialog,
222
224
  RESET_AUTHENTICATION_ROUTER_ERROR,
223
225
  ROW_DRAGGING_SELECTION_COLUMN_DEF,
224
- default73 as RadioInput,
225
- default95 as RangeInput,
226
- default90 as RawReadOnlyInput,
226
+ default75 as RadioInput,
227
+ default97 as RangeInput,
228
+ default92 as RawReadOnlyInput,
227
229
  SHOW_AUTH_INFO_LOGIN,
228
230
  SIGNIN_CALLBACK_ERROR,
229
231
  SVC,
230
- default67 as SelectClearable,
231
- default77 as SelectInput,
232
+ default69 as SelectClearable,
233
+ default79 as SelectInput,
232
234
  ShuntCompensator,
233
235
  default10 as SignInCallbackHandler,
234
236
  default11 as SilentRenewCallbackHandler,
235
- default74 as SliderInput,
237
+ default76 as SliderInput,
236
238
  default5 as SnackbarProvider,
237
- default85 as SubmitButton,
239
+ default87 as SubmitButton,
238
240
  Substation,
239
- default79 as SwitchInput,
241
+ default81 as SwitchInput,
240
242
  default13 as TagRenderer,
241
- default83 as TextFieldWithAdornment,
242
- default71 as TextInput,
243
+ default85 as TextFieldWithAdornment,
244
+ default73 as TextInput,
243
245
  ThreeWindingTransfo,
244
246
  default3 as TopBar,
245
247
  default2 as TreeViewFinder,
@@ -248,7 +250,7 @@ export {
248
250
  USER,
249
251
  USER_VALIDATION_ERROR,
250
252
  UnauthorizedAccessAlert,
251
- default101 as UniqueNameInput,
253
+ default103 as UniqueNameInput,
252
254
  UserManagerMock,
253
255
  VSC,
254
256
  VoltageLevel,
@@ -347,7 +349,7 @@ export {
347
349
  default37 as treeview_finder_fr,
348
350
  unitToMicroUnit,
349
351
  default65 as useConfidentialityWarning,
350
- default68 as useCustomFormContext,
352
+ default70 as useCustomFormContext,
351
353
  default64 as useDebounce,
352
354
  default14 as useElementSearch,
353
355
  default63 as useIntlRef,
@@ -355,5 +357,7 @@ export {
355
357
  default66 as usePredefinedProperties,
356
358
  usePrevious,
357
359
  useSnackMessage,
360
+ default67 as useStateBoolean,
361
+ default68 as useStateNumber,
358
362
  yup
359
363
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Settings, Article, NoteAlt, OfflineBolt, Photo, PhotoLibrary } from "@mui/icons-material";
2
+ import { Calculate, Settings, Article, NoteAlt, OfflineBolt, Photo, PhotoLibrary } from "@mui/icons-material";
3
3
  import { ElementType } from "../types/elementType.js";
4
4
  function getFileIcon(type, style) {
5
5
  switch (type) {
@@ -20,6 +20,8 @@ function getFileIcon(type, style) {
20
20
  case ElementType.SENSITIVITY_PARAMETERS:
21
21
  case ElementType.SHORT_CIRCUIT_PARAMETERS:
22
22
  return /* @__PURE__ */ jsx(Settings, { sx: style });
23
+ case ElementType.SPREADSHEET_CONFIG:
24
+ return /* @__PURE__ */ jsx(Calculate, { sx: style });
23
25
  case ElementType.DIRECTORY:
24
26
  return void 0;
25
27
  default:
@@ -12,6 +12,7 @@ export declare enum ElementType {
12
12
  SECURITY_ANALYSIS_PARAMETERS = "SECURITY_ANALYSIS_PARAMETERS",
13
13
  LOADFLOW_PARAMETERS = "LOADFLOW_PARAMETERS",
14
14
  SENSITIVITY_PARAMETERS = "SENSITIVITY_PARAMETERS",
15
- SHORT_CIRCUIT_PARAMETERS = "SHORT_CIRCUIT_PARAMETERS"
15
+ SHORT_CIRCUIT_PARAMETERS = "SHORT_CIRCUIT_PARAMETERS",
16
+ SPREADSHEET_CONFIG = "SPREADSHEET_CONFIG"
16
17
  }
17
18
  export type ElementExistsType = (directory: UUID, value: string, elementType: ElementType) => Promise<boolean>;
@@ -11,6 +11,7 @@ var ElementType = /* @__PURE__ */ ((ElementType2) => {
11
11
  ElementType2["LOADFLOW_PARAMETERS"] = "LOADFLOW_PARAMETERS";
12
12
  ElementType2["SENSITIVITY_PARAMETERS"] = "SENSITIVITY_PARAMETERS";
13
13
  ElementType2["SHORT_CIRCUIT_PARAMETERS"] = "SHORT_CIRCUIT_PARAMETERS";
14
+ ElementType2["SPREADSHEET_CONFIG"] = "SPREADSHEET_CONFIG";
14
15
  return ElementType2;
15
16
  })(ElementType || {});
16
17
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.65.3",
3
+ "version": "0.66.1",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",