@shortround/react 0.6.0 → 0.7.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,19 @@
1
1
  # @shortround/react
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - The palette follows core's Enter rule: with no row highlighted, Enter goes to the store (`pressEnter()`), so a line
8
+ that reads two ways, or held free text, runs nothing until the user picks a row, and a `confirm` command asks on the
9
+ first Enter and runs on the second. The arrows and the pointer still pick a row. See MIGRATING.md, 0.7.0.
10
+ - The palette passes the store's `enterLine` (what Enter will do) to the theme's `IntentionPalette.Input` slot; its
11
+ props type gains `enterLine`.
12
+ - The palette's list leaves room for whatever grows above it (the theme's input with its Enter line), so its last
13
+ row isn't cut off. The theme's `Input` slot now renders inside a `<div>` the palette measures; a theme whose input
14
+ relied on being a direct child of the list's container may need its styles moved to that slot's own root.
15
+ - Takes `@shortround/core` `^0.7.0` as a peer.
16
+
3
17
  ## 0.6.0
4
18
 
5
19
  ### 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
@@ -173,7 +178,10 @@ so it can't be typed in while that modal is open; give the modal `disableEnforce
173
178
  the sidekick (a widget in the side panel) sees Escape first and can keep it with `event.preventDefault()`.
174
179
  - **Enter** runs the highlighted row. After every new list the highlight is on the list's first enabled row of your
175
180
  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.
181
+ input), Enter completes the input instead of running anything. On a typed line, core's Enter rule decides first.
182
+ A line that reads several ways, a command declared `confirm`, or free text not declared `asTyped` leaves no row
183
+ highlighted. Enter then runs nothing, or for a `confirm` command asks, so the next Enter runs it. An arrow or the
184
+ pointer highlights a row, and Enter runs it.
177
185
  - **Tab**, with a catalog palette, first completes through the line (see Line hints). Otherwise it completes the input
178
186
  with the first enabled completion row, when the list has one; otherwise Tab moves focus as usual.
179
187
  - **Arrow keys** move through the rows and wrap around at either end. Back and Cancel, when a list shows them, are
@@ -477,10 +485,19 @@ const SIZES = ['compact', 'medium', 'full'];
477
485
  const MySidekickComponents = {
478
486
  IntentionPalette: {
479
487
  Frame: ({ height, children }) => <div style={{ height }}>{children}</div>,
480
- // `input` is ShortRound's input element; place it.
481
- Input: ({ input, inputMessage }) => (
488
+ // `input` is ShortRound's input element; place it. `enterLine` says what Enter will do, on a typed line.
489
+ Input: ({ input, inputMessage, enterLine }) => (
482
490
  <div>
483
491
  {input}
492
+ {enterLine && (
493
+ <p>
494
+ {enterLine.words.map((word, index) => (
495
+ <span data-role={word.role} key={index}>
496
+ {word.text}
497
+ </span>
498
+ ))}
499
+ </p>
500
+ )}
484
501
  {inputMessage && <p>{inputMessage.text}</p>}
485
502
  </div>
486
503
  ),
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";
5
- import { motion as V } from "framer-motion";
6
- import { Command as b, useCommandState as te } from "cmdk";
7
- function ne({
1
+ import { createPaletteStore as ve, createSidekickStore as ne, cycleCorners as ye, RevertIntentionIds as ke, isEnterWaiting as Ee, NAVIGATE_GROUP as Oe, ControlLabels as Ie } from "@shortround/core";
2
+ import { useRef as d, useSyncExternalStore as U, useEffect as L, createContext as oe, useContext as re, useMemo as H, useCallback as G, useState as V, useLayoutEffect as x, createElement as be, forwardRef as Ce } from "react";
3
+ import { jsx as i, jsxs as k, Fragment as Te } from "react/jsx-runtime";
4
+ import Le from "tiny-invariant";
5
+ import { motion as Y } from "framer-motion";
6
+ import { Command as T, useCommandState as se } from "cmdk";
7
+ function ce({
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 = ve({
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 = U(s.subscribe, s.getState, s.getState);
21
+ return L(() => {
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]), L(() => s.watchResolver(), [s]), L(() => s.watchPalette(), [s, e]), { store: s, state: c, intentions: s.rows() };
29
29
  }
30
- function ft({
30
+ function Tt({
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 } = ce({
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 j = 0.35, xe = "100vh", Ae = 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
+ }), Z = 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: xe }
66
+ }), ie = "ShortRound", _e = ({ onOpen: e, installKeyboardShortcuts: t = !0 }) => {
67
+ const n = d({ onOpen: e });
68
+ n.current = { onOpen: e }, L(() => {
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
+ }, ae = oe(null), K = () => re(ae);
77
+ function De({ store: e, initial: t, children: n }) {
78
+ const o = K(), r = d(null);
79
+ !e && !o && !r.current && (r.current = ne(t));
80
+ const s = e ?? o ?? r.current;
81
+ return /* @__PURE__ */ i(ae.Provider, { value: s, children: n });
82
82
  }
83
- function j(e = {}) {
84
- const t = W();
83
+ function B(e = {}) {
84
+ const t = K();
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 = ne(e.initial)), n = o.current);
88
+ const r = U(n.subscribe, n.get, n.get), s = H(() => {
89
+ const { maxTotalWidth: c, commandWidth: a, anchorOrigin: f, internalSidecarRenderer: m, size: l } = r, { height: p } = Z[l], g = `calc(${c} - ${a})`, w = (h) => n.set({ anchorOrigin: h }), R = () => {
90
+ w(ye(f));
91
+ }, E = () => {
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: Ae[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
106
  height: p,
107
- setSize: (f) => {
108
- ye(q[f], `Unknown size: ${f}`), n.set({ size: f });
107
+ setSize: (h) => {
108
+ Le(Z[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: g,
116
116
  closeSidecar: n.closeSidecar,
117
- renderSidecar: y
117
+ renderSidecar: E
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 ue = oe(null), M = () => re(ue), Lt = () => M()?.components ?? null;
123
+ function xt() {
124
+ const e = M();
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 ee(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 Pe() {
133
+ const e = d(null), t = d(null), n = G((r) => {
134
134
  if (r) {
135
- t.current = document.activeElement, e.current = r, X(r);
135
+ t.current = document.activeElement, e.current = r, ee(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 = G(() => {
143
+ e.current && ee(e.current);
144
144
  }, []);
145
145
  return { attachDialog: n, focusInside: o };
146
146
  }
147
- const Ce = { subscribe: () => () => {
147
+ function We(e) {
148
+ const [t, n] = V(0), o = d(1 / 0);
149
+ return x(() => {
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 Fe = { 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 Ne({ palette: e, disableLineHints: t, store: n }) {
165
+ const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null, s = r ?? Fe, c = U(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(ke)), te = (e, t) => t[e] ?? t.unknown, N = (e, t) => e ? be(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 N(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 N(te(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 ? N(t.Icon, { name: r }) : N(te(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 x(() => {
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
+ Ue(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: $e, children: [
213
+ r && /* @__PURE__ */ i("div", { "aria-hidden": !0, "data-testid": "shortround-line-shadow", ref: o, style: ze, children: /* @__PURE__ */ i(Ve, { 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 $e = { position: "relative", flex: "1 1 auto", width: "100%", minWidth: 0 }, ze = {
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 Ue(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 Ve({ 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(Te, { 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 Ye = "Type a intention or search...", je = 107, Be = { display: "flex", flexDirection: "column" }, qe = { order: -1 }, Xe = "shortround::navigate", Je = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "Home", "End"]), Qe = /* @__PURE__ */ new Set(["n", "p", "j", "k"]), Ze = "shortround::no-row", et = (e) => Je.has(e.key) || e.ctrlKey && Qe.has(e.key), tt = (e) => e.nativeEvent.isComposing || e.keyCode === 229, nt = "shortround::no-group";
251
+ function ot(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 rt({ intention: e, onSelect: t, Item: n, iconSources: o }) {
256
+ const r = se((s) => s.value) === e.id.trim();
242
257
  return /* @__PURE__ */ i(
243
- b.Item,
258
+ T.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,14 @@ function Ve({ intention: e, onSelect: t, Item: n, iconSources: o }) {
258
273
  }
259
274
  );
260
275
  }
261
- const Ue = (e) => e.reduce((t, n) => {
276
+ const st = (e) => e.reduce((t, n) => {
262
277
  const o = n.group ?? void 0;
263
- let r = t.find((c) => c.name === o);
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
280
  }, []);
266
- function je({ groupRef: e, rowIds: t }) {
267
- const n = te((r) => r.value), o = t.includes(n);
268
- return C(() => {
281
+ function ct({ groupRef: e, rowIds: t }) {
282
+ const n = se((r) => r.value), o = t.includes(n);
283
+ return L(() => {
269
284
  if (!o)
270
285
  return;
271
286
  const r = requestAnimationFrame(
@@ -274,295 +289,316 @@ function je({ groupRef: e, rowIds: t }) {
274
289
  return () => cancelAnimationFrame(r);
275
290
  }, [n, o, e]), null;
276
291
  }
277
- function Ye(e) {
278
- const t = m(null);
279
- return L(() => {
292
+ function it(e) {
293
+ const t = d(null);
294
+ return x(() => {
280
295
  t.current !== null && e.current && (e.current.setSelectionRange(t.current, t.current), t.current = null);
281
296
  }), t;
282
297
  }
283
- function Me({
298
+ function at({
284
299
  palette: e,
285
300
  defaultIntentions: t,
286
301
  resolveDefaultInput: n,
287
302
  resolveDefaultFallbackInput: o,
288
303
  defaultSidecarRenderer: r,
289
- IntentionPalette: c,
290
- iconSources: s = {},
304
+ IntentionPalette: s,
305
+ iconSources: c = {},
291
306
  showToast: a,
292
- label: d,
293
- disableLineHints: h = !1
307
+ label: f,
308
+ disableLineHints: m = !1
294
309
  }) {
295
- const { store: l, state: p, intentions: w } = ne({
310
+ const { store: l, state: p, intentions: g } = ce({
296
311
  palette: e,
297
312
  defaultIntentions: t,
298
313
  resolveDefaultInput: n,
299
314
  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 = () => {
307
- 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();
315
+ }), { inputValue: w, inputMessage: R, enterLine: E, revertIntentions: h } = p, { height: v, onClose: I } = B(), b = K(), y = d(null), P = d(null), $ = We(P), W = d(null), z = it(y), A = Ne({ palette: e, disableLineHints: m, store: l }), F = H(() => st(g), [g]), [le, de] = V(0), he = p.highlightedId?.trim() ?? `${Ze}:${le}`, _ = d(!1), q = () => {
316
+ _.current = !0, queueMicrotask(() => {
317
+ _.current = !1;
318
+ });
319
+ }, fe = (u) => {
320
+ const S = _.current;
321
+ _.current = !1;
322
+ const { enter: O } = l.getState();
323
+ if (O && Ee(O) && !S) {
324
+ de((D) => D + 1);
316
325
  return;
317
326
  }
318
- g.isRejected || (g.message && a?.({ message: g.message }), g.shouldReset && O());
319
- }, Y = /* @__PURE__ */ i(
320
- b.Input,
327
+ const C = [...g, ...h].find(({ id: D }) => D.trim() === u);
328
+ l.highlight(C?.id ?? u);
329
+ }, me = (u) => {
330
+ _.current = !1, l.changeInput(u, y.current?.selectionStart);
331
+ }, pe = (u) => {
332
+ const { value: S, selectionStart: O } = u.target, C = l.commandLine()?.getState();
333
+ C && S === l.getState().inputValue && C.caret !== O && l.changeInput(S, O);
334
+ }, Se = () => {
335
+ const u = A.complete();
336
+ return u !== null ? (z.current = u, !0) : l.completeFirst();
337
+ }, ge = (u) => {
338
+ if (u.key === "Tab" && Se()) {
339
+ u.preventDefault(), y.current?.focus();
340
+ return;
341
+ }
342
+ if (et(u)) {
343
+ q();
344
+ return;
345
+ }
346
+ u.key === "Enter" && !tt(u) && !l.getState().highlightedId && (u.preventDefault(), l.pressEnter());
347
+ }, we = async (u) => {
348
+ ot(y.current);
349
+ const S = await l.select(u, { sidekickStore: b, defaultSidecarRenderer: r });
350
+ if (S.isCompletion) {
351
+ y.current?.focus();
352
+ return;
353
+ }
354
+ S.isRejected || (S.message && a?.({ message: S.message }), S.shouldReset && I());
355
+ }, X = /* @__PURE__ */ i(
356
+ T.Input,
321
357
  {
322
358
  "data-testid": "shortround-input",
323
- onKeyDown: ae,
324
- onSelect: se,
325
- onValueChange: P,
326
- placeholder: Ne,
327
- ref: S,
328
- value: v
359
+ onKeyDown: ge,
360
+ onSelect: pe,
361
+ onValueChange: me,
362
+ placeholder: Ye,
363
+ ref: y,
364
+ value: w
329
365
  }
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,
366
+ ), Re = A.canShowHints ? /* @__PURE__ */ i(Me, { inputRef: y, lineState: A.lineState, children: X }) : X, J = ({ key: u, name: S, intentions: O, style: C, ref: D }) => /* @__PURE__ */ k(T.Group, { ref: D, style: C, children: [
367
+ /* @__PURE__ */ i(s.Group, { name: S }),
368
+ O.map((Q) => /* @__PURE__ */ i(
369
+ rt,
334
370
  {
335
- Item: c.Item,
336
- iconSources: s,
337
- intention: B,
338
- onSelect: ue
371
+ Item: s.Item,
372
+ iconSources: c,
373
+ intention: Q,
374
+ onSelect: we
339
375
  },
340
- B.id
376
+ Q.id
341
377
  ))
342
378
  ] }, u);
343
- return /* @__PURE__ */ i(c.Frame, { height: f, children: /* @__PURE__ */ k(
344
- b,
379
+ return /* @__PURE__ */ i(s.Frame, { height: v, children: /* @__PURE__ */ k(
380
+ T,
345
381
  {
346
- label: d,
382
+ label: f,
347
383
  loop: !0,
348
- onValueChange: K,
384
+ onValueChange: fe,
349
385
  shouldFilter: !1,
350
- value: z,
386
+ value: he,
351
387
  children: [
352
- /* @__PURE__ */ i(c.Input, { input: le, inputMessage: R }),
388
+ /* @__PURE__ */ i("div", { ref: P, children: /* @__PURE__ */ i(s.Input, { enterLine: E, input: Re, inputMessage: R }) }),
353
389
  /* @__PURE__ */ k(
354
- b.List,
390
+ T.List,
355
391
  {
392
+ onPointerMoveCapture: q,
356
393
  style: {
357
- height: `calc(${f} - 107px)`,
358
- // not sure why 107 works
394
+ height: `calc(${v} - ${je + $}px)`,
359
395
  overflowY: "auto",
360
396
  padding: "8px 0"
361
397
  },
362
398
  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
399
+ /* @__PURE__ */ i(T.Empty, { children: /* @__PURE__ */ i(s.NoMatches, { inputValue: w }) }),
400
+ /* @__PURE__ */ k("div", { style: Be, children: [
401
+ F.map((u) => J({ key: u.name ?? nt, ...u })),
402
+ h.length > 0 && J({
403
+ key: Xe,
404
+ name: Oe,
405
+ intentions: h,
406
+ style: qe,
407
+ ref: W
372
408
  })
373
409
  ] })
374
410
  ]
375
411
  }
376
412
  ),
377
413
  /* @__PURE__ */ i(
378
- je,
414
+ ct,
379
415
  {
380
- groupRef: x,
381
- rowIds: y.map(({ id: u }) => u)
416
+ groupRef: W,
417
+ rowIds: h.map(({ id: u }) => u)
382
418
  }
383
419
  )
384
420
  ]
385
421
  }
386
422
  ) });
387
423
  }
388
- function Be({
424
+ function ut({
389
425
  title: e,
390
426
  palette: t,
391
427
  defaultIntentions: n,
392
428
  resolveDefaultInput: o,
393
429
  resolveDefaultFallbackInput: r,
394
- SidekickComponents: c,
395
- showToast: s,
430
+ SidekickComponents: s,
431
+ showToast: c,
396
432
  defaultSidecarRenderer: a,
397
- disableLineHints: d
433
+ disableLineHints: f
398
434
  }) {
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]
435
+ const { onClose: m, setSize: l, anchorOrigin: p, cycleAnchorOrigin: g, height: w, size: R, commandWidth: E } = B(), { Sidekick: h, IntentionPalette: v } = s, I = M()?.icons, b = H(
436
+ () => ({ registry: I, themeIcons: s.icons }),
437
+ [I, s.icons]
402
438
  );
403
- return /* @__PURE__ */ i(V.div, { layout: !0, transition: { duration: U, ease: "easeInOut" }, children: /* @__PURE__ */ k(f.Frame, { commandWidth: y, height: v, children: [
439
+ return /* @__PURE__ */ i(Y.div, { layout: !0, transition: { duration: j, ease: "easeInOut" }, children: /* @__PURE__ */ k(h.Frame, { commandWidth: E, height: w, children: [
404
440
  /* @__PURE__ */ i(
405
- f.ControlBar,
441
+ h.ControlBar,
406
442
  {
407
443
  anchorOrigin: p,
408
- cycleAnchorOrigin: w,
409
- labels: Se,
410
- onClose: h,
444
+ cycleAnchorOrigin: g,
445
+ labels: Ie,
446
+ onClose: m,
411
447
  setSize: l,
412
448
  size: R,
413
449
  title: e
414
450
  }
415
451
  ),
416
452
  R !== "compact" && /* @__PURE__ */ i(
417
- Me,
453
+ at,
418
454
  {
419
- IntentionPalette: O,
455
+ IntentionPalette: v,
420
456
  defaultIntentions: n,
421
457
  defaultSidecarRenderer: a,
422
- disableLineHints: d,
423
- iconSources: S,
424
- label: e ?? oe,
458
+ disableLineHints: f,
459
+ iconSources: b,
460
+ label: e ?? ie,
425
461
  palette: t,
426
462
  resolveDefaultFallbackInput: r,
427
463
  resolveDefaultInput: o,
428
- showToast: s
464
+ showToast: c
429
465
  }
430
466
  )
431
467
  ] }) });
432
468
  }
433
- function qe({ isOpen: e, renderSidecar: t, height: n, width: o, Content: r }) {
434
- const c = {
469
+ function lt({ isOpen: e, renderSidecar: t, height: n, width: o, Content: r }) {
470
+ const s = {
435
471
  open: { width: o, pointerEvents: "auto" },
436
472
  closed: { width: 0, pointerEvents: "none" }
437
473
  };
438
474
  return /* @__PURE__ */ i(
439
- V.div,
475
+ Y.div,
440
476
  {
441
477
  animate: e ? "open" : "closed",
442
478
  layout: !0,
443
479
  style: { display: "flex", overflow: "hidden", opacity: 1 },
444
- transition: { duration: U, ease: "easeInOut" },
445
- variants: c,
480
+ transition: { duration: j, ease: "easeInOut" },
481
+ variants: s,
446
482
  children: /* @__PURE__ */ i(r, { height: n, isOpen: e, renderSidecar: t })
447
483
  }
448
484
  );
449
485
  }
450
- function Xe(e, t) {
451
- const n = m(e), o = m(t);
452
- o.current = t, C(() => {
486
+ function dt(e, t) {
487
+ const n = d(e), o = d(t);
488
+ o.current = t, L(() => {
453
489
  n.current && !e && o.current?.(), n.current = e;
454
490
  }, [e]);
455
491
  }
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;
492
+ function ht(e, t, { sidecarReducer: n, defaultSidecarRenderer: o, palette: r }) {
493
+ const s = d(n);
494
+ s.current = n;
495
+ const c = d(!1), a = () => r ? r.current().sidecarRenderer : o, f = d(a);
496
+ f.current = a, x(() => (e.setSidecarReducer(
497
+ (...m) => (s.current ?? ((l, p) => p))(...m)
498
+ ), () => e.setSidecarReducer(void 0)), [e]), x(() => {
499
+ t && !c.current ? e.changeSidecar({ renderer: f.current() ?? null }, "open") : !t && c.current && e.clearSidecar(), c.current = t;
464
500
  }, [e, t]);
465
501
  }
466
- function Qe(e, t) {
467
- L(() => {
502
+ function ft(e, t) {
503
+ x(() => {
468
504
  document.activeElement === document.body && t();
469
505
  }, [e, t]);
470
506
  }
471
- const Ze = {
507
+ const mt = {
472
508
  display: "flex",
473
509
  flexDirection: "inherit",
474
510
  alignItems: "inherit",
475
511
  width: "100%",
476
512
  height: "100%"
477
- }, et = we(function({ name: t, onClose: n, children: o }, r) {
513
+ }, pt = Ce(function({ name: t, onClose: n, children: o }, r) {
478
514
  return /* @__PURE__ */ i(
479
515
  "div",
480
516
  {
481
517
  "aria-label": t,
482
518
  "aria-modal": "false",
483
- onKeyDown: (s) => {
484
- s.key === "Escape" && !s.defaultPrevented && n();
519
+ onKeyDown: (c) => {
520
+ c.key === "Escape" && !c.defaultPrevented && n();
485
521
  },
486
522
  ref: r,
487
523
  role: "dialog",
488
- style: Ze,
524
+ style: mt,
489
525
  tabIndex: -1,
490
526
  children: o
491
527
  }
492
528
  );
493
529
  });
494
- function tt({
530
+ function St({
495
531
  title: e,
496
532
  palette: t,
497
533
  defaultIntentions: n,
498
534
  resolveDefaultInput: o,
499
535
  resolveDefaultFallbackInput: r,
500
- SidekickComponents: c,
501
- showToast: s,
536
+ SidekickComponents: s,
537
+ showToast: c,
502
538
  installKeyboardShortcuts: a,
503
- notifyClose: d,
504
- sidecarReducer: h,
539
+ notifyClose: f,
540
+ sidecarReducer: m,
505
541
  defaultSidecarRenderer: l,
506
542
  disableLineHints: p
507
543
  }) {
508
544
  const {
509
- isSidecarOpen: w,
510
- anchorOrigin: v,
545
+ isSidecarOpen: g,
546
+ anchorOrigin: w,
511
547
  renderSidecar: R,
512
- height: y,
513
- sidecarWidth: f,
514
- isOpen: O,
548
+ height: E,
549
+ sidecarWidth: h,
550
+ isOpen: v,
515
551
  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,
552
+ totalWidth: b,
553
+ size: y,
554
+ onOpen: P,
555
+ onClose: $
556
+ } = B(), { Sidekick: W, SidecarContent: z } = s, { attachDialog: A, focusInside: F } = Pe();
557
+ return _e({
558
+ onOpen: v ? F : P,
523
559
  installKeyboardShortcuts: a
524
- }), Qe(x, P), Xe(O, d), Je(W(), O, {
525
- sidecarReducer: h,
560
+ }), ft(y, F), dt(v, f), ht(K(), v, {
561
+ sidecarReducer: m,
526
562
  defaultSidecarRenderer: l,
527
563
  palette: t
528
- }), O ? /* @__PURE__ */ i(
529
- V.div,
564
+ }), v ? /* @__PURE__ */ i(
565
+ Y.div,
530
566
  {
531
567
  animate: {
532
- width: S
568
+ width: b
533
569
  },
534
570
  layout: !0,
535
- transition: { duration: U, ease: "easeInOut" },
571
+ transition: { duration: j, ease: "easeInOut" },
536
572
  children: /* @__PURE__ */ i(
537
- $.Popover,
573
+ W.Popover,
538
574
  {
539
- anchorOrigin: v,
575
+ anchorOrigin: w,
540
576
  anchorPosition: I,
541
- height: y,
542
- totalWidth: S,
543
- children: /* @__PURE__ */ k(et, { name: e ?? oe, onClose: T, ref: K, children: [
577
+ height: E,
578
+ totalWidth: b,
579
+ children: /* @__PURE__ */ k(pt, { name: e ?? ie, onClose: $, ref: A, children: [
544
580
  /* @__PURE__ */ i(
545
- Be,
581
+ ut,
546
582
  {
547
- SidekickComponents: c,
583
+ SidekickComponents: s,
548
584
  defaultIntentions: n,
549
585
  defaultSidecarRenderer: l,
550
586
  disableLineHints: p,
551
587
  palette: t,
552
588
  resolveDefaultFallbackInput: r,
553
589
  resolveDefaultInput: o,
554
- showToast: s,
590
+ showToast: c,
555
591
  title: e
556
592
  }
557
593
  ),
558
594
  /* @__PURE__ */ i(
559
- qe,
595
+ lt,
560
596
  {
561
597
  Content: z,
562
- height: y,
563
- isOpen: w,
598
+ height: E,
599
+ isOpen: g,
564
600
  renderSidecar: R,
565
- width: f
601
+ width: h
566
602
  }
567
603
  )
568
604
  ] })
@@ -571,46 +607,46 @@ function tt({
571
607
  }
572
608
  ) : null;
573
609
  }
574
- function nt(e, t) {
575
- const n = N(), o = e ?? n?.components;
610
+ function gt(e, t) {
611
+ const n = M(), o = e ?? n?.components;
576
612
  if (!o)
577
613
  throw new Error(
578
614
  "ShortRoundSidekick has no theme: wrap the app in <ShortRoundProvider theme={…}>, or pass SidekickComponents"
579
615
  );
580
- return rt(o), { components: o, showToast: t ?? n?.showToast };
616
+ return Rt(o), { components: o, showToast: t ?? n?.showToast };
581
617
  }
582
- const ot = ["IntentionPalette", "Sidekick", "SidecarContent"];
583
- function rt(e) {
584
- const t = ot.filter((n) => !e[n]);
618
+ const wt = ["IntentionPalette", "Sidekick", "SidecarContent"];
619
+ function Rt(e) {
620
+ const t = wt.filter((n) => !e[n]);
585
621
  if (t.length > 0)
586
622
  throw new Error(
587
623
  `ShortRoundSidekick: the theme has no ${t.map((n) => `components.${n}`).join(" or ")}`
588
624
  );
589
625
  }
590
- function St({
626
+ function At({
591
627
  title: e,
592
628
  palette: t,
593
629
  defaultIntentions: n,
594
630
  resolveDefaultInput: o,
595
631
  resolveDefaultFallbackInput: r,
596
- SidekickComponents: c,
597
- showToast: s,
632
+ SidekickComponents: s,
633
+ showToast: c,
598
634
  installKeyboardShortcuts: a,
599
- sidekickStore: d,
600
- initialSidekickState: h,
635
+ sidekickStore: f,
636
+ initialSidekickState: m,
601
637
  onClose: l,
602
638
  sidecarReducer: p,
603
- defaultSidecarRenderer: w,
604
- disableLineHints: v
639
+ defaultSidecarRenderer: g,
640
+ disableLineHints: w
605
641
  }) {
606
- const R = nt(c, s);
607
- return /* @__PURE__ */ i(Ee, { initial: h, store: d, children: /* @__PURE__ */ i(
608
- tt,
642
+ const R = gt(s, c);
643
+ return /* @__PURE__ */ i(De, { initial: m, store: f, children: /* @__PURE__ */ i(
644
+ St,
609
645
  {
610
646
  SidekickComponents: R.components,
611
647
  defaultIntentions: n,
612
- defaultSidecarRenderer: w,
613
- disableLineHints: v,
648
+ defaultSidecarRenderer: g,
649
+ disableLineHints: w,
614
650
  installKeyboardShortcuts: a,
615
651
  notifyClose: l,
616
652
  palette: t,
@@ -622,31 +658,31 @@ function St({
622
658
  }
623
659
  ) });
624
660
  }
625
- const ct = { isOpen: !1, message: null };
626
- function st(e) {
661
+ const vt = { isOpen: !1, message: null };
662
+ function yt(e) {
627
663
  const t = ["components", "Toast"].filter((n) => !e?.[n]);
628
664
  if (t.length > 0)
629
665
  throw new Error(`ShortRoundProvider: the theme has no ${t.join(" or ")}`);
630
666
  }
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: [
667
+ function _t({ theme: e, icons: t, children: n }) {
668
+ yt(e);
669
+ const [o, r] = V(vt), s = G(({ message: m }) => r({ isOpen: !0, message: m }), []), c = G(() => r((m) => ({ ...m, isOpen: !1 })), []), a = H(
670
+ () => ({ components: e.components, showToast: s, icons: t }),
671
+ [e.components, s, t]
672
+ ), { Toast: f } = e;
673
+ return /* @__PURE__ */ k(ue.Provider, { value: a, children: [
638
674
  n,
639
- /* @__PURE__ */ i(d, { isOpen: o.isOpen, message: o.message, onClose: s })
675
+ /* @__PURE__ */ i(f, { isOpen: o.isOpen, message: o.message, onClose: c })
640
676
  ] });
641
677
  }
642
678
  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,
650
- j as useSidekick,
651
- W as useSidekickStore
679
+ Me as LineInput,
680
+ _t as ShortRoundProvider,
681
+ At as ShortRoundSidekick,
682
+ De as SidekickStoreProvider,
683
+ Tt as useShortRound,
684
+ Lt as useShortRoundComponents,
685
+ xt as useShortRoundToast,
686
+ B as useSidekick,
687
+ K as useSidekickStore
652
688
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shortround/react",
3
- "version": "0.6.0",
3
+ "version": "0.7.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.7.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.7.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