Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 6.x into Master #7830

Merged
merged 37 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
97c2832
RG-2293 Get rid of side effects in setState updater function of Selec…
vkrol Jul 26, 2024
c15a99d
6.0.50
JetBrainsTeamCity Jul 26, 2024
f6781e3
RG-2462 switch sidebar and main background in dark theme (#7565)
andrey-skl Jul 26, 2024
42c54b6
6.0.51
JetBrainsTeamCity Jul 26, 2024
c1feb8a
Support passing theme down via React Context (#7592)
andrey-skl Jul 31, 2024
76b9900
6.0.52
JetBrainsTeamCity Jul 31, 2024
580369f
RG-2420 chore: undeprecate "Badge" in 6.x version
andrey-skl Jul 31, 2024
98c09b3
Chore: export GLOBAL_DARK_CLASS_NAME constant [publish]
andrey-skl Aug 12, 2024
ac15fa4
6.0.53
JetBrainsTeamCity Aug 12, 2024
708b012
JT-83359 Enable back controlling shortcuts by having '.ring-js-shortc…
andrey-skl Aug 15, 2024
f189d8c
RG-2473 don't unmount react root because it can be reused later (#7656)
andrey-skl Aug 21, 2024
b97848f
6.0.54
JetBrainsTeamCity Aug 21, 2024
df6176f
Revert "JT-83359 Enable back controlling shortcuts by having '.ring-j…
andrey-skl Aug 26, 2024
801b8f8
6.0.55
JetBrainsTeamCity Aug 26, 2024
3dfbca3
Put page reload in timeout for USER_CHANGED event to let all other ev…
andrey-skl Aug 30, 2024
a6a6cc5
6.0.56
JetBrainsTeamCity Aug 30, 2024
35d29c1
Chore: add example with dialog with close button inside
andrey-skl Sep 4, 2024
062f75f
RG-2227 Clicking on a select label reopens the dropdown
Hypnosphi Sep 6, 2024
380979e
chore: Prevent dialog scroll (#7710)
burkov Sep 12, 2024
8457001
6.0.57
JetBrainsTeamCity Sep 12, 2024
b740cdb
Add attributes prop to DatePicker button (#7727)
pltnm239 Sep 16, 2024
6eb3982
6.0.58
JetBrainsTeamCity Sep 16, 2024
704bb21
[publish] fix breadcrumbs work with React.Fragment containers as a tr…
nightflash Sep 16, 2024
fae8622
6.0.59
JetBrainsTeamCity Sep 16, 2024
8ff345e
Revert "[publish] fix breadcrumbs work with React.Fragment containers…
nightflash Sep 17, 2024
f66aa7f
6.0.60
JetBrainsTeamCity Sep 17, 2024
854de55
Fix Table colspan calculation when columns is passed as function
vkrol Sep 23, 2024
ea86d56
Merge pull request #7752 from JetBrains/fix-table-colspan
vkrol Sep 23, 2024
e41ec76
6.0.61
JetBrainsTeamCity Sep 23, 2024
2619d84
Get rid of unused Table maxColSpan prop
vkrol Sep 23, 2024
053e9a9
RG-2490 support moving cursor from anchor to tooltip (#7754)
andrey-skl Sep 23, 2024
5b3b936
Merge pull request #7753 from JetBrains/get-rid-of-table-maxcolspan
vkrol Sep 24, 2024
d033d06
6.0.62
JetBrainsTeamCity Sep 24, 2024
58411fb
Check className in QueryAssist shouldComponentUpdate
vkrol Sep 24, 2024
1222a6d
Merge pull request #7761 from JetBrains/check-classname-in-query-assi…
vkrol Sep 24, 2024
cfd2d59
6.0.63
JetBrainsTeamCity Sep 24, 2024
abff69d
Merge branch 'release-6.x'
andrey-skl Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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