Skip to content

Commit

Permalink
Merge 6.x into Master (#7830)
Browse files Browse the repository at this point in the history
* RG-2293 Get rid of side effects in setState updater function of Select component (#7574)

* 6.0.50

* RG-2462 switch sidebar and main background in dark theme (#7565)

(cherry picked from commit 647dd76)

* 6.0.51

* Support passing theme down via React Context (#7592)

* 6.0.52

* RG-2420 chore: undeprecate "Badge" in 6.x version

* Chore: export GLOBAL_DARK_CLASS_NAME constant [publish]

* 6.0.53

* JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554 (#7637)

* RG-2473 don't unmount react root because it can be reused later (#7656)

minor: log auth error

* 6.0.54

* Revert "JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554"

This reverts commit 9192646.

* 6.0.55

* Put page reload in timeout for USER_CHANGED event to let all other events to be called. JT-83975 related

* 6.0.56

* Chore: add example with dialog with close button inside

* RG-2227 Clicking on a select label reopens the dropdown

(cherry picked from commit a685a07)

* chore: Prevent dialog scroll (#7710)

* chore: Prevent dialog scroll

* chore: preventBodyScroll should not be passed as a part of restProps

* 6.0.57

* Add attributes prop to DatePicker button (#7727)

Co-authored-by: Mikhail Cherviakov <mikhail.cherviakov@jetbrains.com>

* 6.0.58

* [publish] fix breadcrumbs work with React.Fragment containers as a transparent containers

reactjs/rfcs#61

* 6.0.59

* Revert "[publish] fix breadcrumbs work with React.Fragment containers as a transparent containers"

This reverts commit 704bb21.

* 6.0.60

* Fix Table colspan calculation when columns is passed as function

* 6.0.61

* Get rid of unused Table maxColSpan prop

* RG-2490 support moving cursor from anchor to tooltip (#7754)

* RG-2490 support moving cursor from anchor to tooltip

* RG-2490 use React for "mouseout" event

* 6.0.62

* Check className in QueryAssist shouldComponentUpdate

* 6.0.63

---------

Co-authored-by: Veniamin Krol <153412+vkrol@users.noreply.github.com>
Co-authored-by: JetBrains Ring UI Automation <npmjs-buildserver@jetbrains.com>
Co-authored-by: Filipp Riabchun <filipp.riabchun@jetbrains.com>
Co-authored-by: Alexander Burkov <a.p.burkov@gmail.com>
Co-authored-by: Mihail Ch. <pltnm239@gmail.com>
Co-authored-by: Mikhail Cherviakov <mikhail.cherviakov@jetbrains.com>
Co-authored-by: maksim.erekhinskii <maxim.erehinskiy@jetbrains.com>
Co-authored-by: Veniamin Krol <veniamin.krol@jetbrains.com>
  • Loading branch information
9 people authored Oct 21, 2024
1 parent b7daadf commit 8804695
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 33 deletions.
11 changes: 9 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'file-loader?name=ring-ui-favicon.ico!@jetbrains/logos/ring-ui/favicon.ic
import {Component} from '@storybook/addon-docs';
import {Parameters} from '@storybook/react';

import Theme, {applyTheme} from '../src/global/theme';
import Theme, {applyTheme, GLOBAL_DARK_CLASS_NAME} from '../src/global/theme';

import styles from './preview.css';
import strictModeDecorator from './strict-mode-decorator';
Expand Down Expand Up @@ -41,7 +41,14 @@ export const parameters = {
}
},
actions: {argTypesRegex: '^on.*'},
backgrounds: {disable: true}
backgrounds: {disable: true},
themes: {
default: 'Light',
list: [
{name: 'Light', color: '#FFF'},
{name: 'Dark', class: GLOBAL_DARK_CLASS_NAME, color: '#23272b'}
]
}
};

export const decorators = [
Expand Down
4 changes: 0 additions & 4 deletions src/badge/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {PureComponent, HTMLAttributes} from 'react';
import classNames from 'classnames';
import deprecate from 'util-deprecate';

import dataTests from '../global/data-tests';

Expand All @@ -14,15 +13,12 @@ export interface BadgeProps extends HTMLAttributes<HTMLElement> {
'data-test'?: string | null | undefined
}

const warn = deprecate(() => {}, 'Badge is deprecated and will be removed in RingUI 7.0. Use Tag instead.');

/**
* @name Badge
*/
// TODO remove in 7.0
export default class Badge extends PureComponent<BadgeProps> {
render() {
warn();
const {
// Modifiers
gray,
Expand Down
4 changes: 3 additions & 1 deletion src/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PureComponent, Ref} from 'react';
import {PureComponent, Ref, ButtonHTMLAttributes} from 'react';
import * as React from 'react';
import classNames from 'classnames';
import type {Locale} from 'date-fns';
Expand Down Expand Up @@ -91,6 +91,7 @@ export type DatePickerProps = Omit<DatePopupProps, 'translations' | 'parseDateIn
disabled?: boolean | null | undefined
parseDateInput: (input: string | null | undefined) => Date | null
size?: Size
buttonAttributes?: Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label'>
}

/**
Expand Down Expand Up @@ -286,6 +287,7 @@ export default class DatePicker extends PureComponent<DatePickerProps> {
className={styles.anchor}
text={false}
disabled={this.props.disabled ?? false}
{...this.props.buttonAttributes}
>
{anchorContent}
</Button>
Expand Down
9 changes: 7 additions & 2 deletions src/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
dense?: boolean | null | undefined
native?: boolean
modal?: boolean
preventBodyScroll?: boolean
}

/**
Expand All @@ -58,7 +59,8 @@ export default class Dialog extends PureComponent<DialogProps> {
shortcutOptions: {modal: false},
trapFocus: false,
autoFocusFirst: true,
modal: true
modal: true,
preventBodyScroll: true
};

state = {
Expand Down Expand Up @@ -108,6 +110,9 @@ export default class Dialog extends PureComponent<DialogProps> {
}

toggleScrollPreventer() {
if (!this.props.preventBodyScroll) {
return;
}
if (this.props.show) {
this.scrollPreventer.prevent();
} else {
Expand Down Expand Up @@ -149,7 +154,7 @@ export default class Dialog extends PureComponent<DialogProps> {
const {show, showCloseButton, onOverlayClick, onCloseAttempt, onEscPress, onCloseClick,
children, className, contentClassName, trapFocus, 'data-test': dataTest, closeButtonInside,
portalTarget, label, closeButtonTitle, dense, shortcutOptions, native, modal,
...restProps} = this.props;
preventBodyScroll, ...restProps} = this.props;
const classes = classNames(styles.container, className);
const shortcutsMap = this.getShortcutsMap();
const content = (
Expand Down
3 changes: 2 additions & 1 deletion src/query-assist/query-assist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ export default class QueryAssist extends Component<QueryAssistProps> {
props.focus !== this.props.focus ||
props.actions !== this.props.actions ||
props.loader !== this.props.loader ||
props.glass !== this.props.glass;
props.glass !== this.props.glass ||
props.className !== this.props.className;
}

componentDidUpdate(prevProps: QueryAssistProps) {
Expand Down
7 changes: 0 additions & 7 deletions src/table/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export interface HeaderProps {
sortOrder: boolean
caption?: string | null | undefined
checkboxDisabled?: boolean | undefined
maxColSpan?: number
}

export default class Header extends PureComponent<HeaderProps> {
Expand Down Expand Up @@ -68,20 +67,14 @@ export default class Header extends PureComponent<HeaderProps> {
</div>
);

let colSpan = 0;
return columns.map((column, index) => {
const columnStyle = widths[index] ? {width: widths[index]} : undefined;
const props = {column, onSort, sortKey, sortOrder, style: columnStyle};
colSpan += column.colSpan || 1;
if (colSpan > (this.props.maxColSpan || Infinity)) {
return null;
}

return (
<HeaderCell
key={column.id}
data-test={column.id}
colSpan={column.colSpan}
{...props}
>
{index === 0 && (draggable || selectable) && metaColumn}
Expand Down
9 changes: 2 additions & 7 deletions src/table/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export interface RowProps<T extends SelectionItem> extends Omit<
>, FocusSensorAddProps<HTMLTableRowElement> {
item: T
columns: readonly Column<T>[] | ((item: T) => readonly Column<T>[])
maxColSpan?: number
selectable: boolean
showFocus: boolean
draggable: boolean
Expand Down Expand Up @@ -138,7 +137,7 @@ export default class Row<T extends SelectionItem> extends PureComponent<RowProps
const {
item, columns: columnProps, selectable, selected,
showFocus, draggable, alwaysShowDragHandle, dragHandleTitle, level,
collapsible, parentCollapsible, collapsed, maxColSpan,
collapsible, parentCollapsible, collapsed,
onCollapse, onExpand, showDisabledSelection, onSelect,
checkboxTooltip, innerRef, focused, autofocus, onFocusReset,
onFocusRestore, onHover, className, metaColumnClassName, 'data-test': dataTest, ...restProps
Expand Down Expand Up @@ -223,7 +222,7 @@ export default class Row<T extends SelectionItem> extends PureComponent<RowProps
);

const columns = typeof columnProps === 'function' ? columnProps(item) : columnProps;
let colSpan = 0;

const cells = columns.map((column, index) => {
const getValue = column.getValue || (() => item[column.id] as ReactNode);
const getDataTest = column.getDataTest || (() => column.id);
Expand All @@ -232,10 +231,6 @@ export default class Row<T extends SelectionItem> extends PureComponent<RowProps
const showMetaColumn =
draggable || selectable || collapsible || showDisabledSelection || !!level;

colSpan += column.colSpan || 1;
if (colSpan > (maxColSpan || Infinity)) {
return null;
}
return (
<Cell
colSpan={column.colSpan}
Expand Down
3 changes: 1 addition & 2 deletions src/table/table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ EmptyTable.args = {
}
],
renderEmpty: () => 'Empty table',
selectable: false,
maxColSpan: 3
selectable: false
};
EmptyTable.storyName = 'empty table';

Expand Down
12 changes: 6 additions & 6 deletions src/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export interface TableProps<T extends SelectionItem> extends
FocusSensorAddProps<HTMLTableRowElement>, SelectionShortcutsAddProps<T>, DisableHoverAddProps {
data: readonly T[]
columns: readonly Column<T>[] | ((item:T|null)=>readonly Column<T>[])
maxColSpan?:number;
isItemSelectable: (item: T) => boolean
loading: boolean
onSort: (params: SortParams) => void
Expand Down Expand Up @@ -184,17 +183,19 @@ export class Table<T extends SelectionItem> extends PureComponent<TableProps<T>>
loading, onSort, sortKey, sortOrder, loaderClassName, stickyHeader,
stickyHeaderOffset, isItemCollapsible, isParentCollapsible, isItemCollapsed,
onItemCollapse, onItemExpand, isDisabledSelectionVisible, getCheckboxTooltip,
onItemDoubleClick, onItemClick, renderEmpty, maxColSpan, RowComponent
onItemDoubleClick, onItemClick, renderEmpty, RowComponent
} = this.props;


// NOTE: Do not construct new object per render because it causes all rows rerendering

const columnsArray = typeof columns === 'function' ? columns(null) : columns;

const headerProps: HeaderAttrs = {
caption, selectable, draggable,
columns: typeof columns === 'function' ? columns(null) : columns, onSort, sortKey, sortOrder,
columns: columnsArray, onSort, sortKey, sortOrder,
sticky: stickyHeader,
topStickOffset: stickyHeaderOffset, maxColSpan: this.props.maxColSpan
topStickOffset: stickyHeaderOffset
};

const selectedSize = selection.getSelected().size;
Expand All @@ -220,7 +221,7 @@ export class Table<T extends SelectionItem> extends PureComponent<TableProps<T>>
const empty = (
<tr>
<td
colSpan={this.props.columns.length || 1}
colSpan={columnsArray.length || 1}
className={style.tableMessage}
>
{renderEmpty ? renderEmpty() : null}
Expand Down Expand Up @@ -273,7 +274,6 @@ export class Table<T extends SelectionItem> extends PureComponent<TableProps<T>>
dragHandleTitle={dragHandleTitle}
columns={columns}
data-test={getItemDataTest(value)}
maxColSpan={maxColSpan}
{...restProps}
key={restProps.key ?? getItemKey(value)}
/>
Expand Down
9 changes: 8 additions & 1 deletion src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export default class Tooltip extends Component<TooltipProps> {
addListeners() {
if (this.containerNode != null) {
this.listeners.add(this.containerNode, 'mouseenter', this.tryToShowPopup);
this.listeners.add(this.containerNode, 'mouseleave', this.hidePopup);
this.listeners.add(this.containerNode, 'mouseleave', ev => {
if (ev.relatedTarget && this.popup?.container?.contains(ev.relatedTarget as Node)) {
return;
}

this.hidePopup();
});
}
this.listeners.add(document, 'scroll', () => scheduleScroll(this.hidePopup), {passive: true});
}
Expand Down Expand Up @@ -178,6 +184,7 @@ export default class Tooltip extends Component<TooltipProps> {
maxHeight={400}
className={classNames(styles.tooltip, {[styles.long]: long})}
attached={false}
onMouseOut={this.hidePopup}
top={4}
dontCloseOnAnchorClick
ref={this.popupRef}
Expand Down

0 comments on commit 8804695

Please sign in to comment.