@defra/forms-model 3.0.2
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/LICENCE +8 -0
- package/README.md +22 -0
- package/dist/browser/components/component-types.d.ts +3 -0
- package/dist/browser/components/component-types.d.ts.map +1 -0
- package/dist/browser/components/component-types.js +220 -0
- package/dist/browser/components/component-types.js.map +1 -0
- package/dist/browser/components/conditional-component-types.d.ts +3 -0
- package/dist/browser/components/conditional-component-types.d.ts.map +1 -0
- package/dist/browser/components/conditional-component-types.js +28 -0
- package/dist/browser/components/conditional-component-types.js.map +1 -0
- package/dist/browser/components/index.d.ts +4 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/components/index.js +45 -0
- package/dist/browser/components/index.js.map +1 -0
- package/dist/browser/components/types.d.ts +244 -0
- package/dist/browser/components/types.d.ts.map +1 -0
- package/dist/browser/components/types.js +56 -0
- package/dist/browser/components/types.js.map +1 -0
- package/dist/browser/conditions/condition-abstract.d.ts +16 -0
- package/dist/browser/conditions/condition-abstract.d.ts.map +1 -0
- package/dist/browser/conditions/condition-abstract.js +62 -0
- package/dist/browser/conditions/condition-abstract.js.map +1 -0
- package/dist/browser/conditions/condition-field.d.ts +13 -0
- package/dist/browser/conditions/condition-field.d.ts.map +1 -0
- package/dist/browser/conditions/condition-field.js +45 -0
- package/dist/browser/conditions/condition-field.js.map +1 -0
- package/dist/browser/conditions/condition-group-def.d.ts +10 -0
- package/dist/browser/conditions/condition-group-def.d.ts.map +1 -0
- package/dist/browser/conditions/condition-group-def.js +45 -0
- package/dist/browser/conditions/condition-group-def.js.map +1 -0
- package/dist/browser/conditions/condition-group.d.ts +15 -0
- package/dist/browser/conditions/condition-group.d.ts.map +1 -0
- package/dist/browser/conditions/condition-group.js +64 -0
- package/dist/browser/conditions/condition-group.js.map +1 -0
- package/dist/browser/conditions/condition-model.d.ts +41 -0
- package/dist/browser/conditions/condition-model.d.ts.map +1 -0
- package/dist/browser/conditions/condition-model.js +214 -0
- package/dist/browser/conditions/condition-model.js.map +1 -0
- package/dist/browser/conditions/condition-operators.d.ts +248 -0
- package/dist/browser/conditions/condition-operators.d.ts.map +1 -0
- package/dist/browser/conditions/condition-operators.js +132 -0
- package/dist/browser/conditions/condition-operators.js.map +1 -0
- package/dist/browser/conditions/condition-ref.d.ts +12 -0
- package/dist/browser/conditions/condition-ref.d.ts.map +1 -0
- package/dist/browser/conditions/condition-ref.js +51 -0
- package/dist/browser/conditions/condition-ref.js.map +1 -0
- package/dist/browser/conditions/condition-value-abstract.d.ts +8 -0
- package/dist/browser/conditions/condition-value-abstract.d.ts.map +1 -0
- package/dist/browser/conditions/condition-value-abstract.js +41 -0
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -0
- package/dist/browser/conditions/condition-value-registration.d.ts +10 -0
- package/dist/browser/conditions/condition-value-registration.d.ts.map +1 -0
- package/dist/browser/conditions/condition-value-registration.js +37 -0
- package/dist/browser/conditions/condition-value-registration.js.map +1 -0
- package/dist/browser/conditions/condition-values.d.ts +38 -0
- package/dist/browser/conditions/condition-values.d.ts.map +1 -0
- package/dist/browser/conditions/condition-values.js +127 -0
- package/dist/browser/conditions/condition-values.js.map +1 -0
- package/dist/browser/conditions/condition.d.ts +15 -0
- package/dist/browser/conditions/condition.d.ts.map +1 -0
- package/dist/browser/conditions/condition.js +56 -0
- package/dist/browser/conditions/condition.js.map +1 -0
- package/dist/browser/conditions/helpers.d.ts +3 -0
- package/dist/browser/conditions/helpers.d.ts.map +1 -0
- package/dist/browser/conditions/helpers.js +26 -0
- package/dist/browser/conditions/helpers.js.map +1 -0
- package/dist/browser/conditions/index.d.ts +11 -0
- package/dist/browser/conditions/index.d.ts.map +1 -0
- package/dist/browser/conditions/index.js +144 -0
- package/dist/browser/conditions/index.js.map +1 -0
- package/dist/browser/conditions/inline-condition-model.d.ts +86 -0
- package/dist/browser/conditions/inline-condition-model.d.ts.map +1 -0
- package/dist/browser/conditions/inline-condition-model.js +418 -0
- package/dist/browser/conditions/inline-condition-model.js.map +1 -0
- package/dist/browser/conditions/inline-condition-operators.d.ts +175 -0
- package/dist/browser/conditions/inline-condition-operators.d.ts.map +1 -0
- package/dist/browser/conditions/inline-condition-operators.js +132 -0
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -0
- package/dist/browser/conditions/inline-condition-values.d.ts +93 -0
- package/dist/browser/conditions/inline-condition-values.d.ts.map +1 -0
- package/dist/browser/conditions/inline-condition-values.js +159 -0
- package/dist/browser/conditions/inline-condition-values.js.map +1 -0
- package/dist/browser/conditions/types.d.ts +38 -0
- package/dist/browser/conditions/types.d.ts.map +1 -0
- package/dist/browser/conditions/types.js +24 -0
- package/dist/browser/conditions/types.js.map +1 -0
- package/dist/browser/data-model/conditions-wrapper.d.ts +19 -0
- package/dist/browser/data-model/conditions-wrapper.d.ts.map +1 -0
- package/dist/browser/data-model/conditions-wrapper.js +49 -0
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -0
- package/dist/browser/data-model/index.d.ts +4 -0
- package/dist/browser/data-model/index.d.ts.map +1 -0
- package/dist/browser/data-model/index.js +66 -0
- package/dist/browser/data-model/index.js.map +1 -0
- package/dist/browser/data-model/input-wrapper.d.ts +16 -0
- package/dist/browser/data-model/input-wrapper.d.ts.map +1 -0
- package/dist/browser/data-model/input-wrapper.js +49 -0
- package/dist/browser/data-model/input-wrapper.js.map +1 -0
- package/dist/browser/data-model/types.d.ts +153 -0
- package/dist/browser/data-model/types.d.ts.map +1 -0
- package/dist/browser/data-model/types.js +34 -0
- package/dist/browser/data-model/types.js.map +1 -0
- package/dist/browser/form/form-configuration.d.ts +8 -0
- package/dist/browser/form/form-configuration.d.ts.map +1 -0
- package/dist/browser/form/form-configuration.js +38 -0
- package/dist/browser/form/form-configuration.js.map +1 -0
- package/dist/browser/form/index.d.ts +2 -0
- package/dist/browser/form/index.d.ts.map +1 -0
- package/dist/browser/form/index.js +24 -0
- package/dist/browser/form/index.js.map +1 -0
- package/dist/browser/index.d.ts +12 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +138 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/migration/index.d.ts +2 -0
- package/dist/browser/migration/index.d.ts.map +1 -0
- package/dist/browser/migration/index.js +24 -0
- package/dist/browser/migration/index.js.map +1 -0
- package/dist/browser/migration/migration.0-2.d.ts +3 -0
- package/dist/browser/migration/migration.0-2.d.ts.map +1 -0
- package/dist/browser/migration/migration.0-2.js +65 -0
- package/dist/browser/migration/migration.0-2.js.map +1 -0
- package/dist/browser/migration/migration.1-2.d.ts +3 -0
- package/dist/browser/migration/migration.1-2.d.ts.map +1 -0
- package/dist/browser/migration/migration.1-2.js +108 -0
- package/dist/browser/migration/migration.1-2.js.map +1 -0
- package/dist/browser/migration/types.d.ts +2 -0
- package/dist/browser/migration/types.d.ts.map +1 -0
- package/dist/browser/migration/types.js +16 -0
- package/dist/browser/migration/types.js.map +1 -0
- package/dist/browser/migration/whichMigrations.d.ts +7 -0
- package/dist/browser/migration/whichMigrations.d.ts.map +1 -0
- package/dist/browser/migration/whichMigrations.js +38 -0
- package/dist/browser/migration/whichMigrations.js.map +1 -0
- package/dist/browser/schema/index.d.ts +2 -0
- package/dist/browser/schema/index.d.ts.map +1 -0
- package/dist/browser/schema/index.js +30 -0
- package/dist/browser/schema/index.js.map +1 -0
- package/dist/browser/schema/schema.d.ts +20 -0
- package/dist/browser/schema/schema.d.ts.map +1 -0
- package/dist/browser/schema/schema.js +255 -0
- package/dist/browser/schema/schema.js.map +1 -0
- package/dist/browser/utils/helpers.d.ts +9 -0
- package/dist/browser/utils/helpers.d.ts.map +1 -0
- package/dist/browser/utils/helpers.js +48 -0
- package/dist/browser/utils/helpers.js.map +1 -0
- package/dist/browser/utils/logger.d.ts +11 -0
- package/dist/browser/utils/logger.d.ts.map +1 -0
- package/dist/browser/utils/logger.js +46 -0
- package/dist/browser/utils/logger.js.map +1 -0
- package/dist/module/components/component-types.d.ts +3 -0
- package/dist/module/components/component-types.d.ts.map +1 -0
- package/dist/module/components/component-types.js +206 -0
- package/dist/module/components/component-types.js.map +1 -0
- package/dist/module/components/conditional-component-types.d.ts +3 -0
- package/dist/module/components/conditional-component-types.d.ts.map +1 -0
- package/dist/module/components/conditional-component-types.js +14 -0
- package/dist/module/components/conditional-component-types.js.map +1 -0
- package/dist/module/components/index.d.ts +4 -0
- package/dist/module/components/index.d.ts.map +1 -0
- package/dist/module/components/index.js +34 -0
- package/dist/module/components/index.js.map +1 -0
- package/dist/module/components/types.d.ts +244 -0
- package/dist/module/components/types.d.ts.map +1 -0
- package/dist/module/components/types.js +42 -0
- package/dist/module/components/types.js.map +1 -0
- package/dist/module/conditions/condition-abstract.d.ts +16 -0
- package/dist/module/conditions/condition-abstract.d.ts.map +1 -0
- package/dist/module/conditions/condition-abstract.js +45 -0
- package/dist/module/conditions/condition-abstract.js.map +1 -0
- package/dist/module/conditions/condition-field.d.ts +13 -0
- package/dist/module/conditions/condition-field.d.ts.map +1 -0
- package/dist/module/conditions/condition-field.js +26 -0
- package/dist/module/conditions/condition-field.js.map +1 -0
- package/dist/module/conditions/condition-group-def.d.ts +10 -0
- package/dist/module/conditions/condition-group-def.d.ts.map +1 -0
- package/dist/module/conditions/condition-group-def.js +26 -0
- package/dist/module/conditions/condition-group-def.js.map +1 -0
- package/dist/module/conditions/condition-group.d.ts +15 -0
- package/dist/module/conditions/condition-group.d.ts.map +1 -0
- package/dist/module/conditions/condition-group.js +47 -0
- package/dist/module/conditions/condition-group.js.map +1 -0
- package/dist/module/conditions/condition-model.d.ts +41 -0
- package/dist/module/conditions/condition-model.d.ts.map +1 -0
- package/dist/module/conditions/condition-model.js +199 -0
- package/dist/module/conditions/condition-model.js.map +1 -0
- package/dist/module/conditions/condition-operators.d.ts +248 -0
- package/dist/module/conditions/condition-operators.d.ts.map +1 -0
- package/dist/module/conditions/condition-operators.js +119 -0
- package/dist/module/conditions/condition-operators.js.map +1 -0
- package/dist/module/conditions/condition-ref.d.ts +12 -0
- package/dist/module/conditions/condition-ref.d.ts.map +1 -0
- package/dist/module/conditions/condition-ref.js +33 -0
- package/dist/module/conditions/condition-ref.js.map +1 -0
- package/dist/module/conditions/condition-value-abstract.d.ts +8 -0
- package/dist/module/conditions/condition-value-abstract.d.ts.map +1 -0
- package/dist/module/conditions/condition-value-abstract.js +24 -0
- package/dist/module/conditions/condition-value-abstract.js.map +1 -0
- package/dist/module/conditions/condition-value-registration.d.ts +10 -0
- package/dist/module/conditions/condition-value-registration.d.ts.map +1 -0
- package/dist/module/conditions/condition-value-registration.js +19 -0
- package/dist/module/conditions/condition-value-registration.js.map +1 -0
- package/dist/module/conditions/condition-values.d.ts +38 -0
- package/dist/module/conditions/condition-values.d.ts.map +1 -0
- package/dist/module/conditions/condition-values.js +106 -0
- package/dist/module/conditions/condition-values.js.map +1 -0
- package/dist/module/conditions/condition.d.ts +15 -0
- package/dist/module/conditions/condition.d.ts.map +1 -0
- package/dist/module/conditions/condition.js +40 -0
- package/dist/module/conditions/condition.js.map +1 -0
- package/dist/module/conditions/helpers.d.ts +3 -0
- package/dist/module/conditions/helpers.d.ts.map +1 -0
- package/dist/module/conditions/helpers.js +12 -0
- package/dist/module/conditions/helpers.js.map +1 -0
- package/dist/module/conditions/index.d.ts +11 -0
- package/dist/module/conditions/index.d.ts.map +1 -0
- package/dist/module/conditions/index.js +140 -0
- package/dist/module/conditions/index.js.map +1 -0
- package/dist/module/conditions/inline-condition-model.d.ts +86 -0
- package/dist/module/conditions/inline-condition-model.d.ts.map +1 -0
- package/dist/module/conditions/inline-condition-model.js +384 -0
- package/dist/module/conditions/inline-condition-model.js.map +1 -0
- package/dist/module/conditions/inline-condition-operators.d.ts +175 -0
- package/dist/module/conditions/inline-condition-operators.d.ts.map +1 -0
- package/dist/module/conditions/inline-condition-operators.js +119 -0
- package/dist/module/conditions/inline-condition-operators.js.map +1 -0
- package/dist/module/conditions/inline-condition-values.d.ts +93 -0
- package/dist/module/conditions/inline-condition-values.d.ts.map +1 -0
- package/dist/module/conditions/inline-condition-values.js +134 -0
- package/dist/module/conditions/inline-condition-values.js.map +1 -0
- package/dist/module/conditions/types.d.ts +38 -0
- package/dist/module/conditions/types.d.ts.map +1 -0
- package/dist/module/conditions/types.js +10 -0
- package/dist/module/conditions/types.js.map +1 -0
- package/dist/module/data-model/conditions-wrapper.d.ts +19 -0
- package/dist/module/data-model/conditions-wrapper.d.ts.map +1 -0
- package/dist/module/data-model/conditions-wrapper.js +30 -0
- package/dist/module/data-model/conditions-wrapper.js.map +1 -0
- package/dist/module/data-model/index.d.ts +4 -0
- package/dist/module/data-model/index.d.ts.map +1 -0
- package/dist/module/data-model/index.js +55 -0
- package/dist/module/data-model/index.js.map +1 -0
- package/dist/module/data-model/input-wrapper.d.ts +16 -0
- package/dist/module/data-model/input-wrapper.d.ts.map +1 -0
- package/dist/module/data-model/input-wrapper.js +25 -0
- package/dist/module/data-model/input-wrapper.js.map +1 -0
- package/dist/module/data-model/types.d.ts +153 -0
- package/dist/module/data-model/types.d.ts.map +1 -0
- package/dist/module/data-model/types.js +20 -0
- package/dist/module/data-model/types.js.map +1 -0
- package/dist/module/form/form-configuration.d.ts +8 -0
- package/dist/module/form/form-configuration.d.ts.map +1 -0
- package/dist/module/form/form-configuration.js +17 -0
- package/dist/module/form/form-configuration.js.map +1 -0
- package/dist/module/form/index.d.ts +2 -0
- package/dist/module/form/index.d.ts.map +1 -0
- package/dist/module/form/index.js +11 -0
- package/dist/module/form/index.js.map +1 -0
- package/dist/module/index.d.ts +12 -0
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +135 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/migration/index.d.ts +2 -0
- package/dist/module/migration/index.d.ts.map +1 -0
- package/dist/module/migration/index.js +11 -0
- package/dist/module/migration/index.js.map +1 -0
- package/dist/module/migration/migration.0-2.d.ts +3 -0
- package/dist/module/migration/migration.0-2.d.ts.map +1 -0
- package/dist/module/migration/migration.0-2.js +42 -0
- package/dist/module/migration/migration.0-2.js.map +1 -0
- package/dist/module/migration/migration.1-2.d.ts +3 -0
- package/dist/module/migration/migration.1-2.d.ts.map +1 -0
- package/dist/module/migration/migration.1-2.js +90 -0
- package/dist/module/migration/migration.1-2.js.map +1 -0
- package/dist/module/migration/types.d.ts +2 -0
- package/dist/module/migration/types.d.ts.map +1 -0
- package/dist/module/migration/types.js +1 -0
- package/dist/module/migration/types.js.map +1 -0
- package/dist/module/migration/whichMigrations.d.ts +7 -0
- package/dist/module/migration/whichMigrations.d.ts.map +1 -0
- package/dist/module/migration/whichMigrations.js +26 -0
- package/dist/module/migration/whichMigrations.js.map +1 -0
- package/dist/module/schema/index.d.ts +2 -0
- package/dist/module/schema/index.d.ts.map +1 -0
- package/dist/module/schema/index.js +17 -0
- package/dist/module/schema/index.js.map +1 -0
- package/dist/module/schema/schema.d.ts +20 -0
- package/dist/module/schema/schema.d.ts.map +1 -0
- package/dist/module/schema/schema.js +239 -0
- package/dist/module/schema/schema.js.map +1 -0
- package/dist/module/utils/helpers.d.ts +9 -0
- package/dist/module/utils/helpers.d.ts.map +1 -0
- package/dist/module/utils/helpers.js +35 -0
- package/dist/module/utils/helpers.js.map +1 -0
- package/dist/module/utils/logger.d.ts +11 -0
- package/dist/module/utils/logger.d.ts.map +1 -0
- package/dist/module/utils/logger.js +27 -0
- package/dist/module/utils/logger.js.map +1 -0
- package/package.json +35 -0
- package/src/components/component-types.ts +229 -0
- package/src/components/conditional-component-types.ts +14 -0
- package/src/components/index.ts +3 -0
- package/src/components/types.ts +362 -0
- package/src/conditions/condition-abstract.ts +59 -0
- package/src/conditions/condition-field.ts +29 -0
- package/src/conditions/condition-group-def.ts +29 -0
- package/src/conditions/condition-group.ts +61 -0
- package/src/conditions/condition-model.ts +314 -0
- package/src/conditions/condition-operators.ts +176 -0
- package/src/conditions/condition-ref.ts +47 -0
- package/src/conditions/condition-value-abstract.ts +31 -0
- package/src/conditions/condition-value-registration.ts +18 -0
- package/src/conditions/condition-values.ts +146 -0
- package/src/conditions/condition.ts +64 -0
- package/src/conditions/helpers.ts +7 -0
- package/src/conditions/index.ts +27 -0
- package/src/conditions/inline-condition-model.ts +550 -0
- package/src/conditions/inline-condition-operators.ts +166 -0
- package/src/conditions/inline-condition-values.ts +153 -0
- package/src/conditions/types.ts +30 -0
- package/src/data-model/conditions-wrapper.ts +42 -0
- package/src/data-model/index.ts +3 -0
- package/src/data-model/input-wrapper.ts +40 -0
- package/src/data-model/types.ts +179 -0
- package/src/form/form-configuration.ts +21 -0
- package/src/form/index.ts +1 -0
- package/src/index.ts +11 -0
- package/src/migration/index.ts +1 -0
- package/src/migration/migration.0-2.ts +29 -0
- package/src/migration/migration.1-2.ts +105 -0
- package/src/migration/types.ts +1 -0
- package/src/migration/whichMigrations.ts +23 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/schema.ts +300 -0
- package/src/utils/helpers.ts +37 -0
- package/src/utils/logger.ts +29 -0
@@ -0,0 +1,362 @@
|
|
1
|
+
export enum ComponentTypeEnum {
|
2
|
+
TextField = 'TextField',
|
3
|
+
MultilineTextField = 'MultilineTextField',
|
4
|
+
YesNoField = 'YesNoField',
|
5
|
+
DateField = 'DateField',
|
6
|
+
TimeField = 'TimeField',
|
7
|
+
DateTimeField = 'DateTimeField',
|
8
|
+
DatePartsField = 'DatePartsField',
|
9
|
+
MonthYearField = 'MonthYearField',
|
10
|
+
DateTimePartsField = 'DateTimePartsField',
|
11
|
+
SelectField = 'SelectField',
|
12
|
+
AutocompleteField = 'AutocompleteField',
|
13
|
+
RadiosField = 'RadiosField',
|
14
|
+
CheckboxesField = 'CheckboxesField',
|
15
|
+
NumberField = 'NumberField',
|
16
|
+
UkAddressField = 'UkAddressField',
|
17
|
+
TelephoneNumberField = 'TelephoneNumberField',
|
18
|
+
EmailAddressField = 'EmailAddressField',
|
19
|
+
FileUploadField = 'FileUploadField',
|
20
|
+
Para = 'Para',
|
21
|
+
Html = 'Html',
|
22
|
+
InsetText = 'InsetText',
|
23
|
+
Details = 'Details',
|
24
|
+
FlashCard = 'FlashCard',
|
25
|
+
List = 'List'
|
26
|
+
}
|
27
|
+
|
28
|
+
export type ComponentType =
|
29
|
+
| 'TextField'
|
30
|
+
| 'MultilineTextField'
|
31
|
+
| 'YesNoField'
|
32
|
+
| 'DateField'
|
33
|
+
| 'TimeField'
|
34
|
+
| 'DateTimeField'
|
35
|
+
| 'MonthYearField'
|
36
|
+
| 'DatePartsField'
|
37
|
+
| 'DateTimePartsField'
|
38
|
+
| 'SelectField'
|
39
|
+
| 'AutocompleteField'
|
40
|
+
| 'RadiosField'
|
41
|
+
| 'CheckboxesField'
|
42
|
+
| 'NumberField'
|
43
|
+
| 'UkAddressField'
|
44
|
+
| 'TelephoneNumberField'
|
45
|
+
| 'EmailAddressField'
|
46
|
+
| 'FileUploadField'
|
47
|
+
| 'Para'
|
48
|
+
| 'Html'
|
49
|
+
| 'InsetText'
|
50
|
+
| 'Details'
|
51
|
+
| 'FlashCard'
|
52
|
+
| 'List'
|
53
|
+
| 'WebsiteField'
|
54
|
+
|
55
|
+
export type ComponentSubType = 'field' | 'content'
|
56
|
+
|
57
|
+
export type ConditionalComponent = {
|
58
|
+
name: 'TextField' | 'NumberField'
|
59
|
+
title: string
|
60
|
+
subType: 'field'
|
61
|
+
}
|
62
|
+
|
63
|
+
export type ContentOptions = {
|
64
|
+
condition?: string
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists
|
69
|
+
*/
|
70
|
+
interface TextFieldBase {
|
71
|
+
subType?: 'field'
|
72
|
+
type: string
|
73
|
+
name: string
|
74
|
+
title: string
|
75
|
+
hint?: string
|
76
|
+
options: {
|
77
|
+
hideTitle?: boolean
|
78
|
+
required?: boolean
|
79
|
+
optionalText?: boolean
|
80
|
+
classes?: string
|
81
|
+
allow?: string
|
82
|
+
autocomplete?: string
|
83
|
+
exposeToContext?: boolean
|
84
|
+
}
|
85
|
+
schema: {
|
86
|
+
max?: number
|
87
|
+
min?: number
|
88
|
+
length?: number
|
89
|
+
regex?: string
|
90
|
+
error?: any // TODO: in same cases this is a function e.g. addressLine1 in ukaddress
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
interface NumberFieldBase {
|
95
|
+
subType?: 'field'
|
96
|
+
type: string
|
97
|
+
name: string
|
98
|
+
title: string
|
99
|
+
hint: string
|
100
|
+
options: {
|
101
|
+
prefix?: string
|
102
|
+
suffix?: string
|
103
|
+
exposeToContext?: boolean
|
104
|
+
}
|
105
|
+
schema: {
|
106
|
+
min?: number
|
107
|
+
max?: number
|
108
|
+
precision?: number
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
interface ListFieldBase {
|
113
|
+
subType?: 'listField' | 'content'
|
114
|
+
type: string
|
115
|
+
name: string
|
116
|
+
title: string
|
117
|
+
options: {
|
118
|
+
type?: string
|
119
|
+
hideTitle?: boolean
|
120
|
+
required?: boolean
|
121
|
+
optionalText?: boolean
|
122
|
+
classes?: string
|
123
|
+
bold?: boolean
|
124
|
+
exposeToContext?: boolean
|
125
|
+
allowPrePopulation?: boolean
|
126
|
+
}
|
127
|
+
list: string
|
128
|
+
schema: {}
|
129
|
+
}
|
130
|
+
|
131
|
+
interface ContentFieldBase {
|
132
|
+
subType?: 'content'
|
133
|
+
type: string
|
134
|
+
name: string
|
135
|
+
title: string
|
136
|
+
content: string
|
137
|
+
options: ContentOptions
|
138
|
+
schema: {}
|
139
|
+
}
|
140
|
+
|
141
|
+
interface DateFieldBase {
|
142
|
+
subType?: 'field'
|
143
|
+
type: string
|
144
|
+
name: string
|
145
|
+
title: string
|
146
|
+
hint: string
|
147
|
+
options: {
|
148
|
+
hideTitle?: boolean
|
149
|
+
required?: boolean
|
150
|
+
optionalText?: boolean
|
151
|
+
maxDaysInFuture?: number
|
152
|
+
maxDaysInPast?: number
|
153
|
+
exposeToContext?: boolean
|
154
|
+
}
|
155
|
+
schema: {}
|
156
|
+
}
|
157
|
+
|
158
|
+
// Text Fields
|
159
|
+
export interface TextFieldComponent extends TextFieldBase {
|
160
|
+
type: 'TextField'
|
161
|
+
options: TextFieldBase['options'] & {
|
162
|
+
customValidationMessage?: string
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
export interface EmailAddressFieldComponent extends TextFieldBase {
|
167
|
+
type: 'EmailAddressField'
|
168
|
+
}
|
169
|
+
|
170
|
+
export interface NumberFieldComponent extends NumberFieldBase {
|
171
|
+
type: 'NumberField'
|
172
|
+
}
|
173
|
+
|
174
|
+
export interface WebsiteFieldComponent extends TextFieldBase {
|
175
|
+
type: 'WebsiteField'
|
176
|
+
options: TextFieldBase['options'] & {
|
177
|
+
customValidationMessage?: string
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
export interface MultilineTextFieldComponent {
|
182
|
+
type: 'MultilineTextField'
|
183
|
+
}
|
184
|
+
|
185
|
+
export interface TelephoneNumberFieldComponent extends TextFieldBase {
|
186
|
+
type: 'TelephoneNumberField'
|
187
|
+
options: TextFieldBase['options'] & {
|
188
|
+
customValidationMessage?: string
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
export interface YesNoFieldComponent extends TextFieldBase {
|
193
|
+
type: 'YesNoField'
|
194
|
+
}
|
195
|
+
|
196
|
+
export interface MultilineTextFieldComponent extends TextFieldBase {
|
197
|
+
type: 'MultilineTextField'
|
198
|
+
options: TextFieldBase['options'] & {
|
199
|
+
customValidationMessage?: string
|
200
|
+
rows?: number
|
201
|
+
maxWords?: number
|
202
|
+
}
|
203
|
+
schema: {
|
204
|
+
max?: number
|
205
|
+
min?: number
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
export interface FileUploadFieldComponent {
|
210
|
+
subType?: 'field'
|
211
|
+
type: 'FileUploadField'
|
212
|
+
name: string
|
213
|
+
title: string
|
214
|
+
hint: string
|
215
|
+
options: {
|
216
|
+
required?: boolean
|
217
|
+
hideTitle?: boolean
|
218
|
+
multiple?: boolean
|
219
|
+
classes?: string
|
220
|
+
exposeToContext?: boolean
|
221
|
+
imageQualityPlayback?: boolean
|
222
|
+
}
|
223
|
+
schema: {}
|
224
|
+
}
|
225
|
+
|
226
|
+
export interface UkAddressFieldComponent extends TextFieldBase {
|
227
|
+
type: 'UkAddressField'
|
228
|
+
}
|
229
|
+
|
230
|
+
// Date Fields
|
231
|
+
export interface DateFieldComponent extends DateFieldBase {
|
232
|
+
type: 'DateField'
|
233
|
+
}
|
234
|
+
|
235
|
+
export interface DateTimeFieldComponent extends DateFieldBase {
|
236
|
+
type: 'DateTimeField'
|
237
|
+
}
|
238
|
+
|
239
|
+
export interface DatePartsFieldFieldComponent extends DateFieldBase {
|
240
|
+
type: 'DatePartsField'
|
241
|
+
}
|
242
|
+
|
243
|
+
export interface MonthYearFieldComponent extends DateFieldBase {
|
244
|
+
type: 'MonthYearField'
|
245
|
+
}
|
246
|
+
|
247
|
+
export interface DateTimePartsFieldComponent extends DateFieldBase {
|
248
|
+
type: 'DateTimePartsField'
|
249
|
+
}
|
250
|
+
|
251
|
+
export interface TimeFieldComponent extends DateFieldBase {
|
252
|
+
type: 'TimeField'
|
253
|
+
}
|
254
|
+
|
255
|
+
// Content Fields
|
256
|
+
export interface ParaComponent extends ContentFieldBase {
|
257
|
+
type: 'Para'
|
258
|
+
}
|
259
|
+
|
260
|
+
export interface DetailsComponent extends ContentFieldBase {
|
261
|
+
type: 'Details'
|
262
|
+
}
|
263
|
+
|
264
|
+
export interface HtmlComponent extends ContentFieldBase {
|
265
|
+
type: 'Html'
|
266
|
+
}
|
267
|
+
|
268
|
+
export interface InsetTextComponent extends ContentFieldBase {
|
269
|
+
type: 'InsetText'
|
270
|
+
}
|
271
|
+
|
272
|
+
// List Fields
|
273
|
+
export interface ListComponent extends ListFieldBase {
|
274
|
+
type: 'List'
|
275
|
+
}
|
276
|
+
|
277
|
+
export interface AutocompleteFieldComponent extends ListFieldBase {
|
278
|
+
type: 'AutocompleteField'
|
279
|
+
subType?: 'listField'
|
280
|
+
}
|
281
|
+
|
282
|
+
export interface CheckboxesFieldComponent extends ListFieldBase {
|
283
|
+
type: 'CheckboxesField'
|
284
|
+
subType?: 'listField'
|
285
|
+
}
|
286
|
+
|
287
|
+
export interface FlashCardComponent extends ListFieldBase {
|
288
|
+
type: 'FlashCard'
|
289
|
+
}
|
290
|
+
|
291
|
+
export interface RadiosFieldComponent extends ListFieldBase {
|
292
|
+
type: 'RadiosField'
|
293
|
+
subType?: 'listField'
|
294
|
+
}
|
295
|
+
|
296
|
+
export interface SelectFieldComponent extends ListFieldBase {
|
297
|
+
type: 'SelectField'
|
298
|
+
options: ListFieldBase['options'] & { autocomplete?: string }
|
299
|
+
subType?: 'listField'
|
300
|
+
}
|
301
|
+
|
302
|
+
export type ComponentDef =
|
303
|
+
| InsetTextComponent
|
304
|
+
| AutocompleteFieldComponent
|
305
|
+
| CheckboxesFieldComponent
|
306
|
+
| DateFieldComponent
|
307
|
+
| DatePartsFieldFieldComponent
|
308
|
+
| MonthYearFieldComponent
|
309
|
+
| DateTimeFieldComponent
|
310
|
+
| DateTimePartsFieldComponent
|
311
|
+
| DetailsComponent
|
312
|
+
| EmailAddressFieldComponent
|
313
|
+
| FileUploadFieldComponent
|
314
|
+
| FlashCardComponent
|
315
|
+
| HtmlComponent
|
316
|
+
| ListComponent
|
317
|
+
| MultilineTextFieldComponent
|
318
|
+
| NumberFieldComponent
|
319
|
+
| ParaComponent
|
320
|
+
| RadiosFieldComponent
|
321
|
+
| SelectFieldComponent
|
322
|
+
| TelephoneNumberFieldComponent
|
323
|
+
| TextFieldComponent
|
324
|
+
| TimeFieldComponent
|
325
|
+
| UkAddressFieldComponent
|
326
|
+
| YesNoFieldComponent
|
327
|
+
| WebsiteFieldComponent
|
328
|
+
|
329
|
+
// Components that render inputs.
|
330
|
+
export type InputFieldsComponentsDef =
|
331
|
+
| TextFieldComponent
|
332
|
+
| EmailAddressFieldComponent
|
333
|
+
| NumberFieldComponent
|
334
|
+
| MultilineTextFieldComponent
|
335
|
+
| TelephoneNumberFieldComponent
|
336
|
+
| YesNoFieldComponent
|
337
|
+
| FileUploadFieldComponent
|
338
|
+
| DateFieldComponent
|
339
|
+
| DateTimeFieldComponent
|
340
|
+
| DateTimePartsFieldComponent
|
341
|
+
| MonthYearFieldComponent
|
342
|
+
| TimeFieldComponent
|
343
|
+
| UkAddressFieldComponent
|
344
|
+
| WebsiteFieldComponent
|
345
|
+
|
346
|
+
// Components that render content.
|
347
|
+
export type ContentComponentsDef =
|
348
|
+
| ParaComponent
|
349
|
+
| DetailsComponent
|
350
|
+
| HtmlComponent
|
351
|
+
| InsetTextComponent
|
352
|
+
| ListComponent
|
353
|
+
| FlashCardComponent
|
354
|
+
|
355
|
+
// Components that render Lists
|
356
|
+
export type ListComponentsDef =
|
357
|
+
| ListComponent
|
358
|
+
| AutocompleteFieldComponent
|
359
|
+
| CheckboxesFieldComponent
|
360
|
+
| FlashCardComponent
|
361
|
+
| RadiosFieldComponent
|
362
|
+
| SelectFieldComponent
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { Coordinator } from './types'
|
2
|
+
|
3
|
+
export class ConditionAbstract {
|
4
|
+
coordinator: Coordinator | undefined
|
5
|
+
|
6
|
+
constructor(coordinator: Coordinator | undefined) {
|
7
|
+
if (coordinator && !Object.values(Coordinator).includes(coordinator)) {
|
8
|
+
throw Error(`coordinator ${coordinator} is not a valid coordinator`)
|
9
|
+
}
|
10
|
+
|
11
|
+
this.coordinator = coordinator
|
12
|
+
}
|
13
|
+
|
14
|
+
coordinatorString() {
|
15
|
+
return this.coordinator ? `${this.coordinator} ` : ''
|
16
|
+
}
|
17
|
+
|
18
|
+
getCoordinator() {
|
19
|
+
return this.coordinator
|
20
|
+
}
|
21
|
+
|
22
|
+
setCoordinator(coordinator: Coordinator | undefined) {
|
23
|
+
this.coordinator = coordinator
|
24
|
+
}
|
25
|
+
|
26
|
+
isGroup() {
|
27
|
+
return false
|
28
|
+
}
|
29
|
+
|
30
|
+
getGroupedConditions() {
|
31
|
+
return [this]
|
32
|
+
}
|
33
|
+
|
34
|
+
_asFirstCondition() {
|
35
|
+
delete this.coordinator
|
36
|
+
}
|
37
|
+
|
38
|
+
asFirstCondition() {
|
39
|
+
throw Error(
|
40
|
+
'Unsupported Operation. Method asFirstCondition have not been implemented'
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
clone() {
|
45
|
+
throw Error('Unsupported Operation. Method clone have not been implemented')
|
46
|
+
}
|
47
|
+
|
48
|
+
conditionString() {
|
49
|
+
throw Error(
|
50
|
+
'Unsupported Operation. Method conditionString have not been implemented'
|
51
|
+
)
|
52
|
+
}
|
53
|
+
|
54
|
+
conditionExpression() {
|
55
|
+
throw Error(
|
56
|
+
'Unsupported Operation. Method conditionExpression have not been implemented'
|
57
|
+
)
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { ComponentTypes, ComponentType } from '../components'
|
2
|
+
|
3
|
+
export class ConditionField {
|
4
|
+
name: string
|
5
|
+
type: ComponentType
|
6
|
+
display: string
|
7
|
+
|
8
|
+
constructor(name: string, type: ComponentType, display: string) {
|
9
|
+
if (!name || typeof name !== 'string') {
|
10
|
+
throw Error(`name ${name} is not valid`)
|
11
|
+
}
|
12
|
+
|
13
|
+
if (!ComponentTypes.find((componentType) => componentType.type === type)) {
|
14
|
+
throw Error(`type ${type} is not valid`)
|
15
|
+
}
|
16
|
+
|
17
|
+
if (!display || typeof display !== 'string') {
|
18
|
+
throw Error(`display ${display} is not valid`)
|
19
|
+
}
|
20
|
+
|
21
|
+
this.name = name
|
22
|
+
this.type = type
|
23
|
+
this.display = display
|
24
|
+
}
|
25
|
+
|
26
|
+
static from(obj: { name: string; type: ComponentType; display: string }) {
|
27
|
+
return new ConditionField(obj.name, obj.type, obj.display)
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { ConditionsArray } from './types'
|
2
|
+
|
3
|
+
export class ConditionGroupDef {
|
4
|
+
first: number
|
5
|
+
last: number
|
6
|
+
|
7
|
+
constructor(first: number, last: number) {
|
8
|
+
if (typeof first !== 'number' || typeof last !== 'number') {
|
9
|
+
throw Error(`Cannot construct a group from ${first} and ${last}`)
|
10
|
+
} else if (first >= last) {
|
11
|
+
throw Error(`Last (${last}) must be greater than first (${first})`)
|
12
|
+
}
|
13
|
+
|
14
|
+
this.first = first
|
15
|
+
this.last = last
|
16
|
+
}
|
17
|
+
|
18
|
+
contains(index: number) {
|
19
|
+
return this.first <= index && this.last >= index
|
20
|
+
}
|
21
|
+
|
22
|
+
startsWith(index: number) {
|
23
|
+
return this.first === index
|
24
|
+
}
|
25
|
+
|
26
|
+
applyTo(conditions: ConditionsArray) {
|
27
|
+
return [...conditions].splice(this.first, this.last - this.first + 1)
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { toPresentationString, toExpression } from './helpers'
|
2
|
+
import { Coordinator, ConditionsArray } from './types'
|
3
|
+
|
4
|
+
export class ConditionGroup {
|
5
|
+
conditions: ConditionsArray
|
6
|
+
|
7
|
+
constructor(conditions: ConditionsArray = []) {
|
8
|
+
if (!Array.isArray(conditions) || conditions.length < 2) {
|
9
|
+
throw Error('Cannot construct a condition group from a single condition')
|
10
|
+
}
|
11
|
+
|
12
|
+
this.conditions = conditions
|
13
|
+
}
|
14
|
+
|
15
|
+
coordinatorString() {
|
16
|
+
return this.conditions[0].coordinatorString()
|
17
|
+
}
|
18
|
+
|
19
|
+
conditionString() {
|
20
|
+
const copy = [...this.conditions]
|
21
|
+
copy.splice(0, 1)
|
22
|
+
return `(${this.conditions[0].conditionString()} ${copy
|
23
|
+
.map((condition) => toPresentationString(condition))
|
24
|
+
.join(' ')})`
|
25
|
+
}
|
26
|
+
|
27
|
+
conditionExpression() {
|
28
|
+
const copy = [...this.conditions]
|
29
|
+
copy.splice(0, 1)
|
30
|
+
return `(${this.conditions[0].conditionExpression()} ${copy
|
31
|
+
.map((condition) => toExpression(condition))
|
32
|
+
.join(' ')})`
|
33
|
+
}
|
34
|
+
|
35
|
+
asFirstCondition() {
|
36
|
+
this.conditions[0].asFirstCondition()
|
37
|
+
return this
|
38
|
+
}
|
39
|
+
|
40
|
+
getCoordinator() {
|
41
|
+
return this.conditions[0].getCoordinator()
|
42
|
+
}
|
43
|
+
|
44
|
+
setCoordinator(coordinator: Coordinator | undefined) {
|
45
|
+
this.conditions[0].setCoordinator(coordinator)
|
46
|
+
}
|
47
|
+
|
48
|
+
isGroup() {
|
49
|
+
return true
|
50
|
+
}
|
51
|
+
|
52
|
+
getGroupedConditions() {
|
53
|
+
return this.conditions.map((condition) => condition.clone())
|
54
|
+
}
|
55
|
+
|
56
|
+
clone() {
|
57
|
+
return new ConditionGroup(
|
58
|
+
this.conditions.map((condition) => condition.clone())
|
59
|
+
)
|
60
|
+
}
|
61
|
+
}
|