@tooee/choose 0.2.4 → 0.3.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.
Files changed (94) hide show
  1. package/README.md +2 -2
  2. package/dist/{ChooseFilter.d.ts → choose-filter.d.ts} +2 -2
  3. package/dist/choose-filter.d.ts.map +1 -0
  4. package/dist/choose-filter.js +11 -0
  5. package/dist/choose-filter.js.map +1 -0
  6. package/dist/choose-highlighted-text.d.ts +9 -0
  7. package/dist/choose-highlighted-text.d.ts.map +1 -0
  8. package/dist/{ChooseHighlightedText.js → choose-highlighted-text.js} +10 -8
  9. package/dist/choose-highlighted-text.js.map +1 -0
  10. package/dist/{ChooseList.d.ts → choose-list.d.ts} +3 -3
  11. package/dist/choose-list.d.ts.map +1 -0
  12. package/dist/{ChooseList.js → choose-list.js} +20 -15
  13. package/dist/choose-list.js.map +1 -0
  14. package/dist/{ChooseOverlay.d.ts → choose-overlay.d.ts} +6 -6
  15. package/dist/choose-overlay.d.ts.map +1 -0
  16. package/dist/{ChooseOverlay.js → choose-overlay.js} +15 -13
  17. package/dist/choose-overlay.js.map +1 -0
  18. package/dist/{ChoosePanel.d.ts → choose-panel.d.ts} +5 -5
  19. package/dist/choose-panel.d.ts.map +1 -0
  20. package/dist/choose-panel.js +31 -0
  21. package/dist/choose-panel.js.map +1 -0
  22. package/dist/choose.d.ts +28 -0
  23. package/dist/choose.d.ts.map +1 -0
  24. package/dist/{Choose.js → choose.js} +25 -18
  25. package/dist/choose.js.map +1 -0
  26. package/dist/default-provider.d.ts +2 -2
  27. package/dist/default-provider.d.ts.map +1 -1
  28. package/dist/default-provider.js +4 -4
  29. package/dist/default-provider.js.map +1 -1
  30. package/dist/fuzzy.d.ts +1 -1
  31. package/dist/fuzzy.d.ts.map +1 -1
  32. package/dist/fuzzy.js +5 -5
  33. package/dist/fuzzy.js.map +1 -1
  34. package/dist/index.d.ts +12 -12
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +6 -6
  37. package/dist/index.js.map +1 -1
  38. package/dist/launch.d.ts +1 -1
  39. package/dist/launch.d.ts.map +1 -1
  40. package/dist/launch.js +5 -4
  41. package/dist/launch.js.map +1 -1
  42. package/dist/source.d.ts +2 -2
  43. package/dist/source.d.ts.map +1 -1
  44. package/dist/source.js +8 -6
  45. package/dist/source.js.map +1 -1
  46. package/dist/types.d.ts +1 -1
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/use-choose-dialog.d.ts +12 -10
  49. package/dist/use-choose-dialog.d.ts.map +1 -1
  50. package/dist/use-choose-dialog.js +98 -77
  51. package/dist/use-choose-dialog.js.map +1 -1
  52. package/dist/use-choose-dialog.typecheck.d.ts +1 -1
  53. package/dist/use-choose-dialog.typecheck.d.ts.map +1 -1
  54. package/dist/use-choose-dialog.typecheck.js +5 -5
  55. package/dist/use-choose-dialog.typecheck.js.map +1 -1
  56. package/dist/use-choose.d.ts +16 -16
  57. package/dist/use-choose.d.ts.map +1 -1
  58. package/dist/use-choose.js +176 -138
  59. package/dist/use-choose.js.map +1 -1
  60. package/package.json +7 -7
  61. package/src/{ChooseFilter.tsx → choose-filter.tsx} +18 -16
  62. package/src/choose-highlighted-text.tsx +49 -0
  63. package/src/{ChooseList.tsx → choose-list.tsx} +73 -60
  64. package/src/choose-overlay.tsx +96 -0
  65. package/src/{ChoosePanel.tsx → choose-panel.tsx} +41 -34
  66. package/src/choose.tsx +142 -0
  67. package/src/default-provider.ts +18 -15
  68. package/src/fuzzy.ts +16 -16
  69. package/src/index.ts +23 -23
  70. package/src/launch.tsx +15 -12
  71. package/src/source.ts +15 -9
  72. package/src/types.ts +12 -12
  73. package/src/use-choose-dialog.tsx +168 -139
  74. package/src/use-choose-dialog.typecheck.ts +19 -18
  75. package/src/use-choose.ts +349 -302
  76. package/dist/Choose.d.ts +0 -21
  77. package/dist/Choose.d.ts.map +0 -1
  78. package/dist/Choose.js.map +0 -1
  79. package/dist/ChooseFilter.d.ts.map +0 -1
  80. package/dist/ChooseFilter.js +0 -9
  81. package/dist/ChooseFilter.js.map +0 -1
  82. package/dist/ChooseHighlightedText.d.ts +0 -9
  83. package/dist/ChooseHighlightedText.d.ts.map +0 -1
  84. package/dist/ChooseHighlightedText.js.map +0 -1
  85. package/dist/ChooseList.d.ts.map +0 -1
  86. package/dist/ChooseList.js.map +0 -1
  87. package/dist/ChooseOverlay.d.ts.map +0 -1
  88. package/dist/ChooseOverlay.js.map +0 -1
  89. package/dist/ChoosePanel.d.ts.map +0 -1
  90. package/dist/ChoosePanel.js +0 -25
  91. package/dist/ChoosePanel.js.map +0 -1
  92. package/src/Choose.tsx +0 -126
  93. package/src/ChooseHighlightedText.tsx +0 -42
  94. package/src/ChooseOverlay.tsx +0 -88
package/README.md CHANGED
@@ -20,13 +20,13 @@ Use `controllerRef` on an assembly, or the controller returned by `useChoose`, t
20
20
  overlay stack and resolves the typed selection:
21
21
 
22
22
  ```tsx
23
- const choose = useChooseDialog<Model>()
23
+ const choose = useChooseDialog<Model>();
24
24
 
25
25
  const model = await choose.open({
26
26
  items: models, // readonly T[] or a sync/async loader
27
27
  toItem: (m) => ({ text: m.label }), // optional when T is a ChooseItem
28
28
  prompt: "Pick a model",
29
- })
29
+ });
30
30
  // T on select, T[] with { multi: true }, null on cancel/replacement/unmount
31
31
  ```
32
32
 
@@ -8,5 +8,5 @@ export interface ChooseFilterProps {
8
8
  onClose?: () => void;
9
9
  }
10
10
  /** Controlled filter row shared by fullscreen and overlay chooser assemblies. */
11
- export declare function ChooseFilter({ choose, prompt, placeholder, right, onClose, }: ChooseFilterProps): ReactNode;
12
- //# sourceMappingURL=ChooseFilter.d.ts.map
11
+ export declare const ChooseFilter: ({ choose, prompt, placeholder, right, onClose, }: ChooseFilterProps) => ReactNode;
12
+ //# sourceMappingURL=choose-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-filter.d.ts","sourceRoot":"","sources":["../src/choose-filter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,iFAAiF;AACjF,eAAO,MAAM,YAAY,GAAyB,kDAM/C,iBAAiB,KAAG,SA2BtB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
+ import { CloseButton, useTheme } from "@tooee/themes";
3
+ /** Controlled filter row shared by fullscreen and overlay chooser assemblies. */
4
+ export const ChooseFilter = function ChooseFilter({ choose, prompt = "> ", placeholder = "Filter...", right, onClose, }) {
5
+ const { theme } = useTheme();
6
+ const { state, view } = choose;
7
+ const handleFilterInput = view.onFilterInput;
8
+ const handleFilterKeyDown = view.onFilterKeyDown;
9
+ return (_jsxs("box", { flexDirection: "row", height: 1, style: { paddingLeft: 1, paddingRight: 1 }, children: [typeof prompt === "string" ? _jsx("text", { content: prompt, fg: theme.accent }) : prompt, _jsx("input", { ref: view.filterRef, focused: view.filterFocused, value: state.filterQuery, placeholder: placeholder, onInput: handleFilterInput, onKeyDown: handleFilterKeyDown, backgroundColor: "transparent", textColor: theme.text, placeholderColor: theme.textMuted, cursorColor: theme.primary, style: { flexGrow: 1 } }), _jsx("text", { content: ` ${state.matches.length}/${state.items.length}`, fg: theme.textMuted }), right, onClose && _jsx(CloseButton, { onClose: onClose })] }));
10
+ };
11
+ //# sourceMappingURL=choose-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-filter.js","sourceRoot":"","sources":["../src/choose-filter.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAA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AAK,EACL,OAAO,IAAI,KAAC,WAAW,IAAC,OAAO,EAAE,OAAO,GAAI,IACzC,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ export interface ChooseHighlightedTextProps {
3
+ text: string;
4
+ positions: number[];
5
+ highlightColor: string;
6
+ }
7
+ /** Render fuzzy-match characters with one shared segmentation implementation. */
8
+ export declare const ChooseHighlightedText: ({ text, positions, highlightColor, }: ChooseHighlightedTextProps) => ReactNode;
9
+ //# sourceMappingURL=choose-highlighted-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-highlighted-text.d.ts","sourceRoot":"","sources":["../src/choose-highlighted-text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,GAAkC,sCAIjE,0BAA0B,KAAG,SAkC/B,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import { jsx as _jsx } from "@opentui/react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
3
  /** Render fuzzy-match characters with one shared segmentation implementation. */
4
- export function ChooseHighlightedText({ text, positions, highlightColor, }) {
5
- if (positions.length === 0)
4
+ export const ChooseHighlightedText = function ChooseHighlightedText({ text, positions, highlightColor, }) {
5
+ if (positions.length === 0) {
6
6
  return text;
7
+ }
7
8
  const positionSet = new Set(positions);
8
9
  const parts = [];
9
10
  let current = "";
10
11
  let currentHighlighted = false;
11
- for (let index = 0; index < text.length; index++) {
12
+ for (let index = 0; index < text.length; index += 1) {
12
13
  const highlighted = positionSet.has(index);
13
14
  if (index === 0) {
14
15
  current = text[index];
@@ -18,13 +19,14 @@ export function ChooseHighlightedText({ text, positions, highlightColor, }) {
18
19
  current += text[index];
19
20
  }
20
21
  else {
21
- parts.push({ text: current, highlighted: currentHighlighted });
22
+ parts.push({ highlighted: currentHighlighted, text: current });
22
23
  current = text[index];
23
24
  currentHighlighted = highlighted;
24
25
  }
25
26
  }
26
- if (current)
27
- parts.push({ text: current, highlighted: currentHighlighted });
27
+ if (current) {
28
+ parts.push({ highlighted: currentHighlighted, text: current });
29
+ }
28
30
  return parts.map((part, index) => (_jsx(Fragment, { children: part.highlighted ? _jsx("span", { fg: highlightColor, children: part.text }) : part.text }, index)));
29
- }
30
- //# sourceMappingURL=ChooseHighlightedText.js.map
31
+ };
32
+ //# sourceMappingURL=choose-highlighted-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-highlighted-text.js","sourceRoot":"","sources":["../src/choose-highlighted-text.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AASjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,qBAAqB,CAAC,EAClE,IAAI,EACJ,SAAS,EACT,cAAc,GACa;IAC3B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IACvC,MAAM,KAAK,GAA6C,EAAE,CAAC;IAC3D,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,kBAAkB,GAAG,WAAW,CAAC;QACnC,CAAC;aAAM,IAAI,WAAW,KAAK,kBAAkB,EAAE,CAAC;YAC9C,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC/D,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,kBAAkB,GAAG,WAAW,CAAC;QACnC,CAAC;IACH,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,KAAK,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CACd,CAAC,IAAI,EAAE,KAAK,EAAa,EAAE,CAAC,CAC1B,KAAC,QAAQ,cACN,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,eAAM,EAAE,EAAE,cAAc,YAAG,IAAI,CAAC,IAAI,GAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAD/D,KAAK,CAET,CACZ,CACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from "react";
1
+ import type { ReactNode } from "react";
2
2
  import type { FuzzyMatch } from "./fuzzy.js";
3
3
  import type { ChooseItem } from "./types.js";
4
4
  import type { UseChooseResult } from "./use-choose.js";
@@ -24,5 +24,5 @@ export interface ChooseListProps {
24
24
  suspended?: boolean;
25
25
  }
26
26
  /** Scrollable chooser rows plus loading/error/empty presentation. */
27
- export declare function ChooseList({ choose, rowClick, renderItem, loadingContent, errorContent, emptyContent, suspended, }: ChooseListProps): ReactNode;
28
- //# sourceMappingURL=ChooseList.d.ts.map
27
+ export declare const ChooseList: ({ choose, rowClick, renderItem, loadingContent, errorContent, emptyContent, suspended, }: ChooseListProps) => ReactNode;
28
+ //# sourceMappingURL=choose-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-list.d.ts","sourceRoot":"","sources":["../src/choose-list.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC1C,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,SAAS,CAAC;IAC7D,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAC5C,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoBD,qEAAqE;AACrE,eAAO,MAAM,UAAU,GAAuB,0FAQ3C,eAAe,KAAG,SA0FpB,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
2
  import { useEffect, useRef } from "react";
3
3
  import { useTheme } from "@tooee/themes";
4
- import { ChooseHighlightedText } from "./ChooseHighlightedText.js";
5
- function ThemedLine({ content, color }) {
4
+ import { ChooseHighlightedText } from "./choose-highlighted-text.js";
5
+ const ThemedLine = function ThemedLine({ content, color, }) {
6
6
  return (_jsx("box", { height: 1, style: { paddingLeft: 2 }, children: typeof content === "string" ? _jsx("text", { content: content, fg: color }) : content }));
7
- }
8
- function defaultErrorContent(error) {
7
+ };
8
+ const defaultErrorContent = function defaultErrorContent(error) {
9
9
  return `Error: ${error}`;
10
- }
10
+ };
11
11
  /** Scrollable chooser rows plus loading/error/empty presentation. */
12
- export function ChooseList({ choose, rowClick = "activate", renderItem, loadingContent = "Loading...", errorContent = defaultErrorContent, emptyContent, suspended, }) {
12
+ export const ChooseList = function ChooseList({ choose, rowClick = "activate", renderItem, loadingContent = "Loading...", errorContent = defaultErrorContent, emptyContent, suspended, }) {
13
13
  const { theme } = useTheme();
14
14
  const scrollRef = useRef(null);
15
15
  const { state, controller } = choose;
@@ -19,23 +19,28 @@ export function ChooseList({ choose, rowClick = "activate", renderItem, loadingC
19
19
  scrollRef.current.scrollTop = Math.max(0, state.activeIndex - 5);
20
20
  }
21
21
  }, [state.activeIndex, state.matches.length]);
22
- return (_jsxs("scrollbox", { ref: scrollRef, flexDirection: "column", style: { flexGrow: 1 }, focused: false, children: [state.loading && _jsx(ThemedLine, { content: loadingContent, color: theme.textMuted }), !state.loading && state.error && (_jsx(ThemedLine, { content: errorContent(state.error), color: theme.error })), !state.loading && !state.error && state.matches.length === 0 && emptyContent != null && (_jsx(ThemedLine, { content: emptyContent, color: theme.textMuted })), state.matches.map((match, index) => {
22
+ return (_jsxs("scrollbox", { ref: scrollRef, flexDirection: "column", style: { flexGrow: 1 }, focused: false, children: [state.loading && _jsx(ThemedLine, { content: loadingContent, color: theme.textMuted }), !state.loading && state.error !== null && state.error !== "" && (_jsx(ThemedLine, { content: errorContent(state.error), color: theme.error })), !state.loading &&
23
+ (state.error?.length ?? 0) === 0 &&
24
+ state.matches.length === 0 &&
25
+ emptyContent !== null &&
26
+ emptyContent !== undefined && _jsx(ThemedLine, { content: emptyContent, color: theme.textMuted }), state.matches.map((match, index) => {
23
27
  const isActive = index === state.activeIndex;
24
28
  const isSelected = state.selectedOriginalIndices.has(match.originalIndex);
25
- const defaultContent = (_jsxs(_Fragment, { children: [state.multi && (_jsx("text", { content: isSelected ? "✓ " : " ", fg: isSelected ? theme.accent : theme.textMuted })), match.item.icon && _jsx("text", { content: `${match.item.icon} `, fg: theme.textMuted }), _jsx("text", { fg: isActive ? theme.primary : theme.text, children: _jsx(ChooseHighlightedText, { text: match.item.text, positions: match.positions, highlightColor: theme.warning }) }), match.item.description && (_jsx("text", { content: ` ${match.item.description}`, fg: theme.textMuted }))] }));
29
+ const defaultContent = (_jsxs(_Fragment, { children: [state.multi && (_jsx("text", { content: isSelected ? "✓ " : " ", fg: isSelected ? theme.accent : theme.textMuted })), (match.item.icon?.length ?? 0) > 0 && (_jsx("text", { content: `${match.item.icon} `, fg: theme.textMuted })), _jsx("text", { fg: isActive ? theme.primary : theme.text, children: _jsx(ChooseHighlightedText, { text: match.item.text, positions: match.positions, highlightColor: theme.warning }) }), (match.item.description?.length ?? 0) > 0 && (_jsx("text", { content: ` ${match.item.description}`, fg: theme.textMuted }))] }));
26
30
  const context = {
31
+ defaultContent,
32
+ index,
33
+ isActive,
34
+ isSelected,
27
35
  item: match.item,
28
36
  match,
29
- index,
30
37
  originalIndex: match.originalIndex,
31
38
  positions: match.positions,
32
- isActive,
33
- isSelected,
34
- defaultContent,
35
39
  };
36
40
  return (_jsx("box", { flexDirection: "row", height: 1, backgroundColor: isActive ? theme.backgroundElement : undefined, style: { paddingLeft: 1 }, onMouseDown: (event) => {
37
- if (interactionSuspended || event.button !== 0 || rowClick === "none")
41
+ if (interactionSuspended || event.button !== 0 || rowClick === "none") {
38
42
  return;
43
+ }
39
44
  if (rowClick === "submit") {
40
45
  event.preventDefault();
41
46
  event.stopPropagation();
@@ -47,5 +52,5 @@ export function ChooseList({ choose, rowClick = "activate", renderItem, loadingC
47
52
  }
48
53
  }, children: renderItem ? renderItem(context) : defaultContent }, match.originalIndex));
49
54
  })] }));
50
- }
51
- //# sourceMappingURL=ChooseList.js.map
55
+ };
56
+ //# sourceMappingURL=choose-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-list.js","sourceRoot":"","sources":["../src/choose-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AA4BrE,MAAM,UAAU,GAAG,SAAS,UAAU,CAAC,EACrC,OAAO,EACP,KAAK,GAIN;IACC,OAAO,CACL,cAAK,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,YACtC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAM,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,GAAI,CAAC,CAAC,CAAC,OAAO,GAC1E,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,SAAS,mBAAmB,CAAC,KAAa;IACpE,OAAO,UAAU,KAAK,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,UAAU,CAAC,EAC5C,MAAM,EACN,QAAQ,GAAG,UAAU,EACrB,UAAU,EACV,cAAc,GAAG,YAAY,EAC7B,YAAY,GAAG,mBAAmB,EAClC,YAAY,EACZ,SAAS,GACO;IAChB,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACpD,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC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AAI,EAAE,KAAK,CAAC,IAAI;oBAChB,KAAK;oBACL,aAAa,EAAE,KAAK,CAAC,aAAa;oBAClC,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B,CAAC;gBAEF,OAAO,CACL,cAEE,aAAa,EAAC,KAAK,EACnB,MAAM,EAAE,CAAC,EACT,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EAC/D,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,EACzB,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;wBACrB,IAAI,oBAAoB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;4BACtE,OAAO;wBACT,CAAC;wBACD,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;4BAC1B,KAAK,CAAC,cAAc,EAAE,CAAC;4BACvB,KAAK,CAAC,eAAe,EAAE,CAAC;4BACxB,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;4BACjC,UAAU,CAAC,MAAM,EAAE,CAAC;wBACtB,CAAC;6BAAM,CAAC;4BACN,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;wBACnC,CAAC;oBACH,CAAC,YAEA,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,IAnB7C,KAAK,CAAC,aAAa,CAoBpB,CACP,CAAC;YACJ,CAAC,CAAC,IACQ,CACb,CAAC;AACJ,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
- import { type ReactNode, type Ref } from "react";
1
+ import type { ReactNode, Ref } from "react";
2
2
  import type { ActionDefinition } from "@tooee/commands";
3
- import { type ChooseListProps } from "./ChooseList.js";
4
- import { type ChoosePanelProps } from "./ChoosePanel.js";
3
+ import type { ChooseListProps } from "./choose-list.js";
4
+ import type { ChoosePanelProps } from "./choose-panel.js";
5
5
  import type { ChooseItem, ChooseResult, ChooseSource } from "./types.js";
6
- import { type ChooseController } from "./use-choose.js";
6
+ import type { ChooseController } from "./use-choose.js";
7
7
  interface ChooseOverlayBaseProps {
8
8
  items: ChooseSource;
9
9
  prompt?: string;
@@ -35,6 +35,6 @@ export type ChooseOverlayProps = ChooseOverlayBaseProps & ({
35
35
  * Composed picker surface. Hosts should mount it on an owned modal command
36
36
  * surface (as Tooee's overlay manager does) so nested surfaces suspend it.
37
37
  */
38
- export declare function ChooseOverlay(props: ChooseOverlayProps): ReactNode;
38
+ export declare const ChooseOverlay: (props: ChooseOverlayProps) => ReactNode;
39
39
  export {};
40
- //# sourceMappingURL=ChooseOverlay.d.ts.map
40
+ //# sourceMappingURL=choose-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-overlay.d.ts","sourceRoot":"","sources":["../src/choose-overlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,UAAU,sBAAsB;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,sFAAsF;IACtF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GACrD,CACI;IACE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CACJ,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,aAAa,GAA0B,OAAO,kBAAkB,KAAG,SA8C/E,CAAC"}
@@ -1,31 +1,33 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
2
  import { useImperativeHandle } from "react";
3
- import { ChooseFilter } from "./ChooseFilter.js";
4
- import { ChooseList } from "./ChooseList.js";
5
- import { ChoosePanel } from "./ChoosePanel.js";
3
+ import { ChooseFilter } from "./choose-filter.js";
4
+ import { ChooseList } from "./choose-list.js";
5
+ import { ChoosePanel } from "./choose-panel.js";
6
6
  import { useChoose } from "./use-choose.js";
7
7
  /**
8
8
  * Composed picker surface. Hosts should mount it on an owned modal command
9
9
  * surface (as Tooee's overlay manager does) so nested surfaces suspend it.
10
10
  */
11
- export function ChooseOverlay(props) {
11
+ export const ChooseOverlay = function ChooseOverlay(props) {
12
12
  const multi = props.multi === true;
13
13
  const choose = useChoose({
14
- source: props.items,
14
+ commandScope: "choose-overlay",
15
+ commands: props.commands,
15
16
  multi,
17
+ onCancel: props.onCancel,
16
18
  onSubmit: (result) => {
17
- if (multi)
19
+ if (multi) {
18
20
  return props.onSubmit(result);
19
- const item = result.items[0];
20
- if (item)
21
+ }
22
+ const [item] = result.items;
23
+ if (item !== undefined) {
21
24
  return props.onSelect(item);
25
+ }
22
26
  },
23
- onCancel: props.onCancel,
24
- commands: props.commands,
25
- commandScope: "choose-overlay",
27
+ source: props.items,
26
28
  suspended: props.suspended,
27
29
  });
28
30
  useImperativeHandle(props.controllerRef, () => choose.controller, [choose.controller]);
29
31
  return (_jsxs(_Fragment, { children: [_jsx(ChoosePanel, { title: props.prompt, filter: _jsx(ChooseFilter, { choose: choose, placeholder: props.placeholder, onClose: props.onCancel }), multi: multi, hints: props.hints, statusRight: props.statusRight, footer: props.footer, inset: props.inset, children: _jsx(ChooseList, { choose: choose, rowClick: "submit", renderItem: props.renderItem, emptyContent: props.emptyMessage, suspended: props.suspended }) }), props.children] }));
30
- }
31
- //# sourceMappingURL=ChooseOverlay.js.map
32
+ };
33
+ //# sourceMappingURL=choose-overlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-overlay.js","sourceRoot":"","sources":["../src/choose-overlay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoC5C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAA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EACjB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,SAAS,EAAE,KAAK,CAAC,SAAS,GAC1B,GACU,EACb,KAAK,CAAC,QAAQ,IACd,CACJ,CAAC;AACJ,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import type { ReactNode } from "react";
2
- import { type Mode } from "@tooee/commands";
3
- export declare function buildChooseHints(mode: Mode, options?: {
2
+ import type { Mode } from "@tooee/commands";
3
+ export declare const buildChooseHints: (mode: Mode, options?: {
4
4
  multi?: boolean;
5
5
  extra?: string[];
6
- }): string[];
6
+ }) => string[];
7
7
  export type ChoosePanelInsetValue = number | "auto" | `${number}%`;
8
8
  export interface ChoosePanelInset {
9
9
  left?: ChoosePanelInsetValue;
@@ -26,5 +26,5 @@ export interface ChoosePanelProps {
26
26
  inset?: ChoosePanelInset;
27
27
  }
28
28
  /** Bordered chooser chrome with filter, content, hint/status, and footer slots. */
29
- export declare function ChoosePanel({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, }: ChoosePanelProps): ReactNode;
30
- //# sourceMappingURL=ChoosePanel.d.ts.map
29
+ export declare const ChoosePanel: ({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, }: ChoosePanelProps) => ReactNode;
30
+ //# sourceMappingURL=choose-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-panel.d.ts","sourceRoot":"","sources":["../src/choose-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,gBAAgB,GAC3B,MAAM,IAAI,EACV,UAAS;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,KAClD,MAAM,EAiBR,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,GAAG,CAAC,EAAE,qBAAqB,CAAC;IAC5B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,SAAS,CAAC;IACnE,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,mFAAmF;AACnF,eAAO,MAAM,WAAW,GAAwB,iFAU7C,gBAAgB,KAAG,SAsErB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
+ import { useMode } from "@tooee/commands";
3
+ import { CloseButton, useTheme } from "@tooee/themes";
4
+ export const buildChooseHints = function buildChooseHints(mode, options = {}) {
5
+ const base = mode === "insert"
6
+ ? [
7
+ "↑↓ navigate",
8
+ "Enter confirm",
9
+ ...(options.multi === true ? ["Tab toggle"] : []),
10
+ "Esc commands",
11
+ ]
12
+ : [
13
+ "j/k navigate",
14
+ "i insert",
15
+ ...(options.multi === true ? ["Tab toggle"] : []),
16
+ "Esc/q cancel",
17
+ "Enter confirm",
18
+ ];
19
+ return options.extra ? [...base, ...options.extra] : base;
20
+ };
21
+ /** Bordered chooser chrome with filter, content, hint/status, and footer slots. */
22
+ export const ChoosePanel = function ChoosePanel({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, }) {
23
+ const { theme } = useTheme();
24
+ const mode = useMode();
25
+ const defaults = buildChooseHints(mode, { multi });
26
+ const hintContent = hints ? hints({ defaults, mode }) : defaults.join(" ");
27
+ return (_jsxs("box", { position: "absolute", left: inset?.left ?? "20%", right: inset?.right ?? "20%", top: inset?.top ?? "20%", bottom: inset?.bottom ?? "20%", flexDirection: "column", backgroundColor: theme.backgroundPanel, border: true, borderColor: theme.borderActive, children: [title !== null && title !== undefined && (_jsxs("box", { flexDirection: "row", height: 1, paddingLeft: 1, paddingRight: 1, backgroundColor: theme.backgroundElement, children: [typeof title === "string" ? (_jsx("text", { content: title, fg: theme.accent, style: { flexGrow: 1 } })) : (_jsx("box", { flexDirection: "row", style: { flexGrow: 1 }, children: title })), onClose && _jsx(CloseButton, { onClose: onClose })] })), filter, children, footer !== null && footer !== undefined && (_jsx("box", { height: 1, paddingLeft: 1, paddingRight: 1, children: footer })), _jsxs("box", { flexDirection: "row", height: 1, paddingLeft: 1, paddingRight: 1, backgroundColor: theme.backgroundElement, children: [_jsx("box", { flexDirection: "row", style: { flexGrow: 1 }, children: typeof hintContent === "string" ? (_jsx("text", { content: hintContent, fg: theme.textMuted })) : (hintContent) }), statusRight !== null &&
28
+ statusRight !== undefined &&
29
+ (typeof statusRight === "string" ? (_jsx("text", { content: statusRight, fg: theme.textMuted })) : (statusRight))] })] }));
30
+ };
31
+ //# sourceMappingURL=choose-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose-panel.js","sourceRoot":"","sources":["../src/choose-panel.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,gBAAgB,CACvD,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AW,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,GAAI,CACpD,CAAC,CAAC,CAAC,CACF,WAAW,CACZ,GACG,EACL,WAAW,KAAK,IAAI;wBACnB,WAAW,KAAK,SAAS;wBACzB,CAAC,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,CACjC,eAAM,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,GAAI,CACpD,CAAC,CAAC,CAAC,CACF,WAAW,CACZ,CAAC,IACA,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Ref } from "react";
2
+ import type { ActionDefinition } from "@tooee/commands";
3
+ import type { ChooseListProps } from "./choose-list.js";
4
+ import type { ChooseContentProvider, ChooseOptions, ChooseResult } from "./types.js";
5
+ import type { ChooseController } from "./use-choose.js";
6
+ export interface ChooseProps {
7
+ contentProvider: ChooseContentProvider;
8
+ options?: ChooseOptions;
9
+ /** Legacy name retained for source compatibility. */
10
+ actions?: ActionDefinition[];
11
+ /** Additive alias used by new chooser compositions. */
12
+ commands?: ActionDefinition[];
13
+ controllerRef?: Ref<ChooseController>;
14
+ renderItem?: ChooseListProps["renderItem"];
15
+ /**
16
+ * Called with the selection when the chooser is submitted. This is the
17
+ * component-level equivalent of `useChoose`'s `onSubmit` and is how a host
18
+ * (including `launch()`) receives a `ChooseResult`. A registered command with
19
+ * the id `submit` still takes precedence, because a command can express its
20
+ * own submit behaviour — but commands receive a `CommandContext`, not a
21
+ * result, so they are not a replacement for this callback.
22
+ */
23
+ onConfirm?: (result: ChooseResult) => void;
24
+ /** Called when the chooser is cancelled (quit, or submit with no selection). */
25
+ onCancel?: () => void;
26
+ }
27
+ export declare const Choose: ({ contentProvider, options, actions, commands, controllerRef, renderItem, onConfirm, onCancel, }: ChooseProps) => React.ReactNode;
28
+ //# sourceMappingURL=choose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose.d.ts","sourceRoot":"","sources":["../src/choose.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAMjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAErF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,qBAAqB,CAAC;IACvC,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,qDAAqD;IACrD,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,GAAmB,kGASnC,WAAW,KAAG,KAAK,CAAC,SA8FtB,CAAC"}
@@ -5,11 +5,11 @@ import { useHasOverlay, useHasModalOverlay } from "@tooee/overlays";
5
5
  import { useTheme } from "@tooee/themes";
6
6
  import { useThemeCommands, useQuitCommand } from "@tooee/shell";
7
7
  import { useCommandContext } from "@tooee/commands";
8
- import { ChooseFilter } from "./ChooseFilter.js";
9
- import { ChooseList } from "./ChooseList.js";
10
- import { buildChooseHints } from "./ChoosePanel.js";
8
+ import { ChooseFilter } from "./choose-filter.js";
9
+ import { ChooseList } from "./choose-list.js";
10
+ import { buildChooseHints } from "./choose-panel.js";
11
11
  import { useChoose } from "./use-choose.js";
12
- export function Choose({ contentProvider, options, actions, commands, controllerRef, renderItem, onConfirm, onCancel, }) {
12
+ export const Choose = function Choose({ contentProvider, options, actions, commands, controllerRef, renderItem, onConfirm, onCancel, }) {
13
13
  const { theme } = useTheme();
14
14
  const { invoke } = useCommandContext();
15
15
  const effectiveCommands = commands ?? actions;
@@ -19,35 +19,42 @@ export function Choose({ contentProvider, options, actions, commands, controller
19
19
  const hasOverlay = useHasOverlay();
20
20
  const hasModalOverlay = useHasModalOverlay();
21
21
  const choose = useChoose({
22
- source: contentProvider,
22
+ commands: effectiveCommands,
23
23
  multi,
24
+ onCancel,
24
25
  onSubmit: (result) => {
25
- // Historical standalone behaviour: a command named `submit` wins over
26
- // the deprecated callback, so existing action-driven CLIs are unchanged.
27
- if (effectiveCommands?.some((action) => action.id === "submit")) {
26
+ // Standalone behaviour: a command named `submit` wins over `onConfirm`, so
27
+ // action-driven CLIs keep their own submit semantics.
28
+ if (effectiveCommands?.some((action) => action.id === "submit") === true) {
28
29
  invoke("submit");
29
30
  return;
30
31
  }
31
- if (multi || result.items.length > 0)
32
+ if (multi || result.items.length > 0) {
32
33
  onConfirm?.(result);
33
- else
34
+ }
35
+ else {
34
36
  onCancel?.();
37
+ }
35
38
  },
36
- onCancel,
37
- commands: effectiveCommands,
39
+ source: contentProvider,
38
40
  suspended: hasOverlay,
39
41
  });
40
42
  useImperativeHandle(controllerRef, () => choose.controller, [choose.controller]);
41
43
  if (choose.state.loading) {
42
44
  return (_jsx("box", { children: _jsx("text", { content: "Loading...", fg: theme.textMuted }) }));
43
45
  }
44
- if (choose.state.error) {
46
+ if ((choose.state.error?.length ?? 0) > 0) {
45
47
  return (_jsx("box", { children: _jsx("text", { content: `Error: ${choose.state.error}`, fg: theme.error }) }));
46
48
  }
47
49
  const hints = buildChooseHints(choose.view.mode, { multi });
48
- return (_jsx(AppLayout, { titleBar: (options?.title ?? options?.prompt)
49
- ? { title: (options.title ?? options.prompt) }
50
- : undefined, statusBar: {
50
+ let titleBar;
51
+ if (options?.title !== undefined && options.title !== "") {
52
+ titleBar = { title: options.title };
53
+ }
54
+ else if (options?.prompt !== undefined && options.prompt !== "") {
55
+ titleBar = { title: options.prompt };
56
+ }
57
+ return (_jsx(AppLayout, { titleBar: titleBar, statusBar: {
51
58
  items: [
52
59
  {
53
60
  label: "Matches:",
@@ -65,5 +72,5 @@ export function Choose({ contentProvider, options, actions, commands, controller
65
72
  { label: "", value: hints.join(" ") },
66
73
  ],
67
74
  }, scrollProps: { focused: false }, children: _jsxs("box", { flexDirection: "column", style: { flexGrow: 1 }, children: [_jsx(ChooseFilter, { choose: choose, placeholder: options?.placeholder }), _jsx(ChooseList, { choose: choose, rowClick: "activate", renderItem: renderItem, emptyContent: options?.emptyMessage, suspended: hasModalOverlay })] }) }));
68
- }
69
- //# sourceMappingURL=Choose.js.map
75
+ };
76
+ //# sourceMappingURL=choose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choose.js","sourceRoot":"","sources":["../src/choose.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAyB5C,MAAM,CAAC,MAAM,MAAM,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M,EAAE;iBACrE;gBACD,GAAG,CAAC,KAAK;oBACP,CAAC,CAAC;wBACE;4BACE,KAAK,EAAE,WAAW;4BAClB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC;yBACzD;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;gBACP,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE;gBACrC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACvC;SACF,EACD,WAAW,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,YAE/B,eAAK,aAAa,EAAC,QAAQ,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,aAChD,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAI,EACnE,KAAC,UAAU,IACT,MAAM,EAAE,MAAM,EACd,QAAQ,EAAC,UAAU,EACnB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,OAAO,EAAE,YAAY,EACnC,SAAS,EAAE,eAAe,GAC1B,IACE,GACI,CACb,CAAC;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { ChooseItem, ChooseContentProvider } from "./types.js";
2
- export declare function createStdinChooseProvider(): ChooseContentProvider;
3
- export declare function createStaticProvider(items: ChooseItem[]): ChooseContentProvider;
2
+ export declare const createStdinChooseProvider: () => ChooseContentProvider;
3
+ export declare const createStaticProvider: (items: ChooseItem[]) => ChooseContentProvider;
4
4
  //# sourceMappingURL=default-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEnE,wBAAgB,yBAAyB,IAAI,qBAAqB,CAUjE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,qBAAqB,CAI/E"}
1
+ {"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEpE,eAAO,MAAM,yBAAyB,QACE,qBAUrC,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAC/B,OAAO,UAAU,EAAE,KAClB,qBAIF,CAAC"}
@@ -1,4 +1,4 @@
1
- export function createStdinChooseProvider() {
1
+ export const createStdinChooseProvider = function createStdinChooseProvider() {
2
2
  return {
3
3
  async load() {
4
4
  const text = await new Response(Bun.stdin.stream()).text();
@@ -8,10 +8,10 @@ export function createStdinChooseProvider() {
8
8
  .map((line) => ({ text: line }));
9
9
  },
10
10
  };
11
- }
12
- export function createStaticProvider(items) {
11
+ };
12
+ export const createStaticProvider = function createStaticProvider(items) {
13
13
  return {
14
14
  load: () => items,
15
15
  };
16
- }
16
+ };
17
17
  //# sourceMappingURL=default-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,IAAI,GAAG,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAA+B,CAAC,CAAC,IAAI,EAAE,CAAA;YACvF,OAAO,IAAI;iBACR,KAAK,CAAC,IAAI,CAAC;iBACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;iBACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QACpC,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAmB;IACtD,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK;KAClB,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GACpC,SAAS,yBAAyB;IAChC,OAAO;QACL,KAAK,CAAC,IAAI;YACR,MAAM,IAAI,GAAG,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3D,OAAO,IAAI;iBACR,KAAK,CAAC,IAAI,CAAC;iBACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;iBACjC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,oBAAoB,CAC/D,KAAmB;IAEnB,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK;KAClB,CAAC;AACJ,CAAC,CAAC"}
package/dist/fuzzy.d.ts CHANGED
@@ -5,5 +5,5 @@ export interface FuzzyMatch {
5
5
  score: number;
6
6
  positions: number[];
7
7
  }
8
- export declare function fuzzyFilter(items: ChooseItem[], query: string): FuzzyMatch[];
8
+ export declare const fuzzyFilter: (items: ChooseItem[], query: string) => FuzzyMatch[];
9
9
  //# sourceMappingURL=fuzzy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAiB5E"}
1
+ {"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,GAAwB,OAAO,UAAU,EAAE,EAAE,OAAO,MAAM,KAAG,UAAU,EAiB9F,CAAC"}
package/dist/fuzzy.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { fuzzyMatchPositions } from "@tooee/fuzzy";
2
- export function fuzzyFilter(items, query) {
2
+ export const fuzzyFilter = function fuzzyFilter(items, query) {
3
3
  if (!query) {
4
- return items.map((item, i) => ({ item, originalIndex: i, score: 0, positions: [] }));
4
+ return items.map((item, i) => ({ item, originalIndex: i, positions: [], score: 0 }));
5
5
  }
6
6
  const results = [];
7
- for (let i = 0; i < items.length; i++) {
7
+ for (let i = 0; i < items.length; i += 1) {
8
8
  const item = items[i];
9
9
  const match = fuzzyMatchPositions(query, item.text);
10
10
  if (match) {
11
- results.push({ item, originalIndex: i, score: match.score, positions: match.positions });
11
+ results.push({ item, originalIndex: i, positions: match.positions, score: match.score });
12
12
  }
13
13
  }
14
14
  results.sort((a, b) => b.score - a.score);
15
15
  return results;
16
- }
16
+ };
17
17
  //# sourceMappingURL=fuzzy.js.map
package/dist/fuzzy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fuz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Aa;IAChF,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,OAAO,GAAiB,EAAE,CAAC;IAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export { Choose } from "./Choose.js";
2
- export type { ChooseProps } from "./Choose.js";
3
- export { ChooseOverlay } from "./ChooseOverlay.js";
4
- export type { ChooseOverlayProps } from "./ChooseOverlay.js";
5
- export { ChoosePanel, buildChooseHints } from "./ChoosePanel.js";
6
- export type { ChoosePanelProps, ChoosePanelInset, ChoosePanelInsetValue } from "./ChoosePanel.js";
7
- export { ChooseFilter } from "./ChooseFilter.js";
8
- export type { ChooseFilterProps } from "./ChooseFilter.js";
9
- export { ChooseList } from "./ChooseList.js";
10
- export type { ChooseItemRenderContext, ChooseListProps } from "./ChooseList.js";
11
- export { ChooseHighlightedText } from "./ChooseHighlightedText.js";
12
- export type { ChooseHighlightedTextProps } from "./ChooseHighlightedText.js";
1
+ export { Choose } from "./choose.js";
2
+ export type { ChooseProps } from "./choose.js";
3
+ export { ChooseOverlay } from "./choose-overlay.js";
4
+ export type { ChooseOverlayProps } from "./choose-overlay.js";
5
+ export { ChoosePanel, buildChooseHints } from "./choose-panel.js";
6
+ export type { ChoosePanelProps, ChoosePanelInset, ChoosePanelInsetValue } from "./choose-panel.js";
7
+ export { ChooseFilter } from "./choose-filter.js";
8
+ export type { ChooseFilterProps } from "./choose-filter.js";
9
+ export { ChooseList } from "./choose-list.js";
10
+ export type { ChooseItemRenderContext, ChooseListProps } from "./choose-list.js";
11
+ export { ChooseHighlightedText } from "./choose-highlighted-text.js";
12
+ export type { ChooseHighlightedTextProps } from "./choose-highlighted-text.js";
13
13
  export { useChoose } from "./use-choose.js";
14
14
  export type { ChooseCommandGroup, ChooseController, ChooseState, ChooseViewModel, UseChooseOptions, UseChooseResult, } from "./use-choose.js";
15
15
  export { useChooseDialog } from "./use-choose-dialog.js";