@common-origin/design-system 2.19.0 → 2.20.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/client.js +169 -169
- package/dist/client.js.map +1 -1
- package/dist/components/atoms/Avatar/Avatar.d.mts +8 -0
- package/dist/components/atoms/Avatar/Avatar.mjs +103 -0
- package/dist/components/atoms/Avatar/Avatar.mjs.map +1 -0
- package/dist/components/atoms/Avatar/index.d.mts +1 -0
- package/dist/components/atoms/Badge/Badge.d.mts +25 -0
- package/dist/components/atoms/Badge/Badge.mjs +98 -0
- package/dist/components/atoms/Badge/Badge.mjs.map +1 -0
- package/dist/components/atoms/Badge/index.d.mts +2 -0
- package/dist/components/atoms/Box/Box.d.mts +62 -0
- package/dist/components/atoms/Box/Box.mjs +246 -0
- package/dist/components/atoms/Box/Box.mjs.map +1 -0
- package/dist/components/atoms/Box/index.d.mts +1 -0
- package/dist/components/atoms/Button/Button.d.mts +40 -0
- package/dist/components/atoms/Button/Button.mjs +208 -0
- package/dist/components/atoms/Button/Button.mjs.map +1 -0
- package/dist/components/atoms/Button/index.d.mts +1 -0
- package/dist/components/atoms/CategoryBadge/CategoryBadge.d.mts +29 -0
- package/dist/components/atoms/CategoryBadge/CategoryBadge.mjs +29 -0
- package/dist/components/atoms/CategoryBadge/CategoryBadge.mjs.map +1 -0
- package/dist/components/atoms/CategoryBadge/index.d.mts +2 -0
- package/dist/components/atoms/CategoryLabel/CategoryLabel.d.mts +69 -0
- package/dist/components/atoms/CategoryLabel/CategoryLabel.mjs +151 -0
- package/dist/components/atoms/CategoryLabel/CategoryLabel.mjs.map +1 -0
- package/dist/components/atoms/CategoryLabel/index.d.mts +2 -0
- package/dist/components/atoms/Chip/BooleanChip.d.mts +28 -0
- package/dist/components/atoms/Chip/BooleanChip.mjs +76 -0
- package/dist/components/atoms/Chip/BooleanChip.mjs.map +1 -0
- package/dist/components/atoms/Chip/Chip.d.mts +37 -0
- package/dist/components/atoms/Chip/Chip.mjs +76 -0
- package/dist/components/atoms/Chip/Chip.mjs.map +1 -0
- package/dist/components/atoms/Chip/FilterChip.d.mts +13 -0
- package/dist/components/atoms/Chip/FilterChip.mjs +14 -0
- package/dist/components/atoms/Chip/FilterChip.mjs.map +1 -0
- package/dist/components/atoms/Chip/InputChip.d.mts +27 -0
- package/dist/components/atoms/Chip/InputChip.mjs +97 -0
- package/dist/components/atoms/Chip/InputChip.mjs.map +1 -0
- package/dist/components/atoms/Chip/index.d.mts +4 -0
- package/dist/components/atoms/Chip/shared/ChipBase.d.mts +12 -0
- package/dist/components/atoms/Chip/shared/ChipBase.mjs +45 -0
- package/dist/components/atoms/Chip/shared/ChipBase.mjs.map +1 -0
- package/dist/components/atoms/Chip/shared/types.d.mts +34 -0
- package/dist/components/atoms/Chip/shared/utils.d.mts +10 -0
- package/dist/components/atoms/Chip/shared/utils.mjs +46 -0
- package/dist/components/atoms/Chip/shared/utils.mjs.map +1 -0
- package/dist/components/atoms/Container/Container.d.mts +6 -0
- package/dist/components/atoms/Container/Container.mjs +24 -0
- package/dist/components/atoms/Container/Container.mjs.map +1 -0
- package/dist/components/atoms/Container/index.d.mts +1 -0
- package/dist/components/atoms/DateFormatter/DateFormatter.d.mts +23 -0
- package/dist/components/atoms/DateFormatter/DateFormatter.mjs +64 -0
- package/dist/components/atoms/DateFormatter/DateFormatter.mjs.map +1 -0
- package/dist/components/atoms/DateFormatter/index.d.mts +1 -0
- package/dist/components/atoms/Divider/Divider.d.mts +30 -0
- package/dist/components/atoms/Divider/Divider.mjs +134 -0
- package/dist/components/atoms/Divider/Divider.mjs.map +1 -0
- package/dist/components/atoms/Divider/index.d.mts +1 -0
- package/dist/components/atoms/Icon/Icon.d.mts +22 -0
- package/dist/components/atoms/Icon/Icon.mjs +95 -0
- package/dist/components/atoms/Icon/Icon.mjs.map +1 -0
- package/dist/components/atoms/Icon/index.d.mts +1 -0
- package/dist/components/atoms/IconButton/IconButton.d.mts +14 -0
- package/dist/components/atoms/IconButton/IconButton.mjs +150 -0
- package/dist/components/atoms/IconButton/IconButton.mjs.map +1 -0
- package/dist/components/atoms/IconButton/index.d.mts +1 -0
- package/dist/components/atoms/MoneyDisplay/MoneyDisplay.d.mts +26 -0
- package/dist/components/atoms/MoneyDisplay/MoneyDisplay.mjs +126 -0
- package/dist/components/atoms/MoneyDisplay/MoneyDisplay.mjs.map +1 -0
- package/dist/components/atoms/MoneyDisplay/index.d.mts +2 -0
- package/dist/components/atoms/Picture/Picture.d.mts +12 -0
- package/dist/components/atoms/Picture/Picture.mjs +65 -0
- package/dist/components/atoms/Picture/Picture.mjs.map +1 -0
- package/dist/components/atoms/Picture/index.d.mts +1 -0
- package/dist/components/atoms/ProgressBar/ProgressBar.d.mts +21 -0
- package/dist/components/atoms/ProgressBar/ProgressBar.mjs +91 -0
- package/dist/components/atoms/ProgressBar/ProgressBar.mjs.map +1 -0
- package/dist/components/atoms/ProgressBar/index.d.mts +2 -0
- package/dist/components/atoms/Stack/Stack.d.mts +16 -0
- package/dist/components/atoms/Stack/Stack.mjs +71 -0
- package/dist/components/atoms/Stack/Stack.mjs.map +1 -0
- package/dist/components/atoms/Stack/index.d.mts +1 -0
- package/dist/components/atoms/StatusBadge/StatusBadge.d.mts +23 -0
- package/dist/components/atoms/StatusBadge/StatusBadge.mjs +18 -0
- package/dist/components/atoms/StatusBadge/StatusBadge.mjs.map +1 -0
- package/dist/components/atoms/StatusBadge/index.d.mts +2 -0
- package/dist/components/atoms/StatusLabel/StatusLabel.d.mts +17 -0
- package/dist/components/atoms/StatusLabel/StatusLabel.mjs +28 -0
- package/dist/components/atoms/StatusLabel/StatusLabel.mjs.map +1 -0
- package/dist/components/atoms/StatusLabel/StatusLabelBase.d.mts +49 -0
- package/dist/components/atoms/StatusLabel/StatusLabelBase.mjs +161 -0
- package/dist/components/atoms/StatusLabel/StatusLabelBase.mjs.map +1 -0
- package/dist/components/atoms/StatusLabel/index.d.mts +2 -0
- package/dist/components/atoms/Tag/Tag.d.mts +36 -0
- package/dist/components/atoms/Tag/Tag.mjs +115 -0
- package/dist/components/atoms/Tag/Tag.mjs.map +1 -0
- package/dist/components/atoms/Tag/index.d.mts +2 -0
- package/dist/components/atoms/Typography/Typography.d.mts +34 -0
- package/dist/components/atoms/Typography/Typography.mjs +139 -0
- package/dist/components/atoms/Typography/Typography.mjs.map +1 -0
- package/dist/components/atoms/Typography/index.d.mts +1 -0
- package/dist/components/atoms/index.d.mts +20 -0
- package/dist/components/index.d.mts +4 -0
- package/dist/components/layout/GridSystem/GridSystem.d.mts +58 -0
- package/dist/components/layout/GridSystem/GridSystem.mjs +221 -0
- package/dist/components/layout/GridSystem/GridSystem.mjs.map +1 -0
- package/dist/components/layout/GridSystem/index.d.mts +1 -0
- package/dist/components/layout/index.d.mts +1 -0
- package/dist/components/molecules/AccountCard/AccountCard.d.mts +44 -0
- package/dist/components/molecules/AccountCard/AccountCard.mjs +191 -0
- package/dist/components/molecules/AccountCard/AccountCard.mjs.map +1 -0
- package/dist/components/molecules/AccountCard/index.d.mts +2 -0
- package/dist/components/molecules/ActionSheet/ActionSheet.d.mts +111 -0
- package/dist/components/molecules/ActionSheet/ActionSheet.mjs +283 -0
- package/dist/components/molecules/ActionSheet/ActionSheet.mjs.map +1 -0
- package/dist/components/molecules/ActionSheet/index.d.mts +2 -0
- package/dist/components/molecules/AgentInput/AgentInput.d.mts +30 -0
- package/dist/components/molecules/AgentInput/AgentInput.mjs +735 -0
- package/dist/components/molecules/AgentInput/AgentInput.mjs.map +1 -0
- package/dist/components/molecules/AgentInput/agentInputSpeech.d.mts +43 -0
- package/dist/components/molecules/AgentInput/agentInputSpeech.mjs +49 -0
- package/dist/components/molecules/AgentInput/agentInputSpeech.mjs.map +1 -0
- package/dist/components/molecules/AgentInput/agentInputStateMachine.d.mts +29 -0
- package/dist/components/molecules/AgentInput/agentInputStateMachine.mjs +55 -0
- package/dist/components/molecules/AgentInput/agentInputStateMachine.mjs.map +1 -0
- package/dist/components/molecules/AgentInput/index.d.mts +3 -0
- package/dist/components/molecules/Alert/Alert.d.mts +68 -0
- package/dist/components/molecules/Alert/Alert.mjs +284 -0
- package/dist/components/molecules/Alert/Alert.mjs.map +1 -0
- package/dist/components/molecules/Alert/index.d.mts +1 -0
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.mts +16 -0
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.mjs +74 -0
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.mjs.map +1 -0
- package/dist/components/molecules/Breadcrumbs/index.d.mts +1 -0
- package/dist/components/molecules/CardLarge/CardLarge.d.mts +12 -0
- package/dist/components/molecules/CardLarge/CardLarge.mjs +75 -0
- package/dist/components/molecules/CardLarge/CardLarge.mjs.map +1 -0
- package/dist/components/molecules/CardLarge/index.d.mts +1 -0
- package/dist/components/molecules/CardSmall/CardSmall.d.mts +16 -0
- package/dist/components/molecules/CardSmall/CardSmall.mjs +73 -0
- package/dist/components/molecules/CardSmall/CardSmall.mjs.map +1 -0
- package/dist/components/molecules/CardSmall/index.d.mts +1 -0
- package/dist/components/molecules/Checkbox/Checkbox.d.mts +64 -0
- package/dist/components/molecules/Checkbox/Checkbox.mjs +139 -0
- package/dist/components/molecules/Checkbox/Checkbox.mjs.map +1 -0
- package/dist/components/molecules/Checkbox/SelectableInputBase.d.mts +40 -0
- package/dist/components/molecules/Checkbox/SelectableInputBase.mjs +99 -0
- package/dist/components/molecules/Checkbox/SelectableInputBase.mjs.map +1 -0
- package/dist/components/molecules/Checkbox/index.d.mts +3 -0
- package/dist/components/molecules/ChipGroup/ChipGroup.d.mts +7 -0
- package/dist/components/molecules/ChipGroup/ChipGroup.mjs +54 -0
- package/dist/components/molecules/ChipGroup/ChipGroup.mjs.map +1 -0
- package/dist/components/molecules/ChipGroup/index.d.mts +1 -0
- package/dist/components/molecules/CodeBlock/CodeBlock.d.mts +46 -0
- package/dist/components/molecules/CodeBlock/CodeBlock.mjs +231 -0
- package/dist/components/molecules/CodeBlock/CodeBlock.mjs.map +1 -0
- package/dist/components/molecules/CodeBlock/index.d.mts +1 -0
- package/dist/components/molecules/DateGroup/DateGroup.d.mts +37 -0
- package/dist/components/molecules/DateGroup/DateGroup.mjs +104 -0
- package/dist/components/molecules/DateGroup/DateGroup.mjs.map +1 -0
- package/dist/components/molecules/DateGroup/index.d.mts +2 -0
- package/dist/components/molecules/Dropdown/Dropdown.d.mts +27 -0
- package/dist/components/molecules/Dropdown/Dropdown.mjs +282 -0
- package/dist/components/molecules/Dropdown/Dropdown.mjs.map +1 -0
- package/dist/components/molecules/Dropdown/index.d.mts +1 -0
- package/dist/components/molecules/EmptyState/EmptyState.d.mts +32 -0
- package/dist/components/molecules/EmptyState/EmptyState.mjs +133 -0
- package/dist/components/molecules/EmptyState/EmptyState.mjs.map +1 -0
- package/dist/components/molecules/EmptyState/index.d.mts +2 -0
- package/dist/components/molecules/FeatureBlock/FeatureBlock.d.mts +14 -0
- package/dist/components/molecules/FeatureBlock/FeatureBlock.mjs +99 -0
- package/dist/components/molecules/FeatureBlock/FeatureBlock.mjs.map +1 -0
- package/dist/components/molecules/FeatureBlock/index.d.mts +1 -0
- package/dist/components/molecules/InlineAlert/InlineAlert.d.mts +54 -0
- package/dist/components/molecules/InlineAlert/InlineAlert.mjs +140 -0
- package/dist/components/molecules/InlineAlert/InlineAlert.mjs.map +1 -0
- package/dist/components/molecules/InlineAlert/index.d.mts +2 -0
- package/dist/components/molecules/List/List.d.mts +30 -0
- package/dist/components/molecules/List/List.mjs +45 -0
- package/dist/components/molecules/List/List.mjs.map +1 -0
- package/dist/components/molecules/List/ListContext.d.mts +6 -0
- package/dist/components/molecules/List/ListContext.mjs +11 -0
- package/dist/components/molecules/List/ListContext.mjs.map +1 -0
- package/dist/components/molecules/List/ListItem.d.mts +101 -0
- package/dist/components/molecules/List/ListItem.mjs +224 -0
- package/dist/components/molecules/List/ListItem.mjs.map +1 -0
- package/dist/components/molecules/List/index.d.mts +4 -0
- package/dist/components/molecules/Modal/Modal.d.mts +69 -0
- package/dist/components/molecules/Modal/Modal.mjs +259 -0
- package/dist/components/molecules/Modal/Modal.mjs.map +1 -0
- package/dist/components/molecules/Modal/index.d.mts +2 -0
- package/dist/components/molecules/NumberInput/NumberInput.d.mts +86 -0
- package/dist/components/molecules/NumberInput/NumberInput.mjs +268 -0
- package/dist/components/molecules/NumberInput/NumberInput.mjs.map +1 -0
- package/dist/components/molecules/NumberInput/index.d.mts +2 -0
- package/dist/components/molecules/PageTitle/PageTitle.d.mts +21 -0
- package/dist/components/molecules/PageTitle/PageTitle.mjs +77 -0
- package/dist/components/molecules/PageTitle/PageTitle.mjs.map +1 -0
- package/dist/components/molecules/PageTitle/index.d.mts +1 -0
- package/dist/components/molecules/PasswordField/PasswordField.d.mts +55 -0
- package/dist/components/molecules/PasswordField/PasswordField.mjs +146 -0
- package/dist/components/molecules/PasswordField/PasswordField.mjs.map +1 -0
- package/dist/components/molecules/PasswordField/index.d.mts +2 -0
- package/dist/components/molecules/SearchField/SearchField.d.mts +108 -0
- package/dist/components/molecules/SearchField/SearchField.mjs +340 -0
- package/dist/components/molecules/SearchField/SearchField.mjs.map +1 -0
- package/dist/components/molecules/SearchField/index.d.mts +2 -0
- package/dist/components/molecules/Sheet/Sheet.d.mts +96 -0
- package/dist/components/molecules/Sheet/Sheet.mjs +243 -0
- package/dist/components/molecules/Sheet/Sheet.mjs.map +1 -0
- package/dist/components/molecules/Sheet/index.d.mts +2 -0
- package/dist/components/molecules/Slider/Slider.d.mts +102 -0
- package/dist/components/molecules/Slider/Slider.mjs +462 -0
- package/dist/components/molecules/Slider/Slider.mjs.map +1 -0
- package/dist/components/molecules/Slider/index.d.mts +2 -0
- package/dist/components/molecules/TabBar/TabBar.d.mts +82 -0
- package/dist/components/molecules/TabBar/TabBar.mjs +213 -0
- package/dist/components/molecules/TabBar/TabBar.mjs.map +1 -0
- package/dist/components/molecules/TabBar/index.d.mts +2 -0
- package/dist/components/molecules/TextField/InputBase.d.mts +22 -0
- package/dist/components/molecules/TextField/InputBase.mjs +56 -0
- package/dist/components/molecules/TextField/InputBase.mjs.map +1 -0
- package/dist/components/molecules/TextField/TextField.d.mts +56 -0
- package/dist/components/molecules/TextField/TextField.mjs +115 -0
- package/dist/components/molecules/TextField/TextField.mjs.map +1 -0
- package/dist/components/molecules/TextField/index.d.mts +4 -0
- package/dist/components/molecules/TransactionListItem/TransactionListItem.d.mts +39 -0
- package/dist/components/molecules/TransactionListItem/TransactionListItem.mjs +224 -0
- package/dist/components/molecules/TransactionListItem/TransactionListItem.mjs.map +1 -0
- package/dist/components/molecules/TransactionListItem/index.d.mts +2 -0
- package/dist/components/molecules/index.d.mts +26 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +55 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/cssTokens.d.mts +14 -0
- package/dist/lib/cssTokens.mjs +19 -0
- package/dist/lib/cssTokens.mjs.map +1 -0
- package/dist/lib/cssVariables.d.mts +15 -0
- package/dist/lib/cssVariables.mjs +37 -0
- package/dist/lib/cssVariables.mjs.map +1 -0
- package/dist/lib/styleUtils.d.mts +42 -0
- package/dist/lib/styleUtils.mjs +160 -0
- package/dist/lib/styleUtils.mjs.map +1 -0
- package/dist/lib/tokenAliases.d.mts +13 -0
- package/dist/lib/tokenAliases.mjs +121 -0
- package/dist/lib/tokenAliases.mjs.map +1 -0
- package/dist/lib/usePresence.d.mts +16 -0
- package/dist/lib/usePresence.mjs +50 -0
- package/dist/lib/usePresence.mjs.map +1 -0
- package/dist/{data.esm.js → styles/icons.json.mjs} +2 -1466
- package/dist/styles/icons.json.mjs.map +1 -0
- package/dist/styles/tokens.d.mts +3174 -0
- package/dist/styles/tokens.json.mjs +1454 -0
- package/dist/{tokens/index.esm.js.map → styles/tokens.json.mjs.map} +1 -1
- package/dist/tokens/{index.esm.js → index.mjs} +1 -1
- package/dist/tokens/index.mjs.map +1 -0
- package/dist/tokens/styles/tokens.d.mts +3174 -0
- package/dist/tokens/tokens.d.mts +4 -0
- package/dist/tokens/types/tokens.d.mts +6 -0
- package/dist/tokens.css.d.mts +4 -0
- package/dist/types/icons.d.mts +25 -0
- package/dist/types/icons.mjs +10 -0
- package/dist/types/icons.mjs.map +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/tokens.d.mts +6 -0
- package/dist/types/tokens.mjs +10 -0
- package/dist/types/tokens.mjs.map +1 -0
- package/dist/vendor/tslib/tslib.es6.mjs +99 -0
- package/dist/vendor/tslib/tslib.es6.mjs.map +1 -0
- package/package.json +26 -12
- package/dist/client.esm.js +0 -8289
- package/dist/client.esm.js.map +0 -1
- package/dist/data.esm.js.map +0 -1
- package/dist/index.esm.js +0 -8
- package/dist/index.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentInput.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type AgentInputSubmitSource = 'text' | 'voice-final';
|
|
2
|
+
export type AgentInputVoiceErrorCode = 'not-supported' | 'not-allowed' | 'no-speech' | 'audio-capture' | 'aborted' | 'unknown';
|
|
3
|
+
export interface AgentInputVoiceError {
|
|
4
|
+
code: AgentInputVoiceErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SpeechRecognitionAlternativeLike {
|
|
8
|
+
transcript: string;
|
|
9
|
+
confidence: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SpeechRecognitionResultLike {
|
|
12
|
+
isFinal: boolean;
|
|
13
|
+
length: number;
|
|
14
|
+
[index: number]: SpeechRecognitionAlternativeLike;
|
|
15
|
+
}
|
|
16
|
+
export interface SpeechRecognitionResultListLike {
|
|
17
|
+
length: number;
|
|
18
|
+
[index: number]: SpeechRecognitionResultLike;
|
|
19
|
+
}
|
|
20
|
+
export interface SpeechRecognitionEventLike {
|
|
21
|
+
resultIndex: number;
|
|
22
|
+
results: SpeechRecognitionResultListLike;
|
|
23
|
+
}
|
|
24
|
+
export interface SpeechRecognitionErrorEventLike {
|
|
25
|
+
error?: string;
|
|
26
|
+
message?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SpeechRecognitionLike {
|
|
29
|
+
lang: string;
|
|
30
|
+
interimResults: boolean;
|
|
31
|
+
continuous: boolean;
|
|
32
|
+
onresult: ((event: SpeechRecognitionEventLike) => void) | null;
|
|
33
|
+
onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;
|
|
34
|
+
onend: (() => void) | null;
|
|
35
|
+
start: () => void;
|
|
36
|
+
stop: () => void;
|
|
37
|
+
abort: () => void;
|
|
38
|
+
}
|
|
39
|
+
export type SpeechRecognitionConstructorLike = new () => SpeechRecognitionLike;
|
|
40
|
+
export declare function detectSpeechRecognitionConstructor(targetWindow?: Window): SpeechRecognitionConstructorLike | null;
|
|
41
|
+
export declare function normalizeTranscript(input: string): string;
|
|
42
|
+
export declare function mapSpeechErrorCode(error?: string): AgentInputVoiceErrorCode;
|
|
43
|
+
export declare function defaultVoiceErrorMessage(code: AgentInputVoiceErrorCode): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
function detectSpeechRecognitionConstructor(targetWindow) {
|
|
3
|
+
if (!targetWindow) return null;
|
|
4
|
+
var candidateWindow = targetWindow;
|
|
5
|
+
if (candidateWindow.SpeechRecognition) {
|
|
6
|
+
return candidateWindow.SpeechRecognition;
|
|
7
|
+
}
|
|
8
|
+
if (candidateWindow.webkitSpeechRecognition) {
|
|
9
|
+
return candidateWindow.webkitSpeechRecognition;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function normalizeTranscript(input) {
|
|
14
|
+
return input.replace(/\s+/g, ' ').trim();
|
|
15
|
+
}
|
|
16
|
+
function mapSpeechErrorCode(error) {
|
|
17
|
+
switch (error) {
|
|
18
|
+
case 'not-allowed':
|
|
19
|
+
case 'service-not-allowed':
|
|
20
|
+
return 'not-allowed';
|
|
21
|
+
case 'no-speech':
|
|
22
|
+
return 'no-speech';
|
|
23
|
+
case 'audio-capture':
|
|
24
|
+
return 'audio-capture';
|
|
25
|
+
case 'aborted':
|
|
26
|
+
return 'aborted';
|
|
27
|
+
default:
|
|
28
|
+
return 'unknown';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function defaultVoiceErrorMessage(code) {
|
|
32
|
+
switch (code) {
|
|
33
|
+
case 'not-supported':
|
|
34
|
+
return 'Voice input is not supported in this browser. Use Chrome or Edge.';
|
|
35
|
+
case 'not-allowed':
|
|
36
|
+
return 'Microphone permission denied. Allow access and try again.';
|
|
37
|
+
case 'no-speech':
|
|
38
|
+
return 'No speech detected. Try again.';
|
|
39
|
+
case 'audio-capture':
|
|
40
|
+
return 'No microphone device detected. Check your microphone and try again.';
|
|
41
|
+
case 'aborted':
|
|
42
|
+
return 'Voice input was stopped.';
|
|
43
|
+
default:
|
|
44
|
+
return 'Voice input failed. Try again.';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { defaultVoiceErrorMessage, detectSpeechRecognitionConstructor, mapSpeechErrorCode, normalizeTranscript };
|
|
49
|
+
//# sourceMappingURL=agentInputSpeech.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentInputSpeech.mjs","sources":["../../../../src/components/molecules/AgentInput/agentInputSpeech.ts"],"sourcesContent":["export type AgentInputSubmitSource = 'text' | 'voice-final'\n\nexport type AgentInputVoiceErrorCode =\n | 'not-supported'\n | 'not-allowed'\n | 'no-speech'\n | 'audio-capture'\n | 'aborted'\n | 'unknown'\n\nexport interface AgentInputVoiceError {\n code: AgentInputVoiceErrorCode\n message: string\n}\n\nexport interface SpeechRecognitionAlternativeLike {\n transcript: string\n confidence: number\n}\n\nexport interface SpeechRecognitionResultLike {\n isFinal: boolean\n length: number\n [index: number]: SpeechRecognitionAlternativeLike\n}\n\nexport interface SpeechRecognitionResultListLike {\n length: number\n [index: number]: SpeechRecognitionResultLike\n}\n\nexport interface SpeechRecognitionEventLike {\n resultIndex: number\n results: SpeechRecognitionResultListLike\n}\n\nexport interface SpeechRecognitionErrorEventLike {\n error?: string\n message?: string\n}\n\nexport interface SpeechRecognitionLike {\n lang: string\n interimResults: boolean\n continuous: boolean\n onresult: ((event: SpeechRecognitionEventLike) => void) | null\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null\n onend: (() => void) | null\n start: () => void\n stop: () => void\n abort: () => void\n}\n\nexport type SpeechRecognitionConstructorLike = new () => SpeechRecognitionLike\n\ntype BrowserWindowWithSpeech = Window & {\n SpeechRecognition?: SpeechRecognitionConstructorLike\n webkitSpeechRecognition?: SpeechRecognitionConstructorLike\n}\n\nexport function detectSpeechRecognitionConstructor(\n targetWindow?: Window\n): SpeechRecognitionConstructorLike | null {\n if (!targetWindow) return null\n\n const candidateWindow = targetWindow as BrowserWindowWithSpeech\n if (candidateWindow.SpeechRecognition) {\n return candidateWindow.SpeechRecognition\n }\n\n if (candidateWindow.webkitSpeechRecognition) {\n return candidateWindow.webkitSpeechRecognition\n }\n\n return null\n}\n\nexport function normalizeTranscript(input: string): string {\n return input.replace(/\\s+/g, ' ').trim()\n}\n\nexport function mapSpeechErrorCode(error?: string): AgentInputVoiceErrorCode {\n switch (error) {\n case 'not-allowed':\n case 'service-not-allowed':\n return 'not-allowed'\n case 'no-speech':\n return 'no-speech'\n case 'audio-capture':\n return 'audio-capture'\n case 'aborted':\n return 'aborted'\n default:\n return 'unknown'\n }\n}\n\nexport function defaultVoiceErrorMessage(code: AgentInputVoiceErrorCode): string {\n switch (code) {\n case 'not-supported':\n return 'Voice input is not supported in this browser. Use Chrome or Edge.'\n case 'not-allowed':\n return 'Microphone permission denied. Allow access and try again.'\n case 'no-speech':\n return 'No speech detected. Try again.'\n case 'audio-capture':\n return 'No microphone device detected. Check your microphone and try again.'\n case 'aborted':\n return 'Voice input was stopped.'\n default:\n return 'Voice input failed. Try again.'\n }\n}\n"],"names":["detectSpeechRecognitionConstructor","targetWindow","candidateWindow","SpeechRecognition","webkitSpeechRecognition","normalizeTranscript","input","replace","trim","mapSpeechErrorCode","error","defaultVoiceErrorMessage","code"],"mappings":";AA4DM,SAAUA,kCAAkCA,CAChDC,YAAqB,EAAA;AAErB,EAAA,IAAI,CAACA,YAAY,EAAE,OAAO,IAAI,CAAA;EAE9B,IAAMC,eAAe,GAAGD,YAAuC,CAAA;EAC/D,IAAIC,eAAe,CAACC,iBAAiB,EAAE;IACrC,OAAOD,eAAe,CAACC,iBAAiB,CAAA;AAC1C,GAAA;EAEA,IAAID,eAAe,CAACE,uBAAuB,EAAE;IAC3C,OAAOF,eAAe,CAACE,uBAAuB,CAAA;AAChD,GAAA;AAEA,EAAA,OAAO,IAAI,CAAA;AACb,CAAA;AAEM,SAAUC,mBAAmBA,CAACC,KAAa,EAAA;EAC/C,OAAOA,KAAK,CAACC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAACC,IAAI,EAAE,CAAA;AAC1C,CAAA;AAEM,SAAUC,kBAAkBA,CAACC,KAAc,EAAA;AAC/C,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa,CAAA;AAClB,IAAA,KAAK,qBAAqB;AACxB,MAAA,OAAO,aAAa,CAAA;AACtB,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,WAAW,CAAA;AACpB,IAAA,KAAK,eAAe;AAClB,MAAA,OAAO,eAAe,CAAA;AACxB,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,SAAS,CAAA;AAClB,IAAA;AACE,MAAA,OAAO,SAAS,CAAA;AACpB,GAAA;AACF,CAAA;AAEM,SAAUC,wBAAwBA,CAACC,IAA8B,EAAA;AACrE,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,eAAe;AAClB,MAAA,OAAO,mEAAmE,CAAA;AAC5E,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,2DAA2D,CAAA;AACpE,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,gCAAgC,CAAA;AACzC,IAAA,KAAK,eAAe;AAClB,MAAA,OAAO,qEAAqE,CAAA;AAC9E,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,0BAA0B,CAAA;AACnC,IAAA;AACE,MAAA,OAAO,gCAAgC,CAAA;AAC3C,GAAA;AACF;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type AgentInputMachineState = 'idle' | 'typing' | 'listening' | 'processingFinalTranscript' | 'submitting' | 'error' | 'disabled';
|
|
2
|
+
export type AgentInputMachineEvent = {
|
|
3
|
+
type: 'INPUT_CHANGE';
|
|
4
|
+
hasText: boolean;
|
|
5
|
+
} | {
|
|
6
|
+
type: 'MIC_START';
|
|
7
|
+
} | {
|
|
8
|
+
type: 'MIC_STOP';
|
|
9
|
+
hasText: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'VOICE_INTERIM';
|
|
12
|
+
} | {
|
|
13
|
+
type: 'VOICE_FINAL';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'VOICE_ERROR';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'TIMEOUT_NO_SPEECH';
|
|
18
|
+
} | {
|
|
19
|
+
type: 'SUBMIT';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'SUBMIT_SUCCESS';
|
|
22
|
+
hasText?: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'SUBMIT_ERROR';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'RESET_ERROR';
|
|
27
|
+
hasText: boolean;
|
|
28
|
+
};
|
|
29
|
+
export declare function agentInputStateTransition(currentState: AgentInputMachineState, event: AgentInputMachineEvent): AgentInputMachineState;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var textDrivenState = function textDrivenState(hasText) {
|
|
3
|
+
return hasText ? 'typing' : 'idle';
|
|
4
|
+
};
|
|
5
|
+
function agentInputStateTransition(currentState, event) {
|
|
6
|
+
if (currentState === 'disabled') {
|
|
7
|
+
return 'disabled';
|
|
8
|
+
}
|
|
9
|
+
switch (event.type) {
|
|
10
|
+
case 'INPUT_CHANGE':
|
|
11
|
+
if (currentState === 'listening' || currentState === 'processingFinalTranscript' || currentState === 'submitting') {
|
|
12
|
+
return currentState;
|
|
13
|
+
}
|
|
14
|
+
return textDrivenState(event.hasText);
|
|
15
|
+
case 'MIC_START':
|
|
16
|
+
if (currentState === 'idle' || currentState === 'typing') {
|
|
17
|
+
return 'listening';
|
|
18
|
+
}
|
|
19
|
+
return currentState;
|
|
20
|
+
case 'VOICE_INTERIM':
|
|
21
|
+
if (currentState === 'listening') {
|
|
22
|
+
return 'listening';
|
|
23
|
+
}
|
|
24
|
+
return currentState;
|
|
25
|
+
case 'VOICE_FINAL':
|
|
26
|
+
if (currentState === 'listening') {
|
|
27
|
+
return 'processingFinalTranscript';
|
|
28
|
+
}
|
|
29
|
+
return currentState;
|
|
30
|
+
case 'MIC_STOP':
|
|
31
|
+
if (currentState === 'listening' || currentState === 'processingFinalTranscript') {
|
|
32
|
+
return textDrivenState(event.hasText);
|
|
33
|
+
}
|
|
34
|
+
return currentState;
|
|
35
|
+
case 'SUBMIT':
|
|
36
|
+
return 'submitting';
|
|
37
|
+
case 'SUBMIT_SUCCESS':
|
|
38
|
+
return 'idle';
|
|
39
|
+
case 'SUBMIT_ERROR':
|
|
40
|
+
return 'error';
|
|
41
|
+
case 'VOICE_ERROR':
|
|
42
|
+
case 'TIMEOUT_NO_SPEECH':
|
|
43
|
+
return 'error';
|
|
44
|
+
case 'RESET_ERROR':
|
|
45
|
+
if (currentState === 'error') {
|
|
46
|
+
return textDrivenState(event.hasText);
|
|
47
|
+
}
|
|
48
|
+
return currentState;
|
|
49
|
+
default:
|
|
50
|
+
return currentState;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { agentInputStateTransition };
|
|
55
|
+
//# sourceMappingURL=agentInputStateMachine.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentInputStateMachine.mjs","sources":["../../../../src/components/molecules/AgentInput/agentInputStateMachine.ts"],"sourcesContent":["export type AgentInputMachineState =\n | 'idle'\n | 'typing'\n | 'listening'\n | 'processingFinalTranscript'\n | 'submitting'\n | 'error'\n | 'disabled'\n\nexport type AgentInputMachineEvent =\n | { type: 'INPUT_CHANGE'; hasText: boolean }\n | { type: 'MIC_START' }\n | { type: 'MIC_STOP'; hasText: boolean }\n | { type: 'VOICE_INTERIM' }\n | { type: 'VOICE_FINAL' }\n | { type: 'VOICE_ERROR' }\n | { type: 'TIMEOUT_NO_SPEECH' }\n | { type: 'SUBMIT' }\n | { type: 'SUBMIT_SUCCESS'; hasText?: boolean }\n | { type: 'SUBMIT_ERROR' }\n | { type: 'RESET_ERROR'; hasText: boolean }\n\nconst textDrivenState = (hasText: boolean): AgentInputMachineState => (hasText ? 'typing' : 'idle')\n\nexport function agentInputStateTransition(\n currentState: AgentInputMachineState,\n event: AgentInputMachineEvent\n): AgentInputMachineState {\n if (currentState === 'disabled') {\n return 'disabled'\n }\n\n switch (event.type) {\n case 'INPUT_CHANGE':\n if (currentState === 'listening' || currentState === 'processingFinalTranscript' || currentState === 'submitting') {\n return currentState\n }\n return textDrivenState(event.hasText)\n\n case 'MIC_START':\n if (currentState === 'idle' || currentState === 'typing') {\n return 'listening'\n }\n return currentState\n\n case 'VOICE_INTERIM':\n if (currentState === 'listening') {\n return 'listening'\n }\n return currentState\n\n case 'VOICE_FINAL':\n if (currentState === 'listening') {\n return 'processingFinalTranscript'\n }\n return currentState\n\n case 'MIC_STOP':\n if (currentState === 'listening' || currentState === 'processingFinalTranscript') {\n return textDrivenState(event.hasText)\n }\n return currentState\n\n case 'SUBMIT':\n return 'submitting'\n\n case 'SUBMIT_SUCCESS':\n return 'idle'\n\n case 'SUBMIT_ERROR':\n return 'error'\n\n case 'VOICE_ERROR':\n case 'TIMEOUT_NO_SPEECH':\n return 'error'\n\n case 'RESET_ERROR':\n if (currentState === 'error') {\n return textDrivenState(event.hasText)\n }\n return currentState\n\n default:\n return currentState\n }\n}\n"],"names":["textDrivenState","hasText","agentInputStateTransition","currentState","event","type"],"mappings":";AAsBA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,OAAgB,EAA6B;AAAA,EAAA,OAACA,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAA5B,CAA6B,CAAA;AAEnF,SAAAC,yBAAyBA,CACvCC,YAAoC,EACpCC,KAA6B,EAAA;EAE7B,IAAID,YAAY,KAAK,UAAU,EAAE;AAC/B,IAAA,OAAO,UAAU,CAAA;AACnB,GAAA;EAEA,QAAQC,KAAK,CAACC,IAAI;AAChB,IAAA,KAAK,cAAc;MACjB,IAAIF,YAAY,KAAK,WAAW,IAAIA,YAAY,KAAK,2BAA2B,IAAIA,YAAY,KAAK,YAAY,EAAE;AACjH,QAAA,OAAOA,YAAY,CAAA;AACrB,OAAA;AACA,MAAA,OAAOH,eAAe,CAACI,KAAK,CAACH,OAAO,CAAC,CAAA;AAEvC,IAAA,KAAK,WAAW;AACd,MAAA,IAAIE,YAAY,KAAK,MAAM,IAAIA,YAAY,KAAK,QAAQ,EAAE;AACxD,QAAA,OAAO,WAAW,CAAA;AACpB,OAAA;AACA,MAAA,OAAOA,YAAY,CAAA;AAErB,IAAA,KAAK,eAAe;MAClB,IAAIA,YAAY,KAAK,WAAW,EAAE;AAChC,QAAA,OAAO,WAAW,CAAA;AACpB,OAAA;AACA,MAAA,OAAOA,YAAY,CAAA;AAErB,IAAA,KAAK,aAAa;MAChB,IAAIA,YAAY,KAAK,WAAW,EAAE;AAChC,QAAA,OAAO,2BAA2B,CAAA;AACpC,OAAA;AACA,MAAA,OAAOA,YAAY,CAAA;AAErB,IAAA,KAAK,UAAU;AACb,MAAA,IAAIA,YAAY,KAAK,WAAW,IAAIA,YAAY,KAAK,2BAA2B,EAAE;AAChF,QAAA,OAAOH,eAAe,CAACI,KAAK,CAACH,OAAO,CAAC,CAAA;AACvC,OAAA;AACA,MAAA,OAAOE,YAAY,CAAA;AAErB,IAAA,KAAK,QAAQ;AACX,MAAA,OAAO,YAAY,CAAA;AAErB,IAAA,KAAK,gBAAgB;AACnB,MAAA,OAAO,MAAM,CAAA;AAEf,IAAA,KAAK,cAAc;AACjB,MAAA,OAAO,OAAO,CAAA;AAEhB,IAAA,KAAK,aAAa,CAAA;AAClB,IAAA,KAAK,mBAAmB;AACtB,MAAA,OAAO,OAAO,CAAA;AAEhB,IAAA,KAAK,aAAa;MAChB,IAAIA,YAAY,KAAK,OAAO,EAAE;AAC5B,QAAA,OAAOH,eAAe,CAACI,KAAK,CAACH,OAAO,CAAC,CAAA;AACvC,OAAA;AACA,MAAA,OAAOE,YAAY,CAAA;AAErB,IAAA;AACE,MAAA,OAAOA,YAAY,CAAA;AACvB,GAAA;AACF;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface AlertProps {
|
|
3
|
+
/**
|
|
4
|
+
* Visual style variant affecting background, border, and icon colors
|
|
5
|
+
* - error: Critical issues, validation errors (crossCircle icon)
|
|
6
|
+
* - warning: Cautions, potential issues (bell icon)
|
|
7
|
+
* - info: Tips, helper text, neutral information (info icon)
|
|
8
|
+
* - success: Confirmations, successful operations (checkRing icon)
|
|
9
|
+
* @default 'info'
|
|
10
|
+
*/
|
|
11
|
+
variant?: 'error' | 'warning' | 'info' | 'success';
|
|
12
|
+
/**
|
|
13
|
+
* Whether the severity border is drawn (decision 0019)
|
|
14
|
+
* - outlined: severity tint and a 1px severity border. Only for alerts at the top: a
|
|
15
|
+
* page-level alert at the top of the page, an alert at the top of the content area, and an
|
|
16
|
+
* error summary
|
|
17
|
+
* - borderless: severity tint only. Every other alert, including alerts inside content and at
|
|
18
|
+
* the bottom of a page; the icon and title colour carry the severity
|
|
19
|
+
* @default 'outlined'
|
|
20
|
+
*/
|
|
21
|
+
appearance?: 'outlined' | 'borderless';
|
|
22
|
+
/**
|
|
23
|
+
* Alert message content
|
|
24
|
+
*/
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Optional title/heading for the alert
|
|
28
|
+
*/
|
|
29
|
+
title?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Show close/dismiss button
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
dismissible?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Callback function when alert is dismissed. Called once the dismiss animation has
|
|
37
|
+
* finished and the alert has been removed.
|
|
38
|
+
*/
|
|
39
|
+
onDismiss?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Optional action button or component, placed below the message and left-aligned with it
|
|
42
|
+
*/
|
|
43
|
+
action?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Compact inline variant with reduced padding
|
|
46
|
+
* @default false
|
|
47
|
+
* @deprecated Use `InlineAlert` for a short, local message (decision 0019). `inline` keeps
|
|
48
|
+
* working until it is removed in 3.0. An inline alert that needs a title, action or dismiss
|
|
49
|
+
* button stays an Alert.
|
|
50
|
+
*/
|
|
51
|
+
inline?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* ARIA live region behavior
|
|
54
|
+
* - polite: Non-urgent announcements
|
|
55
|
+
* - assertive: Important, time-sensitive information
|
|
56
|
+
* - off: Not announced
|
|
57
|
+
* @default 'polite'
|
|
58
|
+
*/
|
|
59
|
+
ariaLive?: 'polite' | 'assertive' | 'off';
|
|
60
|
+
/**
|
|
61
|
+
* Test identifier for automated testing
|
|
62
|
+
*/
|
|
63
|
+
'data-testid'?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare const Alert: {
|
|
66
|
+
({ variant, appearance, children, title, dismissible, onDismiss, action, inline, ariaLive, "data-testid": dataTestId, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element | null;
|
|
67
|
+
displayName: string;
|
|
68
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { __makeTemplateObject, __rest, __assign } from '../../../vendor/tslib/tslib.es6.mjs';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import styled$module, { keyframes, css } from 'styled-components';
|
|
6
|
+
const styled = styled$module.default || styled$module;
|
|
7
|
+
import tokens from '../../../lib/cssTokens.mjs';
|
|
8
|
+
import tokensJson from '../../../styles/tokens.json.mjs';
|
|
9
|
+
import { Icon } from '../../atoms/Icon/Icon.mjs';
|
|
10
|
+
import { IconButton } from '../../atoms/IconButton/IconButton.mjs';
|
|
11
|
+
import { useInert } from '../../../lib/usePresence.mjs';
|
|
12
|
+
|
|
13
|
+
var semantic = tokens.semantic;
|
|
14
|
+
var alert = tokens.component.alert;
|
|
15
|
+
var _a = semantic.motion,
|
|
16
|
+
duration = _a.duration,
|
|
17
|
+
easing = _a.easing;
|
|
18
|
+
// Dismissing fades the alert out, then collapses the space it took (Ollie's call, #35).
|
|
19
|
+
// Each half takes duration.fast, so the whole exit stays within the 300ms maximum (P6). The timer
|
|
20
|
+
// needs the resolved value, not the CSS variable (decision 0041).
|
|
21
|
+
var FADE_MS = parseInt(tokensJson.semantic.motion.duration.fast, 10);
|
|
22
|
+
var EXIT_MS = FADE_MS * 2;
|
|
23
|
+
// The --alert-exit-* properties are the alert's height and vertical padding, measured
|
|
24
|
+
// when it's dismissed, so nothing moves until the fade has finished
|
|
25
|
+
var fadeThenCollapse = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0%, 50% {\n max-height: var(--alert-exit-height);\n padding-top: var(--alert-exit-padding-top);\n padding-bottom: var(--alert-exit-padding-bottom);\n border-width: ", ";\n }\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n }\n 100% {\n opacity: 0;\n max-height: 0;\n padding-top: 0;\n padding-bottom: 0;\n border-width: 0;\n }\n"], ["\n 0%, 50% {\n max-height: var(--alert-exit-height);\n padding-top: var(--alert-exit-padding-top);\n padding-bottom: var(--alert-exit-padding-bottom);\n border-width: ", ";\n }\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n }\n 100% {\n opacity: 0;\n max-height: 0;\n padding-top: 0;\n padding-bottom: 0;\n border-width: 0;\n }\n"])), semantic.border.width.thin);
|
|
26
|
+
var fadeOut = keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n from { opacity: 1; }\n to { opacity: 0; }\n"], ["\n from { opacity: 1; }\n to { opacity: 0; }\n"
|
|
27
|
+
// The exit ends on the alert's own animationend: 300ms, or 150ms under reduced motion
|
|
28
|
+
// (chosen when dismissed). A timer of the same length removes it if no animation event
|
|
29
|
+
// arrives, for example where animations are disabled or the tab is hidden.
|
|
30
|
+
// The generated names of the two exits (full, and reduced motion)
|
|
31
|
+
])));
|
|
32
|
+
// The exit ends on the alert's own animationend: 300ms, or 150ms under reduced motion
|
|
33
|
+
// (chosen when dismissed). A timer of the same length removes it if no animation event
|
|
34
|
+
// arrives, for example where animations are disabled or the tab is hidden.
|
|
35
|
+
// The generated names of the two exits (full, and reduced motion)
|
|
36
|
+
var EXIT_ANIMATION_NAMES = [fadeThenCollapse.getName(), fadeOut.getName()];
|
|
37
|
+
// Default icons by variant
|
|
38
|
+
var variantIcons = {
|
|
39
|
+
error: 'crossCircle',
|
|
40
|
+
warning: 'bell',
|
|
41
|
+
info: 'info',
|
|
42
|
+
success: 'checkRing'
|
|
43
|
+
};
|
|
44
|
+
// Icon colors by variant (using semantic icon color tokens)
|
|
45
|
+
var variantIconColors = {
|
|
46
|
+
error: 'error',
|
|
47
|
+
warning: 'warning',
|
|
48
|
+
info: 'interactive',
|
|
49
|
+
success: 'success'
|
|
50
|
+
};
|
|
51
|
+
// Title colors by variant (using semantic text color tokens)
|
|
52
|
+
var variantTitleColors = {
|
|
53
|
+
error: 'error',
|
|
54
|
+
warning: 'warning',
|
|
55
|
+
info: 'interactive',
|
|
56
|
+
success: 'success'
|
|
57
|
+
};
|
|
58
|
+
var StyledAlert = /*#__PURE__*/styled.div.withConfig({
|
|
59
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
60
|
+
return !prop.startsWith('$');
|
|
61
|
+
},
|
|
62
|
+
displayName: "Alert__StyledAlert",
|
|
63
|
+
componentId: "sc-18tq5d-0"
|
|
64
|
+
})(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n /* Items start at the top, so the icon and dismiss button line up with the first line */\n align-items: flex-start;\n gap: ", ";\n padding: ", ";\n border-radius: ", ";\n border: ", " solid;\n position: relative;\n width: 100%;\n \n /* Severity \xD7 appearance colours from Alert's component tokens (decision 0019). Borderless\n keeps a transparent border, so both appearances take the same space. */\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n \n /* Responsive adjustments */\n @media (min-width: ", ") {\n padding: ", ";\n }\n\n /* The exit is chosen once, when dismissed (not by a media query), so a reduced-motion\n preference that changes mid-exit can't swap animations and flash the faded alert back.\n Reduced motion: fade only; the space closes instantly afterwards. */\n ", "\n"], ["\n display: flex;\n /* Items start at the top, so the icon and dismiss button line up with the first line */\n align-items: flex-start;\n gap: ", ";\n padding: ", ";\n border-radius: ", ";\n border: ", " solid;\n position: relative;\n width: 100%;\n \n /* Severity \xD7 appearance colours from Alert's component tokens (decision 0019). Borderless\n keeps a transparent border, so both appearances take the same space. */\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n \n /* Responsive adjustments */\n @media (min-width: ", ") {\n padding: ", ";\n }\n\n /* The exit is chosen once, when dismissed (not by a media query), so a reduced-motion\n preference that changes mid-exit can't swap animations and flash the faded alert back.\n Reduced motion: fade only; the space closes instantly afterwards. */\n ", "\n"])), function (_a) {
|
|
65
|
+
var $inline = _a.$inline;
|
|
66
|
+
return $inline ? semantic.space[200] : semantic.space[300];
|
|
67
|
+
}, function (_a) {
|
|
68
|
+
var $inline = _a.$inline;
|
|
69
|
+
return $inline ? semantic.space[200] : semantic.space[300];
|
|
70
|
+
}, semantic.radius.sm, semantic.border.width.thin, function (_a) {
|
|
71
|
+
var _b = _a.$variant,
|
|
72
|
+
$variant = _b === void 0 ? 'info' : _b;
|
|
73
|
+
return alert.severity[$variant].background;
|
|
74
|
+
}, function (_a) {
|
|
75
|
+
var _b = _a.$variant,
|
|
76
|
+
$variant = _b === void 0 ? 'info' : _b;
|
|
77
|
+
return alert.severity[$variant].text;
|
|
78
|
+
}, function (_a) {
|
|
79
|
+
var _b = _a.$variant,
|
|
80
|
+
$variant = _b === void 0 ? 'info' : _b,
|
|
81
|
+
$appearance = _a.$appearance;
|
|
82
|
+
return alert.appearance[$appearance].borderColor[$variant];
|
|
83
|
+
}, semantic.breakpoint.md, function (_a) {
|
|
84
|
+
var $inline = _a.$inline;
|
|
85
|
+
return $inline ? semantic.space[200] : semantic.space[400];
|
|
86
|
+
}, function (_a) {
|
|
87
|
+
var $isExiting = _a.$isExiting,
|
|
88
|
+
$reducedExit = _a.$reducedExit;
|
|
89
|
+
return $isExiting && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n overflow: hidden;\n pointer-events: none;\n animation: ", ";\n "], ["\n overflow: hidden;\n pointer-events: none;\n animation: ", ";\n "])), $reducedExit ? css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["", " ", " ", " forwards"], ["", " ", " ", " forwards"])), fadeOut, duration.fast, easing.accelerate) : css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["", " ", "ms ", " forwards"], ["", " ", "ms ", " forwards"])), fadeThenCollapse, EXIT_MS, easing.accelerate));
|
|
90
|
+
});
|
|
91
|
+
var StyledIconContainer = /*#__PURE__*/styled.div.withConfig({
|
|
92
|
+
displayName: "Alert__StyledIconContainer",
|
|
93
|
+
componentId: "sc-18tq5d-1"
|
|
94
|
+
})(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n flex-shrink: 0;\n"], ["\n display: flex;\n align-items: center;\n flex-shrink: 0;\n"])));
|
|
95
|
+
var StyledContent = /*#__PURE__*/styled.div.withConfig({
|
|
96
|
+
displayName: "Alert__StyledContent",
|
|
97
|
+
componentId: "sc-18tq5d-2"
|
|
98
|
+
})(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: ", ";\n min-width: 0; /* Allow text wrapping */\n"], ["\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: ", ";\n min-width: 0; /* Allow text wrapping */\n"])), semantic.space[100]);
|
|
99
|
+
var StyledTitle = /*#__PURE__*/styled.span.withConfig({
|
|
100
|
+
displayName: "Alert__StyledTitle",
|
|
101
|
+
componentId: "sc-18tq5d-3"
|
|
102
|
+
})(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n font: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin: 0;\n"], ["\n font: ", ";\n font-weight: ", ";\n line-height: ", ";\n margin: 0;\n"])), alert.title.typography, alert.title.fontWeight, alert.title.lineHeight);
|
|
103
|
+
var StyledMessage = /*#__PURE__*/styled.span.withConfig({
|
|
104
|
+
displayName: "Alert__StyledMessage",
|
|
105
|
+
componentId: "sc-18tq5d-4"
|
|
106
|
+
})(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n font: ", ";\n line-height: ", ";\n"], ["\n font: ", ";\n line-height: ", ";\n"
|
|
107
|
+
// The action follows the content, left-aligned with it, so it's read after the message
|
|
108
|
+
// (#122). With the content's xs gap, the space above it is md: a separate step.
|
|
109
|
+
])), alert.message.typography, alert.message.lineHeight);
|
|
110
|
+
// The action follows the content, left-aligned with it, so it's read after the message
|
|
111
|
+
// (#122). With the content's xs gap, the space above it is md: a separate step.
|
|
112
|
+
var StyledActions = /*#__PURE__*/styled.div.withConfig({
|
|
113
|
+
displayName: "Alert__StyledActions",
|
|
114
|
+
componentId: "sc-18tq5d-5"
|
|
115
|
+
})(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: ", ";\n margin-top: calc(", " - ", ");\n"], ["\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: ", ";\n margin-top: calc(", " - ", ");\n"
|
|
116
|
+
// The dismiss button's centre lines up with the first line of content: the title, or the
|
|
117
|
+
// message when there's no title (decision 0019). The slot is as tall as that line and the
|
|
118
|
+
// button is centred in it, overflowing evenly into the padding, so it stays aligned at every
|
|
119
|
+
// padding and line height. Being in the row, it also keeps text and actions from running under it.
|
|
120
|
+
])), semantic.space[200], semantic.space[300], semantic.space[100]);
|
|
121
|
+
// The dismiss button's centre lines up with the first line of content: the title, or the
|
|
122
|
+
// message when there's no title (decision 0019). The slot is as tall as that line and the
|
|
123
|
+
// button is centred in it, overflowing evenly into the padding, so it stays aligned at every
|
|
124
|
+
// padding and line height. Being in the row, it also keeps text and actions from running under it.
|
|
125
|
+
var StyledDismissSlot = /*#__PURE__*/styled.div.withConfig({
|
|
126
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
127
|
+
return !prop.startsWith('$');
|
|
128
|
+
},
|
|
129
|
+
displayName: "Alert__StyledDismissSlot",
|
|
130
|
+
componentId: "sc-18tq5d-6"
|
|
131
|
+
})(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n flex-shrink: 0;\n height: ", ";\n"], ["\n display: flex;\n align-items: center;\n flex-shrink: 0;\n height: ", ";\n"
|
|
132
|
+
// The glyph sits on the padding edge, mirroring the severity icon on the left. The inline
|
|
133
|
+
// alert's padding is too small for that, so its button stays inside the padding.
|
|
134
|
+
])), function (_a) {
|
|
135
|
+
var $lineHeight = _a.$lineHeight;
|
|
136
|
+
return $lineHeight;
|
|
137
|
+
});
|
|
138
|
+
// The glyph sits on the padding edge, mirroring the severity icon on the left. The inline
|
|
139
|
+
// alert's padding is too small for that, so its button stays inside the padding.
|
|
140
|
+
var StyledDismissButton = /*#__PURE__*/styled(IconButton).withConfig({
|
|
141
|
+
displayName: "Alert__StyledDismissButton",
|
|
142
|
+
componentId: "sc-18tq5d-7"
|
|
143
|
+
})(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n margin-right: ", ";\n"], ["\n margin-right: ", ";\n"])), function (_a) {
|
|
144
|
+
var $inline = _a.$inline;
|
|
145
|
+
return $inline ? 0 : "calc((".concat(semantic.size.control.sm, " - ").concat(semantic.size.icon.sm, ") / -2)");
|
|
146
|
+
});
|
|
147
|
+
var Alert = function Alert(_a) {
|
|
148
|
+
var _b = _a.variant,
|
|
149
|
+
variant = _b === void 0 ? 'info' : _b,
|
|
150
|
+
_c = _a.appearance,
|
|
151
|
+
appearance = _c === void 0 ? 'outlined' : _c,
|
|
152
|
+
children = _a.children,
|
|
153
|
+
title = _a.title,
|
|
154
|
+
_d = _a.dismissible,
|
|
155
|
+
dismissible = _d === void 0 ? false : _d,
|
|
156
|
+
onDismiss = _a.onDismiss,
|
|
157
|
+
action = _a.action,
|
|
158
|
+
_e = _a.inline,
|
|
159
|
+
inline = _e === void 0 ? false : _e,
|
|
160
|
+
_f = _a.ariaLive,
|
|
161
|
+
ariaLive = _f === void 0 ? 'polite' : _f,
|
|
162
|
+
dataTestId = _a["data-testid"],
|
|
163
|
+
props = __rest(_a, ["variant", "appearance", "children", "title", "dismissible", "onDismiss", "action", "inline", "ariaLive", 'data-testid']);
|
|
164
|
+
var _g = React.useState('visible'),
|
|
165
|
+
phase = _g[0],
|
|
166
|
+
setPhase = _g[1];
|
|
167
|
+
var _h = React.useState(false),
|
|
168
|
+
reducedExit = _h[0],
|
|
169
|
+
setReducedExit = _h[1];
|
|
170
|
+
var _j = React.useState(),
|
|
171
|
+
exitStyle = _j[0],
|
|
172
|
+
setExitStyle = _j[1];
|
|
173
|
+
var alertRef = React.useRef(null);
|
|
174
|
+
// While it exits, its controls leave the tab order and can't be activated
|
|
175
|
+
useInert(alertRef, phase === 'exiting');
|
|
176
|
+
var onDismissRef = React.useRef(onDismiss);
|
|
177
|
+
React.useEffect(function () {
|
|
178
|
+
onDismissRef.current = onDismiss;
|
|
179
|
+
}, [onDismiss]);
|
|
180
|
+
var handleDismiss = function handleDismiss() {
|
|
181
|
+
var node = alertRef.current;
|
|
182
|
+
if (node) {
|
|
183
|
+
var style = window.getComputedStyle(node);
|
|
184
|
+
var paddingTop = style.paddingTop,
|
|
185
|
+
paddingBottom = style.paddingBottom;
|
|
186
|
+
// max-height applies to the content box unless the alert is border-box (it depends on
|
|
187
|
+
// the consumer's reset), so measure whichever box it uses; nothing moves at the click
|
|
188
|
+
var height = Math.max(0, style.boxSizing === 'border-box' ? node.offsetHeight : node.offsetHeight - parseFloat(paddingTop) - parseFloat(paddingBottom) - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth));
|
|
189
|
+
setExitStyle({
|
|
190
|
+
'--alert-exit-height': "".concat(height, "px"),
|
|
191
|
+
'--alert-exit-padding-top': paddingTop,
|
|
192
|
+
'--alert-exit-padding-bottom': paddingBottom
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
setReducedExit(typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
|
|
196
|
+
setPhase('exiting');
|
|
197
|
+
};
|
|
198
|
+
React.useEffect(function () {
|
|
199
|
+
if (phase !== 'exiting') return;
|
|
200
|
+
var timer = setTimeout(function () {
|
|
201
|
+
return setPhase('dismissed');
|
|
202
|
+
}, reducedExit ? FADE_MS : EXIT_MS);
|
|
203
|
+
return function () {
|
|
204
|
+
return clearTimeout(timer);
|
|
205
|
+
};
|
|
206
|
+
}, [phase, reducedExit]);
|
|
207
|
+
// onDismiss fires once the alert has been removed from the DOM, so a consumer that
|
|
208
|
+
// unmounts it in onDismiss still gets the animation, and can't observe it
|
|
209
|
+
React.useEffect(function () {
|
|
210
|
+
var _a;
|
|
211
|
+
if (phase === 'dismissed') (_a = onDismissRef.current) === null || _a === void 0 ? void 0 : _a.call(onDismissRef);
|
|
212
|
+
}, [phase]);
|
|
213
|
+
if (phase === 'dismissed') {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
var isExiting = phase === 'exiting';
|
|
217
|
+
// Consumers can pass extra HTML attributes, including style, aria-hidden and onAnimationEnd
|
|
218
|
+
var forwarded = props;
|
|
219
|
+
var handleAnimationEnd = function handleAnimationEnd(event) {
|
|
220
|
+
var _a;
|
|
221
|
+
(_a = forwarded.onAnimationEnd) === null || _a === void 0 ? void 0 : _a.call(forwarded, event);
|
|
222
|
+
// Only the exit itself ends the dismissal: not animations bubbling up from children,
|
|
223
|
+
// on pseudo-elements, or other animations a consumer puts on the alert
|
|
224
|
+
if (isExiting && event.target === event.currentTarget && !event.pseudoElement && EXIT_ANIMATION_NAMES.includes(event.animationName)) {
|
|
225
|
+
setPhase('dismissed');
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
// Get the icon for the current variant
|
|
229
|
+
var iconName = variantIcons[variant];
|
|
230
|
+
var alertIconColor = variantIconColors[variant];
|
|
231
|
+
var alertTitleColor = variantTitleColors[variant];
|
|
232
|
+
// Determine ARIA role based on variant and aria-live
|
|
233
|
+
var role = variant === 'error' ? 'alert' : 'status';
|
|
234
|
+
return jsxs(StyledAlert, __assign({
|
|
235
|
+
role: role,
|
|
236
|
+
"aria-live": ariaLive,
|
|
237
|
+
"$variant": variant,
|
|
238
|
+
"$appearance": appearance,
|
|
239
|
+
"$inline": inline,
|
|
240
|
+
"$isExiting": isExiting,
|
|
241
|
+
"$reducedExit": reducedExit,
|
|
242
|
+
"data-testid": dataTestId
|
|
243
|
+
}, props, {
|
|
244
|
+
ref: alertRef,
|
|
245
|
+
"aria-hidden": isExiting ? true : forwarded['aria-hidden'],
|
|
246
|
+
style: isExiting ? __assign(__assign({}, forwarded.style), exitStyle) : forwarded.style,
|
|
247
|
+
onAnimationEnd: handleAnimationEnd,
|
|
248
|
+
children: [jsx(StyledIconContainer, {
|
|
249
|
+
"aria-hidden": "true",
|
|
250
|
+
children: jsx(Icon, {
|
|
251
|
+
name: iconName,
|
|
252
|
+
size: "md",
|
|
253
|
+
iconColor: alertIconColor
|
|
254
|
+
})
|
|
255
|
+
}), jsxs(StyledContent, {
|
|
256
|
+
children: [title && jsx(StyledTitle, {
|
|
257
|
+
role: "heading",
|
|
258
|
+
"aria-level": 6,
|
|
259
|
+
color: alertTitleColor,
|
|
260
|
+
children: title
|
|
261
|
+
}), jsx(StyledMessage, {
|
|
262
|
+
children: children
|
|
263
|
+
}), action && jsx(StyledActions, {
|
|
264
|
+
children: action
|
|
265
|
+
})]
|
|
266
|
+
}), dismissible && jsx(StyledDismissSlot, {
|
|
267
|
+
"$lineHeight": title ? alert.title.lineHeight : alert.message.lineHeight,
|
|
268
|
+
children: jsx(StyledDismissButton, {
|
|
269
|
+
iconName: "close",
|
|
270
|
+
size: "small",
|
|
271
|
+
variant: "naked",
|
|
272
|
+
"$inline": inline,
|
|
273
|
+
onClick: handleDismiss,
|
|
274
|
+
"aria-label": "Dismiss alert",
|
|
275
|
+
"data-testid": dataTestId ? "".concat(dataTestId, "-dismiss") : undefined
|
|
276
|
+
})
|
|
277
|
+
})]
|
|
278
|
+
}));
|
|
279
|
+
};
|
|
280
|
+
Alert.displayName = 'Alert';
|
|
281
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13;
|
|
282
|
+
|
|
283
|
+
export { Alert };
|
|
284
|
+
//# sourceMappingURL=Alert.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Alert.mjs';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Breadcrumb {
|
|
3
|
+
label: string;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
6
|
+
interface BreadcrumbsProps {
|
|
7
|
+
breadcrumbs: Breadcrumb[];
|
|
8
|
+
'data-testid'?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Custom link component (e.g., Next.js Link)
|
|
11
|
+
* @example linkComponent={NextLink}
|
|
12
|
+
*/
|
|
13
|
+
linkComponent?: React.ComponentType<any>;
|
|
14
|
+
}
|
|
15
|
+
export declare const Breadcrumbs: React.FC<BreadcrumbsProps>;
|
|
16
|
+
export {};
|