@young1lin/dsh-ui-gitworkbench 0.1.11 → 0.1.13

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 (36) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/CHANGELOG_EN.md +28 -0
  4. package/README.md +100 -50
  5. package/README_EN.md +2 -1
  6. package/lib/client.js +6902 -6256
  7. package/package.json +1 -1
  8. package/src/client/ChangesFileTree.tsx +550 -0
  9. package/src/client/ChromeGlyph.tsx +27 -0
  10. package/src/client/CodeEditor.tsx +129 -3
  11. package/src/client/CommitHistory.tsx +1001 -0
  12. package/src/client/DiffViews.tsx +1070 -0
  13. package/src/client/GitWorkbenchPanel.module.css +15 -2513
  14. package/src/client/GitWorkbenchPanel.tsx +37 -3959
  15. package/src/client/PaneDivider.tsx +74 -0
  16. package/src/client/WorkbenchControls.tsx +1047 -0
  17. package/src/client/WorktreeGlyph.tsx +24 -0
  18. package/src/client/cm-search-theme.ts +250 -0
  19. package/src/client/diff-nav.ts +59 -0
  20. package/src/client/git-workbench-types.ts +252 -0
  21. package/src/client/locales.ts +14 -8
  22. package/src/client/row-window.ts +23 -0
  23. package/src/client/search-count.ts +125 -0
  24. package/src/client/side-rows.ts +66 -0
  25. package/src/client/styles/changes.css +505 -0
  26. package/src/client/styles/controls.css +236 -0
  27. package/src/client/styles/environment.css +89 -0
  28. package/src/client/styles/files.css +113 -0
  29. package/src/client/styles/history-filters.css +400 -0
  30. package/src/client/styles/history.css +276 -0
  31. package/src/client/styles/image.css +67 -0
  32. package/src/client/styles/operations.css +179 -0
  33. package/src/client/styles/shell.css +431 -0
  34. package/src/client/styles/themes.css +224 -0
  35. package/src/client/use-change-nav.ts +6 -5
  36. package/src/client/use-row-window.ts +55 -0
@@ -0,0 +1,74 @@
1
+ import { useState, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react'
2
+
3
+ import css from './GitWorkbenchPanel.module.css'
4
+
5
+ /**
6
+ * One pointer-captured horizontal drag, shared by the drawer's leading edge and
7
+ * both pane dividers.
8
+ *
9
+ * Pointer capture is what keeps a drag alive over every pane and past the window
10
+ * edge; a plain mousemove listener on the handle loses it as soon as the pointer
11
+ * crosses a child that stops propagation.
12
+ * @returns the active flag for styling, and the pointerdown handler to attach.
13
+ */
14
+ export function usePaneDrag(axis: 'x' | 'y' = 'x'): {
15
+ dragging: boolean
16
+ start: (event: ReactPointerEvent<HTMLElement>, onDrag: (position: number, done: boolean) => void) => void
17
+ } {
18
+ const along = (event: { clientX: number; clientY: number }): number =>
19
+ axis === 'y' ? event.clientY : event.clientX
20
+ const [dragging, setDragging] = useState(false)
21
+ const start = (event: ReactPointerEvent<HTMLElement>, onDrag: (position: number, done: boolean) => void): void => {
22
+ event.preventDefault()
23
+ const handle = event.currentTarget
24
+ handle.setPointerCapture(event.pointerId)
25
+ setDragging(true)
26
+ const onMove = (move: PointerEvent): void => { onDrag(along(move), false) }
27
+ // `pointercancel` ends a drag the browser took over (a touch became a
28
+ // gesture, the window lost focus). It releases capture itself, so only the
29
+ // pointerup path releases — and both must detach, or the next drag stacks a
30
+ // second set of listeners on the same handle.
31
+ const finish = (end: PointerEvent): void => {
32
+ if (end.type === 'pointerup') {
33
+ onDrag(along(end), true)
34
+ handle.releasePointerCapture(end.pointerId)
35
+ }
36
+ handle.removeEventListener('pointermove', onMove)
37
+ handle.removeEventListener('pointerup', finish)
38
+ handle.removeEventListener('pointercancel', finish)
39
+ setDragging(false)
40
+ }
41
+ handle.addEventListener('pointermove', onMove)
42
+ handle.addEventListener('pointerup', finish)
43
+ handle.addEventListener('pointercancel', finish)
44
+ }
45
+ return { dragging, start }
46
+ }
47
+
48
+ /**
49
+ * Drag handle between two panes.
50
+ * @param label - accessible name.
51
+ * @param onDrag - receives the pointer's x and whether the drag just ended.
52
+ * @returns the divider element.
53
+ */
54
+ export function PaneDivider({ label, onDrag, axis = 'x' }: {
55
+ label: string
56
+ /** clientX for an 'x' handle, clientY for a 'y' one. */
57
+ onDrag: (position: number, done: boolean) => void
58
+ /** Which way the handle moves. 'y' is the History tab's stacked split. */
59
+ axis?: 'x' | 'y'
60
+ }): ReactNode {
61
+ const { dragging, start } = usePaneDrag(axis)
62
+ const base = axis === 'y' ? `${css.paneDivider} ${css.paneDividerY}` : css.paneDivider
63
+ return (
64
+ <div
65
+ className={dragging ? `${base} ${css.paneDividerActive}` : base}
66
+ role="separator"
67
+ // The orientation a separator reports is the axis it SEPARATES along,
68
+ // which is the opposite of the one it slides on.
69
+ aria-orientation={axis === 'y' ? 'horizontal' : 'vertical'}
70
+ aria-label={label}
71
+ onPointerDown={event => start(event, onDrag)}
72
+ />
73
+ )
74
+ }