@deepseek-ai/dsh-client-ui-primitives 0.2.2-rc.5 → 0.2.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.i18n.yaml +12 -12
  2. package/README.md +21 -10
  3. package/README.zh.md +21 -10
  4. package/lib/index.js +2961 -868
  5. package/lib/index.js.map +1 -1
  6. package/lib/types/Checkbox.d.ts.map +1 -1
  7. package/lib/types/Checkbox.js.map +1 -1
  8. package/lib/types/HoverCard.d.ts +5 -3
  9. package/lib/types/HoverCard.d.ts.map +1 -1
  10. package/lib/types/HoverCard.js.map +1 -1
  11. package/lib/types/ImageLightbox.d.ts.map +1 -1
  12. package/lib/types/ImageLightbox.js.map +1 -1
  13. package/lib/types/LinkIcon.js.map +1 -1
  14. package/lib/types/Marquee.d.ts +35 -0
  15. package/lib/types/Marquee.d.ts.map +1 -0
  16. package/lib/types/Marquee.js.map +1 -0
  17. package/lib/types/Menu.d.ts +24 -5
  18. package/lib/types/Menu.d.ts.map +1 -1
  19. package/lib/types/Menu.js.map +1 -1
  20. package/lib/types/PermissionIcon.d.ts.map +1 -1
  21. package/lib/types/PermissionIcon.js.map +1 -1
  22. package/lib/types/SearchField.d.ts +18 -0
  23. package/lib/types/SearchField.d.ts.map +1 -0
  24. package/lib/types/SearchField.js.map +1 -0
  25. package/lib/types/Switch.d.ts +5 -1
  26. package/lib/types/Switch.d.ts.map +1 -1
  27. package/lib/types/Switch.js.map +1 -1
  28. package/lib/types/TerminalBlock.js.map +1 -1
  29. package/lib/types/clipboard.d.ts +4 -2
  30. package/lib/types/clipboard.d.ts.map +1 -1
  31. package/lib/types/clipboard.js.map +1 -1
  32. package/lib/types/icons/artwork.d.ts +16 -0
  33. package/lib/types/icons/artwork.d.ts.map +1 -1
  34. package/lib/types/icons/artwork.js.map +1 -1
  35. package/lib/types/icons/index.d.ts +21 -5
  36. package/lib/types/icons/index.d.ts.map +1 -1
  37. package/lib/types/icons/index.js.map +1 -1
  38. package/lib/types/icons/props.d.ts +1 -1
  39. package/lib/types/icons/props.d.ts.map +1 -1
  40. package/lib/types/icons/shared-artwork.js.map +1 -1
  41. package/lib/types/index.d.ts +2 -1
  42. package/lib/types/index.d.ts.map +1 -1
  43. package/lib/types/index.js.map +1 -1
  44. package/lib/types/input-modality.d.ts +5 -0
  45. package/lib/types/input-modality.d.ts.map +1 -1
  46. package/lib/types/input-modality.js.map +1 -1
  47. package/lib/types/markdown/cjkFriendlyStrong.d.ts +4 -1
  48. package/lib/types/markdown/cjkFriendlyStrong.d.ts.map +1 -1
  49. package/lib/types/markdown/cjkFriendlyStrong.js.map +1 -1
  50. package/lib/types/useMenuSubmenu.d.ts +1 -0
  51. package/lib/types/useMenuSubmenu.d.ts.map +1 -1
  52. package/lib/types/useMenuSubmenu.js.map +1 -1
  53. package/lib/types/useModalLayer.d.ts +3 -1
  54. package/lib/types/useModalLayer.d.ts.map +1 -1
  55. package/lib/types/useModalLayer.js.map +1 -1
  56. package/package.json +6 -6
  57. package/src/Checkbox.module.css +43 -2
  58. package/src/Checkbox.tsx +7 -3
  59. package/src/HoverCard.module.css +42 -0
  60. package/src/HoverCard.tsx +53 -49
  61. package/src/ImageLightbox.tsx +2 -1
  62. package/src/Input.module.css +7 -1
  63. package/src/LinkIcon.tsx +9 -9
  64. package/src/Marquee.module.css +47 -0
  65. package/src/Marquee.tsx +109 -0
  66. package/src/Menu.module.css +34 -4
  67. package/src/Menu.tsx +138 -35
  68. package/src/Modal.module.css +8 -4
  69. package/src/PermissionIcon.tsx +10 -12
  70. package/src/Pill.module.css +11 -1
  71. package/src/RiskConfirmation.module.css +6 -1
  72. package/src/SearchField.module.css +74 -0
  73. package/src/SearchField.tsx +37 -0
  74. package/src/SegmentedTabs.module.css +4 -10
  75. package/src/Switch.tsx +7 -1
  76. package/src/TerminalBlock.tsx +4 -4
  77. package/src/clipboard.ts +29 -15
  78. package/src/icons/artwork.ts +89 -85
  79. package/src/icons/index.tsx +29 -5
  80. package/src/icons/props.ts +1 -1
  81. package/src/icons/shared-artwork.tsx +14 -14
  82. package/src/index.ts +2 -1
  83. package/src/input-modality.ts +13 -5
  84. package/src/markdown/MarkdownText.module.css +21 -10
  85. package/src/markdown/cjkFriendlyStrong.ts +9 -2
  86. package/src/useMenuSubmenu.ts +6 -3
  87. package/src/useModalLayer.ts +5 -2
  88. package/lib/AnimatedRows.module.css +0 -7
  89. package/lib/Button.module.css +0 -84
  90. package/lib/Checkbox.module.css +0 -28
  91. package/lib/CodeCard.module.css +0 -85
  92. package/lib/CommandText.module.css +0 -12
  93. package/lib/ConnectionIndicator.module.css +0 -120
  94. package/lib/DetailDocument.module.css +0 -67
  95. package/lib/DiffBlock.module.css +0 -82
  96. package/lib/DisclosureRow.module.css +0 -115
  97. package/lib/FileTypeIcon.module.css +0 -50
  98. package/lib/HoverCard.module.css +0 -108
  99. package/lib/ImageLightbox.module.css +0 -54
  100. package/lib/ImagePreview.module.css +0 -24
  101. package/lib/InlineEditor.module.css +0 -23
  102. package/lib/Input.module.css +0 -38
  103. package/lib/JsonTree.module.css +0 -371
  104. package/lib/Menu.module.css +0 -443
  105. package/lib/MenuGroup.module.css +0 -37
  106. package/lib/MenuSurface.module.css +0 -65
  107. package/lib/Modal.module.css +0 -147
  108. package/lib/PathLabel.module.css +0 -28
  109. package/lib/Pill.module.css +0 -30
  110. package/lib/QuotePreview.module.css +0 -138
  111. package/lib/ReadBlock.module.css +0 -45
  112. package/lib/RiskConfirmation.module.css +0 -47
  113. package/lib/RowDragPreview.module.css +0 -12
  114. package/lib/SearchBlock.module.css +0 -114
  115. package/lib/SegmentedControl.module.css +0 -81
  116. package/lib/SegmentedTabs.module.css +0 -77
  117. package/lib/ShortcutKeys.module.css +0 -33
  118. package/lib/StateDot.module.css +0 -100
  119. package/lib/Switch.module.css +0 -49
  120. package/lib/Tag.module.css +0 -57
  121. package/lib/TerminalBlock.module.css +0 -207
  122. package/lib/TextShimmer.module.css +0 -88
  123. package/lib/Toast.module.css +0 -102
  124. package/lib/Tooltip.module.css +0 -68
  125. package/lib/UserMessageBubble.module.css +0 -11
  126. package/lib/WebBlock.module.css +0 -153
  127. package/lib/ZoomControls.module.css +0 -54
  128. package/lib/markdown/CodeBlock.module.css +0 -209
  129. package/lib/markdown/JsonBlock.module.css +0 -34
  130. package/lib/markdown/MarkdownText.module.css +0 -511
  131. package/lib/settings-form/SettingsForm.module.css +0 -53
  132. package/lib/settings-form/fields.module.css +0 -153
  133. package/lib/types/rank-by-name.d.ts +0 -22
  134. package/lib/types/rank-by-name.d.ts.map +0 -1
  135. package/lib/types/rank-by-name.js.map +0 -1
  136. package/lib/user-text.module.css +0 -46
  137. package/src/rank-by-name.ts +0 -93
@@ -22,6 +22,7 @@
22
22
  ui-theme styles/scrollbar.css for the rebinding contract). */
23
23
  --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
24
24
  --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
25
+ --dsh-menu-row-height: 34px;
25
26
  }
26
27
 
27
28
  /* Primary cards grow with their content between compact and readable bounds. */
@@ -35,7 +36,7 @@
35
36
  }
36
37
 
37
38
  /* Legacy slots can render no rows; keep empty context popups out of layout. */
38
- .list[data-context-menu]:not(:has([role='menuitem'])) {
39
+ .list[data-context-menu]:not([data-menu-popup]):not(:has([role='menuitem'])) {
39
40
  display: none;
40
41
  }
41
42
 
@@ -147,6 +148,7 @@
147
148
  display: flex;
148
149
  flex-direction: column;
149
150
  min-height: 0;
151
+ max-height: calc(var(--dsh-menu-visible-rows) * var(--dsh-menu-row-height));
150
152
  }
151
153
 
152
154
  .scrollable .viewport {
@@ -170,6 +172,31 @@
170
172
  border-top: none;
171
173
  }
172
174
 
175
+ .searchRows {
176
+ display: flex;
177
+ flex-direction: column;
178
+ min-height: 0;
179
+ }
180
+
181
+ .list:has(> .search) {
182
+ min-width: min(216px, calc(100vw - 24px));
183
+ }
184
+
185
+ .search {
186
+ --dsh-search-field-height: var(--dsh-menu-row-height);
187
+ }
188
+
189
+ .searchStatus {
190
+ box-sizing: border-box;
191
+ min-block-size: var(--dsh-menu-row-height);
192
+ display: flex;
193
+ align-items: center;
194
+ padding: 6px 8px;
195
+ font-size: 13px;
196
+ line-height: 20px;
197
+ color: var(--dsw-alias-label-secondary);
198
+ }
199
+
173
200
  .itemWrap {
174
201
  position: relative;
175
202
  }
@@ -180,7 +207,7 @@
180
207
  align-items: center;
181
208
  gap: 6px;
182
209
  width: 100%;
183
- min-height: 34px;
210
+ min-height: var(--dsh-menu-row-height);
184
211
  padding: 6px 8px;
185
212
  border: none;
186
213
  border-radius: var(--dsw-radius-md);
@@ -206,8 +233,11 @@
206
233
  outline: none;
207
234
  }
208
235
 
236
+ .denseList {
237
+ --dsh-menu-row-height: 30px;
238
+ }
239
+
209
240
  .denseList .item {
210
- min-height: 30px;
211
241
  padding-block: 4px;
212
242
  }
213
243
 
@@ -217,12 +247,12 @@
217
247
 
218
248
  .list.compactList,
219
249
  .submenu.compactList {
250
+ --dsh-menu-row-height: 24px;
220
251
  min-width: min(156px, calc(100vw - 24px));
221
252
  padding: 4px;
222
253
  }
223
254
 
224
255
  .compactList .item {
225
- min-height: 24px;
226
256
  gap: 5px;
227
257
  padding: 2px 6px;
228
258
  border-radius: var(--dsw-radius-sm);
package/src/Menu.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react'
2
- import type { ReactNode, RefObject } from 'react'
2
+ import type { CSSProperties, ReactNode, RefObject } from 'react'
3
3
  import { createPortal } from 'react-dom'
4
4
  import clsx from 'clsx'
5
5
  import { useMenuSubmenu, menuHoverAllowed } from './useMenuSubmenu.ts'
@@ -9,7 +9,9 @@ import { usePointerGrace } from './pointer-grace.ts'
9
9
  import { isBehindModal } from './useModalLayer.ts'
10
10
  import { observeComposition } from './keyboard-composition.ts'
11
11
  import { focusWithoutRing } from './focus.ts'
12
+ import { touchModality } from './input-modality.ts'
12
13
  import { MenuSurface } from './MenuSurface.tsx'
14
+ import { SearchField } from './SearchField.tsx'
13
15
  import css from './Menu.module.css'
14
16
 
15
17
  /** Selectable row (optionally with a nested submenu). */
@@ -95,6 +97,11 @@ export function MenuItemButton({ onSelect, ...props }: MenuItemButtonProps) {
95
97
  return <MenuRow {...props} decorativeIcon={false} onClick={onSelect} />
96
98
  }
97
99
 
100
+ /** Buttons reachable by keyboard within a menu row group. */
101
+ function menuButtons(container: HTMLElement | null): HTMLButtonElement[] {
102
+ return Array.from(container?.querySelectorAll<HTMLButtonElement>('button:not(:disabled)') ?? [])
103
+ }
104
+
98
105
  /**
99
106
  * Render an anchored dropdown menu. While the list is open its keys mirror the
100
107
  * composer's: Tab settles the focused row — from the trigger, Tab enters the
@@ -110,7 +117,8 @@ export function MenuItemButton({ onSelect, ...props }: MenuItemButtonProps) {
110
117
  * @param props.returnFocus - original control captured before asynchronous menu preparation.
111
118
  * @param props.isExternalTrigger - recognizes external controls whose pointer presses should not dismiss;
112
119
  * omitted, every press outside the anchor and menu panels dismisses.
113
- * @param props.autoFocus - focus the first item on open; the arrow keys walk the list either way.
120
+ * @param props.autoFocus - focus the first focusable row on open when `search` is omitted.
121
+ * With `search`, the search settings determine initial focus. Arrow keys navigate either way.
114
122
  * @param props.open - whether the list is showing (owner-controlled).
115
123
  * @param props.anchor - the trigger element (rendered in place).
116
124
  * @param props.items - selectable data rows and optional separators (default none; with no `children` either, the list is empty).
@@ -119,9 +127,11 @@ export function MenuItemButton({ onSelect, ...props }: MenuItemButtonProps) {
119
127
  * @param props.selectedId - row shown as selected.
120
128
  * @param props.selectedIds - rows shown as selected when a menu contains independent option groups.
121
129
  * @param props.onSelect - data-row activation callback (not called for disabled rows or submenu parents that only open children).
122
- * @param props.onClose - invoked on outside click, Escape, or a window blur
123
- * that moved focus into an iframe (the only signal a pointerdown inside a
124
- * cross-origin iframe leaves).
130
+ * @param props.onClose - invoked on outside click, on activating another popup
131
+ * trigger (an `aria-haspopup` control outside this menu that
132
+ * `isExternalTrigger` does not claim) even when that trigger stops its
133
+ * pointer presses, on Escape, or on a window blur that moved focus into an
134
+ * iframe (the only signal a pointerdown inside a cross-origin iframe leaves).
125
135
  * @param props.align - list alignment against the anchor (default 'start').
126
136
  * @param props.side - open below (`bottom`, default) or above (`top`) the anchor.
127
137
  * @param props.portal - render the list into document.body, fixed-positioned
@@ -139,6 +149,11 @@ export function MenuItemButton({ onSelect, ...props }: MenuItemButtonProps) {
139
149
  * @param props.minWidthFromAnchor - in portal mode, keep the menu at least as wide as its anchor, bounded by viewport margins.
140
150
  * @param props.footer - rows pinned below the scrolling items area, separated
141
151
  * by a hairline; contextual menus reuse an explicit leading separator. These rows stay visible while the items above scroll.
152
+ * @param props.search - controlled field above the rows. It focuses on open unless
153
+ * `skipAutoFocusOnTouch` is set and opened by touch. Enter activates the first available
154
+ * result in the scrolling rows. `clearLabel` enables a clear button that restores input focus.
155
+ * The owner filters `items` and provides the labels and empty message.
156
+ * @param props.maxVisibleRows - cap the scrolling viewport at this many row heights.
142
157
  * @param props.children - component rows rendered after `items` in the same
143
158
  * list, each a `role="menuitem"` button such as {@link MenuItemButton}; they
144
159
  * share the keyboard walk, the submenu exclusivity, and the post-selection
@@ -153,7 +168,7 @@ export function MenuItemButton({ onSelect, ...props }: MenuItemButtonProps) {
153
168
  * document.body outside the owner's DOM subtree.
154
169
  * @returns anchor wrapper with the conditional list.
155
170
  */
156
- export function Menu({ open, anchor, items = [], children, submenuBackLabel, selectedId, selectedIds, onSelect, onClose, align = 'start', side = 'bottom', portal = false, closeOnPointerLeave = false, dense = false, compact = false, autoFocus = false, selection = 'check', anchorRef, anchorPoint, minWidthFromAnchor = false, footer, className, listClassName, contextual = false, exiting, returnFocus, isExternalTrigger }: {
171
+ export function Menu({ open, anchor, items = [], children, submenuBackLabel, selectedId, selectedIds, onSelect, onClose, align = 'start', side = 'bottom', portal = false, closeOnPointerLeave = false, dense = false, compact = false, autoFocus = false, selection = 'check', anchorRef, anchorPoint, minWidthFromAnchor = false, footer, search, maxVisibleRows, className, listClassName, contextual = false, exiting, returnFocus, isExternalTrigger }: {
157
172
  open: boolean
158
173
  /** Pointer-positioned popup: cursor clearance, grouped icons, and context gestures. */
159
174
  contextual?: boolean
@@ -170,6 +185,17 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
170
185
  submenuBackLabel?: string | undefined
171
186
  children?: ReactNode
172
187
  footer?: readonly MenuEntry[]
188
+ search?: {
189
+ label: string
190
+ /** Localized label for the optional clear button. */
191
+ clearLabel?: string | undefined
192
+ value: string
193
+ onChange: (value: string) => void
194
+ emptyMessage?: string | undefined
195
+ /** Leave the search field unfocused when touch opens the menu. */
196
+ skipAutoFocusOnTouch?: boolean
197
+ } | undefined
198
+ maxVisibleRows?: number | undefined
173
199
  selectedId?: string | undefined
174
200
  selectedIds?: readonly string[] | undefined
175
201
  onSelect?: (id: string) => void
@@ -190,6 +216,14 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
190
216
  }) {
191
217
  const rootRef = useRef<HTMLSpanElement>(null)
192
218
  const listRef = useRef<HTMLDivElement>(null)
219
+ const searchRowsRef = useRef<HTMLDivElement>(null)
220
+ const viewportRef = useRef<HTMLDivElement>(null)
221
+ const searchFieldRef = useRef<HTMLDivElement>(null)
222
+ const searchRef = useRef<HTMLInputElement>(null)
223
+ const hasSearch = search !== undefined
224
+ const hasSearchClear = search?.clearLabel !== undefined
225
+ const skipAutoFocusOnTouch = search?.skipAutoFocusOnTouch === true
226
+ const openedByTouch = useRef(false)
193
227
  const menuId = useId()
194
228
  const pointX = anchorPoint?.x
195
229
  const pointY = anchorPoint?.y
@@ -259,7 +293,7 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
259
293
  exitingRef.current = exiting
260
294
  const openRef = useRef(open)
261
295
  openRef.current = open
262
- const submenu = useMenuSubmenu({ open: open && exiting === undefined, items, footer, listRef, refocusAnchor })
296
+ const submenu = useMenuSubmenu({ open: open && exiting === undefined, items, footer, listRef, searchRowsRef, refocusAnchor })
263
297
  const submenuEvents = useRef<Pick<typeof submenu, 'contains' | 'activeList' | 'returnToParent'>>(submenu)
264
298
  submenuEvents.current = submenu
265
299
  const close = useRef(onClose)
@@ -309,6 +343,7 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
309
343
  // sees the trigger, not the row autoFocus is about to focus.
310
344
  useEffect(() => {
311
345
  if (!open) return
346
+ openedByTouch.current = touchModality()
312
347
  const active = document.activeElement
313
348
  triggerRef.current = active instanceof HTMLElement && active !== document.body
314
349
  && (anchorRef !== undefined || anchorPoint !== undefined || rootRef.current?.contains(active) === true)
@@ -316,12 +351,20 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
316
351
  }, [open])
317
352
 
318
353
  useEffect(() => {
319
- if (!open || !positioned || exiting !== undefined || !autoFocus
354
+ if (open && positioned && exiting === undefined && hasSearch
355
+ && !(skipAutoFocusOnTouch && openedByTouch.current)
356
+ && !isBehindModal(triggerRef.current ?? rootRef.current)) {
357
+ searchRef.current?.focus({ preventScroll: true })
358
+ }
359
+ }, [open, positioned, exiting, hasSearch, skipAutoFocusOnTouch])
360
+
361
+ useEffect(() => {
362
+ if (!open || !positioned || exiting !== undefined || !autoFocus || hasSearch
320
363
  || listRef.current?.contains(document.activeElement) || submenu.contains(document.activeElement)) return
321
- const first = listRef.current?.querySelector<HTMLButtonElement>('button:not(:disabled)')
322
- walkIndex.current = first === undefined || first === null ? null : 0
323
- if (first != null) focusWithoutRing(first)
324
- }, [open, autoFocus, items.length, footer?.length, positioned, exiting])
364
+ const first = menuButtons(listRef.current)[0]
365
+ walkIndex.current = first === undefined ? null : 0
366
+ if (first !== undefined) focusWithoutRing(first)
367
+ }, [open, autoFocus, hasSearch, items.length, footer?.length, positioned, exiting])
325
368
 
326
369
  useEffect(() => {
327
370
  if (!open || exiting !== undefined) {
@@ -337,15 +380,34 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
337
380
  if (listRef.current?.contains(e.target) === true || submenuEvents.current.contains(e.target)) return
338
381
  onClose()
339
382
  }
383
+ // Activating another popup trigger closes this menu even when that trigger
384
+ // isolates its presses from its owners, as the shared context-menu button
385
+ // does: its pointerdown never reaches the listener above, so the
386
+ // activating click is caught in the capture phase instead.
387
+ const onOtherTrigger = (e: MouseEvent) => {
388
+ const trigger = e.target instanceof Element ? e.target.closest('[aria-haspopup]') : null
389
+ if (trigger === null || rootRef.current?.contains(trigger) === true || anchorRef?.current?.contains(trigger) === true) return
390
+ if (isExternalTrigger?.(trigger) === true) return
391
+ if (listRef.current?.contains(trigger) === true || submenuEvents.current.contains(trigger)) return
392
+ onClose()
393
+ }
340
394
  const onKeyDown = (e: KeyboardEvent) => {
341
395
  if (composition.guards(e) || isBehindModal(triggerRef.current ?? rootRef.current)
342
396
  || e.defaultPrevented || e.ctrlKey || e.altKey || e.metaKey) return
343
397
  // Where the keyboard is, computed once: the menu owns it when it holds a
344
398
  // row or sits on its anchor region.
345
399
  const focused = document.activeElement
400
+ const inSearch = focused !== null && focused === searchRef.current
401
+ const onClearSearch = !inSearch && searchFieldRef.current?.contains(focused) === true
346
402
  const insideList = listRef.current?.contains(focused) === true || submenuEvents.current.contains(focused)
347
403
  const anchored = focused === returnFocus?.() || anchorRef?.current?.contains(focused) === true
348
- || rootRef.current?.contains(focused) === true || insideList
404
+ || rootRef.current?.contains(focused) === true || insideList || (hasSearch && focused === triggerRef.current)
405
+ if (inSearch && e.key === 'Enter' && !e.shiftKey) {
406
+ e.preventDefault()
407
+ if (!e.repeat) menuButtons(viewportRef.current).find(button =>
408
+ button.getAttribute('role') === 'menuitem' && button.getAttribute('aria-disabled') !== 'true')?.click()
409
+ return
410
+ }
349
411
  if (e.key === 'Escape' && !e.shiftKey) {
350
412
  e.preventDefault()
351
413
  if (e.repeat) return
@@ -373,17 +435,16 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
373
435
  if (e.key === 'Tab') {
374
436
  const list = submenuEvents.current.activeList(focused)
375
437
  if (list === null || !anchored) return
438
+ if ((!e.shiftKey && inSearch && hasSearchClear) || (e.shiftKey && onClearSearch)) return
376
439
  if (e.shiftKey) {
377
440
  e.preventDefault()
378
441
  onClose()
379
442
  refocusAnchor(true)
380
443
  return
381
444
  }
382
- // Tab settles the row it is on; from anywhere else in the menu region
383
- // it enters the list. A focused control that is not a row (a retry
384
- // button inside an error strip) and a list with no enabled row keep the
385
- // browser's traversal instead of being swallowed.
386
- if (insideList) {
445
+ // Tab settles a focused row. Other controls inside the list keep
446
+ // native traversal unless they belong to the search field.
447
+ if (insideList && !inSearch && !onClearSearch) {
387
448
  if (focused instanceof Element && focused.getAttribute('role') === 'menuitem') {
388
449
  e.preventDefault()
389
450
  if (focused.getAttribute('aria-disabled') === 'true') {
@@ -397,8 +458,14 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
397
458
  }
398
459
  return
399
460
  }
400
- const row = list.querySelector<HTMLButtonElement>('button:not(:disabled)')
401
- if (row === null) return
461
+ const row = menuButtons(list)[0]
462
+ if (row === undefined) {
463
+ if (inSearch || onClearSearch) {
464
+ e.preventDefault()
465
+ searchRef.current?.focus()
466
+ }
467
+ return
468
+ }
402
469
  e.preventDefault()
403
470
  row.focus()
404
471
  walkIndex.current = 0
@@ -413,12 +480,13 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
413
480
  // otherwise re-enter at the near end on every press and the walk would
414
481
  // alternate between two rows.
415
482
  if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(e.key)) return
483
+ if (inSearch && (e.key === 'Home' || e.key === 'End')) return
416
484
  const list = submenuEvents.current.activeList(focused)
417
485
  if (list === null || !anchored) return
418
- const buttons = Array.from(list.querySelectorAll<HTMLButtonElement>('button:not(:disabled)'))
486
+ const buttons = menuButtons(list)
419
487
  if (buttons.length === 0) return
420
488
  const index = buttons.indexOf(focused as HTMLButtonElement)
421
- const from = index >= 0 ? index : walkIndex.current
489
+ const from = index >= 0 ? index : inSearch || onClearSearch ? null : walkIndex.current
422
490
  const next = e.key === 'Home' ? 0 : e.key === 'End' ? buttons.length - 1
423
491
  : from === null
424
492
  ? (e.key === 'ArrowDown' ? 0 : buttons.length - 1)
@@ -435,6 +503,7 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
435
503
  if (document.activeElement instanceof HTMLIFrameElement) onClose()
436
504
  }
437
505
  document.addEventListener('pointerdown', onPointerDown)
506
+ document.addEventListener('click', onOtherTrigger, true)
438
507
  const onEscape = (event: KeyboardEvent): void => { if (event.key === 'Escape') onKeyDown(event) }
439
508
  const onOtherKey = (event: KeyboardEvent): void => { if (event.key !== 'Escape') onKeyDown(event) }
440
509
  document.addEventListener('keydown', onOtherKey)
@@ -443,11 +512,12 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
443
512
  return () => {
444
513
  composition.dispose()
445
514
  document.removeEventListener('pointerdown', onPointerDown)
515
+ document.removeEventListener('click', onOtherTrigger, true)
446
516
  document.removeEventListener('keydown', onOtherKey)
447
517
  document.removeEventListener('keydown', onEscape, true)
448
518
  window.removeEventListener('blur', onWindowBlur)
449
519
  }
450
- }, [open, onClose, autoFocus, contextual, exiting, anchorRef, returnFocus, isExternalTrigger])
520
+ }, [open, onClose, autoFocus, hasSearch, hasSearchClear, contextual, exiting, anchorRef, returnFocus, isExternalTrigger])
451
521
 
452
522
  useLayoutEffect(() => {
453
523
  if (exiting === 'dismiss' && listRef.current?.contains(document.activeElement)) refocusAnchor()
@@ -486,16 +556,38 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
486
556
  }}>{entry.label}</MenuRow>
487
557
  }
488
558
 
559
+ const rows = <>
560
+ <div ref={viewportRef} className={css.viewport} role="presentation">
561
+ {items.map(entry => renderEntry(entry, itemColumns))}
562
+ {children}
563
+ </div>
564
+ {footer !== undefined && footer.length > 0 && (
565
+ <div className={css.footer} role="presentation">
566
+ {footer.map(entry => renderEntry(entry, footerColumns))}
567
+ </div>
568
+ )}
569
+ </>
570
+ const visible = exiting === undefined && !submenu.page
571
+ const cardStyle: CSSProperties & { '--dsh-menu-visible-rows'?: number } = {
572
+ positionAnchor: portal ? anchorName : undefined,
573
+ ...(maxVisibleRows === undefined ? {} : { '--dsh-menu-visible-rows': maxVisibleRows }),
574
+ }
575
+ const updateSearch = (value: string): void => {
576
+ if (viewportRef.current !== null) viewportRef.current.scrollTop = 0
577
+ search?.onChange(value)
578
+ }
579
+
489
580
  const list = open && positioned && (
490
581
  <MenuSurface compact={compact} id={contextual ? menuId : undefined}
491
582
  ref={listRef}
492
583
  className={clsx(css.list, listClassName, dense && css.denseList, compact && css.compactList, css.scrollable, submenu.page && css.parentPage, portal && css.portal, side === 'top' && !portal && css.sideTop, align === 'end' && !portal && css.alignEnd)}
493
- style={portal ? { positionAnchor: anchorName } : undefined}
584
+ style={cardStyle}
494
585
  data-anchor-side={portal ? side : undefined}
495
586
  data-anchor-align={portal ? align : undefined}
496
587
  data-match-anchor-width={portal && minWidthFromAnchor ? '' : undefined}
497
- role={exiting === undefined && !submenu.page ? 'menu' : undefined}
498
- aria-hidden={exiting === undefined && !submenu.page ? undefined : true}
588
+ data-menu-popup={visible && hasSearch ? '' : undefined}
589
+ role={visible && !hasSearch ? 'menu' : undefined}
590
+ aria-hidden={visible ? undefined : true}
499
591
  data-context-menu={contextual ? '' : undefined}
500
592
  phase={contextual ? exiting ?? 'enter' : undefined}
501
593
  // React portals bubble synthetic events through the REACT tree: without
@@ -517,15 +609,26 @@ export function Menu({ open, anchor, items = [], children, submenuBackLabel, sel
517
609
  >
518
610
  {/* Child cards anchor to this unscrolled box, which matches the card itself. */}
519
611
  {submenu.entry !== undefined && <span aria-hidden="true" className={css.submenuAnchor} style={{ anchorName: submenu.parentAnchor }} />}
520
- <div className={css.viewport} role="presentation">
521
- {items.map(entry => renderEntry(entry, itemColumns))}
522
- {children}
523
- </div>
524
- {footer !== undefined && footer.length > 0 && (
525
- <div className={css.footer} role="presentation">
526
- {footer.map(entry => renderEntry(entry, footerColumns))}
527
- </div>
528
- )}
612
+ {search === undefined ? rows : <>
613
+ <SearchField
614
+ inputRef={searchRef}
615
+ rootRef={searchFieldRef}
616
+ className={css.search}
617
+ role="searchbox"
618
+ aria-label={search.label}
619
+ placeholder={search.label}
620
+ value={search.value}
621
+ onChange={updateSearch}
622
+ clearLabel={search.clearLabel}
623
+ onClear={() => {
624
+ updateSearch('')
625
+ searchRef.current?.focus({ preventScroll: true })
626
+ }}
627
+ />
628
+ {search.emptyMessage !== undefined && items.length === 0 && <div role="status" className={css.searchStatus}>{search.emptyMessage}</div>}
629
+ <div ref={searchRowsRef} className={css.searchRows}
630
+ role={visible && (items.length > 0 || children != null || !!footer?.length) ? 'menu' : undefined}>{rows}</div>
631
+ </>}
529
632
  </MenuSurface>
530
633
  )
531
634
 
@@ -66,14 +66,13 @@
66
66
  width: 100%;
67
67
  }
68
68
 
69
- /* Header row (figma Title row): pad l24/t22/r14/b12, SPACE_BETWEEN —
70
- * title left, close button right. */
69
+ /* Header controls and footer actions share the content column's trailing edge. */
71
70
  .header {
72
71
  display: flex;
73
72
  align-items: center;
74
73
  justify-content: space-between;
75
74
  gap: 8px;
76
- padding: 22px 14px 12px 24px;
75
+ padding: 22px 24px 12px;
77
76
  }
78
77
 
79
78
  .title {
@@ -96,7 +95,7 @@
96
95
  color: var(--dsw-alias-state-warn-primary);
97
96
  }
98
97
 
99
- .warning .body {
98
+ .warning .header + .body {
100
99
  margin-top: 0;
101
100
  }
102
101
 
@@ -107,6 +106,7 @@
107
106
  justify-content: center;
108
107
  width: 28px;
109
108
  height: 28px;
109
+ padding: 0;
110
110
  border: none;
111
111
  border-radius: var(--dsw-radius-sm);
112
112
  background: transparent;
@@ -138,6 +138,10 @@
138
138
  padding: 0 24px;
139
139
  }
140
140
 
141
+ .header + .body {
142
+ margin-top: 8px;
143
+ }
144
+
141
145
  .footer {
142
146
  display: flex;
143
147
  align-items: center;
@@ -9,8 +9,8 @@ interface PermissionIconArtworkProps extends IconProps {
9
9
  function ReadOnlyArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
10
10
  return (
11
11
  <svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
12
- <path d="M5.08545 8.13775L7.18455 10.2368C7.26636 10.3187 7.4003 10.3142 7.47649 10.2271L11.5148 5.61194" stroke="currentColor" />
13
- <path d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L13.9245 3.84317V7.11961C13.9245 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2.07544 11.6089 2.07544 7.11961V3.84317L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
12
+ <path vectorEffect="non-scaling-stroke" d="M5.08545 8.13775L7.18455 10.2368C7.26636 10.3187 7.4003 10.3142 7.47649 10.2271L11.5148 5.61194" stroke="currentColor" />
13
+ <path vectorEffect="non-scaling-stroke" d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L14 4V7.11961C14 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2 11.6089 2 7.11961V4L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
14
14
  </svg>
15
15
  )
16
16
  }
@@ -18,11 +18,9 @@ function ReadOnlyArtwork({ size = 16, className, strokeWidth }: PermissionIconAr
18
18
  function WorkspaceWriteArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
19
19
  return (
20
20
  <svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
21
- <path d="M6.4209 1.68067C7.43922 1.299 8.56177 1.29898 9.58008 1.68067L14.0996 3.375C14.2946 3.44811 14.4236 3.63455 14.4238 3.84278V6.89063C14.1115 6.71853 13.7761 6.58312 13.4238 6.48926V4.18946L9.22852 2.61621C8.43657 2.31947 7.56341 2.31939 6.77148 2.61621L2.5752 4.18946V7.11914C2.5752 11.1796 5.52369 13.056 8 14.0391C8.27653 13.9293 8.55827 13.8067 8.8418 13.6729C9.07101 13.9468 9.33228 14.1929 9.62012 14.4053C9.12409 14.6579 8.63578 14.8696 8.17871 15.0449C8.0637 15.0889 7.93628 15.0889 7.82129 15.0449C5.22011 14.0472 1.5752 11.9381 1.5752 7.11914V3.84278C1.57541 3.63469 1.70463 3.44821 1.89941 3.375L6.4209 1.68067Z" fill="currentColor" />
22
- <path d="M5.26392 6.60339H10.7361" stroke="currentColor" />
23
- <path d="M5.26392 9.86902H8.32833" stroke="currentColor" />
24
- <path d="M10.0317 13.2229C10.263 13.3929 10.4943 13.563 10.7256 13.733C10.7932 13.6482 10.8608 13.5634 10.9284 13.4786C12.1455 11.9522 13.3626 10.4258 14.5798 8.89935C14.6474 8.81455 14.715 8.72975 14.7826 8.64495C14.4143 8.37419 14.046 8.10344 13.6777 7.83268C13.6169 7.92252 13.5562 8.01236 13.4954 8.10219C12.4016 9.71926 11.3078 11.3363 10.214 12.9534C10.1532 13.0432 10.0924 13.1331 10.0317 13.2229Z" fill="currentColor" />
25
- <path d="M12.6516 12.6696C12.6516 12.925 12.6516 13.1804 12.6516 13.4359C12.6952 13.4378 12.7387 13.4398 12.7823 13.4417C13.5663 13.4768 14.3504 13.5118 15.1345 13.5469C15.178 13.5488 15.2216 13.5508 15.2651 13.5527C15.2651 13.2194 15.2651 12.8861 15.2651 12.5527C15.2216 12.5547 15.178 12.5566 15.1345 12.5586C14.3504 12.5936 13.5663 12.6287 12.7823 12.6637C12.7387 12.6657 12.6952 12.6676 12.6516 12.6696Z" fill="currentColor" />
21
+ <path vectorEffect="non-scaling-stroke" d="M14 6.68994V4L9.40444 2.14859C8.49914 1.80919 7.50155 1.80917 6.59624 2.14853L2 4V7.11961C2 11.6089 5.44423 13.5975 8.00035 14.5779C8.404 14.4231 8.8303 14.2432 9.264 14.035" stroke="currentColor" strokeLinejoin="round" />
22
+ <path vectorEffect="non-scaling-stroke" d="M5.5 6.5H10.5M5.5 10H8.5" stroke="currentColor" />
23
+ <path vectorEffect="non-scaling-stroke" d="M10.37865 13.47795L14.23015 8.23882M12.5 13H15.5" stroke="currentColor" />
26
24
  </svg>
27
25
  )
28
26
  }
@@ -30,9 +28,9 @@ function WorkspaceWriteArtwork({ size = 16, className, strokeWidth }: Permission
30
28
  function FullAccessArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
31
29
  return (
32
30
  <svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
33
- <path d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L13.9245 3.84317V7.11961C13.9245 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2.07544 11.6089 2.07544 7.11961V3.84317L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
34
- <path d="M8 4.39209V9.89209" stroke="currentColor" />
35
- <path d="M8 10.8081V11.8081" stroke="currentColor" />
31
+ <path vectorEffect="non-scaling-stroke" d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L14 4V7.11961C14 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2 11.6089 2 7.11961V4L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
32
+ <path vectorEffect="non-scaling-stroke" d="M8 4.5V10" stroke="currentColor" />
33
+ <path vectorEffect="non-scaling-stroke" d="M8 11V12" stroke="currentColor" />
36
34
  </svg>
37
35
  )
38
36
  }
@@ -40,8 +38,8 @@ function FullAccessArtwork({ size = 16, className, strokeWidth }: PermissionIcon
40
38
  function AutoReviewArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
41
39
  return (
42
40
  <svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
43
- <path d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L13.9245 3.84317V7.11961C13.9245 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2.07544 11.6089 2.07544 7.11961V3.84317L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
44
- <path d="M5.75 10.15L8 4.95L10.25 10.15M6.43 8.59H9.57" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
41
+ <path vectorEffect="non-scaling-stroke" d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L14 4V7.11961C14 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2 11.6089 2 7.11961V4L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
42
+ <path vectorEffect="non-scaling-stroke" d="M5.75 10.15L8 4.95L10.25 10.15M6.5 8.5H9.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
45
43
  </svg>
46
44
  )
47
45
  }
@@ -18,7 +18,7 @@
18
18
  }
19
19
 
20
20
  @media (hover: hover) {
21
- .interactive:hover {
21
+ .interactive:hover:where(:not(:disabled):not(.active)) {
22
22
  background: var(--dsw-alias-interactive-bg-hover);
23
23
  }
24
24
  }
@@ -28,3 +28,13 @@
28
28
  background: var(--dsw-alias-button-ghost-active-fill);
29
29
  box-shadow: inset 0 0 0 1px var(--dsw-alias-button-ghost-active-border);
30
30
  }
31
+
32
+ .interactive:disabled {
33
+ cursor: default;
34
+ opacity: 0.4;
35
+ }
36
+
37
+ .interactive:focus-visible {
38
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
39
+ outline-offset: 2px;
40
+ }
@@ -25,6 +25,7 @@
25
25
 
26
26
  .confirmation .acknowledgement {
27
27
  align-items: flex-start;
28
+ gap: 6px;
28
29
  margin-top: 16px;
29
30
  color: var(--dsw-alias-label-secondary);
30
31
  font-size: 14px;
@@ -32,10 +33,14 @@
32
33
  line-height: 20px;
33
34
  }
34
35
 
36
+ .confirmation .acknowledgement > :first-child {
37
+ margin-top: 3px;
38
+ }
39
+
35
40
  .confirmation .acknowledgement input {
36
41
  width: 14px;
37
42
  height: 14px;
38
- margin-top: 3px;
43
+ margin: 0;
39
44
  }
40
45
 
41
46
  .modalAction {
@@ -0,0 +1,74 @@
1
+ .field {
2
+ flex: none;
3
+ display: flex;
4
+ align-items: center;
5
+ gap: 6px;
6
+ width: 100%;
7
+ height: calc(var(--dsh-search-field-height, 32px) + 3px + 0.5px);
8
+ margin: 0;
9
+ margin-block-end: 3px;
10
+ padding: 0 8px 3px;
11
+ box-sizing: border-box;
12
+ border-block-end: 0.5px solid var(--dsw-alias-border-l2);
13
+ background: transparent;
14
+ cursor: text;
15
+ color: var(--dsw-alias-label-tertiary);
16
+ overflow: hidden;
17
+ }
18
+
19
+ .leading,
20
+ .clear {
21
+ flex: none;
22
+ display: inline-flex;
23
+ align-items: center;
24
+ justify-content: center;
25
+ border: none;
26
+ border-radius: var(--dsw-radius-sm);
27
+ padding: 0;
28
+ background: transparent;
29
+ }
30
+
31
+ .leading {
32
+ width: 14px;
33
+ color: var(--dsw-alias-menu-icon);
34
+ }
35
+
36
+ .clear {
37
+ cursor: pointer;
38
+ width: 24px;
39
+ height: 24px;
40
+ color: var(--dsw-alias-label-secondary);
41
+ }
42
+
43
+ .clear:focus-visible {
44
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
45
+ outline-offset: -2px;
46
+ }
47
+
48
+ @media (hover: hover) {
49
+ .clear:hover {
50
+ background: var(--dsw-alias-interactive-bg-hover);
51
+ }
52
+ }
53
+
54
+ .input {
55
+ flex: 1;
56
+ width: 0;
57
+ min-width: 0;
58
+ border: none;
59
+ outline: none;
60
+ background: transparent;
61
+ margin: 0;
62
+ padding: 0;
63
+ font-size: 13px;
64
+ line-height: 20px;
65
+ color: var(--dsw-alias-label-primary);
66
+ }
67
+
68
+ .input::placeholder {
69
+ color: var(--dsw-alias-label-tertiary);
70
+ }
71
+
72
+ @media (pointer: coarse) {
73
+ .input { font-size: 16px; }
74
+ }