@db-ux/react-core-components 2.0.6 → 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.
- package/dist/components/input/input.js +2 -2
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +13 -0
- package/package.json +3 -3
|
@@ -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) {
|
|
@@ -119,7 +119,7 @@ function DBInputFn(props, component) {
|
|
|
119
119
|
}, [props.value]);
|
|
120
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) }),
|
|
121
121
|
React.createElement("label", { htmlFor: _id }, (_a = props.label) !== null && _a !== void 0 ? _a : DEFAULT_LABEL),
|
|
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:
|
|
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") ||
|
|
123
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 })),
|
|
124
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,
|
|
125
125
|
props.children,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/utils/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
42
|
-
"@db-ux/core-foundations": "2.0.
|
|
41
|
+
"@db-ux/core-components": "2.0.7",
|
|
42
|
+
"@db-ux/core-foundations": "2.0.7"
|
|
43
43
|
}
|
|
44
44
|
}
|