@gridsuite/commons-ui 0.134.0 → 0.135.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/README.md
CHANGED
|
@@ -7,6 +7,16 @@ Library for sharing GridSuite apps commons components
|
|
|
7
7
|
The commons-ui library have a demo app in which you can call your components to test them.
|
|
8
8
|
The `npm start` command install the library's dependencies then launches the demo app.
|
|
9
9
|
|
|
10
|
+
##### Development Scripts
|
|
11
|
+
|
|
12
|
+
- **`npm run type-check`** - Runs TypeScript type checking without emitting files. This ensures all developers use the project's local TypeScript version from `node_modules` rather than a potentially different globally-installed version. Run this to verify your code has no type errors before committing.
|
|
13
|
+
|
|
14
|
+
- **`npm run build`** - Builds the library. Note: This automatically runs `npm run prebuild` first.
|
|
15
|
+
|
|
16
|
+
- **`npm run prebuild`** - Runs linting and type checking before the build. This script is executed automatically by npm before `npm run build` and ensures that the build is not executed if linting or type checking fails. You don't need to call this manually unless you want to verify code quality without building.
|
|
17
|
+
|
|
18
|
+
##### Local Testing
|
|
19
|
+
|
|
10
20
|
If you want to test your library integration with a consumer application my-app you have first
|
|
11
21
|
to build commons-ui via
|
|
12
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Grid } from "@mui/material";
|
|
3
3
|
import { FormattedMessage } from "react-intl";
|
|
4
4
|
import { parametersStyles } from "../../parameters-style.js";
|
|
@@ -35,7 +35,8 @@ function sanitizePercentageValue(value) {
|
|
|
35
35
|
const styles = {
|
|
36
36
|
container: {
|
|
37
37
|
...parametersStyles.controlItem,
|
|
38
|
-
|
|
38
|
+
paddingTop: 3,
|
|
39
|
+
paddingRight: 3
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
function ParameterLineSlider({
|
|
@@ -46,9 +47,9 @@ function ParameterLineSlider({
|
|
|
46
47
|
minValue = 0,
|
|
47
48
|
maxValue = 100
|
|
48
49
|
}) {
|
|
49
|
-
return /* @__PURE__ */ jsxs(
|
|
50
|
+
return /* @__PURE__ */ jsxs(Grid, { container: true, sx: styles.container, children: [
|
|
50
51
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 8, sx: parametersStyles.parameterName, children: /* @__PURE__ */ jsx(FormattedMessage, { id: label }) }),
|
|
51
|
-
/* @__PURE__ */ jsx(Grid, { item: true,
|
|
52
|
+
/* @__PURE__ */ jsx(Grid, { item: true, xs: 4, children: /* @__PURE__ */ jsx(
|
|
52
53
|
SliderInput,
|
|
53
54
|
{
|
|
54
55
|
name,
|
|
@@ -124,6 +124,7 @@ const setLimitReductions = (provider, defaultLimitReductions, formMethods) => {
|
|
|
124
124
|
} else {
|
|
125
125
|
formMethods.setValue(PARAM_LIMIT_REDUCTION, DEFAULT_LIMIT_REDUCTION_VALUE);
|
|
126
126
|
formMethods.setValue(LIMIT_REDUCTIONS_FORM, []);
|
|
127
|
+
formMethods.clearErrors(LIMIT_REDUCTIONS_FORM);
|
|
127
128
|
}
|
|
128
129
|
};
|
|
129
130
|
const mapLimitReductions = (vlLimits, formLimits, indexVl) => {
|
|
@@ -58,6 +58,7 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
|
|
|
58
58
|
] = parametersBackend;
|
|
59
59
|
const [currentProvider, setCurrentProvider] = useState(params?.provider);
|
|
60
60
|
const [selectedTab, setSelectedTab] = useState(TabValues.GENERAL);
|
|
61
|
+
const [limitReductionNumber, setLimitReductionNumber] = useState(0);
|
|
61
62
|
const [tabIndexesWithError, setTabIndexesWithError] = useState([]);
|
|
62
63
|
const { snackError } = useSnackMessage();
|
|
63
64
|
const handleTabChange = useCallback((event, newValue) => {
|
|
@@ -83,12 +84,10 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
|
|
|
83
84
|
[PROVIDER]: yup.string().required(),
|
|
84
85
|
[PARAM_LIMIT_REDUCTION]: yup.number().nullable(),
|
|
85
86
|
...getCommonLoadFlowParametersFormSchema().fields,
|
|
86
|
-
...getLimitReductionsFormSchema(
|
|
87
|
-
params?.limitReductions ? params.limitReductions[0]?.temporaryLimitReductions.length : 0
|
|
88
|
-
).fields,
|
|
87
|
+
...getLimitReductionsFormSchema(limitReductionNumber).fields,
|
|
89
88
|
...getSpecificLoadFlowParametersFormSchema(specificParameters).fields
|
|
90
89
|
}).concat(getNameElementEditorSchema(name));
|
|
91
|
-
}, [name,
|
|
90
|
+
}, [name, limitReductionNumber, specificParameters]);
|
|
92
91
|
const formMethods = useForm({
|
|
93
92
|
defaultValues: {
|
|
94
93
|
...getNameElementEditorEmptyFormData(name, description),
|
|
@@ -240,12 +239,28 @@ const useLoadFlowParametersForm = (parametersBackend, enableDeveloperMode, param
|
|
|
240
239
|
reset(toLoadFlowFormValues(params));
|
|
241
240
|
}, [paramsLoaded, params, reset, specificParamsDescriptions, toLoadFlowFormValues]);
|
|
242
241
|
useEffect(() => {
|
|
243
|
-
if (watchProvider !== currentProvider) {
|
|
242
|
+
if (watchProvider && watchProvider !== currentProvider) {
|
|
244
243
|
setCurrentProvider(watchProvider);
|
|
245
244
|
setSpecificParameters(watchProvider, specificParamsDescriptions, formMethods);
|
|
246
245
|
setLimitReductions(watchProvider, defaultLimitReductions, formMethods);
|
|
246
|
+
if (watchProvider === PARAM_PROVIDER_OPENLOADFLOW) {
|
|
247
|
+
if (currentProvider) {
|
|
248
|
+
setLimitReductionNumber(defaultLimitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
|
|
249
|
+
} else {
|
|
250
|
+
setLimitReductionNumber(params?.limitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
|
|
251
|
+
}
|
|
252
|
+
} else {
|
|
253
|
+
setLimitReductionNumber(0);
|
|
254
|
+
}
|
|
247
255
|
}
|
|
248
|
-
}, [
|
|
256
|
+
}, [
|
|
257
|
+
currentProvider,
|
|
258
|
+
defaultLimitReductions,
|
|
259
|
+
formMethods,
|
|
260
|
+
params?.limitReductions,
|
|
261
|
+
specificParamsDescriptions,
|
|
262
|
+
watchProvider
|
|
263
|
+
]);
|
|
249
264
|
return {
|
|
250
265
|
formMethods,
|
|
251
266
|
formSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridsuite/commons-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.135.0",
|
|
4
4
|
"description": "common react components for gridsuite applications",
|
|
5
5
|
"author": "gridsuite team",
|
|
6
6
|
"homepage": "https://github.com/gridsuite",
|
|
@@ -23,13 +23,16 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"start": "vite demo/ --config vite.config.ts",
|
|
25
25
|
"start:open": "vite demo/ --config vite.config.ts --open",
|
|
26
|
-
"build": "
|
|
26
|
+
"build": "vite build",
|
|
27
27
|
"build:pack": "tsc && vite build && npm pack",
|
|
28
28
|
"prepublishOnly": "npm run build",
|
|
29
29
|
"test": "jest",
|
|
30
30
|
"test:coverage": "jest --coverage",
|
|
31
31
|
"test:watch": "jest --watch",
|
|
32
|
-
"
|
|
32
|
+
"type-check": "tsc",
|
|
33
|
+
"prebuild": "npm run lint && npm run type-check",
|
|
34
|
+
"lint": "eslint . --max-warnings 0",
|
|
35
|
+
"lint:fix": "eslint . --fix",
|
|
33
36
|
"lint:format": "prettier --check --cache .",
|
|
34
37
|
"licenses-check": "license-checker --summary --excludePrivatePackages --production --onlyAllow \"$( jq -r .onlyAllow[] license-checker-config.json | tr '\n' ';')\" --excludePackages \"$( jq -r .excludePackages[] license-checker-config.json | tr '\n' ';')\""
|
|
35
38
|
},
|
|
@@ -80,17 +83,19 @@
|
|
|
80
83
|
"@babel/preset-typescript": "^7.27.1",
|
|
81
84
|
"@emotion/react": "^11.14.0",
|
|
82
85
|
"@emotion/styled": "^11.14.1",
|
|
86
|
+
"@eslint/compat": "^1.4.1",
|
|
87
|
+
"@eslint/js": "^9.38.0",
|
|
83
88
|
"@hookform/resolvers": "^4.1.3",
|
|
84
89
|
"@jest/globals": "^30.1.2",
|
|
85
90
|
"@mui/icons-material": "^5.18.0",
|
|
86
91
|
"@mui/lab": "5.0.0-alpha.175",
|
|
87
92
|
"@mui/material": "^5.18.0",
|
|
88
93
|
"@react-hook/window-size": "^3.1.1",
|
|
94
|
+
"@stylistic/eslint-plugin": "^3.1.0",
|
|
89
95
|
"@testing-library/jest-dom": "^6.8.0",
|
|
90
96
|
"@testing-library/react": "^16.3.0",
|
|
91
97
|
"@testing-library/user-event": "^14.6.1",
|
|
92
98
|
"@types/autosuggest-highlight": "^3.2.3",
|
|
93
|
-
"@types/eslint": "^8.56.12",
|
|
94
99
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
95
100
|
"@types/jest": "^30.0.0",
|
|
96
101
|
"@types/json-logic-js": "^2.0.8",
|
|
@@ -101,25 +106,21 @@
|
|
|
101
106
|
"@types/react": "^18.3.24",
|
|
102
107
|
"@types/react-dom": "^18.3.7",
|
|
103
108
|
"@types/react-resizable": "^3.0.8",
|
|
104
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
105
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
106
109
|
"@vitejs/plugin-react": "^5.0.4",
|
|
107
110
|
"ag-grid-community": "^33.1.0",
|
|
108
111
|
"ag-grid-react": "^33.3.2",
|
|
109
112
|
"babel-eslint": "^10.1.0",
|
|
110
113
|
"babel-preset-airbnb": "^5.0.0",
|
|
111
114
|
"babel-preset-vite": "^1.1.3",
|
|
112
|
-
"eslint": "^
|
|
113
|
-
"eslint-config-airbnb": "^
|
|
114
|
-
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
115
|
+
"eslint": "^9.38.0",
|
|
116
|
+
"eslint-config-airbnb-extended": "^2.3.2",
|
|
115
117
|
"eslint-config-prettier": "^10.1.8",
|
|
116
|
-
"eslint-
|
|
117
|
-
"eslint-plugin-
|
|
118
|
-
"eslint-plugin-import": "^2.32.0",
|
|
118
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
119
|
+
"eslint-plugin-import-x": "^4.16.1",
|
|
119
120
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
120
121
|
"eslint-plugin-prettier": "^5.5.4",
|
|
121
122
|
"eslint-plugin-react": "^7.37.5",
|
|
122
|
-
"eslint-plugin-react-hooks": "^
|
|
123
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
123
124
|
"glob": "^11.0.3",
|
|
124
125
|
"identity-obj-proxy": "^3.0.0",
|
|
125
126
|
"jest": "^30.1.3",
|
|
@@ -136,10 +137,11 @@
|
|
|
136
137
|
"react-resizable": "^3.0.5",
|
|
137
138
|
"react-router": "^7.8.2",
|
|
138
139
|
"ts-node": "^10.9.2",
|
|
139
|
-
"typescript": "~5.
|
|
140
|
+
"typescript": "~5.9.3",
|
|
141
|
+
"typescript-eslint": "^8.46.2",
|
|
140
142
|
"vite": "^7.1.12",
|
|
143
|
+
"vite-plugin-checker": "^0.8.0",
|
|
141
144
|
"vite-plugin-dts": "^4.5.4",
|
|
142
|
-
"vite-plugin-eslint": "^1.8.1",
|
|
143
145
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
144
146
|
"vite-plugin-svgr": "^4.5.0",
|
|
145
147
|
"yup": "^1.7.0"
|