@kortix/ui 0.15.7 → 0.15.8
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/README.md +7 -7
- package/dist/_vendor/kortix-shared.js +36 -1
- package/dist/_vendor/shared/my-kortix-agent.d.ts +7 -0
- package/dist/_vendor/shared/pixel-mark.d.ts +18 -0
- package/dist/customize/connectors/catalog/connector-categories.d.ts +2 -2
- package/dist/customize/connectors/catalog/connector-categories.js +2 -2
- package/dist/customize/connectors/detail/connector-modal.js +1 -1
- package/dist/customize/sections/gateway-view.d.ts +1 -1
- package/dist/customize/sections/gateway-view.js +1 -1
- package/dist/customize/sections/view/account-secret-resources-panel.js +4 -2
- package/dist/customize/sections/view/agent-editor-basics-fields.js +1 -1
- package/dist/customize/sections/view/gateway/gateway-logs.d.ts +1 -1
- package/dist/customize/sections/view/git-view.js +1 -1
- package/dist/customize/sections/view/permission-editor.js +1 -1
- package/dist/customize/sections/view/subscription-usage.d.ts +3 -32
- package/dist/customize/sections/view/subscription-usage.js +2 -86
- package/dist/customize/shared/entity/entity-modal.js +8 -10
- package/dist/files/project/components/drive-toolbar.d.ts +1 -1
- package/dist/files/project/components/drive-toolbar.js +1 -1
- package/dist/files/project/store/version-store.d.ts +1 -1
- package/dist/files/renderers/shared/scroll-area-compat.d.ts +6 -6
- package/dist/files/renderers/shared/scroll-area-compat.js +7 -9
- package/dist/files/renderers/shared/select-compat.js +3 -7
- package/dist/files/viewer/file-preview-modal.d.ts +10 -11
- package/dist/files/viewer/file-preview-modal.js +17 -18
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.js +7 -4
- package/dist/index.js +1 -1
- package/dist/internal/account-hub/account-hub-location.js +2 -2
- package/dist/internal/account-hub/use-account-members.d.ts +28 -1
- package/dist/internal/account-hub/use-account-members.js +27 -10
- package/dist/internal/components/agent-mark.d.ts +1 -8
- package/dist/internal/components/agent-mark.js +2 -19
- package/dist/internal/lib/navigation/modified-click.js +2 -2
- package/dist/internal/lib/pixel-mark.d.ts +3 -20
- package/dist/internal/lib/pixel-mark.js +3 -34
- package/dist/internal/stores/active-space-store.d.ts +1 -1
- package/dist/internal/stores/browser-recents-store.d.ts +1 -1
- package/dist/internal/stores/current-account-store.d.ts +1 -1
- package/dist/internal/stores/first-chat-store.d.ts +1 -1
- package/dist/internal/stores/mobile-app-promo-store.d.ts +1 -1
- package/dist/internal/stores/session-browser-store.d.ts +1 -1
- package/dist/internal/stores/session-expanded-store.d.ts +1 -1
- package/dist/internal/stores/session-filter-store.d.ts +1 -1
- package/dist/internal/stores/session-history-view-store.d.ts +1 -1
- package/dist/internal/stores/session-hover-store.d.ts +1 -1
- package/dist/internal/stores/session-hover-store.js +1 -1
- package/dist/internal/stores/session-panel-memory-store.d.ts +1 -1
- package/dist/internal/stores/sound-store.d.ts +1 -1
- package/dist/internal/stores/tab-store.d.ts +1 -1
- package/dist/internal/stores/user-preferences-store.d.ts +1 -1
- package/dist/internal/stores/web-notification-store.d.ts +1 -1
- package/dist/lib/base-ui-compat.d.ts +149 -0
- package/dist/lib/base-ui-compat.js +339 -0
- package/dist/lib/portal-container.d.ts +3 -7
- package/dist/lib/portal-container.js +5 -3
- package/dist/lib/z-stack.d.ts +4 -4
- package/dist/lib/z-stack.js +5 -5
- package/dist/primitives/accordion.d.ts +36 -5
- package/dist/primitives/accordion.js +41 -8
- package/dist/primitives/alert-dialog.d.ts +33 -11
- package/dist/primitives/alert-dialog.js +41 -19
- package/dist/primitives/avatar.d.ts +5 -2
- package/dist/primitives/avatar.js +3 -3
- package/dist/primitives/badge.js +1 -1
- package/dist/primitives/breadcrumb.js +1 -1
- package/dist/primitives/button-group.js +3 -3
- package/dist/primitives/button.js +1 -1
- package/dist/primitives/checkbox.d.ts +14 -5
- package/dist/primitives/checkbox.js +24 -9
- package/dist/primitives/collapsible.d.ts +16 -4
- package/dist/primitives/collapsible.js +18 -7
- package/dist/primitives/command-core.d.ts +121 -0
- package/dist/primitives/command-core.js +642 -0
- package/dist/primitives/command.d.ts +38 -4
- package/dist/primitives/command.js +22 -13
- package/dist/primitives/context-menu.d.ts +61 -31
- package/dist/primitives/context-menu.js +40 -53
- package/dist/primitives/dialog.d.ts +48 -10
- package/dist/primitives/dialog.js +48 -19
- package/dist/primitives/disclosure.d.ts +1 -1
- package/dist/primitives/disclosure.js +2 -2
- package/dist/primitives/drawer.d.ts +28 -9
- package/dist/primitives/drawer.js +42 -18
- package/dist/primitives/dropdown-menu.d.ts +55 -33
- package/dist/primitives/dropdown-menu.js +46 -82
- package/dist/primitives/faded-scroll-area.js +2 -1
- package/dist/primitives/hint.js +3 -3
- package/dist/primitives/hover-card.d.ts +17 -5
- package/dist/primitives/hover-card.js +45 -8
- package/dist/primitives/item.js +2 -2
- package/dist/primitives/label.d.ts +5 -2
- package/dist/primitives/label.js +10 -3
- package/dist/primitives/menu-base.d.ts +150 -0
- package/dist/primitives/menu-base.js +171 -0
- package/dist/primitives/menu-recipe.d.ts +1 -1
- package/dist/primitives/menu-recipe.js +2 -7
- package/dist/primitives/modal.d.ts +19 -52
- package/dist/primitives/modal.js +24 -28
- package/dist/primitives/navigation-menu.d.ts +36 -11
- package/dist/primitives/navigation-menu.js +31 -12
- package/dist/primitives/popover.d.ts +31 -6
- package/dist/primitives/popover.js +79 -12
- package/dist/primitives/preview-image.d.ts +18 -7
- package/dist/primitives/preview-image.js +14 -11
- package/dist/primitives/progress.d.ts +4 -2
- package/dist/primitives/progress.js +4 -3
- package/dist/primitives/project-icon-picker.js +2 -2
- package/dist/primitives/radio-group.d.ts +28 -5
- package/dist/primitives/radio-group.js +18 -10
- package/dist/primitives/scroll-area.d.ts +2 -2
- package/dist/primitives/scroll-area.js +8 -3
- package/dist/primitives/select.d.ts +55 -12
- package/dist/primitives/select.js +93 -36
- package/dist/primitives/separator.d.ts +6 -2
- package/dist/primitives/separator.js +10 -2
- package/dist/primitives/sheet.d.ts +17 -10
- package/dist/primitives/sheet.js +19 -22
- package/dist/primitives/sidebar-menu-primitives.js +8 -8
- package/dist/primitives/slider-native.d.ts +2 -2
- package/dist/primitives/slider-native.js +11 -9
- package/dist/primitives/slider.d.ts +24 -6
- package/dist/primitives/slider.js +26 -24
- package/dist/primitives/slot.d.ts +6 -0
- package/dist/primitives/slot.js +7 -0
- package/dist/primitives/split-sheet.js +1 -1
- package/dist/primitives/stepper.js +1 -1
- package/dist/primitives/switch.d.ts +16 -3
- package/dist/primitives/switch.js +7 -6
- package/dist/primitives/tabs.d.ts +36 -20
- package/dist/primitives/tabs.js +131 -102
- package/dist/primitives/toggle.d.ts +16 -3
- package/dist/primitives/toggle.js +8 -3
- package/dist/primitives/tooltip.d.ts +24 -5
- package/dist/primitives/tooltip.js +32 -10
- package/dist/primitives/type-to-confirm-dialog.d.ts +1 -1
- package/dist/primitives/type-to-confirm-dialog.js +1 -1
- package/dist/session/composer/animated-placeholder.js +1 -1
- package/dist/session/composer/chat-input/chat-input-control.js +3 -3
- package/dist/session/composer/editor/composer-editor.js +1 -1
- package/dist/session/composer/menus/menu-shell.d.ts +1 -1
- package/dist/session/composer/menus/menu-shell.js +1 -1
- package/dist/session/composer/menus/mount.js +1 -1
- package/dist/session/composer/reasoning-effort-selector.js +1 -1
- package/dist/session/header/session-site-header.js +2 -2
- package/dist/session/header/subagent-hover-card.js +2 -2
- package/dist/session/media/image-preview.js +1 -1
- package/dist/session/models/model-selector.d.ts +1 -1
- package/dist/session/models/model-selector.js +18 -12
- package/dist/session/models/subscription-switcher.d.ts +37 -0
- package/dist/session/models/subscription-switcher.js +97 -0
- package/dist/session/models/subscription-windows.d.ts +40 -0
- package/dist/session/models/subscription-windows.js +86 -0
- package/dist/session/overrides/session-overrides-control.js +3 -3
- package/dist/session/panel/diff-dialog.js +1 -1
- package/dist/session/panel/easy/detail-view.js +3 -3
- package/dist/session/panel/mobile-tool-drawer.js +2 -2
- package/dist/session/panel/panel-fallback.js +1 -1
- package/dist/session/panel/session-files-explorer.d.ts +1 -1
- package/dist/session/panel/session-files-explorer.js +1 -1
- package/dist/session/thread/session-chat.js +2 -2
- package/dist/session/thread/session-context-message-explorer.js +1 -1
- package/dist/session/thread/turn-share.js +3 -4
- package/dist/session/tool/shared/show-helpers.js +1 -1
- package/dist/session/turn/message-time-label.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +3 -0
- package/dist/workspace/projects/modal/project-icon-field.js +9 -23
- package/dist/workspace/review/review-center.js +1 -1
- package/dist/workspace/sessions/session-row.js +1 -1
- package/dist/workspace/sidebar/project-session-list.js +2 -2
- package/dist/workspace/sidebar/session-brief-hover-card.d.ts +1 -1
- package/dist/workspace/sidebar/session-brief-hover-card.js +3 -3
- package/dist/workspace/sidebar/session-title.d.ts +2 -2
- package/dist/workspace/sidebar/session-title.js +2 -2
- package/dist/workspace/sidebar/workspace-menu-section.js +1 -1
- package/dist/workspace/spaces/space-links.js +1 -1
- package/dist/workspace/spaces/space-threads-tab.js +1 -1
- package/package.json +16 -35
- package/skills/kortix-ui/SKILL.md +1 -1
- package/skills/kortix-ui/references/custom-dashboard.md +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@kortix/ui` primitives run on Base UI and keep the prop and attribute
|
|
3
|
+
* contract they had on Radix. `@kortix/ui` is published, so customer apps and
|
|
4
|
+
* our own call sites keep `asChild`, `data-state`, `--radix-*` CSS variables,
|
|
5
|
+
* `onEscapeKeyDown` / `onPointerDownOutside` / `onInteractOutside`, and
|
|
6
|
+
* `onOpenAutoFocus` / `onCloseAutoFocus`. This file translates them.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
type AnyProps = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Turns Radix `asChild` into Base UI `render`: the only child becomes the
|
|
12
|
+
* rendered element and keeps its own children.
|
|
13
|
+
*/
|
|
14
|
+
export declare function asChildRender(asChild: boolean | undefined, children: React.ReactNode): {
|
|
15
|
+
render?: React.ReactElement;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A Base UI `render` function that adds a Radix `data-state` attribute, on
|
|
20
|
+
* the `asChild` element when there is one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function stateRender<S = any>(tag: keyof React.JSX.IntrinsicElements, toState: (state: S) => string | undefined, element?: React.ReactElement, extra?: (state: S) => AnyProps): (props: any, state: S) => React.ReactElement;
|
|
23
|
+
export declare const openState: (s: any) => "open" | "closed";
|
|
24
|
+
export declare const checkedState: (s: any) => "indeterminate" | "checked" | "unchecked";
|
|
25
|
+
/**
|
|
26
|
+
* A Base UI `render` for a form control: a native `<button>` that writes
|
|
27
|
+
* `data-state` and `disabled` last, in Radix's attribute order.
|
|
28
|
+
* Switch, radio and tab items use it too.
|
|
29
|
+
*/
|
|
30
|
+
export declare function controlRender<S extends {
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
}>(toState: (state: S) => string): (props: React.ComponentProps<"button">, state: S) => React.JSX.Element;
|
|
33
|
+
/** Merges props the way Radix `Slot` did: handlers chain, classes join, styles merge. */
|
|
34
|
+
export declare function mergeElementProps(own: AnyProps, slot: AnyProps): AnyProps;
|
|
35
|
+
export declare function composeRefs<T>(...refs: Array<React.Ref<T> | undefined>): React.RefCallback<T>;
|
|
36
|
+
/** The part of a Radix dismiss event that consumers read. */
|
|
37
|
+
export interface LegacyDismissEvent {
|
|
38
|
+
readonly target: EventTarget | null;
|
|
39
|
+
readonly detail: {
|
|
40
|
+
originalEvent: Event;
|
|
41
|
+
};
|
|
42
|
+
readonly defaultPrevented: boolean;
|
|
43
|
+
preventDefault(): void;
|
|
44
|
+
}
|
|
45
|
+
export interface DismissHandlers {
|
|
46
|
+
onEscapeKeyDown?: (event: KeyboardEvent & LegacyDismissEvent) => void;
|
|
47
|
+
onPointerDownOutside?: (event: LegacyDismissEvent) => void;
|
|
48
|
+
onFocusOutside?: (event: LegacyDismissEvent) => void;
|
|
49
|
+
onInteractOutside?: (event: LegacyDismissEvent) => void;
|
|
50
|
+
}
|
|
51
|
+
/** The Base UI change details passed to `onOpenChange`. */
|
|
52
|
+
export interface ChangeDetails {
|
|
53
|
+
reason: string;
|
|
54
|
+
event?: Event;
|
|
55
|
+
cancel(): void;
|
|
56
|
+
}
|
|
57
|
+
type DismissRegistry = React.MutableRefObject<DismissHandlers>;
|
|
58
|
+
/**
|
|
59
|
+
* The root half: wraps `onOpenChange` so a close that a content-level Radix
|
|
60
|
+
* handler prevented is cancelled.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useDismissRoot<A extends unknown[]>(onOpenChange: ((open: boolean, ...rest: A) => void) | undefined): {
|
|
63
|
+
registry: React.RefObject<DismissHandlers>;
|
|
64
|
+
onOpenChange: (open: boolean, details?: ChangeDetails) => void;
|
|
65
|
+
};
|
|
66
|
+
export declare function DismissProvider({ kind, registry, children, }: {
|
|
67
|
+
/** The component family: `dialog`, `menu`, `select`, ... */
|
|
68
|
+
kind: string;
|
|
69
|
+
registry: DismissRegistry;
|
|
70
|
+
children: React.ReactNode;
|
|
71
|
+
}): React.JSX.Element;
|
|
72
|
+
/** The content half: registers this content's Radix dismiss handlers with the nearest root of `kind`. */
|
|
73
|
+
export declare function useDismissContent(kind: string, handlers: DismissHandlers): void;
|
|
74
|
+
/**
|
|
75
|
+
* Radix `onOpenAutoFocus` / `onCloseAutoFocus` → Base UI `initialFocus` /
|
|
76
|
+
* `finalFocus`, plus Radix's rule that an `autoFocus` field inside the popup
|
|
77
|
+
* keeps focus on open. As in Radix, the handler gets a cancelable event dispatched on
|
|
78
|
+
* the popup, so `event.currentTarget` is the popup; `preventDefault()` keeps
|
|
79
|
+
* focus where the handler put it.
|
|
80
|
+
*/
|
|
81
|
+
export declare function focusProps(getPopup: () => HTMLElement | null, onOpenAutoFocus?: (event: Event) => void, onCloseAutoFocus?: (event: Event) => void): {
|
|
82
|
+
initialFocus: () => boolean;
|
|
83
|
+
finalFocus: () => boolean;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Base UI `nativeButton` for a trigger: true when it renders a real `<button>`.
|
|
87
|
+
* That is the default, an `asChild` child that is `<button>`, and an `asChild`
|
|
88
|
+
* child component whose name ends in `Button` (`Button`, `SidebarMenuButton`,
|
|
89
|
+
* ...) and does not itself slot into another element.
|
|
90
|
+
*/
|
|
91
|
+
export declare function nativeButtonFor(asChild: boolean | undefined, children: React.ReactNode): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* `nativeButton` for a trigger, checked against the DOM. `nativeButtonFor`
|
|
94
|
+
* guesses from the child's name, which a production build can minify away;
|
|
95
|
+
* after mount this reads the rendered element's tag and corrects the guess.
|
|
96
|
+
* Spread `ref` onto the Base UI part (compose it with the caller's ref).
|
|
97
|
+
*/
|
|
98
|
+
export declare function useNativeButton(asChild: boolean | undefined, children: React.ReactNode): {
|
|
99
|
+
nativeButton: boolean;
|
|
100
|
+
ref: (node: HTMLElement | null) => void;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Marks a Base UI `Positioner` as a floating layer (the role Radix's
|
|
104
|
+
* `data-radix-popper-content-wrapper` played). `lib/z-stack.tsx`, the desktop
|
|
105
|
+
* titlebar CSS and outside-click guards match `[data-kortix-floating]`.
|
|
106
|
+
*/
|
|
107
|
+
export declare const FLOATING_LAYER_ATTR: {
|
|
108
|
+
readonly 'data-kortix-floating': "";
|
|
109
|
+
};
|
|
110
|
+
export interface LegacyPositionProps {
|
|
111
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
112
|
+
align?: 'start' | 'center' | 'end';
|
|
113
|
+
sideOffset?: number;
|
|
114
|
+
alignOffset?: number;
|
|
115
|
+
collisionPadding?: number | Partial<Record<'top' | 'right' | 'bottom' | 'left', number>>;
|
|
116
|
+
avoidCollisions?: boolean;
|
|
117
|
+
sticky?: 'partial' | 'always';
|
|
118
|
+
collisionBoundary?: Element | null | Array<Element | null>;
|
|
119
|
+
arrowPadding?: number;
|
|
120
|
+
hideWhenDetached?: boolean;
|
|
121
|
+
updatePositionStrategy?: 'optimized' | 'always';
|
|
122
|
+
}
|
|
123
|
+
/** Splits Radix `Content` positioning props into Base UI `Positioner` props. */
|
|
124
|
+
export declare function splitPosition<P extends LegacyPositionProps>(props: P): {
|
|
125
|
+
positioner: AnyProps;
|
|
126
|
+
rest: Omit<P, "sticky" | "side" | "align" | "sideOffset" | "alignOffset" | "collisionPadding" | "avoidCollisions" | "collisionBoundary" | "arrowPadding" | "hideWhenDetached" | "updatePositionStrategy">;
|
|
127
|
+
};
|
|
128
|
+
/** Maps Base UI positioner variables to the `--radix-<name>-*` names consumers read. */
|
|
129
|
+
export declare function radixPositionVars(name: string): React.CSSProperties;
|
|
130
|
+
/**
|
|
131
|
+
* Renders its only child with these props merged in, the way Radix `Slot`
|
|
132
|
+
* did: handlers chain, classes join, styles merge, refs compose.
|
|
133
|
+
*/
|
|
134
|
+
export declare const Slot: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLElement> & AnyProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
135
|
+
/** Hides content visually and keeps it for screen readers. */
|
|
136
|
+
export declare const VisuallyHidden: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
|
|
137
|
+
asChild?: boolean;
|
|
138
|
+
} & React.RefAttributes<HTMLSpanElement>>;
|
|
139
|
+
/**
|
|
140
|
+
* An `onClick` for a Base UI checkbox or radio root. Base UI forwards a
|
|
141
|
+
* press to its hidden `<input>`; inside a consumer's `<label>`, that click
|
|
142
|
+
* bubbles to the label. Browsers ignore it (the target is interactive
|
|
143
|
+
* content), but happy-dom re-dispatches it to the button and loops. This
|
|
144
|
+
* drops the re-entrant click; in a browser it never fires.
|
|
145
|
+
*/
|
|
146
|
+
export declare function useLabelReentryGuard(onClick?: (event: any) => void): (event: React.MouseEvent<HTMLElement> & {
|
|
147
|
+
preventBaseUIHandler?: () => void;
|
|
148
|
+
}) => void;
|
|
149
|
+
export {};
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The `@kortix/ui` primitives run on Base UI and keep the prop and attribute
|
|
5
|
+
* contract they had on Radix. `@kortix/ui` is published, so customer apps and
|
|
6
|
+
* our own call sites keep `asChild`, `data-state`, `--radix-*` CSS variables,
|
|
7
|
+
* `onEscapeKeyDown` / `onPointerDownOutside` / `onInteractOutside`, and
|
|
8
|
+
* `onOpenAutoFocus` / `onCloseAutoFocus`. This file translates them.
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
/* ---------- asChild → render ---------- */
|
|
12
|
+
/**
|
|
13
|
+
* Turns Radix `asChild` into Base UI `render`: the only child becomes the
|
|
14
|
+
* rendered element and keeps its own children.
|
|
15
|
+
*/
|
|
16
|
+
export function asChildRender(asChild, children) {
|
|
17
|
+
if (asChild && React.isValidElement(children)) {
|
|
18
|
+
return {
|
|
19
|
+
render: children,
|
|
20
|
+
children: children.props.children,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return { children };
|
|
24
|
+
}
|
|
25
|
+
/* ---------- data-state ---------- */
|
|
26
|
+
/**
|
|
27
|
+
* A Base UI `render` function that adds a Radix `data-state` attribute, on
|
|
28
|
+
* the `asChild` element when there is one.
|
|
29
|
+
*/
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
export function stateRender(tag, toState, element, extra) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
return function renderWithState(props, state) {
|
|
34
|
+
const attrs = { ...props, 'data-state': toState(state), ...extra?.(state) };
|
|
35
|
+
if (element) {
|
|
36
|
+
// `render` with an element merges into it; a function must merge itself.
|
|
37
|
+
const own = element.props;
|
|
38
|
+
return React.cloneElement(element, mergeElementProps(own, attrs));
|
|
39
|
+
}
|
|
40
|
+
return React.createElement(tag, attrs);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
export const openState = (s) => (s.open ? 'open' : 'closed');
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
export const checkedState = (s) => s.indeterminate ? 'indeterminate' : s.checked ? 'checked' : 'unchecked';
|
|
47
|
+
/**
|
|
48
|
+
* A Base UI `render` for a form control: a native `<button>` that writes
|
|
49
|
+
* `data-state` and `disabled` last, in Radix's attribute order.
|
|
50
|
+
* Switch, radio and tab items use it too.
|
|
51
|
+
*/
|
|
52
|
+
export function controlRender(toState) {
|
|
53
|
+
function renderControl(props, state) {
|
|
54
|
+
const { disabled: _disabled, ...rest } = props;
|
|
55
|
+
return _jsx("button", { ...rest, "data-state": toState(state), disabled: state.disabled || undefined });
|
|
56
|
+
}
|
|
57
|
+
return renderControl;
|
|
58
|
+
}
|
|
59
|
+
/** Merges props the way Radix `Slot` did: handlers chain, classes join, styles merge. */
|
|
60
|
+
export function mergeElementProps(own, slot) {
|
|
61
|
+
const merged = { ...slot, ...own };
|
|
62
|
+
for (const key of Object.keys(slot)) {
|
|
63
|
+
const a = slot[key];
|
|
64
|
+
const b = own[key];
|
|
65
|
+
if (/^on[A-Z]/.test(key) && typeof a === 'function' && typeof b === 'function') {
|
|
66
|
+
merged[key] = (...args) => {
|
|
67
|
+
b(...args);
|
|
68
|
+
a(...args);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
else if (key === 'className' && a && b) {
|
|
72
|
+
merged[key] = `${a} ${b}`;
|
|
73
|
+
}
|
|
74
|
+
else if (key === 'style' && a && b) {
|
|
75
|
+
merged[key] = { ...a, ...b };
|
|
76
|
+
}
|
|
77
|
+
else if (key === 'ref') {
|
|
78
|
+
merged[key] =
|
|
79
|
+
b && a ? composeRefs(a, b) : (b ?? a);
|
|
80
|
+
}
|
|
81
|
+
else if (key === 'children') {
|
|
82
|
+
merged[key] = b ?? a;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return merged;
|
|
86
|
+
}
|
|
87
|
+
export function composeRefs(...refs) {
|
|
88
|
+
return (node) => {
|
|
89
|
+
for (const ref of refs) {
|
|
90
|
+
if (typeof ref === 'function')
|
|
91
|
+
ref(node);
|
|
92
|
+
else if (ref)
|
|
93
|
+
ref.current = node;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function legacyEvent(native) {
|
|
98
|
+
let prevented = false;
|
|
99
|
+
const original = native ?? new Event('dismiss');
|
|
100
|
+
const event = {
|
|
101
|
+
target: original.target,
|
|
102
|
+
detail: { originalEvent: original },
|
|
103
|
+
get defaultPrevented() {
|
|
104
|
+
return prevented;
|
|
105
|
+
},
|
|
106
|
+
preventDefault() {
|
|
107
|
+
prevented = true;
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
// Escape handlers read `key` and friends from the keyboard event.
|
|
111
|
+
return new Proxy(event, {
|
|
112
|
+
get(obj, prop, receiver) {
|
|
113
|
+
if (prop in obj)
|
|
114
|
+
return Reflect.get(obj, prop, receiver);
|
|
115
|
+
const value = original[prop];
|
|
116
|
+
return typeof value === 'function' ? value.bind(original) : value;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const DismissContext = React.createContext({});
|
|
121
|
+
/**
|
|
122
|
+
* The root half: wraps `onOpenChange` so a close that a content-level Radix
|
|
123
|
+
* handler prevented is cancelled.
|
|
124
|
+
*/
|
|
125
|
+
export function useDismissRoot(onOpenChange) {
|
|
126
|
+
const registry = React.useRef({});
|
|
127
|
+
const handle = React.useCallback((open, details) => {
|
|
128
|
+
if (!open && details && runDismissHandlers(registry.current, details)) {
|
|
129
|
+
details.cancel();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
onOpenChange?.(open);
|
|
133
|
+
}, [onOpenChange]);
|
|
134
|
+
return { registry, onOpenChange: handle };
|
|
135
|
+
}
|
|
136
|
+
/** Returns true when a handler called `preventDefault()`. */
|
|
137
|
+
function runDismissHandlers(h, details) {
|
|
138
|
+
const event = legacyEvent(details.event);
|
|
139
|
+
if (details.reason === 'escape-key') {
|
|
140
|
+
h.onEscapeKeyDown?.(event);
|
|
141
|
+
}
|
|
142
|
+
else if (details.reason === 'outside-press') {
|
|
143
|
+
h.onPointerDownOutside?.(event);
|
|
144
|
+
if (!event.defaultPrevented)
|
|
145
|
+
h.onInteractOutside?.(event);
|
|
146
|
+
}
|
|
147
|
+
else if (details.reason === 'focus-out') {
|
|
148
|
+
h.onFocusOutside?.(event);
|
|
149
|
+
if (!event.defaultPrevented)
|
|
150
|
+
h.onInteractOutside?.(event);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
return event.defaultPrevented;
|
|
156
|
+
}
|
|
157
|
+
export function DismissProvider({ kind, registry, children, }) {
|
|
158
|
+
const parent = React.useContext(DismissContext);
|
|
159
|
+
const value = React.useMemo(() => ({ ...parent, [kind]: registry }), [parent, kind, registry]);
|
|
160
|
+
return _jsx(DismissContext.Provider, { value: value, children: children });
|
|
161
|
+
}
|
|
162
|
+
/** The content half: registers this content's Radix dismiss handlers with the nearest root of `kind`. */
|
|
163
|
+
export function useDismissContent(kind, handlers) {
|
|
164
|
+
const registry = React.useContext(DismissContext)[kind];
|
|
165
|
+
if (registry)
|
|
166
|
+
registry.current = handlers;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Radix `onOpenAutoFocus` / `onCloseAutoFocus` → Base UI `initialFocus` /
|
|
170
|
+
* `finalFocus`, plus Radix's rule that an `autoFocus` field inside the popup
|
|
171
|
+
* keeps focus on open. As in Radix, the handler gets a cancelable event dispatched on
|
|
172
|
+
* the popup, so `event.currentTarget` is the popup; `preventDefault()` keeps
|
|
173
|
+
* focus where the handler put it.
|
|
174
|
+
*/
|
|
175
|
+
export function focusProps(getPopup, onOpenAutoFocus, onCloseAutoFocus) {
|
|
176
|
+
const run = (type, handler) => {
|
|
177
|
+
const event = new CustomEvent(type, { cancelable: true });
|
|
178
|
+
const node = getPopup();
|
|
179
|
+
if (!node) {
|
|
180
|
+
handler(event);
|
|
181
|
+
return !event.defaultPrevented;
|
|
182
|
+
}
|
|
183
|
+
node.addEventListener(type, handler, { once: true });
|
|
184
|
+
node.dispatchEvent(event);
|
|
185
|
+
return !event.defaultPrevented;
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
// As in Radix, focus that is already inside the popup when it opens (an
|
|
189
|
+
// `autoFocus` field) stays there; Base UI would move it to its own pick.
|
|
190
|
+
initialFocus: () => {
|
|
191
|
+
const node = getPopup();
|
|
192
|
+
if (node)
|
|
193
|
+
returnFocusTo.set(node, document.activeElement);
|
|
194
|
+
if (node && node.contains(document.activeElement))
|
|
195
|
+
return false;
|
|
196
|
+
return onOpenAutoFocus ? run('focusScope.autoFocusOnMount', onOpenAutoFocus) : true;
|
|
197
|
+
},
|
|
198
|
+
// Focus returns to where it was before the popup opened, a task after the
|
|
199
|
+
// close, and only when nothing else took it meanwhile: a menu item that
|
|
200
|
+
// opens a dialog leaves focus in the dialog's `autoFocus` field. Base UI
|
|
201
|
+
// would move focus back to the trigger after its exit, over the dialog.
|
|
202
|
+
finalFocus: () => {
|
|
203
|
+
const node = getPopup();
|
|
204
|
+
if (onCloseAutoFocus && !run('focusScope.autoFocusOnUnmount', onCloseAutoFocus))
|
|
205
|
+
return false;
|
|
206
|
+
const target = node ? returnFocusTo.get(node) : null;
|
|
207
|
+
// Nothing was focused at open (a click that does not focus): Base UI's default, the trigger.
|
|
208
|
+
if (!(target instanceof HTMLElement) || target === document.body)
|
|
209
|
+
return true;
|
|
210
|
+
setTimeout(() => {
|
|
211
|
+
const active = document.activeElement;
|
|
212
|
+
const lost = !active || active === document.body || (node?.contains(active) ?? false);
|
|
213
|
+
if (lost && target.isConnected)
|
|
214
|
+
target.focus({ preventScroll: true });
|
|
215
|
+
}, 0);
|
|
216
|
+
return false;
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/** The element that had focus when each popup opened. */
|
|
221
|
+
const returnFocusTo = new WeakMap();
|
|
222
|
+
/**
|
|
223
|
+
* Base UI `nativeButton` for a trigger: true when it renders a real `<button>`.
|
|
224
|
+
* That is the default, an `asChild` child that is `<button>`, and an `asChild`
|
|
225
|
+
* child component whose name ends in `Button` (`Button`, `SidebarMenuButton`,
|
|
226
|
+
* ...) and does not itself slot into another element.
|
|
227
|
+
*/
|
|
228
|
+
export function nativeButtonFor(asChild, children) {
|
|
229
|
+
if (!asChild)
|
|
230
|
+
return true;
|
|
231
|
+
if (!React.isValidElement(children))
|
|
232
|
+
return false;
|
|
233
|
+
if (typeof children.type === 'string')
|
|
234
|
+
return children.type === 'button';
|
|
235
|
+
return (/Button$/.test(componentName(children.type)) &&
|
|
236
|
+
!children.props.asChild);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* `nativeButton` for a trigger, checked against the DOM. `nativeButtonFor`
|
|
240
|
+
* guesses from the child's name, which a production build can minify away;
|
|
241
|
+
* after mount this reads the rendered element's tag and corrects the guess.
|
|
242
|
+
* Spread `ref` onto the Base UI part (compose it with the caller's ref).
|
|
243
|
+
*/
|
|
244
|
+
export function useNativeButton(asChild, children) {
|
|
245
|
+
const guess = nativeButtonFor(asChild, children);
|
|
246
|
+
const [actual, setActual] = React.useState(null);
|
|
247
|
+
const ref = React.useCallback((node) => {
|
|
248
|
+
if (!node || !asChild)
|
|
249
|
+
return;
|
|
250
|
+
const isButton = node.tagName === 'BUTTON';
|
|
251
|
+
setActual((current) => (current === isButton ? current : isButton));
|
|
252
|
+
}, [asChild]);
|
|
253
|
+
return { nativeButton: actual ?? guess, ref };
|
|
254
|
+
}
|
|
255
|
+
/** The name of a component, through `forwardRef` and `memo` wrappers. */
|
|
256
|
+
function componentName(type) {
|
|
257
|
+
const t = type;
|
|
258
|
+
if (!t)
|
|
259
|
+
return '';
|
|
260
|
+
return (t.displayName ??
|
|
261
|
+
t.name ??
|
|
262
|
+
(t.render ? componentName(t.render) : t.type ? componentName(t.type) : ''));
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Marks a Base UI `Positioner` as a floating layer (the role Radix's
|
|
266
|
+
* `data-radix-popper-content-wrapper` played). `lib/z-stack.tsx`, the desktop
|
|
267
|
+
* titlebar CSS and outside-click guards match `[data-kortix-floating]`.
|
|
268
|
+
*/
|
|
269
|
+
export const FLOATING_LAYER_ATTR = { 'data-kortix-floating': '' };
|
|
270
|
+
/** Splits Radix `Content` positioning props into Base UI `Positioner` props. */
|
|
271
|
+
export function splitPosition(props) {
|
|
272
|
+
const { side, align, sideOffset, alignOffset, collisionPadding, avoidCollisions, sticky, collisionBoundary, arrowPadding, hideWhenDetached: _hideWhenDetached, updatePositionStrategy: _updatePositionStrategy, ...rest } = props;
|
|
273
|
+
const positioner = { side, align, sideOffset, alignOffset, arrowPadding };
|
|
274
|
+
if (collisionPadding !== undefined)
|
|
275
|
+
positioner.collisionPadding = collisionPadding;
|
|
276
|
+
if (collisionBoundary)
|
|
277
|
+
positioner.collisionBoundary = collisionBoundary;
|
|
278
|
+
if (avoidCollisions === false)
|
|
279
|
+
positioner.collisionAvoidance = { side: 'none', align: 'none' };
|
|
280
|
+
if (sticky === 'always')
|
|
281
|
+
positioner.sticky = true;
|
|
282
|
+
for (const key of Object.keys(positioner))
|
|
283
|
+
if (positioner[key] === undefined)
|
|
284
|
+
delete positioner[key];
|
|
285
|
+
return { positioner, rest };
|
|
286
|
+
}
|
|
287
|
+
/** Maps Base UI positioner variables to the `--radix-<name>-*` names consumers read. */
|
|
288
|
+
export function radixPositionVars(name) {
|
|
289
|
+
return {
|
|
290
|
+
[`--radix-${name}-content-available-height`]: 'var(--available-height)',
|
|
291
|
+
[`--radix-${name}-content-available-width`]: 'var(--available-width)',
|
|
292
|
+
[`--radix-${name}-content-transform-origin`]: 'var(--transform-origin)',
|
|
293
|
+
[`--radix-${name}-trigger-width`]: 'var(--anchor-width)',
|
|
294
|
+
[`--radix-${name}-trigger-height`]: 'var(--anchor-height)',
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/* ---------- Slot and VisuallyHidden ---------- */
|
|
298
|
+
/**
|
|
299
|
+
* Renders its only child with these props merged in, the way Radix `Slot`
|
|
300
|
+
* did: handlers chain, classes join, styles merge, refs compose.
|
|
301
|
+
*/
|
|
302
|
+
export const Slot = React.forwardRef(({ children, ...props }, ref) => {
|
|
303
|
+
if (!React.isValidElement(children))
|
|
304
|
+
return null;
|
|
305
|
+
const own = children.props;
|
|
306
|
+
return React.cloneElement(children, mergeElementProps(own, { ...props, ref }));
|
|
307
|
+
});
|
|
308
|
+
Slot.displayName = 'Slot';
|
|
309
|
+
/** Hides content visually and keeps it for screen readers. */
|
|
310
|
+
export const VisuallyHidden = React.forwardRef(({ asChild, className, ...props }, ref) => {
|
|
311
|
+
const cls = className ? `sr-only ${className}` : 'sr-only';
|
|
312
|
+
if (asChild)
|
|
313
|
+
return _jsx(Slot, { ref: ref, className: cls, ...props });
|
|
314
|
+
return _jsx("span", { ref: ref, className: cls, ...props });
|
|
315
|
+
});
|
|
316
|
+
VisuallyHidden.displayName = 'VisuallyHidden';
|
|
317
|
+
/* ---------- label re-entry ---------- */
|
|
318
|
+
/**
|
|
319
|
+
* An `onClick` for a Base UI checkbox or radio root. Base UI forwards a
|
|
320
|
+
* press to its hidden `<input>`; inside a consumer's `<label>`, that click
|
|
321
|
+
* bubbles to the label. Browsers ignore it (the target is interactive
|
|
322
|
+
* content), but happy-dom re-dispatches it to the button and loops. This
|
|
323
|
+
* drops the re-entrant click; in a browser it never fires.
|
|
324
|
+
*/
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
326
|
+
export function useLabelReentryGuard(onClick) {
|
|
327
|
+
const inClick = React.useRef(false);
|
|
328
|
+
return React.useCallback((event) => {
|
|
329
|
+
if (inClick.current) {
|
|
330
|
+
event.preventBaseUIHandler?.();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
inClick.current = true;
|
|
334
|
+
queueMicrotask(() => {
|
|
335
|
+
inClick.current = false;
|
|
336
|
+
});
|
|
337
|
+
onClick?.(event);
|
|
338
|
+
}, [onClick]);
|
|
339
|
+
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export declare const PortalContainerProvider: React.Provider<HTMLElement | null>;
|
|
3
3
|
export declare function usePortalContainer(): HTMLElement | undefined;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** Wraps a Radix-style Portal so it defaults `container` to the nearest ThemeScope. */
|
|
8
|
-
export declare function withPortalContainer<P extends PortalLike>(Portal: React.ComponentType<P>): {
|
|
9
|
-
(props: P): React.JSX.Element;
|
|
4
|
+
/** Wraps a Base UI Portal so it defaults `container` to the nearest ThemeScope. */
|
|
5
|
+
export declare function withPortalContainer<C extends React.ComponentType<any>>(Portal: C): {
|
|
6
|
+
(props: React.ComponentProps<C>): React.JSX.Element;
|
|
10
7
|
displayName: string;
|
|
11
8
|
};
|
|
12
|
-
export {};
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* Where overlays portal to. Unset (the default), every overlay portals to
|
|
6
|
-
* document.body
|
|
6
|
+
* document.body. ThemeScope sets it to an element inside its
|
|
7
7
|
* subtree, so a dialog, popover or menu opened in a scope paints the scope's
|
|
8
8
|
* tokens instead of the page's.
|
|
9
9
|
*/
|
|
@@ -12,11 +12,13 @@ export const PortalContainerProvider = PortalContainerContext.Provider;
|
|
|
12
12
|
export function usePortalContainer() {
|
|
13
13
|
return React.useContext(PortalContainerContext) ?? undefined;
|
|
14
14
|
}
|
|
15
|
-
/** Wraps a
|
|
15
|
+
/** Wraps a Base UI Portal so it defaults `container` to the nearest ThemeScope. */
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
export function withPortalContainer(Portal) {
|
|
17
18
|
function ScopedPortal(props) {
|
|
18
19
|
const scoped = usePortalContainer();
|
|
19
|
-
|
|
20
|
+
const Component = Portal;
|
|
21
|
+
return _jsx(Component, { ...props, container: props.container ?? scoped });
|
|
20
22
|
}
|
|
21
23
|
ScopedPortal.displayName = `Scoped(${Portal.displayName ?? Portal.name ?? 'Portal'})`;
|
|
22
24
|
return ScopedPortal;
|
package/dist/lib/z-stack.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ type DialogRootOpenProps = {
|
|
|
31
31
|
onOpenChange?: (open: boolean) => void;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
* `useDialogLayerDepth` for a
|
|
35
|
-
* of uncontrolled roots too, so this owns it and hands
|
|
34
|
+
* `useDialogLayerDepth` for a dialog root. The stack needs the open state
|
|
35
|
+
* of uncontrolled roots too, so this owns it and hands the Base UI root a controlled
|
|
36
36
|
* `open` / `onOpenChange` pair — observable behaviour is unchanged.
|
|
37
37
|
*/
|
|
38
38
|
export declare function useDialogRootLayer({ open, defaultOpen, onOpenChange }: DialogRootOpenProps): {
|
|
@@ -44,11 +44,11 @@ export declare function dialogOverlayZ(depth: number): number;
|
|
|
44
44
|
export declare function dialogContentZ(depth: number): number;
|
|
45
45
|
export declare function floatingZ(depth: number): number;
|
|
46
46
|
/** Portaled popovers/menus/selects rendered outside dialog DOM. */
|
|
47
|
-
export declare const FLOATING_LAYER_SELECTOR = "[role=\"menu\"],[role=\"listbox\"],[role=\"tooltip\"],[data-
|
|
47
|
+
export declare const FLOATING_LAYER_SELECTOR = "[role=\"menu\"],[role=\"listbox\"],[role=\"tooltip\"],[data-kortix-floating]";
|
|
48
48
|
export declare function isFloatingLayerTarget(target: EventTarget | null): boolean;
|
|
49
49
|
export declare function hasOpenFloatingLayer(): boolean;
|
|
50
50
|
/** Nested modals/sheets opened above the customize panel (or any parent dialog).
|
|
51
|
-
*
|
|
51
|
+
* The alert dialog has `role="alertdialog"`, so confirm dialogs only count here
|
|
52
52
|
* if that role is matched too — miss it and Escape aimed at a confirm tears
|
|
53
53
|
* down the panel behind it. */
|
|
54
54
|
export declare function hasOpenNestedDialog(): boolean;
|
package/dist/lib/z-stack.js
CHANGED
|
@@ -81,8 +81,8 @@ export function useDialogLayerDepth(open) {
|
|
|
81
81
|
return Math.max(level, parentDepth + 1);
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* `useDialogLayerDepth` for a
|
|
85
|
-
* of uncontrolled roots too, so this owns it and hands
|
|
84
|
+
* `useDialogLayerDepth` for a dialog root. The stack needs the open state
|
|
85
|
+
* of uncontrolled roots too, so this owns it and hands the Base UI root a controlled
|
|
86
86
|
* `open` / `onOpenChange` pair — observable behaviour is unchanged.
|
|
87
87
|
*/
|
|
88
88
|
export function useDialogRootLayer({ open, defaultOpen, onOpenChange }) {
|
|
@@ -114,15 +114,15 @@ export function floatingZ(depth) {
|
|
|
114
114
|
return dialogContentZ(depth) + 2;
|
|
115
115
|
}
|
|
116
116
|
/** Portaled popovers/menus/selects rendered outside dialog DOM. */
|
|
117
|
-
export const FLOATING_LAYER_SELECTOR = '[role="menu"],[role="listbox"],[role="tooltip"],[data-
|
|
117
|
+
export const FLOATING_LAYER_SELECTOR = '[role="menu"],[role="listbox"],[role="tooltip"],[data-kortix-floating]';
|
|
118
118
|
export function isFloatingLayerTarget(target) {
|
|
119
119
|
return target instanceof Element && Boolean(target.closest(FLOATING_LAYER_SELECTOR));
|
|
120
120
|
}
|
|
121
121
|
export function hasOpenFloatingLayer() {
|
|
122
|
-
return Boolean(document.querySelector('[role="menu"][data-state="open"],[role="listbox"][data-state="open"],[data-
|
|
122
|
+
return Boolean(document.querySelector('[role="menu"][data-state="open"],[role="listbox"][data-state="open"],[data-kortix-floating] [data-state="open"]'));
|
|
123
123
|
}
|
|
124
124
|
/** Nested modals/sheets opened above the customize panel (or any parent dialog).
|
|
125
|
-
*
|
|
125
|
+
* The alert dialog has `role="alertdialog"`, so confirm dialogs only count here
|
|
126
126
|
* if that role is matched too — miss it and Escape aimed at a confirm tears
|
|
127
127
|
* down the panel behind it. */
|
|
128
128
|
export function hasOpenNestedDialog() {
|
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
type AccordionBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'defaultValue' | 'dir' | 'onChange'> & {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
orientation?: 'horizontal' | 'vertical';
|
|
5
|
+
dir?: 'ltr' | 'rtl';
|
|
6
|
+
asChild?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type AccordionSingleProps = AccordionBaseProps & {
|
|
9
|
+
type: 'single';
|
|
10
|
+
value?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
onValueChange?: (value: string) => void;
|
|
13
|
+
/** Lets the open item close again. Without it one item always stays open. */
|
|
14
|
+
collapsible?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type AccordionMultipleProps = AccordionBaseProps & {
|
|
17
|
+
type: 'multiple';
|
|
18
|
+
value?: string[];
|
|
19
|
+
defaultValue?: string[];
|
|
20
|
+
onValueChange?: (value: string[]) => void;
|
|
21
|
+
};
|
|
22
|
+
type AccordionProps = AccordionSingleProps | AccordionMultipleProps;
|
|
23
|
+
/**
|
|
24
|
+
* The Radix accordion contract on Base UI: `type="single"` takes and returns
|
|
25
|
+
* a string, `type="multiple"` an array, and a single accordion without
|
|
26
|
+
* `collapsible` keeps its open item open.
|
|
27
|
+
*/
|
|
28
|
+
declare function Accordion(props: AccordionProps): React.JSX.Element;
|
|
29
|
+
declare function AccordionItem({ className, asChild, children, ...props }: Omit<React.ComponentPropsWithoutRef<'div'>, 'onChange'> & {
|
|
30
|
+
value: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
asChild?: boolean;
|
|
33
|
+
}): React.JSX.Element;
|
|
34
|
+
declare function AccordionTrigger({ className, children, ...props }: React.ComponentPropsWithoutRef<'button'>): React.JSX.Element;
|
|
35
|
+
declare function AccordionContent({ className, children, forceMount, style, ...props }: React.ComponentPropsWithoutRef<'div'> & {
|
|
36
|
+
forceMount?: true;
|
|
37
|
+
}): React.JSX.Element;
|
|
7
38
|
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
|