@carbon-labs/react-animated-header 0.31.0 → 0.33.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.
Files changed (52) hide show
  1. package/es/__stories__/AnimatedHeader.stories.d.ts +148 -1944
  2. package/es/__stories__/data/index.d.ts +52 -225
  3. package/es/_virtual/lottie.js +1 -1
  4. package/es/components/AnimatedHeader/AnimatedHeader.d.ts +11 -27
  5. package/es/components/AnimatedHeader/AnimatedHeader.js +42 -36
  6. package/es/components/AnimatedHeader/types.d.ts +24 -0
  7. package/es/components/HeaderTitle/HeaderTitle.d.ts +1 -1
  8. package/es/components/TasksController/TasksController.d.ts +1 -1
  9. package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +10 -11
  10. package/es/components/Tiles/AIPromptTile/AIPromptTile.js +14 -16
  11. package/es/components/Tiles/AITile/AITile.d.ts +26 -0
  12. package/es/components/Tiles/AITile/AITile.js +65 -0
  13. package/es/components/Tiles/AITile/AITileBody.d.ts +19 -0
  14. package/es/components/Tiles/AITile/AITileBody.js +59 -0
  15. package/es/components/Tiles/BaseTile/BaseTile.d.ts +15 -18
  16. package/es/components/Tiles/BaseTile/BaseTile.js +34 -4
  17. package/es/components/Tiles/GlassTile/GlassTile.d.ts +13 -9
  18. package/es/components/Tiles/GlassTile/GlassTile.js +13 -15
  19. package/es/components/Tiles/GlassTile/GlassTileBody.d.ts +4 -4
  20. package/es/components/Tiles/GlassTile/GlassTileBody.js +6 -6
  21. package/es/components/Tiles/index.d.ts +2 -1
  22. package/es/index.d.ts +3 -2
  23. package/es/node_modules/lottie-web/build/player/lottie.js +194 -193
  24. package/lib/__stories__/AnimatedHeader.stories.d.ts +148 -1944
  25. package/lib/__stories__/data/index.d.ts +52 -225
  26. package/lib/_virtual/lottie.js +1 -1
  27. package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +11 -27
  28. package/lib/components/AnimatedHeader/AnimatedHeader.js +42 -36
  29. package/lib/components/AnimatedHeader/types.d.ts +24 -0
  30. package/lib/components/HeaderTitle/HeaderTitle.d.ts +1 -1
  31. package/lib/components/TasksController/TasksController.d.ts +1 -1
  32. package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +10 -11
  33. package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +14 -16
  34. package/lib/components/Tiles/AITile/AITile.d.ts +26 -0
  35. package/lib/components/Tiles/AITile/AITile.js +70 -0
  36. package/lib/components/Tiles/AITile/AITileBody.d.ts +19 -0
  37. package/lib/components/Tiles/AITile/AITileBody.js +61 -0
  38. package/lib/components/Tiles/BaseTile/BaseTile.d.ts +15 -18
  39. package/lib/components/Tiles/BaseTile/BaseTile.js +34 -4
  40. package/lib/components/Tiles/GlassTile/GlassTile.d.ts +13 -9
  41. package/lib/components/Tiles/GlassTile/GlassTile.js +13 -15
  42. package/lib/components/Tiles/GlassTile/GlassTileBody.d.ts +4 -4
  43. package/lib/components/Tiles/GlassTile/GlassTileBody.js +6 -6
  44. package/lib/components/Tiles/index.d.ts +2 -1
  45. package/lib/index.d.ts +3 -2
  46. package/lib/node_modules/lottie-web/build/player/lottie.js +194 -193
  47. package/package.json +2 -2
  48. package/scss/AnimatedHeader/animated-header.scss +66 -36
  49. package/scss/Tiles/AIPromptTile/ai-prompt-tile.scss +14 -2
  50. package/scss/Tiles/AITile/ai-tile.scss +222 -0
  51. package/scss/Tiles/GlassTile/glass-tile.scss +14 -2
  52. package/scss/animated-header.scss +1 -0
@@ -0,0 +1,65 @@
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 { Link } from '@carbon/react';
10
+ import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
11
+ import { AITileBody } from './AITileBody.js';
12
+
13
+ const AITile = ({
14
+ tileId,
15
+ href,
16
+ title,
17
+ subtitle,
18
+ disabledTaskLabel,
19
+ customContent,
20
+ primaryIcon: PrimaryIcon,
21
+ secondaryIcon: SecondaryIcon,
22
+ onClick: aiTileClickHandler,
23
+ ariaLabel,
24
+ open,
25
+ isLoading,
26
+ isDisabled
27
+ }) => {
28
+ const prefix = usePrefix();
29
+ const blockClass = `${prefix}--animated-header__ai-tile`;
30
+ const body = /*#__PURE__*/React.createElement(AITileBody, {
31
+ open: open,
32
+ primaryIcon: PrimaryIcon,
33
+ secondaryIcon: SecondaryIcon,
34
+ title: title,
35
+ subtitle: subtitle,
36
+ customContent: customContent,
37
+ isLoading: isLoading
38
+ });
39
+
40
+ // Non-interactive tile
41
+ if (!href && !aiTileClickHandler) {
42
+ return /*#__PURE__*/React.createElement("div", {
43
+ className: `${prefix}--animated-header__tile ${blockClass}`,
44
+ key: tileId,
45
+ "aria-label": ariaLabel ?? title ?? 'AI Tile',
46
+ title: isDisabled ? disabledTaskLabel ?? '' : '',
47
+ tabIndex: -1
48
+ }, body);
49
+ }
50
+ return /*#__PURE__*/React.createElement(Link, {
51
+ onClick: () => {
52
+ aiTileClickHandler?.();
53
+ },
54
+ className: `${prefix}--animated-header__tile ${blockClass}`,
55
+ "aria-label": ariaLabel ?? title ?? 'AI Tile',
56
+ role: "listitem",
57
+ tabIndex: isDisabled || isLoading ? -1 : 0,
58
+ key: tileId,
59
+ href: href ?? undefined,
60
+ disabled: isDisabled || isLoading,
61
+ title: isDisabled ? disabledTaskLabel ?? '' : ''
62
+ }, body);
63
+ };
64
+
65
+ export { AITile, AITile as default };
@@ -0,0 +1,19 @@
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 { ElementType, ReactNode } from 'react';
10
+ export type AITileBodyProps = {
11
+ open?: boolean;
12
+ title?: string | null;
13
+ subtitle?: string | null;
14
+ customContent?: ReactNode;
15
+ primaryIcon?: ElementType | null;
16
+ secondaryIcon?: ElementType | null;
17
+ isLoading?: boolean;
18
+ };
19
+ export declare const AITileBody: ({ open, title, subtitle, customContent, primaryIcon: PrimaryIcon, secondaryIcon: SecondaryIcon, isLoading, }: AITileBodyProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,59 @@
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 { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
10
+ import { SkeletonPlaceholder, AILabel } from '@carbon/react';
11
+
12
+ var _AILabel;
13
+ const AITileBody = ({
14
+ open,
15
+ title,
16
+ subtitle,
17
+ customContent,
18
+ primaryIcon: PrimaryIcon,
19
+ secondaryIcon: SecondaryIcon,
20
+ isLoading
21
+ }) => {
22
+ const prefix = usePrefix();
23
+ const blockClass = `${prefix}--animated-header__ai-tile`;
24
+ if (isLoading) {
25
+ return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
26
+ className: `${blockClass}--loading-skeleton`
27
+ });
28
+ }
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ className: `${blockClass}--body`,
31
+ "data-expanded": open
32
+ }, /*#__PURE__*/React.createElement("div", {
33
+ className: `${blockClass}--body-background`
34
+ }), /*#__PURE__*/React.createElement("div", {
35
+ className: `${blockClass}--body-gradient`
36
+ }), customContent ? /*#__PURE__*/React.createElement("div", {
37
+ className: `${blockClass}--custom-content`
38
+ }, customContent) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
39
+ className: `${blockClass}--icons`
40
+ }, PrimaryIcon && /*#__PURE__*/React.createElement(PrimaryIcon, {
41
+ fill: `var(--cds-icon-secondary)`,
42
+ size: 24
43
+ }), _AILabel || (_AILabel = /*#__PURE__*/React.createElement(AILabel, {
44
+ autoAlign: true,
45
+ aiText: "AI",
46
+ size: "xs"
47
+ }))), /*#__PURE__*/React.createElement("div", {
48
+ className: `${blockClass}--title`
49
+ }, title), /*#__PURE__*/React.createElement("div", {
50
+ className: `${blockClass}--footer`
51
+ }, subtitle && /*#__PURE__*/React.createElement("div", {
52
+ className: `${blockClass}--subtitle`
53
+ }, subtitle), SecondaryIcon && /*#__PURE__*/React.createElement(SecondaryIcon, {
54
+ size: 16,
55
+ fill: `var(--cds-icon-secondary)`
56
+ }))));
57
+ };
58
+
59
+ export { AITileBody };
@@ -6,23 +6,20 @@
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 React, { ElementType, ReactNode } from 'react';
10
- /** Base Tile */
11
- interface BaseTileProps {
9
+ import React from 'react';
10
+ import { type AITileProps } from '../AITile/AITile';
11
+ import { type AIPromptTileProps } from '../AIPromptTile/AIPromptTile';
12
+ import { type GlassTileProps } from '../GlassTile/GlassTile';
13
+ /** Base Tile router */
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) & {
12
22
  id?: string;
13
- open?: boolean;
14
- href?: string | null;
15
- mainIcon?: ElementType | null;
16
- secondaryIcon?: ElementType | null;
17
- title?: string | null;
18
- subtitle?: string | null;
19
- productName?: string;
20
- customContent?: ReactNode;
21
- isLoading?: boolean;
22
- isDisabled?: boolean;
23
- disabledTaskLabel?: string;
24
- onClick?: (() => void) | null;
25
- ariaLabel?: string;
26
- }
23
+ tileId?: string | null;
24
+ });
27
25
  export declare const BaseTile: React.FC<BaseTileProps>;
28
- export {};
@@ -6,16 +6,46 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
+ import { AITile } from '../AITile/AITile.js';
9
10
  import { AIPromptTile } from '../AIPromptTile/AIPromptTile.js';
10
11
  import { GlassTile } from '../GlassTile/GlassTile.js';
11
12
 
12
- /** Base Tile */
13
+ /** Base Tile router */
13
14
 
14
- const BaseTile = props => {
15
+ function inferVariant(props) {
16
+ if (props.variant) {
17
+ return props.variant;
18
+ }
15
19
  if (props.id === 'ai-tile') {
16
- return /*#__PURE__*/React.createElement(AIPromptTile, props);
20
+ return 'aiPrompt';
21
+ }
22
+ return 'glass';
23
+ }
24
+ const BaseTile = props => {
25
+ // Back-compat: alias legacy icon prop to the new name
26
+ const normalizedProps = {
27
+ ...props,
28
+ primaryIcon: props.primaryIcon ?? props.mainIcon // ← fallback
29
+ };
30
+
31
+ // strip legacy id, but flow it into tileId if needed
32
+ const {
33
+ id: legacyId,
34
+ ...rest
35
+ } = normalizedProps;
36
+ const forward = {
37
+ ...rest,
38
+ tileId: rest.tileId ?? legacyId
39
+ };
40
+ switch (inferVariant(props)) {
41
+ case 'ai':
42
+ return /*#__PURE__*/React.createElement(AITile, forward);
43
+ case 'aiPrompt':
44
+ return /*#__PURE__*/React.createElement(AIPromptTile, forward);
45
+ case 'glass':
46
+ default:
47
+ return /*#__PURE__*/React.createElement(GlassTile, forward);
17
48
  }
18
- return /*#__PURE__*/React.createElement(GlassTile, props);
19
49
  };
20
50
 
21
51
  export { BaseTile };
@@ -6,16 +6,20 @@
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 React from 'react';
10
- /** Primary UI component for user interaction */
11
- interface GlassTileProps {
9
+ import React, { ElementType } from 'react';
10
+ export type GlassTileProps = {
11
+ tileId: string | null;
12
12
  href?: string | null;
13
- id?: string;
14
- isLoading?: boolean;
15
- isDisabled?: boolean;
16
- disabledTaskLabel?: string;
13
+ title?: string | null;
14
+ subtitle?: string | null;
15
+ disabledTaskLabel?: string | null;
16
+ customContent?: React.ReactNode | null;
17
+ primaryIcon?: ElementType | null;
18
+ secondaryIcon?: ElementType | null;
17
19
  onClick?: (() => void) | null;
18
20
  ariaLabel?: string;
19
- }
21
+ open?: boolean;
22
+ isLoading?: boolean;
23
+ isDisabled?: boolean;
24
+ } & Record<string, unknown>;
20
25
  export declare const GlassTile: React.FC<GlassTileProps>;
21
- export {};
@@ -10,29 +10,27 @@ import { Link } from '@carbon/react';
10
10
  import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
11
11
  import { GlassTileBody } from './GlassTileBody.js';
12
12
 
13
- /** Primary UI component for user interaction */
14
-
15
13
  const GlassTile = ({
14
+ tileId,
16
15
  href,
17
- id,
18
- mainIcon,
19
- open,
20
- secondaryIcon,
21
- subtitle,
22
16
  title,
23
- customContent,
24
- isLoading,
25
- isDisabled,
17
+ subtitle,
26
18
  disabledTaskLabel,
19
+ customContent,
20
+ primaryIcon: PrimaryIcon,
21
+ secondaryIcon: SecondaryIcon,
27
22
  onClick: glassTileClickHandler,
28
- ariaLabel
23
+ ariaLabel,
24
+ open,
25
+ isLoading,
26
+ isDisabled
29
27
  }) => {
30
28
  const prefix = usePrefix();
31
29
  const blockClass = `${prefix}--animated-header__glass-tile`;
32
30
  const body = /*#__PURE__*/React.createElement(GlassTileBody, {
33
- mainIcon: mainIcon,
34
31
  open: open,
35
- secondaryIcon: secondaryIcon,
32
+ primaryIcon: PrimaryIcon,
33
+ secondaryIcon: SecondaryIcon,
36
34
  title: title,
37
35
  subtitle: subtitle,
38
36
  customContent: customContent,
@@ -43,7 +41,7 @@ const GlassTile = ({
43
41
  if (!href && !glassTileClickHandler) {
44
42
  return /*#__PURE__*/React.createElement("div", {
45
43
  className: `${prefix}--animated-header__tile ${blockClass}`,
46
- key: id,
44
+ key: tileId,
47
45
  "aria-label": ariaLabel ?? title ?? 'Glass Tile',
48
46
  title: isDisabled ? disabledTaskLabel ?? '' : '',
49
47
  tabIndex: -1
@@ -57,7 +55,7 @@ const GlassTile = ({
57
55
  "aria-label": ariaLabel ?? title ?? 'Glass Tile',
58
56
  role: "listitem",
59
57
  tabIndex: isDisabled || isLoading ? -1 : 0,
60
- key: id,
58
+ key: tileId,
61
59
  href: href ?? undefined,
62
60
  disabled: isDisabled || isLoading,
63
61
  title: isDisabled ? disabledTaskLabel ?? '' : ''
@@ -8,12 +8,12 @@
8
8
  */
9
9
  import { ElementType, ReactNode } from 'react';
10
10
  export type GlassTileBodyProps = {
11
- mainIcon?: ElementType | null;
12
11
  open?: boolean;
13
- secondaryIcon?: ElementType | null;
14
- subtitle?: string | null;
15
12
  title?: string | null;
13
+ subtitle?: string | null;
16
14
  customContent?: ReactNode;
15
+ primaryIcon?: ElementType | null;
16
+ secondaryIcon?: ElementType | null;
17
17
  isLoading?: boolean;
18
18
  };
19
- export declare const GlassTileBody: ({ mainIcon: MainIcon, open, secondaryIcon: SecondaryIcon, subtitle, title, customContent, isLoading, }: GlassTileBodyProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const GlassTileBody: ({ open, title, subtitle, customContent, primaryIcon: PrimaryIcon, secondaryIcon: SecondaryIcon, isLoading, }: GlassTileBodyProps) => import("react/jsx-runtime").JSX.Element;
@@ -10,31 +10,31 @@ import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePr
10
10
  import { SkeletonPlaceholder } from '@carbon/react';
11
11
 
12
12
  const GlassTileBody = ({
13
- mainIcon: MainIcon,
14
13
  open,
15
- secondaryIcon: SecondaryIcon,
16
- subtitle,
17
14
  title,
15
+ subtitle,
18
16
  customContent,
17
+ primaryIcon: PrimaryIcon,
18
+ secondaryIcon: SecondaryIcon,
19
19
  isLoading
20
20
  }) => {
21
21
  const prefix = usePrefix();
22
22
  const blockClass = `${prefix}--animated-header__glass-tile`;
23
- const collapsed = `${blockClass}--collapsed`;
24
23
  if (isLoading) {
25
24
  return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
26
25
  className: `${blockClass}--loading-skeleton`
27
26
  });
28
27
  }
29
28
  return /*#__PURE__*/React.createElement("div", {
30
- className: `${blockClass}--body${!open ? ` ${collapsed}` : ''}`
29
+ className: `${blockClass}--body`,
30
+ "data-expanded": open
31
31
  }, /*#__PURE__*/React.createElement("div", {
32
32
  className: `${blockClass}--body-background`
33
33
  }), customContent ? /*#__PURE__*/React.createElement("div", {
34
34
  className: `${blockClass}--custom-content`
35
35
  }, customContent) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
36
36
  className: `${blockClass}--icons`
37
- }, MainIcon && /*#__PURE__*/React.createElement(MainIcon, {
37
+ }, PrimaryIcon && /*#__PURE__*/React.createElement(PrimaryIcon, {
38
38
  fill: `var(--cds-icon-secondary)`,
39
39
  size: 24
40
40
  })), /*#__PURE__*/React.createElement("div", {
@@ -6,7 +6,8 @@
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 { AITile } from './AITile/AITile';
9
10
  import { AIPromptTile } from './AIPromptTile/AIPromptTile';
10
11
  import { BaseTile } from './BaseTile/BaseTile';
11
12
  import { GlassTile } from './GlassTile/GlassTile';
12
- export { AIPromptTile, BaseTile, GlassTile };
13
+ export { AITile, AIPromptTile, BaseTile, GlassTile };
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, { AriaLabels, TileGroup } from './components/AnimatedHeader/AnimatedHeader';
9
+ import AnimatedHeader from './components/AnimatedHeader/AnimatedHeader';
10
+ import { AriaLabels, TileGroup } from './components/AnimatedHeader/types';
10
11
  import HeaderTitle from './components/HeaderTitle/HeaderTitle';
11
- import { BaseTile } from './components/Tiles/index.js';
12
+ import { BaseTile } from './components/Tiles/index';
12
13
  export * from './assets';
13
14
  export type { Workspace, WorkspaceSelectorConfig, } from './components/WorkspaceSelector/WorkspaceSelector';
14
15
  export type { TasksControllerConfig } from './components/TasksController/TasksController';