@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,70 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var React = require('react');
13
+ var react = require('@carbon/react');
14
+ var usePrefix = require('../../../node_modules/@carbon-labs/utilities/es/usePrefix.js');
15
+ var AITileBody = require('./AITileBody.js');
16
+
17
+ const AITile = ({
18
+ tileId,
19
+ href,
20
+ title,
21
+ subtitle,
22
+ disabledTaskLabel,
23
+ customContent,
24
+ primaryIcon: PrimaryIcon,
25
+ secondaryIcon: SecondaryIcon,
26
+ onClick: aiTileClickHandler,
27
+ ariaLabel,
28
+ open,
29
+ isLoading,
30
+ isDisabled
31
+ }) => {
32
+ const prefix = usePrefix.usePrefix();
33
+ const blockClass = `${prefix}--animated-header__ai-tile`;
34
+ const body = /*#__PURE__*/React.createElement(AITileBody.AITileBody, {
35
+ open: open,
36
+ primaryIcon: PrimaryIcon,
37
+ secondaryIcon: SecondaryIcon,
38
+ title: title,
39
+ subtitle: subtitle,
40
+ customContent: customContent,
41
+ isLoading: isLoading
42
+ });
43
+
44
+ // Non-interactive tile
45
+ if (!href && !aiTileClickHandler) {
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ className: `${prefix}--animated-header__tile ${blockClass}`,
48
+ key: tileId,
49
+ "aria-label": ariaLabel ?? title ?? 'AI Tile',
50
+ title: isDisabled ? disabledTaskLabel ?? '' : '',
51
+ tabIndex: -1
52
+ }, body);
53
+ }
54
+ return /*#__PURE__*/React.createElement(react.Link, {
55
+ onClick: () => {
56
+ aiTileClickHandler?.();
57
+ },
58
+ className: `${prefix}--animated-header__tile ${blockClass}`,
59
+ "aria-label": ariaLabel ?? title ?? 'AI Tile',
60
+ role: "listitem",
61
+ tabIndex: isDisabled || isLoading ? -1 : 0,
62
+ key: tileId,
63
+ href: href ?? undefined,
64
+ disabled: isDisabled || isLoading,
65
+ title: isDisabled ? disabledTaskLabel ?? '' : ''
66
+ }, body);
67
+ };
68
+
69
+ exports.AITile = AITile;
70
+ exports.default = AITile;
@@ -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,61 @@
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
+ 'use strict';
9
+
10
+ var React = require('react');
11
+ var usePrefix = require('../../../node_modules/@carbon-labs/utilities/es/usePrefix.js');
12
+ var react = require('@carbon/react');
13
+
14
+ var _AILabel;
15
+ const AITileBody = ({
16
+ open,
17
+ title,
18
+ subtitle,
19
+ customContent,
20
+ primaryIcon: PrimaryIcon,
21
+ secondaryIcon: SecondaryIcon,
22
+ isLoading
23
+ }) => {
24
+ const prefix = usePrefix.usePrefix();
25
+ const blockClass = `${prefix}--animated-header__ai-tile`;
26
+ if (isLoading) {
27
+ return /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
28
+ className: `${blockClass}--loading-skeleton`
29
+ });
30
+ }
31
+ return /*#__PURE__*/React.createElement("div", {
32
+ className: `${blockClass}--body`,
33
+ "data-expanded": open
34
+ }, /*#__PURE__*/React.createElement("div", {
35
+ className: `${blockClass}--body-background`
36
+ }), /*#__PURE__*/React.createElement("div", {
37
+ className: `${blockClass}--body-gradient`
38
+ }), customContent ? /*#__PURE__*/React.createElement("div", {
39
+ className: `${blockClass}--custom-content`
40
+ }, customContent) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
41
+ className: `${blockClass}--icons`
42
+ }, PrimaryIcon && /*#__PURE__*/React.createElement(PrimaryIcon, {
43
+ fill: `var(--cds-icon-secondary)`,
44
+ size: 24
45
+ }), _AILabel || (_AILabel = /*#__PURE__*/React.createElement(react.AILabel, {
46
+ autoAlign: true,
47
+ aiText: "AI",
48
+ size: "xs"
49
+ }))), /*#__PURE__*/React.createElement("div", {
50
+ className: `${blockClass}--title`
51
+ }, title), /*#__PURE__*/React.createElement("div", {
52
+ className: `${blockClass}--footer`
53
+ }, subtitle && /*#__PURE__*/React.createElement("div", {
54
+ className: `${blockClass}--subtitle`
55
+ }, subtitle), SecondaryIcon && /*#__PURE__*/React.createElement(SecondaryIcon, {
56
+ size: 16,
57
+ fill: `var(--cds-icon-secondary)`
58
+ }))));
59
+ };
60
+
61
+ exports.AITileBody = 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 {};
@@ -8,16 +8,46 @@
8
8
  'use strict';
9
9
 
10
10
  var React = require('react');
11
+ var AITile = require('../AITile/AITile.js');
11
12
  var AIPromptTile = require('../AIPromptTile/AIPromptTile.js');
12
13
  var GlassTile = require('../GlassTile/GlassTile.js');
13
14
 
14
- /** Base Tile */
15
+ /** Base Tile router */
15
16
 
16
- const BaseTile = props => {
17
+ function inferVariant(props) {
18
+ if (props.variant) {
19
+ return props.variant;
20
+ }
17
21
  if (props.id === 'ai-tile') {
18
- return /*#__PURE__*/React.createElement(AIPromptTile.AIPromptTile, props);
22
+ return 'aiPrompt';
23
+ }
24
+ return 'glass';
25
+ }
26
+ const BaseTile = props => {
27
+ // Back-compat: alias legacy icon prop to the new name
28
+ const normalizedProps = {
29
+ ...props,
30
+ primaryIcon: props.primaryIcon ?? props.mainIcon // ← fallback
31
+ };
32
+
33
+ // strip legacy id, but flow it into tileId if needed
34
+ const {
35
+ id: legacyId,
36
+ ...rest
37
+ } = normalizedProps;
38
+ const forward = {
39
+ ...rest,
40
+ tileId: rest.tileId ?? legacyId
41
+ };
42
+ switch (inferVariant(props)) {
43
+ case 'ai':
44
+ return /*#__PURE__*/React.createElement(AITile.AITile, forward);
45
+ case 'aiPrompt':
46
+ return /*#__PURE__*/React.createElement(AIPromptTile.AIPromptTile, forward);
47
+ case 'glass':
48
+ default:
49
+ return /*#__PURE__*/React.createElement(GlassTile.GlassTile, forward);
19
50
  }
20
- return /*#__PURE__*/React.createElement(GlassTile.GlassTile, props);
21
51
  };
22
52
 
23
53
  exports.BaseTile = 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 {};
@@ -12,29 +12,27 @@ var react = require('@carbon/react');
12
12
  var usePrefix = require('../../../node_modules/@carbon-labs/utilities/es/usePrefix.js');
13
13
  var GlassTileBody = require('./GlassTileBody.js');
14
14
 
15
- /** Primary UI component for user interaction */
16
-
17
15
  const GlassTile = ({
16
+ tileId,
18
17
  href,
19
- id,
20
- mainIcon,
21
- open,
22
- secondaryIcon,
23
- subtitle,
24
18
  title,
25
- customContent,
26
- isLoading,
27
- isDisabled,
19
+ subtitle,
28
20
  disabledTaskLabel,
21
+ customContent,
22
+ primaryIcon: PrimaryIcon,
23
+ secondaryIcon: SecondaryIcon,
29
24
  onClick: glassTileClickHandler,
30
- ariaLabel
25
+ ariaLabel,
26
+ open,
27
+ isLoading,
28
+ isDisabled
31
29
  }) => {
32
30
  const prefix = usePrefix.usePrefix();
33
31
  const blockClass = `${prefix}--animated-header__glass-tile`;
34
32
  const body = /*#__PURE__*/React.createElement(GlassTileBody.GlassTileBody, {
35
- mainIcon: mainIcon,
36
33
  open: open,
37
- secondaryIcon: secondaryIcon,
34
+ primaryIcon: PrimaryIcon,
35
+ secondaryIcon: SecondaryIcon,
38
36
  title: title,
39
37
  subtitle: subtitle,
40
38
  customContent: customContent,
@@ -45,7 +43,7 @@ const GlassTile = ({
45
43
  if (!href && !glassTileClickHandler) {
46
44
  return /*#__PURE__*/React.createElement("div", {
47
45
  className: `${prefix}--animated-header__tile ${blockClass}`,
48
- key: id,
46
+ key: tileId,
49
47
  "aria-label": ariaLabel ?? title ?? 'Glass Tile',
50
48
  title: isDisabled ? disabledTaskLabel ?? '' : '',
51
49
  tabIndex: -1
@@ -59,7 +57,7 @@ const GlassTile = ({
59
57
  "aria-label": ariaLabel ?? title ?? 'Glass Tile',
60
58
  role: "listitem",
61
59
  tabIndex: isDisabled || isLoading ? -1 : 0,
62
- key: id,
60
+ key: tileId,
63
61
  href: href ?? undefined,
64
62
  disabled: isDisabled || isLoading,
65
63
  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;
@@ -12,31 +12,31 @@ var usePrefix = require('../../../node_modules/@carbon-labs/utilities/es/usePref
12
12
  var react = require('@carbon/react');
13
13
 
14
14
  const GlassTileBody = ({
15
- mainIcon: MainIcon,
16
15
  open,
17
- secondaryIcon: SecondaryIcon,
18
- subtitle,
19
16
  title,
17
+ subtitle,
20
18
  customContent,
19
+ primaryIcon: PrimaryIcon,
20
+ secondaryIcon: SecondaryIcon,
21
21
  isLoading
22
22
  }) => {
23
23
  const prefix = usePrefix.usePrefix();
24
24
  const blockClass = `${prefix}--animated-header__glass-tile`;
25
- const collapsed = `${blockClass}--collapsed`;
26
25
  if (isLoading) {
27
26
  return /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
28
27
  className: `${blockClass}--loading-skeleton`
29
28
  });
30
29
  }
31
30
  return /*#__PURE__*/React.createElement("div", {
32
- className: `${blockClass}--body${!open ? ` ${collapsed}` : ''}`
31
+ className: `${blockClass}--body`,
32
+ "data-expanded": open
33
33
  }, /*#__PURE__*/React.createElement("div", {
34
34
  className: `${blockClass}--body-background`
35
35
  }), customContent ? /*#__PURE__*/React.createElement("div", {
36
36
  className: `${blockClass}--custom-content`
37
37
  }, customContent) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
38
38
  className: `${blockClass}--icons`
39
- }, MainIcon && /*#__PURE__*/React.createElement(MainIcon, {
39
+ }, PrimaryIcon && /*#__PURE__*/React.createElement(PrimaryIcon, {
40
40
  fill: `var(--cds-icon-secondary)`,
41
41
  size: 24
42
42
  })), /*#__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/lib/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';