@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.
@@ -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.test) {
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.stopPropagation();
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("close");
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("close");
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 (event === "close") {
272
+ if (forceClose) {
271
273
  detailsRef.current.open = false;
272
274
  handleSummaryFocus();
273
275
  }
274
- else if (detailsRef.current.open && (event === null || event === void 0 ? void 0 : event.relatedTarget)) {
275
- const relatedTarget = event.relatedTarget;
276
- if (!detailsRef.current.contains(relatedTarget)) {
277
- // We need to use delay here because the combination of `contains`
278
- // and changing the DOM element causes a race condition inside browser
279
- delay(() => (detailsRef.current.open = false), 1);
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("close");
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(event) {
378
+ function handleSearch(valueOrEvent) {
379
+ if (valueOrEvent === undefined) {
380
+ return;
381
+ }
375
382
  let filterText;
376
- if (typeof event === "string") {
377
- filterText = event;
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("close") }, (_j = props.mobileCloseButtonText) !== null && _j !== void 0 ? _j : DEFAULT_CLOSE_BUTTON))))) : null),
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: any) => void;
49
+ onDropdownToggle?: (event: GeneralEvent<HTMLDetailsElement>) => void;
50
50
  /**
51
51
  * Informs the user when dropdown was toggled.
52
52
  */
53
- dropdownToggle?: (event: any) => void;
53
+ dropdownToggle?: (event: GeneralEvent<HTMLDetailsElement>) => void;
54
54
  /**
55
55
  * Informs the user when a search was performed.
56
56
  */
57
- onSearch?: (event: any) => void;
57
+ onSearch?: (event: InputEvent<HTMLInputElement>) => void;
58
58
  /**
59
59
  * Informs the user when a search was performed.
60
60
  */
61
- search?: (event: any) => void;
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?: any) => void;
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
- declare const DBDrawer: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, "width" | "spacing" | keyof import("../..").GlobalProps | keyof import("../..").CloseEventProps | keyof import("../..").InnerCloseButtonProps | keyof import("./model").DBDrawerDefaultProps> & import("./model").DBDrawerDefaultProps & import("../..").GlobalProps & import("../..").CloseEventProps & import("../..").InnerCloseButtonProps & import("../..").WidthProps & import("../..").SpacingProps & React.RefAttributes<any>>;
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
- if (event.key === "Escape") {
14
- event.preventDefault();
15
- }
16
- if (forceClose) {
17
- event.stopPropagation();
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
- if (forceClose ||
20
- event.key === "Escape" ||
21
- (event.target.nodeName === "DIALOG" &&
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
- if (props.onClose) {
25
- props.onClose(event);
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
- 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 | "semantic" | keyof import("../../shared/model").InnerCloseButtonProps | keyof import("../../shared/model").PopoverProps> & import("./model").DBNotificationDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").CloseEventProps & 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>>;
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;
@@ -9,6 +9,8 @@ function DBNotificationFn(props, component) {
9
9
  var _a;
10
10
  const _ref = component || useRef(component);
11
11
  function handleClose(event) {
12
+ if (!event)
13
+ return;
12
14
  event.stopPropagation();
13
15
  if (props.onClose) {
14
16
  props.onClose(event);
@@ -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
- * Informs the user if the current tab index has changed.
31
+ * Provide simple tabs with label + text as content
32
32
  */
33
- onIndexChange?: (index?: number) => void;
33
+ tabs?: DBSimpleTabProps[] | string;
34
+ };
35
+ export type DBTabsEventProps = {
34
36
  /**
35
- * Informs the user if another tab has been selected.
37
+ * Informs the user if the current tab index has changed.
36
38
  */
37
- onTabSelect?: (event?: Event) => void;
39
+ indexChange?: (index?: number) => void;
38
40
  /**
39
41
  * Informs the user if the current tab index has changed.
40
42
  */
41
- indexChange?: (index?: number) => void;
43
+ onIndexChange?: (index?: number) => void;
42
44
  /**
43
45
  * Informs the user if another tab has been selected.
44
46
  */
45
- tabSelect?: (event?: Event) => void;
47
+ onTabSelect?: (event?: InputEvent<HTMLElement>) => void;
46
48
  /**
47
- * Provide simple tabs with label + text as content
49
+ * Informs the user if another tab has been selected.
48
50
  */
49
- tabs?: DBSimpleTabProps[] | string;
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: any) => void;
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("../..").GlobalProps | keyof import("./model").DBTabsDefaultProps | "alignment"> & import("./model").DBTabsDefaultProps & import("../..").GlobalProps & import("../..").OrientationProps & import("../..").WidthProps & import("../..").AlignmentProps & React.RefAttributes<any>>;
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 list = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest("ul");
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 = event.target.closest("db-tab-item")) !== null && _b !== void 0 ? _b : event.target.closest("li");
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
- event === null || event === void 0 ? void 0 : event.stopPropagation();
13
+ if (!event)
14
+ return;
15
+ event.stopPropagation();
14
16
  if (props.onRemove) {
15
17
  props.onRemove(event);
16
18
  }
@@ -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 | any) => void;
405
- onToggle?: (open: boolean | any) => void;
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?: any) => void;
416
+ onClose?: (event?: T) => void;
415
417
  /**
416
418
  * Function to handle button click (close).
417
419
  */
418
- close?: (event?: any) => void;
420
+ close?: (event?: T) => void;
419
421
  };
420
- export type CloseEventState = {
421
- handleClose: (event: any, forceClose?: boolean) => void;
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,
@@ -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>;
@@ -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-getBoundingClientRect-a18038f",
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.3-getBoundingClientRect-a18038f",
42
- "@db-ux/core-foundations": "2.2.3-getBoundingClientRect-a18038f"
41
+ "@db-ux/core-components": "2.2.4",
42
+ "@db-ux/core-foundations": "2.2.4"
43
43
  }
44
44
  }