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