@carbon-labs/react-animated-header 0.15.0 → 0.17.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 (34) hide show
  1. package/es/__stories__/AnimatedHeader.stories.d.ts +882 -44
  2. package/es/__stories__/data/index.d.ts +112 -3
  3. package/es/components/AnimatedHeader/AnimatedHeader.d.ts +11 -31
  4. package/es/components/AnimatedHeader/AnimatedHeader.js +65 -104
  5. package/es/components/TasksController/TasksController.d.ts +30 -0
  6. package/es/components/TasksController/TasksController.js +73 -0
  7. package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +6 -3
  8. package/es/components/Tiles/AIPromptTile/AIPromptTile.js +12 -6
  9. package/es/components/Tiles/BaseTile/BaseTile.d.ts +8 -5
  10. package/es/components/Tiles/BaseTile/BaseTile.js +5 -27
  11. package/es/components/Tiles/GlassTile/GlassTile.d.ts +8 -5
  12. package/es/components/Tiles/GlassTile/GlassTile.js +10 -3
  13. package/es/components/WorkspaceSelector/WorkspaceSelector.d.ts +27 -0
  14. package/es/components/WorkspaceSelector/WorkspaceSelector.js +57 -0
  15. package/es/index.d.ts +2 -0
  16. package/lib/__stories__/AnimatedHeader.stories.d.ts +882 -44
  17. package/lib/__stories__/data/index.d.ts +112 -3
  18. package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +11 -31
  19. package/lib/components/AnimatedHeader/AnimatedHeader.js +64 -103
  20. package/lib/components/TasksController/TasksController.d.ts +30 -0
  21. package/lib/components/TasksController/TasksController.js +77 -0
  22. package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +6 -3
  23. package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +11 -5
  24. package/lib/components/Tiles/BaseTile/BaseTile.d.ts +8 -5
  25. package/lib/components/Tiles/BaseTile/BaseTile.js +5 -27
  26. package/lib/components/Tiles/GlassTile/GlassTile.d.ts +8 -5
  27. package/lib/components/Tiles/GlassTile/GlassTile.js +9 -2
  28. package/lib/components/WorkspaceSelector/WorkspaceSelector.d.ts +27 -0
  29. package/lib/components/WorkspaceSelector/WorkspaceSelector.js +61 -0
  30. package/lib/index.d.ts +2 -0
  31. package/package.json +2 -2
  32. package/scss/AnimatedHeader/animated-header.scss +37 -6
  33. package/scss/Tiles/AIPromptTile/ai-prompt-tile.scss +22 -0
  34. package/scss/Tiles/GlassTile/glass-tile.scss +22 -0
@@ -27,6 +27,26 @@ export const headerTiles: ({
27
27
  title: string;
28
28
  subtitle: string;
29
29
  mainIcon: string;
30
+ isLoading: boolean;
31
+ isDisabled?: undefined;
32
+ secondaryIcon?: undefined;
33
+ } | {
34
+ id: string;
35
+ href: string;
36
+ title: string;
37
+ subtitle: string;
38
+ mainIcon: string;
39
+ isLoading?: undefined;
40
+ isDisabled?: undefined;
41
+ secondaryIcon?: undefined;
42
+ } | {
43
+ id: string;
44
+ href: string;
45
+ title: string;
46
+ subtitle: string;
47
+ mainIcon: string;
48
+ isDisabled: boolean;
49
+ isLoading?: undefined;
30
50
  secondaryIcon?: undefined;
31
51
  } | {
32
52
  id: string;
@@ -35,6 +55,8 @@ export const headerTiles: ({
35
55
  mainIcon: string;
36
56
  secondaryIcon: string;
37
57
  subtitle?: undefined;
58
+ isLoading?: undefined;
59
+ isDisabled?: undefined;
38
60
  })[];
39
61
  } | {
40
62
  id: number;
@@ -44,7 +66,7 @@ export const headerTiles: ({
44
66
  customContent: import("react/jsx-runtime").JSX.Element;
45
67
  }[];
46
68
  })[];
47
- export namespace tasksConfigButton {
69
+ export namespace tasksControllerConfigButton {
48
70
  let type: string;
49
71
  namespace button {
50
72
  export let href: string;
@@ -54,11 +76,98 @@ export namespace tasksConfigButton {
54
76
  export { type_1 as type };
55
77
  }
56
78
  }
57
- export namespace tasksConfigDropdown {
79
+ export namespace tasksControllerConfigDropdown {
58
80
  let type_2: string;
59
81
  export { type_2 as type };
60
82
  export namespace dropdown {
61
- let label: string;
83
+ export let label: string;
84
+ export { headerTiles as allTileGroups };
85
+ export let selectedTileGroup: {
86
+ id: number;
87
+ label: string;
88
+ tiles: ({
89
+ id: string;
90
+ href: string;
91
+ title: string;
92
+ mainIcon: string;
93
+ subtitle?: undefined;
94
+ } | {
95
+ id: string;
96
+ href: string;
97
+ title: string;
98
+ subtitle: string;
99
+ mainIcon: string;
100
+ })[];
101
+ } | {
102
+ id: number;
103
+ label: string;
104
+ tiles: ({
105
+ id: string;
106
+ href: string;
107
+ title: string;
108
+ subtitle: string;
109
+ mainIcon: string;
110
+ isLoading: boolean;
111
+ isDisabled?: undefined;
112
+ secondaryIcon?: undefined;
113
+ } | {
114
+ id: string;
115
+ href: string;
116
+ title: string;
117
+ subtitle: string;
118
+ mainIcon: string;
119
+ isLoading?: undefined;
120
+ isDisabled?: undefined;
121
+ secondaryIcon?: undefined;
122
+ } | {
123
+ id: string;
124
+ href: string;
125
+ title: string;
126
+ subtitle: string;
127
+ mainIcon: string;
128
+ isDisabled: boolean;
129
+ isLoading?: undefined;
130
+ secondaryIcon?: undefined;
131
+ } | {
132
+ id: string;
133
+ href: string;
134
+ title: string;
135
+ mainIcon: string;
136
+ secondaryIcon: string;
137
+ subtitle?: undefined;
138
+ isLoading?: undefined;
139
+ isDisabled?: undefined;
140
+ })[];
141
+ } | {
142
+ id: number;
143
+ label: string;
144
+ tiles: {
145
+ id: string;
146
+ customContent: import("react/jsx-runtime").JSX.Element;
147
+ }[];
148
+ };
149
+ export function setSelectedTileGroup(): void;
62
150
  }
63
151
  }
152
+ export namespace tasksControllerConfigLoading {
153
+ let type_3: string;
154
+ export { type_3 as type };
155
+ export let isLoading: boolean;
156
+ }
157
+ export namespace workspaceSelectorConfig {
158
+ export { workspaceData as allWorkspaces };
159
+ export function setSelectedWorkspace(): void;
160
+ export namespace propsOverrides {
161
+ let label_1: string;
162
+ export { label_1 as label };
163
+ export function renderSelectedItem(item: any): string;
164
+ }
165
+ }
166
+ export namespace workspaceSelectorConfigLoading {
167
+ export { workspaceData as allWorkspaces };
168
+ export function setSelectedWorkspace_1(): void;
169
+ export { setSelectedWorkspace_1 as setSelectedWorkspace };
170
+ let isLoading_1: boolean;
171
+ export { isLoading_1 as isLoading };
172
+ }
64
173
  import { Add } from '@carbon/react/icons';
@@ -1,22 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { ButtonKind } from '@carbon/react';
2
+ import { TasksControllerProps } from '../TasksController/TasksController';
3
+ import { WorkspaceSelectorProps } from '../WorkspaceSelector/WorkspaceSelector';
3
4
  /** Animated Header */
4
- export interface TasksConfig {
5
- type: 'button' | 'dropdown' | string;
6
- button?: {
7
- href?: string;
8
- icon?: any;
9
- text?: string;
10
- type?: ButtonKind;
11
- };
12
- dropdown?: {
13
- label?: string;
14
- };
15
- }
16
- export interface SelectedWorkspace {
17
- id: string;
18
- label: string;
19
- }
20
5
  export interface Tile {
21
6
  href?: string | null;
22
7
  id: string;
@@ -25,34 +10,29 @@ export interface Tile {
25
10
  subtitle?: string | null;
26
11
  title?: string | null;
27
12
  customContent?: ReactNode | null;
13
+ isLoading?: boolean;
14
+ isDisabled?: boolean;
28
15
  }
29
16
  export interface TileGroup {
30
17
  id: number;
31
18
  label: string;
32
19
  tiles: Tile[];
33
20
  }
34
- export interface AnimatedHeaderProps {
35
- allTiles: TileGroup[];
36
- allWorkspaces?: SelectedWorkspace[];
21
+ export type AnimatedHeaderProps = {
22
+ allTileGroups?: TileGroup[];
23
+ selectedTileGroup?: TileGroup;
24
+ setSelectedTileGroup: (e: any) => void;
37
25
  description?: string;
38
- handleHeaderItemsToString?: (item: TileGroup | null) => string;
39
- renderHeaderSelectedItem?: (item: TileGroup | null) => ReactNode;
40
- handleWorkspaceItemsToString?: (item: SelectedWorkspace | null) => string;
41
- renderWorkspaceSelectedItem?: (item: SelectedWorkspace | null) => ReactNode;
42
26
  headerAnimation?: object;
43
27
  headerStatic?: React.JSX.Element;
44
28
  productName?: string;
45
- selectedTileGroup: TileGroup[] | any;
46
- selectedWorkspace?: SelectedWorkspace | any;
47
- setSelectedTileGroup: (e: any) => void;
48
- setSelectedWorkspace: (e: any) => void;
49
- tasksConfig?: TasksConfig;
50
29
  userName?: string;
51
30
  welcomeText?: string;
52
- workspaceLabel?: string;
31
+ isLoading?: boolean;
32
+ disabledTaskLabel?: string;
53
33
  expandButtonLabel?: string;
54
34
  collapseButtonLabel?: string;
55
35
  tileClickHandler?: (tile: Tile) => void;
56
- }
36
+ } & TasksControllerProps & WorkspaceSelectorProps;
57
37
  declare const AnimatedHeader: React.FC<AnimatedHeaderProps>;
58
38
  export default AnimatedHeader;
@@ -5,37 +5,33 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
8
  import PropTypes from 'prop-types';
10
9
  import React, { useRef, useState, useEffect } from 'react';
11
- import { Grid, Column, Tooltip, Button, Dropdown } from '@carbon/react';
10
+ import { Grid, Column, Tooltip, Button } from '@carbon/react';
12
11
  import lottie from '../../_virtual/lottie.js';
13
12
  import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
14
13
  import { BaseTile } from '../Tiles/BaseTile/BaseTile.js';
14
+ import TasksController from '../TasksController/TasksController.js';
15
+ import WorkspaceSelector from '../WorkspaceSelector/WorkspaceSelector.js';
15
16
  import { ChevronUp, ChevronDown } from '../../node_modules/@carbon/icons-react/es/generated/bucket-3.js';
16
17
 
17
18
  /** Animated Header */
18
19
 
19
20
  const AnimatedHeader = _ref => {
20
21
  let {
21
- allTiles,
22
- allWorkspaces,
22
+ allTileGroups,
23
+ selectedTileGroup,
24
+ setSelectedTileGroup,
23
25
  description,
24
- handleHeaderItemsToString,
25
- handleWorkspaceItemsToString,
26
26
  headerAnimation,
27
27
  headerStatic,
28
28
  productName = '[Product name]',
29
- renderHeaderSelectedItem,
30
- renderWorkspaceSelectedItem,
31
- selectedTileGroup,
32
- selectedWorkspace,
33
- setSelectedTileGroup,
34
- setSelectedWorkspace,
35
- tasksConfig,
36
29
  userName,
37
30
  welcomeText,
38
- workspaceLabel = `Open in: ${userName}'s workspace` || `Select a workspace`,
31
+ tasksControllerConfig,
32
+ workspaceSelectorConfig,
33
+ isLoading,
34
+ disabledTaskLabel,
39
35
  expandButtonLabel = 'Expand',
40
36
  collapseButtonLabel = 'Collapse',
41
37
  tileClickHandler
@@ -100,7 +96,9 @@ const AnimatedHeader = _ref => {
100
96
  }), !headerAnimation && headerStatic && /*#__PURE__*/React.createElement("div", {
101
97
  className: `${blockClass}__static--container`
102
98
  }, /*#__PURE__*/React.createElement("div", {
103
- className: `${blockClass}__static`,
99
+ className: `${blockClass}__static`
100
+ // eslint-disable-next-line react/forbid-dom-props
101
+ ,
104
102
  style: {
105
103
  backgroundImage: `url(${headerStatic})`
106
104
  }
@@ -122,58 +120,31 @@ const AnimatedHeader = _ref => {
122
120
  className: `${blockClass}__heading-welcome`
123
121
  }, welcomeText, ",", ' '), /*#__PURE__*/React.createElement("span", {
124
122
  className: `${blockClass}__heading-name`
125
- }, userName)))), (description || tasksConfig && tasksConfig.type === 'button' && tasksConfig.button?.text || tasksConfig && tasksConfig.type === 'dropdown' && tasksConfig.dropdown?.label) && /*#__PURE__*/React.createElement(Column, {
123
+ }, userName)))), (description || tasksControllerConfig) && /*#__PURE__*/React.createElement(Column, {
126
124
  sm: 4,
127
125
  md: 8,
128
126
  lg: 4,
129
127
  className: `${blockClass}__left-area-container${!open ? ` ${descriptionCollapsed}` : ''}`
130
128
  }, description && /*#__PURE__*/React.createElement("h2", {
131
129
  className: `${blockClass}__description`
132
- }, description), tasksConfig?.button?.text && /*#__PURE__*/React.createElement(Button, {
133
- className: `${blockClass}__button`,
134
- kind: tasksConfig.button.type,
135
- renderIcon: tasksConfig.button.icon,
136
- href: tasksConfig.button.href
137
- }, tasksConfig.button.text), !tasksConfig?.button?.text && tasksConfig && tasksConfig.type === 'dropdown' && allTiles && /*#__PURE__*/React.createElement("div", {
138
- className: `${blockClass}__header-dropdown--container`
139
- }, /*#__PURE__*/React.createElement(Dropdown, _extends({
140
- id: `${blockClass}__header-dropdown`,
141
- className: `${blockClass}__header-dropdown`,
142
- size: "md",
143
- titleText: "Label",
144
- label: tasksConfig.dropdown?.label || allTiles[0].label,
145
- hideLabel: true,
146
- type: "inline",
147
- items: allTiles,
148
- onChange: e => setSelectedTileGroup(e)
149
- }, handleHeaderItemsToString ? {
150
- itemToString: handleHeaderItemsToString
151
- } : {}, renderHeaderSelectedItem ? {
152
- renderSelectedItem: renderHeaderSelectedItem
153
- } : {})))), selectedTileGroup && /*#__PURE__*/React.createElement(Column, {
130
+ }, description), /*#__PURE__*/React.createElement(TasksController, {
131
+ tasksControllerConfig: tasksControllerConfig,
132
+ isLoading: isLoading,
133
+ allTileGroups: allTileGroups,
134
+ selectedTileGroup: selectedTileGroup,
135
+ setSelectedTileGroup: setSelectedTileGroup
136
+ })), selectedTileGroup && /*#__PURE__*/React.createElement(Column, {
154
137
  sm: 4,
155
138
  md: 8,
156
139
  lg: 12,
157
140
  className: `${blockClass}__content`
158
- }, allWorkspaces && /*#__PURE__*/React.createElement("div", {
141
+ }, workspaceSelectorConfig?.allWorkspaces?.length && /*#__PURE__*/React.createElement("div", {
159
142
  className: `${blockClass}__workspace--container${!open ? ` ${contentCollapsed}` : ''}`
160
- }, /*#__PURE__*/React.createElement(Dropdown, _extends({
161
- id: `${blockClass}__workspace`,
162
- className: `${blockClass}__workspace`,
163
- size: "sm",
164
- titleText: "Label",
165
- label: workspaceLabel,
166
- hideLabel: true,
167
- type: "inline",
168
- items: allWorkspaces,
169
- onChange: e => setSelectedWorkspace(e)
170
- }, handleWorkspaceItemsToString ? {
171
- itemToString: handleWorkspaceItemsToString
172
- } : {}, renderWorkspaceSelectedItem ? {
173
- renderSelectedItem: renderWorkspaceSelectedItem
174
- } : {}, selectedWorkspace ? {
175
- selectedItem: selectedWorkspace
176
- } : {}))), /*#__PURE__*/React.createElement("div", {
143
+ }, /*#__PURE__*/React.createElement(WorkspaceSelector, {
144
+ workspaceSelectorConfig: workspaceSelectorConfig,
145
+ userName: userName,
146
+ isLoading: isLoading
147
+ })), /*#__PURE__*/React.createElement("div", {
177
148
  className: `${blockClass}__tiles-container`
178
149
  }, selectedTileGroup.tiles.map(tile => {
179
150
  return /*#__PURE__*/React.createElement(BaseTile, {
@@ -187,7 +158,10 @@ const AnimatedHeader = _ref => {
187
158
  title: tile.title,
188
159
  subtitle: tile.subtitle,
189
160
  productName: productName,
190
- customContent: tile.customContent
161
+ customContent: tile.customContent,
162
+ isLoading: isLoading || tile.isLoading,
163
+ isDisabled: tile.isDisabled,
164
+ disabledTaskLabel: disabledTaskLabel
191
165
  });
192
166
  }))), /*#__PURE__*/React.createElement("div", {
193
167
  className: `${blockClass}__button-collapse--gradient`
@@ -205,11 +179,7 @@ AnimatedHeader.propTypes = {
205
179
  /**
206
180
  * Array of each tile group setup
207
181
  */
208
- allTiles: PropTypes.arrayOf(PropTypes.object),
209
- /**
210
- * Array of all workspace options
211
- */
212
- allWorkspaces: PropTypes.arrayOf(PropTypes.object),
182
+ allTileGroups: PropTypes.arrayOf(PropTypes.object),
213
183
  /**
214
184
  * Specify an optional className to be added to your Animated Header
215
185
  */
@@ -226,20 +196,6 @@ AnimatedHeader.propTypes = {
226
196
  * Custom expand button label
227
197
  */
228
198
  expandButtonLabel: PropTypes.string,
229
- /**
230
- * Helper function passed to downshift that allows the library to render a
231
- * given item to a string label. By default, it extracts the `label` field
232
- * from a given item to serve as the item label in the list. (Dropdown
233
- * under description in header).
234
- */
235
- handleHeaderItemsToString: PropTypes.func,
236
- /**
237
- * Helper function passed to downshift that allows the library to render a
238
- * given item to a string label. By default, it extracts the `label` field
239
- * from a given item to serve as the item label in the list. (Dropdown
240
- * related to workspace selection).
241
- */
242
- handleWorkspaceItemsToString: PropTypes.func,
243
199
  /**
244
200
  * In-product imagery / lottie animation (.json) dim. 1312 x 738
245
201
  * (to update headerAnimation content storybook requires remount in toolbar)
@@ -251,45 +207,48 @@ AnimatedHeader.propTypes = {
251
207
  */
252
208
  headerStatic: PropTypes.object,
253
209
  /**
254
- * Provide current product name
210
+ * Check if is loading
255
211
  */
256
- productName: PropTypes.string,
212
+ isLoading: PropTypes.bool,
257
213
  /**
258
- * Helper function passed to downshift that allows the library to render a
259
- * selected item to as an arbitrary ReactNode. By default it uses standard Carbon renderer that renders only item.label text
260
- * (Dropdown under description in header)
261
- */
262
- renderHeaderSelectedItem: PropTypes.func,
263
- /**
264
- * Helper function passed to downshift that allows the library to render a
265
- * selected item to as an arbitrary ReactNode. By default it uses standard Carbon renderer that renders only item.label text
266
- * (Dropdown related to workspace selection)
214
+ * Provide current product name
267
215
  */
268
- renderWorkspaceSelectedItem: PropTypes.func,
216
+ productName: PropTypes.string,
269
217
  /**
270
218
  * The tile group that is active in the header
271
219
  * ex. "AI Chat Tile w/ two glass tiles", "Four glass tiles", ect.
272
220
  */
273
221
  selectedTileGroup: PropTypes.object,
274
- /**
275
- * Object containing workspace selection
276
- * `Open in: "_"`
277
- */
278
- selectedWorkspace: PropTypes.object,
279
222
  /**
280
223
  * Provide function to be called when switching selected tile group
281
224
  */
282
225
  setSelectedTileGroup: PropTypes.func,
283
- /**
284
- * Provide function to be called when switching workspace selection
285
- */
286
- setSelectedWorkspace: PropTypes.func,
287
226
  /**
288
227
  * Configuration for Carbon button or dropdown menu in header. Customized
289
228
  * tasks are used to allow users that have multiple roles and permissions
290
229
  * to experience better tailored content based on their need.
230
+ * It also allows to override Carbon Button props by specifying them in tasksConfig.button.propsOverrides
231
+ * or to override Carbon Dropdown props by specifying them in tasksConfig.dropdown.propsOverrides.
291
232
  */
292
- tasksConfig: PropTypes.object,
233
+ tasksControllerConfig: PropTypes.shape({
234
+ type: PropTypes.oneOf(['button', 'dropdown']).isRequired,
235
+ button: PropTypes.shape({
236
+ text: PropTypes.string.isRequired,
237
+ // Override Carbon Button props
238
+ propsOverrides: PropTypes.object
239
+ }),
240
+ dropdown: PropTypes.shape({
241
+ allTileGroups: PropTypes.arrayOf(PropTypes.object),
242
+ selectedTileGroup: PropTypes.object,
243
+ setSelectedTileGroup: PropTypes.func.isRequired,
244
+ // Override Carbon Dropdown props
245
+ propsOverrides: PropTypes.object
246
+ })
247
+ }),
248
+ /**
249
+ * Handler for tile clicks
250
+ */
251
+ tileClickHandler: PropTypes.func,
293
252
  /**
294
253
  * Specify the current username of active user
295
254
  */
@@ -299,13 +258,15 @@ AnimatedHeader.propTypes = {
299
258
  */
300
259
  welcomeText: PropTypes.string,
301
260
  /**
302
- * Specify the default workspace label above the tiles
303
- */
304
- workspaceLabel: PropTypes.string,
305
- /**
306
- * Handler for tile clicks
261
+ * Configuration for Carbon dropdown for workspace selection. To override Carbon Dropdown props use workspaceSelectorConfig.propsOverride
307
262
  */
308
- tileClickHandler: PropTypes.func
263
+ workspaceSelectorConfig: PropTypes.shape({
264
+ // Override Carbon Dropdown props
265
+ propsOverrides: PropTypes.object,
266
+ allWorkspaces: PropTypes.arrayOf(PropTypes.object),
267
+ selectedWorkspace: PropTypes.object,
268
+ setSelectedWorkspace: PropTypes.func.isRequired
269
+ })
309
270
  };
310
271
 
311
272
  export { AnimatedHeader as default };
@@ -0,0 +1,30 @@
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 { ButtonBaseProps, DropdownProps } from '@carbon/react';
10
+ import { TileGroup } from '../AnimatedHeader/AnimatedHeader';
11
+ export interface TasksControllerConfig {
12
+ type: 'button' | 'dropdown';
13
+ isLoading?: boolean;
14
+ button?: {
15
+ text: string;
16
+ propsOverrides?: Partial<ButtonBaseProps>;
17
+ };
18
+ dropdown?: {
19
+ propsOverrides?: Partial<Omit<DropdownProps<TileGroup>, 'id' | 'items' | 'selectedItem'>>;
20
+ };
21
+ }
22
+ export type TasksControllerProps = {
23
+ tasksControllerConfig?: TasksControllerConfig;
24
+ isLoading?: boolean;
25
+ allTileGroups?: TileGroup[];
26
+ selectedTileGroup?: TileGroup;
27
+ setSelectedTileGroup: (e: any) => void;
28
+ };
29
+ declare const TasksController: ({ tasksControllerConfig, isLoading, allTileGroups, selectedTileGroup, setSelectedTileGroup, }: TasksControllerProps) => import("react/jsx-runtime").JSX.Element | null;
30
+ export default TasksController;
@@ -0,0 +1,73 @@
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 { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import { SkeletonPlaceholder, Button, Dropdown } from '@carbon/react';
10
+ import React, { useMemo } from 'react';
11
+ import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
12
+
13
+ const TasksController = _ref => {
14
+ let {
15
+ tasksControllerConfig,
16
+ isLoading,
17
+ allTileGroups,
18
+ selectedTileGroup,
19
+ setSelectedTileGroup
20
+ } = _ref;
21
+ const {
22
+ className: buttonCustomClass,
23
+ ...buttonOverrideProps
24
+ } = tasksControllerConfig?.button?.propsOverrides || {};
25
+ const {
26
+ className: dropdownCustomClass,
27
+ onChange: dropdownCustomOnChange,
28
+ ...dropdownOverrideProps
29
+ } = tasksControllerConfig?.dropdown?.propsOverrides || {};
30
+ const prefix = usePrefix();
31
+ const blockClass = `${prefix}--animated-header`;
32
+ const dropdownProps = useMemo(() => {
33
+ if (!allTileGroups?.length) {
34
+ return null;
35
+ }
36
+ return {
37
+ id: `${blockClass}__header-dropdown`,
38
+ className: `${blockClass}__header-dropdown${dropdownCustomClass ? ` ${dropdownCustomClass}` : ''}`,
39
+ size: 'md',
40
+ titleText: 'Label',
41
+ label: allTileGroups[0]?.label ?? '',
42
+ hideLabel: true,
43
+ type: 'inline',
44
+ items: allTileGroups,
45
+ selectedItem: selectedTileGroup,
46
+ onChange: e => {
47
+ setSelectedTileGroup?.(e);
48
+ dropdownCustomOnChange?.(e);
49
+ },
50
+ ...dropdownOverrideProps
51
+ };
52
+ }, [allTileGroups, selectedTileGroup, setSelectedTileGroup, blockClass, dropdownCustomClass, dropdownOverrideProps, dropdownCustomOnChange]);
53
+ if (isLoading || tasksControllerConfig?.isLoading) {
54
+ return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
55
+ className: `${blockClass}__task-controller-skeleton`
56
+ });
57
+ }
58
+
59
+ // Button
60
+ if (tasksControllerConfig?.type === 'button' && tasksControllerConfig?.button?.text) {
61
+ return /*#__PURE__*/React.createElement(Button, _extends({
62
+ className: `${blockClass}__button${buttonCustomClass ? ` ${buttonCustomClass}` : ''}`
63
+ }, buttonOverrideProps), tasksControllerConfig.button.text);
64
+ }
65
+ if (tasksControllerConfig?.type === 'dropdown' && dropdownProps) {
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ className: `${blockClass}__header-dropdown--container`
68
+ }, /*#__PURE__*/React.createElement(Dropdown, dropdownProps));
69
+ }
70
+ return null;
71
+ };
72
+
73
+ export { TasksController as default };
@@ -9,12 +9,15 @@
9
9
  import React from 'react';
10
10
  /** Primary UI component for user interaction */
11
11
  interface AIPromptTileProps {
12
- href?: string;
12
+ href?: string | null;
13
13
  id?: string;
14
- mainIcon?: string;
14
+ mainIcon?: string | null;
15
15
  open?: boolean;
16
16
  productName?: string;
17
- title?: string;
17
+ title?: string | null;
18
+ isLoading?: boolean;
19
+ isDisabled?: boolean;
20
+ disabledTaskLabel?: string;
18
21
  }
19
22
  export declare const AIPromptTile: React.FC<AIPromptTileProps>;
20
23
  export {};
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import React, { useState } from 'react';
9
- import { AILabel, TextInput, IconButton, Button } from '@carbon/react';
9
+ import { SkeletonPlaceholder, AILabel, TextInput, IconButton, Button } from '@carbon/react';
10
10
  import * as index from '../../../node_modules/@carbon/icons-react/es/index.js';
11
11
  import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
12
12
  import { Send } from '../../../node_modules/@carbon/icons-react/es/generated/bucket-15.js';
@@ -22,11 +22,15 @@ const AIPromptTile = _ref => {
22
22
  mainIcon,
23
23
  open,
24
24
  productName,
25
- title
25
+ title,
26
+ isLoading,
27
+ isDisabled,
28
+ disabledTaskLabel
26
29
  } = _ref;
27
30
  const prefix = usePrefix();
28
31
  const blockClass = `${prefix}--animated-header__ai-prompt-tile`;
29
32
  const collapsed = `${blockClass}--collapsed`;
33
+ const disabled = `${blockClass}--disabled`;
30
34
  const [textInput, setTextInput] = useState('');
31
35
  const MainIcon = mainIcon ? index[mainIcon] : null;
32
36
  const Send$1 = Send;
@@ -41,15 +45,17 @@ const AIPromptTile = _ref => {
41
45
  };
42
46
  const handleTextInputKeyDown = event => {
43
47
  if (event.key === 'Enter') {
44
- console.log('do validate');
45
48
  openInNewTab(`${href}&primed_chat=${textInput}`);
46
49
  }
47
50
  };
48
51
  return /*#__PURE__*/React.createElement("div", {
49
52
  id: `${blockClass}`,
50
- className: `${prefix}--animated-header__tile ${blockClass}`,
53
+ className: `${prefix}--animated-header__tile ${blockClass}${isDisabled ? ' ' + disabled : ''}`,
54
+ title: isDisabled ? disabledTaskLabel ?? '' : '',
51
55
  key: id
52
- }, /*#__PURE__*/React.createElement("div", {
56
+ }, isLoading ? /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
57
+ className: `${blockClass}--loading-skeleton`
58
+ }) : /*#__PURE__*/React.createElement("div", {
53
59
  className: `${blockClass}--body${!open ? ` ${collapsed}` : ''}`
54
60
  }, /*#__PURE__*/React.createElement("div", {
55
61
  className: `${blockClass}--body-background`
@@ -93,7 +99,7 @@ const AIPromptTile = _ref => {
93
99
  }, /*#__PURE__*/React.createElement(Button, {
94
100
  kind: "ghost",
95
101
  size: "sm",
96
- href: href
102
+ href: href ?? undefined
97
103
  }, "Open ", productName))));
98
104
  };
99
105
 
@@ -11,13 +11,16 @@ import React, { ReactNode } from 'react';
11
11
  interface BaseTileProps {
12
12
  id?: string;
13
13
  open?: boolean;
14
- href?: string;
15
- mainIcon?: string;
16
- secondaryIcon?: string;
17
- title?: string;
18
- subtitle?: string;
14
+ href?: string | null;
15
+ mainIcon?: string | null;
16
+ secondaryIcon?: string | null;
17
+ title?: string | null;
18
+ subtitle?: string | null;
19
19
  productName?: string;
20
20
  customContent?: ReactNode;
21
+ isLoading?: boolean;
22
+ isDisabled?: boolean;
23
+ disabledTaskLabel?: string;
21
24
  onClick?: () => void;
22
25
  }
23
26
  export declare const BaseTile: React.FC<BaseTileProps>;