@jetbrains/ring-ui 5.0.32 → 5.0.33

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.
@@ -124,3 +124,11 @@
124
124
  font-size: 24px;
125
125
  line-height: 28px;
126
126
  }
127
+
128
+ .dense .header {
129
+ padding-top: calc(unit * 2);
130
+ }
131
+
132
+ .dense .panel {
133
+ padding-bottom: calc(unit * 2);
134
+ }
@@ -15,6 +15,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
15
15
  contentClassName?: string | null | undefined;
16
16
  portalTarget?: Element | null | undefined;
17
17
  'data-test'?: string | null | undefined;
18
+ dense?: boolean | null | undefined;
18
19
  }
19
20
  /**
20
21
  * @name Dialog
@@ -100,7 +100,7 @@ export default class Dialog extends PureComponent {
100
100
  this.dialog = tabTrap && tabTrap.node;
101
101
  };
102
102
  render() {
103
- const { show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick, children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside, portalTarget, label, closeButtonTitle, ...restProps } = this.props;
103
+ const { show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick, children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside, portalTarget, label, closeButtonTitle, dense, ...restProps } = this.props;
104
104
  const classes = classNames(styles.container, className);
105
105
  const shortcutsMap = this.getShortcutsMap();
106
106
  return show && createPortal(<PopupTarget id={this.uid} className={styles.popupTarget}>
@@ -110,7 +110,7 @@ export default class Dialog extends PureComponent {
110
110
  // click handler is duplicated in close button
111
111
  role="presentation" className={styles.clickableOverlay} onClick={this.handleClick}/>)}
112
112
  <div className={styles.innerContainer}>
113
- <AdaptiveIsland className={classNames(styles.content, contentClassName)} data-test="ring-dialog" role="dialog" aria-label={label}>
113
+ <AdaptiveIsland className={classNames(styles.content, contentClassName, { [styles.dense]: dense })} data-test="ring-dialog" role="dialog" aria-label={label}>
114
114
  {children}
115
115
  {showCloseButton &&
116
116
  (<Button icon={closeIcon} data-test="ring-dialog-close-button" className={classNames(styles.closeButton, {
@@ -1,29 +1,19 @@
1
1
  @import "../global/variables.css";
2
2
 
3
+ @value unit from "../global/global.css";
3
4
  @value outerContainer, container, input from "../input/input.css";
4
5
 
5
6
  .tagsInput {
6
- padding-top: 2px;
7
- padding-bottom: 2px;
7
+ --ring-input-icon-offset: calc(unit * 2.5);
8
+ --ring-input-padding-inline: 3px;
8
9
 
9
- white-space: normal;
10
- }
11
-
12
- .tagsInputLegacyMode {
13
- padding-top: 0;
14
- padding-bottom: 1px;
15
-
16
- border: 1px solid var(--ring-borders-color);
17
- background-color: var(--ring-content-background-color);
18
-
19
- & .tagsList {
20
- padding-top: 1px;
10
+ box-sizing: border-box;
21
11
 
22
- line-height: 20px;
23
- }
12
+ font-size: var(--ring-font-size);
13
+ line-height: var(--ring-line-height);
24
14
 
25
- & .tag {
26
- margin-right: 2px;
15
+ & * {
16
+ box-sizing: border-box;
27
17
  }
28
18
  }
29
19
 
@@ -35,10 +25,6 @@
35
25
  & .input {
36
26
  background-color: transparent;
37
27
  }
38
-
39
- & .underline {
40
- border-bottom-style: dashed;
41
- }
42
28
  }
43
29
 
44
30
  .tagsInputFocused {
@@ -46,16 +32,41 @@
46
32
  }
47
33
 
48
34
  .tagsList {
49
- display: inline-block;
50
-
51
- box-sizing: border-box;
35
+ --ring-input-padding-start: var(--ring-input-padding-inline);
36
+ --ring-input-padding-end: var(--ring-input-padding-inline);
52
37
 
53
38
  width: 100%;
54
- margin-bottom: -1px;
55
39
 
56
- padding-left: 2px;
40
+ margin: 0;
41
+ padding-top: var(--ring-input-padding-block);
42
+ padding-right: var(--ring-input-padding-end);
43
+ padding-bottom: var(--ring-input-padding-block);
44
+ padding-left: var(--ring-input-padding-start);
45
+
46
+ cursor: text;
47
+
48
+ transition: border-color var(--ring-ease);
49
+
50
+ color: var(--ring-text-color);
51
+ border: 1px solid var(--ring-borders-color);
52
+ border-radius: var(--ring-border-radius);
53
+ outline: none;
54
+ background: transparent;
55
+
56
+ font: inherit;
57
+
58
+ caret-color: var(--ring-main-color);
59
+
60
+ @nest [dir=rtl] & {
61
+ padding-right: var(--ring-input-padding-start);
62
+ padding-left: var(--ring-input-padding-end);
63
+ }
64
+
65
+ &:hover {
66
+ transition: none;
57
67
 
58
- line-height: 22px;
68
+ border-color: var(--ring-border-hover-color);
69
+ }
59
70
  }
60
71
 
61
72
  .tagsSelect {
@@ -69,24 +80,3 @@
69
80
  line-height: calc(var(--ring-line-height) - 2px);
70
81
  }
71
82
  }
72
-
73
- .underline {
74
- height: 1px;
75
-
76
- border-bottom: var(--ring-borders-color) 1px solid;
77
- }
78
-
79
- .focusUnderline {
80
- width: 0;
81
- height: 2px;
82
-
83
- margin-top: -1px;
84
-
85
- transition: width 0.15s ease-out;
86
-
87
- background: var(--ring-main-color);
88
-
89
- @nest .tagsInputFocused & {
90
- width: 100%;
91
- }
92
- }
@@ -1,8 +1,10 @@
1
- import React, { Component, PureComponent, SyntheticEvent } from 'react';
1
+ import React, { Component, PureComponent, SyntheticEvent, ReactNode } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Select, { SelectItem } from '../select/select';
4
4
  import { TagType } from '../tags-list/tags-list';
5
5
  import Caret from '../caret/caret';
6
+ import { Size } from '../input/input';
7
+ import { ControlsHeight } from '../global/controls-height';
6
8
  import { Filter } from '../select/select__popup';
7
9
  declare function noop(): void;
8
10
  export interface ToggleTagParams {
@@ -22,7 +24,6 @@ export interface TagsInputProps {
22
24
  disabled: boolean;
23
25
  autoOpen: boolean;
24
26
  renderOptimization: boolean;
25
- legacyMode: boolean;
26
27
  allowAddNewTags: boolean;
27
28
  filter: boolean | Filter;
28
29
  placeholder: string;
@@ -30,6 +31,9 @@ export interface TagsInputProps {
30
31
  tags?: readonly TagType[] | null | undefined;
31
32
  loadingMessage?: string | undefined;
32
33
  notFoundMessage?: string | undefined;
34
+ size: Size;
35
+ height?: ControlsHeight | undefined;
36
+ label?: ReactNode;
33
37
  }
34
38
  interface TagsInputState {
35
39
  tags: TagType[];
@@ -61,7 +65,6 @@ export default class TagsInput extends PureComponent<TagsInputProps, TagsInputSt
61
65
  disabled: PropTypes.Requireable<boolean>;
62
66
  autoOpen: PropTypes.Requireable<boolean>;
63
67
  renderOptimization: PropTypes.Requireable<boolean>;
64
- legacyMode: PropTypes.Requireable<boolean>;
65
68
  filter: PropTypes.Requireable<NonNullable<boolean | PropTypes.InferProps<{
66
69
  fn: PropTypes.Requireable<(...args: any[]) => any>;
67
70
  }> | null | undefined>>;
@@ -80,12 +83,12 @@ export default class TagsInput extends PureComponent<TagsInputProps, TagsInputSt
80
83
  disabled: boolean;
81
84
  autoOpen: boolean;
82
85
  renderOptimization: boolean;
83
- legacyMode: boolean;
84
86
  allowAddNewTags: boolean;
85
87
  filter: {
86
88
  fn: () => boolean;
87
89
  };
88
90
  placeholder: string;
91
+ size: Size;
89
92
  };
90
93
  constructor(props: TagsInputProps);
91
94
  state: TagsInputState;
@@ -95,6 +98,8 @@ export default class TagsInput extends PureComponent<TagsInputProps, TagsInputSt
95
98
  componentDidMount(): void;
96
99
  static ngModelStateField: string;
97
100
  ngModelStateField: string;
101
+ static contextType: React.Context<ControlsHeight>;
102
+ id: string;
98
103
  node?: HTMLElement | null;
99
104
  nodeRef: (node: HTMLElement | null) => void;
100
105
  input?: HTMLInputElement | null;
@@ -7,6 +7,10 @@ import TagsList from '../tags-list/tags-list';
7
7
  import Caret from '../caret/caret';
8
8
  import memoize from '../global/memoize';
9
9
  import rerenderHOC from '../global/rerender-hoc';
10
+ import { Size } from '../input/input';
11
+ import { ControlsHeightContext } from '../global/controls-height';
12
+ import getUID from '../global/get-uid';
13
+ import inputStyles from '../input/input.css';
10
14
  import styles from './tags-input.css';
11
15
  function noop() { }
12
16
  /**
@@ -34,7 +38,6 @@ export default class TagsInput extends PureComponent {
34
38
  disabled: PropTypes.bool,
35
39
  autoOpen: PropTypes.bool,
36
40
  renderOptimization: PropTypes.bool,
37
- legacyMode: PropTypes.bool,
38
41
  filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({ fn: PropTypes.func })]),
39
42
  loadingMessage: PropTypes.string,
40
43
  notFoundMessage: PropTypes.string,
@@ -51,10 +54,10 @@ export default class TagsInput extends PureComponent {
51
54
  disabled: false,
52
55
  autoOpen: false,
53
56
  renderOptimization: true,
54
- legacyMode: false,
55
57
  allowAddNewTags: false,
56
58
  filter: { fn: () => true },
57
- placeholder: 'Select an option'
59
+ placeholder: 'Select an option',
60
+ size: Size.M
58
61
  };
59
62
  constructor(props) {
60
63
  super(props);
@@ -85,6 +88,8 @@ export default class TagsInput extends PureComponent {
85
88
  }
86
89
  static ngModelStateField = 'tags';
87
90
  ngModelStateField;
91
+ static contextType = ControlsHeightContext;
92
+ id = getUID('ring-tags-list-');
88
93
  node;
89
94
  nodeRef = (node) => {
90
95
  this.node = node;
@@ -244,21 +249,21 @@ export default class TagsInput extends PureComponent {
244
249
  };
245
250
  render() {
246
251
  const { focused, tags, activeIndex } = this.state;
247
- const { legacyMode, disabled, canNotBeEmpty, allowAddNewTags, filter } = this.props;
248
- const classes = classNames(styles.tagsInput, {
252
+ const { disabled, canNotBeEmpty, allowAddNewTags, filter, size, height = this.context, label } = this.props;
253
+ const classes = classNames(styles.tagsInput, [inputStyles[`size${size}`]], [inputStyles[`height${height}`]], {
249
254
  [styles.tagsInputDisabled]: disabled,
250
- [styles.tagsInputFocused]: focused,
251
- [styles.tagsInputLegacyMode]: legacyMode
255
+ [styles.tagsInputFocused]: focused
252
256
  }, this.props.className);
253
257
  return (<div
254
258
  // it transfers focus to input
255
259
  role="presentation" className={classes} onKeyDown={this.handleKeyDown} onClick={this.clickHandler} ref={this.nodeRef}>
260
+ {label && (<label htmlFor={this.id} className={classNames(inputStyles.label, {
261
+ [inputStyles.disabledLabel]: disabled
262
+ })}>{label}</label>)}
263
+
256
264
  <TagsList tags={tags} activeIndex={activeIndex} disabled={disabled} canNotBeEmpty={canNotBeEmpty} handleRemove={this.handleRemove} className={styles.tagsList} tagClassName={styles.tag} handleClick={this.handleClick}>
257
- <Select ref={this.selectRef} size={Select.Size.AUTO} type={Select.Type.INPUT_WITHOUT_CONTROLS} inputPlaceholder={this.props.placeholder} data={this.state.suggestions} className={classNames(styles.tagsSelect)} onSelect={this.addTag} onFocus={this._focusHandler} onBlur={this._blurHandler} renderOptimization={this.props.renderOptimization} add={allowAddNewTags ? { prefix: 'Add new tag' } : undefined} onAdd={allowAddNewTags ? this.handleTagCreation : undefined} filter={filter} maxHeight={this.props.maxPopupHeight} minWidth={this.props.minPopupWidth} top={POPUP_VERTICAL_SHIFT} loading={this.state.loading} onFilter={this.loadSuggestions} onBeforeOpen={this.loadSuggestions} onKeyDown={this.handleKeyDown} disabled={this.props.disabled} loadingMessage={this.props.loadingMessage} notFoundMessage={this.props.notFoundMessage}/>
265
+ <Select id={this.id} ref={this.selectRef} size={Select.Size.AUTO} type={Select.Type.INPUT_WITHOUT_CONTROLS} inputPlaceholder={this.props.placeholder} data={this.state.suggestions} className={classNames(styles.tagsSelect)} onSelect={this.addTag} onFocus={this._focusHandler} onBlur={this._blurHandler} renderOptimization={this.props.renderOptimization} add={allowAddNewTags ? { prefix: 'Add new tag' } : undefined} onAdd={allowAddNewTags ? this.handleTagCreation : undefined} filter={filter} maxHeight={this.props.maxPopupHeight} minWidth={this.props.minPopupWidth} top={POPUP_VERTICAL_SHIFT} loading={this.state.loading} onFilter={this.loadSuggestions} onBeforeOpen={this.loadSuggestions} onKeyDown={this.handleKeyDown} disabled={this.props.disabled} loadingMessage={this.props.loadingMessage} notFoundMessage={this.props.notFoundMessage}/>
258
266
  </TagsList>
259
-
260
- {!legacyMode && <div className={styles.underline}/>}
261
- {!legacyMode && <div className={styles.focusUnderline}/>}
262
267
  </div>);
263
268
  }
264
269
  }
@@ -1,6 +1,6 @@
1
1
  import scrollbarWidth from 'scrollbar-width';
2
2
 
3
- var modules_5e9b8c03 = {"unit":"8px","header":"header_rui_1d72","container":"container_rui_381e","innerContainer":"innerContainer_rui_381e","content":"content_rui_381e","panel":"panel_rui_381e","clickableOverlay":"clickableOverlay_rui_381e","closeIcon":"closeIcon_rui_381e","closeButton":"closeButton_rui_381e","closeButtonOutside":"closeButtonOutside_rui_381e","closeButtonInside":"closeButtonInside_rui_381e","documentWithoutScroll":"documentWithoutScroll_rui_381e","popupTarget":"popupTarget_rui_381e"};
3
+ var modules_5e9b8c03 = {"unit":"8px","header":"header_rui_1d72","container":"container_rui_381e","innerContainer":"innerContainer_rui_381e","content":"content_rui_381e","panel":"panel_rui_381e","clickableOverlay":"clickableOverlay_rui_381e","closeIcon":"closeIcon_rui_381e","closeButton":"closeButton_rui_381e","closeButtonOutside":"closeButtonOutside_rui_381e","closeButtonInside":"closeButtonInside_rui_381e","documentWithoutScroll":"documentWithoutScroll_rui_381e","popupTarget":"popupTarget_rui_381e","dense":"dense_rui_381e"};
4
4
 
5
5
  const isPrevented = new Set();
6
6
  let previousDocumentWidth = null;
@@ -15,6 +15,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
15
15
  contentClassName?: string | null | undefined;
16
16
  portalTarget?: Element | null | undefined;
17
17
  'data-test'?: string | null | undefined;
18
+ dense?: boolean | null | undefined;
18
19
  }
19
20
  /**
20
21
  * @name Dialog
@@ -124,6 +124,7 @@ class Dialog extends PureComponent {
124
124
  portalTarget,
125
125
  label,
126
126
  closeButtonTitle,
127
+ dense,
127
128
  ...restProps
128
129
  } = this.props;
129
130
  const classes = classNames(modules_5e9b8c03.container, className);
@@ -148,7 +149,9 @@ class Dialog extends PureComponent {
148
149
  }), /*#__PURE__*/React.createElement("div", {
149
150
  className: modules_5e9b8c03.innerContainer
150
151
  }, /*#__PURE__*/React.createElement(AdaptiveIsland, {
151
- className: classNames(modules_5e9b8c03.content, contentClassName),
152
+ className: classNames(modules_5e9b8c03.content, contentClassName, {
153
+ [modules_5e9b8c03.dense]: dense
154
+ }),
152
155
  "data-test": "ring-dialog",
153
156
  role: "dialog",
154
157
  "aria-label": label