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

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 +8 -8
  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
@@ -0,0 +1,37 @@
1
+ /** Menu search input with a leading magnifier and an optional clear button. */
2
+ import type { ComponentPropsWithoutRef, Ref } from 'react'
3
+ import clsx from 'clsx'
4
+ import { IconCloseFillRegular, IconSearchOutlineRegular } from './icons/index.tsx'
5
+ import css from './SearchField.module.css'
6
+
7
+ /**
8
+ * Render a controlled search input.
9
+ * @param props - localized labels, input value and attributes, and optional clear button.
10
+ * @returns the search control with refs to its wrapper and native input.
11
+ */
12
+ export function SearchField({ inputRef, rootRef, className, placeholder, value, onChange, clearLabel, onClear, ...input }: {
13
+ inputRef?: Ref<HTMLInputElement>
14
+ rootRef?: Ref<HTMLDivElement>
15
+ className?: string | undefined
16
+ placeholder: string
17
+ value: string
18
+ onChange: (value: string) => void
19
+ clearLabel?: string | undefined
20
+ onClear: () => void
21
+ } & Pick<ComponentPropsWithoutRef<'input'>, 'aria-label' | 'role'>) {
22
+ return (
23
+ <div ref={rootRef} data-search-field="" className={clsx(css.field, className)}>
24
+ <span className={css.leading} aria-hidden="true"><IconSearchOutlineRegular size={14} /></span>
25
+ <input {...input} ref={inputRef} className={css.input} type="text" placeholder={placeholder} value={value}
26
+ onChange={(event) => { onChange(event.currentTarget.value) }} />
27
+ {clearLabel !== undefined && (
28
+ <button type="button" className={css.clear} aria-label={clearLabel} onClick={(event) => {
29
+ event.stopPropagation()
30
+ onClear()
31
+ }}>
32
+ <IconCloseFillRegular />
33
+ </button>
34
+ )}
35
+ </div>
36
+ )
37
+ }
@@ -38,14 +38,14 @@
38
38
  }
39
39
 
40
40
  @media (hover: hover) {
41
- .tab:hover {
41
+ .tab:hover:not(:disabled) {
42
42
  background: transparent;
43
43
  color: var(--dsw-alias-label-primary);
44
44
  }
45
45
  }
46
46
 
47
47
  .tab[aria-selected='true'] {
48
- font-weight: 600;
48
+ font-weight: 500;
49
49
  }
50
50
 
51
51
  .tabs[data-size='sm'] {
@@ -58,15 +58,9 @@
58
58
  height: 30px;
59
59
  }
60
60
 
61
- .tabs[data-size='sm'] .tab[aria-selected='true'] {
62
- font-weight: 500;
63
- }
64
-
65
61
  .tab:focus-visible {
66
- outline: none;
67
- text-decoration: underline;
68
- text-decoration-thickness: 1px;
69
- text-underline-offset: 4px;
62
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
63
+ outline-offset: -2px;
70
64
  }
71
65
 
72
66
  @media (prefers-reduced-motion: reduce) {
package/src/Switch.tsx CHANGED
@@ -13,9 +13,11 @@ import css from './Switch.module.css'
13
13
  * while a write is in flight, not only when a deployment locks the toggle.
14
14
  * @param props.title - localized hover text, typically why the toggle is locked.
15
15
  * @param props.className - extra class for layout placement.
16
+ * @param props.autoFocus - whether the control takes focus when it mounts enabled.
17
+ * @param props.describedBy - id of the element that describes the control.
16
18
  * @returns the switch element.
17
19
  */
18
- export function Switch({ checked, onChange, label, disabled = false, title, className }: {
20
+ export function Switch({ checked, onChange, label, disabled = false, title, className, autoFocus, describedBy }: {
19
21
  checked: boolean
20
22
  onChange: (next: boolean) => void
21
23
  label: string
@@ -24,6 +26,8 @@ export function Switch({ checked, onChange, label, disabled = false, title, clas
24
26
  // `| undefined` so a caller can forward an optional class straight through
25
27
  // under exactOptionalPropertyTypes (a CSS-module lookup is string|undefined).
26
28
  className?: string | undefined
29
+ autoFocus?: boolean
30
+ describedBy?: string | undefined
27
31
  }) {
28
32
  return (
29
33
  <button
@@ -31,8 +35,10 @@ export function Switch({ checked, onChange, label, disabled = false, title, clas
31
35
  role="switch"
32
36
  aria-checked={checked}
33
37
  aria-label={label}
38
+ aria-describedby={describedBy}
34
39
  title={title}
35
40
  disabled={disabled}
41
+ autoFocus={autoFocus}
36
42
  className={clsx(css.switch, className)}
37
43
  onClick={() => { onChange(!checked) }}
38
44
  >
@@ -236,9 +236,9 @@ export function TerminalBlock({
236
236
  data-running={running ? '' : undefined}
237
237
  data-body={body ? '' : undefined}
238
238
  >
239
- <div className={css.header}>
239
+ <div className={css.header} data-terminal-banner="">
240
240
  <div className={css.prompt}>
241
- {showState && <span className={css.runStateLabel}>{state.label}</span>}
241
+ {showState && <span className={css.runStateLabel} data-terminal-state-label="">{state.label}</span>}
242
242
  {commandLines.map((line, index) => (
243
243
  <div key={index} className={css.promptLine}>
244
244
  {/* One dot for the card, on the first row: the exit status the
@@ -252,7 +252,7 @@ export function TerminalBlock({
252
252
  command is enough), so repeating the label down the rows would
253
253
  assert a directory per line that nothing here knows. Later
254
254
  rows keep a bare `$` to stay aligned as prompts. */}
255
- <span className={css.cwd}>
255
+ <span className={css.cwd} data-terminal-prompt="">
256
256
  {index > 0 || cwd === undefined ? '$' : promptLabel(cwd, home)}
257
257
  </span>
258
258
  <CommandText className={css.command} text={line} label={copy.commandLine(index + 1)} />
@@ -269,7 +269,7 @@ export function TerminalBlock({
269
269
  {body && (empty
270
270
  ? <div className={css.empty}>{copy.noOutput}</div>
271
271
  : (
272
- <div className={css.output}>
272
+ <div className={css.output} data-terminal-output="">
273
273
  {(capped ? lines.slice(0, headLines) : lines).map((line, index) => (
274
274
  <div key={index} className={css.line}>{renderLine(line)}</div>
275
275
  ))}
package/src/clipboard.ts CHANGED
@@ -1,10 +1,28 @@
1
1
  // Host clipboard write shared by Web UI copy controls. Success feedback stays
2
- // with each control; this helper only reports whether the host accepted a write.
2
+ // with each control; this helper reports whether the host accepted a write and
3
+ // leaves focus where it found it.
4
+
5
+ /**
6
+ * Attempt the async Clipboard API write.
7
+ * @param text - the exact text to place on the clipboard.
8
+ * @returns true only when the host accepted the write.
9
+ */
10
+ async function writeWithClipboardApi(text: string): Promise<boolean> {
11
+ try {
12
+ await navigator.clipboard.writeText(text)
13
+ } catch (_error) {
14
+ // A denied permission can block the async API while execCommand still works; the caller tries it below.
15
+ return false
16
+ }
17
+ return true
18
+ }
3
19
 
4
20
  /**
5
21
  * Write text to the host clipboard, preferring the async Clipboard API and
6
- * falling back to `execCommand('copy')` on hosts (jsdom, insecure contexts)
7
- * that omit it.
22
+ * falling back to `execCommand('copy')` when that API is missing (jsdom,
23
+ * insecure contexts) or refuses the write (for example, a denied clipboard
24
+ * permission). The fallback replaces the page selection and succeeds only while
25
+ * the triggering user gesture's transient activation is still valid.
8
26
  * @param text - the exact text to place on the clipboard.
9
27
  * @returns true only when the host accepted the write.
10
28
  */
@@ -12,36 +30,32 @@ export async function writeClipboard(text: string): Promise<boolean> {
12
30
  // lib.dom types clipboard non-optional, but insecure contexts omit it —
13
31
  // that runtime gap is exactly what this guard detects.
14
32
  /* oxlint-disable-next-line typescript/no-unnecessary-condition */
15
- if (navigator.clipboard?.writeText) {
16
- try {
17
- await navigator.clipboard.writeText(text)
18
- return true
19
- } catch {
20
- // Denied permissions / iframe policy — do not claim success.
21
- return false
22
- }
33
+ if (typeof navigator.clipboard?.writeText === 'function') {
34
+ if (await writeWithClipboardApi(text)) return true
23
35
  }
24
- // jsdom and older hosts: best-effort execCommand path when present.
25
36
  // execCommand('copy') is the only clipboard fallback where the async API
26
- // is missing; deprecated but deliberately retained.
37
+ // is missing or refused; deprecated but deliberately retained.
27
38
  /* oxlint-disable typescript/no-deprecated */
28
39
  const exec = typeof document.execCommand === 'function'
29
40
  ? document.execCommand.bind(document)
30
41
  : undefined
31
42
  if (exec === undefined) return false
43
+ // Selecting the textarea moves focus; return it so a keyboard user stays on the copy control.
44
+ const focused = document.activeElement
32
45
  const el = document.createElement('textarea')
33
46
  el.value = text
34
47
  el.setAttribute('readonly', '')
35
48
  el.style.position = 'fixed'
36
49
  el.style.left = '-9999px'
37
- document.body.appendChild(el)
38
- el.select()
39
50
  try {
51
+ document.body.appendChild(el)
52
+ el.select()
40
53
  return exec('copy')
41
54
  } catch {
42
55
  return false
43
56
  } finally {
44
57
  el.remove()
58
+ if (focused instanceof HTMLElement) focused.focus({ preventScroll: true })
45
59
  }
46
60
  /* oxlint-enable typescript/no-deprecated */
47
61
  }