|
1 | 1 | 'use client';
|
2 | 2 |
|
| 3 | +import type { ListSelectionChangeEventDetail } from '@ui5/webcomponents/dist/List.js'; |
3 | 4 | import '@ui5/webcomponents-fiori/dist/illustrations/UnableToLoad.js';
|
4 | 5 | import navDownIcon from '@ui5/webcomponents-icons/dist/navigation-down-arrow.js';
|
5 | 6 | import searchIcon from '@ui5/webcomponents-icons/dist/search.js';
|
@@ -32,7 +33,13 @@ import { useCanRenderPortal } from '../../internal/ssr.js';
|
32 | 33 | import { stopPropagation } from '../../internal/stopPropagation.js';
|
33 | 34 | import type { SelectedVariant } from '../../internal/VariantManagementContext.js';
|
34 | 35 | import { VariantManagementContext } from '../../internal/VariantManagementContext.js';
|
35 |
| -import type { ResponsivePopoverDomRef } from '../../webComponents/index.js'; |
| 36 | +import type { |
| 37 | + ButtonPropTypes, |
| 38 | + ListDomRef, |
| 39 | + ResponsivePopoverDomRef, |
| 40 | + ResponsivePopoverPropTypes, |
| 41 | + TitlePropTypes |
| 42 | +} from '../../webComponents/index.js'; |
36 | 43 | import {
|
37 | 44 | Bar,
|
38 | 45 | Button,
|
@@ -62,38 +69,25 @@ export interface VariantManagementPropTypes extends Omit<CommonProps, 'onSelect'
|
62 | 69 | /**
|
63 | 70 | * Determines on which side the VariantManagement popover is placed at.
|
64 | 71 | */
|
65 |
| - placement?: PopoverPlacementType | keyof typeof PopoverPlacementType; |
| 72 | + placement?: ResponsivePopoverPropTypes['placementType']; |
66 | 73 | /**
|
67 | 74 | * Describes the title of the VariantManagement popover.
|
68 | 75 | *
|
69 | 76 | * __Note:__ If not set, the default title is used.
|
70 | 77 | */
|
71 |
| - titleText?: string; |
| 78 | + titleText?: ResponsivePopoverPropTypes['headerText']; |
72 | 79 | /**
|
73 | 80 | * Defines whether the VariantManagement should be closed if an item was selected.
|
74 | 81 | */
|
75 | 82 | closeOnItemSelect?: boolean;
|
76 | 83 | /**
|
77 | 84 | * Describes the `HTML Title` level of the variants.
|
78 | 85 | */
|
79 |
| - level?: TitleLevel | keyof typeof TitleLevel; |
| 86 | + level?: TitlePropTypes['level']; |
80 | 87 | /**
|
81 | 88 | * Defines whether the VariantManagement is disabled.
|
82 | 89 | */
|
83 | 90 | disabled?: boolean;
|
84 |
| - /** |
85 |
| - * Fired after a variant has been selected. |
86 |
| - */ |
87 |
| - onSelect?: ( |
88 |
| - event: Ui5CustomEvent< |
89 |
| - HTMLElement, |
90 |
| - { |
91 |
| - selectedVariant: SelectedVariant; |
92 |
| - selectedItems: unknown[]; |
93 |
| - previouslySelectedItems: unknown[]; |
94 |
| - } |
95 |
| - > |
96 |
| - ) => void; |
97 | 91 | /**
|
98 | 92 | * Indicator for modified but not saved variants.
|
99 | 93 | *
|
@@ -146,31 +140,46 @@ export interface VariantManagementPropTypes extends Omit<CommonProps, 'onSelect'
|
146 | 140 | * Defaults to: `document.body`
|
147 | 141 | */
|
148 | 142 | portalContainer?: Element;
|
| 143 | + /** |
| 144 | + * Fired after a variant has been selected. |
| 145 | + * |
| 146 | + * __Note:__ This event inherits part of its details from the `onSelectionChange` event of the `List` component. |
| 147 | + */ |
| 148 | + onSelect?: ( |
| 149 | + event: Ui5CustomEvent< |
| 150 | + ListDomRef, |
| 151 | + ListSelectionChangeEventDetail & { |
| 152 | + selectedVariant: SelectedVariant; |
| 153 | + } |
| 154 | + > |
| 155 | + ) => void; |
149 | 156 | /**
|
150 | 157 | * The event is fired when the "Save" button is clicked inside the Save View dialog.
|
151 | 158 | *
|
152 | 159 | * __Note:__ Calling `event.preventDefault()` prevents the dialog from closing when clicked.
|
153 | 160 | */
|
154 |
| - onSaveAs?: (e: CustomEvent<SelectedVariant>) => void; |
| 161 | + onSaveAs?: (e: Parameters<ButtonPropTypes['onClick']>[0] & { detail: SelectedVariant }) => void; |
155 | 162 | /**
|
156 | 163 | * The event is fired when the "Save" button is clicked inside the Manage Views dialog.
|
157 | 164 | *
|
158 | 165 | * __Note:__ Calling `event.preventDefault()` prevents the dialog from closing when clicked.
|
159 | 166 | */
|
160 | 167 | onSaveManageViews?: (
|
161 |
| - e: CustomEvent<{ |
162 |
| - deletedVariants: VariantItemPropTypes[]; |
163 |
| - prevVariants: VariantItemPropTypes[]; |
164 |
| - updatedVariants: UpdatedVariant[]; |
165 |
| - variants: SelectedVariant[]; |
166 |
| - }> |
| 168 | + e: Parameters<ButtonPropTypes['onClick']>[0] & { |
| 169 | + detail: { |
| 170 | + deletedVariants: VariantItemPropTypes[]; |
| 171 | + prevVariants: VariantItemPropTypes[]; |
| 172 | + updatedVariants: UpdatedVariant[]; |
| 173 | + variants: SelectedVariant[]; |
| 174 | + }; |
| 175 | + } |
167 | 176 | ) => void;
|
168 | 177 | /**
|
169 | 178 | * The event is fired when the "Save" button is clicked in the `VariantManagement` popover.
|
170 | 179 | *
|
171 | 180 | * __Note:__ The save button is only displayed if the `VariantManagement` is in `dirtyState` and the selected variant is not in `readOnly` mode.
|
172 | 181 | */
|
173 |
| - onSave?: (e: CustomEvent<SelectedVariant>) => void; |
| 182 | + onSave?: (e: Parameters<ButtonPropTypes['onClick']>[0] & { detail: SelectedVariant }) => void; |
174 | 183 | }
|
175 | 184 |
|
176 | 185 | const styles = {
|
|
0 commit comments