@jetbrains/ring-ui 5.0.157 → 5.0.159
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/components/control-label/control-label.css +1 -1
- package/components/control-label/control-label.d.ts +1 -1
- package/components/control-label/control-label.js +2 -2
- package/components/list/consts.js +3 -0
- package/components/select/select.d.ts +1 -0
- package/components/select/select.js +5 -2
- package/components/select/select__popup.d.ts +36 -0
- package/components/select/select__popup.js +7 -1
- package/dist/_helpers/control-label.js +1 -1
- package/dist/control-label/control-label.d.ts +1 -1
- package/dist/control-label/control-label.js +2 -2
- package/dist/list/consts.js +3 -0
- package/dist/select/select.d.ts +1 -0
- package/dist/select/select.js +6 -2
- package/dist/select/select__popup.d.ts +36 -0
- package/dist/select/select__popup.js +10 -1
- package/dist/style.css +1 -1
- package/package.json +14 -14
|
@@ -5,11 +5,11 @@ import styles from './control-label.css';
|
|
|
5
5
|
export var LabelType;
|
|
6
6
|
(function (LabelType) {
|
|
7
7
|
LabelType["SECONDARY"] = "secondary";
|
|
8
|
-
LabelType["
|
|
8
|
+
LabelType["FORM"] = "form";
|
|
9
9
|
})(LabelType || (LabelType = {}));
|
|
10
10
|
const classNameByType = {
|
|
11
11
|
[LabelType.SECONDARY]: styles.secondaryLabel,
|
|
12
|
-
[LabelType.
|
|
12
|
+
[LabelType.FORM]: styles.formLabel
|
|
13
13
|
};
|
|
14
14
|
export const ControlLabel = ({ children, type = LabelType.SECONDARY, disabled, ...rest }) => (<label className={classNames(styles.label, classNameByType[type], {
|
|
15
15
|
[styles.disabledLabel]: disabled
|
|
@@ -11,16 +11,19 @@ export var Type;
|
|
|
11
11
|
Type[Type["TITLE"] = 5] = "TITLE";
|
|
12
12
|
Type[Type["MARGIN"] = 6] = "MARGIN";
|
|
13
13
|
})(Type || (Type = {}));
|
|
14
|
+
// TODO refactor to plain object in 6.0
|
|
14
15
|
export var Dimension;
|
|
15
16
|
(function (Dimension) {
|
|
16
17
|
Dimension[Dimension["ITEM_PADDING"] = 16] = "ITEM_PADDING";
|
|
17
18
|
Dimension[Dimension["ITEM_HEIGHT"] = 32] = "ITEM_HEIGHT";
|
|
18
19
|
Dimension[Dimension["COMPACT_ITEM_HEIGHT"] = 24] = "COMPACT_ITEM_HEIGHT";
|
|
19
20
|
Dimension[Dimension["SEPARATOR_HEIGHT"] = 25] = "SEPARATOR_HEIGHT";
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
20
22
|
Dimension[Dimension["SEPARATOR_FIRST_HEIGHT"] = 16] = "SEPARATOR_FIRST_HEIGHT";
|
|
21
23
|
Dimension[Dimension["SEPARATOR_TEXT_HEIGHT"] = 18] = "SEPARATOR_TEXT_HEIGHT";
|
|
22
24
|
Dimension[Dimension["TITLE_HEIGHT"] = 42] = "TITLE_HEIGHT";
|
|
23
25
|
Dimension[Dimension["INNER_PADDING"] = 8] = "INNER_PADDING";
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
24
27
|
Dimension[Dimension["MARGIN"] = 8] = "MARGIN";
|
|
25
28
|
})(Dimension || (Dimension = {}));
|
|
26
29
|
export const DEFAULT_ITEM_TYPE = Type.ITEM;
|
|
@@ -584,8 +584,11 @@ export default class Select extends Component {
|
|
|
584
584
|
selected.isResetItem) {
|
|
585
585
|
return;
|
|
586
586
|
}
|
|
587
|
+
const tryKeepOpen = this.props.tryKeepOpen ?? opts.tryKeepOpen;
|
|
587
588
|
if (!this.props.multiple) {
|
|
588
|
-
|
|
589
|
+
if (!tryKeepOpen) {
|
|
590
|
+
this._hidePopup(isSelectItemEvent);
|
|
591
|
+
}
|
|
589
592
|
this.setState({
|
|
590
593
|
selected,
|
|
591
594
|
selectedIndex: this._getSelectedIndex(selected, this.props.data)
|
|
@@ -600,7 +603,6 @@ export default class Select extends Component {
|
|
|
600
603
|
});
|
|
601
604
|
}
|
|
602
605
|
else {
|
|
603
|
-
const { tryKeepOpen } = opts;
|
|
604
606
|
if (!tryKeepOpen) {
|
|
605
607
|
this._hidePopup(isSelectItemEvent);
|
|
606
608
|
}
|
|
@@ -933,6 +935,7 @@ Select.propTypes = {
|
|
|
933
935
|
clear: PropTypes.bool,
|
|
934
936
|
hideArrow: PropTypes.bool,
|
|
935
937
|
showPopup: PropTypes.bool,
|
|
938
|
+
tryKeepOpen: PropTypes.bool,
|
|
936
939
|
compact: PropTypes.bool,
|
|
937
940
|
size: PropTypes.oneOf(Object.values(Size)),
|
|
938
941
|
customAnchor: PropTypes.func,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @description Displays a popup with select's options.
|
|
3
3
|
*/
|
|
4
4
|
import React, { CSSProperties, PureComponent, ReactNode, SyntheticEvent } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import { IconType } from '../icon/icon';
|
|
6
7
|
import Popup from '../popup/popup';
|
|
7
8
|
import { Directions } from '../popup/position';
|
|
@@ -9,6 +10,7 @@ import List, { SelectHandlerParams } from '../list/list';
|
|
|
9
10
|
import Caret from '../caret/caret';
|
|
10
11
|
import { ListDataItem } from '../list/consts';
|
|
11
12
|
import { ShortcutsMap } from '../shortcuts/core';
|
|
13
|
+
import { TagAttrs } from '../tag/tag';
|
|
12
14
|
import { SelectItem } from './select';
|
|
13
15
|
export type FilterFn<T> = (itemToCheck: SelectItem<T>, checkString: string, data: readonly SelectItem<T>[]) => boolean;
|
|
14
16
|
export interface Filter<T = unknown> {
|
|
@@ -33,6 +35,7 @@ export interface TagsReset {
|
|
|
33
35
|
}
|
|
34
36
|
export interface Tags {
|
|
35
37
|
reset?: TagsReset | null | undefined;
|
|
38
|
+
customTagComponent?: (tag: TagAttrs) => ReactNode;
|
|
36
39
|
}
|
|
37
40
|
export interface SelectPopupProps<T = unknown> {
|
|
38
41
|
data: readonly ListDataItem<T>[];
|
|
@@ -106,6 +109,39 @@ export default class SelectPopup<T = unknown> extends PureComponent<SelectPopupP
|
|
|
106
109
|
getFilter(): React.JSX.Element | null;
|
|
107
110
|
handleRemoveTag: (arg: ListDataItem<T>) => (event: SyntheticEvent) => void;
|
|
108
111
|
handleTagClick: (arg: ListDataItem<T>) => () => void;
|
|
112
|
+
getCustomTag(tags: Tags | boolean | null): ((tag: Pick<Pick<import("../tag/tag").TagProps, keyof import("../tag/tag").TagProps> & Pick<PropTypes.InferProps<{
|
|
113
|
+
onRemove: PropTypes.Requireable<(...args: any[]) => any>;
|
|
114
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
115
|
+
rgTagIcon: PropTypes.Requireable<NonNullable<PropTypes.ReactComponentLike | null | undefined>>;
|
|
116
|
+
icon: PropTypes.Requireable<string>;
|
|
117
|
+
avatar: PropTypes.Requireable<string>;
|
|
118
|
+
rgTagTitle: PropTypes.Requireable<string>;
|
|
119
|
+
readOnly: PropTypes.Requireable<boolean>;
|
|
120
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
121
|
+
focused: PropTypes.Requireable<boolean>;
|
|
122
|
+
angled: PropTypes.Requireable<boolean>;
|
|
123
|
+
backgroundColor: PropTypes.Requireable<string>;
|
|
124
|
+
textColor: PropTypes.Requireable<string>;
|
|
125
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
126
|
+
className: PropTypes.Requireable<string>;
|
|
127
|
+
render: PropTypes.Requireable<(...args: any[]) => any>;
|
|
128
|
+
}>, never> & Pick<import("../tag/tag").TagProps, never>, never> & {
|
|
129
|
+
className?: string | null | undefined;
|
|
130
|
+
children?: React.ReactNode;
|
|
131
|
+
onClick?: ((event: React.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
|
|
132
|
+
icon?: string | undefined;
|
|
133
|
+
disabled?: boolean | undefined;
|
|
134
|
+
avatar?: string | null | undefined;
|
|
135
|
+
readOnly?: boolean | undefined;
|
|
136
|
+
focused?: boolean | undefined;
|
|
137
|
+
render?: ((props: import("../tag/tag").TagRenderProps) => React.ReactNode) | undefined;
|
|
138
|
+
onRemove?: ((event: React.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
|
|
139
|
+
rgTagIcon?: string | IconType | null | undefined;
|
|
140
|
+
rgTagTitle?: string | undefined;
|
|
141
|
+
angled?: boolean | null | undefined;
|
|
142
|
+
textColor?: string | undefined;
|
|
143
|
+
backgroundColor?: string | undefined;
|
|
144
|
+
} & {}) => React.ReactNode) | undefined;
|
|
109
145
|
getTags(): false | React.JSX.Element;
|
|
110
146
|
getFilterWithTags(): React.JSX.Element | null;
|
|
111
147
|
getBottomLine(): "" | React.JSX.Element | null;
|
|
@@ -196,9 +196,15 @@ export default class SelectPopup extends PureComponent {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
|
+
getCustomTag(tags) {
|
|
200
|
+
if (tags !== null && typeof tags !== 'boolean') {
|
|
201
|
+
return tags.customTagComponent;
|
|
202
|
+
}
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
199
205
|
getTags() {
|
|
200
206
|
return Array.isArray(this.props.selected) && (<div>
|
|
201
|
-
<TagsList tags={this.props.selected} activeIndex={this.state.tagsActiveIndex} handleRemove={this.handleRemoveTag} handleClick={this.handleTagClick} disabled={this.props.disabled}/>
|
|
207
|
+
<TagsList tags={this.props.selected} activeIndex={this.state.tagsActiveIndex} handleRemove={this.handleRemoveTag} handleClick={this.handleTagClick} disabled={this.props.disabled} customTagComponent={this.getCustomTag(this.props.tags)}/>
|
|
202
208
|
</div>);
|
|
203
209
|
}
|
|
204
210
|
getFilterWithTags() {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var modules_9eb96a10 = {"label":"label_rui_40a4","
|
|
1
|
+
var modules_9eb96a10 = {"label":"label_rui_40a4","formLabel":"formLabel_rui_40a4","secondaryLabel":"secondaryLabel_rui_40a4","disabledLabel":"disabledLabel_rui_40a4"};
|
|
2
2
|
|
|
3
3
|
export { modules_9eb96a10 as m };
|
|
@@ -9,9 +9,9 @@ var _classNameByType;
|
|
|
9
9
|
var LabelType;
|
|
10
10
|
(function (LabelType) {
|
|
11
11
|
LabelType["SECONDARY"] = "secondary";
|
|
12
|
-
LabelType["
|
|
12
|
+
LabelType["FORM"] = "form";
|
|
13
13
|
})(LabelType || (LabelType = {}));
|
|
14
|
-
var classNameByType = (_classNameByType = {}, _defineProperty(_classNameByType, LabelType.SECONDARY, modules_9eb96a10.secondaryLabel), _defineProperty(_classNameByType, LabelType.
|
|
14
|
+
var classNameByType = (_classNameByType = {}, _defineProperty(_classNameByType, LabelType.SECONDARY, modules_9eb96a10.secondaryLabel), _defineProperty(_classNameByType, LabelType.FORM, modules_9eb96a10.formLabel), _classNameByType);
|
|
15
15
|
var ControlLabel = function ControlLabel(_ref) {
|
|
16
16
|
var children = _ref.children,
|
|
17
17
|
_ref$type = _ref.type,
|
package/dist/list/consts.js
CHANGED
|
@@ -11,16 +11,19 @@ var Type;
|
|
|
11
11
|
Type[Type["TITLE"] = 5] = "TITLE";
|
|
12
12
|
Type[Type["MARGIN"] = 6] = "MARGIN";
|
|
13
13
|
})(Type || (Type = {}));
|
|
14
|
+
// TODO refactor to plain object in 6.0
|
|
14
15
|
var Dimension;
|
|
15
16
|
(function (Dimension) {
|
|
16
17
|
Dimension[Dimension["ITEM_PADDING"] = 16] = "ITEM_PADDING";
|
|
17
18
|
Dimension[Dimension["ITEM_HEIGHT"] = 32] = "ITEM_HEIGHT";
|
|
18
19
|
Dimension[Dimension["COMPACT_ITEM_HEIGHT"] = 24] = "COMPACT_ITEM_HEIGHT";
|
|
19
20
|
Dimension[Dimension["SEPARATOR_HEIGHT"] = 25] = "SEPARATOR_HEIGHT";
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
20
22
|
Dimension[Dimension["SEPARATOR_FIRST_HEIGHT"] = 16] = "SEPARATOR_FIRST_HEIGHT";
|
|
21
23
|
Dimension[Dimension["SEPARATOR_TEXT_HEIGHT"] = 18] = "SEPARATOR_TEXT_HEIGHT";
|
|
22
24
|
Dimension[Dimension["TITLE_HEIGHT"] = 42] = "TITLE_HEIGHT";
|
|
23
25
|
Dimension[Dimension["INNER_PADDING"] = 8] = "INNER_PADDING";
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
24
27
|
Dimension[Dimension["MARGIN"] = 8] = "MARGIN";
|
|
25
28
|
})(Dimension || (Dimension = {}));
|
|
26
29
|
var DEFAULT_ITEM_TYPE = Type.ITEM;
|
package/dist/select/select.d.ts
CHANGED
package/dist/select/select.js
CHANGED
|
@@ -452,6 +452,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
454
|
_defineProperty(_assertThisInitialized(_this), "_listSelectHandler", function (selected, event) {
|
|
455
|
+
var _this$props$tryKeepOp;
|
|
455
456
|
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
456
457
|
var isItem = function isItem(item) {
|
|
457
458
|
return List.isItemType(List.ListProps.Type.ITEM, item);
|
|
@@ -466,8 +467,11 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
466
467
|
if (!isItem(selected) && !isCustomItem(selected) || selected.disabled || selected.isResetItem) {
|
|
467
468
|
return;
|
|
468
469
|
}
|
|
470
|
+
var tryKeepOpen = (_this$props$tryKeepOp = _this.props.tryKeepOpen) !== null && _this$props$tryKeepOp !== void 0 ? _this$props$tryKeepOp : opts.tryKeepOpen;
|
|
469
471
|
if (!_this.props.multiple) {
|
|
470
|
-
|
|
472
|
+
if (!tryKeepOpen) {
|
|
473
|
+
_this._hidePopup(isSelectItemEvent);
|
|
474
|
+
}
|
|
471
475
|
_this.setState({
|
|
472
476
|
selected: selected,
|
|
473
477
|
selectedIndex: _this._getSelectedIndex(selected, _this.props.data)
|
|
@@ -479,7 +483,6 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
479
483
|
_this.props.onChange(selected, event);
|
|
480
484
|
});
|
|
481
485
|
} else {
|
|
482
|
-
var tryKeepOpen = opts.tryKeepOpen;
|
|
483
486
|
if (!tryKeepOpen) {
|
|
484
487
|
_this._hidePopup(isSelectItemEvent);
|
|
485
488
|
}
|
|
@@ -1262,6 +1265,7 @@ Select.propTypes = {
|
|
|
1262
1265
|
clear: PropTypes.bool,
|
|
1263
1266
|
hideArrow: PropTypes.bool,
|
|
1264
1267
|
showPopup: PropTypes.bool,
|
|
1268
|
+
tryKeepOpen: PropTypes.bool,
|
|
1265
1269
|
compact: PropTypes.bool,
|
|
1266
1270
|
size: PropTypes.oneOf(Object.values(Size)),
|
|
1267
1271
|
customAnchor: PropTypes.func,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @description Displays a popup with select's options.
|
|
3
3
|
*/
|
|
4
4
|
import React, { CSSProperties, PureComponent, ReactNode, SyntheticEvent } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import { IconType } from '../icon/icon';
|
|
6
7
|
import Popup from '../popup/popup';
|
|
7
8
|
import { Directions } from '../popup/position';
|
|
@@ -9,6 +10,7 @@ import List, { SelectHandlerParams } from '../list/list';
|
|
|
9
10
|
import Caret from '../caret/caret';
|
|
10
11
|
import { ListDataItem } from '../list/consts';
|
|
11
12
|
import { ShortcutsMap } from '../shortcuts/core';
|
|
13
|
+
import { TagAttrs } from '../tag/tag';
|
|
12
14
|
import { SelectItem } from './select';
|
|
13
15
|
export type FilterFn<T> = (itemToCheck: SelectItem<T>, checkString: string, data: readonly SelectItem<T>[]) => boolean;
|
|
14
16
|
export interface Filter<T = unknown> {
|
|
@@ -33,6 +35,7 @@ export interface TagsReset {
|
|
|
33
35
|
}
|
|
34
36
|
export interface Tags {
|
|
35
37
|
reset?: TagsReset | null | undefined;
|
|
38
|
+
customTagComponent?: (tag: TagAttrs) => ReactNode;
|
|
36
39
|
}
|
|
37
40
|
export interface SelectPopupProps<T = unknown> {
|
|
38
41
|
data: readonly ListDataItem<T>[];
|
|
@@ -106,6 +109,39 @@ export default class SelectPopup<T = unknown> extends PureComponent<SelectPopupP
|
|
|
106
109
|
getFilter(): React.JSX.Element | null;
|
|
107
110
|
handleRemoveTag: (arg: ListDataItem<T>) => (event: SyntheticEvent) => void;
|
|
108
111
|
handleTagClick: (arg: ListDataItem<T>) => () => void;
|
|
112
|
+
getCustomTag(tags: Tags | boolean | null): ((tag: Pick<Pick<import("../tag/tag").TagProps, keyof import("../tag/tag").TagProps> & Pick<PropTypes.InferProps<{
|
|
113
|
+
onRemove: PropTypes.Requireable<(...args: any[]) => any>;
|
|
114
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
115
|
+
rgTagIcon: PropTypes.Requireable<NonNullable<PropTypes.ReactComponentLike | null | undefined>>;
|
|
116
|
+
icon: PropTypes.Requireable<string>;
|
|
117
|
+
avatar: PropTypes.Requireable<string>;
|
|
118
|
+
rgTagTitle: PropTypes.Requireable<string>;
|
|
119
|
+
readOnly: PropTypes.Requireable<boolean>;
|
|
120
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
121
|
+
focused: PropTypes.Requireable<boolean>;
|
|
122
|
+
angled: PropTypes.Requireable<boolean>;
|
|
123
|
+
backgroundColor: PropTypes.Requireable<string>;
|
|
124
|
+
textColor: PropTypes.Requireable<string>;
|
|
125
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
126
|
+
className: PropTypes.Requireable<string>;
|
|
127
|
+
render: PropTypes.Requireable<(...args: any[]) => any>;
|
|
128
|
+
}>, never> & Pick<import("../tag/tag").TagProps, never>, never> & {
|
|
129
|
+
className?: string | null | undefined;
|
|
130
|
+
children?: React.ReactNode;
|
|
131
|
+
onClick?: ((event: React.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
|
|
132
|
+
icon?: string | undefined;
|
|
133
|
+
disabled?: boolean | undefined;
|
|
134
|
+
avatar?: string | null | undefined;
|
|
135
|
+
readOnly?: boolean | undefined;
|
|
136
|
+
focused?: boolean | undefined;
|
|
137
|
+
render?: ((props: import("../tag/tag").TagRenderProps) => React.ReactNode) | undefined;
|
|
138
|
+
onRemove?: ((event: React.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
|
|
139
|
+
rgTagIcon?: string | IconType | null | undefined;
|
|
140
|
+
rgTagTitle?: string | undefined;
|
|
141
|
+
angled?: boolean | null | undefined;
|
|
142
|
+
textColor?: string | undefined;
|
|
143
|
+
backgroundColor?: string | undefined;
|
|
144
|
+
} & {}) => React.ReactNode) | undefined;
|
|
109
145
|
getTags(): false | React.JSX.Element;
|
|
110
146
|
getFilterWithTags(): React.JSX.Element | null;
|
|
111
147
|
getBottomLine(): "" | React.JSX.Element | null;
|
|
@@ -416,6 +416,14 @@ var SelectPopup = /*#__PURE__*/function (_PureComponent) {
|
|
|
416
416
|
}
|
|
417
417
|
return null;
|
|
418
418
|
}
|
|
419
|
+
}, {
|
|
420
|
+
key: "getCustomTag",
|
|
421
|
+
value: function getCustomTag(tags) {
|
|
422
|
+
if (tags !== null && typeof tags !== 'boolean') {
|
|
423
|
+
return tags.customTagComponent;
|
|
424
|
+
}
|
|
425
|
+
return undefined;
|
|
426
|
+
}
|
|
419
427
|
}, {
|
|
420
428
|
key: "getTags",
|
|
421
429
|
value: function getTags() {
|
|
@@ -424,7 +432,8 @@ var SelectPopup = /*#__PURE__*/function (_PureComponent) {
|
|
|
424
432
|
activeIndex: this.state.tagsActiveIndex,
|
|
425
433
|
handleRemove: this.handleRemoveTag,
|
|
426
434
|
handleClick: this.handleTagClick,
|
|
427
|
-
disabled: this.props.disabled
|
|
435
|
+
disabled: this.props.disabled,
|
|
436
|
+
customTagComponent: this.getCustomTag(this.props.tags)
|
|
428
437
|
}));
|
|
429
438
|
}
|
|
430
439
|
}, {
|