@stonecrop/aform 0.3.4 → 0.3.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.
@@ -5,60 +5,195 @@ import type { TableColumn, TableConfig, TableRow } from '@stonecrop/atable'
5
5
  * @public
6
6
  */
7
7
  export type ComponentProps = {
8
+ /**
9
+ * The schema object to pass to the component
10
+ * @public
11
+ */
12
+ schema?: SchemaTypes
13
+
14
+ /**
15
+ * The label to display in the component
16
+ * @public
17
+ */
8
18
  label?: string
19
+
20
+ /**
21
+ * The masking string to apply to inputs inside the component
22
+ * @public
23
+ */
9
24
  mask?: string
25
+
26
+ /**
27
+ * Indicate whether input is required for text and/or select elements inside the component
28
+ * @public
29
+ */
10
30
  required?: boolean
31
+
32
+ /**
33
+ * Indicate whether elements inside the component are read-only
34
+ * @public
35
+ */
11
36
  readonly?: boolean
37
+
38
+ /**
39
+ * Set a unique identifier for elements inside the component
40
+ * @public
41
+ */
12
42
  uuid?: string
13
- validation?: Record<string, any>
43
+
44
+ /**
45
+ * Validation options for elements inside the component
46
+ * @public
47
+ */
48
+ validation?: {
49
+ /**
50
+ * The error message to display when validation fails
51
+ * @public
52
+ */
53
+ errorMessage: string
54
+
55
+ [key: string]: any
56
+ }
14
57
  }
15
58
 
16
59
  /**
17
- * Base schemda for AForm components
18
- * @beta
60
+ * Basic field structure for AForm schemas
61
+ * @public
19
62
  */
20
- export type BasicSchema = {
21
- component: string
63
+ export type BaseSchema = {
64
+ /**
65
+ * The fieldname for the schema field
66
+ * @public
67
+ */
22
68
  fieldname: string
23
- value: any
69
+
70
+ /**
71
+ * The component to render
72
+ *
73
+ * @remarks
74
+ * This must be a string that represents the component to render. The registration of the component
75
+ * should be done in the main application.
76
+ *
77
+ * @public
78
+ */
79
+ component?: string
80
+
81
+ /**
82
+ * A placeholder value for the field
83
+ * @beta
84
+ */
85
+ value?: any
24
86
  }
25
87
 
26
88
  /**
27
- * Form schema
28
- * @beta
89
+ * Schema structure for defining forms inside AForm
90
+ * @public
29
91
  */
30
- export type FormSchema = BasicSchema & {
31
- align: string
32
- edit: boolean
33
- fieldtype: string
34
- label: string
35
- name: string
36
- width: string
92
+ export type FormSchema = BaseSchema & {
93
+ /**
94
+ * Align the field in the form
95
+ * @beta
96
+ */
97
+ align?: string
98
+
99
+ /**
100
+ * Indicate whether the field is editable
101
+ * @beta
102
+ */
103
+ edit?: boolean
104
+
105
+ /**
106
+ * The field type for the schema field
107
+ *
108
+ * @remarks
109
+ * This must be a string that represents the field type. A mask string will be automatically
110
+ * applied for the following field types:
111
+ * - Date ('##/##/####')
112
+ * - Datetime ('####/##/## ##:##')
113
+ * - Time ('##:##')
114
+ * - Fulltime ('##:##:##')
115
+ * - Phone ('(###) ### - ####')
116
+ * - Card ('#### #### #### ####')
117
+ *
118
+ * @public
119
+ */
120
+ fieldtype?: string
121
+
122
+ /**
123
+ * The label to display in the form
124
+ * @public
125
+ */
126
+ label?: string
127
+
128
+ /**
129
+ * The unique identifier for the field
130
+ * @beta
131
+ */
132
+ name?: string
133
+
134
+ /**
135
+ * The width of the field element.
136
+ * @beta
137
+ */
138
+ width?: string
139
+
140
+ /**
141
+ * The mask string for the field
142
+ * @beta
143
+ */
37
144
  mask?: string
38
145
  }
39
146
 
40
147
  /**
41
- * Table schema
42
- * @beta
148
+ * Schema structure for defining tables inside AForm
149
+ * @public
43
150
  */
44
- export type TableSchema = BasicSchema & {
45
- columns: TableColumn[]
46
- config: TableConfig
47
- rows: TableRow[]
151
+ export type TableSchema = BaseSchema & {
152
+ /**
153
+ * The columns to display in the table
154
+ * @public
155
+ */
156
+ columns?: TableColumn[]
157
+
158
+ /**
159
+ * The configuration for the table
160
+ * @public
161
+ */
162
+ config?: TableConfig
163
+
164
+ /**
165
+ * The rows to display in the table
166
+ * @public
167
+ */
168
+ rows?: TableRow[]
48
169
  }
49
170
 
50
171
  /**
51
- * Fieldset schema
52
- * @beta
172
+ * Schema structure for defining fieldsets inside AForm
173
+ * @public
53
174
  */
54
- export type FieldsetSchema = BasicSchema & {
55
- label: string
56
- schema: (FormSchema | TableSchema)[]
175
+ export type FieldsetSchema = BaseSchema & {
176
+ /**
177
+ * The label to display in the fieldset
178
+ * @public
179
+ */
180
+ label?: string
181
+
182
+ /**
183
+ * The schemas to be rendered inside the fieldset
184
+ * @public
185
+ */
186
+ schema?: (FormSchema | TableSchema)[]
187
+
188
+ /**
189
+ * Indicate whether the fieldset is collapsible
190
+ * @public
191
+ */
57
192
  collapsible?: boolean
58
193
  }
59
194
 
60
195
  /**
61
- * Superset of schema types
62
- * @beta
196
+ * Superset of all schema types for AForm
197
+ * @public
63
198
  */
64
199
  export type SchemaTypes = FormSchema | TableSchema | FieldsetSchema