-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathmessages.tsx
More file actions
75 lines (68 loc) · 1.8 KB
/
Copy pathmessages.tsx
File metadata and controls
75 lines (68 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright © 2024 Ory Corp
// SPDX-License-Identifier: Apache-2.0
import type { UiText } from "@ory/client-fetch"
import { useComponents, useOryFlow } from "../../context"
import type { PropsWithChildren } from "react"
/**
* Props for the OryMessageContent component.
*
* @interface
*/
export type OryMessageContentProps = {
/**
* The message to display.
*/
message: UiText
}
/**
*
* @interface
* @expand
*/
export type OryMessageRootProps = PropsWithChildren
/**
* Props for the {@link OryCardValidationMessages} component.
*
* @inline
* @hidden
*/
export interface OryCardValidationMessagesProps {
/**
* An array of message IDs that should be hidden.
* This is useful for hiding specific messages that are not relevant to the user or are rendered elsewhere.
* If not provided, the default list of message IDs to hide will be used.
* @default [1040009, 1060003, 1080003, 1010004, 1010014, 1040005, 1010016, 1010003]
*
* @see https://www.ory.com/docs/kratos/concepts/ui-messages
*/
hiddenMessageIds?: number[]
}
/**
* Renders the {@link OryFlowComponents.Message.Content} component for each message in the current flow.
*
* See also {@link useOryFlow}
* @returns
* @group Components
*/
export function OryCardValidationMessages({
hiddenMessageIds = [
1040009, 1060003, 1080003, 1010004, 1010014, 1010025, 1040005, 1010016,
1010003, 1060004, 1060005, 1060006,
],
}: OryCardValidationMessagesProps) {
const { flow } = useOryFlow()
const messages = flow.ui.messages?.filter(
(m) => !hiddenMessageIds.includes(m.id),
)
const { Message } = useComponents()
if (!messages) {
return null
}
return (
<Message.Root>
{messages?.map((message) => (
<Message.Content key={message.id} message={message} />
))}
</Message.Root>
)
}