@opensite/ui 1.7.5 → 1.7.6

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,92 @@
1
+ /**
2
+ * Form field types and utilities for dynamic form generation
3
+ */
4
+ type FormFieldType = "text" | "email" | "search" | "password" | "tel" | "textarea" | "select" | "radio" | "checkbox" | "checkbox-group" | "number" | "url" | "date" | "date-picker" | "date-range" | "time" | "file" | "rich-text" | "multi-select";
5
+ interface SelectOption {
6
+ value: string;
7
+ label: string;
8
+ disabled?: boolean;
9
+ }
10
+ interface FormFieldConfig {
11
+ /**
12
+ * Unique field name (used as the key in form values)
13
+ */
14
+ name: string;
15
+ /**
16
+ * Field type
17
+ */
18
+ type: FormFieldType;
19
+ /**
20
+ * Display label for the field
21
+ */
22
+ label: string;
23
+ /**
24
+ * Placeholder text
25
+ */
26
+ placeholder?: string;
27
+ /**
28
+ * Whether the field is required
29
+ * @default false
30
+ */
31
+ required?: boolean;
32
+ /**
33
+ * Column span in grid layout (1-12)
34
+ * @default 12 (full width)
35
+ */
36
+ columnSpan?: number;
37
+ /**
38
+ * Options for select/radio/checkbox-group fields
39
+ */
40
+ options?: SelectOption[];
41
+ /**
42
+ * Number of rows for textarea
43
+ * @default 4
44
+ */
45
+ rows?: number;
46
+ /**
47
+ * Custom validation function
48
+ * Return undefined for valid, or an error message string for invalid
49
+ */
50
+ validator?: (value: any, allValues: Record<string, any>) => string | undefined;
51
+ /**
52
+ * Additional CSS classes for the field wrapper
53
+ */
54
+ className?: string;
55
+ /**
56
+ * Whether the field is disabled
57
+ * @default false
58
+ */
59
+ disabled?: boolean;
60
+ /**
61
+ * Accepted file types for file inputs (MIME types or extensions)
62
+ * @example ".pdf,.doc,.docx"
63
+ * @example "image/*,application/pdf"
64
+ */
65
+ accept?: string;
66
+ /**
67
+ * Maximum file size in bytes for file inputs
68
+ * @default 5MB (5 * 1024 * 1024)
69
+ */
70
+ maxSize?: number;
71
+ /**
72
+ * Maximum number of files for file inputs
73
+ * @default 1
74
+ */
75
+ maxFiles?: number;
76
+ /**
77
+ * Allow multiple file selection
78
+ * @default false
79
+ */
80
+ multiple?: boolean;
81
+ /**
82
+ * Description text for rich-text editor
83
+ */
84
+ description?: string;
85
+ /**
86
+ * Layout for radio/checkbox groups
87
+ * @default "stacked"
88
+ */
89
+ layout?: "inline" | "stacked";
90
+ }
91
+
92
+ export type { FormFieldConfig as F };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Form field types and utilities for dynamic form generation
3
+ */
4
+ type FormFieldType = "text" | "email" | "search" | "password" | "tel" | "textarea" | "select" | "radio" | "checkbox" | "checkbox-group" | "number" | "url" | "date" | "date-picker" | "date-range" | "time" | "file" | "rich-text" | "multi-select";
5
+ interface SelectOption {
6
+ value: string;
7
+ label: string;
8
+ disabled?: boolean;
9
+ }
10
+ interface FormFieldConfig {
11
+ /**
12
+ * Unique field name (used as the key in form values)
13
+ */
14
+ name: string;
15
+ /**
16
+ * Field type
17
+ */
18
+ type: FormFieldType;
19
+ /**
20
+ * Display label for the field
21
+ */
22
+ label: string;
23
+ /**
24
+ * Placeholder text
25
+ */
26
+ placeholder?: string;
27
+ /**
28
+ * Whether the field is required
29
+ * @default false
30
+ */
31
+ required?: boolean;
32
+ /**
33
+ * Column span in grid layout (1-12)
34
+ * @default 12 (full width)
35
+ */
36
+ columnSpan?: number;
37
+ /**
38
+ * Options for select/radio/checkbox-group fields
39
+ */
40
+ options?: SelectOption[];
41
+ /**
42
+ * Number of rows for textarea
43
+ * @default 4
44
+ */
45
+ rows?: number;
46
+ /**
47
+ * Custom validation function
48
+ * Return undefined for valid, or an error message string for invalid
49
+ */
50
+ validator?: (value: any, allValues: Record<string, any>) => string | undefined;
51
+ /**
52
+ * Additional CSS classes for the field wrapper
53
+ */
54
+ className?: string;
55
+ /**
56
+ * Whether the field is disabled
57
+ * @default false
58
+ */
59
+ disabled?: boolean;
60
+ /**
61
+ * Accepted file types for file inputs (MIME types or extensions)
62
+ * @example ".pdf,.doc,.docx"
63
+ * @example "image/*,application/pdf"
64
+ */
65
+ accept?: string;
66
+ /**
67
+ * Maximum file size in bytes for file inputs
68
+ * @default 5MB (5 * 1024 * 1024)
69
+ */
70
+ maxSize?: number;
71
+ /**
72
+ * Maximum number of files for file inputs
73
+ * @default 1
74
+ */
75
+ maxFiles?: number;
76
+ /**
77
+ * Allow multiple file selection
78
+ * @default false
79
+ */
80
+ multiple?: boolean;
81
+ /**
82
+ * Description text for rich-text editor
83
+ */
84
+ description?: string;
85
+ /**
86
+ * Layout for radio/checkbox groups
87
+ * @default "stacked"
88
+ */
89
+ layout?: "inline" | "stacked";
90
+ }
91
+
92
+ export type { FormFieldConfig as F };