@vibes.diy/base 14.3.454 → 14.3.455

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.
@@ -243,8 +243,9 @@ export function CodeCard(props) {
243
243
  composerField.current?.focus();
244
244
  return undefined;
245
245
  };
246
- const suggestionsNode = (React.createElement(Suggestions, { items: suggestions, gold: code.goldSuggestion, onPick: pickSuggestion, fastPaths: code.suggestionFastPaths, onToggleFastPath: onToggleFastPath }));
247
- const inlineSuggestionsNode = (React.createElement(Suggestions, { items: suggestions, gold: code.goldSuggestion, onPick: pickSuggestion, fastPaths: code.suggestionFastPaths, onToggleFastPath: onToggleFastPath, inline: true }));
246
+ const onSuggestionsShown = props.open === true ? code.onSuggestionsShown : undefined;
247
+ const suggestionsNode = (React.createElement(Suggestions, { items: suggestions, ...(onSuggestionsShown === undefined ? {} : { onShown: onSuggestionsShown }), gold: code.goldSuggestion, onPick: pickSuggestion, fastPaths: code.suggestionFastPaths, onToggleFastPath: onToggleFastPath }));
248
+ const inlineSuggestionsNode = (React.createElement(Suggestions, { items: suggestions, ...(onSuggestionsShown === undefined ? {} : { onShown: onSuggestionsShown }), gold: code.goldSuggestion, onPick: pickSuggestion, fastPaths: code.suggestionFastPaths, onToggleFastPath: onToggleFastPath, inline: true }));
248
249
  const onNavPick = (active, item) => {
249
250
  if (item === "code") {
250
251
  if (codeModeOn) {
@@ -32,8 +32,16 @@ export function withBuildAskAnswer(composer, ask) {
32
32
  return {
33
33
  ...composer,
34
34
  onSubmit: (text, attachments, source) => {
35
- const answer = composer.onSubmit(text, attachments, source);
36
- if (answer === true && attachments.length === 0 && source === undefined)
35
+ const candidate = attachments.length === 0 && source === undefined;
36
+ const after = candidate ? ask.beforeAnswer?.() : undefined;
37
+ let answer;
38
+ try {
39
+ answer = composer.onSubmit(text, attachments, source);
40
+ }
41
+ finally {
42
+ after?.();
43
+ }
44
+ if (answer === true && candidate)
37
45
  ask.onAnswered(text);
38
46
  return answer;
39
47
  },
@@ -35,6 +35,7 @@ export interface SuggestionsProps {
35
35
  readonly onToggleFastPath?: ((text: string) => void) | null;
36
36
  readonly gold?: string | null;
37
37
  readonly inline?: boolean;
38
+ readonly onShown?: (rowId: string, labels: readonly string[]) => void;
38
39
  }
39
40
  export declare function Suggestions(props: SuggestionsProps): React.ReactElement | null;
40
41
  export interface RefreshButtonProps {
@@ -52,6 +52,15 @@ function isPromiseLike(value) {
52
52
  export function Suggestions(props) {
53
53
  const workingRef = React.useRef(null);
54
54
  const [working, setWorking] = React.useState(null);
55
+ const rowId = React.useId();
56
+ const { onShown } = props;
57
+ const shownKey = props.items.slice(0, 3).join("\n");
58
+ React.useEffect(() => {
59
+ if (onShown === undefined)
60
+ return;
61
+ onShown(rowId, shownKey === "" ? [] : shownKey.split("\n"));
62
+ return () => onShown(rowId, []);
63
+ }, [onShown, rowId, shownKey]);
55
64
  if (props.items.length === 0)
56
65
  return null;
57
66
  const onToggle = props.onToggleFastPath;
@@ -117,6 +117,7 @@ export interface CodeSlice {
117
117
  suggestions: readonly string[];
118
118
  goldSuggestion: string | null;
119
119
  onSuggestion(text: string): unknown;
120
+ readonly onSuggestionsShown?: (rowId: string, labels: readonly string[]) => void;
120
121
  readonly actionSuggestions?: readonly string[];
121
122
  suggestionFastPaths: readonly SuggestionFastPath[] | null;
122
123
  onToggleFastPath: ((text: string) => void) | null;
@@ -314,6 +315,7 @@ export interface ShareSlice {
314
315
  export interface BuildAskSlice {
315
316
  readonly question: string;
316
317
  onAnswered(text: string): void;
318
+ beforeAnswer?(): () => void;
317
319
  onDismiss(): void;
318
320
  onShown?(): void;
319
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/base",
3
- "version": "14.3.454",
3
+ "version": "14.3.455",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -10,10 +10,10 @@
10
10
  "dependencies": {
11
11
  "@adviser/cement": "~0.5.37",
12
12
  "@emotion/css": "~11.13.5",
13
- "@vibes.diy/api-types": "14.3.454",
14
- "@vibes.diy/use-vibes-types": "14.3.454",
15
- "@vibes.diy/vibe-runtime": "14.3.454",
16
- "@vibes.diy/vibe-types": "14.3.454",
13
+ "@vibes.diy/api-types": "14.3.455",
14
+ "@vibes.diy/use-vibes-types": "14.3.455",
15
+ "@vibes.diy/vibe-runtime": "14.3.455",
16
+ "@vibes.diy/vibe-types": "14.3.455",
17
17
  "arktype": "~2.2.10",
18
18
  "officeparser": "~8.9.0",
19
19
  "qrcode-generator": "~2.0.4",