@carbon-labs/react-animated-header 0.36.0 → 0.38.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 +2 -2
- package/es/components/AnimatedHeader/AnimatedHeader.js +6 -6
- package/es/components/AnimatedHeader/types.d.ts +1 -3
- package/es/components/ContentSwitcherSelector/ContentSwitcherSelector.js +9 -10
- package/es/components/TasksController/TasksController.d.ts +2 -4
- package/es/components/TasksController/TasksController.js +20 -16
- package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +4 -3
- package/es/components/Tiles/AIPromptTile/AIPromptTile.js +2 -2
- package/es/components/Tiles/AITile/AITile.d.ts +4 -3
- package/es/components/Tiles/AITile/AITile.js +2 -2
- package/es/components/Tiles/BaseTile/BaseTile.d.ts +1 -10
- package/es/components/Tiles/BaseTile/BaseTile.js +1 -1
- package/es/components/Tiles/GlassTile/GlassTile.d.ts +4 -3
- package/es/components/Tiles/GlassTile/GlassTile.js +2 -2
- package/lib/__stories__/AnimatedHeader.stories.d.ts +2 -2
- package/lib/components/AnimatedHeader/AnimatedHeader.js +6 -6
- package/lib/components/AnimatedHeader/types.d.ts +1 -3
- package/lib/components/ContentSwitcherSelector/ContentSwitcherSelector.js +8 -9
- package/lib/components/TasksController/TasksController.d.ts +2 -4
- package/lib/components/TasksController/TasksController.js +20 -16
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +4 -3
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +2 -2
- package/lib/components/Tiles/AITile/AITile.d.ts +4 -3
- package/lib/components/Tiles/AITile/AITile.js +2 -2
- package/lib/components/Tiles/BaseTile/BaseTile.d.ts +1 -10
- package/lib/components/Tiles/BaseTile/BaseTile.js +1 -1
- package/lib/components/Tiles/GlassTile/GlassTile.d.ts +4 -3
- package/lib/components/Tiles/GlassTile/GlassTile.js +2 -2
- package/package.json +2 -2
|
@@ -15065,7 +15065,7 @@ export declare const ThemeG10: {
|
|
|
15065
15065
|
type: string;
|
|
15066
15066
|
button: {
|
|
15067
15067
|
href: string;
|
|
15068
|
-
icon: import("@carbon/icons
|
|
15068
|
+
icon: import("@carbon/react/icons").CarbonIconType;
|
|
15069
15069
|
text: string;
|
|
15070
15070
|
type: "tertiary";
|
|
15071
15071
|
};
|
|
@@ -30258,7 +30258,7 @@ export declare const ThemeG100: {
|
|
|
30258
30258
|
type: string;
|
|
30259
30259
|
button: {
|
|
30260
30260
|
href: string;
|
|
30261
|
-
icon: import("@carbon/icons
|
|
30261
|
+
icon: import("@carbon/react/icons").CarbonIconType;
|
|
30262
30262
|
text: string;
|
|
30263
30263
|
type: "tertiary";
|
|
30264
30264
|
};
|
|
@@ -58,7 +58,9 @@ const AnimatedHeader = ({
|
|
|
58
58
|
animRef.current.destroy();
|
|
59
59
|
animRef.current = null;
|
|
60
60
|
}
|
|
61
|
-
if (!animationContainer.current || !headerAnimation)
|
|
61
|
+
if (!animationContainer.current || !headerAnimation) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
62
64
|
const animation = lottie.loadAnimation({
|
|
63
65
|
container: animationContainer.current,
|
|
64
66
|
animationData: headerAnimation,
|
|
@@ -183,7 +185,7 @@ const AnimatedHeader = ({
|
|
|
183
185
|
const legacyId = tile.id; // old configs
|
|
184
186
|
const resolvedTileId = tileId ?? legacyId;
|
|
185
187
|
const key = resolvedTileId ?? `tile-${index}`;
|
|
186
|
-
const hasAction = tile.href || tile.onClick === 'function';
|
|
188
|
+
const hasAction = tile.href || typeof tile.onClick === 'function';
|
|
187
189
|
return /*#__PURE__*/React.createElement(BaseTile, _extends({
|
|
188
190
|
key: key,
|
|
189
191
|
tileId: resolvedTileId
|
|
@@ -192,11 +194,9 @@ const AnimatedHeader = ({
|
|
|
192
194
|
productName: productName,
|
|
193
195
|
isLoading: isLoading || tile.isLoading,
|
|
194
196
|
disabledTaskLabel: disabledTaskLabel,
|
|
195
|
-
onClick: hasAction ?
|
|
197
|
+
onClick: hasAction ? event => {
|
|
196
198
|
tileClickHandler?.(tile);
|
|
197
|
-
|
|
198
|
-
tile.onClick();
|
|
199
|
-
}
|
|
199
|
+
tile.onClick?.(event);
|
|
200
200
|
} : undefined
|
|
201
201
|
}));
|
|
202
202
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
import type { BaseTileProps } from '../../components/Tiles/BaseTile/BaseTile';
|
|
10
|
-
export type Tile =
|
|
11
|
-
tileId: string;
|
|
12
|
-
};
|
|
10
|
+
export type Tile = BaseTileProps;
|
|
13
11
|
export interface TileGroup {
|
|
14
12
|
id: number;
|
|
15
13
|
label: string;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React
|
|
9
|
+
import React from 'react';
|
|
10
10
|
import { SkeletonPlaceholder, ContentSwitcher, Switch } from '@carbon/react';
|
|
11
11
|
import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
|
|
12
12
|
|
|
@@ -17,11 +17,8 @@ const ContentSwitcherSelector = ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
const prefix = usePrefix();
|
|
19
19
|
const blockClass = `${prefix}--animated-header__content-switcher`;
|
|
20
|
-
if (!contentSwitcherConfig)
|
|
21
|
-
|
|
22
|
-
return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
23
|
-
className: `${blockClass}-skeleton`
|
|
24
|
-
});
|
|
20
|
+
if (!contentSwitcherConfig) {
|
|
21
|
+
return null;
|
|
25
22
|
}
|
|
26
23
|
const {
|
|
27
24
|
items = [],
|
|
@@ -34,16 +31,18 @@ const ContentSwitcherSelector = ({
|
|
|
34
31
|
} = contentSwitcherConfig;
|
|
35
32
|
const count = visibleCount === 3 ? 3 : 2;
|
|
36
33
|
const visibleItems = items.slice(0, count);
|
|
34
|
+
const selectedIndexSafe = Math.min(Math.max(selectedIndex, 0), visibleItems.length - 1);
|
|
35
|
+
if (isLoading || contentSwitcherConfig.isLoading) {
|
|
36
|
+
return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
37
|
+
className: `${blockClass}-skeleton`
|
|
38
|
+
});
|
|
39
|
+
}
|
|
37
40
|
if (visibleItems.length < 2 || visibleItems.length > 3) {
|
|
38
41
|
if (process.env.NODE_ENV !== 'production') {
|
|
39
42
|
console.warn('[ContentSwitcherSelector] contentSwitcherConfig.items must contain 2 or 3 items.');
|
|
40
43
|
}
|
|
41
44
|
return null;
|
|
42
45
|
}
|
|
43
|
-
const selectedIndexSafe = useMemo(() => {
|
|
44
|
-
const idx = typeof selectedIndex === 'number' ? selectedIndex : 0;
|
|
45
|
-
return Math.min(Math.max(idx, 0), visibleItems.length - 1);
|
|
46
|
-
}, [selectedIndex, visibleItems.length]);
|
|
47
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
48
47
|
className: `${blockClass}--container`,
|
|
49
48
|
"data-expanded": headerExpanded
|
|
@@ -25,10 +25,8 @@ export type TasksControllerProps = {
|
|
|
25
25
|
tasksControllerConfig?: TasksControllerConfig | null;
|
|
26
26
|
isLoading?: boolean;
|
|
27
27
|
allTileGroups?: TileGroup[];
|
|
28
|
-
selectedTileGroup?: TileGroup
|
|
29
|
-
setSelectedTileGroup?: (
|
|
30
|
-
selectedItem: TileGroup;
|
|
31
|
-
}) => void;
|
|
28
|
+
selectedTileGroup?: TileGroup;
|
|
29
|
+
setSelectedTileGroup?: (e: any) => void;
|
|
32
30
|
};
|
|
33
31
|
declare const TasksController: ({ tasksControllerConfig, isLoading, allTileGroups, selectedTileGroup, setSelectedTileGroup, }: TasksControllerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
34
32
|
export default TasksController;
|
|
@@ -33,24 +33,11 @@ const TasksController = ({
|
|
|
33
33
|
...dropdownOverrideProps
|
|
34
34
|
} = tasksControllerConfig?.dropdown?.propsOverrides || {};
|
|
35
35
|
|
|
36
|
-
/** Early outs */
|
|
37
|
-
if (!tasksControllerConfig?.type) return null;
|
|
38
|
-
if (isLoading || tasksControllerConfig?.isLoading) {
|
|
39
|
-
return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
40
|
-
className: `${blockClass}__task-controller-skeleton`
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Button mode */
|
|
45
|
-
if (tasksControllerConfig?.type === 'button' && tasksControllerConfig?.button?.text) {
|
|
46
|
-
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
47
|
-
className: `${blockClass}__button${buttonCustomClass ? ` ${buttonCustomClass}` : ''}`
|
|
48
|
-
}, buttonOverrideProps), tasksControllerConfig.button.text);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
36
|
/** Build Dropdown props (uses top-level list/selection/setter) */
|
|
52
37
|
const dropdownProps = useMemo(() => {
|
|
53
|
-
if (!allTileGroups?.length)
|
|
38
|
+
if (!allTileGroups?.length) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
54
41
|
return {
|
|
55
42
|
id: `${blockClass}__header-dropdown`,
|
|
56
43
|
className: `${blockClass}__header-dropdown${dropdownCustomClass ? ` ${dropdownCustomClass}` : ''}`,
|
|
@@ -74,6 +61,23 @@ const TasksController = ({
|
|
|
74
61
|
};
|
|
75
62
|
}, [allTileGroups, selectedTileGroup, setSelectedTileGroup, blockClass, dropdownCustomClass, dropdownOverrideProps, dropdownCustomOnChange, tasksControllerConfig?.dropdown?.label, tasksControllerConfig?.dropdown?.ariaLabel]);
|
|
76
63
|
|
|
64
|
+
/** Early outs */
|
|
65
|
+
if (!tasksControllerConfig?.type) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (isLoading || tasksControllerConfig?.isLoading) {
|
|
69
|
+
return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
70
|
+
className: `${blockClass}__task-controller-skeleton`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Button mode */
|
|
75
|
+
if (tasksControllerConfig?.type === 'button' && tasksControllerConfig?.button?.text) {
|
|
76
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
77
|
+
className: `${blockClass}__button${buttonCustomClass ? ` ${buttonCustomClass}` : ''}`
|
|
78
|
+
}, buttonOverrideProps), tasksControllerConfig.button.text);
|
|
79
|
+
}
|
|
80
|
+
|
|
77
81
|
/** Dropdown mode */
|
|
78
82
|
if (tasksControllerConfig?.type === 'dropdown' && dropdownProps) {
|
|
79
83
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -8,17 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { ElementType } from 'react';
|
|
10
10
|
export type AIPromptTileProps = {
|
|
11
|
-
|
|
11
|
+
variant: 'aiPrompt';
|
|
12
|
+
tileId: string;
|
|
12
13
|
href?: string | null;
|
|
13
14
|
title?: string | null;
|
|
14
15
|
disabledTaskLabel?: string | null;
|
|
15
16
|
productName?: string;
|
|
16
17
|
promptPlaceholder?: string;
|
|
17
18
|
primaryIcon?: ElementType | null;
|
|
18
|
-
onClick?: (() => void) | null;
|
|
19
|
+
onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
19
20
|
ariaLabel?: string;
|
|
20
21
|
open?: boolean;
|
|
21
22
|
isLoading?: boolean;
|
|
22
23
|
isDisabled?: boolean;
|
|
23
|
-
}
|
|
24
|
+
};
|
|
24
25
|
export declare const AIPromptTile: React.FC<AIPromptTileProps>;
|
|
@@ -90,8 +90,8 @@ const AIPromptTile = ({
|
|
|
90
90
|
size: "sm",
|
|
91
91
|
disabled: !textInput,
|
|
92
92
|
align: "top-end",
|
|
93
|
-
onClick:
|
|
94
|
-
onClick?.();
|
|
93
|
+
onClick: event => {
|
|
94
|
+
onClick?.(event);
|
|
95
95
|
openInNewTab(`${href}&primed_chat=${textInput}`);
|
|
96
96
|
},
|
|
97
97
|
onKeyDown: handleTextInputKeyDown
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { ElementType } from 'react';
|
|
10
10
|
export type AITileProps = {
|
|
11
|
-
|
|
11
|
+
variant: 'ai';
|
|
12
|
+
tileId: string;
|
|
12
13
|
href?: string | null;
|
|
13
14
|
title?: string | null;
|
|
14
15
|
subtitle?: string | null;
|
|
@@ -16,11 +17,11 @@ export type AITileProps = {
|
|
|
16
17
|
customContent?: React.ReactNode | null;
|
|
17
18
|
primaryIcon?: ElementType | null;
|
|
18
19
|
secondaryIcon?: ElementType | null;
|
|
19
|
-
onClick?: (() => void) | null;
|
|
20
|
+
onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
20
21
|
ariaLabel?: string;
|
|
21
22
|
open?: boolean;
|
|
22
23
|
isLoading?: boolean;
|
|
23
24
|
isDisabled?: boolean;
|
|
24
|
-
}
|
|
25
|
+
};
|
|
25
26
|
export declare const AITile: React.FC<AITileProps>;
|
|
26
27
|
export default AITile;
|
|
@@ -48,8 +48,8 @@ const AITile = ({
|
|
|
48
48
|
}, body);
|
|
49
49
|
}
|
|
50
50
|
return /*#__PURE__*/React.createElement(Link, {
|
|
51
|
-
onClick:
|
|
52
|
-
aiTileClickHandler?.();
|
|
51
|
+
onClick: event => {
|
|
52
|
+
aiTileClickHandler?.(event);
|
|
53
53
|
},
|
|
54
54
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
55
55
|
"aria-label": ariaLabel ?? title ?? 'AI Tile',
|
|
@@ -12,14 +12,5 @@ import { type AIPromptTileProps } from '../AIPromptTile/AIPromptTile';
|
|
|
12
12
|
import { type GlassTileProps } from '../GlassTile/GlassTile';
|
|
13
13
|
/** Base Tile router */
|
|
14
14
|
export type TileVariant = 'glass' | 'aiPrompt' | 'ai';
|
|
15
|
-
export type BaseTileProps =
|
|
16
|
-
variant?: 'glass';
|
|
17
|
-
} & GlassTileProps) | ({
|
|
18
|
-
variant: 'aiPrompt';
|
|
19
|
-
} & AIPromptTileProps) | (({
|
|
20
|
-
variant: 'ai';
|
|
21
|
-
} & AITileProps) & {
|
|
22
|
-
id?: string;
|
|
23
|
-
tileId?: string | null;
|
|
24
|
-
});
|
|
15
|
+
export type BaseTileProps = GlassTileProps | AIPromptTileProps | AITileProps;
|
|
25
16
|
export declare const BaseTile: React.FC<BaseTileProps>;
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { ElementType } from 'react';
|
|
10
10
|
export type GlassTileProps = {
|
|
11
|
-
|
|
11
|
+
variant?: 'glass';
|
|
12
|
+
tileId: string;
|
|
12
13
|
href?: string | null;
|
|
13
14
|
title?: string | null;
|
|
14
15
|
subtitle?: string | null;
|
|
@@ -16,10 +17,10 @@ export type GlassTileProps = {
|
|
|
16
17
|
customContent?: React.ReactNode | null;
|
|
17
18
|
primaryIcon?: ElementType | null;
|
|
18
19
|
secondaryIcon?: ElementType | null;
|
|
19
|
-
onClick?: (() => void) | null;
|
|
20
|
+
onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
20
21
|
ariaLabel?: string;
|
|
21
22
|
open?: boolean;
|
|
22
23
|
isLoading?: boolean;
|
|
23
24
|
isDisabled?: boolean;
|
|
24
|
-
}
|
|
25
|
+
};
|
|
25
26
|
export declare const GlassTile: React.FC<GlassTileProps>;
|
|
@@ -48,8 +48,8 @@ const GlassTile = ({
|
|
|
48
48
|
}, body);
|
|
49
49
|
}
|
|
50
50
|
return /*#__PURE__*/React.createElement(Link, {
|
|
51
|
-
onClick:
|
|
52
|
-
glassTileClickHandler?.();
|
|
51
|
+
onClick: event => {
|
|
52
|
+
glassTileClickHandler?.(event);
|
|
53
53
|
},
|
|
54
54
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
55
55
|
"aria-label": ariaLabel ?? title ?? 'Glass Tile',
|
|
@@ -15065,7 +15065,7 @@ export declare const ThemeG10: {
|
|
|
15065
15065
|
type: string;
|
|
15066
15066
|
button: {
|
|
15067
15067
|
href: string;
|
|
15068
|
-
icon: import("@carbon/icons
|
|
15068
|
+
icon: import("@carbon/react/icons").CarbonIconType;
|
|
15069
15069
|
text: string;
|
|
15070
15070
|
type: "tertiary";
|
|
15071
15071
|
};
|
|
@@ -30258,7 +30258,7 @@ export declare const ThemeG100: {
|
|
|
30258
30258
|
type: string;
|
|
30259
30259
|
button: {
|
|
30260
30260
|
href: string;
|
|
30261
|
-
icon: import("@carbon/icons
|
|
30261
|
+
icon: import("@carbon/react/icons").CarbonIconType;
|
|
30262
30262
|
text: string;
|
|
30263
30263
|
type: "tertiary";
|
|
30264
30264
|
};
|
|
@@ -62,7 +62,9 @@ const AnimatedHeader = ({
|
|
|
62
62
|
animRef.current.destroy();
|
|
63
63
|
animRef.current = null;
|
|
64
64
|
}
|
|
65
|
-
if (!animationContainer.current || !headerAnimation)
|
|
65
|
+
if (!animationContainer.current || !headerAnimation) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
66
68
|
const animation = lottie.default.loadAnimation({
|
|
67
69
|
container: animationContainer.current,
|
|
68
70
|
animationData: headerAnimation,
|
|
@@ -187,7 +189,7 @@ const AnimatedHeader = ({
|
|
|
187
189
|
const legacyId = tile.id; // old configs
|
|
188
190
|
const resolvedTileId = tileId ?? legacyId;
|
|
189
191
|
const key = resolvedTileId ?? `tile-${index}`;
|
|
190
|
-
const hasAction = tile.href || tile.onClick === 'function';
|
|
192
|
+
const hasAction = tile.href || typeof tile.onClick === 'function';
|
|
191
193
|
return /*#__PURE__*/React.createElement(BaseTile.BaseTile, _rollupPluginBabelHelpers.extends({
|
|
192
194
|
key: key,
|
|
193
195
|
tileId: resolvedTileId
|
|
@@ -196,11 +198,9 @@ const AnimatedHeader = ({
|
|
|
196
198
|
productName: productName,
|
|
197
199
|
isLoading: isLoading || tile.isLoading,
|
|
198
200
|
disabledTaskLabel: disabledTaskLabel,
|
|
199
|
-
onClick: hasAction ?
|
|
201
|
+
onClick: hasAction ? event => {
|
|
200
202
|
tileClickHandler?.(tile);
|
|
201
|
-
|
|
202
|
-
tile.onClick();
|
|
203
|
-
}
|
|
203
|
+
tile.onClick?.(event);
|
|
204
204
|
} : undefined
|
|
205
205
|
}));
|
|
206
206
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
import type { BaseTileProps } from '../../components/Tiles/BaseTile/BaseTile';
|
|
10
|
-
export type Tile =
|
|
11
|
-
tileId: string;
|
|
12
|
-
};
|
|
10
|
+
export type Tile = BaseTileProps;
|
|
13
11
|
export interface TileGroup {
|
|
14
12
|
id: number;
|
|
15
13
|
label: string;
|
|
@@ -21,11 +21,8 @@ const ContentSwitcherSelector = ({
|
|
|
21
21
|
}) => {
|
|
22
22
|
const prefix = usePrefix.usePrefix();
|
|
23
23
|
const blockClass = `${prefix}--animated-header__content-switcher`;
|
|
24
|
-
if (!contentSwitcherConfig)
|
|
25
|
-
|
|
26
|
-
return /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
|
|
27
|
-
className: `${blockClass}-skeleton`
|
|
28
|
-
});
|
|
24
|
+
if (!contentSwitcherConfig) {
|
|
25
|
+
return null;
|
|
29
26
|
}
|
|
30
27
|
const {
|
|
31
28
|
items = [],
|
|
@@ -38,16 +35,18 @@ const ContentSwitcherSelector = ({
|
|
|
38
35
|
} = contentSwitcherConfig;
|
|
39
36
|
const count = visibleCount === 3 ? 3 : 2;
|
|
40
37
|
const visibleItems = items.slice(0, count);
|
|
38
|
+
const selectedIndexSafe = Math.min(Math.max(selectedIndex, 0), visibleItems.length - 1);
|
|
39
|
+
if (isLoading || contentSwitcherConfig.isLoading) {
|
|
40
|
+
return /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
|
|
41
|
+
className: `${blockClass}-skeleton`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
41
44
|
if (visibleItems.length < 2 || visibleItems.length > 3) {
|
|
42
45
|
if (process.env.NODE_ENV !== 'production') {
|
|
43
46
|
console.warn('[ContentSwitcherSelector] contentSwitcherConfig.items must contain 2 or 3 items.');
|
|
44
47
|
}
|
|
45
48
|
return null;
|
|
46
49
|
}
|
|
47
|
-
const selectedIndexSafe = React.useMemo(() => {
|
|
48
|
-
const idx = typeof selectedIndex === 'number' ? selectedIndex : 0;
|
|
49
|
-
return Math.min(Math.max(idx, 0), visibleItems.length - 1);
|
|
50
|
-
}, [selectedIndex, visibleItems.length]);
|
|
51
50
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
51
|
className: `${blockClass}--container`,
|
|
53
52
|
"data-expanded": headerExpanded
|
|
@@ -25,10 +25,8 @@ export type TasksControllerProps = {
|
|
|
25
25
|
tasksControllerConfig?: TasksControllerConfig | null;
|
|
26
26
|
isLoading?: boolean;
|
|
27
27
|
allTileGroups?: TileGroup[];
|
|
28
|
-
selectedTileGroup?: TileGroup
|
|
29
|
-
setSelectedTileGroup?: (
|
|
30
|
-
selectedItem: TileGroup;
|
|
31
|
-
}) => void;
|
|
28
|
+
selectedTileGroup?: TileGroup;
|
|
29
|
+
setSelectedTileGroup?: (e: any) => void;
|
|
32
30
|
};
|
|
33
31
|
declare const TasksController: ({ tasksControllerConfig, isLoading, allTileGroups, selectedTileGroup, setSelectedTileGroup, }: TasksControllerProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
34
32
|
export default TasksController;
|
|
@@ -37,24 +37,11 @@ const TasksController = ({
|
|
|
37
37
|
...dropdownOverrideProps
|
|
38
38
|
} = tasksControllerConfig?.dropdown?.propsOverrides || {};
|
|
39
39
|
|
|
40
|
-
/** Early outs */
|
|
41
|
-
if (!tasksControllerConfig?.type) return null;
|
|
42
|
-
if (isLoading || tasksControllerConfig?.isLoading) {
|
|
43
|
-
return /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
|
|
44
|
-
className: `${blockClass}__task-controller-skeleton`
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Button mode */
|
|
49
|
-
if (tasksControllerConfig?.type === 'button' && tasksControllerConfig?.button?.text) {
|
|
50
|
-
return /*#__PURE__*/React.createElement(react.Button, _rollupPluginBabelHelpers.extends({
|
|
51
|
-
className: `${blockClass}__button${buttonCustomClass ? ` ${buttonCustomClass}` : ''}`
|
|
52
|
-
}, buttonOverrideProps), tasksControllerConfig.button.text);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
40
|
/** Build Dropdown props (uses top-level list/selection/setter) */
|
|
56
41
|
const dropdownProps = React.useMemo(() => {
|
|
57
|
-
if (!allTileGroups?.length)
|
|
42
|
+
if (!allTileGroups?.length) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
58
45
|
return {
|
|
59
46
|
id: `${blockClass}__header-dropdown`,
|
|
60
47
|
className: `${blockClass}__header-dropdown${dropdownCustomClass ? ` ${dropdownCustomClass}` : ''}`,
|
|
@@ -78,6 +65,23 @@ const TasksController = ({
|
|
|
78
65
|
};
|
|
79
66
|
}, [allTileGroups, selectedTileGroup, setSelectedTileGroup, blockClass, dropdownCustomClass, dropdownOverrideProps, dropdownCustomOnChange, tasksControllerConfig?.dropdown?.label, tasksControllerConfig?.dropdown?.ariaLabel]);
|
|
80
67
|
|
|
68
|
+
/** Early outs */
|
|
69
|
+
if (!tasksControllerConfig?.type) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (isLoading || tasksControllerConfig?.isLoading) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
|
|
74
|
+
className: `${blockClass}__task-controller-skeleton`
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Button mode */
|
|
79
|
+
if (tasksControllerConfig?.type === 'button' && tasksControllerConfig?.button?.text) {
|
|
80
|
+
return /*#__PURE__*/React.createElement(react.Button, _rollupPluginBabelHelpers.extends({
|
|
81
|
+
className: `${blockClass}__button${buttonCustomClass ? ` ${buttonCustomClass}` : ''}`
|
|
82
|
+
}, buttonOverrideProps), tasksControllerConfig.button.text);
|
|
83
|
+
}
|
|
84
|
+
|
|
81
85
|
/** Dropdown mode */
|
|
82
86
|
if (tasksControllerConfig?.type === 'dropdown' && dropdownProps) {
|
|
83
87
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -8,17 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { ElementType } from 'react';
|
|
10
10
|
export type AIPromptTileProps = {
|
|
11
|
-
|
|
11
|
+
variant: 'aiPrompt';
|
|
12
|
+
tileId: string;
|
|
12
13
|
href?: string | null;
|
|
13
14
|
title?: string | null;
|
|
14
15
|
disabledTaskLabel?: string | null;
|
|
15
16
|
productName?: string;
|
|
16
17
|
promptPlaceholder?: string;
|
|
17
18
|
primaryIcon?: ElementType | null;
|
|
18
|
-
onClick?: (() => void) | null;
|
|
19
|
+
onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
19
20
|
ariaLabel?: string;
|
|
20
21
|
open?: boolean;
|
|
21
22
|
isLoading?: boolean;
|
|
22
23
|
isDisabled?: boolean;
|
|
23
|
-
}
|
|
24
|
+
};
|
|
24
25
|
export declare const AIPromptTile: React.FC<AIPromptTileProps>;
|
|
@@ -92,8 +92,8 @@ const AIPromptTile = ({
|
|
|
92
92
|
size: "sm",
|
|
93
93
|
disabled: !textInput,
|
|
94
94
|
align: "top-end",
|
|
95
|
-
onClick:
|
|
96
|
-
onClick?.();
|
|
95
|
+
onClick: event => {
|
|
96
|
+
onClick?.(event);
|
|
97
97
|
openInNewTab(`${href}&primed_chat=${textInput}`);
|
|
98
98
|
},
|
|
99
99
|
onKeyDown: handleTextInputKeyDown
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { ElementType } from 'react';
|
|
10
10
|
export type AITileProps = {
|
|
11
|
-
|
|
11
|
+
variant: 'ai';
|
|
12
|
+
tileId: string;
|
|
12
13
|
href?: string | null;
|
|
13
14
|
title?: string | null;
|
|
14
15
|
subtitle?: string | null;
|
|
@@ -16,11 +17,11 @@ export type AITileProps = {
|
|
|
16
17
|
customContent?: React.ReactNode | null;
|
|
17
18
|
primaryIcon?: ElementType | null;
|
|
18
19
|
secondaryIcon?: ElementType | null;
|
|
19
|
-
onClick?: (() => void) | null;
|
|
20
|
+
onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
20
21
|
ariaLabel?: string;
|
|
21
22
|
open?: boolean;
|
|
22
23
|
isLoading?: boolean;
|
|
23
24
|
isDisabled?: boolean;
|
|
24
|
-
}
|
|
25
|
+
};
|
|
25
26
|
export declare const AITile: React.FC<AITileProps>;
|
|
26
27
|
export default AITile;
|
|
@@ -52,8 +52,8 @@ const AITile = ({
|
|
|
52
52
|
}, body);
|
|
53
53
|
}
|
|
54
54
|
return /*#__PURE__*/React.createElement(react.Link, {
|
|
55
|
-
onClick:
|
|
56
|
-
aiTileClickHandler?.();
|
|
55
|
+
onClick: event => {
|
|
56
|
+
aiTileClickHandler?.(event);
|
|
57
57
|
},
|
|
58
58
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
59
59
|
"aria-label": ariaLabel ?? title ?? 'AI Tile',
|
|
@@ -12,14 +12,5 @@ import { type AIPromptTileProps } from '../AIPromptTile/AIPromptTile';
|
|
|
12
12
|
import { type GlassTileProps } from '../GlassTile/GlassTile';
|
|
13
13
|
/** Base Tile router */
|
|
14
14
|
export type TileVariant = 'glass' | 'aiPrompt' | 'ai';
|
|
15
|
-
export type BaseTileProps =
|
|
16
|
-
variant?: 'glass';
|
|
17
|
-
} & GlassTileProps) | ({
|
|
18
|
-
variant: 'aiPrompt';
|
|
19
|
-
} & AIPromptTileProps) | (({
|
|
20
|
-
variant: 'ai';
|
|
21
|
-
} & AITileProps) & {
|
|
22
|
-
id?: string;
|
|
23
|
-
tileId?: string | null;
|
|
24
|
-
});
|
|
15
|
+
export type BaseTileProps = GlassTileProps | AIPromptTileProps | AITileProps;
|
|
25
16
|
export declare const BaseTile: React.FC<BaseTileProps>;
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React, { ElementType } from 'react';
|
|
10
10
|
export type GlassTileProps = {
|
|
11
|
-
|
|
11
|
+
variant?: 'glass';
|
|
12
|
+
tileId: string;
|
|
12
13
|
href?: string | null;
|
|
13
14
|
title?: string | null;
|
|
14
15
|
subtitle?: string | null;
|
|
@@ -16,10 +17,10 @@ export type GlassTileProps = {
|
|
|
16
17
|
customContent?: React.ReactNode | null;
|
|
17
18
|
primaryIcon?: ElementType | null;
|
|
18
19
|
secondaryIcon?: ElementType | null;
|
|
19
|
-
onClick?: (() => void) | null;
|
|
20
|
+
onClick?: ((event: React.MouseEvent<HTMLElement>) => void) | null;
|
|
20
21
|
ariaLabel?: string;
|
|
21
22
|
open?: boolean;
|
|
22
23
|
isLoading?: boolean;
|
|
23
24
|
isDisabled?: boolean;
|
|
24
|
-
}
|
|
25
|
+
};
|
|
25
26
|
export declare const GlassTile: React.FC<GlassTileProps>;
|
|
@@ -50,8 +50,8 @@ const GlassTile = ({
|
|
|
50
50
|
}, body);
|
|
51
51
|
}
|
|
52
52
|
return /*#__PURE__*/React.createElement(react.Link, {
|
|
53
|
-
onClick:
|
|
54
|
-
glassTileClickHandler?.();
|
|
53
|
+
onClick: event => {
|
|
54
|
+
glassTileClickHandler?.(event);
|
|
55
55
|
},
|
|
56
56
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
57
57
|
"aria-label": ariaLabel ?? title ?? 'Glass Tile',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon-labs/react-animated-header",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@carbon-labs/utilities": "canary"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "f339f983db13e1cc4af78c6f9dcd20370b07290d"
|
|
49
49
|
}
|