@tooee/choose 0.7.3 → 0.9.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/dist/choose-filter.d.ts +2 -11
- package/dist/choose-filter.d.ts.map +1 -1
- package/dist/choose-filter.js +1 -10
- package/dist/choose-filter.js.map +1 -1
- package/dist/choose-highlighted-text.d.ts +2 -8
- package/dist/choose-highlighted-text.d.ts.map +1 -1
- package/dist/choose-highlighted-text.js +1 -31
- package/dist/choose-highlighted-text.js.map +1 -1
- package/dist/choose-list.d.ts +2 -27
- package/dist/choose-list.d.ts.map +1 -1
- package/dist/choose-list.js +1 -56
- package/dist/choose-list.js.map +1 -1
- package/dist/choose-panel.d.ts +7 -9
- package/dist/choose-panel.d.ts.map +1 -1
- package/dist/choose-panel.js +5 -8
- package/dist/choose-panel.js.map +1 -1
- package/dist/choose-store.d.ts +3 -0
- package/dist/choose-store.d.ts.map +1 -0
- package/dist/choose-store.js +2 -0
- package/dist/choose-store.js.map +1 -0
- package/dist/choose.d.ts +3 -7
- package/dist/choose.d.ts.map +1 -1
- package/dist/choose.js +10 -12
- package/dist/choose.js.map +1 -1
- package/dist/choose.public-contract.typecheck.d.ts +11 -0
- package/dist/choose.public-contract.typecheck.d.ts.map +1 -0
- package/dist/choose.public-contract.typecheck.js +2 -0
- package/dist/choose.public-contract.typecheck.js.map +1 -0
- package/dist/fuzzy.d.ts +2 -8
- package/dist/fuzzy.d.ts.map +1 -1
- package/dist/fuzzy.js +1 -16
- package/dist/fuzzy.js.map +1 -1
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +2 -1
- package/dist/launch.js.map +1 -1
- package/dist/source.d.ts +1 -4
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +1 -13
- package/dist/source.js.map +1 -1
- package/dist/types.d.ts +1 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/use-choose-dialog.d.ts.map +1 -1
- package/dist/use-choose-dialog.js +22 -84
- package/dist/use-choose-dialog.js.map +1 -1
- package/dist/use-choose.d.ts +2 -79
- package/dist/use-choose.d.ts.map +1 -1
- package/dist/use-choose.js +1 -402
- package/dist/use-choose.js.map +1 -1
- package/package.json +8 -7
- package/src/choose-filter.tsx +2 -47
- package/src/choose-highlighted-text.tsx +2 -49
- package/src/choose-list.tsx +2 -148
- package/src/choose-panel.tsx +18 -71
- package/src/choose-store.ts +12 -0
- package/src/choose.public-contract.typecheck.ts +12 -0
- package/src/choose.tsx +20 -24
- package/src/fuzzy.ts +2 -28
- package/src/launch.tsx +8 -2
- package/src/source.ts +1 -18
- package/src/types.ts +7 -28
- package/src/use-choose-dialog.tsx +30 -98
- package/src/use-choose.ts +9 -526
package/dist/choose-filter.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface ChooseFilterProps {
|
|
4
|
-
choose: UseChooseResult;
|
|
5
|
-
prompt?: ReactNode;
|
|
6
|
-
placeholder?: string;
|
|
7
|
-
right?: ReactNode;
|
|
8
|
-
onClose?: () => void;
|
|
9
|
-
}
|
|
10
|
-
/** Controlled filter row shared by fullscreen and overlay chooser assemblies. */
|
|
11
|
-
export declare const ChooseFilter: ({ choose, prompt, placeholder, right, onClose, }: ChooseFilterProps) => ReactNode;
|
|
1
|
+
export { ChooseFilter } from "@tooee/renderers";
|
|
2
|
+
export type { ChooseFilterProps } from "@tooee/renderers";
|
|
12
3
|
//# sourceMappingURL=choose-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-filter.d.ts","sourceRoot":"","sources":["../src/choose-filter.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"choose-filter.d.ts","sourceRoot":"","sources":["../src/choose-filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/choose-filter.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
export { ChooseFilter } from "@tooee/renderers";
|
|
11
2
|
//# sourceMappingURL=choose-filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-filter.js","sourceRoot":"","sources":["../src/choose-filter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choose-filter.js","sourceRoot":"","sources":["../src/choose-filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
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;
|
|
1
|
+
export { ChooseHighlightedText } from "@tooee/renderers";
|
|
2
|
+
export type { ChooseHighlightedTextProps } from "@tooee/renderers";
|
|
9
3
|
//# sourceMappingURL=choose-highlighted-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-highlighted-text.d.ts","sourceRoot":"","sources":["../src/choose-highlighted-text.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choose-highlighted-text.d.ts","sourceRoot":"","sources":["../src/choose-highlighted-text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,YAAY,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Fragment } from "react";
|
|
3
|
-
/** Render fuzzy-match characters with one shared segmentation implementation. */
|
|
4
|
-
export const ChooseHighlightedText = function ChooseHighlightedText({ text, positions, highlightColor, }) {
|
|
5
|
-
if (positions.length === 0) {
|
|
6
|
-
return text;
|
|
7
|
-
}
|
|
8
|
-
const positionSet = new Set(positions);
|
|
9
|
-
const parts = [];
|
|
10
|
-
let current = "";
|
|
11
|
-
let currentHighlighted = false;
|
|
12
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
13
|
-
const highlighted = positionSet.has(index);
|
|
14
|
-
if (index === 0) {
|
|
15
|
-
current = text[index];
|
|
16
|
-
currentHighlighted = highlighted;
|
|
17
|
-
}
|
|
18
|
-
else if (highlighted === currentHighlighted) {
|
|
19
|
-
current += text[index];
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
parts.push({ highlighted: currentHighlighted, text: current });
|
|
23
|
-
current = text[index];
|
|
24
|
-
currentHighlighted = highlighted;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (current) {
|
|
28
|
-
parts.push({ highlighted: currentHighlighted, text: current });
|
|
29
|
-
}
|
|
30
|
-
return parts.map((part, index) => (_jsx(Fragment, { children: part.highlighted ? _jsx("span", { fg: highlightColor, children: part.text }) : part.text }, index)));
|
|
31
|
-
};
|
|
1
|
+
export { ChooseHighlightedText } from "@tooee/renderers";
|
|
32
2
|
//# sourceMappingURL=choose-highlighted-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-highlighted-text.js","sourceRoot":"","sources":["../src/choose-highlighted-text.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choose-highlighted-text.js","sourceRoot":"","sources":["../src/choose-highlighted-text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/choose-list.d.ts
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { ChooseItem } from "./types.js";
|
|
4
|
-
import type { UseChooseResult } from "./use-choose.js";
|
|
5
|
-
export interface ChooseItemRenderContext {
|
|
6
|
-
item: ChooseItem;
|
|
7
|
-
match: FuzzyMatch;
|
|
8
|
-
index: number;
|
|
9
|
-
originalIndex: number;
|
|
10
|
-
positions: number[];
|
|
11
|
-
isActive: boolean;
|
|
12
|
-
isSelected: boolean;
|
|
13
|
-
defaultContent: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
export interface ChooseListProps {
|
|
16
|
-
choose: UseChooseResult;
|
|
17
|
-
/** Fullscreen defaults to activate; picker overlays default to submit. */
|
|
18
|
-
rowClick?: "activate" | "submit" | "none";
|
|
19
|
-
renderItem?: (context: ChooseItemRenderContext) => ReactNode;
|
|
20
|
-
loadingContent?: ReactNode;
|
|
21
|
-
errorContent?: (error: string) => ReactNode;
|
|
22
|
-
emptyContent?: ReactNode;
|
|
23
|
-
/** Mouse guard for visible rows covered by another surface. */
|
|
24
|
-
suspended?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/** Scrollable chooser rows plus loading/error/empty presentation. */
|
|
27
|
-
export declare const ChooseList: ({ choose, rowClick, renderItem, loadingContent, errorContent, emptyContent, suspended, }: ChooseListProps) => ReactNode;
|
|
1
|
+
export { ChooseList } from "@tooee/renderers";
|
|
2
|
+
export type { ChooseItemRenderContext, ChooseListProps } from "@tooee/renderers";
|
|
28
3
|
//# sourceMappingURL=choose-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-list.d.ts","sourceRoot":"","sources":["../src/choose-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choose-list.d.ts","sourceRoot":"","sources":["../src/choose-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/choose-list.js
CHANGED
|
@@ -1,57 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { useTheme } from "@tooee/themes";
|
|
4
|
-
import { ChooseHighlightedText } from "./choose-highlighted-text.js";
|
|
5
|
-
const ThemedLine = function ThemedLine({ content, color, }) {
|
|
6
|
-
return (_jsx("box", { height: 1, style: { paddingLeft: 2 }, children: typeof content === "string" ? _jsx("text", { content: content, fg: color }) : content }));
|
|
7
|
-
};
|
|
8
|
-
const defaultErrorContent = function defaultErrorContent(error) {
|
|
9
|
-
return `Error: ${error}`;
|
|
10
|
-
};
|
|
11
|
-
/** Scrollable chooser rows plus loading/error/empty presentation. */
|
|
12
|
-
export const ChooseList = function ChooseList({ choose, rowClick = "activate", renderItem, loadingContent = "Loading...", errorContent = defaultErrorContent, emptyContent, suspended, }) {
|
|
13
|
-
const { theme } = useTheme();
|
|
14
|
-
const scrollRef = useRef(null);
|
|
15
|
-
const { state, controller } = choose;
|
|
16
|
-
const interactionSuspended = choose.view.suspended || (suspended ?? false);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const activeMatch = state.matches[state.activeIndex];
|
|
19
|
-
if (scrollRef.current && activeMatch !== undefined) {
|
|
20
|
-
scrollRef.current.scrollChildIntoView(`choose-item-${activeMatch.originalIndex}`);
|
|
21
|
-
}
|
|
22
|
-
}, [state.activeIndex, state.matches]);
|
|
23
|
-
return (_jsxs("scrollbox", { ref: scrollRef, 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 &&
|
|
24
|
-
(state.error?.length ?? 0) === 0 &&
|
|
25
|
-
state.matches.length === 0 &&
|
|
26
|
-
emptyContent !== null &&
|
|
27
|
-
emptyContent !== undefined && _jsx(ThemedLine, { content: emptyContent, color: theme.textMuted }), state.matches.map((match, index) => {
|
|
28
|
-
const isActive = index === state.activeIndex;
|
|
29
|
-
const isSelected = state.selectedOriginalIndices.has(match.originalIndex);
|
|
30
|
-
const defaultContent = (_jsxs("text", { fg: isActive ? theme.primary : theme.text, style: { flexGrow: 1 }, children: [state.multi && (_jsx("span", { fg: isSelected ? theme.accent : theme.textMuted, children: isSelected ? "✓ " : " " })), (match.item.icon?.length ?? 0) > 0 && (_jsx("span", { fg: theme.textMuted, children: `${match.item.icon} ` })), _jsx(ChooseHighlightedText, { text: match.item.text, positions: match.positions, highlightColor: theme.warning }), (match.item.description?.length ?? 0) > 0 && (_jsx("span", { fg: theme.textMuted, children: ` ${match.item.description}` }))] }));
|
|
31
|
-
const context = {
|
|
32
|
-
defaultContent,
|
|
33
|
-
index,
|
|
34
|
-
isActive,
|
|
35
|
-
isSelected,
|
|
36
|
-
item: match.item,
|
|
37
|
-
match,
|
|
38
|
-
originalIndex: match.originalIndex,
|
|
39
|
-
positions: match.positions,
|
|
40
|
-
};
|
|
41
|
-
return (_jsx("box", { id: `choose-item-${match.originalIndex}`, flexDirection: "row", backgroundColor: isActive ? theme.backgroundElement : undefined, style: { paddingLeft: 1, paddingRight: 1 }, onMouseDown: (event) => {
|
|
42
|
-
if (interactionSuspended || event.button !== 0 || rowClick === "none") {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (rowClick === "submit") {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
event.stopPropagation();
|
|
48
|
-
controller.setActiveIndex(index);
|
|
49
|
-
controller.submit();
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
controller.setActiveIndex(index);
|
|
53
|
-
}
|
|
54
|
-
}, children: renderItem ? renderItem(context) : defaultContent }, match.originalIndex));
|
|
55
|
-
})] }));
|
|
56
|
-
};
|
|
1
|
+
export { ChooseList } from "@tooee/renderers";
|
|
57
2
|
//# sourceMappingURL=choose-list.js.map
|
package/dist/choose-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-list.js","sourceRoot":"","sources":["../src/choose-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choose-list.js","sourceRoot":"","sources":["../src/choose-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/choose-panel.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { MouseEvent } from "@opentui/core";
|
|
2
3
|
import type { Mode } from "@tooee/commands";
|
|
4
|
+
import type { PanelInset, PanelInsetValue } from "@tooee/layout";
|
|
3
5
|
export declare const buildChooseHints: (mode: Mode, options?: {
|
|
4
6
|
multi?: boolean;
|
|
5
7
|
extra?: string[];
|
|
6
8
|
}) => string[];
|
|
7
|
-
export type ChoosePanelInsetValue =
|
|
8
|
-
export
|
|
9
|
-
left?: ChoosePanelInsetValue;
|
|
10
|
-
right?: ChoosePanelInsetValue;
|
|
11
|
-
top?: ChoosePanelInsetValue;
|
|
12
|
-
bottom?: ChoosePanelInsetValue;
|
|
13
|
-
}
|
|
9
|
+
export type ChoosePanelInsetValue = PanelInsetValue;
|
|
10
|
+
export type ChoosePanelInset = PanelInset;
|
|
14
11
|
export interface ChoosePanelProps {
|
|
15
12
|
title?: ReactNode;
|
|
16
13
|
filter: ReactNode;
|
|
@@ -24,7 +21,8 @@ export interface ChoosePanelProps {
|
|
|
24
21
|
footer?: ReactNode;
|
|
25
22
|
onClose?: () => void;
|
|
26
23
|
inset?: ChoosePanelInset;
|
|
24
|
+
onMouseDown?: (event: MouseEvent) => void;
|
|
27
25
|
}
|
|
28
|
-
/**
|
|
29
|
-
export declare const ChoosePanel: ({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, }: ChoosePanelProps) => ReactNode;
|
|
26
|
+
/** Chooser-specific overlay panel with mode-aware default hints. */
|
|
27
|
+
export declare const ChoosePanel: ({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, onMouseDown, }: ChoosePanelProps) => ReactNode;
|
|
30
28
|
//# sourceMappingURL=choose-panel.d.ts.map
|
|
@@ -1 +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;
|
|
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;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,gBAAgB,SACrB,IAAI,YACD;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,KAC7C,MAAM,EAiBR,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC;AACpD,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE1C,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;IACzB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC3C;AAED,oEAAoE;AACpE,eAAO,MAAM,WAAW,iGAWrB,gBAAgB,KAAG,SAmBrB,CAAC"}
|
package/dist/choose-panel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useMode } from "@tooee/commands";
|
|
3
|
-
import {
|
|
3
|
+
import { OverlayPanel } from "@tooee/layout";
|
|
4
4
|
export const buildChooseHints = function buildChooseHints(mode, options = {}) {
|
|
5
5
|
const base = mode === "insert"
|
|
6
6
|
? [
|
|
@@ -18,14 +18,11 @@ export const buildChooseHints = function buildChooseHints(mode, options = {}) {
|
|
|
18
18
|
];
|
|
19
19
|
return options.extra ? [...base, ...options.extra] : base;
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
export const ChoosePanel = function ChoosePanel({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, }) {
|
|
23
|
-
const { theme } = useTheme();
|
|
21
|
+
/** Chooser-specific overlay panel with mode-aware default hints. */
|
|
22
|
+
export const ChoosePanel = function ChoosePanel({ title, filter, children, multi, hints, statusRight, footer, onClose, inset, onMouseDown, }) {
|
|
24
23
|
const mode = useMode();
|
|
25
24
|
const defaults = buildChooseHints(mode, { multi });
|
|
26
25
|
const hintContent = hints ? hints({ defaults, mode }) : defaults.join(" ");
|
|
27
|
-
return (
|
|
28
|
-
statusRight !== undefined &&
|
|
29
|
-
(typeof statusRight === "string" ? (_jsx("text", { content: statusRight, fg: theme.textMuted })) : (statusRight))] })] }));
|
|
26
|
+
return (_jsx(OverlayPanel, { title: title, prompt: filter, hints: hintContent, statusRight: statusRight, footer: footer, onClose: onClose, inset: inset, onMouseDown: onMouseDown, children: children }));
|
|
30
27
|
};
|
|
31
28
|
//# sourceMappingURL=choose-panel.js.map
|
package/dist/choose-panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose-panel.js","sourceRoot":"","sources":["../src/choose-panel.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"choose-panel.js","sourceRoot":"","sources":["../src/choose-panel.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,gBAAgB,CACvD,IAAU,EACV,OAAO,GAA0C,EAAE;IAEnD,MAAM,IAAI,GACR,IAAI,KAAK,QAAQ;QACf,CAAC,CAAC;YACE,aAAa;YACb,eAAe;YACf,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,cAAc;SACf;QACH,CAAC,CAAC;YACE,cAAc;YACd,UAAU;YACV,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,cAAc;YACd,eAAe;SAChB,CAAC;IACR,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC,CAAC;AAkBF,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,WAAW,CAAC,EAC9C,KAAK,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,GACM;IACjB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE5E,OAAO,CACL,KAAC,YAAY,IACX,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,YAEvB,QAAQ,GACI,CAChB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createChooseStore, selectActiveIndex, selectError, selectFilterQuery, selectItems, selectLoading, selectMatches, selectReloadRevision, selectSelectedOriginalIndices, } from "@tooee/renderers";
|
|
2
|
+
export type { ChooseStore, ChooseStoreContext, ChooseStoreEvents } from "@tooee/renderers";
|
|
3
|
+
//# sourceMappingURL=choose-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose-store.d.ts","sourceRoot":"","sources":["../src/choose-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose-store.js","sourceRoot":"","sources":["../src/choose-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC"}
|
package/dist/choose.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import type { Ref } from "react";
|
|
1
|
+
import type { ReactNode, Ref } from "react";
|
|
2
2
|
import type { ActionDefinition } from "@tooee/commands";
|
|
3
3
|
import type { ChooseListProps } from "./choose-list.js";
|
|
4
4
|
import type { ChooseContentProvider, ChooseOptions, ChooseResult } from "./types.js";
|
|
5
5
|
import type { ChooseController } from "./use-choose.js";
|
|
6
|
-
export interface ChooseProps {
|
|
6
|
+
export interface ChooseProps extends ChooseOptions {
|
|
7
7
|
contentProvider: ChooseContentProvider;
|
|
8
|
-
options?: ChooseOptions;
|
|
9
|
-
/** Legacy name retained for source compatibility. */
|
|
10
8
|
actions?: ActionDefinition[];
|
|
11
|
-
/** Additive alias used by new chooser compositions. */
|
|
12
|
-
commands?: ActionDefinition[];
|
|
13
9
|
controllerRef?: Ref<ChooseController>;
|
|
14
10
|
renderItem?: ChooseListProps["renderItem"];
|
|
15
11
|
/**
|
|
@@ -24,5 +20,5 @@ export interface ChooseProps {
|
|
|
24
20
|
/** Called when the chooser is cancelled (quit, or submit with no selection). */
|
|
25
21
|
onCancel?: () => void;
|
|
26
22
|
}
|
|
27
|
-
export declare const Choose: ({ contentProvider,
|
|
23
|
+
export declare const Choose: ({ contentProvider, actions, controllerRef, emptyMessage, multi, onCancel, onConfirm, placeholder, prompt, renderItem, title, }: ChooseProps) => ReactNode;
|
|
28
24
|
//# sourceMappingURL=choose.d.ts.map
|
package/dist/choose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choose.d.ts","sourceRoot":"","sources":["../src/choose.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"choose.d.ts","sourceRoot":"","sources":["../src/choose.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAM5C,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,WAAY,SAAQ,aAAa;IAChD,eAAe,EAAE,qBAAqB,CAAC;IACvC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,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,mIAYhB,WAAW,KAAG,SA2FhB,CAAC"}
|
package/dist/choose.js
CHANGED
|
@@ -4,28 +4,26 @@ import { AppLayout } from "@tooee/layout";
|
|
|
4
4
|
import { useHasOverlay, useHasModalOverlay } from "@tooee/overlays";
|
|
5
5
|
import { useTheme } from "@tooee/themes";
|
|
6
6
|
import { useThemeCommands, useQuitCommand } from "@tooee/shell";
|
|
7
|
-
import {
|
|
7
|
+
import { useSurfaceInvoke } from "@tooee/commands";
|
|
8
8
|
import { ChooseFilter } from "./choose-filter.js";
|
|
9
9
|
import { ChooseList } from "./choose-list.js";
|
|
10
10
|
import { buildChooseHints } from "./choose-panel.js";
|
|
11
11
|
import { useChoose } from "./use-choose.js";
|
|
12
|
-
export const Choose = function Choose({ contentProvider,
|
|
12
|
+
export const Choose = function Choose({ contentProvider, actions, controllerRef, emptyMessage, multi = false, onCancel, onConfirm, placeholder, prompt, renderItem, title, }) {
|
|
13
13
|
const { theme } = useTheme();
|
|
14
|
-
const { invoke } =
|
|
15
|
-
const effectiveCommands = commands ?? actions;
|
|
16
|
-
const multi = options?.multi ?? false;
|
|
14
|
+
const { invoke } = useSurfaceInvoke();
|
|
17
15
|
const { name: themeName } = useThemeCommands();
|
|
18
16
|
useQuitCommand({ onQuit: () => onCancel?.() });
|
|
19
17
|
const hasOverlay = useHasOverlay();
|
|
20
18
|
const hasModalOverlay = useHasModalOverlay();
|
|
21
19
|
const choose = useChoose({
|
|
22
|
-
commands:
|
|
20
|
+
commands: actions,
|
|
23
21
|
multi,
|
|
24
22
|
onCancel,
|
|
25
23
|
onSubmit: (result) => {
|
|
26
24
|
// Standalone behaviour: a command named `submit` wins over `onConfirm`, so
|
|
27
25
|
// action-driven CLIs keep their own submit semantics.
|
|
28
|
-
if (
|
|
26
|
+
if (actions?.some((action) => action.id === "submit") === true) {
|
|
29
27
|
invoke("submit");
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
@@ -48,11 +46,11 @@ export const Choose = function Choose({ contentProvider, options, actions, comma
|
|
|
48
46
|
}
|
|
49
47
|
const hints = buildChooseHints(choose.view.mode, { multi });
|
|
50
48
|
let titleBar;
|
|
51
|
-
if (
|
|
52
|
-
titleBar = { title
|
|
49
|
+
if (title !== undefined && title !== "") {
|
|
50
|
+
titleBar = { title };
|
|
53
51
|
}
|
|
54
|
-
else if (
|
|
55
|
-
titleBar = { title:
|
|
52
|
+
else if (prompt !== undefined && prompt !== "") {
|
|
53
|
+
titleBar = { title: prompt };
|
|
56
54
|
}
|
|
57
55
|
return (_jsx(AppLayout, { titleBar: titleBar, statusBar: {
|
|
58
56
|
items: [
|
|
@@ -71,6 +69,6 @@ export const Choose = function Choose({ contentProvider, options, actions, comma
|
|
|
71
69
|
{ label: "Theme:", value: themeName },
|
|
72
70
|
{ label: "", value: hints.join(" ") },
|
|
73
71
|
],
|
|
74
|
-
},
|
|
72
|
+
}, children: _jsxs("box", { flexDirection: "column", style: { flexGrow: 1 }, children: [_jsx(ChooseFilter, { choose: choose, placeholder: placeholder }), _jsx(ChooseList, { choose: choose, rowClick: "activate", renderItem: renderItem, emptyContent: emptyMessage, suspended: hasModalOverlay })] }) }));
|
|
75
73
|
};
|
|
76
74
|
//# sourceMappingURL=choose.js.map
|
package/dist/choose.js.map
CHANGED
|
@@ -1 +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,
|
|
1
|
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** Compile-time checks for the Choose component's 0.9 public props. */
|
|
2
|
+
import type { ChooseProps } from "./choose.js";
|
|
3
|
+
type Assert<T extends true> = T;
|
|
4
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
5
|
+
type Has<TKeys, TName> = [Extract<TKeys, TName>] extends [never] ? false : true;
|
|
6
|
+
type Props = keyof ChooseProps;
|
|
7
|
+
type RetainedProps = Assert<Has<Props, "actions" | "multi" | "prompt" | "title">>;
|
|
8
|
+
type RemovedProps = Assert<IsNever<Extract<Props, "commands" | "options">>>;
|
|
9
|
+
export type ChoosePublicContractChecks = [RetainedProps, RemovedProps];
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=choose.public-contract.typecheck.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose.public-contract.typecheck.d.ts","sourceRoot":"","sources":["../src/choose.public-contract.typecheck.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAChC,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AACrD,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;AAEhF,KAAK,KAAK,GAAG,MAAM,WAAW,CAAC;AAC/B,KAAK,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;AAClF,KAAK,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,0BAA0B,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose.public-contract.typecheck.js","sourceRoot":"","sources":["../src/choose.public-contract.typecheck.ts"],"names":[],"mappings":""}
|
package/dist/fuzzy.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
item: ChooseItem;
|
|
4
|
-
originalIndex: number;
|
|
5
|
-
score: number;
|
|
6
|
-
positions: number[];
|
|
7
|
-
}
|
|
8
|
-
export declare const fuzzyFilter: (items: ChooseItem[], query: string) => FuzzyMatch[];
|
|
1
|
+
export { fuzzyFilter } from "@tooee/renderers";
|
|
2
|
+
export type { FuzzyMatch } from "@tooee/renderers";
|
|
9
3
|
//# sourceMappingURL=fuzzy.d.ts.map
|
package/dist/fuzzy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fuzzy.d.ts","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/fuzzy.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export const fuzzyFilter = function fuzzyFilter(items, query) {
|
|
3
|
-
if (!query) {
|
|
4
|
-
return items.map((item, i) => ({ item, originalIndex: i, positions: [], score: 0 }));
|
|
5
|
-
}
|
|
6
|
-
const results = [];
|
|
7
|
-
for (let i = 0; i < items.length; i += 1) {
|
|
8
|
-
const item = items[i];
|
|
9
|
-
const match = fuzzyMatchPositions(query, item.text);
|
|
10
|
-
if (match) {
|
|
11
|
-
results.push({ item, originalIndex: i, positions: match.positions, score: match.score });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
results.sort((a, b) => b.score - a.score);
|
|
15
|
-
return results;
|
|
16
|
-
};
|
|
1
|
+
export { fuzzyFilter } from "@tooee/renderers";
|
|
17
2
|
//# sourceMappingURL=fuzzy.js.map
|
package/dist/fuzzy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuzzy.js","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fuzzy.js","sourceRoot":"","sources":["../src/fuzzy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/launch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrF,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,qBAAqB,CAAC;IACvC,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,MAAM,SACX,mBAAmB,KACxB,OAAO,CAAC,YAAY,GAAG,IAAI,CAsB7B,CAAC"}
|
package/dist/launch.js
CHANGED
|
@@ -2,9 +2,10 @@ import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
|
2
2
|
import { runCliSession } from "@tooee/shell";
|
|
3
3
|
import { Choose } from "./choose.js";
|
|
4
4
|
export const launch = async function launch(opts) {
|
|
5
|
-
const result = await runCliSession(({ resolve, cancel }) => (_jsx(Choose, { contentProvider: opts.contentProvider, options: opts.options, actions: opts.actions, onConfirm: resolve, onCancel: cancel })), {
|
|
5
|
+
const result = await runCliSession(({ resolve, cancel }) => (_jsx(Choose, { contentProvider: opts.contentProvider, title: opts.options?.title, prompt: opts.options?.prompt, placeholder: opts.options?.placeholder, multi: opts.options?.multi, emptyMessage: opts.options?.emptyMessage, actions: opts.actions, onConfirm: resolve, onCancel: cancel })), {
|
|
6
6
|
provider: { initialMode: "insert" },
|
|
7
7
|
stdinPolicy: "tty-if-piped",
|
|
8
|
+
stdoutPolicy: "tty-if-redirected",
|
|
8
9
|
});
|
|
9
10
|
return result;
|
|
10
11
|
};
|
package/dist/launch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../src/launch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../src/launch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,UAAU,MAAM,CACzC,IAAyB;IAEzB,MAAM,MAAM,GAAG,MAAM,aAAa,CAChC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAa,EAAE,CAAC,CAClC,KAAC,MAAM,IACL,eAAe,EAAE,IAAI,CAAC,eAAe,EACrC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAC1B,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAC5B,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EACtC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAC1B,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,EACxC,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,GAChB,CACH,EACD;QACE,QAAQ,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE;QACnC,WAAW,EAAE,cAAc;QAC3B,YAAY,EAAE,mBAAmB;KAClC,CACF,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/source.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/** Resolve every public Choose source shape through one compatibility boundary. */
|
|
3
|
-
export declare const loadChooseSource: (source: ChooseSource) => ChooseItem[] | Promise<ChooseItem[]>;
|
|
4
|
-
export declare const chooseSourceError: (error: unknown) => string;
|
|
1
|
+
export { loadChooseSource } from "@tooee/renderers";
|
|
5
2
|
//# sourceMappingURL=source.d.ts.map
|
package/dist/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/source.js
CHANGED
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export const loadChooseSource = function loadChooseSource(source) {
|
|
3
|
-
if (Array.isArray(source)) {
|
|
4
|
-
return source;
|
|
5
|
-
}
|
|
6
|
-
if (typeof source === "function") {
|
|
7
|
-
return source();
|
|
8
|
-
}
|
|
9
|
-
return source.load();
|
|
10
|
-
};
|
|
11
|
-
export const chooseSourceError = function chooseSourceError(error) {
|
|
12
|
-
return error instanceof Error ? error.message : String(error);
|
|
13
|
-
};
|
|
1
|
+
export { loadChooseSource } from "@tooee/renderers";
|
|
14
2
|
//# sourceMappingURL=source.js.map
|
package/dist/source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
text: string;
|
|
3
|
-
value?: string;
|
|
4
|
-
icon?: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ChooseContentProvider {
|
|
8
|
-
load: () => Promise<ChooseItem[]> | ChooseItem[];
|
|
9
|
-
}
|
|
10
|
-
/** Any item source accepted by the shared chooser core. */
|
|
11
|
-
export type ChooseSource = ChooseItem[] | ChooseContentProvider | (() => ChooseItem[] | Promise<ChooseItem[]>);
|
|
12
|
-
export interface ChooseResult {
|
|
13
|
-
items: ChooseItem[];
|
|
14
|
-
}
|
|
15
|
-
export interface ChooseOptions {
|
|
16
|
-
multi?: boolean;
|
|
17
|
-
title?: string;
|
|
18
|
-
prompt?: string;
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
emptyMessage?: string;
|
|
21
|
-
}
|
|
1
|
+
export type { ChooseContentProvider, ChooseItem, ChooseOptions, ChooseResult, ChooseSource, } from "@tooee/renderers";
|
|
22
2
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC"}
|