@itwin/itwinui-react 1.42.0 → 1.44.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/CHANGELOG.md +30 -0
- package/cjs/core/Backdrop/Backdrop.d.ts +10 -0
- package/cjs/core/Backdrop/Backdrop.js +41 -0
- package/cjs/core/Backdrop/index.d.ts +2 -0
- package/cjs/core/Backdrop/index.js +9 -0
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +18 -18
- package/cjs/core/ButtonGroup/ButtonGroup.js +11 -4
- package/cjs/core/Dialog/Dialog.d.ts +41 -0
- package/cjs/core/Dialog/Dialog.js +59 -0
- package/cjs/core/Dialog/DialogBackdrop.d.ts +12 -0
- package/cjs/core/Dialog/DialogBackdrop.js +61 -0
- package/cjs/core/Dialog/DialogButtonBar.d.ts +18 -0
- package/cjs/core/Dialog/DialogButtonBar.js +50 -0
- package/cjs/core/Dialog/DialogContent.d.ts +17 -0
- package/cjs/core/Dialog/DialogContent.js +49 -0
- package/cjs/core/Dialog/DialogContext.d.ts +39 -0
- package/cjs/core/Dialog/DialogContext.js +16 -0
- package/cjs/core/Dialog/DialogMain.d.ts +36 -0
- package/cjs/core/Dialog/DialogMain.js +120 -0
- package/cjs/core/Dialog/DialogTitleBar.d.ts +34 -0
- package/cjs/core/Dialog/DialogTitleBar.js +69 -0
- package/cjs/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
- package/cjs/core/Dialog/DialogTitleBarTitle.js +47 -0
- package/cjs/core/Dialog/index.d.ts +8 -0
- package/cjs/core/Dialog/index.js +10 -0
- package/cjs/core/Footer/Footer.d.ts +16 -2
- package/cjs/core/Footer/Footer.js +57 -45
- package/cjs/core/Footer/FooterItem.d.ts +8 -0
- package/cjs/core/Footer/FooterItem.js +46 -0
- package/cjs/core/Footer/FooterList.d.ts +8 -0
- package/cjs/core/Footer/FooterList.js +46 -0
- package/cjs/core/Footer/FooterSeparator.d.ts +8 -0
- package/cjs/core/Footer/FooterSeparator.js +46 -0
- package/cjs/core/Footer/index.d.ts +1 -1
- package/cjs/core/Footer/index.js +2 -1
- package/cjs/core/Menu/Menu.js +0 -3
- package/cjs/core/Modal/Modal.d.ts +4 -14
- package/cjs/core/Modal/Modal.js +9 -74
- package/cjs/core/Modal/ModalButtonBar.d.ts +1 -2
- package/cjs/core/Modal/ModalButtonBar.js +2 -39
- package/cjs/core/Modal/ModalContent.d.ts +1 -2
- package/cjs/core/Modal/ModalContent.js +2 -39
- package/cjs/core/Select/Select.d.ts +23 -8
- package/cjs/core/Select/Select.js +82 -25
- package/cjs/core/Select/SelectTag.d.ts +15 -0
- package/cjs/core/Select/SelectTag.js +48 -0
- package/cjs/core/Select/index.d.ts +1 -1
- package/cjs/core/Slider/Slider.d.ts +10 -0
- package/cjs/core/Slider/Slider.js +20 -14
- package/cjs/core/Slider/Thumb.d.ts +2 -1
- package/cjs/core/Slider/Thumb.js +5 -3
- package/cjs/core/Slider/Track.d.ts +2 -1
- package/cjs/core/Slider/Track.js +23 -4
- package/cjs/core/Table/Table.d.ts +2 -1
- package/cjs/core/Table/Table.js +8 -2
- package/cjs/core/Table/columns/actionColumn.d.ts +8 -3
- package/cjs/core/Table/columns/actionColumn.js +33 -2
- package/cjs/core/Table/hooks/useScrollToRow.d.ts +1 -1
- package/cjs/core/Table/hooks/useScrollToRow.js +3 -3
- package/cjs/core/index.d.ts +4 -2
- package/cjs/core/index.js +6 -3
- package/cjs/core/utils/components/FocusTrap.js +1 -1
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -1
- package/cjs/core/utils/hooks/useOverflow.js +4 -1
- package/esm/core/Backdrop/Backdrop.d.ts +10 -0
- package/esm/core/Backdrop/Backdrop.js +35 -0
- package/esm/core/Backdrop/index.d.ts +2 -0
- package/esm/core/Backdrop/index.js +5 -0
- package/esm/core/Breadcrumbs/Breadcrumbs.js +18 -18
- package/esm/core/ButtonGroup/ButtonGroup.js +11 -4
- package/esm/core/Dialog/Dialog.d.ts +41 -0
- package/esm/core/Dialog/Dialog.js +53 -0
- package/esm/core/Dialog/DialogBackdrop.d.ts +12 -0
- package/esm/core/Dialog/DialogBackdrop.js +55 -0
- package/esm/core/Dialog/DialogButtonBar.d.ts +18 -0
- package/esm/core/Dialog/DialogButtonBar.js +44 -0
- package/esm/core/Dialog/DialogContent.d.ts +17 -0
- package/esm/core/Dialog/DialogContent.js +43 -0
- package/esm/core/Dialog/DialogContext.d.ts +39 -0
- package/esm/core/Dialog/DialogContext.js +9 -0
- package/esm/core/Dialog/DialogMain.d.ts +36 -0
- package/esm/core/Dialog/DialogMain.js +114 -0
- package/esm/core/Dialog/DialogTitleBar.d.ts +34 -0
- package/esm/core/Dialog/DialogTitleBar.js +63 -0
- package/esm/core/Dialog/DialogTitleBarTitle.d.ts +15 -0
- package/esm/core/Dialog/DialogTitleBarTitle.js +41 -0
- package/esm/core/Dialog/index.d.ts +8 -0
- package/esm/core/Dialog/index.js +6 -0
- package/esm/core/Footer/Footer.d.ts +16 -2
- package/esm/core/Footer/Footer.js +56 -43
- package/esm/core/Footer/FooterItem.d.ts +8 -0
- package/esm/core/Footer/FooterItem.js +39 -0
- package/esm/core/Footer/FooterList.d.ts +8 -0
- package/esm/core/Footer/FooterList.js +39 -0
- package/esm/core/Footer/FooterSeparator.d.ts +8 -0
- package/esm/core/Footer/FooterSeparator.js +39 -0
- package/esm/core/Footer/index.d.ts +1 -1
- package/esm/core/Footer/index.js +1 -1
- package/esm/core/Menu/Menu.js +0 -3
- package/esm/core/Modal/Modal.d.ts +4 -14
- package/esm/core/Modal/Modal.js +10 -75
- package/esm/core/Modal/ModalButtonBar.d.ts +1 -2
- package/esm/core/Modal/ModalButtonBar.js +2 -35
- package/esm/core/Modal/ModalContent.d.ts +1 -2
- package/esm/core/Modal/ModalContent.js +2 -35
- package/esm/core/Select/Select.d.ts +23 -8
- package/esm/core/Select/Select.js +83 -26
- package/esm/core/Select/SelectTag.d.ts +15 -0
- package/esm/core/Select/SelectTag.js +41 -0
- package/esm/core/Select/index.d.ts +1 -1
- package/esm/core/Slider/Slider.d.ts +10 -0
- package/esm/core/Slider/Slider.js +20 -14
- package/esm/core/Slider/Thumb.d.ts +2 -1
- package/esm/core/Slider/Thumb.js +5 -3
- package/esm/core/Slider/Track.d.ts +2 -1
- package/esm/core/Slider/Track.js +23 -4
- package/esm/core/Table/Table.d.ts +2 -1
- package/esm/core/Table/Table.js +8 -2
- package/esm/core/Table/columns/actionColumn.d.ts +8 -3
- package/esm/core/Table/columns/actionColumn.js +33 -2
- package/esm/core/Table/hooks/useScrollToRow.d.ts +1 -1
- package/esm/core/Table/hooks/useScrollToRow.js +3 -3
- package/esm/core/index.d.ts +4 -2
- package/esm/core/index.js +2 -1
- package/esm/core/utils/components/FocusTrap.js +1 -1
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -1
- package/esm/core/utils/hooks/useOverflow.js +4 -1
- package/package.json +6 -5
|
@@ -44,19 +44,38 @@ export declare type SelectOption<T> = {
|
|
|
44
44
|
*/
|
|
45
45
|
[key: string]: unknown;
|
|
46
46
|
} & CommonProps;
|
|
47
|
-
export declare type
|
|
47
|
+
export declare type SelectValueChangeEvent = 'added' | 'removed';
|
|
48
|
+
export declare type SelectMultipleTypeProps<T> = {
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
+
* Enable multiple selection.
|
|
51
|
+
* @default false
|
|
50
52
|
*/
|
|
51
|
-
|
|
53
|
+
multiple?: false;
|
|
54
|
+
/**
|
|
55
|
+
* Custom renderer for the selected item in select.
|
|
56
|
+
* If `multiple` is enabled, it will give array of options to render.
|
|
57
|
+
*/
|
|
58
|
+
selectedItemRenderer?: (option: SelectOption<T>) => JSX.Element;
|
|
52
59
|
/**
|
|
53
60
|
* Selected option value.
|
|
61
|
+
* If `multiple` is enabled, it is an array of values.
|
|
54
62
|
*/
|
|
55
63
|
value?: T;
|
|
56
64
|
/**
|
|
57
65
|
* Callback function handling change event on select.
|
|
58
66
|
*/
|
|
59
67
|
onChange?: (value: T) => void;
|
|
68
|
+
} | {
|
|
69
|
+
multiple: true;
|
|
70
|
+
selectedItemRenderer?: (options: SelectOption<T>[]) => JSX.Element;
|
|
71
|
+
value?: T[];
|
|
72
|
+
onChange?: (value: T, event: SelectValueChangeEvent) => void;
|
|
73
|
+
};
|
|
74
|
+
export declare type SelectProps<T> = {
|
|
75
|
+
/**
|
|
76
|
+
* Array of options that populates the select menu.
|
|
77
|
+
*/
|
|
78
|
+
options: SelectOption<T>[];
|
|
60
79
|
/**
|
|
61
80
|
* Placeholder when no item is selected.
|
|
62
81
|
*/
|
|
@@ -79,10 +98,6 @@ export declare type SelectProps<T> = {
|
|
|
79
98
|
* Custom renderer for an item in the dropdown list. `MenuItem` item props are going to be populated if not provided.
|
|
80
99
|
*/
|
|
81
100
|
itemRenderer?: (option: SelectOption<T>, itemProps: ItemRendererProps) => JSX.Element;
|
|
82
|
-
/**
|
|
83
|
-
* Custom renderer for the selected item in select.
|
|
84
|
-
*/
|
|
85
|
-
selectedItemRenderer?: (option: SelectOption<T>) => JSX.Element;
|
|
86
101
|
/**
|
|
87
102
|
* Custom class for menu.
|
|
88
103
|
*/
|
|
@@ -96,7 +111,7 @@ export declare type SelectProps<T> = {
|
|
|
96
111
|
* @see [tippy.js props](https://atomiks.github.io/tippyjs/v6/all-props/)
|
|
97
112
|
*/
|
|
98
113
|
popoverProps?: Omit<PopoverProps, 'onShow' | 'onHide' | 'disabled'>;
|
|
99
|
-
} & Pick<PopoverProps, 'onShow' | 'onHide'> & Omit<React.ComponentPropsWithoutRef<'div'>, 'size' | 'disabled' | 'placeholder' | 'onChange'>;
|
|
114
|
+
} & SelectMultipleTypeProps<T> & Pick<PopoverProps, 'onShow' | 'onHide'> & Omit<React.ComponentPropsWithoutRef<'div'>, 'size' | 'disabled' | 'placeholder' | 'onChange'>;
|
|
100
115
|
/**
|
|
101
116
|
* Select component to select value from options.
|
|
102
117
|
* Generic type is used for value. It prevents you from mistakenly using other types in `options`, `value` and `onChange`.
|
|
@@ -28,9 +28,17 @@ import React from 'react';
|
|
|
28
28
|
import cx from 'classnames';
|
|
29
29
|
import { DropdownMenu } from '../DropdownMenu';
|
|
30
30
|
import { MenuItem } from '../Menu/MenuItem';
|
|
31
|
-
import { useTheme } from '../utils';
|
|
31
|
+
import { useTheme, useOverflow, } from '../utils';
|
|
32
32
|
import '@itwin/itwinui-css/css/inputs.css';
|
|
33
33
|
import SvgCaretDownSmall from '@itwin/itwinui-icons-react/cjs/icons/CaretDownSmall';
|
|
34
|
+
import SelectTag from './SelectTag';
|
|
35
|
+
var isMultipleEnabled = function (variable, multiple) {
|
|
36
|
+
return multiple;
|
|
37
|
+
};
|
|
38
|
+
// Type guard for multiple did not work
|
|
39
|
+
var isSingleOnChange = function (onChange, multiple) {
|
|
40
|
+
return !multiple;
|
|
41
|
+
};
|
|
34
42
|
/**
|
|
35
43
|
* Select component to select value from options.
|
|
36
44
|
* Generic type is used for value. It prevents you from mistakenly using other types in `options`, `value` and `onChange`.
|
|
@@ -83,13 +91,13 @@ import SvgCaretDownSmall from '@itwin/itwinui-icons-react/cjs/icons/CaretDownSma
|
|
|
83
91
|
export var Select = function (props) {
|
|
84
92
|
var _a;
|
|
85
93
|
var _b;
|
|
86
|
-
var options = props.options, value = props.value, onChange = props.onChange, placeholder = props.placeholder, _c = props.disabled, disabled = _c === void 0 ? false : _c, size = props.size, _d = props.setFocus, setFocus = _d === void 0 ? false : _d, itemRenderer = props.itemRenderer, selectedItemRenderer = props.selectedItemRenderer, className = props.className, style = props.style, menuClassName = props.menuClassName, menuStyle = props.menuStyle, onShow = props.onShow, onHide = props.onHide, popoverProps = props.popoverProps, rest = __rest(props, ["options", "value", "onChange", "placeholder", "disabled", "size", "setFocus", "itemRenderer", "selectedItemRenderer", "className", "style", "menuClassName", "menuStyle", "onShow", "onHide", "popoverProps"]);
|
|
94
|
+
var options = props.options, value = props.value, onChange = props.onChange, placeholder = props.placeholder, _c = props.disabled, disabled = _c === void 0 ? false : _c, size = props.size, _d = props.setFocus, setFocus = _d === void 0 ? false : _d, itemRenderer = props.itemRenderer, selectedItemRenderer = props.selectedItemRenderer, className = props.className, style = props.style, menuClassName = props.menuClassName, menuStyle = props.menuStyle, onShow = props.onShow, onHide = props.onHide, popoverProps = props.popoverProps, _e = props.multiple, multiple = _e === void 0 ? false : _e, rest = __rest(props, ["options", "value", "onChange", "placeholder", "disabled", "size", "setFocus", "itemRenderer", "selectedItemRenderer", "className", "style", "menuClassName", "menuStyle", "onShow", "onHide", "popoverProps", "multiple"]);
|
|
87
95
|
useTheme();
|
|
88
|
-
var
|
|
96
|
+
var _f = React.useState((_b = popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.visible) !== null && _b !== void 0 ? _b : false), isOpen = _f[0], setIsOpen = _f[1];
|
|
89
97
|
React.useEffect(function () {
|
|
90
98
|
setIsOpen(function (open) { var _a; return (_a = popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.visible) !== null && _a !== void 0 ? _a : open; });
|
|
91
99
|
}, [popoverProps]);
|
|
92
|
-
var
|
|
100
|
+
var _g = React.useState(0), minWidth = _g[0], setMinWidth = _g[1];
|
|
93
101
|
var toggle = function () { return setIsOpen(function (open) { return !open; }); };
|
|
94
102
|
var selectRef = React.useRef(null);
|
|
95
103
|
var toggleButtonRef = React.useRef(null);
|
|
@@ -116,8 +124,10 @@ export var Select = function (props) {
|
|
|
116
124
|
case 'Enter':
|
|
117
125
|
case ' ':
|
|
118
126
|
case 'Spacebar':
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
if (event.target === selectRef.current) {
|
|
128
|
+
toggle();
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
}
|
|
121
131
|
break;
|
|
122
132
|
default:
|
|
123
133
|
break;
|
|
@@ -125,20 +135,41 @@ export var Select = function (props) {
|
|
|
125
135
|
};
|
|
126
136
|
var menuItems = React.useCallback(function (close) {
|
|
127
137
|
return options.map(function (option, index) {
|
|
128
|
-
var
|
|
138
|
+
var _a;
|
|
139
|
+
var isSelected = isMultipleEnabled(value, multiple)
|
|
140
|
+
? (_a = value === null || value === void 0 ? void 0 : value.includes(option.value)) !== null && _a !== void 0 ? _a : false
|
|
141
|
+
: value === option.value;
|
|
129
142
|
var menuItem = itemRenderer ? (itemRenderer(option, { close: close, isSelected: isSelected })) : (React.createElement(MenuItem, null, option.label));
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
var label = option.label, restOption = __rest(option, ["label"]);
|
|
144
|
+
return React.cloneElement(menuItem, __assign(__assign({ key: "".concat(label, "-").concat(index), isSelected: isSelected, onClick: function () {
|
|
145
|
+
if (option.disabled) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (isSingleOnChange(onChange, multiple)) {
|
|
149
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option.value);
|
|
150
|
+
close();
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option.value, isSelected ? 'removed' : 'added');
|
|
154
|
+
}
|
|
155
|
+
}, ref: function (el) {
|
|
156
|
+
if (isSelected && !multiple) {
|
|
157
|
+
el === null || el === void 0 ? void 0 : el.scrollIntoView();
|
|
158
|
+
}
|
|
159
|
+
}, role: 'option' }, restOption), menuItem.props));
|
|
134
160
|
});
|
|
135
|
-
}, [itemRenderer, onChange, options, value]);
|
|
136
|
-
var
|
|
161
|
+
}, [itemRenderer, multiple, onChange, options, value]);
|
|
162
|
+
var selectedItems = React.useMemo(function () {
|
|
137
163
|
if (value == null) {
|
|
138
164
|
return undefined;
|
|
139
165
|
}
|
|
140
|
-
return
|
|
141
|
-
|
|
166
|
+
return isMultipleEnabled(value, multiple)
|
|
167
|
+
? options.filter(function (option) { return value.some(function (val) { return val === option.value; }); })
|
|
168
|
+
: options.find(function (option) { return option.value === value; });
|
|
169
|
+
}, [multiple, options, value]);
|
|
170
|
+
var tagRenderer = React.useCallback(function (item) {
|
|
171
|
+
return React.createElement(SelectTag, { key: item.label, label: item.label });
|
|
172
|
+
}, []);
|
|
142
173
|
return (React.createElement("div", __assign({ className: cx('iui-input-with-icon', className), "aria-expanded": isOpen, "aria-haspopup": 'listbox', style: style }, rest),
|
|
143
174
|
React.createElement(DropdownMenu, __assign({ menuItems: menuItems, placement: 'bottom-start', className: cx('iui-scroll', menuClassName), style: __assign({ minWidth: minWidth, maxWidth: "min(".concat(minWidth * 2, "px, 90vw)"), maxHeight: 315 }, menuStyle), role: 'listbox', onShow: onShowHandler, onHide: onHideHandler, disabled: disabled }, popoverProps, { visible: isOpen, onClickOutside: function (_, _a) {
|
|
144
175
|
var _b;
|
|
@@ -148,21 +179,13 @@ export var Select = function (props) {
|
|
|
148
179
|
}
|
|
149
180
|
} }),
|
|
150
181
|
React.createElement("div", { ref: selectRef, className: cx('iui-select-button', (_a = {
|
|
151
|
-
'iui-placeholder': !
|
|
182
|
+
'iui-placeholder': (!selectedItems || selectedItems.length === 0) && !!placeholder,
|
|
152
183
|
'iui-disabled': disabled
|
|
153
184
|
},
|
|
154
185
|
_a["iui-".concat(size)] = !!size,
|
|
155
186
|
_a)), onClick: function () { return !disabled && toggle(); }, onKeyDown: function (e) { return !disabled && onKeyDown(e, toggle); }, tabIndex: !disabled ? 0 : undefined },
|
|
156
|
-
!
|
|
157
|
-
selectedItem
|
|
158
|
-
selectedItemRenderer &&
|
|
159
|
-
selectedItemRenderer(selectedItem),
|
|
160
|
-
selectedItem && !selectedItemRenderer && (React.createElement(React.Fragment, null,
|
|
161
|
-
(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon) &&
|
|
162
|
-
React.cloneElement(selectedItem.icon, {
|
|
163
|
-
className: cx(selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.icon.props.className, 'iui-icon'),
|
|
164
|
-
}),
|
|
165
|
-
React.createElement("span", { className: 'iui-content' }, selectedItem.label))))),
|
|
187
|
+
(!selectedItems || selectedItems.length === 0) && (React.createElement("span", { className: 'iui-content' }, placeholder)),
|
|
188
|
+
isMultipleEnabled(selectedItems, multiple) ? (React.createElement(MultipleSelectButton, { selectedItems: selectedItems, selectedItemsRenderer: selectedItemRenderer, tagRenderer: tagRenderer })) : (React.createElement(SingleSelectButton, { selectedItem: selectedItems, selectedItemRenderer: selectedItemRenderer })))),
|
|
166
189
|
React.createElement("span", { ref: toggleButtonRef, className: cx('iui-end-icon', {
|
|
167
190
|
'iui-actionable': !disabled,
|
|
168
191
|
'iui-disabled': disabled,
|
|
@@ -170,4 +193,38 @@ export var Select = function (props) {
|
|
|
170
193
|
}), onClick: function () { return !disabled && toggle(); } },
|
|
171
194
|
React.createElement(SvgCaretDownSmall, { "aria-hidden": true }))));
|
|
172
195
|
};
|
|
196
|
+
var SingleSelectButton = function (_a) {
|
|
197
|
+
var selectedItem = _a.selectedItem, selectedItemRenderer = _a.selectedItemRenderer;
|
|
198
|
+
return (React.createElement(React.Fragment, null,
|
|
199
|
+
selectedItem &&
|
|
200
|
+
selectedItemRenderer &&
|
|
201
|
+
selectedItemRenderer(selectedItem),
|
|
202
|
+
selectedItem && !selectedItemRenderer && (React.createElement(React.Fragment, null,
|
|
203
|
+
selectedItem.icon &&
|
|
204
|
+
React.cloneElement(selectedItem.icon, {
|
|
205
|
+
className: cx(selectedItem.icon.props.className, 'iui-icon'),
|
|
206
|
+
}),
|
|
207
|
+
React.createElement("span", { className: 'iui-content' }, selectedItem.label)))));
|
|
208
|
+
};
|
|
209
|
+
var MultipleSelectButton = function (_a) {
|
|
210
|
+
var selectedItems = _a.selectedItems, selectedItemsRenderer = _a.selectedItemsRenderer, tagRenderer = _a.tagRenderer;
|
|
211
|
+
var selectedItemsElements = React.useMemo(function () {
|
|
212
|
+
if (!selectedItems) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
return selectedItems.map(function (item) { return tagRenderer(item); });
|
|
216
|
+
}, [selectedItems, tagRenderer]);
|
|
217
|
+
var _b = useOverflow(selectedItemsElements), containerRef = _b[0], visibleCount = _b[1];
|
|
218
|
+
return (React.createElement(React.Fragment, null,
|
|
219
|
+
selectedItems &&
|
|
220
|
+
selectedItemsRenderer &&
|
|
221
|
+
selectedItemsRenderer(selectedItems),
|
|
222
|
+
selectedItems && !selectedItemsRenderer && (React.createElement("span", { className: 'iui-content' },
|
|
223
|
+
React.createElement("div", { className: 'iui-select-tag-container', ref: containerRef },
|
|
224
|
+
React.createElement(React.Fragment, null,
|
|
225
|
+
visibleCount < selectedItemsElements.length
|
|
226
|
+
? selectedItemsElements.slice(0, visibleCount - 1)
|
|
227
|
+
: selectedItemsElements,
|
|
228
|
+
visibleCount < selectedItemsElements.length && (React.createElement(SelectTag, { label: "+".concat(selectedItemsElements.length - visibleCount + 1, " item(s)") }))))))));
|
|
229
|
+
};
|
|
173
230
|
export default Select;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/inputs.css';
|
|
4
|
+
export declare type SelectTagProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Text inside the tag.
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
} & CommonProps;
|
|
10
|
+
/**
|
|
11
|
+
* Tag for showing selected value in `Select`.
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
export declare const SelectTag: (props: SelectTagProps) => JSX.Element;
|
|
15
|
+
export default SelectTag;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
/*---------------------------------------------------------------------------------------------
|
|
24
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
+
*--------------------------------------------------------------------------------------------*/
|
|
27
|
+
import cx from 'classnames';
|
|
28
|
+
import React from 'react';
|
|
29
|
+
import { useTheme } from '../utils';
|
|
30
|
+
import '@itwin/itwinui-css/css/inputs.css';
|
|
31
|
+
/**
|
|
32
|
+
* Tag for showing selected value in `Select`.
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
export var SelectTag = function (props) {
|
|
36
|
+
var className = props.className, label = props.label, rest = __rest(props, ["className", "label"]);
|
|
37
|
+
useTheme();
|
|
38
|
+
return (React.createElement("span", __assign({ className: cx('iui-select-tag', className) }, rest),
|
|
39
|
+
React.createElement("span", { className: 'iui-select-tag-label' }, label)));
|
|
40
|
+
};
|
|
41
|
+
export default SelectTag;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Select } from './Select';
|
|
2
|
-
export type { SelectProps, SelectOption, ItemRendererProps } from './Select';
|
|
2
|
+
export type { SelectProps, SelectOption, ItemRendererProps, SelectValueChangeEvent, } from './Select';
|
|
3
3
|
declare const _default: "./Select";
|
|
4
4
|
export default _default;
|
|
@@ -96,6 +96,11 @@ export declare type SliderProps = {
|
|
|
96
96
|
* high-volume of updates will occur when dragging.
|
|
97
97
|
*/
|
|
98
98
|
onUpdate?: (values: ReadonlyArray<number>) => void;
|
|
99
|
+
/**
|
|
100
|
+
* The orientation of slider
|
|
101
|
+
* @default 'horizontal'
|
|
102
|
+
*/
|
|
103
|
+
orientation?: 'horizontal' | 'vertical';
|
|
99
104
|
} & Omit<CommonProps, 'title'>;
|
|
100
105
|
/**
|
|
101
106
|
* Slider component that display Thumbs for each value specified along a Rail.
|
|
@@ -195,5 +200,10 @@ export declare const Slider: React.ForwardRefExoticComponent<{
|
|
|
195
200
|
* high-volume of updates will occur when dragging.
|
|
196
201
|
*/
|
|
197
202
|
onUpdate?: ((values: ReadonlyArray<number>) => void) | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* The orientation of slider
|
|
205
|
+
* @default 'horizontal'
|
|
206
|
+
*/
|
|
207
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
198
208
|
} & Omit<CommonProps, "title"> & React.RefAttributes<HTMLDivElement>>;
|
|
199
209
|
export default Slider;
|
|
@@ -39,9 +39,13 @@ import { useTheme, getBoundedValue, useEventListener, } from '../utils';
|
|
|
39
39
|
import '@itwin/itwinui-css/css/slider.css';
|
|
40
40
|
import { Track } from './Track';
|
|
41
41
|
import { Thumb } from './Thumb';
|
|
42
|
-
var getPercentageOfRectangle = function (rect,
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
var getPercentageOfRectangle = function (rect, pointerX, pointerY, orientation) {
|
|
43
|
+
if (orientation === 'horizontal') {
|
|
44
|
+
var position_1 = getBoundedValue(pointerX, rect.left, rect.right);
|
|
45
|
+
return (position_1 - rect.left) / rect.width;
|
|
46
|
+
}
|
|
47
|
+
var position = getBoundedValue(pointerY, rect.top, rect.bottom);
|
|
48
|
+
return (rect.bottom - position) / rect.height;
|
|
45
49
|
};
|
|
46
50
|
var getClosestValueIndex = function (values, pointerValue) {
|
|
47
51
|
if (1 === values.length) {
|
|
@@ -88,20 +92,20 @@ var focusThumb = function (sliderContainer, activeIndex) {
|
|
|
88
92
|
*/
|
|
89
93
|
export var Slider = React.forwardRef(function (props, ref) {
|
|
90
94
|
var _a, _b;
|
|
91
|
-
var _c = props.min, min = _c === void 0 ? 0 : _c, _d = props.max, max = _d === void 0 ? 100 : _d, values = props.values, _e = props.step, step = _e === void 0 ? 1 : _e, _f = props.setFocus, setFocus = _f === void 0 ? false : _f, tooltipProps = props.tooltipProps, _g = props.disabled, disabled = _g === void 0 ? false : _g, tickLabels = props.tickLabels, minLabel = props.minLabel, maxLabel = props.maxLabel, _h = props.trackDisplayMode, trackDisplayMode = _h === void 0 ? 'auto' : _h, _j = props.thumbMode, thumbMode = _j === void 0 ? 'inhibit-crossing' : _j, onChange = props.onChange, onUpdate = props.onUpdate, thumbProps = props.thumbProps, className = props.className, railContainerProps = props.railContainerProps, rest = __rest(props, ["min", "max", "values", "step", "setFocus", "tooltipProps", "disabled", "tickLabels", "minLabel", "maxLabel", "trackDisplayMode", "thumbMode", "onChange", "onUpdate", "thumbProps", "className", "railContainerProps"]);
|
|
92
|
-
var
|
|
95
|
+
var _c = props.min, min = _c === void 0 ? 0 : _c, _d = props.max, max = _d === void 0 ? 100 : _d, values = props.values, _e = props.step, step = _e === void 0 ? 1 : _e, _f = props.setFocus, setFocus = _f === void 0 ? false : _f, tooltipProps = props.tooltipProps, _g = props.disabled, disabled = _g === void 0 ? false : _g, tickLabels = props.tickLabels, minLabel = props.minLabel, maxLabel = props.maxLabel, _h = props.trackDisplayMode, trackDisplayMode = _h === void 0 ? 'auto' : _h, _j = props.thumbMode, thumbMode = _j === void 0 ? 'inhibit-crossing' : _j, onChange = props.onChange, onUpdate = props.onUpdate, thumbProps = props.thumbProps, className = props.className, railContainerProps = props.railContainerProps, _k = props.orientation, orientation = _k === void 0 ? 'horizontal' : _k, rest = __rest(props, ["min", "max", "values", "step", "setFocus", "tooltipProps", "disabled", "tickLabels", "minLabel", "maxLabel", "trackDisplayMode", "thumbMode", "onChange", "onUpdate", "thumbProps", "className", "railContainerProps", "orientation"]);
|
|
96
|
+
var _l = React.useState(values), currentValues = _l[0], setCurrentValues = _l[1];
|
|
93
97
|
React.useEffect(function () {
|
|
94
98
|
setCurrentValues(values);
|
|
95
99
|
}, [values]);
|
|
96
|
-
var
|
|
100
|
+
var _m = React.useState(function () { return minLabel !== null && minLabel !== void 0 ? minLabel : min.toString(); }), minValueLabel = _m[0], setMinValueLabel = _m[1];
|
|
97
101
|
React.useEffect(function () {
|
|
98
102
|
setMinValueLabel(minLabel !== null && minLabel !== void 0 ? minLabel : min.toString());
|
|
99
103
|
}, [minLabel, min]);
|
|
100
|
-
var
|
|
104
|
+
var _o = React.useState(function () { return maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString(); }), maxValueLabel = _o[0], setMaxValueLabel = _o[1];
|
|
101
105
|
React.useEffect(function () {
|
|
102
106
|
setMaxValueLabel(maxLabel !== null && maxLabel !== void 0 ? maxLabel : max.toString());
|
|
103
107
|
}, [maxLabel, max]);
|
|
104
|
-
var
|
|
108
|
+
var _p = React.useState(function () { return getDefaultTrackDisplay(trackDisplayMode, currentValues); }), trackDisplay = _p[0], setTrackDisplay = _p[1];
|
|
105
109
|
React.useEffect(function () {
|
|
106
110
|
setTrackDisplay(getDefaultTrackDisplay(trackDisplayMode, currentValues));
|
|
107
111
|
}, [trackDisplayMode, currentValues]);
|
|
@@ -127,10 +131,10 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
127
131
|
}
|
|
128
132
|
return [min, max];
|
|
129
133
|
}, [max, min, step, thumbMode, currentValues]);
|
|
130
|
-
var
|
|
134
|
+
var _q = React.useState(undefined), activeThumbIndex = _q[0], setActiveThumbIndex = _q[1];
|
|
131
135
|
var updateThumbValue = React.useCallback(function (event, callbackType) {
|
|
132
136
|
if (containerRef.current && undefined !== activeThumbIndex) {
|
|
133
|
-
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX);
|
|
137
|
+
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX, event.clientY, orientation);
|
|
134
138
|
var pointerValue = min + (max - min) * percent;
|
|
135
139
|
pointerValue = roundValueToClosestStep(pointerValue, step, min);
|
|
136
140
|
var _a = getAllowableThumbRange(activeThumbIndex), minVal = _a[0], maxVal = _a[1];
|
|
@@ -156,6 +160,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
156
160
|
currentValues,
|
|
157
161
|
onUpdate,
|
|
158
162
|
onChange,
|
|
163
|
+
orientation,
|
|
159
164
|
]);
|
|
160
165
|
var handlePointerMove = React.useCallback(function (event) {
|
|
161
166
|
if (activeThumbIndex === undefined) {
|
|
@@ -189,7 +194,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
189
194
|
}, [activeThumbIndex, updateThumbValue]);
|
|
190
195
|
var handlePointerDownOnSlider = React.useCallback(function (event) {
|
|
191
196
|
if (containerRef.current) {
|
|
192
|
-
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX);
|
|
197
|
+
var percent = getPercentageOfRectangle(containerRef.current.getBoundingClientRect(), event.clientX, event.clientY, orientation);
|
|
193
198
|
var pointerValue = min + (max - min) * percent;
|
|
194
199
|
pointerValue = roundValueToClosestStep(pointerValue, step, min);
|
|
195
200
|
var closestValueIndex = getClosestValueIndex(currentValues, pointerValue);
|
|
@@ -215,6 +220,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
215
220
|
getAllowableThumbRange,
|
|
216
221
|
onChange,
|
|
217
222
|
onUpdate,
|
|
223
|
+
orientation,
|
|
218
224
|
]);
|
|
219
225
|
useEventListener('pointermove', handlePointerMove, (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument);
|
|
220
226
|
useEventListener('pointerup', handlePointerUp, (_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.ownerDocument);
|
|
@@ -235,7 +241,7 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
235
241
|
? outProps.content
|
|
236
242
|
: formatNumberValue(val, step, getNumDecimalPlaces) });
|
|
237
243
|
}, [getNumDecimalPlaces, step, tooltipProps]);
|
|
238
|
-
return (React.createElement("div", __assign({ ref: ref, className: cx('iui-slider-component-container', { 'iui-disabled': disabled }, className) }, rest),
|
|
244
|
+
return (React.createElement("div", __assign({ ref: ref, className: cx('iui-slider-component-container', "iui-slider-".concat(orientation), { 'iui-disabled': disabled }, className) }, rest),
|
|
239
245
|
minValueLabel && (React.createElement("span", { className: 'iui-slider-min' }, minValueLabel)),
|
|
240
246
|
React.createElement("div", __assign({ ref: containerRef, className: cx('iui-slider-container', {
|
|
241
247
|
'iui-grabbing': undefined !== activeThumbIndex,
|
|
@@ -245,9 +251,9 @@ export var Slider = React.forwardRef(function (props, ref) {
|
|
|
245
251
|
var _a;
|
|
246
252
|
var _b = getAllowableThumbRange(index), minVal = _b[0], maxVal = _b[1];
|
|
247
253
|
var thisThumbProps = thumbProps === null || thumbProps === void 0 ? void 0 : thumbProps(index);
|
|
248
|
-
return (React.createElement(Thumb, { key: (_a = thisThumbProps === null || thisThumbProps === void 0 ? void 0 : thisThumbProps.id) !== null && _a !== void 0 ? _a : index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max }));
|
|
254
|
+
return (React.createElement(Thumb, { key: (_a = thisThumbProps === null || thisThumbProps === void 0 ? void 0 : thisThumbProps.id) !== null && _a !== void 0 ? _a : index, index: index, disabled: disabled, isActive: activeThumbIndex === index, onThumbActivated: onThumbActivated, onThumbValueChanged: onThumbValueChanged, minVal: minVal, maxVal: maxVal, value: thumbValue, tooltipProps: generateTooltipProps(index, thumbValue), thumbProps: thisThumbProps, step: step, sliderMin: min, sliderMax: max, orientation: orientation }));
|
|
249
255
|
}),
|
|
250
|
-
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues }),
|
|
256
|
+
React.createElement(Track, { trackDisplayMode: trackDisplay, sliderMin: min, sliderMax: max, values: currentValues, orientation: orientation }),
|
|
251
257
|
tickMarkArea),
|
|
252
258
|
maxValueLabel && (React.createElement("span", { className: 'iui-slider-max' }, maxValueLabel))));
|
|
253
259
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TooltipProps } from '../Tooltip';
|
|
3
|
+
import { SliderProps } from './Slider';
|
|
3
4
|
export declare type ThumbProps = {
|
|
4
5
|
/**
|
|
5
6
|
* Thumb value.
|
|
@@ -53,7 +54,7 @@ export declare type ThumbProps = {
|
|
|
53
54
|
* Additional props for Thumb.
|
|
54
55
|
*/
|
|
55
56
|
thumbProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
56
|
-
}
|
|
57
|
+
} & Pick<SliderProps, 'orientation'>;
|
|
57
58
|
/**
|
|
58
59
|
* Thumb is a local component used to show and modify the values maintained by the Slider.
|
|
59
60
|
* Only one Thumb can be active at a time. A Thumb is made active when the user selects
|
package/esm/core/Slider/Thumb.js
CHANGED
|
@@ -33,7 +33,7 @@ import { Tooltip } from '../Tooltip';
|
|
|
33
33
|
* it with pointer. Whenever a Thumb is active, focused, or hovered its tooltip is shown.
|
|
34
34
|
*/
|
|
35
35
|
export var Thumb = function (props) {
|
|
36
|
-
var value = props.value, index = props.index, minVal = props.minVal, maxVal = props.maxVal, step = props.step, sliderMin = props.sliderMin, sliderMax = props.sliderMax, isActive = props.isActive, onThumbActivated = props.onThumbActivated, onThumbValueChanged = props.onThumbValueChanged, tooltipProps = props.tooltipProps, thumbProps = props.thumbProps, disabled = props.disabled;
|
|
36
|
+
var value = props.value, index = props.index, minVal = props.minVal, maxVal = props.maxVal, step = props.step, sliderMin = props.sliderMin, sliderMax = props.sliderMax, isActive = props.isActive, onThumbActivated = props.onThumbActivated, onThumbValueChanged = props.onThumbValueChanged, tooltipProps = props.tooltipProps, thumbProps = props.thumbProps, disabled = props.disabled, orientation = props.orientation;
|
|
37
37
|
var thumbRef = React.useRef(null);
|
|
38
38
|
var handleOnKeyDown = React.useCallback(function (event) {
|
|
39
39
|
if (disabled || event.altKey) {
|
|
@@ -73,7 +73,7 @@ export var Thumb = function (props) {
|
|
|
73
73
|
}
|
|
74
74
|
return value;
|
|
75
75
|
}, [sliderMax, sliderMin, value]);
|
|
76
|
-
var
|
|
76
|
+
var lowPercent = React.useMemo(function () {
|
|
77
77
|
if (sliderMax === sliderMin) {
|
|
78
78
|
return 0;
|
|
79
79
|
}
|
|
@@ -81,5 +81,7 @@ export var Thumb = function (props) {
|
|
|
81
81
|
}, [adjustedValue, sliderMax, sliderMin]);
|
|
82
82
|
var _c = thumbProps || {}, style = _c.style, className = _c.className, rest = __rest(_c, ["style", "className"]);
|
|
83
83
|
return (React.createElement(Tooltip, __assign({ visible: isActive || hasFocus || isHovered, placement: 'top' }, tooltipProps),
|
|
84
|
-
React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style),
|
|
84
|
+
React.createElement("div", __assign({}, rest, { "data-index": index, ref: thumbRef, style: __assign(__assign({}, style), (orientation === 'horizontal'
|
|
85
|
+
? { left: "".concat(lowPercent, "%") }
|
|
86
|
+
: { bottom: "".concat(lowPercent, "%") })), className: cx('iui-slider-thumb', { 'iui-active': isActive }, className), role: 'slider', tabIndex: disabled ? undefined : 0, "aria-valuemin": minVal, "aria-valuenow": value, "aria-valuemax": maxVal, "aria-disabled": disabled, onPointerDown: handlePointerDownOnThumb, onKeyDown: handleOnKeyDown, onFocus: function () { return setHasFocus(true); }, onBlur: function () { return setHasFocus(false); }, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }))));
|
|
85
87
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TrackDisplayMode } from './Slider';
|
|
2
|
+
import { SliderProps, TrackDisplayMode } from './Slider';
|
|
3
3
|
export declare type TrackProps = {
|
|
4
4
|
trackDisplayMode: TrackDisplayMode;
|
|
5
5
|
sliderMin: number;
|
|
6
6
|
sliderMax: number;
|
|
7
7
|
values: number[];
|
|
8
|
+
orientation: SliderProps['orientation'];
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
11
|
* Track displays color segments above Rail. Which, if any, segments that are
|
package/esm/core/Slider/Track.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
13
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
14
|
if (ar || !(i in from)) {
|
|
@@ -44,7 +55,7 @@ function generateSegments(values, min, max) {
|
|
|
44
55
|
* colorized is based on `trackDisplayMode`.
|
|
45
56
|
*/
|
|
46
57
|
export var Track = function (props) {
|
|
47
|
-
var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values;
|
|
58
|
+
var trackDisplayMode = props.trackDisplayMode, sliderMin = props.sliderMin, sliderMax = props.sliderMax, values = props.values, orientation = props.orientation;
|
|
48
59
|
var _a = React.useState(function () {
|
|
49
60
|
return generateSegments(values, sliderMin, sliderMax);
|
|
50
61
|
}), segments = _a[0], setSegments = _a[1];
|
|
@@ -53,13 +64,21 @@ export var Track = function (props) {
|
|
|
53
64
|
}, [values, sliderMin, sliderMax]);
|
|
54
65
|
return (React.createElement(React.Fragment, null, 'none' !== trackDisplayMode &&
|
|
55
66
|
segments.map(function (segment, index) {
|
|
56
|
-
var
|
|
67
|
+
var lowPercent = segment.left >= sliderMin && sliderMax !== sliderMin
|
|
57
68
|
? (100.0 * (segment.left - sliderMin)) / (sliderMax - sliderMin)
|
|
58
69
|
: 0;
|
|
59
|
-
var
|
|
70
|
+
var highPercent = segment.right >= sliderMin && sliderMax !== sliderMin
|
|
60
71
|
? 100.0 -
|
|
61
72
|
(100.0 * (segment.right - sliderMin)) / (sliderMax - sliderMin)
|
|
62
73
|
: 100;
|
|
63
|
-
return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: {
|
|
74
|
+
return (React.createElement(React.Fragment, { key: index }, shouldDisplaySegment(index, trackDisplayMode) ? (React.createElement("div", { className: 'iui-slider-track', style: __assign({}, (orientation === 'horizontal'
|
|
75
|
+
? {
|
|
76
|
+
left: "".concat(lowPercent, "%"),
|
|
77
|
+
right: "".concat(highPercent, "%"),
|
|
78
|
+
}
|
|
79
|
+
: {
|
|
80
|
+
top: "".concat(highPercent, "%"),
|
|
81
|
+
bottom: "".concat(lowPercent, "%"),
|
|
82
|
+
})) })) : null));
|
|
64
83
|
})));
|
|
65
84
|
};
|
|
@@ -185,7 +185,8 @@ export declare type TableProps<T extends Record<string, unknown> = Record<string
|
|
|
185
185
|
/**
|
|
186
186
|
* Function that returns index of the row that you want to scroll to.
|
|
187
187
|
*
|
|
188
|
-
*
|
|
188
|
+
* When using with lazy-loading table, you need to take care that row is already loaded.
|
|
189
|
+
* It doesn't work with paginated tables.
|
|
189
190
|
* @beta
|
|
190
191
|
* @example
|
|
191
192
|
* <Table
|
package/esm/core/Table/Table.js
CHANGED
|
@@ -327,7 +327,12 @@ export var Table = function (props) {
|
|
|
327
327
|
className: cx('iui-table', (_a = {}, _a["iui-".concat(density)] = density !== 'default', _a), className),
|
|
328
328
|
style: __assign({ minWidth: 0 }, style),
|
|
329
329
|
}), ariaDataAttributes),
|
|
330
|
-
React.createElement("div", { className: 'iui-table-header-wrapper', ref: headerRef
|
|
330
|
+
React.createElement("div", { className: 'iui-table-header-wrapper', ref: headerRef, onScroll: function () {
|
|
331
|
+
if (headerRef.current && bodyRef.current) {
|
|
332
|
+
bodyRef.current.scrollLeft = headerRef.current.scrollLeft;
|
|
333
|
+
updateStickyState();
|
|
334
|
+
}
|
|
335
|
+
} },
|
|
331
336
|
React.createElement("div", { className: 'iui-table-header' }, headerGroups.slice(1).map(function (headerGroup) {
|
|
332
337
|
var headerGroupProps = headerGroup.getHeaderGroupProps({
|
|
333
338
|
className: 'iui-row',
|
|
@@ -348,7 +353,8 @@ export var Table = function (props) {
|
|
|
348
353
|
(showFilterButton(column) ||
|
|
349
354
|
showSortButton(column)) && (React.createElement("div", { className: 'iui-table-header-actions-container' },
|
|
350
355
|
showFilterButton(column) && (React.createElement(FilterToggle, { column: column, ownerDocument: ownerDocument })),
|
|
351
|
-
showSortButton(column) && (React.createElement("div", { className: 'iui-cell-end-icon' }, column.
|
|
356
|
+
showSortButton(column) && (React.createElement("div", { className: 'iui-cell-end-icon' }, column.isSortedDesc ||
|
|
357
|
+
(!column.isSorted && column.sortDescFirst) ? (React.createElement(SvgSortDown, { className: 'iui-icon iui-sort', "aria-hidden": true })) : (React.createElement(SvgSortUp, { className: 'iui-icon iui-sort', "aria-hidden": true })))))),
|
|
352
358
|
isResizable &&
|
|
353
359
|
column.isResizerVisible &&
|
|
354
360
|
index !== headerGroup.headers.length - 1 && (React.createElement("div", __assign({}, column.getResizerProps(), { className: 'iui-resizer' }),
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { HeaderProps } from 'react-table';
|
|
3
|
+
import { DropdownMenuProps } from '../../DropdownMenu';
|
|
4
|
+
declare type ActionColumnProps = {
|
|
5
|
+
columnManager?: boolean | {
|
|
6
|
+
dropdownMenuProps: Omit<DropdownMenuProps, 'menuItems' | 'children'>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* Action column that adds column manager to the Table header.
|
|
5
11
|
* It is recommended to add this column to the end of the Table
|
|
@@ -19,9 +25,7 @@ import { HeaderProps } from 'react-table';
|
|
|
19
25
|
* ),
|
|
20
26
|
* },
|
|
21
27
|
*/
|
|
22
|
-
export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: {
|
|
23
|
-
columnManager?: boolean | undefined;
|
|
24
|
-
}) => {
|
|
28
|
+
export declare const ActionColumn: <T extends Record<string, unknown>>({ columnManager, }?: ActionColumnProps) => {
|
|
25
29
|
id: string;
|
|
26
30
|
disableResizing: boolean;
|
|
27
31
|
disableGroupBy: boolean;
|
|
@@ -33,3 +37,4 @@ export declare const ActionColumn: <T extends Record<string, unknown>>({ columnM
|
|
|
33
37
|
disableReordering: boolean;
|
|
34
38
|
Header: ({ allColumns, dispatch, state }: HeaderProps<T>) => JSX.Element | null;
|
|
35
39
|
};
|
|
40
|
+
export {};
|