@gridsuite/commons-ui 0.281.0 → 0.282.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.
- package/dist/components/composite/customAGGrid/custom-aggrid-filters/hooks/use-custom-aggrid-comparator-filter.js +1 -0
- package/dist/components/composite/customAGGrid/hooks/use-custom-aggrid-sort.js +1 -0
- package/dist/components/composite/reactQueryBuilder/OperatorSelector.js +1 -0
- package/dist/components/composite/report/QuickSearch.js +1 -0
- package/dist/components/composite/report/report-viewer/log-table/log-table.js +1 -1
- package/dist/components/ui/directoryItemSelector/DirectoryItemSelector.js +1 -0
- package/dist/features/index.js +12 -9
- package/dist/features/network-modification-table/network-modifications-table.js +1 -0
- package/dist/features/network-modification-table/renderers/reference-link-cell.js +1 -1
- package/dist/features/network-modification-table/renderers/root-network-chip-cell.js +1 -0
- package/dist/features/network-modification-table/renderers/switch-cell.js +1 -0
- package/dist/features/network-modification-table/row/drag-row-clone.js +1 -0
- package/dist/features/network-modification-table/use-modifications-drag-and-drop.js +1 -0
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabs.d.ts +3 -3
- package/dist/features/network-modifications/battery/modification/BatteryDialogTabs.js +2 -2
- package/dist/features/network-modifications/battery/modification/BatteryModificationForm.d.ts +4 -1
- package/dist/features/network-modifications/battery/modification/BatteryModificationForm.js +7 -11
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabs.d.ts +3 -3
- package/dist/features/network-modifications/generator/modification/GeneratorDialogTabs.js +2 -2
- package/dist/features/network-modifications/generator/modification/GeneratorModificationForm.d.ts +4 -1
- package/dist/features/network-modifications/generator/modification/GeneratorModificationForm.js +4 -8
- package/dist/features/network-modifications/index.d.ts +0 -1
- package/dist/features/network-modifications/index.js +3 -3
- package/dist/features/network-modifications/line/common/LineDialogTabs.d.ts +3 -3
- package/dist/features/network-modifications/line/common/LineDialogTabs.js +2 -2
- package/dist/features/network-modifications/line/common/LineForm.d.ts +4 -1
- package/dist/features/network-modifications/line/common/LineForm.js +7 -11
- package/dist/features/network-modifications/line/common/line.utils.d.ts +1 -1
- package/dist/features/network-modifications/load/common/LoadDialogTabs.d.ts +3 -3
- package/dist/features/network-modifications/load/common/LoadDialogTabs.js +2 -2
- package/dist/features/network-modifications/load/common/LoadForm.d.ts +4 -1
- package/dist/features/network-modifications/load/common/LoadForm.js +7 -11
- package/dist/features/network-modifications/static-var-compensator/common/static-var-compensator-dialog-tabs.d.ts +3 -2
- package/dist/features/network-modifications/static-var-compensator/common/static-var-compensator-dialog-tabs.js +2 -2
- package/dist/features/network-modifications/static-var-compensator/creation/static-var-compensator-creation-form.d.ts +4 -1
- package/dist/features/network-modifications/static-var-compensator/creation/static-var-compensator-creation-form.js +8 -11
- package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogTabs.d.ts +3 -3
- package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerDialogTabs.js +2 -2
- package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerForm.d.ts +4 -1
- package/dist/features/network-modifications/twoWindingsTransformer/common/TwoWindingsTransformerForm.js +7 -11
- package/dist/features/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.d.ts +4 -7
- package/dist/features/network-modifications/voltageLevel/creation/VoltageLevelCreationForm.js +16 -19
- package/dist/features/network-modifications/voltageLevel/creation/index.d.ts +1 -1
- package/dist/features/network-modifications/voltageLevel/creation/index.js +3 -1
- package/dist/features/network-modifications/voltageLevel/index.js +3 -1
- package/dist/features/parameters/common/hook/index.d.ts +0 -1
- package/dist/features/parameters/common/hook/index.js +1 -3
- package/dist/features/parameters/common/index.js +1 -3
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-form.d.ts +1 -1
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation-inline.js +4 -4
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation.type.d.ts +1 -0
- package/dist/features/parameters/dynamic-margin-calculation/dynamic-margin-calculation.type.js +2 -0
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-inline.js +3 -3
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis-parameters-form.d.ts +1 -1
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis.type.d.ts +1 -0
- package/dist/features/parameters/dynamic-security-analysis/dynamic-security-analysis.type.js +2 -0
- package/dist/features/parameters/dynamic-simulation/curve/dialog/curve-preview.js +1 -0
- package/dist/features/parameters/dynamic-simulation/curve/dialog/equipment-filter.js +1 -0
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-inline.js +3 -3
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation-parameters-form.d.ts +1 -1
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation.type.d.ts +1 -0
- package/dist/features/parameters/dynamic-simulation/dynamic-simulation.type.js +2 -0
- package/dist/features/parameters/index.js +10 -7
- package/dist/features/parameters/loadflow/load-flow-parameters-inline.js +1 -1
- package/dist/features/parameters/loadflow/load-flow-parameters-utils.d.ts +1 -0
- package/dist/features/parameters/loadflow/load-flow-parameters-utils.js +2 -0
- package/dist/features/parameters/loadflow/use-load-flow-parameters-form.js +3 -3
- package/dist/features/parameters/network-visualizations/constants.d.ts +1 -0
- package/dist/features/parameters/network-visualizations/constants.js +2 -0
- package/dist/features/parameters/network-visualizations/index.js +2 -1
- package/dist/features/parameters/network-visualizations/network-visualizations-parameters-inline.js +1 -1
- package/dist/features/parameters/network-visualizations/use-network-visualizations-parameters-form.js +3 -7
- package/dist/features/parameters/pcc-min/pcc-min-parameters-inline.js +1 -1
- package/dist/features/parameters/security-analysis/constants.d.ts +1 -0
- package/dist/features/parameters/security-analysis/constants.js +2 -0
- package/dist/features/parameters/security-analysis/index.js +2 -1
- package/dist/features/parameters/security-analysis/security-analysis-parameters-content.js +1 -1
- package/dist/features/parameters/security-analysis/security-analysis-parameters-dialog.js +1 -1
- package/dist/features/parameters/security-analysis/use-security-analysis-parameters-form.js +3 -3
- package/dist/features/parameters/sensi/columns-definitions.d.ts +2 -0
- package/dist/features/parameters/sensi/columns-definitions.js +36 -1
- package/dist/features/parameters/sensi/index.js +3 -1
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-dialog.js +1 -1
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-form.js +2 -1
- package/dist/features/parameters/sensi/sensitivity-analysis-parameters-inline.js +4 -1
- package/dist/features/parameters/sensi/sensitivity-parameters-selector.d.ts +3 -1
- package/dist/features/parameters/sensi/sensitivity-parameters-selector.js +19 -35
- package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +9 -1
- package/dist/features/parameters/sensi/use-sensitivity-analysis-parameters.js +29 -1
- package/dist/features/parameters/short-circuit/short-circuit-parameters-inline.js +1 -1
- package/dist/features/parameters/short-circuit/short-circuit-parameters-utils.d.ts +1 -0
- package/dist/features/parameters/short-circuit/short-circuit-parameters-utils.js +2 -0
- package/dist/features/parameters/short-circuit/use-short-circuit-parameters-form.js +3 -3
- package/dist/features/parameters/voltage-init/constants.d.ts +1 -0
- package/dist/features/parameters/voltage-init/constants.js +2 -0
- package/dist/features/parameters/voltage-init/index.js +2 -1
- package/dist/features/parameters/voltage-init/use-voltage-init-parameters-form.js +4 -8
- package/dist/features/parameters/voltage-init/voltage-init-parameters-inline.js +1 -1
- package/dist/features/process-configs/loadflow/lf-process-config-edition.js +7 -1
- package/dist/features/process-configs/security-analysis/sa-process-config-edition.js +7 -1
- package/dist/features/process-configs/shortcircuit/sc-process-config-edition.js +7 -1
- package/dist/features/results/loadflow/limit-violation-result.js +1 -1
- package/dist/features/results/shortcircuit/shortcircuit-analysis-result.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/use-tabs.d.ts +33 -0
- package/dist/hooks/use-tabs.js +55 -0
- package/dist/index.js +13 -8
- package/package.json +1 -1
- package/dist/features/network-modifications/hooks/index.d.ts +0 -7
- package/dist/features/network-modifications/hooks/index.js +0 -4
- package/dist/features/network-modifications/hooks/useTabsWithError.d.ts +0 -15
- package/dist/features/network-modifications/hooks/useTabsWithError.js +0 -28
- package/dist/features/parameters/common/hook/use-tabs.d.ts +0 -16
- package/dist/features/parameters/common/hook/use-tabs.js +0 -65
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FieldConstants } from '../../../utils';
|
|
2
|
-
type TabFieldsMap<T extends number> = Readonly<Partial<Record<T, FieldConstants[]>>>;
|
|
3
|
-
/**
|
|
4
|
-
* Manages tab navigation with automatic error highlighting for react-hook-form-based tabbed forms.
|
|
5
|
-
*
|
|
6
|
-
* @param tabFields - Maps each tab index to the field names it owns. Must be a module-level
|
|
7
|
-
* constant to remain stable across renders.
|
|
8
|
-
* @param initialTab - The tab to show on first render.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useTabsWithError<T extends number>(tabFields: TabFieldsMap<T>, initialTab: T): {
|
|
11
|
-
tabIndex: T;
|
|
12
|
-
setTabIndex: (tab: T) => void;
|
|
13
|
-
tabIndexesWithError: T[];
|
|
14
|
-
};
|
|
15
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
-
import { useFormState } from "react-hook-form";
|
|
3
|
-
function useTabsWithError(tabFields, initialTab) {
|
|
4
|
-
const { errors, submitCount } = useFormState();
|
|
5
|
-
const [tabIndex, setTabIndex] = useState(initialTab);
|
|
6
|
-
const tabIndexRef = useRef(tabIndex);
|
|
7
|
-
const tabIndexesWithError = Object.keys(tabFields).map(Number).filter(
|
|
8
|
-
(tab) => tabFields[tab].some((field) => errors[field] !== void 0)
|
|
9
|
-
);
|
|
10
|
-
const tabIndexesWithErrorRef = useRef(tabIndexesWithError);
|
|
11
|
-
tabIndexesWithErrorRef.current = tabIndexesWithError;
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const tabs = tabIndexesWithErrorRef.current;
|
|
14
|
-
if (tabs.length > 0 && !tabs.includes(tabIndexRef.current)) {
|
|
15
|
-
const tab = tabs[0];
|
|
16
|
-
tabIndexRef.current = tab;
|
|
17
|
-
setTabIndex(tab);
|
|
18
|
-
}
|
|
19
|
-
}, [submitCount]);
|
|
20
|
-
const handleSetTabIndex = useCallback((tab) => {
|
|
21
|
-
tabIndexRef.current = tab;
|
|
22
|
-
setTabIndex(tab);
|
|
23
|
-
}, []);
|
|
24
|
-
return { tabIndex, setTabIndex: handleSetTabIndex, tabIndexesWithError };
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
useTabsWithError
|
|
28
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SyntheticEvent } from 'react';
|
|
2
|
-
import { FieldErrors } from 'react-hook-form';
|
|
3
|
-
export type UseTabsReturn<TTabValue extends string> = {
|
|
4
|
-
selectedTab: TTabValue;
|
|
5
|
-
setSelectedTab: (selectedTab: TTabValue) => void;
|
|
6
|
-
tabsWithError: TTabValue[];
|
|
7
|
-
onTabChange: (event: SyntheticEvent, newValue: TTabValue) => void;
|
|
8
|
-
onError: (errors: FieldErrors) => void;
|
|
9
|
-
};
|
|
10
|
-
export type UseTabsProps<TTabValue extends string> = {
|
|
11
|
-
defaultTab: TTabValue;
|
|
12
|
-
tabEnum: Record<string, TTabValue>;
|
|
13
|
-
errors: FieldErrors;
|
|
14
|
-
tabFields?: Record<TTabValue, string[]>;
|
|
15
|
-
};
|
|
16
|
-
export declare function useTabs<TTabValue extends string>({ defaultTab, tabEnum, errors, tabFields, }: Readonly<UseTabsProps<TTabValue>>): UseTabsReturn<TTabValue>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from "react";
|
|
2
|
-
import { get } from "react-hook-form";
|
|
3
|
-
import { isObjectEmpty } from "../../../../utils/functions.js";
|
|
4
|
-
function useTabs({
|
|
5
|
-
defaultTab,
|
|
6
|
-
tabEnum,
|
|
7
|
-
errors,
|
|
8
|
-
tabFields
|
|
9
|
-
}) {
|
|
10
|
-
const [selectedTab, setSelectedTab] = useState(defaultTab);
|
|
11
|
-
const [tabsWithError, setTabsWithError] = useState([]);
|
|
12
|
-
const getTabsWithError = useCallback(
|
|
13
|
-
(_errors) => {
|
|
14
|
-
const tabsHasError = [];
|
|
15
|
-
Object.values(tabEnum).forEach((tabValue) => {
|
|
16
|
-
const fields = tabFields?.[tabValue] ?? [tabValue];
|
|
17
|
-
if (fields.some((field) => get(_errors, field))) {
|
|
18
|
-
tabsHasError.push(tabValue);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return tabsHasError;
|
|
22
|
-
},
|
|
23
|
-
[tabEnum, tabFields]
|
|
24
|
-
);
|
|
25
|
-
const onTabChange = useCallback(
|
|
26
|
-
(event, newSelectedTab) => {
|
|
27
|
-
setSelectedTab(newSelectedTab);
|
|
28
|
-
if (!errors || isObjectEmpty(errors)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const tabsHasError = getTabsWithError(errors);
|
|
32
|
-
if (tabsHasError.includes(newSelectedTab)) {
|
|
33
|
-
setTabsWithError(tabsHasError.filter((errorTab) => errorTab !== newSelectedTab));
|
|
34
|
-
} else {
|
|
35
|
-
setTabsWithError(tabsHasError);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
[errors, getTabsWithError]
|
|
39
|
-
);
|
|
40
|
-
const onError = useCallback(
|
|
41
|
-
(_errors) => {
|
|
42
|
-
if (!_errors || isObjectEmpty(_errors)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const tabsHasError = getTabsWithError(_errors);
|
|
46
|
-
if (tabsHasError.includes(selectedTab)) {
|
|
47
|
-
setTabsWithError(tabsHasError.filter((errorTab) => errorTab !== selectedTab));
|
|
48
|
-
} else if (tabsHasError.length > 0) {
|
|
49
|
-
setSelectedTab(tabsHasError[0]);
|
|
50
|
-
setTabsWithError(tabsHasError.filter((errorTab, index, arr) => errorTab !== arr[0]));
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
[getTabsWithError, selectedTab]
|
|
54
|
-
);
|
|
55
|
-
return {
|
|
56
|
-
selectedTab,
|
|
57
|
-
setSelectedTab,
|
|
58
|
-
tabsWithError,
|
|
59
|
-
onTabChange,
|
|
60
|
-
onError
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
useTabs
|
|
65
|
-
};
|