@shortround/react 0.6.0 → 0.8.0
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.
- package/CHANGELOG.md +27 -0
- package/README.md +37 -6
- package/dist/react.es.js +324 -279
- package/package.json +3 -3
- package/src/index.d.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @shortround/react
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- The palette follows the store's highlight only: cmdk's own first row no longer runs when the store highlights
|
|
8
|
+
nothing, so Enter goes to the store (with a producer, it asks it). See MIGRATING.md, 0.8.0.
|
|
9
|
+
- While the user's chosen row holds (`isHighlightChosen`), rows that arrive are drawn below it, and a group whose rows
|
|
10
|
+
sit apart has its heading drawn again where they sit.
|
|
11
|
+
- During a run the input is empty and a Status row says what runs; a run that rejects shows its error under the input
|
|
12
|
+
and is logged (`ShortRoundPalette: an intention failed`), where 0.7.0 left the rejection unhandled.
|
|
13
|
+
- Tab completes the highlighted completion row, else the first.
|
|
14
|
+
- Takes `@shortround/core` `^0.8.0` as a peer.
|
|
15
|
+
|
|
16
|
+
## 0.7.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- The palette follows core's Enter rule: with no row highlighted, Enter goes to the store (`pressEnter()`), so a line
|
|
21
|
+
that reads two ways, or held free text, runs nothing until the user picks a row, and a `confirm` command asks on the
|
|
22
|
+
first Enter and runs on the second. The arrows and the pointer still pick a row. See MIGRATING.md, 0.7.0.
|
|
23
|
+
- The palette passes the store's `enterLine` (what Enter will do) to the theme's `IntentionPalette.Input` slot; its
|
|
24
|
+
props type gains `enterLine`.
|
|
25
|
+
- The palette's list leaves room for whatever grows above it (the theme's input with its Enter line), so its last
|
|
26
|
+
row isn't cut off. The theme's `Input` slot now renders inside a `<div>` the palette measures; a theme whose input
|
|
27
|
+
relied on being a direct child of the list's container may need its styles moved to that slot's own root.
|
|
28
|
+
- Takes `@shortround/core` `^0.7.0` as a peer.
|
|
29
|
+
|
|
3
30
|
## 0.6.0
|
|
4
31
|
|
|
5
32
|
### Breaking Changes
|
package/README.md
CHANGED
|
@@ -89,6 +89,11 @@ the input's position and text style. A theme's `data-role` rules should change o
|
|
|
89
89
|
words sit under the input's own text, so anything that changes a word's width (weight, size, font, letter spacing)
|
|
90
90
|
moves the words after it away from the caret.
|
|
91
91
|
|
|
92
|
+
On a typed line, the `IntentionPalette.Input` slot also receives `enterLine`: what Enter will do, in the catalog's
|
|
93
|
+
names ("↵ search grid", "↑↓ Choose …, then ↵", "Confirm: queue all?"; core's README, "The Enter line"). Show it
|
|
94
|
+
apart from `inputMessage`, each of its `words` in a `span` with `data-role` when it has a `role`, so the same rules
|
|
95
|
+
colour it as the input's words. It follows the highlight: after the arrows, it says what the row they moved to runs.
|
|
96
|
+
|
|
92
97
|
## Icons
|
|
93
98
|
|
|
94
99
|
An intention's `icon` is a name. Without anything more, the theme draws its own icon for that name (see the theme's
|
|
@@ -165,7 +170,9 @@ so it can't be typed in while that modal is open; give the modal `disableEnforce
|
|
|
165
170
|
`ModalProps={{ disableEnforceFocus: true }}` on a `Drawer`).
|
|
166
171
|
|
|
167
172
|
- **Cmd/Ctrl+K** opens it from anywhere, or brings focus back into it when it is already open.
|
|
168
|
-
`installKeyboardShortcuts={false}` turns off this global shortcut only.
|
|
173
|
+
`installKeyboardShortcuts={false}` turns off this global shortcut only. To name it in your own text, as the user's
|
|
174
|
+
keyboard has it, use core's `describeShortcut('K')` ("Cmd+K" on a Mac, "Ctrl+K" elsewhere), on the client: during a server
|
|
175
|
+
render it names the server's platform.
|
|
169
176
|
- On open, focus moves to its input (to the sidekick itself in compact size); on close, focus returns to where it
|
|
170
177
|
was, unless the user has since moved it elsewhere in the page. After a row is clicked, focus goes back to the
|
|
171
178
|
input, so typing carries on.
|
|
@@ -173,9 +180,24 @@ so it can't be typed in while that modal is open; give the modal `disableEnforce
|
|
|
173
180
|
the sidekick (a widget in the side panel) sees Escape first and can keep it with `event.preventDefault()`.
|
|
174
181
|
- **Enter** runs the highlighted row. After every new list the highlight is on the list's first enabled row of your
|
|
175
182
|
own, so the first Enter in a picker or a typed-text prompt runs it rather than Back. On a completion row (see Typed
|
|
176
|
-
input), Enter completes the input instead of running anything.
|
|
177
|
-
|
|
178
|
-
|
|
183
|
+
input), Enter completes the input instead of running anything. On a typed line, core's Enter rule decides first.
|
|
184
|
+
A line that reads several ways, a command declared `confirm`, a line read only through a rewrite, a near spelling
|
|
185
|
+
of a value (alone, `refnd`, or before its command's name, `in trnsit filter`), free text not declared `asTyped`, or a
|
|
186
|
+
lookup that could add a reading still loading beside one that could run leaves no row highlighted. Enter then runs
|
|
187
|
+
nothing, or for a `confirm` command, a rewritten line or a near spelling asks, so the next Enter runs it.
|
|
188
|
+
On a line Enter can't yet run or complete, your fallback rows aren't highlighted while Enter would ask your
|
|
189
|
+
producer, or while such a lookup loads; a line whose first word starts no command keeps its fallback row
|
|
190
|
+
highlighted while a lookup loads, unless the lookup is a `canStartCommand` param's. A line that can complete still
|
|
191
|
+
highlights its completion row. An arrow or the pointer highlights a row, and Enter runs it. That row stays
|
|
192
|
+
highlighted, in its place, while the text is the same and it still shows: rows a lookup brings then are drawn below
|
|
193
|
+
it, under their group's heading again when that group is already above. Once a row runs, the input
|
|
194
|
+
clears, and a Status row and the Enter line say "Running archive…" until it settles ("· ↵ waits until it finishes"
|
|
195
|
+
on the Enter line over a line typed meanwhile); no row is highlighted then, so Enter starts nothing more (an arrow, a click, Back and Cancel still act),
|
|
196
|
+
text typed meanwhile stays, and a run that rejects gives the text back with its error as the input's message (the
|
|
197
|
+
palette logs the rejection with `console.error`).
|
|
198
|
+
- **Tab**, with a catalog palette, first completes through the line (see Line hints): the completion row the arrows
|
|
199
|
+
reached, else the first. Otherwise it completes the input with the highlighted completion row, else the first enabled
|
|
200
|
+
one, when the list has one; otherwise Tab moves focus as usual.
|
|
179
201
|
- **Arrow keys** move through the rows and wrap around at either end. Back and Cancel, when a list shows them, are
|
|
180
202
|
drawn at the top under **Navigate** but come last for the keyboard: ArrowUp from the first row reaches them.
|
|
181
203
|
- It is announced as a dialog named by `title` (or "ShortRound"), and its controls carry `ControlLabels`.
|
|
@@ -477,10 +499,19 @@ const SIZES = ['compact', 'medium', 'full'];
|
|
|
477
499
|
const MySidekickComponents = {
|
|
478
500
|
IntentionPalette: {
|
|
479
501
|
Frame: ({ height, children }) => <div style={{ height }}>{children}</div>,
|
|
480
|
-
// `input` is ShortRound's input element; place it.
|
|
481
|
-
Input: ({ input, inputMessage }) => (
|
|
502
|
+
// `input` is ShortRound's input element; place it. `enterLine` says what Enter will do, on a typed line.
|
|
503
|
+
Input: ({ input, inputMessage, enterLine }) => (
|
|
482
504
|
<div>
|
|
483
505
|
{input}
|
|
506
|
+
{enterLine && (
|
|
507
|
+
<p>
|
|
508
|
+
{enterLine.words.map((word, index) => (
|
|
509
|
+
<span data-role={word.role} key={index}>
|
|
510
|
+
{word.text}
|
|
511
|
+
</span>
|
|
512
|
+
))}
|
|
513
|
+
</p>
|
|
514
|
+
)}
|
|
484
515
|
{inputMessage && <p>{inputMessage.text}</p>}
|
|
485
516
|
</div>
|
|
486
517
|
),
|
package/dist/react.es.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { createPaletteStore as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { jsx as i, jsxs as k, Fragment as
|
|
4
|
-
import
|
|
1
|
+
import { createPaletteStore as ke, createSidekickStore as te, cycleCorners as Oe, RevertIntentionIds as Ee, NAVIGATE_GROUP as Ie, ControlLabels as be } from "@shortround/core";
|
|
2
|
+
import { useRef as d, useSyncExternalStore as z, useEffect as x, createContext as ne, useContext as oe, useMemo as $, useCallback as N, useState as U, useLayoutEffect as A, createElement as Ce, forwardRef as Te } from "react";
|
|
3
|
+
import { jsx as i, jsxs as k, Fragment as Le } from "react/jsx-runtime";
|
|
4
|
+
import xe from "tiny-invariant";
|
|
5
5
|
import { motion as V } from "framer-motion";
|
|
6
|
-
import { Command as
|
|
7
|
-
function
|
|
6
|
+
import { Command as L, useCommandState as re } from "cmdk";
|
|
7
|
+
function se({
|
|
8
8
|
palette: e,
|
|
9
9
|
defaultIntentions: t,
|
|
10
10
|
resolveDefaultInput: n,
|
|
11
11
|
resolveDefaultFallbackInput: o
|
|
12
12
|
}) {
|
|
13
|
-
const r =
|
|
14
|
-
r.current || (r.current =
|
|
13
|
+
const r = d(null);
|
|
14
|
+
r.current || (r.current = ke({
|
|
15
15
|
palette: e,
|
|
16
16
|
defaultIntentions: t,
|
|
17
17
|
resolveDefaultInput: n,
|
|
18
18
|
resolveDefaultFallbackInput: o
|
|
19
19
|
}));
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
|
|
20
|
+
const s = r.current, c = z(s.subscribe, s.getState, s.getState);
|
|
21
|
+
return x(() => {
|
|
22
|
+
s.setDefaults({
|
|
23
23
|
palette: e,
|
|
24
24
|
defaultIntentions: t,
|
|
25
25
|
resolveDefaultInput: n,
|
|
26
26
|
resolveDefaultFallbackInput: o
|
|
27
27
|
});
|
|
28
|
-
}, [
|
|
28
|
+
}, [s, e, t, n, o]), x(() => s.watchResolver(), [s]), x(() => s.watchPalette(), [s, e]), { store: s, state: c, intentions: s.rows() };
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function At({
|
|
31
31
|
defaultIntentions: e,
|
|
32
32
|
resolveDefaultInput: t,
|
|
33
33
|
resolveDefaultFallbackInput: n
|
|
34
34
|
}) {
|
|
35
|
-
const { store: o, state: r, intentions:
|
|
35
|
+
const { store: o, state: r, intentions: s } = se({
|
|
36
36
|
defaultIntentions: e,
|
|
37
37
|
resolveDefaultInput: t,
|
|
38
38
|
resolveDefaultFallbackInput: n
|
|
@@ -41,15 +41,15 @@ function ft({
|
|
|
41
41
|
inputValue: r.inputValue,
|
|
42
42
|
inputMessage: r.inputMessage,
|
|
43
43
|
onInputChange: o.changeInput,
|
|
44
|
-
intentions:
|
|
44
|
+
intentions: s,
|
|
45
45
|
revertIntentions: r.revertIntentions,
|
|
46
|
-
dispatch: (
|
|
46
|
+
dispatch: (c) => o.select(c),
|
|
47
47
|
reset: o.reset,
|
|
48
48
|
back: o.back,
|
|
49
49
|
dispatchedStack: r.dispatchedStack
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const Y = 0.35, Ae = "100vh", _e = Object.freeze({
|
|
53
53
|
center: { top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
|
|
54
54
|
"top-left": { top: 0, left: 0 },
|
|
55
55
|
top: { top: 0, left: "50%", transform: "translateX(-50%)" },
|
|
@@ -59,13 +59,13 @@ const U = 0.35, ke = "100vh", Oe = Object.freeze({
|
|
|
59
59
|
"bottom-right": { bottom: 0, right: 0 },
|
|
60
60
|
bottom: { bottom: 0, left: "50%", transform: "translateX(-50%)" },
|
|
61
61
|
"bottom-left": { bottom: 0, left: 0 }
|
|
62
|
-
}),
|
|
62
|
+
}), Q = Object.freeze({
|
|
63
63
|
compact: { height: "auto" },
|
|
64
64
|
medium: { height: "50vh" },
|
|
65
|
-
full: { height:
|
|
66
|
-
}),
|
|
67
|
-
const n =
|
|
68
|
-
n.current = { onOpen: e },
|
|
65
|
+
full: { height: Ae }
|
|
66
|
+
}), ce = "ShortRound", Pe = ({ onOpen: e, installKeyboardShortcuts: t = !0 }) => {
|
|
67
|
+
const n = d({ onOpen: e });
|
|
68
|
+
n.current = { onOpen: e }, x(() => {
|
|
69
69
|
if (!t)
|
|
70
70
|
return;
|
|
71
71
|
const o = (r) => {
|
|
@@ -73,96 +73,111 @@ const U = 0.35, ke = "100vh", Oe = Object.freeze({
|
|
|
73
73
|
};
|
|
74
74
|
return document.addEventListener("keydown", o, { capture: !0 }), () => document.removeEventListener("keydown", o, { capture: !0 });
|
|
75
75
|
}, [t]);
|
|
76
|
-
},
|
|
77
|
-
function
|
|
78
|
-
const o =
|
|
79
|
-
!e && !o && !r.current && (r.current =
|
|
80
|
-
const
|
|
81
|
-
return /* @__PURE__ */ i(
|
|
76
|
+
}, ie = ne(null), F = () => oe(ie);
|
|
77
|
+
function De({ store: e, initial: t, children: n }) {
|
|
78
|
+
const o = F(), r = d(null);
|
|
79
|
+
!e && !o && !r.current && (r.current = te(t));
|
|
80
|
+
const s = e ?? o ?? r.current;
|
|
81
|
+
return /* @__PURE__ */ i(ie.Provider, { value: s, children: n });
|
|
82
82
|
}
|
|
83
83
|
function j(e = {}) {
|
|
84
|
-
const t =
|
|
84
|
+
const t = F();
|
|
85
85
|
let n = e.store || t;
|
|
86
|
-
const o =
|
|
87
|
-
n || (o.current || (o.current =
|
|
88
|
-
const r =
|
|
89
|
-
const { maxTotalWidth:
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
86
|
+
const o = d(null);
|
|
87
|
+
n || (o.current || (o.current = te(e.initial)), n = o.current);
|
|
88
|
+
const r = z(n.subscribe, n.get, n.get), s = $(() => {
|
|
89
|
+
const { maxTotalWidth: c, commandWidth: a, anchorOrigin: f, internalSidecarRenderer: m, size: l } = r, { height: g } = Q[l], S = `calc(${c} - ${a})`, w = (h) => n.set({ anchorOrigin: h }), R = () => {
|
|
90
|
+
w(Oe(f));
|
|
91
|
+
}, O = () => {
|
|
92
|
+
if (m)
|
|
93
|
+
return m();
|
|
94
94
|
};
|
|
95
95
|
return {
|
|
96
96
|
// Worked out from the origin, so a store created with only `anchorOrigin` opens there; a position stored
|
|
97
97
|
// beside it (a 0.3.0 workaround) is ignored.
|
|
98
|
-
anchorPosition:
|
|
98
|
+
anchorPosition: _e[f],
|
|
99
99
|
onOpen: () => n.set({ isOpen: !0 }),
|
|
100
|
-
setIsOpen: (
|
|
101
|
-
n.set({ isOpen:
|
|
100
|
+
setIsOpen: (h) => {
|
|
101
|
+
n.set({ isOpen: h });
|
|
102
102
|
},
|
|
103
103
|
onClose: () => {
|
|
104
104
|
n.clearSidecar(), n.set({ isOpen: !1 });
|
|
105
105
|
},
|
|
106
|
-
height:
|
|
107
|
-
setSize: (
|
|
108
|
-
|
|
106
|
+
height: g,
|
|
107
|
+
setSize: (h) => {
|
|
108
|
+
xe(Q[h], `Unknown size: ${h}`), n.set({ size: h });
|
|
109
109
|
},
|
|
110
|
-
setAnchorOrigin:
|
|
110
|
+
setAnchorOrigin: w,
|
|
111
111
|
cycleAnchorOrigin: R,
|
|
112
112
|
// The app's own calls: through the reducer, with the reason `app`.
|
|
113
113
|
setSidecarRenderer: n.openSidecar,
|
|
114
114
|
commandWidth: a,
|
|
115
|
-
sidecarWidth:
|
|
115
|
+
sidecarWidth: S,
|
|
116
116
|
closeSidecar: n.closeSidecar,
|
|
117
|
-
renderSidecar:
|
|
117
|
+
renderSidecar: O
|
|
118
118
|
};
|
|
119
119
|
}, [n, r]);
|
|
120
|
-
return { ...r, ...
|
|
120
|
+
return { ...r, ...s };
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
124
|
-
const e =
|
|
122
|
+
const ae = ne(null), G = () => oe(ae), _t = () => G()?.components ?? null;
|
|
123
|
+
function Pt() {
|
|
124
|
+
const e = G();
|
|
125
125
|
if (!e)
|
|
126
126
|
throw new Error("useShortRoundToast needs a <ShortRoundProvider theme={…}> above it");
|
|
127
127
|
return { showToast: e.showToast };
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Z(e) {
|
|
130
130
|
(e.querySelector("[cmdk-input]") ?? e).focus();
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
const e =
|
|
132
|
+
function We() {
|
|
133
|
+
const e = d(null), t = d(null), n = N((r) => {
|
|
134
134
|
if (r) {
|
|
135
|
-
t.current = document.activeElement, e.current = r,
|
|
135
|
+
t.current = document.activeElement, e.current = r, Z(r);
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const s = e.current, c = t.current;
|
|
139
139
|
e.current = null, t.current = null;
|
|
140
140
|
const a = document.activeElement;
|
|
141
|
-
(!a || a === document.body ||
|
|
142
|
-
}, []), o =
|
|
143
|
-
e.current &&
|
|
141
|
+
(!a || a === document.body || s?.contains(a)) && c && c !== document.body && c.isConnected && c.focus();
|
|
142
|
+
}, []), o = N(() => {
|
|
143
|
+
e.current && Z(e.current);
|
|
144
144
|
}, []);
|
|
145
145
|
return { attachDialog: n, focusInside: o };
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
function Ne(e) {
|
|
148
|
+
const [t, n] = U(0), o = d(1 / 0);
|
|
149
|
+
return A(() => {
|
|
150
|
+
const r = e.current;
|
|
151
|
+
if (!r || typeof ResizeObserver > "u")
|
|
152
|
+
return;
|
|
153
|
+
const s = () => {
|
|
154
|
+
const a = r.offsetHeight;
|
|
155
|
+
o.current = Math.min(o.current, a), n(a - o.current);
|
|
156
|
+
};
|
|
157
|
+
s();
|
|
158
|
+
const c = new ResizeObserver(s);
|
|
159
|
+
return c.observe(r), () => c.disconnect();
|
|
160
|
+
}, [e]), t;
|
|
161
|
+
}
|
|
162
|
+
const $e = { subscribe: () => () => {
|
|
148
163
|
}, getState: () => null };
|
|
149
|
-
function
|
|
150
|
-
const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null,
|
|
151
|
-
return { canShowHints: o, lineState: r ?
|
|
164
|
+
function Fe({ palette: e, disableLineHints: t, store: n }) {
|
|
165
|
+
const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null, s = r ?? $e, c = z(s.subscribe, s.getState, s.getState);
|
|
166
|
+
return { canShowHints: o, lineState: r ? c : null, complete: () => !n.commandLine() || !n.completeFirst() ? null : n.commandLine()?.getState().caret ?? null };
|
|
152
167
|
}
|
|
153
|
-
const
|
|
154
|
-
function
|
|
168
|
+
const Ge = new Set(Object.values(Ee)), ee = (e, t) => t[e] ?? t.unknown, W = (e, t) => e ? Ce(e, t) : void 0;
|
|
169
|
+
function He(e, { registry: t = {}, themeIcons: n = {} }) {
|
|
155
170
|
const o = t.intentions?.[e.id];
|
|
156
171
|
if (o)
|
|
157
|
-
return
|
|
172
|
+
return W(o);
|
|
158
173
|
if (!e.icon)
|
|
159
174
|
return;
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
175
|
+
if (Ge.has(e.id))
|
|
176
|
+
return W(ee(e.icon, n));
|
|
162
177
|
const r = t.names?.[e.icon] ?? e.icon;
|
|
163
|
-
return t.Icon ?
|
|
178
|
+
return t.Icon ? W(t.Icon, { name: r }) : W(ee(r, n));
|
|
164
179
|
}
|
|
165
|
-
const
|
|
180
|
+
const Ke = [
|
|
166
181
|
"fontFamily",
|
|
167
182
|
"fontSize",
|
|
168
183
|
"fontWeight",
|
|
@@ -179,27 +194,27 @@ const Pe = [
|
|
|
179
194
|
"borderBottomWidth",
|
|
180
195
|
"borderLeftWidth"
|
|
181
196
|
];
|
|
182
|
-
function
|
|
183
|
-
const o =
|
|
184
|
-
return
|
|
185
|
-
const
|
|
186
|
-
if (!
|
|
197
|
+
function Me({ children: e, inputRef: t, lineState: n }) {
|
|
198
|
+
const o = d(null), r = !!n;
|
|
199
|
+
return A(() => {
|
|
200
|
+
const s = t.current, c = o.current;
|
|
201
|
+
if (!s)
|
|
187
202
|
return;
|
|
188
203
|
if (!r) {
|
|
189
|
-
|
|
204
|
+
s.style.color = "", s.style.caretColor = "";
|
|
190
205
|
return;
|
|
191
206
|
}
|
|
192
|
-
|
|
207
|
+
Ve(s, c);
|
|
193
208
|
const a = () => {
|
|
194
|
-
|
|
209
|
+
c.scrollLeft = s.scrollLeft;
|
|
195
210
|
};
|
|
196
|
-
return a(),
|
|
197
|
-
}), /* @__PURE__ */ k("div", { "data-testid": "shortround-line-input", style:
|
|
198
|
-
r && /* @__PURE__ */ i("div", { "aria-hidden": !0, "data-testid": "shortround-line-shadow", ref: o, style:
|
|
211
|
+
return a(), s.addEventListener("scroll", a), () => s.removeEventListener("scroll", a);
|
|
212
|
+
}), /* @__PURE__ */ k("div", { "data-testid": "shortround-line-input", style: ze, children: [
|
|
213
|
+
r && /* @__PURE__ */ i("div", { "aria-hidden": !0, "data-testid": "shortround-line-shadow", ref: o, style: Ue, children: /* @__PURE__ */ i(Ye, { state: n }) }),
|
|
199
214
|
e
|
|
200
215
|
] });
|
|
201
216
|
}
|
|
202
|
-
const
|
|
217
|
+
const ze = { position: "relative", flex: "1 1 auto", width: "100%", minWidth: 0 }, Ue = {
|
|
203
218
|
position: "absolute",
|
|
204
219
|
pointerEvents: "none",
|
|
205
220
|
whiteSpace: "pre",
|
|
@@ -209,9 +224,9 @@ const Ae = { position: "relative", flex: "1 1 auto", width: "100%", minWidth: 0
|
|
|
209
224
|
// The shadow is sized from the input's offset box, which includes padding and border.
|
|
210
225
|
boxSizing: "border-box"
|
|
211
226
|
};
|
|
212
|
-
function
|
|
227
|
+
function Ve(e, t) {
|
|
213
228
|
const n = window.getComputedStyle(e);
|
|
214
|
-
e.style.color !== "transparent" && (t.style.color = n.color, e.style.caretColor = n.color, e.style.color = "transparent"),
|
|
229
|
+
e.style.color !== "transparent" && (t.style.color = n.color, e.style.caretColor = n.color, e.style.color = "transparent"), Ke.forEach((o) => {
|
|
215
230
|
t.style[o] = n[o];
|
|
216
231
|
}), Object.assign(t.style, {
|
|
217
232
|
left: `${e.offsetLeft}px`,
|
|
@@ -220,27 +235,27 @@ function Fe(e, t) {
|
|
|
220
235
|
height: `${e.offsetHeight}px`
|
|
221
236
|
});
|
|
222
237
|
}
|
|
223
|
-
function
|
|
238
|
+
function Ye({ state: e }) {
|
|
224
239
|
const t = [];
|
|
225
240
|
let n = 0;
|
|
226
241
|
for (const o of e.roles)
|
|
227
242
|
o.start > n && t.push(/* @__PURE__ */ i("span", { children: e.text.slice(n, o.start) }, `gap-${n}`)), t.push(
|
|
228
243
|
/* @__PURE__ */ i("span", { "data-role": o.role, title: o.reason, children: e.text.slice(o.start, o.end) }, o.start)
|
|
229
244
|
), n = o.end;
|
|
230
|
-
return n < e.text.length && t.push(/* @__PURE__ */ i("span", { children: e.text.slice(n) }, `tail-${n}`)), /* @__PURE__ */ k(
|
|
245
|
+
return n < e.text.length && t.push(/* @__PURE__ */ i("span", { children: e.text.slice(n) }, `tail-${n}`)), /* @__PURE__ */ k(Le, { children: [
|
|
231
246
|
t,
|
|
232
247
|
e.ghost && /* @__PURE__ */ i("span", { "data-role": "ghost", children: e.ghost })
|
|
233
248
|
] });
|
|
234
249
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
250
|
+
const je = "Type a intention or search...", Be = 107, qe = { display: "flex", flexDirection: "column" }, Xe = { order: -1 }, Je = "shortround::navigate", Qe = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "Home", "End"]), Ze = /* @__PURE__ */ new Set(["n", "p", "j", "k"]), et = "shortround::no-row", tt = (e) => Qe.has(e.key) || e.ctrlKey && Ze.has(e.key), nt = (e) => e.nativeEvent.isComposing || e.keyCode === 229, ot = "shortround::no-group";
|
|
251
|
+
function rt(e) {
|
|
237
252
|
const t = document.activeElement;
|
|
238
253
|
e && t !== e && e.closest("[cmdk-root]")?.contains(t) && e.focus();
|
|
239
254
|
}
|
|
240
|
-
function
|
|
241
|
-
const r =
|
|
255
|
+
function st({ intention: e, onSelect: t, Item: n, iconSources: o }) {
|
|
256
|
+
const r = re((s) => s.value) === e.id.trim();
|
|
242
257
|
return /* @__PURE__ */ i(
|
|
243
|
-
|
|
258
|
+
L.Item,
|
|
244
259
|
{
|
|
245
260
|
"data-testid": `shortround-item-${e.id}`,
|
|
246
261
|
disabled: e.disabled,
|
|
@@ -250,7 +265,7 @@ function Ve({ intention: e, onSelect: t, Item: n, iconSources: o }) {
|
|
|
250
265
|
children: /* @__PURE__ */ i(
|
|
251
266
|
n,
|
|
252
267
|
{
|
|
253
|
-
icon:
|
|
268
|
+
icon: He(e, o),
|
|
254
269
|
intention: e,
|
|
255
270
|
isSelected: r
|
|
256
271
|
}
|
|
@@ -258,14 +273,20 @@ function Ve({ intention: e, onSelect: t, Item: n, iconSources: o }) {
|
|
|
258
273
|
}
|
|
259
274
|
);
|
|
260
275
|
}
|
|
261
|
-
const
|
|
262
|
-
const o = n
|
|
263
|
-
let r = t.find((
|
|
276
|
+
const ue = (e) => e.group ?? void 0, ct = (e) => e.reduce((t, n) => {
|
|
277
|
+
const o = ue(n);
|
|
278
|
+
let r = t.find((s) => s.name === o);
|
|
264
279
|
return r || (r = { name: o, intentions: [] }, t.push(r)), r.intentions.push(n), t;
|
|
265
|
-
}, [])
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
280
|
+
}, []), it = (e) => e.reduce((t, n) => {
|
|
281
|
+
const o = ue(n), r = t.at(-1);
|
|
282
|
+
if (r && r.name === o)
|
|
283
|
+
return r.intentions.push(n), t;
|
|
284
|
+
const s = t.filter((c) => c.name === o).length;
|
|
285
|
+
return [...t, { name: o, run: s, intentions: [n] }];
|
|
286
|
+
}, []), at = ({ name: e, run: t = 0 }) => `${e ?? ot}${t ? `#${t}` : ""}`;
|
|
287
|
+
function ut({ groupRef: e, rowIds: t }) {
|
|
288
|
+
const n = re((r) => r.value), o = t.includes(n);
|
|
289
|
+
return x(() => {
|
|
269
290
|
if (!o)
|
|
270
291
|
return;
|
|
271
292
|
const r = requestAnimationFrame(
|
|
@@ -274,164 +295,188 @@ function je({ groupRef: e, rowIds: t }) {
|
|
|
274
295
|
return () => cancelAnimationFrame(r);
|
|
275
296
|
}, [n, o, e]), null;
|
|
276
297
|
}
|
|
277
|
-
function
|
|
278
|
-
const t =
|
|
279
|
-
return
|
|
298
|
+
function lt(e) {
|
|
299
|
+
const t = d(null);
|
|
300
|
+
return A(() => {
|
|
280
301
|
t.current !== null && e.current && (e.current.setSelectionRange(t.current, t.current), t.current = null);
|
|
281
302
|
}), t;
|
|
282
303
|
}
|
|
283
|
-
function
|
|
304
|
+
function dt({
|
|
284
305
|
palette: e,
|
|
285
306
|
defaultIntentions: t,
|
|
286
307
|
resolveDefaultInput: n,
|
|
287
308
|
resolveDefaultFallbackInput: o,
|
|
288
309
|
defaultSidecarRenderer: r,
|
|
289
|
-
IntentionPalette:
|
|
290
|
-
iconSources:
|
|
310
|
+
IntentionPalette: s,
|
|
311
|
+
iconSources: c = {},
|
|
291
312
|
showToast: a,
|
|
292
|
-
label:
|
|
293
|
-
disableLineHints:
|
|
313
|
+
label: f,
|
|
314
|
+
disableLineHints: m = !1
|
|
294
315
|
}) {
|
|
295
|
-
const { store: l, state:
|
|
316
|
+
const { store: l, state: g, intentions: S } = se({
|
|
296
317
|
palette: e,
|
|
297
318
|
defaultIntentions: t,
|
|
298
319
|
resolveDefaultInput: n,
|
|
299
320
|
resolveDefaultFallbackInput: o
|
|
300
|
-
}), { inputValue:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
321
|
+
}), { inputValue: w, inputMessage: R, enterLine: O, revertIntentions: h, isHighlightChosen: v } = g, { height: b, onClose: C } = j(), H = F(), y = d(null), P = d(null), K = Ne(P), D = d(null), M = lt(y), T = Fe({ palette: e, disableLineHints: m, store: l }), le = $(
|
|
322
|
+
() => v ? it(S) : ct(S),
|
|
323
|
+
[S, v]
|
|
324
|
+
), [de, he] = U(0), fe = g.highlightedId?.trim() ?? `${et}:${de}`, _ = d(!1), B = () => {
|
|
325
|
+
_.current = !0, queueMicrotask(() => {
|
|
326
|
+
_.current = !1;
|
|
327
|
+
});
|
|
328
|
+
}, me = (u) => {
|
|
329
|
+
const p = _.current;
|
|
330
|
+
if (_.current = !1, l.getState().highlightedId === void 0 && !p) {
|
|
331
|
+
he((I) => I + 1);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const E = [...S, ...h].find(({ id: I }) => I.trim() === u);
|
|
335
|
+
l.highlight(E?.id ?? u);
|
|
336
|
+
}, pe = (u) => {
|
|
337
|
+
_.current = !1, l.changeInput(u, y.current?.selectionStart);
|
|
338
|
+
}, ge = (u) => {
|
|
339
|
+
const { value: p, selectionStart: E } = u.target, I = l.commandLine()?.getState();
|
|
340
|
+
I && p === l.getState().inputValue && I.caret !== E && l.changeInput(p, E);
|
|
341
|
+
}, Se = () => {
|
|
307
342
|
const u = T.complete();
|
|
308
|
-
return u !== null ? (
|
|
309
|
-
},
|
|
310
|
-
u.key === "Tab" &&
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (
|
|
315
|
-
|
|
343
|
+
return u !== null ? (M.current = u, !0) : l.completeFirst();
|
|
344
|
+
}, we = (u) => {
|
|
345
|
+
if (u.key === "Tab" && Se()) {
|
|
346
|
+
u.preventDefault(), y.current?.focus();
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (tt(u)) {
|
|
350
|
+
B();
|
|
316
351
|
return;
|
|
317
352
|
}
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
|
|
353
|
+
u.key === "Enter" && !nt(u) && !l.getState().highlightedId && (u.preventDefault(), l.pressEnter());
|
|
354
|
+
}, Re = async (u) => {
|
|
355
|
+
rt(y.current);
|
|
356
|
+
const p = await l.select(u, { sidekickStore: H, defaultSidecarRenderer: r }).catch((E) => console.error("ShortRoundPalette: an intention failed", { id: u, error: E }));
|
|
357
|
+
if (p) {
|
|
358
|
+
if (p.isCompletion) {
|
|
359
|
+
y.current?.focus();
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
p.isRejected || (p.message && a?.({ message: p.message }), p.shouldReset && C());
|
|
363
|
+
}
|
|
364
|
+
}, q = /* @__PURE__ */ i(
|
|
365
|
+
L.Input,
|
|
321
366
|
{
|
|
322
367
|
"data-testid": "shortround-input",
|
|
323
|
-
onKeyDown:
|
|
324
|
-
onSelect:
|
|
325
|
-
onValueChange:
|
|
326
|
-
placeholder:
|
|
327
|
-
ref:
|
|
328
|
-
value:
|
|
368
|
+
onKeyDown: we,
|
|
369
|
+
onSelect: ge,
|
|
370
|
+
onValueChange: pe,
|
|
371
|
+
placeholder: je,
|
|
372
|
+
ref: y,
|
|
373
|
+
value: w
|
|
329
374
|
}
|
|
330
|
-
),
|
|
331
|
-
/* @__PURE__ */ i(
|
|
332
|
-
E.map((
|
|
333
|
-
|
|
375
|
+
), ve = T.canShowHints ? /* @__PURE__ */ i(Me, { inputRef: y, lineState: T.lineState, children: q }) : q, X = ({ key: u, name: p, intentions: E, style: I, ref: ye }) => /* @__PURE__ */ k(L.Group, { ref: ye, style: I, children: [
|
|
376
|
+
/* @__PURE__ */ i(s.Group, { name: p }),
|
|
377
|
+
E.map((J) => /* @__PURE__ */ i(
|
|
378
|
+
st,
|
|
334
379
|
{
|
|
335
|
-
Item:
|
|
336
|
-
iconSources:
|
|
337
|
-
intention:
|
|
338
|
-
onSelect:
|
|
380
|
+
Item: s.Item,
|
|
381
|
+
iconSources: c,
|
|
382
|
+
intention: J,
|
|
383
|
+
onSelect: Re
|
|
339
384
|
},
|
|
340
|
-
|
|
385
|
+
J.id
|
|
341
386
|
))
|
|
342
387
|
] }, u);
|
|
343
|
-
return /* @__PURE__ */ i(
|
|
344
|
-
|
|
388
|
+
return /* @__PURE__ */ i(s.Frame, { height: b, children: /* @__PURE__ */ k(
|
|
389
|
+
L,
|
|
345
390
|
{
|
|
346
|
-
label:
|
|
391
|
+
label: f,
|
|
347
392
|
loop: !0,
|
|
348
|
-
onValueChange:
|
|
393
|
+
onValueChange: me,
|
|
349
394
|
shouldFilter: !1,
|
|
350
|
-
value:
|
|
395
|
+
value: fe,
|
|
351
396
|
children: [
|
|
352
|
-
/* @__PURE__ */ i(
|
|
397
|
+
/* @__PURE__ */ i("div", { ref: P, children: /* @__PURE__ */ i(s.Input, { enterLine: O, input: ve, inputMessage: R }) }),
|
|
353
398
|
/* @__PURE__ */ k(
|
|
354
|
-
|
|
399
|
+
L.List,
|
|
355
400
|
{
|
|
401
|
+
onPointerMoveCapture: B,
|
|
356
402
|
style: {
|
|
357
|
-
height: `calc(${
|
|
358
|
-
// not sure why 107 works
|
|
403
|
+
height: `calc(${b} - ${Be + K}px)`,
|
|
359
404
|
overflowY: "auto",
|
|
360
405
|
padding: "8px 0"
|
|
361
406
|
},
|
|
362
407
|
children: [
|
|
363
|
-
/* @__PURE__ */ i(
|
|
364
|
-
/* @__PURE__ */ k("div", { style:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
key:
|
|
368
|
-
name:
|
|
369
|
-
intentions:
|
|
370
|
-
style:
|
|
371
|
-
ref:
|
|
408
|
+
/* @__PURE__ */ i(L.Empty, { children: /* @__PURE__ */ i(s.NoMatches, { inputValue: w }) }),
|
|
409
|
+
/* @__PURE__ */ k("div", { style: qe, children: [
|
|
410
|
+
le.map((u) => X({ key: at(u), ...u })),
|
|
411
|
+
h.length > 0 && X({
|
|
412
|
+
key: Je,
|
|
413
|
+
name: Ie,
|
|
414
|
+
intentions: h,
|
|
415
|
+
style: Xe,
|
|
416
|
+
ref: D
|
|
372
417
|
})
|
|
373
418
|
] })
|
|
374
419
|
]
|
|
375
420
|
}
|
|
376
421
|
),
|
|
377
422
|
/* @__PURE__ */ i(
|
|
378
|
-
|
|
423
|
+
ut,
|
|
379
424
|
{
|
|
380
|
-
groupRef:
|
|
381
|
-
rowIds:
|
|
425
|
+
groupRef: D,
|
|
426
|
+
rowIds: h.map(({ id: u }) => u)
|
|
382
427
|
}
|
|
383
428
|
)
|
|
384
429
|
]
|
|
385
430
|
}
|
|
386
431
|
) });
|
|
387
432
|
}
|
|
388
|
-
function
|
|
433
|
+
function ht({
|
|
389
434
|
title: e,
|
|
390
435
|
palette: t,
|
|
391
436
|
defaultIntentions: n,
|
|
392
437
|
resolveDefaultInput: o,
|
|
393
438
|
resolveDefaultFallbackInput: r,
|
|
394
|
-
SidekickComponents:
|
|
395
|
-
showToast:
|
|
439
|
+
SidekickComponents: s,
|
|
440
|
+
showToast: c,
|
|
396
441
|
defaultSidecarRenderer: a,
|
|
397
|
-
disableLineHints:
|
|
442
|
+
disableLineHints: f
|
|
398
443
|
}) {
|
|
399
|
-
const { onClose:
|
|
400
|
-
() => ({ registry:
|
|
401
|
-
[
|
|
444
|
+
const { onClose: m, setSize: l, anchorOrigin: g, cycleAnchorOrigin: S, height: w, size: R, commandWidth: O } = j(), { Sidekick: h, IntentionPalette: v } = s, b = G()?.icons, C = $(
|
|
445
|
+
() => ({ registry: b, themeIcons: s.icons }),
|
|
446
|
+
[b, s.icons]
|
|
402
447
|
);
|
|
403
|
-
return /* @__PURE__ */ i(V.div, { layout: !0, transition: { duration:
|
|
448
|
+
return /* @__PURE__ */ i(V.div, { layout: !0, transition: { duration: Y, ease: "easeInOut" }, children: /* @__PURE__ */ k(h.Frame, { commandWidth: O, height: w, children: [
|
|
404
449
|
/* @__PURE__ */ i(
|
|
405
|
-
|
|
450
|
+
h.ControlBar,
|
|
406
451
|
{
|
|
407
|
-
anchorOrigin:
|
|
408
|
-
cycleAnchorOrigin:
|
|
409
|
-
labels:
|
|
410
|
-
onClose:
|
|
452
|
+
anchorOrigin: g,
|
|
453
|
+
cycleAnchorOrigin: S,
|
|
454
|
+
labels: be,
|
|
455
|
+
onClose: m,
|
|
411
456
|
setSize: l,
|
|
412
457
|
size: R,
|
|
413
458
|
title: e
|
|
414
459
|
}
|
|
415
460
|
),
|
|
416
461
|
R !== "compact" && /* @__PURE__ */ i(
|
|
417
|
-
|
|
462
|
+
dt,
|
|
418
463
|
{
|
|
419
|
-
IntentionPalette:
|
|
464
|
+
IntentionPalette: v,
|
|
420
465
|
defaultIntentions: n,
|
|
421
466
|
defaultSidecarRenderer: a,
|
|
422
|
-
disableLineHints:
|
|
423
|
-
iconSources:
|
|
424
|
-
label: e ??
|
|
467
|
+
disableLineHints: f,
|
|
468
|
+
iconSources: C,
|
|
469
|
+
label: e ?? ce,
|
|
425
470
|
palette: t,
|
|
426
471
|
resolveDefaultFallbackInput: r,
|
|
427
472
|
resolveDefaultInput: o,
|
|
428
|
-
showToast:
|
|
473
|
+
showToast: c
|
|
429
474
|
}
|
|
430
475
|
)
|
|
431
476
|
] }) });
|
|
432
477
|
}
|
|
433
|
-
function
|
|
434
|
-
const
|
|
478
|
+
function ft({ isOpen: e, renderSidecar: t, height: n, width: o, Content: r }) {
|
|
479
|
+
const s = {
|
|
435
480
|
open: { width: o, pointerEvents: "auto" },
|
|
436
481
|
closed: { width: 0, pointerEvents: "none" }
|
|
437
482
|
};
|
|
@@ -441,128 +486,128 @@ function qe({ isOpen: e, renderSidecar: t, height: n, width: o, Content: r }) {
|
|
|
441
486
|
animate: e ? "open" : "closed",
|
|
442
487
|
layout: !0,
|
|
443
488
|
style: { display: "flex", overflow: "hidden", opacity: 1 },
|
|
444
|
-
transition: { duration:
|
|
445
|
-
variants:
|
|
489
|
+
transition: { duration: Y, ease: "easeInOut" },
|
|
490
|
+
variants: s,
|
|
446
491
|
children: /* @__PURE__ */ i(r, { height: n, isOpen: e, renderSidecar: t })
|
|
447
492
|
}
|
|
448
493
|
);
|
|
449
494
|
}
|
|
450
|
-
function
|
|
451
|
-
const n =
|
|
452
|
-
o.current = t,
|
|
495
|
+
function mt(e, t) {
|
|
496
|
+
const n = d(e), o = d(t);
|
|
497
|
+
o.current = t, x(() => {
|
|
453
498
|
n.current && !e && o.current?.(), n.current = e;
|
|
454
499
|
}, [e]);
|
|
455
500
|
}
|
|
456
|
-
function
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
(...
|
|
462
|
-
), () => e.setSidecarReducer(void 0)), [e]),
|
|
463
|
-
t && !
|
|
501
|
+
function pt(e, t, { sidecarReducer: n, defaultSidecarRenderer: o, palette: r }) {
|
|
502
|
+
const s = d(n);
|
|
503
|
+
s.current = n;
|
|
504
|
+
const c = d(!1), a = () => r ? r.current().sidecarRenderer : o, f = d(a);
|
|
505
|
+
f.current = a, A(() => (e.setSidecarReducer(
|
|
506
|
+
(...m) => (s.current ?? ((l, g) => g))(...m)
|
|
507
|
+
), () => e.setSidecarReducer(void 0)), [e]), A(() => {
|
|
508
|
+
t && !c.current ? e.changeSidecar({ renderer: f.current() ?? null }, "open") : !t && c.current && e.clearSidecar(), c.current = t;
|
|
464
509
|
}, [e, t]);
|
|
465
510
|
}
|
|
466
|
-
function
|
|
467
|
-
|
|
511
|
+
function gt(e, t) {
|
|
512
|
+
A(() => {
|
|
468
513
|
document.activeElement === document.body && t();
|
|
469
514
|
}, [e, t]);
|
|
470
515
|
}
|
|
471
|
-
const
|
|
516
|
+
const St = {
|
|
472
517
|
display: "flex",
|
|
473
518
|
flexDirection: "inherit",
|
|
474
519
|
alignItems: "inherit",
|
|
475
520
|
width: "100%",
|
|
476
521
|
height: "100%"
|
|
477
|
-
},
|
|
522
|
+
}, wt = Te(function({ name: t, onClose: n, children: o }, r) {
|
|
478
523
|
return /* @__PURE__ */ i(
|
|
479
524
|
"div",
|
|
480
525
|
{
|
|
481
526
|
"aria-label": t,
|
|
482
527
|
"aria-modal": "false",
|
|
483
|
-
onKeyDown: (
|
|
484
|
-
|
|
528
|
+
onKeyDown: (c) => {
|
|
529
|
+
c.key === "Escape" && !c.defaultPrevented && n();
|
|
485
530
|
},
|
|
486
531
|
ref: r,
|
|
487
532
|
role: "dialog",
|
|
488
|
-
style:
|
|
533
|
+
style: St,
|
|
489
534
|
tabIndex: -1,
|
|
490
535
|
children: o
|
|
491
536
|
}
|
|
492
537
|
);
|
|
493
538
|
});
|
|
494
|
-
function
|
|
539
|
+
function Rt({
|
|
495
540
|
title: e,
|
|
496
541
|
palette: t,
|
|
497
542
|
defaultIntentions: n,
|
|
498
543
|
resolveDefaultInput: o,
|
|
499
544
|
resolveDefaultFallbackInput: r,
|
|
500
|
-
SidekickComponents:
|
|
501
|
-
showToast:
|
|
545
|
+
SidekickComponents: s,
|
|
546
|
+
showToast: c,
|
|
502
547
|
installKeyboardShortcuts: a,
|
|
503
|
-
notifyClose:
|
|
504
|
-
sidecarReducer:
|
|
548
|
+
notifyClose: f,
|
|
549
|
+
sidecarReducer: m,
|
|
505
550
|
defaultSidecarRenderer: l,
|
|
506
|
-
disableLineHints:
|
|
551
|
+
disableLineHints: g
|
|
507
552
|
}) {
|
|
508
553
|
const {
|
|
509
|
-
isSidecarOpen:
|
|
510
|
-
anchorOrigin:
|
|
554
|
+
isSidecarOpen: S,
|
|
555
|
+
anchorOrigin: w,
|
|
511
556
|
renderSidecar: R,
|
|
512
|
-
height:
|
|
513
|
-
sidecarWidth:
|
|
514
|
-
isOpen:
|
|
515
|
-
anchorPosition:
|
|
516
|
-
totalWidth:
|
|
517
|
-
size:
|
|
518
|
-
onOpen:
|
|
519
|
-
onClose:
|
|
520
|
-
} = j(), { Sidekick:
|
|
521
|
-
return
|
|
522
|
-
onOpen:
|
|
557
|
+
height: O,
|
|
558
|
+
sidecarWidth: h,
|
|
559
|
+
isOpen: v,
|
|
560
|
+
anchorPosition: b,
|
|
561
|
+
totalWidth: C,
|
|
562
|
+
size: H,
|
|
563
|
+
onOpen: y,
|
|
564
|
+
onClose: P
|
|
565
|
+
} = j(), { Sidekick: K, SidecarContent: D } = s, { attachDialog: M, focusInside: T } = We();
|
|
566
|
+
return Pe({
|
|
567
|
+
onOpen: v ? T : y,
|
|
523
568
|
installKeyboardShortcuts: a
|
|
524
|
-
}),
|
|
525
|
-
sidecarReducer:
|
|
569
|
+
}), gt(H, T), mt(v, f), pt(F(), v, {
|
|
570
|
+
sidecarReducer: m,
|
|
526
571
|
defaultSidecarRenderer: l,
|
|
527
572
|
palette: t
|
|
528
|
-
}),
|
|
573
|
+
}), v ? /* @__PURE__ */ i(
|
|
529
574
|
V.div,
|
|
530
575
|
{
|
|
531
576
|
animate: {
|
|
532
|
-
width:
|
|
577
|
+
width: C
|
|
533
578
|
},
|
|
534
579
|
layout: !0,
|
|
535
|
-
transition: { duration:
|
|
580
|
+
transition: { duration: Y, ease: "easeInOut" },
|
|
536
581
|
children: /* @__PURE__ */ i(
|
|
537
|
-
|
|
582
|
+
K.Popover,
|
|
538
583
|
{
|
|
539
|
-
anchorOrigin:
|
|
540
|
-
anchorPosition:
|
|
541
|
-
height:
|
|
542
|
-
totalWidth:
|
|
543
|
-
children: /* @__PURE__ */ k(
|
|
584
|
+
anchorOrigin: w,
|
|
585
|
+
anchorPosition: b,
|
|
586
|
+
height: O,
|
|
587
|
+
totalWidth: C,
|
|
588
|
+
children: /* @__PURE__ */ k(wt, { name: e ?? ce, onClose: P, ref: M, children: [
|
|
544
589
|
/* @__PURE__ */ i(
|
|
545
|
-
|
|
590
|
+
ht,
|
|
546
591
|
{
|
|
547
|
-
SidekickComponents:
|
|
592
|
+
SidekickComponents: s,
|
|
548
593
|
defaultIntentions: n,
|
|
549
594
|
defaultSidecarRenderer: l,
|
|
550
|
-
disableLineHints:
|
|
595
|
+
disableLineHints: g,
|
|
551
596
|
palette: t,
|
|
552
597
|
resolveDefaultFallbackInput: r,
|
|
553
598
|
resolveDefaultInput: o,
|
|
554
|
-
showToast:
|
|
599
|
+
showToast: c,
|
|
555
600
|
title: e
|
|
556
601
|
}
|
|
557
602
|
),
|
|
558
603
|
/* @__PURE__ */ i(
|
|
559
|
-
|
|
604
|
+
ft,
|
|
560
605
|
{
|
|
561
|
-
Content:
|
|
562
|
-
height:
|
|
563
|
-
isOpen:
|
|
606
|
+
Content: D,
|
|
607
|
+
height: O,
|
|
608
|
+
isOpen: S,
|
|
564
609
|
renderSidecar: R,
|
|
565
|
-
width:
|
|
610
|
+
width: h
|
|
566
611
|
}
|
|
567
612
|
)
|
|
568
613
|
] })
|
|
@@ -571,82 +616,82 @@ function tt({
|
|
|
571
616
|
}
|
|
572
617
|
) : null;
|
|
573
618
|
}
|
|
574
|
-
function
|
|
575
|
-
const n =
|
|
619
|
+
function vt(e, t) {
|
|
620
|
+
const n = G(), o = e ?? n?.components;
|
|
576
621
|
if (!o)
|
|
577
622
|
throw new Error(
|
|
578
623
|
"ShortRoundSidekick has no theme: wrap the app in <ShortRoundProvider theme={…}>, or pass SidekickComponents"
|
|
579
624
|
);
|
|
580
|
-
return
|
|
625
|
+
return kt(o), { components: o, showToast: t ?? n?.showToast };
|
|
581
626
|
}
|
|
582
|
-
const
|
|
583
|
-
function
|
|
584
|
-
const t =
|
|
627
|
+
const yt = ["IntentionPalette", "Sidekick", "SidecarContent"];
|
|
628
|
+
function kt(e) {
|
|
629
|
+
const t = yt.filter((n) => !e[n]);
|
|
585
630
|
if (t.length > 0)
|
|
586
631
|
throw new Error(
|
|
587
632
|
`ShortRoundSidekick: the theme has no ${t.map((n) => `components.${n}`).join(" or ")}`
|
|
588
633
|
);
|
|
589
634
|
}
|
|
590
|
-
function
|
|
635
|
+
function Dt({
|
|
591
636
|
title: e,
|
|
592
637
|
palette: t,
|
|
593
638
|
defaultIntentions: n,
|
|
594
639
|
resolveDefaultInput: o,
|
|
595
640
|
resolveDefaultFallbackInput: r,
|
|
596
|
-
SidekickComponents:
|
|
597
|
-
showToast:
|
|
641
|
+
SidekickComponents: s,
|
|
642
|
+
showToast: c,
|
|
598
643
|
installKeyboardShortcuts: a,
|
|
599
|
-
sidekickStore:
|
|
600
|
-
initialSidekickState:
|
|
644
|
+
sidekickStore: f,
|
|
645
|
+
initialSidekickState: m,
|
|
601
646
|
onClose: l,
|
|
602
|
-
sidecarReducer:
|
|
603
|
-
defaultSidecarRenderer:
|
|
604
|
-
disableLineHints:
|
|
647
|
+
sidecarReducer: g,
|
|
648
|
+
defaultSidecarRenderer: S,
|
|
649
|
+
disableLineHints: w
|
|
605
650
|
}) {
|
|
606
|
-
const R =
|
|
607
|
-
return /* @__PURE__ */ i(
|
|
608
|
-
|
|
651
|
+
const R = vt(s, c);
|
|
652
|
+
return /* @__PURE__ */ i(De, { initial: m, store: f, children: /* @__PURE__ */ i(
|
|
653
|
+
Rt,
|
|
609
654
|
{
|
|
610
655
|
SidekickComponents: R.components,
|
|
611
656
|
defaultIntentions: n,
|
|
612
|
-
defaultSidecarRenderer:
|
|
613
|
-
disableLineHints:
|
|
657
|
+
defaultSidecarRenderer: S,
|
|
658
|
+
disableLineHints: w,
|
|
614
659
|
installKeyboardShortcuts: a,
|
|
615
660
|
notifyClose: l,
|
|
616
661
|
palette: t,
|
|
617
662
|
resolveDefaultFallbackInput: r,
|
|
618
663
|
resolveDefaultInput: o,
|
|
619
664
|
showToast: R.showToast,
|
|
620
|
-
sidecarReducer:
|
|
665
|
+
sidecarReducer: g,
|
|
621
666
|
title: e
|
|
622
667
|
}
|
|
623
668
|
) });
|
|
624
669
|
}
|
|
625
|
-
const
|
|
626
|
-
function
|
|
670
|
+
const Ot = { isOpen: !1, message: null };
|
|
671
|
+
function Et(e) {
|
|
627
672
|
const t = ["components", "Toast"].filter((n) => !e?.[n]);
|
|
628
673
|
if (t.length > 0)
|
|
629
674
|
throw new Error(`ShortRoundProvider: the theme has no ${t.join(" or ")}`);
|
|
630
675
|
}
|
|
631
|
-
function
|
|
632
|
-
|
|
633
|
-
const [o, r] =
|
|
634
|
-
() => ({ components: e.components, showToast:
|
|
635
|
-
[e.components,
|
|
636
|
-
), { Toast:
|
|
637
|
-
return /* @__PURE__ */ k(
|
|
676
|
+
function Wt({ theme: e, icons: t, children: n }) {
|
|
677
|
+
Et(e);
|
|
678
|
+
const [o, r] = U(Ot), s = N(({ message: m }) => r({ isOpen: !0, message: m }), []), c = N(() => r((m) => ({ ...m, isOpen: !1 })), []), a = $(
|
|
679
|
+
() => ({ components: e.components, showToast: s, icons: t }),
|
|
680
|
+
[e.components, s, t]
|
|
681
|
+
), { Toast: f } = e;
|
|
682
|
+
return /* @__PURE__ */ k(ae.Provider, { value: a, children: [
|
|
638
683
|
n,
|
|
639
|
-
/* @__PURE__ */ i(
|
|
684
|
+
/* @__PURE__ */ i(f, { isOpen: o.isOpen, message: o.message, onClose: c })
|
|
640
685
|
] });
|
|
641
686
|
}
|
|
642
687
|
export {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
688
|
+
Me as LineInput,
|
|
689
|
+
Wt as ShortRoundProvider,
|
|
690
|
+
Dt as ShortRoundSidekick,
|
|
691
|
+
De as SidekickStoreProvider,
|
|
692
|
+
At as useShortRound,
|
|
693
|
+
_t as useShortRoundComponents,
|
|
694
|
+
Pt as useShortRoundToast,
|
|
650
695
|
j as useSidekick,
|
|
651
|
-
|
|
696
|
+
F as useSidekickStore
|
|
652
697
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shortround/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "ShortRound for React: the command palette, the sidekick, the provider and the theme contract, on @shortround/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shortround",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"types": "./src/index.d.ts",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@shortround/core": "0.
|
|
43
|
+
"@shortround/core": "0.8.0",
|
|
44
44
|
"@testing-library/jest-dom": "^6.6.3",
|
|
45
45
|
"@testing-library/react": "^16.3.0",
|
|
46
46
|
"@types/react": "19.1.8",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"vitest": "^3.2.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@shortround/core": "^0.
|
|
56
|
+
"@shortround/core": "^0.8.0",
|
|
57
57
|
"react": "^18.2.0 || ^19.0.0",
|
|
58
58
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
59
59
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
AnchorPosition,
|
|
5
5
|
CommandLineState,
|
|
6
6
|
ControlLabels,
|
|
7
|
+
EnterLine,
|
|
7
8
|
Intention,
|
|
8
9
|
IntentionActionResult,
|
|
9
10
|
PaletteSource,
|
|
@@ -52,10 +53,15 @@ export interface SidekickComponents {
|
|
|
52
53
|
IntentionPalette: {
|
|
53
54
|
/** Renders its children. Row styling goes here, through cmdk's attributes (`[cmdk-item]`, `[data-selected]`). */
|
|
54
55
|
Frame: React.ComponentType<{ height: string; children: ReactNode }>;
|
|
55
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Places `input` (the palette's cmdk input, `data-testid="shortround-input"`) and shows `inputMessage.text`. Shows
|
|
58
|
+
* `enterLine`, when given, apart from the message: what Enter will do ("↵ search grid"), each of its `words` with
|
|
59
|
+
* its `role` (`verb`, `param`, `value`; the roles the input's words have), and `enterLine.text` whole.
|
|
60
|
+
*/
|
|
56
61
|
Input: React.ComponentType<{
|
|
57
62
|
input: ReactNode;
|
|
58
63
|
inputMessage?: { type: string; text: string };
|
|
64
|
+
enterLine?: EnterLine;
|
|
59
65
|
}>;
|
|
60
66
|
/**
|
|
61
67
|
* Draws one row inside the palette's cmdk item (`data-testid="shortround-item-<id>"`): shows the title and
|