@jetbrains/ring-ui 8.0.0-beta.1 → 8.0.0-beta.3

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.
Files changed (81) hide show
  1. package/babel.config.js +1 -1
  2. package/components/auth-dialog-service/auth-dialog-service.js +2 -2
  3. package/components/collapse/collapse-content.js +2 -2
  4. package/components/collapse/collapse-control.js +2 -2
  5. package/components/collapse/collapse.js +2 -2
  6. package/components/confirm-service/confirm-service.js +2 -2
  7. package/components/data-list/data-list.d.ts +1 -1
  8. package/components/data-list/data-list.mock.d.ts +1 -1
  9. package/components/data-list/item.d.ts +1 -1
  10. package/components/data-list/selection.d.ts +1 -1
  11. package/components/data-list/selection.js +1 -1
  12. package/components/date-picker/months.js +2 -2
  13. package/components/date-picker/use-scroll-behavior.js +5 -6
  14. package/components/date-picker/years.js +2 -2
  15. package/components/dialog/dialog.d.ts +2 -2
  16. package/components/dialog/dialog.js +2 -2
  17. package/components/dropdown-menu/dropdown-menu.d.ts +4 -4
  18. package/components/dropdown-menu/dropdown-menu.js +4 -4
  19. package/components/editable-heading/editable-heading.d.ts +1 -2
  20. package/components/editable-heading/editable-heading.js +5 -6
  21. package/components/expand/collapsible-group.d.ts +5 -1
  22. package/components/expand/collapsible-group.js +12 -12
  23. package/components/global/create-stateful-context.js +5 -5
  24. package/components/global/intersection-observer-context.d.ts +2 -2
  25. package/components/global/intersection-observer-context.js +5 -5
  26. package/components/global/rerender-hoc.d.ts +4 -2
  27. package/components/global/rerender-hoc.js +4 -4
  28. package/components/{legacy-table/selection.d.ts → global/table-selection.d.ts} +14 -14
  29. package/components/{legacy-table/selection.js → global/table-selection.js} +1 -1
  30. package/components/global/theme.d.ts +4 -3
  31. package/components/global/theme.js +8 -8
  32. package/components/i18n/i18n-context.js +1 -1
  33. package/components/island/adaptive-island-hoc.js +4 -4
  34. package/components/island/content.d.ts +7 -2
  35. package/components/island/content.js +5 -5
  36. package/components/legacy-table/cell.js +1 -1
  37. package/components/legacy-table/header-cell.js +1 -1
  38. package/components/legacy-table/header.js +1 -1
  39. package/components/legacy-table/multitable.d.ts +1 -1
  40. package/components/legacy-table/row.js +1 -1
  41. package/components/legacy-table/selection-adapter.d.ts +3 -3
  42. package/components/legacy-table/selection-shortcuts-hoc.d.ts +5 -5
  43. package/components/legacy-table/simple-table.d.ts +2 -2
  44. package/components/legacy-table/simple-table.js +3 -3
  45. package/components/legacy-table/smart-table.d.ts +5 -5
  46. package/components/legacy-table/smart-table.js +3 -3
  47. package/components/legacy-table/table.js +1 -1
  48. package/components/login-dialog/service.js +2 -2
  49. package/components/popup/popup.target.d.ts +3 -2
  50. package/components/popup/popup.target.js +4 -6
  51. package/components/query-assist/query-assist.d.ts +3 -1
  52. package/components/query-assist/query-assist.js +2 -2
  53. package/components/radio/radio-item.d.ts +3 -3
  54. package/components/radio/radio-item.js +3 -4
  55. package/components/radio/radio.d.ts +2 -2
  56. package/components/radio/radio.js +1 -1
  57. package/components/select/select.d.ts +3 -1
  58. package/components/slider/slider.js +4 -5
  59. package/components/tab-trap/tab-trap.d.ts +3 -3
  60. package/components/tab-trap/tab-trap.js +3 -5
  61. package/components/table/default-item-renderer.d.ts +20 -9
  62. package/components/table/default-item-renderer.js +15 -36
  63. package/components/table/table-component.d.ts +43 -16
  64. package/components/table/table-component.js +66 -37
  65. package/components/table/table-primitives.d.ts +28 -0
  66. package/components/table/{table-base.js → table-primitives.js} +22 -22
  67. package/components/table/table-row-focus.d.ts +4 -0
  68. package/components/table/table-row-focus.js +42 -0
  69. package/components/table/table-virtualize.d.ts +3 -3
  70. package/components/table/table-virtualize.js +13 -14
  71. package/components/table/table.d.ts +9 -24
  72. package/components/tags-input/tags-input.d.ts +3 -1
  73. package/components/tooltip/tooltip.js +2 -2
  74. package/components/upload/upload.d.ts +4 -3
  75. package/components/upload/upload.js +3 -7
  76. package/components/user-agreement/service.js +2 -2
  77. package/package.json +20 -19
  78. package/components/global/use-event-callback.d.ts +0 -1
  79. package/components/global/use-event-callback.js +0 -15
  80. package/components/table/table-base.d.ts +0 -24
  81. /package/components/legacy-table/{table.css → legacy-table.css} +0 -0
@@ -17,11 +17,11 @@ export default function adaptiveIslandHOC(ComposedComponent) {
17
17
  }
18
18
  };
19
19
  render() {
20
- return (<PhaseContext.Provider value={this.state.phase}>
21
- <ScrollHandlerContext.Provider value={this.onContentScroll}>
20
+ return (<PhaseContext value={this.state.phase}>
21
+ <ScrollHandlerContext value={this.onContentScroll}>
22
22
  <ComposedComponent {...this.props}/>
23
- </ScrollHandlerContext.Provider>
24
- </PhaseContext.Provider>);
23
+ </ScrollHandlerContext>
24
+ </PhaseContext>);
25
25
  }
26
26
  };
27
27
  }
@@ -1,11 +1,13 @@
1
- import { Component, type HTMLAttributes } from 'react';
1
+ import { Component, type Ref, type HTMLAttributes } from 'react';
2
2
  import createResizeDetector from 'element-resize-detector';
3
3
  export interface IslandContentProps extends Omit<HTMLAttributes<HTMLElement>, 'onScroll'> {
4
+ ref?: Ref<Content>;
4
5
  fade?: boolean | null | undefined;
5
6
  onScrollToBottom?: (() => void) | null | undefined;
6
7
  scrollableWrapperClassName?: string | null | undefined;
7
8
  }
8
9
  export interface IslandContentInnerProps extends IslandContentProps {
10
+ ref?: Ref<Content>;
9
11
  onScroll: (node: HTMLElement) => void;
10
12
  bottomBorder: boolean;
11
13
  }
@@ -29,5 +31,8 @@ declare class Content extends Component<IslandContentInnerProps> {
29
31
  setScrollableNodeAndCalculatePosition: (node: HTMLElement | null) => void;
30
32
  render(): import("react").JSX.Element;
31
33
  }
32
- declare const ContentWrapper: import("react").ForwardRefExoticComponent<IslandContentProps & import("react").RefAttributes<Content>>;
34
+ declare const ContentWrapper: {
35
+ ({ ...props }: IslandContentProps): import("react").JSX.Element;
36
+ displayName: string;
37
+ };
33
38
  export default ContentWrapper;
@@ -1,4 +1,4 @@
1
- import { forwardRef, Component } from 'react';
1
+ import { Component } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import createResizeDetector from 'element-resize-detector';
4
4
  import scheduleRAF from '../global/schedule-raf';
@@ -57,7 +57,7 @@ class Content extends Component {
57
57
  this.calculateScrollPosition();
58
58
  };
59
59
  render() {
60
- const { children, className, bottomBorder, scrollableWrapperClassName, onScroll, onScrollToBottom, fade, tabIndex, ...restProps } = this.props;
60
+ const { ref, children, className, bottomBorder, scrollableWrapperClassName, onScroll, onScrollToBottom, fade, tabIndex, ...restProps } = this.props;
61
61
  const { scrolledToTop, scrolledToBottom } = this.state;
62
62
  const classes = classNames(styles.content, className, {
63
63
  [styles.contentWithTopFade]: fade && !scrolledToTop,
@@ -75,11 +75,11 @@ class Content extends Component {
75
75
  </div>);
76
76
  }
77
77
  }
78
- const ContentWrapper = forwardRef((props, ref) => (<ScrollHandlerContext.Consumer>
78
+ const ContentWrapper = ({ ...props }) => (<ScrollHandlerContext.Consumer>
79
79
  {onScroll => {
80
80
  const addProps = onScroll ? { onScroll, bottomBorder: true } : {};
81
- return <Content {...props} {...addProps} ref={ref}/>;
81
+ return <Content {...props} {...addProps}/>;
82
82
  }}
83
- </ScrollHandlerContext.Consumer>));
83
+ </ScrollHandlerContext.Consumer>);
84
84
  ContentWrapper.displayName = 'ContentWrapper';
85
85
  export default ContentWrapper;
@@ -1,7 +1,7 @@
1
1
  import { PureComponent } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import dataTests from '../global/data-tests';
4
- import style from './table.css';
4
+ import style from './legacy-table.css';
5
5
  export default class Cell extends PureComponent {
6
6
  render() {
7
7
  const classes = classNames(style.cell, this.props.className);
@@ -4,7 +4,7 @@ import sortableIcon from '@jetbrains/icons/unsorted-12px';
4
4
  import sortedIcon from '@jetbrains/icons/chevron-12px-down';
5
5
  import Icon from '../icon/icon';
6
6
  import dataTests from '../global/data-tests';
7
- import style from './table.css';
7
+ import style from './legacy-table.css';
8
8
  export default class HeaderCell extends PureComponent {
9
9
  static defaultProps = {
10
10
  onSort: () => { },
@@ -3,7 +3,7 @@ import classNames from 'classnames';
3
3
  import Checkbox from '../checkbox/checkbox';
4
4
  import getUID from '../global/get-uid';
5
5
  import HeaderCell from './header-cell';
6
- import style from './table.css';
6
+ import style from './legacy-table.css';
7
7
  export default class Header extends PureComponent {
8
8
  static defaultProps = {
9
9
  selectable: true,
@@ -1,6 +1,6 @@
1
1
  import { PureComponent, type ReactElement } from 'react';
2
2
  import { type TableAttrs } from './table';
3
- import { type SelectionItem } from './selection';
3
+ import { type SelectionItem } from '../global/table-selection';
4
4
  type TableComponent = ReactElement<TableAttrs<SelectionItem>>;
5
5
  export interface MultiTableProps {
6
6
  children: TableComponent[];
@@ -11,7 +11,7 @@ import dataTests from '../global/data-tests';
11
11
  import getUID from '../global/get-uid';
12
12
  import { createComposedRef } from '../global/compose-refs';
13
13
  import Cell from './cell';
14
- import style from './table.css';
14
+ import style from './legacy-table.css';
15
15
  const DragHandle = ({ alwaysShowDragHandle, dragHandleTitle = 'Drag to reorder' }) => {
16
16
  const classes = classNames(style.dragHandle, {
17
17
  [style.visibleDragHandle]: alwaysShowDragHandle,
@@ -1,6 +1,6 @@
1
- import type Selection from './selection';
2
- import type { SelectionItem } from './selection';
3
- export default function selectionAdapter(getSelection: () => Selection<SelectionItem>): {
1
+ import type TableSelection from '../global/table-selection';
2
+ import type { SelectionItem } from '../global/table-selection';
3
+ export default function selectionAdapter(getSelection: () => TableSelection<SelectionItem>): {
4
4
  readonly size: number;
5
5
  readonly items: SelectionItem[];
6
6
  };
@@ -1,16 +1,16 @@
1
1
  import { type ComponentClass } from 'react';
2
2
  import { type ShortcutsMap } from '../shortcuts/core';
3
- import type Selection from './selection';
3
+ import type TableSelection from '../global/table-selection';
4
4
  export interface SelectionShortcutsOuterProps<T extends object> {
5
- selection: Selection<T>;
5
+ selection: TableSelection<T>;
6
6
  selectable?: boolean | undefined;
7
- onSelect?: ((selection: Selection<T>) => void) | undefined;
7
+ onSelect?: ((selection: TableSelection<T>) => void) | undefined;
8
8
  shortcuts?: ShortcutsMap | undefined;
9
9
  }
10
10
  export interface SelectionShortcutsAddProps<T extends object> {
11
- selection: Selection<T>;
11
+ selection: TableSelection<T>;
12
12
  selectable: boolean;
13
- onSelect: (selection: Selection<T>) => void;
13
+ onSelect: (selection: TableSelection<T>) => void;
14
14
  shortcutsMap: ShortcutsMap;
15
15
  }
16
16
  export type SelectionShortcutsProps<T extends object, P> = Omit<P, keyof SelectionShortcutsAddProps<T>> & SelectionShortcutsOuterProps<T>;
@@ -1,6 +1,6 @@
1
1
  import { PureComponent } from 'react';
2
2
  import { type TableAttrs } from './table';
3
- import Selection, { type SelectionItem } from './selection';
3
+ import TableSelection, { type SelectionItem } from '../global/table-selection';
4
4
  export interface SimpleTableProps<T extends SelectionItem> extends Omit<TableAttrs<T>, 'selection' | 'onSelect' | 'selectable'> {
5
5
  }
6
6
  declare class SimpleTable<T extends SelectionItem> extends PureComponent<SimpleTableProps<T>> {
@@ -9,7 +9,7 @@ declare class SimpleTable<T extends SelectionItem> extends PureComponent<SimpleT
9
9
  wideFirstColumn: boolean;
10
10
  };
11
11
  state: {
12
- selection: Selection<T>;
12
+ selection: TableSelection<T>;
13
13
  };
14
14
  classes: string;
15
15
  render(): import("react").JSX.Element;
@@ -1,15 +1,15 @@
1
1
  import { PureComponent } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import Table from './table';
4
- import Selection from './selection';
5
- import style from './table.css';
4
+ import TableSelection from '../global/table-selection';
5
+ import style from './legacy-table.css';
6
6
  class SimpleTable extends PureComponent {
7
7
  static defaultProps = {
8
8
  selectable: false,
9
9
  wideFirstColumn: false,
10
10
  };
11
11
  state = {
12
- selection: new Selection({
12
+ selection: new TableSelection({
13
13
  data: this.props.data,
14
14
  }),
15
15
  };
@@ -1,19 +1,19 @@
1
1
  import { PureComponent } from 'react';
2
2
  import { type TableAttrs } from './table';
3
- import Selection, { type SelectionItem } from './selection';
3
+ import TableSelection, { type SelectionItem } from '../global/table-selection';
4
4
  export interface SmartTableProps<T extends SelectionItem> extends Omit<TableAttrs<T>, 'selection' | 'onSelect'> {
5
- onSelectionChange: (selection: Selection<T>) => void;
6
- selection?: Selection<T>;
5
+ onSelectionChange: (selection: TableSelection<T>) => void;
6
+ selection?: TableSelection<T>;
7
7
  }
8
8
  declare class SmartTable<T extends SelectionItem> extends PureComponent<SmartTableProps<T>> {
9
9
  static defaultProps: {
10
10
  onSelectionChange: () => void;
11
11
  };
12
12
  state: {
13
- selection: Selection<T>;
13
+ selection: TableSelection<T>;
14
14
  };
15
15
  UNSAFE_componentWillReceiveProps(nextProps: SmartTableProps<T>): void;
16
- onSelect: (selection: Selection<T>) => void;
16
+ onSelect: (selection: TableSelection<T>) => void;
17
17
  render(): import("react").JSX.Element;
18
18
  }
19
19
  export default SmartTable;
@@ -1,12 +1,12 @@
1
1
  import { PureComponent } from 'react';
2
2
  import Table from './table';
3
- import Selection from './selection';
3
+ import TableSelection from '../global/table-selection';
4
4
  class SmartTable extends PureComponent {
5
5
  static defaultProps = {
6
6
  onSelectionChange: () => { },
7
7
  };
8
8
  state = {
9
- selection: new Selection({
9
+ selection: new TableSelection({
10
10
  data: this.props.data,
11
11
  isItemSelectable: this.props.isItemSelectable,
12
12
  }),
@@ -18,7 +18,7 @@ class SmartTable extends PureComponent {
18
18
  }
19
19
  else if (this.props.data !== data || this.props.isItemSelectable !== isItemSelectable) {
20
20
  this.setState({
21
- selection: new Selection({ data, isItemSelectable }),
21
+ selection: new TableSelection({ data, isItemSelectable }),
22
22
  });
23
23
  }
24
24
  }
@@ -13,7 +13,7 @@ import Header from './header';
13
13
  import selectionShortcutsHOC from './selection-shortcuts-hoc';
14
14
  import disableHoverHOC from './disable-hover-hoc';
15
15
  import Row from './row-with-focus-sensor';
16
- import style from './table.css';
16
+ import style from './legacy-table.css';
17
17
  /**
18
18
  * Interactive table with selection and keyboard navigation support.
19
19
  */
@@ -7,9 +7,9 @@ const reactRoot = createRoot(containerElement);
7
7
  * Renders LoginDialog into virtual node to skip maintaining container
8
8
  */
9
9
  function renderLoginDialog(props) {
10
- reactRoot.render(<ControlsHeightContext.Provider value={getGlobalControlsHeight()}>
10
+ reactRoot.render(<ControlsHeightContext value={getGlobalControlsHeight()}>
11
11
  <LoginDialog {...props}/>
12
- </ControlsHeightContext.Provider>);
12
+ </ControlsHeightContext>);
13
13
  }
14
14
  function noop() { }
15
15
  export default function showAuthDialog(props = { onCancel: noop }) {
@@ -1,13 +1,14 @@
1
- import { type HTMLAttributes, type ReactNode } from 'react';
1
+ import { type HTMLAttributes, type Ref, type ReactNode } from 'react';
2
2
  interface ComplexConfig {
3
3
  target: string | Element | undefined;
4
4
  cssPositioning?: boolean;
5
5
  }
6
6
  export declare const PopupTargetContext: import("react").Context<string | Element | ComplexConfig | undefined>;
7
7
  export interface PopupTargetProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
8
+ ref?: Ref<HTMLDivElement>;
8
9
  id: string;
9
10
  children: ReactNode | ((target: ReactNode) => ReactNode);
10
11
  }
11
12
  export declare function normalizePopupTarget(value: string | Element | undefined | ComplexConfig): string | Element | undefined;
12
- export declare const PopupTarget: import("react").ForwardRefExoticComponent<PopupTargetProps & import("react").RefAttributes<HTMLDivElement>>;
13
+ export declare function PopupTarget({ ref, id, children, ...restProps }: PopupTargetProps): import("react").JSX.Element;
13
14
  export {};
@@ -1,13 +1,11 @@
1
- import { createContext, forwardRef } from 'react';
1
+ import { createContext } from 'react';
2
2
  export const PopupTargetContext = createContext(undefined);
3
3
  export function normalizePopupTarget(value) {
4
4
  return typeof value === 'string' || value instanceof Element ? value : value?.target;
5
5
  }
6
- export const PopupTarget = forwardRef(function PopupTarget({ id, children, ...restProps }, ref) {
6
+ export function PopupTarget({ ref, id, children, ...restProps }) {
7
7
  const target = (<div {...restProps} data-portaltarget={id} ref={ref}>
8
8
  {typeof children !== 'function' && children}
9
9
  </div>);
10
- return (<PopupTargetContext.Provider value={id}>
11
- {typeof children === 'function' ? children(target) : target}
12
- </PopupTargetContext.Provider>);
13
- });
10
+ return (<PopupTargetContext value={id}>{typeof children === 'function' ? children(target) : target}</PopupTargetContext>);
11
+ }
@@ -285,5 +285,7 @@ export default class QueryAssist extends Component<QueryAssistProps> {
285
285
  render(): React.JSX.Element;
286
286
  }
287
287
  export type QueryAssistAttrs = React.JSX.LibraryManagedAttributes<typeof QueryAssist, QueryAssistProps>;
288
- export declare const RerenderableQueryAssist: React.ForwardRefExoticComponent<QueryAssistProps & React.RefAttributes<QueryAssist>>;
288
+ export declare const RerenderableQueryAssist: ({ ref, ...props }: QueryAssistProps & {
289
+ ref?: React.Ref<QueryAssist> | undefined;
290
+ }) => React.JSX.Element;
289
291
  export {};
@@ -733,7 +733,7 @@ export default class QueryAssist extends Component {
733
733
  [styles.hugePlaceholder]: huge,
734
734
  [styles.withoutGlass]: !glass || (!renderLoader && huge),
735
735
  });
736
- return (<ControlsHeightContext.Provider value={ControlsHeight.M}>
736
+ return (<ControlsHeightContext value={ControlsHeight.M}>
737
737
  <I18nContext.Consumer>
738
738
  {({ translate }) => (<div data-test={dataTests('ring-query-assist', dataTest)} className={containerClasses} role='presentation' ref={this.nodeRef}>
739
739
  {this.state.shortcuts && <Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>}
@@ -768,7 +768,7 @@ export default class QueryAssist extends Component {
768
768
  </div>)}
769
769
  </div>)}
770
770
  </I18nContext.Consumer>
771
- </ControlsHeightContext.Provider>);
771
+ </ControlsHeightContext>);
772
772
  }
773
773
  }
774
774
  export const RerenderableQueryAssist = rerenderHOC(QueryAssist);
@@ -1,4 +1,4 @@
1
- import { Component, type InputHTMLAttributes, type ReactNode } from 'react';
1
+ import { Component, type Ref, type InputHTMLAttributes, type ReactNode } from 'react';
2
2
  export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
3
3
  value?: string | undefined;
4
4
  onChange?: ((value: string) => void) | null | undefined;
@@ -17,7 +17,7 @@ export declare class RadioItemInner extends Component<RadioItemInnerProps> {
17
17
  render(): import("react").JSX.Element;
18
18
  }
19
19
  export interface RadioItemProps extends RadioItemInnerProps {
20
+ ref?: Ref<RadioItemInner>;
20
21
  value: string;
21
22
  }
22
- declare const RadioItem: import("react").ForwardRefExoticComponent<RadioItemProps & import("react").RefAttributes<RadioItemInner>>;
23
- export default RadioItem;
23
+ export default function RadioItem({ ref, ...props }: RadioItemProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Component, createContext, forwardRef } from 'react';
1
+ import { Component, createContext } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import getUID from '../global/get-uid';
4
4
  import ControlHelp from '../control-help/control-help';
@@ -28,9 +28,8 @@ export class RadioItemInner extends Component {
28
28
  </label>);
29
29
  }
30
30
  }
31
- const RadioItem = forwardRef(function RadioItem(props, ref) {
31
+ export default function RadioItem({ ref, ...props }) {
32
32
  return (<RadioContext.Consumer>
33
33
  {({ value, onChange, ...restContext }) => (<RadioItemInner ref={ref} {...restContext} checked={value !== undefined ? value === props.value : undefined} onChange={onChange ? () => onChange(props.value) : undefined} {...props}/>)}
34
34
  </RadioContext.Consumer>);
35
- });
36
- export default RadioItem;
35
+ }
@@ -1,10 +1,10 @@
1
1
  import { Component } from 'react';
2
- import { type RadioProps } from './radio-item';
2
+ import RadioItem, { type RadioProps } from './radio-item';
3
3
  /**
4
4
  * @name Radio
5
5
  */
6
6
  export default class Radio extends Component<RadioProps> {
7
- static Item: import("react").ForwardRefExoticComponent<import("./radio-item").RadioItemProps & import("react").RefAttributes<import("./radio-item").RadioItemInner>>;
7
+ static Item: typeof RadioItem;
8
8
  uid: string;
9
9
  render(): import("react").JSX.Element;
10
10
  }
@@ -8,6 +8,6 @@ export default class Radio extends Component {
8
8
  static Item = RadioItem;
9
9
  uid = getUID('ring-radio-');
10
10
  render() {
11
- return <RadioContext.Provider value={{ name: this.uid, ...this.props }}>{this.props.children}</RadioContext.Provider>;
11
+ return <RadioContext value={{ name: this.uid, ...this.props }}>{this.props.children}</RadioContext>;
12
12
  }
13
13
  }
@@ -282,5 +282,7 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
282
282
  export type SingleSelectAttrs<T = unknown> = React.JSX.LibraryManagedAttributes<typeof Select, SingleSelectProps<T>>;
283
283
  export type MultipleSelectAttrs<T = unknown> = React.JSX.LibraryManagedAttributes<typeof Select, MultipleSelectProps<T>>;
284
284
  export type SelectAttrs<T = unknown> = React.JSX.LibraryManagedAttributes<typeof Select, SelectProps<T>>;
285
- export declare const RerenderableSelect: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<any>>;
285
+ export declare const RerenderableSelect: ({ ref, ...props }: Omit<any, "ref"> & {
286
+ ref?: Ref<any> | undefined;
287
+ }) => React.JSX.Element;
286
288
  export {};
@@ -1,11 +1,10 @@
1
- import { Fragment, useEffect, useRef, useState } from 'react';
1
+ import { Fragment, useEffect, useEffectEvent, useRef, useState } from 'react';
2
2
  import * as React from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { isArray } from '../global/typescript-utils';
5
5
  import Shortcuts from '../shortcuts/shortcuts';
6
6
  import getUID from '../global/get-uid';
7
7
  import { adjustValues, calculateMarks, calculateValue, HUNDRED, toPercent, toRange, validateValue } from './slider.utils';
8
- import useEventCallback from '../global/use-event-callback';
9
8
  import styles from './slider.css';
10
9
  export const Slider = ({ defaultValue, value, min = 0, max = HUNDRED, step = 1, disabled, marks, showTicks, showTag, className, renderTag, onChange, }) => {
11
10
  const ref = useRef(null);
@@ -86,7 +85,7 @@ export const Slider = ({ defaultValue, value, min = 0, max = HUNDRED, step = 1,
86
85
  setIsDragging(true);
87
86
  previouslyDragged.current = false;
88
87
  };
89
- const handleMouseUp = useEventCallback(({ pageX }) => {
88
+ const handleMouseUp = useEffectEvent(({ pageX }) => {
90
89
  const nextValues = adjustValues(validValues, ref, draggedIndex, pageX, max, min, validStep);
91
90
  if (nextValues[0] > nextValues[1]) {
92
91
  nextValues.reverse();
@@ -96,7 +95,7 @@ export const Slider = ({ defaultValue, value, min = 0, max = HUNDRED, step = 1,
96
95
  setIsDragging(false);
97
96
  previouslyDragged.current = true;
98
97
  });
99
- const handleMouseMove = useEventCallback(({ pageX }) => {
98
+ const handleMouseMove = useEffectEvent(({ pageX }) => {
100
99
  const nextValues = adjustValues(validValues, ref, draggedIndex, pageX, max, min, validStep);
101
100
  if (nextValues[0] > nextValues[1]) {
102
101
  nextValues.reverse();
@@ -120,7 +119,7 @@ export const Slider = ({ defaultValue, value, min = 0, max = HUNDRED, step = 1,
120
119
  window.removeEventListener('mousemove', handleMouseMove);
121
120
  window.removeEventListener('mouseup', handleMouseUp);
122
121
  };
123
- }, [isDragging, disabled, handleMouseMove, handleMouseUp]);
122
+ }, [isDragging, disabled]);
124
123
  return (<div ref={ref} role='presentation' // contains interactive elements
125
124
  className={classNames(styles.slider, className, {
126
125
  [styles.disabled]: disabled,
@@ -2,6 +2,7 @@ import { type HTMLAttributes, type ReactNode } from 'react';
2
2
  import * as React from 'react';
3
3
  export declare const FOCUSABLE_ELEMENTS = "input, button, select, textarea, a[href], *[tabindex]:not([data-trap-button]):not([data-scrollable-container])";
4
4
  export interface TabTrapProps extends HTMLAttributes<HTMLElement> {
5
+ ref?: React.Ref<TabTrapObject>;
5
6
  children: ReactNode;
6
7
  trapDisabled?: boolean;
7
8
  autoFocusFirst?: boolean;
@@ -11,8 +12,7 @@ export interface TabTrapProps extends HTMLAttributes<HTMLElement> {
11
12
  /**
12
13
  * @name TabTrap
13
14
  */
14
- interface TabTrap {
15
+ export interface TabTrapObject {
15
16
  node: HTMLElement | null;
16
17
  }
17
- declare const TabTrap: React.ForwardRefExoticComponent<TabTrapProps & React.RefAttributes<TabTrap>>;
18
- export default TabTrap;
18
+ export default function TabTrap({ ref, children, trapDisabled, autoFocusFirst, focusBackOnClose, focusBackOnExit, ...restProps }: TabTrapProps): React.JSX.Element;
@@ -1,10 +1,9 @@
1
- import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, } from 'react';
1
+ import { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
2
2
  import * as React from 'react';
3
3
  import { isNodeInVisiblePartOfPage } from '../global/dom';
4
4
  import styles from './tab-trap.css';
5
5
  export const FOCUSABLE_ELEMENTS = 'input, button, select, textarea, a[href], *[tabindex]:not([data-trap-button]):not([data-scrollable-container])';
6
- // eslint-disable-next-line no-shadow
7
- const TabTrap = forwardRef(function TabTrap({ children, trapDisabled = false, autoFocusFirst = true, focusBackOnClose = true, focusBackOnExit = false, ...restProps }, ref) {
6
+ export default function TabTrap({ ref, children, trapDisabled = false, autoFocusFirst = true, focusBackOnClose = true, focusBackOnExit = false, ...restProps }) {
8
7
  const nodeRef = useRef(null);
9
8
  const trapButtonNodeRef = useRef(null);
10
9
  const previousFocusedNodeRef = useRef(null);
@@ -121,5 +120,4 @@ const TabTrap = forwardRef(function TabTrap({ children, trapDisabled = false, au
121
120
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
122
121
  tabIndex={0} onFocus={restoreFocusOrFocusFirst} data-trap-button/>
123
122
  </div>);
124
- });
125
- export default TabTrap;
123
+ }
@@ -1,25 +1,36 @@
1
- import { type ComponentPropsWithoutRef } from 'react';
1
+ import { type ComponentPropsWithRef } from 'react';
2
2
  export interface DefaultItemRendererProps {
3
3
  /**
4
- * Installed on the `<tr>` element
4
+ * The index of the `data` item to render.
5
5
  */
6
- ref?: React.RefObject<HTMLTableRowElement | null>;
6
+ index: number;
7
7
  /**
8
- * The index of the `data` item to render
8
+ * If true, the row will be focusable with up/down arrow keys.
9
+ * Focus is implemented using the
10
+ * ["roving tabindex"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Guides/Keyboard-navigable_JavaScript_widgets#technique_1_roving_tabindex)
11
+ * technique, that is, only the focused row has `tabIndex={0}`.
12
+ *
13
+ * To focus the row on click or other user interaction, add e.g. `onClick()`
14
+ * and invoke `focusRow(e.currentTarget)` imported from `table-row-focus.ts`.
9
15
  */
10
- index: number;
16
+ keyboardFocusable?: boolean;
11
17
  /**
12
- * Changes the highlight on hover and applies the pointer cursor.
13
- * Note that `false` doesn't mean it cannot handle `onClick`.
18
+ * Changes the background on hover and applies the pointer cursor.
19
+ * Note that `false` does not mean the row cannot handle `onClick`.
14
20
  */
15
21
  clickable?: boolean;
22
+ /**
23
+ * If true, the row is highlighted as selected, that is, with the
24
+ * a different background color.
25
+ */
26
+ selected?: boolean;
16
27
  /**
17
28
  * A level of a nested item. Results in an indent for columns with `indent: true`.
18
- * 0, negative and not set mean no indent.
29
+ * 0, negative values, and an unset value mean no indent.
19
30
  */
20
31
  level?: number;
21
32
  }
22
33
  /**
23
34
  * @see TableProps.renderItem
24
35
  */
25
- export declare function DefaultItemRenderer<T>({ ref: userRef, index, clickable, level, className, onKeyDown, onBlur, ...restProps }: DefaultItemRendererProps & ComponentPropsWithoutRef<'tr'>): import("react").JSX.Element;
36
+ export declare function DefaultItemRenderer<T>({ index, keyboardFocusable, clickable, selected, level, ref: userRef, className, ...restProps }: DefaultItemRendererProps & ComponentPropsWithRef<'tr'>): import("react").JSX.Element | null;
@@ -1,50 +1,29 @@
1
- import { useContext, useEffect, useRef } from 'react';
1
+ import { use, useRef } from 'react';
2
2
  import classNames from 'classnames';
3
+ import { mergeRefs } from 'react-merge-refs';
3
4
  import { CollapseItemIntoSpacerContext, TablePropsContext } from './table-const';
4
5
  import { useIsIntersectingListener } from '../global/intersection-observer-context';
5
- import { TableCell, TableRow } from './table-base';
6
+ import { TableCell, TableRow } from './table-primitives';
6
7
  import styles from './table.css';
7
8
  const INDENT_SIZE = 24;
8
9
  /**
9
10
  * @see TableProps.renderItem
10
11
  */
11
- export function DefaultItemRenderer({ ref: userRef, index, clickable, level, className, onKeyDown, onBlur, ...restProps }) {
12
- const selfRef = useRef(null);
13
- const ref = userRef ?? selfRef;
14
- const collapseItemIntoSpacer = useContext(CollapseItemIntoSpacerContext);
15
- useIsIntersectingListener(ref, isIntersecting => {
16
- if (ref.current && !isIntersecting) {
17
- collapseItemIntoSpacer(ref.current.getBoundingClientRect().height);
12
+ export function DefaultItemRenderer({ index, keyboardFocusable, clickable, selected, level, ref: userRef, className, ...restProps }) {
13
+ const localRef = useRef(null);
14
+ const collapseItemIntoSpacer = use(CollapseItemIntoSpacerContext);
15
+ useIsIntersectingListener(localRef, isIntersecting => {
16
+ if (localRef.current && !isIntersecting) {
17
+ collapseItemIntoSpacer(localRef.current.getBoundingClientRect().height);
18
18
  }
19
19
  });
20
- const { data, columns, selection, isItemKeyboardFocusable, onItemFocus } = useContext(TablePropsContext);
21
- const item = data[index];
22
- const selected = selection?.isSelected(item);
23
- function handleKeyDown(e) {
24
- onKeyDown?.(e);
25
- if (!e.defaultPrevented && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
26
- const step = e.key === 'ArrowUp' ? -1 : 1;
27
- // eslint-disable-next-line yoda
28
- for (let i = index + step; 0 <= i && i < data.length; i += step) {
29
- if (isItemKeyboardFocusable?.(data[i], i, data)) {
30
- onItemFocus?.(data[i], i, data);
31
- break;
32
- }
33
- }
34
- }
20
+ const tableProps = use(TablePropsContext);
21
+ if (!tableProps) {
22
+ return null;
35
23
  }
36
- const focused = selection?.isFocused(item);
37
- useEffect(() => {
38
- if (focused)
39
- ref.current?.focus();
40
- }, [focused, ref]);
41
- function handleBlur(e) {
42
- onBlur?.(e);
43
- if (!e.defaultPrevented && focused) {
44
- onItemFocus?.(null, -1, data);
45
- }
46
- }
47
- return (<TableRow ref={ref} className={classNames(className, clickable && styles.clickableRow, selected && styles.selectedRow)} onKeyDown={handleKeyDown} tabIndex={focused ? 0 : undefined} onBlur={focused ? handleBlur : undefined} {...restProps}>
24
+ const { data, columns } = tableProps;
25
+ const item = data[index];
26
+ return (<TableRow ref={mergeRefs([userRef, localRef])} keyboardFocusable={keyboardFocusable} className={classNames(className, clickable && styles.clickableRow, selected && styles.selectedRow)} {...restProps}>
48
27
  {columns.map((column, columnIndex) => (<TableCell key={column.key} className={column.tdClassName?.(item, index, data)} style={column.indent && level != null && level > 0 ? { paddingInlineStart: `${level * INDENT_SIZE}px` } : undefined}>
49
28
  {column.renderCell?.(item, index, data) ?? getDefaultCellValue(item, columnIndex)}
50
29
  </TableCell>))}