@shortround/react 0.7.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 +13 -0
- package/README.md +20 -6
- package/dist/react.es.js +220 -211
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
3
16
|
## 0.7.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -170,7 +170,9 @@ so it can't be typed in while that modal is open; give the modal `disableEnforce
|
|
|
170
170
|
`ModalProps={{ disableEnforceFocus: true }}` on a `Drawer`).
|
|
171
171
|
|
|
172
172
|
- **Cmd/Ctrl+K** opens it from anywhere, or brings focus back into it when it is already open.
|
|
173
|
-
`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.
|
|
174
176
|
- On open, focus moves to its input (to the sidekick itself in compact size); on close, focus returns to where it
|
|
175
177
|
was, unless the user has since moved it elsewhere in the page. After a row is clicked, focus goes back to the
|
|
176
178
|
input, so typing carries on.
|
|
@@ -179,11 +181,23 @@ so it can't be typed in while that modal is open; give the modal `disableEnforce
|
|
|
179
181
|
- **Enter** runs the highlighted row. After every new list the highlight is on the list's first enabled row of your
|
|
180
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
|
|
181
183
|
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`,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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.
|
|
187
201
|
- **Arrow keys** move through the rows and wrap around at either end. Back and Cancel, when a list shows them, are
|
|
188
202
|
drawn at the top under **Navigate** but come last for the keyboard: ArrowUp from the first row reaches them.
|
|
189
203
|
- It is announced as a dialog named by `title` (or "ShortRound"), and its controls carry `ControlLabels`.
|
package/dist/react.es.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { createPaletteStore as
|
|
2
|
-
import { useRef as d, useSyncExternalStore 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 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
|
+
import { motion as V } from "framer-motion";
|
|
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
13
|
const r = d(null);
|
|
14
|
-
r.current || (r.current =
|
|
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 s = r.current, c =
|
|
21
|
-
return
|
|
20
|
+
const s = r.current, c = z(s.subscribe, s.getState, s.getState);
|
|
21
|
+
return x(() => {
|
|
22
22
|
s.setDefaults({
|
|
23
23
|
palette: e,
|
|
24
24
|
defaultIntentions: t,
|
|
25
25
|
resolveDefaultInput: n,
|
|
26
26
|
resolveDefaultFallbackInput: o
|
|
27
27
|
});
|
|
28
|
-
}, [s, e, t, n, o]),
|
|
28
|
+
}, [s, e, t, n, o]), x(() => s.watchResolver(), [s]), x(() => s.watchPalette(), [s, e]), { store: s, state: c, intentions: s.rows() };
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function At({
|
|
31
31
|
defaultIntentions: e,
|
|
32
32
|
resolveDefaultInput: t,
|
|
33
33
|
resolveDefaultFallbackInput: n
|
|
34
34
|
}) {
|
|
35
|
-
const { store: o, state: r, intentions: s } =
|
|
35
|
+
const { store: o, state: r, intentions: s } = se({
|
|
36
36
|
defaultIntentions: e,
|
|
37
37
|
resolveDefaultInput: t,
|
|
38
38
|
resolveDefaultFallbackInput: n
|
|
@@ -49,7 +49,7 @@ function Tt({
|
|
|
49
49
|
dispatchedStack: r.dispatchedStack
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const Y = 0.35, Ae = "100vh", _e = Object.freeze({
|
|
53
53
|
center: { top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
|
|
54
54
|
"top-left": { top: 0, left: 0 },
|
|
55
55
|
top: { top: 0, left: "50%", transform: "translateX(-50%)" },
|
|
@@ -59,13 +59,13 @@ const j = 0.35, xe = "100vh", Ae = Object.freeze({
|
|
|
59
59
|
"bottom-right": { bottom: 0, right: 0 },
|
|
60
60
|
bottom: { bottom: 0, left: "50%", transform: "translateX(-50%)" },
|
|
61
61
|
"bottom-left": { bottom: 0, left: 0 }
|
|
62
|
-
}),
|
|
62
|
+
}), Q = Object.freeze({
|
|
63
63
|
compact: { height: "auto" },
|
|
64
64
|
medium: { height: "50vh" },
|
|
65
|
-
full: { height:
|
|
66
|
-
}),
|
|
65
|
+
full: { height: Ae }
|
|
66
|
+
}), ce = "ShortRound", Pe = ({ onOpen: e, installKeyboardShortcuts: t = !0 }) => {
|
|
67
67
|
const n = d({ onOpen: e });
|
|
68
|
-
n.current = { onOpen: e },
|
|
68
|
+
n.current = { onOpen: e }, x(() => {
|
|
69
69
|
if (!t)
|
|
70
70
|
return;
|
|
71
71
|
const o = (r) => {
|
|
@@ -73,29 +73,29 @@ const j = 0.35, xe = "100vh", Ae = Object.freeze({
|
|
|
73
73
|
};
|
|
74
74
|
return document.addEventListener("keydown", o, { capture: !0 }), () => document.removeEventListener("keydown", o, { capture: !0 });
|
|
75
75
|
}, [t]);
|
|
76
|
-
},
|
|
76
|
+
}, ie = ne(null), F = () => oe(ie);
|
|
77
77
|
function De({ store: e, initial: t, children: n }) {
|
|
78
|
-
const o =
|
|
79
|
-
!e && !o && !r.current && (r.current =
|
|
78
|
+
const o = F(), r = d(null);
|
|
79
|
+
!e && !o && !r.current && (r.current = te(t));
|
|
80
80
|
const s = e ?? o ?? r.current;
|
|
81
|
-
return /* @__PURE__ */ i(
|
|
81
|
+
return /* @__PURE__ */ i(ie.Provider, { value: s, children: n });
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const t =
|
|
83
|
+
function j(e = {}) {
|
|
84
|
+
const t = F();
|
|
85
85
|
let n = e.store || t;
|
|
86
86
|
const o = d(null);
|
|
87
|
-
n || (o.current || (o.current =
|
|
88
|
-
const r =
|
|
89
|
-
const { maxTotalWidth: c, commandWidth: a, anchorOrigin: f, internalSidecarRenderer: m, size: l } = r, { height:
|
|
90
|
-
w(
|
|
91
|
-
},
|
|
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
92
|
if (m)
|
|
93
93
|
return m();
|
|
94
94
|
};
|
|
95
95
|
return {
|
|
96
96
|
// Worked out from the origin, so a store created with only `anchorOrigin` opens there; a position stored
|
|
97
97
|
// beside it (a 0.3.0 workaround) is ignored.
|
|
98
|
-
anchorPosition:
|
|
98
|
+
anchorPosition: _e[f],
|
|
99
99
|
onOpen: () => n.set({ isOpen: !0 }),
|
|
100
100
|
setIsOpen: (h) => {
|
|
101
101
|
n.set({ isOpen: h });
|
|
@@ -103,50 +103,50 @@ function B(e = {}) {
|
|
|
103
103
|
onClose: () => {
|
|
104
104
|
n.clearSidecar(), n.set({ isOpen: !1 });
|
|
105
105
|
},
|
|
106
|
-
height:
|
|
106
|
+
height: g,
|
|
107
107
|
setSize: (h) => {
|
|
108
|
-
|
|
108
|
+
xe(Q[h], `Unknown size: ${h}`), n.set({ size: h });
|
|
109
109
|
},
|
|
110
110
|
setAnchorOrigin: w,
|
|
111
111
|
cycleAnchorOrigin: R,
|
|
112
112
|
// The app's own calls: through the reducer, with the reason `app`.
|
|
113
113
|
setSidecarRenderer: n.openSidecar,
|
|
114
114
|
commandWidth: a,
|
|
115
|
-
sidecarWidth:
|
|
115
|
+
sidecarWidth: S,
|
|
116
116
|
closeSidecar: n.closeSidecar,
|
|
117
|
-
renderSidecar:
|
|
117
|
+
renderSidecar: O
|
|
118
118
|
};
|
|
119
119
|
}, [n, r]);
|
|
120
120
|
return { ...r, ...s };
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
function
|
|
124
|
-
const e =
|
|
122
|
+
const ae = ne(null), G = () => oe(ae), _t = () => G()?.components ?? null;
|
|
123
|
+
function Pt() {
|
|
124
|
+
const e = G();
|
|
125
125
|
if (!e)
|
|
126
126
|
throw new Error("useShortRoundToast needs a <ShortRoundProvider theme={…}> above it");
|
|
127
127
|
return { showToast: e.showToast };
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Z(e) {
|
|
130
130
|
(e.querySelector("[cmdk-input]") ?? e).focus();
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
const e = d(null), t = d(null), n =
|
|
132
|
+
function We() {
|
|
133
|
+
const e = d(null), t = d(null), n = N((r) => {
|
|
134
134
|
if (r) {
|
|
135
|
-
t.current = document.activeElement, e.current = r,
|
|
135
|
+
t.current = document.activeElement, e.current = r, Z(r);
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
const s = e.current, c = t.current;
|
|
139
139
|
e.current = null, t.current = null;
|
|
140
140
|
const a = document.activeElement;
|
|
141
141
|
(!a || a === document.body || s?.contains(a)) && c && c !== document.body && c.isConnected && c.focus();
|
|
142
|
-
}, []), o =
|
|
143
|
-
e.current &&
|
|
142
|
+
}, []), o = N(() => {
|
|
143
|
+
e.current && Z(e.current);
|
|
144
144
|
}, []);
|
|
145
145
|
return { attachDialog: n, focusInside: o };
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const [t, n] =
|
|
149
|
-
return
|
|
147
|
+
function Ne(e) {
|
|
148
|
+
const [t, n] = U(0), o = d(1 / 0);
|
|
149
|
+
return A(() => {
|
|
150
150
|
const r = e.current;
|
|
151
151
|
if (!r || typeof ResizeObserver > "u")
|
|
152
152
|
return;
|
|
@@ -159,23 +159,23 @@ function We(e) {
|
|
|
159
159
|
return c.observe(r), () => c.disconnect();
|
|
160
160
|
}, [e]), t;
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const $e = { subscribe: () => () => {
|
|
163
163
|
}, getState: () => null };
|
|
164
|
-
function
|
|
165
|
-
const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null, s = r ??
|
|
164
|
+
function Fe({ palette: e, disableLineHints: t, store: n }) {
|
|
165
|
+
const o = typeof e?.commandLine == "function" && !t, r = o ? n.commandLine() : null, s = r ?? $e, c = z(s.subscribe, s.getState, s.getState);
|
|
166
166
|
return { canShowHints: o, lineState: r ? c : null, complete: () => !n.commandLine() || !n.completeFirst() ? null : n.commandLine()?.getState().caret ?? null };
|
|
167
167
|
}
|
|
168
|
-
const Ge = new Set(Object.values(
|
|
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
169
|
function He(e, { registry: t = {}, themeIcons: n = {} }) {
|
|
170
170
|
const o = t.intentions?.[e.id];
|
|
171
171
|
if (o)
|
|
172
|
-
return
|
|
172
|
+
return W(o);
|
|
173
173
|
if (!e.icon)
|
|
174
174
|
return;
|
|
175
175
|
if (Ge.has(e.id))
|
|
176
|
-
return
|
|
176
|
+
return W(ee(e.icon, n));
|
|
177
177
|
const r = t.names?.[e.icon] ?? e.icon;
|
|
178
|
-
return t.Icon ?
|
|
178
|
+
return t.Icon ? W(t.Icon, { name: r }) : W(ee(r, n));
|
|
179
179
|
}
|
|
180
180
|
const Ke = [
|
|
181
181
|
"fontFamily",
|
|
@@ -196,7 +196,7 @@ const Ke = [
|
|
|
196
196
|
];
|
|
197
197
|
function Me({ children: e, inputRef: t, lineState: n }) {
|
|
198
198
|
const o = d(null), r = !!n;
|
|
199
|
-
return
|
|
199
|
+
return A(() => {
|
|
200
200
|
const s = t.current, c = o.current;
|
|
201
201
|
if (!s)
|
|
202
202
|
return;
|
|
@@ -204,17 +204,17 @@ function Me({ children: e, inputRef: t, lineState: n }) {
|
|
|
204
204
|
s.style.color = "", s.style.caretColor = "";
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
Ve(s, c);
|
|
208
208
|
const a = () => {
|
|
209
209
|
c.scrollLeft = s.scrollLeft;
|
|
210
210
|
};
|
|
211
211
|
return a(), s.addEventListener("scroll", a), () => s.removeEventListener("scroll", a);
|
|
212
|
-
}), /* @__PURE__ */ k("div", { "data-testid": "shortround-line-input", style:
|
|
213
|
-
r && /* @__PURE__ */ i("div", { "aria-hidden": !0, "data-testid": "shortround-line-shadow", ref: o, style:
|
|
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 }) }),
|
|
214
214
|
e
|
|
215
215
|
] });
|
|
216
216
|
}
|
|
217
|
-
const
|
|
217
|
+
const ze = { position: "relative", flex: "1 1 auto", width: "100%", minWidth: 0 }, Ue = {
|
|
218
218
|
position: "absolute",
|
|
219
219
|
pointerEvents: "none",
|
|
220
220
|
whiteSpace: "pre",
|
|
@@ -224,7 +224,7 @@ const $e = { position: "relative", flex: "1 1 auto", width: "100%", minWidth: 0
|
|
|
224
224
|
// The shadow is sized from the input's offset box, which includes padding and border.
|
|
225
225
|
boxSizing: "border-box"
|
|
226
226
|
};
|
|
227
|
-
function
|
|
227
|
+
function Ve(e, t) {
|
|
228
228
|
const n = window.getComputedStyle(e);
|
|
229
229
|
e.style.color !== "transparent" && (t.style.color = n.color, e.style.caretColor = n.color, e.style.color = "transparent"), Ke.forEach((o) => {
|
|
230
230
|
t.style[o] = n[o];
|
|
@@ -235,27 +235,27 @@ function Ue(e, t) {
|
|
|
235
235
|
height: `${e.offsetHeight}px`
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function Ye({ state: e }) {
|
|
239
239
|
const t = [];
|
|
240
240
|
let n = 0;
|
|
241
241
|
for (const o of e.roles)
|
|
242
242
|
o.start > n && t.push(/* @__PURE__ */ i("span", { children: e.text.slice(n, o.start) }, `gap-${n}`)), t.push(
|
|
243
243
|
/* @__PURE__ */ i("span", { "data-role": o.role, title: o.reason, children: e.text.slice(o.start, o.end) }, o.start)
|
|
244
244
|
), n = o.end;
|
|
245
|
-
return n < e.text.length && t.push(/* @__PURE__ */ i("span", { children: e.text.slice(n) }, `tail-${n}`)), /* @__PURE__ */ k(
|
|
245
|
+
return n < e.text.length && t.push(/* @__PURE__ */ i("span", { children: e.text.slice(n) }, `tail-${n}`)), /* @__PURE__ */ k(Le, { children: [
|
|
246
246
|
t,
|
|
247
247
|
e.ghost && /* @__PURE__ */ i("span", { "data-role": "ghost", children: e.ghost })
|
|
248
248
|
] });
|
|
249
249
|
}
|
|
250
|
-
const
|
|
251
|
-
function
|
|
250
|
+
const je = "Type a intention or search...", Be = 107, qe = { display: "flex", flexDirection: "column" }, Xe = { order: -1 }, Je = "shortround::navigate", Qe = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "Home", "End"]), Ze = /* @__PURE__ */ new Set(["n", "p", "j", "k"]), et = "shortround::no-row", tt = (e) => Qe.has(e.key) || e.ctrlKey && Ze.has(e.key), nt = (e) => e.nativeEvent.isComposing || e.keyCode === 229, ot = "shortround::no-group";
|
|
251
|
+
function rt(e) {
|
|
252
252
|
const t = document.activeElement;
|
|
253
253
|
e && t !== e && e.closest("[cmdk-root]")?.contains(t) && e.focus();
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
const r =
|
|
255
|
+
function st({ intention: e, onSelect: t, Item: n, iconSources: o }) {
|
|
256
|
+
const r = re((s) => s.value) === e.id.trim();
|
|
257
257
|
return /* @__PURE__ */ i(
|
|
258
|
-
|
|
258
|
+
L.Item,
|
|
259
259
|
{
|
|
260
260
|
"data-testid": `shortround-item-${e.id}`,
|
|
261
261
|
disabled: e.disabled,
|
|
@@ -273,14 +273,20 @@ function rt({ intention: e, onSelect: t, Item: n, iconSources: o }) {
|
|
|
273
273
|
}
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
|
-
const
|
|
277
|
-
const o = n
|
|
276
|
+
const ue = (e) => e.group ?? void 0, ct = (e) => e.reduce((t, n) => {
|
|
277
|
+
const o = ue(n);
|
|
278
278
|
let r = t.find((s) => s.name === o);
|
|
279
279
|
return r || (r = { name: o, intentions: [] }, t.push(r)), r.intentions.push(n), t;
|
|
280
|
-
}, [])
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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(() => {
|
|
284
290
|
if (!o)
|
|
285
291
|
return;
|
|
286
292
|
const r = requestAnimationFrame(
|
|
@@ -289,13 +295,13 @@ function ct({ groupRef: e, rowIds: t }) {
|
|
|
289
295
|
return () => cancelAnimationFrame(r);
|
|
290
296
|
}, [n, o, e]), null;
|
|
291
297
|
}
|
|
292
|
-
function
|
|
298
|
+
function lt(e) {
|
|
293
299
|
const t = d(null);
|
|
294
|
-
return
|
|
300
|
+
return A(() => {
|
|
295
301
|
t.current !== null && e.current && (e.current.setSelectionRange(t.current, t.current), t.current = null);
|
|
296
302
|
}), t;
|
|
297
303
|
}
|
|
298
|
-
function
|
|
304
|
+
function dt({
|
|
299
305
|
palette: e,
|
|
300
306
|
defaultIntentions: t,
|
|
301
307
|
resolveDefaultInput: n,
|
|
@@ -307,113 +313,116 @@ function at({
|
|
|
307
313
|
label: f,
|
|
308
314
|
disableLineHints: m = !1
|
|
309
315
|
}) {
|
|
310
|
-
const { store: l, state:
|
|
316
|
+
const { store: l, state: g, intentions: S } = se({
|
|
311
317
|
palette: e,
|
|
312
318
|
defaultIntentions: t,
|
|
313
319
|
resolveDefaultInput: n,
|
|
314
320
|
resolveDefaultFallbackInput: o
|
|
315
|
-
}), { inputValue: w, inputMessage: R, enterLine:
|
|
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 = () => {
|
|
316
325
|
_.current = !0, queueMicrotask(() => {
|
|
317
326
|
_.current = !1;
|
|
318
327
|
});
|
|
319
|
-
},
|
|
320
|
-
const
|
|
321
|
-
_.current = !1
|
|
322
|
-
|
|
323
|
-
if (O && Ee(O) && !S) {
|
|
324
|
-
de((D) => D + 1);
|
|
328
|
+
}, me = (u) => {
|
|
329
|
+
const p = _.current;
|
|
330
|
+
if (_.current = !1, l.getState().highlightedId === void 0 && !p) {
|
|
331
|
+
he((I) => I + 1);
|
|
325
332
|
return;
|
|
326
333
|
}
|
|
327
|
-
const
|
|
328
|
-
l.highlight(
|
|
329
|
-
}, me = (u) => {
|
|
330
|
-
_.current = !1, l.changeInput(u, y.current?.selectionStart);
|
|
334
|
+
const E = [...S, ...h].find(({ id: I }) => I.trim() === u);
|
|
335
|
+
l.highlight(E?.id ?? u);
|
|
331
336
|
}, pe = (u) => {
|
|
332
|
-
|
|
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
|
+
_.current = !1, l.changeInput(u, y.current?.selectionStart);
|
|
337
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 = () => {
|
|
342
|
+
const u = T.complete();
|
|
343
|
+
return u !== null ? (M.current = u, !0) : l.completeFirst();
|
|
344
|
+
}, we = (u) => {
|
|
338
345
|
if (u.key === "Tab" && Se()) {
|
|
339
346
|
u.preventDefault(), y.current?.focus();
|
|
340
347
|
return;
|
|
341
348
|
}
|
|
342
|
-
if (
|
|
343
|
-
|
|
349
|
+
if (tt(u)) {
|
|
350
|
+
B();
|
|
344
351
|
return;
|
|
345
352
|
}
|
|
346
|
-
u.key === "Enter" && !
|
|
347
|
-
},
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
|
|
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());
|
|
353
363
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
T.Input,
|
|
364
|
+
}, q = /* @__PURE__ */ i(
|
|
365
|
+
L.Input,
|
|
357
366
|
{
|
|
358
367
|
"data-testid": "shortround-input",
|
|
359
|
-
onKeyDown:
|
|
360
|
-
onSelect:
|
|
361
|
-
onValueChange:
|
|
362
|
-
placeholder:
|
|
368
|
+
onKeyDown: we,
|
|
369
|
+
onSelect: ge,
|
|
370
|
+
onValueChange: pe,
|
|
371
|
+
placeholder: je,
|
|
363
372
|
ref: y,
|
|
364
373
|
value: w
|
|
365
374
|
}
|
|
366
|
-
),
|
|
367
|
-
/* @__PURE__ */ i(s.Group, { name:
|
|
368
|
-
|
|
369
|
-
|
|
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,
|
|
370
379
|
{
|
|
371
380
|
Item: s.Item,
|
|
372
381
|
iconSources: c,
|
|
373
|
-
intention:
|
|
374
|
-
onSelect:
|
|
382
|
+
intention: J,
|
|
383
|
+
onSelect: Re
|
|
375
384
|
},
|
|
376
|
-
|
|
385
|
+
J.id
|
|
377
386
|
))
|
|
378
387
|
] }, u);
|
|
379
|
-
return /* @__PURE__ */ i(s.Frame, { height:
|
|
380
|
-
|
|
388
|
+
return /* @__PURE__ */ i(s.Frame, { height: b, children: /* @__PURE__ */ k(
|
|
389
|
+
L,
|
|
381
390
|
{
|
|
382
391
|
label: f,
|
|
383
392
|
loop: !0,
|
|
384
|
-
onValueChange:
|
|
393
|
+
onValueChange: me,
|
|
385
394
|
shouldFilter: !1,
|
|
386
|
-
value:
|
|
395
|
+
value: fe,
|
|
387
396
|
children: [
|
|
388
|
-
/* @__PURE__ */ i("div", { ref: P, children: /* @__PURE__ */ i(s.Input, { enterLine:
|
|
397
|
+
/* @__PURE__ */ i("div", { ref: P, children: /* @__PURE__ */ i(s.Input, { enterLine: O, input: ve, inputMessage: R }) }),
|
|
389
398
|
/* @__PURE__ */ k(
|
|
390
|
-
|
|
399
|
+
L.List,
|
|
391
400
|
{
|
|
392
|
-
onPointerMoveCapture:
|
|
401
|
+
onPointerMoveCapture: B,
|
|
393
402
|
style: {
|
|
394
|
-
height: `calc(${
|
|
403
|
+
height: `calc(${b} - ${Be + K}px)`,
|
|
395
404
|
overflowY: "auto",
|
|
396
405
|
padding: "8px 0"
|
|
397
406
|
},
|
|
398
407
|
children: [
|
|
399
|
-
/* @__PURE__ */ i(
|
|
400
|
-
/* @__PURE__ */ k("div", { style:
|
|
401
|
-
|
|
402
|
-
h.length > 0 &&
|
|
403
|
-
key:
|
|
404
|
-
name:
|
|
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,
|
|
405
414
|
intentions: h,
|
|
406
|
-
style:
|
|
407
|
-
ref:
|
|
415
|
+
style: Xe,
|
|
416
|
+
ref: D
|
|
408
417
|
})
|
|
409
418
|
] })
|
|
410
419
|
]
|
|
411
420
|
}
|
|
412
421
|
),
|
|
413
422
|
/* @__PURE__ */ i(
|
|
414
|
-
|
|
423
|
+
ut,
|
|
415
424
|
{
|
|
416
|
-
groupRef:
|
|
425
|
+
groupRef: D,
|
|
417
426
|
rowIds: h.map(({ id: u }) => u)
|
|
418
427
|
}
|
|
419
428
|
)
|
|
@@ -421,7 +430,7 @@ function at({
|
|
|
421
430
|
}
|
|
422
431
|
) });
|
|
423
432
|
}
|
|
424
|
-
function
|
|
433
|
+
function ht({
|
|
425
434
|
title: e,
|
|
426
435
|
palette: t,
|
|
427
436
|
defaultIntentions: n,
|
|
@@ -432,17 +441,17 @@ function ut({
|
|
|
432
441
|
defaultSidecarRenderer: a,
|
|
433
442
|
disableLineHints: f
|
|
434
443
|
}) {
|
|
435
|
-
const { onClose: m, setSize: l, anchorOrigin:
|
|
436
|
-
() => ({ registry:
|
|
437
|
-
[
|
|
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]
|
|
438
447
|
);
|
|
439
|
-
return /* @__PURE__ */ i(
|
|
448
|
+
return /* @__PURE__ */ i(V.div, { layout: !0, transition: { duration: Y, ease: "easeInOut" }, children: /* @__PURE__ */ k(h.Frame, { commandWidth: O, height: w, children: [
|
|
440
449
|
/* @__PURE__ */ i(
|
|
441
450
|
h.ControlBar,
|
|
442
451
|
{
|
|
443
|
-
anchorOrigin:
|
|
444
|
-
cycleAnchorOrigin:
|
|
445
|
-
labels:
|
|
452
|
+
anchorOrigin: g,
|
|
453
|
+
cycleAnchorOrigin: S,
|
|
454
|
+
labels: be,
|
|
446
455
|
onClose: m,
|
|
447
456
|
setSize: l,
|
|
448
457
|
size: R,
|
|
@@ -450,14 +459,14 @@ function ut({
|
|
|
450
459
|
}
|
|
451
460
|
),
|
|
452
461
|
R !== "compact" && /* @__PURE__ */ i(
|
|
453
|
-
|
|
462
|
+
dt,
|
|
454
463
|
{
|
|
455
464
|
IntentionPalette: v,
|
|
456
465
|
defaultIntentions: n,
|
|
457
466
|
defaultSidecarRenderer: a,
|
|
458
467
|
disableLineHints: f,
|
|
459
|
-
iconSources:
|
|
460
|
-
label: e ??
|
|
468
|
+
iconSources: C,
|
|
469
|
+
label: e ?? ce,
|
|
461
470
|
palette: t,
|
|
462
471
|
resolveDefaultFallbackInput: r,
|
|
463
472
|
resolveDefaultInput: o,
|
|
@@ -466,51 +475,51 @@ function ut({
|
|
|
466
475
|
)
|
|
467
476
|
] }) });
|
|
468
477
|
}
|
|
469
|
-
function
|
|
478
|
+
function ft({ isOpen: e, renderSidecar: t, height: n, width: o, Content: r }) {
|
|
470
479
|
const s = {
|
|
471
480
|
open: { width: o, pointerEvents: "auto" },
|
|
472
481
|
closed: { width: 0, pointerEvents: "none" }
|
|
473
482
|
};
|
|
474
483
|
return /* @__PURE__ */ i(
|
|
475
|
-
|
|
484
|
+
V.div,
|
|
476
485
|
{
|
|
477
486
|
animate: e ? "open" : "closed",
|
|
478
487
|
layout: !0,
|
|
479
488
|
style: { display: "flex", overflow: "hidden", opacity: 1 },
|
|
480
|
-
transition: { duration:
|
|
489
|
+
transition: { duration: Y, ease: "easeInOut" },
|
|
481
490
|
variants: s,
|
|
482
491
|
children: /* @__PURE__ */ i(r, { height: n, isOpen: e, renderSidecar: t })
|
|
483
492
|
}
|
|
484
493
|
);
|
|
485
494
|
}
|
|
486
|
-
function
|
|
495
|
+
function mt(e, t) {
|
|
487
496
|
const n = d(e), o = d(t);
|
|
488
|
-
o.current = t,
|
|
497
|
+
o.current = t, x(() => {
|
|
489
498
|
n.current && !e && o.current?.(), n.current = e;
|
|
490
499
|
}, [e]);
|
|
491
500
|
}
|
|
492
|
-
function
|
|
501
|
+
function pt(e, t, { sidecarReducer: n, defaultSidecarRenderer: o, palette: r }) {
|
|
493
502
|
const s = d(n);
|
|
494
503
|
s.current = n;
|
|
495
504
|
const c = d(!1), a = () => r ? r.current().sidecarRenderer : o, f = d(a);
|
|
496
|
-
f.current = a,
|
|
497
|
-
(...m) => (s.current ?? ((l,
|
|
498
|
-
), () => e.setSidecarReducer(void 0)), [e]),
|
|
505
|
+
f.current = a, A(() => (e.setSidecarReducer(
|
|
506
|
+
(...m) => (s.current ?? ((l, g) => g))(...m)
|
|
507
|
+
), () => e.setSidecarReducer(void 0)), [e]), A(() => {
|
|
499
508
|
t && !c.current ? e.changeSidecar({ renderer: f.current() ?? null }, "open") : !t && c.current && e.clearSidecar(), c.current = t;
|
|
500
509
|
}, [e, t]);
|
|
501
510
|
}
|
|
502
|
-
function
|
|
503
|
-
|
|
511
|
+
function gt(e, t) {
|
|
512
|
+
A(() => {
|
|
504
513
|
document.activeElement === document.body && t();
|
|
505
514
|
}, [e, t]);
|
|
506
515
|
}
|
|
507
|
-
const
|
|
516
|
+
const St = {
|
|
508
517
|
display: "flex",
|
|
509
518
|
flexDirection: "inherit",
|
|
510
519
|
alignItems: "inherit",
|
|
511
520
|
width: "100%",
|
|
512
521
|
height: "100%"
|
|
513
|
-
},
|
|
522
|
+
}, wt = Te(function({ name: t, onClose: n, children: o }, r) {
|
|
514
523
|
return /* @__PURE__ */ i(
|
|
515
524
|
"div",
|
|
516
525
|
{
|
|
@@ -521,13 +530,13 @@ const mt = {
|
|
|
521
530
|
},
|
|
522
531
|
ref: r,
|
|
523
532
|
role: "dialog",
|
|
524
|
-
style:
|
|
533
|
+
style: St,
|
|
525
534
|
tabIndex: -1,
|
|
526
535
|
children: o
|
|
527
536
|
}
|
|
528
537
|
);
|
|
529
538
|
});
|
|
530
|
-
function
|
|
539
|
+
function Rt({
|
|
531
540
|
title: e,
|
|
532
541
|
palette: t,
|
|
533
542
|
defaultIntentions: n,
|
|
@@ -539,51 +548,51 @@ function St({
|
|
|
539
548
|
notifyClose: f,
|
|
540
549
|
sidecarReducer: m,
|
|
541
550
|
defaultSidecarRenderer: l,
|
|
542
|
-
disableLineHints:
|
|
551
|
+
disableLineHints: g
|
|
543
552
|
}) {
|
|
544
553
|
const {
|
|
545
|
-
isSidecarOpen:
|
|
554
|
+
isSidecarOpen: S,
|
|
546
555
|
anchorOrigin: w,
|
|
547
556
|
renderSidecar: R,
|
|
548
|
-
height:
|
|
557
|
+
height: O,
|
|
549
558
|
sidecarWidth: h,
|
|
550
559
|
isOpen: v,
|
|
551
|
-
anchorPosition:
|
|
552
|
-
totalWidth:
|
|
553
|
-
size:
|
|
554
|
-
onOpen:
|
|
555
|
-
onClose:
|
|
556
|
-
} =
|
|
557
|
-
return
|
|
558
|
-
onOpen: 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,
|
|
559
568
|
installKeyboardShortcuts: a
|
|
560
|
-
}),
|
|
569
|
+
}), gt(H, T), mt(v, f), pt(F(), v, {
|
|
561
570
|
sidecarReducer: m,
|
|
562
571
|
defaultSidecarRenderer: l,
|
|
563
572
|
palette: t
|
|
564
573
|
}), v ? /* @__PURE__ */ i(
|
|
565
|
-
|
|
574
|
+
V.div,
|
|
566
575
|
{
|
|
567
576
|
animate: {
|
|
568
|
-
width:
|
|
577
|
+
width: C
|
|
569
578
|
},
|
|
570
579
|
layout: !0,
|
|
571
|
-
transition: { duration:
|
|
580
|
+
transition: { duration: Y, ease: "easeInOut" },
|
|
572
581
|
children: /* @__PURE__ */ i(
|
|
573
|
-
|
|
582
|
+
K.Popover,
|
|
574
583
|
{
|
|
575
584
|
anchorOrigin: w,
|
|
576
|
-
anchorPosition:
|
|
577
|
-
height:
|
|
578
|
-
totalWidth:
|
|
579
|
-
children: /* @__PURE__ */ k(
|
|
585
|
+
anchorPosition: b,
|
|
586
|
+
height: O,
|
|
587
|
+
totalWidth: C,
|
|
588
|
+
children: /* @__PURE__ */ k(wt, { name: e ?? ce, onClose: P, ref: M, children: [
|
|
580
589
|
/* @__PURE__ */ i(
|
|
581
|
-
|
|
590
|
+
ht,
|
|
582
591
|
{
|
|
583
592
|
SidekickComponents: s,
|
|
584
593
|
defaultIntentions: n,
|
|
585
594
|
defaultSidecarRenderer: l,
|
|
586
|
-
disableLineHints:
|
|
595
|
+
disableLineHints: g,
|
|
587
596
|
palette: t,
|
|
588
597
|
resolveDefaultFallbackInput: r,
|
|
589
598
|
resolveDefaultInput: o,
|
|
@@ -592,11 +601,11 @@ function St({
|
|
|
592
601
|
}
|
|
593
602
|
),
|
|
594
603
|
/* @__PURE__ */ i(
|
|
595
|
-
|
|
604
|
+
ft,
|
|
596
605
|
{
|
|
597
|
-
Content:
|
|
598
|
-
height:
|
|
599
|
-
isOpen:
|
|
606
|
+
Content: D,
|
|
607
|
+
height: O,
|
|
608
|
+
isOpen: S,
|
|
600
609
|
renderSidecar: R,
|
|
601
610
|
width: h
|
|
602
611
|
}
|
|
@@ -607,23 +616,23 @@ function St({
|
|
|
607
616
|
}
|
|
608
617
|
) : null;
|
|
609
618
|
}
|
|
610
|
-
function
|
|
611
|
-
const n =
|
|
619
|
+
function vt(e, t) {
|
|
620
|
+
const n = G(), o = e ?? n?.components;
|
|
612
621
|
if (!o)
|
|
613
622
|
throw new Error(
|
|
614
623
|
"ShortRoundSidekick has no theme: wrap the app in <ShortRoundProvider theme={…}>, or pass SidekickComponents"
|
|
615
624
|
);
|
|
616
|
-
return
|
|
625
|
+
return kt(o), { components: o, showToast: t ?? n?.showToast };
|
|
617
626
|
}
|
|
618
|
-
const
|
|
619
|
-
function
|
|
620
|
-
const t =
|
|
627
|
+
const yt = ["IntentionPalette", "Sidekick", "SidecarContent"];
|
|
628
|
+
function kt(e) {
|
|
629
|
+
const t = yt.filter((n) => !e[n]);
|
|
621
630
|
if (t.length > 0)
|
|
622
631
|
throw new Error(
|
|
623
632
|
`ShortRoundSidekick: the theme has no ${t.map((n) => `components.${n}`).join(" or ")}`
|
|
624
633
|
);
|
|
625
634
|
}
|
|
626
|
-
function
|
|
635
|
+
function Dt({
|
|
627
636
|
title: e,
|
|
628
637
|
palette: t,
|
|
629
638
|
defaultIntentions: n,
|
|
@@ -635,17 +644,17 @@ function At({
|
|
|
635
644
|
sidekickStore: f,
|
|
636
645
|
initialSidekickState: m,
|
|
637
646
|
onClose: l,
|
|
638
|
-
sidecarReducer:
|
|
639
|
-
defaultSidecarRenderer:
|
|
647
|
+
sidecarReducer: g,
|
|
648
|
+
defaultSidecarRenderer: S,
|
|
640
649
|
disableLineHints: w
|
|
641
650
|
}) {
|
|
642
|
-
const R =
|
|
651
|
+
const R = vt(s, c);
|
|
643
652
|
return /* @__PURE__ */ i(De, { initial: m, store: f, children: /* @__PURE__ */ i(
|
|
644
|
-
|
|
653
|
+
Rt,
|
|
645
654
|
{
|
|
646
655
|
SidekickComponents: R.components,
|
|
647
656
|
defaultIntentions: n,
|
|
648
|
-
defaultSidecarRenderer:
|
|
657
|
+
defaultSidecarRenderer: S,
|
|
649
658
|
disableLineHints: w,
|
|
650
659
|
installKeyboardShortcuts: a,
|
|
651
660
|
notifyClose: l,
|
|
@@ -653,36 +662,36 @@ function At({
|
|
|
653
662
|
resolveDefaultFallbackInput: r,
|
|
654
663
|
resolveDefaultInput: o,
|
|
655
664
|
showToast: R.showToast,
|
|
656
|
-
sidecarReducer:
|
|
665
|
+
sidecarReducer: g,
|
|
657
666
|
title: e
|
|
658
667
|
}
|
|
659
668
|
) });
|
|
660
669
|
}
|
|
661
|
-
const
|
|
662
|
-
function
|
|
670
|
+
const Ot = { isOpen: !1, message: null };
|
|
671
|
+
function Et(e) {
|
|
663
672
|
const t = ["components", "Toast"].filter((n) => !e?.[n]);
|
|
664
673
|
if (t.length > 0)
|
|
665
674
|
throw new Error(`ShortRoundProvider: the theme has no ${t.join(" or ")}`);
|
|
666
675
|
}
|
|
667
|
-
function
|
|
668
|
-
|
|
669
|
-
const [o, r] =
|
|
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 = $(
|
|
670
679
|
() => ({ components: e.components, showToast: s, icons: t }),
|
|
671
680
|
[e.components, s, t]
|
|
672
681
|
), { Toast: f } = e;
|
|
673
|
-
return /* @__PURE__ */ k(
|
|
682
|
+
return /* @__PURE__ */ k(ae.Provider, { value: a, children: [
|
|
674
683
|
n,
|
|
675
684
|
/* @__PURE__ */ i(f, { isOpen: o.isOpen, message: o.message, onClose: c })
|
|
676
685
|
] });
|
|
677
686
|
}
|
|
678
687
|
export {
|
|
679
688
|
Me as LineInput,
|
|
680
|
-
|
|
681
|
-
|
|
689
|
+
Wt as ShortRoundProvider,
|
|
690
|
+
Dt as ShortRoundSidekick,
|
|
682
691
|
De as SidekickStoreProvider,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
692
|
+
At as useShortRound,
|
|
693
|
+
_t as useShortRoundComponents,
|
|
694
|
+
Pt as useShortRoundToast,
|
|
695
|
+
j as useSidekick,
|
|
696
|
+
F as useSidekickStore
|
|
688
697
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shortround/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "ShortRound for React: the command palette, the sidekick, the provider and the theme contract, on @shortround/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shortround",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"types": "./src/index.d.ts",
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@shortround/core": "0.
|
|
43
|
+
"@shortround/core": "0.8.0",
|
|
44
44
|
"@testing-library/jest-dom": "^6.6.3",
|
|
45
45
|
"@testing-library/react": "^16.3.0",
|
|
46
46
|
"@types/react": "19.1.8",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"vitest": "^3.2.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@shortround/core": "^0.
|
|
56
|
+
"@shortround/core": "^0.8.0",
|
|
57
57
|
"react": "^18.2.0 || ^19.0.0",
|
|
58
58
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
59
59
|
},
|