@nick-skriabin/glyph 0.1.69 → 0.1.71

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/index.d.ts CHANGED
@@ -84,6 +84,69 @@ interface AppHandle {
84
84
  exit(code?: number): void;
85
85
  }
86
86
 
87
+ /**
88
+ * DOM-like imperative handles for focusable components.
89
+ * Use these with React refs to programmatically control components.
90
+ *
91
+ * @example
92
+ * ```tsx
93
+ * const inputRef = useRef<InputHandle>(null);
94
+ *
95
+ * // Programmatic focus
96
+ * inputRef.current?.focus();
97
+ *
98
+ * // Read current value
99
+ * console.log(inputRef.current?.value);
100
+ *
101
+ * <Input ref={inputRef} onChange={setValue} />
102
+ * ```
103
+ */
104
+ /** Base handle shared by all focusable elements */
105
+ interface FocusableHandle {
106
+ /** Programmatically focus this element */
107
+ focus(): void;
108
+ /** Programmatically blur (unfocus) this element */
109
+ blur(): void;
110
+ /** Whether this element is currently focused */
111
+ readonly isFocused: boolean;
112
+ }
113
+ /** Handle for Button */
114
+ interface ButtonHandle extends FocusableHandle {
115
+ }
116
+ /** Handle for Input — exposes current value */
117
+ interface InputHandle extends FocusableHandle {
118
+ /** Current text value */
119
+ readonly value: string;
120
+ }
121
+ /** Handle for Select — exposes current selected value */
122
+ interface SelectHandle extends FocusableHandle {
123
+ /** Currently selected value (undefined if nothing selected) */
124
+ readonly value: string | undefined;
125
+ /** Whether the dropdown is currently open */
126
+ readonly isOpen: boolean;
127
+ }
128
+ /** Handle for Checkbox — exposes checked state */
129
+ interface CheckboxHandle extends FocusableHandle {
130
+ /** Whether the checkbox is currently checked */
131
+ readonly checked: boolean;
132
+ }
133
+ /** Handle for Radio — exposes selected value */
134
+ interface RadioHandle<T = string> extends FocusableHandle {
135
+ /** Currently selected value */
136
+ readonly value: T | undefined;
137
+ }
138
+ /** Handle for List — exposes selected index */
139
+ interface ListHandle extends FocusableHandle {
140
+ /** Currently selected index */
141
+ readonly selectedIndex: number;
142
+ }
143
+ /** Handle for Image */
144
+ interface ImageHandle extends FocusableHandle {
145
+ }
146
+ /** Handle for Text (when focusable) */
147
+ interface TextHandle extends FocusableHandle {
148
+ }
149
+
87
150
  declare function render(element: ReactElement, opts?: RenderOptions): AppHandle;
88
151
 
89
152
  type GlyphNodeType = "box" | "text" | "input";
@@ -123,7 +186,7 @@ interface TextProps {
123
186
  focusable?: boolean;
124
187
  focusedStyle?: Style;
125
188
  }
126
- declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<GlyphNode>>;
189
+ declare const Text: React.ForwardRefExoticComponent<TextProps & React.RefAttributes<TextHandle>>;
127
190
 
128
191
  type InputType = "text" | "number";
129
192
  interface InputProps {
@@ -157,7 +220,7 @@ interface InputProps {
157
220
  */
158
221
  type?: InputType;
159
222
  }
160
- declare function Input(props: InputProps): React.JSX.Element;
223
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputHandle>>;
161
224
 
162
225
  interface FocusScopeProps {
163
226
  trap?: boolean;
@@ -206,7 +269,7 @@ interface ButtonProps {
206
269
  children?: ReactNode;
207
270
  disabled?: boolean;
208
271
  }
209
- declare function Button({ onPress, style, focusedStyle, children, disabled, }: ButtonProps): React.JSX.Element;
272
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<ButtonHandle>>;
210
273
 
211
274
  /** Visible range passed to render function in virtualized mode */
212
275
  interface VisibleRange {
@@ -289,7 +352,7 @@ interface ListProps {
289
352
  /** Whether the list is focusable (default: true) */
290
353
  focusable?: boolean;
291
354
  }
292
- declare function List({ count, renderItem, selectedIndex: controlledIndex, onSelectionChange, onSelect, defaultSelectedIndex, disabledIndices, style, focusable, }: ListProps): React.JSX.Element;
355
+ declare const List: React.ForwardRefExoticComponent<ListProps & React.RefAttributes<ListHandle>>;
293
356
 
294
357
  interface MenuItem {
295
358
  label: string;
@@ -395,7 +458,7 @@ interface SelectProps {
395
458
  /** Disabled state */
396
459
  disabled?: boolean;
397
460
  }
398
- declare function Select({ items, value, onChange, placeholder, style, focusedStyle, dropdownStyle, highlightColor, maxVisible, searchable, disabled, }: SelectProps): React.JSX.Element;
461
+ declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<SelectHandle>>;
399
462
 
400
463
  interface CheckboxProps {
401
464
  /** Whether the checkbox is checked */
@@ -415,7 +478,7 @@ interface CheckboxProps {
415
478
  /** Custom character for unchecked state (default: " ") */
416
479
  uncheckedChar?: string;
417
480
  }
418
- declare function Checkbox({ checked, onChange, label, style, focusedStyle, disabled, checkedChar, uncheckedChar, }: CheckboxProps): React.JSX.Element;
481
+ declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<CheckboxHandle>>;
419
482
 
420
483
  interface RadioItem<T = string> {
421
484
  /** Display label */
@@ -451,7 +514,11 @@ interface RadioProps<T = string> {
451
514
  /** Custom character for unselected state (default: "○") */
452
515
  unselectedChar?: string;
453
516
  }
454
- declare function Radio<T = string>({ items, value, onChange, style, itemStyle, focusedItemStyle, selectedItemStyle, disabled, direction, gap, selectedChar, unselectedChar, }: RadioProps<T>): React.JSX.Element;
517
+ /**
518
+ * Radio group component with imperative handle support.
519
+ * Use `ref` to get `{ focus, blur, isFocused, value }`.
520
+ */
521
+ declare const Radio: <T = string>(props: RadioProps<T> & React.RefAttributes<RadioHandle<T>>) => React.JSX.Element;
455
522
 
456
523
  interface AlertOptions {
457
524
  /** Text for the OK button (default: "OK") */
@@ -598,7 +665,7 @@ interface ImageProps {
598
665
  */
599
666
  unloadTrigger?: number;
600
667
  }
601
- declare function Image({ src, width, height, unloadTrigger, style, focusedStyle, placeholderStyle, focusable, disabled, inline, placeholder, onStateChange, onError, autoLoad, autoSize, maxWidth, maxHeight, }: ImageProps): React.JSX.Element;
668
+ declare const Image: React.ForwardRefExoticComponent<ImageProps & React.RefAttributes<ImageHandle>>;
602
669
 
603
670
  declare function useInput(handler: (key: Key) => void, deps?: any[]): void;
604
671
 
@@ -630,6 +697,8 @@ interface UseFocusableResult {
630
697
  isFocused: boolean;
631
698
  /** Programmatically request focus on this element */
632
699
  focus: () => void;
700
+ /** Programmatically blur (unfocus) this element */
701
+ blur: () => void;
633
702
  /** The focus ID (useful for conditional logic) */
634
703
  focusId: string | null;
635
704
  }
@@ -834,4 +903,4 @@ declare function detectTerminalCapabilities(debug?: boolean): TerminalCapabiliti
834
903
  */
835
904
  declare function supportsInlineImages(): boolean;
836
905
 
837
- export { type AlertOptions, type AnsiStyle, type AppHandle, type BorderStyle, Box, type BoxProps, Button, type ButtonProps, Checkbox, type CheckboxProps, type Color, type ConfirmOptions, type DialogContextValue, DialogHost, type DialogHostProps, type DimensionValue, type FocusRegistryValue, FocusScope, type FocusScopeProps, type FocusableElement, type HexColor, Image, type ImageProps, type ImageState, Input, type InputProps, type InputType, JumpNav, type JumpNavProps, type Key, Keybind, type KeybindProps, type LayoutRect, List, type ListItemInfo, type ListProps, type MaskOptions, Menu, type MenuItem, type MenuProps, type NamedColor, Portal, type PortalProps, Progress, type ProgressProps, type RGBColor, Radio, type RadioItem, type RadioProps, type RenderOptions, ScrollView, type ScrollViewProps, Select, type SelectItem, type SelectProps, Spacer, type SpacerProps, Spinner, type SpinnerProps, type Style, type StyledSegment, type TerminalCapabilities, Text, type TextAlign, type TextProps, type Toast, ToastHost, type ToastHostProps, type ToastPosition, type ToastVariant, type UseFocusableOptions, type UseFocusableResult, type VisibleRange, type WrapMode, createMask, detectTerminalCapabilities, masks, parseAnsi, render, stripAnsi, supportsInlineImages, useApp, useDialog, useFocus, useFocusRegistry, useFocusable, useInput, useLayout, useToast };
906
+ export { type AlertOptions, type AnsiStyle, type AppHandle, type BorderStyle, Box, type BoxProps, Button, type ButtonHandle, type ButtonProps, Checkbox, type CheckboxHandle, type CheckboxProps, type Color, type ConfirmOptions, type DialogContextValue, DialogHost, type DialogHostProps, type DimensionValue, type FocusRegistryValue, FocusScope, type FocusScopeProps, type FocusableElement, type FocusableHandle, type HexColor, Image, type ImageHandle, type ImageProps, type ImageState, Input, type InputHandle, type InputProps, type InputType, JumpNav, type JumpNavProps, type Key, Keybind, type KeybindProps, type LayoutRect, List, type ListHandle, type ListItemInfo, type ListProps, type MaskOptions, Menu, type MenuItem, type MenuProps, type NamedColor, Portal, type PortalProps, Progress, type ProgressProps, type RGBColor, Radio, type RadioHandle, type RadioItem, type RadioProps, type RenderOptions, ScrollView, type ScrollViewProps, Select, type SelectHandle, type SelectItem, type SelectProps, Spacer, type SpacerProps, Spinner, type SpinnerProps, type Style, type StyledSegment, type TerminalCapabilities, Text, type TextAlign, type TextHandle, type TextProps, type Toast, ToastHost, type ToastHostProps, type ToastPosition, type ToastVariant, type UseFocusableOptions, type UseFocusableResult, type VisibleRange, type WrapMode, createMask, detectTerminalCapabilities, masks, parseAnsi, render, stripAnsi, supportsInlineImages, useApp, useDialog, useFocus, useFocusRegistry, useFocusable, useInput, useLayout, useToast };