|
|
|
@ -58,7 +58,7 @@ const MessageGroup = forwardRef< |
|
|
|
|
(key: string, message?: Message) => { |
|
|
|
|
let length = 0; |
|
|
|
|
|
|
|
|
|
setMessages(({ [key]: unused, ...rest }) => { |
|
|
|
|
const { [key]: unused, ...rest } = messages; |
|
|
|
|
const result: Messages = rest; |
|
|
|
|
|
|
|
|
|
if (message) { |
|
|
|
@ -69,10 +69,9 @@ const MessageGroup = forwardRef< |
|
|
|
|
|
|
|
|
|
onSet?.call(null, length); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
}); |
|
|
|
|
setMessages(result); |
|
|
|
|
}, |
|
|
|
|
[onSet], |
|
|
|
|
[messages, onSet], |
|
|
|
|
); |
|
|
|
|
const setMessageRe = useCallback( |
|
|
|
|
(re: RegExp, message?: Message) => { |
|
|
|
@ -84,25 +83,22 @@ const MessageGroup = forwardRef< |
|
|
|
|
length += 1; |
|
|
|
|
} |
|
|
|
|
: undefined; |
|
|
|
|
|
|
|
|
|
setMessages((previous) => { |
|
|
|
|
const result: Messages = {}; |
|
|
|
|
|
|
|
|
|
Object.keys(previous).forEach((key: string) => { |
|
|
|
|
Object.keys(messages).forEach((key: string) => { |
|
|
|
|
if (re.test(key)) { |
|
|
|
|
assignMessage?.call(null, result, key); |
|
|
|
|
} else { |
|
|
|
|
result[key] = previous[key]; |
|
|
|
|
result[key] = messages[key]; |
|
|
|
|
length += 1; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
onSet?.call(null, length); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
}); |
|
|
|
|
setMessages(result); |
|
|
|
|
}, |
|
|
|
|
[onSet], |
|
|
|
|
[messages, onSet], |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const messageElements = useMemo(() => { |
|
|
|
|