@lostgradient/cinder 0.25.1 → 0.26.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/CHANGELOG.md +227 -0
- package/components.json +13 -6
- package/dist/components/alert-dialog/index.js +2 -2
- package/dist/components/approval-card/index.js +2 -2
- package/dist/components/area-chart/index.js +2 -2
- package/dist/components/autocomplete/index.js +2 -2
- package/dist/components/avatar-group/index.js +2 -2
- package/dist/components/backdrop/index.js +2 -2
- package/dist/components/bar-chart/index.js +2 -2
- package/dist/components/button/button.css +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/code-block/index.js +2 -2
- package/dist/components/color-field/index.js +2 -2
- package/dist/components/combobox/index.js +2 -2
- package/dist/components/command-menu/index.js +2 -2
- package/dist/components/command-palette/command-palette.css +50 -46
- package/dist/components/command-palette/index.js +2 -2
- package/dist/components/confirm-dialog/index.js +2 -2
- package/dist/components/context-menu/index.js +2 -2
- package/dist/components/data-table/index.js +2 -2
- package/dist/components/date-picker/index.js +2 -2
- package/dist/components/date-range-field/index.js +2 -2
- package/dist/components/drawer/index.js +2 -2
- package/dist/components/dropdown/index.js +2 -2
- package/dist/components/dropdown-menu/index.js +2 -2
- package/dist/components/find-bar/find-bar.css +9 -1
- package/dist/components/focus-trap/index.js +2 -2
- package/dist/components/form-field/index.js +2 -2
- package/dist/components/hover-card/index.js +2 -2
- package/dist/components/inline-confirm/index.js +2 -2
- package/dist/components/input/index.js +2 -2
- package/dist/components/input/input.css +95 -6
- package/dist/components/invocation-rule-builder/index.js +2 -2
- package/dist/components/json-editor/index.js +2 -2
- package/dist/components/json-schema-editor/index.js +4 -4
- package/dist/components/key-value-editor/index.css +1 -1
- package/dist/components/line-chart/index.js +2 -2
- package/dist/components/matrix-chart/index.js +2 -2
- package/dist/components/menu-bar/index.js +3 -3
- package/dist/components/modal/index.js +2 -2
- package/dist/components/modal-region/index.css +1 -1
- package/dist/components/multi-select/index.js +2 -2
- package/dist/components/navigation-bar/index.js +2 -2
- package/dist/components/parameter-field/index.js +2 -2
- package/dist/components/permission-matrix/index.js +2 -2
- package/dist/components/policy-lock/index.js +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/radio-group/index.js +2 -2
- package/dist/components/schedule-builder/index.js +2 -2
- package/dist/components/schema-form/index.js +2 -2
- package/dist/components/scroll-area/index.js +2 -2
- package/dist/components/select/index.js +2 -2
- package/dist/components/selection-popover/index.js +2 -2
- package/dist/components/share-card/index.js +2 -2
- package/dist/components/sidebar/index.js +2 -2
- package/dist/components/speed-dial/index.js +2 -2
- package/dist/components/statistic-group/index.js +2 -2
- package/dist/components/statistic-group/statistic-group.css +116 -66
- package/dist/components/table/index.js +2 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/time-field/index.js +2 -2
- package/dist/components/time-field/time-field.css +9 -8
- package/dist/components/toast-region/index.js +2 -2
- package/dist/components/tooltip/index.js +2 -2
- package/dist/components/transfer-list/index.js +2 -2
- package/dist/components/virtual-list/_internal/adaptive-overscan.d.ts +87 -0
- package/dist/components/virtual-list/_internal/edge-proximity.d.ts +75 -0
- package/dist/components/virtual-list/_internal/frame-scheduler.d.ts +76 -0
- package/dist/components/virtual-list/_internal/geometry.d.ts +170 -0
- package/dist/components/virtual-list/_internal/list-semantics.d.ts +93 -0
- package/dist/components/virtual-list/_internal/measurement-window.d.ts +125 -0
- package/dist/components/virtual-list/_internal/reverse-order.d.ts +87 -0
- package/dist/components/virtual-list/_internal/scroll-restoration.d.ts +98 -0
- package/dist/components/virtual-list/_internal/sticky-items.d.ts +48 -0
- package/dist/components/virtual-list/_internal/virtual-list-measurement-store.svelte.d.ts +69 -0
- package/dist/components/virtual-list/index.d.ts +1 -1
- package/dist/components/virtual-list/index.js +2 -2
- package/dist/components/virtual-list/virtual-list.css +153 -0
- package/dist/components/virtual-list/virtual-list.schema.js +69 -6
- package/dist/components/virtual-list/virtual-list.svelte.d.ts +11 -8
- package/dist/components/virtual-list/virtual-list.types.d.ts +177 -4
- package/dist/index.browser.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -18
- package/dist/server/components/alert-dialog/index.js +1 -1
- package/dist/server/components/approval-card/index.js +1 -1
- package/dist/server/components/area-chart/index.js +1 -1
- package/dist/server/components/autocomplete/index.js +1 -1
- package/dist/server/components/avatar-group/index.js +1 -1
- package/dist/server/components/backdrop/index.js +1 -1
- package/dist/server/components/bar-chart/index.js +1 -1
- package/dist/server/components/checkbox/index.js +1 -1
- package/dist/server/components/code-block/index.js +1 -1
- package/dist/server/components/color-field/index.js +1 -1
- package/dist/server/components/combobox/index.js +1 -1
- package/dist/server/components/command-menu/index.js +1 -1
- package/dist/server/components/command-palette/index.js +2 -2
- package/dist/server/components/confirm-dialog/index.js +1 -1
- package/dist/server/components/context-menu/index.js +1 -1
- package/dist/server/components/data-table/index.js +1 -1
- package/dist/server/components/date-picker/index.js +1 -1
- package/dist/server/components/date-range-field/index.js +1 -1
- package/dist/server/components/drawer/index.js +1 -1
- package/dist/server/components/dropdown/index.js +1 -1
- package/dist/server/components/dropdown-menu/index.js +2 -2
- package/dist/server/components/focus-trap/index.js +1 -1
- package/dist/server/components/form-field/index.js +1 -1
- package/dist/server/components/hover-card/index.js +1 -1
- package/dist/server/components/inline-confirm/index.js +1 -1
- package/dist/server/components/input/index.js +1 -1
- package/dist/server/components/invocation-rule-builder/index.js +1 -1
- package/dist/server/components/json-editor/index.js +1 -1
- package/dist/server/components/json-schema-editor/index.js +1 -1
- package/dist/server/components/line-chart/index.js +1 -1
- package/dist/server/components/matrix-chart/index.js +1 -1
- package/dist/server/components/menu-bar/index.js +2 -2
- package/dist/server/components/modal/index.js +1 -1
- package/dist/server/components/multi-select/index.js +1 -1
- package/dist/server/components/navigation-bar/index.js +2 -2
- package/dist/server/components/parameter-field/index.js +1 -1
- package/dist/server/components/permission-matrix/index.js +1 -1
- package/dist/server/components/policy-lock/index.js +1 -1
- package/dist/server/components/popover/index.js +1 -1
- package/dist/server/components/radio-group/index.js +1 -1
- package/dist/server/components/schedule-builder/index.js +1 -1
- package/dist/server/components/schema-form/index.js +1 -1
- package/dist/server/components/scroll-area/index.js +1 -1
- package/dist/server/components/select/index.js +1 -1
- package/dist/server/components/selection-popover/index.js +1 -1
- package/dist/server/components/share-card/index.js +1 -1
- package/dist/server/components/sidebar/index.js +1 -1
- package/dist/server/components/speed-dial/index.js +2 -2
- package/dist/server/components/statistic-group/index.js +1 -1
- package/dist/server/components/table/index.js +1 -1
- package/dist/server/components/textarea/index.js +1 -1
- package/dist/server/components/time-field/index.js +1 -1
- package/dist/server/components/toast-region/index.js +1 -1
- package/dist/server/components/tooltip/index.js +1 -1
- package/dist/server/components/transfer-list/index.js +1 -1
- package/dist/server/components/virtual-list/index.js +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/{index.server-skq0f5sr.js → index.server-0jw25w9w.js} +1 -1
- package/dist/server/index.server-0kk20wvp.js +4 -0
- package/dist/server/{index.server-fzsqdajc.js → index.server-2awq6q9m.js} +1 -1
- package/dist/server/{index.server-e4hmhaeh.js → index.server-3xwvw6w2.js} +3 -3
- package/dist/server/{index.server-95h7xy01.js → index.server-428dh2t9.js} +2 -2
- package/dist/server/{index.server-jd88r74m.js → index.server-5dq66aja.js} +2 -2
- package/dist/server/{index.server-dvwfhf77.js → index.server-5s94r0kk.js} +2 -2
- package/dist/server/{index.server-qv6z5ta3.js → index.server-80qgcjnm.js} +1 -1
- package/dist/server/{index.server-7k2732ky.js → index.server-81abtrsw.js} +1 -1
- package/dist/server/{index.server-csmqnx5w.js → index.server-83q1gv2c.js} +1 -1
- package/dist/server/{index.server-qw8k9rjg.js → index.server-8fyav10d.js} +1 -1
- package/dist/server/{index.server-4dgjj4k1.js → index.server-8h5caecr.js} +2 -2
- package/dist/server/{index.server-emyqytmm.js → index.server-90n8sd9e.js} +1 -1
- package/dist/server/{index.server-0xrdyzvh.js → index.server-99penx1m.js} +1 -1
- package/dist/server/{index.server-p94j3jah.js → index.server-9g9d15z1.js} +1 -1
- package/dist/server/{index.server-xp9hkc81.js → index.server-9kbdx511.js} +1 -1
- package/dist/server/index.server-a2yhk45s.js +3 -0
- package/dist/server/{index.server-g8d2m2tk.js → index.server-acq55gjs.js} +1 -1
- package/dist/server/{index.server-ewze54tv.js → index.server-afjftjmr.js} +1 -1
- package/dist/server/{index.server-ejyye4gv.js → index.server-bfed6a8a.js} +1 -1
- package/dist/server/{index.server-z5ng08q2.js → index.server-c1746s0z.js} +1 -1
- package/dist/server/{index.server-gt1tfc1w.js → index.server-dmeztywe.js} +1 -1
- package/dist/server/{index.server-kzsppq0n.js → index.server-dyj3jdx9.js} +1 -1
- package/dist/server/index.server-dz92zvx6.js +4 -0
- package/dist/server/{index.server-3md8kdcr.js → index.server-e6682k08.js} +1 -1
- package/dist/server/{index.server-t1pshh65.js → index.server-ewkv461x.js} +1 -1
- package/dist/server/{index.server-zfgwhtmp.js → index.server-fa449wd3.js} +1 -1
- package/dist/server/{index.server-1kgwayct.js → index.server-fhfypmgw.js} +1 -1
- package/dist/server/{index.server-s4z8hsby.js → index.server-ge4adxs2.js} +1 -1
- package/dist/server/{index.server-68xyfsg3.js → index.server-gggkq22y.js} +2 -2
- package/dist/server/{index.server-acgwdamx.js → index.server-j52rbk57.js} +1 -1
- package/dist/server/{index.server-z0nwftx6.js → index.server-jm89hxfb.js} +1 -1
- package/dist/server/{index.server-xa98r8p2.js → index.server-jw0v64se.js} +1 -1
- package/dist/server/index.server-m321p69g.js +3 -0
- package/dist/server/{index.server-xyervw3d.js → index.server-m7q2tc41.js} +1 -1
- package/dist/server/{index.server-tnrxy86j.js → index.server-mak7dmj2.js} +1 -1
- package/dist/server/{index.server-n5g5h5k1.js → index.server-mw5r2524.js} +1 -1
- package/dist/server/{index.server-caf7s6m7.js → index.server-nwq1cg55.js} +1 -1
- package/dist/server/{index.server-3wdvs0wr.js → index.server-p423fy4q.js} +2 -2
- package/dist/server/{index.server-ks7fvwxt.js → index.server-prk5syj2.js} +1 -1
- package/dist/server/{index.server-6w9fp018.js → index.server-q4hytsq3.js} +1 -1
- package/dist/server/{index.server-5w2qw8fm.js → index.server-q597a1ck.js} +1 -1
- package/dist/server/{index.server-fz1pkvda.js → index.server-qgne9v2w.js} +1 -1
- package/dist/server/{index.server-1f2app32.js → index.server-rvdavf92.js} +1 -1
- package/dist/server/index.server-rwq20a22.js +3 -0
- package/dist/server/{index.server-0rvmnrw2.js → index.server-s9tjs45r.js} +1 -1
- package/dist/server/{index.server-cm2prec7.js → index.server-sqgxyfsw.js} +1 -1
- package/dist/server/{index.server-v6777tgn.js → index.server-t761nwvb.js} +1 -1
- package/dist/server/index.server-tbds8nwq.js +4 -0
- package/dist/server/index.server-tyhta5n3.js +3 -0
- package/dist/server/{index.server-yw7rah51.js → index.server-v5dxham4.js} +1 -1
- package/dist/server/index.server-va98cpyf.js +3 -0
- package/dist/server/index.server-vq1k69xt.js +3 -0
- package/dist/server/{index.server-egd355s6.js → index.server-wnf9btp7.js} +2 -2
- package/dist/server/{index.server-sjcbaztf.js → index.server-y3zgdtbv.js} +1 -1
- package/dist/server/{index.server-4tjtgzf9.js → index.server-y6vtbmyj.js} +1 -1
- package/dist/server/{index.server-2p2mjzzb.js → index.server-zff2qp1v.js} +1 -1
- package/dist/server/tokens/registry.generated.js +2 -2
- package/dist/tokens/registry.generated.js +2 -2
- package/package.json +2 -2
- package/src/_internal/form-field-frame.svelte +5 -0
- package/src/_internal/overlay.ts +14 -1
- package/src/components/_internal/create-command-list-state.svelte.ts +4 -0
- package/src/components/button/button.css +1 -1
- package/src/components/command-menu/command-menu.svelte +63 -7
- package/src/components/command-palette/command-palette.css +50 -46
- package/src/components/command-palette/command-palette.svelte +68 -78
- package/src/components/dropdown/dropdown.svelte +73 -18
- package/src/components/dropdown-menu/dropdown-menu.svelte +63 -7
- package/src/components/find-bar/find-bar.css +9 -1
- package/src/components/input/input.css +95 -6
- package/src/components/input/input.svelte +44 -81
- package/src/components/menu-bar/menu-bar.svelte +12 -1
- package/src/components/multi-select/multi-select.svelte +7 -0
- package/src/components/navigation-bar/navigation-bar.svelte +82 -6
- package/src/components/selection-popover/selection-popover.svelte +24 -10
- package/src/components/share-card/share-card.svelte +24 -44
- package/src/components/speed-dial/speed-dial.svelte +23 -5
- package/src/components/statistic-group/statistic-group.css +116 -66
- package/src/components/statistic-group/statistic-group.examples.json +6 -0
- package/src/components/statistic-group/statistic-group.svelte +13 -1
- package/src/components/time-field/time-field.css +9 -8
- package/src/components/toast-region/toast-region.svelte +9 -0
- package/src/components/virtual-list/_internal/adaptive-overscan.ts +248 -0
- package/src/components/virtual-list/_internal/edge-proximity.ts +130 -0
- package/src/components/virtual-list/_internal/frame-scheduler.ts +136 -0
- package/src/components/virtual-list/_internal/geometry.ts +236 -0
- package/src/components/virtual-list/_internal/list-semantics.ts +151 -0
- package/src/components/virtual-list/_internal/measurement-window.ts +300 -0
- package/src/components/virtual-list/_internal/reverse-order.ts +146 -0
- package/src/components/virtual-list/_internal/scroll-restoration.ts +209 -0
- package/src/components/virtual-list/_internal/sticky-items.ts +111 -0
- package/src/components/virtual-list/_internal/virtual-list-measurement-store.svelte.ts +145 -0
- package/src/components/virtual-list/index.ts +7 -1
- package/src/components/virtual-list/virtual-list.css +153 -0
- package/src/components/virtual-list/virtual-list.examples.json +42 -0
- package/src/components/virtual-list/virtual-list.schema.json +53 -3
- package/src/components/virtual-list/virtual-list.schema.ts +64 -3
- package/src/components/virtual-list/virtual-list.svelte +1527 -36
- package/src/components/virtual-list/virtual-list.types.ts +181 -4
- package/src/index.ts +3 -0
- package/src/styles/tokens-base.css +29 -21
- package/src/tokens/cinder.resolver.json +8 -0
- package/src/tokens/index.json +1 -1
- package/src/tokens/registry.generated.json +29 -3
- package/src/tokens/registry.generated.ts +31 -3
- package/src/tokens/resolved/dark-reduced-motion.json +46 -16
- package/src/tokens/resolved/dark.json +46 -16
- package/src/tokens/resolved/light-reduced-motion.json +47 -17
- package/src/tokens/resolved/light.json +47 -17
- package/src/tokens/sets/semantic.tokens.json +120 -30
- package/src/tokens/themes/dark.tokens.json +115 -19
- package/src/tokens/themes/light.tokens.json +51 -3
- package/dist/server/index.server-191cnacw.js +0 -3
- package/dist/server/index.server-25dqx151.js +0 -3
- package/dist/server/index.server-77jyqvbv.js +0 -4
- package/dist/server/index.server-bgjrzr70.js +0 -3
- package/dist/server/index.server-khsp90vh.js +0 -3
- package/dist/server/index.server-ryk2pgbe.js +0 -4
- package/dist/server/index.server-tajr81bm.js +0 -3
- package/dist/server/index.server-vjzcrw3d.js +0 -4
- package/dist/server/index.server-zg3fx1n1.js +0 -3
|
@@ -6,6 +6,7 @@ export {};
|
|
|
6
6
|
import { tick } from 'svelte';
|
|
7
7
|
import { createAnchoredOverlay } from '../../_internal/anchored-overlay.svelte.ts';
|
|
8
8
|
import { getLocaleContext } from '../../_internal/locale-context.ts';
|
|
9
|
+
import { pushEscapeHandler } from '../../_internal/overlay.ts';
|
|
9
10
|
import { observeTextDirection, resolveTextDirection } from '../../_internal/text-direction.ts';
|
|
10
11
|
import { classNames } from '../../utilities/class-names.ts';
|
|
11
12
|
import { findTypeaheadMatch, isTypeaheadKey, TypeaheadBuffer, } from '../../utilities/typeahead.ts';
|
|
@@ -107,17 +108,72 @@ function focusMenuItem(index) {
|
|
|
107
108
|
const item = items.at(resolvedIndex);
|
|
108
109
|
item?.focus();
|
|
109
110
|
}
|
|
111
|
+
// Escape ownership (CIN-428). The local, target-scoped Escape branch is
|
|
112
|
+
// deleted — the escape-stack registration below is the single Escape
|
|
113
|
+
// dispatch path, and it fires whenever this menu is open regardless of
|
|
114
|
+
// where focus sits. The `target.closest('[role="menu"]')` scoping in
|
|
115
|
+
// handleKeydown below still applies to ArrowDown/Up/Home/End/typeahead —
|
|
116
|
+
// Escape no longer needs it, since the shared stack itself arbitrates
|
|
117
|
+
// between nested/sibling overlays via LIFO ordering (MenuBar's staged
|
|
118
|
+
// submenu-then-menubar close falls out of this naturally: each open
|
|
119
|
+
// DropdownMenu instance — submenu, then top-level — registers separately,
|
|
120
|
+
// so the submenu's registration sits above the top-level's on the stack).
|
|
121
|
+
//
|
|
122
|
+
// Split by `context.supportsPopover`, mirroring dropdown.svelte's own
|
|
123
|
+
// legacy native-popover branch: the fallback (non-popover) path dismisses
|
|
124
|
+
// directly. The native-popover path must NOT call `preventDefault()` —
|
|
125
|
+
// doing so would cancel the browser's own Escape close-request for the
|
|
126
|
+
// top-layer `popover="auto"` element, leaving it visually open (and
|
|
127
|
+
// `ontoggle` never firing to sync `context.isOpen` back to false) even
|
|
128
|
+
// though this handler had already called `setOpen(false)`. Registering a
|
|
129
|
+
// no-op still matters: without an entry here, a lower escape-stack overlay
|
|
130
|
+
// would incorrectly react to the same keystroke, since the stack only
|
|
131
|
+
// invokes the top-most handler. The browser's native light-dismiss closes
|
|
132
|
+
// the popover on its own, and `handleToggle`'s `ontoggle` listener keeps
|
|
133
|
+
// `context.isOpen` in sync once it does.
|
|
134
|
+
function dismissMenu(event) {
|
|
135
|
+
event?.preventDefault();
|
|
136
|
+
event?.stopPropagation();
|
|
137
|
+
setOpen(false);
|
|
138
|
+
context.focusTrigger();
|
|
139
|
+
}
|
|
140
|
+
$effect(() => {
|
|
141
|
+
if (context.supportsPopover || !context.isOpen)
|
|
142
|
+
return;
|
|
143
|
+
const releaseEscape = pushEscapeHandler(dismissMenu);
|
|
144
|
+
return releaseEscape;
|
|
145
|
+
});
|
|
146
|
+
$effect(() => {
|
|
147
|
+
if (!context.supportsPopover || !context.isOpen)
|
|
148
|
+
return;
|
|
149
|
+
const releaseEscape = pushEscapeHandler((event) => {
|
|
150
|
+
// Still must not preventDefault (see above) — the browser's own
|
|
151
|
+
// Escape close-request is what actually hides the popover. It DOES
|
|
152
|
+
// still call stopPropagation(): the two are independent (propagation
|
|
153
|
+
// only controls whether the event keeps reaching other listeners in
|
|
154
|
+
// its path; only preventDefault() cancels the browser's own default
|
|
155
|
+
// action), so stopping propagation here is safe and is what keeps a
|
|
156
|
+
// focused descendant's own keydown listener, or a page-level Escape
|
|
157
|
+
// handler, from also reacting to the same keystroke while the
|
|
158
|
+
// top-most overlay's stack registration is supposed to own it.
|
|
159
|
+
event?.stopPropagation();
|
|
160
|
+
// Native focus restoration only returns focus to the invoker if focus
|
|
161
|
+
// was still *inside* the popover at the moment it closes; if focus had
|
|
162
|
+
// already moved outside (e.g. the user tabbed out while the menu was
|
|
163
|
+
// open), native restoration doesn't apply and focus would otherwise
|
|
164
|
+
// be left on whatever was outside — breaking dropdown.a11y.md's
|
|
165
|
+
// Escape-returns-focus-to-trigger contract. Restore it ourselves in
|
|
166
|
+
// that case only; when focus is still inside, leave it to native.
|
|
167
|
+
if (menuElement && !menuElement.contains(document.activeElement)) {
|
|
168
|
+
context.focusTrigger();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return releaseEscape;
|
|
172
|
+
});
|
|
110
173
|
function handleKeydown(event) {
|
|
111
174
|
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
112
175
|
if (target?.closest('[role="menu"]') !== menuElement)
|
|
113
176
|
return;
|
|
114
|
-
if (event.key === 'Escape') {
|
|
115
|
-
event.preventDefault();
|
|
116
|
-
event.stopPropagation();
|
|
117
|
-
setOpen(false);
|
|
118
|
-
context.focusTrigger();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
177
|
const itemsArray = getOwnedMenuItems();
|
|
122
178
|
if (!itemsArray.length)
|
|
123
179
|
return;
|
|
@@ -14,7 +14,15 @@
|
|
|
14
14
|
border-block-end: 1px solid var(--cinder-border-muted);
|
|
15
15
|
background: var(--cinder-surface-raised);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
/* Direct child, not a descendant selector: FindBar's own FormField renders
|
|
18
|
+
`.cinder-form-field` as a direct child of `.cinder-find-bar`, but since
|
|
19
|
+
CIN-511 the Input inside it *also* renders its own nested
|
|
20
|
+
`.cinder-form-field` (Input always frames itself when it has field
|
|
21
|
+
context now, with label/description/error simply absent). A descendant
|
|
22
|
+
selector would match that inner frame too, applying `flex`/
|
|
23
|
+
`min-inline-size` to it a second time inside the outer frame's own flex
|
|
24
|
+
column and distorting the row's layout. */
|
|
25
|
+
.cinder-find-bar > .cinder-form-field {
|
|
18
26
|
flex: 1 1 12rem;
|
|
19
27
|
min-inline-size: min(12rem, 100%);
|
|
20
28
|
}
|
|
@@ -6,6 +6,22 @@
|
|
|
6
6
|
* INPUT
|
|
7
7
|
* ======================================== */
|
|
8
8
|
|
|
9
|
+
/* One recipe for the invalid border's hover step, shared by the three
|
|
10
|
+
* surfaces that can paint that edge: the bare input, the host wrapper that
|
|
11
|
+
* takes ownership when an addon appears, and the group. Deriving it three
|
|
12
|
+
* times over is what pushed this file past its raw-color allowance, and a
|
|
13
|
+
* single declaration keeps the three in step by construction — they are the
|
|
14
|
+
* same edge, and a divergence between them would be a bug rather than a
|
|
15
|
+
* choice.
|
|
16
|
+
*/
|
|
17
|
+
.cinder-input,
|
|
18
|
+
.cinder-input-host,
|
|
19
|
+
.cinder-input-group {
|
|
20
|
+
--_cinder-input-invalid-border-hover: oklch(
|
|
21
|
+
from var(--cinder-status-danger-solid) calc(l - 0.06) c h
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
9
25
|
/* ----------------------------------------
|
|
10
26
|
* Field wrapper
|
|
11
27
|
* ---------------------------------------- */
|
|
@@ -168,7 +184,7 @@
|
|
|
168
184
|
|
|
169
185
|
@media (hover: hover) {
|
|
170
186
|
.cinder-input[aria-invalid='true']:hover:not(:disabled) {
|
|
171
|
-
border-color:
|
|
187
|
+
border-color: var(--_cinder-input-invalid-border-hover);
|
|
172
188
|
}
|
|
173
189
|
}
|
|
174
190
|
|
|
@@ -190,6 +206,64 @@
|
|
|
190
206
|
margin: 0;
|
|
191
207
|
}
|
|
192
208
|
|
|
209
|
+
/* ----------------------------------------
|
|
210
|
+
* Input host (no addons)
|
|
211
|
+
* ---------------------------------------- */
|
|
212
|
+
|
|
213
|
+
/* The control wrapper is always rendered so the native <input> keeps one
|
|
214
|
+
position in the tree when an addon appears or disappears (see
|
|
215
|
+
input.svelte). Without addons the wrapper is `.cinder-input-host` instead of
|
|
216
|
+
`.cinder-input-group`, and `display: contents` removes its box: the input
|
|
217
|
+
takes part in the parent's layout exactly as a bare element did, so a
|
|
218
|
+
flex-row parent still sizes the input itself rather than a shrink-wrapped
|
|
219
|
+
div around it. The host still carries `data-cinder-full-width` so ancestors
|
|
220
|
+
that detect a full-width control by direct child (access-gate.css) keep
|
|
221
|
+
matching. */
|
|
222
|
+
.cinder-input-host {
|
|
223
|
+
display: contents;
|
|
224
|
+
/* The host and the group are the SAME element: when an addon appears the
|
|
225
|
+
class swaps, and `.cinder-input-group`'s border-color transition runs
|
|
226
|
+
from whatever the host computed. Pin the host's resting border colours
|
|
227
|
+
to the group's so the appearing border does not fade in from
|
|
228
|
+
`currentcolor` (the initial value). A boxless element paints nothing,
|
|
229
|
+
so these are inert until the swap. Same source order as the group's
|
|
230
|
+
state rules, so disabled wins over invalid here too. */
|
|
231
|
+
border-color: var(--cinder-border);
|
|
232
|
+
}
|
|
233
|
+
/* The host is hovered whenever the input inside it is (`:hover` matches an
|
|
234
|
+
ancestor of the hovered element even when that ancestor has no box), so
|
|
235
|
+
the hover colours are mirrored too — with the same precedence as the
|
|
236
|
+
group's rules below: invalid beats resting, hover beats both, disabled
|
|
237
|
+
beats everything. Sticky-hover suppression on touch, as for the group. */
|
|
238
|
+
@media (hover: hover) {
|
|
239
|
+
.cinder-input-host:hover:not([data-disabled]) {
|
|
240
|
+
border-color: var(--cinder-border-strong);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
.cinder-input-host[data-invalid] {
|
|
244
|
+
--_cinder-input-ring: var(--cinder-status-danger-solid);
|
|
245
|
+
border-color: var(--cinder-status-danger-solid);
|
|
246
|
+
}
|
|
247
|
+
@media (hover: hover) {
|
|
248
|
+
.cinder-input-host[data-invalid]:hover:not([data-disabled]) {
|
|
249
|
+
border-color: var(--_cinder-input-invalid-border-hover);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
.cinder-input-host[data-disabled] {
|
|
253
|
+
border-color: var(--cinder-border-muted);
|
|
254
|
+
}
|
|
255
|
+
/* Ring ownership moves from the input to the wrapper when an addon appears.
|
|
256
|
+
The host is boxless and paints nothing, but its computed box-shadow is
|
|
257
|
+
what the group's box-shadow transition would start from, so pin it to the
|
|
258
|
+
group's ring while the input inside is focused — the same token math as
|
|
259
|
+
`.cinder-input-group:focus-within` below. */
|
|
260
|
+
.cinder-input-host:focus-within {
|
|
261
|
+
box-shadow:
|
|
262
|
+
0 0 0 var(--cinder-ring-offset) var(--cinder-ring-offset-color),
|
|
263
|
+
0 0 0 calc(var(--cinder-ring-offset) + var(--cinder-ring-width))
|
|
264
|
+
var(--_cinder-input-ring, var(--cinder-ring-color));
|
|
265
|
+
}
|
|
266
|
+
|
|
193
267
|
/* ----------------------------------------
|
|
194
268
|
* Input group (leading / trailing addons)
|
|
195
269
|
* ---------------------------------------- */
|
|
@@ -207,14 +281,29 @@
|
|
|
207
281
|
box-shadow var(--cinder-duration-fast) var(--cinder-ease-standard);
|
|
208
282
|
}
|
|
209
283
|
|
|
210
|
-
/* Inner input: strip its own chrome, inherit the group's
|
|
284
|
+
/* Inner input: strip its own chrome, inherit the group's. `border-style`
|
|
285
|
+
rather than the `border` shorthand: the shorthand would reset the input's
|
|
286
|
+
computed border-color to `currentcolor`, and because the input is the
|
|
287
|
+
same element before and after an addon is removed, its own border-color
|
|
288
|
+
transition would then run from the text colour when its border comes
|
|
289
|
+
back. Leaving the colour alone keeps it equal on both sides of the swap,
|
|
290
|
+
for the invalid and disabled states too. */
|
|
211
291
|
.cinder-input-group > .cinder-input {
|
|
212
|
-
border: none;
|
|
292
|
+
border-style: none;
|
|
213
293
|
border-radius: 0;
|
|
214
294
|
background: transparent;
|
|
215
295
|
flex: 1 1 auto;
|
|
216
296
|
min-width: 0;
|
|
217
297
|
padding-inline: var(--cinder-space-3);
|
|
298
|
+
/* The input keeps its own focus ring VALUE inside the group and the clip
|
|
299
|
+
hides it, rather than setting `box-shadow: none`: the input is the same
|
|
300
|
+
element before and after an addon is removed, and a value change would
|
|
301
|
+
run its box-shadow transition — the ring fading in while the group's
|
|
302
|
+
ring vanished. With the value unchanged and only the clip toggling
|
|
303
|
+
(not a transitioned property), ring ownership moves between the input
|
|
304
|
+
and the wrapper without any animation. The clip is the border box, so
|
|
305
|
+
nothing the input paints itself is affected. */
|
|
306
|
+
clip-path: inset(0);
|
|
218
307
|
}
|
|
219
308
|
|
|
220
309
|
/* When an addon is present on a given side, the input trims its padding on
|
|
@@ -231,9 +320,9 @@
|
|
|
231
320
|
}
|
|
232
321
|
|
|
233
322
|
.cinder-input-group > .cinder-input:focus-visible {
|
|
234
|
-
box-shadow: none;
|
|
235
323
|
/* cinder-focus-ring-owner: parent — the .cinder-input-group wrapper paints
|
|
236
|
-
the ring for the whole grouped control
|
|
324
|
+
the ring for the whole grouped control; the input's own ring is clipped
|
|
325
|
+
away above, not zeroed, so the swap does not animate it. */
|
|
237
326
|
outline: none;
|
|
238
327
|
}
|
|
239
328
|
|
|
@@ -267,7 +356,7 @@
|
|
|
267
356
|
}
|
|
268
357
|
@media (hover: hover) {
|
|
269
358
|
.cinder-input-group--invalid:hover:not(.cinder-input-group--disabled) {
|
|
270
|
-
border-color:
|
|
359
|
+
border-color: var(--_cinder-input-invalid-border-hover);
|
|
271
360
|
}
|
|
272
361
|
}
|
|
273
362
|
|
|
@@ -38,6 +38,14 @@ const hasTrailing = $derived(!!trailing || isNativeDateInput);
|
|
|
38
38
|
const hasGroupWrapper = $derived(!!leading || hasTrailing);
|
|
39
39
|
const isInvalid = $derived(resolvedAriaInvalid === 'true');
|
|
40
40
|
const groupModifiers = $derived(classNames(leading && 'cinder-input-group--leading', hasTrailing && 'cinder-input-group--trailing', rendersNativeDateIcon && 'cinder-input-group--native-date', resolvedDisabled && 'cinder-input-group--disabled', isInvalid && 'cinder-input-group--invalid'));
|
|
41
|
+
// One class string for the control wrapper in both of its states. The
|
|
42
|
+
// wrapper itself is always rendered — via `controlClass` on FormFieldFrame's
|
|
43
|
+
// own `.cinder-form-field__control` div (see the `{#if context}` block
|
|
44
|
+
// below), so the two states differ only by class, never by a wrapper
|
|
45
|
+
// switching in or out.
|
|
46
|
+
const hostClass = $derived(hasGroupWrapper
|
|
47
|
+
? classNames('cinder-input-group', groupClassName, groupModifiers)
|
|
48
|
+
: 'cinder-input-host');
|
|
41
49
|
let inputNode = $state();
|
|
42
50
|
let resetSyncTimeout;
|
|
43
51
|
function syncValueAfterFormReset() {
|
|
@@ -112,51 +120,6 @@ function handleInput(event) {
|
|
|
112
120
|
/>
|
|
113
121
|
{/snippet}
|
|
114
122
|
|
|
115
|
-
{#snippet control()}
|
|
116
|
-
{#if hasGroupWrapper}
|
|
117
|
-
<div
|
|
118
|
-
class={classNames('cinder-input-group', groupClassName, groupModifiers)}
|
|
119
|
-
data-leading={leading ? '' : undefined}
|
|
120
|
-
data-trailing={hasTrailing ? '' : undefined}
|
|
121
|
-
data-native-date={rendersNativeDateIcon ? '' : undefined}
|
|
122
|
-
data-disabled={resolvedDisabled ? '' : undefined}
|
|
123
|
-
data-invalid={isInvalid ? '' : undefined}
|
|
124
|
-
data-cinder-full-width
|
|
125
|
-
>
|
|
126
|
-
{#if leading}
|
|
127
|
-
<span
|
|
128
|
-
class={classNames(
|
|
129
|
-
'cinder-input-group__leading',
|
|
130
|
-
!leadingInteractive && 'cinder-_truncate',
|
|
131
|
-
)}
|
|
132
|
-
aria-hidden={leadingInteractive ? undefined : 'true'}>{@render leading()}</span
|
|
133
|
-
>
|
|
134
|
-
{/if}
|
|
135
|
-
|
|
136
|
-
{@render inputElement()}
|
|
137
|
-
|
|
138
|
-
{#if trailing}
|
|
139
|
-
<span
|
|
140
|
-
class={classNames(
|
|
141
|
-
'cinder-input-group__trailing',
|
|
142
|
-
!trailingInteractive && 'cinder-_truncate',
|
|
143
|
-
)}
|
|
144
|
-
aria-hidden={trailingInteractive ? undefined : 'true'}>{@render trailing()}</span
|
|
145
|
-
>
|
|
146
|
-
{:else if rendersNativeDateIcon}
|
|
147
|
-
<span
|
|
148
|
-
class="cinder-input-group__trailing cinder-input-group__date-icon cinder-_truncate"
|
|
149
|
-
aria-hidden="true"
|
|
150
|
-
>
|
|
151
|
-
{@render calendarIcon()}
|
|
152
|
-
</span>
|
|
153
|
-
{/if}
|
|
154
|
-
</div>
|
|
155
|
-
{:else}
|
|
156
|
-
{@render inputElement()}
|
|
157
|
-
{/if}
|
|
158
|
-
{/snippet}
|
|
159
|
-
|
|
160
123
|
{#snippet leadingAdornment()}
|
|
161
124
|
{#if leading}
|
|
162
125
|
<span
|
|
@@ -180,37 +143,39 @@ function handleInput(event) {
|
|
|
180
143
|
{/snippet}
|
|
181
144
|
|
|
182
145
|
{#if context}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
{
|
|
213
|
-
|
|
146
|
+
<!-- Always render the nested frame here, even when label/description/error
|
|
147
|
+
are all unset — collapsing what used to be a second `{#if}` arm switch
|
|
148
|
+
between this frame and rendering the control snippet bare. Switching
|
|
149
|
+
arms as those props became truthy destroyed and recreated the native
|
|
150
|
+
<input> (same failure mode CIN-500 fixed one level up, for the
|
|
151
|
+
leading/trailing wrapper). label/description/error are simply
|
|
152
|
+
absent/undefined on the frame when unset, so there is exactly one code
|
|
153
|
+
path for the context-truthy case. See CIN-511. -->
|
|
154
|
+
<FormFieldFrame
|
|
155
|
+
{id}
|
|
156
|
+
label={context.labelId ? undefined : label}
|
|
157
|
+
{labelVisible}
|
|
158
|
+
{description}
|
|
159
|
+
{error}
|
|
160
|
+
required={resolvedRequired}
|
|
161
|
+
disabled={resolvedDisabled}
|
|
162
|
+
class="cinder-input-field"
|
|
163
|
+
data-cinder-variant={variant}
|
|
164
|
+
fullWidth
|
|
165
|
+
descriptionClass="cinder-input-field__description"
|
|
166
|
+
errorClass="cinder-input-field__error"
|
|
167
|
+
descriptionId={field.ownDescriptionId}
|
|
168
|
+
errorId={field.ownErrorId}
|
|
169
|
+
control={inputElement}
|
|
170
|
+
controlClass={hostClass}
|
|
171
|
+
controlLeading={!!leading}
|
|
172
|
+
controlTrailing={hasTrailing}
|
|
173
|
+
controlNativeDate={rendersNativeDateIcon}
|
|
174
|
+
controlDisabled={resolvedDisabled}
|
|
175
|
+
controlInvalid={isInvalid}
|
|
176
|
+
before={leadingAdornment}
|
|
177
|
+
after={trailingAdornment}
|
|
178
|
+
/>
|
|
214
179
|
{:else}
|
|
215
180
|
<FormFieldFrame
|
|
216
181
|
{id}
|
|
@@ -226,15 +191,13 @@ function handleInput(event) {
|
|
|
226
191
|
descriptionClass="cinder-input-field__description"
|
|
227
192
|
errorClass="cinder-input-field__error"
|
|
228
193
|
control={inputElement}
|
|
229
|
-
controlClass={
|
|
230
|
-
? classNames('cinder-input-group', groupClassName, groupModifiers)
|
|
231
|
-
: undefined}
|
|
194
|
+
controlClass={hostClass}
|
|
232
195
|
controlLeading={!!leading}
|
|
233
196
|
controlTrailing={hasTrailing}
|
|
234
197
|
controlNativeDate={rendersNativeDateIcon}
|
|
235
198
|
controlDisabled={resolvedDisabled}
|
|
236
199
|
controlInvalid={isInvalid}
|
|
237
|
-
before={
|
|
238
|
-
after={
|
|
200
|
+
before={leadingAdornment}
|
|
201
|
+
after={trailingAdornment}
|
|
239
202
|
/>
|
|
240
203
|
{/if}
|
|
@@ -419,7 +419,18 @@ function handleTriggerKeydown(event, index) {
|
|
|
419
419
|
// Only consume Escape when a menu or submenu is actually open. On a closed
|
|
420
420
|
// menubar item, swallowing Escape (preventDefault + a no-op closeAll) would
|
|
421
421
|
// block an enclosing overlay or page-level Escape handler from ever running.
|
|
422
|
-
|
|
422
|
+
//
|
|
423
|
+
// `defaultPrevented` guard (CIN-428 hazard): DropdownMenu's own
|
|
424
|
+
// escape-stack registration runs at the window capture phase, before this
|
|
425
|
+
// bubble-phase trigger listener ever sees the key. In the normal case it
|
|
426
|
+
// already preventDefault()s + stopPropagation()s, so this branch never
|
|
427
|
+
// even runs for that keystroke — this guard is defense-in-depth for any
|
|
428
|
+
// path where the event still reaches here with defaultPrevented already
|
|
429
|
+
// true, so this doesn't run a redundant/conflicting closeAll() on top of
|
|
430
|
+
// whatever the stack handler already did.
|
|
431
|
+
if (event.key === 'Escape' &&
|
|
432
|
+
!event.defaultPrevented &&
|
|
433
|
+
(openMenuIndex !== null || openSubmenuKey !== null)) {
|
|
423
434
|
event.preventDefault();
|
|
424
435
|
closeAll();
|
|
425
436
|
return;
|
|
@@ -212,6 +212,13 @@ function clearSelection(event) {
|
|
|
212
212
|
triggerElement?.focus();
|
|
213
213
|
}
|
|
214
214
|
function handleListNavigationKeydown(event) {
|
|
215
|
+
// Fallback-guard, matching Combobox's pattern (CIN-428): in a real
|
|
216
|
+
// browser the capture-phase escape-stack handler (registered via
|
|
217
|
+
// `commandList.bindDismissal` below) runs first and already
|
|
218
|
+
// preventDefault()s + stopPropagation()s — this bails rather than
|
|
219
|
+
// redundantly re-closing an already-closed menu.
|
|
220
|
+
if (event.key === 'Escape' && event.defaultPrevented)
|
|
221
|
+
return;
|
|
215
222
|
commandList.handleKeydown({
|
|
216
223
|
event,
|
|
217
224
|
onEnter: (itemId) => {
|
|
@@ -3,10 +3,11 @@ export {};
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import { onDestroy } from 'svelte';
|
|
6
|
+
import { flushSync, onDestroy } from 'svelte';
|
|
7
7
|
import { BROWSER as browser } from 'esm-env';
|
|
8
8
|
import { createAnchoredOverlay } from '../../_internal/anchored-overlay.svelte.ts';
|
|
9
9
|
import { createAnchoredOverlayExitState } from '../../_internal/anchored-overlay-exit.svelte.ts';
|
|
10
|
+
import { pushEscapeHandler } from '../../_internal/overlay.ts';
|
|
10
11
|
import { classNames } from '../../utilities/class-names.ts';
|
|
11
12
|
import { getSequentialFocusTargets, getTabIndexValue } from '../../utilities/focus.ts';
|
|
12
13
|
import { useReducedMotion } from '../../utilities/use-reduced-motion.svelte.ts';
|
|
@@ -399,6 +400,69 @@ function focusMenuToggle() {
|
|
|
399
400
|
const focusTarget = findFocusTargetBeforeNavigationItems(navigationBarElement, toggleElement, false);
|
|
400
401
|
focusTarget?.focus();
|
|
401
402
|
}
|
|
403
|
+
// Escape ownership (CIN-428). The escape-stack registration is the single
|
|
404
|
+
// Escape dispatch path, firing whenever the mobile panel is open
|
|
405
|
+
// regardless of focus location — so a dispatch that originates outside the
|
|
406
|
+
// bar's own DOM tree (`pressing Escape outside the navbar still closes the
|
|
407
|
+
// mobile menu`) still closes it, swallowing the key uniformly like every
|
|
408
|
+
// other escape-stack overlay.
|
|
409
|
+
//
|
|
410
|
+
// Escape dispatched *inside* the bar's tree is different: this handler
|
|
411
|
+
// runs at the window capture phase, which is necessarily reached before
|
|
412
|
+
// the event arrives at its actual target — before a nested control (a
|
|
413
|
+
// search field, a disclosure) or the consumer's own composed `<nav
|
|
414
|
+
// onkeydown>` ever sees it. Closing unconditionally here would make it
|
|
415
|
+
// impossible for either to call `preventDefault()` and cancel the close,
|
|
416
|
+
// contradicting the cooperative Escape contract in
|
|
417
|
+
// navigation-bar.a11y.md's "Cooperative Escape semantics" section. So for
|
|
418
|
+
// an in-tree target, stash the event and let it keep propagating — the
|
|
419
|
+
// decision happens in `handleKeyDown` below (the bar's own bubble-phase
|
|
420
|
+
// listener on `<nav>`), which runs *after* the target's own handler and
|
|
421
|
+
// the composed consumer handler, once `event.defaultPrevented` reflects
|
|
422
|
+
// their answer. Identity comparison against `pendingEscapeEvent` makes a
|
|
423
|
+
// stale stash harmless (it's only ever consulted for the exact event that
|
|
424
|
+
// set it).
|
|
425
|
+
let pendingEscapeEvent = null;
|
|
426
|
+
function closeMobilePanel(event) {
|
|
427
|
+
event?.preventDefault();
|
|
428
|
+
// Once the panel actually accepts the dismissal — whether immediately,
|
|
429
|
+
// for a dispatch outside the bar's tree, or after the deferred in-tree
|
|
430
|
+
// decision in `handleKeyDown` below — stop the key from leaking past
|
|
431
|
+
// here to unrelated ancestor keydown handlers (review findings from
|
|
432
|
+
// both Copilot and Codex). This still preserves the cooperative path
|
|
433
|
+
// above: propagation is only cut off once the close is decided, never
|
|
434
|
+
// before a nested control or the composed consumer handler got a look.
|
|
435
|
+
event?.stopPropagation();
|
|
436
|
+
mobileMenuOpen = false;
|
|
437
|
+
focusMenuToggle();
|
|
438
|
+
}
|
|
439
|
+
function dismissMobilePanel(event) {
|
|
440
|
+
const target = event?.target;
|
|
441
|
+
// The open mobile panel is portaled to `document.body` by default (no
|
|
442
|
+
// enclosing top layer to anchor to — see `itemsPortalScope` above), so a
|
|
443
|
+
// target inside it is no longer a DOM descendant of `navigationBarElement`
|
|
444
|
+
// once open. Check `itemsRegionElement` too: portaling re-parents that
|
|
445
|
+
// wrapper but never changes its own descendants, so this still correctly
|
|
446
|
+
// recognizes "inside the bar" regardless of where the wrapper currently
|
|
447
|
+
// sits. The original portaled-target event never reaches `handleKeyDown`
|
|
448
|
+
// directly (it isn't a DOM ancestor anymore), but `bridgePortaledEvents`
|
|
449
|
+
// below re-dispatches a bridged copy at `navigationBarElement` — which
|
|
450
|
+
// re-enters this same handler with a *new* event object, re-stashing
|
|
451
|
+
// `pendingEscapeEvent` to the one `handleKeyDown` will actually see.
|
|
452
|
+
if (event &&
|
|
453
|
+
target instanceof Node &&
|
|
454
|
+
(navigationBarElement?.contains(target) || itemsRegionElement?.contains(target))) {
|
|
455
|
+
pendingEscapeEvent = event;
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
closeMobilePanel(event);
|
|
459
|
+
}
|
|
460
|
+
$effect(() => {
|
|
461
|
+
if (!isCollapsible || !mobilePanelOpen)
|
|
462
|
+
return;
|
|
463
|
+
const releaseEscape = pushEscapeHandler(dismissMobilePanel);
|
|
464
|
+
return releaseEscape;
|
|
465
|
+
});
|
|
402
466
|
function getFocusTargetBeforeItems(navigationItem = null) {
|
|
403
467
|
return findFocusTargetBeforeNavigationItems(navigationBarElement, toggleElement, menuTogglePlacement === 'before-brand', navigationItem);
|
|
404
468
|
}
|
|
@@ -527,15 +591,27 @@ function handleKeyDown(event) {
|
|
|
527
591
|
if (consumerOnKeyDown) {
|
|
528
592
|
consumerOnKeyDown(withNavigationCurrentTarget(event));
|
|
529
593
|
}
|
|
594
|
+
// Resolve an Escape stashed by `dismissMobilePanel` above (CIN-428): by
|
|
595
|
+
// the time this bubble-phase listener on `<nav>` runs, any nested
|
|
596
|
+
// control's own keydown handler (fired at the target phase, before
|
|
597
|
+
// bubbling reaches here) and the consumer handler just above have both
|
|
598
|
+
// had their chance to call `preventDefault()`.
|
|
599
|
+
if (event.key === 'Escape' && pendingEscapeEvent === event) {
|
|
600
|
+
pendingEscapeEvent = null;
|
|
601
|
+
// `handleKeyDown` runs as a plain, un-flushed consequence of the DOM's
|
|
602
|
+
// own bubble-phase dispatch to <nav> (see overlay.ts's `onEscapeKeydown`
|
|
603
|
+
// for the same reasoning) — flush explicitly so a second Escape
|
|
604
|
+
// dispatched immediately afterward observes this close (and this
|
|
605
|
+
// handler's stack release) synchronously, matching the guarantee the
|
|
606
|
+
// shared escape stack gives every other overlay.
|
|
607
|
+
if (!event.defaultPrevented)
|
|
608
|
+
flushSync(() => closeMobilePanel(event));
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
530
611
|
if (event.defaultPrevented)
|
|
531
612
|
return;
|
|
532
613
|
if (bridgeBrandTabToPortaledPanel(event))
|
|
533
614
|
return;
|
|
534
|
-
if (event.key === 'Escape' && isCollapsible && isMobileLayout && mobileMenuOpen) {
|
|
535
|
-
mobileMenuOpen = false;
|
|
536
|
-
focusMenuToggle();
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
615
|
const navigationItem = getEventNavigationItem(event);
|
|
540
616
|
if (event.key === 'Tab' &&
|
|
541
617
|
event.target instanceof HTMLElement &&
|
|
@@ -6,6 +6,7 @@ export {};
|
|
|
6
6
|
import { onDestroy, tick } from 'svelte';
|
|
7
7
|
import { createAnchoredOverlay } from '../../_internal/anchored-overlay.svelte.ts';
|
|
8
8
|
import { createAnchoredOverlayExitState } from '../../_internal/anchored-overlay-exit.svelte.ts';
|
|
9
|
+
import { pushEscapeHandler } from '../../_internal/overlay.ts';
|
|
9
10
|
import { createClickOutside } from '../../utilities/attachments.ts';
|
|
10
11
|
import { classNames } from '../../utilities/class-names.ts';
|
|
11
12
|
import { useReducedMotion } from '../../utilities/use-reduced-motion.svelte.ts';
|
|
@@ -249,17 +250,30 @@ function handleSubmit() {
|
|
|
249
250
|
commentBody = '';
|
|
250
251
|
restoreFocus();
|
|
251
252
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
// Escape ownership (CIN-428). The shared internal function below holds the
|
|
254
|
+
// dismiss logic — expanded-restore/cancel first stage, else close — and
|
|
255
|
+
// the escape-stack registration further down is the ONLY caller: this is
|
|
256
|
+
// no longer duplicated as a local `onkeydown` branch, so it fires
|
|
257
|
+
// regardless of where focus sits while the popover is open, not just
|
|
258
|
+
// while focus is inside its own DOM tree.
|
|
259
|
+
function dismissEscape(event) {
|
|
260
|
+
// Uniform swallow-at-the-top (CIN-428): both stages consume the key.
|
|
261
|
+
event?.preventDefault();
|
|
262
|
+
event?.stopPropagation();
|
|
263
|
+
if (expanded) {
|
|
264
|
+
handleCancel();
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
closePopover();
|
|
262
268
|
}
|
|
269
|
+
}
|
|
270
|
+
$effect(() => {
|
|
271
|
+
if (!isPositionedOpen)
|
|
272
|
+
return;
|
|
273
|
+
const releaseEscape = pushEscapeHandler(dismissEscape);
|
|
274
|
+
return releaseEscape;
|
|
275
|
+
});
|
|
276
|
+
function handleKeydown(event) {
|
|
263
277
|
if ((event.key === 'Enter' || event.key === ' ') && !expanded && !event.defaultPrevented) {
|
|
264
278
|
event.preventDefault();
|
|
265
279
|
handleExpand();
|