@jetbrains/ring-ui 7.0.99 → 7.0.100
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.
|
@@ -9,8 +9,8 @@ const defaultAriaLabel = 'Dropdown menu';
|
|
|
9
9
|
function DropdownAnchorWrapper({ anchor, pinned, active, activeListItemId, listId, ...restProps }) {
|
|
10
10
|
const anchorAriaProps = {
|
|
11
11
|
...(listId ? { 'aria-haspopup': true } : {}),
|
|
12
|
-
...(activeListItemId ? { 'aria-activedescendant': activeListItemId
|
|
13
|
-
...(active ? { 'aria-expanded': true } : {}),
|
|
12
|
+
...(activeListItemId ? { 'aria-activedescendant': activeListItemId } : {}),
|
|
13
|
+
...(active ? { 'aria-expanded': true, 'aria-owns': listId } : {}),
|
|
14
14
|
};
|
|
15
15
|
const anchorProps = { active, pinned, ...restProps, ...anchorAriaProps };
|
|
16
16
|
const anchorComponentProps = { ...anchorProps, pinned: `${anchorProps.pinned}` };
|
|
@@ -39,7 +39,7 @@ const DropdownMenu = forwardRef(function DropdownMenu({ id, anchor, ariaLabel, d
|
|
|
39
39
|
id: listId,
|
|
40
40
|
ariaLabel: ariaLabel || defaultAriaLabel,
|
|
41
41
|
closeOnSelect: true,
|
|
42
|
-
activateFirstItem:
|
|
42
|
+
activateFirstItem: false,
|
|
43
43
|
data,
|
|
44
44
|
onSelect,
|
|
45
45
|
...menuProps,
|
|
@@ -97,7 +97,7 @@ export class Input extends PureComponent {
|
|
|
97
97
|
// Modifiers
|
|
98
98
|
size, multiline, borderless,
|
|
99
99
|
// Props
|
|
100
|
-
label, labelType, error, help, className, inputClassName, children, value, onClear, disabled, inputRef, onChange, enableShortcuts, id, placeholder, icon, translations, height = typeof this.context === 'function' ? this.context() : this.context, beforeInput, afterInput, autogrow, ...restProps } = this.props;
|
|
100
|
+
label, labelType, error, help, className, inputClassName, clearButtonClassName, children, value, onClear, disabled, inputRef, onChange, enableShortcuts, id, placeholder, icon, translations, height = typeof this.context === 'function' ? this.context() : this.context, beforeInput, afterInput, autogrow, ...restProps } = this.props;
|
|
101
101
|
const { empty } = this.state;
|
|
102
102
|
const clearable = !!onClear;
|
|
103
103
|
const classes = classNames(className, styles.outerContainer, size && size !== Size.AUTO && styles[`size${size}`], styles[`height${height}`], {
|
|
@@ -129,7 +129,7 @@ export class Input extends PureComponent {
|
|
|
129
129
|
{icon && <Icon glyph={icon} className={styles.icon}/>}
|
|
130
130
|
{beforeInput}
|
|
131
131
|
{multiline ? (<textarea onChange={this.handleTextareaChange} rows={1} {...commonProps} {...restProps}/>) : (<input onChange={this.handleInputChange} {...commonProps} {...restProps}/>)}
|
|
132
|
-
{clearable && !disabled && (<Button title={translations?.clear ?? translate('clear')} data-test='ring-input-clear' className={classNames(styles.clear,
|
|
132
|
+
{clearable && !disabled && (<Button title={translations?.clear ?? translate('clear')} data-test='ring-input-clear' className={classNames(styles.clear, clearButtonClassName)} icon={closeIcon} onClick={this.clear}/>)}
|
|
133
133
|
{afterInput}
|
|
134
134
|
</div>
|
|
135
135
|
{error ? (<div className={styles.errorText}>{error}</div>) : (help && <ControlHelp className={styles.helpText}>{help}</ControlHelp>)}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { PureComponent, type SyntheticEvent } from 'react';
|
|
2
2
|
import { type ListDataItemProps } from './consts';
|
|
3
|
+
/**
|
|
4
|
+
* @constructor
|
|
5
|
+
* @extends {ReactComponent}
|
|
6
|
+
*/
|
|
3
7
|
export default class ListItem<T> extends PureComponent<ListDataItemProps<T>> {
|
|
4
8
|
id: string;
|
|
5
9
|
stopBubbling: (e: SyntheticEvent) => void;
|
|
@@ -13,9 +13,6 @@ import styles from './list.css';
|
|
|
13
13
|
* @constructor
|
|
14
14
|
* @extends {ReactComponent}
|
|
15
15
|
*/
|
|
16
|
-
const RING_UNIT = 8;
|
|
17
|
-
const DEFAULT_PADDING = 8;
|
|
18
|
-
const CHECKBOX_WIDTH = 28;
|
|
19
16
|
export default class ListItem extends PureComponent {
|
|
20
17
|
id = getUID('list-item-');
|
|
21
18
|
stopBubbling = (e) => e.stopPropagation();
|
|
@@ -31,10 +28,12 @@ export default class ListItem extends PureComponent {
|
|
|
31
28
|
const classes = getListClasses(this.props);
|
|
32
29
|
const detailsClasses = classNames({
|
|
33
30
|
[styles.details]: details,
|
|
34
|
-
[styles.padded]:
|
|
31
|
+
[styles.padded]: !showCheckbox && hasLeftNodes,
|
|
35
32
|
}, detailsClassName);
|
|
33
|
+
const levelPadding = `var(--ring-unit) * ${1 + (Number(level) || 0)}`;
|
|
34
|
+
const checkboxPadding = showCheckbox ? ' + var(--ring-list-item-icon-size) + var(--ring-unit)' : '';
|
|
36
35
|
const style = {
|
|
37
|
-
paddingLeft:
|
|
36
|
+
paddingLeft: `calc(${levelPadding}${checkboxPadding})`,
|
|
38
37
|
};
|
|
39
38
|
let computedTitle;
|
|
40
39
|
if (this._isString(title)) {
|
package/components/list/list.css
CHANGED
|
@@ -74,6 +74,8 @@
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
.itemContainer {
|
|
77
|
+
--ring-list-item-icon-size: 20px;
|
|
78
|
+
|
|
77
79
|
position: relative;
|
|
78
80
|
}
|
|
79
81
|
|
|
@@ -150,7 +152,7 @@
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
.padded {
|
|
153
|
-
margin-left:
|
|
155
|
+
margin-left: calc(var(--ring-unit) + var(--ring-list-item-icon-size));
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
/* Override :last-child */
|
|
@@ -194,8 +196,8 @@
|
|
|
194
196
|
.icon {
|
|
195
197
|
display: inline-block;
|
|
196
198
|
|
|
197
|
-
width:
|
|
198
|
-
height:
|
|
199
|
+
width: var(--ring-list-item-icon-size);
|
|
200
|
+
height: var(--ring-list-item-icon-size);
|
|
199
201
|
margin-left: calc(var(--ring-unit) * 2);
|
|
200
202
|
|
|
201
203
|
background-repeat: no-repeat;
|
|
@@ -215,7 +217,7 @@
|
|
|
215
217
|
.glyph {
|
|
216
218
|
float: left;
|
|
217
219
|
|
|
218
|
-
width:
|
|
220
|
+
width: var(--ring-list-item-icon-size);
|
|
219
221
|
|
|
220
222
|
margin-right: var(--ring-unit);
|
|
221
223
|
|
|
@@ -227,7 +229,7 @@
|
|
|
227
229
|
|
|
228
230
|
top: 0;
|
|
229
231
|
|
|
230
|
-
height:
|
|
232
|
+
height: var(--ring-list-item-icon-size);
|
|
231
233
|
|
|
232
234
|
object-fit: cover;
|
|
233
235
|
object-position: center;
|
|
@@ -247,8 +249,8 @@
|
|
|
247
249
|
top: 7px;
|
|
248
250
|
left: 19px;
|
|
249
251
|
|
|
250
|
-
width:
|
|
251
|
-
height:
|
|
252
|
+
width: var(--ring-list-item-icon-size);
|
|
253
|
+
height: var(--ring-list-item-icon-size);
|
|
252
254
|
margin-right: var(--ring-unit);
|
|
253
255
|
}
|
|
254
256
|
|
package/components/list/list.js
CHANGED
|
@@ -342,7 +342,13 @@ export default class List extends Component {
|
|
|
342
342
|
else {
|
|
343
343
|
const itemId = this.getId(this.props.data[activeIndex]);
|
|
344
344
|
if (itemId) {
|
|
345
|
-
|
|
345
|
+
// scrollIntoView({container: 'nearest'}) is not yet supported in Firefox and Safari, emulating
|
|
346
|
+
const itemElement = document.getElementById(itemId);
|
|
347
|
+
const scrollerElement = this.inner;
|
|
348
|
+
if (itemElement && scrollerElement) {
|
|
349
|
+
scrollerElement.scrollTop =
|
|
350
|
+
itemElement.offsetTop + itemElement.clientHeight / 2 - scrollerElement.clientHeight / 2;
|
|
351
|
+
}
|
|
346
352
|
}
|
|
347
353
|
}
|
|
348
354
|
};
|