form-craft-package 1.7.9-dev.1 → 1.7.9

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.
Files changed (34) hide show
  1. package/AJV_JSON_Schema_Guide.md +408 -408
  2. package/package.json +2 -1
  3. package/src/components/common/custom-hooks/use-find-dynamic-form.hook.ts +30 -11
  4. package/src/components/common/custom-hooks/use-many-to-many-connector.hook.ts +30 -0
  5. package/src/components/common/not-found.tsx +21 -0
  6. package/src/components/companies/1-authenticated/change-password.tsx +1 -1
  7. package/src/components/form/1-list/index.tsx +4 -5
  8. package/src/components/form/1-list/table-header.tsx +5 -5
  9. package/src/components/form/1-list/table.tsx +10 -12
  10. package/src/components/form/2-details/index.tsx +53 -40
  11. package/src/components/form/layout-renderer/1-row/index.tsx +2 -1
  12. package/src/components/form/layout-renderer/3-element/1-dynamic-button/index.tsx +57 -87
  13. package/src/components/form/layout-renderer/3-element/1-dynamic-button/use-button-navigate.hook.tsx +88 -0
  14. package/src/components/form/layout-renderer/3-element/1-dynamic-button/use-create-data.hook.ts +22 -23
  15. package/src/components/form/layout-renderer/3-element/1-dynamic-button/use-generate-report.hook.tsx +3 -4
  16. package/src/components/form/layout-renderer/3-element/1-dynamic-button/use-save-data.hook.ts +2 -2
  17. package/src/components/form/layout-renderer/3-element/11-breadcrumb.tsx +3 -2
  18. package/src/components/form/layout-renderer/3-element/2-field-element.tsx +4 -1
  19. package/src/components/form/layout-renderer/3-element/8-fields-with-options.tsx +9 -12
  20. package/src/components/form/layout-renderer/3-element/9-form-data-render.tsx +48 -79
  21. package/src/components/modals/report-filters.modal/helper-functions.ts +3 -6
  22. package/src/constants.ts +7 -1
  23. package/src/enums/form.enum.ts +5 -3
  24. package/src/functions/forms/breadcrumb-handlers.ts +21 -0
  25. package/src/functions/forms/data-render-functions.tsx +1 -0
  26. package/src/functions/forms/extended-json-handlers.ts +56 -0
  27. package/src/functions/forms/index.ts +17 -11
  28. package/src/functions/reports/index.tsx +2 -1
  29. package/src/types/forms/index.ts +1 -0
  30. package/src/types/forms/layout-elements/button.ts +11 -3
  31. package/src/types/forms/layout-elements/index.ts +6 -2
  32. package/src/types/forms/layout-elements/sanitization.ts +6 -1
  33. package/src/types/forms/relationship/index.ts +12 -1
  34. package/src/functions/forms/json-handlers.ts +0 -19
@@ -1,409 +1,409 @@
1
- # AJV JSON Schema Documentation
2
-
3
- ## 1. `$schema`
4
-
5
- Defines the JSON Schema version.
6
-
7
- ```json
8
- {
9
- "$schema": "http://json-schema.org/draft-07/schema#"
10
- }
11
- ```
12
-
13
- ## 2. `type`
14
-
15
- Specifies the data type: `object`, `array`, `string`, `number`, `integer`, or `boolean`.
16
-
17
- ```json
18
- {
19
- "type": "string"
20
- }
21
- ```
22
-
23
- ## 3. `properties`
24
-
25
- Defines the properties of an object and their types.
26
-
27
- ```json
28
- {
29
- "type": "object",
30
- "properties": {
31
- "name": { "type": "string" },
32
- "age": { "type": "integer" }
33
- }
34
- }
35
- ```
36
-
37
- ## 4. `required`
38
-
39
- Lists mandatory fields in an object.
40
-
41
- ```json
42
- {
43
- "type": "object",
44
- "properties": {
45
- "name": { "type": "string" },
46
- "age": { "type": "integer" }
47
- },
48
- "required": ["name"]
49
- }
50
- ```
51
-
52
- - **`name`** is required.
53
- - **`age`** is optional.
54
-
55
- ---
56
-
57
- ## 5. `items`
58
-
59
- If the `type` is `array`, the `items` property defines the schema for the array elements.
60
-
61
- ### a. Single Type for All Items
62
-
63
- ```json
64
- {
65
- "type": "array",
66
- "items": { "type": "string" }
67
- }
68
- ```
69
-
70
- - Valid: `["apple", "banana"]`
71
- - Invalid: `[1, "apple"]`
72
-
73
- ### b. Different Types for Items (Tuple Validation)
74
-
75
- ```json
76
- {
77
- "type": "array",
78
- "items": [{ "type": "string" }, { "type": "integer" }]
79
- }
80
- ```
81
-
82
- - Valid: `["apple", 5]`
83
- - Invalid: `["apple", "banana"]`
84
-
85
- ### c. Additional Items
86
-
87
- Control extra items beyond those specified.
88
-
89
- ```json
90
- {
91
- "type": "array",
92
- "items": [{ "type": "string" }, { "type": "integer" }],
93
- "additionalItems": false
94
- }
95
- ```
96
-
97
- - Valid: `["apple", 5]`
98
- - Invalid: `["apple", 5, "extra"]`
99
-
100
- ---
101
-
102
- ## 6. `enum`
103
-
104
- Restricts a field to specific values.
105
-
106
- ```json
107
- {
108
- "type": "string",
109
- "enum": ["red", "green", "blue"]
110
- }
111
- ```
112
- - Allows only these three values.
113
-
114
- ## 7. `minimum` and `maximum`
115
-
116
- Sets the range for numbers.
117
-
118
- ```json
119
- {
120
- "type": "number",
121
- "minimum": 10,
122
- "maximum": 100
123
- }
124
- ```
125
-
126
- ## 8. `minLength` and `maxLength`
127
-
128
- Sets the length constraints for strings.
129
-
130
- ```json
131
- {
132
- "type": "string",
133
- "minLength": 3,
134
- "maxLength": 10
135
- }
136
- ```
137
-
138
- ## 9. `pattern`
139
-
140
- Validates strings against a regex pattern.
141
-
142
- ```json
143
- {
144
- "type": "string",
145
- "pattern": "^[A-Z][a-z]+$"
146
- }
147
- ```
148
- - The string should start with an uppercase letter.
149
-
150
- ## 10. `format`
151
-
152
- AJV supports several predefined string formats:
153
-
154
- | **Format** | **Description** |
155
- | -------------- | ----------------------------------------------------- |
156
- | `email` | Valid email address (e.g., `user@domain.com`) |
157
- | `uri` | Uniform Resource Identifier (URI) |
158
- | `url` | Web address (HTTP/HTTPS) |
159
- | `date` | Date in `YYYY-MM-DD` format |
160
- | `time` | Time in `HH:MM:SS` format |
161
- | `date-time` | Combined date and time (e.g., `2023-10-12T10:15:30Z`) |
162
- | `ipv4` | IPv4 address (e.g., `192.168.1.1`) |
163
- | `ipv6` | IPv6 address (e.g., `::1`) |
164
- | `uuid` | UUID (e.g., `550e8400-e29b-41d4-a716-446655440000`) |
165
- | `hostname` | Valid DNS hostname |
166
- | `regex` | Regular expression |
167
- | `json-pointer` | JSON Pointer (e.g., `/path/to/data`) |
168
-
169
- Custom formats can be defined using `ajv.addFormat`.
170
-
171
- ```json
172
- {
173
- "type": "string",
174
- "format": "email"
175
- }
176
- ```
177
-
178
- ## 11. `default`
179
-
180
- Provides a default value for a property.
181
-
182
- ```json
183
- {
184
- "type": "object",
185
- "properties": {
186
- "isActive": { "type": "boolean", "default": true }
187
- }
188
- }
189
- ```
190
-
191
- ## 12. `oneOf`
192
-
193
- Specifies multiple valid schemas (OR).
194
-
195
- ```json
196
- {
197
- "oneOf": [{ "type": "string" }, { "type": "integer" }]
198
- }
199
- ```
200
- - Allows either a string or an integer, but not both.
201
-
202
- ## 13. `allOf`
203
-
204
- Requires the data to match all schemas.
205
-
206
- ```json
207
- {
208
- "allOf": [
209
- { "type": "object", "properties": { "name": { "type": "string" } } },
210
- { "type": "object", "properties": { "age": { "type": "integer" } } }
211
- ]
212
- }
213
- ```
214
- - Allows either a string or a boolean.
215
-
216
- ## 14. `anyOf`
217
-
218
- Requires the data to match at least one schema.
219
-
220
- ```json
221
- {
222
- "anyOf": [{ "type": "string" }, { "type": "boolean" }]
223
- }
224
- ```
225
-
226
- ## 15. `not`
227
-
228
- Specifies that data must not match a schema.
229
-
230
- ```json
231
- {
232
- "not": { "type": "null" }
233
- }
234
- ```
235
- - Disallows null values.
236
-
237
- ## 16. `additionalProperties`
238
-
239
- Allows or disallows extra properties in an object.
240
-
241
- ```json
242
- {
243
- "type": "object",
244
- "properties": {
245
- "name": { "type": "string" }
246
- },
247
- "additionalProperties": false
248
- }
249
- ```
250
- - Disallows extra fields.
251
-
252
- ## 17. `patternProperties`
253
-
254
- Validates object keys using a regex.
255
-
256
- ```json
257
- {
258
- "type": "object",
259
- "patternProperties": {
260
- "^user_": { "type": "string" }
261
- }
262
- }
263
- ```
264
-
265
- - All keys starting with `user_` (e.g., `user_1`, `user_123`) must have string values.
266
-
267
- ## 18. `dependencies`
268
-
269
- Dependencies specify logical relationships between properties.
270
-
271
- ### Property Dependencies
272
-
273
- This means the presence of one property requires another property.
274
-
275
- #### Example
276
-
277
- ```json
278
- {
279
- "type": "object",
280
- "properties": {
281
- "creditCard": { "type": "string" },
282
- "billingAddress": { "type": "string" }
283
- },
284
- "dependencies": {
285
- "creditCard": ["billingAddress"]
286
- }
287
- }
288
- ```
289
-
290
- - If `creditCard` is present, `billingAddress` **must** also be present.
291
- - If `creditCard` is not present, `billingAddress` can be omitted.
292
-
293
- ### Schema Dependencies
294
-
295
- Schema dependencies apply different schemas based on the presence of a field.
296
-
297
- #### Example
298
-
299
- ```json
300
- {
301
- "type": "object",
302
- "properties": {
303
- "country": { "type": "string" },
304
- "postalCode": { "type": "string" }
305
- },
306
- "dependencies": {
307
- "country": {
308
- "oneOf": [
309
- {
310
- "properties": { "country": { "const": "US" }, "postalCode": { "pattern": "^[0-9]{5}$" } },
311
- "required": ["postalCode"]
312
- },
313
- {
314
- "properties": {
315
- "country": { "const": "CA" },
316
- "postalCode": { "pattern": "^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$" }
317
- },
318
- "required": ["postalCode"]
319
- }
320
- ]
321
- }
322
- }
323
- }
324
- ```
325
-
326
- - If `country` is `"US"`, `postalCode` must match the US zip code format.
327
- - If `country` is `"CA"`, `postalCode` must match the Canadian postal code format.
328
-
329
- ---
330
-
331
- ## 19. `const`
332
-
333
- Requires a field to have a specific value.
334
-
335
- ```json
336
- {
337
- "type": "object",
338
- "properties": {
339
- "status": { "const": "active" }
340
- }
341
- }
342
- ```
343
- - Ensures the field always equals "active".
344
-
345
- ## 20. `if`, `then`, `else`
346
-
347
- Conditional validation.
348
-
349
- ```json
350
- {
351
- "if": { "properties": { "role": { "const": "admin" } } },
352
- "then": { "required": ["adminCode"] },
353
- "else": { "required": ["userCode"] }
354
- }
355
- ```
356
-
357
- ## 21. `uniqueItems`
358
-
359
- Ensures all items in an array are unique.
360
-
361
- ```json
362
- {
363
- "type": "array",
364
- "items": { "type": "integer" },
365
- "uniqueItems": true
366
- }
367
- ```
368
- - Ensures [1, 2, 3] is valid, but [1, 2, 2] is not.
369
-
370
- ## 22. `minItems` and `maxItems`
371
-
372
- Limits the number of items in an array.
373
-
374
- ```json
375
- {
376
- "type": "array",
377
- "items": { "type": "string" },
378
- "minItems": 1,
379
- "maxItems": 5
380
- }
381
- ```
382
-
383
- ## 23. `contains`
384
-
385
- Requires at least one item in an array to match a schema.
386
-
387
- ```json
388
- {
389
- "type": "array",
390
- "items": { "type": "integer" },
391
- "contains": { "const": 10 }
392
- }
393
- ```
394
-
395
- ## 24. `$ref`
396
-
397
- References reusable schemas.
398
-
399
- ```json
400
- {
401
- "$ref": "#/definitions/person",
402
- "definitions": {
403
- "person": {
404
- "type": "object",
405
- "properties": { "name": { "type": "string" } }
406
- }
407
- }
408
- }
1
+ # AJV JSON Schema Documentation
2
+
3
+ ## 1. `$schema`
4
+
5
+ Defines the JSON Schema version.
6
+
7
+ ```json
8
+ {
9
+ "$schema": "http://json-schema.org/draft-07/schema#"
10
+ }
11
+ ```
12
+
13
+ ## 2. `type`
14
+
15
+ Specifies the data type: `object`, `array`, `string`, `number`, `integer`, or `boolean`.
16
+
17
+ ```json
18
+ {
19
+ "type": "string"
20
+ }
21
+ ```
22
+
23
+ ## 3. `properties`
24
+
25
+ Defines the properties of an object and their types.
26
+
27
+ ```json
28
+ {
29
+ "type": "object",
30
+ "properties": {
31
+ "name": { "type": "string" },
32
+ "age": { "type": "integer" }
33
+ }
34
+ }
35
+ ```
36
+
37
+ ## 4. `required`
38
+
39
+ Lists mandatory fields in an object.
40
+
41
+ ```json
42
+ {
43
+ "type": "object",
44
+ "properties": {
45
+ "name": { "type": "string" },
46
+ "age": { "type": "integer" }
47
+ },
48
+ "required": ["name"]
49
+ }
50
+ ```
51
+
52
+ - **`name`** is required.
53
+ - **`age`** is optional.
54
+
55
+ ---
56
+
57
+ ## 5. `items`
58
+
59
+ If the `type` is `array`, the `items` property defines the schema for the array elements.
60
+
61
+ ### a. Single Type for All Items
62
+
63
+ ```json
64
+ {
65
+ "type": "array",
66
+ "items": { "type": "string" }
67
+ }
68
+ ```
69
+
70
+ - Valid: `["apple", "banana"]`
71
+ - Invalid: `[1, "apple"]`
72
+
73
+ ### b. Different Types for Items (Tuple Validation)
74
+
75
+ ```json
76
+ {
77
+ "type": "array",
78
+ "items": [{ "type": "string" }, { "type": "integer" }]
79
+ }
80
+ ```
81
+
82
+ - Valid: `["apple", 5]`
83
+ - Invalid: `["apple", "banana"]`
84
+
85
+ ### c. Additional Items
86
+
87
+ Control extra items beyond those specified.
88
+
89
+ ```json
90
+ {
91
+ "type": "array",
92
+ "items": [{ "type": "string" }, { "type": "integer" }],
93
+ "additionalItems": false
94
+ }
95
+ ```
96
+
97
+ - Valid: `["apple", 5]`
98
+ - Invalid: `["apple", 5, "extra"]`
99
+
100
+ ---
101
+
102
+ ## 6. `enum`
103
+
104
+ Restricts a field to specific values.
105
+
106
+ ```json
107
+ {
108
+ "type": "string",
109
+ "enum": ["red", "green", "blue"]
110
+ }
111
+ ```
112
+ - Allows only these three values.
113
+
114
+ ## 7. `minimum` and `maximum`
115
+
116
+ Sets the range for numbers.
117
+
118
+ ```json
119
+ {
120
+ "type": "number",
121
+ "minimum": 10,
122
+ "maximum": 100
123
+ }
124
+ ```
125
+
126
+ ## 8. `minLength` and `maxLength`
127
+
128
+ Sets the length constraints for strings.
129
+
130
+ ```json
131
+ {
132
+ "type": "string",
133
+ "minLength": 3,
134
+ "maxLength": 10
135
+ }
136
+ ```
137
+
138
+ ## 9. `pattern`
139
+
140
+ Validates strings against a regex pattern.
141
+
142
+ ```json
143
+ {
144
+ "type": "string",
145
+ "pattern": "^[A-Z][a-z]+$"
146
+ }
147
+ ```
148
+ - The string should start with an uppercase letter.
149
+
150
+ ## 10. `format`
151
+
152
+ AJV supports several predefined string formats:
153
+
154
+ | **Format** | **Description** |
155
+ | -------------- | ----------------------------------------------------- |
156
+ | `email` | Valid email address (e.g., `user@domain.com`) |
157
+ | `uri` | Uniform Resource Identifier (URI) |
158
+ | `url` | Web address (HTTP/HTTPS) |
159
+ | `date` | Date in `YYYY-MM-DD` format |
160
+ | `time` | Time in `HH:MM:SS` format |
161
+ | `date-time` | Combined date and time (e.g., `2023-10-12T10:15:30Z`) |
162
+ | `ipv4` | IPv4 address (e.g., `192.168.1.1`) |
163
+ | `ipv6` | IPv6 address (e.g., `::1`) |
164
+ | `uuid` | UUID (e.g., `550e8400-e29b-41d4-a716-446655440000`) |
165
+ | `hostname` | Valid DNS hostname |
166
+ | `regex` | Regular expression |
167
+ | `json-pointer` | JSON Pointer (e.g., `/path/to/data`) |
168
+
169
+ Custom formats can be defined using `ajv.addFormat`.
170
+
171
+ ```json
172
+ {
173
+ "type": "string",
174
+ "format": "email"
175
+ }
176
+ ```
177
+
178
+ ## 11. `default`
179
+
180
+ Provides a default value for a property.
181
+
182
+ ```json
183
+ {
184
+ "type": "object",
185
+ "properties": {
186
+ "isActive": { "type": "boolean", "default": true }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ## 12. `oneOf`
192
+
193
+ Specifies multiple valid schemas (OR).
194
+
195
+ ```json
196
+ {
197
+ "oneOf": [{ "type": "string" }, { "type": "integer" }]
198
+ }
199
+ ```
200
+ - Allows either a string or an integer, but not both.
201
+
202
+ ## 13. `allOf`
203
+
204
+ Requires the data to match all schemas.
205
+
206
+ ```json
207
+ {
208
+ "allOf": [
209
+ { "type": "object", "properties": { "name": { "type": "string" } } },
210
+ { "type": "object", "properties": { "age": { "type": "integer" } } }
211
+ ]
212
+ }
213
+ ```
214
+ - Allows either a string or a boolean.
215
+
216
+ ## 14. `anyOf`
217
+
218
+ Requires the data to match at least one schema.
219
+
220
+ ```json
221
+ {
222
+ "anyOf": [{ "type": "string" }, { "type": "boolean" }]
223
+ }
224
+ ```
225
+
226
+ ## 15. `not`
227
+
228
+ Specifies that data must not match a schema.
229
+
230
+ ```json
231
+ {
232
+ "not": { "type": "null" }
233
+ }
234
+ ```
235
+ - Disallows null values.
236
+
237
+ ## 16. `additionalProperties`
238
+
239
+ Allows or disallows extra properties in an object.
240
+
241
+ ```json
242
+ {
243
+ "type": "object",
244
+ "properties": {
245
+ "name": { "type": "string" }
246
+ },
247
+ "additionalProperties": false
248
+ }
249
+ ```
250
+ - Disallows extra fields.
251
+
252
+ ## 17. `patternProperties`
253
+
254
+ Validates object keys using a regex.
255
+
256
+ ```json
257
+ {
258
+ "type": "object",
259
+ "patternProperties": {
260
+ "^user_": { "type": "string" }
261
+ }
262
+ }
263
+ ```
264
+
265
+ - All keys starting with `user_` (e.g., `user_1`, `user_123`) must have string values.
266
+
267
+ ## 18. `dependencies`
268
+
269
+ Dependencies specify logical relationships between properties.
270
+
271
+ ### Property Dependencies
272
+
273
+ This means the presence of one property requires another property.
274
+
275
+ #### Example
276
+
277
+ ```json
278
+ {
279
+ "type": "object",
280
+ "properties": {
281
+ "creditCard": { "type": "string" },
282
+ "billingAddress": { "type": "string" }
283
+ },
284
+ "dependencies": {
285
+ "creditCard": ["billingAddress"]
286
+ }
287
+ }
288
+ ```
289
+
290
+ - If `creditCard` is present, `billingAddress` **must** also be present.
291
+ - If `creditCard` is not present, `billingAddress` can be omitted.
292
+
293
+ ### Schema Dependencies
294
+
295
+ Schema dependencies apply different schemas based on the presence of a field.
296
+
297
+ #### Example
298
+
299
+ ```json
300
+ {
301
+ "type": "object",
302
+ "properties": {
303
+ "country": { "type": "string" },
304
+ "postalCode": { "type": "string" }
305
+ },
306
+ "dependencies": {
307
+ "country": {
308
+ "oneOf": [
309
+ {
310
+ "properties": { "country": { "const": "US" }, "postalCode": { "pattern": "^[0-9]{5}$" } },
311
+ "required": ["postalCode"]
312
+ },
313
+ {
314
+ "properties": {
315
+ "country": { "const": "CA" },
316
+ "postalCode": { "pattern": "^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$" }
317
+ },
318
+ "required": ["postalCode"]
319
+ }
320
+ ]
321
+ }
322
+ }
323
+ }
324
+ ```
325
+
326
+ - If `country` is `"US"`, `postalCode` must match the US zip code format.
327
+ - If `country` is `"CA"`, `postalCode` must match the Canadian postal code format.
328
+
329
+ ---
330
+
331
+ ## 19. `const`
332
+
333
+ Requires a field to have a specific value.
334
+
335
+ ```json
336
+ {
337
+ "type": "object",
338
+ "properties": {
339
+ "status": { "const": "active" }
340
+ }
341
+ }
342
+ ```
343
+ - Ensures the field always equals "active".
344
+
345
+ ## 20. `if`, `then`, `else`
346
+
347
+ Conditional validation.
348
+
349
+ ```json
350
+ {
351
+ "if": { "properties": { "role": { "const": "admin" } } },
352
+ "then": { "required": ["adminCode"] },
353
+ "else": { "required": ["userCode"] }
354
+ }
355
+ ```
356
+
357
+ ## 21. `uniqueItems`
358
+
359
+ Ensures all items in an array are unique.
360
+
361
+ ```json
362
+ {
363
+ "type": "array",
364
+ "items": { "type": "integer" },
365
+ "uniqueItems": true
366
+ }
367
+ ```
368
+ - Ensures [1, 2, 3] is valid, but [1, 2, 2] is not.
369
+
370
+ ## 22. `minItems` and `maxItems`
371
+
372
+ Limits the number of items in an array.
373
+
374
+ ```json
375
+ {
376
+ "type": "array",
377
+ "items": { "type": "string" },
378
+ "minItems": 1,
379
+ "maxItems": 5
380
+ }
381
+ ```
382
+
383
+ ## 23. `contains`
384
+
385
+ Requires at least one item in an array to match a schema.
386
+
387
+ ```json
388
+ {
389
+ "type": "array",
390
+ "items": { "type": "integer" },
391
+ "contains": { "const": 10 }
392
+ }
393
+ ```
394
+
395
+ ## 24. `$ref`
396
+
397
+ References reusable schemas.
398
+
399
+ ```json
400
+ {
401
+ "$ref": "#/definitions/person",
402
+ "definitions": {
403
+ "person": {
404
+ "type": "object",
405
+ "properties": { "name": { "type": "string" } }
406
+ }
407
+ }
408
+ }
409
409
  ```