@itwin/itwinui-react 1.32.0-dev.0 → 1.32.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 +16 -0
- package/cjs/core/Checkbox/Checkbox.d.ts +13 -0
- package/cjs/core/Checkbox/Checkbox.js +15 -22
- package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/cjs/core/ComboBox/ComboBox.d.ts +11 -0
- package/cjs/core/ComboBox/ComboBox.js +52 -19
- package/cjs/core/ExpandableBlock/ExpandableBlock.d.ts +6 -0
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +3 -2
- package/cjs/core/Menu/Menu.js +3 -3
- package/cjs/core/Radio/Radio.d.ts +13 -0
- package/cjs/core/Radio/Radio.js +7 -8
- package/cjs/core/Tree/Tree.d.ts +123 -0
- package/cjs/core/Tree/Tree.js +177 -0
- package/cjs/core/Tree/TreeContext.d.ts +25 -0
- package/cjs/core/Tree/TreeContext.js +20 -0
- package/cjs/core/Tree/TreeNode.d.ts +87 -0
- package/cjs/core/Tree/TreeNode.js +169 -0
- package/cjs/core/Tree/TreeNodeExpander.d.ts +8 -0
- package/cjs/core/Tree/TreeNodeExpander.js +46 -0
- package/cjs/core/Tree/index.d.ts +6 -0
- package/cjs/core/Tree/index.js +13 -0
- package/cjs/core/index.d.ts +2 -0
- package/cjs/core/index.js +5 -1
- package/cjs/core/utils/functions/focusable.js +6 -2
- package/esm/core/Checkbox/Checkbox.d.ts +13 -0
- package/esm/core/Checkbox/Checkbox.js +15 -22
- package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
- package/esm/core/ComboBox/ComboBox.d.ts +11 -0
- package/esm/core/ComboBox/ComboBox.js +53 -20
- package/esm/core/ExpandableBlock/ExpandableBlock.d.ts +6 -0
- package/esm/core/ExpandableBlock/ExpandableBlock.js +3 -2
- package/esm/core/Menu/Menu.js +3 -3
- package/esm/core/Radio/Radio.d.ts +13 -0
- package/esm/core/Radio/Radio.js +7 -8
- package/esm/core/Tree/Tree.d.ts +123 -0
- package/esm/core/Tree/Tree.js +170 -0
- package/esm/core/Tree/TreeContext.d.ts +25 -0
- package/esm/core/Tree/TreeContext.js +13 -0
- package/esm/core/Tree/TreeNode.d.ts +87 -0
- package/esm/core/Tree/TreeNode.js +162 -0
- package/esm/core/Tree/TreeNodeExpander.d.ts +8 -0
- package/esm/core/Tree/TreeNodeExpander.js +39 -0
- package/esm/core/Tree/index.d.ts +6 -0
- package/esm/core/Tree/index.js +7 -0
- package/esm/core/index.d.ts +2 -0
- package/esm/core/index.js +1 -0
- package/esm/core/utils/functions/focusable.js +6 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.32.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.31.0...v1.32.0) (2022-02-25)
|
|
4
|
+
|
|
5
|
+
### What's new
|
|
6
|
+
|
|
7
|
+
* **Popover:** Append to `body` by default and increase z-index ([#562](https://www.github.com/iTwin/iTwinUI-react/issues/562)) ([66df49f](https://www.github.com/iTwin/iTwinUI-react/commit/66df49fec85ec13707cc73bb3fdf84ca3a4c7655))
|
|
8
|
+
- This will fix many clipping and positioning issues in tooltips and dropdowns, without the need for any workarounds.
|
|
9
|
+
- If a popover is nested within another popover which is already appended to document.body, then it should use `appendTo='parent'`.
|
|
10
|
+
* **Tree:** Add new Tree Component ([#468](https://www.github.com/iTwin/iTwinUI-react/issues/468)) ([1d5083c](https://www.github.com/iTwin/iTwinUI-react/commit/1d5083c612cd1f1b1cbec0e5ea82b8b573d72b86))
|
|
11
|
+
* **ComboBox:** Add new `itemRenderer` prop for customizing the look of menu items ([#547](https://www.github.com/iTwin/iTwinUI-react/issues/547)) ([d866d32](https://www.github.com/iTwin/iTwinUI-react/commit/d866d32a719dea6e359519ae40bc66dc7df209e1))
|
|
12
|
+
* **ExpandableBlock:** Add borderless variant via new `styleType` prop ([#557](https://www.github.com/iTwin/iTwinUI-react/issues/557)) ([9e8c8ab](https://www.github.com/iTwin/iTwinUI-react/commit/9e8c8ab76a7c6d24c51d5eea9e4424417c0e2fad))
|
|
13
|
+
* **Checkbox** and **Radio**: Render without `<label>` wrapper if `label` prop is not passed ([#556](https://www.github.com/iTwin/iTwinUI-react/issues/556)) ([a436cbf](https://www.github.com/iTwin/iTwinUI-react/commit/a436cbf333629b2603bf160f9a8ffe2592093805))
|
|
14
|
+
|
|
15
|
+
### Fixes
|
|
16
|
+
|
|
17
|
+
* **Menu:** Fix lost item focus in edge cases ([#563](https://www.github.com/iTwin/iTwinUI-react/issues/563)) ([3ccb5ed](https://www.github.com/iTwin/iTwinUI-react/commit/3ccb5ed98ac4f60479e0450abb31cbb659d902b9))
|
|
18
|
+
|
|
3
19
|
## [1.31.0](https://www.github.com/iTwin/iTwinUI-react/compare/v1.30.0...v1.31.0) (2022-02-15)
|
|
4
20
|
|
|
5
21
|
### What's new
|
|
@@ -30,16 +30,23 @@ export declare type CheckboxProps = {
|
|
|
30
30
|
isLoading?: boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Custom CSS class name for the checkmark element.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated As of 1.32.0, this is applied on the actual checkbox `<input>` element.
|
|
35
|
+
* The checkmark has been moved into a pseudo-element.
|
|
33
36
|
*/
|
|
34
37
|
checkmarkClassName?: string;
|
|
35
38
|
/**
|
|
36
39
|
* Custom CSS Style for the checkmark element.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated As of 1.32.0, this is applied on the actual checkbox `<input>` element.
|
|
42
|
+
* The checkmark has been moved into a pseudo-element.
|
|
37
43
|
*/
|
|
38
44
|
checkmarkStyle?: React.CSSProperties;
|
|
39
45
|
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'>;
|
|
40
46
|
/**
|
|
41
47
|
* Simple input checkbox
|
|
42
48
|
* @example
|
|
49
|
+
* <Checkbox />
|
|
43
50
|
* <Checkbox label='Basic Checkbox' />
|
|
44
51
|
* <Checkbox label='Disabled Checkbox' disabled />
|
|
45
52
|
* <Checkbox label='Checked' checked />
|
|
@@ -78,10 +85,16 @@ export declare const Checkbox: React.ForwardRefExoticComponent<{
|
|
|
78
85
|
isLoading?: boolean | undefined;
|
|
79
86
|
/**
|
|
80
87
|
* Custom CSS class name for the checkmark element.
|
|
88
|
+
*
|
|
89
|
+
* @deprecated As of 1.32.0, this is applied on the actual checkbox `<input>` element.
|
|
90
|
+
* The checkmark has been moved into a pseudo-element.
|
|
81
91
|
*/
|
|
82
92
|
checkmarkClassName?: string | undefined;
|
|
83
93
|
/**
|
|
84
94
|
* Custom CSS Style for the checkmark element.
|
|
95
|
+
*
|
|
96
|
+
* @deprecated As of 1.32.0, this is applied on the actual checkbox `<input>` element.
|
|
97
|
+
* The checkmark has been moved into a pseudo-element.
|
|
85
98
|
*/
|
|
86
99
|
checkmarkStyle?: React.CSSProperties | undefined;
|
|
87
100
|
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -38,6 +38,7 @@ require("@itwin/itwinui-css/css/inputs.css");
|
|
|
38
38
|
/**
|
|
39
39
|
* Simple input checkbox
|
|
40
40
|
* @example
|
|
41
|
+
* <Checkbox />
|
|
41
42
|
* <Checkbox label='Basic Checkbox' />
|
|
42
43
|
* <Checkbox label='Disabled Checkbox' disabled />
|
|
43
44
|
* <Checkbox label='Checked' checked />
|
|
@@ -47,8 +48,8 @@ require("@itwin/itwinui-css/css/inputs.css");
|
|
|
47
48
|
* <Checkbox label='Visibility Checkbox' variant='eyeball' />
|
|
48
49
|
*/
|
|
49
50
|
exports.Checkbox = react_1.default.forwardRef(function (props, ref) {
|
|
50
|
-
var _a;
|
|
51
|
-
var className = props.className,
|
|
51
|
+
var _a, _b;
|
|
52
|
+
var className = props.className, _c = props.disabled, disabled = _c === void 0 ? false : _c, _d = props.indeterminate, indeterminate = _d === void 0 ? false : _d, label = props.label, status = props.status, _e = props.variant, variant = _e === void 0 ? 'default' : _e, setFocus = props.setFocus, _f = props.isLoading, isLoading = _f === void 0 ? false : _f, style = props.style, checkmarkClassName = props.checkmarkClassName, checkmarkStyle = props.checkmarkStyle, rest = __rest(props, ["className", "disabled", "indeterminate", "label", "status", "variant", "setFocus", "isLoading", "style", "checkmarkClassName", "checkmarkStyle"]);
|
|
52
53
|
(0, utils_1.useTheme)();
|
|
53
54
|
var inputElementRef = react_1.default.useRef(null);
|
|
54
55
|
var refs = (0, utils_1.useMergedRefs)(inputElementRef, ref);
|
|
@@ -65,27 +66,19 @@ exports.Checkbox = react_1.default.forwardRef(function (props, ref) {
|
|
|
65
66
|
: inputElementRef.current.checked;
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
|
-
var
|
|
69
|
-
react_1.default.createElement("
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
react_1.default.createElement(
|
|
74
|
-
|
|
75
|
-
react_1.default.createElement("path", { d: 'm8 0a1 1 0 0 0 -1 1v2.07135a8.91637 8.91637 0 0 0 -7 4.92865 8.91637 8.91637 0 0 0 7 4.92865v2.07135a1 1 0 0 0 2 0v-14a1 1 0 0 0 -1-1zm-1.5 4.9a1.55426 1.55426 0 0 1 .5.087v2.81451a1.40746 1.40746 0 0 1 -.5.09849 1.538 1.538 0 0 1 -1.5-1.5 1.53794 1.53794 0 0 1 1.5-1.5zm-2.3 5.4a6.97279 6.97279 0 0 1 -2.5-2.3 6.89429 6.89429 0 0 1 2.4-2.4c.1 0 .1-.1.2-.1a3.194 3.194 0 0 0 -.3 1.4 4.0047 4.0047 0 0 0 3 3.857v.65289a6.37491 6.37491 0 0 1 -2.8-1.10989z' })),
|
|
76
|
-
react_1.default.createElement("path", { className: 'iui-uncheck', d: 'm1.70671 12.879 11.17218-11.17219 1.4142 1.4142-11.17218 11.17218zm.99329-1.679 1.1-1.1a5.06317 5.06317 0 0 1 -2-2.1 7.48268 7.48268 0 0 1 6.2-3.5 4.86877 4.86877 0 0 1 1.2.1l1.3-1.3a10.07431 10.07431 0 0 0 -2.5-.3 8.84129 8.84129 0 0 0 -8 5 8.42455 8.42455 0 0 0 2.7 3.2zm10.7-6.4-1.1 1.1a7.08625 7.08625 0 0 1 2 2.1 7.50323 7.50323 0 0 1 -6.2 3.5 8.31665 8.31665 0 0 1 -1.3-.2l-1.3 1.3a8.909 8.909 0 0 0 6.4-.5 9.04344 9.04344 0 0 0 4.1-4.1 9.168 9.168 0 0 0 -2.6-3.2z' })));
|
|
77
|
-
return (react_1.default.createElement("label", { className: (0, classnames_1.default)('iui-checkbox', (_a = {
|
|
69
|
+
var checkbox = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
70
|
+
react_1.default.createElement("input", __assign({ className: (0, classnames_1.default)('iui-checkbox', {
|
|
71
|
+
'iui-checkbox-visibility': variant === 'eyeball',
|
|
72
|
+
'iui-loading': isLoading,
|
|
73
|
+
}, className && (_a = {}, _a[className] = !label, _a), checkmarkClassName), style: __assign(__assign({}, (!label && style)), checkmarkStyle), disabled: disabled || isLoading, type: 'checkbox', ref: refs }, rest)),
|
|
74
|
+
isLoading && react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { size: 'x-small', indeterminate: true })));
|
|
75
|
+
return !label ? (checkbox) : (react_1.default.createElement("label", { className: (0, classnames_1.default)('iui-checkbox-wrapper', (_b = {
|
|
78
76
|
'iui-disabled': disabled
|
|
79
77
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
react_1.default.createElement("
|
|
85
|
-
react_1.default.createElement("span", { className: (0, classnames_1.default)('iui-checkbox-checkmark', checkmarkClassName), style: checkmarkStyle },
|
|
86
|
-
isLoading && react_1.default.createElement(ProgressIndicators_1.ProgressRadial, { indeterminate: true }),
|
|
87
|
-
!isLoading &&
|
|
88
|
-
(variant === 'default' ? defaultCheckbox : visibilityCheckbox)),
|
|
89
|
-
label && react_1.default.createElement("span", { className: 'iui-label' }, label)));
|
|
78
|
+
_b["iui-" + status] = !!status,
|
|
79
|
+
_b['iui-loading'] = isLoading,
|
|
80
|
+
_b), className), style: style },
|
|
81
|
+
checkbox,
|
|
82
|
+
label && react_1.default.createElement("span", { className: 'iui-checkbox-label' }, label)));
|
|
90
83
|
});
|
|
91
84
|
exports.default = exports.Checkbox;
|
|
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
|
|
|
17
17
|
* <ColorSwatch color='#23450b' onClick={onClick}/>
|
|
18
18
|
* <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
|
|
19
19
|
*/
|
|
20
|
-
export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-
|
|
20
|
+
export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "aria-disabled" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "isActive"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
21
|
export default ColorSwatch;
|
|
@@ -33,6 +33,17 @@ export declare type ComboBoxProps<T> = {
|
|
|
33
33
|
* @default 'No options found'
|
|
34
34
|
*/
|
|
35
35
|
emptyStateMessage?: string;
|
|
36
|
+
/**
|
|
37
|
+
* A custom item renderer can be specified to control the rendering.
|
|
38
|
+
* This function should ideally return a customized version of `MenuItem`,
|
|
39
|
+
* otherwise you will need to make sure to provide styling for the `isFocused` state.
|
|
40
|
+
*/
|
|
41
|
+
itemRenderer?: (option: SelectOption<T>, states: {
|
|
42
|
+
isSelected: boolean;
|
|
43
|
+
isFocused: boolean;
|
|
44
|
+
id: string;
|
|
45
|
+
index: number;
|
|
46
|
+
}) => JSX.Element;
|
|
36
47
|
} & Pick<InputContainerProps, 'status'> & Omit<CommonProps, 'title'>;
|
|
37
48
|
/**
|
|
38
49
|
* ComboBox component that allows typing a value to filter the options in dropdown list.
|
|
@@ -52,7 +52,7 @@ require("tippy.js/animations/shift-away.css");
|
|
|
52
52
|
* />
|
|
53
53
|
*/
|
|
54
54
|
var ComboBox = function (props) {
|
|
55
|
-
var options = props.options, value = props.value, onChange = props.onChange, filterFunction = props.filterFunction, className = props.className, inputProps = props.inputProps, dropdownMenuProps = props.dropdownMenuProps, _a = props.emptyStateMessage, emptyStateMessage = _a === void 0 ? 'No options found' : _a, rest = __rest(props, ["options", "value", "onChange", "filterFunction", "className", "inputProps", "dropdownMenuProps", "emptyStateMessage"]);
|
|
55
|
+
var options = props.options, value = props.value, onChange = props.onChange, filterFunction = props.filterFunction, className = props.className, inputProps = props.inputProps, dropdownMenuProps = props.dropdownMenuProps, _a = props.emptyStateMessage, emptyStateMessage = _a === void 0 ? 'No options found' : _a, itemRenderer = props.itemRenderer, rest = __rest(props, ["options", "value", "onChange", "filterFunction", "className", "inputProps", "dropdownMenuProps", "emptyStateMessage", "itemRenderer"]);
|
|
56
56
|
// Generate a stateful random id if not specified
|
|
57
57
|
var id = react_1.default.useState(function () {
|
|
58
58
|
var _a, _b;
|
|
@@ -67,16 +67,31 @@ var ComboBox = function (props) {
|
|
|
67
67
|
return value === options[index].value;
|
|
68
68
|
});
|
|
69
69
|
}, [options, id]);
|
|
70
|
+
var userOnChange = react_1.default.useRef(onChange);
|
|
70
71
|
var memoizedItems = react_1.default.useMemo(function () {
|
|
71
|
-
return options.map(function (
|
|
72
|
-
var label =
|
|
73
|
-
|
|
72
|
+
return options.map(function (option, index) {
|
|
73
|
+
var label = option.label, value = option.value, rest = __rest(option, ["label", "value"]);
|
|
74
|
+
var additionalProps = {
|
|
75
|
+
value: value,
|
|
76
|
+
role: 'option',
|
|
77
|
+
onClick: function () {
|
|
78
|
+
var _a;
|
|
74
79
|
setSelectedValue(value);
|
|
75
|
-
|
|
80
|
+
(_a = userOnChange.current) === null || _a === void 0 ? void 0 : _a.call(userOnChange, value);
|
|
76
81
|
setIsOpen(false);
|
|
77
|
-
}
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
if (itemRenderer) {
|
|
85
|
+
return react_1.default.cloneElement(itemRenderer(option, {
|
|
86
|
+
id: getOptionId(index),
|
|
87
|
+
index: index,
|
|
88
|
+
isSelected: false,
|
|
89
|
+
isFocused: false,
|
|
90
|
+
}), additionalProps);
|
|
91
|
+
}
|
|
92
|
+
return (react_1.default.createElement(Menu_1.MenuItem, __assign({ id: getOptionId(index), key: getOptionId(index) }, additionalProps, rest), label));
|
|
78
93
|
});
|
|
79
|
-
}, [options, getOptionId,
|
|
94
|
+
}, [options, getOptionId, itemRenderer]);
|
|
80
95
|
var inputRef = react_1.default.useRef(null);
|
|
81
96
|
var menuRef = react_1.default.useRef(null);
|
|
82
97
|
var toggleButtonRef = react_1.default.useRef(null);
|
|
@@ -155,6 +170,7 @@ var ComboBox = function (props) {
|
|
|
155
170
|
});
|
|
156
171
|
}, [inputValue, options, selectedValue, isOpen, filterFunction]);
|
|
157
172
|
var onKeyDown = react_1.default.useCallback(function (event) {
|
|
173
|
+
var _a;
|
|
158
174
|
var focusableOptions = (0, utils_1.getFocusableElements)(menuRef.current);
|
|
159
175
|
var focusedIndexInFilteredList = focusableOptions.findIndex(function (_a) {
|
|
160
176
|
var _b;
|
|
@@ -188,7 +204,7 @@ var ComboBox = function (props) {
|
|
|
188
204
|
case 'Enter':
|
|
189
205
|
if (isOpen) {
|
|
190
206
|
setSelectedValue(options[focusedIndex].value);
|
|
191
|
-
|
|
207
|
+
(_a = userOnChange.current) === null || _a === void 0 ? void 0 : _a.call(userOnChange, options[focusedIndex].value);
|
|
192
208
|
}
|
|
193
209
|
setIsOpen(function (open) { return !open; });
|
|
194
210
|
event.preventDefault();
|
|
@@ -208,26 +224,41 @@ var ComboBox = function (props) {
|
|
|
208
224
|
}
|
|
209
225
|
break;
|
|
210
226
|
}
|
|
211
|
-
}, [focusedIndex, isOpen, options, getOptionId
|
|
227
|
+
}, [focusedIndex, isOpen, options, getOptionId]);
|
|
212
228
|
var menuItems = react_1.default.useMemo(function () {
|
|
213
229
|
if (filteredOptions.length === 0) {
|
|
214
|
-
return
|
|
215
|
-
react_1.default.createElement(
|
|
230
|
+
return [
|
|
231
|
+
react_1.default.createElement(Menu_1.MenuExtraContent, { key: 0 },
|
|
232
|
+
react_1.default.createElement(Typography_1.Text, { isMuted: true }, emptyStateMessage)),
|
|
233
|
+
];
|
|
216
234
|
}
|
|
217
235
|
return filteredOptions.map(function (option) {
|
|
236
|
+
var _a;
|
|
218
237
|
var index = options.findIndex(function (_a) {
|
|
219
238
|
var value = _a.value;
|
|
220
239
|
return option.value === value;
|
|
221
240
|
});
|
|
222
241
|
if (index < 0) {
|
|
223
|
-
return;
|
|
242
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
224
243
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
244
|
+
var id = getOptionId(index);
|
|
245
|
+
var isSelected = selectedValue === option.value;
|
|
246
|
+
var isFocused = focusedIndex === index;
|
|
247
|
+
var focusScrollRef = function (el) {
|
|
248
|
+
return isFocused && (el === null || el === void 0 ? void 0 : el.scrollIntoView({ block: 'nearest' }));
|
|
249
|
+
};
|
|
250
|
+
if (isSelected || isFocused) {
|
|
251
|
+
var item = (_a = itemRenderer === null || itemRenderer === void 0 ? void 0 : itemRenderer(option, { index: index, id: id, isSelected: isSelected, isFocused: isFocused })) !== null && _a !== void 0 ? _a : react_1.default.cloneElement(memoizedItems[index], { isSelected: isSelected });
|
|
252
|
+
return react_1.default.cloneElement(item, {
|
|
253
|
+
className: (0, classnames_1.default)({ 'iui-focused': isFocused }, item.props.className),
|
|
254
|
+
ref: (0, utils_1.mergeRefs)(focusScrollRef, item.props.ref),
|
|
255
|
+
value: option.value,
|
|
256
|
+
role: 'option',
|
|
257
|
+
onClick: function () {
|
|
258
|
+
var _a;
|
|
259
|
+
setSelectedValue(option.value);
|
|
260
|
+
(_a = userOnChange.current) === null || _a === void 0 ? void 0 : _a.call(userOnChange, option.value);
|
|
261
|
+
setIsOpen(false);
|
|
231
262
|
},
|
|
232
263
|
});
|
|
233
264
|
}
|
|
@@ -237,8 +268,10 @@ var ComboBox = function (props) {
|
|
|
237
268
|
filteredOptions,
|
|
238
269
|
emptyStateMessage,
|
|
239
270
|
options,
|
|
240
|
-
|
|
271
|
+
getOptionId,
|
|
241
272
|
selectedValue,
|
|
273
|
+
focusedIndex,
|
|
274
|
+
itemRenderer,
|
|
242
275
|
memoizedItems,
|
|
243
276
|
]);
|
|
244
277
|
return (react_1.default.createElement(utils_1.InputContainer, __assign({ className: className, isIconInline: true }, rest, { id: id }),
|
|
@@ -38,6 +38,12 @@ export declare type ExpandableBlockProps = {
|
|
|
38
38
|
* @default 'default'
|
|
39
39
|
*/
|
|
40
40
|
size?: 'default' | 'small';
|
|
41
|
+
/**
|
|
42
|
+
* Style of the ExpandableBlock.
|
|
43
|
+
* Use 'borderless' to hide outline.
|
|
44
|
+
* @default 'default'
|
|
45
|
+
*/
|
|
46
|
+
styleType?: 'default' | 'borderless';
|
|
41
47
|
} & Omit<CommonProps, 'title'>;
|
|
42
48
|
/**
|
|
43
49
|
* Container that allows content to be hidden behind a brief title and a caption.
|
|
@@ -46,10 +46,10 @@ require("@itwin/itwinui-css/css/expandable-block.css");
|
|
|
46
46
|
*/
|
|
47
47
|
var ExpandableBlock = function (props) {
|
|
48
48
|
var _a;
|
|
49
|
-
var caption = props.caption, children = props.children, className = props.className, title = props.title, onToggle = props.onToggle, style = props.style, _b = props.isExpanded, isExpanded = _b === void 0 ? false : _b, endIcon = props.endIcon, status = props.status, _c = props.size, size = _c === void 0 ? 'default' : _c, rest = __rest(props, ["caption", "children", "className", "title", "onToggle", "style", "isExpanded", "endIcon", "status", "size"]);
|
|
49
|
+
var caption = props.caption, children = props.children, className = props.className, title = props.title, onToggle = props.onToggle, style = props.style, _b = props.isExpanded, isExpanded = _b === void 0 ? false : _b, endIcon = props.endIcon, status = props.status, _c = props.size, size = _c === void 0 ? 'default' : _c, _d = props.styleType, styleType = _d === void 0 ? 'default' : _d, rest = __rest(props, ["caption", "children", "className", "title", "onToggle", "style", "isExpanded", "endIcon", "status", "size", "styleType"]);
|
|
50
50
|
(0, utils_1.useTheme)();
|
|
51
51
|
var icon = endIcon !== null && endIcon !== void 0 ? endIcon : (status && utils_1.StatusIconMap[status]());
|
|
52
|
-
var
|
|
52
|
+
var _e = react_1.default.useState(isExpanded), expanded = _e[0], setExpanded = _e[1];
|
|
53
53
|
react_1.default.useEffect(function () {
|
|
54
54
|
setExpanded(isExpanded);
|
|
55
55
|
}, [isExpanded]);
|
|
@@ -68,6 +68,7 @@ var ExpandableBlock = function (props) {
|
|
|
68
68
|
'iui-with-caption': !!caption,
|
|
69
69
|
'iui-expanded': expanded,
|
|
70
70
|
'iui-small': size === 'small',
|
|
71
|
+
'iui-borderless': styleType === 'borderless',
|
|
71
72
|
}, className), style: style }, rest),
|
|
72
73
|
react_1.default.createElement("div", { "aria-expanded": expanded, className: 'iui-header', tabIndex: 0, onClick: handleToggle, onKeyDown: onKeyDown },
|
|
73
74
|
react_1.default.createElement(ChevronRight_1.default, { className: 'iui-icon', "aria-hidden": true }),
|
package/cjs/core/Menu/Menu.js
CHANGED
|
@@ -43,6 +43,9 @@ exports.Menu = react_1.default.forwardRef(function (props, ref) {
|
|
|
43
43
|
var _c = react_1.default.useState(), focusedIndex = _c[0], setFocusedIndex = _c[1];
|
|
44
44
|
var menuRef = react_1.default.useRef(null);
|
|
45
45
|
var refs = (0, utils_1.useMergedRefs)(menuRef, ref);
|
|
46
|
+
react_1.default.useEffect(function () {
|
|
47
|
+
setFocusedIndex(null);
|
|
48
|
+
}, [children]);
|
|
46
49
|
react_1.default.useEffect(function () {
|
|
47
50
|
var _a;
|
|
48
51
|
var items = (0, utils_1.getFocusableElements)(menuRef.current);
|
|
@@ -55,9 +58,6 @@ exports.Menu = react_1.default.forwardRef(function (props, ref) {
|
|
|
55
58
|
setFocusedIndex(selectedIndex > -1 ? selectedIndex : 0);
|
|
56
59
|
}
|
|
57
60
|
}, [setFocus, focusedIndex]);
|
|
58
|
-
react_1.default.useEffect(function () {
|
|
59
|
-
setFocusedIndex(null);
|
|
60
|
-
}, [children]);
|
|
61
61
|
var onKeyDown = function (event) {
|
|
62
62
|
var items = (0, utils_1.getFocusableElements)(menuRef.current);
|
|
63
63
|
if (!(items === null || items === void 0 ? void 0 : items.length)) {
|
|
@@ -11,10 +11,16 @@ export declare type RadioProps = {
|
|
|
11
11
|
status?: 'positive' | 'warning' | 'negative';
|
|
12
12
|
/**
|
|
13
13
|
* Custom CSS class name for the checkmark element.
|
|
14
|
+
*
|
|
15
|
+
* @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
|
|
16
|
+
* The checkmark has been moved into a pseudo-element.
|
|
14
17
|
*/
|
|
15
18
|
checkmarkClassName?: string;
|
|
16
19
|
/**
|
|
17
20
|
* Custom CSS Style for the checkmark element.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
|
|
23
|
+
* The checkmark has been moved into a pseudo-element.
|
|
18
24
|
*/
|
|
19
25
|
checkmarkStyle?: React.CSSProperties;
|
|
20
26
|
/**
|
|
@@ -26,6 +32,7 @@ export declare type RadioProps = {
|
|
|
26
32
|
/**
|
|
27
33
|
* Basic radio input component
|
|
28
34
|
* @example
|
|
35
|
+
* <Radio />
|
|
29
36
|
* <Radio label='Radio' />
|
|
30
37
|
* <Radio disabled={true} label='Radio' />
|
|
31
38
|
* <Radio status='positive' label='Positive' />
|
|
@@ -43,10 +50,16 @@ export declare const Radio: React.ForwardRefExoticComponent<{
|
|
|
43
50
|
status?: "positive" | "warning" | "negative" | undefined;
|
|
44
51
|
/**
|
|
45
52
|
* Custom CSS class name for the checkmark element.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
|
|
55
|
+
* The checkmark has been moved into a pseudo-element.
|
|
46
56
|
*/
|
|
47
57
|
checkmarkClassName?: string | undefined;
|
|
48
58
|
/**
|
|
49
59
|
* Custom CSS Style for the checkmark element.
|
|
60
|
+
*
|
|
61
|
+
* @deprecated As of 1.32.0, this is applied on the actual radio `<input>` element.
|
|
62
|
+
* The checkmark has been moved into a pseudo-element.
|
|
50
63
|
*/
|
|
51
64
|
checkmarkStyle?: React.CSSProperties | undefined;
|
|
52
65
|
/**
|
package/cjs/core/Radio/Radio.js
CHANGED
|
@@ -37,6 +37,7 @@ require("@itwin/itwinui-css/css/inputs.css");
|
|
|
37
37
|
/**
|
|
38
38
|
* Basic radio input component
|
|
39
39
|
* @example
|
|
40
|
+
* <Radio />
|
|
40
41
|
* <Radio label='Radio' />
|
|
41
42
|
* <Radio disabled={true} label='Radio' />
|
|
42
43
|
* <Radio status='positive' label='Positive' />
|
|
@@ -44,8 +45,8 @@ require("@itwin/itwinui-css/css/inputs.css");
|
|
|
44
45
|
* <Radio status='negative' label='Negative' />
|
|
45
46
|
*/
|
|
46
47
|
exports.Radio = react_1.default.forwardRef(function (props, ref) {
|
|
47
|
-
var _a;
|
|
48
|
-
var className = props.className,
|
|
48
|
+
var _a, _b;
|
|
49
|
+
var className = props.className, _c = props.disabled, disabled = _c === void 0 ? false : _c, label = props.label, status = props.status, style = props.style, checkmarkClassName = props.checkmarkClassName, checkmarkStyle = props.checkmarkStyle, _d = props.setFocus, setFocus = _d === void 0 ? false : _d, rest = __rest(props, ["className", "disabled", "label", "status", "style", "checkmarkClassName", "checkmarkStyle", "setFocus"]);
|
|
49
50
|
(0, utils_1.useTheme)();
|
|
50
51
|
var inputElementRef = react_1.default.useRef(null);
|
|
51
52
|
var refs = (0, utils_1.useMergedRefs)(inputElementRef, ref);
|
|
@@ -54,11 +55,9 @@ exports.Radio = react_1.default.forwardRef(function (props, ref) {
|
|
|
54
55
|
inputElementRef.current.focus();
|
|
55
56
|
}
|
|
56
57
|
}, [setFocus]);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
react_1.default.createElement("circle", { cx: '8', cy: '8', r: '4' }))),
|
|
62
|
-
label && react_1.default.createElement("span", { className: 'iui-label' }, label)));
|
|
58
|
+
var radio = (react_1.default.createElement("input", __assign({ className: (0, classnames_1.default)('iui-radio', className && (_a = {}, _a[className] = !label, _a), checkmarkClassName), style: __assign(__assign({}, (!label && style)), checkmarkStyle), disabled: disabled, type: 'radio', ref: refs }, rest)));
|
|
59
|
+
return !label ? (radio) : (react_1.default.createElement("label", { className: (0, classnames_1.default)('iui-radio-wrapper', (_b = { 'iui-disabled': disabled }, _b["iui-" + status] = !!status, _b), className), style: style },
|
|
60
|
+
radio,
|
|
61
|
+
label && react_1.default.createElement("span", { className: 'iui-radio-label' }, label)));
|
|
63
62
|
});
|
|
64
63
|
exports.default = exports.Radio;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from '../utils';
|
|
3
|
+
import '@itwin/itwinui-css/css/tree.css';
|
|
4
|
+
export declare type NodeData<T> = {
|
|
5
|
+
/**
|
|
6
|
+
* Array of the child nodes contained in the node.
|
|
7
|
+
*/
|
|
8
|
+
subNodes?: Array<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Unique id of the node.
|
|
11
|
+
*/
|
|
12
|
+
nodeId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Custom type used to map type `T` to `NodeData`
|
|
15
|
+
*/
|
|
16
|
+
node: T;
|
|
17
|
+
/**
|
|
18
|
+
* Flag whether the node is expanded.
|
|
19
|
+
*/
|
|
20
|
+
isExpanded?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Flag whether the node is disabled.
|
|
23
|
+
*/
|
|
24
|
+
isDisabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Flag whether the node is selected.
|
|
27
|
+
*/
|
|
28
|
+
isSelected?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Flag whether the node has sub-nodes.
|
|
31
|
+
* Used to determine if node should be expandable.
|
|
32
|
+
*/
|
|
33
|
+
hasSubNodes: boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare type NodeRenderProps<T> = Omit<NodeData<T>, 'subNodes'>;
|
|
36
|
+
export declare type TreeProps<T> = {
|
|
37
|
+
/**
|
|
38
|
+
* Render function that should return the node element.
|
|
39
|
+
* Recommended to use `TreeNode` component.
|
|
40
|
+
* Must be memoized.
|
|
41
|
+
* @example
|
|
42
|
+
* const nodeRenderer = React.useCallback(({ node, ...rest }: NodeRenderProps<DataType>) => (
|
|
43
|
+
* <TreeNode
|
|
44
|
+
* label={node.label}
|
|
45
|
+
* onNodeExpanded={onNodeExpanded}
|
|
46
|
+
* {...rest}
|
|
47
|
+
* />
|
|
48
|
+
* ), [onNodeExpanded])
|
|
49
|
+
*/
|
|
50
|
+
nodeRenderer: (props: NodeRenderProps<T>) => JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* Array of custom data used for `TreeNodes` inside `Tree`.
|
|
53
|
+
*/
|
|
54
|
+
data: T[];
|
|
55
|
+
/**
|
|
56
|
+
* Function that maps your `data` entry to `NodeData` that has all info about the node state.
|
|
57
|
+
* It will be used to render a tree node in `nodeRenderer`.
|
|
58
|
+
* Must be memoized.
|
|
59
|
+
* @example
|
|
60
|
+
* const getNode = React.useCallback((node: DemoData): NodeData<DemoData> => {
|
|
61
|
+
* return {
|
|
62
|
+
* subNodes: node.subItems,
|
|
63
|
+
* nodeId: node.id,
|
|
64
|
+
* node,
|
|
65
|
+
* isExpanded: expandedNodes[node.id],
|
|
66
|
+
* hasSubNodes: node.subItems.length > 0,
|
|
67
|
+
* };
|
|
68
|
+
* }, [expandedNodes]);
|
|
69
|
+
*/
|
|
70
|
+
getNode: (node: T) => NodeData<T>;
|
|
71
|
+
} & Omit<CommonProps, 'title'>;
|
|
72
|
+
/**
|
|
73
|
+
* Tree component used to display a hierarchical structure of `TreeNodes`.
|
|
74
|
+
* User should control state of expanded, selected and disabled nodes using `getNode` prop.
|
|
75
|
+
* @example
|
|
76
|
+
type DemoData = {
|
|
77
|
+
id: string;
|
|
78
|
+
label: string;
|
|
79
|
+
subItems: DemoData[];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const data: Array<DemoData> = [
|
|
83
|
+
{
|
|
84
|
+
id: 'Node-1',
|
|
85
|
+
label: 'Facility 1',
|
|
86
|
+
subItems: [{ id: 'Node-1-1', label: 'Unit 1', subItems: [] }],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'Node-2',
|
|
90
|
+
label: 'Facility 2',
|
|
91
|
+
subItems: [{ id: 'Node-2-1', label: 'Unit 2', subItems: [] }],
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const [expandedNodes, setExpandedNodes] = React.useState<Record<string, boolean>>({});
|
|
96
|
+
const onNodeExpanded = React.useCallback((nodeId: string, isExpanded: boolean) => {
|
|
97
|
+
setExpandedNodes((oldExpanded) => ({ ...oldExpanded, [nodeId]: isExpanded }));
|
|
98
|
+
}, []);
|
|
99
|
+
|
|
100
|
+
const getNode = React.useCallback((node: DemoData): NodeData<DemoData> => {
|
|
101
|
+
return {
|
|
102
|
+
subNodes: node.subItems,
|
|
103
|
+
nodeId: node.id,
|
|
104
|
+
node,
|
|
105
|
+
isExpanded: expandedNodes[node.id],
|
|
106
|
+
hasSubNodes: node.subItems.length > 0,
|
|
107
|
+
};
|
|
108
|
+
}, [expandedNodes]);
|
|
109
|
+
|
|
110
|
+
<Tree<DemoData>
|
|
111
|
+
data={data}
|
|
112
|
+
getNode={getNode}
|
|
113
|
+
nodeRenderer={React.useCallback(({ node, ...rest }) => (
|
|
114
|
+
<TreeNode
|
|
115
|
+
label={node.label}
|
|
116
|
+
onNodeExpanded={onNodeExpanded}
|
|
117
|
+
{...rest}
|
|
118
|
+
/>
|
|
119
|
+
), [onNodeExpanded])}
|
|
120
|
+
/>
|
|
121
|
+
*/
|
|
122
|
+
export declare const Tree: <T>(props: TreeProps<T>) => JSX.Element;
|
|
123
|
+
export default Tree;
|