@opencode/ui 2.2.5 → 2.2.7

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 (119) hide show
  1. package/dist/actions/button/button.d.ts +2 -2
  2. package/dist/actions/icon-button/icon-button.d.ts +1 -1
  3. package/dist/components/animated-number-machine.d.ts +95 -0
  4. package/dist/components/file-icon-machine.d.ts +40 -0
  5. package/dist/components/file-icon.d.ts +0 -2
  6. package/dist/components/file-icons/choose-icon-name.d.ts +2 -0
  7. package/dist/components/image-flight-machine.d.ts +135 -0
  8. package/dist/components/image-zoom-machine.d.ts +95 -0
  9. package/dist/components/image-zoom.d.ts +6 -3
  10. package/dist/components/list.d.ts +2 -6
  11. package/dist/components/menu-scroll.d.ts +9 -3
  12. package/dist/components/popover-machine.d.ts +96 -0
  13. package/dist/components/popover.d.ts +2 -2
  14. package/dist/components/resize-handle-machine.d.ts +71 -0
  15. package/dist/components/resize-handle.d.ts +2 -0
  16. package/dist/components/scroll-view-machine.d.ts +68 -0
  17. package/dist/components/scroll-view.d.ts +2 -2
  18. package/dist/components/spinner.d.ts +11 -3
  19. package/dist/components/text-field-machine.d.ts +62 -0
  20. package/dist/components/text-reveal-machine.d.ts +90 -0
  21. package/dist/components/typewriter-machine.d.ts +62 -0
  22. package/dist/context/dialog-machine.d.ts +125 -0
  23. package/dist/context/dialog.d.ts +17 -16
  24. package/dist/data-display/line-comment/machine.d.ts +157 -0
  25. package/dist/data-display/project-avatar/animation-machine.d.ts +62 -0
  26. package/dist/data-display/project-avatar/animation.d.ts +1 -1
  27. package/dist/feedback/activity-ring/activity-ring.d.ts +2 -1
  28. package/dist/feedback/toast/machine.d.ts +57 -0
  29. package/dist/feedback/toast/toast.d.ts +1 -1
  30. package/dist/forms/checkbox/checkbox.d.ts +6 -1
  31. package/dist/forms/select/machine.d.ts +45 -0
  32. package/dist/forms/select/select.d.ts +4 -0
  33. package/dist/forms/typeahead/machine.d.ts +85 -0
  34. package/dist/hooks/auto-scroll-machine.d.ts +89 -0
  35. package/dist/hooks/create-auto-scroll.d.ts +1 -1
  36. package/dist/hooks/list-machine.d.ts +150 -0
  37. package/dist/hooks/use-filtered-list.d.ts +21 -35
  38. package/dist/i18n/en.d.ts +5 -0
  39. package/dist/icons/catalog.d.ts +8 -0
  40. package/dist/navigation/menu/machine.d.ts +49 -0
  41. package/dist/navigation/menu/menu.d.ts +5 -3
  42. package/dist/navigation/segmented-control/machine.d.ts +46 -0
  43. package/dist/overlays/mcp-sign-in/machine.d.ts +184 -0
  44. package/dist/overlays/mcp-sign-in/mcp-sign-in.d.ts +40 -0
  45. package/dist/overlays/tooltip/machine.d.ts +146 -0
  46. package/dist/theme/context.d.ts +38 -14
  47. package/dist/theme/machine.d.ts +174 -0
  48. package/dist/typography/text-shimmer/machine.d.ts +48 -0
  49. package/package.json +128 -111
  50. package/src/actions/button/button.tsx +11 -6
  51. package/src/actions/icon-button/icon-button.tsx +17 -4
  52. package/src/components/animated-number-machine.ts +214 -0
  53. package/src/components/animated-number.tsx +134 -83
  54. package/src/components/file-icon-machine.ts +78 -0
  55. package/src/components/file-icon.tsx +96 -579
  56. package/src/components/file-icons/choose-icon-name.ts +574 -0
  57. package/src/components/image-flight-machine.ts +247 -0
  58. package/src/components/image-preview.css +5 -2
  59. package/src/components/image-preview.tsx +390 -252
  60. package/src/components/image-zoom-machine.ts +191 -0
  61. package/src/components/image-zoom.ts +22 -14
  62. package/src/components/list.tsx +46 -137
  63. package/src/components/menu-scroll.css +19 -8
  64. package/src/components/menu-scroll.tsx +111 -34
  65. package/src/components/popover-machine.ts +198 -0
  66. package/src/components/popover.tsx +157 -89
  67. package/src/components/resize-handle-machine.ts +174 -0
  68. package/src/components/resize-handle.tsx +116 -67
  69. package/src/components/scroll-view-machine.ts +244 -0
  70. package/src/components/scroll-view.tsx +163 -116
  71. package/src/components/spinner.css +18 -5
  72. package/src/components/spinner.tsx +28 -14
  73. package/src/components/text-field-machine.ts +102 -0
  74. package/src/components/text-field.tsx +78 -24
  75. package/src/components/text-reveal-machine.ts +184 -0
  76. package/src/components/text-reveal.tsx +96 -93
  77. package/src/components/typewriter-machine.ts +134 -0
  78. package/src/components/typewriter.tsx +50 -39
  79. package/src/context/dialog-machine.ts +280 -0
  80. package/src/context/dialog.tsx +168 -177
  81. package/src/data-display/line-comment/line-comment.tsx +157 -178
  82. package/src/data-display/line-comment/machine.ts +391 -0
  83. package/src/data-display/project-avatar/animation-machine.ts +182 -0
  84. package/src/data-display/project-avatar/animation.ts +67 -38
  85. package/src/feedback/activity-ring/activity-ring.tsx +1 -1
  86. package/src/feedback/toast/machine.ts +115 -0
  87. package/src/feedback/toast/toast.tsx +59 -59
  88. package/src/forms/checkbox/checkbox-compact.css +169 -0
  89. package/src/forms/checkbox/checkbox.tsx +93 -31
  90. package/src/forms/inline-input/inline-input.css +0 -1
  91. package/src/forms/search-list/search-list.css +5 -1
  92. package/src/forms/search-list/search-list.tsx +18 -10
  93. package/src/forms/select/machine.ts +81 -0
  94. package/src/forms/select/select.css +59 -17
  95. package/src/forms/select/select.tsx +74 -32
  96. package/src/forms/typeahead/machine.ts +253 -0
  97. package/src/forms/typeahead/typeahead.tsx +70 -62
  98. package/src/hooks/auto-scroll-machine.ts +261 -0
  99. package/src/hooks/create-auto-scroll.tsx +110 -205
  100. package/src/hooks/list-machine.ts +359 -0
  101. package/src/hooks/use-filtered-list.tsx +101 -112
  102. package/src/i18n/en.ts +6 -1
  103. package/src/i18n/uk.ts +3 -3
  104. package/src/icons/catalog.ts +8 -0
  105. package/src/navigation/menu/machine.ts +109 -0
  106. package/src/navigation/menu/menu.tsx +133 -22
  107. package/src/navigation/segmented-control/machine.ts +72 -0
  108. package/src/navigation/segmented-control/segmented-control.tsx +46 -46
  109. package/src/overlays/dialog/dialog.tsx +7 -1
  110. package/src/overlays/mcp-sign-in/machine.ts +343 -0
  111. package/src/overlays/mcp-sign-in/mcp-sign-in.ts +159 -0
  112. package/src/overlays/tooltip/machine.ts +303 -0
  113. package/src/overlays/tooltip/tooltip.tsx +159 -92
  114. package/src/styles/theme.css +10 -2
  115. package/src/theme/context.tsx +192 -269
  116. package/src/theme/machine.ts +508 -0
  117. package/src/typography/text-shimmer/machine.ts +90 -0
  118. package/src/typography/text-shimmer/text-shimmer.css +71 -39
  119. package/src/typography/text-shimmer/text-shimmer.tsx +41 -24
@@ -0,0 +1,68 @@
1
+ export declare const SCROLL_IDLE_MS = 800;
2
+ export type ScrollAxis = "vertical" | "horizontal";
3
+ /**
4
+ * `scrolling` shows the thumb until `SCROLL_IDLE_MS` after the last scroll. `dragging` holds the pointer on one thumb;
5
+ * `scrolled` records a scroll during the drag, so its release keeps the thumb up for the idle delay. A thumb exists
6
+ * only while its axis overflows, so losing that overflow ends a drag on it.
7
+ */
8
+ export type ScrollThumbState = {
9
+ readonly status: "idle" | "scrolling";
10
+ readonly hovered: boolean;
11
+ readonly verticalOverflow: boolean;
12
+ readonly horizontalOverflow: boolean;
13
+ } | {
14
+ readonly status: "dragging";
15
+ readonly axis: ScrollAxis;
16
+ readonly pointerId: number;
17
+ readonly grabOffset: number;
18
+ readonly rtl: boolean;
19
+ readonly hovered: boolean;
20
+ readonly scrolled: boolean;
21
+ readonly verticalOverflow: boolean;
22
+ readonly horizontalOverflow: boolean;
23
+ } | {
24
+ readonly status: "disposed";
25
+ };
26
+ export type ScrollThumbEvent = {
27
+ readonly type: "hover.changed";
28
+ readonly hovered: boolean;
29
+ } | {
30
+ readonly type: "scrolled";
31
+ } | {
32
+ readonly type: "idle.elapsed";
33
+ } | {
34
+ readonly type: "overflow.changed";
35
+ readonly vertical: boolean;
36
+ readonly horizontal: boolean;
37
+ } | {
38
+ readonly type: "drag.started";
39
+ readonly axis: ScrollAxis;
40
+ readonly pointerId: number;
41
+ readonly grabOffset: number;
42
+ readonly rtl: boolean;
43
+ } | {
44
+ readonly type: "drag.ended";
45
+ readonly pointerId: number;
46
+ } | {
47
+ readonly type: "disposed";
48
+ };
49
+ export type ScrollThumbEffect = "reset-idle-timer" | "clear-idle-timer" | "release-capture";
50
+ export type ScrollThumbTransition = {
51
+ readonly state: ScrollThumbState;
52
+ readonly effects: readonly ScrollThumbEffect[];
53
+ };
54
+ export declare const INITIAL_SCROLL_THUMB_STATE: ScrollThumbState;
55
+ export declare const SCROLLED: ScrollThumbEvent;
56
+ export declare const SCROLL_IDLE_ELAPSED: ScrollThumbEvent;
57
+ export declare const HOVER_ENTERED: ScrollThumbEvent;
58
+ export declare const HOVER_LEFT: ScrollThumbEvent;
59
+ export declare const SCROLL_THUMB_DISPOSED: ScrollThumbEvent;
60
+ export declare function overflowChanged(vertical: boolean, horizontal: boolean): ScrollThumbEvent;
61
+ export declare function transitionScrollThumb(state: ScrollThumbState, event: ScrollThumbEvent): ScrollThumbTransition;
62
+ export declare function selectShowVerticalThumb(state: ScrollThumbState): boolean;
63
+ export declare function selectShowHorizontalThumb(state: ScrollThumbState): boolean;
64
+ /** Scroll-only reveal: a drag shows the thumb through `selectDraggingAxis` instead. */
65
+ export declare function selectThumbScrolling(state: ScrollThumbState): boolean;
66
+ export declare function selectDraggingAxis(state: ScrollThumbState): ScrollAxis | undefined;
67
+ /** `hoverReveals` is the `hover` visibility mode; in `scroll` mode only scrolling and dragging show the thumb. */
68
+ export declare function selectThumbVisible(state: ScrollThumbState, hoverReveals: boolean): boolean;
@@ -1,4 +1,4 @@
1
- import { type ComponentProps } from "solid-js";
1
+ import { type ComponentProps, type JSX } from "solid-js";
2
2
  export type ScrollViewThumbVisibility = "hover" | "scroll";
3
3
  export interface ScrollViewProps extends ComponentProps<"div"> {
4
4
  viewportRef?: (el: HTMLDivElement) => void;
@@ -47,4 +47,4 @@ export declare function scrollOffsetFromThumbPointer(input: {
47
47
  * A scroll container that draws its own thumb, for a thumb in an external track or one corrected for virtualized
48
48
  * rows. Everything else scrolls with a plain `overflow: auto` element, which `styles/scrollbar.css` already styles.
49
49
  */
50
- export declare function ScrollView(props: ScrollViewProps): import("solid-js").JSX.Element;
50
+ export declare function ScrollView(props: ScrollViewProps): JSX.Element;
@@ -1,4 +1,12 @@
1
- import { type ComponentProps } from "solid-js";
2
- export declare function Spinner(props: ComponentProps<"svg"> & {
1
+ import { type ComponentProps, type JSX } from "solid-js";
2
+ /**
3
+ * Each dot is its own SVG over the whole box, drawn exactly where it sat in one SVG. The compositor runs the opacity
4
+ * animation of an SVG element but not of a shape inside one, so a spinner no longer restyles and repaints on every
5
+ * frame. `width` and `height` size it like an SVG's attributes, below any CSS size.
6
+ */
7
+ export declare function Spinner(props: Omit<ComponentProps<"span">, "style"> & {
3
8
  "data-component"?: string;
4
- }): import("solid-js").JSX.Element;
9
+ width?: number;
10
+ height?: number;
11
+ style?: JSX.CSSProperties;
12
+ }): JSX.Element;
@@ -0,0 +1,62 @@
1
+ export declare const TEXT_FIELD_COPIED_MS = 2000;
2
+ /** A clipboard write that never settles gives up, so the button can copy again. */
3
+ export declare const TEXT_FIELD_COPY_TIMEOUT_MS = 2000;
4
+ export type TextFieldCopyKind = "clipboard" | "link";
5
+ /**
6
+ * The copy button's feedback. `copying` claims the click before the write starts, so a second click waits for it;
7
+ * `keepCopied` keeps the checkmark of an earlier copy while a repeat copy settles. `attempt` lets only the latest
8
+ * write, its timeout and its own reset timer move the button.
9
+ */
10
+ export type TextFieldCopyState = {
11
+ readonly status: "idle";
12
+ readonly issued: number;
13
+ } | {
14
+ readonly status: "copying";
15
+ readonly attempt: number;
16
+ readonly keepCopied: boolean;
17
+ } | {
18
+ readonly status: "copied";
19
+ readonly attempt: number;
20
+ } | {
21
+ readonly status: "disposed";
22
+ };
23
+ export type TextFieldCopyEvent = {
24
+ readonly type: "copy.requested";
25
+ readonly value: string;
26
+ readonly enabled: boolean;
27
+ } | {
28
+ readonly type: "copy.succeeded";
29
+ readonly attempt: number;
30
+ } | {
31
+ readonly type: "copy.failed";
32
+ readonly attempt: number;
33
+ } | {
34
+ readonly type: "copy.timed-out";
35
+ readonly attempt: number;
36
+ } | {
37
+ readonly type: "reset.elapsed";
38
+ readonly attempt: number;
39
+ } | {
40
+ readonly type: "disposed";
41
+ };
42
+ export type TextFieldCopyEffect = {
43
+ readonly type: "clipboard.write";
44
+ readonly attempt: number;
45
+ readonly value: string;
46
+ readonly timeoutMs: number;
47
+ } | {
48
+ readonly type: "reset.schedule";
49
+ readonly attempt: number;
50
+ readonly delayMs: number;
51
+ } | {
52
+ readonly type: "timer.clear";
53
+ };
54
+ export type TextFieldCopyTransition = {
55
+ readonly state: TextFieldCopyState;
56
+ readonly effects: readonly TextFieldCopyEffect[];
57
+ };
58
+ export declare const INITIAL_TEXT_FIELD_COPY_STATE: TextFieldCopyState;
59
+ export declare function transitionTextFieldCopy(state: TextFieldCopyState, event: TextFieldCopyEvent): TextFieldCopyTransition;
60
+ export declare function selectTextFieldCopied(state: TextFieldCopyState): boolean;
61
+ export declare function selectTextFieldCopyLabelKey(state: TextFieldCopyState, kind: TextFieldCopyKind | undefined): "ui.textField.copied" | "ui.textField.copyLink" | "ui.textField.copyToClipboard";
62
+ export declare function selectTextFieldCopyIcon(state: TextFieldCopyState, kind: TextFieldCopyKind | undefined): "check" | "copy" | "link";
@@ -0,0 +1,90 @@
1
+ /** Fonts that never settle must not keep the reveal from animating. */
2
+ export declare const TEXT_REVEAL_READY_TIMEOUT_MS = 1000;
3
+ /**
4
+ * `measuring` waits for fonts and one painted frame before transitions turn on, so the first text never animates in.
5
+ * It only moves forward, so its results match on the phase. `swapping` holds a replaced text in place for one frame,
6
+ * then the wipe runs. `leaving` is always text that was on screen, so text replaced within one frame never wipes out.
7
+ */
8
+ export type TextRevealState = {
9
+ readonly status: "measuring";
10
+ readonly current: string | undefined;
11
+ readonly widthPx: number;
12
+ } | {
13
+ readonly status: "idle";
14
+ readonly issued: number;
15
+ readonly current: string | undefined;
16
+ readonly leaving: string | undefined;
17
+ readonly widthPx: number;
18
+ } | {
19
+ readonly status: "swapping";
20
+ readonly attempt: number;
21
+ readonly current: string | undefined;
22
+ readonly leaving: string | undefined;
23
+ readonly widthPx: number;
24
+ } | {
25
+ readonly status: "disposed";
26
+ };
27
+ type Measured = {
28
+ readonly widthPx: number;
29
+ readonly growOnly: boolean;
30
+ };
31
+ export type TextRevealEvent = {
32
+ readonly type: "text.changed";
33
+ readonly text: string | undefined;
34
+ } | ({
35
+ readonly type: "width.measured";
36
+ } & Measured) | ({
37
+ readonly type: "fonts.settled";
38
+ } & Measured) | ({
39
+ readonly type: "ready.settled";
40
+ } & Measured) | ({
41
+ readonly type: "ready.timed-out";
42
+ } & Measured) | ({
43
+ readonly type: "swap.settled";
44
+ readonly attempt: number;
45
+ } & Measured) | {
46
+ readonly type: "disposed";
47
+ };
48
+ export type TextRevealEffect = {
49
+ readonly type: "measure.entering";
50
+ } | {
51
+ readonly type: "ready.frame";
52
+ } | {
53
+ readonly type: "swap.frame";
54
+ readonly attempt: number;
55
+ } | {
56
+ readonly type: "cancel.frame";
57
+ } | {
58
+ readonly type: "cancel.ready-timer";
59
+ };
60
+ export type TextRevealTransition = {
61
+ readonly state: TextRevealState;
62
+ readonly effects: readonly TextRevealEffect[];
63
+ };
64
+ export declare function createTextRevealState(text: string | undefined): TextRevealState;
65
+ export declare function transitionTextReveal(state: TextRevealState, event: TextRevealEvent): TextRevealTransition;
66
+ /** Transitions turn on once the first text has painted. */
67
+ export declare function selectTextRevealReady(state: TextRevealState): state is {
68
+ readonly status: "idle";
69
+ readonly issued: number;
70
+ readonly current: string | undefined;
71
+ readonly leaving: string | undefined;
72
+ readonly widthPx: number;
73
+ } | {
74
+ readonly status: "swapping";
75
+ readonly attempt: number;
76
+ readonly current: string | undefined;
77
+ readonly leaving: string | undefined;
78
+ readonly widthPx: number;
79
+ };
80
+ export declare function selectTextRevealSwapping(state: TextRevealState): state is {
81
+ readonly status: "swapping";
82
+ readonly attempt: number;
83
+ readonly current: string | undefined;
84
+ readonly leaving: string | undefined;
85
+ readonly widthPx: number;
86
+ };
87
+ export declare function selectTextRevealEntering(state: TextRevealState): string;
88
+ export declare function selectTextRevealLeaving(state: TextRevealState): string;
89
+ export declare function selectTextRevealTrackWidth(state: TextRevealState, truncate: boolean | undefined): string;
90
+ export {};
@@ -0,0 +1,62 @@
1
+ export declare const TYPEWRITER_INITIAL_DELAY_MS = 200;
2
+ export declare const TYPEWRITER_LINGER_MS = 2000;
3
+ export type TypewriterCursor = "none" | "solid" | "blinking";
4
+ /**
5
+ * `typing` shows the first `index` characters behind a solid cursor; `index` 0 is the pause before the first one.
6
+ * `lingering` shows the whole text behind a blinking cursor, then `done` hides the cursor.
7
+ */
8
+ export type TypewriterState = {
9
+ readonly status: "empty";
10
+ readonly attempts: number;
11
+ } | {
12
+ readonly status: "typing";
13
+ readonly attempt: number;
14
+ readonly text: string;
15
+ /** Code points, so a step never shows half of a surrogate pair. */
16
+ readonly chars: readonly string[];
17
+ readonly index: number;
18
+ } | {
19
+ readonly status: "lingering";
20
+ readonly attempt: number;
21
+ readonly text: string;
22
+ } | {
23
+ readonly status: "done";
24
+ readonly attempts: number;
25
+ readonly text: string;
26
+ } | {
27
+ readonly status: "disposed";
28
+ };
29
+ export type TypewriterEvent = {
30
+ readonly type: "sync";
31
+ readonly text: string | undefined;
32
+ readonly reducedMotion: boolean;
33
+ } | {
34
+ readonly type: "typing.step";
35
+ readonly attempt: number;
36
+ } | {
37
+ readonly type: "linger.ended";
38
+ readonly attempt: number;
39
+ } | {
40
+ readonly type: "disposed";
41
+ };
42
+ export type TypewriterEffect = {
43
+ readonly type: "none";
44
+ } | {
45
+ readonly type: "clear";
46
+ } | {
47
+ readonly type: "schedule";
48
+ readonly kind: "initial" | "step" | "linger";
49
+ readonly attempt: number;
50
+ };
51
+ export type TypewriterTransition = {
52
+ readonly state: TypewriterState;
53
+ readonly effect: TypewriterEffect;
54
+ };
55
+ export declare const INITIAL_EMPTY_TYPEWRITER_STATE: TypewriterState;
56
+ export declare const DISPOSED_TYPEWRITER_STATE: TypewriterState;
57
+ export declare const DISPOSED_TYPEWRITER_EVENT: TypewriterEvent;
58
+ /** Mostly quick keystrokes, with an occasional hesitation. `roll` and `jitter` are uniform in [0, 1). */
59
+ export declare function typingStepDelayMs(roll: number, jitter: number): number;
60
+ export declare function transitionTypewriter(state: TypewriterState, event: TypewriterEvent): TypewriterTransition;
61
+ export declare function selectTypewriterDisplayed(state: TypewriterState): string;
62
+ export declare function selectTypewriterCursor(state: TypewriterState): TypewriterCursor;
@@ -0,0 +1,125 @@
1
+ /** How long a dialog stays mounted once it starts closing, unless its layer asks for longer. */
2
+ export declare const DIALOG_EXIT_MS = 100;
3
+ /**
4
+ * `attempt` identifies one mount, so a reused caller `id` never collides with a layer that is still closing. `focus` is
5
+ * where focus returns: where it was before this dialog opened, or before the dialogs it replaced opened. `replaced`
6
+ * holds the attempts of the open dialogs this one replaced through `show`, and theirs in turn, so a close from inside
7
+ * one of them closes this dialog.
8
+ */
9
+ export type DialogOpenEntry<F = unknown> = {
10
+ readonly status: "open";
11
+ readonly attempt: number;
12
+ readonly id: string;
13
+ readonly exitMs: number;
14
+ readonly backdropDismiss: boolean;
15
+ readonly focus: F | undefined;
16
+ readonly replaced: readonly number[];
17
+ };
18
+ /** Waits for its exit animation. It keeps `focus` so a `show` that replaces it still returns focus to the origin. */
19
+ export type DialogClosingEntry<F = unknown> = {
20
+ readonly status: "closing";
21
+ readonly attempt: number;
22
+ readonly id: string;
23
+ readonly focus: F | undefined;
24
+ readonly replaced: readonly number[];
25
+ };
26
+ export type DialogEntry<F = unknown> = DialogOpenEntry<F> | DialogClosingEntry<F>;
27
+ export type DialogStackState<F = unknown> = {
28
+ readonly status: "active";
29
+ readonly issued: number;
30
+ readonly entries: readonly DialogEntry<F>[];
31
+ } | {
32
+ readonly status: "disposed";
33
+ readonly issued: number;
34
+ };
35
+ /** `request` is the driver's content for the open; the machine only hands it back in `mount` or `discard`. */
36
+ export type DialogStackEvent<F = unknown, R = unknown> = {
37
+ readonly type: "open";
38
+ readonly mode: "show" | "push";
39
+ readonly id: string;
40
+ readonly aborted: boolean;
41
+ readonly focus: F | undefined;
42
+ readonly request: R;
43
+ }
44
+ /**
45
+ * With `id`, closes the newest open dialog with that id. Without one, `layer` is the attempt of the dialog that asked:
46
+ * that dialog closes itself, even under a dialog that is still exiting, or the dialog that replaced it through `show`.
47
+ * Once that dialog is gone, a late close (after an await) closes nothing. A close from outside every dialog closes the
48
+ * newest dialog. Both close one at a time: while the target plays its exit animation, a second close (a double click,
49
+ * a callback closing again) closes nothing below it.
50
+ */
51
+ | {
52
+ readonly type: "close";
53
+ readonly id?: string;
54
+ readonly layer?: number;
55
+ }
56
+ /** Escape, or a dismissal that applies only while `id` is the top open dialog. */
57
+ | {
58
+ readonly type: "dismiss";
59
+ readonly id?: string;
60
+ }
61
+ /** A click on one layer's backdrop. */
62
+ | {
63
+ readonly type: "backdrop.click";
64
+ readonly attempt: number;
65
+ }
66
+ /** Kobalte asking one layer to close, as its close button does. */
67
+ | {
68
+ readonly type: "layer.dismiss";
69
+ readonly attempt: number;
70
+ } | {
71
+ readonly type: "layer.backdrop-dismiss";
72
+ readonly attempt: number;
73
+ readonly enabled: boolean;
74
+ } | {
75
+ readonly type: "layer.exit-duration";
76
+ readonly attempt: number;
77
+ readonly exitMs: number;
78
+ } | {
79
+ readonly type: "exit.completed";
80
+ readonly attempt: number;
81
+ } | {
82
+ readonly type: "disposed";
83
+ };
84
+ export type DialogStackEffect<F = unknown, R = unknown> = {
85
+ readonly type: "mount";
86
+ readonly attempt: number;
87
+ readonly id: string;
88
+ readonly request: R;
89
+ } | {
90
+ readonly type: "discard";
91
+ readonly request: R;
92
+ readonly notify: boolean;
93
+ } | {
94
+ readonly type: "timer.start";
95
+ readonly attempt: number;
96
+ readonly delayMs: number;
97
+ } | {
98
+ readonly type: "timer.stop";
99
+ readonly attempt: number;
100
+ } | {
101
+ readonly type: "notify.close";
102
+ readonly attempt: number;
103
+ } | {
104
+ readonly type: "focus.return";
105
+ readonly attempt: number;
106
+ readonly focus: F | undefined;
107
+ } | {
108
+ readonly type: "dispose";
109
+ readonly attempt: number;
110
+ readonly notify: boolean;
111
+ };
112
+ export type DialogStackTransition<F = unknown, R = unknown> = {
113
+ readonly state: DialogStackState<F>;
114
+ readonly effects: readonly DialogStackEffect<F, R>[];
115
+ };
116
+ export declare function createDialogStackState<F = unknown>(): DialogStackState<F>;
117
+ export declare function transitionDialogStack<F, R>(state: DialogStackState<F>, event: DialogStackEvent<F, R>): DialogStackTransition<F, R>;
118
+ /** The top dialog that is open. One that started closing no longer counts, though it waits to be disposed. */
119
+ export declare function selectTopDialog<F>(state: DialogStackState<F>): DialogOpenEntry<F> | undefined;
120
+ /** True from the moment a layer starts closing, through its exit animation, and once it is gone. */
121
+ export declare function selectLayerClosing<F>(state: DialogStackState<F>, attempt: number): boolean;
122
+ /** Stacked dialogs render as sibling portals, so only the top open layer may own the focus trap. */
123
+ export declare function selectLayerModal<F>(state: DialogStackState<F>, attempt: number, contained: boolean): boolean;
124
+ /** The layer's place in the stack, so a newer dialog always renders above. */
125
+ export declare function selectLayerIndex<F>(state: DialogStackState<F>, attempt: number): number;
@@ -1,24 +1,16 @@
1
- import { type Owner, type ParentProps, type JSX } from "solid-js";
1
+ import { type Accessor, type ParentProps, type JSX } from "solid-js";
2
2
  type DialogElement = () => JSX.Element;
3
- type FocusReturn = {
3
+ export type FocusReturn = {
4
4
  element: HTMLElement;
5
5
  visible: boolean;
6
6
  range?: Range;
7
7
  };
8
- type Active = {
9
- id: string;
10
- node: JSX.Element;
11
- dispose: () => void;
12
- owner: Owner;
13
- onClose?: () => void;
14
- setClosing: (closing: boolean) => void;
15
- /** How long the dialog stays mounted once it starts closing, so its exit animation can finish. */
16
- exit: () => number;
17
- /** Where focus was before this dialog opened, or before the dialogs it replaced opened. */
18
- focus?: FocusReturn;
19
- returnFocus: () => void;
20
- };
21
8
  export declare function useDialogLayer(): {
9
+ readonly id: string;
10
+ /** This layer's mount, which a `close()` from inside it targets. */
11
+ readonly attempt: number;
12
+ /** True from the moment this dialog starts closing, through its exit animation. */
13
+ readonly closing: Accessor<boolean>;
22
14
  setBackdropDismiss: (value: boolean) => void;
23
15
  setExitDuration: (ms: number) => void;
24
16
  container?: HTMLElement;
@@ -32,13 +24,22 @@ export declare function DialogProvider(props: ParentProps<{
32
24
  }>): JSX.Element;
33
25
  export declare function useDialog(): {
34
26
  /** The top dialog that is open. One that has started closing no longer counts, though it waits to be disposed. */
35
- readonly active: Active | undefined;
27
+ readonly active: import("./dialog-machine").DialogOpenEntry<FocusReturn> | undefined;
28
+ /** Inside a dialog, true from the moment that dialog starts closing; outside every dialog, false. */
29
+ readonly closing: boolean;
36
30
  /**
37
31
  * id lets the caller close this dialog later rather than whichever is on top. Opening is deferred; once
38
32
  * signal aborts, the open neither mounts nor replaces anything and onClose runs as for a replaced dialog.
39
33
  */
40
34
  show(element: DialogElement, onClose?: () => void, id?: string, signal?: AbortSignal): Promise<void>;
41
35
  push(element: DialogElement, onClose?: () => void, id?: string, signal?: AbortSignal): Promise<void>;
36
+ /**
37
+ * Programmatic close. With an id it closes that dialog at once. Without one, called inside a dialog, it closes that
38
+ * dialog, or the dialog that replaced it through `show`, and nothing once it is gone; outside every dialog it closes
39
+ * the top one. Either way one at a time, so a double click closes one dialog.
40
+ */
42
41
  close(id?: string): void;
42
+ /** Dismisses the top open dialog, as Escape does; with an id, only while that dialog is on top. */
43
+ dismiss(id?: string): void;
43
44
  };
44
45
  export {};
@@ -0,0 +1,157 @@
1
+ export declare const MENTION_LIMIT = 10;
2
+ /** A file search that never answers stops holding Enter and Tab after this long. */
3
+ export declare const MENTION_TIMEOUT_MS = 5000;
4
+ /** The `@query` the caret sits at the end of, and where it starts and ends in the value. */
5
+ export type MentionToken = {
6
+ readonly query: string;
7
+ readonly start: number;
8
+ readonly end: number;
9
+ };
10
+ /** The editor props the machine reads, captured when the event happens. */
11
+ export type LineCommentEditorConfig = {
12
+ readonly value: string;
13
+ readonly allowEmpty: boolean;
14
+ readonly variant: "default" | "compact";
15
+ readonly alternateSubmit: {
16
+ readonly disabled: boolean;
17
+ } | null;
18
+ readonly submitting: boolean;
19
+ };
20
+ /**
21
+ * `alternate` is whether Mod is held over a compact editor with an alternate submit. `attempt` counts mention
22
+ * searches; only the search a `mention-loading` state started may settle it.
23
+ */
24
+ export type LineCommentEditorState = {
25
+ readonly status: "editing";
26
+ readonly attempt: number;
27
+ readonly alternate: boolean;
28
+ /** A token the user closed with Escape, or that found nothing, stays closed while the caret stays on it. */
29
+ readonly dismissed: {
30
+ readonly start: number;
31
+ readonly query: string;
32
+ } | null;
33
+ } | {
34
+ readonly status: "mention-loading";
35
+ readonly attempt: number;
36
+ readonly alternate: boolean;
37
+ readonly token: MentionToken;
38
+ /** The previous results while the user refines the same token, so the list does not flash between keystrokes. */
39
+ readonly items: readonly string[];
40
+ readonly activeIndex: number;
41
+ } | {
42
+ readonly status: "mention-open";
43
+ readonly attempt: number;
44
+ readonly alternate: boolean;
45
+ readonly token: MentionToken;
46
+ /** Never empty, and at most `MENTION_LIMIT`: every item is on screen. */
47
+ readonly items: readonly string[];
48
+ readonly activeIndex: number;
49
+ }
50
+ /** The owner set `submitting`: the draft is read-only until it clears. */
51
+ | {
52
+ readonly status: "submitting";
53
+ readonly attempt: number;
54
+ readonly alternate: boolean;
55
+ } | {
56
+ readonly status: "disposed";
57
+ };
58
+ export type LineCommentEditorKey = {
59
+ readonly key: string;
60
+ readonly ctrl: boolean;
61
+ readonly meta: boolean;
62
+ readonly alt: boolean;
63
+ readonly shift: boolean;
64
+ readonly repeat: boolean;
65
+ };
66
+ export type LineCommentEditorEvent =
67
+ /** Props changed, or the owner replaced the value; `token` is read from the textarea after the change. */
68
+ {
69
+ readonly type: "props.synced";
70
+ readonly config: LineCommentEditorConfig;
71
+ readonly token: MentionToken | null;
72
+ }
73
+ /** The user typed or moved the caret. `token` is null without a `mention` prop. */
74
+ | {
75
+ readonly type: "mention.synced";
76
+ readonly token: MentionToken | null;
77
+ } | {
78
+ readonly type: "mention.loaded";
79
+ readonly attempt: number;
80
+ readonly items: readonly string[];
81
+ } | {
82
+ readonly type: "mention.failed";
83
+ readonly attempt: number;
84
+ } | {
85
+ readonly type: "mention.timeout";
86
+ readonly attempt: number;
87
+ } | {
88
+ readonly type: "mention.hovered";
89
+ readonly index: number;
90
+ } | {
91
+ readonly type: "mention.selected";
92
+ readonly index: number;
93
+ } | {
94
+ readonly type: "modifier.changed";
95
+ readonly active: boolean;
96
+ readonly config: LineCommentEditorConfig;
97
+ } | {
98
+ readonly type: "window.blurred";
99
+ }
100
+ /** A key outside an IME composition, in the textarea or on the compact action. */
101
+ | (LineCommentEditorKey & {
102
+ readonly type: "key.down";
103
+ readonly target: "textarea" | "action";
104
+ readonly config: LineCommentEditorConfig;
105
+ }) | {
106
+ readonly type: "action.clicked";
107
+ readonly modified: boolean;
108
+ readonly config: LineCommentEditorConfig;
109
+ }
110
+ /** The default layout's Submit button. */
111
+ | {
112
+ readonly type: "submit.requested";
113
+ readonly config: LineCommentEditorConfig;
114
+ }
115
+ /** The default layout's Cancel button. */
116
+ | {
117
+ readonly type: "cancel.requested";
118
+ } | {
119
+ readonly type: "disposed";
120
+ };
121
+ export type LineCommentEditorEffect = {
122
+ readonly type: "mention.load";
123
+ readonly attempt: number;
124
+ readonly query: string;
125
+ } | {
126
+ readonly type: "mention.insert";
127
+ readonly path: string;
128
+ readonly token: MentionToken;
129
+ } | {
130
+ readonly type: "submit";
131
+ readonly mode: "primary" | "alternate";
132
+ readonly value: string;
133
+ } | {
134
+ readonly type: "cancel";
135
+ readonly blur: boolean;
136
+ };
137
+ export type LineCommentEditorTransition = {
138
+ readonly state: LineCommentEditorState;
139
+ readonly effects: readonly LineCommentEditorEffect[];
140
+ /** The key event belongs to the editor: the driver calls `preventDefault()`. */
141
+ readonly handled: boolean;
142
+ };
143
+ export declare function createLineCommentEditorState(): LineCommentEditorState;
144
+ /** The mention token the caret sits at the end of, or null for a selection, a bare `@`, or no `@` at all. */
145
+ export declare function parseMentionToken(value: string, selectionStart: number | null, selectionEnd: number | null): MentionToken | null;
146
+ export declare function transitionLineCommentEditor(state: LineCommentEditorState, event: LineCommentEditorEvent): LineCommentEditorTransition;
147
+ export declare function viewLineCommentEditor(state: LineCommentEditorState, config: LineCommentEditorConfig): {
148
+ readonly submitting: boolean;
149
+ readonly canSubmit: boolean;
150
+ readonly compactCancel: boolean;
151
+ readonly alternateActive: boolean;
152
+ readonly trackModifiers: boolean;
153
+ readonly compactVariant: "ghost-muted" | "neutral" | "submit";
154
+ readonly compactDisabled: boolean;
155
+ readonly mentionItems: readonly string[];
156
+ readonly activeMentionPath: string | null;
157
+ };