@carbon-labs/react-animated-header 0.14.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/assets/static/illustration_data_fabric_dark_05.svg.js +1 -1
- package/es/assets/static/illustration_data_fabric_light_04.svg.js +1 -1
- package/es/assets/static/illustration_watson_x_data_dark_03.svg.js +1 -1
- package/es/assets/static/illustration_watson_x_data_light_03.svg.js +1 -1
- package/es/components/AnimatedHeader/AnimatedHeader.d.ts +12 -31
- package/es/components/AnimatedHeader/AnimatedHeader.js +68 -101
- 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 +9 -5
- package/es/components/Tiles/BaseTile/BaseTile.js +5 -25
- package/es/components/Tiles/GlassTile/GlassTile.d.ts +9 -5
- package/es/components/Tiles/GlassTile/GlassTile.js +15 -4
- 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/assets/static/illustration_data_fabric_dark_05.svg.js +1 -1
- package/lib/assets/static/illustration_data_fabric_light_04.svg.js +1 -1
- package/lib/assets/static/illustration_watson_x_data_dark_03.svg.js +1 -1
- package/lib/assets/static/illustration_watson_x_data_light_03.svg.js +1 -1
- package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +12 -31
- package/lib/components/AnimatedHeader/AnimatedHeader.js +67 -100
- 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 +9 -5
- package/lib/components/Tiles/BaseTile/BaseTile.js +5 -25
- package/lib/components/Tiles/GlassTile/GlassTile.d.ts +9 -5
- package/lib/components/Tiles/GlassTile/GlassTile.js +14 -3
- 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
|
@@ -5,39 +5,36 @@
|
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
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
|
-
|
|
31
|
+
tasksControllerConfig,
|
|
32
|
+
workspaceSelectorConfig,
|
|
33
|
+
isLoading,
|
|
34
|
+
disabledTaskLabel,
|
|
39
35
|
expandButtonLabel = 'Expand',
|
|
40
|
-
collapseButtonLabel = 'Collapse'
|
|
36
|
+
collapseButtonLabel = 'Collapse',
|
|
37
|
+
tileClickHandler
|
|
41
38
|
} = _ref;
|
|
42
39
|
const prefix = usePrefix();
|
|
43
40
|
const blockClass = `${prefix}--animated-header`;
|
|
@@ -99,7 +96,9 @@ const AnimatedHeader = _ref => {
|
|
|
99
96
|
}), !headerAnimation && headerStatic && /*#__PURE__*/React.createElement("div", {
|
|
100
97
|
className: `${blockClass}__static--container`
|
|
101
98
|
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: `${blockClass}__static
|
|
99
|
+
className: `${blockClass}__static`
|
|
100
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
101
|
+
,
|
|
103
102
|
style: {
|
|
104
103
|
backgroundImage: `url(${headerStatic})`
|
|
105
104
|
}
|
|
@@ -121,61 +120,35 @@ const AnimatedHeader = _ref => {
|
|
|
121
120
|
className: `${blockClass}__heading-welcome`
|
|
122
121
|
}, welcomeText, ",", ' '), /*#__PURE__*/React.createElement("span", {
|
|
123
122
|
className: `${blockClass}__heading-name`
|
|
124
|
-
}, userName)))), (description ||
|
|
123
|
+
}, userName)))), (description || tasksControllerConfig) && /*#__PURE__*/React.createElement(Column, {
|
|
125
124
|
sm: 4,
|
|
126
125
|
md: 8,
|
|
127
126
|
lg: 4,
|
|
128
127
|
className: `${blockClass}__left-area-container${!open ? ` ${descriptionCollapsed}` : ''}`
|
|
129
128
|
}, description && /*#__PURE__*/React.createElement("h2", {
|
|
130
129
|
className: `${blockClass}__description`
|
|
131
|
-
}, description),
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
139
|
-
id: `${blockClass}__header-dropdown`,
|
|
140
|
-
className: `${blockClass}__header-dropdown`,
|
|
141
|
-
size: "md",
|
|
142
|
-
titleText: "Label",
|
|
143
|
-
label: tasksConfig.dropdown?.label || allTiles[0].label,
|
|
144
|
-
hideLabel: true,
|
|
145
|
-
type: "inline",
|
|
146
|
-
items: allTiles,
|
|
147
|
-
onChange: e => setSelectedTileGroup(e)
|
|
148
|
-
}, handleHeaderItemsToString ? {
|
|
149
|
-
itemToString: handleHeaderItemsToString
|
|
150
|
-
} : {}, renderHeaderSelectedItem ? {
|
|
151
|
-
renderSelectedItem: renderHeaderSelectedItem
|
|
152
|
-
} : {})))), 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, {
|
|
153
137
|
sm: 4,
|
|
154
138
|
md: 8,
|
|
155
139
|
lg: 12,
|
|
156
140
|
className: `${blockClass}__content`
|
|
157
|
-
}, allWorkspaces && /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
}, workspaceSelectorConfig?.allWorkspaces?.length && /*#__PURE__*/React.createElement("div", {
|
|
158
142
|
className: `${blockClass}__workspace--container${!open ? ` ${contentCollapsed}` : ''}`
|
|
159
|
-
}, /*#__PURE__*/React.createElement(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
label: workspaceLabel,
|
|
165
|
-
hideLabel: true,
|
|
166
|
-
type: "inline",
|
|
167
|
-
items: allWorkspaces,
|
|
168
|
-
onChange: e => setSelectedWorkspace(e)
|
|
169
|
-
}, handleWorkspaceItemsToString ? {
|
|
170
|
-
itemToString: handleWorkspaceItemsToString
|
|
171
|
-
} : {}, renderWorkspaceSelectedItem ? {
|
|
172
|
-
renderSelectedItem: renderWorkspaceSelectedItem
|
|
173
|
-
} : {}, selectedWorkspace ? {
|
|
174
|
-
selectedItem: selectedWorkspace
|
|
175
|
-
} : {}))), /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
}, /*#__PURE__*/React.createElement(WorkspaceSelector, {
|
|
144
|
+
workspaceSelectorConfig: workspaceSelectorConfig,
|
|
145
|
+
userName: userName,
|
|
146
|
+
isLoading: isLoading
|
|
147
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
176
148
|
className: `${blockClass}__tiles-container`
|
|
177
149
|
}, selectedTileGroup.tiles.map(tile => {
|
|
178
150
|
return /*#__PURE__*/React.createElement(BaseTile, {
|
|
151
|
+
onClick: () => tileClickHandler?.(tile),
|
|
179
152
|
key: tile.id,
|
|
180
153
|
id: tile.id,
|
|
181
154
|
open: open,
|
|
@@ -185,7 +158,10 @@ const AnimatedHeader = _ref => {
|
|
|
185
158
|
title: tile.title,
|
|
186
159
|
subtitle: tile.subtitle,
|
|
187
160
|
productName: productName,
|
|
188
|
-
customContent: tile.customContent
|
|
161
|
+
customContent: tile.customContent,
|
|
162
|
+
isLoading: isLoading || tile.isLoading,
|
|
163
|
+
isDisabled: tile.isDisabled,
|
|
164
|
+
disabledTaskLabel: disabledTaskLabel
|
|
189
165
|
});
|
|
190
166
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
191
167
|
className: `${blockClass}__button-collapse--gradient`
|
|
@@ -203,11 +179,7 @@ AnimatedHeader.propTypes = {
|
|
|
203
179
|
/**
|
|
204
180
|
* Array of each tile group setup
|
|
205
181
|
*/
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Array of all workspace options
|
|
209
|
-
*/
|
|
210
|
-
allWorkspaces: PropTypes.arrayOf(PropTypes.object),
|
|
182
|
+
allTileGroups: PropTypes.arrayOf(PropTypes.object),
|
|
211
183
|
/**
|
|
212
184
|
* Specify an optional className to be added to your Animated Header
|
|
213
185
|
*/
|
|
@@ -224,20 +196,6 @@ AnimatedHeader.propTypes = {
|
|
|
224
196
|
* Custom expand button label
|
|
225
197
|
*/
|
|
226
198
|
expandButtonLabel: PropTypes.string,
|
|
227
|
-
/**
|
|
228
|
-
* Helper function passed to downshift that allows the library to render a
|
|
229
|
-
* given item to a string label. By default, it extracts the `label` field
|
|
230
|
-
* from a given item to serve as the item label in the list. (Dropdown
|
|
231
|
-
* under description in header).
|
|
232
|
-
*/
|
|
233
|
-
handleHeaderItemsToString: PropTypes.func,
|
|
234
|
-
/**
|
|
235
|
-
* Helper function passed to downshift that allows the library to render a
|
|
236
|
-
* given item to a string label. By default, it extracts the `label` field
|
|
237
|
-
* from a given item to serve as the item label in the list. (Dropdown
|
|
238
|
-
* related to workspace selection).
|
|
239
|
-
*/
|
|
240
|
-
handleWorkspaceItemsToString: PropTypes.func,
|
|
241
199
|
/**
|
|
242
200
|
* In-product imagery / lottie animation (.json) dim. 1312 x 738
|
|
243
201
|
* (to update headerAnimation content storybook requires remount in toolbar)
|
|
@@ -249,45 +207,48 @@ AnimatedHeader.propTypes = {
|
|
|
249
207
|
*/
|
|
250
208
|
headerStatic: PropTypes.object,
|
|
251
209
|
/**
|
|
252
|
-
*
|
|
210
|
+
* Check if is loading
|
|
253
211
|
*/
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Helper function passed to downshift that allows the library to render a
|
|
257
|
-
* selected item to as an arbitrary ReactNode. By default it uses standard Carbon renderer that renders only item.label text
|
|
258
|
-
* (Dropdown under description in header)
|
|
259
|
-
*/
|
|
260
|
-
renderHeaderSelectedItem: PropTypes.func,
|
|
212
|
+
isLoading: PropTypes.bool,
|
|
261
213
|
/**
|
|
262
|
-
*
|
|
263
|
-
* selected item to as an arbitrary ReactNode. By default it uses standard Carbon renderer that renders only item.label text
|
|
264
|
-
* (Dropdown related to workspace selection)
|
|
214
|
+
* Provide current product name
|
|
265
215
|
*/
|
|
266
|
-
|
|
216
|
+
productName: PropTypes.string,
|
|
267
217
|
/**
|
|
268
218
|
* The tile group that is active in the header
|
|
269
219
|
* ex. "AI Chat Tile w/ two glass tiles", "Four glass tiles", ect.
|
|
270
220
|
*/
|
|
271
221
|
selectedTileGroup: PropTypes.object,
|
|
272
|
-
/**
|
|
273
|
-
* Object containing workspace selection
|
|
274
|
-
* `Open in: "_"`
|
|
275
|
-
*/
|
|
276
|
-
selectedWorkspace: PropTypes.object,
|
|
277
222
|
/**
|
|
278
223
|
* Provide function to be called when switching selected tile group
|
|
279
224
|
*/
|
|
280
225
|
setSelectedTileGroup: PropTypes.func,
|
|
281
|
-
/**
|
|
282
|
-
* Provide function to be called when switching workspace selection
|
|
283
|
-
*/
|
|
284
|
-
setSelectedWorkspace: PropTypes.func,
|
|
285
226
|
/**
|
|
286
227
|
* Configuration for Carbon button or dropdown menu in header. Customized
|
|
287
228
|
* tasks are used to allow users that have multiple roles and permissions
|
|
288
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.
|
|
232
|
+
*/
|
|
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
|
|
289
250
|
*/
|
|
290
|
-
|
|
251
|
+
tileClickHandler: PropTypes.func,
|
|
291
252
|
/**
|
|
292
253
|
* Specify the current username of active user
|
|
293
254
|
*/
|
|
@@ -297,9 +258,15 @@ AnimatedHeader.propTypes = {
|
|
|
297
258
|
*/
|
|
298
259
|
welcomeText: PropTypes.string,
|
|
299
260
|
/**
|
|
300
|
-
*
|
|
261
|
+
* Configuration for Carbon dropdown for workspace selection. To override Carbon Dropdown props use workspaceSelectorConfig.propsOverride
|
|
301
262
|
*/
|
|
302
|
-
|
|
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
|
+
})
|
|
303
270
|
};
|
|
304
271
|
|
|
305
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(
|
|
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,17 @@ 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;
|
|
24
|
+
onClick?: () => void;
|
|
21
25
|
}
|
|
22
26
|
export declare const BaseTile: React.FC<BaseTileProps>;
|
|
23
27
|
export {};
|
|
@@ -11,31 +11,11 @@ import { GlassTile } from '../GlassTile/GlassTile.js';
|
|
|
11
11
|
|
|
12
12
|
/** Base Tile */
|
|
13
13
|
|
|
14
|
-
const BaseTile =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
mainIcon,
|
|
20
|
-
secondaryIcon,
|
|
21
|
-
title,
|
|
22
|
-
subtitle,
|
|
23
|
-
productName,
|
|
24
|
-
customContent
|
|
25
|
-
} = _ref;
|
|
26
|
-
const props = {
|
|
27
|
-
id,
|
|
28
|
-
open,
|
|
29
|
-
href,
|
|
30
|
-
mainIcon,
|
|
31
|
-
secondaryIcon,
|
|
32
|
-
title,
|
|
33
|
-
subtitle,
|
|
34
|
-
productName,
|
|
35
|
-
customContent
|
|
36
|
-
};
|
|
37
|
-
const tile = id === 'ai-tile' ? /*#__PURE__*/React.createElement(AIPromptTile, props) : /*#__PURE__*/React.createElement(GlassTile, props);
|
|
38
|
-
return tile;
|
|
14
|
+
const BaseTile = props => {
|
|
15
|
+
if (props.id === 'ai-tile') {
|
|
16
|
+
return /*#__PURE__*/React.createElement(AIPromptTile, props);
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement(GlassTile, props);
|
|
39
19
|
};
|
|
40
20
|
|
|
41
21
|
export { BaseTile };
|
|
@@ -9,14 +9,18 @@
|
|
|
9
9
|
import React, { ReactNode } from 'react';
|
|
10
10
|
/** Primary UI component for user interaction */
|
|
11
11
|
interface GlassTileProps {
|
|
12
|
-
href?: string;
|
|
12
|
+
href?: string | null;
|
|
13
13
|
id?: string;
|
|
14
|
-
mainIcon?: string;
|
|
14
|
+
mainIcon?: string | null;
|
|
15
15
|
open?: boolean;
|
|
16
|
-
secondaryIcon?: string;
|
|
17
|
-
subtitle?: string;
|
|
18
|
-
title?: string;
|
|
16
|
+
secondaryIcon?: string | null;
|
|
17
|
+
subtitle?: string | null;
|
|
18
|
+
title?: string | null;
|
|
19
19
|
customContent?: ReactNode;
|
|
20
|
+
isLoading?: boolean;
|
|
21
|
+
isDisabled?: boolean;
|
|
22
|
+
disabledTaskLabel?: string;
|
|
23
|
+
onClick?: () => void;
|
|
20
24
|
}
|
|
21
25
|
export declare const GlassTile: React.FC<GlassTileProps>;
|
|
22
26
|
export {};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import { Link } from '@carbon/react';
|
|
9
|
+
import { Link, SkeletonPlaceholder } 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
|
|
|
@@ -21,7 +21,11 @@ const GlassTile = _ref => {
|
|
|
21
21
|
secondaryIcon,
|
|
22
22
|
subtitle,
|
|
23
23
|
title,
|
|
24
|
-
customContent
|
|
24
|
+
customContent,
|
|
25
|
+
isLoading,
|
|
26
|
+
isDisabled,
|
|
27
|
+
disabledTaskLabel,
|
|
28
|
+
onClick: glassTileClickHandler
|
|
25
29
|
} = _ref;
|
|
26
30
|
const prefix = usePrefix();
|
|
27
31
|
const blockClass = `${prefix}--animated-header__glass-tile`;
|
|
@@ -29,10 +33,17 @@ const GlassTile = _ref => {
|
|
|
29
33
|
const MainIcon = mainIcon ? index[mainIcon] : null;
|
|
30
34
|
const SecondaryIcon = secondaryIcon ? index[secondaryIcon] : null;
|
|
31
35
|
return /*#__PURE__*/React.createElement(Link, {
|
|
36
|
+
onClick: () => {
|
|
37
|
+
glassTileClickHandler?.();
|
|
38
|
+
},
|
|
32
39
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
33
40
|
key: id,
|
|
34
|
-
href: href
|
|
35
|
-
|
|
41
|
+
href: href ?? undefined,
|
|
42
|
+
disabled: isDisabled || isLoading,
|
|
43
|
+
title: isDisabled ? disabledTaskLabel ?? '' : ''
|
|
44
|
+
}, isLoading ? /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
45
|
+
className: `${blockClass}--loading-skeleton`
|
|
46
|
+
}) : /*#__PURE__*/React.createElement("div", {
|
|
36
47
|
className: `${blockClass}--body${!open ? ` ${collapsed}` : ''}`
|
|
37
48
|
}, /*#__PURE__*/React.createElement("div", {
|
|
38
49
|
className: `${blockClass}--body-background`
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { DropdownProps } from '@carbon/react';
|
|
10
|
+
export interface Workspace {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}
|
|
14
|
+
export type WorkspaceSelectorConfig = {
|
|
15
|
+
propsOverrides: Partial<Omit<DropdownProps<Workspace>, 'id' | 'items' | 'selectedItem' | 'setSelectedWorkspace'>>;
|
|
16
|
+
allWorkspaces: Workspace[];
|
|
17
|
+
selectedWorkspace?: Workspace;
|
|
18
|
+
setSelectedWorkspace: (e: any) => void;
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type WorkspaceSelectorProps = {
|
|
22
|
+
workspaceSelectorConfig?: WorkspaceSelectorConfig;
|
|
23
|
+
userName?: string;
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare const WorkspaceSelector: ({ workspaceSelectorConfig, userName, isLoading, }: WorkspaceSelectorProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
27
|
+
export default WorkspaceSelector;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { SkeletonPlaceholder, Dropdown } from '@carbon/react';
|
|
9
|
+
import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
|
|
10
|
+
import React, { useMemo } from 'react';
|
|
11
|
+
|
|
12
|
+
const WorkspaceSelector = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
workspaceSelectorConfig,
|
|
15
|
+
userName,
|
|
16
|
+
isLoading
|
|
17
|
+
} = _ref;
|
|
18
|
+
const {
|
|
19
|
+
className: dropdownCustomClass,
|
|
20
|
+
onChange: dropdownCustomOnChange,
|
|
21
|
+
...dropdownOverrideProps
|
|
22
|
+
} = workspaceSelectorConfig?.propsOverrides || {};
|
|
23
|
+
const prefix = usePrefix();
|
|
24
|
+
const blockClass = `${prefix}--animated-header`;
|
|
25
|
+
const dropdownProps = useMemo(() => {
|
|
26
|
+
if (!workspaceSelectorConfig?.allWorkspaces) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
id: `${blockClass}__workspace`,
|
|
31
|
+
className: `${blockClass}__workspace${dropdownCustomClass ? ` ${dropdownCustomClass}` : ''}`,
|
|
32
|
+
size: 'sm',
|
|
33
|
+
titleText: 'Label',
|
|
34
|
+
label: `Open in: ${userName}'s workspace` || `Select a workspace`,
|
|
35
|
+
hideLabel: true,
|
|
36
|
+
type: 'inline',
|
|
37
|
+
items: workspaceSelectorConfig?.allWorkspaces,
|
|
38
|
+
selectedItem: workspaceSelectorConfig?.selectedWorkspace,
|
|
39
|
+
onChange: e => {
|
|
40
|
+
workspaceSelectorConfig?.setSelectedWorkspace?.(e);
|
|
41
|
+
dropdownCustomOnChange?.(e);
|
|
42
|
+
},
|
|
43
|
+
...dropdownOverrideProps
|
|
44
|
+
};
|
|
45
|
+
}, [blockClass, dropdownCustomClass, dropdownOverrideProps, userName, workspaceSelectorConfig, dropdownCustomOnChange]);
|
|
46
|
+
if (isLoading || workspaceSelectorConfig?.isLoading) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(SkeletonPlaceholder, {
|
|
48
|
+
className: `${blockClass}__workspace-selector-skeleton`
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (!dropdownProps) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return /*#__PURE__*/React.createElement(Dropdown, dropdownProps);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { WorkspaceSelector as default };
|
package/es/index.d.ts
CHANGED
|
@@ -9,4 +9,6 @@
|
|
|
9
9
|
import AnimatedHeader from './components/AnimatedHeader/AnimatedHeader';
|
|
10
10
|
import { BaseTile } from './components/Tiles/index.js';
|
|
11
11
|
export * from './assets';
|
|
12
|
+
export type { Workspace, WorkspaceSelectorConfig, } from './components/WorkspaceSelector/WorkspaceSelector';
|
|
13
|
+
export type { TasksControllerConfig } from './components/TasksController/TasksController';
|
|
12
14
|
export { AnimatedHeader, BaseTile };
|