@adea-ai/ui 0.153.0 → 0.154.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/NOTICE +10 -1
- package/dist/components/composites/model-selector/model-selector.d.ts +15 -1
- package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
- package/dist/components/composites/model-selector/model-selector.js +263 -29
- package/dist/components/composites/model-selector/model-selector.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
- package/dist/components/layout/side-rail/side-rail.js +46 -42
- package/dist/components/layout/side-rail/side-rail.js.map +1 -1
- package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
- package/dist/components/layout/top-bar/top-bar.js +13 -12
- package/dist/components/layout/top-bar/top-bar.js.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.js +10 -10
- package/dist/components/ui/dialog/dialog-layer.js.map +1 -1
- package/dist/components/ui/kbd/kbd.d.ts +23 -10
- package/dist/components/ui/kbd/kbd.d.ts.map +1 -1
- package/dist/components/ui/kbd/kbd.js +42 -11
- package/dist/components/ui/kbd/kbd.js.map +1 -1
- package/dist/lib/overlay.d.ts +1 -1
- package/dist/lib/overlay.d.ts.map +1 -1
- package/dist/lib/overlay.js +1 -1
- package/dist/lib/overlay.js.map +1 -1
- package/dist/r/model-selector.json +1 -0
- package/dist/r/registry.json +3 -0
- package/dist/r/side-rail.json +1 -0
- package/dist/r/src/components/composites/model-selector/model-selector.tsx +186 -10
- package/dist/r/src/components/layout/side-rail/side-rail.tsx +16 -19
- package/dist/r/src/components/layout/top-bar/top-bar.tsx +3 -7
- package/dist/r/src/components/ui/dialog/dialog-layer.tsx +16 -18
- package/dist/r/src/components/ui/kbd/kbd.tsx +53 -12
- package/dist/r/src/lib/overlay.ts +1 -1
- package/dist/r/top-bar.json +1 -0
- package/package.json +1 -1
- package/registry.json +3 -0
- package/src/components/composites/model-selector/model-selector.tsx +186 -10
- package/src/components/layout/side-rail/side-rail.tsx +16 -19
- package/src/components/layout/top-bar/top-bar.tsx +3 -7
- package/src/components/ui/dialog/dialog-layer.tsx +16 -18
- package/src/components/ui/kbd/kbd.tsx +53 -12
- package/src/lib/overlay.ts +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tooltipTip } from "../../../lib/overlay.js";
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
|
+
import { KbdChord } from "../../ui/kbd/kbd.js";
|
|
3
4
|
import { SideRailContext } from "./side-rail-context.js";
|
|
4
5
|
import { Portal, className, createComponent, effect, insert, memo, mergeProps, setStyleProperty, spread, template, use } from "solid-js/web";
|
|
5
6
|
import { Show, children, createMemo, createSignal, splitProps, useContext } from "solid-js";
|
|
@@ -11,13 +12,11 @@ var _tmpl$3 = /*#__PURE__*/ template(`<div data-slot=side-rail-footer>`);
|
|
|
11
12
|
var _tmpl$4 = /*#__PURE__*/ template(`<div data-slot=side-rail-section>`);
|
|
12
13
|
var _tmpl$5 = /*#__PURE__*/ template(`<div class="text-sidebar-muted-foreground px-2 pt-2 pb-1 text-2xs font-medium tracking-wide uppercase group-data-[collapsed=true]/rail:hidden">`);
|
|
13
14
|
var _tmpl$6 = /*#__PURE__*/ template(`<div aria-hidden=true data-slot=side-rail-tip><span>`);
|
|
14
|
-
var _tmpl$7 = /*#__PURE__*/ template(`<span class="
|
|
15
|
-
var _tmpl$8 = /*#__PURE__*/ template(`<span class="
|
|
16
|
-
var _tmpl$9 = /*#__PURE__*/ template(`<span class="
|
|
17
|
-
var _tmpl$0 = /*#__PURE__*/ template(`<span
|
|
18
|
-
var _tmpl$1 = /*#__PURE__*/ template(`<
|
|
19
|
-
var _tmpl$10 = /*#__PURE__*/ template(`<span class="ms-auto shrink-0">`);
|
|
20
|
-
var _tmpl$11 = /*#__PURE__*/ template(`<button type=button><span class="flex size-5 shrink-0 items-center justify-center [&_svg]:size-5"></span><span class="min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only">`);
|
|
15
|
+
var _tmpl$7 = /*#__PURE__*/ template(`<span class="flex size-5 shrink-0 items-center justify-center [&_svg]:size-5">`);
|
|
16
|
+
var _tmpl$8 = /*#__PURE__*/ template(`<span class="min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only">`);
|
|
17
|
+
var _tmpl$9 = /*#__PURE__*/ template(`<span data-slot=side-rail-badge class="flex shrink-0 items-center justify-center group-data-[collapsed=true]/rail:absolute group-data-[collapsed=true]/rail:end-1/2 group-data-[collapsed=true]/rail:top-1/2 group-data-[collapsed=true]/rail:-me-3.5 group-data-[collapsed=true]/rail:-mt-3.5">`);
|
|
18
|
+
var _tmpl$0 = /*#__PURE__*/ template(`<span class="ms-auto shrink-0">`);
|
|
19
|
+
var _tmpl$1 = /*#__PURE__*/ template(`<button type=button><span class="flex size-5 shrink-0 items-center justify-center [&_svg]:size-5"></span><span class="min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only">`);
|
|
21
20
|
function SideRail(props) {
|
|
22
21
|
const [local, rest] = splitProps(props, [
|
|
23
22
|
"class",
|
|
@@ -160,11 +159,12 @@ function RailTip(props) {
|
|
|
160
159
|
get when() {
|
|
161
160
|
return props.shortcut;
|
|
162
161
|
},
|
|
163
|
-
children: (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
children: (shortcut) => createComponent(KbdChord, {
|
|
163
|
+
get keys() {
|
|
164
|
+
return shortcut();
|
|
165
|
+
},
|
|
166
|
+
"class": "shrink-0"
|
|
167
|
+
})
|
|
168
168
|
}), null);
|
|
169
169
|
effect((_p$) => {
|
|
170
170
|
var _v$ = cn(tooltipTip, "pointer-events-none fixed z-(--z-tooltip) flex items-center gap-2.5 ps-3 pe-3 whitespace-nowrap"), _v$2 = `${position.top}px`, _v$3 = `${position.left}px`, _v$4 = `${position.height}px`, _v$5 = cn("flex size-5 shrink-0 items-center justify-center [&_svg]:size-5", { "text-primary": props.active });
|
|
@@ -234,43 +234,45 @@ function SideRailItem(props) {
|
|
|
234
234
|
}, rest, { get children() {
|
|
235
235
|
return [
|
|
236
236
|
(() => {
|
|
237
|
-
var _el$
|
|
238
|
-
insert(_el$
|
|
239
|
-
return _el$
|
|
237
|
+
var _el$8 = _tmpl$7();
|
|
238
|
+
insert(_el$8, () => local.children);
|
|
239
|
+
return _el$8;
|
|
240
240
|
})(),
|
|
241
241
|
(() => {
|
|
242
|
-
var _el$
|
|
243
|
-
insert(_el$
|
|
244
|
-
return _el$
|
|
242
|
+
var _el$9 = _tmpl$8();
|
|
243
|
+
insert(_el$9, () => local.label);
|
|
244
|
+
return _el$9;
|
|
245
245
|
})(),
|
|
246
246
|
createComponent(Show, {
|
|
247
247
|
get when() {
|
|
248
248
|
return local.badge;
|
|
249
249
|
},
|
|
250
250
|
children: (badgeSlot) => (() => {
|
|
251
|
-
var _el$
|
|
252
|
-
insert(_el$
|
|
253
|
-
return _el$
|
|
251
|
+
var _el$0 = _tmpl$9();
|
|
252
|
+
insert(_el$0, badgeSlot);
|
|
253
|
+
return _el$0;
|
|
254
254
|
})()
|
|
255
255
|
}),
|
|
256
256
|
createComponent(Show, {
|
|
257
257
|
get when() {
|
|
258
|
-
return memo(() =>
|
|
258
|
+
return memo(() => trailing() === void 0)() && local.shortcut;
|
|
259
259
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
children: (shortcut) => createComponent(KbdChord, {
|
|
261
|
+
get keys() {
|
|
262
|
+
return shortcut();
|
|
263
|
+
},
|
|
264
|
+
size: "compact",
|
|
265
|
+
"class": "shrink-0 opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden"
|
|
266
|
+
})
|
|
265
267
|
}),
|
|
266
268
|
createComponent(Show, {
|
|
267
269
|
get when() {
|
|
268
270
|
return trailing();
|
|
269
271
|
},
|
|
270
272
|
children: (trailingSlot) => (() => {
|
|
271
|
-
var _el$
|
|
272
|
-
insert(_el$
|
|
273
|
-
return _el$
|
|
273
|
+
var _el$1 = _tmpl$0();
|
|
274
|
+
insert(_el$1, trailingSlot);
|
|
275
|
+
return _el$1;
|
|
274
276
|
})()
|
|
275
277
|
})
|
|
276
278
|
];
|
|
@@ -303,10 +305,10 @@ function SideRailButton(props) {
|
|
|
303
305
|
]);
|
|
304
306
|
const tip = createRailTip();
|
|
305
307
|
return [(() => {
|
|
306
|
-
var _el$
|
|
308
|
+
var _el$10 = _tmpl$1(), _el$11 = _el$10.firstChild, _el$12 = _el$11.nextSibling;
|
|
307
309
|
var _ref$2 = tip.setRow;
|
|
308
|
-
typeof _ref$2 === "function" ? use(_ref$2, _el$
|
|
309
|
-
spread(_el$
|
|
310
|
+
typeof _ref$2 === "function" ? use(_ref$2, _el$10) : tip.setRow = _el$10;
|
|
311
|
+
spread(_el$10, mergeProps({
|
|
310
312
|
get ["aria-label"]() {
|
|
311
313
|
return local.label;
|
|
312
314
|
},
|
|
@@ -329,19 +331,21 @@ function SideRailButton(props) {
|
|
|
329
331
|
return cn(sideRailItemClass, local.active ? sideRailItemStateClass.active : sideRailItemStateClass.idle, "disabled:pointer-events-none disabled:opacity-50", local.class);
|
|
330
332
|
}
|
|
331
333
|
}, rest), false, true);
|
|
332
|
-
insert(_el$
|
|
333
|
-
insert(_el$
|
|
334
|
-
insert(_el$
|
|
334
|
+
insert(_el$11, () => local.children);
|
|
335
|
+
insert(_el$12, () => local.label);
|
|
336
|
+
insert(_el$10, createComponent(Show, {
|
|
335
337
|
get when() {
|
|
336
338
|
return local.shortcut;
|
|
337
339
|
},
|
|
338
|
-
children: (
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
children: (shortcut) => createComponent(KbdChord, {
|
|
341
|
+
get keys() {
|
|
342
|
+
return shortcut();
|
|
343
|
+
},
|
|
344
|
+
size: "compact",
|
|
345
|
+
"class": "shrink-0 opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden"
|
|
346
|
+
})
|
|
343
347
|
}), null);
|
|
344
|
-
return _el$
|
|
348
|
+
return _el$10;
|
|
345
349
|
})(), createComponent(RailTip, {
|
|
346
350
|
get position() {
|
|
347
351
|
return tip.position();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-rail.js","names":["Polymorphic","children","resolveChildren","Show","createMemo","createSignal","splitProps","useContext","Portal","tooltipTip","cn","SideRailContext","class","collapsed","SideRail","props","local","rest","value","width","_$createComponent","Provider","_$mergeProps","as","SideRailHeader","_el$","_tmpl$","_$spread","SideRailContent","_el$2","_tmpl$2","SideRailFooter","_el$3","_tmpl$3","SideRailSection","label","_el$4","_tmpl$4","_$insert","when","labelSlot","_el$5","_tmpl$5","sideRailItemClass","join","sideRailItemStateClass","active","idle","TIP_GAP_PX","top","left","height","createRailTip","rail","row","setRow","position","setPosition","show","element","rect","getBoundingClientRect","right","hide","RailTip","icon","shortcut","keyed","_el$6","_tmpl$6","_el$7","firstChild","shortcutSlot","_el$8","_tmpl$7","_$effect","_p$","_v$","_v$2","_v$3","_v$4","_v$5","e","_$className","t","_$setStyleProperty","a","o","i","undefined","badge","trailing","keyshortcuts","SideRailItem","tip","ref","r$","_ref$","onPointerEnter","onPointerLeave","onFocus","onBlur","_el$9","_tmpl$8","_el$0","_tmpl$9","badgeSlot","_el$10","_tmpl$1","_$memo","_el$1","_tmpl$0","trailingSlot","_el$11","_tmpl$10","SideRailButton","_el$12","_tmpl$11","_el$13","_el$14","nextSibling","_ref$2","_$use","_el$15"],"sources":["../../../../src/components/layout/side-rail/side-rail.tsx"],"sourcesContent":["import { Polymorphic, type PolymorphicProps } from '@kobalte/core/polymorphic'\nimport type { ComponentProps, JSX, ValidComponent } from 'solid-js'\nimport {\n children as resolveChildren,\n Show,\n createMemo,\n createSignal,\n splitProps,\n useContext,\n} from 'solid-js'\nimport { Portal } from 'solid-js/web'\nimport { tooltipTip } from '#lib/overlay'\nimport { cn } from '#lib/utils'\nimport { SideRailContext } from './side-rail-context'\n\n/**\n * SideRail.\n *\n * The narrow, persistent column of top-level destinations at the window's leading\n * edge: the app mark, the primary sections, and a footer for account and settings.\n * It is the one piece of chrome that is always on screen, which is why it is a\n * component rather than something each view arranges.\n *\n * Two forms, one component. Collapsed it is an icon column; expanded it carries\n * labels. Both widths come from `--rail-width` (56px) and `--rail-width-expanded`\n * (236px), so an app cannot pick its own and end up a few pixels out of step with\n * the app beside it.\n *\n * The rail does not own its collapsed state; the app does. That state has to\n * survive a reload and usually lives with the rest of the window preferences, and\n * a rail that kept it privately could not be restored.\n */\nexport type SideRailProps<T extends ValidComponent = 'nav'> = PolymorphicProps<\n T,\n {\n class?: string\n collapsed?: boolean\n 'aria-label'?: string\n }\n>\n\nexport function SideRail<T extends ValidComponent = 'nav'>(props: SideRailProps<T>) {\n const [local, rest] = splitProps(props as SideRailProps, [\n 'class',\n 'collapsed',\n 'aria-label',\n 'children',\n ])\n\n const collapsed = createMemo(() => local.collapsed ?? false)\n const value = {\n collapsed,\n width: createMemo(() => (collapsed() ? 'var(--rail-width)' : 'var(--rail-width-expanded)')),\n }\n\n return (\n <SideRailContext.Provider value={value}>\n <Polymorphic\n as=\"nav\"\n aria-label={local['aria-label'] ?? 'Primary'}\n /* Rendered in both states, with a real value, so the descendant selectors\n below can key on true *and* false — an absent attribute would leave the\n expanded form matching neither. */\n data-collapsed={collapsed() ? 'true' : 'false'}\n class={cn(\n 'group/rail bg-sidebar text-sidebar-foreground flex h-full shrink-0 flex-col border-e border-sidebar-border',\n 'transition-[width] duration-150 ease-out',\n { 'w-rail': collapsed(), 'w-rail-expanded': !collapsed() },\n local.class\n )}\n {...(rest as ComponentProps<'nav'>)}\n >\n {local.children}\n </Polymorphic>\n </SideRailContext.Provider>\n )\n}\n\n/** The header slot: the app mark, and the product name when there is room. */\nexport function SideRailHeader(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"side-rail-header\"\n class={cn(\n 'h-topbar flex shrink-0 items-center gap-2.5 px-3 group-data-[collapsed=true]/rail:justify-center group-data-[collapsed=true]/rail:px-0',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** The scrolling middle. Keeps the header and the footer pinned. */\nexport function SideRailContent(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"side-rail-content\"\n class={cn(\n 'flex min-h-0 flex-1 flex-col gap-0.5 overflow-x-hidden overflow-y-auto px-2 py-2',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** The pinned footer: account, settings, help. */\nexport function SideRailFooter(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"side-rail-footer\"\n class={cn(\n 'flex shrink-0 flex-col gap-0.5 border-t border-sidebar-border px-2 py-2',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** A titled group of rail destinations. The title hides when collapsed. */\nexport function SideRailSection(props: ComponentProps<'div'> & { label?: string }) {\n const [local, rest] = splitProps(props, ['class', 'label', 'children'])\n\n return (\n <div data-slot=\"side-rail-section\" class={cn('flex flex-col gap-0.5', local.class)} {...rest}>\n <Show when={local.label}>\n {(labelSlot) => (\n <div class=\"text-sidebar-muted-foreground px-2 pt-2 pb-1 text-2xs font-medium tracking-wide uppercase group-data-[collapsed=true]/rail:hidden\">\n {labelSlot()}\n </div>\n )}\n </Show>\n {local.children}\n </div>\n )\n}\n\nconst sideRailItemClass = [\n 'group/rail-item flex h-rail-item min-w-0 w-full items-center gap-2.5 rounded-md px-3 text-sm font-medium',\n 'group-data-[collapsed=true]/rail:justify-center group-data-[collapsed=true]/rail:px-0',\n 'transition-[color,background-color,transform] ease-out outline-none select-none',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n /*\n * The donor's row scales up slightly under the pointer and down under a press.\n * It is a CSS transform rather than a motion-library gesture because the two are\n * the same thing here and the transform costs nothing at runtime: no wrapper\n * element, no listener, and it works on whatever element a caller renders the row\n * as — an anchor, a button, a router's own link.\n *\n * The collapsed rail opts out: a 1.02 scale on a 56px column pushes the row past\n * the rail's own edge, which reads as a glitch rather than as feedback.\n */\n 'hover:scale-[1.02] active:scale-[0.97] group-data-[collapsed=true]/rail:hover:scale-100 group-data-[collapsed=true]/rail:active:scale-[0.98]',\n '[&_svg]:size-5 [&_svg]:shrink-0',\n].join(' ')\n\n/*\n * The rail's states are accent-driven: the icon carries `--primary` on hover and\n * on the active destination, and both states draw the accent's own tint rather\n * than a neutral fill, so the rail reads as the app's accent chroma instead of a\n * grey column. The active label stays on `sidebar-foreground` because the accent\n * presets guarantee their 3:1 interaction minimum against the surface, not the\n * 4.5:1 small text owes; the icon is a graphic and rides the accent.\n */\nconst sideRailItemStateClass = {\n active: 'bg-primary-subtle text-sidebar-foreground [&_svg]:text-primary',\n idle: 'text-sidebar-muted-foreground hover:bg-primary-subtle/60 hover:text-primary',\n}\n\nconst TIP_GAP_PX = 8\n\ntype TipPosition = { top: number; left: number; height: number }\n\n/** The collapsed rail's tip state for one row; see `SideRailItem` for its treatment. */\nfunction createRailTip() {\n const rail = useContext(SideRailContext)\n const [row, setRow] = createSignal<HTMLElement>()\n const [position, setPosition] = createSignal<TipPosition | null>(null)\n return {\n setRow,\n position,\n show: () => {\n const element = row()\n if (!element || !rail?.collapsed()) return\n const rect = element.getBoundingClientRect()\n setPosition({ top: rect.top, left: rect.right + TIP_GAP_PX, height: rect.height })\n },\n hide: () => setPosition(null),\n }\n}\n\nfunction RailTip(props: {\n position: TipPosition | null\n icon: JSX.Element\n label: string\n active?: boolean\n shortcut?: string\n}) {\n return (\n /* The portal can finish an effect after the tooltip closes; capture its position. */\n <Show when={props.position} keyed>\n {(position) => (\n <Portal>\n <div\n aria-hidden=\"true\"\n data-slot=\"side-rail-tip\"\n class={cn(\n tooltipTip,\n 'pointer-events-none fixed z-(--z-tooltip) flex items-center gap-2.5 ps-3 pe-3 whitespace-nowrap'\n )}\n style={{\n top: `${position.top}px`,\n left: `${position.left}px`,\n height: `${position.height}px`,\n }}\n >\n <span\n class={cn('flex size-5 shrink-0 items-center justify-center [&_svg]:size-5', {\n 'text-primary': props.active,\n })}\n >\n {props.icon}\n </span>\n {props.label}\n <Show when={props.shortcut}>\n {(shortcutSlot) => (\n <span class=\"text-muted-foreground shrink-0 font-code text-code leading-none\">\n {shortcutSlot()}\n </span>\n )}\n </Show>\n </div>\n </Portal>\n )}\n </Show>\n )\n}\n\n/**\n * A rail destination.\n *\n * ## The tooltip is the rail's hover affordance, not a generic bubble\n *\n * Collapsed, the row has no text, so the label has to come from somewhere. This\n * ports the donor's treatment rather than using a standard tooltip, because the\n * details are what make it read as part of the rail:\n *\n * - It is **flush with the row**: positioned at the row's own top and given the\n * row's own height, so it continues the row outward instead of floating near\n * it. A centred bubble with an arrow reads as a separate object.\n * - It **repeats the icon**, which anchors it to the row it belongs to.\n * - It carries the **keyboard chord**, which is the one piece of information a\n * collapsed rail otherwise cannot show.\n * - It opens on **hover and on focus**, so a keyboard user gets the same label a\n * pointer user does.\n * - It is `pointer-events-none` and `aria-hidden`: the row already carries the\n * name (as a visually hidden span when collapsed), so this is decoration and\n * must never be the accessible name.\n *\n * ## The chord on the row\n *\n * Expanded, the row shows its chord on hover and on focus — and the chord is\n * declared once to assistive technology through `aria-keyshortcuts` rather than\n * being read out as glyphs. The visible badge is `aria-hidden` for that reason.\n */\nexport type SideRailItemProps<T extends ValidComponent = 'a'> = PolymorphicProps<\n T,\n {\n class?: string\n /** Marks the item as the current destination. */\n active?: boolean\n /**\n * The item's accessible name. Required, and always in the accessibility tree:\n * collapsed it moves into the tooltip and a visually hidden span rather than\n * being deleted.\n */\n label: string\n /**\n * A count or a dot. Expanded, it trails the label at the row's end; collapsed,\n * it moves onto the icon's corner, so the rail never loses it.\n */\n badge?: JSX.Element\n /** An indicator pinned to the trailing edge in the expanded form. */\n trailing?: JSX.Element\n /** The chord as it should be drawn, e.g. `⌘1`. Shown on hover and focus. */\n shortcut?: string\n /**\n * The same chord in the ARIA grammar, e.g. `Meta+1`. Declared to assistive\n * technology instead of the display glyphs, which are not a keyboard shortcut\n * a screen reader can parse. Supply it whenever `shortcut` is drawn.\n */\n keyshortcuts?: string\n }\n>\n\nexport function SideRailItem<T extends ValidComponent = 'a'>(props: SideRailItemProps<T>) {\n const [local, rest] = splitProps(props as SideRailItemProps, [\n 'as',\n 'class',\n 'active',\n 'label',\n 'badge',\n 'trailing',\n 'shortcut',\n 'keyshortcuts',\n 'children',\n ])\n\n const tip = createRailTip()\n const trailing = resolveChildren(() => local.trailing)\n\n return (\n <>\n <Polymorphic\n as={local.as ?? 'a'}\n ref={tip.setRow}\n aria-current={local.active ? 'page' : undefined}\n aria-keyshortcuts={local.keyshortcuts}\n data-active={local.active ? '' : undefined}\n class={cn(\n sideRailItemClass,\n 'relative',\n local.active ? sideRailItemStateClass.active : sideRailItemStateClass.idle,\n local.class\n )}\n onPointerEnter={tip.show}\n onPointerLeave={tip.hide}\n onFocus={tip.show}\n onBlur={tip.hide}\n {...(rest as Record<string, unknown>)}\n >\n <span class=\"flex size-5 shrink-0 items-center justify-center [&_svg]:size-5\">\n {local.children}\n </span>\n\n <span class=\"min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only\">\n {local.label}\n </span>\n\n {/*\n * One element, two placements, because the badge is caller content and a DOM\n * node cannot be in two places. Expanded, it is a trailing count in the row's\n * flow, after the label — over the icon it would cover the glyph the row is\n * recognised by. Collapsed, there is no label to trail, so it leaves the flow\n * and pins to the icon's top-end corner: anchored to the row's centre (where\n * the centred icon sits) and pushed out by 14px, the icon's half-width plus\n * the 4px overhang, so a wider count grows back over the icon rather than past\n * the rail's edge.\n */}\n <Show when={local.badge}>\n {(badgeSlot) => (\n <span\n data-slot=\"side-rail-badge\"\n class=\"flex shrink-0 items-center justify-center group-data-[collapsed=true]/rail:absolute group-data-[collapsed=true]/rail:end-1/2 group-data-[collapsed=true]/rail:top-1/2 group-data-[collapsed=true]/rail:-me-3.5 group-data-[collapsed=true]/rail:-mt-3.5\"\n >\n {badgeSlot()}\n </span>\n )}\n </Show>\n\n <Show when={local.shortcut && trailing() === undefined}>\n <span\n aria-hidden=\"true\"\n class=\"text-sidebar-muted-foreground shrink-0 font-code text-code leading-none opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden\"\n >\n {local.shortcut}\n </span>\n </Show>\n\n <Show when={trailing()}>\n {(trailingSlot) => <span class=\"ms-auto shrink-0\">{trailingSlot()}</span>}\n </Show>\n </Polymorphic>\n\n <RailTip\n position={tip.position()}\n icon={local.children}\n label={local.label}\n active={local.active}\n shortcut={local.shortcut}\n />\n </>\n )\n}\n\n/** A non-navigating rail control: a collapse toggle, a \"new\" action. */\nexport function SideRailButton(\n props: Omit<ComponentProps<'button'>, 'type'> & {\n label: string\n shortcut?: string\n active?: boolean\n }\n) {\n const [local, rest] = splitProps(props, ['class', 'label', 'shortcut', 'children', 'active'])\n const tip = createRailTip()\n\n return (\n <>\n <button\n type=\"button\"\n ref={tip.setRow}\n aria-label={local.label}\n data-active={local.active ? 'true' : undefined}\n onPointerEnter={tip.show}\n onPointerLeave={tip.hide}\n onFocus={tip.show}\n onBlur={tip.hide}\n class={cn(\n sideRailItemClass,\n local.active ? sideRailItemStateClass.active : sideRailItemStateClass.idle,\n 'disabled:pointer-events-none disabled:opacity-50',\n local.class\n )}\n {...rest}\n >\n <span class=\"flex size-5 shrink-0 items-center justify-center [&_svg]:size-5\">\n {local.children}\n </span>\n <span class=\"min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only\">\n {local.label}\n </span>\n <Show when={local.shortcut}>\n {(shortcutSlot) => (\n <span\n aria-hidden=\"true\"\n class=\"text-sidebar-muted-foreground shrink-0 font-code text-code leading-none opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden\"\n >\n {shortcutSlot()}\n </span>\n )}\n </Show>\n </button>\n\n <RailTip position={tip.position()} icon={local.children} label={local.label} />\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,SAAgBc,SAA2CC,OAAyB;CAClF,MAAM,CAACC,OAAOC,QAAQX,WAAWS,OAAwB;EACvD;EACA;EACA;EACA;CAAU,CACX;CAED,MAAMF,YAAYT,iBAAiBY,MAAMH,aAAa,KAAK;CAC3D,MAAMK,QAAQ;EACZL;EACAM,OAAOf,iBAAkBS,UAAU,IAAI,sBAAsB,4BAA6B;CAC5F;CAEA,OAAAO,gBACGT,gBAAgBU,UAAQ;EAAQH;EAAK,IAAAjB,WAAA;GAAA,OAAAmB,gBACnCpB,aAAWsB,WAAA;IACVC,IAAE;IAAA,KAAA,gBAAA;KAAA,OACUP,MAAM,iBAAiB;IAAS;IAAA,KAAA,oBAAA;KAAA,OAI5BH,UAAU,IAAI,SAAS;IAAO;IAAA,KAAA,WAAA;KAAA,OACvCH,GACL,8GACA,4CACA;MAAE,UAAUG,UAAU;MAAG,mBAAmB,CAACA,UAAU;KAAE,GACzDG,MAAMJ,KACR;IAAC;GAAA,GACIK,MAA6B,EAAA,IAAAhB,WAAA;IAAA,OAEjCe,MAAMf;GAAQ,EAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAIvB;;AAGA,SAAgBuB,eAAeT,OAA8B;CAC3D,MAAM,CAACC,OAAOC,QAAQX,WAAWS,OAAO,CAAC,OAAO,CAAC;CACjD,cAAA;EAAA,IAAAU,OAAAC,OAAA;EAAAC,OAAAF,MAAAH,WAAA,EAAA,KAAA,WAAA;GAAA,OAGWZ,GACL,0IACAM,MAAMJ,KACR;EAAC,EAAA,GACGK,IAAI,GAAA,OAAA,KAAA;EAAA,OAAAQ;CAAA,EAAA,CAAA;AAGd;;AAGA,SAAgBG,gBAAgBb,O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,KAAK;EAAAG,OAAA8E,QAAAhG,gBAEbjB,MAAI;GAAA,IAACoC,OAAI;IAAA,OAAEvB,MAAMkD;GAAQ;GAAAjE,WACtBuE,wBAAY;IAAA,IAAAmD,SAAAZ,QAAA;IAAAzE,OAAAqF,QAKTnD,YAAY;IAAA,OAAAmD;GAAA,EAAA,CAAA;EAEhB,CAAA,GAAA,IAAA;EAAA,OAAAP;CAAA,EAAA,CAAA,GAAAhG,gBAIJ4C,SAAO;EAAA,IAACR,WAAQ;GAAA,OAAEsC,IAAItC,SAAS;EAAC;EAAA,IAAES,OAAI;GAAA,OAAEjD,MAAMf;EAAQ;EAAA,IAAEkC,QAAK;GAAA,OAAEnB,MAAMmB;EAAK;CAAA,CAAA,CAAA;AAGjF"}
|
|
1
|
+
{"version":3,"file":"side-rail.js","names":["Polymorphic","children","resolveChildren","Show","createMemo","createSignal","splitProps","useContext","Portal","tooltipTip","cn","KbdChord","SideRailContext","class","collapsed","SideRail","props","local","rest","value","width","_$createComponent","Provider","_$mergeProps","as","SideRailHeader","_el$","_tmpl$","_$spread","SideRailContent","_el$2","_tmpl$2","SideRailFooter","_el$3","_tmpl$3","SideRailSection","label","_el$4","_tmpl$4","_$insert","when","labelSlot","_el$5","_tmpl$5","sideRailItemClass","join","sideRailItemStateClass","active","idle","TIP_GAP_PX","top","left","height","createRailTip","rail","row","setRow","position","setPosition","show","element","rect","getBoundingClientRect","right","hide","RailTip","icon","shortcut","keyed","_el$6","_tmpl$6","_el$7","firstChild","keys","_$effect","_p$","_v$","_v$2","_v$3","_v$4","_v$5","e","_$className","t","_$setStyleProperty","a","o","i","undefined","badge","trailing","keyshortcuts","SideRailItem","tip","ref","r$","_ref$","onPointerEnter","onPointerLeave","onFocus","onBlur","_el$8","_tmpl$7","_el$9","_tmpl$8","badgeSlot","_el$0","_tmpl$9","_$memo","size","trailingSlot","_el$1","_tmpl$0","SideRailButton","_el$10","_tmpl$1","_el$11","_el$12","nextSibling","_ref$2","_$use"],"sources":["../../../../src/components/layout/side-rail/side-rail.tsx"],"sourcesContent":["import { Polymorphic, type PolymorphicProps } from '@kobalte/core/polymorphic'\nimport type { ComponentProps, JSX, ValidComponent } from 'solid-js'\nimport {\n children as resolveChildren,\n Show,\n createMemo,\n createSignal,\n splitProps,\n useContext,\n} from 'solid-js'\nimport { Portal } from 'solid-js/web'\nimport { tooltipTip } from '#lib/overlay'\nimport { cn } from '#lib/utils'\nimport { KbdChord } from '../../ui/kbd'\nimport { SideRailContext } from './side-rail-context'\n\n/**\n * SideRail.\n *\n * The narrow, persistent column of top-level destinations at the window's leading\n * edge: the app mark, the primary sections, and a footer for account and settings.\n * It is the one piece of chrome that is always on screen, which is why it is a\n * component rather than something each view arranges.\n *\n * Two forms, one component. Collapsed it is an icon column; expanded it carries\n * labels. Both widths come from `--rail-width` (56px) and `--rail-width-expanded`\n * (236px), so an app cannot pick its own and end up a few pixels out of step with\n * the app beside it.\n *\n * The rail does not own its collapsed state; the app does. That state has to\n * survive a reload and usually lives with the rest of the window preferences, and\n * a rail that kept it privately could not be restored.\n */\nexport type SideRailProps<T extends ValidComponent = 'nav'> = PolymorphicProps<\n T,\n {\n class?: string\n collapsed?: boolean\n 'aria-label'?: string\n }\n>\n\nexport function SideRail<T extends ValidComponent = 'nav'>(props: SideRailProps<T>) {\n const [local, rest] = splitProps(props as SideRailProps, [\n 'class',\n 'collapsed',\n 'aria-label',\n 'children',\n ])\n\n const collapsed = createMemo(() => local.collapsed ?? false)\n const value = {\n collapsed,\n width: createMemo(() => (collapsed() ? 'var(--rail-width)' : 'var(--rail-width-expanded)')),\n }\n\n return (\n <SideRailContext.Provider value={value}>\n <Polymorphic\n as=\"nav\"\n aria-label={local['aria-label'] ?? 'Primary'}\n /* Rendered in both states, with a real value, so the descendant selectors\n below can key on true *and* false — an absent attribute would leave the\n expanded form matching neither. */\n data-collapsed={collapsed() ? 'true' : 'false'}\n class={cn(\n 'group/rail bg-sidebar text-sidebar-foreground flex h-full shrink-0 flex-col border-e border-sidebar-border',\n 'transition-[width] duration-150 ease-out',\n { 'w-rail': collapsed(), 'w-rail-expanded': !collapsed() },\n local.class\n )}\n {...(rest as ComponentProps<'nav'>)}\n >\n {local.children}\n </Polymorphic>\n </SideRailContext.Provider>\n )\n}\n\n/** The header slot: the app mark, and the product name when there is room. */\nexport function SideRailHeader(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"side-rail-header\"\n class={cn(\n 'h-topbar flex shrink-0 items-center gap-2.5 px-3 group-data-[collapsed=true]/rail:justify-center group-data-[collapsed=true]/rail:px-0',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** The scrolling middle. Keeps the header and the footer pinned. */\nexport function SideRailContent(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"side-rail-content\"\n class={cn(\n 'flex min-h-0 flex-1 flex-col gap-0.5 overflow-x-hidden overflow-y-auto px-2 py-2',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** The pinned footer: account, settings, help. */\nexport function SideRailFooter(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"side-rail-footer\"\n class={cn(\n 'flex shrink-0 flex-col gap-0.5 border-t border-sidebar-border px-2 py-2',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** A titled group of rail destinations. The title hides when collapsed. */\nexport function SideRailSection(props: ComponentProps<'div'> & { label?: string }) {\n const [local, rest] = splitProps(props, ['class', 'label', 'children'])\n\n return (\n <div data-slot=\"side-rail-section\" class={cn('flex flex-col gap-0.5', local.class)} {...rest}>\n <Show when={local.label}>\n {(labelSlot) => (\n <div class=\"text-sidebar-muted-foreground px-2 pt-2 pb-1 text-2xs font-medium tracking-wide uppercase group-data-[collapsed=true]/rail:hidden\">\n {labelSlot()}\n </div>\n )}\n </Show>\n {local.children}\n </div>\n )\n}\n\nconst sideRailItemClass = [\n 'group/rail-item flex h-rail-item min-w-0 w-full items-center gap-2.5 rounded-md px-3 text-sm font-medium',\n 'group-data-[collapsed=true]/rail:justify-center group-data-[collapsed=true]/rail:px-0',\n 'transition-[color,background-color,transform] ease-out outline-none select-none',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n /*\n * The donor's row scales up slightly under the pointer and down under a press.\n * It is a CSS transform rather than a motion-library gesture because the two are\n * the same thing here and the transform costs nothing at runtime: no wrapper\n * element, no listener, and it works on whatever element a caller renders the row\n * as — an anchor, a button, a router's own link.\n *\n * The collapsed rail opts out: a 1.02 scale on a 56px column pushes the row past\n * the rail's own edge, which reads as a glitch rather than as feedback.\n */\n 'hover:scale-[1.02] active:scale-[0.97] group-data-[collapsed=true]/rail:hover:scale-100 group-data-[collapsed=true]/rail:active:scale-[0.98]',\n '[&_svg]:size-5 [&_svg]:shrink-0',\n].join(' ')\n\n/*\n * The rail's states are accent-driven: the icon carries `--primary` on hover and\n * on the active destination, and both states draw the accent's own tint rather\n * than a neutral fill, so the rail reads as the app's accent chroma instead of a\n * grey column. The active label stays on `sidebar-foreground` because the accent\n * presets guarantee their 3:1 interaction minimum against the surface, not the\n * 4.5:1 small text owes; the icon is a graphic and rides the accent.\n */\nconst sideRailItemStateClass = {\n active: 'bg-primary-subtle text-sidebar-foreground [&_svg]:text-primary',\n idle: 'text-sidebar-muted-foreground hover:bg-primary-subtle/60 hover:text-primary',\n}\n\nconst TIP_GAP_PX = 8\n\ntype TipPosition = { top: number; left: number; height: number }\n\n/** The collapsed rail's tip state for one row; see `SideRailItem` for its treatment. */\nfunction createRailTip() {\n const rail = useContext(SideRailContext)\n const [row, setRow] = createSignal<HTMLElement>()\n const [position, setPosition] = createSignal<TipPosition | null>(null)\n return {\n setRow,\n position,\n show: () => {\n const element = row()\n if (!element || !rail?.collapsed()) return\n const rect = element.getBoundingClientRect()\n setPosition({ top: rect.top, left: rect.right + TIP_GAP_PX, height: rect.height })\n },\n hide: () => setPosition(null),\n }\n}\n\nfunction RailTip(props: {\n position: TipPosition | null\n icon: JSX.Element\n label: string\n active?: boolean\n shortcut?: string\n}) {\n return (\n /* The portal can finish an effect after the tooltip closes; capture its position. */\n <Show when={props.position} keyed>\n {(position) => (\n <Portal>\n <div\n aria-hidden=\"true\"\n data-slot=\"side-rail-tip\"\n class={cn(\n tooltipTip,\n 'pointer-events-none fixed z-(--z-tooltip) flex items-center gap-2.5 ps-3 pe-3 whitespace-nowrap'\n )}\n style={{\n top: `${position.top}px`,\n left: `${position.left}px`,\n height: `${position.height}px`,\n }}\n >\n <span\n class={cn('flex size-5 shrink-0 items-center justify-center [&_svg]:size-5', {\n 'text-primary': props.active,\n })}\n >\n {props.icon}\n </span>\n {props.label}\n <Show when={props.shortcut}>\n {(shortcut) => <KbdChord keys={shortcut()} class=\"shrink-0\" />}\n </Show>\n </div>\n </Portal>\n )}\n </Show>\n )\n}\n\n/**\n * A rail destination.\n *\n * ## The tooltip is the rail's hover affordance, not a generic bubble\n *\n * Collapsed, the row has no text, so the label has to come from somewhere. This\n * ports the donor's treatment rather than using a standard tooltip, because the\n * details are what make it read as part of the rail:\n *\n * - It is **flush with the row**: positioned at the row's own top and given the\n * row's own height, so it continues the row outward instead of floating near\n * it. A centred bubble with an arrow reads as a separate object.\n * - It **repeats the icon**, which anchors it to the row it belongs to.\n * - It carries the **keyboard chord**, which is the one piece of information a\n * collapsed rail otherwise cannot show.\n * - It opens on **hover and on focus**, so a keyboard user gets the same label a\n * pointer user does.\n * - It is `pointer-events-none` and `aria-hidden`: the row already carries the\n * name (as a visually hidden span when collapsed), so this is decoration and\n * must never be the accessible name.\n *\n * ## The chord on the row\n *\n * Expanded, the row shows its chord on hover and on focus — and the chord is\n * declared once to assistive technology through `aria-keyshortcuts` rather than\n * being read out as glyphs. The visible badge is `aria-hidden` for that reason.\n */\nexport type SideRailItemProps<T extends ValidComponent = 'a'> = PolymorphicProps<\n T,\n {\n class?: string\n /** Marks the item as the current destination. */\n active?: boolean\n /**\n * The item's accessible name. Required, and always in the accessibility tree:\n * collapsed it moves into the tooltip and a visually hidden span rather than\n * being deleted.\n */\n label: string\n /**\n * A count or a dot. Expanded, it trails the label at the row's end; collapsed,\n * it moves onto the icon's corner, so the rail never loses it.\n */\n badge?: JSX.Element\n /** An indicator pinned to the trailing edge in the expanded form. */\n trailing?: JSX.Element\n /** The chord as it should be drawn, e.g. `⌘1`. Shown on hover and focus. */\n shortcut?: string\n /**\n * The same chord in the ARIA grammar, e.g. `Meta+1`. Declared to assistive\n * technology instead of the display glyphs, which are not a keyboard shortcut\n * a screen reader can parse. Supply it whenever `shortcut` is drawn.\n */\n keyshortcuts?: string\n }\n>\n\nexport function SideRailItem<T extends ValidComponent = 'a'>(props: SideRailItemProps<T>) {\n const [local, rest] = splitProps(props as SideRailItemProps, [\n 'as',\n 'class',\n 'active',\n 'label',\n 'badge',\n 'trailing',\n 'shortcut',\n 'keyshortcuts',\n 'children',\n ])\n\n const tip = createRailTip()\n const trailing = resolveChildren(() => local.trailing)\n\n return (\n <>\n <Polymorphic\n as={local.as ?? 'a'}\n ref={tip.setRow}\n aria-current={local.active ? 'page' : undefined}\n aria-keyshortcuts={local.keyshortcuts}\n data-active={local.active ? '' : undefined}\n class={cn(\n sideRailItemClass,\n 'relative',\n local.active ? sideRailItemStateClass.active : sideRailItemStateClass.idle,\n local.class\n )}\n onPointerEnter={tip.show}\n onPointerLeave={tip.hide}\n onFocus={tip.show}\n onBlur={tip.hide}\n {...(rest as Record<string, unknown>)}\n >\n <span class=\"flex size-5 shrink-0 items-center justify-center [&_svg]:size-5\">\n {local.children}\n </span>\n\n <span class=\"min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only\">\n {local.label}\n </span>\n\n {/*\n * One element, two placements, because the badge is caller content and a DOM\n * node cannot be in two places. Expanded, it is a trailing count in the row's\n * flow, after the label — over the icon it would cover the glyph the row is\n * recognised by. Collapsed, there is no label to trail, so it leaves the flow\n * and pins to the icon's top-end corner: anchored to the row's centre (where\n * the centred icon sits) and pushed out by 14px, the icon's half-width plus\n * the 4px overhang, so a wider count grows back over the icon rather than past\n * the rail's edge.\n */}\n <Show when={local.badge}>\n {(badgeSlot) => (\n <span\n data-slot=\"side-rail-badge\"\n class=\"flex shrink-0 items-center justify-center group-data-[collapsed=true]/rail:absolute group-data-[collapsed=true]/rail:end-1/2 group-data-[collapsed=true]/rail:top-1/2 group-data-[collapsed=true]/rail:-me-3.5 group-data-[collapsed=true]/rail:-mt-3.5\"\n >\n {badgeSlot()}\n </span>\n )}\n </Show>\n\n <Show when={trailing() === undefined && local.shortcut}>\n {(shortcut) => (\n <KbdChord\n keys={shortcut()}\n size=\"compact\"\n class=\"shrink-0 opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden\"\n />\n )}\n </Show>\n\n <Show when={trailing()}>\n {(trailingSlot) => <span class=\"ms-auto shrink-0\">{trailingSlot()}</span>}\n </Show>\n </Polymorphic>\n\n <RailTip\n position={tip.position()}\n icon={local.children}\n label={local.label}\n active={local.active}\n shortcut={local.shortcut}\n />\n </>\n )\n}\n\n/** A non-navigating rail control: a collapse toggle, a \"new\" action. */\nexport function SideRailButton(\n props: Omit<ComponentProps<'button'>, 'type'> & {\n label: string\n shortcut?: string\n active?: boolean\n }\n) {\n const [local, rest] = splitProps(props, ['class', 'label', 'shortcut', 'children', 'active'])\n const tip = createRailTip()\n\n return (\n <>\n <button\n type=\"button\"\n ref={tip.setRow}\n aria-label={local.label}\n data-active={local.active ? 'true' : undefined}\n onPointerEnter={tip.show}\n onPointerLeave={tip.hide}\n onFocus={tip.show}\n onBlur={tip.hide}\n class={cn(\n sideRailItemClass,\n local.active ? sideRailItemStateClass.active : sideRailItemStateClass.idle,\n 'disabled:pointer-events-none disabled:opacity-50',\n local.class\n )}\n {...rest}\n >\n <span class=\"flex size-5 shrink-0 items-center justify-center [&_svg]:size-5\">\n {local.children}\n </span>\n <span class=\"min-w-0 flex-1 truncate text-start group-data-[collapsed=true]/rail:sr-only\">\n {local.label}\n </span>\n <Show when={local.shortcut}>\n {(shortcut) => (\n <KbdChord\n keys={shortcut()}\n size=\"compact\"\n class=\"shrink-0 opacity-0 transition-opacity group-hover/rail-item:opacity-100 group-focus-visible/rail-item:opacity-100 group-data-[collapsed=true]/rail:hidden\"\n />\n )}\n </Show>\n </button>\n\n <RailTip position={tip.position()} icon={local.children} label={local.label} />\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,SAAgBe,SAA2CC,OAAyB;CAClF,MAAM,CAACC,OAAOC,QAAQZ,WAAWU,OAAwB;EACvD;EACA;EACA;EACA;CAAU,CACX;CAED,MAAMF,YAAYV,iBAAiBa,MAAMH,aAAa,KAAK;CAC3D,MAAMK,QAAQ;EACZL;EACAM,OAAOhB,iBAAkBU,UAAU,IAAI,sBAAsB,4BAA6B;CAC5F;CAEA,OAAAO,gBACGT,gBAAgBU,UAAQ;EAAQH;EAAK,IAAAlB,WAAA;GAAA,OAAAoB,gBACnCrB,aAAWuB,WAAA;IACVC,IAAE;IAAA,KAAA,gBAAA;KAAA,OACUP,MAAM,iBAAiB;IAAS;IAAA,KAAA,oBAAA;KAAA,OAI5BH,UAAU,IAAI,SAAS;IAAO;IAAA,KAAA,WAAA;KAAA,OACvCJ,GACL,8GACA,4CACA;MAAE,UAAUI,UAAU;MAAG,mBAAmB,CAACA,UAAU;KAAE,GACzDG,MAAMJ,KACR;IAAC;GAAA,GACIK,MAA6B,EAAA,IAAAjB,WAAA;IAAA,OAEjCgB,MAAMhB;GAAQ,EAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAIvB;;AAGA,SAAgBwB,eAAeT,OAA8B;CAC3D,MAAM,CAACC,OAAOC,QAAQZ,WAAWU,OAAO,CAAC,OAAO,CAAC;CACjD,cAAA;EAAA,IAAAU,OAAAC,OAAA;EAAAC,OAAAF,MAAAH,WAAA,EAAA,KAAA,WAAA;GAAA,OAGWb,GACL,0IACAO,MAAM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;GAAC;EAAA,GACGK,IAAI,GAAA,OAAA,IAAA;EAAAqB,OAAA6E,cAGLnG,MAAMhB,QAAQ;EAAAsC,OAAA8E,cAGdpG,MAAMmB,KAAK;EAAAG,OAAA2E,QAAA7F,gBAEblB,MAAI;GAAA,IAACqC,OAAI;IAAA,OAAEvB,MAAMkD;GAAQ;GAAAlE,WACtBkE,aAAQ9C,gBACPV,UAAQ;IAAA,IACP8D,OAAI;KAAA,OAAEN,SAAS;IAAC;IAChB0C,MAAI;IAAA,SAAA;GAAA,CAAA;EAGP,CAAA,GAAA,IAAA;EAAA,OAAAK;CAAA,EAAA,CAAA,GAAA7F,gBAIJ4C,SAAO;EAAA,IAACR,WAAQ;GAAA,OAAEoC,IAAIpC,SAAS;EAAC;EAAA,IAAES,OAAI;GAAA,OAAEjD,MAAMhB;EAAQ;EAAA,IAAEmC,QAAK;GAAA,OAAEnB,MAAMmB;EAAK;CAAA,CAAA,CAAA;AAGjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"top-bar.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/top-bar/top-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"top-bar.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/top-bar/top-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAM9C,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,GAChD,iBAAiB,GAAG;IAClB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAC/B,CAAA;AAEH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,kCA2BxC;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;CAAE,kCAqBvF;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IAC7B,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAC3B,kCAgBF;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,kCAY5D;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG;IACzD,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,kCA2BpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,kCAqB7E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { callHandler } from "../../../lib/events.js";
|
|
2
2
|
import { cn } from "../../../lib/utils.js";
|
|
3
|
+
import { KbdChord } from "../../ui/kbd/kbd.js";
|
|
3
4
|
import { windowChromeClass } from "./window-chrome.js";
|
|
4
5
|
import { createComponent, delegateEvents, insert, mergeProps, spread, template } from "solid-js/web";
|
|
5
6
|
import { Search } from "lucide-solid";
|
|
@@ -10,8 +11,7 @@ var _tmpl$2 = /*#__PURE__*/ template(`<div data-slot=top-bar-section>`);
|
|
|
10
11
|
var _tmpl$3 = /*#__PURE__*/ template(`<div data-slot=top-bar-title>`);
|
|
11
12
|
var _tmpl$4 = /*#__PURE__*/ template(`<div data-slot=top-bar-breadcrumb>`);
|
|
12
13
|
var _tmpl$5 = /*#__PURE__*/ template(`<button type=button data-slot=top-bar-search><span class="sr-only sm:not-sr-only sm:truncate">`);
|
|
13
|
-
var _tmpl$6 = /*#__PURE__*/ template(`<
|
|
14
|
-
var _tmpl$7 = /*#__PURE__*/ template(`<button type=button data-slot=top-bar-pill><span>`);
|
|
14
|
+
var _tmpl$6 = /*#__PURE__*/ template(`<button type=button data-slot=top-bar-pill><span>`);
|
|
15
15
|
function TopBar(props) {
|
|
16
16
|
const [local, rest] = splitProps(props, [
|
|
17
17
|
"class",
|
|
@@ -107,11 +107,12 @@ function TopBarSearch(props) {
|
|
|
107
107
|
get when() {
|
|
108
108
|
return local.shortcut;
|
|
109
109
|
},
|
|
110
|
-
children: (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
children: (shortcut) => createComponent(KbdChord, {
|
|
111
|
+
get keys() {
|
|
112
|
+
return shortcut();
|
|
113
|
+
},
|
|
114
|
+
"class": "ms-auto hidden shrink-0 sm:inline-flex"
|
|
115
|
+
})
|
|
115
116
|
}), null);
|
|
116
117
|
return _el$5;
|
|
117
118
|
})();
|
|
@@ -128,13 +129,13 @@ function TopBarPill(props) {
|
|
|
128
129
|
"children"
|
|
129
130
|
]);
|
|
130
131
|
return (() => {
|
|
131
|
-
var _el$
|
|
132
|
-
spread(_el$
|
|
132
|
+
var _el$7 = _tmpl$6(), _el$8 = _el$7.firstChild;
|
|
133
|
+
spread(_el$7, mergeProps({ get ["class"]() {
|
|
133
134
|
return cn("text-muted-foreground inline-flex h-control-sm shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium", "transition-colors ease-out outline-none", "hover:border-input hover:text-foreground", "focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle", "window-no-drag [&_svg]:size-3.5 [&_svg]:shrink-0", local.class);
|
|
134
135
|
} }, rest), false, true);
|
|
135
|
-
insert(_el$
|
|
136
|
-
insert(_el$
|
|
137
|
-
return _el$
|
|
136
|
+
insert(_el$7, () => local.children, _el$8);
|
|
137
|
+
insert(_el$8, () => local.label);
|
|
138
|
+
return _el$7;
|
|
138
139
|
})();
|
|
139
140
|
}
|
|
140
141
|
delegateEvents(["focusin"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"top-bar.js","names":["Show","splitProps","Search","callHandler","cn","windowChromeClass","centerWidth","TopBar","props","local","rest","_el$","_tmpl$","_$spread","_$mergeProps","class","TopBarSection","align","_el$2","_tmpl$2","$$focusin","event","target","HTMLElement","scrollIntoView","block","inline","onFocusIn","TopBarTitle","_el$3","_tmpl$3","TopBarBreadcrumb","_el$4","_tmpl$4","placeholder","shortcut","keyshortcuts","TopBarSearch","_el$5","_tmpl$5","_el$6","firstChild","_$insert","_$createComponent","when","children","shortcutSlot","_el$7","_tmpl$6","TopBarPill","label","_el$8","_tmpl$7","_el$9","_$delegateEvents"],"sources":["../../../../src/components/layout/top-bar/top-bar.tsx"],"sourcesContent":["import type { ComponentProps } from 'solid-js'\nimport { Show, splitProps } from 'solid-js'\nimport { Search } from 'lucide-solid'\nimport { callHandler } from '#lib/events'\nimport { cn } from '#lib/utils'\nimport { windowChromeClass, type WindowChromeProps } from './window-chrome'\n\n/**\n * TopBar.\n *\n * The window's title row and primary toolbar. Three tracks: a leading group, a\n * centred search, and a trailing group. On wide screens the search is a fixed\n * function of the window width and the side groups are equal remainders. On\n * narrow screens the middle track yields space to the controls, and each side\n * group scrolls when necessary so keyboard focus can reveal every action.\n *\n * The centre track is sized for a lone search field. A bar whose centre holds\n * more than that, such as a search plus an action beside it, passes\n * `centerWidth=\"wide\"`: the centre then stays fluid below 1280px, with each\n * side group sized to its content but capped between 30% and 40% of the row\n * (a longer group scrolls instead): the cap is 30% on the narrowest rows and\n * grows to 40% as the row widens, so full side groups never squeeze the\n * centre's search out of it and enlarged text never pushes a short leading\n * control such as a navigation toggle out of the row. Above 1280px it takes a\n * wider fixed track.\n *\n * A wide bar also never squeezes its centre to nothing. When the row is\n * narrower than 19rem (measured in rem, so enlarged text reaches it at a wider\n * window) the centre moves to a second row of its own and the two side groups\n * share the first, the trailing group taking the remainder beside the leading\n * group's cap, so the leading and trailing controls and the whole centre each\n * keep a full row instead of fighting for one. The bar grows from one row\n * to two only then. The wide layout places the leading group, centre and\n * trailing group as its first, second and third children.\n *\n * On a frameless desktop window this row is also the drag region, so it carries\n * `window-drag` and the controls inside it opt back out. `macos-inset` and\n * `windows-inset` reserve the space the native window controls occupy, which is\n * why the row can look off-centre in a frameless window and be correct: it is\n * centred in the space the user can actually see.\n */\nexport type TopBarProps = ComponentProps<'header'> &\n WindowChromeProps & {\n /**\n * How wide the centre track is. `field` (default) suits a lone search field.\n * `wide` suits a centre that also holds an action: fluid below 1280px between\n * side groups sized to their content and capped between 30% and 40% of the\n * row (a longer group scrolls), then a clamp of 32vw up to 672px between equal\n * side tracks.\n * Below a 19rem row the centre drops to a second row of its own.\n */\n centerWidth?: 'field' | 'wide'\n }\n\nexport function TopBar(props: TopBarProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'draggable',\n 'macosInset',\n 'windowsInset',\n 'glass',\n 'centerWidth',\n ])\n\n return (\n <header\n data-slot=\"top-bar\"\n class={cn(\n 'h-topbar relative z-(--z-sticky) grid shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-3 border-b border-border bg-card text-card-foreground md:grid-cols-[minmax(0,1fr)_clamp(240px,22vw,480px)_minmax(0,1fr)]',\n /* The bar is its own container so its children can move to a second\n row by the row's width in rem, which enlarged text shrinks. The\n first row keeps the bar's height (less the 1px bottom border); the\n second only exists when the centre has dropped onto it. */\n local.centerWidth === 'wide' &&\n '@container/top-bar h-auto grid-cols-[fit-content(max(30%,min(40%,calc(50%-3.75rem))))_minmax(0,1fr)_fit-content(max(30%,min(40%,calc(50%-3.75rem))))] grid-rows-[minmax(calc(var(--topbar-height)-1px),auto)] gap-x-2 gap-y-0 md:grid-cols-[fit-content(max(30%,min(40%,calc(50%-3.75rem))))_minmax(0,1fr)_fit-content(max(30%,min(40%,calc(50%-3.75rem))))] xl:grid-cols-[minmax(0,1fr)_clamp(240px,32vw,672px)_minmax(0,1fr)] [&>:nth-child(2)]:@max-[19rem]/top-bar:col-span-full [&>:nth-child(2)]:@max-[19rem]/top-bar:row-start-2 [&>:nth-child(2)]:@max-[19rem]/top-bar:pb-2 [&>:nth-child(3)]:@max-[19rem]/top-bar:col-span-2 [&>:nth-child(3)]:@max-[19rem]/top-bar:col-start-2 [&>:nth-child(3)]:@max-[19rem]/top-bar:row-start-1',\n windowChromeClass(local),\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** A scrollable side group; equal wide-screen tracks centre the search. */\nexport function TopBarSection(props: ComponentProps<'div'> & { align?: 'start' | 'end' }) {\n const [local, rest] = splitProps(props, ['class', 'align', 'onFocusIn'])\n\n return (\n <div\n data-slot=\"top-bar-section\"\n class={cn(\n 'window-no-drag flex min-w-0 items-center gap-2 overflow-x-auto overflow-y-hidden',\n local.align === 'end' && 'md:justify-end-safe',\n local.align !== 'end' && 'justify-start',\n local.class\n )}\n onFocusIn={(event) => {\n if (event.target instanceof HTMLElement) {\n event.target.scrollIntoView({ block: 'nearest', inline: 'nearest' })\n }\n callHandler(local.onFocusIn, event)\n }}\n {...rest}\n />\n )\n}\n\nexport function TopBarTitle(\n props: ComponentProps<'div'> & {\n /** Aligns text within this slot; it does not position the slot. */\n align?: 'start' | 'center'\n }\n) {\n const [local, rest] = splitProps(props, ['class', 'align'])\n return (\n <div\n data-slot=\"top-bar-title\"\n class={cn(\n /* The title slot sits in the drag region; a link, button or field\n placed in it (a breadcrumb, a view's search) must stay pressable. */\n 'truncate text-sm font-medium [&_:is(a,button,input)]:window-no-drag',\n local.align === 'center' && 'text-center',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** A breadcrumb or path readout that yields to the actions when space runs out. */\nexport function TopBarBreadcrumb(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"top-bar-breadcrumb\"\n class={cn(\n 'flex min-w-0 items-center gap-1.5 text-sm [&_:is(a,button,input)]:window-no-drag',\n local.class\n )}\n {...rest}\n />\n )\n}\n\nexport type TopBarSearchProps = ComponentProps<'button'> & {\n /** The hint shown inside the field, e.g. \"Search projects and files\". */\n placeholder?: string\n /** The shortcut chip drawn at the trailing edge, e.g. \"⌘K\". */\n shortcut?: string\n /**\n * The parseable chord behind `shortcut`, e.g. `Meta+K`. The chip is\n * `aria-hidden` — reading it out would pollute the button's accessible\n * name — so this is what assistive technology announces instead. Supply it\n * whenever `shortcut` is drawn.\n */\n keyshortcuts?: string\n}\n\n/**\n * The search affordance in the middle track.\n *\n * It is a button, not an input, and that is deliberate: clicking it opens the\n * command palette, which already owns the input, the ranking and the keyboard\n * handling. A second live input here would be a second source of truth for the\n * same query. It is styled to read as a field because that is what it behaves\n * like from the user's side.\n */\nexport function TopBarSearch(props: TopBarSearchProps) {\n const [local, rest] = splitProps(props, ['class', 'placeholder', 'shortcut', 'keyshortcuts'])\n\n return (\n <button\n type=\"button\"\n data-slot=\"top-bar-search\"\n class={cn(\n 'text-muted-foreground flex h-control-md w-full min-w-(--control-height-md) items-center justify-center gap-2 rounded-md border border-input px-3 text-sm sm:justify-start',\n 'transition-colors ease-out outline-none',\n 'hover:bg-surface-hover hover:text-foreground',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n 'window-no-drag',\n local.class\n )}\n aria-keyshortcuts={local.keyshortcuts}\n {...rest}\n >\n <Search aria-hidden=\"true\" class=\"size-4 shrink-0 sm:hidden\" />\n <span class=\"sr-only sm:not-sr-only sm:truncate\">{local.placeholder ?? 'Search'}</span>\n <Show when={local.shortcut}>\n {(shortcutSlot) => (\n <kbd\n aria-hidden=\"true\"\n class=\"bg-muted ms-auto hidden h-5 shrink-0 items-center rounded-sm border border-border px-1.5 font-code text-code sm:flex\"\n >\n {shortcutSlot()}\n </kbd>\n )}\n </Show>\n </button>\n )\n}\n\n/**\n * A labelled top-bar control — the readouts KiroCrew puts in the trailing\n * group. Container queries on the group decide which of these survive a narrow\n * window; a caller marks the cheap-to-drop ones and the group handles the rest.\n */\nexport function TopBarPill(props: ComponentProps<'button'> & { label: string }) {\n const [local, rest] = splitProps(props, ['class', 'label', 'children'])\n\n return (\n <button\n type=\"button\"\n data-slot=\"top-bar-pill\"\n class={cn(\n 'text-muted-foreground inline-flex h-control-sm shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium',\n 'transition-colors ease-out outline-none',\n 'hover:border-input hover:text-foreground',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n 'window-no-drag [&_svg]:size-3.5 [&_svg]:shrink-0',\n local.class\n )}\n {...rest}\n >\n {local.children}\n <span>{local.label}</span>\n </button>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAsDA,SAAgBO,OAAOC,OAAoB;CACzC,MAAM,CAACC,OAAOC,QAAQT,WAAWO,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;CAAa,CACd;CAED,cAAA;EAAA,IAAAG,OAAAC,OAAA;EAAAC,OAAAF,MAAAG,WAAA,EAAA,KAAA,WAAA;GAAA,OAGWV,GACL,yOAKAK,MAAMH,gBAAgB,UACpB,+sBACFD,kBAAkBI,KAAK,GACvBA,MAAMM,KACR;EAAC,EAAA,GACGL,IAAI,GAAA,OAAA,KAAA;EAAA,OAAAC;CAAA,EAAA,CAAA;AAGd;;AAGA,SAAgBK,cAAcR,OAA4D;CACxF,MAAM,CAACC,OAAOC,QAAQT,WAAWO,OAAO;EAAC;EAAS;EAAS;CAAW,CAAC;CAEvE,cAAA;EAAA,IAAAU,QAAAC,QAAA;EAAAD,MAAAE,aASgBC,UAAU;GACpB,IAAIA,MAAMC,kBAAkBC,aAC1BF,MAAMC,OAAOE,eA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MAAMM,KACR;GAAC;GAAA,KAAA,uBAAA;IAAA,OACkBN,MAAM2B;GAAY;EAAA,GACjC1B,IAAI,GAAA,OAAA,IAAA;EAAAgC,OAAAJ,OAAAK,gBAEPzC,QAAM;GAAA,eAAA;GAAA,SAAA;EAAA,CAAA,GAAAsC,KAAA;EAAAE,OAAAF,aAC2C/B,MAAMyB,eAAe,QAAQ;EAAAQ,OAAAJ,OAAAK,gBAC9E3C,MAAI;GAAA,IAAC4C,OAAI;IAAA,OAAEnC,MAAM0B;GAAQ;GAAAU,WACtBC,wBAAY;IAAA,IAAAC,QAAAC,QAAA;IAAAN,OAAAK,OAKTD,YAAY;IAAA,OAAAC;GAAA,EAAA,CAAA;EAEhB,CAAA,GAAA,IAAA;EAAA,OAAAT;CAAA,EAAA,CAAA;AAIT;;;;;;AAOA,SAAgBW,WAAWzC,OAAqD;CAC9E,MAAM,CAACC,OAAOC,QAAQT,WAAWO,OAAO;EAAC;EAAS;EAAS;CAAU,CAAC;CAEtE,cAAA;EAAA,IAAA2C,QAAAC,QAAA,GAAAC,QAAAF,MAAAV;EAAA5B,OAAAsC,OAAArC,WAAA,EAAA,KAAA,WAAA;GAAA,OAIWV,GACL,2IACA,2CACA,4CACA,oFACA,oDACAK,MAAMM,KACR;EAAC,EAAA,GACGL,IAAI,GAAA,OAAA,IAAA;EAAAgC,OAAAS,aAEP1C,MAAMoC,UAAQQ,KAAA;EAAAX,OAAAW,aACR5C,MAAMyC,KAAK;EAAA,OAAAC;CAAA,EAAA,CAAA;AAGxB;AAACG,eAAA,CAAA,SAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"top-bar.js","names":["Show","splitProps","Search","callHandler","cn","KbdChord","windowChromeClass","centerWidth","TopBar","props","local","rest","_el$","_tmpl$","_$spread","_$mergeProps","class","TopBarSection","align","_el$2","_tmpl$2","$$focusin","event","target","HTMLElement","scrollIntoView","block","inline","onFocusIn","TopBarTitle","_el$3","_tmpl$3","TopBarBreadcrumb","_el$4","_tmpl$4","placeholder","shortcut","keyshortcuts","TopBarSearch","_el$5","_tmpl$5","_el$6","firstChild","_$insert","_$createComponent","when","children","keys","TopBarPill","label","_el$7","_tmpl$6","_el$8","_$delegateEvents"],"sources":["../../../../src/components/layout/top-bar/top-bar.tsx"],"sourcesContent":["import type { ComponentProps } from 'solid-js'\nimport { Show, splitProps } from 'solid-js'\nimport { Search } from 'lucide-solid'\nimport { callHandler } from '#lib/events'\nimport { cn } from '#lib/utils'\nimport { KbdChord } from '../../ui/kbd'\nimport { windowChromeClass, type WindowChromeProps } from './window-chrome'\n\n/**\n * TopBar.\n *\n * The window's title row and primary toolbar. Three tracks: a leading group, a\n * centred search, and a trailing group. On wide screens the search is a fixed\n * function of the window width and the side groups are equal remainders. On\n * narrow screens the middle track yields space to the controls, and each side\n * group scrolls when necessary so keyboard focus can reveal every action.\n *\n * The centre track is sized for a lone search field. A bar whose centre holds\n * more than that, such as a search plus an action beside it, passes\n * `centerWidth=\"wide\"`: the centre then stays fluid below 1280px, with each\n * side group sized to its content but capped between 30% and 40% of the row\n * (a longer group scrolls instead): the cap is 30% on the narrowest rows and\n * grows to 40% as the row widens, so full side groups never squeeze the\n * centre's search out of it and enlarged text never pushes a short leading\n * control such as a navigation toggle out of the row. Above 1280px it takes a\n * wider fixed track.\n *\n * A wide bar also never squeezes its centre to nothing. When the row is\n * narrower than 19rem (measured in rem, so enlarged text reaches it at a wider\n * window) the centre moves to a second row of its own and the two side groups\n * share the first, the trailing group taking the remainder beside the leading\n * group's cap, so the leading and trailing controls and the whole centre each\n * keep a full row instead of fighting for one. The bar grows from one row\n * to two only then. The wide layout places the leading group, centre and\n * trailing group as its first, second and third children.\n *\n * On a frameless desktop window this row is also the drag region, so it carries\n * `window-drag` and the controls inside it opt back out. `macos-inset` and\n * `windows-inset` reserve the space the native window controls occupy, which is\n * why the row can look off-centre in a frameless window and be correct: it is\n * centred in the space the user can actually see.\n */\nexport type TopBarProps = ComponentProps<'header'> &\n WindowChromeProps & {\n /**\n * How wide the centre track is. `field` (default) suits a lone search field.\n * `wide` suits a centre that also holds an action: fluid below 1280px between\n * side groups sized to their content and capped between 30% and 40% of the\n * row (a longer group scrolls), then a clamp of 32vw up to 672px between equal\n * side tracks.\n * Below a 19rem row the centre drops to a second row of its own.\n */\n centerWidth?: 'field' | 'wide'\n }\n\nexport function TopBar(props: TopBarProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'draggable',\n 'macosInset',\n 'windowsInset',\n 'glass',\n 'centerWidth',\n ])\n\n return (\n <header\n data-slot=\"top-bar\"\n class={cn(\n 'h-topbar relative z-(--z-sticky) grid shrink-0 grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-3 border-b border-border bg-card text-card-foreground md:grid-cols-[minmax(0,1fr)_clamp(240px,22vw,480px)_minmax(0,1fr)]',\n /* The bar is its own container so its children can move to a second\n row by the row's width in rem, which enlarged text shrinks. The\n first row keeps the bar's height (less the 1px bottom border); the\n second only exists when the centre has dropped onto it. */\n local.centerWidth === 'wide' &&\n '@container/top-bar h-auto grid-cols-[fit-content(max(30%,min(40%,calc(50%-3.75rem))))_minmax(0,1fr)_fit-content(max(30%,min(40%,calc(50%-3.75rem))))] grid-rows-[minmax(calc(var(--topbar-height)-1px),auto)] gap-x-2 gap-y-0 md:grid-cols-[fit-content(max(30%,min(40%,calc(50%-3.75rem))))_minmax(0,1fr)_fit-content(max(30%,min(40%,calc(50%-3.75rem))))] xl:grid-cols-[minmax(0,1fr)_clamp(240px,32vw,672px)_minmax(0,1fr)] [&>:nth-child(2)]:@max-[19rem]/top-bar:col-span-full [&>:nth-child(2)]:@max-[19rem]/top-bar:row-start-2 [&>:nth-child(2)]:@max-[19rem]/top-bar:pb-2 [&>:nth-child(3)]:@max-[19rem]/top-bar:col-span-2 [&>:nth-child(3)]:@max-[19rem]/top-bar:col-start-2 [&>:nth-child(3)]:@max-[19rem]/top-bar:row-start-1',\n windowChromeClass(local),\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** A scrollable side group; equal wide-screen tracks centre the search. */\nexport function TopBarSection(props: ComponentProps<'div'> & { align?: 'start' | 'end' }) {\n const [local, rest] = splitProps(props, ['class', 'align', 'onFocusIn'])\n\n return (\n <div\n data-slot=\"top-bar-section\"\n class={cn(\n 'window-no-drag flex min-w-0 items-center gap-2 overflow-x-auto overflow-y-hidden',\n local.align === 'end' && 'md:justify-end-safe',\n local.align !== 'end' && 'justify-start',\n local.class\n )}\n onFocusIn={(event) => {\n if (event.target instanceof HTMLElement) {\n event.target.scrollIntoView({ block: 'nearest', inline: 'nearest' })\n }\n callHandler(local.onFocusIn, event)\n }}\n {...rest}\n />\n )\n}\n\nexport function TopBarTitle(\n props: ComponentProps<'div'> & {\n /** Aligns text within this slot; it does not position the slot. */\n align?: 'start' | 'center'\n }\n) {\n const [local, rest] = splitProps(props, ['class', 'align'])\n return (\n <div\n data-slot=\"top-bar-title\"\n class={cn(\n /* The title slot sits in the drag region; a link, button or field\n placed in it (a breadcrumb, a view's search) must stay pressable. */\n 'truncate text-sm font-medium [&_:is(a,button,input)]:window-no-drag',\n local.align === 'center' && 'text-center',\n local.class\n )}\n {...rest}\n />\n )\n}\n\n/** A breadcrumb or path readout that yields to the actions when space runs out. */\nexport function TopBarBreadcrumb(props: ComponentProps<'div'>) {\n const [local, rest] = splitProps(props, ['class'])\n return (\n <div\n data-slot=\"top-bar-breadcrumb\"\n class={cn(\n 'flex min-w-0 items-center gap-1.5 text-sm [&_:is(a,button,input)]:window-no-drag',\n local.class\n )}\n {...rest}\n />\n )\n}\n\nexport type TopBarSearchProps = ComponentProps<'button'> & {\n /** The hint shown inside the field, e.g. \"Search projects and files\". */\n placeholder?: string\n /** The shortcut chip drawn at the trailing edge, e.g. \"⌘K\". */\n shortcut?: string\n /**\n * The parseable chord behind `shortcut`, e.g. `Meta+K`. The chip is\n * `aria-hidden` — reading it out would pollute the button's accessible\n * name — so this is what assistive technology announces instead. Supply it\n * whenever `shortcut` is drawn.\n */\n keyshortcuts?: string\n}\n\n/**\n * The search affordance in the middle track.\n *\n * It is a button, not an input, and that is deliberate: clicking it opens the\n * command palette, which already owns the input, the ranking and the keyboard\n * handling. A second live input here would be a second source of truth for the\n * same query. It is styled to read as a field because that is what it behaves\n * like from the user's side.\n */\nexport function TopBarSearch(props: TopBarSearchProps) {\n const [local, rest] = splitProps(props, ['class', 'placeholder', 'shortcut', 'keyshortcuts'])\n\n return (\n <button\n type=\"button\"\n data-slot=\"top-bar-search\"\n class={cn(\n 'text-muted-foreground flex h-control-md w-full min-w-(--control-height-md) items-center justify-center gap-2 rounded-md border border-input px-3 text-sm sm:justify-start',\n 'transition-colors ease-out outline-none',\n 'hover:bg-surface-hover hover:text-foreground',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n 'window-no-drag',\n local.class\n )}\n aria-keyshortcuts={local.keyshortcuts}\n {...rest}\n >\n <Search aria-hidden=\"true\" class=\"size-4 shrink-0 sm:hidden\" />\n <span class=\"sr-only sm:not-sr-only sm:truncate\">{local.placeholder ?? 'Search'}</span>\n <Show when={local.shortcut}>\n {(shortcut) => (\n <KbdChord keys={shortcut()} class=\"ms-auto hidden shrink-0 sm:inline-flex\" />\n )}\n </Show>\n </button>\n )\n}\n\n/**\n * A labelled top-bar control — the readouts KiroCrew puts in the trailing\n * group. Container queries on the group decide which of these survive a narrow\n * window; a caller marks the cheap-to-drop ones and the group handles the rest.\n */\nexport function TopBarPill(props: ComponentProps<'button'> & { label: string }) {\n const [local, rest] = splitProps(props, ['class', 'label', 'children'])\n\n return (\n <button\n type=\"button\"\n data-slot=\"top-bar-pill\"\n class={cn(\n 'text-muted-foreground inline-flex h-control-sm shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-medium',\n 'transition-colors ease-out outline-none',\n 'hover:border-input hover:text-foreground',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n 'window-no-drag [&_svg]:size-3.5 [&_svg]:shrink-0',\n local.class\n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AM,CAACC,OAAOC,QAAQV,WAAWQ,OAAO;EAAC;EAAS;EAAS;CAAU,CAAC;CAEtE,cAAA;EAAA,IAAAyC,QAAAC,QAAA,GAAAC,QAAAF,MAAAR;EAAA5B,OAAAoC,OAAAnC,WAAA,EAAA,KAAA,WAAA;GAAA,OAIWX,GACL,2IACA,2CACA,4CACA,oFACA,oDACAM,MAAMM,KACR;EAAC,EAAA,GACGL,IAAI,GAAA,OAAA,IAAA;EAAAgC,OAAAO,aAEPxC,MAAMoC,UAAQM,KAAA;EAAAT,OAAAS,aACR1C,MAAMuC,KAAK;EAAA,OAAAC;CAAA,EAAA,CAAA;AAGxB;AAACG,eAAA,CAAA,SAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-layer.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/dialog/dialog-layer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAI7C;;;;;;;;;;;;;;GAcG;AAEH,KAAK,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,CAAC,EAAE,QAAQ,CAAC,WAAW,GAAG,SAAS,CAAC,CAAA;IACnD,eAAe,CAAC,EAAE,gBAAgB,CAAA;IAClC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,CAAA;
|
|
1
|
+
{"version":3,"file":"dialog-layer.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/dialog/dialog-layer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAI7C;;;;;;;;;;;;;;GAcG;AAEH,KAAK,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,CAAC,EAAE,QAAQ,CAAC,WAAW,GAAG,SAAS,CAAC,CAAA;IACnD,eAAe,CAAC,EAAE,gBAAgB,CAAA;IAClC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC,CAAA;AA6DD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,EACvB,OAAO,EAAE,kBAAkB,GAC1B;IAAE,eAAe,EAAE,gBAAgB,CAAC;IAAC,gBAAgB,EAAE,gBAAgB,CAAA;CAAE,CA4K3E;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB;qBA/KvC,gBAAgB;sBAAoB,gBAAgB;EAiLzE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAChD,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;CACvB,eAWA"}
|
|
@@ -19,8 +19,13 @@ function anotherLayerOpen(content, opener) {
|
|
|
19
19
|
* The focus-return half of the layer rules, for a layer whose open state is
|
|
20
20
|
* `open`. Returns the autofocus handlers to give the Kobalte content.
|
|
21
21
|
*/
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* How many restore frames a closed layer may spend on an opener that is still
|
|
24
|
+
* hidden. It counts frames, not time: Kobalte clears its own markers when the
|
|
25
|
+
* overlay finishes unmounting, which on a loaded machine (WebKit in CI) can be
|
|
26
|
+
* well over a second, and a frame count slows down with the page.
|
|
27
|
+
*/
|
|
28
|
+
var FOCUS_RESTORE_FRAME_BUDGET = 120;
|
|
24
29
|
function createDialogFocusReturn(open, options) {
|
|
25
30
|
const focusCycles = /* @__PURE__ */ new WeakMap();
|
|
26
31
|
let activeFocusCycle;
|
|
@@ -64,7 +69,8 @@ function createDialogFocusReturn(open, options) {
|
|
|
64
69
|
return;
|
|
65
70
|
}
|
|
66
71
|
if (opener.closest("[inert], [aria-hidden=\"true\"]")) {
|
|
67
|
-
|
|
72
|
+
cycle.hiddenFrames += 1;
|
|
73
|
+
if (cycle.hiddenFrames >= FOCUS_RESTORE_FRAME_BUDGET) finishFocusCycle(cycle);
|
|
68
74
|
return;
|
|
69
75
|
}
|
|
70
76
|
if (cycle.openerEligible && canRestoreFocus(opener)) opener.focus({ preventScroll: true });
|
|
@@ -88,7 +94,7 @@ function createDialogFocusReturn(open, options) {
|
|
|
88
94
|
closed: false,
|
|
89
95
|
focusMovedOutside: false,
|
|
90
96
|
closeAutoFocusScheduled: false,
|
|
91
|
-
|
|
97
|
+
hiddenFrames: 0,
|
|
92
98
|
onFocusIn: (focusEvent) => {
|
|
93
99
|
const target = focusEvent.target;
|
|
94
100
|
if (!(target instanceof HTMLElement) || target === document.body || target === document.documentElement) return;
|
|
@@ -129,12 +135,6 @@ function createDialogFocusReturn(open, options) {
|
|
|
129
135
|
subtree: true
|
|
130
136
|
});
|
|
131
137
|
scheduleFocusRestore(cycle);
|
|
132
|
-
cycle.fallbackTimer = window.setTimeout(() => {
|
|
133
|
-
cycle.fallbackTimer = void 0;
|
|
134
|
-
cycle.deadlinePassed = true;
|
|
135
|
-
cycle.observer?.disconnect();
|
|
136
|
-
if (cycle.frame === void 0) finishFocusCycle(cycle);
|
|
137
|
-
}, FOCUS_RESTORE_DEADLINE_MS);
|
|
138
138
|
};
|
|
139
139
|
onCleanup(() => {
|
|
140
140
|
const cycle = activeFocusCycle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-layer.js","names":["useDialogContext","createRenderEffect","onCleanup","TooltipEscapeTargetContext","event","restoreFocusRef","HTMLElement","onOpenAutoFocus","onCloseAutoFocus","content","opener","openerEligible","closed","focusMovedOutside","closeAutoFocusScheduled","deadlinePassed","frame","fallbackTimer","observer","MutationObserver","onFocusIn","openLayers","Set","isVisible","element","isConnected","getClientRects","length","canRestoreFocus","target","document","body","documentElement","closest","matches","anotherLayerOpen","layer","contains","FOCUS_RESTORE_DEADLINE_MS","createDialogFocusReturn","open","options","focusCycles","WeakMap","activeFocusCycle","pendingOpener","pendingOpenerEligible","active","activeElement","finishFocusCycle","cycle","undefined","window","cancelAnimationFrame","clearTimeout","disconnect","removeEventListener","delete","markClosed","scheduleFocusRestore","requestAnimationFrame","focusIsAvailable","Node","focus","preventScroll","currentTarget","openerWasCaptured","openerElement","focusEvent","set","add","addEventListener","get","defaultPrevented","observe","attributes","attributeFilter","childList","subtree","setTimeout","queueMicrotask","createDialogLayer","isOpen","DialogEscapeTarget","props","onEscapeKeyDown","children","dialog","dismiss","close","_$createComponent","Provider","value","contentRef"],"sources":["../../../../src/components/ui/dialog/dialog-layer.tsx"],"sourcesContent":["import { useDialogContext } from '@kobalte/core/dialog'\nimport type { Accessor, JSX } from 'solid-js'\nimport { createRenderEffect, onCleanup } from 'solid-js'\nimport { TooltipEscapeTargetContext } from '../tooltip/tooltip'\n\n/**\n * The rules the kit's dialog-shaped layers share, so a caller never wires them\n * by hand:\n *\n * 1. Focus returns to whatever had it before the layer opened. Kobalte only\n * returns focus to its own `Trigger`; a controlled layer opened from a menu\n * row, a shortcut or another layer would otherwise drop focus on `<body>`.\n * Dialog, AlertDialog, Sheet and the command palette.\n * 2. An Escape that a tooltip inside the layer swallowed still closes the layer\n * (see `TooltipEscapeTargetContext`). Dialog, AlertDialog and Sheet only;\n * the command palette does not provide it.\n *\n * Private to the overlay kit: content components apply it; callers pass\n * `restoreFocusRef` when the opener is gone by the time the layer opens.\n */\n\ntype AutoFocusHandler = (event: Event) => void\n\nexport type DialogLayerOptions = {\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n onOpenAutoFocus?: AutoFocusHandler\n onCloseAutoFocus?: AutoFocusHandler\n}\n\ntype FocusCycle = {\n content: HTMLElement\n opener: HTMLElement | null\n openerEligible: boolean\n closed: boolean\n focusMovedOutside: boolean\n closeAutoFocusScheduled: boolean\n /** The restore deadline passed: stop waiting on the opener after the frame that is due. */\n deadlinePassed: boolean\n frame?: number\n fallbackTimer?: number\n observer?: MutationObserver\n onFocusIn: (event: FocusEvent) => void\n}\n\n/** The kit's dialog layers that are open now, so a closing layer can tell a newer one took over. */\nconst openLayers = new Set<HTMLElement>()\n\nfunction isVisible(element: HTMLElement) {\n return element.isConnected && element.getClientRects().length > 0\n}\n\nfunction canRestoreFocus(target: HTMLElement): boolean {\n return (\n target !== document.body &&\n target !== document.documentElement &&\n !target.closest('[inert], [aria-hidden=\"true\"]') &&\n !target.matches(':disabled') &&\n isVisible(target)\n )\n}\n\nfunction anotherLayerOpen(content: HTMLElement, opener: HTMLElement): boolean {\n for (const layer of openLayers) {\n if (\n layer !== content &&\n !content.contains(layer) &&\n !layer.contains(opener) &&\n !layer.closest('[aria-hidden=\"true\"], [inert]') &&\n isVisible(layer)\n ) {\n return true\n }\n }\n return false\n}\n\n/**\n * The focus-return half of the layer rules, for a layer whose open state is\n * `open`. Returns the autofocus handlers to give the Kobalte content.\n */\n/** How long a closed layer may wait for its opener to become focusable again. */\nconst FOCUS_RESTORE_DEADLINE_MS = 1000\n\nexport function createDialogFocusReturn(\n open: Accessor<boolean>,\n options: DialogLayerOptions\n): { onOpenAutoFocus: AutoFocusHandler; onCloseAutoFocus: AutoFocusHandler } {\n const focusCycles = new WeakMap<HTMLElement, FocusCycle>()\n let activeFocusCycle: FocusCycle | undefined\n let pendingOpener: HTMLElement | null = null\n let pendingOpenerEligible = false\n\n // Captured while the open state changes, before Kobalte's effects move focus\n // into the layer and before a closing menu takes its row out of the page.\n createRenderEffect(() => {\n if (!open() || typeof document === 'undefined') {\n pendingOpener = null\n pendingOpenerEligible = false\n return\n }\n const active = options.restoreFocusRef?.() ?? document.activeElement\n pendingOpener = active instanceof HTMLElement ? active : null\n pendingOpenerEligible = active instanceof HTMLElement && canRestoreFocus(active)\n })\n\n const finishFocusCycle = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) window.cancelAnimationFrame(cycle.frame)\n if (cycle.fallbackTimer !== undefined) window.clearTimeout(cycle.fallbackTimer)\n cycle.observer?.disconnect()\n document.removeEventListener('focusin', cycle.onFocusIn)\n openLayers.delete(cycle.content)\n if (activeFocusCycle === cycle) activeFocusCycle = undefined\n }\n\n const markClosed = (cycle: FocusCycle) => {\n cycle.closed = true\n openLayers.delete(cycle.content)\n }\n\n const scheduleFocusRestore = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) return\n cycle.frame = window.requestAnimationFrame(() => {\n cycle.frame = undefined\n const opener = cycle.opener\n const active = document.activeElement\n const focusIsAvailable =\n active === document.body ||\n active === document.documentElement ||\n active === cycle.content ||\n (active instanceof Node && cycle.content.contains(active))\n if (\n activeFocusCycle !== cycle ||\n !cycle.closed ||\n cycle.focusMovedOutside ||\n !opener ||\n !isVisible(opener) ||\n opener.matches(':disabled') ||\n !focusIsAvailable ||\n anotherLayerOpen(cycle.content, opener)\n ) {\n finishFocusCycle(cycle)\n return\n }\n\n // Nothing to restore: stop watching the document now.\n if (!cycle.openerEligible) {\n finishFocusCycle(cycle)\n return\n }\n // Kobalte removes the `inert` / `aria-hidden` it put on the background\n // only after the layer unmounts; the observer below brings us back here.\n if (opener.closest('[inert], [aria-hidden=\"true\"]')) {\n if (cycle.deadlinePassed) finishFocusCycle(cycle)\n return\n }\n if (cycle.openerEligible && canRestoreFocus(opener)) {\n opener.focus({ preventScroll: true })\n }\n finishFocusCycle(cycle)\n })\n }\n\n const onOpenAutoFocus = (event: Event) => {\n const element = event.currentTarget\n if (element instanceof HTMLElement) {\n if (activeFocusCycle) finishFocusCycle(activeFocusCycle)\n\n const openerWasCaptured = pendingOpener !== null\n const opener = pendingOpener ?? document.activeElement\n const openerEligible = openerWasCaptured\n ? pendingOpenerEligible\n : opener instanceof HTMLElement && canRestoreFocus(opener)\n pendingOpener = null\n pendingOpenerEligible = false\n const openerElement = opener instanceof HTMLElement ? opener : null\n const cycle: FocusCycle = {\n content: element,\n opener: openerElement,\n openerEligible,\n closed: false,\n focusMovedOutside: false,\n closeAutoFocusScheduled: false,\n deadlinePassed: false,\n onFocusIn: (focusEvent) => {\n const target = focusEvent.target\n if (\n !(target instanceof HTMLElement) ||\n target === document.body ||\n target === document.documentElement\n ) {\n return\n }\n if (target === element || element.contains(target) || target === openerElement) {\n if (!cycle.closed) cycle.focusMovedOutside = false\n return\n }\n cycle.focusMovedOutside = true\n },\n }\n focusCycles.set(element, cycle)\n activeFocusCycle = cycle\n openLayers.add(element)\n document.addEventListener('focusin', cycle.onFocusIn)\n }\n options.onOpenAutoFocus?.(event)\n }\n\n const onCloseAutoFocus = (event: Event) => {\n const element = event.currentTarget\n const cycle = element instanceof HTMLElement ? focusCycles.get(element) : undefined\n options.onCloseAutoFocus?.(event)\n\n if (!cycle) return\n markClosed(cycle)\n\n // A caller that prevents Kobalte's close autofocus owns the focus decision.\n if (event.defaultPrevented) {\n finishFocusCycle(cycle)\n return\n }\n\n if (cycle.fallbackTimer !== undefined) {\n window.clearTimeout(cycle.fallbackTimer)\n cycle.fallbackTimer = undefined\n }\n cycle.closeAutoFocusScheduled = true\n cycle.observer = new MutationObserver(() => scheduleFocusRestore(cycle))\n cycle.observer.observe(document.body, {\n attributes: true,\n attributeFilter: ['aria-hidden', 'inert'],\n childList: true,\n subtree: true,\n })\n scheduleFocusRestore(cycle)\n // The observer watches every mutation in the document. If the opener stays\n // under an `inert` or `aria-hidden` that is not this layer's, nothing above\n // finishes the cycle, and a streaming page would schedule a frame per DOM\n // change for good. Kobalte clears its own markers within a frame or two.\n // The deadline stops the watching, not a restore already asked for: a busy\n // or throttled page (WebKit under load) can hold the frame past it.\n cycle.fallbackTimer = window.setTimeout(() => {\n cycle.fallbackTimer = undefined\n cycle.deadlinePassed = true\n cycle.observer?.disconnect()\n if (cycle.frame === undefined) finishFocusCycle(cycle)\n }, FOCUS_RESTORE_DEADLINE_MS)\n }\n\n onCleanup(() => {\n const cycle = activeFocusCycle\n if (!cycle) return\n markClosed(cycle)\n\n // Kobalte dispatches the close autofocus from a timer after unmount. If the\n // content never dispatches it, release the focus listener after that timer.\n queueMicrotask(() => {\n if (cycle.closeAutoFocusScheduled) return\n cycle.fallbackTimer = window.setTimeout(() => {\n cycle.fallbackTimer = undefined\n if (!cycle.closeAutoFocusScheduled) finishFocusCycle(cycle)\n }, 0)\n })\n })\n\n return { onOpenAutoFocus, onCloseAutoFocus }\n}\n\n/** The layer rules for a content rendered inside a Kobalte Dialog or AlertDialog root. */\nexport function createDialogLayer(options: DialogLayerOptions) {\n return createDialogFocusReturn(useDialogContext().isOpen, options)\n}\n\n/**\n * Lets an Escape swallowed by a tooltip inside the layer close the layer. The\n * content's own `onEscapeKeyDown` sees that Escape first, so a layer that\n * blocks Escape (a dirty form, a save in flight) stays blocked.\n */\nexport function DialogEscapeTarget(props: {\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n children?: JSX.Element\n}) {\n const dialog = useDialogContext()\n const dismiss = (event: KeyboardEvent) => {\n props.onEscapeKeyDown?.(event)\n if (!event.defaultPrevented) dialog.close()\n }\n return (\n <TooltipEscapeTargetContext.Provider value={{ element: dialog.contentRef, dismiss }}>\n {props.children}\n </TooltipEscapeTargetContext.Provider>\n )\n}\n"],"mappings":";;;;;;AA6CA,IAAMqB,6BAAa,IAAIC,IAAiB;AAExC,SAASC,UAAUC,SAAsB;CACvC,OAAOA,QAAQC,eAAeD,QAAQE,eAAe,CAAC,CAACC,SAAS;AAClE;AAEA,SAASC,gBAAgBC,QAA8B;CACrD,OACEA,WAAWC,SAASC,QACpBF,WAAWC,SAASE,mBACpB,CAACH,OAAOI,QAAQ,iCAA+B,KAC/C,CAACJ,OAAOK,QAAQ,WAAW,KAC3BX,UAAUM,MAAM;AAEpB;AAEA,SAASM,iBAAiB1B,SAAsBC,QAA8B;CAC5E,KAAK,MAAM0B,SAASf,YAClB,IACEe,UAAU3B,WACV,CAACA,QAAQ4B,SAASD,KAAK,KACvB,CAACA,MAAMC,SAAS3B,MAAM,KACtB,CAAC0B,MAAMH,QAAQ,iCA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AACM,OAAO;EACZQ,WAAWR,KAAK;EAIhB8B,qBAAqB;GACnB,IAAI9B,MAAMpC,yBAAyB;GACnCoC,MAAMjC,gBAAgBmC,OAAO2B,iBAAiB;IAC5C7B,MAAMjC,gBAAgBkC,KAAAA;IACtB,IAAI,CAACD,MAAMpC,yBAAyBmC,iBAAiBC,KAAK;GAC5D,GAAG,CAAC;EACN,CAAC;CACH,CAAC;CAED,OAAO;EAAE3C;EAAiBC;CAAiB;AAC7C;;AAGA,SAAgByE,kBAAkBxC,SAA6B;CAC7D,OAAOF,wBAAwBvC,iBAAiB,CAAC,CAACkF,QAAQzC,OAAO;AACnE;;;;;;AAOA,SAAgB0C,mBAAmBC,OAGhC;CACD,MAAMG,SAASvF,iBAAiB;CAChC,MAAMwF,WAAWpF,UAAyB;EACxCgF,MAAMC,kBAAkBjF,KAAK;EAC7B,IAAI,CAACA,MAAMqE,kBAAkBc,OAAOE,MAAM;CAC5C;CACA,OAAAC,gBACGvF,2BAA2BwF,UAAQ;EAAA,IAACC,QAAK;GAAA,OAAE;IAAEpE,SAAS+D,OAAOM;IAAYL;GAAQ;EAAC;EAAA,IAAAF,WAAA;GAAA,OAChFF,MAAME;EAAQ;CAAA,CAAA;AAGrB"}
|
|
1
|
+
{"version":3,"file":"dialog-layer.js","names":["useDialogContext","createRenderEffect","onCleanup","TooltipEscapeTargetContext","event","restoreFocusRef","HTMLElement","onOpenAutoFocus","onCloseAutoFocus","content","opener","openerEligible","closed","focusMovedOutside","closeAutoFocusScheduled","hiddenFrames","frame","fallbackTimer","observer","MutationObserver","onFocusIn","openLayers","Set","isVisible","element","isConnected","getClientRects","length","canRestoreFocus","target","document","body","documentElement","closest","matches","anotherLayerOpen","layer","contains","FOCUS_RESTORE_FRAME_BUDGET","createDialogFocusReturn","open","options","focusCycles","WeakMap","activeFocusCycle","pendingOpener","pendingOpenerEligible","active","activeElement","finishFocusCycle","cycle","undefined","window","cancelAnimationFrame","clearTimeout","disconnect","removeEventListener","delete","markClosed","scheduleFocusRestore","requestAnimationFrame","focusIsAvailable","Node","focus","preventScroll","currentTarget","openerWasCaptured","openerElement","focusEvent","set","add","addEventListener","get","defaultPrevented","observe","attributes","attributeFilter","childList","subtree","queueMicrotask","setTimeout","createDialogLayer","isOpen","DialogEscapeTarget","props","onEscapeKeyDown","children","dialog","dismiss","close","_$createComponent","Provider","value","contentRef"],"sources":["../../../../src/components/ui/dialog/dialog-layer.tsx"],"sourcesContent":["import { useDialogContext } from '@kobalte/core/dialog'\nimport type { Accessor, JSX } from 'solid-js'\nimport { createRenderEffect, onCleanup } from 'solid-js'\nimport { TooltipEscapeTargetContext } from '../tooltip/tooltip'\n\n/**\n * The rules the kit's dialog-shaped layers share, so a caller never wires them\n * by hand:\n *\n * 1. Focus returns to whatever had it before the layer opened. Kobalte only\n * returns focus to its own `Trigger`; a controlled layer opened from a menu\n * row, a shortcut or another layer would otherwise drop focus on `<body>`.\n * Dialog, AlertDialog, Sheet and the command palette.\n * 2. An Escape that a tooltip inside the layer swallowed still closes the layer\n * (see `TooltipEscapeTargetContext`). Dialog, AlertDialog and Sheet only;\n * the command palette does not provide it.\n *\n * Private to the overlay kit: content components apply it; callers pass\n * `restoreFocusRef` when the opener is gone by the time the layer opens.\n */\n\ntype AutoFocusHandler = (event: Event) => void\n\nexport type DialogLayerOptions = {\n restoreFocusRef?: Accessor<HTMLElement | undefined>\n onOpenAutoFocus?: AutoFocusHandler\n onCloseAutoFocus?: AutoFocusHandler\n}\n\ntype FocusCycle = {\n content: HTMLElement\n opener: HTMLElement | null\n openerEligible: boolean\n closed: boolean\n focusMovedOutside: boolean\n closeAutoFocusScheduled: boolean\n /** Restore frames that found the opener still hidden; see FOCUS_RESTORE_FRAME_BUDGET. */\n hiddenFrames: number\n frame?: number\n fallbackTimer?: number\n observer?: MutationObserver\n onFocusIn: (event: FocusEvent) => void\n}\n\n/** The kit's dialog layers that are open now, so a closing layer can tell a newer one took over. */\nconst openLayers = new Set<HTMLElement>()\n\nfunction isVisible(element: HTMLElement) {\n return element.isConnected && element.getClientRects().length > 0\n}\n\nfunction canRestoreFocus(target: HTMLElement): boolean {\n return (\n target !== document.body &&\n target !== document.documentElement &&\n !target.closest('[inert], [aria-hidden=\"true\"]') &&\n !target.matches(':disabled') &&\n isVisible(target)\n )\n}\n\nfunction anotherLayerOpen(content: HTMLElement, opener: HTMLElement): boolean {\n for (const layer of openLayers) {\n if (\n layer !== content &&\n !content.contains(layer) &&\n !layer.contains(opener) &&\n !layer.closest('[aria-hidden=\"true\"], [inert]') &&\n isVisible(layer)\n ) {\n return true\n }\n }\n return false\n}\n\n/**\n * The focus-return half of the layer rules, for a layer whose open state is\n * `open`. Returns the autofocus handlers to give the Kobalte content.\n */\n/**\n * How many restore frames a closed layer may spend on an opener that is still\n * hidden. It counts frames, not time: Kobalte clears its own markers when the\n * overlay finishes unmounting, which on a loaded machine (WebKit in CI) can be\n * well over a second, and a frame count slows down with the page.\n */\nconst FOCUS_RESTORE_FRAME_BUDGET = 120\n\nexport function createDialogFocusReturn(\n open: Accessor<boolean>,\n options: DialogLayerOptions\n): { onOpenAutoFocus: AutoFocusHandler; onCloseAutoFocus: AutoFocusHandler } {\n const focusCycles = new WeakMap<HTMLElement, FocusCycle>()\n let activeFocusCycle: FocusCycle | undefined\n let pendingOpener: HTMLElement | null = null\n let pendingOpenerEligible = false\n\n // Captured while the open state changes, before Kobalte's effects move focus\n // into the layer and before a closing menu takes its row out of the page.\n createRenderEffect(() => {\n if (!open() || typeof document === 'undefined') {\n pendingOpener = null\n pendingOpenerEligible = false\n return\n }\n const active = options.restoreFocusRef?.() ?? document.activeElement\n pendingOpener = active instanceof HTMLElement ? active : null\n pendingOpenerEligible = active instanceof HTMLElement && canRestoreFocus(active)\n })\n\n const finishFocusCycle = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) window.cancelAnimationFrame(cycle.frame)\n if (cycle.fallbackTimer !== undefined) window.clearTimeout(cycle.fallbackTimer)\n cycle.observer?.disconnect()\n document.removeEventListener('focusin', cycle.onFocusIn)\n openLayers.delete(cycle.content)\n if (activeFocusCycle === cycle) activeFocusCycle = undefined\n }\n\n const markClosed = (cycle: FocusCycle) => {\n cycle.closed = true\n openLayers.delete(cycle.content)\n }\n\n const scheduleFocusRestore = (cycle: FocusCycle) => {\n if (cycle.frame !== undefined) return\n cycle.frame = window.requestAnimationFrame(() => {\n cycle.frame = undefined\n const opener = cycle.opener\n const active = document.activeElement\n const focusIsAvailable =\n active === document.body ||\n active === document.documentElement ||\n active === cycle.content ||\n (active instanceof Node && cycle.content.contains(active))\n if (\n activeFocusCycle !== cycle ||\n !cycle.closed ||\n cycle.focusMovedOutside ||\n !opener ||\n !isVisible(opener) ||\n opener.matches(':disabled') ||\n !focusIsAvailable ||\n anotherLayerOpen(cycle.content, opener)\n ) {\n finishFocusCycle(cycle)\n return\n }\n\n // Nothing to restore: stop watching the document now.\n if (!cycle.openerEligible) {\n finishFocusCycle(cycle)\n return\n }\n // Kobalte removes the `inert` / `aria-hidden` it put on the background\n // only after the layer unmounts; the observer below brings us back here.\n if (opener.closest('[inert], [aria-hidden=\"true\"]')) {\n cycle.hiddenFrames += 1\n if (cycle.hiddenFrames >= FOCUS_RESTORE_FRAME_BUDGET) finishFocusCycle(cycle)\n return\n }\n if (cycle.openerEligible && canRestoreFocus(opener)) {\n opener.focus({ preventScroll: true })\n }\n finishFocusCycle(cycle)\n })\n }\n\n const onOpenAutoFocus = (event: Event) => {\n const element = event.currentTarget\n if (element instanceof HTMLElement) {\n if (activeFocusCycle) finishFocusCycle(activeFocusCycle)\n\n const openerWasCaptured = pendingOpener !== null\n const opener = pendingOpener ?? document.activeElement\n const openerEligible = openerWasCaptured\n ? pendingOpenerEligible\n : opener instanceof HTMLElement && canRestoreFocus(opener)\n pendingOpener = null\n pendingOpenerEligible = false\n const openerElement = opener instanceof HTMLElement ? opener : null\n const cycle: FocusCycle = {\n content: element,\n opener: openerElement,\n openerEligible,\n closed: false,\n focusMovedOutside: false,\n closeAutoFocusScheduled: false,\n hiddenFrames: 0,\n onFocusIn: (focusEvent) => {\n const target = focusEvent.target\n if (\n !(target instanceof HTMLElement) ||\n target === document.body ||\n target === document.documentElement\n ) {\n return\n }\n if (target === element || element.contains(target) || target === openerElement) {\n if (!cycle.closed) cycle.focusMovedOutside = false\n return\n }\n cycle.focusMovedOutside = true\n },\n }\n focusCycles.set(element, cycle)\n activeFocusCycle = cycle\n openLayers.add(element)\n document.addEventListener('focusin', cycle.onFocusIn)\n }\n options.onOpenAutoFocus?.(event)\n }\n\n const onCloseAutoFocus = (event: Event) => {\n const element = event.currentTarget\n const cycle = element instanceof HTMLElement ? focusCycles.get(element) : undefined\n options.onCloseAutoFocus?.(event)\n\n if (!cycle) return\n markClosed(cycle)\n\n // A caller that prevents Kobalte's close autofocus owns the focus decision.\n if (event.defaultPrevented) {\n finishFocusCycle(cycle)\n return\n }\n\n if (cycle.fallbackTimer !== undefined) {\n window.clearTimeout(cycle.fallbackTimer)\n cycle.fallbackTimer = undefined\n }\n cycle.closeAutoFocusScheduled = true\n cycle.observer = new MutationObserver(() => scheduleFocusRestore(cycle))\n cycle.observer.observe(document.body, {\n attributes: true,\n attributeFilter: ['aria-hidden', 'inert'],\n childList: true,\n subtree: true,\n })\n // The observer watches every mutation in the document. If the opener stays\n // under an `inert` or `aria-hidden` that is not this layer's, a streaming\n // page would schedule a frame per DOM change for good, so the frames that\n // find it hidden are capped. A quiet page schedules none while it waits.\n scheduleFocusRestore(cycle)\n }\n\n onCleanup(() => {\n const cycle = activeFocusCycle\n if (!cycle) return\n markClosed(cycle)\n\n // Kobalte dispatches the close autofocus from a timer after unmount. If the\n // content never dispatches it, release the focus listener after that timer.\n queueMicrotask(() => {\n if (cycle.closeAutoFocusScheduled) return\n cycle.fallbackTimer = window.setTimeout(() => {\n cycle.fallbackTimer = undefined\n if (!cycle.closeAutoFocusScheduled) finishFocusCycle(cycle)\n }, 0)\n })\n })\n\n return { onOpenAutoFocus, onCloseAutoFocus }\n}\n\n/** The layer rules for a content rendered inside a Kobalte Dialog or AlertDialog root. */\nexport function createDialogLayer(options: DialogLayerOptions) {\n return createDialogFocusReturn(useDialogContext().isOpen, options)\n}\n\n/**\n * Lets an Escape swallowed by a tooltip inside the layer close the layer. The\n * content's own `onEscapeKeyDown` sees that Escape first, so a layer that\n * blocks Escape (a dirty form, a save in flight) stays blocked.\n */\nexport function DialogEscapeTarget(props: {\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n children?: JSX.Element\n}) {\n const dialog = useDialogContext()\n const dismiss = (event: KeyboardEvent) => {\n props.onEscapeKeyDown?.(event)\n if (!event.defaultPrevented) dialog.close()\n }\n return (\n <TooltipEscapeTargetContext.Provider value={{ element: dialog.contentRef, dismiss }}>\n {props.children}\n </TooltipEscapeTargetContext.Provider>\n )\n}\n"],"mappings":";;;;;;AA6CA,IAAMqB,6BAAa,IAAIC,IAAiB;AAExC,SAASC,UAAUC,SAAsB;CACvC,OAAOA,QAAQC,eAAeD,QAAQE,eAAe,CAAC,CAACC,SAAS;AAClE;AAEA,SAASC,gBAAgBC,QAA8B;CACrD,OACEA,WAAWC,SAASC,QACpBF,WAAWC,SAASE,mBACpB,CAACH,OAAOI,QAAQ,iCAA+B,KAC/C,CAACJ,OAAOK,QAAQ,WAAW,KAC3BX,UAAUM,MAAM;AAEpB;AAEA,SAASM,iBAAiB1B,SAAsBC,QAA8B;CAC5E,KAAK,MAAM0B,SAASf,YAClB,IACEe,UAAU3B,WACV,CAACA,QAAQ4B,SAASD,KAAK,KACvB,CAACA,MAAMC,SAAS3B,MAAM,KACtB,CAAC0B,MAAMH,QAAQ,iCAA+B,KAC9CV,UAAUa,KAAK,GAEf,OAAO;CAGX,OAAO;AACT;;;;;;;;;;;AAYA,IAAME,6BAA6B;AAEnC,SAAgBC,wBACdC,MACAC,SAC2E;CAC3E,MAAMC,8BAAc,IAAIC,QAAiC;CACzD,IAAIC;CACJ,IAAIC,gBAAoC;CACxC,IAAIC,wBAAwB;CAI5B7C,y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