|
1 | | -import type { ConfirmOptions } from '@clack/prompts'; |
2 | | -import { confirm } from '@clack/prompts'; |
3 | | - |
4 | | -namespace JSX { |
5 | | - export interface IntrinsicElements { |
6 | | - } |
7 | | - |
8 | | - export type Element = Promise<unknown>; |
9 | | -} |
| 1 | +import { Confirm, type ConfirmProps } from './components/confirm.js'; |
| 2 | +import { Note, type NoteProps } from './components/note.js'; |
| 3 | +import { Option, type OptionProps } from './components/option.js'; |
| 4 | +import { Password, type PasswordProps } from './components/password.js'; |
| 5 | +import { Select, type SelectProps } from './components/select.js'; |
| 6 | +import { Text, type TextProps } from './components/text.js'; |
| 7 | +import type { JSX } from './types.js'; |
10 | 8 |
|
11 | 9 | export type { JSX }; |
| 10 | +export { |
| 11 | + Confirm, |
| 12 | + type ConfirmProps, |
| 13 | + Note, |
| 14 | + type NoteProps, |
| 15 | + Text, |
| 16 | + type TextProps, |
| 17 | + Password, |
| 18 | + type PasswordProps, |
| 19 | + Option, |
| 20 | + type OptionProps, |
| 21 | + Select, |
| 22 | + type SelectProps, |
| 23 | +}; |
12 | 24 |
|
13 | | -export function Confirm(props: ConfirmOptions): ReturnType<typeof confirm> { |
14 | | - return confirm(props); |
| 25 | +export function Fragment(props: { children: JSX.Element | JSX.Element[] }): JSX.Element { |
| 26 | + return Promise.resolve(props.children); |
15 | 27 | } |
16 | 28 |
|
17 | 29 | export type Component = |
18 | | - | typeof Confirm; |
| 30 | + | typeof Confirm |
| 31 | + | typeof Note |
| 32 | + | typeof Text |
| 33 | + | typeof Password |
| 34 | + | typeof Option |
| 35 | + | typeof Select; |
19 | 36 |
|
20 | 37 | function jsx<T extends keyof JSX.IntrinsicElements>( |
21 | 38 | tag: T, |
22 | 39 | props: JSX.IntrinsicElements[T], |
23 | 40 | _key?: string |
24 | 41 | ): JSX.Element; |
25 | | -function jsx<T extends Component>( |
26 | | - fn: T, |
27 | | - props: Parameters<T>[0], |
28 | | - _key?: string |
29 | | -): JSX.Element; |
30 | | -function jsx( |
31 | | - tagOrFn: string | Component, |
32 | | - props: unknown, |
33 | | - _key?: string |
34 | | -): JSX.Element { |
| 42 | +function jsx<T extends Component>(fn: T, props: Parameters<T>[0], _key?: string): JSX.Element; |
| 43 | +function jsx(tagOrFn: string | Component, props: unknown, _key?: string): JSX.Element { |
35 | 44 | if (typeof tagOrFn === 'function') { |
36 | 45 | return (tagOrFn as (props: unknown) => JSX.Element)(props); |
37 | 46 | } |
|
0 commit comments