@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 +14 -0
- package/README.md +20 -3
- package/dist/react.es.js +310 -274
- package/package.json +3 -3
- package/src/index.d.ts +7 -1
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
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { jsx as i, jsxs as k, Fragment as
|
|
4
|
-
import
|
|
5
|
-
import { motion as
|
|
6
|
-
import { Command as
|
|
7
|
-
function
|
|
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 =
|
|
14
|
-
r.current || (r.current =
|
|
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
|
|
21
|
-
return
|
|
22
|
-
|
|
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
|
-
}, [
|
|
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
|
|
30
|
+
function Tt({
|
|
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 } = 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:
|
|
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 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
|
-
}),
|
|
62
|
+
}), Z = 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: 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
|
-
},
|
|
77
|
-
function
|
|
78
|
-
const o =
|
|
79
|
-
!e && !o && !r.current && (r.current =
|
|
80
|
-
const
|
|
81
|
-
return /* @__PURE__ */ i(
|
|
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
|
|
84
|
-
const t =
|
|
83
|
+
function B(e = {}) {
|
|
84
|
+
const t = K();
|
|
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 = 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:
|
|
98
|
+
anchorPosition: Ae[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
106
|
height: p,
|
|
107
|
-
setSize: (
|
|
108
|
-
|
|
107
|
+
setSize: (h) => {
|
|
108
|
+
Le(Z[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: g,
|
|
116
116
|
closeSidecar: n.closeSidecar,
|
|
117
|
-
renderSidecar:
|
|
117
|
+
renderSidecar: E
|
|
118
118
|
};
|
|
119
119
|
}, [n, r]);
|
|
120
|
-
return { ...r, ...
|
|
120
|
+
return { ...r, ...s };
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
124
|
-
const e =
|
|
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
|
|
129
|
+
function ee(e) {
|
|
130
130
|
(e.querySelector("[cmdk-input]") ?? e).focus();
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
const e =
|
|
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,
|
|
135
|
+
t.current = document.activeElement, e.current = r, ee(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 = G(() => {
|
|
143
|
+
e.current && ee(e.current);
|
|
144
144
|
}, []);
|
|
145
145
|
return { attachDialog: n, focusInside: o };
|
|
146
146
|
}
|
|
147
|
-
|
|
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
|
|
150
|
-
const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null,
|
|
151
|
-
return { canShowHints: o, lineState: r ?
|
|
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
|
|
154
|
-
function
|
|
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
|
|
172
|
+
return N(o);
|
|
158
173
|
if (!e.icon)
|
|
159
174
|
return;
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
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 ?
|
|
178
|
+
return t.Icon ? N(t.Icon, { name: r }) : N(te(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 x(() => {
|
|
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
|
+
Ue(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: $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
|
|
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
|
|
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"),
|
|
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 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(
|
|
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
|
|
236
|
-
function
|
|
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
|
|
241
|
-
const r =
|
|
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
|
-
|
|
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:
|
|
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
|
|
276
|
+
const st = (e) => e.reduce((t, n) => {
|
|
262
277
|
const o = n.group ?? void 0;
|
|
263
|
-
let r = t.find((
|
|
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
|
|
267
|
-
const n =
|
|
268
|
-
return
|
|
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
|
|
278
|
-
const t =
|
|
279
|
-
return
|
|
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
|
|
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:
|
|
290
|
-
iconSources:
|
|
304
|
+
IntentionPalette: s,
|
|
305
|
+
iconSources: c = {},
|
|
291
306
|
showToast: a,
|
|
292
|
-
label:
|
|
293
|
-
disableLineHints:
|
|
307
|
+
label: f,
|
|
308
|
+
disableLineHints: m = !1
|
|
294
309
|
}) {
|
|
295
|
-
const { store: l, state: p, intentions:
|
|
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:
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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:
|
|
324
|
-
onSelect:
|
|
325
|
-
onValueChange:
|
|
326
|
-
placeholder:
|
|
327
|
-
ref:
|
|
328
|
-
value:
|
|
359
|
+
onKeyDown: ge,
|
|
360
|
+
onSelect: pe,
|
|
361
|
+
onValueChange: me,
|
|
362
|
+
placeholder: Ye,
|
|
363
|
+
ref: y,
|
|
364
|
+
value: w
|
|
329
365
|
}
|
|
330
|
-
),
|
|
331
|
-
/* @__PURE__ */ i(
|
|
332
|
-
|
|
333
|
-
|
|
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:
|
|
336
|
-
iconSources:
|
|
337
|
-
intention:
|
|
338
|
-
onSelect:
|
|
371
|
+
Item: s.Item,
|
|
372
|
+
iconSources: c,
|
|
373
|
+
intention: Q,
|
|
374
|
+
onSelect: we
|
|
339
375
|
},
|
|
340
|
-
|
|
376
|
+
Q.id
|
|
341
377
|
))
|
|
342
378
|
] }, u);
|
|
343
|
-
return /* @__PURE__ */ i(
|
|
344
|
-
|
|
379
|
+
return /* @__PURE__ */ i(s.Frame, { height: v, children: /* @__PURE__ */ k(
|
|
380
|
+
T,
|
|
345
381
|
{
|
|
346
|
-
label:
|
|
382
|
+
label: f,
|
|
347
383
|
loop: !0,
|
|
348
|
-
onValueChange:
|
|
384
|
+
onValueChange: fe,
|
|
349
385
|
shouldFilter: !1,
|
|
350
|
-
value:
|
|
386
|
+
value: he,
|
|
351
387
|
children: [
|
|
352
|
-
/* @__PURE__ */ i(
|
|
388
|
+
/* @__PURE__ */ i("div", { ref: P, children: /* @__PURE__ */ i(s.Input, { enterLine: E, input: Re, inputMessage: R }) }),
|
|
353
389
|
/* @__PURE__ */ k(
|
|
354
|
-
|
|
390
|
+
T.List,
|
|
355
391
|
{
|
|
392
|
+
onPointerMoveCapture: q,
|
|
356
393
|
style: {
|
|
357
|
-
height: `calc(${
|
|
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(
|
|
364
|
-
/* @__PURE__ */ k("div", { style:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
key:
|
|
368
|
-
name:
|
|
369
|
-
intentions:
|
|
370
|
-
style:
|
|
371
|
-
ref:
|
|
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
|
-
|
|
414
|
+
ct,
|
|
379
415
|
{
|
|
380
|
-
groupRef:
|
|
381
|
-
rowIds:
|
|
416
|
+
groupRef: W,
|
|
417
|
+
rowIds: h.map(({ id: u }) => u)
|
|
382
418
|
}
|
|
383
419
|
)
|
|
384
420
|
]
|
|
385
421
|
}
|
|
386
422
|
) });
|
|
387
423
|
}
|
|
388
|
-
function
|
|
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:
|
|
395
|
-
showToast:
|
|
430
|
+
SidekickComponents: s,
|
|
431
|
+
showToast: c,
|
|
396
432
|
defaultSidecarRenderer: a,
|
|
397
|
-
disableLineHints:
|
|
433
|
+
disableLineHints: f
|
|
398
434
|
}) {
|
|
399
|
-
const { onClose:
|
|
400
|
-
() => ({ registry: I, themeIcons:
|
|
401
|
-
[I,
|
|
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(
|
|
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
|
-
|
|
441
|
+
h.ControlBar,
|
|
406
442
|
{
|
|
407
443
|
anchorOrigin: p,
|
|
408
|
-
cycleAnchorOrigin:
|
|
409
|
-
labels:
|
|
410
|
-
onClose:
|
|
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
|
-
|
|
453
|
+
at,
|
|
418
454
|
{
|
|
419
|
-
IntentionPalette:
|
|
455
|
+
IntentionPalette: v,
|
|
420
456
|
defaultIntentions: n,
|
|
421
457
|
defaultSidecarRenderer: a,
|
|
422
|
-
disableLineHints:
|
|
423
|
-
iconSources:
|
|
424
|
-
label: e ??
|
|
458
|
+
disableLineHints: f,
|
|
459
|
+
iconSources: b,
|
|
460
|
+
label: e ?? ie,
|
|
425
461
|
palette: t,
|
|
426
462
|
resolveDefaultFallbackInput: r,
|
|
427
463
|
resolveDefaultInput: o,
|
|
428
|
-
showToast:
|
|
464
|
+
showToast: c
|
|
429
465
|
}
|
|
430
466
|
)
|
|
431
467
|
] }) });
|
|
432
468
|
}
|
|
433
|
-
function
|
|
434
|
-
const
|
|
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
|
-
|
|
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:
|
|
445
|
-
variants:
|
|
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
|
|
451
|
-
const n =
|
|
452
|
-
o.current = t,
|
|
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
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
(...
|
|
462
|
-
), () => e.setSidecarReducer(void 0)), [e]),
|
|
463
|
-
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
|
|
467
|
-
|
|
502
|
+
function ft(e, t) {
|
|
503
|
+
x(() => {
|
|
468
504
|
document.activeElement === document.body && t();
|
|
469
505
|
}, [e, t]);
|
|
470
506
|
}
|
|
471
|
-
const
|
|
507
|
+
const mt = {
|
|
472
508
|
display: "flex",
|
|
473
509
|
flexDirection: "inherit",
|
|
474
510
|
alignItems: "inherit",
|
|
475
511
|
width: "100%",
|
|
476
512
|
height: "100%"
|
|
477
|
-
},
|
|
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: (
|
|
484
|
-
|
|
519
|
+
onKeyDown: (c) => {
|
|
520
|
+
c.key === "Escape" && !c.defaultPrevented && n();
|
|
485
521
|
},
|
|
486
522
|
ref: r,
|
|
487
523
|
role: "dialog",
|
|
488
|
-
style:
|
|
524
|
+
style: mt,
|
|
489
525
|
tabIndex: -1,
|
|
490
526
|
children: o
|
|
491
527
|
}
|
|
492
528
|
);
|
|
493
529
|
});
|
|
494
|
-
function
|
|
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:
|
|
501
|
-
showToast:
|
|
536
|
+
SidekickComponents: s,
|
|
537
|
+
showToast: c,
|
|
502
538
|
installKeyboardShortcuts: a,
|
|
503
|
-
notifyClose:
|
|
504
|
-
sidecarReducer:
|
|
539
|
+
notifyClose: f,
|
|
540
|
+
sidecarReducer: m,
|
|
505
541
|
defaultSidecarRenderer: l,
|
|
506
542
|
disableLineHints: p
|
|
507
543
|
}) {
|
|
508
544
|
const {
|
|
509
|
-
isSidecarOpen:
|
|
510
|
-
anchorOrigin:
|
|
545
|
+
isSidecarOpen: g,
|
|
546
|
+
anchorOrigin: w,
|
|
511
547
|
renderSidecar: R,
|
|
512
|
-
height:
|
|
513
|
-
sidecarWidth:
|
|
514
|
-
isOpen:
|
|
548
|
+
height: E,
|
|
549
|
+
sidecarWidth: h,
|
|
550
|
+
isOpen: v,
|
|
515
551
|
anchorPosition: I,
|
|
516
|
-
totalWidth:
|
|
517
|
-
size:
|
|
518
|
-
onOpen:
|
|
519
|
-
onClose:
|
|
520
|
-
} =
|
|
521
|
-
return
|
|
522
|
-
onOpen:
|
|
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
|
-
}),
|
|
525
|
-
sidecarReducer:
|
|
560
|
+
}), ft(y, F), dt(v, f), ht(K(), v, {
|
|
561
|
+
sidecarReducer: m,
|
|
526
562
|
defaultSidecarRenderer: l,
|
|
527
563
|
palette: t
|
|
528
|
-
}),
|
|
529
|
-
|
|
564
|
+
}), v ? /* @__PURE__ */ i(
|
|
565
|
+
Y.div,
|
|
530
566
|
{
|
|
531
567
|
animate: {
|
|
532
|
-
width:
|
|
568
|
+
width: b
|
|
533
569
|
},
|
|
534
570
|
layout: !0,
|
|
535
|
-
transition: { duration:
|
|
571
|
+
transition: { duration: j, ease: "easeInOut" },
|
|
536
572
|
children: /* @__PURE__ */ i(
|
|
537
|
-
|
|
573
|
+
W.Popover,
|
|
538
574
|
{
|
|
539
|
-
anchorOrigin:
|
|
575
|
+
anchorOrigin: w,
|
|
540
576
|
anchorPosition: I,
|
|
541
|
-
height:
|
|
542
|
-
totalWidth:
|
|
543
|
-
children: /* @__PURE__ */ k(
|
|
577
|
+
height: E,
|
|
578
|
+
totalWidth: b,
|
|
579
|
+
children: /* @__PURE__ */ k(pt, { name: e ?? ie, onClose: $, ref: A, children: [
|
|
544
580
|
/* @__PURE__ */ i(
|
|
545
|
-
|
|
581
|
+
ut,
|
|
546
582
|
{
|
|
547
|
-
SidekickComponents:
|
|
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:
|
|
590
|
+
showToast: c,
|
|
555
591
|
title: e
|
|
556
592
|
}
|
|
557
593
|
),
|
|
558
594
|
/* @__PURE__ */ i(
|
|
559
|
-
|
|
595
|
+
lt,
|
|
560
596
|
{
|
|
561
597
|
Content: z,
|
|
562
|
-
height:
|
|
563
|
-
isOpen:
|
|
598
|
+
height: E,
|
|
599
|
+
isOpen: g,
|
|
564
600
|
renderSidecar: R,
|
|
565
|
-
width:
|
|
601
|
+
width: h
|
|
566
602
|
}
|
|
567
603
|
)
|
|
568
604
|
] })
|
|
@@ -571,46 +607,46 @@ function tt({
|
|
|
571
607
|
}
|
|
572
608
|
) : null;
|
|
573
609
|
}
|
|
574
|
-
function
|
|
575
|
-
const n =
|
|
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
|
|
616
|
+
return Rt(o), { components: o, showToast: t ?? n?.showToast };
|
|
581
617
|
}
|
|
582
|
-
const
|
|
583
|
-
function
|
|
584
|
-
const t =
|
|
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
|
|
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:
|
|
597
|
-
showToast:
|
|
632
|
+
SidekickComponents: s,
|
|
633
|
+
showToast: c,
|
|
598
634
|
installKeyboardShortcuts: a,
|
|
599
|
-
sidekickStore:
|
|
600
|
-
initialSidekickState:
|
|
635
|
+
sidekickStore: f,
|
|
636
|
+
initialSidekickState: m,
|
|
601
637
|
onClose: l,
|
|
602
638
|
sidecarReducer: p,
|
|
603
|
-
defaultSidecarRenderer:
|
|
604
|
-
disableLineHints:
|
|
639
|
+
defaultSidecarRenderer: g,
|
|
640
|
+
disableLineHints: w
|
|
605
641
|
}) {
|
|
606
|
-
const R =
|
|
607
|
-
return /* @__PURE__ */ i(
|
|
608
|
-
|
|
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:
|
|
613
|
-
disableLineHints:
|
|
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
|
|
626
|
-
function
|
|
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
|
|
632
|
-
|
|
633
|
-
const [o, r] =
|
|
634
|
-
() => ({ components: e.components, showToast:
|
|
635
|
-
[e.components,
|
|
636
|
-
), { Toast:
|
|
637
|
-
return /* @__PURE__ */ k(
|
|
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(
|
|
675
|
+
/* @__PURE__ */ i(f, { isOpen: o.isOpen, message: o.message, onClose: c })
|
|
640
676
|
] });
|
|
641
677
|
}
|
|
642
678
|
export {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
/**
|
|
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
|