@mdxui/terminal 2.0.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/README.md +571 -0
- package/dist/ansi-css-Sk5mWtdK.d.ts +119 -0
- package/dist/ansi-css-V6JIHGsM.d.ts +119 -0
- package/dist/ansi-css-_3eSEU9d.d.ts +119 -0
- package/dist/chunk-3EFDH7PK.js +5235 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-3X5IR6WE.js +884 -0
- package/dist/chunk-4FV5ZDCE.js +5236 -0
- package/dist/chunk-4OVMSF2J.js +243 -0
- package/dist/chunk-63FEETIS.js +4048 -0
- package/dist/chunk-B43KP7XJ.js +884 -0
- package/dist/chunk-BMTJXWUV.js +655 -0
- package/dist/chunk-C3SVH4N7.js +882 -0
- package/dist/chunk-EVWR7Y47.js +874 -0
- package/dist/chunk-F6A5VWUC.js +1285 -0
- package/dist/chunk-FD7KW7GE.js +882 -0
- package/dist/chunk-GBQ6UD6I.js +655 -0
- package/dist/chunk-GMDD3M6U.js +5227 -0
- package/dist/chunk-JBHRXOXM.js +1058 -0
- package/dist/chunk-JFOO3EYO.js +1182 -0
- package/dist/chunk-JQ5H3WXL.js +1291 -0
- package/dist/chunk-JQD5NASE.js +234 -0
- package/dist/chunk-KRHJP5R7.js +592 -0
- package/dist/chunk-KWF6WVJE.js +962 -0
- package/dist/chunk-LHYQVN3H.js +1038 -0
- package/dist/chunk-M3TLQLGC.js +1032 -0
- package/dist/chunk-MVW4Q5OP.js +240 -0
- package/dist/chunk-NXCZSWLU.js +1294 -0
- package/dist/chunk-O25TNRO6.js +607 -0
- package/dist/chunk-PNECDA2I.js +884 -0
- package/dist/chunk-QIHWRLJR.js +962 -0
- package/dist/chunk-QW5YMQ7K.js +882 -0
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/chunk-RP2MVQLR.js +962 -0
- package/dist/chunk-TP6RXGXA.js +1087 -0
- package/dist/chunk-TQQSTITZ.js +655 -0
- package/dist/chunk-X24GWXQV.js +1281 -0
- package/dist/components/index.d.ts +802 -0
- package/dist/components/index.js +149 -0
- package/dist/data/index.d.ts +2554 -0
- package/dist/data/index.js +51 -0
- package/dist/forms/index.d.ts +1596 -0
- package/dist/forms/index.js +464 -0
- package/dist/index-CQRFZntR.d.ts +867 -0
- package/dist/index.d.ts +579 -0
- package/dist/index.js +786 -0
- package/dist/interactive-D0JkWosD.d.ts +217 -0
- package/dist/keyboard/index.d.ts +2 -0
- package/dist/keyboard/index.js +43 -0
- package/dist/renderers/index.d.ts +546 -0
- package/dist/renderers/index.js +2157 -0
- package/dist/storybook/index.d.ts +396 -0
- package/dist/storybook/index.js +641 -0
- package/dist/theme/index.d.ts +1339 -0
- package/dist/theme/index.js +123 -0
- package/dist/types-Bxu5PAgA.d.ts +710 -0
- package/dist/types-CIlop5Ji.d.ts +701 -0
- package/dist/types-Ca8p_p5X.d.ts +710 -0
- package/package.json +90 -0
- package/src/__tests__/components/data/card.test.ts +458 -0
- package/src/__tests__/components/data/list.test.ts +473 -0
- package/src/__tests__/components/data/metrics.test.ts +541 -0
- package/src/__tests__/components/data/table.test.ts +448 -0
- package/src/__tests__/components/input/field.test.ts +555 -0
- package/src/__tests__/components/input/form.test.ts +870 -0
- package/src/__tests__/components/input/search.test.ts +1238 -0
- package/src/__tests__/components/input/select.test.ts +658 -0
- package/src/__tests__/components/navigation/breadcrumb.test.ts +923 -0
- package/src/__tests__/components/navigation/command-palette.test.ts +1095 -0
- package/src/__tests__/components/navigation/sidebar.test.ts +1018 -0
- package/src/__tests__/components/navigation/tabs.test.ts +995 -0
- package/src/__tests__/components.test.tsx +1197 -0
- package/src/__tests__/core/compiler.test.ts +986 -0
- package/src/__tests__/core/parser.test.ts +785 -0
- package/src/__tests__/core/tier-switcher.test.ts +1103 -0
- package/src/__tests__/core/types.test.ts +1398 -0
- package/src/__tests__/data/collections.test.ts +1337 -0
- package/src/__tests__/data/db.test.ts +1265 -0
- package/src/__tests__/data/reactive.test.ts +1010 -0
- package/src/__tests__/data/sync.test.ts +1614 -0
- package/src/__tests__/errors.test.ts +660 -0
- package/src/__tests__/forms/integration.test.ts +444 -0
- package/src/__tests__/integration.test.ts +905 -0
- package/src/__tests__/keyboard.test.ts +1791 -0
- package/src/__tests__/renderer.test.ts +489 -0
- package/src/__tests__/renderers/ansi-css.test.ts +948 -0
- package/src/__tests__/renderers/ansi.test.ts +1366 -0
- package/src/__tests__/renderers/ascii.test.ts +1360 -0
- package/src/__tests__/renderers/interactive.test.ts +2353 -0
- package/src/__tests__/renderers/markdown.test.ts +1483 -0
- package/src/__tests__/renderers/text.test.ts +1369 -0
- package/src/__tests__/renderers/unicode.test.ts +1307 -0
- package/src/__tests__/theme.test.ts +639 -0
- package/src/__tests__/utils/assertions.ts +685 -0
- package/src/__tests__/utils/index.ts +115 -0
- package/src/__tests__/utils/test-renderer.ts +381 -0
- package/src/__tests__/utils/utils.test.ts +560 -0
- package/src/components/containers/card.ts +56 -0
- package/src/components/containers/dialog.ts +53 -0
- package/src/components/containers/index.ts +9 -0
- package/src/components/containers/panel.ts +59 -0
- package/src/components/feedback/badge.ts +40 -0
- package/src/components/feedback/index.ts +8 -0
- package/src/components/feedback/spinner.ts +23 -0
- package/src/components/helpers.ts +81 -0
- package/src/components/index.ts +153 -0
- package/src/components/layout/breadcrumb.ts +31 -0
- package/src/components/layout/index.ts +10 -0
- package/src/components/layout/list.ts +29 -0
- package/src/components/layout/sidebar.ts +79 -0
- package/src/components/layout/table.ts +62 -0
- package/src/components/primitives/box.ts +95 -0
- package/src/components/primitives/button.ts +54 -0
- package/src/components/primitives/index.ts +11 -0
- package/src/components/primitives/input.ts +88 -0
- package/src/components/primitives/select.ts +97 -0
- package/src/components/primitives/text.ts +60 -0
- package/src/components/render.ts +155 -0
- package/src/components/templates/app.ts +43 -0
- package/src/components/templates/index.ts +8 -0
- package/src/components/templates/site.ts +54 -0
- package/src/components/types.ts +777 -0
- package/src/core/compiler.ts +718 -0
- package/src/core/parser.ts +127 -0
- package/src/core/tier-switcher.ts +607 -0
- package/src/core/types.ts +672 -0
- package/src/data/collection.ts +316 -0
- package/src/data/collections.ts +50 -0
- package/src/data/context.tsx +174 -0
- package/src/data/db.ts +127 -0
- package/src/data/hooks.ts +532 -0
- package/src/data/index.ts +138 -0
- package/src/data/reactive.ts +1225 -0
- package/src/data/saas-collections.ts +375 -0
- package/src/data/sync.ts +1213 -0
- package/src/data/types.ts +660 -0
- package/src/forms/converters.ts +512 -0
- package/src/forms/index.ts +133 -0
- package/src/forms/schemas.ts +403 -0
- package/src/forms/types.ts +476 -0
- package/src/index.ts +542 -0
- package/src/keyboard/focus.ts +748 -0
- package/src/keyboard/index.ts +96 -0
- package/src/keyboard/integration.ts +371 -0
- package/src/keyboard/manager.ts +377 -0
- package/src/keyboard/presets.ts +90 -0
- package/src/renderers/ansi-css.ts +576 -0
- package/src/renderers/ansi.ts +802 -0
- package/src/renderers/ascii.ts +680 -0
- package/src/renderers/breadcrumb.ts +480 -0
- package/src/renderers/command-palette.ts +802 -0
- package/src/renderers/components/field.ts +210 -0
- package/src/renderers/components/form.ts +327 -0
- package/src/renderers/components/index.ts +21 -0
- package/src/renderers/components/search.ts +449 -0
- package/src/renderers/components/select.ts +222 -0
- package/src/renderers/index.ts +101 -0
- package/src/renderers/interactive/component-handlers.ts +622 -0
- package/src/renderers/interactive/cursor-manager.ts +147 -0
- package/src/renderers/interactive/focus-manager.ts +279 -0
- package/src/renderers/interactive/index.ts +661 -0
- package/src/renderers/interactive/input-handler.ts +164 -0
- package/src/renderers/interactive/keyboard-handler.ts +212 -0
- package/src/renderers/interactive/mouse-handler.ts +167 -0
- package/src/renderers/interactive/state-manager.ts +109 -0
- package/src/renderers/interactive/types.ts +338 -0
- package/src/renderers/interactive-string.ts +299 -0
- package/src/renderers/interactive.ts +59 -0
- package/src/renderers/markdown.ts +950 -0
- package/src/renderers/sidebar.ts +549 -0
- package/src/renderers/tabs.ts +682 -0
- package/src/renderers/text.ts +791 -0
- package/src/renderers/unicode.ts +917 -0
- package/src/renderers/utils.ts +942 -0
- package/src/router/adapters.ts +383 -0
- package/src/router/types.ts +140 -0
- package/src/router/utils.ts +452 -0
- package/src/schemas.ts +205 -0
- package/src/storybook/index.ts +91 -0
- package/src/storybook/interactive-decorator.tsx +659 -0
- package/src/storybook/keyboard-simulator.ts +501 -0
- package/src/theme/ansi-codes.ts +80 -0
- package/src/theme/box-drawing.ts +132 -0
- package/src/theme/color-convert.ts +254 -0
- package/src/theme/color-support.ts +321 -0
- package/src/theme/index.ts +134 -0
- package/src/theme/strip-ansi.ts +50 -0
- package/src/theme/tailwind-map.ts +469 -0
- package/src/theme/text-styles.ts +206 -0
- package/src/theme/theme-system.ts +568 -0
- package/src/types.ts +103 -0
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mdxui/terminal Form Integration Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript types for React Hook Form integration with terminal renderers.
|
|
5
|
+
* These types provide a bridge between RHF's form state management and the
|
|
6
|
+
* UINode-based rendering system.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { z } from 'zod'
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Core Form Value Types
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Base field value types supported by terminal form components.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* These represent the primitive values that can be stored in form fields.
|
|
22
|
+
* Compatible with RHF's FieldValues constraint.
|
|
23
|
+
*/
|
|
24
|
+
export type FieldValue =
|
|
25
|
+
| string
|
|
26
|
+
| number
|
|
27
|
+
| boolean
|
|
28
|
+
| null
|
|
29
|
+
| undefined
|
|
30
|
+
| string[]
|
|
31
|
+
| FieldValue[]
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Generic form values type compatible with React Hook Form.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* This is the base constraint for all form value types.
|
|
38
|
+
* Equivalent to RHF's FieldValues type.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* interface LoginFormValues extends FormValues {
|
|
43
|
+
* email: string
|
|
44
|
+
* password: string
|
|
45
|
+
* rememberMe: boolean
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export interface FormValues {
|
|
50
|
+
[key: string]: FieldValue | FormValues
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Field Configuration Types
|
|
55
|
+
// ============================================================================
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Configuration for a single form field.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* This interface represents the complete state and configuration of a form field,
|
|
62
|
+
* including validation state, UI state, and metadata. This maps directly to
|
|
63
|
+
* the props expected by the Field renderer.
|
|
64
|
+
*
|
|
65
|
+
* @typeParam T - The value type for this field (defaults to FieldValue)
|
|
66
|
+
*/
|
|
67
|
+
export interface FieldConfig<T extends FieldValue = FieldValue> {
|
|
68
|
+
/** Unique field name (used as form key) */
|
|
69
|
+
name: string
|
|
70
|
+
|
|
71
|
+
/** Display label for the field */
|
|
72
|
+
label?: string
|
|
73
|
+
|
|
74
|
+
/** Field input type */
|
|
75
|
+
type?: 'text' | 'email' | 'password' | 'number' | 'checkbox' | 'textarea' | 'select'
|
|
76
|
+
|
|
77
|
+
/** Current field value */
|
|
78
|
+
value?: T
|
|
79
|
+
|
|
80
|
+
/** Placeholder text when empty */
|
|
81
|
+
placeholder?: string
|
|
82
|
+
|
|
83
|
+
/** Whether the field is required */
|
|
84
|
+
required?: boolean
|
|
85
|
+
|
|
86
|
+
/** Validation error message */
|
|
87
|
+
error?: string
|
|
88
|
+
|
|
89
|
+
/** Whether the field has passed validation */
|
|
90
|
+
valid?: boolean
|
|
91
|
+
|
|
92
|
+
/** Whether the field is disabled */
|
|
93
|
+
disabled?: boolean
|
|
94
|
+
|
|
95
|
+
/** Whether the field is read-only */
|
|
96
|
+
readonly?: boolean
|
|
97
|
+
|
|
98
|
+
/** Helper text displayed below the field */
|
|
99
|
+
helperText?: string
|
|
100
|
+
|
|
101
|
+
/** Whether the field is currently focused */
|
|
102
|
+
focused?: boolean
|
|
103
|
+
|
|
104
|
+
/** Cursor position for text inputs (interactive tier) */
|
|
105
|
+
cursorPosition?: number
|
|
106
|
+
|
|
107
|
+
/** Selection start for text inputs (interactive tier) */
|
|
108
|
+
selectionStart?: number
|
|
109
|
+
|
|
110
|
+
/** Selection end for text inputs (interactive tier) */
|
|
111
|
+
selectionEnd?: number
|
|
112
|
+
|
|
113
|
+
/** Options for select fields */
|
|
114
|
+
options?: Array<{ label: string; value: string; disabled?: boolean }>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Form group configuration for organizing related fields.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* Groups allow organizing fields into logical sections with
|
|
122
|
+
* optional collapse functionality.
|
|
123
|
+
*/
|
|
124
|
+
export interface FieldGroup {
|
|
125
|
+
/** Group title */
|
|
126
|
+
title: string
|
|
127
|
+
|
|
128
|
+
/** Fields in this group */
|
|
129
|
+
fields: FieldConfig[]
|
|
130
|
+
|
|
131
|
+
/** Whether the group can be collapsed */
|
|
132
|
+
collapsible?: boolean
|
|
133
|
+
|
|
134
|
+
/** Whether the group is currently collapsed */
|
|
135
|
+
collapsed?: boolean
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Form State Types
|
|
140
|
+
// ============================================================================
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Complete form state configuration.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* This represents the full state of a form, including all fields,
|
|
147
|
+
* groups, validation state, and submission state. This maps directly
|
|
148
|
+
* to the props expected by the Form renderer.
|
|
149
|
+
*
|
|
150
|
+
* @typeParam T - The form values type
|
|
151
|
+
*/
|
|
152
|
+
export interface FormState<T extends FormValues = FormValues> {
|
|
153
|
+
/** Form title */
|
|
154
|
+
title?: string
|
|
155
|
+
|
|
156
|
+
/** Form description */
|
|
157
|
+
description?: string
|
|
158
|
+
|
|
159
|
+
/** Standalone fields (not in groups) */
|
|
160
|
+
fields?: FieldConfig[]
|
|
161
|
+
|
|
162
|
+
/** Grouped fields */
|
|
163
|
+
groups?: FieldGroup[]
|
|
164
|
+
|
|
165
|
+
/** Form-level error message */
|
|
166
|
+
error?: string
|
|
167
|
+
|
|
168
|
+
/** Form-level success message */
|
|
169
|
+
success?: string
|
|
170
|
+
|
|
171
|
+
/** Whether the form is currently loading/submitting */
|
|
172
|
+
loading?: boolean
|
|
173
|
+
|
|
174
|
+
/** Submit button label */
|
|
175
|
+
submitLabel?: string
|
|
176
|
+
|
|
177
|
+
/** Cancel button label */
|
|
178
|
+
cancelLabel?: string
|
|
179
|
+
|
|
180
|
+
/** Whether the submit button is disabled */
|
|
181
|
+
submitDisabled?: boolean
|
|
182
|
+
|
|
183
|
+
/** Submit button hotkey (interactive tier) */
|
|
184
|
+
submitHotkey?: string
|
|
185
|
+
|
|
186
|
+
/** Whether to show a border around the form */
|
|
187
|
+
border?: boolean
|
|
188
|
+
|
|
189
|
+
/** The current form values (for RHF integration) */
|
|
190
|
+
values?: T
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ============================================================================
|
|
194
|
+
// React Hook Form Integration Types
|
|
195
|
+
// ============================================================================
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* RHF register function signature.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* This is a simplified version of RHF's UseFormRegister type,
|
|
202
|
+
* designed to work with the terminal renderer system.
|
|
203
|
+
*/
|
|
204
|
+
export type RegisterFn = (name: string, options?: {
|
|
205
|
+
required?: boolean | string
|
|
206
|
+
min?: number | { value: number; message: string }
|
|
207
|
+
max?: number | { value: number; message: string }
|
|
208
|
+
minLength?: number | { value: number; message: string }
|
|
209
|
+
maxLength?: number | { value: number; message: string }
|
|
210
|
+
pattern?: RegExp | { value: RegExp; message: string }
|
|
211
|
+
validate?: (value: FieldValue) => boolean | string | Promise<boolean | string>
|
|
212
|
+
}) => {
|
|
213
|
+
name: string
|
|
214
|
+
onChange: (event: { target: { value: FieldValue } }) => void
|
|
215
|
+
onBlur: () => void
|
|
216
|
+
ref: (element: unknown) => void
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* RHF form state subset relevant to terminal rendering.
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
* This represents the subset of RHF's FormState that is relevant
|
|
224
|
+
* for rendering form UI in the terminal.
|
|
225
|
+
*/
|
|
226
|
+
export interface RHFFormState {
|
|
227
|
+
/** Whether the form is currently submitting */
|
|
228
|
+
isSubmitting: boolean
|
|
229
|
+
|
|
230
|
+
/** Whether the form has been submitted at least once */
|
|
231
|
+
isSubmitted: boolean
|
|
232
|
+
|
|
233
|
+
/** Whether the form is valid */
|
|
234
|
+
isValid: boolean
|
|
235
|
+
|
|
236
|
+
/** Whether any field has been modified */
|
|
237
|
+
isDirty: boolean
|
|
238
|
+
|
|
239
|
+
/** Field-level errors */
|
|
240
|
+
errors: Record<string, { message?: string; type?: string }>
|
|
241
|
+
|
|
242
|
+
/** Fields that have been touched (focused and blurred) */
|
|
243
|
+
touchedFields: Record<string, boolean>
|
|
244
|
+
|
|
245
|
+
/** Fields that have been modified */
|
|
246
|
+
dirtyFields: Record<string, boolean>
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Configuration for connecting RHF to terminal form renderer.
|
|
251
|
+
*
|
|
252
|
+
* @remarks
|
|
253
|
+
* This interface provides the bridge between RHF's hooks and
|
|
254
|
+
* the terminal form rendering system.
|
|
255
|
+
*
|
|
256
|
+
* @typeParam T - The form values type
|
|
257
|
+
*/
|
|
258
|
+
export interface RHFFormConfig<T extends FormValues = FormValues> {
|
|
259
|
+
/** RHF register function */
|
|
260
|
+
register: RegisterFn
|
|
261
|
+
|
|
262
|
+
/** RHF form state */
|
|
263
|
+
formState: RHFFormState
|
|
264
|
+
|
|
265
|
+
/** RHF getValues function */
|
|
266
|
+
getValues: () => T
|
|
267
|
+
|
|
268
|
+
/** RHF setValue function */
|
|
269
|
+
setValue: (name: keyof T, value: FieldValue) => void
|
|
270
|
+
|
|
271
|
+
/** RHF trigger function (validate field) */
|
|
272
|
+
trigger: (name?: keyof T | (keyof T)[]) => Promise<boolean>
|
|
273
|
+
|
|
274
|
+
/** RHF handleSubmit function */
|
|
275
|
+
handleSubmit: (onSubmit: (data: T) => void | Promise<void>) => (e?: Event) => Promise<void>
|
|
276
|
+
|
|
277
|
+
/** RHF reset function */
|
|
278
|
+
reset: (values?: Partial<T>) => void
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// ============================================================================
|
|
282
|
+
// Select/Search Component Types
|
|
283
|
+
// ============================================================================
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Select field option configuration.
|
|
287
|
+
*/
|
|
288
|
+
export interface SelectOption<T = string> {
|
|
289
|
+
/** Display label */
|
|
290
|
+
label: string
|
|
291
|
+
|
|
292
|
+
/** Value when selected */
|
|
293
|
+
value: T
|
|
294
|
+
|
|
295
|
+
/** Whether the option is disabled */
|
|
296
|
+
disabled?: boolean
|
|
297
|
+
|
|
298
|
+
/** Optional description */
|
|
299
|
+
description?: string
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Select field state configuration.
|
|
304
|
+
*
|
|
305
|
+
* @remarks
|
|
306
|
+
* This maps to the props expected by the Select renderer.
|
|
307
|
+
*/
|
|
308
|
+
export interface SelectState<T = string> {
|
|
309
|
+
/** Available options */
|
|
310
|
+
options: SelectOption<T>[]
|
|
311
|
+
|
|
312
|
+
/** Currently selected value(s) */
|
|
313
|
+
value?: T | T[]
|
|
314
|
+
|
|
315
|
+
/** Field label */
|
|
316
|
+
label?: string
|
|
317
|
+
|
|
318
|
+
/** Placeholder text */
|
|
319
|
+
placeholder?: string
|
|
320
|
+
|
|
321
|
+
/** Whether the field is required */
|
|
322
|
+
required?: boolean
|
|
323
|
+
|
|
324
|
+
/** Validation error message */
|
|
325
|
+
error?: string
|
|
326
|
+
|
|
327
|
+
/** Whether the field has passed validation */
|
|
328
|
+
valid?: boolean
|
|
329
|
+
|
|
330
|
+
/** Whether the field is disabled */
|
|
331
|
+
disabled?: boolean
|
|
332
|
+
|
|
333
|
+
/** Whether the dropdown is open */
|
|
334
|
+
open?: boolean
|
|
335
|
+
|
|
336
|
+
/** Whether multiple selection is allowed */
|
|
337
|
+
multiple?: boolean
|
|
338
|
+
|
|
339
|
+
/** Currently highlighted option index */
|
|
340
|
+
highlightedIndex?: number
|
|
341
|
+
|
|
342
|
+
/** Whether the select is searchable */
|
|
343
|
+
searchable?: boolean
|
|
344
|
+
|
|
345
|
+
/** Current search query */
|
|
346
|
+
searchValue?: string
|
|
347
|
+
|
|
348
|
+
/** Filtered options (when searchable) */
|
|
349
|
+
filteredOptions?: SelectOption<T>[]
|
|
350
|
+
|
|
351
|
+
/** Whether options are loading */
|
|
352
|
+
loading?: boolean
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Search field suggestion configuration.
|
|
357
|
+
*/
|
|
358
|
+
export interface SearchSuggestion {
|
|
359
|
+
/** Display label */
|
|
360
|
+
label: string
|
|
361
|
+
|
|
362
|
+
/** Value when selected */
|
|
363
|
+
value: string
|
|
364
|
+
|
|
365
|
+
/** Optional description */
|
|
366
|
+
description?: string
|
|
367
|
+
|
|
368
|
+
/** Optional icon identifier */
|
|
369
|
+
icon?: string
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Search field state configuration.
|
|
374
|
+
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* This maps to the props expected by the Search renderer.
|
|
377
|
+
*/
|
|
378
|
+
export interface SearchState {
|
|
379
|
+
/** Current search query */
|
|
380
|
+
value: string
|
|
381
|
+
|
|
382
|
+
/** Placeholder text */
|
|
383
|
+
placeholder?: string
|
|
384
|
+
|
|
385
|
+
/** Field label */
|
|
386
|
+
label?: string
|
|
387
|
+
|
|
388
|
+
/** Whether the field is disabled */
|
|
389
|
+
disabled?: boolean
|
|
390
|
+
|
|
391
|
+
/** Whether results are loading */
|
|
392
|
+
loading?: boolean
|
|
393
|
+
|
|
394
|
+
/** Validation error message */
|
|
395
|
+
error?: string
|
|
396
|
+
|
|
397
|
+
/** Whether the field is focused */
|
|
398
|
+
focused?: boolean
|
|
399
|
+
|
|
400
|
+
/** Cursor position (interactive tier) */
|
|
401
|
+
cursorPosition?: number
|
|
402
|
+
|
|
403
|
+
/** Available suggestions */
|
|
404
|
+
suggestions?: SearchSuggestion[] | null
|
|
405
|
+
|
|
406
|
+
/** Whether to show suggestions dropdown */
|
|
407
|
+
showSuggestions?: boolean
|
|
408
|
+
|
|
409
|
+
/** Currently highlighted suggestion index */
|
|
410
|
+
highlightedIndex?: number
|
|
411
|
+
|
|
412
|
+
/** Maximum suggestions to show */
|
|
413
|
+
maxSuggestions?: number
|
|
414
|
+
|
|
415
|
+
/** Whether to highlight matching text */
|
|
416
|
+
highlightMatches?: boolean
|
|
417
|
+
|
|
418
|
+
/** Whether user is currently typing (debounce indicator) */
|
|
419
|
+
isTyping?: boolean
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// ============================================================================
|
|
423
|
+
// Utility Types
|
|
424
|
+
// ============================================================================
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Extracts the inferred type from a Zod schema.
|
|
428
|
+
*
|
|
429
|
+
* @remarks
|
|
430
|
+
* Use this to derive TypeScript types from your Zod validation schemas.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```tsx
|
|
434
|
+
* const loginSchema = z.object({
|
|
435
|
+
* email: z.string().email(),
|
|
436
|
+
* password: z.string().min(8),
|
|
437
|
+
* })
|
|
438
|
+
*
|
|
439
|
+
* type LoginForm = InferFormValues<typeof loginSchema>
|
|
440
|
+
* // { email: string; password: string }
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
export type InferFormValues<T extends z.ZodType> = z.infer<T>
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Converts RHF form state to terminal FormState format.
|
|
447
|
+
*
|
|
448
|
+
* @remarks
|
|
449
|
+
* This type represents a function that transforms RHF's internal
|
|
450
|
+
* state representation to the format expected by terminal renderers.
|
|
451
|
+
*/
|
|
452
|
+
export type FormStateConverter<T extends FormValues = FormValues> = (
|
|
453
|
+
rhfConfig: RHFFormConfig<T>,
|
|
454
|
+
fieldConfigs: FieldConfig[]
|
|
455
|
+
) => FormState<T>
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Field registration options for RHF integration.
|
|
459
|
+
*/
|
|
460
|
+
export interface FieldRegistration {
|
|
461
|
+
/** Field name */
|
|
462
|
+
name: string
|
|
463
|
+
|
|
464
|
+
/** Validation rules */
|
|
465
|
+
rules?: {
|
|
466
|
+
required?: boolean | string
|
|
467
|
+
min?: number | { value: number; message: string }
|
|
468
|
+
max?: number | { value: number; message: string }
|
|
469
|
+
minLength?: number | { value: number; message: string }
|
|
470
|
+
maxLength?: number | { value: number; message: string }
|
|
471
|
+
pattern?: RegExp | { value: RegExp; message: string }
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** Default value */
|
|
475
|
+
defaultValue?: FieldValue
|
|
476
|
+
}
|