@db-ux/react-core-components 3.0.8 → 3.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.
|
@@ -257,12 +257,23 @@ function DBCustomSelectFn(props, component) {
|
|
|
257
257
|
event.preventDefault();
|
|
258
258
|
}
|
|
259
259
|
function handleKeyboardPress(event) {
|
|
260
|
-
var _a;
|
|
260
|
+
var _a, _b;
|
|
261
261
|
event.stopPropagation();
|
|
262
262
|
if (event.key === "Escape" && ((_a = detailsRef.current) === null || _a === void 0 ? void 0 : _a.open)) {
|
|
263
263
|
handleClose(undefined, true);
|
|
264
264
|
handleSummaryFocus();
|
|
265
265
|
}
|
|
266
|
+
else if (event.key === "Enter" && ((_b = detailsRef.current) === null || _b === void 0 ? void 0 : _b.open)) {
|
|
267
|
+
// Handle Enter key to select option like Space key
|
|
268
|
+
if (self.document) {
|
|
269
|
+
const activeElement = self.document.activeElement;
|
|
270
|
+
if (["checkbox", "radio"].includes(activeElement.getAttribute("type") || "")) {
|
|
271
|
+
// Trigger click to simulate Space key behavior
|
|
272
|
+
activeElement.click();
|
|
273
|
+
event.preventDefault();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
266
277
|
else if (event.key === "ArrowDown" ||
|
|
267
278
|
event.key === "ArrowUp" ||
|
|
268
279
|
event.key === "ArrowLeft" ||
|
|
@@ -117,12 +117,12 @@ function DBInputFn(props, component) {
|
|
|
117
117
|
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-show-icon": getBooleanAsString((_a = props.showIconLeading) !== null && _a !== void 0 ? _a : props.showIcon), "data-icon": (_b = props.iconLeading) !== null && _b !== void 0 ? _b : props.icon, "data-icon-trailing": props.iconTrailing, "data-hide-asterisk": getHideProp(props.showRequiredAsterisk), "data-show-icon-trailing": getBooleanAsString(props.showIconTrailing) }),
|
|
118
118
|
React.createElement("label", { htmlFor: _id }, (_c = props.label) !== null && _c !== void 0 ? _c : DEFAULT_LABEL),
|
|
119
119
|
React.createElement("input", Object.assign({ "aria-invalid": props.validation === "invalid", "data-custom-validity": props.validation, "data-field-sizing": props.fieldSizing, 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", multiple: getBoolean(props.multiple, "multiple"), placeholder: (_d = props.placeholder) !== null && _d !== void 0 ? _d : 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") ||
|
|
120
|
-
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": (_e = props.ariaDescribedBy) !== null && _e !== void 0 ? _e : _descByIds })),
|
|
120
|
+
getBoolean(props.readonly, "readonly"), form: props.form, pattern: props.pattern, size: props.size, autoComplete: props.autocomplete, autoFocus: getBoolean(props.autofocus, "autofocus"), enterKeyHint: props.enterkeyhint, inputMode: props.inputmode, onInput: (event) => handleInput(event), onChange: (event) => handleChange(event), onBlur: (event) => handleBlur(event), onFocus: (event) => handleFocus(event), list: props.dataList && _dataListId, "aria-describedby": (_e = props.ariaDescribedBy) !== null && _e !== void 0 ? _e : _descByIds })),
|
|
121
121
|
props.dataList ? (React.createElement("datalist", { id: _dataListId }, (_f = getDataList()) === null || _f === void 0 ? void 0 : _f.map((option) => (React.createElement("option", { key: _dataListId + "-option-" + option.value, value: option.value }, option.label))))) : null,
|
|
122
122
|
props.children,
|
|
123
|
-
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
124
|
-
hasValidState() ? (React.createElement(DBInfotext, {
|
|
125
|
-
React.createElement(DBInfotext, {
|
|
123
|
+
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: props.messageSize || "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
124
|
+
hasValidState() ? (React.createElement(DBInfotext, { semantic: "successful", id: _validMessageId, size: props.validMessageSize || "small" }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
|
|
125
|
+
React.createElement(DBInfotext, { semantic: "critical", id: _invalidMessageId, size: props.invalidMessageSize || "small" }, _invalidMessage),
|
|
126
126
|
React.createElement("span", { "data-visually-hidden": "true", role: "status" }, _voiceOverFallback)));
|
|
127
127
|
}
|
|
128
128
|
const DBInput = forwardRef(DBInputFn);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEventProps, ChangeEventState, FocusEventProps, FocusEventState, FormMessageProps, FormProps, FormSizeProps, FormState, FormTextProps, FromValidState, GlobalProps, GlobalState, IconLeadingProps, IconProps, IconTrailingProps, InputEventProps, InputEventState, ShowIconLeadingProps, ShowIconProps, ShowIconTrailingProps, ValueLabelType } from '../../shared/model';
|
|
1
|
+
import { ChangeEventProps, ChangeEventState, FocusEventProps, FocusEventState, FormMessageProps, FormProps, FormSizeProps, FormState, FormTextProps, FromValidState, GlobalProps, GlobalState, IconLeadingProps, IconProps, IconTrailingProps, InputEventProps, InputEventState, ShowIconLeadingProps, ShowIconProps, ShowIconTrailingProps, SizeType, ValueLabelType } from '../../shared/model';
|
|
2
2
|
export declare const InputTypeList: readonly ["color", "date", "datetime-local", "email", "file", "hidden", "month", "number", "password", "range", "search", "tel", "text", "time", "url", "week"];
|
|
3
3
|
export type InputTypeType = (typeof InputTypeList)[number];
|
|
4
4
|
export type DBInputDefaultProps = {
|
|
@@ -34,6 +34,26 @@ export type DBInputDefaultProps = {
|
|
|
34
34
|
* Sets [step value](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step).
|
|
35
35
|
*/
|
|
36
36
|
step?: number | string;
|
|
37
|
+
/**
|
|
38
|
+
* Hint for the [enter key behavior](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint) on virtual keyboards.
|
|
39
|
+
*/
|
|
40
|
+
enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
41
|
+
/**
|
|
42
|
+
* Hint for [virtual keyboard](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) selection.
|
|
43
|
+
*/
|
|
44
|
+
inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
45
|
+
/**
|
|
46
|
+
* The size of the message infotext. Defaults to "small".
|
|
47
|
+
*/
|
|
48
|
+
messageSize?: SizeType;
|
|
49
|
+
/**
|
|
50
|
+
* The size of the valid message infotext. Defaults to "small".
|
|
51
|
+
*/
|
|
52
|
+
validMessageSize?: SizeType;
|
|
53
|
+
/**
|
|
54
|
+
* The size of the invalid message infotext. Defaults to "small".
|
|
55
|
+
*/
|
|
56
|
+
invalidMessageSize?: SizeType;
|
|
37
57
|
};
|
|
38
58
|
export type DBInputProps = DBInputDefaultProps & GlobalProps & FormTextProps & InputEventProps<HTMLInputElement> & ChangeEventProps<HTMLInputElement> & FocusEventProps<HTMLInputElement> & FormProps & IconProps & IconTrailingProps & FormMessageProps & ShowIconProps & IconLeadingProps & ShowIconLeadingProps & ShowIconTrailingProps & FormSizeProps;
|
|
39
59
|
export type DBInputDefaultState = {
|
|
@@ -6,7 +6,7 @@ import { DEFAULT_INVALID_MESSAGE, DEFAULT_INVALID_MESSAGE_ID_SUFFIX, DEFAULT_LAB
|
|
|
6
6
|
import { cls, delay, getBoolean, getBooleanAsString, getHideProp, getOptionKey, hasVoiceOver, stringPropVisible, uuid, } from "../../utils";
|
|
7
7
|
import DBInfotext from "../infotext/infotext";
|
|
8
8
|
function DBSelectFn(props, component) {
|
|
9
|
-
var _a, _b, _c, _d
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
10
|
const _ref = component || useRef(component);
|
|
11
11
|
const [_id, set_id] = useState(() => undefined);
|
|
12
12
|
const [_messageId, set_messageId] = useState(() => undefined);
|
|
@@ -47,9 +47,12 @@ function DBSelectFn(props, component) {
|
|
|
47
47
|
else if (stringPropVisible(props.message, props.showMessage)) {
|
|
48
48
|
set_descByIds(_messageId);
|
|
49
49
|
}
|
|
50
|
-
else {
|
|
50
|
+
else if (props.placeholder) {
|
|
51
51
|
set_descByIds(_placeholderId);
|
|
52
52
|
}
|
|
53
|
+
else {
|
|
54
|
+
set_descByIds(undefined);
|
|
55
|
+
}
|
|
53
56
|
}
|
|
54
57
|
function handleClick(event) {
|
|
55
58
|
if (props.onClick) {
|
|
@@ -110,9 +113,12 @@ function DBSelectFn(props, component) {
|
|
|
110
113
|
if (stringPropVisible(props.message, props.showMessage)) {
|
|
111
114
|
set_descByIds(messageId);
|
|
112
115
|
}
|
|
113
|
-
else {
|
|
116
|
+
else if (props.placeholder) {
|
|
114
117
|
set_descByIds(placeholderId);
|
|
115
118
|
}
|
|
119
|
+
else {
|
|
120
|
+
set_descByIds(undefined);
|
|
121
|
+
}
|
|
116
122
|
handleValidation();
|
|
117
123
|
setInitialized(false);
|
|
118
124
|
}
|
|
@@ -123,12 +129,12 @@ function DBSelectFn(props, component) {
|
|
|
123
129
|
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-select", props.className), "data-variant": props.variant, "data-hide-label": getHideProp(props.showLabel), "data-hide-asterisk": getHideProp(props.showRequiredAsterisk), "data-icon": props.icon, "data-show-icon": getBooleanAsString(props.showIcon) }),
|
|
124
130
|
React.createElement("label", { htmlFor: _id }, (_a = props.label) !== null && _a !== void 0 ? _a : DEFAULT_LABEL),
|
|
125
131
|
React.createElement("select", 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"]), { required: getBoolean(props.required, "required"), disabled: getBoolean(props.disabled, "disabled"), id: _id, name: props.name, size: props.size, value: props.value, autoComplete: props.autocomplete, multiple: props.multiple, onInput: (event) => handleInput(event), onClick: (event) => handleClick(event), onChange: (event) => handleChange(event), onBlur: (event) => handleBlur(event), onFocus: (event) => handleFocus(event), "aria-describedby": (_b = props.ariaDescribedBy) !== null && _b !== void 0 ? _b : _descByIds }),
|
|
126
|
-
React.createElement("option", {
|
|
132
|
+
props.variant === "floating" || props.placeholder ? (React.createElement("option", { className: "placeholder", value: "" })) : null,
|
|
127
133
|
((_c = props.options) === null || _c === void 0 ? void 0 : _c.length) ? (React.createElement(React.Fragment, null, (_d = props.options) === null || _d === void 0 ? void 0 : _d.map((option) => {
|
|
128
134
|
var _a;
|
|
129
135
|
return option.options ? (React.createElement("optgroup", { label: getOptionLabel(option), key: getOptionKey(option, "select-optgroup-") }, (_a = option.options) === null || _a === void 0 ? void 0 : _a.map((optgroupOption) => (React.createElement("option", { value: optgroupOption.value, disabled: optgroupOption.disabled, key: getOptionKey(optgroupOption, "select-optgroup-option-") }, getOptionLabel(optgroupOption)))))) : (React.createElement("option", { value: option.value, disabled: option.disabled, key: getOptionKey(option, "select-option-") }, getOptionLabel(option)));
|
|
130
136
|
}))) : (React.createElement(React.Fragment, null, props.children))),
|
|
131
|
-
React.createElement("span", { id: _placeholderId },
|
|
137
|
+
props.placeholder ? (React.createElement("span", { id: _placeholderId }, props.placeholder)) : null,
|
|
132
138
|
stringPropVisible(props.message, props.showMessage) ? (React.createElement(DBInfotext, { size: "small", icon: props.messageIcon, id: _messageId }, props.message)) : null,
|
|
133
139
|
hasValidState() ? (React.createElement(DBInfotext, { size: "small", semantic: "successful", id: _validMessageId }, props.validMessage || DEFAULT_VALID_MESSAGE)) : null,
|
|
134
140
|
React.createElement(DBInfotext, { size: "small", semantic: "critical", id: _invalidMessageId }, _invalidMessage),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/react-core-components",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.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": "3.
|
|
42
|
-
"@db-ux/core-foundations": "3.
|
|
41
|
+
"@db-ux/core-components": "3.1.1",
|
|
42
|
+
"@db-ux/core-foundations": "3.1.1"
|
|
43
43
|
}
|
|
44
44
|
}
|