@carbon-labs/react-animated-header 0.22.0 → 0.24.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/es/__stories__/AnimatedHeader.stories.d.ts +198 -332
- package/es/__stories__/data/index.d.ts +21 -0
- package/es/components/AnimatedHeader/AnimatedHeader.d.ts +9 -0
- package/es/components/AnimatedHeader/AnimatedHeader.js +30 -22
- package/es/components/HeaderTitle/HeaderTitle.d.ts +18 -0
- package/es/components/HeaderTitle/HeaderTitle.js +53 -0
- package/es/components/TasksController/TasksController.d.ts +1 -0
- package/es/components/TasksController/TasksController.js +2 -1
- package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +1 -0
- package/es/components/Tiles/AIPromptTile/AIPromptTile.js +4 -1
- package/es/components/Tiles/BaseTile/BaseTile.d.ts +1 -0
- package/es/components/Tiles/GlassTile/GlassTile.d.ts +1 -0
- package/es/components/Tiles/GlassTile/GlassTile.js +9 -2
- package/es/components/WorkspaceSelector/WorkspaceSelector.d.ts +1 -0
- package/es/components/WorkspaceSelector/WorkspaceSelector.js +1 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +1 -0
- package/lib/__stories__/AnimatedHeader.stories.d.ts +198 -332
- package/lib/__stories__/data/index.d.ts +21 -0
- package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +9 -0
- package/lib/components/AnimatedHeader/AnimatedHeader.js +29 -21
- package/lib/components/HeaderTitle/HeaderTitle.d.ts +18 -0
- package/lib/components/HeaderTitle/HeaderTitle.js +57 -0
- package/lib/components/TasksController/TasksController.d.ts +1 -0
- package/lib/components/TasksController/TasksController.js +2 -1
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +1 -0
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +4 -1
- package/lib/components/Tiles/BaseTile/BaseTile.d.ts +1 -0
- package/lib/components/Tiles/GlassTile/GlassTile.d.ts +1 -0
- package/lib/components/Tiles/GlassTile/GlassTile.js +9 -2
- package/lib/components/WorkspaceSelector/WorkspaceSelector.d.ts +1 -0
- package/lib/components/WorkspaceSelector/WorkspaceSelector.js +1 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +2 -0
- package/package.json +2 -2
- package/scss/AnimatedHeader/animated-header.scss +20 -113
- package/scss/HeaderTitle/header-title.scss +60 -0
- package/scss/animated-header.scss +1 -0
|
@@ -10,6 +10,7 @@ export const headerTiles: ({
|
|
|
10
10
|
href: string;
|
|
11
11
|
title: string;
|
|
12
12
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
13
|
+
ariaLabel: string;
|
|
13
14
|
subtitle?: undefined;
|
|
14
15
|
} | {
|
|
15
16
|
id: string;
|
|
@@ -17,6 +18,7 @@ export const headerTiles: ({
|
|
|
17
18
|
title: string;
|
|
18
19
|
subtitle: string;
|
|
19
20
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
21
|
+
ariaLabel: string;
|
|
20
22
|
})[];
|
|
21
23
|
} | {
|
|
22
24
|
id: number;
|
|
@@ -27,6 +29,7 @@ export const headerTiles: ({
|
|
|
27
29
|
title: string;
|
|
28
30
|
subtitle: string;
|
|
29
31
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
32
|
+
ariaLabel: string;
|
|
30
33
|
secondaryIcon?: undefined;
|
|
31
34
|
} | {
|
|
32
35
|
id: string;
|
|
@@ -34,6 +37,7 @@ export const headerTiles: ({
|
|
|
34
37
|
title: string;
|
|
35
38
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
36
39
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
40
|
+
ariaLabel: string;
|
|
37
41
|
subtitle?: undefined;
|
|
38
42
|
})[];
|
|
39
43
|
} | {
|
|
@@ -46,6 +50,7 @@ export const headerTiles: ({
|
|
|
46
50
|
subtitle: string;
|
|
47
51
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
48
52
|
isLoading: boolean;
|
|
53
|
+
ariaLabel: string;
|
|
49
54
|
isDisabled?: undefined;
|
|
50
55
|
secondaryIcon?: undefined;
|
|
51
56
|
} | {
|
|
@@ -53,6 +58,7 @@ export const headerTiles: ({
|
|
|
53
58
|
title: string;
|
|
54
59
|
subtitle: string;
|
|
55
60
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
61
|
+
ariaLabel: string;
|
|
56
62
|
href?: undefined;
|
|
57
63
|
isLoading?: undefined;
|
|
58
64
|
isDisabled?: undefined;
|
|
@@ -64,6 +70,7 @@ export const headerTiles: ({
|
|
|
64
70
|
subtitle: string;
|
|
65
71
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
66
72
|
isDisabled: boolean;
|
|
73
|
+
ariaLabel: string;
|
|
67
74
|
isLoading?: undefined;
|
|
68
75
|
secondaryIcon?: undefined;
|
|
69
76
|
} | {
|
|
@@ -72,6 +79,7 @@ export const headerTiles: ({
|
|
|
72
79
|
title: string;
|
|
73
80
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
74
81
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
82
|
+
ariaLabel: string;
|
|
75
83
|
subtitle?: undefined;
|
|
76
84
|
isLoading?: undefined;
|
|
77
85
|
isDisabled?: undefined;
|
|
@@ -82,6 +90,7 @@ export const headerTiles: ({
|
|
|
82
90
|
tiles: {
|
|
83
91
|
id: string;
|
|
84
92
|
customContent: import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
ariaLabel: string;
|
|
85
94
|
}[];
|
|
86
95
|
})[];
|
|
87
96
|
export namespace tasksControllerConfigButton {
|
|
@@ -108,6 +117,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
108
117
|
href: string;
|
|
109
118
|
title: string;
|
|
110
119
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
120
|
+
ariaLabel: string;
|
|
111
121
|
subtitle?: undefined;
|
|
112
122
|
} | {
|
|
113
123
|
id: string;
|
|
@@ -115,6 +125,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
115
125
|
title: string;
|
|
116
126
|
subtitle: string;
|
|
117
127
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
128
|
+
ariaLabel: string;
|
|
118
129
|
})[];
|
|
119
130
|
} | {
|
|
120
131
|
id: number;
|
|
@@ -125,6 +136,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
125
136
|
title: string;
|
|
126
137
|
subtitle: string;
|
|
127
138
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
139
|
+
ariaLabel: string;
|
|
128
140
|
secondaryIcon?: undefined;
|
|
129
141
|
} | {
|
|
130
142
|
id: string;
|
|
@@ -132,6 +144,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
132
144
|
title: string;
|
|
133
145
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
134
146
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
147
|
+
ariaLabel: string;
|
|
135
148
|
subtitle?: undefined;
|
|
136
149
|
})[];
|
|
137
150
|
} | {
|
|
@@ -144,6 +157,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
144
157
|
subtitle: string;
|
|
145
158
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
146
159
|
isLoading: boolean;
|
|
160
|
+
ariaLabel: string;
|
|
147
161
|
isDisabled?: undefined;
|
|
148
162
|
secondaryIcon?: undefined;
|
|
149
163
|
} | {
|
|
@@ -151,6 +165,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
151
165
|
title: string;
|
|
152
166
|
subtitle: string;
|
|
153
167
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
168
|
+
ariaLabel: string;
|
|
154
169
|
href?: undefined;
|
|
155
170
|
isLoading?: undefined;
|
|
156
171
|
isDisabled?: undefined;
|
|
@@ -162,6 +177,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
162
177
|
subtitle: string;
|
|
163
178
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
164
179
|
isDisabled: boolean;
|
|
180
|
+
ariaLabel: string;
|
|
165
181
|
isLoading?: undefined;
|
|
166
182
|
secondaryIcon?: undefined;
|
|
167
183
|
} | {
|
|
@@ -170,6 +186,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
170
186
|
title: string;
|
|
171
187
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
172
188
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
189
|
+
ariaLabel: string;
|
|
173
190
|
subtitle?: undefined;
|
|
174
191
|
isLoading?: undefined;
|
|
175
192
|
isDisabled?: undefined;
|
|
@@ -180,9 +197,11 @@ export namespace tasksControllerConfigDropdown {
|
|
|
180
197
|
tiles: {
|
|
181
198
|
id: string;
|
|
182
199
|
customContent: import("react/jsx-runtime").JSX.Element;
|
|
200
|
+
ariaLabel: string;
|
|
183
201
|
}[];
|
|
184
202
|
};
|
|
185
203
|
export function setSelectedTileGroup(): void;
|
|
204
|
+
export let ariaLabel: string;
|
|
186
205
|
}
|
|
187
206
|
}
|
|
188
207
|
export namespace tasksControllerConfigLoading {
|
|
@@ -198,6 +217,8 @@ export namespace workspaceSelectorConfig {
|
|
|
198
217
|
export { label_1 as label };
|
|
199
218
|
export function renderSelectedItem(item: any): string;
|
|
200
219
|
}
|
|
220
|
+
let ariaLabel_1: string;
|
|
221
|
+
export { ariaLabel_1 as ariaLabel };
|
|
201
222
|
}
|
|
202
223
|
export namespace workspaceSelectorConfigLoading {
|
|
203
224
|
export { workspaceData as allWorkspaces };
|
|
@@ -2,6 +2,13 @@ import React, { ElementType, ReactNode } from 'react';
|
|
|
2
2
|
import { TasksControllerProps } from '../TasksController/TasksController';
|
|
3
3
|
import { WorkspaceSelectorProps } from '../WorkspaceSelector/WorkspaceSelector';
|
|
4
4
|
/** Animated Header */
|
|
5
|
+
export interface AriaLabels {
|
|
6
|
+
welcome?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
collapseButton?: string;
|
|
9
|
+
expandButton?: string;
|
|
10
|
+
tilesContainer?: string;
|
|
11
|
+
}
|
|
5
12
|
export interface Tile {
|
|
6
13
|
href?: string | null;
|
|
7
14
|
id: string;
|
|
@@ -13,6 +20,7 @@ export interface Tile {
|
|
|
13
20
|
isLoading?: boolean;
|
|
14
21
|
isDisabled?: boolean;
|
|
15
22
|
onClick?: () => void;
|
|
23
|
+
ariaLabel?: string;
|
|
16
24
|
}
|
|
17
25
|
export interface TileGroup {
|
|
18
26
|
id: number;
|
|
@@ -21,6 +29,7 @@ export interface TileGroup {
|
|
|
21
29
|
}
|
|
22
30
|
export type AnimatedHeaderProps = {
|
|
23
31
|
allTileGroups?: TileGroup[];
|
|
32
|
+
ariaLabels?: AriaLabels;
|
|
24
33
|
selectedTileGroup?: TileGroup;
|
|
25
34
|
setSelectedTileGroup: (e: any) => void;
|
|
26
35
|
description?: string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import React, { useRef, useState, useEffect } from 'react';
|
|
10
|
-
import { Grid, Column,
|
|
10
|
+
import { Grid, Column, Button } from '@carbon/react';
|
|
11
11
|
import { ChevronUp, ChevronDown } from '@carbon/icons-react';
|
|
12
12
|
import lottie from '../../_virtual/lottie.js';
|
|
13
13
|
import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
|
|
@@ -15,11 +15,13 @@ import '@carbon/react/icons';
|
|
|
15
15
|
import { BaseTile } from '../Tiles/BaseTile/BaseTile.js';
|
|
16
16
|
import TasksController from '../TasksController/TasksController.js';
|
|
17
17
|
import WorkspaceSelector from '../WorkspaceSelector/WorkspaceSelector.js';
|
|
18
|
+
import HeaderTitle from '../HeaderTitle/HeaderTitle.js';
|
|
18
19
|
|
|
19
20
|
/** Animated Header */
|
|
20
21
|
|
|
21
22
|
const AnimatedHeader = ({
|
|
22
23
|
allTileGroups,
|
|
24
|
+
ariaLabels = {},
|
|
23
25
|
selectedTileGroup,
|
|
24
26
|
setSelectedTileGroup,
|
|
25
27
|
description,
|
|
@@ -40,17 +42,13 @@ const AnimatedHeader = ({
|
|
|
40
42
|
const blockClass = `${prefix}--animated-header`;
|
|
41
43
|
const animationContainer = useRef(null);
|
|
42
44
|
const [open, setOpen] = useState(true);
|
|
43
|
-
const [headingTextAnimation, setHeadingTextAnimation] = useState('');
|
|
44
45
|
const isReduced = window.matchMedia('(prefers-reduced-motion)').matches;
|
|
45
46
|
const collapsed = `${blockClass}--collapsed`;
|
|
46
47
|
const contentCollapsed = `${blockClass}__content--collapsed`;
|
|
47
48
|
const descriptionCollapsed = `${blockClass}__left-area-container--collapsed`;
|
|
48
|
-
const headingCollapsed = `${blockClass}__heading--collapsed`;
|
|
49
|
-
const headingExpanded = `${blockClass}__heading--expanded`;
|
|
50
49
|
const lottieCollapsed = `${blockClass}__lottie-animation--collapsed`;
|
|
51
50
|
const handleButtonCollapseClick = () => {
|
|
52
51
|
setOpen(!open);
|
|
53
|
-
open ? setHeadingTextAnimation(headingCollapsed) : setHeadingTextAnimation(headingExpanded);
|
|
54
52
|
};
|
|
55
53
|
useEffect(() => {
|
|
56
54
|
if (!animationContainer.current) {
|
|
@@ -87,7 +85,7 @@ const AnimatedHeader = ({
|
|
|
87
85
|
};
|
|
88
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
87
|
}, [isReduced]);
|
|
90
|
-
return /*#__PURE__*/React.createElement("
|
|
88
|
+
return /*#__PURE__*/React.createElement("header", {
|
|
91
89
|
className: `${blockClass}${!open ? ` ${collapsed}` : ''}`
|
|
92
90
|
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement("div", {
|
|
93
91
|
className: `${blockClass}__gradient--overlay`
|
|
@@ -101,32 +99,32 @@ const AnimatedHeader = ({
|
|
|
101
99
|
,
|
|
102
100
|
style: {
|
|
103
101
|
backgroundImage: `url(${headerStatic})`
|
|
104
|
-
}
|
|
102
|
+
},
|
|
103
|
+
"aria-hidden": "true"
|
|
105
104
|
})), /*#__PURE__*/React.createElement("div", {
|
|
106
105
|
className: `${blockClass}__lottie-animation--container`
|
|
107
106
|
}, /*#__PURE__*/React.createElement("div", {
|
|
108
107
|
ref: animationContainer,
|
|
109
|
-
className: `${blockClass}__lottie-animation${!open ? ` ${lottieCollapsed}` : ''}
|
|
108
|
+
className: `${blockClass}__lottie-animation${!open ? ` ${lottieCollapsed}` : ''}`,
|
|
109
|
+
"aria-hidden": "true"
|
|
110
110
|
})), /*#__PURE__*/React.createElement(Column, {
|
|
111
111
|
sm: 4,
|
|
112
112
|
md: 8,
|
|
113
113
|
lg: 16
|
|
114
|
-
}, /*#__PURE__*/React.createElement(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, /*#__PURE__*/React.createElement(
|
|
120
|
-
className: `${blockClass}__heading-welcome`
|
|
121
|
-
}, welcomeText, ",", ' '), /*#__PURE__*/React.createElement("span", {
|
|
122
|
-
className: `${blockClass}__heading-name`
|
|
123
|
-
}, userName)))), (description || tasksControllerConfig) && /*#__PURE__*/React.createElement(Column, {
|
|
114
|
+
}, /*#__PURE__*/React.createElement(HeaderTitle, {
|
|
115
|
+
userName: userName,
|
|
116
|
+
welcomeText: welcomeText,
|
|
117
|
+
headerExpanded: open,
|
|
118
|
+
ariaLabels: ariaLabels
|
|
119
|
+
})), (description || tasksControllerConfig) && /*#__PURE__*/React.createElement(Column, {
|
|
124
120
|
sm: 4,
|
|
125
121
|
md: 8,
|
|
126
122
|
lg: 4,
|
|
123
|
+
id: `${blockClass}-content`,
|
|
127
124
|
className: `${blockClass}__left-area-container${!open ? ` ${descriptionCollapsed}` : ''}`
|
|
128
125
|
}, description && /*#__PURE__*/React.createElement("h2", {
|
|
129
|
-
className: `${blockClass}__description
|
|
126
|
+
className: `${blockClass}__description`,
|
|
127
|
+
"aria-label": ariaLabels?.description ?? `Header description`
|
|
130
128
|
}, description), /*#__PURE__*/React.createElement(TasksController, {
|
|
131
129
|
tasksControllerConfig: tasksControllerConfig,
|
|
132
130
|
isLoading: isLoading,
|
|
@@ -145,7 +143,9 @@ const AnimatedHeader = ({
|
|
|
145
143
|
userName: userName,
|
|
146
144
|
isLoading: isLoading
|
|
147
145
|
})), /*#__PURE__*/React.createElement("div", {
|
|
148
|
-
className: `${blockClass}__tiles-container
|
|
146
|
+
className: `${blockClass}__tiles-container`,
|
|
147
|
+
"aria-label": ariaLabels?.tilesContainer ?? `Feature tiles`,
|
|
148
|
+
role: "list"
|
|
149
149
|
}, selectedTileGroup.tiles.map(tile => {
|
|
150
150
|
return /*#__PURE__*/React.createElement(BaseTile, {
|
|
151
151
|
onClick: tile.href || tile.onClick ? () => {
|
|
@@ -164,7 +164,8 @@ const AnimatedHeader = ({
|
|
|
164
164
|
customContent: tile.customContent,
|
|
165
165
|
isLoading: isLoading || tile.isLoading,
|
|
166
166
|
isDisabled: tile.isDisabled,
|
|
167
|
-
disabledTaskLabel: disabledTaskLabel
|
|
167
|
+
disabledTaskLabel: disabledTaskLabel,
|
|
168
|
+
ariaLabel: tile.ariaLabel
|
|
168
169
|
});
|
|
169
170
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
170
171
|
className: `${blockClass}__button-collapse--gradient`
|
|
@@ -174,7 +175,10 @@ const AnimatedHeader = ({
|
|
|
174
175
|
id: `${blockClass}__button-collapse`,
|
|
175
176
|
kind: "ghost",
|
|
176
177
|
renderIcon: open ? ChevronUp : ChevronDown,
|
|
177
|
-
onClick: handleButtonCollapseClick
|
|
178
|
+
onClick: handleButtonCollapseClick,
|
|
179
|
+
"aria-expanded": open,
|
|
180
|
+
"aria-controls": `${blockClass}-content`,
|
|
181
|
+
"aria-label": open ? ariaLabels?.collapseButton ?? 'Collapse header details' : ariaLabels?.expandButton ?? 'Expand header details'
|
|
178
182
|
}, open ? collapseButtonLabel : expandButtonLabel))));
|
|
179
183
|
};
|
|
180
184
|
AnimatedHeader.displayName = 'Animated Header';
|
|
@@ -183,6 +187,10 @@ AnimatedHeader.propTypes = {
|
|
|
183
187
|
* Array of each tile group setup
|
|
184
188
|
*/
|
|
185
189
|
allTileGroups: PropTypes.arrayOf(PropTypes.object),
|
|
190
|
+
/**
|
|
191
|
+
* Provide custom aria labels for each part of the header.
|
|
192
|
+
*/
|
|
193
|
+
ariaLabels: PropTypes.object,
|
|
186
194
|
/**
|
|
187
195
|
* Specify an optional className to be added to your Animated Header
|
|
188
196
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright IBM Corp. 2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { AriaLabels } from '../AnimatedHeader/AnimatedHeader';
|
|
11
|
+
export type HeaderTitleProps = {
|
|
12
|
+
userName?: string;
|
|
13
|
+
welcomeText?: string;
|
|
14
|
+
headerExpanded?: boolean;
|
|
15
|
+
ariaLabels?: AriaLabels;
|
|
16
|
+
};
|
|
17
|
+
declare const HeaderTitle: React.FC<HeaderTitleProps>;
|
|
18
|
+
export default HeaderTitle;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2024
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Tooltip } from '@carbon/react';
|
|
10
|
+
import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
|
|
11
|
+
|
|
12
|
+
const NAME_FIRST_LANGS = ['ar',
|
|
13
|
+
// Arabic
|
|
14
|
+
'he',
|
|
15
|
+
// Hebrew
|
|
16
|
+
'fa',
|
|
17
|
+
// Farsi/Persian
|
|
18
|
+
'ur',
|
|
19
|
+
// Urdu
|
|
20
|
+
'ja',
|
|
21
|
+
// Japanese
|
|
22
|
+
'zh' // Chinese
|
|
23
|
+
];
|
|
24
|
+
const HeaderTitle = ({
|
|
25
|
+
userName,
|
|
26
|
+
welcomeText,
|
|
27
|
+
headerExpanded,
|
|
28
|
+
ariaLabels
|
|
29
|
+
}) => {
|
|
30
|
+
const prefix = usePrefix();
|
|
31
|
+
const blockClass = `${prefix}--animated-header__title`;
|
|
32
|
+
const currentLang = typeof window !== 'undefined' ? document.documentElement.lang || 'en' : 'en';
|
|
33
|
+
const isNameFirst = NAME_FIRST_LANGS.includes(currentLang.slice(0, 2));
|
|
34
|
+
const headingCollapsed = `${blockClass}-collapsed`;
|
|
35
|
+
const headingExpanded = `${blockClass}-expanded`;
|
|
36
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
37
|
+
align: "bottom",
|
|
38
|
+
label: `${welcomeText}, ${userName}`
|
|
39
|
+
}, /*#__PURE__*/React.createElement("h1", {
|
|
40
|
+
className: `${blockClass} ${headerExpanded ? headingExpanded : headingCollapsed}`,
|
|
41
|
+
"aria-label": ariaLabels?.welcome ?? `${welcomeText}, ${userName}`
|
|
42
|
+
}, isNameFirst ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
className: `${blockClass}-first`
|
|
44
|
+
}, userName, ", "), /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: `${blockClass}-second`
|
|
46
|
+
}, welcomeText)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
className: `${blockClass}-first`
|
|
48
|
+
}, welcomeText, ", "), /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
className: `${blockClass}-second`
|
|
50
|
+
}, userName))));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { HeaderTitle as default };
|
|
@@ -46,9 +46,10 @@ const TasksController = ({
|
|
|
46
46
|
setSelectedTileGroup?.(e);
|
|
47
47
|
dropdownCustomOnChange?.(e);
|
|
48
48
|
},
|
|
49
|
+
'aria-label': tasksControllerConfig?.dropdown?.ariaLabel ?? 'Select a task group',
|
|
49
50
|
...dropdownOverrideProps
|
|
50
51
|
};
|
|
51
|
-
}, [allTileGroups,
|
|
52
|
+
}, [allTileGroups, blockClass, dropdownCustomClass, selectedTileGroup, tasksControllerConfig?.dropdown?.ariaLabel, dropdownOverrideProps, setSelectedTileGroup, dropdownCustomOnChange]);
|
|
52
53
|
if (!tasksControllerConfig?.type) {
|
|
53
54
|
return null;
|
|
54
55
|
}
|
|
@@ -24,7 +24,8 @@ const AIPromptTile = ({
|
|
|
24
24
|
isLoading,
|
|
25
25
|
isDisabled,
|
|
26
26
|
disabledTaskLabel,
|
|
27
|
-
onClick
|
|
27
|
+
onClick,
|
|
28
|
+
ariaLabel
|
|
28
29
|
}) => {
|
|
29
30
|
const prefix = usePrefix();
|
|
30
31
|
const blockClass = `${prefix}--animated-header__ai-prompt-tile`;
|
|
@@ -48,6 +49,8 @@ const AIPromptTile = ({
|
|
|
48
49
|
return /*#__PURE__*/React.createElement("div", {
|
|
49
50
|
id: `${blockClass}`,
|
|
50
51
|
className: `${prefix}--animated-header__tile ${blockClass}${isDisabled ? ' ' + disabled : ''}`,
|
|
52
|
+
"aria-label": ariaLabel ?? title ?? 'AI Tile',
|
|
53
|
+
role: "listitem",
|
|
51
54
|
title: isDisabled ? disabledTaskLabel ?? '' : '',
|
|
52
55
|
key: id
|
|
53
56
|
}, isLoading ? /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
@@ -24,7 +24,8 @@ const GlassTile = ({
|
|
|
24
24
|
isLoading,
|
|
25
25
|
isDisabled,
|
|
26
26
|
disabledTaskLabel,
|
|
27
|
-
onClick: glassTileClickHandler
|
|
27
|
+
onClick: glassTileClickHandler,
|
|
28
|
+
ariaLabel
|
|
28
29
|
}) => {
|
|
29
30
|
const prefix = usePrefix();
|
|
30
31
|
const blockClass = `${prefix}--animated-header__glass-tile`;
|
|
@@ -42,7 +43,10 @@ const GlassTile = ({
|
|
|
42
43
|
if (!href && !glassTileClickHandler) {
|
|
43
44
|
return /*#__PURE__*/React.createElement("div", {
|
|
44
45
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
45
|
-
key: id
|
|
46
|
+
key: id,
|
|
47
|
+
"aria-label": ariaLabel ?? title ?? 'Glass Tile',
|
|
48
|
+
title: isDisabled ? disabledTaskLabel ?? '' : '',
|
|
49
|
+
tabIndex: -1
|
|
46
50
|
}, body);
|
|
47
51
|
}
|
|
48
52
|
return /*#__PURE__*/React.createElement(Link, {
|
|
@@ -50,6 +54,9 @@ const GlassTile = ({
|
|
|
50
54
|
glassTileClickHandler?.();
|
|
51
55
|
},
|
|
52
56
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
57
|
+
"aria-label": ariaLabel ?? title ?? 'Glass Tile',
|
|
58
|
+
role: "listitem",
|
|
59
|
+
tabIndex: isDisabled || isLoading ? -1 : 0,
|
|
53
60
|
key: id,
|
|
54
61
|
href: href ?? undefined,
|
|
55
62
|
disabled: isDisabled || isLoading,
|
|
@@ -13,6 +13,7 @@ export interface Workspace {
|
|
|
13
13
|
}
|
|
14
14
|
export type WorkspaceSelectorConfig = {
|
|
15
15
|
propsOverrides: Partial<Omit<DropdownProps<Workspace>, 'id' | 'items' | 'selectedItem' | 'setSelectedWorkspace'>>;
|
|
16
|
+
ariaLabel?: string;
|
|
16
17
|
allWorkspaces: Workspace[];
|
|
17
18
|
selectedWorkspace?: Workspace | null;
|
|
18
19
|
setSelectedWorkspace: (e: any) => void;
|
|
@@ -39,6 +39,7 @@ const WorkspaceSelector = ({
|
|
|
39
39
|
workspaceSelectorConfig?.setSelectedWorkspace?.(e);
|
|
40
40
|
dropdownCustomOnChange?.(e);
|
|
41
41
|
},
|
|
42
|
+
'aria-label': workspaceSelectorConfig?.ariaLabel ?? 'Select a workspace',
|
|
42
43
|
...dropdownOverrideProps
|
|
43
44
|
};
|
|
44
45
|
}, [blockClass, dropdownCustomClass, dropdownOverrideProps, userName, workspaceSelectorConfig, dropdownCustomOnChange]);
|
package/es/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
import AnimatedHeader from './components/AnimatedHeader/AnimatedHeader';
|
|
9
|
+
import AnimatedHeader, { AriaLabels } from './components/AnimatedHeader/AnimatedHeader';
|
|
10
|
+
import HeaderTitle from './components/HeaderTitle/HeaderTitle';
|
|
10
11
|
import { BaseTile } from './components/Tiles/index.js';
|
|
11
12
|
export * from './assets';
|
|
12
13
|
export type { Workspace, WorkspaceSelectorConfig, } from './components/WorkspaceSelector/WorkspaceSelector';
|
|
13
14
|
export type { TasksControllerConfig } from './components/TasksController/TasksController';
|
|
14
|
-
export { AnimatedHeader, BaseTile };
|
|
15
|
+
export { AnimatedHeader, BaseTile, HeaderTitle, type AriaLabels };
|
package/es/index.js
CHANGED