@defra/forms-model 3.0.167 → 3.0.169

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 (60) hide show
  1. package/dist/module/components/component-types.js +47 -46
  2. package/dist/module/components/component-types.js.map +1 -1
  3. package/dist/module/components/enums.js +31 -24
  4. package/dist/module/components/enums.js.map +1 -1
  5. package/dist/module/components/index.js +1 -2
  6. package/dist/module/components/index.js.map +1 -1
  7. package/dist/module/components/types.js.map +1 -1
  8. package/dist/module/conditions/condition-field.js.map +1 -1
  9. package/dist/module/conditions/condition-operators.js +12 -11
  10. package/dist/module/conditions/condition-operators.js.map +1 -1
  11. package/dist/module/conditions/enums.js +5 -0
  12. package/dist/module/conditions/enums.js.map +1 -1
  13. package/dist/module/conditions/index.js +1 -1
  14. package/dist/module/conditions/index.js.map +1 -1
  15. package/dist/module/form/form-definition/index.js +10 -4
  16. package/dist/module/form/form-definition/index.js.map +1 -1
  17. package/dist/module/form/form-definition/types.js.map +1 -1
  18. package/dist/module/index.js +0 -1
  19. package/dist/module/index.js.map +1 -1
  20. package/dist/types/components/component-types.d.ts.map +1 -1
  21. package/dist/types/components/enums.d.ts +8 -2
  22. package/dist/types/components/enums.d.ts.map +1 -1
  23. package/dist/types/components/index.d.ts +1 -2
  24. package/dist/types/components/index.d.ts.map +1 -1
  25. package/dist/types/components/types.d.ts +46 -47
  26. package/dist/types/components/types.d.ts.map +1 -1
  27. package/dist/types/conditions/condition-field.d.ts +1 -1
  28. package/dist/types/conditions/condition-operators.d.ts +2 -1
  29. package/dist/types/conditions/condition-operators.d.ts.map +1 -1
  30. package/dist/types/conditions/enums.d.ts +4 -0
  31. package/dist/types/conditions/enums.d.ts.map +1 -1
  32. package/dist/types/conditions/index.d.ts +1 -1
  33. package/dist/types/conditions/index.d.ts.map +1 -1
  34. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  35. package/dist/types/form/form-definition/types.d.ts +1 -0
  36. package/dist/types/form/form-definition/types.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +0 -1
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/components/component-types.ts +47 -46
  41. package/src/components/enums.ts +9 -2
  42. package/src/components/index.ts +1 -2
  43. package/src/components/types.ts +68 -71
  44. package/src/conditions/condition-field.ts +1 -1
  45. package/src/conditions/condition-operators.ts +19 -15
  46. package/src/conditions/enums.ts +5 -0
  47. package/src/conditions/index.ts +1 -1
  48. package/src/form/form-definition/index.ts +25 -12
  49. package/src/form/form-definition/types.ts +1 -0
  50. package/src/index.ts +0 -1
  51. package/dist/module/components/conditional-component-types.js +0 -10
  52. package/dist/module/components/conditional-component-types.js.map +0 -1
  53. package/dist/module/form/form-configuration/index.js +0 -16
  54. package/dist/module/form/form-configuration/index.js.map +0 -1
  55. package/dist/types/components/conditional-component-types.d.ts +0 -3
  56. package/dist/types/components/conditional-component-types.d.ts.map +0 -1
  57. package/dist/types/form/form-configuration/index.d.ts +0 -8
  58. package/dist/types/form/form-configuration/index.d.ts.map +0 -1
  59. package/src/components/conditional-component-types.ts +0 -14
  60. package/src/form/form-configuration/index.ts +0 -21
@@ -1,209 +1,210 @@
1
+ import { ComponentSubType, ComponentType } from '~/src/components/enums.js'
1
2
  import { type ComponentDef } from '~/src/components/types.js'
2
3
 
3
4
  export const ComponentTypes: ComponentDef[] = [
4
5
  {
5
6
  name: 'TextField',
6
- type: 'TextField',
7
+ type: ComponentType.TextField,
7
8
  title: 'Text field',
8
- subType: 'field',
9
+ subType: ComponentSubType.Field,
9
10
  hint: '',
10
11
  options: {},
11
12
  schema: {}
12
13
  },
13
14
  {
14
15
  name: 'MultilineTextField',
15
- type: 'MultilineTextField',
16
+ type: ComponentType.MultilineTextField,
16
17
  title: 'Multiline text field',
17
- subType: 'field',
18
+ subType: ComponentSubType.Field,
18
19
  hint: '',
19
20
  options: {},
20
21
  schema: {}
21
22
  },
22
23
  {
23
24
  name: 'YesNoField',
24
- type: 'YesNoField',
25
+ type: ComponentType.YesNoField,
25
26
  title: 'Yes/No field',
26
- subType: 'field',
27
+ subType: ComponentSubType.Field,
27
28
  hint: '',
28
29
  options: {},
29
30
  schema: {}
30
31
  },
31
32
  {
32
33
  name: 'DateField',
33
- type: 'DateField',
34
+ type: ComponentType.DateField,
34
35
  title: 'Date field',
35
- subType: 'field',
36
+ subType: ComponentSubType.Field,
36
37
  hint: '',
37
38
  options: {},
38
39
  schema: {}
39
40
  },
40
41
  {
41
42
  name: 'TimeField',
42
- type: 'TimeField',
43
+ type: ComponentType.TimeField,
43
44
  title: 'Time field',
44
- subType: 'field',
45
+ subType: ComponentSubType.Field,
45
46
  hint: '',
46
47
  options: {},
47
48
  schema: {}
48
49
  },
49
50
  {
50
51
  name: 'DateTimeField',
51
- type: 'DateTimeField',
52
+ type: ComponentType.DateTimeField,
52
53
  title: 'Date time field',
53
- subType: 'field',
54
+ subType: ComponentSubType.Field,
54
55
  hint: '',
55
56
  options: {},
56
57
  schema: {}
57
58
  },
58
59
  {
59
60
  name: 'DatePartsField',
60
- type: 'DatePartsField',
61
+ type: ComponentType.DatePartsField,
61
62
  title: 'Date parts field',
62
- subType: 'field',
63
+ subType: ComponentSubType.Field,
63
64
  hint: '',
64
65
  options: {},
65
66
  schema: {}
66
67
  },
67
68
  {
68
69
  name: 'DateTimePartsField',
69
- type: 'DateTimePartsField',
70
+ type: ComponentType.DateTimePartsField,
70
71
  title: 'Date time parts field',
71
- subType: 'field',
72
+ subType: ComponentSubType.Field,
72
73
  hint: '',
73
74
  options: {},
74
75
  schema: {}
75
76
  },
76
77
  {
77
78
  name: 'MonthYearField',
78
- type: 'MonthYearField',
79
+ type: ComponentType.MonthYearField,
79
80
  title: 'Month year field',
80
- subType: 'field',
81
+ subType: ComponentSubType.Field,
81
82
  hint: '',
82
83
  options: {},
83
84
  schema: {}
84
85
  },
85
86
  {
86
87
  name: 'SelectField',
87
- type: 'SelectField',
88
+ type: ComponentType.SelectField,
88
89
  title: 'Select field',
89
- subType: 'listField',
90
+ subType: ComponentSubType.ListField,
90
91
  options: {},
91
92
  schema: {},
92
93
  list: ''
93
94
  },
94
95
  {
95
96
  name: 'AutocompleteField',
96
- type: 'AutocompleteField',
97
+ type: ComponentType.AutocompleteField,
97
98
  title: 'Autocomplete field',
98
- subType: 'listField',
99
+ subType: ComponentSubType.ListField,
99
100
  options: {},
100
101
  schema: {},
101
102
  list: ''
102
103
  },
103
104
  {
104
105
  name: 'RadiosField',
105
- type: 'RadiosField',
106
+ type: ComponentType.RadiosField,
106
107
  title: 'Radios field',
107
- subType: 'listField',
108
+ subType: ComponentSubType.ListField,
108
109
  options: {},
109
110
  schema: {},
110
111
  list: ''
111
112
  },
112
113
  {
113
114
  name: 'CheckboxesField',
114
- type: 'CheckboxesField',
115
+ type: ComponentType.CheckboxesField,
115
116
  title: 'Checkboxes field',
116
- subType: 'listField',
117
+ subType: ComponentSubType.ListField,
117
118
  options: {},
118
119
  schema: {},
119
120
  list: ''
120
121
  },
121
122
  {
122
123
  name: 'NumberField',
123
- type: 'NumberField',
124
+ type: ComponentType.NumberField,
124
125
  title: 'Number field',
125
- subType: 'field',
126
+ subType: ComponentSubType.Field,
126
127
  hint: '',
127
128
  options: {},
128
129
  schema: {}
129
130
  },
130
131
  {
131
132
  name: 'UkAddressField',
132
- type: 'UkAddressField',
133
+ type: ComponentType.UkAddressField,
133
134
  title: 'UK address field',
134
- subType: 'field',
135
+ subType: ComponentSubType.Field,
135
136
  hint: '',
136
137
  options: {},
137
138
  schema: {}
138
139
  },
139
140
  {
140
141
  name: 'TelephoneNumberField',
141
- type: 'TelephoneNumberField',
142
+ type: ComponentType.TelephoneNumberField,
142
143
  title: 'Telephone number field',
143
- subType: 'field',
144
+ subType: ComponentSubType.Field,
144
145
  hint: '',
145
146
  options: {},
146
147
  schema: {}
147
148
  },
148
149
  {
149
150
  name: 'EmailAddressField',
150
- type: 'EmailAddressField',
151
+ type: ComponentType.EmailAddressField,
151
152
  title: 'Email address field',
152
- subType: 'field',
153
+ subType: ComponentSubType.Field,
153
154
  hint: '',
154
155
  options: {},
155
156
  schema: {}
156
157
  },
157
158
  {
158
159
  name: 'FileUploadField',
159
- type: 'FileUploadField',
160
+ type: ComponentType.FileUploadField,
160
161
  title: 'File upload field',
161
- subType: 'field',
162
+ subType: ComponentSubType.Field,
162
163
  hint: '',
163
164
  options: {},
164
165
  schema: {}
165
166
  },
166
167
  {
167
168
  name: 'Html',
168
- type: 'Html',
169
+ type: ComponentType.Html,
169
170
  title: 'Html',
170
- subType: 'content',
171
+ subType: ComponentSubType.Content,
171
172
  content: '',
172
173
  options: {},
173
174
  schema: {}
174
175
  },
175
176
  {
176
177
  name: 'InsetText',
177
- type: 'InsetText',
178
+ type: ComponentType.InsetText,
178
179
  title: 'Inset text',
179
- subType: 'content',
180
+ subType: ComponentSubType.Content,
180
181
  content: '',
181
182
  options: {},
182
183
  schema: {}
183
184
  },
184
185
  {
185
186
  name: 'Details',
186
- type: 'Details',
187
+ type: ComponentType.Details,
187
188
  title: 'Details',
188
- subType: 'content',
189
+ subType: ComponentSubType.Content,
189
190
  content: '',
190
191
  options: {},
191
192
  schema: {}
192
193
  },
193
194
  {
194
195
  name: 'List',
195
- type: 'List',
196
+ type: ComponentType.List,
196
197
  title: 'List',
197
- subType: 'content',
198
+ subType: ComponentSubType.Content,
198
199
  options: {},
199
200
  schema: {},
200
201
  list: ''
201
202
  },
202
203
  {
203
204
  name: 'WebsiteField',
204
- type: 'WebsiteField',
205
+ type: ComponentType.WebsiteField,
205
206
  title: 'Website field',
206
- subType: 'field',
207
+ subType: ComponentSubType.Field,
207
208
  hint: '',
208
209
  options: {},
209
210
  schema: {}
@@ -1,4 +1,4 @@
1
- export enum ComponentTypeEnum {
1
+ export enum ComponentType {
2
2
  TextField = 'TextField',
3
3
  MultilineTextField = 'MultilineTextField',
4
4
  YesNoField = 'YesNoField',
@@ -20,5 +20,12 @@ export enum ComponentTypeEnum {
20
20
  Html = 'Html',
21
21
  InsetText = 'InsetText',
22
22
  Details = 'Details',
23
- List = 'List'
23
+ List = 'List',
24
+ WebsiteField = 'WebsiteField'
25
+ }
26
+
27
+ export enum ComponentSubType {
28
+ Content = 'content',
29
+ Field = 'field',
30
+ ListField = 'listField'
24
31
  }
@@ -1,3 +1,2 @@
1
1
  export { ComponentTypes } from '~/src/components/component-types.js'
2
- export { ConditionalComponentTypes } from '~/src/components/conditional-component-types.js'
3
- export { ComponentTypeEnum } from '~/src/components/enums.js'
2
+ export { ComponentType, ComponentSubType } from '~/src/components/enums.js'
@@ -1,34 +1,12 @@
1
- export type ComponentType =
2
- | 'TextField'
3
- | 'MultilineTextField'
4
- | 'YesNoField'
5
- | 'DateField'
6
- | 'TimeField'
7
- | 'DateTimeField'
8
- | 'MonthYearField'
9
- | 'DatePartsField'
10
- | 'DateTimePartsField'
11
- | 'SelectField'
12
- | 'AutocompleteField'
13
- | 'RadiosField'
14
- | 'CheckboxesField'
15
- | 'NumberField'
16
- | 'UkAddressField'
17
- | 'TelephoneNumberField'
18
- | 'EmailAddressField'
19
- | 'FileUploadField'
20
- | 'Html'
21
- | 'InsetText'
22
- | 'Details'
23
- | 'List'
24
- | 'WebsiteField'
25
-
26
- export type ComponentSubType = 'field' | 'content'
1
+ import {
2
+ type ComponentSubType,
3
+ type ComponentType
4
+ } from '~/src/components/enums.js'
27
5
 
28
6
  export interface ConditionalComponent {
29
- name: 'TextField' | 'NumberField'
7
+ name: string
30
8
  title: string
31
- subType: 'field'
9
+ subType: ComponentSubType.Field
32
10
  }
33
11
 
34
12
  export interface ContentOptions {
@@ -39,8 +17,16 @@ export interface ContentOptions {
39
17
  * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists
40
18
  */
41
19
  interface TextFieldBase {
42
- subType?: 'field'
43
- type: string
20
+ type:
21
+ | ComponentType.EmailAddressField
22
+ | ComponentType.MultilineTextField
23
+ | ComponentType.NumberField
24
+ | ComponentType.TelephoneNumberField
25
+ | ComponentType.TextField
26
+ | ComponentType.UkAddressField
27
+ | ComponentType.WebsiteField
28
+ | ComponentType.YesNoField
29
+ subType?: ComponentSubType.Field
44
30
  name: string
45
31
  title: string
46
32
  hint?: string
@@ -58,13 +44,13 @@ interface TextFieldBase {
58
44
  min?: number
59
45
  length?: number
60
46
  regex?: string
61
- error?: any // TODO: in same cases this is a function e.g. addressLine1 in ukaddress
47
+ error?: unknown
62
48
  }
63
49
  }
64
50
 
65
51
  interface NumberFieldBase {
66
- subType?: 'field'
67
- type: string
52
+ type: ComponentType
53
+ subType?: ComponentSubType.Field
68
54
  name: string
69
55
  title: string
70
56
  hint: string
@@ -81,8 +67,13 @@ interface NumberFieldBase {
81
67
  }
82
68
 
83
69
  interface ListFieldBase {
84
- subType?: 'listField' | 'content'
85
- type: string
70
+ type:
71
+ | ComponentType.AutocompleteField
72
+ | ComponentType.CheckboxesField
73
+ | ComponentType.List
74
+ | ComponentType.RadiosField
75
+ | ComponentType.SelectField
76
+ subType?: ComponentSubType.Content | ComponentSubType.ListField
86
77
  name: string
87
78
  title: string
88
79
  options: {
@@ -96,22 +87,28 @@ interface ListFieldBase {
96
87
  allowPrePopulation?: boolean
97
88
  }
98
89
  list: string
99
- schema: {}
90
+ schema: object
100
91
  }
101
92
 
102
93
  interface ContentFieldBase {
103
- subType?: 'content'
104
- type: string
94
+ type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText
95
+ subType?: ComponentSubType.Content
105
96
  name: string
106
97
  title: string
107
98
  content: string
108
99
  options: ContentOptions
109
- schema: {}
100
+ schema?: object
110
101
  }
111
102
 
112
103
  interface DateFieldBase {
113
- subType?: 'field'
114
- type: string
104
+ type:
105
+ | ComponentType.DateField
106
+ | ComponentType.DatePartsField
107
+ | ComponentType.DateTimeField
108
+ | ComponentType.DateTimePartsField
109
+ | ComponentType.MonthYearField
110
+ | ComponentType.TimeField
111
+ subType?: ComponentSubType.Field
115
112
  name: string
116
113
  title: string
117
114
  hint: string
@@ -123,45 +120,45 @@ interface DateFieldBase {
123
120
  maxDaysInPast?: number
124
121
  exposeToContext?: boolean
125
122
  }
126
- schema: {}
123
+ schema: object
127
124
  }
128
125
 
129
126
  // Text Fields
130
127
  export interface TextFieldComponent extends TextFieldBase {
131
- type: 'TextField'
128
+ type: ComponentType.TextField
132
129
  options: TextFieldBase['options'] & {
133
130
  customValidationMessage?: string
134
131
  }
135
132
  }
136
133
 
137
134
  export interface EmailAddressFieldComponent extends TextFieldBase {
138
- type: 'EmailAddressField'
135
+ type: ComponentType.EmailAddressField
139
136
  }
140
137
 
141
138
  export interface NumberFieldComponent extends NumberFieldBase {
142
- type: 'NumberField'
139
+ type: ComponentType.NumberField
143
140
  }
144
141
 
145
142
  export interface WebsiteFieldComponent extends TextFieldBase {
146
- type: 'WebsiteField'
143
+ type: ComponentType.WebsiteField
147
144
  options: TextFieldBase['options'] & {
148
145
  customValidationMessage?: string
149
146
  }
150
147
  }
151
148
 
152
149
  export interface TelephoneNumberFieldComponent extends TextFieldBase {
153
- type: 'TelephoneNumberField'
150
+ type: ComponentType.TelephoneNumberField
154
151
  options: TextFieldBase['options'] & {
155
152
  customValidationMessage?: string
156
153
  }
157
154
  }
158
155
 
159
156
  export interface YesNoFieldComponent extends TextFieldBase {
160
- type: 'YesNoField'
157
+ type: ComponentType.YesNoField
161
158
  }
162
159
 
163
160
  export interface MultilineTextFieldComponent extends TextFieldBase {
164
- type: 'MultilineTextField'
161
+ type: ComponentType.MultilineTextField
165
162
  options: TextFieldBase['options'] & {
166
163
  customValidationMessage?: string
167
164
  rows?: number
@@ -174,8 +171,8 @@ export interface MultilineTextFieldComponent extends TextFieldBase {
174
171
  }
175
172
 
176
173
  export interface FileUploadFieldComponent {
177
- subType?: 'field'
178
- type: 'FileUploadField'
174
+ type: ComponentType.FileUploadField
175
+ subType?: ComponentSubType.Field
179
176
  name: string
180
177
  title: string
181
178
  hint: string
@@ -187,75 +184,75 @@ export interface FileUploadFieldComponent {
187
184
  exposeToContext?: boolean
188
185
  imageQualityPlayback?: boolean
189
186
  }
190
- schema: {}
187
+ schema: object
191
188
  }
192
189
 
193
190
  export interface UkAddressFieldComponent extends TextFieldBase {
194
- type: 'UkAddressField'
191
+ type: ComponentType.UkAddressField
195
192
  }
196
193
 
197
194
  // Date Fields
198
195
  export interface DateFieldComponent extends DateFieldBase {
199
- type: 'DateField'
196
+ type: ComponentType.DateField
200
197
  }
201
198
 
202
199
  export interface DateTimeFieldComponent extends DateFieldBase {
203
- type: 'DateTimeField'
200
+ type: ComponentType.DateTimeField
204
201
  }
205
202
 
206
203
  export interface DatePartsFieldFieldComponent extends DateFieldBase {
207
- type: 'DatePartsField'
204
+ type: ComponentType.DatePartsField
208
205
  }
209
206
 
210
207
  export interface MonthYearFieldComponent extends DateFieldBase {
211
- type: 'MonthYearField'
208
+ type: ComponentType.MonthYearField
212
209
  }
213
210
 
214
211
  export interface DateTimePartsFieldComponent extends DateFieldBase {
215
- type: 'DateTimePartsField'
212
+ type: ComponentType.DateTimePartsField
216
213
  }
217
214
 
218
215
  export interface TimeFieldComponent extends DateFieldBase {
219
- type: 'TimeField'
216
+ type: ComponentType.TimeField
220
217
  }
221
218
 
222
219
  // Content Fields
223
220
  export interface DetailsComponent extends ContentFieldBase {
224
- type: 'Details'
221
+ type: ComponentType.Details
225
222
  }
226
223
 
227
224
  export interface HtmlComponent extends ContentFieldBase {
228
- type: 'Html'
225
+ type: ComponentType.Html
229
226
  }
230
227
 
231
228
  export interface InsetTextComponent extends ContentFieldBase {
232
- type: 'InsetText'
229
+ type: ComponentType.InsetText
233
230
  }
234
231
 
235
232
  // List Fields
236
233
  export interface ListComponent extends ListFieldBase {
237
- type: 'List'
234
+ type: ComponentType.List
238
235
  }
239
236
 
240
237
  export interface AutocompleteFieldComponent extends ListFieldBase {
241
- type: 'AutocompleteField'
242
- subType?: 'listField'
238
+ type: ComponentType.AutocompleteField
239
+ subType?: ComponentSubType.ListField
243
240
  }
244
241
 
245
242
  export interface CheckboxesFieldComponent extends ListFieldBase {
246
- type: 'CheckboxesField'
247
- subType?: 'listField'
243
+ type: ComponentType.CheckboxesField
244
+ subType?: ComponentSubType.ListField
248
245
  }
249
246
 
250
247
  export interface RadiosFieldComponent extends ListFieldBase {
251
- type: 'RadiosField'
252
- subType?: 'listField'
248
+ type: ComponentType.RadiosField
249
+ subType?: ComponentSubType.ListField
253
250
  }
254
251
 
255
252
  export interface SelectFieldComponent extends ListFieldBase {
256
- type: 'SelectField'
253
+ type: ComponentType.SelectField
254
+ subType?: ComponentSubType.ListField
257
255
  options: ListFieldBase['options'] & { autocomplete?: string }
258
- subType?: 'listField'
259
256
  }
260
257
 
261
258
  export type ComponentDef =
@@ -1,5 +1,5 @@
1
1
  import { ComponentTypes } from '~/src/components/component-types.js'
2
- import { type ComponentType } from '~/src/components/types.js'
2
+ import { type ComponentType } from '~/src/components/enums.js'
3
3
 
4
4
  export class ConditionField {
5
5
  name: string
@@ -1,7 +1,5 @@
1
- import {
2
- type ComponentType,
3
- type ComponentDef
4
- } from '~/src/components/types.js'
1
+ import { ComponentType } from '~/src/components/enums.js'
2
+ import { type ComponentDef } from '~/src/components/types.js'
5
3
  import { type ConditionValueAbstract } from '~/src/conditions/condition-value-abstract.js'
6
4
  import {
7
5
  timeUnits,
@@ -44,44 +42,46 @@ const relativeTimeOperators = (units) => ({
44
42
  })
45
43
 
46
44
  export const customOperators = {
47
- CheckboxesField: {
45
+ [ComponentType.CheckboxesField]: {
48
46
  contains: reverseInline('in'),
49
47
  'does not contain': not(reverseInline('in'))
50
48
  },
51
- NumberField: withDefaults({
49
+ [ComponentType.NumberField]: withDefaults({
52
50
  'is at least': inline('>='),
53
51
  'is at most': inline('<='),
54
52
  'is less than': inline('<'),
55
53
  'is more than': inline('>')
56
54
  }),
57
- DateField: Object.assign(
55
+ [ComponentType.DateField]: Object.assign(
58
56
  {},
59
57
  absoluteDateTimeOperators,
60
58
  relativeTimeOperators(dateUnits)
61
59
  ),
62
- TimeField: Object.assign(
60
+ [ComponentType.TimeField]: Object.assign(
63
61
  {},
64
62
  absoluteDateTimeOperators,
65
63
  relativeTimeOperators(timeUnits)
66
64
  ),
67
- DatePartsField: Object.assign(
65
+ [ComponentType.DatePartsField]: Object.assign(
68
66
  {},
69
67
  absoluteDateTimeOperators,
70
68
  relativeTimeOperators(dateUnits)
71
69
  ),
72
- DateTimeField: Object.assign(
70
+ [ComponentType.DateTimeField]: Object.assign(
73
71
  {},
74
72
  absoluteDateTimeOperators,
75
73
  relativeTimeOperators(dateTimeUnits)
76
74
  ),
77
- DateTimePartsField: Object.assign(
75
+ [ComponentType.DateTimePartsField]: Object.assign(
78
76
  {},
79
77
  absoluteDateTimeOperators,
80
78
  relativeTimeOperators(dateTimeUnits)
81
79
  ),
82
- TextField: withDefaults(textBasedFieldCustomisations),
83
- MultilineTextField: withDefaults(textBasedFieldCustomisations),
84
- EmailAddressField: withDefaults(textBasedFieldCustomisations)
80
+ [ComponentType.TextField]: withDefaults(textBasedFieldCustomisations),
81
+ [ComponentType.MultilineTextField]: withDefaults(
82
+ textBasedFieldCustomisations
83
+ ),
84
+ [ComponentType.EmailAddressField]: withDefaults(textBasedFieldCustomisations)
85
85
  }
86
86
 
87
87
  export function getOperatorNames(fieldType) {
@@ -137,9 +137,13 @@ function not(operatorDefinition) {
137
137
  }
138
138
 
139
139
  function formatValue(fieldType: ComponentType, value) {
140
- if (fieldType === 'NumberField' || fieldType === 'YesNoField') {
140
+ if (
141
+ fieldType === ComponentType.YesNoField ||
142
+ fieldType === ComponentType.NumberField
143
+ ) {
141
144
  return value
142
145
  }
146
+
143
147
  return `'${value}'`
144
148
  }
145
149
 
@@ -1,3 +1,8 @@
1
+ export enum ConditionType {
2
+ Value = 'Value',
3
+ RelativeTime = 'RelativeTime'
4
+ }
5
+
1
6
  export enum Coordinator {
2
7
  AND = 'and',
3
8
  OR = 'or'
@@ -24,4 +24,4 @@ export { ConditionsModel } from '~/src/conditions/condition-model.js'
24
24
  export { ConditionGroupDef } from '~/src/conditions/condition-group-def.js'
25
25
  export { toExpression, toPresentationString } from '~/src/conditions/helpers.js'
26
26
 
27
- export { Coordinator } from '~/src/conditions/enums.js'
27
+ export { ConditionType, Coordinator } from '~/src/conditions/enums.js'