@deepseek-ai/dsh-client-ui-primitives 0.2.2-rc.4 → 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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-client-ui-primitives",
3
3
  "description": "Pure React atoms for the dsh web UI: controls, icons, markdown, and JSON inspectors (zero cordis)",
4
- "version": "0.2.2-rc.4",
4
+ "version": "0.2.3-alpha.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@deepseek-ai/dsh-client-store": "0.2.2-rc.4",
26
+ "@deepseek-ai/dsh-client-store": "0.2.3-alpha.1",
27
27
  "@deepseek-ai/cordis": "~4.1.0",
28
- "@deepseek-ai/dsh-util-code-language": "0.2.2-rc.4",
28
+ "@deepseek-ai/dsh-util-code-language": "0.2.3-alpha.1",
29
29
  "react": "^18.2.0",
30
30
  "clsx": "^2.0.0",
31
31
  "diff": "^9.0.0",
@@ -39,18 +39,18 @@
39
39
  "micromark-util-symbol": "^2.0.1",
40
40
  "micromark-util-types": "^2.0.2",
41
41
  "shiki": "^4.4.3",
42
- "@deepseek-ai/dsh-util-workspace-path": "0.2.2-rc.4",
42
+ "@deepseek-ai/dsh-util-workspace-path": "0.2.3-alpha.1",
43
43
  "@shikijs/langs": "^4.4.3",
44
44
  "@types/mdast": "^4.0.4",
45
45
  "micromark-factory-space": "^2.0.1",
46
46
  "micromark-extension-math": "^3.1.0",
47
- "mdast-util-from-markdown": "^2.0.3",
47
+ "mdast-util-from-markdown": "^2.1.0",
48
48
  "mdast-util-gfm": "^3.1.0",
49
49
  "mdast-util-math": "^3.0.0",
50
50
  "micromark-extension-gfm": "^3.0.0",
51
51
  "micromark-util-sanitize-uri": "^2.0.1",
52
52
  "simple-icons": "16.31.0",
53
- "@deepseek-ai/dsh-util-file-drag": "0.2.2-rc.4"
53
+ "@deepseek-ai/dsh-util-file-drag": "0.2.3-alpha.1"
54
54
  },
55
55
  "files": [
56
56
  "lib/index.js",
@@ -1,22 +1,63 @@
1
1
  .checkbox {
2
2
  display: inline-flex;
3
3
  align-items: center;
4
- gap: 6px;
4
+ gap: 8px;
5
5
  font-size: 14px;
6
6
  line-height: 20px;
7
7
  color: var(--dsw-alias-label-primary);
8
8
  cursor: pointer;
9
9
  }
10
10
 
11
+ .control {
12
+ position: relative;
13
+ display: inline-flex;
14
+ flex: none;
15
+ }
16
+
11
17
  .checkbox input {
18
+ appearance: none;
19
+ box-sizing: border-box;
12
20
  flex: 0 0 auto;
13
21
  width: 16px;
14
22
  height: 16px;
15
23
  margin: 0;
16
- accent-color: var(--dsw-alias-brand-primary);
24
+ border: 0.5px solid var(--dsw-alias-border-l4);
25
+ border-radius: var(--dsw-radius-xs);
26
+ background: var(--dsw-alias-bg-layer-1);
17
27
  cursor: inherit;
18
28
  }
19
29
 
30
+ .checkbox input:checked {
31
+ border-color: var(--dsw-alias-button-primary-fill);
32
+ background: var(--dsw-alias-button-primary-fill);
33
+ }
34
+
35
+ .mark {
36
+ position: absolute;
37
+ inset: 0;
38
+ margin: auto;
39
+ display: flex;
40
+ width: 12px;
41
+ height: 12px;
42
+ visibility: hidden;
43
+ pointer-events: none;
44
+ color: var(--dsw-alias-label-primary-foreground);
45
+ }
46
+
47
+ .checkbox input:checked + .mark {
48
+ visibility: visible;
49
+ }
50
+
51
+ @media (forced-colors: active) {
52
+ .checkbox input {
53
+ appearance: auto;
54
+ }
55
+
56
+ .checkbox input:checked + .mark {
57
+ visibility: hidden;
58
+ }
59
+ }
60
+
20
61
  .checkbox input:focus-visible {
21
62
  outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
22
63
  outline-offset: 2px;
package/src/Checkbox.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Controlled native checkbox with a caller-owned visible and accessible label. */
2
2
 
3
3
  import clsx from 'clsx'
4
+ import { IconCheckOutlineRegular } from './icons/index.tsx'
4
5
  import css from './Checkbox.module.css'
5
6
 
6
7
  /**
@@ -25,9 +26,12 @@ export function Checkbox({ checked, onChange, label, disabled = false, title, cl
25
26
  }) {
26
27
  return (
27
28
  <label className={clsx(css.checkbox, className)} title={title}>
28
- <input type="checkbox" checked={checked} disabled={disabled}
29
- data-modal-autofocus={modalAutofocus || undefined}
30
- onChange={(event) => { onChange(event.target.checked) }} />
29
+ <span className={css.control}>
30
+ <input type="checkbox" checked={checked} disabled={disabled}
31
+ data-modal-autofocus={modalAutofocus || undefined}
32
+ onChange={(event) => { onChange(event.target.checked) }} />
33
+ <span className={css.mark} aria-hidden="true"><IconCheckOutlineRegular size={12} /></span>
34
+ </span>
31
35
  <span>{label}</span>
32
36
  </label>
33
37
  )
@@ -17,6 +17,48 @@
17
17
  box-shadow: var(--dsw-shadow-lv3);
18
18
  }
19
19
 
20
+ /* A compact card sits beside its anchor's end edge with its top on the
21
+ anchor's top: the insets keep it 8px from the anchor and from the viewport's
22
+ edges. When that would cross the viewport, the first fallback that fits
23
+ places it: beside the start edge; on either side with its bottom at the
24
+ viewport's margin; then, with room on neither side, below the anchor from
25
+ the anchor's start edge, or above it, so the card does not cover its anchor.
26
+ A card too tall for that holds the viewport's bottom and end margins.
27
+ Chromium tries five fallbacks, so there the browser's own overflow shift
28
+ keeps such a card inside the viewport instead, against its edges. */
29
+ .compact {
30
+ position-area: inline-end span-block-end;
31
+ inset: 0 8px 8px;
32
+ position-try-fallbacks:
33
+ flip-inline,
34
+ --dsh-hover-card-low,
35
+ --dsh-hover-card-low flip-inline,
36
+ --dsh-hover-card-below,
37
+ --dsh-hover-card-above,
38
+ --dsh-hover-card-held;
39
+ }
40
+
41
+ @position-try --dsh-hover-card-low {
42
+ position-area: inline-end span-all;
43
+ align-self: end;
44
+ }
45
+
46
+ @position-try --dsh-hover-card-below {
47
+ position-area: block-end span-inline-end;
48
+ inset: 8px 8px 8px 0;
49
+ }
50
+
51
+ @position-try --dsh-hover-card-above {
52
+ position-area: block-start span-inline-end;
53
+ inset: 8px 8px 8px 0;
54
+ }
55
+
56
+ @position-try --dsh-hover-card-held {
57
+ position-area: span-all;
58
+ justify-self: end;
59
+ align-self: end;
60
+ }
61
+
20
62
  .copyable {
21
63
  cursor: pointer;
22
64
  }
package/src/HoverCard.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'
1
+ import { useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
2
2
  import type { CSSProperties, ReactNode, RefObject, SyntheticEvent } from 'react'
3
3
  import clsx from 'clsx'
4
4
  import { createPortal } from 'react-dom'
@@ -16,15 +16,19 @@ const INLINE_PREVIEW_WIDTH = 300
16
16
  const ANCHOR_GAP = 8
17
17
  const VIEWPORT_MARGIN = 8
18
18
 
19
+ /** Where the script places a card; a compact card has no coordinates, since the stylesheet anchors it. */
19
20
  interface CardPosition {
20
- left: number
21
- top: number
21
+ left?: number
22
+ top?: number
22
23
  width?: number
23
24
  maxWidth?: number
24
25
  maxHeight?: number
25
26
  bridge?: { left: number; top: number; width: number; height: number }
26
27
  }
27
28
 
29
+ /** The position of every compact card: one value, so placing it again renders nothing. */
30
+ const ANCHORED: CardPosition = {}
31
+
28
32
  /**
29
33
  * Render an anchor with a hover-triggered preview card independently of nested tooltips.
30
34
  * Touch entry does not open a preview or intercept the anchor's action.
@@ -32,9 +36,11 @@ interface CardPosition {
32
36
  * @param props.content - card content; the pointer may rest on it, so it is
33
37
  * readable and selectable, but it carries no dismissal affordance of its own.
34
38
  * @param props.openDelayMs - hover dwell before the card shows (default 500).
35
- * @param props.variant - compact card beside the anchor, or a preview above/below it
36
- * with 24px side insets, a 420px height cap, the frame-top clearance (capped below an anchor inside the top strip),
37
- * and 100ms opacity transitions.
39
+ * @param props.variant - compact card beside the anchor's end edge, or its start edge when only that side fits, or
40
+ * below the anchor, else above it, when neither side fits, or in the viewport's bottom end corner when it is too
41
+ * tall for those, which the stylesheet decides by CSS anchor positioning; or a preview above/below it with 24px
42
+ * side insets, a 420px height cap, the frame-top clearance (capped below an anchor inside the top strip), and 100ms
43
+ * opacity transitions.
38
44
  * @param props.widthAnchorRef - optional element whose width and horizontal position size the preview.
39
45
  * @param props.inline - keep the anchor in prose; show a contained preview on hover or keyboard focus.
40
46
  * Its hover region connects the anchor and preview across the visual gap.
@@ -67,6 +73,8 @@ export function HoverCard({
67
73
  copyLabel?: string
68
74
  copiedLabel?: string
69
75
  })) {
76
+ const compact = variant !== 'preview' && !inline
77
+ const anchorName = `--dsh-hover-card-${useId().replaceAll(':', '')}`
70
78
  const rootRef = useRef<HTMLSpanElement>(null)
71
79
  const cardRef = useRef<HTMLDivElement>(null)
72
80
  const portalRef = useRef<HTMLSpanElement>(null)
@@ -168,6 +176,8 @@ export function HoverCard({
168
176
 
169
177
  // Fixed-position from the anchor rect before paint; track the anchor while
170
178
  // open (capture-phase scroll catches nested panes), as in Menu portal mode.
179
+ // The stylesheet anchors a compact card, so it needs neither the rect nor
180
+ // the tracking.
171
181
  useLayoutEffect(() => {
172
182
  if (!open) { setPos(null); return }
173
183
  const place = () => {
@@ -178,6 +188,10 @@ export function HoverCard({
178
188
  dismissImmediately()
179
189
  return
180
190
  }
191
+ if (compact) {
192
+ setPos(ANCHORED)
193
+ return
194
+ }
181
195
  const r = wrapper.getBoundingClientRect()
182
196
  const h = cardRef.current?.offsetHeight ?? 0
183
197
  if (variant === 'preview') {
@@ -196,32 +210,27 @@ export function HoverCard({
196
210
  })
197
211
  return
198
212
  }
199
- if (inline) {
200
- const height = Math.max(h, cardRef.current?.scrollHeight ?? 0)
201
- const maxWidth = Math.max(0, Math.min(INLINE_PREVIEW_WIDTH, window.innerWidth - VIEWPORT_MARGIN * 2))
202
- const width = fitContent ? Math.min(cardRef.current?.offsetWidth ?? maxWidth, maxWidth) : maxWidth
203
- const topMargin = overlayTopMargin(VIEWPORT_MARGIN, r, ANCHOR_GAP)
204
- const belowTop = Math.max(topMargin, r.bottom + ANCHOR_GAP)
205
- const above = Math.max(0, r.top - ANCHOR_GAP - topMargin)
206
- const below = Math.max(0, window.innerHeight - belowTop - VIEWPORT_MARGIN)
207
- const onTop = height > below && above > below
208
- const maxHeight = onTop ? above : below
209
- const left = Math.max(VIEWPORT_MARGIN, Math.min(r.left, window.innerWidth - width - VIEWPORT_MARGIN))
210
- const top = onTop ? r.top - ANCHOR_GAP - Math.min(height, maxHeight) : belowTop
211
- const bridgeTop = onTop ? top + Math.min(height, maxHeight) : r.bottom
212
- const bridgeLeft = Math.min(r.left, left)
213
- setPos({
214
- left, top, ...fitContent ? {} : { width }, maxWidth, maxHeight,
215
- bridge: {
216
- left: bridgeLeft, top: bridgeTop,
217
- width: Math.max(r.right, left + width) - bridgeLeft,
218
- height: Math.max(0, (onTop ? r.top : top) - bridgeTop),
219
- },
220
- })
221
- return
222
- }
223
- const top = r.top + h > window.innerHeight - VIEWPORT_MARGIN ? window.innerHeight - h - VIEWPORT_MARGIN : r.top
224
- setPos({ left: r.right + ANCHOR_GAP, top })
213
+ const height = Math.max(h, cardRef.current?.scrollHeight ?? 0)
214
+ const maxWidth = Math.max(0, Math.min(INLINE_PREVIEW_WIDTH, window.innerWidth - VIEWPORT_MARGIN * 2))
215
+ const width = fitContent ? Math.min(cardRef.current?.offsetWidth ?? maxWidth, maxWidth) : maxWidth
216
+ const topMargin = overlayTopMargin(VIEWPORT_MARGIN, r, ANCHOR_GAP)
217
+ const belowTop = Math.max(topMargin, r.bottom + ANCHOR_GAP)
218
+ const above = Math.max(0, r.top - ANCHOR_GAP - topMargin)
219
+ const below = Math.max(0, window.innerHeight - belowTop - VIEWPORT_MARGIN)
220
+ const onTop = height > below && above > below
221
+ const maxHeight = onTop ? above : below
222
+ const left = Math.max(VIEWPORT_MARGIN, Math.min(r.left, window.innerWidth - width - VIEWPORT_MARGIN))
223
+ const top = onTop ? r.top - ANCHOR_GAP - Math.min(height, maxHeight) : belowTop
224
+ const bridgeTop = onTop ? top + Math.min(height, maxHeight) : r.bottom
225
+ const bridgeLeft = Math.min(r.left, left)
226
+ setPos({
227
+ left, top, ...fitContent ? {} : { width }, maxWidth, maxHeight,
228
+ bridge: {
229
+ left: bridgeLeft, top: bridgeTop,
230
+ width: Math.max(r.right, left + width) - bridgeLeft,
231
+ height: Math.max(0, (onTop ? r.top : top) - bridgeTop),
232
+ },
233
+ })
225
234
  }
226
235
  place()
227
236
  // Observe only the anchor's ancestors: an offscreen drawer can hide without resizing its retained row.
@@ -229,31 +238,21 @@ export function HoverCard({
229
238
  for (let ancestor = rootRef.current?.parentElement; ancestor != null; ancestor = ancestor.parentElement) {
230
239
  visibility.observe(ancestor, { attributes: true, attributeFilter: ['inert', 'hidden'] })
231
240
  }
232
- const observer = (variant === 'preview' || inline) && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(place) : null
241
+ const observer = !compact && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(place) : null
233
242
  for (const element of [cardRef.current, rootRef.current, widthAnchorRef?.current]) {
234
243
  if (element !== null && element !== undefined) observer?.observe(element)
235
244
  }
236
- window.addEventListener('scroll', place, true)
237
- window.addEventListener('resize', place)
245
+ if (!compact) {
246
+ window.addEventListener('scroll', place, true)
247
+ window.addEventListener('resize', place)
248
+ }
238
249
  return () => {
239
250
  observer?.disconnect()
240
251
  visibility.disconnect()
241
252
  window.removeEventListener('scroll', place, true)
242
253
  window.removeEventListener('resize', place)
243
254
  }
244
- }, [open, variant, widthAnchorRef, positioned, inline, fitContent, dismissImmediately])
245
-
246
- // The first placement ran before the card mounted (height read 0): once the
247
- // card's real height is measurable, correct the bottom-edge clamp. The
248
- // correction converges — a clamped top satisfies the guard, so it runs once.
249
- useLayoutEffect(() => {
250
- if (!open || pos === null || variant === 'preview' || inline) return
251
- /* v8 ignore next -- the card is mounted whenever pos is set, so the ref is attached here. */
252
- const h = cardRef.current?.offsetHeight ?? 0
253
- if (pos.top + h > window.innerHeight - VIEWPORT_MARGIN) {
254
- setPos({ left: pos.left, top: window.innerHeight - h - VIEWPORT_MARGIN })
255
- }
256
- }, [open, pos, variant, inline])
255
+ }, [open, compact, variant, widthAnchorRef, positioned, fitContent, dismissImmediately])
257
256
 
258
257
  const copy = async (text: string): Promise<void> => {
259
258
  if (copied || copyingRef.current) return
@@ -280,9 +279,13 @@ export function HoverCard({
280
279
  const card = open && pos !== null && (
281
280
  <div
282
281
  ref={cardRef}
283
- className={clsx(css.card, variant === 'preview' && css.preview, inline && css.media, inline && fitContent && css.fitContent, copyable && css.copyable, copied && css.feedback)}
282
+ className={clsx(
283
+ css.card, compact && css.compact, variant === 'preview' && css.preview, inline && css.media, inline && fitContent && css.fitContent,
284
+ copyable && css.copyable, copied && css.feedback,
285
+ )}
284
286
  data-closing={closing || undefined}
285
287
  style={{
288
+ positionAnchor: compact ? anchorName : undefined,
286
289
  left: pos.left, top: pos.top, width: pos.width, maxWidth: pos.maxWidth, maxHeight: pos.maxHeight,
287
290
  minHeight: copied && copyHeightRef.current !== null ? copyHeightRef.current : undefined,
288
291
  '--dsh-hover-preview-fade': `${PREVIEW_FADE_MS}ms`,
@@ -317,6 +320,7 @@ export function HoverCard({
317
320
  <span
318
321
  ref={rootRef}
319
322
  className={clsx(css.root, inline && css.inline)}
323
+ style={compact && open ? { anchorName } : undefined}
320
324
  onFocus={inline ? (event) => {
321
325
  if (!disabled && event.target.matches(':focus-visible')) { cancelClose(); setPhase('open') }
322
326
  } : undefined}
@@ -2,6 +2,7 @@ import type { HTMLAttributes } from 'react'
2
2
  import { useEffect, useRef } from 'react'
3
3
  import { createPortal } from 'react-dom'
4
4
  import { IconCloseOutlineRegular } from './icons/index.tsx'
5
+ import { menuPopupSelector } from './useModalLayer.ts'
5
6
  import css from './ImageLightbox.module.css'
6
7
 
7
8
  /** Lightbox strings the owner resolves from its own locale namespace. */
@@ -41,7 +42,7 @@ export function ImageLightbox({ src, alt, labels, onClose, contextMenuProps }: {
41
42
  closeRef.current?.focus()
42
43
  const onKeyDown = (event: globalThis.KeyboardEvent): void => {
43
44
  // A portaled image menu owns Escape and Tab until it returns focus.
44
- if (event.defaultPrevented || document.activeElement?.closest('[role="menu"]')) return
45
+ if (event.defaultPrevented || document.activeElement?.closest(menuPopupSelector)) return
45
46
  if (event.key === 'Escape') { event.stopPropagation(); onClose() }
46
47
  if (event.key === 'Tab') { event.preventDefault(); closeRef.current?.focus() }
47
48
  }
@@ -34,5 +34,11 @@
34
34
  }
35
35
 
36
36
  .input::placeholder {
37
- color: var(--dsw-alias-label-dimmed);
37
+ color: var(--dsw-alias-label-tertiary);
38
+ }
39
+
40
+ @media (pointer: coarse) {
41
+ .input {
42
+ font-size: 16px;
43
+ }
38
44
  }
package/src/LinkIcon.tsx CHANGED
@@ -53,25 +53,25 @@ export function classifyLinkPath(path: string): LinkIconKind {
53
53
 
54
54
  const PhotoGlyph = ({ size, className, strokeWidth }: IconProps & { strokeWidth: number }) => (
55
55
  <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}>
56
- <path d="M12.4326 2.38086H3.56763C2.46306 2.38086 1.56763 3.27629 1.56763 4.38086V11.6192C1.56763 12.7237 2.46306 13.6192 3.56763 13.6192H12.4326C13.5372 13.6192 14.4326 12.7237 14.4326 11.6192V4.38086C14.4326 3.27629 13.5372 2.38086 12.4326 2.38086Z" stroke="currentColor" />
57
- <path d="M10.536 7.03286C11.1948 7.03286 11.7288 6.49884 11.7288 5.8401C11.7288 5.18136 11.1948 4.64734 10.536 4.64734C9.87728 4.64734 9.34326 5.18136 9.34326 5.8401C9.34326 6.49884 9.87728 7.03286 10.536 7.03286Z" stroke="currentColor" />
58
- <path d="M1.5979 9.28409L4.17738 7.37514C4.57462 7.08117 5.12701 7.12145 5.47741 7.46992L8.3322 10.309C8.6572 10.6323 9.1605 10.6931 9.5532 10.4566L10.8859 9.65399C11.2531 9.43289 11.7205 9.47039 12.0477 9.74729L14.2823 11.6379" stroke="currentColor" />
56
+ <path vectorEffect="non-scaling-stroke" d="M12.4326 2.38086H3.56763C2.46306 2.38086 1.56763 3.27629 1.56763 4.38086V11.6192C1.56763 12.7237 2.46306 13.6192 3.56763 13.6192H12.4326C13.5372 13.6192 14.4326 12.7237 14.4326 11.6192V4.38086C14.4326 3.27629 13.5372 2.38086 12.4326 2.38086Z" stroke="currentColor" />
57
+ <path vectorEffect="non-scaling-stroke" d="M10.536 7.03286C11.1948 7.03286 11.7288 6.49884 11.7288 5.8401C11.7288 5.18136 11.1948 4.64734 10.536 4.64734C9.87728 4.64734 9.34326 5.18136 9.34326 5.8401C9.34326 6.49884 9.87728 7.03286 10.536 7.03286Z" stroke="currentColor" />
58
+ <path vectorEffect="non-scaling-stroke" d="M1.5979 9.28409L4.17738 7.37514C4.57462 7.08117 5.12701 7.12145 5.47741 7.46992L8.3322 10.309C8.6572 10.6323 9.1605 10.6931 9.5532 10.4566L10.8859 9.65399C11.2531 9.43289 11.7205 9.47039 12.0477 9.74729L14.2823 11.6379" stroke="currentColor" />
59
59
  </svg>
60
60
  )
61
61
 
62
62
  const PaperDocGlyph = ({ size, className, strokeWidth }: IconProps & { strokeWidth: number }) => (
63
63
  <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}>
64
- <path d="M3.51919 14.5069H12.4807C13.0679 14.5069 13.5438 14.031 13.5438 13.4438V5.97499C13.5438 5.68818 13.428 5.41352 13.2226 5.21341L9.71251 1.79459C9.51402 1.60124 9.24781 1.49304 8.97075 1.49304H3.51919C2.93204 1.49304 2.45605 1.96902 2.45605 2.55618V13.4438C2.45605 14.031 2.93203 14.5069 3.51919 14.5069Z" stroke="currentColor" />
65
- <path d="M8.90454 1.6095V4.87091C8.90454 5.45806 9.38051 5.93405 9.96768 5.93405H13.4953" stroke="currentColor" />
66
- <path d="M4.31152 8.7561H7.83046" stroke="currentColor" />
67
- <path d="M4.31152 11.3651H9.36598" stroke="currentColor" />
64
+ <path vectorEffect="non-scaling-stroke" d="M3.51919 14.5069H12.4807C13.0679 14.5069 13.5438 14.031 13.5438 13.4438V5.97499C13.5438 5.68818 13.428 5.41352 13.2226 5.21341L9.71251 1.79459C9.51402 1.60124 9.24781 1.49304 8.97075 1.49304H3.51919C2.93204 1.49304 2.45605 1.96902 2.45605 2.55618V13.4438C2.45605 14.031 2.93203 14.5069 3.51919 14.5069Z" stroke="currentColor" />
65
+ <path vectorEffect="non-scaling-stroke" d="M8.90454 1.6095V4.87091C8.90454 5.45806 9.38051 5.93405 9.96768 5.93405H13.4953" stroke="currentColor" />
66
+ <path vectorEffect="non-scaling-stroke" d="M4.31152 8.7561H7.83046" stroke="currentColor" />
67
+ <path vectorEffect="non-scaling-stroke" d="M4.31152 11.3651H9.36598" stroke="currentColor" />
68
68
  </svg>
69
69
  )
70
70
 
71
71
  const PaperGlyph = ({ size, className, strokeWidth }: IconProps & { strokeWidth: number }) => (
72
72
  <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}>
73
- <path d="M3.75275 14.271H12.2473C12.7749 14.271 13.2027 13.8433 13.2027 13.3156V5.91732C13.2027 5.65958 13.0985 5.41276 12.9139 5.23293L9.59477 2.00011C9.4164 1.82636 9.17717 1.72913 8.9282 1.72913H3.75275C3.22511 1.72913 2.79736 2.15686 2.79736 2.68451V13.3156C2.79736 13.8433 3.22511 14.271 3.75275 14.271Z" stroke="currentColor" />
74
- <path d="M8.84888 1.83838V4.94133C8.84888 5.46896 9.2766 5.89671 9.80426 5.89671H13.157" stroke="currentColor" />
73
+ <path vectorEffect="non-scaling-stroke" d="M3.75275 14.271H12.2473C12.7749 14.271 13.2027 13.8433 13.2027 13.3156V5.91732C13.2027 5.65958 13.0985 5.41276 12.9139 5.23293L9.59477 2.00011C9.4164 1.82636 9.17717 1.72913 8.9282 1.72913H3.75275C3.22511 1.72913 2.79736 2.15686 2.79736 2.68451V13.3156C2.79736 13.8433 3.22511 14.271 3.75275 14.271Z" stroke="currentColor" />
74
+ <path vectorEffect="non-scaling-stroke" d="M8.84888 1.83838V4.94133C8.84888 5.46896 9.2766 5.89671 9.80426 5.89671H13.157" stroke="currentColor" />
75
75
  </svg>
76
76
  )
77
77
 
@@ -0,0 +1,47 @@
1
+ /* Single-line text that clips with an ellipsis at rest. While it marquees
2
+ (data-marquee), the ellipsis drops, the inner span travels to the far edge
3
+ over the distance and time the hook measured, and both clipping edges fade
4
+ in over 12px instead of hard-cutting a character. */
5
+ .text {
6
+ display: block;
7
+ min-width: 0;
8
+ overflow: hidden;
9
+ text-overflow: ellipsis;
10
+ white-space: nowrap;
11
+ }
12
+
13
+ /* At the far edge the end fade lifts so the final character reads at full
14
+ strength: a zero-length animation, delayed by the travel's duration, swaps
15
+ the mask and holds it. */
16
+ .text[data-marquee] {
17
+ text-overflow: clip;
18
+ mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 12px), transparent);
19
+ animation: dsh-marquee-arrive 0s var(--dsh-marquee-duration) forwards;
20
+ }
21
+
22
+ @keyframes dsh-marquee-arrive {
23
+ to { mask-image: linear-gradient(to right, transparent, #000 12px); }
24
+ }
25
+
26
+ /* Inline at rest, so the ellipsis cuts between characters; a transform needs a box. */
27
+ .text[data-marquee] > .travel {
28
+ display: inline-block;
29
+ animation: dsh-marquee-travel var(--dsh-marquee-duration) linear forwards;
30
+ }
31
+
32
+ @keyframes dsh-marquee-travel {
33
+ to { transform: translateX(calc(-1 * var(--dsh-marquee-range))); }
34
+ }
35
+
36
+ /* Reduced motion shows the far edge at once, so only the start edge hides text. */
37
+ @media (prefers-reduced-motion: reduce) {
38
+ .text[data-marquee] {
39
+ mask-image: linear-gradient(to right, transparent, #000 12px);
40
+ animation: none;
41
+ }
42
+
43
+ .text[data-marquee] > .travel {
44
+ animation: none;
45
+ transform: translateX(calc(-1 * var(--dsh-marquee-range)));
46
+ }
47
+ }
@@ -0,0 +1,109 @@
1
+ // Hover marquee for single-line text that its cell clips: while the pointer is
2
+ // on the owning row, a CSS animation carries the text to its far edge, and
3
+ // leaving returns it to the start.
4
+
5
+ import { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react'
6
+ import type { HTMLAttributes, PointerEvent, RefObject } from 'react'
7
+ import clsx from 'clsx'
8
+ import css from './Marquee.module.css'
9
+
10
+ /* Overflow this small hides no meaningful tail; travelling for it reads as an
11
+ accidental jitter, so the text stays put. */
12
+ const MIN_REVEAL_PX = 8
13
+
14
+ /* Travel speed: slow enough to read the text as it passes. */
15
+ const PX_PER_MS = 0.03
16
+
17
+ /** Pointer handlers of the row whose hover marquees one text; spread them onto the row. */
18
+ export interface HoverMarquee {
19
+ /** Start the travel; touch pointers and text that fits do nothing. */
20
+ readonly onPointerEnter: (event: PointerEvent) => void
21
+ /** Return the text to its start in one step, unless the marquee is held. */
22
+ readonly onPointerLeave: () => void
23
+ }
24
+
25
+ /** Options of {@link useHoverMarquee}. */
26
+ export interface HoverMarqueeOptions {
27
+ /** Marquee the text while true, with or without the pointer on the row, such as while the row's menu is open. */
28
+ readonly hold?: boolean | undefined
29
+ }
30
+
31
+ /**
32
+ * Start the text's travel unless it already marquees: measure how far the text
33
+ * overflows its cell, and hand the stylesheet that distance and the time it
34
+ * takes at the constant speed.
35
+ * @param text - the clipping text element.
36
+ */
37
+ function travel(text: HTMLElement): void {
38
+ if (text.dataset.marquee !== undefined) return
39
+ const range = text.scrollWidth - text.clientWidth
40
+ if (range <= MIN_REVEAL_PX) return
41
+ text.style.setProperty('--dsh-marquee-range', `${range}px`)
42
+ text.style.setProperty('--dsh-marquee-duration', `${Math.round(range / PX_PER_MS)}ms`)
43
+ text.dataset.marquee = ''
44
+ }
45
+
46
+ /**
47
+ * Return the text to its resting state: at its start, with the ellipsis and
48
+ * without fades.
49
+ * @param text - the clipping text element.
50
+ */
51
+ function rest(text: HTMLElement): void {
52
+ delete text.dataset.marquee
53
+ text.style.removeProperty('--dsh-marquee-range')
54
+ text.style.removeProperty('--dsh-marquee-duration')
55
+ }
56
+
57
+ /**
58
+ * Marquee one-line text wider than its cell while the pointer is on its row:
59
+ * the text travels at 30px/s until its far edge is in view, then rests there
60
+ * under the pointer. Overflow of at most 8px stays put. Leaving returns the
61
+ * text to the start in one step, because the resting ellipsis and the narrowed
62
+ * cell would otherwise meet the text while it travelled back. The stylesheet
63
+ * animates the travel and its fades, so the script only measures the overflow
64
+ * once per entry; reduced motion shows the far edge at once.
65
+ * @param text - ref to the clipping text element, a {@link MarqueeText}.
66
+ * @param options - whether the marquee is held without the pointer.
67
+ * @returns stable pointer enter and leave handlers for the row.
68
+ */
69
+ export function useHoverMarquee(text: RefObject<HTMLElement | null>, { hold = false }: HoverMarqueeOptions = {}): HoverMarquee {
70
+ const hovered = useRef(false)
71
+ const held = useRef(hold)
72
+ const sync = useCallback((): void => {
73
+ const element = text.current
74
+ if (element === null) return
75
+ if (hovered.current || held.current) travel(element)
76
+ else rest(element)
77
+ }, [text])
78
+ useEffect(() => {
79
+ held.current = hold
80
+ sync()
81
+ }, [hold, sync])
82
+ return useMemo(() => ({
83
+ onPointerEnter: (event: PointerEvent): void => {
84
+ if (event.pointerType === 'touch') return
85
+ hovered.current = true
86
+ sync()
87
+ },
88
+ onPointerLeave: (): void => {
89
+ hovered.current = false
90
+ sync()
91
+ },
92
+ }), [sync])
93
+ }
94
+
95
+ /** Props of single-line text that a {@link useHoverMarquee} can marquee. */
96
+ export type MarqueeTextProps = HTMLAttributes<HTMLSpanElement>
97
+
98
+ /**
99
+ * Render single-line text that clips with an ellipsis at rest and, while a
100
+ * {@link useHoverMarquee} marquees it, drops the ellipsis and fades whichever
101
+ * edge still hides text. The children sit in an inner span, which travels.
102
+ */
103
+ export const MarqueeText = forwardRef<HTMLSpanElement, MarqueeTextProps>(function MarqueeText({ className, children, ...attributes }, ref) {
104
+ return (
105
+ <span {...attributes} ref={ref} className={clsx(css.text, className)}>
106
+ <span className={css.travel}>{children}</span>
107
+ </span>
108
+ )
109
+ })