@carbonid1/design-system 7.3.1 → 7.5.0
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/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/Autocomplete/Autocomplete.js +6 -4
- package/dist/Badge/Badge.js +1 -1
- package/dist/Button/Button.variants.js +2 -2
- package/dist/ContextMenu/ContextMenu.d.ts +29 -45
- package/dist/ContextMenu/ContextMenu.js +6 -33
- package/dist/Input/Input.js +1 -1
- package/dist/InputGroup/InputGroup.d.ts +1 -0
- package/dist/InputGroup/InputGroup.js +3 -1
- package/dist/Item/Item.js +1 -1
- package/dist/Kbd/Kbd.js +11 -4
- package/dist/Menu/Menu.d.ts +7 -2
- package/dist/Menu/Menu.js +3 -2
- package/dist/MessageScroller/MessageScroller.js +77 -34
- package/dist/Popover/Popover.js +1 -1
- package/dist/Select/Select.d.ts +1 -1
- package/dist/Select/Select.js +13 -3
- package/dist/Select/Select.types.d.ts +1 -0
- package/dist/Slider/Slider.js +2 -2
- package/dist/Switch/Switch.js +2 -2
- package/dist/Tooltip/Tooltip.js +1 -1
- package/dist/helpers/cn/cn.tables.js +5 -5
- package/package.json +1 -1
- package/skills/design-system/SKILL.md +46 -131
- package/skills/design-system/references/controls.md +29 -0
- package/skills/design-system/references/destructive-actions.md +10 -0
- package/skills/design-system/references/theming.md +13 -31
- package/skills/design-system/references/typeset.md +13 -0
- package/skills/design-system-package/SKILL.md +48 -57
- package/skills/design-system-package/references/release.md +9 -0
- package/skills/design-system-package/references/tokens.md +11 -0
- package/skills/design-system-package/references/verification.md +16 -0
|
@@ -4,7 +4,7 @@ import type { AutocompleteClearProps, AutocompleteEmptyProps, AutocompleteGroupL
|
|
|
4
4
|
export declare const Autocomplete: {
|
|
5
5
|
Root: <Value>({ autoHighlight, modal, ...props }: AutocompleteRootProps<Value>) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
InputGroup: ({ className, ...props }: AutocompleteInputGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
Input: (props: AutocompleteInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
Input: ({ className, ...props }: AutocompleteInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
Trigger: ({ children, className, "aria-label": ariaLabel, ...props }: AutocompleteTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
Clear: ({ children, className, "aria-label": ariaLabel, keepMounted, ...props }: AutocompleteClearProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
Portal: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").AutocompletePortalProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Combobox as BaseCombobox } from '@base-ui/react/combobox';
|
|
4
4
|
import { Check, ChevronDown, X } from 'lucide-react';
|
|
5
|
-
import { InputGroup as StyledInputGroup } from '../InputGroup/InputGroup';
|
|
5
|
+
import { InputGroup as StyledInputGroup, inputGroupControlClassName, } from '../InputGroup/InputGroup';
|
|
6
6
|
import { mergeStatefulClassName } from '../helpers/mergeStatefulClassName/mergeStatefulClassName';
|
|
7
7
|
const Root = ({ autoHighlight = true, modal = false, ...props }) => (_jsx(BaseCombobox.Root, { autoHighlight: autoHighlight, modal: modal, ...props, multiple: false }));
|
|
8
8
|
const InputGroup = ({ className, ...props }) => (_jsx(BaseCombobox.InputGroup, { render: _jsx(StyledInputGroup.Root, {}), className: mergeStatefulClassName('min-h-9 gap-0 p-0.5', className), ...props }));
|
|
9
|
+
// Only the group's look, not InputGroup.Control: that is a Field control, and it would submit the
|
|
10
|
+
// typed text under the field's name next to the combobox's own hidden input.
|
|
9
11
|
/** Compose inside InputGroup so the input and its actions share one focus ring and surface. */
|
|
10
|
-
const Input = (props) => (_jsx(BaseCombobox.Input, {
|
|
11
|
-
const Trigger = ({ children, className, 'aria-label': ariaLabel = 'Show options', ...props }) => (_jsx(BaseCombobox.Trigger, { "aria-label": ariaLabel, "aria-labelledby": undefined, render: _jsx(StyledInputGroup.Action, { variant: "ghost" }), className: mergeStatefulClassName('group motion-reduce:transition-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-[Highlight]', className), ...props, children: children ?? (_jsx(ChevronDown, { "aria-hidden": true, className: "size-4 transition-transform group-data-[popup-open]:rotate-180 motion-reduce:transition-none" })) }));
|
|
12
|
-
const Clear = ({ children, className, 'aria-label': ariaLabel = 'Clear selection', keepMounted = true, ...props }) => (_jsx(BaseCombobox.Clear, { "aria-label": ariaLabel, keepMounted: keepMounted, render: _jsx(StyledInputGroup.Action, { variant: "ghost" }), className: mergeStatefulClassName('not-data-[visible]:invisible motion-reduce:transition-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-[Highlight]', className), ...props, children: children ?? _jsx(X, { "aria-hidden": true, className: "size-4" }) }));
|
|
12
|
+
const Input = ({ className, ...props }) => (_jsx(BaseCombobox.Input, { "data-slot": "input-group-control", className: mergeStatefulClassName(inputGroupControlClassName, className), ...props }));
|
|
13
|
+
const Trigger = ({ children, className, 'aria-label': ariaLabel = 'Show options', ...props }) => (_jsx(BaseCombobox.Trigger, { "aria-label": ariaLabel, "aria-labelledby": undefined, render: _jsx(StyledInputGroup.Action, { variant: "ghost" }), className: mergeStatefulClassName('group motion-reduce:transition-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-[Highlight] forced-colors:focus-visible:outline-solid', className), ...props, children: children ?? (_jsx(ChevronDown, { "aria-hidden": true, className: "size-4 transition-transform group-data-[popup-open]:rotate-180 motion-reduce:transition-none" })) }));
|
|
14
|
+
const Clear = ({ children, className, 'aria-label': ariaLabel = 'Clear selection', keepMounted = true, ...props }) => (_jsx(BaseCombobox.Clear, { "aria-label": ariaLabel, keepMounted: keepMounted, render: _jsx(StyledInputGroup.Action, { variant: "ghost" }), className: mergeStatefulClassName('not-data-[visible]:invisible motion-reduce:transition-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-[Highlight] forced-colors:focus-visible:outline-solid', className), ...props, children: children ?? _jsx(X, { "aria-hidden": true, className: "size-4" }) }));
|
|
13
15
|
const Positioner = ({ className, sideOffset = 4, collisionPadding = 8, positionMethod = 'fixed', ...props }) => (_jsx(BaseCombobox.Positioner, { sideOffset: sideOffset, collisionPadding: collisionPadding, positionMethod: positionMethod, className: mergeStatefulClassName('z-50 outline-hidden', className), ...props }));
|
|
14
16
|
const Popup = ({ className, ...props }) => (_jsx(BaseCombobox.Popup, { className: mergeStatefulClassName('border-border bg-popover text-popover-foreground shadow-popover flex max-h-[var(--available-height)] w-[var(--anchor-width)] max-w-[var(--available-width)] flex-col overflow-hidden rounded-lg border outline-hidden', className), ...props }));
|
|
15
17
|
const List = ({ className, ...props }) => (_jsx(BaseCombobox.List, { className: mergeStatefulClassName('max-h-60 min-h-0 scroll-py-1 space-y-1 overflow-y-auto overscroll-contain p-1 empty:p-0', className), ...props }));
|
package/dist/Badge/Badge.js
CHANGED
|
@@ -5,6 +5,6 @@ import { X } from 'lucide-react';
|
|
|
5
5
|
import { badgeVariants } from './Badge.variants';
|
|
6
6
|
const Badge = ({ className, variant, onRemove, removeLabel, children, ...props }) => {
|
|
7
7
|
const resolvedRemoveLabel = removeLabel ?? (typeof children === 'string' ? `Remove ${children}` : 'Remove');
|
|
8
|
-
return (_jsxs("span", { className: cn(badgeVariants({ variant }), className), ...props, children: [onRemove ? _jsx("span", { className: "truncate", children: children }) : children, onRemove && (_jsx("button", { type: "button", "aria-label": resolvedRemoveLabel, onClick: onRemove, className: "-me-0.5 inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full opacity-70 hover:opacity-100 focus-visible:ring-2 focus-visible:ring-current focus-visible:ring-offset-1 focus-visible:ring-offset-transparent focus-visible:outline-none", children: _jsx(X, { className: "size-3", "aria-hidden": "true" }) }))] }));
|
|
8
|
+
return (_jsxs("span", { className: cn(badgeVariants({ variant }), className), ...props, children: [onRemove ? _jsx("span", { className: "truncate", children: children }) : children, onRemove && (_jsx("button", { type: "button", "aria-label": resolvedRemoveLabel, onClick: onRemove, className: "-me-0.5 inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full opacity-70 hover:opacity-100 focus-visible:ring-2 focus-visible:ring-current focus-visible:ring-offset-1 focus-visible:ring-offset-transparent focus-visible:outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-[Highlight] forced-colors:focus-visible:outline-solid", children: _jsx(X, { className: "size-3", "aria-hidden": "true" }) }))] }));
|
|
9
9
|
};
|
|
10
10
|
export { Badge };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cva } from 'class-variance-authority';
|
|
2
|
-
const buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[color,background-color,opacity,
|
|
2
|
+
const buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-[color,background-color,opacity,translate] outline-hidden select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
3
3
|
variants: {
|
|
4
4
|
variant: {
|
|
5
5
|
ghost: 'hover:bg-accent aria-expanded:bg-accent dark:hover:bg-accent/50',
|
|
@@ -24,7 +24,7 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
|
|
|
24
24
|
relaxed: 'gap-2',
|
|
25
25
|
},
|
|
26
26
|
selected: {
|
|
27
|
-
true: 'bg-primary/10 ring-1 ring-primary/20',
|
|
27
|
+
true: 'bg-primary/10 ring-1 ring-primary/20 forced-colors:bg-[Highlight] forced-colors:text-[HighlightText] forced-colors:forced-color-adjust-none',
|
|
28
28
|
false: '',
|
|
29
29
|
},
|
|
30
30
|
},
|
|
@@ -1,56 +1,40 @@
|
|
|
1
1
|
import { ContextMenu as BaseContextMenu } from '@base-ui/react/context-menu';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
type BasePositionerProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Positioner>;
|
|
5
|
-
type BaseItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Item>;
|
|
6
|
-
type BaseSeparatorProps = ComponentPropsWithoutRef<typeof BaseContextMenu.Separator>;
|
|
7
|
-
type BaseGroupLabelProps = ComponentPropsWithoutRef<typeof BaseContextMenu.GroupLabel>;
|
|
8
|
-
type BaseSubmenuTriggerProps = ComponentPropsWithoutRef<typeof BaseContextMenu.SubmenuTrigger>;
|
|
9
|
-
type BaseCheckboxItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.CheckboxItem>;
|
|
10
|
-
type BaseRadioItemProps = ComponentPropsWithoutRef<typeof BaseContextMenu.RadioItem>;
|
|
11
|
-
type ItemVariant = 'default' | 'destructive';
|
|
12
|
-
type PositionerProps = BasePositionerProps & {
|
|
13
|
-
ref?: Ref<HTMLDivElement>;
|
|
14
|
-
};
|
|
15
|
-
type PopupProps = BasePopupProps & {
|
|
16
|
-
ref?: Ref<HTMLDivElement>;
|
|
17
|
-
};
|
|
18
|
-
type SeparatorProps = BaseSeparatorProps & {
|
|
19
|
-
ref?: Ref<HTMLDivElement>;
|
|
20
|
-
};
|
|
21
|
-
type GroupLabelProps = BaseGroupLabelProps & {
|
|
22
|
-
ref?: Ref<HTMLDivElement>;
|
|
23
|
-
};
|
|
24
|
-
type ItemProps = BaseItemProps & {
|
|
25
|
-
ref?: Ref<HTMLDivElement>;
|
|
26
|
-
variant?: ItemVariant;
|
|
27
|
-
};
|
|
28
|
-
type CheckboxItemProps = BaseCheckboxItemProps & {
|
|
29
|
-
ref?: Ref<HTMLDivElement>;
|
|
30
|
-
};
|
|
31
|
-
type RadioItemProps = BaseRadioItemProps & {
|
|
32
|
-
ref?: Ref<HTMLDivElement>;
|
|
33
|
-
};
|
|
34
|
-
type SubmenuTriggerProps = BaseSubmenuTriggerProps & {
|
|
35
|
-
ref?: Ref<HTMLDivElement>;
|
|
36
|
-
};
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import { Menu } from '../Menu/Menu';
|
|
37
4
|
export declare const ContextMenu: {
|
|
38
5
|
Root: typeof BaseContextMenu.Root;
|
|
39
6
|
Trigger: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
Popup: ({ className, ...props }: ComponentProps<typeof Menu.Popup>) => import("react/jsx-runtime").JSX.Element;
|
|
40
8
|
Portal: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuPortalProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
41
9
|
Backdrop: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
42
|
-
Positioner: ({ className, sideOffset, ...props }:
|
|
43
|
-
|
|
10
|
+
Positioner: ({ className, sideOffset, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuPositionerProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
11
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
44
13
|
Arrow: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
45
14
|
Group: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").ContextMenuGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
-
GroupLabel: ({ className, ...props }:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
15
|
+
GroupLabel: ({ className, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuGroupLabelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
16
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
Separator: ({ className, ...props }: Omit<Omit<import("@base-ui/react").SeparatorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
19
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
20
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
Item: ({ className, variant, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & {
|
|
22
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
23
|
+
variant?: "default" | "destructive";
|
|
24
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
LinkItem: ({ className, variant, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuLinkItemProps, "ref"> & import("react").RefAttributes<Element>, "ref"> & {
|
|
26
|
+
ref?: import("react").Ref<HTMLAnchorElement>;
|
|
27
|
+
variant?: "default" | "destructive";
|
|
28
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
CheckboxItem: ({ className, children, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuCheckboxItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & {
|
|
30
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
31
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
51
32
|
RadioGroup: import("react").NamedExoticComponent<Omit<import("@base-ui/react").ContextMenuRadioGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
52
|
-
RadioItem: ({ className, children, ...props }:
|
|
33
|
+
RadioItem: ({ className, children, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuRadioItemProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & {
|
|
34
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
35
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
53
36
|
SubmenuRoot: typeof BaseContextMenu.SubmenuRoot;
|
|
54
|
-
SubmenuTrigger: ({ className, children, ...props }:
|
|
37
|
+
SubmenuTrigger: ({ className, children, ...props }: Omit<Omit<import("@base-ui/react").ContextMenuSubmenuTriggerProps, "ref"> & import("react").RefAttributes<HTMLElement>, "ref"> & {
|
|
38
|
+
ref?: import("react").Ref<HTMLDivElement>;
|
|
39
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
55
40
|
};
|
|
56
|
-
export {};
|
|
@@ -1,41 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { ContextMenu as BaseContextMenu } from '@base-ui/react/context-menu';
|
|
4
|
-
import { ChevronRight } from 'lucide-react';
|
|
5
|
-
import { cn } from '../helpers/cn/cn';
|
|
6
4
|
import { mergeStatefulClassName } from '../helpers/mergeStatefulClassName/mergeStatefulClassName';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
destructive: 'text-destructive data-[highlighted]:bg-destructive/10 data-[highlighted]:text-destructive',
|
|
12
|
-
};
|
|
13
|
-
const Positioner = ({ className, sideOffset = 4, ...props }) => (_jsx(BaseContextMenu.Positioner, { sideOffset: sideOffset, className: mergeStatefulClassName('z-50 outline-hidden', className), ...props }));
|
|
14
|
-
const Popup = ({ className, ...props }) => (_jsx(BaseContextMenu.Popup, { className: mergeStatefulClassName(popupClasses, className), ...props }));
|
|
15
|
-
const Item = ({ className, variant = 'default', ...props }) => (_jsx(BaseContextMenu.Item, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses[variant]), className), ...props }));
|
|
16
|
-
const Separator = ({ className, ...props }) => (_jsx(BaseContextMenu.Separator, { className: mergeStatefulClassName('bg-border my-1 h-px', className), ...props }));
|
|
17
|
-
const GroupLabel = ({ className, ...props }) => (_jsx(BaseContextMenu.GroupLabel, { className: mergeStatefulClassName('text-muted-foreground px-2.5 py-1 text-xs', className), ...props }));
|
|
18
|
-
const CheckboxItem = ({ className, children, ...props }) => (_jsxs(BaseContextMenu.CheckboxItem, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses.default, 'pl-7'), className), ...props, children: [_jsx("span", { "aria-hidden": true, className: "absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(BaseContextMenu.CheckboxItemIndicator, { className: "size-3.5", children: _jsx(CheckIcon, {}) }) }), children] }));
|
|
19
|
-
const RadioItem = ({ className, children, ...props }) => (_jsxs(BaseContextMenu.RadioItem, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses.default, 'pl-7'), className), ...props, children: [_jsx("span", { "aria-hidden": true, className: "absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(BaseContextMenu.RadioItemIndicator, { className: "size-3.5", children: _jsx(DotIcon, {}) }) }), children] }));
|
|
20
|
-
const SubmenuTrigger = ({ className, children, ...props }) => (_jsxs(BaseContextMenu.SubmenuTrigger, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses.default, 'data-popup-open:bg-accent data-popup-open:text-accent-foreground pr-2'), className), ...props, children: [children, _jsx(ChevronRight, { className: "ml-auto size-4 opacity-60", "aria-hidden": true })] }));
|
|
21
|
-
const CheckIcon = () => (_jsx("svg", { viewBox: "0 0 14 14", fill: "none", className: "size-3.5", children: _jsx("path", { d: "M3 7.5 6 10.5 11 4.5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
22
|
-
const DotIcon = () => (_jsx("svg", { viewBox: "0 0 14 14", className: "size-3.5", children: _jsx("circle", { cx: "7", cy: "7", r: "3", fill: "currentColor" }) }));
|
|
5
|
+
import { Menu } from '../Menu/Menu';
|
|
6
|
+
// Base UI's ContextMenu is Menu with its own Root and Trigger; every other part is the same
|
|
7
|
+
// component, so the styled Menu parts apply as-is. A context menu just opens a little wider.
|
|
8
|
+
const Popup = ({ className, ...props }) => (_jsx(Menu.Popup, { className: mergeStatefulClassName('min-w-45', className), ...props }));
|
|
23
9
|
export const ContextMenu = {
|
|
10
|
+
...Menu,
|
|
24
11
|
Root: BaseContextMenu.Root,
|
|
25
12
|
Trigger: BaseContextMenu.Trigger,
|
|
26
|
-
Portal: BaseContextMenu.Portal,
|
|
27
|
-
Backdrop: BaseContextMenu.Backdrop,
|
|
28
|
-
Positioner,
|
|
29
13
|
Popup,
|
|
30
|
-
Arrow: BaseContextMenu.Arrow,
|
|
31
|
-
Group: BaseContextMenu.Group,
|
|
32
|
-
GroupLabel,
|
|
33
|
-
Separator,
|
|
34
|
-
Item,
|
|
35
|
-
LinkItem: BaseContextMenu.LinkItem,
|
|
36
|
-
CheckboxItem,
|
|
37
|
-
RadioGroup: BaseContextMenu.RadioGroup,
|
|
38
|
-
RadioItem,
|
|
39
|
-
SubmenuRoot: BaseContextMenu.SubmenuRoot,
|
|
40
|
-
SubmenuTrigger,
|
|
41
14
|
};
|
package/dist/Input/Input.js
CHANGED
|
@@ -3,5 +3,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Input as BaseInput } from '@base-ui/react/input';
|
|
4
4
|
import { cn } from '../helpers/cn/cn';
|
|
5
5
|
import { mergeStatefulClassName } from '../helpers/mergeStatefulClassName/mergeStatefulClassName';
|
|
6
|
-
const Input = ({ className, ...props }) => (_jsx(BaseInput, { ...props, "data-slot": "input", className: mergeStatefulClassName(cn('border-input-border bg-surface-inset inset-shadow-surface text-foreground placeholder:text-muted-foreground h-9 w-full min-w-0 rounded-lg border px-3 py-1 text-sm outline-hidden dark:inset-shadow-none', 'enabled:hover:border-ring', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3', 'forced-colors:focus-visible:ring-0 forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-[Highlight]', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 aria-invalid:ring-3'), className) }));
|
|
6
|
+
const Input = ({ className, ...props }) => (_jsx(BaseInput, { ...props, "data-slot": "input", className: mergeStatefulClassName(cn('border-input-border bg-surface-inset inset-shadow-surface text-foreground placeholder:text-muted-foreground h-9 w-full min-w-0 rounded-lg border px-3 py-1 text-sm outline-hidden dark:inset-shadow-none', 'enabled:hover:border-ring', 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3', 'forced-colors:focus-visible:ring-0 forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-[Highlight] forced-colors:focus-visible:outline-solid', 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50', 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 aria-invalid:ring-3'), className) }));
|
|
7
7
|
export { Input };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InputGroupActionProps, InputGroupControlProps, InputGroupRootProps } from './InputGroup.types';
|
|
2
|
+
export declare const inputGroupControlClassName = "text-foreground placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent px-2 py-1 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50 forced-colors:focus-visible:outline-none";
|
|
2
3
|
export declare const InputGroup: {
|
|
3
4
|
Root: ({ className, onPointerDown, ...props }: InputGroupRootProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
Control: ({ className, ...props }: InputGroupControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,7 +16,9 @@ const Root = ({ className, onPointerDown, ...props }) => {
|
|
|
16
16
|
};
|
|
17
17
|
return (_jsx("div", { ...props, "data-slot": "input-group", onPointerDown: focusControlFromShell, className: cn('border-input-border bg-surface-inset inset-shadow-surface flex min-h-11 w-full min-w-0 items-center gap-1 rounded-lg border p-2 dark:inset-shadow-none', 'has-[[data-slot=input-group-control]:enabled]:hover:border-ring', 'has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-3', 'has-[[data-slot=input-group-control][aria-invalid=true]]:border-destructive has-[[data-slot=input-group-control][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot=input-group-control][aria-invalid=true]]:border-destructive/50 dark:has-[[data-slot=input-group-control][aria-invalid=true]]:ring-destructive/40 has-[[data-slot=input-group-control][aria-invalid=true]]:ring-3', 'forced-colors:has-[[data-slot=input-group-control]:focus-visible]:ring-0 forced-colors:has-[[data-slot=input-group-control]:focus-visible]:outline-2 forced-colors:has-[[data-slot=input-group-control]:focus-visible]:outline-offset-2 forced-colors:has-[[data-slot=input-group-control]:focus-visible]:outline-[Highlight]', '[&:has([data-native-picker-action])_[data-slot=input-group-control]::-webkit-calendar-picker-indicator]:hidden', className) }));
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
// Shared with inputs that bring their own form behavior, like Autocomplete's combobox input.
|
|
20
|
+
export const inputGroupControlClassName = 'text-foreground placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent px-2 py-1 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50 forced-colors:focus-visible:outline-none';
|
|
21
|
+
const Control = ({ className, ...props }) => (_jsx(BaseInput, { ...props, "data-slot": "input-group-control", className: mergeStatefulClassName(inputGroupControlClassName, className) }));
|
|
20
22
|
const Action = ({ className, variant = 'subtle', size = 'icon', replacesNativePicker = false, ...props }) => (_jsx(Button, { ...props, "data-slot": "input-group-action", "data-native-picker-action": replacesNativePicker ? '' : undefined, variant: variant, size: size, className: mergeStatefulClassName(cn('rounded-md',
|
|
21
23
|
// Firefox does not expose its native date indicator to author CSS, so it keeps that
|
|
22
24
|
// affordance and omits the replacement action instead of rendering two calendar buttons.
|
package/dist/Item/Item.js
CHANGED
|
@@ -10,7 +10,7 @@ const itemVariants = cva('min-w-0 rounded-lg', {
|
|
|
10
10
|
outline: 'border-border border bg-transparent',
|
|
11
11
|
},
|
|
12
12
|
interactive: {
|
|
13
|
-
true: 'outline-hidden hover:bg-accent focus-within:bg-accent focus-visible:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 dark:hover:bg-accent/50 dark:focus-within:bg-accent/50 dark:focus-visible:bg-accent/50 forced-colors:focus-visible:ring-0 forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-[Highlight]',
|
|
13
|
+
true: 'outline-hidden hover:bg-accent focus-within:bg-accent focus-visible:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 dark:hover:bg-accent/50 dark:focus-within:bg-accent/50 dark:focus-visible:bg-accent/50 forced-colors:focus-visible:ring-0 forced-colors:focus-visible:outline-solid forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-[Highlight]',
|
|
14
14
|
false: '',
|
|
15
15
|
},
|
|
16
16
|
},
|
package/dist/Kbd/Kbd.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useSyncExternalStore } from 'react';
|
|
3
4
|
import { getModKey } from '../helpers/getModKey/getModKey';
|
|
4
5
|
import { cn } from '../helpers/cn/cn';
|
|
5
6
|
import { kbdVariants } from './Kbd.variants';
|
|
@@ -16,16 +17,22 @@ const KEY_SYMBOLS = {
|
|
|
16
17
|
up: '↑',
|
|
17
18
|
down: '↓',
|
|
18
19
|
};
|
|
19
|
-
const resolveKey = (key) => {
|
|
20
|
+
const resolveKey = (key, modKey) => {
|
|
20
21
|
const lower = key.toLowerCase();
|
|
21
22
|
if (lower === 'mod')
|
|
22
|
-
return MOD_SYMBOLS[
|
|
23
|
+
return MOD_SYMBOLS[modKey] ?? 'Ctrl';
|
|
23
24
|
if (lower === 'ctrl')
|
|
24
|
-
return
|
|
25
|
+
return modKey === 'Cmd' ? '⌃' : 'Ctrl';
|
|
25
26
|
return KEY_SYMBOLS[lower] ?? key;
|
|
26
27
|
};
|
|
28
|
+
// The platform never changes after load, so there is nothing to subscribe to. The server
|
|
29
|
+
// snapshot pins SSR and hydration to the non-Mac glyphs; React then re-renders with the
|
|
30
|
+
// client's real platform, so Mac users get ⌘ without a hydration mismatch.
|
|
31
|
+
const subscribeToNothing = () => () => { };
|
|
32
|
+
const getServerModKey = () => 'Ctrl';
|
|
27
33
|
const Kbd = ({ keys, size, className }) => {
|
|
28
34
|
const keyList = Array.isArray(keys) ? keys : [keys];
|
|
29
|
-
|
|
35
|
+
const modKey = useSyncExternalStore(subscribeToNothing, getModKey, getServerModKey);
|
|
36
|
+
return (_jsx("span", { className: "inline-flex items-center gap-0.5", role: "presentation", children: keyList.map((key, i) => (_jsx("kbd", { className: cn(kbdVariants({ size }), className), children: resolveKey(key, modKey) }, i))) }));
|
|
30
37
|
};
|
|
31
38
|
export { Kbd };
|
package/dist/Menu/Menu.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ type BaseGroupLabelProps = ComponentPropsWithoutRef<typeof BaseMenu.GroupLabel>;
|
|
|
8
8
|
type BaseSubmenuTriggerProps = ComponentPropsWithoutRef<typeof BaseMenu.SubmenuTrigger>;
|
|
9
9
|
type BaseCheckboxItemProps = ComponentPropsWithoutRef<typeof BaseMenu.CheckboxItem>;
|
|
10
10
|
type BaseRadioItemProps = ComponentPropsWithoutRef<typeof BaseMenu.RadioItem>;
|
|
11
|
+
type BaseLinkItemProps = ComponentPropsWithoutRef<typeof BaseMenu.LinkItem>;
|
|
11
12
|
type ItemVariant = 'default' | 'destructive';
|
|
12
13
|
type PositionerProps = BasePositionerProps & {
|
|
13
14
|
ref?: Ref<HTMLDivElement>;
|
|
@@ -16,7 +17,7 @@ type PopupProps = BasePopupProps & {
|
|
|
16
17
|
ref?: Ref<HTMLDivElement>;
|
|
17
18
|
};
|
|
18
19
|
type SeparatorProps = BaseSeparatorProps & {
|
|
19
|
-
ref?: Ref<
|
|
20
|
+
ref?: Ref<HTMLDivElement>;
|
|
20
21
|
};
|
|
21
22
|
type GroupLabelProps = BaseGroupLabelProps & {
|
|
22
23
|
ref?: Ref<HTMLDivElement>;
|
|
@@ -25,6 +26,10 @@ type ItemProps = BaseItemProps & {
|
|
|
25
26
|
ref?: Ref<HTMLDivElement>;
|
|
26
27
|
variant?: ItemVariant;
|
|
27
28
|
};
|
|
29
|
+
type LinkItemProps = BaseLinkItemProps & {
|
|
30
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
31
|
+
variant?: ItemVariant;
|
|
32
|
+
};
|
|
28
33
|
type CheckboxItemProps = BaseCheckboxItemProps & {
|
|
29
34
|
ref?: Ref<HTMLDivElement>;
|
|
30
35
|
};
|
|
@@ -46,7 +51,7 @@ export declare const Menu: {
|
|
|
46
51
|
GroupLabel: ({ className, ...props }: GroupLabelProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
52
|
Separator: ({ className, ...props }: SeparatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
53
|
Item: ({ className, variant, ...props }: ItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
|
-
LinkItem:
|
|
54
|
+
LinkItem: ({ className, variant, ...props }: LinkItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
55
|
CheckboxItem: ({ className, children, ...props }: CheckboxItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
56
|
RadioGroup: import("react").NamedExoticComponent<Omit<import("@base-ui/react").ContextMenuRadioGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
52
57
|
RadioItem: ({ className, children, ...props }: RadioItemProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/Menu/Menu.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
|
4
4
|
import { ChevronRight } from 'lucide-react';
|
|
5
5
|
import { cn } from '../helpers/cn/cn';
|
|
6
6
|
import { mergeStatefulClassName } from '../helpers/mergeStatefulClassName/mergeStatefulClassName';
|
|
7
|
-
const popupClasses = 'bg-popover text-popover-foreground border-border shadow-popover z-50 min-w-36 origin-[var(--transform-origin)] rounded-lg border py-1 outline-hidden transition-[
|
|
7
|
+
const popupClasses = 'bg-popover text-popover-foreground border-border shadow-popover z-50 min-w-36 origin-[var(--transform-origin)] rounded-lg border py-1 outline-hidden transition-[scale,opacity] data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0 motion-reduce:transition-none';
|
|
8
8
|
const itemBaseClasses = 'relative flex h-7 cursor-default items-center gap-1.5 rounded-[calc(var(--radius)-0.25rem)] px-2.5 text-[0.8rem] outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 data-[disabled]:pointer-events-none data-[disabled]:opacity-50';
|
|
9
9
|
const itemVariantClasses = {
|
|
10
10
|
default: 'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground',
|
|
@@ -13,6 +13,7 @@ const itemVariantClasses = {
|
|
|
13
13
|
const Positioner = ({ className, sideOffset = 4, ...props }) => (_jsx(BaseMenu.Positioner, { sideOffset: sideOffset, className: mergeStatefulClassName('z-50 outline-hidden', className), ...props }));
|
|
14
14
|
const Popup = ({ className, ...props }) => (_jsx(BaseMenu.Popup, { className: mergeStatefulClassName(popupClasses, className), ...props }));
|
|
15
15
|
const Item = ({ className, variant = 'default', ...props }) => (_jsx(BaseMenu.Item, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses[variant]), className), ...props }));
|
|
16
|
+
const LinkItem = ({ className, variant = 'default', ...props }) => (_jsx(BaseMenu.LinkItem, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses[variant]), className), ...props }));
|
|
16
17
|
const Separator = ({ className, ...props }) => (_jsx(BaseMenu.Separator, { className: mergeStatefulClassName('bg-border my-1 h-px', className), ...props }));
|
|
17
18
|
const GroupLabel = ({ className, ...props }) => (_jsx(BaseMenu.GroupLabel, { className: mergeStatefulClassName('text-muted-foreground px-2.5 py-1 text-xs', className), ...props }));
|
|
18
19
|
const CheckboxItem = ({ className, children, ...props }) => (_jsxs(BaseMenu.CheckboxItem, { className: mergeStatefulClassName(cn(itemBaseClasses, itemVariantClasses.default, 'pl-7'), className), ...props, children: [_jsx("span", { "aria-hidden": true, className: "absolute left-2 flex size-3.5 items-center justify-center", children: _jsx(BaseMenu.CheckboxItemIndicator, { className: "size-3.5", children: _jsx(CheckIcon, {}) }) }), children] }));
|
|
@@ -32,7 +33,7 @@ export const Menu = {
|
|
|
32
33
|
GroupLabel,
|
|
33
34
|
Separator,
|
|
34
35
|
Item,
|
|
35
|
-
LinkItem
|
|
36
|
+
LinkItem,
|
|
36
37
|
CheckboxItem,
|
|
37
38
|
RadioGroup: BaseMenu.RadioGroup,
|
|
38
39
|
RadioItem,
|
|
@@ -70,6 +70,27 @@ function assignRef(ref, element) {
|
|
|
70
70
|
;
|
|
71
71
|
ref.current = element;
|
|
72
72
|
}
|
|
73
|
+
// Returns a ref callback that stays the same across renders and also forwards the element to
|
|
74
|
+
// the consumer's `ref`. An inline `ref={node => ...}` is a new function every render; if our
|
|
75
|
+
// callback changed with it, React would detach and reattach the element each render, and
|
|
76
|
+
// detaching resets the scroller.
|
|
77
|
+
function useForwardedRef(ref, onElement) {
|
|
78
|
+
const elementRef = useRef(null);
|
|
79
|
+
const forwardedRef = useRef(ref);
|
|
80
|
+
useLayoutEffect(() => {
|
|
81
|
+
if (forwardedRef.current === ref) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
assignRef(forwardedRef.current, null);
|
|
85
|
+
forwardedRef.current = ref;
|
|
86
|
+
assignRef(ref, elementRef.current);
|
|
87
|
+
});
|
|
88
|
+
return useCallback((element) => {
|
|
89
|
+
elementRef.current = element;
|
|
90
|
+
onElement(element);
|
|
91
|
+
assignRef(forwardedRef.current, element);
|
|
92
|
+
}, [onElement]);
|
|
93
|
+
}
|
|
73
94
|
function getMessageElements(contentElement, spacerElement) {
|
|
74
95
|
if (!contentElement) {
|
|
75
96
|
return [];
|
|
@@ -102,6 +123,18 @@ function canKeyboardScroll(viewportElement, event) {
|
|
|
102
123
|
}
|
|
103
124
|
return false;
|
|
104
125
|
}
|
|
126
|
+
// Keys pressed in a text field move its caret or change its value, and Space presses a button.
|
|
127
|
+
// Neither scrolls the viewport, so they don't mean the reader took over.
|
|
128
|
+
function isKeyHandledByTarget(event) {
|
|
129
|
+
const target = event.target;
|
|
130
|
+
if (!(target instanceof HTMLElement)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (target.isContentEditable || target.matches('input, select, textarea')) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return event.key === ' ' && target.matches('button, summary');
|
|
137
|
+
}
|
|
105
138
|
function getElementTop(element, viewportElement) {
|
|
106
139
|
const elementRectangle = element.getBoundingClientRect();
|
|
107
140
|
const viewportRectangle = viewportElement.getBoundingClientRect();
|
|
@@ -187,8 +220,10 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
187
220
|
const userScrollIntentRef = useRef(false);
|
|
188
221
|
// Smooth bottom scrolls can briefly measure as away from bottom while still settling.
|
|
189
222
|
const bottomFollowIntentRef = useRef(autoFollow);
|
|
190
|
-
const
|
|
191
|
-
|
|
223
|
+
const lastScrollTopRef = useRef(0);
|
|
224
|
+
// Where the current jump is headed. A smooth jump sends scroll events for many frames, and one
|
|
225
|
+
// that lands on the bottom must not read as the reader scrolling there to resume following.
|
|
226
|
+
const jumpInFlightRef = useRef(null);
|
|
192
227
|
const pendingDefaultScrollFrameRef = useRef(null);
|
|
193
228
|
const pendingSyncFrameRef = useRef(null);
|
|
194
229
|
const pendingScrollToMessageRef = useRef(null);
|
|
@@ -266,6 +301,17 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
266
301
|
const commitStatus = useCallback(() => {
|
|
267
302
|
const status = measureStatus();
|
|
268
303
|
const isAnchoredMode = modeRef.current === 'anchored-to-message' || modeRef.current === 'settling-jump';
|
|
304
|
+
const scrollTop = viewportElementRef.current?.scrollTop ?? 0;
|
|
305
|
+
const scrolledUp = scrollTop < lastScrollTopRef.current - SCROLL_TOLERANCE;
|
|
306
|
+
lastScrollTopRef.current = scrollTop;
|
|
307
|
+
// Following never scrolls up on its own, so moving up means someone else scrolled: a
|
|
308
|
+
// scrollbar drag, find-in-page, or scrollIntoView. None of those fire wheel, touch, or key
|
|
309
|
+
// input, so treat them as the reader taking over.
|
|
310
|
+
if (scrolledUp && modeRef.current === 'following-bottom' && !status.isAtBottom) {
|
|
311
|
+
autoscrollingRef.current = false;
|
|
312
|
+
bottomFollowIntentRef.current = false;
|
|
313
|
+
modeRef.current = 'free-scrolling';
|
|
314
|
+
}
|
|
269
315
|
if (status.isAtBottom) {
|
|
270
316
|
userScrollIntentRef.current = false;
|
|
271
317
|
}
|
|
@@ -351,16 +397,6 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
351
397
|
syncVisibility();
|
|
352
398
|
capturePrependAnchor();
|
|
353
399
|
}, [capturePrependAnchor, commitStatus, syncVisibility]);
|
|
354
|
-
const ignoreAnchoredBottomResumeForCurrentFrame = useCallback(() => {
|
|
355
|
-
ignoreAnchoredBottomResumeRef.current = true;
|
|
356
|
-
if (ignoreAnchoredBottomResumeFrameRef.current !== null) {
|
|
357
|
-
window.cancelAnimationFrame(ignoreAnchoredBottomResumeFrameRef.current);
|
|
358
|
-
}
|
|
359
|
-
ignoreAnchoredBottomResumeFrameRef.current = window.requestAnimationFrame(() => {
|
|
360
|
-
ignoreAnchoredBottomResumeFrameRef.current = null;
|
|
361
|
-
ignoreAnchoredBottomResumeRef.current = false;
|
|
362
|
-
});
|
|
363
|
-
}, []);
|
|
364
400
|
const scheduleSyncAfterScroll = useCallback(() => {
|
|
365
401
|
if (pendingSyncFrameRef.current !== null) {
|
|
366
402
|
return;
|
|
@@ -447,15 +483,12 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
447
483
|
setSpacerHeight(spacerHeight);
|
|
448
484
|
anchoredElementRef.current = keepPreviousItemPeek ? element : null;
|
|
449
485
|
modeRef.current = keepPreviousItemPeek ? 'anchored-to-message' : 'settling-jump';
|
|
450
|
-
|
|
486
|
+
jumpInFlightRef.current = {
|
|
487
|
+
distance: Math.abs(viewportElement.scrollTop - Math.max(0, targetScrollTop)),
|
|
488
|
+
targetScrollTop: Math.max(0, targetScrollTop),
|
|
489
|
+
};
|
|
451
490
|
return scrollToTopValue(targetScrollTop, { behavior });
|
|
452
|
-
}, [
|
|
453
|
-
clearSpacer,
|
|
454
|
-
ignoreAnchoredBottomResumeForCurrentFrame,
|
|
455
|
-
scrollToTopValue,
|
|
456
|
-
setAutoscrolling,
|
|
457
|
-
setSpacerHeight,
|
|
458
|
-
]);
|
|
491
|
+
}, [clearSpacer, scrollToTopValue, setAutoscrolling, setSpacerHeight]);
|
|
459
492
|
const scrollToAnchorElement = useCallback((element, options = {}) => scrollToElement(element, {
|
|
460
493
|
align: 'start',
|
|
461
494
|
behavior: options.behavior,
|
|
@@ -491,6 +524,11 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
491
524
|
}
|
|
492
525
|
const element = messageElementsRef.current.get(pendingScrollToMessage.messageId);
|
|
493
526
|
if (!element) {
|
|
527
|
+
// The jump waited for messages, and these don't have its target. Drop it like a direct
|
|
528
|
+
// miss, or it would fire whenever that id shows up later and yank the reader there.
|
|
529
|
+
if (messageElementsRef.current.size > 0) {
|
|
530
|
+
pendingScrollToMessageRef.current = null;
|
|
531
|
+
}
|
|
494
532
|
return false;
|
|
495
533
|
}
|
|
496
534
|
pendingScrollToMessageRef.current = null;
|
|
@@ -601,7 +639,9 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
601
639
|
}, [scrollToAnchorElement]);
|
|
602
640
|
const handleContentChange = useCallback(() => {
|
|
603
641
|
const contentElement = contentElementRef.current;
|
|
604
|
-
|
|
642
|
+
// Content's layout effects run before the Viewport's ref attaches when both mount together.
|
|
643
|
+
// Wait for the Viewport's own pass instead of spending queued jumps and anchors on nothing.
|
|
644
|
+
if (!contentElement || !viewportElementRef.current) {
|
|
605
645
|
return;
|
|
606
646
|
}
|
|
607
647
|
if (flushPendingScrollToMessage()) {
|
|
@@ -658,8 +698,16 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
658
698
|
}, [reanchorToAnchoredMessage, scrollToBottom, syncAfterScroll]);
|
|
659
699
|
const handleViewportScroll = useCallback(() => {
|
|
660
700
|
syncAfterScroll();
|
|
661
|
-
|
|
662
|
-
|
|
701
|
+
const jump = jumpInFlightRef.current;
|
|
702
|
+
if (jump && viewportElementRef.current) {
|
|
703
|
+
const distance = Math.abs(viewportElementRef.current.scrollTop - jump.targetScrollTop);
|
|
704
|
+
// Closing in on the target, or resting on it, is the jump itself. Moving away is someone
|
|
705
|
+
// else scrolling, so from then on the bottom check below applies.
|
|
706
|
+
if (distance <= jump.distance + SCROLL_TOLERANCE) {
|
|
707
|
+
jump.distance = Math.min(jump.distance, distance);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
jumpInFlightRef.current = null;
|
|
663
711
|
}
|
|
664
712
|
const status = measureStatus();
|
|
665
713
|
const isAnchoredMode = modeRef.current === 'anchored-to-message' || modeRef.current === 'settling-jump';
|
|
@@ -676,6 +724,7 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
676
724
|
}, [clearSpacer, measureStatus, syncAfterScroll]);
|
|
677
725
|
const markUserScrollIntent = useCallback(() => {
|
|
678
726
|
userScrollIntentRef.current = true;
|
|
727
|
+
jumpInFlightRef.current = null;
|
|
679
728
|
if (modeRef.current === 'following-bottom' ||
|
|
680
729
|
modeRef.current === 'anchored-to-message' ||
|
|
681
730
|
modeRef.current === 'settling-jump') {
|
|
@@ -719,7 +768,7 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
719
768
|
userScrollIntentRef.current = false;
|
|
720
769
|
defaultScrollPositionAppliedRef.current = false;
|
|
721
770
|
prependRestoreRef.current = null;
|
|
722
|
-
|
|
771
|
+
jumpInFlightRef.current = null;
|
|
723
772
|
visibilityStore.setSnapshot(DEFAULT_VISIBILITY);
|
|
724
773
|
scheduleSyncAfterScroll();
|
|
725
774
|
}, [clearSpacer, scheduleSyncAfterScroll, visibilityStore]);
|
|
@@ -735,9 +784,6 @@ function useMessageScrollerEngine({ autoFollow, defaultScrollPosition, scrollEdg
|
|
|
735
784
|
if (pendingDefaultScrollFrameRef.current !== null) {
|
|
736
785
|
window.cancelAnimationFrame(pendingDefaultScrollFrameRef.current);
|
|
737
786
|
}
|
|
738
|
-
if (ignoreAnchoredBottomResumeFrameRef.current !== null) {
|
|
739
|
-
window.cancelAnimationFrame(ignoreAnchoredBottomResumeFrameRef.current);
|
|
740
|
-
}
|
|
741
787
|
}, []);
|
|
742
788
|
return useMemo(() => ({
|
|
743
789
|
handleContentChange,
|
|
@@ -797,10 +843,7 @@ function MessageScrollerViewport({ 'aria-label': ariaLabel, children, className,
|
|
|
797
843
|
const { handleContentChange, handleResize, handleViewportScroll, markUserScrollIntent, preserveScrollOnPrependRef, setViewportElement, viewportElementRef, } = useMessageScrollerContext('MessageScroller.Viewport');
|
|
798
844
|
const touchClientYRef = useRef(null);
|
|
799
845
|
preserveScrollOnPrependRef.current = preserveScrollOnPrepend;
|
|
800
|
-
const handleRef =
|
|
801
|
-
setViewportElement(element);
|
|
802
|
-
assignRef(ref, element);
|
|
803
|
-
}, [ref, setViewportElement]);
|
|
846
|
+
const handleRef = useForwardedRef(ref, setViewportElement);
|
|
804
847
|
useLayoutEffect(() => {
|
|
805
848
|
handleContentChange();
|
|
806
849
|
}, [handleContentChange]);
|
|
@@ -842,6 +885,7 @@ function MessageScrollerViewport({ 'aria-label': ariaLabel, children, className,
|
|
|
842
885
|
onKeyDown?.(event);
|
|
843
886
|
if (!event.defaultPrevented &&
|
|
844
887
|
USER_SCROLL_INTENT_KEYS.has(event.key) &&
|
|
888
|
+
!isKeyHandledByTarget(event) &&
|
|
845
889
|
canKeyboardScroll(event.currentTarget, event)) {
|
|
846
890
|
markUserScrollIntent();
|
|
847
891
|
}
|
|
@@ -862,12 +906,11 @@ function MessageScrollerContent({ 'aria-relevant': ariaRelevant, children, class
|
|
|
862
906
|
const contentElementRef = useRef(null);
|
|
863
907
|
const contentSignatureRef = useRef('');
|
|
864
908
|
const spacerElementRef = useRef(null);
|
|
865
|
-
const handleContentRef = useCallback((element) => {
|
|
909
|
+
const handleContentRef = useForwardedRef(ref, useCallback((element) => {
|
|
866
910
|
contentElementRef.current = element;
|
|
867
911
|
contentSignatureRef.current = '';
|
|
868
912
|
setContentElement(element);
|
|
869
|
-
|
|
870
|
-
}, [ref, setContentElement]);
|
|
913
|
+
}, [setContentElement]));
|
|
871
914
|
const handleSpacerRef = useCallback((element) => {
|
|
872
915
|
spacerElementRef.current = element;
|
|
873
916
|
setSpacerElement(element);
|
package/dist/Popover/Popover.js
CHANGED
|
@@ -7,7 +7,7 @@ const POPOVER_COLLISION_AVOIDANCE = {
|
|
|
7
7
|
align: 'shift',
|
|
8
8
|
fallbackAxisSide: 'none',
|
|
9
9
|
};
|
|
10
|
-
const popupClasses = 'bg-popover text-popover-foreground border-border shadow-popover box-border max-h-[var(--available-height)] max-w-[var(--available-width)] origin-[var(--transform-origin)] overflow-x-hidden overflow-y-auto rounded-lg border outline-hidden transition-[
|
|
10
|
+
const popupClasses = 'bg-popover text-popover-foreground border-border shadow-popover box-border max-h-[var(--available-height)] max-w-[var(--available-width)] origin-[var(--transform-origin)] overflow-x-hidden overflow-y-auto rounded-lg border outline-hidden transition-[scale,opacity] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] data-[ending-style]:scale-[0.98] data-[ending-style]:opacity-0 data-[instant]:transition-none data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3 focus-visible:transition-none motion-reduce:transition-none';
|
|
11
11
|
const Positioner = ({ className, sideOffset = 6, collisionPadding = 8, collisionAvoidance = POPOVER_COLLISION_AVOIDANCE, positionMethod = 'fixed', ...props }) => (_jsx(BasePopover.Positioner, { sideOffset: sideOffset, collisionPadding: collisionPadding, collisionAvoidance: collisionAvoidance, positionMethod: positionMethod, className: mergeStatefulClassName('z-50 outline-hidden', className), ...props }));
|
|
12
12
|
const Popup = ({ className, ...props }) => (_jsx(BasePopover.Popup, { className: mergeStatefulClassName(popupClasses, className), ...props }));
|
|
13
13
|
/** Accessible floating disclosure over Base UI Popover. The popup supplies the semantic surface,
|
package/dist/Select/Select.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ type GroupLabelProps = ComponentPropsWithoutRef<typeof BaseSelect.GroupLabel> &
|
|
|
23
23
|
ref?: Ref<HTMLDivElement>;
|
|
24
24
|
};
|
|
25
25
|
export declare const Select: {
|
|
26
|
-
({ value, onChange, options, groups, placeholder, id, className, menuClassName, menuAlign, renderOption, onOpenChange, name, form, autoComplete, required, disabled, readOnly, "aria-label": ariaLabel, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
({ value, onChange, options, groups, placeholder, id, className, menuClassName, menuAlign, renderOption, onOpenChange, name, form, autoComplete, required, disabled, readOnly, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
displayName: string;
|
|
28
28
|
} & {
|
|
29
29
|
Root: typeof BaseSelect.Root;
|