@db-ux/react-core-components 2.2.3-getBoundingClientRect-a18038f → 2.2.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/custom-select/custom-select.js +26 -18
- package/dist/components/custom-select/model.d.ts +7 -7
- package/dist/components/drawer/drawer.d.ts +2 -1
- package/dist/components/drawer/drawer.js +23 -12
- package/dist/components/drawer/model.d.ts +3 -3
- package/dist/components/notification/model.d.ts +3 -3
- package/dist/components/notification/notification.d.ts +2 -1
- package/dist/components/notification/notification.js +2 -0
- package/dist/components/tabs/model.d.ts +13 -11
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +5 -2
- package/dist/components/tag/model.d.ts +12 -10
- package/dist/components/tag/tag.d.ts +1 -1
- package/dist/components/tag/tag.js +3 -1
- package/dist/shared/model.d.ts +9 -7
- package/dist/utils/floating-components.d.ts +13 -0
- package/dist/utils/floating-components.js +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +1 -0
- package/package.json +3 -3
|
@@ -102,12 +102,12 @@ function DBCustomSelectFn(props, component) {
|
|
|
102
102
|
event.stopPropagation();
|
|
103
103
|
props.onDropdownToggle(event);
|
|
104
104
|
}
|
|
105
|
-
if (event.target.open) {
|
|
105
|
+
if (event.target instanceof HTMLDetailsElement && event.target.open) {
|
|
106
106
|
set_documentClickListenerCallbackId(new DocumentClickListener().addCallback((event) => handleDocumentClose(event)));
|
|
107
107
|
set_documentScrollListenerCallbackId(new DocumentScrollListener().addCallback((event) => handleDocumentScroll(event)));
|
|
108
108
|
handleAutoPlacement();
|
|
109
109
|
_observer === null || _observer === void 0 ? void 0 : _observer.observe(detailsRef.current);
|
|
110
|
-
if (!event.target.dataset
|
|
110
|
+
if (!event.target.dataset["test"]) {
|
|
111
111
|
// We need this workaround for snapshot testing
|
|
112
112
|
handleOpenByKeyboardFocus();
|
|
113
113
|
}
|
|
@@ -162,7 +162,9 @@ function DBCustomSelectFn(props, component) {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
function handleTagRemove(option, event) {
|
|
165
|
-
event
|
|
165
|
+
if (event) {
|
|
166
|
+
event.stopPropagation();
|
|
167
|
+
}
|
|
166
168
|
handleSelect(option.value);
|
|
167
169
|
handleSummaryFocus();
|
|
168
170
|
}
|
|
@@ -229,7 +231,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
229
231
|
// 2. If we are on the search, and press up we go back to summary and close
|
|
230
232
|
if (activeElement.getAttribute("type") === "search" &&
|
|
231
233
|
(event.key === "ArrowUp" || event.key === "ArrowLeft")) {
|
|
232
|
-
handleClose(
|
|
234
|
+
handleClose(undefined, true);
|
|
233
235
|
handleSummaryFocus();
|
|
234
236
|
}
|
|
235
237
|
else {
|
|
@@ -255,7 +257,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
255
257
|
var _a;
|
|
256
258
|
event.stopPropagation();
|
|
257
259
|
if (event.key === "Escape" && ((_a = detailsRef.current) === null || _a === void 0 ? void 0 : _a.open)) {
|
|
258
|
-
handleClose(
|
|
260
|
+
handleClose(undefined, true);
|
|
259
261
|
handleSummaryFocus();
|
|
260
262
|
}
|
|
261
263
|
else if (event.key === "ArrowDown" ||
|
|
@@ -265,18 +267,20 @@ function DBCustomSelectFn(props, component) {
|
|
|
265
267
|
handleArrowDownUp(event);
|
|
266
268
|
}
|
|
267
269
|
}
|
|
268
|
-
function handleClose(event) {
|
|
270
|
+
function handleClose(event, forceClose) {
|
|
269
271
|
if (detailsRef.current) {
|
|
270
|
-
if (
|
|
272
|
+
if (forceClose) {
|
|
271
273
|
detailsRef.current.open = false;
|
|
272
274
|
handleSummaryFocus();
|
|
273
275
|
}
|
|
274
|
-
else if (detailsRef.current.open &&
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
else if (detailsRef.current.open && event) {
|
|
277
|
+
if (event.relatedTarget) {
|
|
278
|
+
const relatedTarget = event.relatedTarget;
|
|
279
|
+
if (!detailsRef.current.contains(relatedTarget)) {
|
|
280
|
+
// We need to use delay here because the combination of `contains`
|
|
281
|
+
// and changing the DOM element causes a race condition inside browser
|
|
282
|
+
delay(() => (detailsRef.current.open = false), 1);
|
|
283
|
+
}
|
|
280
284
|
}
|
|
281
285
|
}
|
|
282
286
|
}
|
|
@@ -313,7 +317,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
313
317
|
}
|
|
314
318
|
else {
|
|
315
319
|
handleOptionSelected([value]);
|
|
316
|
-
handleClose(
|
|
320
|
+
handleClose(undefined, true);
|
|
317
321
|
}
|
|
318
322
|
}
|
|
319
323
|
}
|
|
@@ -371,12 +375,16 @@ function DBCustomSelectFn(props, component) {
|
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
377
|
}
|
|
374
|
-
function handleSearch(
|
|
378
|
+
function handleSearch(valueOrEvent) {
|
|
379
|
+
if (valueOrEvent === undefined) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
375
382
|
let filterText;
|
|
376
|
-
if (typeof
|
|
377
|
-
filterText =
|
|
383
|
+
if (typeof valueOrEvent === "string") {
|
|
384
|
+
filterText = valueOrEvent;
|
|
378
385
|
}
|
|
379
386
|
else {
|
|
387
|
+
const event = valueOrEvent;
|
|
380
388
|
event.stopPropagation();
|
|
381
389
|
if (props.onSearch) {
|
|
382
390
|
props.onSearch(event);
|
|
@@ -612,7 +620,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
612
620
|
getSelectAllLabel())))) : null,
|
|
613
621
|
React.createElement(DBCustomSelectList, { multiple: getBoolean(props.multiple, "multiple"), label: (_h = (_g = props.ariaListLabel) !== null && _g !== void 0 ? _g : props.label) !== null && _h !== void 0 ? _h : DEFAULT_LABEL }, _options === null || _options === void 0 ? void 0 : _options.map((option) => (React.createElement(DBCustomSelectListItem, { type: props.multiple ? "checkbox" : "radio", showDivider: option.showDivider, icon: option.icon, isGroupTitle: option.isGroupTitle, groupTitle: getOptionLabel(option), name: _id, checked: getOptionChecked(option.value), disabled: option.disabled, value: option.value, onChange: (event) => handleSelect(option.value), key: getOptionKey(option, "custom-select-list-item-") }, !option.isGroupTitle ? (React.createElement(React.Fragment, null, getOptionLabel(option))) : null))))))),
|
|
614
622
|
React.createElement("div", null,
|
|
615
|
-
React.createElement(DBButton, { variant: "ghost", width: "full", icon: "cross", size: "small", name: _id, form: _id, onClick: (event) => handleClose(
|
|
623
|
+
React.createElement(DBButton, { variant: "ghost", width: "full", icon: "cross", size: "small", name: _id, form: _id, onClick: (event) => handleClose(undefined, true) }, (_j = props.mobileCloseButtonText) !== null && _j !== void 0 ? _j : DEFAULT_CLOSE_BUTTON))))) : null),
|
|
616
624
|
((_k = props.showClearSelection) !== null && _k !== void 0 ? _k : true) && (_values === null || _values === void 0 ? void 0 : _values.length) ? (React.createElement(DBButton, { icon: "cross", variant: "ghost", size: "small", noText: true, name: _id, form: _id, onClick: (event) => handleClearAll(event) },
|
|
617
625
|
props.clearSelectionText,
|
|
618
626
|
React.createElement(DBTooltip, { placement: "top" }, props.clearSelectionText))) : null,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseFormProps, CloseEventState, CustomFormProps, DocumentScrollState, FormMessageProps, FormState, FromValidState, GlobalProps, GlobalState, IconProps, PlacementVerticalType, RequiredProps, ShowIconProps, ShowLabelProps, ValidationType, WidthType } from '../../shared/model';
|
|
1
|
+
import { BaseFormProps, ClickEvent, CloseEventState, CustomFormProps, DocumentScrollState, FormMessageProps, FormState, FromValidState, GeneralEvent, GlobalProps, GlobalState, IconProps, InputEvent, InteractionEvent, PlacementVerticalType, RequiredProps, ShowIconProps, ShowLabelProps, ValidationType, WidthType } from '../../shared/model';
|
|
2
2
|
import { DBCustomSelectFormFieldDefaultProps } from '../custom-select-form-field/model';
|
|
3
3
|
import { CustomSelectDropdownWidthType } from '../custom-select-dropdown/model';
|
|
4
4
|
import { DBCustomSelectListItemExtraProps } from '../custom-select-list-item/model';
|
|
@@ -46,19 +46,19 @@ export type DBCustomSelectEvents = {
|
|
|
46
46
|
/**
|
|
47
47
|
* Informs the user when dropdown was toggled.
|
|
48
48
|
*/
|
|
49
|
-
onDropdownToggle?: (event:
|
|
49
|
+
onDropdownToggle?: (event: GeneralEvent<HTMLDetailsElement>) => void;
|
|
50
50
|
/**
|
|
51
51
|
* Informs the user when dropdown was toggled.
|
|
52
52
|
*/
|
|
53
|
-
dropdownToggle?: (event:
|
|
53
|
+
dropdownToggle?: (event: GeneralEvent<HTMLDetailsElement>) => void;
|
|
54
54
|
/**
|
|
55
55
|
* Informs the user when a search was performed.
|
|
56
56
|
*/
|
|
57
|
-
onSearch?: (event:
|
|
57
|
+
onSearch?: (event: InputEvent<HTMLInputElement>) => void;
|
|
58
58
|
/**
|
|
59
59
|
* Informs the user when a search was performed.
|
|
60
60
|
*/
|
|
61
|
-
search?: (event:
|
|
61
|
+
search?: (event: InputEvent<HTMLInputElement>) => void;
|
|
62
62
|
};
|
|
63
63
|
export type DBCustomSelectDefaultProps = {
|
|
64
64
|
/**
|
|
@@ -198,7 +198,7 @@ export type DBCustomSelectDefaultState = {
|
|
|
198
198
|
searchEnabled: boolean;
|
|
199
199
|
amountOptions: number;
|
|
200
200
|
setDescById: (descId?: string) => void;
|
|
201
|
-
handleTagRemove: (option: CustomSelectOptionType, event?:
|
|
201
|
+
handleTagRemove: (option: CustomSelectOptionType, event?: ClickEvent<HTMLButtonElement> | void) => void;
|
|
202
202
|
handleSummaryFocus: () => void;
|
|
203
203
|
handleSelect: (value?: string) => void;
|
|
204
204
|
handleSelectAll: (event: any) => void;
|
|
@@ -216,4 +216,4 @@ export type DBCustomSelectDefaultState = {
|
|
|
216
216
|
selectAllIndeterminate: boolean;
|
|
217
217
|
handleAutoPlacement: () => void;
|
|
218
218
|
};
|
|
219
|
-
export type DBCustomSelectState = DBCustomSelectDefaultState & GlobalState & FormState & FromValidState & CloseEventState & DocumentScrollState;
|
|
219
|
+
export type DBCustomSelectState = DBCustomSelectDefaultState & GlobalState & FormState & FromValidState & CloseEventState<InteractionEvent<HTMLDetailsElement>> & DocumentScrollState;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { ClickEvent, GeneralKeyboardEvent } from "../../shared/model";
|
|
3
|
+
declare const DBDrawer: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "width" | "spacing" | keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").InnerCloseButtonProps | keyof import("./model").DBDrawerDefaultProps | keyof import("../../shared/model").CloseEventProps<ClickEvent<HTMLButtonElement | HTMLDialogElement> | GeneralKeyboardEvent<HTMLDialogElement>>> & import("./model").DBDrawerDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").CloseEventProps<ClickEvent<HTMLButtonElement | HTMLDialogElement> | GeneralKeyboardEvent<HTMLDialogElement>> & import("../../shared/model").InnerCloseButtonProps & import("../../shared/model").WidthProps & import("../../shared/model").SpacingProps & React.RefAttributes<any>>;
|
|
3
4
|
export default DBDrawer;
|
|
@@ -4,25 +4,36 @@ import { filterPassingProps, getRootProps } from "../../utils/react";
|
|
|
4
4
|
import { useRef, useEffect, forwardRef } from "react";
|
|
5
5
|
import DBButton from "../button/button";
|
|
6
6
|
import { DEFAULT_CLOSE_BUTTON } from "../../shared/constants";
|
|
7
|
-
import { cls, delay, getBooleanAsString } from "../../utils";
|
|
7
|
+
import { cls, delay, getBooleanAsString, isKeyboardEvent } from "../../utils";
|
|
8
8
|
function DBDrawerFn(props, component) {
|
|
9
9
|
var _a;
|
|
10
10
|
const _ref = component || useRef(component);
|
|
11
11
|
const dialogContainerRef = useRef(null);
|
|
12
12
|
function handleClose(event, forceClose) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
event.
|
|
13
|
+
var _a;
|
|
14
|
+
if (!event)
|
|
15
|
+
return;
|
|
16
|
+
if (isKeyboardEvent(event)) {
|
|
17
|
+
if (event.key === "Escape") {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
if (props.onClose) {
|
|
20
|
+
props.onClose(event);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
else {
|
|
25
|
+
if (forceClose) {
|
|
26
|
+
event.stopPropagation();
|
|
27
|
+
if (props.onClose) {
|
|
28
|
+
props.onClose(event);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (((_a = event.target) === null || _a === void 0 ? void 0 : _a.nodeName) === "DIALOG" &&
|
|
22
32
|
event.type === "click" &&
|
|
23
|
-
props.backdrop !== "none")
|
|
24
|
-
|
|
25
|
-
|
|
33
|
+
props.backdrop !== "none") {
|
|
34
|
+
if (props.onClose) {
|
|
35
|
+
props.onClose(event);
|
|
36
|
+
}
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CloseEventProps, CloseEventState, GlobalProps, GlobalState, InnerCloseButtonProps, SpacingProps, WidthProps } from '../../shared/model';
|
|
1
|
+
import { ClickEvent, CloseEventProps, CloseEventState, GeneralKeyboardEvent, GlobalProps, GlobalState, InnerCloseButtonProps, SpacingProps, WidthProps } from '../../shared/model';
|
|
2
2
|
export declare const DrawerBackdropList: readonly ["none", "strong", "weak", "invisible"];
|
|
3
3
|
export type DrawerBackdropType = (typeof DrawerBackdropList)[number];
|
|
4
4
|
export declare const DrawerDirectionList: readonly ["left", "right", "up", "down"];
|
|
@@ -34,8 +34,8 @@ export type DBDrawerDefaultProps = {
|
|
|
34
34
|
*/
|
|
35
35
|
variant?: DrawerVariantType;
|
|
36
36
|
};
|
|
37
|
-
export type DBDrawerProps = DBDrawerDefaultProps & GlobalProps & CloseEventProps & InnerCloseButtonProps & WidthProps & SpacingProps;
|
|
37
|
+
export type DBDrawerProps = DBDrawerDefaultProps & GlobalProps & CloseEventProps<ClickEvent<HTMLButtonElement | HTMLDialogElement> | GeneralKeyboardEvent<HTMLDialogElement>> & InnerCloseButtonProps & WidthProps & SpacingProps;
|
|
38
38
|
export type DBDrawerDefaultState = {
|
|
39
39
|
handleDialogOpen: () => void;
|
|
40
40
|
};
|
|
41
|
-
export type DBDrawerState = DBDrawerDefaultState & GlobalState & CloseEventState
|
|
41
|
+
export type DBDrawerState = DBDrawerDefaultState & GlobalState & CloseEventState<ClickEvent<HTMLButtonElement | HTMLDialogElement> | GeneralKeyboardEvent<HTMLDialogElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CloseEventProps, CloseEventState, GlobalProps, GlobalState, IconProps, InnerCloseButtonProps, PopoverProps, SemanticProps, ShowIconProps, TextProps } from '../../shared/model';
|
|
1
|
+
import { ClickEvent, CloseEventProps, CloseEventState, GlobalProps, GlobalState, IconProps, InnerCloseButtonProps, PopoverProps, SemanticProps, ShowIconProps, TextProps } from '../../shared/model';
|
|
2
2
|
export declare const NotificationVariantList: readonly ["docked", "standalone", "overlay"];
|
|
3
3
|
export type NotificationVariantType = (typeof NotificationVariantList)[number];
|
|
4
4
|
export declare const NotificationLinkVariantList: readonly ["block", "inline"];
|
|
@@ -52,6 +52,6 @@ export type DBNotificationDefaultProps = {
|
|
|
52
52
|
*/
|
|
53
53
|
variant?: NotificationVariantType;
|
|
54
54
|
};
|
|
55
|
-
export type DBNotificationProps = DBNotificationDefaultProps & GlobalProps & CloseEventProps & IconProps & SemanticProps & InnerCloseButtonProps & PopoverProps & ShowIconProps & TextProps;
|
|
55
|
+
export type DBNotificationProps = DBNotificationDefaultProps & GlobalProps & CloseEventProps<ClickEvent<HTMLButtonElement>> & IconProps & SemanticProps & InnerCloseButtonProps & PopoverProps & ShowIconProps & TextProps;
|
|
56
56
|
export type DBNotificationDefaultState = {};
|
|
57
|
-
export type DBNotificationState = DBNotificationDefaultState & GlobalState & CloseEventState
|
|
57
|
+
export type DBNotificationState = DBNotificationDefaultState & GlobalState & CloseEventState<ClickEvent<HTMLButtonElement>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { ClickEvent } from "../../shared/model";
|
|
3
|
+
declare const DBNotification: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "text" | "icon" | keyof import("../../shared/model").GlobalProps | "showIcon" | keyof import("./model").DBNotificationDefaultProps | keyof import("../../shared/model").CloseEventProps<ClickEvent<HTMLButtonElement>> | "semantic" | keyof import("../../shared/model").InnerCloseButtonProps | keyof import("../../shared/model").PopoverProps> & import("./model").DBNotificationDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").CloseEventProps<ClickEvent<HTMLButtonElement>> & import("../../shared/model").IconProps & import("../../shared/model").SemanticProps & import("../../shared/model").InnerCloseButtonProps & import("../../shared/model").PopoverProps & import("../../shared/model").ShowIconProps & import("../../shared/model").TextProps & React.RefAttributes<any>>;
|
|
3
4
|
export default DBNotification;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlignmentProps, GlobalProps, GlobalState, InitializedState, OrientationProps, WidthProps } from '../../shared/model';
|
|
1
|
+
import { AlignmentProps, InputEvent, GlobalProps, GlobalState, InitializedState, OrientationProps, WidthProps } from '../../shared/model';
|
|
2
2
|
import { DBTabItemProps } from '../tab-item/model';
|
|
3
3
|
import { DBTabPanelProps } from '../tab-panel/model';
|
|
4
4
|
export declare const TabsBehaviorList: readonly ["scrollbar", "arrows"];
|
|
@@ -28,27 +28,29 @@ export type DBTabsDefaultProps = {
|
|
|
28
28
|
*/
|
|
29
29
|
name?: string;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Provide simple tabs with label + text as content
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
tabs?: DBSimpleTabProps[] | string;
|
|
34
|
+
};
|
|
35
|
+
export type DBTabsEventProps = {
|
|
34
36
|
/**
|
|
35
|
-
* Informs the user if
|
|
37
|
+
* Informs the user if the current tab index has changed.
|
|
36
38
|
*/
|
|
37
|
-
|
|
39
|
+
indexChange?: (index?: number) => void;
|
|
38
40
|
/**
|
|
39
41
|
* Informs the user if the current tab index has changed.
|
|
40
42
|
*/
|
|
41
|
-
|
|
43
|
+
onIndexChange?: (index?: number) => void;
|
|
42
44
|
/**
|
|
43
45
|
* Informs the user if another tab has been selected.
|
|
44
46
|
*/
|
|
45
|
-
|
|
47
|
+
onTabSelect?: (event?: InputEvent<HTMLElement>) => void;
|
|
46
48
|
/**
|
|
47
|
-
*
|
|
49
|
+
* Informs the user if another tab has been selected.
|
|
48
50
|
*/
|
|
49
|
-
|
|
51
|
+
tabSelect?: (event?: InputEvent<HTMLElement>) => void;
|
|
50
52
|
};
|
|
51
|
-
export type DBTabsProps = DBTabsDefaultProps & GlobalProps & OrientationProps & WidthProps & AlignmentProps;
|
|
53
|
+
export type DBTabsProps = DBTabsDefaultProps & GlobalProps & OrientationProps & WidthProps & AlignmentProps & DBTabsEventProps;
|
|
52
54
|
export type DBTabsDefaultState = {
|
|
53
55
|
_name: string;
|
|
54
56
|
scrollContainer?: Element | null;
|
|
@@ -59,6 +61,6 @@ export type DBTabsDefaultState = {
|
|
|
59
61
|
convertTabs: () => DBSimpleTabProps[];
|
|
60
62
|
initTabList: () => void;
|
|
61
63
|
initTabs: (init?: boolean) => void;
|
|
62
|
-
handleChange: (event:
|
|
64
|
+
handleChange: (event: InputEvent<HTMLElement>) => void;
|
|
63
65
|
};
|
|
64
66
|
export type DBTabsState = DBTabsDefaultState & GlobalState & InitializedState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBTabs: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "width" | "orientation" | keyof import("
|
|
2
|
+
declare const DBTabs: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "width" | "orientation" | keyof import("../../shared/model").GlobalProps | keyof import("./model").DBTabsDefaultProps | "alignment" | keyof import("./model").DBTabsEventProps> & import("./model").DBTabsDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").OrientationProps & import("../../shared/model").WidthProps & import("../../shared/model").AlignmentProps & import("./model").DBTabsEventProps & React.RefAttributes<any>>;
|
|
3
3
|
export default DBTabs;
|
|
@@ -104,10 +104,13 @@ function DBTabsFn(props, component) {
|
|
|
104
104
|
function handleChange(event) {
|
|
105
105
|
var _a, _b;
|
|
106
106
|
event.stopPropagation();
|
|
107
|
-
const
|
|
107
|
+
const closest = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest;
|
|
108
|
+
if (!closest)
|
|
109
|
+
return;
|
|
110
|
+
const list = closest("ul");
|
|
108
111
|
const listItem =
|
|
109
112
|
// db-tab-item for angular and stencil wrapping elements
|
|
110
|
-
(_b =
|
|
113
|
+
(_b = closest("db-tab-item")) !== null && _b !== void 0 ? _b : closest("li");
|
|
111
114
|
if (list !== null && listItem !== null) {
|
|
112
115
|
const indices = Array.from(list.childNodes).indexOf(listItem);
|
|
113
116
|
if (props.onIndexChange) {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { ClickEvent, ContentSlotProps, GlobalProps, GlobalState, IconProps, InitializedState, OverflowProps, SemanticProps, ShowIconProps, EmphasisProps } from '../../shared/model';
|
|
2
2
|
export declare const TagBehaviorList: readonly ["static", "removable"];
|
|
3
3
|
export type TagBehaviorType = (typeof TagBehaviorList)[number];
|
|
4
|
+
export type DBTagEventsProps = {
|
|
5
|
+
/**
|
|
6
|
+
* If "removeButton" attribute is set this function will be called when user clicks cancel button inside the tag.
|
|
7
|
+
*/
|
|
8
|
+
onRemove?: (event?: ClickEvent<HTMLButtonElement> | void) => void;
|
|
9
|
+
/**
|
|
10
|
+
* If "removeButton" attribute is set this function will be called when user clicks cancel button inside the tag.
|
|
11
|
+
*/
|
|
12
|
+
remove?: (event?: ClickEvent<HTMLButtonElement> | void) => void;
|
|
13
|
+
};
|
|
4
14
|
export type DBTagDefaultProps = {
|
|
5
15
|
/**
|
|
6
16
|
* Defines the behavior of the component:
|
|
@@ -16,14 +26,6 @@ export type DBTagDefaultProps = {
|
|
|
16
26
|
* Define the text next to the icon specified via the icon Property to get hidden.
|
|
17
27
|
*/
|
|
18
28
|
noText?: boolean | string;
|
|
19
|
-
/**
|
|
20
|
-
* If "removeButton" attribute is set this function will be called when user clicks cancel button inside the tag.
|
|
21
|
-
*/
|
|
22
|
-
onRemove?: (event?: any) => void;
|
|
23
|
-
/**
|
|
24
|
-
* If "removeButton" attribute is set this function will be called when user clicks cancel button inside the tag.
|
|
25
|
-
*/
|
|
26
|
-
remove?: (event?: any) => void;
|
|
27
29
|
/**
|
|
28
30
|
* The removeButton attribute shows the cancel button.
|
|
29
31
|
*/
|
|
@@ -41,9 +43,9 @@ export type DBTagDefaultProps = {
|
|
|
41
43
|
*/
|
|
42
44
|
value?: string;
|
|
43
45
|
};
|
|
44
|
-
export type DBTagProps = DBTagDefaultProps & GlobalProps & IconProps & SemanticProps & OverflowProps & EmphasisProps & ShowIconProps & ContentSlotProps;
|
|
46
|
+
export type DBTagProps = DBTagDefaultProps & GlobalProps & IconProps & SemanticProps & OverflowProps & EmphasisProps & ShowIconProps & ContentSlotProps & DBTagEventsProps;
|
|
45
47
|
export type DBTagDefaultState = {
|
|
46
48
|
getRemoveButtonText: () => string;
|
|
47
|
-
handleRemove: (event?: ClickEvent<HTMLButtonElement>) => void;
|
|
49
|
+
handleRemove: (event?: ClickEvent<HTMLButtonElement> | void) => void;
|
|
48
50
|
};
|
|
49
51
|
export type DBTagState = DBTagDefaultState & GlobalState & InitializedState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBTag: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "content" | "overflow" | "icon" | keyof import("../../shared/model").GlobalProps | "showIcon" | "semantic" | "emphasis" | keyof import("./model").DBTagDefaultProps> & import("./model").DBTagDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").IconProps & import("../../shared/model").SemanticProps & import("../../shared/model").OverflowProps & import("../../shared/model").EmphasisProps & import("../../shared/model").ShowIconProps & import("../../shared/model").ContentSlotProps & React.RefAttributes<any>>;
|
|
2
|
+
declare const DBTag: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "content" | "overflow" | "icon" | keyof import("../../shared/model").GlobalProps | "showIcon" | "semantic" | "emphasis" | keyof import("./model").DBTagDefaultProps | keyof import("./model").DBTagEventsProps> & import("./model").DBTagDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").IconProps & import("../../shared/model").SemanticProps & import("../../shared/model").OverflowProps & import("../../shared/model").EmphasisProps & import("../../shared/model").ShowIconProps & import("../../shared/model").ContentSlotProps & import("./model").DBTagEventsProps & React.RefAttributes<any>>;
|
|
3
3
|
export default DBTag;
|
|
@@ -10,7 +10,9 @@ function DBTagFn(props, component) {
|
|
|
10
10
|
const _ref = component || useRef(component);
|
|
11
11
|
const [initialized, setInitialized] = useState(() => false);
|
|
12
12
|
function handleRemove(event) {
|
|
13
|
-
|
|
13
|
+
if (!event)
|
|
14
|
+
return;
|
|
15
|
+
event.stopPropagation();
|
|
14
16
|
if (props.onRemove) {
|
|
15
17
|
props.onRemove(event);
|
|
16
18
|
}
|
package/dist/shared/model.d.ts
CHANGED
|
@@ -390,6 +390,8 @@ export type TextProps = {
|
|
|
390
390
|
*/
|
|
391
391
|
text?: string;
|
|
392
392
|
};
|
|
393
|
+
export type GeneralEvent<T> = React.SyntheticEvent<T>;
|
|
394
|
+
export type GeneralKeyboardEvent<T> = React.KeyboardEvent<T>;
|
|
393
395
|
export type ClickEvent<T> = React.MouseEvent<T, MouseEvent>;
|
|
394
396
|
export type ClickEventProps<T> = {
|
|
395
397
|
/**
|
|
@@ -401,24 +403,24 @@ export type ClickEventState<T> = {
|
|
|
401
403
|
handleClick: (event: ClickEvent<T> | any) => void;
|
|
402
404
|
};
|
|
403
405
|
export type ToggleEventProps = {
|
|
404
|
-
toggle?: (open: boolean
|
|
405
|
-
onToggle?: (open: boolean
|
|
406
|
+
toggle?: (open: boolean) => void;
|
|
407
|
+
onToggle?: (open: boolean) => void;
|
|
406
408
|
};
|
|
407
409
|
export type ToggleEventState<T> = {
|
|
408
410
|
handleToggle: (event?: ClickEvent<T> | any) => void;
|
|
409
411
|
};
|
|
410
|
-
export type CloseEventProps = {
|
|
412
|
+
export type CloseEventProps<T> = {
|
|
411
413
|
/**
|
|
412
414
|
* Function to handle button click (close).
|
|
413
415
|
*/
|
|
414
|
-
onClose?: (event?:
|
|
416
|
+
onClose?: (event?: T) => void;
|
|
415
417
|
/**
|
|
416
418
|
* Function to handle button click (close).
|
|
417
419
|
*/
|
|
418
|
-
close?: (event?:
|
|
420
|
+
close?: (event?: T) => void;
|
|
419
421
|
};
|
|
420
|
-
export type CloseEventState = {
|
|
421
|
-
handleClose: (event
|
|
422
|
+
export type CloseEventState<T> = {
|
|
423
|
+
handleClose: (event?: T | void, forceClose?: boolean) => void;
|
|
422
424
|
};
|
|
423
425
|
export declare const AlignmentList: readonly ["start", "center"];
|
|
424
426
|
export type AlignmentType = (typeof AlignmentList)[number];
|
|
@@ -4,4 +4,17 @@ export interface DBDataOutsidePair {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const handleDataOutside: (el: HTMLElement) => DBDataOutsidePair;
|
|
6
6
|
export declare const handleFixedDropdown: (element: HTMLElement, parent: HTMLElement, placement: string) => void;
|
|
7
|
+
export declare const getFloatingProps: (element: HTMLElement, parent: HTMLElement, placement: string) => {
|
|
8
|
+
top: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
right: number;
|
|
11
|
+
height: number;
|
|
12
|
+
width: number;
|
|
13
|
+
left: number;
|
|
14
|
+
childHeight: number;
|
|
15
|
+
childWidth: number;
|
|
16
|
+
correctedPlacement: string;
|
|
17
|
+
innerWidth: number;
|
|
18
|
+
innerHeight: number;
|
|
19
|
+
};
|
|
7
20
|
export declare const handleFixedPopover: (element: HTMLElement, parent: HTMLElement, placement: string) => void;
|
|
@@ -82,7 +82,7 @@ export const handleFixedDropdown = (element, parent, placement) => {
|
|
|
82
82
|
}
|
|
83
83
|
element.style.position = 'fixed';
|
|
84
84
|
};
|
|
85
|
-
const getFloatingProps = (element, parent, placement) => {
|
|
85
|
+
export const getFloatingProps = (element, parent, placement) => {
|
|
86
86
|
if (!element || !parent) {
|
|
87
87
|
return {
|
|
88
88
|
top: 0,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClickEvent, GeneralKeyboardEvent } from '../shared/model';
|
|
1
2
|
export declare const uuid: () => string;
|
|
2
3
|
export declare const addAttributeToChildren: (element: Element, attribute: {
|
|
3
4
|
key: string;
|
|
@@ -36,3 +37,4 @@ export declare const getOptionKey: (option: {
|
|
|
36
37
|
id?: string;
|
|
37
38
|
value?: string | number | string[] | undefined;
|
|
38
39
|
}, prefix: string) => string;
|
|
40
|
+
export declare const isKeyboardEvent: <T>(event?: ClickEvent<T> | GeneralKeyboardEvent<T>) => event is GeneralKeyboardEvent<T>;
|
package/dist/utils/index.js
CHANGED
|
@@ -103,3 +103,4 @@ export const getOptionKey = (option, prefix) => {
|
|
|
103
103
|
const key = (_b = (_a = option.id) !== null && _a !== void 0 ? _a : option.value) !== null && _b !== void 0 ? _b : uuid();
|
|
104
104
|
return `${prefix}${key}`;
|
|
105
105
|
};
|
|
106
|
+
export const isKeyboardEvent = (event) => event.key !== undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/react-core-components",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "React components for @db-ux/core-components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"sideEffects": false,
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@db-ux/core-components": "2.2.
|
|
42
|
-
"@db-ux/core-foundations": "2.2.
|
|
41
|
+
"@db-ux/core-components": "2.2.4",
|
|
42
|
+
"@db-ux/core-foundations": "2.2.4"
|
|
43
43
|
}
|
|
44
44
|
}
|