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