@db-ux/react-core-components 2.1.0 → 2.1.1

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.
@@ -7,7 +7,6 @@ function DBButtonFn(props, component) {
7
7
  const _ref = component || useRef(component);
8
8
  function handleClick(event) {
9
9
  if (props.onClick) {
10
- event.stopPropagation();
11
10
  props.onClick(event);
12
11
  }
13
12
  }
@@ -7,7 +7,6 @@ function DBCardFn(props, component) {
7
7
  const _ref = component || useRef(component);
8
8
  function handleClick(event) {
9
9
  if (props.onClick) {
10
- event.stopPropagation();
11
10
  props.onClick(event);
12
11
  }
13
12
  }
@@ -50,20 +50,17 @@ function DBCheckboxFn(props, component) {
50
50
  }
51
51
  }
52
52
  function handleChange(event) {
53
- event.stopPropagation();
54
53
  if (props.onChange) {
55
54
  props.onChange(event);
56
55
  }
57
56
  handleValidation();
58
57
  }
59
58
  function handleBlur(event) {
60
- event.stopPropagation();
61
59
  if (props.onBlur) {
62
60
  props.onBlur(event);
63
61
  }
64
62
  }
65
63
  function handleFocus(event) {
66
- event.stopPropagation();
67
64
  if (props.onFocus) {
68
65
  props.onFocus(event);
69
66
  }
@@ -9,11 +9,14 @@ function DBDrawerFn(props, component) {
9
9
  var _a;
10
10
  const _ref = component || useRef(component);
11
11
  const dialogContainerRef = useRef(null);
12
- function handleClose(event) {
12
+ function handleClose(event, forceClose) {
13
13
  if (event.key === "Escape") {
14
14
  event.preventDefault();
15
15
  }
16
- if (event === "close" ||
16
+ if (forceClose) {
17
+ event.stopPropagation();
18
+ }
19
+ if (forceClose ||
17
20
  event.key === "Escape" ||
18
21
  (event.target.nodeName === "DIALOG" &&
19
22
  event.type === "click" &&
@@ -62,7 +65,7 @@ function DBDrawerFn(props, component) {
62
65
  React.createElement("header", { className: "db-drawer-header" },
63
66
  React.createElement("div", { className: "db-drawer-header-text" },
64
67
  React.createElement(React.Fragment, null, props.drawerHeader)),
65
- React.createElement(DBButton, { className: "button-close-drawer", icon: "cross", variant: "ghost", id: props.closeButtonId, noText: true, onClick: (event) => handleClose("close") }, (_a = props.closeButtonText) !== null && _a !== void 0 ? _a : DEFAULT_CLOSE_BUTTON)),
68
+ React.createElement(DBButton, { className: "button-close-drawer", icon: "cross", variant: "ghost", id: props.closeButtonId, noText: true, onClick: (event) => handleClose(event, true) }, (_a = props.closeButtonText) !== null && _a !== void 0 ? _a : DEFAULT_CLOSE_BUTTON)),
66
69
  React.createElement("div", { className: "db-drawer-content" }, props.children))));
67
70
  }
68
71
  const DBDrawer = forwardRef(DBDrawerFn);
@@ -13,7 +13,10 @@ function DBHeaderFn(props, component) {
13
13
  const [_id, set_id] = useState(() => DEFAULT_ID);
14
14
  const [initialized, setInitialized] = useState(() => false);
15
15
  const [forcedToMobile, setForcedToMobile] = useState(() => false);
16
- function handleToggle() {
16
+ function handleToggle(event) {
17
+ if (event && event.stopPropagation) {
18
+ event.stopPropagation();
19
+ }
17
20
  const open = !getBoolean(props.drawerOpen, "drawerOpen");
18
21
  if (props.onToggle) {
19
22
  props.onToggle(open);
@@ -51,27 +51,23 @@ function DBInputFn(props, component) {
51
51
  }
52
52
  }
53
53
  function handleInput(event) {
54
- event.stopPropagation();
55
54
  if (props.onInput) {
56
55
  props.onInput(event);
57
56
  }
58
57
  handleValidation();
59
58
  }
60
59
  function handleChange(event) {
61
- event.stopPropagation();
62
60
  if (props.onChange) {
63
61
  props.onChange(event);
64
62
  }
65
63
  handleValidation();
66
64
  }
67
65
  function handleBlur(event) {
68
- event.stopPropagation();
69
66
  if (props.onBlur) {
70
67
  props.onBlur(event);
71
68
  }
72
69
  }
73
70
  function handleFocus(event) {
74
- event.stopPropagation();
75
71
  if (props.onFocus) {
76
72
  props.onFocus(event);
77
73
  }
@@ -8,7 +8,6 @@ function DBLinkFn(props, component) {
8
8
  const _ref = component || useRef(component);
9
9
  function handleClick(event) {
10
10
  if (props.onClick) {
11
- event.stopPropagation();
12
11
  props.onClick(event);
13
12
  }
14
13
  }
@@ -9,19 +9,16 @@ function DBRadioFn(props, component) {
9
9
  const [initialized, setInitialized] = useState(() => false);
10
10
  const [_id, set_id] = useState(() => undefined);
11
11
  function handleChange(event) {
12
- event.stopPropagation();
13
12
  if (props.onChange) {
14
13
  props.onChange(event);
15
14
  }
16
15
  }
17
16
  function handleBlur(event) {
18
- event.stopPropagation();
19
17
  if (props.onBlur) {
20
18
  props.onBlur(event);
21
19
  }
22
20
  }
23
21
  function handleFocus(event) {
24
- event.stopPropagation();
25
22
  if (props.onFocus) {
26
23
  props.onFocus(event);
27
24
  }
@@ -53,32 +53,27 @@ function DBSelectFn(props, component) {
53
53
  }
54
54
  function handleClick(event) {
55
55
  if (props.onClick) {
56
- event.stopPropagation();
57
56
  props.onClick(event);
58
57
  }
59
58
  }
60
59
  function handleInput(event) {
61
- event.stopPropagation();
62
60
  if (props.onInput) {
63
61
  props.onInput(event);
64
62
  }
65
63
  handleValidation();
66
64
  }
67
65
  function handleChange(event) {
68
- event.stopPropagation();
69
66
  if (props.onChange) {
70
67
  props.onChange(event);
71
68
  }
72
69
  handleValidation();
73
70
  }
74
71
  function handleBlur(event) {
75
- event.stopPropagation();
76
72
  if (props.onBlur) {
77
73
  props.onBlur(event);
78
74
  }
79
75
  }
80
76
  function handleFocus(event) {
81
- event.stopPropagation();
82
77
  if (props.onFocus) {
83
78
  props.onFocus(event);
84
79
  }
@@ -130,9 +125,7 @@ function DBSelectFn(props, component) {
130
125
  React.createElement("option", { hidden: true }),
131
126
  props.options ? (React.createElement(React.Fragment, null, (_c = props.options) === null || _c === void 0 ? void 0 : _c.map((option) => {
132
127
  var _a;
133
- return (React.createElement(React.Fragment, { key: uuid() },
134
- option.options ? (React.createElement("optgroup", { label: getOptionLabel(option) }, (_a = option.options) === null || _a === void 0 ? void 0 : _a.map((optgroupOption) => (React.createElement("option", { key: optgroupOption.value.toString(), value: optgroupOption.value, disabled: optgroupOption.disabled }, getOptionLabel(optgroupOption)))))) : null,
135
- !option.options ? (React.createElement("option", { value: option.value, disabled: option.disabled }, getOptionLabel(option))) : null));
128
+ return option.options ? (React.createElement("optgroup", { label: getOptionLabel(option) }, (_a = option.options) === null || _a === void 0 ? void 0 : _a.map((optgroupOption) => (React.createElement("option", { key: optgroupOption.value.toString(), value: optgroupOption.value, disabled: optgroupOption.disabled }, getOptionLabel(optgroupOption)))))) : (React.createElement("option", { value: option.value, disabled: option.disabled }, getOptionLabel(option)));
136
129
  }))) : (React.createElement(React.Fragment, null, props.children))),
137
130
  React.createElement("span", { id: _placeholderId }, (_d = props.placeholder) !== null && _d !== void 0 ? _d : props.label),
138
131
  stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
@@ -10,7 +10,6 @@ function DBSwitchFn(props, component) {
10
10
  const [_checked, set_checked] = useState(() => { var _a; return (_a = props["defaultChecked"]) !== null && _a !== void 0 ? _a : false; });
11
11
  function handleChange(event) {
12
12
  var _a;
13
- event.stopPropagation();
14
13
  if (props.onChange) {
15
14
  props.onChange(event);
16
15
  }
@@ -18,13 +17,11 @@ function DBSwitchFn(props, component) {
18
17
  set_checked((_a = event.target) === null || _a === void 0 ? void 0 : _a["checked"]);
19
18
  }
20
19
  function handleBlur(event) {
21
- event.stopPropagation();
22
20
  if (props.onBlur) {
23
21
  props.onBlur(event);
24
22
  }
25
23
  }
26
24
  function handleFocus(event) {
27
- event.stopPropagation();
28
25
  if (props.onFocus) {
29
26
  props.onFocus(event);
30
27
  }
@@ -65,6 +65,7 @@ function DBTabsFn(props, component) {
65
65
  function initTabs(init) {
66
66
  if (_ref.current) {
67
67
  const tabItems = Array.from(_ref.current.getElementsByClassName("db-tab-item"));
68
+ const tabPanels = Array.from(_ref.current.querySelectorAll(":is(:scope > .db-tab-panel, :scope > db-tab-panel > .db-tab-panel)"));
68
69
  for (const tabItem of tabItems) {
69
70
  const index = tabItems.indexOf(tabItem);
70
71
  const label = tabItem.querySelector("label");
@@ -73,9 +74,11 @@ function DBTabsFn(props, component) {
73
74
  if (!input.id) {
74
75
  const tabId = `${_name}-tab-${index}`;
75
76
  label.setAttribute("for", tabId);
76
- input.setAttribute("aria-controls", `${_name}-tab-panel-${index}`);
77
77
  input.id = tabId;
78
78
  input.setAttribute("name", _name);
79
+ if (tabPanels.length > index) {
80
+ input.setAttribute("aria-controls", `${_name}-tab-panel-${index}`);
81
+ }
79
82
  }
80
83
  if (init) {
81
84
  // Auto select
@@ -89,7 +92,6 @@ function DBTabsFn(props, component) {
89
92
  }
90
93
  }
91
94
  }
92
- const tabPanels = Array.from(_ref.current.querySelectorAll(":is(:scope > .db-tab-panel, :scope > db-tab-panel > .db-tab-panel)"));
93
95
  for (const panel of tabPanels) {
94
96
  if (panel.id)
95
97
  continue;
@@ -50,27 +50,23 @@ function DBTextareaFn(props, component) {
50
50
  }
51
51
  }
52
52
  function handleInput(event) {
53
- event.stopPropagation();
54
53
  if (props.onInput) {
55
54
  props.onInput(event);
56
55
  }
57
56
  handleValidation();
58
57
  }
59
58
  function handleChange(event) {
60
- event.stopPropagation();
61
59
  if (props.onChange) {
62
60
  props.onChange(event);
63
61
  }
64
62
  handleValidation();
65
63
  }
66
64
  function handleBlur(event) {
67
- event.stopPropagation();
68
65
  if (props.onBlur) {
69
66
  props.onBlur(event);
70
67
  }
71
68
  }
72
69
  function handleFocus(event) {
73
- event.stopPropagation();
74
70
  if (props.onFocus) {
75
71
  props.onFocus(event);
76
72
  }
@@ -414,7 +414,7 @@ export type CloseEventProps = {
414
414
  close?: (event?: any) => void;
415
415
  };
416
416
  export type CloseEventState = {
417
- handleClose: (event: any) => void;
417
+ handleClose: (event: any, forceClose?: boolean) => void;
418
418
  };
419
419
  export declare const AlignmentList: readonly ["start", "center"];
420
420
  export type AlignmentType = (typeof AlignmentList)[number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/react-core-components",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
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.1.0",
42
- "@db-ux/core-foundations": "2.1.0"
41
+ "@db-ux/core-components": "2.1.1",
42
+ "@db-ux/core-foundations": "2.1.1"
43
43
  }
44
44
  }