@adecore/ui 0.20.0 → 0.20.1
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/dist/Tooltip.d.ts +7 -3
- package/dist/Tooltip.js +2 -2
- package/dist/file-tree/use-slots.js +3 -1
- package/package.json +1 -1
- package/src/Tooltip.tsx +11 -7
- package/src/file-tree/use-slots.ts +3 -1
package/dist/Tooltip.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ReactElement, type ReactNode } from 'react';
|
|
1
|
+
import { type ComponentProps, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { Tooltip as BaseTooltip } from '@base-ui-components/react/tooltip';
|
|
2
3
|
import type { Shortcut } from './shortcut.ts';
|
|
3
4
|
export type TooltipSide = 'top' | 'bottom' | 'left' | 'right';
|
|
4
5
|
export declare function TooltipProvider({ children }: {
|
|
@@ -6,11 +7,14 @@ export declare function TooltipProvider({ children }: {
|
|
|
6
7
|
}): import("react").JSX.Element;
|
|
7
8
|
export interface TooltipProps {
|
|
8
9
|
label: ReactNode;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
onOpenChange?(open: boolean): void;
|
|
12
|
+
anchor?: ComponentProps<typeof BaseTooltip.Positioner>['anchor'];
|
|
9
13
|
kbd?: Shortcut | string;
|
|
10
14
|
side?: TooltipSide;
|
|
11
15
|
sideOffset?: number;
|
|
12
16
|
name?: boolean;
|
|
13
17
|
disabled?: boolean;
|
|
14
|
-
children
|
|
18
|
+
children?: ReactElement<Record<string, unknown>>;
|
|
15
19
|
}
|
|
16
|
-
export declare function Tooltip({ label, kbd, side, sideOffset, name, disabled, children }: TooltipProps): import("react").JSX.Element;
|
|
20
|
+
export declare function Tooltip({ label, open, onOpenChange, anchor, kbd, side, sideOffset, name, disabled, children }: TooltipProps): import("react").JSX.Element;
|
package/dist/Tooltip.js
CHANGED
|
@@ -8,7 +8,7 @@ export function TooltipProvider({ children }) {
|
|
|
8
8
|
return (_jsx(BaseTooltip.Provider, { delay: 150, closeDelay: 0, children: children }));
|
|
9
9
|
}
|
|
10
10
|
/* A hint on hover and on keyboard focus. Every hint in an app is one of these, never a `title`. */
|
|
11
|
-
export function Tooltip({ label, kbd, side = 'top', sideOffset = 6, name = false, disabled = false, children }) {
|
|
11
|
+
export function Tooltip({ label, open, onOpenChange, anchor, kbd, side = 'top', sideOffset = 6, name = false, disabled = false, children }) {
|
|
12
12
|
// Held Cmd (Ctrl off macOS) prints this shortcut under the trigger (`ShortcutHints`).
|
|
13
13
|
const hintRef = useCallback((element) => {
|
|
14
14
|
if (element === null || kbd === undefined || typeof kbd === 'string') {
|
|
@@ -16,6 +16,6 @@ export function Tooltip({ label, kbd, side = 'top', sideOffset = 6, name = false
|
|
|
16
16
|
}
|
|
17
17
|
return registerShortcutHint(element, kbd);
|
|
18
18
|
}, [kbd]);
|
|
19
|
-
return (_jsxs(BaseTooltip.Root, { disabled: disabled, children: [_jsx(BaseTooltip.Trigger, { ref: hintRef, render: children, "aria-label": name && typeof label === 'string' ? label : undefined }), _jsx(BaseTooltip.Portal, { children: _jsx(BaseTooltip.Positioner, { side: side, sideOffset: sideOffset, className: "tooltip-positioner", children: _jsx(BaseTooltip.Popup, { className: "tooltip-popup", children: _jsxs(BaseTooltip.Viewport, { className: "max-w-72 px-[9px] py-[5px] text-pretty", children: [_jsx("span", { className: "wrap-anywhere", children: label }), kbd !== undefined &&
|
|
19
|
+
return (_jsxs(BaseTooltip.Root, { disabled: disabled, open: open, onOpenChange: onOpenChange, disableHoverablePopup: children === undefined, children: [children && _jsx(BaseTooltip.Trigger, { ref: hintRef, render: children, "aria-label": name && typeof label === 'string' ? label : undefined }), _jsx(BaseTooltip.Portal, { children: _jsx(BaseTooltip.Positioner, { anchor: anchor, side: side, sideOffset: sideOffset, className: "tooltip-positioner", children: _jsx(BaseTooltip.Popup, { role: "tooltip", className: "tooltip-popup", children: _jsxs(BaseTooltip.Viewport, { className: "max-w-72 px-[9px] py-[5px] text-pretty", children: [_jsx("span", { className: "wrap-anywhere", children: label }), kbd !== undefined &&
|
|
20
20
|
(typeof kbd === 'string' ? (_jsx(Kbd, { variant: "inline", className: "ml-2", children: kbd })) : (_jsx(Kbd, { shortcut: kbd, variant: "inline", className: "ml-2" })))] }) }) }) })] }));
|
|
21
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useId, useState } from 'react';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
2
3
|
import { pathOfRow, visibleRows } from './helpers.js';
|
|
3
4
|
import { FILE_TREE_CSS } from './style.js';
|
|
4
5
|
// beta.6 owns button rows. Sibling slots keep real controls outside those buttons and in the app's stylesheet.
|
|
@@ -134,7 +135,8 @@ export function useFileTreeSlots(model, frame, label) {
|
|
|
134
135
|
.join('|');
|
|
135
136
|
if (snapshot !== key) {
|
|
136
137
|
snapshot = key;
|
|
137
|
-
|
|
138
|
+
// Recycled rows must paint with their new portal contents in the same frame.
|
|
139
|
+
flushSync(() => setSlots(next));
|
|
138
140
|
}
|
|
139
141
|
position();
|
|
140
142
|
};
|
package/package.json
CHANGED
package/src/Tooltip.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, type ReactElement, type ReactNode } from 'react';
|
|
1
|
+
import { useCallback, type ComponentProps, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import { Tooltip as BaseTooltip } from '@base-ui-components/react/tooltip';
|
|
3
3
|
import { Kbd } from './Kbd.tsx';
|
|
4
4
|
import type { Shortcut } from './shortcut.ts';
|
|
@@ -17,6 +17,10 @@ export function TooltipProvider({ children }: { children: ReactNode }) {
|
|
|
17
17
|
|
|
18
18
|
export interface TooltipProps {
|
|
19
19
|
label: ReactNode;
|
|
20
|
+
open?: boolean;
|
|
21
|
+
onOpenChange?(open: boolean): void;
|
|
22
|
+
/* A virtual anchor positions a controlled hint over canvas content without adding an input target. */
|
|
23
|
+
anchor?: ComponentProps<typeof BaseTooltip.Positioner>['anchor'];
|
|
20
24
|
/* A shortcut, or a short phrase about a key that is not one ("Shift skips the cache"). */
|
|
21
25
|
kbd?: Shortcut | string;
|
|
22
26
|
side?: TooltipSide;
|
|
@@ -27,11 +31,11 @@ export interface TooltipProps {
|
|
|
27
31
|
/* Keeps the hint closed, for a trigger that only needs one some of the time. */
|
|
28
32
|
disabled?: boolean;
|
|
29
33
|
/* The trigger element. Its own children and handlers are kept; Base UI merges the tooltip props in. */
|
|
30
|
-
children
|
|
34
|
+
children?: ReactElement<Record<string, unknown>>;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/* A hint on hover and on keyboard focus. Every hint in an app is one of these, never a `title`. */
|
|
34
|
-
export function Tooltip({ label, kbd, side = 'top', sideOffset = 6, name = false, disabled = false, children }: TooltipProps) {
|
|
38
|
+
export function Tooltip({ label, open, onOpenChange, anchor, kbd, side = 'top', sideOffset = 6, name = false, disabled = false, children }: TooltipProps) {
|
|
35
39
|
// Held Cmd (Ctrl off macOS) prints this shortcut under the trigger (`ShortcutHints`).
|
|
36
40
|
const hintRef = useCallback(
|
|
37
41
|
(element: HTMLElement | null) => {
|
|
@@ -44,11 +48,11 @@ export function Tooltip({ label, kbd, side = 'top', sideOffset = 6, name = false
|
|
|
44
48
|
);
|
|
45
49
|
|
|
46
50
|
return (
|
|
47
|
-
<BaseTooltip.Root disabled={disabled}>
|
|
48
|
-
<BaseTooltip.Trigger ref={hintRef} render={children} aria-label={name && typeof label === 'string' ? label : undefined} />
|
|
51
|
+
<BaseTooltip.Root disabled={disabled} open={open} onOpenChange={onOpenChange} disableHoverablePopup={children === undefined}>
|
|
52
|
+
{children && <BaseTooltip.Trigger ref={hintRef} render={children} aria-label={name && typeof label === 'string' ? label : undefined} />}
|
|
49
53
|
<BaseTooltip.Portal>
|
|
50
|
-
<BaseTooltip.Positioner side={side} sideOffset={sideOffset} className="tooltip-positioner">
|
|
51
|
-
<BaseTooltip.Popup className="tooltip-popup">
|
|
54
|
+
<BaseTooltip.Positioner anchor={anchor} side={side} sideOffset={sideOffset} className="tooltip-positioner">
|
|
55
|
+
<BaseTooltip.Popup role="tooltip" className="tooltip-popup">
|
|
52
56
|
<BaseTooltip.Viewport className="max-w-72 px-[9px] py-[5px] text-pretty">
|
|
53
57
|
<span className="wrap-anywhere">{label}</span>
|
|
54
58
|
{/* The viewport wraps its children in a div of its own, so the 8px
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useId, useState } from 'react';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
2
3
|
import type { FileTree, FileTreeVisibleRow } from '@pierre/trees';
|
|
3
4
|
import { pathOfRow, visibleRows } from './helpers.ts';
|
|
4
5
|
import { FILE_TREE_CSS } from './style.ts';
|
|
@@ -153,7 +154,8 @@ export function useFileTreeSlots(model: FileTree, frame: HTMLElement | null, lab
|
|
|
153
154
|
.join('|');
|
|
154
155
|
if (snapshot !== key) {
|
|
155
156
|
snapshot = key;
|
|
156
|
-
|
|
157
|
+
// Recycled rows must paint with their new portal contents in the same frame.
|
|
158
|
+
flushSync(() => setSlots(next));
|
|
157
159
|
}
|
|
158
160
|
position();
|
|
159
161
|
};
|