performa 1.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.
@@ -0,0 +1,438 @@
1
+ import { c as FormContextValue, d as FormState, R as ResolvedFormConfig, F as FormErrors, e as ResolvedFormField, f as FileMetaData, b as FormField } from './server-Cjhy29dZ.js';
2
+ export { h as FieldOption, g as FieldType, a as FormConfig, G as GridWidth, M as MimeTypeKey, V as ValidationRules, m as mimeTypes } from './server-Cjhy29dZ.js';
3
+ import * as react from 'react';
4
+ import { ReactNode, FormHTMLAttributes } from 'react';
5
+ import * as react_jsx_runtime from 'react/jsx-runtime';
6
+
7
+ /**
8
+ * Form context for sharing form state and configuration with child components
9
+ */
10
+ declare const FormContext: react.Context<FormContextValue | null>;
11
+ /**
12
+ * Hook to access form context
13
+ * @throws Error if used outside of a Form component
14
+ */
15
+ declare function useFormContext(): FormContextValue;
16
+ /**
17
+ * Hook to get the current form state
18
+ */
19
+ declare function useFormState(): FormState;
20
+ /**
21
+ * Hook to get the form configuration
22
+ */
23
+ declare function useFormConfig(): ResolvedFormConfig;
24
+ /**
25
+ * Hook to get errors for a specific field
26
+ */
27
+ declare function useFieldError(fieldName: string): string | undefined;
28
+
29
+ /**
30
+ * Utility functions for the form library
31
+ */
32
+ /**
33
+ * Convert bytes to human-readable format
34
+ */
35
+ declare function bytesToHumanReadable(bytes: number): string;
36
+ /**
37
+ * Check if a filename represents an image based on extension
38
+ */
39
+ declare function isImage(filename: string): boolean;
40
+ /**
41
+ * Grid width classes for responsive layouts
42
+ */
43
+ declare const widthClasses: {
44
+ readonly 1: "col-span-12 @lg:col-span-1";
45
+ readonly 2: "col-span-4 @lg:col-span-2";
46
+ readonly 3: "col-span-6 @lg:col-span-3";
47
+ readonly 4: "col-span-8 @lg:col-span-4";
48
+ readonly 5: "col-span-12 @lg:col-span-5";
49
+ readonly 6: "col-span-12 @lg:col-span-6";
50
+ readonly 7: "col-span-12 @lg:col-span-7";
51
+ readonly 8: "col-span-12 @lg:col-span-8";
52
+ readonly 9: "col-span-12 @lg:col-span-9";
53
+ readonly 10: "col-span-12 @lg:col-span-10";
54
+ readonly 11: "col-span-12 @lg:col-span-11";
55
+ readonly 12: "col-span-12";
56
+ };
57
+
58
+ /**
59
+ * Theme configuration for form components
60
+ */
61
+ type FormTheme = {
62
+ /**
63
+ * Whether to include dark mode styles
64
+ * @default true
65
+ */
66
+ darkMode?: boolean;
67
+ /**
68
+ * Base classes applied to all form groups
69
+ */
70
+ formGroup?: string;
71
+ /**
72
+ * Classes for the form container
73
+ */
74
+ form?: string;
75
+ /**
76
+ * Classes for the fieldset/grid container
77
+ */
78
+ fieldset?: string;
79
+ /**
80
+ * Label styling
81
+ */
82
+ label?: {
83
+ base?: string;
84
+ required?: string;
85
+ };
86
+ /**
87
+ * Input styling
88
+ */
89
+ input?: {
90
+ base?: string;
91
+ error?: string;
92
+ disabled?: string;
93
+ focus?: string;
94
+ };
95
+ /**
96
+ * Select styling
97
+ */
98
+ select?: {
99
+ base?: string;
100
+ error?: string;
101
+ disabled?: string;
102
+ option?: string;
103
+ };
104
+ /**
105
+ * Textarea styling
106
+ */
107
+ textarea?: {
108
+ base?: string;
109
+ error?: string;
110
+ disabled?: string;
111
+ };
112
+ /**
113
+ * Checkbox styling
114
+ */
115
+ checkbox?: {
116
+ base?: string;
117
+ error?: string;
118
+ label?: string;
119
+ };
120
+ /**
121
+ * Toggle/switch styling
122
+ */
123
+ toggle?: {
124
+ track?: string;
125
+ trackActive?: string;
126
+ thumb?: string;
127
+ label?: string;
128
+ };
129
+ /**
130
+ * Radio button styling
131
+ */
132
+ radio?: {
133
+ base?: string;
134
+ label?: string;
135
+ group?: string;
136
+ };
137
+ /**
138
+ * File input styling
139
+ */
140
+ file?: {
141
+ dropzone?: string;
142
+ dropzoneActive?: string;
143
+ dropzoneError?: string;
144
+ icon?: string;
145
+ text?: string;
146
+ hint?: string;
147
+ };
148
+ /**
149
+ * Submit button styling
150
+ */
151
+ submit?: {
152
+ base?: string;
153
+ loading?: string;
154
+ spinner?: string;
155
+ };
156
+ /**
157
+ * Error message styling
158
+ */
159
+ error?: string;
160
+ /**
161
+ * Alert styling
162
+ */
163
+ alert?: {
164
+ base?: string;
165
+ error?: string;
166
+ success?: string;
167
+ warning?: string;
168
+ info?: string;
169
+ };
170
+ /**
171
+ * DateTime picker styling
172
+ */
173
+ datetime?: {
174
+ input?: string;
175
+ dropdown?: string;
176
+ picker?: string;
177
+ calendar?: string;
178
+ day?: string;
179
+ daySelected?: string;
180
+ dayButton?: string;
181
+ dayButtonSelected?: string;
182
+ timeInput?: string;
183
+ timeLabel?: string;
184
+ periodButton?: string;
185
+ periodButtonActive?: string;
186
+ iconButton?: string;
187
+ navButton?: string;
188
+ monthYear?: string;
189
+ weekday?: string;
190
+ formatButton?: string;
191
+ };
192
+ /**
193
+ * Button styling
194
+ */
195
+ button?: {
196
+ primary?: string;
197
+ secondary?: string;
198
+ };
199
+ /**
200
+ * Readonly display styling
201
+ */
202
+ readonly?: string;
203
+ /**
204
+ * None/display field styling
205
+ */
206
+ none?: {
207
+ container?: string;
208
+ label?: string;
209
+ value?: string;
210
+ };
211
+ };
212
+ /**
213
+ * Labels/text customization
214
+ */
215
+ type FormLabels = {
216
+ required?: string;
217
+ loading?: string;
218
+ fileUpload?: {
219
+ clickToUpload?: string;
220
+ dragAndDrop?: string;
221
+ allowedTypes?: string;
222
+ maxSize?: string;
223
+ };
224
+ datetime?: {
225
+ clear?: string;
226
+ done?: string;
227
+ timeFormat?: string;
228
+ weekdays?: string[];
229
+ };
230
+ select?: {
231
+ loading?: string;
232
+ noOptions?: string;
233
+ };
234
+ };
235
+ /**
236
+ * Complete form configuration
237
+ */
238
+ type FormThemeConfig = {
239
+ theme?: FormTheme;
240
+ labels?: FormLabels;
241
+ };
242
+ /**
243
+ * Default theme with Tailwind classes
244
+ */
245
+ declare const defaultTheme: FormTheme;
246
+ /**
247
+ * Theme without dark mode classes
248
+ */
249
+ declare const lightOnlyTheme: FormTheme;
250
+ /**
251
+ * Default labels
252
+ */
253
+ declare const defaultLabels: FormLabels;
254
+ /**
255
+ * Theme context type
256
+ */
257
+ type ThemeContextType = {
258
+ theme: FormTheme;
259
+ labels: FormLabels;
260
+ };
261
+ /**
262
+ * Hook to access the current theme
263
+ */
264
+ declare function useFormTheme(): FormTheme;
265
+ /**
266
+ * Hook to access the current labels
267
+ */
268
+ declare function useFormLabels(): FormLabels;
269
+ /**
270
+ * Hook to access both theme and labels
271
+ */
272
+ declare function useFormThemeConfig(): ThemeContextType;
273
+ type FormThemeProviderProps = {
274
+ children: ReactNode;
275
+ /**
276
+ * Custom theme configuration (will be merged with default)
277
+ */
278
+ theme?: Partial<FormTheme>;
279
+ /**
280
+ * Custom labels (will be merged with default)
281
+ */
282
+ labels?: Partial<FormLabels>;
283
+ /**
284
+ * Use light-only theme as base (no dark mode classes)
285
+ */
286
+ lightOnly?: boolean;
287
+ };
288
+ /**
289
+ * Theme provider component
290
+ * Wrap your app or form container with this to customize styling
291
+ *
292
+ * @example
293
+ * ```tsx
294
+ * <FormThemeProvider
295
+ * theme={{
296
+ * input: { base: 'my-custom-input-class' },
297
+ * submit: { base: 'btn btn-primary' }
298
+ * }}
299
+ * labels={{
300
+ * fileUpload: { clickToUpload: 'Upload a file' }
301
+ * }}
302
+ * >
303
+ * <Form config={formConfig} />
304
+ * </FormThemeProvider>
305
+ * ```
306
+ */
307
+ declare function FormThemeProvider({ children, theme, labels, lightOnly, }: FormThemeProviderProps): react_jsx_runtime.JSX.Element;
308
+ /**
309
+ * Utility to create a complete custom theme
310
+ */
311
+ declare function createTheme(customTheme: Partial<FormTheme>, basedOn?: 'default' | 'lightOnly'): FormTheme;
312
+ /**
313
+ * Utility to combine class names, filtering out undefined/null values
314
+ */
315
+ declare function cx(...classes: (string | undefined | null | false)[]): string;
316
+
317
+ type FormProps = {
318
+ /**
319
+ * Form configuration object
320
+ */
321
+ config: ResolvedFormConfig;
322
+ /**
323
+ * Additional CSS class names
324
+ */
325
+ className?: string;
326
+ /**
327
+ * Form errors from server validation
328
+ */
329
+ errors?: FormErrors;
330
+ /**
331
+ * Whether the form is currently submitting
332
+ */
333
+ isSubmitting?: boolean;
334
+ /**
335
+ * Custom form element to use (e.g., from a router library)
336
+ * If not provided, uses native <form>
337
+ */
338
+ formElement?: React.ComponentType<FormHTMLAttributes<HTMLFormElement> & {
339
+ children: ReactNode;
340
+ }>;
341
+ /**
342
+ * Additional props to pass to the form element
343
+ */
344
+ formProps?: FormHTMLAttributes<HTMLFormElement>;
345
+ /**
346
+ * Base URL for file uploads preview
347
+ */
348
+ fileBaseUrl?: string;
349
+ };
350
+ /**
351
+ * Framework-agnostic Form component
352
+ * Renders form fields based on configuration and handles error display
353
+ */
354
+ declare function Form({ config, className, errors, isSubmitting, formElement: FormElement, formProps, fileBaseUrl, }: FormProps): react_jsx_runtime.JSX.Element;
355
+
356
+ type AlertProps = {
357
+ type: 'error' | 'success' | 'warning' | 'info';
358
+ message: string;
359
+ className?: string;
360
+ };
361
+ declare function Alert({ type, message, className }: AlertProps): react_jsx_runtime.JSX.Element;
362
+ declare const _default$9: react.MemoExoticComponent<typeof Alert>;
363
+
364
+ type TextInputProps = Omit<ResolvedFormField, 'type' | 'options' | 'defaultChecked'> & {
365
+ type: 'text' | 'email' | 'password' | 'number';
366
+ name: string;
367
+ };
368
+ declare function TextInput({ label, placeholder, name, defaultValue, className, disabled, error, rules, type, before, beforeClassName, after, afterClassName, }: TextInputProps): react_jsx_runtime.JSX.Element;
369
+ declare const _default$8: react.MemoExoticComponent<typeof TextInput>;
370
+
371
+ type SelectInputProps = Omit<ResolvedFormField, 'type' | 'defaultChecked'> & {
372
+ name: string;
373
+ };
374
+ declare function SelectInput({ label, name, options, defaultValue, className, disabled, error, rules, before, beforeClassName, after, afterClassName, }: SelectInputProps): react_jsx_runtime.JSX.Element;
375
+ declare const _default$7: react.MemoExoticComponent<typeof SelectInput>;
376
+
377
+ type TextAreaInputProps = Omit<ResolvedFormField, 'type' | 'options' | 'defaultChecked'> & {
378
+ name: string;
379
+ };
380
+ declare function TextAreaInput({ label, name, placeholder, defaultValue, className, disabled, error, rules, before, beforeClassName, after, afterClassName, }: TextAreaInputProps): react_jsx_runtime.JSX.Element;
381
+ declare const _default$6: react.MemoExoticComponent<typeof TextAreaInput>;
382
+
383
+ type CheckboxInputProps = Omit<ResolvedFormField, 'type' | 'options' | 'defaultValue'> & {
384
+ name: string;
385
+ };
386
+ declare function CheckboxInput({ label, name, defaultChecked, className, disabled, error, rules, before, beforeClassName, after, afterClassName, }: CheckboxInputProps): react_jsx_runtime.JSX.Element;
387
+ declare const _default$5: react.MemoExoticComponent<typeof CheckboxInput>;
388
+
389
+ type ToggleInputProps = Omit<ResolvedFormField, 'type' | 'options' | 'defaultValue'> & {
390
+ name: string;
391
+ };
392
+ declare function ToggleInput({ label, name, defaultChecked, className, disabled, error, rules, before, beforeClassName, after, afterClassName, }: ToggleInputProps): react_jsx_runtime.JSX.Element;
393
+ declare const _default$4: react.MemoExoticComponent<typeof ToggleInput>;
394
+
395
+ type RadioInputProps = Omit<ResolvedFormField, 'type' | 'defaultChecked'> & {
396
+ name: string;
397
+ };
398
+ declare function RadioInput({ label, name, options, defaultValue, className, disabled, error, rules, before, beforeClassName, after, afterClassName, }: RadioInputProps): react_jsx_runtime.JSX.Element;
399
+ declare const _default$3: react.MemoExoticComponent<typeof RadioInput>;
400
+
401
+ type FileInputProps = Omit<ResolvedFormField, 'type' | 'options'> & {
402
+ name: string;
403
+ metaData?: FileMetaData;
404
+ /**
405
+ * Optional base URL for displaying existing files
406
+ * If provided along with defaultValue, will show preview for images
407
+ */
408
+ baseUrl?: string;
409
+ };
410
+ declare function FileInput({ label, name, className, disabled, error, rules, before, beforeClassName, after, afterClassName, defaultValue, metaData, uploadDir, baseUrl, }: FileInputProps): react_jsx_runtime.JSX.Element;
411
+ declare const _default$2: react.MemoExoticComponent<typeof FileInput>;
412
+
413
+ type HiddenInputProps = Omit<ResolvedFormField, 'type' | 'options' | 'defaultChecked' | 'label'> & {
414
+ name: string;
415
+ };
416
+ declare function HiddenInput({ name, defaultValue, className, disabled, }: HiddenInputProps): react_jsx_runtime.JSX.Element;
417
+
418
+ type SubmitInputProps = Omit<ResolvedFormField, 'type' | 'options'> & {
419
+ name: string;
420
+ loading: boolean;
421
+ };
422
+ declare function SubmitInput({ label, name, className, disabled, loading, defaultValue, hideSpinner, }: SubmitInputProps): react_jsx_runtime.JSX.Element;
423
+
424
+ type NoneInputProps = {
425
+ label: string;
426
+ value: string;
427
+ className?: string;
428
+ };
429
+ declare function NoneInput({ label, value, className }: NoneInputProps): react_jsx_runtime.JSX.Element;
430
+ declare const _default$1: react.MemoExoticComponent<typeof NoneInput>;
431
+
432
+ type DateTimeInputProps = Omit<FormField, 'type' | 'options' | 'defaultChecked'> & {
433
+ name: string;
434
+ };
435
+ declare function DateTimeInput({ label, name, placeholder, defaultValue, className, disabled, error, rules, before, beforeClassName, after, afterClassName, }: DateTimeInputProps): react_jsx_runtime.JSX.Element;
436
+ declare const _default: react.MemoExoticComponent<typeof DateTimeInput>;
437
+
438
+ export { _default$9 as Alert, type AlertProps, _default$5 as CheckboxInput, type CheckboxInputProps, _default as DateTimeInput, type DateTimeInputProps, _default$2 as FileInput, type FileInputProps, FileMetaData, Form, FormContext, FormContextValue, FormErrors, FormField, type FormLabels, type FormProps, FormState, type FormTheme, type FormThemeConfig, FormThemeProvider, type FormThemeProviderProps, HiddenInput, type HiddenInputProps, _default$1 as NoneInput, type NoneInputProps, _default$3 as RadioInput, type RadioInputProps, ResolvedFormConfig, ResolvedFormField, _default$7 as SelectInput, type SelectInputProps, SubmitInput, type SubmitInputProps, _default$6 as TextAreaInput, type TextAreaInputProps, _default$8 as TextInput, type TextInputProps, _default$4 as ToggleInput, type ToggleInputProps, bytesToHumanReadable, createTheme, cx, defaultLabels, defaultTheme, isImage, lightOnlyTheme, useFieldError, useFormConfig, useFormContext, useFormLabels, useFormState, useFormTheme, useFormThemeConfig, widthClasses };