@gridsuite/commons-ui 0.127.0 → 0.128.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/inputs/reactHookForm/text/TextInput.d.ts +3 -1
- package/dist/components/inputs/reactHookForm/text/TextInput.js +3 -1
- package/dist/components/inputs/reactHookForm/text/UniqueNameInput.d.ts +2 -1
- package/dist/components/inputs/reactHookForm/text/UniqueNameInput.js +3 -1
- package/dist/components/notifications/NotificationsProvider.js +1 -1
- package/dist/components/notifications/contexts/NotificationsContext.d.ts +5 -3
- package/dist/components/notifications/hooks/useListenerManager.d.ts +3 -3
- package/dist/components/notifications/hooks/useListenerManager.js +2 -2
- package/dist/hooks/use-unique-name-validation.d.ts +2 -1
- package/dist/hooks/use-unique-name-validation.js +12 -4
- package/dist/utils/types/equipmentType.d.ts +2 -1
- package/package.json +1 -1
|
@@ -19,9 +19,11 @@ export interface TextInputProps {
|
|
|
19
19
|
clearable?: boolean;
|
|
20
20
|
formProps?: Omit<TextFieldWithAdornmentProps | TextFieldProps, 'value' | 'onChange' | 'inputRef' | 'inputProps' | 'InputProps'>;
|
|
21
21
|
disabledTooltip?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare function TextInput({ name, label, labelValues, // this prop is used to add a value to label. this value is displayed without being translated
|
|
24
25
|
id, adornment, customAdornment, outputTransform, // transform materialUi input value before sending it to react hook form, mostly used to deal with number fields
|
|
25
26
|
inputTransform, // transform react hook form value before sending it to materialUi input, mostly used to deal with number fields
|
|
26
27
|
acceptValue, // used to check user entry before committing the input change, used mostly to prevent user from typing a character in number field
|
|
27
|
-
previousValue, clearable, formProps, disabledTooltip,
|
|
28
|
+
previousValue, clearable, formProps, disabledTooltip, // In case we don't want to show tooltip on the value and warning/info icons
|
|
29
|
+
disabled, }: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,8 +24,9 @@ function TextInput({
|
|
|
24
24
|
previousValue,
|
|
25
25
|
clearable,
|
|
26
26
|
formProps,
|
|
27
|
-
disabledTooltip
|
|
27
|
+
disabledTooltip,
|
|
28
28
|
// In case we don't want to show tooltip on the value and warning/info icons
|
|
29
|
+
disabled
|
|
29
30
|
}) {
|
|
30
31
|
const { validationSchema, getValues, removeOptional, isNodeBuilt, isUpdate } = useCustomFormContext();
|
|
31
32
|
const {
|
|
@@ -60,6 +61,7 @@ function TextInput({
|
|
|
60
61
|
label: fieldLabel,
|
|
61
62
|
value: transformedValue,
|
|
62
63
|
onChange: handleValueChanged,
|
|
64
|
+
disabled,
|
|
63
65
|
InputProps: {
|
|
64
66
|
endAdornment: /* @__PURE__ */ jsxs(InputAdornment, { position: "end", children: [
|
|
65
67
|
clearable && transformedValue !== void 0 && transformedValue !== "" && /* @__PURE__ */ jsx(IconButton, { onClick: handleClearValue, children: /* @__PURE__ */ jsx(Clear, {}) }),
|
|
@@ -11,10 +11,11 @@ export interface UniqueNameInputProps {
|
|
|
11
11
|
formProps?: Omit<TextFieldProps, 'value' | 'onChange' | 'name' | 'label' | 'inputRef' | 'inputProps' | 'InputProps'>;
|
|
12
12
|
activeDirectory?: UUID;
|
|
13
13
|
currentName?: string;
|
|
14
|
+
isPrefilled?: boolean;
|
|
14
15
|
sx?: SxStyle;
|
|
15
16
|
fullWidth?: boolean;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Input component that constantly checks if the field's value is available or not
|
|
19
20
|
*/
|
|
20
|
-
export declare function UniqueNameInput({ name, label, elementType, autoFocus, onManualChangeCallback, formProps, currentName, activeDirectory, sx, fullWidth, }: Readonly<UniqueNameInputProps>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function UniqueNameInput({ name, label, elementType, autoFocus, onManualChangeCallback, formProps, currentName, isPrefilled, activeDirectory, sx, fullWidth, }: Readonly<UniqueNameInputProps>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,6 +12,7 @@ function UniqueNameInput({
|
|
|
12
12
|
onManualChangeCallback,
|
|
13
13
|
formProps,
|
|
14
14
|
currentName = "",
|
|
15
|
+
isPrefilled = false,
|
|
15
16
|
activeDirectory,
|
|
16
17
|
sx,
|
|
17
18
|
fullWidth = true
|
|
@@ -26,7 +27,8 @@ function UniqueNameInput({
|
|
|
26
27
|
name,
|
|
27
28
|
currentName,
|
|
28
29
|
elementType,
|
|
29
|
-
activeDirectory
|
|
30
|
+
activeDirectory,
|
|
31
|
+
isPrefilled
|
|
30
32
|
});
|
|
31
33
|
const handleManualChange = (e) => {
|
|
32
34
|
onChange(e.target.value);
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
5
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
*/
|
|
7
|
-
export type
|
|
7
|
+
export type ListenerEventBase = {
|
|
8
8
|
id: string;
|
|
9
|
+
callback: (...args: any[]) => void;
|
|
10
|
+
};
|
|
11
|
+
export type ListenerEventWS = ListenerEventBase & {
|
|
9
12
|
callback: (event: MessageEvent) => void;
|
|
10
13
|
};
|
|
11
|
-
export type ListenerOnReopen = {
|
|
12
|
-
id: string;
|
|
14
|
+
export type ListenerOnReopen = ListenerEventBase & {
|
|
13
15
|
callback: () => void;
|
|
14
16
|
};
|
|
15
17
|
export type NotificationsContextType = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useListenerManager: <TListener extends
|
|
1
|
+
import { ListenerEventBase } from '../contexts/NotificationsContext';
|
|
2
|
+
export declare const useListenerManager: <TListener extends ListenerEventBase>(urls: Record<string, string | undefined>) => {
|
|
3
3
|
addListener: (urlKey: string, listener: TListener) => void;
|
|
4
4
|
removeListener: (urlKey: string, id: string) => void;
|
|
5
|
-
broadcast: (urlKey: string) => (
|
|
5
|
+
broadcast: (urlKey: string) => (...args: Parameters<TListener["callback"]>) => void;
|
|
6
6
|
};
|
|
@@ -37,12 +37,12 @@ const useListenerManager = (urls) => {
|
|
|
37
37
|
}
|
|
38
38
|
}, []);
|
|
39
39
|
const broadcast = useCallback(
|
|
40
|
-
(urlKey) => (
|
|
40
|
+
(urlKey) => (...args) => {
|
|
41
41
|
var _a;
|
|
42
42
|
const listeners = (_a = urlsListenersRef.current) == null ? void 0 : _a[urlKey];
|
|
43
43
|
if (listeners) {
|
|
44
44
|
listeners.forEach(({ callback }) => {
|
|
45
|
-
callback(
|
|
45
|
+
callback(...args);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
},
|
|
@@ -6,8 +6,9 @@ interface UseUniqueNameValidationParams {
|
|
|
6
6
|
elementType: ElementType;
|
|
7
7
|
activeDirectory?: string;
|
|
8
8
|
elementExists?: (directory: UUID, name: string, type: ElementType) => Promise<boolean>;
|
|
9
|
+
isPrefilled?: boolean;
|
|
9
10
|
}
|
|
10
|
-
export declare function useUniqueNameValidation({ name, currentName, elementType, activeDirectory, elementExists, }: UseUniqueNameValidationParams): {
|
|
11
|
+
export declare function useUniqueNameValidation({ name, currentName, elementType, activeDirectory, elementExists, isPrefilled, }: UseUniqueNameValidationParams): {
|
|
11
12
|
isValidating: Partial<{
|
|
12
13
|
type: string | number;
|
|
13
14
|
message: import('react-hook-form').Message;
|
|
@@ -13,7 +13,8 @@ function useUniqueNameValidation({
|
|
|
13
13
|
currentName = "",
|
|
14
14
|
elementType,
|
|
15
15
|
activeDirectory,
|
|
16
|
-
elementExists = elementAlreadyExists
|
|
16
|
+
elementExists = elementAlreadyExists,
|
|
17
|
+
isPrefilled = false
|
|
17
18
|
}) {
|
|
18
19
|
var _a;
|
|
19
20
|
const {
|
|
@@ -23,7 +24,8 @@ function useUniqueNameValidation({
|
|
|
23
24
|
formState: { errors, defaultValues, isDirty: formIsDirty }
|
|
24
25
|
} = useFormContext();
|
|
25
26
|
const {
|
|
26
|
-
field: { value }
|
|
27
|
+
field: { value },
|
|
28
|
+
fieldState: { isDirty: fieldIsDirty }
|
|
27
29
|
} = useController({ name });
|
|
28
30
|
const {
|
|
29
31
|
field: { value: selectedDirectory }
|
|
@@ -64,11 +66,15 @@ function useUniqueNameValidation({
|
|
|
64
66
|
if (selectedDirectory) {
|
|
65
67
|
debouncedHandleCheckName(trimmedValue);
|
|
66
68
|
}
|
|
67
|
-
if (!
|
|
69
|
+
if (!isPrefilled && !fieldIsDirty) {
|
|
68
70
|
clearErrors(name);
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
|
-
if (
|
|
73
|
+
if (isPrefilled && !formIsDirty) {
|
|
74
|
+
clearErrors(name);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (isPrefilled && trimmedValue === defaultFieldValue && trimmedValue.length > 0) {
|
|
72
78
|
return;
|
|
73
79
|
}
|
|
74
80
|
if (trimmedValue) {
|
|
@@ -91,7 +97,9 @@ function useUniqueNameValidation({
|
|
|
91
97
|
setError,
|
|
92
98
|
clearErrors,
|
|
93
99
|
name,
|
|
100
|
+
fieldIsDirty,
|
|
94
101
|
formIsDirty,
|
|
102
|
+
isPrefilled,
|
|
95
103
|
defaultFieldValue,
|
|
96
104
|
directory,
|
|
97
105
|
selectedDirectory
|
|
@@ -37,7 +37,8 @@ export declare const equipmentStyles: {
|
|
|
37
37
|
/**
|
|
38
38
|
* The order of the equipments in this list is important, as many UI follow it directly.
|
|
39
39
|
* When EquipmentType is used for an interface this order must be maintained.
|
|
40
|
-
*
|
|
40
|
+
* Should be moved to a specialized subtype as this one is used everywhere and cause problems
|
|
41
|
+
* Will be deprecated soon.
|
|
41
42
|
*/
|
|
42
43
|
export declare enum EquipmentType {
|
|
43
44
|
SUBSTATION = "SUBSTATION",
|