@jetbrains/ring-ui-built 7.0.0-beta.12 → 7.0.0-beta.13

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.
@@ -1,7 +1,6 @@
1
1
  import { a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
2
2
  import { PureComponent } from 'react';
3
3
  import classNames from 'classnames';
4
- import deprecate from 'util-deprecate';
5
4
  import joinDataTestAttributes from '../global/data-tests.js';
6
5
  import { m as modules_6c9187df } from '../_helpers/badge.js';
7
6
  import { jsx } from 'react/jsx-runtime';
@@ -9,14 +8,8 @@ import 'core-js/modules/es.array.reduce.js';
9
8
  import 'core-js/modules/web.dom-collections.iterator.js';
10
9
 
11
10
  const _excluded = ["gray", "valid", "invalid", "disabled", "className", "children", "data-test"];
12
- const warn = deprecate(() => {}, 'Badge is deprecated and will be removed in RingUI 7.0. Use Tag instead.');
13
- /**
14
- * @name Badge
15
- */
16
- // TODO remove in 7.0
17
11
  class Badge extends PureComponent {
18
12
  render() {
19
- warn();
20
13
  const _this$props = this.props,
21
14
  {
22
15
  // Modifiers
@@ -9,7 +9,6 @@ import 'core-js/modules/es.array.reduce.js';
9
9
  import 'core-js/modules/web.dom-collections.iterator.js';
10
10
  import '../link/clickableLink.js';
11
11
  import '../_helpers/link.js';
12
- import 'util-deprecate';
13
12
  import '../_helpers/badge.js';
14
13
 
15
14
  const items = [{
@@ -1,4 +1,4 @@
1
- import { PureComponent } from 'react';
1
+ import { PureComponent, ButtonHTMLAttributes } from 'react';
2
2
  import * as React from 'react';
3
3
  import type { Locale } from 'date-fns';
4
4
  import Popup from '../popup/popup';
@@ -28,6 +28,7 @@ export type DatePickerProps = Omit<DatePopupProps, 'translations' | 'parseDateIn
28
28
  disabled?: boolean | null | undefined;
29
29
  parseDateInput: (input: string | null | undefined) => Date | null;
30
30
  size?: Size;
31
+ buttonAttributes?: Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label'>;
31
32
  };
32
33
  /**
33
34
  * @name Date Picker
@@ -258,13 +258,14 @@ class DatePicker extends PureComponent {
258
258
  disabled: (_this$props$disabled = this.props.disabled) !== null && _this$props$disabled !== void 0 ? _this$props$disabled : false,
259
259
  pseudo: true,
260
260
  children: this.getAnchorText()
261
- }) : /*#__PURE__*/jsx(Button, {
261
+ }) : /*#__PURE__*/jsx(Button, _objectSpread2(_objectSpread2({
262
262
  "data-test-ring-dropdown-anchor": true,
263
263
  className: modules_0c7b7d96.anchor,
264
264
  text: false,
265
- disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false,
265
+ disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false
266
+ }, this.props.buttonAttributes), {}, {
266
267
  children: anchorContent
267
- })
268
+ }))
268
269
  }, dropdownProps), {}, {
269
270
  children: /*#__PURE__*/jsx(PopupComponent, {
270
271
  className: popupClassName,
@@ -20,6 +20,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
20
20
  dense?: boolean | null | undefined;
21
21
  native?: boolean;
22
22
  modal?: boolean;
23
+ preventBodyScroll?: boolean;
23
24
  }
24
25
  export default class Dialog extends PureComponent<DialogProps> {
25
26
  static defaultProps: Partial<DialogProps>;
@@ -39,7 +39,7 @@ import '../global/controls-height.js';
39
39
  import '../_helpers/button__classes.js';
40
40
  import 'scrollbar-width';
41
41
 
42
- const _excluded = ["show", "showCloseButton", "onOverlayClick", "onCloseAttempt", "onEscPress", "onCloseClick", "children", "className", "contentClassName", "trapFocus", "data-test", "closeButtonInside", "portalTarget", "label", "closeButtonTitle", "dense", "shortcutOptions", "native", "modal"];
42
+ const _excluded = ["show", "showCloseButton", "onOverlayClick", "onCloseAttempt", "onEscPress", "onCloseClick", "children", "className", "contentClassName", "trapFocus", "data-test", "closeButtonInside", "portalTarget", "label", "closeButtonTitle", "dense", "shortcutOptions", "native", "modal", "preventBodyScroll"];
43
43
  function noop() {}
44
44
  class Dialog extends PureComponent {
45
45
  constructor() {
@@ -118,6 +118,9 @@ class Dialog extends PureComponent {
118
118
  }
119
119
  }
120
120
  toggleScrollPreventer() {
121
+ if (!this.props.preventBodyScroll) {
122
+ return;
123
+ }
121
124
  if (this.props.show) {
122
125
  this.scrollPreventer.prevent();
123
126
  } else {
@@ -145,7 +148,8 @@ class Dialog extends PureComponent {
145
148
  dense,
146
149
  shortcutOptions,
147
150
  native,
148
- modal
151
+ modal,
152
+ preventBodyScroll
149
153
  } = _this$props,
150
154
  restProps = _objectWithoutProperties(_this$props, _excluded);
151
155
  const classes = classNames(modules_5e9b8c03.container, className);
@@ -226,7 +230,8 @@ _defineProperty(Dialog, "defaultProps", {
226
230
  },
227
231
  trapFocus: false,
228
232
  autoFocusFirst: true,
229
- modal: true
233
+ modal: true,
234
+ preventBodyScroll: true
230
235
  });
231
236
 
232
237
  export { Dialog as default };
@@ -560,7 +560,7 @@ class QueryAssist extends Component {
560
560
  this._pushHistory(this.state);
561
561
  }
562
562
  shouldComponentUpdate(props, state) {
563
- return state.query !== this.state.query || state.dirty !== this.state.dirty || state.loading !== this.state.loading || state.showPopup !== this.state.showPopup || state.suggestions !== this.state.suggestions || state.styleRanges !== this.state.styleRanges || state.placeholderEnabled !== this.state.placeholderEnabled || props.placeholder !== this.props.placeholder || props.disabled !== this.props.disabled || props.clear !== this.props.clear || props.focus !== this.props.focus || props.actions !== this.props.actions || props.loader !== this.props.loader || props.glass !== this.props.glass;
563
+ return state.query !== this.state.query || state.dirty !== this.state.dirty || state.loading !== this.state.loading || state.showPopup !== this.state.showPopup || state.suggestions !== this.state.suggestions || state.styleRanges !== this.state.styleRanges || state.placeholderEnabled !== this.state.placeholderEnabled || props.placeholder !== this.props.placeholder || props.disabled !== this.props.disabled || props.clear !== this.props.clear || props.focus !== this.props.focus || props.actions !== this.props.actions || props.loader !== this.props.loader || props.glass !== this.props.glass || props.className !== this.props.className;
564
564
  }
565
565
  componentDidUpdate(prevProps) {
566
566
  const {
@@ -13,7 +13,6 @@ export interface HeaderProps {
13
13
  sortOrder: boolean;
14
14
  caption?: string | null | undefined;
15
15
  checkboxDisabled?: boolean | undefined;
16
- maxColSpan?: number;
17
16
  }
18
17
  export default class Header extends PureComponent<HeaderProps> {
19
18
  static defaultProps: {
@@ -29,7 +28,7 @@ export default class Header extends PureComponent<HeaderProps> {
29
28
  };
30
29
  id: string;
31
30
  onCheckboxFocus: (event: SyntheticEvent<HTMLElement>) => void;
32
- createCells(widths?: never[]): (import("react").JSX.Element | null)[];
31
+ createCells(widths?: never[]): import("react").JSX.Element[];
33
32
  render(): import("react").JSX.Element;
34
33
  }
35
34
  export type HeaderAttrs = JSX.LibraryManagedAttributes<typeof Header, HeaderProps>;
@@ -56,7 +56,6 @@ class Header extends PureComponent {
56
56
  onFocus: this.onCheckboxFocus
57
57
  })
58
58
  });
59
- let colSpan = 0;
60
59
  return columns.map((column, index) => {
61
60
  const columnStyle = widths[index] ? {
62
61
  width: widths[index]
@@ -68,13 +67,8 @@ class Header extends PureComponent {
68
67
  sortOrder,
69
68
  style: columnStyle
70
69
  };
71
- colSpan += column.colSpan || 1;
72
- if (colSpan > (this.props.maxColSpan || Infinity)) {
73
- return null;
74
- }
75
70
  return /*#__PURE__*/jsx(HeaderCell, _objectSpread2(_objectSpread2({
76
- "data-test": column.id,
77
- colSpan: column.colSpan
71
+ "data-test": column.id
78
72
  }, props), {}, {
79
73
  children: index === 0 && (draggable || selectable) && metaColumn
80
74
  }), column.id);
@@ -6,7 +6,6 @@ import { SelectionItem } from './selection';
6
6
  export interface RowProps<T extends SelectionItem> extends Omit<HTMLAttributes<HTMLTableRowElement>, 'onClick' | 'onDoubleClick' | 'onSelect'>, FocusSensorAddProps<HTMLTableRowElement> {
7
7
  item: T;
8
8
  columns: readonly Column<T>[] | ((item: T) => readonly Column<T>[]);
9
- maxColSpan?: number;
10
9
  selectable: boolean;
11
10
  showFocus: boolean;
12
11
  draggable: boolean;
@@ -45,7 +45,7 @@ import '../_helpers/theme.js';
45
45
  import 'core-js/modules/es.array.reduce.js';
46
46
  import 'memoize-one';
47
47
 
48
- const _excluded = ["item", "columns", "selectable", "selected", "showFocus", "draggable", "alwaysShowDragHandle", "dragHandleTitle", "level", "collapsible", "parentCollapsible", "collapsed", "maxColSpan", "onCollapse", "onExpand", "showDisabledSelection", "onSelect", "checkboxTooltip", "innerRef", "focused", "autofocus", "onFocusReset", "onFocusRestore", "onHover", "className", "metaColumnClassName", "data-test"];
48
+ const _excluded = ["item", "columns", "selectable", "selected", "showFocus", "draggable", "alwaysShowDragHandle", "dragHandleTitle", "level", "collapsible", "parentCollapsible", "collapsed", "onCollapse", "onExpand", "showDisabledSelection", "onSelect", "checkboxTooltip", "innerRef", "focused", "autofocus", "onFocusReset", "onFocusRestore", "onHover", "className", "metaColumnClassName", "data-test"];
49
49
  const DragHandle = _ref => {
50
50
  let {
51
51
  alwaysShowDragHandle,
@@ -125,7 +125,6 @@ class Row extends PureComponent {
125
125
  collapsible,
126
126
  parentCollapsible,
127
127
  collapsed,
128
- maxColSpan,
129
128
  onCollapse,
130
129
  onExpand,
131
130
  showDisabledSelection,
@@ -192,7 +191,6 @@ class Row extends PureComponent {
192
191
  })]
193
192
  });
194
193
  const columns = typeof columnProps === 'function' ? columnProps(item) : columnProps;
195
- let colSpan = 0;
196
194
  const cells = columns.map((column, index) => {
197
195
  const getValue = column.getValue || (() => item[column.id]);
198
196
  const getDataTest = column.getDataTest || (() => column.id);
@@ -201,10 +199,6 @@ class Row extends PureComponent {
201
199
  [modules_1db4bbca.cellRight]: column.rightAlign
202
200
  }, column.className);
203
201
  const showMetaColumn = draggable || selectable || collapsible || showDisabledSelection || !!level;
204
- colSpan += column.colSpan || 1;
205
- if (colSpan > (maxColSpan || Infinity)) {
206
- return null;
207
- }
208
202
  return /*#__PURE__*/jsxs(Cell, {
209
203
  colSpan: column.colSpan,
210
204
  className: cellClasses,
@@ -18,7 +18,6 @@ export interface ReorderParams<T> {
18
18
  export interface TableProps<T extends SelectionItem> extends FocusSensorAddProps<HTMLTableRowElement>, SelectionShortcutsAddProps<T>, DisableHoverAddProps {
19
19
  data: readonly T[];
20
20
  columns: readonly Column<T>[] | ((item: T | null) => readonly Column<T>[]);
21
- maxColSpan?: number;
22
21
  isItemSelectable: (item: T) => boolean;
23
22
  loading: boolean;
24
23
  onSort: (params: SortParams) => void;
@@ -190,21 +190,20 @@ class Table extends PureComponent {
190
190
  onItemDoubleClick,
191
191
  onItemClick,
192
192
  renderEmpty,
193
- maxColSpan,
194
193
  RowComponent
195
194
  } = this.props;
196
195
  // NOTE: Do not construct new object per render because it causes all rows rerendering
196
+ const columnsArray = typeof columns === 'function' ? columns(null) : columns;
197
197
  const headerProps = {
198
198
  caption,
199
199
  selectable,
200
200
  draggable,
201
- columns: typeof columns === 'function' ? columns(null) : columns,
201
+ columns: columnsArray,
202
202
  onSort,
203
203
  sortKey,
204
204
  sortOrder,
205
205
  sticky: stickyHeader,
206
- topStickOffset: stickyHeaderOffset,
207
- maxColSpan: this.props.maxColSpan
206
+ topStickOffset: stickyHeaderOffset
208
207
  };
209
208
  const selectedSize = selection.getSelected().size;
210
209
  const allSelectedSize = selection.selectAll().getSelected().size;
@@ -229,7 +228,7 @@ class Table extends PureComponent {
229
228
  } = _ref3;
230
229
  const empty = /*#__PURE__*/jsx("tr", {
231
230
  children: /*#__PURE__*/jsx("td", {
232
- colSpan: this.props.columns.length || 1,
231
+ colSpan: columnsArray.length || 1,
233
232
  className: modules_1db4bbca.tableMessage,
234
233
  children: renderEmpty ? renderEmpty() : null
235
234
  })
@@ -286,8 +285,7 @@ class Table extends PureComponent {
286
285
  alwaysShowDragHandle: alwaysShowDragHandle,
287
286
  dragHandleTitle: dragHandleTitle,
288
287
  columns: columns,
289
- "data-test": getItemDataTest(value),
290
- maxColSpan: maxColSpan
288
+ "data-test": getItemDataTest(value)
291
289
  }, restProps), {}, {
292
290
  key: (_restProps$key = restProps.key) !== null && _restProps$key !== void 0 ? _restProps$key : getItemKey(value)
293
291
  }));
@@ -127,7 +127,13 @@ class Tooltip extends Component {
127
127
  addListeners() {
128
128
  if (this.containerNode != null) {
129
129
  this.listeners.add(this.containerNode, 'mouseenter', this.tryToShowPopup);
130
- this.listeners.add(this.containerNode, 'mouseleave', this.hidePopup);
130
+ this.listeners.add(this.containerNode, 'mouseleave', ev => {
131
+ var _this$popup;
132
+ if (ev.relatedTarget && (_this$popup = this.popup) !== null && _this$popup !== void 0 && (_this$popup = _this$popup.container) !== null && _this$popup !== void 0 && _this$popup.contains(ev.relatedTarget)) {
133
+ return;
134
+ }
135
+ this.hidePopup();
136
+ });
131
137
  }
132
138
  this.listeners.add(document, 'scroll', () => scheduleScroll(this.hidePopup), {
133
139
  passive: true
@@ -177,6 +183,7 @@ class Tooltip extends Component {
177
183
  [modules_cd5e45a9.long]: long
178
184
  }),
179
185
  attached: false,
186
+ onMouseOut: this.hidePopup,
180
187
  top: 4,
181
188
  dontCloseOnAnchorClick: true,
182
189
  ref: this.popupRef
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui-built",
3
- "version": "7.0.0-beta.12",
3
+ "version": "7.0.0-beta.13",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -47,10 +47,10 @@
47
47
  "serve": "http-server storybook-dist/ -p 9999",
48
48
  "start": "storybook dev -p 9999",
49
49
  "storybook-debug": "node --inspect-brk node_modules/@storybook/react/bin -p 9999",
50
- "lint:js": "eslint",
50
+ "lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint",
51
51
  "lint": "npm run lint:js . && npm run stylelint",
52
52
  "prelint-ci": "echo \"##teamcity[importData type='jslint' path='eslint-report.xml']\"",
53
- "lint-ci": "eslint --format jslint-xml . > eslint-report.xml && npm run stylelint-ci",
53
+ "lint-ci": "ESLINT_USE_FLAT_CONFIG=false eslint --format jslint-xml . > eslint-report.xml && npm run stylelint-ci",
54
54
  "stylelint-ci": "stylelint --ignore-path .eslintignore --custom-formatter './jslint-xml.js' '**/*.css' | xmlappend eslint-report.xml",
55
55
  "stylelint": "stylelint --ignore-path .eslintignore '**/*.css'",
56
56
  "validate-tc-config": "mvn --file .teamcity/pom.xml org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate -e",