@aws/mynah-ui 4.36.3 → 4.36.4
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/dist/components/chat-item/chat-item-card.d.ts +1 -0
- package/dist/components/dropdown-form/base-dropdown.d.ts +52 -0
- package/dist/components/dropdown-form/dropdown-list.d.ts +18 -0
- package/dist/components/dropdown-form/dropdown-wrapper.d.ts +20 -0
- package/dist/helper/test-ids.d.ts +11 -0
- package/dist/main.d.ts +3 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/static.d.ts +26 -0
- package/docs/DATAMODEL.md +101 -2
- package/docs/PROPERTIES.md +47 -0
- package/docs/img/data-model/chatItems/dropdown-list.png +0 -0
- package/docs/img/onDropDownLinkClick.png +0 -0
- package/docs/img/onDropDownOptionChange.png +0 -0
- package/package.json +1 -1
- package/ui-tests/__snapshots__/chromium/Open-MynahUI-Dropdown-list-should-open-and-close-dropdown/dropdown-closed.png +0 -0
- package/ui-tests/__snapshots__/chromium/Open-MynahUI-Dropdown-list-should-open-and-close-dropdown/dropdown-initial.png +0 -0
- package/ui-tests/__snapshots__/chromium/Open-MynahUI-Dropdown-list-should-open-and-close-dropdown/dropdown-open.png +0 -0
- package/ui-tests/__snapshots__/chromium/Open-MynahUI-Dropdown-list-should-select-dropdown-option/dropdown-select-final.png +0 -0
- package/ui-tests/__snapshots__/chromium/Open-MynahUI-Dropdown-list-should-select-dropdown-option/dropdown-select-initial.png +0 -0
- package/ui-tests/__snapshots__/chromium/Open-MynahUI-Dropdown-list-should-select-dropdown-option/dropdown-select-open.png +0 -0
- package/ui-tests/__snapshots__/webkit/Open-MynahUI-Dropdown-list-should-open-and-close-dropdown/dropdown-closed.png +0 -0
- package/ui-tests/__snapshots__/webkit/Open-MynahUI-Dropdown-list-should-open-and-close-dropdown/dropdown-initial.png +0 -0
- package/ui-tests/__snapshots__/webkit/Open-MynahUI-Dropdown-list-should-open-and-close-dropdown/dropdown-open.png +0 -0
- package/ui-tests/__snapshots__/webkit/Open-MynahUI-Dropdown-list-should-select-dropdown-option/dropdown-select-final.png +0 -0
- package/ui-tests/__snapshots__/webkit/Open-MynahUI-Dropdown-list-should-select-dropdown-option/dropdown-select-initial.png +0 -0
- package/ui-tests/__snapshots__/webkit/Open-MynahUI-Dropdown-list-should-select-dropdown-option/dropdown-select-open.png +0 -0
package/dist/static.d.ts
CHANGED
|
@@ -219,6 +219,8 @@ export declare enum MynahEventNames {
|
|
|
219
219
|
FILE_ACTION_CLICK = "fileActionClick",
|
|
220
220
|
TAB_FOCUS = "tabFocus",
|
|
221
221
|
CUSTOM_FORM_ACTION_CLICK = "customFormActionClick",
|
|
222
|
+
DROPDOWN_OPTION_CHANGE = "dropdownOptionChange",
|
|
223
|
+
DROPDOWN_LINK_CLICK = "dropdownLinkClick",
|
|
222
224
|
PROMPT_INPUT_OPTIONS_CHANGE = "promptInputOptionsChange",
|
|
223
225
|
PROMPT_INPUT_BUTTON_CLICK = "promptInputButtonClick",
|
|
224
226
|
FORM_MODIFIER_ENTER_PRESS = "formModifierEnterPress",
|
|
@@ -361,6 +363,29 @@ export interface TreeNodeDetails {
|
|
|
361
363
|
clickable?: boolean;
|
|
362
364
|
data?: Record<string, string>;
|
|
363
365
|
}
|
|
366
|
+
export interface DropdownListOption {
|
|
367
|
+
id: string;
|
|
368
|
+
label: string;
|
|
369
|
+
value: string;
|
|
370
|
+
selected?: boolean;
|
|
371
|
+
}
|
|
372
|
+
export interface DropdownListProps {
|
|
373
|
+
description?: string;
|
|
374
|
+
descriptionLink?: {
|
|
375
|
+
id: string;
|
|
376
|
+
text: string;
|
|
377
|
+
destination: string;
|
|
378
|
+
onClick?: () => void;
|
|
379
|
+
};
|
|
380
|
+
options: DropdownListOption[];
|
|
381
|
+
onChange?: (selectedOptions: DropdownListOption[]) => void;
|
|
382
|
+
tabId?: string;
|
|
383
|
+
messageId?: string;
|
|
384
|
+
classNames?: string[];
|
|
385
|
+
}
|
|
386
|
+
export interface DropdownFactoryProps extends DropdownListProps {
|
|
387
|
+
type: 'select' | 'radio' | 'checkbox';
|
|
388
|
+
}
|
|
364
389
|
export interface ChatItemContent {
|
|
365
390
|
header?: (ChatItemContent & {
|
|
366
391
|
icon?: MynahIcons | MynahIconsType | CustomIcon;
|
|
@@ -423,6 +448,7 @@ export interface ChatItemContent {
|
|
|
423
448
|
tabbedContent?: Array<ToggleOption & {
|
|
424
449
|
content: ChatItemContent;
|
|
425
450
|
}> | null;
|
|
451
|
+
quickSettings?: DropdownFactoryProps | null;
|
|
426
452
|
codeBlockActions?: CodeBlockActions | null;
|
|
427
453
|
fullWidth?: boolean;
|
|
428
454
|
padding?: boolean;
|
package/docs/DATAMODEL.md
CHANGED
|
@@ -1370,6 +1370,7 @@ interface ChatItemContent {
|
|
|
1370
1370
|
content: ChatItemContent;
|
|
1371
1371
|
}> | null;
|
|
1372
1372
|
codeBlockActions?: CodeBlockActions | null;
|
|
1373
|
+
quickSettings?: DropdownFactoryProps | null;
|
|
1373
1374
|
fullWidth?: boolean;
|
|
1374
1375
|
padding?: boolean;
|
|
1375
1376
|
wrapCodes?: boolean;
|
|
@@ -2315,6 +2316,105 @@ mynahUI.addChatItem(tabId, {
|
|
|
2315
2316
|
|
|
2316
2317
|
---
|
|
2317
2318
|
|
|
2319
|
+
## `quickSettings`
|
|
2320
|
+
This parameter allows you to add a dropdown selector to the footer of a chat item card. The `quickSettings` component provides a flexible dropdown interface that can be extended for different form item types in the future (radio buttons, checkboxes, etc.).
|
|
2321
|
+
|
|
2322
|
+
Currently, it supports the `select` type for single-selection dropdowns with visual feedback and customizable options.
|
|
2323
|
+
|
|
2324
|
+
The `DropdownList` component provides a customizable dropdown selector that allows users to choose from a list of options. It supports single selection with visual feedback and can be positioned relative to its parent elements.
|
|
2325
|
+
|
|
2326
|
+
```typescript
|
|
2327
|
+
interface DropdownListOption {
|
|
2328
|
+
id: string; // Unique identifier for the option
|
|
2329
|
+
label: string; // Display text for the option
|
|
2330
|
+
value: string; // Value associated with the option
|
|
2331
|
+
selected?: boolean; // Whether the option is initially selected
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
interface DropdownFactoryProps {
|
|
2335
|
+
type: 'select'; // Type of dropdown (currently only 'select', extensible for 'radio', 'checkbox', etc.)
|
|
2336
|
+
title: string; // The title displayed in the dropdown header
|
|
2337
|
+
titleIcon?: MynahIcons; // Icon displayed next to the title
|
|
2338
|
+
description?: string; // Description text displayed below the title
|
|
2339
|
+
descriptionLink?: { // Optional clickable link that appears within the description text
|
|
2340
|
+
id: string; // Unique identifier for the link
|
|
2341
|
+
text: string; // Display text for the link
|
|
2342
|
+
destination: string; // Link destination
|
|
2343
|
+
onClick?: () => void; // Optional callback function triggered when the link is clicked
|
|
2344
|
+
};
|
|
2345
|
+
options: DropdownListOption[]; // Array of options to display in the dropdown
|
|
2346
|
+
onChange?: (selectedOptions: DropdownListOption[]) => void; // Callback when selection changes
|
|
2347
|
+
tabId?: string; // Tab identifier for event dispatching
|
|
2348
|
+
messageId?: string; // Message identifier for event dispatching
|
|
2349
|
+
classNames?: string[]; // Additional CSS class names to apply
|
|
2350
|
+
}
|
|
2351
|
+
```
|
|
2352
|
+
|
|
2353
|
+
When a dropdown option is selected, the component dispatches a `MynahEventNames.DROPDOWN_OPTION_CHANGE` event with the selected options. You can handle this event by implementing the [`onDropDownOptionChange`](./PROPERTIES.md#ondropdownoptionchange) callback in your MynahUI constructor properties.
|
|
2354
|
+
|
|
2355
|
+
When a link in the dropdown description is clicked, the component dispatches a `MynahEventNames.DROP_DOWN_LINK_CLICK` event. You can handle this event by implementing the [`onDropDownLinkClick`](./PROPERTIES.md#ondropdownlinkclick) callback in your MynahUI constructor properties.
|
|
2356
|
+
|
|
2357
|
+
```typescript
|
|
2358
|
+
const mynahUI = new MynahUI({
|
|
2359
|
+
tabs: {
|
|
2360
|
+
'tab-1': {
|
|
2361
|
+
...
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
|
|
2366
|
+
mynahUI.addChatItem('tab-1', {
|
|
2367
|
+
type: ChatItemType.ANSWER,
|
|
2368
|
+
messageId: 'dropdown-example',
|
|
2369
|
+
body: 'Please select your preferred option:',
|
|
2370
|
+
quickSettings: {
|
|
2371
|
+
type: 'select',
|
|
2372
|
+
title: 'Select an option',
|
|
2373
|
+
description: 'Choose one of the following options',
|
|
2374
|
+
tabId: 'tab-1',
|
|
2375
|
+
messageId: 'dropdown-example',
|
|
2376
|
+
options: [
|
|
2377
|
+
{ id: 'option1', label: 'Option 1', value: 'option1', selected: false },
|
|
2378
|
+
{ id: 'option2', label: 'Option 2', value: 'option2', selected: true },
|
|
2379
|
+
{ id: 'option3', label: 'Option 3', value: 'option3', selected: false }
|
|
2380
|
+
]
|
|
2381
|
+
}
|
|
2382
|
+
});
|
|
2383
|
+
|
|
2384
|
+
// Example with descriptionLink
|
|
2385
|
+
mynahUI.addChatItem('tab-1', {
|
|
2386
|
+
type: ChatItemType.ANSWER,
|
|
2387
|
+
messageId: 'dropdown-with-link-example',
|
|
2388
|
+
body: 'Configure your settings:',
|
|
2389
|
+
quickSettings: {
|
|
2390
|
+
type: 'select',
|
|
2391
|
+
title: 'Model Selection',
|
|
2392
|
+
description: 'Choose your preferred AI model. Need help choosing?',
|
|
2393
|
+
descriptionLink: {
|
|
2394
|
+
id: 'model-help-link',
|
|
2395
|
+
text: 'Learn more about models',
|
|
2396
|
+
onClick: () => {
|
|
2397
|
+
console.log('Help link clicked - opening model documentation');
|
|
2398
|
+
// Handle the link click, e.g., open documentation or show help dialog
|
|
2399
|
+
}
|
|
2400
|
+
},
|
|
2401
|
+
tabId: 'tab-1',
|
|
2402
|
+
messageId: 'dropdown-with-link-example',
|
|
2403
|
+
options: [
|
|
2404
|
+
{ id: 'gpt4', label: 'GPT-4', value: 'gpt4', selected: true },
|
|
2405
|
+
{ id: 'claude', label: 'Claude', value: 'claude', selected: false },
|
|
2406
|
+
{ id: 'llama', label: 'Llama', value: 'llama', selected: false }
|
|
2407
|
+
]
|
|
2408
|
+
}
|
|
2409
|
+
});
|
|
2410
|
+
```
|
|
2411
|
+
|
|
2412
|
+
<p align="center">
|
|
2413
|
+
<img src="./img/data-model/chatItems/dropdown-list.png" alt="QuickSettings dropdown" style="max-width:300px; width:100%;border: 1px solid #e0e0e0;">
|
|
2414
|
+
</p>
|
|
2415
|
+
|
|
2416
|
+
---
|
|
2417
|
+
|
|
2318
2418
|
## `footer`
|
|
2319
2419
|
With this parameter, you can add another `ChatItem` only with contents to the footer of a ChatItem.
|
|
2320
2420
|
|
|
@@ -3660,7 +3760,6 @@ export interface DetailedListItem {
|
|
|
3660
3760
|
children?: DetailedListItemGroup[];
|
|
3661
3761
|
keywords?: string[];
|
|
3662
3762
|
}
|
|
3663
|
-
}
|
|
3664
3763
|
```
|
|
3665
3764
|
|
|
3666
3765
|
---
|
|
@@ -3698,4 +3797,4 @@ mynahUI.updateStore('tab-1', {
|
|
|
3698
3797
|
|
|
3699
3798
|
The header will appear above the quick action commands list and provides information to users about new features.
|
|
3700
3799
|
|
|
3701
|
-
---
|
|
3800
|
+
---
|
package/docs/PROPERTIES.md
CHANGED
|
@@ -989,6 +989,53 @@ onFormChange?: (
|
|
|
989
989
|
...
|
|
990
990
|
```
|
|
991
991
|
|
|
992
|
+
---
|
|
993
|
+
|
|
994
|
+
### `onDropDownOptionChange`
|
|
995
|
+
|
|
996
|
+
This event will be fired when a user selects an option from a dropdown list. It passes the `tabId`, `messageId`, and the selected options.
|
|
997
|
+
|
|
998
|
+
```typescript
|
|
999
|
+
...
|
|
1000
|
+
onDropDownOptionChange?: (
|
|
1001
|
+
tabId: string,
|
|
1002
|
+
messageId: string,
|
|
1003
|
+
selectedOptions: DropdownListOption[]): void => {
|
|
1004
|
+
console.log(`Dropdown selection changed in tab: ${tabId}`);
|
|
1005
|
+
console.log(`From message: ${messageId}`);
|
|
1006
|
+
console.log(`Selected option: ${selectedOptions[0].label}`);
|
|
1007
|
+
};
|
|
1008
|
+
...
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
<p align="center">
|
|
1012
|
+
<img src="./img/onDropDownOptionChange.png" alt="Dropdown List" style="max-width:300px; width:100%;border: 1px solid #e0e0e0;">
|
|
1013
|
+
</p>
|
|
1014
|
+
|
|
1015
|
+
---
|
|
1016
|
+
|
|
1017
|
+
### `onDropDownLinkClick`
|
|
1018
|
+
|
|
1019
|
+
This event will be fired when a user clicks on a link within a dropdown list's description. It passes the `tabId` and the `actionId` of the clicked link.
|
|
1020
|
+
|
|
1021
|
+
```typescript
|
|
1022
|
+
...
|
|
1023
|
+
onDropDownLinkClick?: (
|
|
1024
|
+
tabId: string,
|
|
1025
|
+
destination: string,
|
|
1026
|
+
actionId: string): void => {
|
|
1027
|
+
console.log(`Dropdown link clicked in tab: ${tabId}`);
|
|
1028
|
+
console.log(`Link action ID: ${actionId}`);
|
|
1029
|
+
console.log(`Destination ID: ${destination}`);
|
|
1030
|
+
};
|
|
1031
|
+
...
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
<p align="center">
|
|
1035
|
+
<img src="./img/onDropDownLinkClick.png" alt="Dropdown List" style="max-width:300px; width:100%;border: 1px solid #e0e0e0;">
|
|
1036
|
+
</p>
|
|
1037
|
+
|
|
1038
|
+
|
|
992
1039
|
---
|
|
993
1040
|
|
|
994
1041
|
### `onCustomFormAction`
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|