|
1 | 1 | 'use client';
|
2 | 2 |
|
| 3 | +import type ListItemBase from '@ui5/webcomponents/dist/ListItemBase.js'; |
3 | 4 | import ButtonDesign from '@ui5/webcomponents/dist/types/ButtonDesign.js';
|
4 | 5 | import IconMode from '@ui5/webcomponents/dist/types/IconMode.js';
|
5 | 6 | import InputType from '@ui5/webcomponents/dist/types/InputType.js';
|
6 | 7 | import ListSelectionMode from '@ui5/webcomponents/dist/types/ListSelectionMode.js';
|
7 | 8 | import TitleLevel from '@ui5/webcomponents/dist/types/TitleLevel.js';
|
| 9 | +import InvisibleMessageMode from '@ui5/webcomponents-base/dist/types/InvisibleMessageMode.js'; |
| 10 | +import announce from '@ui5/webcomponents-base/dist/util/InvisibleMessage.js'; |
8 | 11 | import iconSearch from '@ui5/webcomponents-icons/dist/search.js';
|
9 | 12 | import { enrichEventWithDetails, useI18nBundle, useStylesheet, useSyncRef } from '@ui5/webcomponents-react-base';
|
10 | 13 | import { clsx } from 'clsx';
|
11 | 14 | import type { ReactNode } from 'react';
|
12 | 15 | import { forwardRef, useEffect, useState } from 'react';
|
13 |
| -import { CANCEL, CLEAR, SEARCH, SELECT, SELECTED } from '../../i18n/i18n-defaults.js'; |
| 16 | +// todo: remove comment once translations are available |
| 17 | +// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 18 | +import { CANCEL, CLEAR, SEARCH, SELECT, SELECTED, SELECTED_ITEMS } from '../../i18n/i18n-defaults.js'; |
14 | 19 | import { Button, Dialog, FlexBox, FlexBoxAlignItems, Icon, Input, List, Text, Title } from '../../index.js';
|
15 | 20 | import type { Ui5CustomEvent } from '../../types/index.js';
|
16 | 21 | import type {
|
@@ -135,9 +140,8 @@ export interface SelectDialogPropTypes
|
135 | 140 | /**
|
136 | 141 | * This event will be fired when the dialog is confirmed by selecting an item in single selection mode or by pressing the confirmation button in multi selection mode.
|
137 | 142 | */
|
138 |
| - onConfirm?: |
139 |
| - | ((event: Ui5CustomEvent<ListDomRef, { selectedItems: ListItemStandardDomRef[] }>) => void) |
140 |
| - | ((event: Ui5CustomEvent<ButtonDomRef, { selectedItems: ListItemStandardDomRef[] }>) => void); |
| 143 | + onConfirm?: (event: Ui5CustomEvent<ListDomRef | ButtonDomRef, { selectedItems: ListItemBase[] }>) => void; |
| 144 | + |
141 | 145 | /**
|
142 | 146 | * This event will be fired when the cancel button is clicked or ESC key is pressed.
|
143 | 147 | */
|
@@ -232,12 +236,18 @@ const SelectDialog = forwardRef<DialogDomRef, SelectDialogPropTypes>((props, ref
|
232 | 236 | setSearchValue('');
|
233 | 237 | };
|
234 | 238 |
|
235 |
| - const handleSelectionChange = (e) => { |
| 239 | + const handleSelectionChange: ListPropTypes['onSelectionChange'] = (e) => { |
| 240 | + const { selectedItems } = e.detail; |
236 | 241 | if (typeof listProps?.onSelectionChange === 'function') {
|
237 | 242 | listProps.onSelectionChange(e);
|
238 | 243 | }
|
239 | 244 | if (selectionMode === ListSelectionMode.Multiple) {
|
240 |
| - setSelectedItems(e.detail.selectedItems); |
| 245 | + setSelectedItems(selectedItems); |
| 246 | + if (selectedItems.length) { |
| 247 | + announce('Selected Items ' + selectedItems.length, InvisibleMessageMode.Polite); |
| 248 | + //todo: uncomment this, once translations are available |
| 249 | + // announce(i18nBundle.getText(SELECTED_ITEMS, selectedItems.length), InvisibleMessageMode.Polite); |
| 250 | + } |
241 | 251 | } else {
|
242 | 252 | if (typeof onConfirm === 'function') {
|
243 | 253 | onConfirm(e);
|
|
0 commit comments