@jetbrains/ring-ui 8.0.0-beta.2 → 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.
- package/babel.config.js +1 -1
- package/components/auth-dialog-service/auth-dialog-service.js +2 -2
- package/components/collapse/collapse-content.js +2 -2
- package/components/collapse/collapse-control.js +2 -2
- package/components/collapse/collapse.js +2 -2
- package/components/confirm-service/confirm-service.js +2 -2
- package/components/data-list/data-list.d.ts +1 -1
- package/components/data-list/data-list.mock.d.ts +1 -1
- package/components/data-list/item.d.ts +1 -1
- package/components/data-list/selection.d.ts +1 -1
- package/components/data-list/selection.js +1 -1
- package/components/date-picker/months.js +2 -2
- package/components/date-picker/use-scroll-behavior.js +5 -6
- package/components/date-picker/years.js +2 -2
- package/components/dialog/dialog.d.ts +2 -2
- package/components/dialog/dialog.js +2 -2
- package/components/dropdown-menu/dropdown-menu.d.ts +4 -4
- package/components/dropdown-menu/dropdown-menu.js +4 -4
- package/components/editable-heading/editable-heading.d.ts +1 -2
- package/components/editable-heading/editable-heading.js +5 -6
- package/components/expand/collapsible-group.d.ts +5 -1
- package/components/expand/collapsible-group.js +12 -12
- package/components/global/create-stateful-context.js +5 -5
- package/components/global/intersection-observer-context.d.ts +2 -2
- package/components/global/intersection-observer-context.js +5 -5
- package/components/global/rerender-hoc.d.ts +4 -2
- package/components/global/rerender-hoc.js +4 -4
- package/components/{legacy-table/selection.d.ts → global/table-selection.d.ts} +14 -14
- package/components/{legacy-table/selection.js → global/table-selection.js} +1 -1
- package/components/global/theme.d.ts +4 -3
- package/components/global/theme.js +8 -8
- package/components/i18n/i18n-context.js +1 -1
- package/components/island/adaptive-island-hoc.js +4 -4
- package/components/island/content.d.ts +7 -2
- package/components/island/content.js +5 -5
- package/components/legacy-table/cell.js +1 -1
- package/components/legacy-table/header-cell.js +1 -1
- package/components/legacy-table/header.js +1 -1
- package/components/legacy-table/multitable.d.ts +1 -1
- package/components/legacy-table/row.js +1 -1
- package/components/legacy-table/selection-adapter.d.ts +3 -3
- package/components/legacy-table/selection-shortcuts-hoc.d.ts +5 -5
- package/components/legacy-table/simple-table.d.ts +2 -2
- package/components/legacy-table/simple-table.js +3 -3
- package/components/legacy-table/smart-table.d.ts +5 -5
- package/components/legacy-table/smart-table.js +3 -3
- package/components/legacy-table/table.js +1 -1
- package/components/login-dialog/service.js +2 -2
- package/components/popup/popup.target.d.ts +3 -2
- package/components/popup/popup.target.js +4 -6
- package/components/query-assist/query-assist.d.ts +3 -1
- package/components/query-assist/query-assist.js +2 -2
- package/components/radio/radio-item.d.ts +3 -3
- package/components/radio/radio-item.js +3 -4
- package/components/radio/radio.d.ts +2 -2
- package/components/radio/radio.js +1 -1
- package/components/select/select.d.ts +3 -1
- package/components/slider/slider.js +4 -5
- package/components/tab-trap/tab-trap.d.ts +3 -3
- package/components/tab-trap/tab-trap.js +3 -5
- package/components/table/default-item-renderer.d.ts +20 -9
- package/components/table/default-item-renderer.js +15 -36
- package/components/table/table-component.d.ts +43 -16
- package/components/table/table-component.js +66 -37
- package/components/table/table-primitives.d.ts +28 -0
- package/components/table/{table-base.js → table-primitives.js} +22 -22
- package/components/table/table-row-focus.d.ts +4 -0
- package/components/table/table-row-focus.js +42 -0
- package/components/table/table-virtualize.d.ts +3 -3
- package/components/table/table-virtualize.js +13 -14
- package/components/table/table.d.ts +9 -24
- package/components/tags-input/tags-input.d.ts +3 -1
- package/components/tooltip/tooltip.js +2 -2
- package/components/upload/upload.d.ts +4 -3
- package/components/upload/upload.js +3 -7
- package/components/user-agreement/service.js +2 -2
- package/package.json +20 -19
- package/components/global/use-event-callback.d.ts +0 -1
- package/components/global/use-event-callback.js +0 -15
- package/components/table/table-base.d.ts +0 -24
- /package/components/legacy-table/{table.css → legacy-table.css} +0 -0
package/babel.config.js
CHANGED
|
@@ -8,7 +8,7 @@ module.exports = function config(api) {
|
|
|
8
8
|
[
|
|
9
9
|
'babel-plugin-react-compiler',
|
|
10
10
|
{
|
|
11
|
-
target: '
|
|
11
|
+
target: '19', // should be the minimal supported version from peerDependencies
|
|
12
12
|
panicThreshold: 'all_errors',
|
|
13
13
|
},
|
|
14
14
|
],
|
|
@@ -10,9 +10,9 @@ export const reactRoot = createRoot(containerElement);
|
|
|
10
10
|
* Renders AuthDialog into virtual node to skip maintaining container
|
|
11
11
|
*/
|
|
12
12
|
function renderAuthDialog(props) {
|
|
13
|
-
reactRoot.render(<ControlsHeightContext
|
|
13
|
+
reactRoot.render(<ControlsHeightContext value={getGlobalControlsHeight()}>
|
|
14
14
|
<AuthDialog {...props}/>
|
|
15
|
-
</ControlsHeightContext
|
|
15
|
+
</ControlsHeightContext>);
|
|
16
16
|
}
|
|
17
17
|
export default function showAuthDialog(props = {}) {
|
|
18
18
|
renderAuthDialog({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef,
|
|
1
|
+
import React, { useState, useEffect, useRef, use } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import dataTests from '../global/data-tests';
|
|
4
4
|
import { getRect } from '../global/dom';
|
|
@@ -14,7 +14,7 @@ const HIDDEN = 0;
|
|
|
14
14
|
* @name CollapseContent
|
|
15
15
|
*/
|
|
16
16
|
export const CollapseContent = ({ children, minHeight = DEFAULT_HEIGHT, 'data-test': dataTest, }) => {
|
|
17
|
-
const { collapsed, duration, id, disableAnimation } =
|
|
17
|
+
const { collapsed, duration, id, disableAnimation } = use(CollapseContext);
|
|
18
18
|
const containerRef = useRef(null);
|
|
19
19
|
const contentRef = useRef(null);
|
|
20
20
|
const [initialContentHeight] = useState(minHeight);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { use, cloneElement } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import dataTests from '../global/data-tests';
|
|
4
4
|
import { CollapseContext } from './collapse-context';
|
|
@@ -7,7 +7,7 @@ import { COLLAPSE_CONTROL_TEST_ID } from './consts';
|
|
|
7
7
|
* @name CollapseControl
|
|
8
8
|
*/
|
|
9
9
|
export const CollapseControl = ({ children, 'data-test': dataTest }) => {
|
|
10
|
-
const { setCollapsed, collapsed, id } =
|
|
10
|
+
const { setCollapsed, collapsed, id } = use(CollapseContext);
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
const child = typeof children === 'function' ? children(collapsed) : children;
|
|
13
13
|
return (<p data-test={dataTests(COLLAPSE_CONTROL_TEST_ID, dataTest)}>
|
|
@@ -14,7 +14,7 @@ export const Collapse = ({ children, duration = BASE_ANIMATION_DURATION, disable
|
|
|
14
14
|
onChange(!finalCollapsedValue);
|
|
15
15
|
};
|
|
16
16
|
return (<div className={className}>
|
|
17
|
-
<CollapseContext
|
|
17
|
+
<CollapseContext value={{
|
|
18
18
|
collapsed: finalCollapsedValue,
|
|
19
19
|
setCollapsed,
|
|
20
20
|
duration,
|
|
@@ -22,7 +22,7 @@ export const Collapse = ({ children, duration = BASE_ANIMATION_DURATION, disable
|
|
|
22
22
|
id,
|
|
23
23
|
}}>
|
|
24
24
|
{children}
|
|
25
|
-
</CollapseContext
|
|
25
|
+
</CollapseContext>
|
|
26
26
|
</div>);
|
|
27
27
|
};
|
|
28
28
|
export default Collapse;
|
|
@@ -8,9 +8,9 @@ export const reactRoot = createRoot(containerElement);
|
|
|
8
8
|
*/
|
|
9
9
|
function renderConfirm(props) {
|
|
10
10
|
const { buttonsHeight = getGlobalControlsHeight(), ...restProps } = props;
|
|
11
|
-
reactRoot.render(<ControlsHeightContext
|
|
11
|
+
reactRoot.render(<ControlsHeightContext value={buttonsHeight}>
|
|
12
12
|
<Confirm {...restProps}/>
|
|
13
|
-
</ControlsHeightContext
|
|
13
|
+
</ControlsHeightContext>);
|
|
14
14
|
}
|
|
15
15
|
export default function confirm({ text, description, confirmLabel = 'OK', rejectLabel = 'Cancel', cancelIsDefault, onBeforeConfirm, buttonsHeight, }) {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
@@ -5,7 +5,7 @@ import { Component } from 'react';
|
|
|
5
5
|
import { type FocusSensorOuterProps } from '../global/focus-sensor-hoc';
|
|
6
6
|
import { type SelectionShortcutsAddProps, type SelectionShortcutsOuterProps } from '../legacy-table/selection-shortcuts-hoc';
|
|
7
7
|
import { type DisableHoverAddProps } from '../legacy-table/disable-hover-hoc';
|
|
8
|
-
import { type SelectionItem } from '../
|
|
8
|
+
import { type SelectionItem } from '../global/table-selection';
|
|
9
9
|
import { type FormattedItem, moreLessButtonStates } from './item';
|
|
10
10
|
export interface DataListBaseProps<T extends SelectionItem> {
|
|
11
11
|
data: readonly T[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PureComponent, type ReactNode } from 'react';
|
|
2
|
-
import { type SelectionItem } from '../
|
|
2
|
+
import { type SelectionItem } from '../global/table-selection';
|
|
3
3
|
import type Selection from './selection';
|
|
4
4
|
export declare enum moreLessButtonStates {
|
|
5
5
|
UNUSED = 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import TableSelection, { type CloneWithConfig, type SelectionItem, type TableSelectionConfig } from '../
|
|
1
|
+
import TableSelection, { type CloneWithConfig, type SelectionItem, type TableSelectionConfig } from '../global/table-selection';
|
|
2
2
|
interface DataListSelectionConfig<T extends SelectionItem> extends TableSelectionConfig<T> {
|
|
3
3
|
partialSelected?: Set<T> | undefined;
|
|
4
4
|
}
|
|
@@ -29,9 +29,9 @@ const intersectionObserverRootMargin = units.cellSize * 2;
|
|
|
29
29
|
export default function Months(props) {
|
|
30
30
|
const { scrollDate, setScrollDate, locale } = props;
|
|
31
31
|
const { containerRef, items } = useScrollBehavior(scrollDate, setScrollDate, locale, 'monthsScroll', scrollArith, scheduleScroll);
|
|
32
|
-
return (<IntersectionObserverContext
|
|
32
|
+
return (<IntersectionObserverContext value={useIntersectionObserverHandle(containerRef, intersectionObserverRootMargin)}>
|
|
33
33
|
<div className={styles.months} ref={containerRef} data-test='ring-date-popup--months'>
|
|
34
34
|
{items.map(month => (<Month {...props} month={month} key={+month}/>))}
|
|
35
35
|
</div>
|
|
36
|
-
</IntersectionObserverContext
|
|
36
|
+
</IntersectionObserverContext>);
|
|
37
37
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import units, { isSafariOnIPhone, scrollerReRenderDelayIPhone } from './consts';
|
|
3
|
-
import useEventCallback from '../global/use-event-callback';
|
|
4
3
|
export function useScrollBehavior(scrollDate, onContainerScroll, locale, selfScrollDateSource, arith, scheduleScroll) {
|
|
5
4
|
const [items, setItems] = useState(() => arith.getItems(scrollDate.date));
|
|
6
5
|
const [scrollTop, setScrollTop] = useState(() => arith.getScrollTop(items, scrollDate.date, locale));
|
|
7
6
|
const containerRef = useRef(null);
|
|
8
|
-
const syncSelfState =
|
|
7
|
+
const syncSelfState = useEffectEvent((newScrollDate) => {
|
|
9
8
|
const newScrollTopOnExistingItems = arith.getScrollTop(items, newScrollDate, locale);
|
|
10
9
|
if (isNearEdge(newScrollTopOnExistingItems, containerRef.current)) {
|
|
11
10
|
const { newItems, newScrollTop } = arith.getItemsAndScrollTop(newScrollDate, locale);
|
|
@@ -28,7 +27,7 @@ export function useScrollBehavior(scrollDate, onContainerScroll, locale, selfScr
|
|
|
28
27
|
if (scrollDate.source === selfScrollDateSource)
|
|
29
28
|
return;
|
|
30
29
|
syncSelfState(scrollDate.date);
|
|
31
|
-
}, [scrollDate, selfScrollDateSource
|
|
30
|
+
}, [scrollDate, selfScrollDateSource]);
|
|
32
31
|
const ignoreNextScrollEventRef = useRef(true);
|
|
33
32
|
useLayoutEffect(function setContainerScrollFromState() {
|
|
34
33
|
const container = containerRef.current;
|
|
@@ -38,7 +37,7 @@ export function useScrollBehavior(scrollDate, onContainerScroll, locale, selfScr
|
|
|
38
37
|
container.scrollTop = scrollTop;
|
|
39
38
|
}, [items, scrollTop]);
|
|
40
39
|
const updateStateTimerRef = useRef(null);
|
|
41
|
-
const handleScroll =
|
|
40
|
+
const handleScroll = useEffectEvent(() => {
|
|
42
41
|
scheduleScroll(() => {
|
|
43
42
|
if (updateStateTimerRef.current != null) {
|
|
44
43
|
window.clearTimeout(updateStateTimerRef.current);
|
|
@@ -83,7 +82,7 @@ export function useScrollBehavior(scrollDate, onContainerScroll, locale, selfScr
|
|
|
83
82
|
updateStateTimerRef.current = null;
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
|
-
}, [
|
|
85
|
+
}, []);
|
|
87
86
|
return { containerRef, items };
|
|
88
87
|
}
|
|
89
88
|
function isNearEdge(scrollTop, container) {
|
|
@@ -87,11 +87,11 @@ export default function Years({ scrollDate, setScrollDate }) {
|
|
|
87
87
|
}, yearsAnimationDuration);
|
|
88
88
|
}, [localScrollDate.date, setScrollDate]);
|
|
89
89
|
const { containerRef, items } = useScrollBehavior(localScrollDate, syncCalendarScrollDate, undefined, 'yearsScroll', scrollArith, scheduleScroll);
|
|
90
|
-
return (<IntersectionObserverContext
|
|
90
|
+
return (<IntersectionObserverContext value={useIntersectionObserverHandle(containerRef, intersectionObserverRootMargin)}>
|
|
91
91
|
<div className={styles.years} ref={containerRef} data-test='ring-date-popup--years'>
|
|
92
92
|
{items.map(year => (<Year year={year} scrollDate={localScrollDate.date} handleYearClick={handleYearClick} key={+year}/>))}
|
|
93
93
|
</div>
|
|
94
|
-
</IntersectionObserverContext
|
|
94
|
+
</IntersectionObserverContext>);
|
|
95
95
|
}
|
|
96
96
|
function Year({ year, scrollDate, handleYearClick, }) {
|
|
97
97
|
const buttonRef = useRef(null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PureComponent } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { type TabTrapObject, type TabTrapProps } from '../tab-trap/tab-trap';
|
|
4
4
|
import type { ShortcutsScopeOptions } from '../shortcuts/core';
|
|
5
5
|
export interface DialogProps extends Partial<TabTrapProps> {
|
|
6
6
|
show: boolean;
|
|
@@ -43,7 +43,7 @@ export default class Dialog extends PureComponent<DialogProps> {
|
|
|
43
43
|
esc: (event: KeyboardEvent) => void;
|
|
44
44
|
};
|
|
45
45
|
dialog?: HTMLElement | null;
|
|
46
|
-
dialogRef: (
|
|
46
|
+
dialogRef: (tabTrapObj: TabTrapObject | null) => void;
|
|
47
47
|
nativeDialog: React.RefObject<HTMLDialogElement | null>;
|
|
48
48
|
render(): false | React.JSX.Element;
|
|
49
49
|
}
|
|
@@ -104,8 +104,8 @@ export default class Dialog extends PureComponent {
|
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
dialog;
|
|
107
|
-
dialogRef = (
|
|
108
|
-
this.dialog =
|
|
107
|
+
dialogRef = (tabTrapObj) => {
|
|
108
|
+
this.dialog = tabTrapObj && tabTrapObj.node;
|
|
109
109
|
};
|
|
110
110
|
nativeDialog = createRef();
|
|
111
111
|
render() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactElement, type HTMLAttributes, type SyntheticEvent, type
|
|
1
|
+
import { type ReactElement, type HTMLAttributes, type SyntheticEvent, type ReactNode } from 'react';
|
|
2
2
|
import { type SelectHandlerParams } from '../list/list';
|
|
3
3
|
import { type AnchorProps, type DropdownAttrs, type DropdownChildrenFunction } from '../dropdown/dropdown';
|
|
4
4
|
import PopupMenu, { type PopupMenuAttrs } from '../popup-menu/popup-menu';
|
|
@@ -10,6 +10,7 @@ export interface DropdownAnchorWrapperProps extends AnchorProps {
|
|
|
10
10
|
}
|
|
11
11
|
type OnSelectHandler<T> = ((item: ListDataItem<T>, event: Event | SyntheticEvent, params?: SelectHandlerParams) => void) | undefined;
|
|
12
12
|
export interface DropdownMenuProps<T = unknown> extends Omit<DropdownAttrs, 'anchor' | 'onSelect' | 'children'> {
|
|
13
|
+
ref?: React.Ref<PopupMenu<T> | null>;
|
|
13
14
|
anchor: ReactElement | ReactNode[] | string | ((props: AnchorProps, ariaProps: HTMLAttributes<HTMLElement>) => ReactElement | null);
|
|
14
15
|
data?: readonly ListDataItem<T>[] | undefined;
|
|
15
16
|
ariaLabel?: string | null | undefined;
|
|
@@ -17,9 +18,8 @@ export interface DropdownMenuProps<T = unknown> extends Omit<DropdownAttrs, 'anc
|
|
|
17
18
|
menuProps?: PopupMenuAttrs<T> | null | undefined;
|
|
18
19
|
children?: DropdownChildrenFunction;
|
|
19
20
|
}
|
|
20
|
-
declare
|
|
21
|
-
|
|
22
|
-
}) => ReactElement | null) & {
|
|
21
|
+
declare function DropdownMenu<T = unknown>({ ref, id, anchor, ariaLabel, data, onSelect, menuProps, children, ...restDropdownProps }: DropdownMenuProps<T>): import("react").JSX.Element;
|
|
22
|
+
declare const _default: typeof DropdownMenu & {
|
|
23
23
|
ListProps: {
|
|
24
24
|
Type: typeof import("../list/consts").Type;
|
|
25
25
|
Dimension: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cloneElement, useState, } from 'react';
|
|
2
2
|
import List, { ActiveItemContext } from '../list/list';
|
|
3
3
|
import Dropdown from '../dropdown/dropdown';
|
|
4
4
|
import PopupMenu from '../popup-menu/popup-menu';
|
|
@@ -31,11 +31,11 @@ function renderDropdownMenuChildren({ children, popupMenuProps }) {
|
|
|
31
31
|
}
|
|
32
32
|
return (popupProps) => children({ ...popupProps, ...popupMenuProps });
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
function DropdownMenu({ ref, id, anchor, ariaLabel, data, onSelect, menuProps, children, ...restDropdownProps }) {
|
|
35
35
|
const [uid] = useState(() => getUID('dropdown-menu-list'));
|
|
36
36
|
const listId = id || uid;
|
|
37
37
|
const popupMenuProps = {
|
|
38
|
-
ref
|
|
38
|
+
ref,
|
|
39
39
|
id: listId,
|
|
40
40
|
ariaLabel: ariaLabel || defaultAriaLabel,
|
|
41
41
|
closeOnSelect: true,
|
|
@@ -51,5 +51,5 @@ const DropdownMenu = forwardRef(function DropdownMenu({ id, anchor, ariaLabel, d
|
|
|
51
51
|
{renderDropdownMenuChildren({ children, popupMenuProps })}
|
|
52
52
|
</Dropdown>
|
|
53
53
|
</ActiveItemContext.Provider>);
|
|
54
|
-
}
|
|
54
|
+
}
|
|
55
55
|
export default Object.assign(DropdownMenu, { ListProps: List.ListProps });
|
|
@@ -29,5 +29,4 @@ export type EditableHeadingProps = Omit<InputHTMLAttributes<HTMLInputElement | H
|
|
|
29
29
|
translations?: EditableHeadingTranslations;
|
|
30
30
|
};
|
|
31
31
|
export declare const EditableHeading: (props: EditableHeadingProps) => React.JSX.Element;
|
|
32
|
-
|
|
33
|
-
export default _default;
|
|
32
|
+
export default EditableHeading;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
1
|
+
import { useEffect, useEffectEvent } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import Heading, { Levels } from '../heading/heading';
|
|
@@ -6,7 +6,6 @@ import Button from '../button/button';
|
|
|
6
6
|
import { Size } from '../input/input';
|
|
7
7
|
import getUID from '../global/get-uid';
|
|
8
8
|
import Shortcuts from '../shortcuts/shortcuts';
|
|
9
|
-
import useEventCallback from '../global/use-event-callback';
|
|
10
9
|
import inputStyles from '../input/input.css';
|
|
11
10
|
import styles from './editable-heading.css';
|
|
12
11
|
export { Levels };
|
|
@@ -69,13 +68,13 @@ export const EditableHeading = (props) => {
|
|
|
69
68
|
const onHeadingMouseDown = () => {
|
|
70
69
|
setIsMouseDown(true);
|
|
71
70
|
};
|
|
72
|
-
const onMouseMove =
|
|
71
|
+
const onMouseMove = useEffectEvent(() => {
|
|
73
72
|
if (!isMouseDown) {
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
76
75
|
setIsInSelectionMode(true);
|
|
77
76
|
});
|
|
78
|
-
const onMouseUp =
|
|
77
|
+
const onMouseUp = useEffectEvent(() => {
|
|
79
78
|
if (isMouseDown && !isInSelectionMode && !disabled) {
|
|
80
79
|
onEdit();
|
|
81
80
|
}
|
|
@@ -108,7 +107,7 @@ export const EditableHeading = (props) => {
|
|
|
108
107
|
window.removeEventListener('mousemove', onMouseMove);
|
|
109
108
|
window.removeEventListener('mouseup', onMouseUp);
|
|
110
109
|
};
|
|
111
|
-
}, [
|
|
110
|
+
}, []);
|
|
112
111
|
return (<>
|
|
113
112
|
<div className={classes}>
|
|
114
113
|
{!disabled && isEditing ? (<>
|
|
@@ -140,4 +139,4 @@ export const EditableHeading = (props) => {
|
|
|
140
139
|
{isEditing && error && (<div className={classNames(styles.errorText, size !== Size.AUTO && inputStyles[`size${size}`])}>{error}</div>)}
|
|
141
140
|
</>);
|
|
142
141
|
};
|
|
143
|
-
export default
|
|
142
|
+
export default EditableHeading;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface CollapsibleGroupProps {
|
|
3
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
3
4
|
avatar?: React.ReactNode;
|
|
4
5
|
title: React.ReactNode;
|
|
5
6
|
subtitle?: React.ReactNode;
|
|
@@ -12,5 +13,8 @@ export interface CollapsibleGroupProps {
|
|
|
12
13
|
interactive?: boolean;
|
|
13
14
|
'data-test'?: string | null | undefined;
|
|
14
15
|
}
|
|
15
|
-
declare const CollapsibleGroup:
|
|
16
|
+
declare const CollapsibleGroup: {
|
|
17
|
+
({ ref, avatar, title, subtitle, children, className, defaultExpanded, expanded, onChange, disableAnimation, interactive, "data-test": dataTest, }: CollapsibleGroupProps): React.JSX.Element;
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
16
20
|
export default CollapsibleGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { use, useState } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import chevronRightIcon from '@jetbrains/icons/chevron-12px-right';
|
|
4
4
|
import chevronDownIcon from '@jetbrains/icons/chevron-12px-down';
|
|
@@ -8,7 +8,7 @@ import CollapseContent from '../collapse/collapse-content';
|
|
|
8
8
|
import { CollapseContext } from '../collapse/collapse-context';
|
|
9
9
|
import styles from './collapsible-group.css';
|
|
10
10
|
function CollapsibleGroupHeaderContent({ avatar, titleContent, subtitle }) {
|
|
11
|
-
const { collapsed } =
|
|
11
|
+
const { collapsed } = use(CollapseContext);
|
|
12
12
|
return (<span className={styles.header}>
|
|
13
13
|
<span className={styles.headerContent}>
|
|
14
14
|
<span className={styles.avatarGroup}>
|
|
@@ -26,7 +26,7 @@ function CollapsibleGroupHeaderContent({ avatar, titleContent, subtitle }) {
|
|
|
26
26
|
</span>);
|
|
27
27
|
}
|
|
28
28
|
function CollapsibleGroupHeader({ avatar, titleContent, subtitle, ...buttonProps }) {
|
|
29
|
-
const { setCollapsed, collapsed, id } =
|
|
29
|
+
const { setCollapsed, collapsed, id } = use(CollapseContext);
|
|
30
30
|
return (<button type='button' {...buttonProps} className={styles.headerButton} onClick={setCollapsed} aria-controls={`collapse-content-${id}`} aria-expanded={!collapsed}>
|
|
31
31
|
<CollapsibleGroupHeaderContent avatar={avatar} titleContent={titleContent} subtitle={subtitle}/>
|
|
32
32
|
</button>);
|
|
@@ -36,7 +36,7 @@ function CollapsibleGroupHeaderStatic({ avatar, titleContent, subtitle }) {
|
|
|
36
36
|
<CollapsibleGroupHeaderContent avatar={avatar} titleContent={titleContent} subtitle={subtitle}/>
|
|
37
37
|
</span>);
|
|
38
38
|
}
|
|
39
|
-
const CollapsibleGroup =
|
|
39
|
+
const CollapsibleGroup = ({ ref, avatar, title, subtitle, children, className, defaultExpanded = false, expanded = null, onChange = () => { }, disableAnimation = false, interactive = true, 'data-test': dataTest, }) => {
|
|
40
40
|
const [innerExpanded, setInnerExpanded] = useState(defaultExpanded);
|
|
41
41
|
const [hovered, setHovered] = useState(false);
|
|
42
42
|
const [focused, setFocused] = useState(false);
|
|
@@ -61,13 +61,13 @@ const CollapsibleGroup = forwardRef(({ avatar, title, subtitle, children, classN
|
|
|
61
61
|
[styles.focused]: focused,
|
|
62
62
|
});
|
|
63
63
|
return (<div ref={ref} className={classes} data-test={dataTest}>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
64
|
+
<Collapse defaultCollapsed={!defaultExpanded} collapsed={expanded == null ? null : !expanded} onChange={handleChange} disableAnimation={disableAnimation} className={styles.collapseRoot}>
|
|
65
|
+
{interactive ? (<CollapsibleGroupHeader avatar={avatar} titleContent={title} subtitle={subtitle} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} onFocus={() => setFocused(true)} onBlur={onBlur}/>) : (<CollapsibleGroupHeaderStatic avatar={avatar} titleContent={title} subtitle={subtitle}/>)}
|
|
66
|
+
<CollapseContent>
|
|
67
|
+
<div className={styles.body}>{children}</div>
|
|
68
|
+
</CollapseContent>
|
|
69
|
+
</Collapse>
|
|
70
|
+
</div>);
|
|
71
|
+
};
|
|
72
72
|
CollapsibleGroup.displayName = 'CollapsibleGroup';
|
|
73
73
|
export default CollapsibleGroup;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createContext, memo,
|
|
1
|
+
import { createContext, memo, use, useEffect, useState } from 'react';
|
|
2
2
|
export default function createStatefulContext(initialValue, name = '') {
|
|
3
3
|
const ValueContext = createContext(initialValue);
|
|
4
4
|
const UpdateContext = createContext(() => { });
|
|
5
5
|
function Provider({ children }) {
|
|
6
6
|
const [value, update] = useState(initialValue);
|
|
7
|
-
return (<ValueContext
|
|
8
|
-
<UpdateContext
|
|
9
|
-
</ValueContext
|
|
7
|
+
return (<ValueContext value={value}>
|
|
8
|
+
<UpdateContext value={update}>{children}</UpdateContext>
|
|
9
|
+
</ValueContext>);
|
|
10
10
|
}
|
|
11
11
|
Provider.displayName = `${name}Provider`;
|
|
12
12
|
function useUpdate(value, skipUpdate) {
|
|
13
|
-
const update =
|
|
13
|
+
const update = use(UpdateContext);
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
if (!skipUpdate) {
|
|
16
16
|
update(value);
|
|
@@ -3,9 +3,9 @@ import { type RefObject } from 'react';
|
|
|
3
3
|
* Usage:
|
|
4
4
|
*
|
|
5
5
|
* ```tsx
|
|
6
|
-
* <IntersectionObserverContext
|
|
6
|
+
* <IntersectionObserverContext value={useIntersectionObserverHandle()}>
|
|
7
7
|
* <YourComponent />
|
|
8
|
-
* </IntersectionObserverContext
|
|
8
|
+
* </IntersectionObserverContext>
|
|
9
9
|
*
|
|
10
10
|
* function YourComponent() {
|
|
11
11
|
* // Contains the current isIntersecting value
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createContext,
|
|
1
|
+
import { createContext, use, useEffect, useState } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Usage:
|
|
4
4
|
*
|
|
5
5
|
* ```tsx
|
|
6
|
-
* <IntersectionObserverContext
|
|
6
|
+
* <IntersectionObserverContext value={useIntersectionObserverHandle()}>
|
|
7
7
|
* <YourComponent />
|
|
8
|
-
* </IntersectionObserverContext
|
|
8
|
+
* </IntersectionObserverContext>
|
|
9
9
|
*
|
|
10
10
|
* function YourComponent() {
|
|
11
11
|
* // Contains the current isIntersecting value
|
|
@@ -51,7 +51,7 @@ export function useIntersectionObserverHandle(rootRef, rootMargin, scrollMargin)
|
|
|
51
51
|
return handle;
|
|
52
52
|
}
|
|
53
53
|
export function useIsIntersecting(elementRef) {
|
|
54
|
-
const handle =
|
|
54
|
+
const handle = use(IntersectionObserverContext);
|
|
55
55
|
const [isIntersecting, setIsIntersecting] = useState(false);
|
|
56
56
|
useEffect(() => {
|
|
57
57
|
const element = elementRef.current;
|
|
@@ -62,7 +62,7 @@ export function useIsIntersecting(elementRef) {
|
|
|
62
62
|
return isIntersecting;
|
|
63
63
|
}
|
|
64
64
|
export function useIsIntersectingListener(elementRef, onChange) {
|
|
65
|
-
const handle =
|
|
65
|
+
const handle = use(IntersectionObserverContext);
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
const element = elementRef.current;
|
|
68
68
|
if (!element || !handle)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, type PropsWithoutRef } from 'react';
|
|
1
|
+
import { Component, type Ref, type PropsWithoutRef } from 'react';
|
|
2
2
|
export interface RerenderableComponent<P, S> extends Component<P, S> {
|
|
3
3
|
node?: HTMLElement | null;
|
|
4
4
|
}
|
|
@@ -7,4 +7,6 @@ export interface RerenderableComponentClass<P, S> {
|
|
|
7
7
|
}
|
|
8
8
|
export default function rerenderHOC<P extends {}, C extends Component<P, unknown>>(ComposedComponent: {
|
|
9
9
|
new (props: P): C;
|
|
10
|
-
}):
|
|
10
|
+
}): ({ ref, ...props }: PropsWithoutRef<P> & {
|
|
11
|
+
ref?: Ref<C>;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component
|
|
1
|
+
import { Component } from 'react';
|
|
2
2
|
import { createComposedRef } from './compose-refs';
|
|
3
3
|
export default function rerenderHOC(ComposedComponent) {
|
|
4
4
|
class Rerenderer extends Component {
|
|
@@ -9,7 +9,7 @@ export default function rerenderHOC(ComposedComponent) {
|
|
|
9
9
|
return (<ComposedComponent {...this.state} ref={instance => ref(instance ? { ...instance, rerender: this.setState.bind(this) } : null)}/>);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
return
|
|
13
|
-
return <Rerenderer props={props} forwardedRef={ref}/>;
|
|
14
|
-
}
|
|
12
|
+
return function RerendererForwardRef({ ref, ...props }) {
|
|
13
|
+
return <Rerenderer props={props} forwardedRef={ref ?? null}/>;
|
|
14
|
+
};
|
|
15
15
|
}
|
|
@@ -17,7 +17,7 @@ export interface CloneWithConfig<T> {
|
|
|
17
17
|
selected?: Set<T> | readonly T[] | null | undefined;
|
|
18
18
|
focused?: T | null | undefined;
|
|
19
19
|
}
|
|
20
|
-
export default class
|
|
20
|
+
export default class TableSelection<T> {
|
|
21
21
|
protected _rawData: readonly T[];
|
|
22
22
|
protected _getChildren: (item: T) => readonly T[];
|
|
23
23
|
protected _data: Set<T>;
|
|
@@ -28,19 +28,19 @@ export default class Selection<T> {
|
|
|
28
28
|
constructor({ data, selected, focused, getKey, getChildren, isItemSelectable, }?: TableSelectionConfig<T>);
|
|
29
29
|
protected _buildData(data: readonly T[] | null | undefined): Set<T>;
|
|
30
30
|
protected _buildSelected(data: Set<T>, selected: Set<T>): Set<T>;
|
|
31
|
-
cloneWith({ data, selected, focused }: CloneWithConfig<T>):
|
|
32
|
-
focus(value: T | null | undefined):
|
|
33
|
-
moveUp():
|
|
34
|
-
moveDown():
|
|
35
|
-
moveStart():
|
|
36
|
-
moveEnd():
|
|
37
|
-
select(value?: T | null):
|
|
38
|
-
deselect(value?: T | null):
|
|
39
|
-
toggleSelection(value?: T | null):
|
|
40
|
-
selectAll():
|
|
41
|
-
resetFocus():
|
|
42
|
-
resetSelection():
|
|
43
|
-
reset():
|
|
31
|
+
cloneWith({ data, selected, focused }: CloneWithConfig<T>): TableSelection<T>;
|
|
32
|
+
focus(value: T | null | undefined): TableSelection<T>;
|
|
33
|
+
moveUp(): TableSelection<T> | undefined;
|
|
34
|
+
moveDown(): TableSelection<T> | undefined;
|
|
35
|
+
moveStart(): TableSelection<T> | undefined;
|
|
36
|
+
moveEnd(): TableSelection<T> | undefined;
|
|
37
|
+
select(value?: T | null): TableSelection<T>;
|
|
38
|
+
deselect(value?: T | null): TableSelection<T>;
|
|
39
|
+
toggleSelection(value?: T | null): TableSelection<T>;
|
|
40
|
+
selectAll(): TableSelection<T>;
|
|
41
|
+
resetFocus(): TableSelection<T>;
|
|
42
|
+
resetSelection(): TableSelection<T>;
|
|
43
|
+
reset(): TableSelection<T>;
|
|
44
44
|
isFocused(value: T | null): boolean;
|
|
45
45
|
isSelected(value: T | null): boolean;
|
|
46
46
|
getFocused(): T | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated SelectionItem is deprecated. Use your own item type and provide a `getKey` function instead if there is no `id` identifier in your item type.
|
|
3
3
|
*/
|
|
4
|
-
export default class
|
|
4
|
+
export default class TableSelection {
|
|
5
5
|
_rawData;
|
|
6
6
|
_getChildren;
|
|
7
7
|
_data;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLAttributes, type ReactElement, type FunctionComponent } from 'react';
|
|
1
|
+
import { type HTMLAttributes, type Ref, type ReactElement, type FunctionComponent } from 'react';
|
|
2
2
|
declare enum Theme {
|
|
3
3
|
AUTO = "auto",
|
|
4
4
|
LIGHT = "light",
|
|
@@ -18,11 +18,12 @@ export interface WithThemeClassesProps {
|
|
|
18
18
|
export declare function WithThemeClasses({ theme, children }: WithThemeClassesProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
19
19
|
export declare function applyTheme(theme: Theme.DARK | Theme.LIGHT, container: HTMLElement): void;
|
|
20
20
|
type WrapperType = FunctionComponent<HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>;
|
|
21
|
-
export interface ThemeProviderProps extends HTMLAttributes<
|
|
21
|
+
export interface ThemeProviderProps extends HTMLAttributes<HTMLElement> {
|
|
22
|
+
ref?: Ref<HTMLElement>;
|
|
22
23
|
theme?: Theme;
|
|
23
24
|
passToPopups?: boolean;
|
|
24
25
|
WrapperComponent?: WrapperType;
|
|
25
26
|
target?: HTMLElement;
|
|
26
27
|
}
|
|
27
|
-
export declare
|
|
28
|
+
export declare function ThemeProvider({ ref, ...props }: ThemeProviderProps): import("react").JSX.Element;
|
|
28
29
|
export default Theme;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect,
|
|
1
|
+
import { useState, useEffect, createContext, } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import defaultStyles from './variables.css';
|
|
4
4
|
import styles from './variables_dark.css';
|
|
@@ -47,9 +47,9 @@ export function applyTheme(theme, container) {
|
|
|
47
47
|
container.classList.add(defaultStyles.light);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
return <div {...props}
|
|
52
|
-
}
|
|
50
|
+
function DefaultWrapper(props) {
|
|
51
|
+
return <div {...props}/>;
|
|
52
|
+
}
|
|
53
53
|
function ThemeProviderInner({ theme = Theme.AUTO, className, passToPopups, children, WrapperComponent = DefaultWrapper, target, wrapperRef, ...restProps }) {
|
|
54
54
|
const systemTheme = useTheme();
|
|
55
55
|
const resolvedTheme = theme === Theme.AUTO ? systemTheme : theme;
|
|
@@ -60,13 +60,13 @@ function ThemeProviderInner({ theme = Theme.AUTO, className, passToPopups, child
|
|
|
60
60
|
}
|
|
61
61
|
}, [resolvedTheme, target]);
|
|
62
62
|
const themeClasses = useThemeClasses(theme);
|
|
63
|
-
return (<ThemeContext
|
|
63
|
+
return (<ThemeContext value={themeValue}>
|
|
64
64
|
<WrapperComponent ref={wrapperRef} className={target ? undefined : classNames(className, themeClasses)} {...restProps}>
|
|
65
65
|
{children}
|
|
66
66
|
</WrapperComponent>
|
|
67
|
-
</ThemeContext
|
|
67
|
+
</ThemeContext>);
|
|
68
68
|
}
|
|
69
|
-
export
|
|
69
|
+
export function ThemeProvider({ ref, ...props }) {
|
|
70
70
|
return <ThemeProviderInner {...props} wrapperRef={ref}/>;
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
72
|
export default Theme;
|
|
@@ -9,5 +9,5 @@ export const I18nContextHolder = ({ children, messages }) => {
|
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
setTranslations(messages);
|
|
11
11
|
}, [messages]);
|
|
12
|
-
return <I18nContext
|
|
12
|
+
return <I18nContext value={{ messages, translate }}>{children}</I18nContext>;
|
|
13
13
|
};
|