@db-ux/react-core-components 2.0.9 → 2.1.0
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/custom-select/custom-select.js +42 -4
- package/dist/components/custom-select/model.d.ts +30 -4
- package/dist/components/icon/model.d.ts +1 -3
- package/dist/components/icon/model.js +0 -1
- package/dist/components/select/model.d.ts +2 -1
- package/dist/components/tag/tag.js +3 -1
- package/dist/components/tooltip/model.d.ts +11 -0
- package/dist/components/tooltip/model.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +6 -1
- package/package.json +3 -3
|
@@ -45,6 +45,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
45
45
|
const [_hasNoOptions, set_hasNoOptions] = useState(() => false);
|
|
46
46
|
const [_documentClickListenerCallbackId, set_documentClickListenerCallbackId,] = useState(() => undefined);
|
|
47
47
|
const [_internalChangeTimestamp, set_internalChangeTimestamp] = useState(() => 0);
|
|
48
|
+
const [_searchValue, set_searchValue] = useState(() => undefined);
|
|
48
49
|
function hasValidState() {
|
|
49
50
|
var _a;
|
|
50
51
|
return !!((_a = props.validMessage) !== null && _a !== void 0 ? _a : props.validation === "valid");
|
|
@@ -356,11 +357,24 @@ function DBCustomSelectFn(props, component) {
|
|
|
356
357
|
}
|
|
357
358
|
}
|
|
358
359
|
function handleSearch(event) {
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
let filterText;
|
|
361
|
+
if (typeof event === "string") {
|
|
362
|
+
filterText = event;
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
event.stopPropagation();
|
|
366
|
+
if (props.onSearch) {
|
|
367
|
+
props.onSearch(event);
|
|
368
|
+
}
|
|
369
|
+
filterText = event.target.value;
|
|
370
|
+
set_searchValue(filterText);
|
|
371
|
+
}
|
|
361
372
|
if (!props.options || !filterText || filterText.length === 0) {
|
|
362
373
|
set_options(props.options);
|
|
363
374
|
}
|
|
375
|
+
else if (props.searchFilter) {
|
|
376
|
+
set_options(props.options.filter((option) => props.searchFilter(option, filterText)));
|
|
377
|
+
}
|
|
364
378
|
else {
|
|
365
379
|
set_options(props.options.filter((option) => !option.isGroupTitle &&
|
|
366
380
|
getOptionLabel(option)
|
|
@@ -479,6 +493,13 @@ function DBCustomSelectFn(props, component) {
|
|
|
479
493
|
set_options(props.options);
|
|
480
494
|
setAmountOptions((_b = (_a = props.options) === null || _a === void 0 ? void 0 : _a.filter((option) => !option.isGroupTitle).length) !== null && _b !== void 0 ? _b : 0);
|
|
481
495
|
}, [props.options]);
|
|
496
|
+
useEffect(() => {
|
|
497
|
+
set_searchValue(props.searchValue);
|
|
498
|
+
if (props.searchValue) {
|
|
499
|
+
const sValue = props.searchValue; // <- workaround for Angular
|
|
500
|
+
handleSearch(sValue);
|
|
501
|
+
}
|
|
502
|
+
}, [props.searchValue]);
|
|
482
503
|
useEffect(() => {
|
|
483
504
|
var _a, _b;
|
|
484
505
|
if ((_a = props.options) === null || _a === void 0 ? void 0 : _a.length) {
|
|
@@ -491,7 +512,18 @@ function DBCustomSelectFn(props, component) {
|
|
|
491
512
|
}
|
|
492
513
|
}, [props.options, _values]);
|
|
493
514
|
useEffect(() => {
|
|
515
|
+
if (props.selectedLabels) {
|
|
516
|
+
set_selectedLabels(props.selectedLabels);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
494
519
|
if (_selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.length) {
|
|
520
|
+
if (props.transformSelectedLabels) {
|
|
521
|
+
// We need to add this to another ``const`` for Angular generated output to work
|
|
522
|
+
const selectedOptions = _selectedOptions;
|
|
523
|
+
const transformFn = props.transformSelectedLabels;
|
|
524
|
+
set_selectedLabels(transformFn(selectedOptions));
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
495
527
|
if (props.selectedType === "amount") {
|
|
496
528
|
set_selectedLabels(props.amountText
|
|
497
529
|
? props.amountText
|
|
@@ -504,7 +536,13 @@ function DBCustomSelectFn(props, component) {
|
|
|
504
536
|
else {
|
|
505
537
|
set_selectedLabels("");
|
|
506
538
|
}
|
|
507
|
-
}, [
|
|
539
|
+
}, [
|
|
540
|
+
_selectedOptions,
|
|
541
|
+
props.selectedType,
|
|
542
|
+
props.amountText,
|
|
543
|
+
props.selectedLabels,
|
|
544
|
+
props.transformSelectedLabels,
|
|
545
|
+
]);
|
|
508
546
|
useEffect(() => {
|
|
509
547
|
var _a;
|
|
510
548
|
if (props.onAmountChange) {
|
|
@@ -537,7 +575,7 @@ function DBCustomSelectFn(props, component) {
|
|
|
537
575
|
props.selectedType === "tag" ? (React.createElement("div", null, _selectedOptions === null || _selectedOptions === void 0 ? void 0 : _selectedOptions.map((option, index) => (React.createElement(DBTag, { emphasis: "strong", behavior: "removable", removeButton: getTagRemoveLabel(index), onRemove: (event) => handleTagRemove(option, event), key: "tag-" + getOptionKey(option) }, getOptionLabel(option)))))) : null),
|
|
538
576
|
React.createElement(DBCustomSelectDropdown, { width: props.dropdownWidth },
|
|
539
577
|
searchEnabled ? (React.createElement("div", null,
|
|
540
|
-
React.createElement(DBInput, { type: "search", ref: searchInputRef, name: _id, form: _id, showLabel: false, label: (_d = props.searchLabel) !== null && _d !== void 0 ? _d : DEFAULT_LABEL, placeholder: (_e = props.searchPlaceholder) !== null && _e !== void 0 ? _e : props.searchLabel, ariaDescribedBy: _hasNoOptions || props.showLoading
|
|
578
|
+
React.createElement(DBInput, { type: "search", ref: searchInputRef, name: _id, form: _id, showLabel: false, value: _searchValue, label: (_d = props.searchLabel) !== null && _d !== void 0 ? _d : DEFAULT_LABEL, placeholder: (_e = props.searchPlaceholder) !== null && _e !== void 0 ? _e : props.searchLabel, ariaDescribedBy: _hasNoOptions || props.showLoading
|
|
541
579
|
? _infoTextId
|
|
542
580
|
: undefined, onInput: (event) => handleSearch(event) }))) : null,
|
|
543
581
|
_hasNoOptions || props.showLoading ? (React.createElement(DBInfotext, { id: _infoTextId, icon: _hasNoOptions ? undefined : "circular_arrows", semantic: _hasNoOptions ? "warning" : "informational" }, (_f = (_hasNoOptions ? props.noResultsText : props.loadingText)) !== null && _f !== void 0 ? _f : DEFAULT_MESSAGE)) : (React.createElement(React.Fragment, null,
|
|
@@ -51,16 +51,24 @@ export type DBCustomSelectEvents = {
|
|
|
51
51
|
* Informs the user when dropdown was toggled.
|
|
52
52
|
*/
|
|
53
53
|
dropdownToggle?: (event: any) => void;
|
|
54
|
-
};
|
|
55
|
-
export type DBCustomSelectDefaultProps = {
|
|
56
54
|
/**
|
|
57
|
-
*
|
|
55
|
+
* Informs the user when a search was performed.
|
|
58
56
|
*/
|
|
59
|
-
|
|
57
|
+
onSearch?: (event: any) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Informs the user when a search was performed.
|
|
60
|
+
*/
|
|
61
|
+
search?: (event: any) => void;
|
|
62
|
+
};
|
|
63
|
+
export type DBCustomSelectDefaultProps = {
|
|
60
64
|
/**
|
|
61
65
|
* Optional: if select-type="amount" change the shown text
|
|
62
66
|
*/
|
|
63
67
|
amountText?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Overwrite the default aria-label (props.label) for the custom-select-list
|
|
70
|
+
*/
|
|
71
|
+
ariaListLabel?: string;
|
|
64
72
|
/**
|
|
65
73
|
* Label for the clear selection button
|
|
66
74
|
*/
|
|
@@ -107,6 +115,10 @@ export type DBCustomSelectDefaultProps = {
|
|
|
107
115
|
* Optional: if you use selectedType=tag and options, you need to set the removeTagsTexts for screen reader users
|
|
108
116
|
*/
|
|
109
117
|
removeTagsTexts?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Optional: Change the filter function for the search input
|
|
120
|
+
*/
|
|
121
|
+
searchFilter?: (option: CustomSelectOptionType, filterText: string) => boolean;
|
|
110
122
|
/**
|
|
111
123
|
* Search label
|
|
112
124
|
*/
|
|
@@ -115,10 +127,19 @@ export type DBCustomSelectDefaultProps = {
|
|
|
115
127
|
* Search placeholder
|
|
116
128
|
*/
|
|
117
129
|
searchPlaceholder?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Optional: Prefill the value of the search input
|
|
132
|
+
*/
|
|
133
|
+
searchValue?: string;
|
|
118
134
|
/**
|
|
119
135
|
* Select all checkbox label
|
|
120
136
|
*/
|
|
121
137
|
selectAllLabel?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Optional: If you want to show a custom label for the selected values.
|
|
140
|
+
* You need to define the empty state as well based on selected options.
|
|
141
|
+
*/
|
|
142
|
+
selectedLabels?: string;
|
|
122
143
|
/**
|
|
123
144
|
* Change the selected type for values shown in multi select
|
|
124
145
|
*/
|
|
@@ -143,6 +164,10 @@ export type DBCustomSelectDefaultProps = {
|
|
|
143
164
|
* Forces select all checkbox (only for multiple).
|
|
144
165
|
*/
|
|
145
166
|
showSelectAll?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Optional: If you want to show a custom label based on the selected options.
|
|
169
|
+
*/
|
|
170
|
+
transformSelectedLabels?: (selectedOptions?: CustomSelectOptionType[]) => string;
|
|
146
171
|
/**
|
|
147
172
|
* Initial value for multi select
|
|
148
173
|
*/
|
|
@@ -164,6 +189,7 @@ export type DBCustomSelectDefaultState = {
|
|
|
164
189
|
_infoTextId?: string;
|
|
165
190
|
_internalChangeTimestamp: number;
|
|
166
191
|
_documentClickListenerCallbackId?: string;
|
|
192
|
+
_searchValue?: string;
|
|
167
193
|
getNativeSelectValue: () => string;
|
|
168
194
|
getOptionLabel: (option: CustomSelectOptionType) => string;
|
|
169
195
|
getOptionChecked: (value?: string) => boolean;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { GlobalProps, GlobalState, IconProps, TextProps } from '../../shared/model';
|
|
2
|
-
export declare const IconVariantList: readonly ["default", "inverted", "filled"];
|
|
3
|
-
export type IconVariantType = (typeof IconVariantList)[number];
|
|
4
2
|
export declare const IconWeightList: readonly ["16", "20", "24", "32", "48", "64"];
|
|
5
3
|
export type IconWeightType = (typeof IconWeightList)[number];
|
|
6
4
|
export type DBIconDefaultProps = {
|
|
7
|
-
variant?:
|
|
5
|
+
variant?: string;
|
|
8
6
|
weight?: IconWeightType;
|
|
9
7
|
};
|
|
10
8
|
export type DBIconProps = DBIconDefaultProps & GlobalProps & IconProps & TextProps;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ChangeEventProps, ChangeEventState, ClickEventProps, ClickEventState, FocusEventProps, FocusEventState, FormMessageProps, FormProps, FormSizeProps, FormState, FromValidState, GlobalProps, GlobalState, IconProps, InitializedState, InputEventProps, InputEventState, ShowIconProps } from '../../shared/model';
|
|
2
2
|
export type DBSelectDefaultProps = {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* @deprecated
|
|
5
|
+
* Enables multiple select, but it isn't styled, please use DBCustomSelect/db-custom-select instead
|
|
5
6
|
*/
|
|
6
7
|
multiple?: boolean;
|
|
7
8
|
/**
|
|
@@ -4,6 +4,7 @@ import { filterPassingProps, getRootProps } from "../../utils/react";
|
|
|
4
4
|
import { useState, useRef, useEffect, forwardRef } from "react";
|
|
5
5
|
import { cls, getBooleanAsString, getHideProp } from "../../utils";
|
|
6
6
|
import { DEFAULT_REMOVE } from "../../shared/constants";
|
|
7
|
+
import DBTooltip from "../tooltip/tooltip";
|
|
7
8
|
function DBTagFn(props, component) {
|
|
8
9
|
var _a;
|
|
9
10
|
const _ref = component || useRef(component);
|
|
@@ -42,7 +43,8 @@ function DBTagFn(props, component) {
|
|
|
42
43
|
React.createElement(React.Fragment, null, props.content),
|
|
43
44
|
props.children,
|
|
44
45
|
props.text ? React.createElement(React.Fragment, null, props.text) : null,
|
|
45
|
-
props.behavior === "removable" ? (React.createElement("button", { className: "db-button db-tab-remove-button", "data-icon": "cross", "data-size": "small", "data-no-text": "true", "data-variant": "ghost", onClick: (event) => handleRemove(event)
|
|
46
|
+
props.behavior === "removable" ? (React.createElement("button", { className: "db-button db-tab-remove-button", "data-icon": "cross", "data-size": "small", "data-no-text": "true", "data-variant": "ghost", type: "button", onClick: (event) => handleRemove(event) },
|
|
47
|
+
React.createElement(DBTooltip, { variant: "label" }, getRemoveButtonText()))) : null));
|
|
46
48
|
}
|
|
47
49
|
const DBTag = forwardRef(DBTagFn);
|
|
48
50
|
export default DBTag;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { ClickEventState, EmphasisProps, GlobalProps, GlobalState, InitializedState, PlacementProps, PopoverProps, PopoverState } from '../../shared/model';
|
|
2
|
+
export declare const TooltipVariantList: readonly ["description", "label"];
|
|
3
|
+
export type TooltipVariantType = (typeof TooltipVariantList)[number];
|
|
2
4
|
export type DBTooltipDefaultProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Show/Hides arrow
|
|
7
|
+
*/
|
|
3
8
|
showArrow?: boolean | string;
|
|
9
|
+
/**
|
|
10
|
+
* Change the behavior of the tooltip:
|
|
11
|
+
* - description: Adds `aria-describedby` to parent
|
|
12
|
+
* - label: Adds `aria-labelledby` to parent
|
|
13
|
+
*/
|
|
14
|
+
variant?: TooltipVariantType;
|
|
4
15
|
};
|
|
5
16
|
export type DBTooltipProps = DBTooltipDefaultProps & GlobalProps & EmphasisProps & PlacementProps & PopoverProps;
|
|
6
17
|
export type DBTooltipDefaultState = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const TooltipVariantList = ['description', 'label'];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBTooltip: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").PopoverProps | "placement" | "emphasis" | "
|
|
2
|
+
declare const DBTooltip: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model").GlobalProps | keyof import("../../shared/model").PopoverProps | "placement" | "emphasis" | keyof import("./model").DBTooltipDefaultProps> & import("./model").DBTooltipDefaultProps & import("../../shared/model").GlobalProps & import("../../shared/model").EmphasisProps & import("../../shared/model").PlacementProps & import("../../shared/model").PopoverProps & React.RefAttributes<any>>;
|
|
3
3
|
export default DBTooltip;
|
|
@@ -32,7 +32,12 @@ function DBTooltipFn(props, component) {
|
|
|
32
32
|
parent.addEventListener(event, () => handleAutoPlacement());
|
|
33
33
|
});
|
|
34
34
|
parent.setAttribute("data-has-tooltip", "true");
|
|
35
|
-
|
|
35
|
+
if (props.variant === "label") {
|
|
36
|
+
parent.setAttribute("aria-labelledby", _id);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
parent.setAttribute("aria-describedby", _id);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
setInitialized(false);
|
|
38
43
|
}
|
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.1.0",
|
|
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.1.0",
|
|
42
|
+
"@db-ux/core-foundations": "2.1.0"
|
|
43
43
|
}
|
|
44
44
|
}
|