@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 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
- - **Tab**, with a catalog palette, first completes through the line (see Line hints). Otherwise it completes the input
178
- with the first enabled completion row, when the list has one; otherwise Tab moves focus as usual.
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 he, createSidekickStore as Q, cycleCorners as fe, RevertIntentionIds as me, NAVIGATE_GROUP as pe, ControlLabels as Se } from "@shortround/core";
2
- import { useRef as m, useSyncExternalStore as H, useEffect as C, createContext as Z, useContext as ee, useMemo as F, useCallback as _, createElement as ge, useLayoutEffect as L, forwardRef as we, useState as ve } from "react";
3
- import { jsx as i, jsxs as k, Fragment as Re } from "react/jsx-runtime";
4
- import ye from "tiny-invariant";
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 b, useCommandState as te } from "cmdk";
7
- function ne({
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 = m(null);
14
- r.current || (r.current = he({
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 c = r.current, s = H(c.subscribe, c.getState, c.getState);
21
- return C(() => {
22
- c.setDefaults({
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
- }, [c, e, t, n, o]), C(() => c.watchResolver(), [c]), C(() => c.watchPalette(), [c, e]), { store: c, state: s, intentions: c.rows() };
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 ft({
30
+ function At({
31
31
  defaultIntentions: e,
32
32
  resolveDefaultInput: t,
33
33
  resolveDefaultFallbackInput: n
34
34
  }) {
35
- const { store: o, state: r, intentions: c } = ne({
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: c,
44
+ intentions: s,
45
45
  revertIntentions: r.revertIntentions,
46
- dispatch: (s) => o.select(s),
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 U = 0.35, ke = "100vh", Oe = Object.freeze({
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
- }), q = Object.freeze({
62
+ }), Q = Object.freeze({
63
63
  compact: { height: "auto" },
64
64
  medium: { height: "50vh" },
65
- full: { height: ke }
66
- }), oe = "ShortRound", Ie = ({ onOpen: e, installKeyboardShortcuts: t = !0 }) => {
67
- const n = m({ onOpen: e });
68
- n.current = { onOpen: e }, C(() => {
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
- }, re = Z(null), W = () => ee(re);
77
- function Ee({ store: e, initial: t, children: n }) {
78
- const o = W(), r = m(null);
79
- !e && !o && !r.current && (r.current = Q(t));
80
- const c = e ?? o ?? r.current;
81
- return /* @__PURE__ */ i(re.Provider, { value: c, children: n });
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 = W();
84
+ const t = F();
85
85
  let n = e.store || t;
86
- const o = m(null);
87
- n || (o.current || (o.current = Q(e.initial)), n = o.current);
88
- const r = H(n.subscribe, n.get, n.get), c = F(() => {
89
- const { maxTotalWidth: s, commandWidth: a, anchorOrigin: d, internalSidecarRenderer: h, size: l } = r, { height: p } = q[l], w = `calc(${s} - ${a})`, v = (f) => n.set({ anchorOrigin: f }), R = () => {
90
- v(fe(d));
91
- }, y = () => {
92
- if (h)
93
- return h();
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: Oe[d],
98
+ anchorPosition: _e[f],
99
99
  onOpen: () => n.set({ isOpen: !0 }),
100
- setIsOpen: (f) => {
101
- n.set({ isOpen: f });
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: p,
107
- setSize: (f) => {
108
- ye(q[f], `Unknown size: ${f}`), n.set({ size: f });
106
+ height: g,
107
+ setSize: (h) => {
108
+ xe(Q[h], `Unknown size: ${h}`), n.set({ size: h });
109
109
  },
110
- setAnchorOrigin: v,
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: w,
115
+ sidecarWidth: S,
116
116
  closeSidecar: n.closeSidecar,
117
- renderSidecar: y
117
+ renderSidecar: O
118
118
  };
119
119
  }, [n, r]);
120
- return { ...r, ...c };
120
+ return { ...r, ...s };
121
121
  }
122
- const ce = Z(null), N = () => ee(ce), mt = () => N()?.components ?? null;
123
- function pt() {
124
- const e = N();
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 X(e) {
129
+ function Z(e) {
130
130
  (e.querySelector("[cmdk-input]") ?? e).focus();
131
131
  }
132
- function be() {
133
- const e = m(null), t = m(null), n = _((r) => {
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, X(r);
135
+ t.current = document.activeElement, e.current = r, Z(r);
136
136
  return;
137
137
  }
138
- const c = e.current, s = t.current;
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 || c?.contains(a)) && s && s !== document.body && s.isConnected && s.focus();
142
- }, []), o = _(() => {
143
- e.current && X(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
- const Ce = { subscribe: () => () => {
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 Te({ palette: e, disableLineHints: t, store: n }) {
150
- const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null, c = r ?? Ce, s = H(c.subscribe, c.getState, c.getState);
151
- return { canShowHints: o, lineState: r ? s : null, complete: () => !n.commandLine() || !n.completeFirst() ? null : n.commandLine()?.getState().caret ?? null };
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 Le = new Set(Object.values(me)), J = (e, t) => t[e] ?? t.unknown, A = (e, t) => e ? ge(e, t) : void 0;
154
- function xe(e, { registry: t = {}, themeIcons: n = {} }) {
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 A(o);
172
+ return W(o);
158
173
  if (!e.icon)
159
174
  return;
160
- if (Le.has(e.id))
161
- return A(J(e.icon, n));
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 ? A(t.Icon, { name: r }) : A(J(r, n));
178
+ return t.Icon ? W(t.Icon, { name: r }) : W(ee(r, n));
164
179
  }
165
- const Pe = [
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 De({ children: e, inputRef: t, lineState: n }) {
183
- const o = m(null), r = !!n;
184
- return L(() => {
185
- const c = t.current, s = o.current;
186
- if (!c)
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
- c.style.color = "", c.style.caretColor = "";
204
+ s.style.color = "", s.style.caretColor = "";
190
205
  return;
191
206
  }
192
- Fe(c, s);
207
+ Ve(s, c);
193
208
  const a = () => {
194
- s.scrollLeft = c.scrollLeft;
209
+ c.scrollLeft = s.scrollLeft;
195
210
  };
196
- return a(), c.addEventListener("scroll", a), () => c.removeEventListener("scroll", a);
197
- }), /* @__PURE__ */ k("div", { "data-testid": "shortround-line-input", style: Ae, children: [
198
- r && /* @__PURE__ */ i("div", { "aria-hidden": !0, "data-testid": "shortround-line-shadow", ref: o, style: _e, children: /* @__PURE__ */ i(We, { state: n }) }),
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 Ae = { position: "relative", flex: "1 1 auto", width: "100%", minWidth: 0 }, _e = {
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 Fe(e, t) {
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"), Pe.forEach((o) => {
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 We({ state: e }) {
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(Re, { children: [
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 Ne = "Type a intention or search...", Ge = { display: "flex", flexDirection: "column" }, $e = { order: -1 }, ze = "shortround::navigate", Ke = "shortround::no-group";
236
- function He(e) {
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 Ve({ intention: e, onSelect: t, Item: n, iconSources: o }) {
241
- const r = te((c) => c.value) === e.id.trim();
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
- b.Item,
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: xe(e, o),
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 Ue = (e) => e.reduce((t, n) => {
262
- const o = n.group ?? void 0;
263
- let r = t.find((c) => c.name === o);
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
- function je({ groupRef: e, rowIds: t }) {
267
- const n = te((r) => r.value), o = t.includes(n);
268
- return C(() => {
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 Ye(e) {
278
- const t = m(null);
279
- return L(() => {
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 Me({
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: c,
290
- iconSources: s = {},
310
+ IntentionPalette: s,
311
+ iconSources: c = {},
291
312
  showToast: a,
292
- label: d,
293
- disableLineHints: h = !1
313
+ label: f,
314
+ disableLineHints: m = !1
294
315
  }) {
295
- const { store: l, state: p, intentions: w } = ne({
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: v, inputMessage: R, revertIntentions: y } = p, { height: f, onClose: O } = j(), I = W(), S = m(null), x = m(null), G = Ye(S), T = Te({ palette: e, disableLineHints: h, store: l }), $ = F(() => Ue(w), [w]), z = p.highlightedId?.trim() ?? "", K = (u) => {
301
- const g = [...w, ...y].find(({ id: E }) => E.trim() === u);
302
- l.highlight(g?.id ?? u);
303
- }, P = (u) => l.changeInput(u, S.current?.selectionStart), se = (u) => {
304
- const { value: g, selectionStart: E } = u.target, D = l.commandLine()?.getState();
305
- D && g === l.getState().inputValue && D.caret !== E && l.changeInput(g, E);
306
- }, ie = () => {
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 ? (G.current = u, !0) : l.completeFirst();
309
- }, ae = (u) => {
310
- u.key === "Tab" && ie() && (u.preventDefault(), S.current?.focus());
311
- }, ue = async (u) => {
312
- He(S.current);
313
- const g = await l.select(u, { sidekickStore: I, defaultSidecarRenderer: r });
314
- if (g.isCompletion) {
315
- S.current?.focus();
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
- g.isRejected || (g.message && a?.({ message: g.message }), g.shouldReset && O());
319
- }, Y = /* @__PURE__ */ i(
320
- b.Input,
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: ae,
324
- onSelect: se,
325
- onValueChange: P,
326
- placeholder: Ne,
327
- ref: S,
328
- value: v
368
+ onKeyDown: we,
369
+ onSelect: ge,
370
+ onValueChange: pe,
371
+ placeholder: je,
372
+ ref: y,
373
+ value: w
329
374
  }
330
- ), le = T.canShowHints ? /* @__PURE__ */ i(De, { inputRef: S, lineState: T.lineState, children: Y }) : Y, M = ({ key: u, name: g, intentions: E, style: D, ref: de }) => /* @__PURE__ */ k(b.Group, { ref: de, style: D, children: [
331
- /* @__PURE__ */ i(c.Group, { name: g }),
332
- E.map((B) => /* @__PURE__ */ i(
333
- Ve,
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: c.Item,
336
- iconSources: s,
337
- intention: B,
338
- onSelect: ue
380
+ Item: s.Item,
381
+ iconSources: c,
382
+ intention: J,
383
+ onSelect: Re
339
384
  },
340
- B.id
385
+ J.id
341
386
  ))
342
387
  ] }, u);
343
- return /* @__PURE__ */ i(c.Frame, { height: f, children: /* @__PURE__ */ k(
344
- b,
388
+ return /* @__PURE__ */ i(s.Frame, { height: b, children: /* @__PURE__ */ k(
389
+ L,
345
390
  {
346
- label: d,
391
+ label: f,
347
392
  loop: !0,
348
- onValueChange: K,
393
+ onValueChange: me,
349
394
  shouldFilter: !1,
350
- value: z,
395
+ value: fe,
351
396
  children: [
352
- /* @__PURE__ */ i(c.Input, { input: le, inputMessage: R }),
397
+ /* @__PURE__ */ i("div", { ref: P, children: /* @__PURE__ */ i(s.Input, { enterLine: O, input: ve, inputMessage: R }) }),
353
398
  /* @__PURE__ */ k(
354
- b.List,
399
+ L.List,
355
400
  {
401
+ onPointerMoveCapture: B,
356
402
  style: {
357
- height: `calc(${f} - 107px)`,
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(b.Empty, { children: /* @__PURE__ */ i(c.NoMatches, { inputValue: v }) }),
364
- /* @__PURE__ */ k("div", { style: Ge, children: [
365
- $.map((u) => M({ key: u.name ?? Ke, ...u })),
366
- y.length > 0 && M({
367
- key: ze,
368
- name: pe,
369
- intentions: y,
370
- style: $e,
371
- ref: x
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
- je,
423
+ ut,
379
424
  {
380
- groupRef: x,
381
- rowIds: y.map(({ id: u }) => u)
425
+ groupRef: D,
426
+ rowIds: h.map(({ id: u }) => u)
382
427
  }
383
428
  )
384
429
  ]
385
430
  }
386
431
  ) });
387
432
  }
388
- function Be({
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: c,
395
- showToast: s,
439
+ SidekickComponents: s,
440
+ showToast: c,
396
441
  defaultSidecarRenderer: a,
397
- disableLineHints: d
442
+ disableLineHints: f
398
443
  }) {
399
- const { onClose: h, setSize: l, anchorOrigin: p, cycleAnchorOrigin: w, height: v, size: R, commandWidth: y } = j(), { Sidekick: f, IntentionPalette: O } = c, I = N()?.icons, S = F(
400
- () => ({ registry: I, themeIcons: c.icons }),
401
- [I, c.icons]
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: U, ease: "easeInOut" }, children: /* @__PURE__ */ k(f.Frame, { commandWidth: y, height: v, children: [
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
- f.ControlBar,
450
+ h.ControlBar,
406
451
  {
407
- anchorOrigin: p,
408
- cycleAnchorOrigin: w,
409
- labels: Se,
410
- onClose: h,
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
- Me,
462
+ dt,
418
463
  {
419
- IntentionPalette: O,
464
+ IntentionPalette: v,
420
465
  defaultIntentions: n,
421
466
  defaultSidecarRenderer: a,
422
- disableLineHints: d,
423
- iconSources: S,
424
- label: e ?? oe,
467
+ disableLineHints: f,
468
+ iconSources: C,
469
+ label: e ?? ce,
425
470
  palette: t,
426
471
  resolveDefaultFallbackInput: r,
427
472
  resolveDefaultInput: o,
428
- showToast: s
473
+ showToast: c
429
474
  }
430
475
  )
431
476
  ] }) });
432
477
  }
433
- function qe({ isOpen: e, renderSidecar: t, height: n, width: o, Content: r }) {
434
- const c = {
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: U, ease: "easeInOut" },
445
- variants: c,
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 Xe(e, t) {
451
- const n = m(e), o = m(t);
452
- o.current = t, C(() => {
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 Je(e, t, { sidecarReducer: n, defaultSidecarRenderer: o, palette: r }) {
457
- const c = m(n);
458
- c.current = n;
459
- const s = m(!1), a = () => r ? r.current().sidecarRenderer : o, d = m(a);
460
- d.current = a, L(() => (e.setSidecarReducer(
461
- (...h) => (c.current ?? ((l, p) => p))(...h)
462
- ), () => e.setSidecarReducer(void 0)), [e]), L(() => {
463
- t && !s.current ? e.changeSidecar({ renderer: d.current() ?? null }, "open") : !t && s.current && e.clearSidecar(), s.current = 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 Qe(e, t) {
467
- L(() => {
511
+ function gt(e, t) {
512
+ A(() => {
468
513
  document.activeElement === document.body && t();
469
514
  }, [e, t]);
470
515
  }
471
- const Ze = {
516
+ const St = {
472
517
  display: "flex",
473
518
  flexDirection: "inherit",
474
519
  alignItems: "inherit",
475
520
  width: "100%",
476
521
  height: "100%"
477
- }, et = we(function({ name: t, onClose: n, children: o }, r) {
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: (s) => {
484
- s.key === "Escape" && !s.defaultPrevented && n();
528
+ onKeyDown: (c) => {
529
+ c.key === "Escape" && !c.defaultPrevented && n();
485
530
  },
486
531
  ref: r,
487
532
  role: "dialog",
488
- style: Ze,
533
+ style: St,
489
534
  tabIndex: -1,
490
535
  children: o
491
536
  }
492
537
  );
493
538
  });
494
- function tt({
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: c,
501
- showToast: s,
545
+ SidekickComponents: s,
546
+ showToast: c,
502
547
  installKeyboardShortcuts: a,
503
- notifyClose: d,
504
- sidecarReducer: h,
548
+ notifyClose: f,
549
+ sidecarReducer: m,
505
550
  defaultSidecarRenderer: l,
506
- disableLineHints: p
551
+ disableLineHints: g
507
552
  }) {
508
553
  const {
509
- isSidecarOpen: w,
510
- anchorOrigin: v,
554
+ isSidecarOpen: S,
555
+ anchorOrigin: w,
511
556
  renderSidecar: R,
512
- height: y,
513
- sidecarWidth: f,
514
- isOpen: O,
515
- anchorPosition: I,
516
- totalWidth: S,
517
- size: x,
518
- onOpen: G,
519
- onClose: T
520
- } = j(), { Sidekick: $, SidecarContent: z } = c, { attachDialog: K, focusInside: P } = be();
521
- return Ie({
522
- onOpen: O ? P : G,
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
- }), Qe(x, P), Xe(O, d), Je(W(), O, {
525
- sidecarReducer: h,
569
+ }), gt(H, T), mt(v, f), pt(F(), v, {
570
+ sidecarReducer: m,
526
571
  defaultSidecarRenderer: l,
527
572
  palette: t
528
- }), O ? /* @__PURE__ */ i(
573
+ }), v ? /* @__PURE__ */ i(
529
574
  V.div,
530
575
  {
531
576
  animate: {
532
- width: S
577
+ width: C
533
578
  },
534
579
  layout: !0,
535
- transition: { duration: U, ease: "easeInOut" },
580
+ transition: { duration: Y, ease: "easeInOut" },
536
581
  children: /* @__PURE__ */ i(
537
- $.Popover,
582
+ K.Popover,
538
583
  {
539
- anchorOrigin: v,
540
- anchorPosition: I,
541
- height: y,
542
- totalWidth: S,
543
- children: /* @__PURE__ */ k(et, { name: e ?? oe, onClose: T, ref: K, children: [
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
- Be,
590
+ ht,
546
591
  {
547
- SidekickComponents: c,
592
+ SidekickComponents: s,
548
593
  defaultIntentions: n,
549
594
  defaultSidecarRenderer: l,
550
- disableLineHints: p,
595
+ disableLineHints: g,
551
596
  palette: t,
552
597
  resolveDefaultFallbackInput: r,
553
598
  resolveDefaultInput: o,
554
- showToast: s,
599
+ showToast: c,
555
600
  title: e
556
601
  }
557
602
  ),
558
603
  /* @__PURE__ */ i(
559
- qe,
604
+ ft,
560
605
  {
561
- Content: z,
562
- height: y,
563
- isOpen: w,
606
+ Content: D,
607
+ height: O,
608
+ isOpen: S,
564
609
  renderSidecar: R,
565
- width: f
610
+ width: h
566
611
  }
567
612
  )
568
613
  ] })
@@ -571,82 +616,82 @@ function tt({
571
616
  }
572
617
  ) : null;
573
618
  }
574
- function nt(e, t) {
575
- const n = N(), o = e ?? n?.components;
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 rt(o), { components: o, showToast: t ?? n?.showToast };
625
+ return kt(o), { components: o, showToast: t ?? n?.showToast };
581
626
  }
582
- const ot = ["IntentionPalette", "Sidekick", "SidecarContent"];
583
- function rt(e) {
584
- const t = ot.filter((n) => !e[n]);
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 St({
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: c,
597
- showToast: s,
641
+ SidekickComponents: s,
642
+ showToast: c,
598
643
  installKeyboardShortcuts: a,
599
- sidekickStore: d,
600
- initialSidekickState: h,
644
+ sidekickStore: f,
645
+ initialSidekickState: m,
601
646
  onClose: l,
602
- sidecarReducer: p,
603
- defaultSidecarRenderer: w,
604
- disableLineHints: v
647
+ sidecarReducer: g,
648
+ defaultSidecarRenderer: S,
649
+ disableLineHints: w
605
650
  }) {
606
- const R = nt(c, s);
607
- return /* @__PURE__ */ i(Ee, { initial: h, store: d, children: /* @__PURE__ */ i(
608
- tt,
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: w,
613
- disableLineHints: v,
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: p,
665
+ sidecarReducer: g,
621
666
  title: e
622
667
  }
623
668
  ) });
624
669
  }
625
- const ct = { isOpen: !1, message: null };
626
- function st(e) {
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 gt({ theme: e, icons: t, children: n }) {
632
- st(e);
633
- const [o, r] = ve(ct), c = _(({ message: h }) => r({ isOpen: !0, message: h }), []), s = _(() => r((h) => ({ ...h, isOpen: !1 })), []), a = F(
634
- () => ({ components: e.components, showToast: c, icons: t }),
635
- [e.components, c, t]
636
- ), { Toast: d } = e;
637
- return /* @__PURE__ */ k(ce.Provider, { value: a, children: [
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(d, { isOpen: o.isOpen, message: o.message, onClose: s })
684
+ /* @__PURE__ */ i(f, { isOpen: o.isOpen, message: o.message, onClose: c })
640
685
  ] });
641
686
  }
642
687
  export {
643
- De as LineInput,
644
- gt as ShortRoundProvider,
645
- St as ShortRoundSidekick,
646
- Ee as SidekickStoreProvider,
647
- ft as useShortRound,
648
- mt as useShortRoundComponents,
649
- pt as useShortRoundToast,
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
- W as useSidekickStore
696
+ F as useSidekickStore
652
697
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shortround/react",
3
- "version": "0.6.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.6.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.6.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
- /** Places `input` (the palette's cmdk input, `data-testid="shortround-input"`) and shows `inputMessage.text`. */
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