@db-ux/react-core-components 2.0.5 → 2.0.7

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.
@@ -6,6 +6,7 @@ import { cls, getBoolean, getBooleanAsString, getHideProp } from "../../utils";
6
6
  function DBButtonFn(props, component) {
7
7
  const _ref = component || useRef(component);
8
8
  function handleClick(event) {
9
+ event.stopPropagation();
9
10
  if (props.onClick) {
10
11
  props.onClick(event);
11
12
  }
@@ -6,6 +6,7 @@ import { cls } from "../../utils";
6
6
  function DBCardFn(props, component) {
7
7
  const _ref = component || useRef(component);
8
8
  function handleClick(event) {
9
+ event.stopPropagation();
9
10
  if (props.onClick) {
10
11
  props.onClick(event);
11
12
  }
@@ -49,17 +49,20 @@ function DBCheckboxFn(props, component) {
49
49
  }
50
50
  }
51
51
  function handleChange(event) {
52
+ event.stopPropagation();
52
53
  if (props.onChange) {
53
54
  props.onChange(event);
54
55
  }
55
56
  handleValidation();
56
57
  }
57
58
  function handleBlur(event) {
59
+ event.stopPropagation();
58
60
  if (props.onBlur) {
59
61
  props.onBlur(event);
60
62
  }
61
63
  }
62
64
  function handleFocus(event) {
65
+ event.stopPropagation();
63
66
  if (props.onFocus) {
64
67
  props.onFocus(event);
65
68
  }
@@ -2,7 +2,7 @@
2
2
  import * as React from "react";
3
3
  import { filterPassingProps, getRootProps } from "../../utils/react";
4
4
  import { useState, useRef, useEffect, forwardRef } from "react";
5
- import { cls, delay, getBoolean, getHideProp, getNumber, hasVoiceOver, isArrayOfStrings, stringPropVisible, uuid, } from "../../utils";
5
+ import { cls, delay, getBoolean, getHideProp, getNumber, hasVoiceOver, isArrayOfStrings, stringPropVisible, uuid, getInputValue, } from "../../utils";
6
6
  import { DEFAULT_DATALIST_ID_SUFFIX, DEFAULT_INVALID_MESSAGE, DEFAULT_INVALID_MESSAGE_ID_SUFFIX, DEFAULT_LABEL, DEFAULT_MESSAGE_ID_SUFFIX, DEFAULT_PLACEHOLDER, DEFAULT_VALID_MESSAGE, DEFAULT_VALID_MESSAGE_ID_SUFFIX, } from "../../shared/constants";
7
7
  import DBInfotext from "../infotext/infotext";
8
8
  function DBInputFn(props, component) {
@@ -51,23 +51,27 @@ function DBInputFn(props, component) {
51
51
  }
52
52
  }
53
53
  function handleInput(event) {
54
+ event.stopPropagation();
54
55
  if (props.onInput) {
55
56
  props.onInput(event);
56
57
  }
57
58
  handleValidation();
58
59
  }
59
60
  function handleChange(event) {
61
+ event.stopPropagation();
60
62
  if (props.onChange) {
61
63
  props.onChange(event);
62
64
  }
63
65
  handleValidation();
64
66
  }
65
67
  function handleBlur(event) {
68
+ event.stopPropagation();
66
69
  if (props.onBlur) {
67
70
  props.onBlur(event);
68
71
  }
69
72
  }
70
73
  function handleFocus(event) {
74
+ event.stopPropagation();
71
75
  if (props.onFocus) {
72
76
  props.onFocus(event);
73
77
  }
@@ -115,7 +119,7 @@ function DBInputFn(props, component) {
115
119
  }, [props.value]);
116
120
  return (React.createElement("div", Object.assign({}, getRootProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { className: cls("db-input", props.className), "data-variant": props.variant, "data-hide-label": getHideProp(props.showLabel), "data-hide-icon": getHideProp(props.showIcon), "data-icon": props.icon, "data-icon-after": props.iconAfter, "data-hide-icon-after": getHideProp(props.showIcon) }),
117
121
  React.createElement("label", { htmlFor: _id }, (_a = props.label) !== null && _a !== void 0 ? _a : DEFAULT_LABEL),
118
- React.createElement("input", Object.assign({ "aria-invalid": props.validation === "invalid", "data-custom-validity": props.validation, ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { id: _id, name: props.name, type: props.type || "text", placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : DEFAULT_PLACEHOLDER, disabled: getBoolean(props.disabled, "disabled"), required: getBoolean(props.required, "required"), step: getNumber(props.step), value: props.value, maxLength: getNumber(props.maxLength, props.maxlength), minLength: getNumber(props.minLength, props.minlength), max: getNumber(props.max), min: getNumber(props.min), readOnly: getBoolean(props.readOnly, "readOnly") ||
122
+ React.createElement("input", Object.assign({ "aria-invalid": props.validation === "invalid", "data-custom-validity": props.validation, ref: _ref }, filterPassingProps(props, ["data-icon-variant", "data-icon-variant-before", "data-icon-variant-after", "data-icon-weight", "data-icon-weight-before", "data-icon-weight-after", "data-interactive", "data-force-mobile", "data-color", "data-container-color", "data-bg-color", "data-on-bg-color", "data-color-scheme", "data-font-size", "data-headline-size", "data-divider", "data-focus", "data-font"]), { id: _id, name: props.name, type: props.type || "text", placeholder: (_b = props.placeholder) !== null && _b !== void 0 ? _b : DEFAULT_PLACEHOLDER, disabled: getBoolean(props.disabled, "disabled"), required: getBoolean(props.required, "required"), step: getNumber(props.step), value: props.value, maxLength: getNumber(props.maxLength, props.maxlength), minLength: getNumber(props.minLength, props.minlength), max: getInputValue(props.max, props.type), min: getInputValue(props.min, props.type), readOnly: getBoolean(props.readOnly, "readOnly") ||
119
123
  getBoolean(props.readonly, "readonly"), form: props.form, pattern: props.pattern, size: props.size, autoComplete: props.autocomplete, autoFocus: getBoolean(props.autofocus, "autofocus"), onInput: (event) => handleInput(event), onChange: (event) => handleChange(event), onBlur: (event) => handleBlur(event), onFocus: (event) => handleFocus(event), list: props.dataList && _dataListId, "aria-describedby": (_c = props.ariaDescribedBy) !== null && _c !== void 0 ? _c : _descByIds })),
120
124
  props.dataList ? (React.createElement("datalist", { id: _dataListId }, (_d = getDataList()) === null || _d === void 0 ? void 0 : _d.map((option) => (React.createElement("option", { key: _dataListId + "-option-" + option.value, value: option.value }, option.label))))) : null,
121
125
  props.children,
@@ -7,6 +7,7 @@ function DBLinkFn(props, component) {
7
7
  var _a;
8
8
  const _ref = component || useRef(component);
9
9
  function handleClick(event) {
10
+ event.stopPropagation();
10
11
  if (props.onClick) {
11
12
  props.onClick(event);
12
13
  }
@@ -25,6 +25,7 @@ function DBNavigationItemFn(props, component) {
25
25
  }
26
26
  }
27
27
  function handleClick(event) {
28
+ event.stopPropagation();
28
29
  if (props.onClick) {
29
30
  props.onClick(event);
30
31
  }
@@ -9,6 +9,7 @@ function DBNotificationFn(props, component) {
9
9
  var _a;
10
10
  const _ref = component || useRef(component);
11
11
  function handleClose(event) {
12
+ event.stopPropagation();
12
13
  if (props.onClose) {
13
14
  props.onClose(event);
14
15
  }
@@ -8,16 +8,19 @@ function DBRadioFn(props, component) {
8
8
  const [initialized, setInitialized] = useState(() => false);
9
9
  const [_id, set_id] = useState(() => undefined);
10
10
  function handleChange(event) {
11
+ event.stopPropagation();
11
12
  if (props.onChange) {
12
13
  props.onChange(event);
13
14
  }
14
15
  }
15
16
  function handleBlur(event) {
17
+ event.stopPropagation();
16
18
  if (props.onBlur) {
17
19
  props.onBlur(event);
18
20
  }
19
21
  }
20
22
  function handleFocus(event) {
23
+ event.stopPropagation();
21
24
  if (props.onFocus) {
22
25
  props.onFocus(event);
23
26
  }
@@ -52,28 +52,33 @@ function DBSelectFn(props, component) {
52
52
  }
53
53
  }
54
54
  function handleClick(event) {
55
+ event.stopPropagation();
55
56
  if (props.onClick) {
56
57
  props.onClick(event);
57
58
  }
58
59
  }
59
60
  function handleInput(event) {
61
+ event.stopPropagation();
60
62
  if (props.onInput) {
61
63
  props.onInput(event);
62
64
  }
63
65
  handleValidation();
64
66
  }
65
67
  function handleChange(event) {
68
+ event.stopPropagation();
66
69
  if (props.onChange) {
67
70
  props.onChange(event);
68
71
  }
69
72
  handleValidation();
70
73
  }
71
74
  function handleBlur(event) {
75
+ event.stopPropagation();
72
76
  if (props.onBlur) {
73
77
  props.onBlur(event);
74
78
  }
75
79
  }
76
80
  function handleFocus(event) {
81
+ event.stopPropagation();
77
82
  if (props.onFocus) {
78
83
  props.onFocus(event);
79
84
  }
@@ -9,6 +9,7 @@ function DBSwitchFn(props, component) {
9
9
  const [_checked, set_checked] = useState(() => { var _a; return (_a = props["defaultChecked"]) !== null && _a !== void 0 ? _a : false; });
10
10
  function handleChange(event) {
11
11
  var _a;
12
+ event.stopPropagation();
12
13
  if (props.onChange) {
13
14
  props.onChange(event);
14
15
  }
@@ -16,11 +17,13 @@ function DBSwitchFn(props, component) {
16
17
  set_checked((_a = event.target) === null || _a === void 0 ? void 0 : _a["checked"]);
17
18
  }
18
19
  function handleBlur(event) {
20
+ event.stopPropagation();
19
21
  if (props.onBlur) {
20
22
  props.onBlur(event);
21
23
  }
22
24
  }
23
25
  function handleFocus(event) {
26
+ event.stopPropagation();
24
27
  if (props.onFocus) {
25
28
  props.onFocus(event);
26
29
  }
@@ -21,6 +21,7 @@ function DBTabItemFn(props, component) {
21
21
  }
22
22
  function handleChange(event) {
23
23
  var _a;
24
+ event.stopPropagation();
24
25
  if (props.onChange) {
25
26
  props.onChange(event);
26
27
  }
@@ -101,6 +101,7 @@ function DBTabsFn(props, component) {
101
101
  }
102
102
  function handleChange(event) {
103
103
  var _a, _b;
104
+ event.stopPropagation();
104
105
  const list = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest("ul");
105
106
  const listItem =
106
107
  // db-tab-item for angular and stencil wrapping elements
@@ -9,6 +9,7 @@ function DBTagFn(props, component) {
9
9
  const _ref = component || useRef(component);
10
10
  const [initialized, setInitialized] = useState(() => false);
11
11
  function handleRemove(event) {
12
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
12
13
  if (props.onRemove) {
13
14
  props.onRemove(event);
14
15
  }
@@ -50,23 +50,27 @@ function DBTextareaFn(props, component) {
50
50
  }
51
51
  }
52
52
  function handleInput(event) {
53
+ event.stopPropagation();
53
54
  if (props.onInput) {
54
55
  props.onInput(event);
55
56
  }
56
57
  handleValidation();
57
58
  }
58
59
  function handleChange(event) {
60
+ event.stopPropagation();
59
61
  if (props.onChange) {
60
62
  props.onChange(event);
61
63
  }
62
64
  handleValidation();
63
65
  }
64
66
  function handleBlur(event) {
67
+ event.stopPropagation();
65
68
  if (props.onBlur) {
66
69
  props.onBlur(event);
67
70
  }
68
71
  }
69
72
  function handleFocus(event) {
73
+ event.stopPropagation();
70
74
  if (props.onFocus) {
71
75
  props.onFocus(event);
72
76
  }
@@ -31,6 +31,17 @@ export declare const delay: (fn: () => void, ms: number) => Promise<unknown>;
31
31
  export declare const getBooleanAsString: (originBool?: boolean | string) => any;
32
32
  export declare const getBoolean: (originBool?: boolean | string, propertyName?: string) => boolean | undefined;
33
33
  export declare const getNumber: (originNumber?: number | string, alternativeNumber?: number | string) => number | undefined;
34
+ /**
35
+ * Retrieves the input value based on the provided value and input type.
36
+ *
37
+ * If the input type is "number" or "range", the value is processed as a number.
38
+ * Otherwise, the value is returned as-is.
39
+ *
40
+ * @param value - The input value, which can be a number, string, or undefined.
41
+ * @param inputType - The type of the input, such as "number", "range", or other string types.
42
+ * @returns The processed input value as a string, number, or undefined.
43
+ */
44
+ export declare const getInputValue: (value?: number | string, inputType?: string) => string | number | undefined;
34
45
  export declare const getHideProp: (show?: boolean | string) => any;
35
46
  export declare const stringPropVisible: (givenString?: string, showString?: boolean | string) => boolean;
36
47
  export declare const getSearchInput: (element: HTMLElement) => HTMLInputElement | null;
@@ -139,6 +139,19 @@ export const getNumber = (originNumber, alternativeNumber) => {
139
139
  }
140
140
  return Number(originNumber !== null && originNumber !== void 0 ? originNumber : alternativeNumber);
141
141
  };
142
+ /**
143
+ * Retrieves the input value based on the provided value and input type.
144
+ *
145
+ * If the input type is "number" or "range", the value is processed as a number.
146
+ * Otherwise, the value is returned as-is.
147
+ *
148
+ * @param value - The input value, which can be a number, string, or undefined.
149
+ * @param inputType - The type of the input, such as "number", "range", or other string types.
150
+ * @returns The processed input value as a string, number, or undefined.
151
+ */
152
+ export const getInputValue = (value, inputType) => {
153
+ return inputType && ['number', 'range'].includes(inputType) ? getNumber(value) : value;
154
+ };
142
155
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
156
  export const getHideProp = (show) => {
144
157
  if (show === undefined || show === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/react-core-components",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
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.0.5",
42
- "@db-ux/core-foundations": "2.0.5"
41
+ "@db-ux/core-components": "2.0.7",
42
+ "@db-ux/core-foundations": "2.0.7"
43
43
  }
44
44
  }