@defra/forms-model 3.0.177 → 3.0.179

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 (58) hide show
  1. package/dist/module/components/component-types.js +2 -0
  2. package/dist/module/components/component-types.js.map +1 -1
  3. package/dist/module/components/helpers.js +57 -0
  4. package/dist/module/components/helpers.js.map +1 -0
  5. package/dist/module/components/index.js +2 -1
  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 +5 -5
  9. package/dist/module/conditions/condition-field.js.map +1 -1
  10. package/dist/module/conditions/condition-operators.js +76 -48
  11. package/dist/module/conditions/condition-operators.js.map +1 -1
  12. package/dist/module/conditions/condition-ref.js.map +1 -1
  13. package/dist/module/conditions/condition-values.js +9 -10
  14. package/dist/module/conditions/condition-values.js.map +1 -1
  15. package/dist/module/conditions/condition.js.map +1 -1
  16. package/dist/module/conditions/enums.js +31 -0
  17. package/dist/module/conditions/enums.js.map +1 -1
  18. package/dist/module/conditions/index.js +2 -2
  19. package/dist/module/conditions/index.js.map +1 -1
  20. package/dist/module/conditions/types.js.map +1 -1
  21. package/dist/types/components/component-types.d.ts +1 -0
  22. package/dist/types/components/component-types.d.ts.map +1 -1
  23. package/dist/types/components/helpers.d.ts +30 -0
  24. package/dist/types/components/helpers.d.ts.map +1 -0
  25. package/dist/types/components/index.d.ts +2 -1
  26. package/dist/types/components/index.d.ts.map +1 -1
  27. package/dist/types/components/types.d.ts +4 -5
  28. package/dist/types/components/types.d.ts.map +1 -1
  29. package/dist/types/conditions/condition-field.d.ts +6 -6
  30. package/dist/types/conditions/condition-field.d.ts.map +1 -1
  31. package/dist/types/conditions/condition-operators.d.ts +84 -230
  32. package/dist/types/conditions/condition-operators.d.ts.map +1 -1
  33. package/dist/types/conditions/condition-ref.d.ts +3 -3
  34. package/dist/types/conditions/condition-ref.d.ts.map +1 -1
  35. package/dist/types/conditions/condition-values.d.ts +5 -8
  36. package/dist/types/conditions/condition-values.d.ts.map +1 -1
  37. package/dist/types/conditions/condition.d.ts +6 -6
  38. package/dist/types/conditions/condition.d.ts.map +1 -1
  39. package/dist/types/conditions/enums.d.ts +28 -0
  40. package/dist/types/conditions/enums.d.ts.map +1 -1
  41. package/dist/types/conditions/index.d.ts +2 -2
  42. package/dist/types/conditions/index.d.ts.map +1 -1
  43. package/dist/types/conditions/types.d.ts +8 -0
  44. package/dist/types/conditions/types.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/components/component-types.ts +6 -47
  47. package/src/components/enums.ts +1 -6
  48. package/src/components/helpers.ts +138 -0
  49. package/src/components/index.ts +14 -1
  50. package/src/components/types.ts +49 -58
  51. package/src/conditions/condition-field.ts +25 -11
  52. package/src/conditions/condition-operators.ts +129 -96
  53. package/src/conditions/condition-ref.ts +2 -2
  54. package/src/conditions/condition-values.ts +15 -20
  55. package/src/conditions/condition.ts +5 -5
  56. package/src/conditions/enums.ts +31 -0
  57. package/src/conditions/index.ts +7 -2
  58. package/src/conditions/types.ts +16 -0
@@ -1,4 +1,5 @@
1
1
  import { ComponentSubType, ComponentType } from "./enums.js";
2
+ import { hasConditionSupport } from "./helpers.js";
2
3
  export const ComponentTypes = [{
3
4
  name: 'TextField',
4
5
  type: ComponentType.TextField,
@@ -184,4 +185,5 @@ export const ComponentTypes = [{
184
185
  options: {},
185
186
  schema: {}
186
187
  }];
188
+ export const ConditionalComponentTypes = ComponentTypes.filter(hasConditionSupport);
187
189
  //# sourceMappingURL=component-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-types.js","names":["ComponentSubType","ComponentType","ComponentTypes","name","type","TextField","title","subType","Field","hint","options","schema","MultilineTextField","YesNoField","DateField","TimeField","DateTimeField","DatePartsField","DateTimePartsField","MonthYearField","SelectField","ListField","list","AutocompleteField","RadiosField","CheckboxesField","NumberField","UkAddressField","TelephoneNumberField","EmailAddressField","FileUploadField","Html","Content","content","InsetText","Details","List","WebsiteField"],"sources":["../../../src/components/component-types.ts"],"sourcesContent":["import { ComponentSubType, ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\n\nexport const ComponentTypes: ComponentDef[] = [\n {\n name: 'TextField',\n type: ComponentType.TextField,\n title: 'Text field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MultilineTextField',\n type: ComponentType.MultilineTextField,\n title: 'Multiline text field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'YesNoField',\n type: ComponentType.YesNoField,\n title: 'Yes/No field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateField',\n type: ComponentType.DateField,\n title: 'Date field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TimeField',\n type: ComponentType.TimeField,\n title: 'Time field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateTimeField',\n type: ComponentType.DateTimeField,\n title: 'Date time field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DatePartsField',\n type: ComponentType.DatePartsField,\n title: 'Date parts field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateTimePartsField',\n type: ComponentType.DateTimePartsField,\n title: 'Date time parts field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MonthYearField',\n type: ComponentType.MonthYearField,\n title: 'Month year field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'SelectField',\n type: ComponentType.SelectField,\n title: 'Select field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'AutocompleteField',\n type: ComponentType.AutocompleteField,\n title: 'Autocomplete field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'RadiosField',\n type: ComponentType.RadiosField,\n title: 'Radios field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'CheckboxesField',\n type: ComponentType.CheckboxesField,\n title: 'Checkboxes field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'NumberField',\n type: ComponentType.NumberField,\n title: 'Number field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'UkAddressField',\n type: ComponentType.UkAddressField,\n title: 'UK address field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TelephoneNumberField',\n type: ComponentType.TelephoneNumberField,\n title: 'Telephone number field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'EmailAddressField',\n type: ComponentType.EmailAddressField,\n title: 'Email address field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'FileUploadField',\n type: ComponentType.FileUploadField,\n title: 'File upload field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'Html',\n type: ComponentType.Html,\n title: 'Html',\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'InsetText',\n type: ComponentType.InsetText,\n title: 'Inset text',\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'Details',\n type: ComponentType.Details,\n title: 'Details',\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'List',\n type: ComponentType.List,\n title: 'List',\n subType: ComponentSubType.Content,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'WebsiteField',\n type: ComponentType.WebsiteField,\n title: 'Website field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n }\n]\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,aAAa;AAGxC,OAAO,MAAMC,cAA8B,GAAG,CAC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K,EAAE,MAAM;EACbC,OAAO,EAAEP,gBAAgB,CAACgC,OAAO;EACjCtB,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC,CAAC;EACVW,IAAI,EAAE;AACR,CAAC,EACD;EACEnB,IAAI,EAAE,cAAc;EACpBC,IAAI,EAAEH,aAAa,CAACoC,YAAY;EAChC/B,KAAK,EAAE,eAAe;EACtBC,OAAO,EAAEP,gBAAgB,CAACQ,KAAK;EAC/BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,CACF","ignoreList":[]}
1
+ {"version":3,"file":"component-types.js","names":["ComponentSubType","ComponentType","hasConditionSupport","ComponentTypes","name","type","TextField","title","subType","Field","hint","options","schema","MultilineTextField","YesNoField","DateField","TimeField","DateTimeField","DatePartsField","DateTimePartsField","MonthYearField","SelectField","ListField","list","AutocompleteField","RadiosField","CheckboxesField","NumberField","UkAddressField","TelephoneNumberField","EmailAddressField","FileUploadField","Html","Content","content","InsetText","Details","List","WebsiteField","ConditionalComponentTypes","filter"],"sources":["../../../src/components/component-types.ts"],"sourcesContent":["import { ComponentSubType, ComponentType } from '~/src/components/enums.js'\nimport { hasConditionSupport } from '~/src/components/helpers.js'\nimport { type ComponentDef } from '~/src/components/types.js'\n\nexport const ComponentTypes: ComponentDef[] = [\n {\n name: 'TextField',\n type: ComponentType.TextField,\n title: 'Text field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MultilineTextField',\n type: ComponentType.MultilineTextField,\n title: 'Multiline text field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'YesNoField',\n type: ComponentType.YesNoField,\n title: 'Yes/No field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateField',\n type: ComponentType.DateField,\n title: 'Date field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TimeField',\n type: ComponentType.TimeField,\n title: 'Time field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateTimeField',\n type: ComponentType.DateTimeField,\n title: 'Date time field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DatePartsField',\n type: ComponentType.DatePartsField,\n title: 'Date parts field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateTimePartsField',\n type: ComponentType.DateTimePartsField,\n title: 'Date time parts field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MonthYearField',\n type: ComponentType.MonthYearField,\n title: 'Month year field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'SelectField',\n type: ComponentType.SelectField,\n title: 'Select field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'AutocompleteField',\n type: ComponentType.AutocompleteField,\n title: 'Autocomplete field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'RadiosField',\n type: ComponentType.RadiosField,\n title: 'Radios field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'CheckboxesField',\n type: ComponentType.CheckboxesField,\n title: 'Checkboxes field',\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'NumberField',\n type: ComponentType.NumberField,\n title: 'Number field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'UkAddressField',\n type: ComponentType.UkAddressField,\n title: 'UK address field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TelephoneNumberField',\n type: ComponentType.TelephoneNumberField,\n title: 'Telephone number field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'EmailAddressField',\n type: ComponentType.EmailAddressField,\n title: 'Email address field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'FileUploadField',\n type: ComponentType.FileUploadField,\n title: 'File upload field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'Html',\n type: ComponentType.Html,\n title: 'Html',\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'InsetText',\n type: ComponentType.InsetText,\n title: 'Inset text',\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'Details',\n type: ComponentType.Details,\n title: 'Details',\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'List',\n type: ComponentType.List,\n title: 'List',\n subType: ComponentSubType.Content,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'WebsiteField',\n type: ComponentType.WebsiteField,\n title: 'Website field',\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n }\n]\n\nexport const ConditionalComponentTypes =\n ComponentTypes.filter(hasConditionSupport)\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,aAAa;AACxC,SAASC,mBAAmB;AAG5B,OAAO,MAAMC,cAA8B,GAAG,CAC5C;EACEC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAEJ,aAAa,CAACK,SAAS;EAC7BC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAER,gBAAgB,CAACS,KAAK;EAC/BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,oBAAoB;EAC1BC,IAAI,EAAEJ,aAAa,CAACY,kBAAkB;EACtCN,KAAK,EAAE,sBAAsB;EAC7BC,OAAO,EAAER,gBAAgB,CAACS,KAAK;EAC/BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAA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oreList":[]}
@@ -0,0 +1,57 @@
1
+ import { ComponentType } from "./enums.js";
2
+ /**
3
+ * Filter known components with support for conditions
4
+ */
5
+ export function hasConditionSupport(component) {
6
+ const allowedTypes = [ComponentType.CheckboxesField, ComponentType.DateField, ComponentType.DatePartsField, ComponentType.DateTimeField, ComponentType.DateTimePartsField, ComponentType.EmailAddressField, ComponentType.MultilineTextField, ComponentType.NumberField, ComponentType.TextField, ComponentType.TimeField, ComponentType.YesNoField];
7
+ return !!component?.type && allowedTypes.includes(component.type);
8
+ }
9
+
10
+ /**
11
+ * Filter known components with content fields
12
+ */
13
+ export function hasContentField(component) {
14
+ const allowedTypes = [ComponentType.Details, ComponentType.Html, ComponentType.InsetText, ComponentType.List];
15
+ return !!component?.type && allowedTypes.includes(component.type);
16
+ }
17
+
18
+ /**
19
+ * Filter known components with text editor
20
+ */
21
+ export function hasEditor(component) {
22
+ const allowedTypes = [ComponentType.TextField, ComponentType.EmailAddressField, ComponentType.TelephoneNumberField, ComponentType.MultilineTextField, ComponentType.NumberField, ComponentType.AutocompleteField, ComponentType.SelectField, ComponentType.RadiosField, ComponentType.CheckboxesField, ComponentType.List, ComponentType.Details, ComponentType.Html, ComponentType.InsetText, ComponentType.FileUploadField, ComponentType.DatePartsField, ComponentType.DateTimeField, ComponentType.DateTimePartsField, ComponentType.DateField];
23
+ return !!component?.type && allowedTypes.includes(component.type);
24
+ }
25
+
26
+ /**
27
+ * Filter known components with input fields
28
+ */
29
+ export function hasInputField(component) {
30
+ const allowedTypes = [ComponentType.TextField, ComponentType.EmailAddressField, ComponentType.NumberField, ComponentType.MultilineTextField, ComponentType.TelephoneNumberField, ComponentType.YesNoField, ComponentType.FileUploadField, ComponentType.DateField, ComponentType.DateTimeField, ComponentType.DateTimePartsField, ComponentType.MonthYearField, ComponentType.TimeField, ComponentType.UkAddressField, ComponentType.WebsiteField];
31
+ return !!component?.type && allowedTypes.includes(component.type);
32
+ }
33
+
34
+ /**
35
+ * Filter known components with lists
36
+ */
37
+ export function hasListField(component) {
38
+ const allowedTypes = [ComponentType.AutocompleteField, ComponentType.List, ComponentType.RadiosField, ComponentType.SelectField, ComponentType.CheckboxesField];
39
+ return !!component?.type && allowedTypes.includes(component.type);
40
+ }
41
+
42
+ /**
43
+ * Filter known components with selection fields
44
+ */
45
+ export function hasSelectionFields(component) {
46
+ const allowedTypes = [ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.SelectField, ComponentType.YesNoField];
47
+ return !!component?.type && allowedTypes.includes(component.type);
48
+ }
49
+
50
+ /**
51
+ * Filter known components with titles
52
+ */
53
+ export function hasTitle(component) {
54
+ const deniedTypes = [ComponentType.InsetText, ComponentType.Html];
55
+ return !!component?.type && !deniedTypes.includes(component.type);
56
+ }
57
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":["ComponentType","hasConditionSupport","component","allowedTypes","CheckboxesField","DateField","DatePartsField","DateTimeField","DateTimePartsField","EmailAddressField","MultilineTextField","NumberField","TextField","TimeField","YesNoField","type","includes","hasContentField","Details","Html","InsetText","List","hasEditor","TelephoneNumberField","AutocompleteField","SelectField","RadiosField","FileUploadField","hasInputField","MonthYearField","UkAddressField","WebsiteField","hasListField","hasSelectionFields","hasTitle","deniedTypes"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n type InputFieldsComponentsDef,\n type ComponentDef,\n type ConditionalComponentsDef,\n type ContentComponentsDef,\n type HtmlComponent,\n type InsetTextComponent,\n type ListComponentsDef,\n type SelectionComponentsDef,\n type EditorComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n const allowedTypes = [\n ComponentType.CheckboxesField,\n ComponentType.DateField,\n ComponentType.DatePartsField,\n ComponentType.DateTimeField,\n ComponentType.DateTimePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField,\n ComponentType.TextField,\n ComponentType.TimeField,\n ComponentType.YesNoField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with content fields\n */\nexport function hasContentField(\n component?: Partial<ComponentDef>\n): component is ContentComponentsDef {\n const allowedTypes = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.List\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with text editor\n */\nexport function hasEditor(\n component?: Partial<ComponentDef>\n): component is EditorComponentsDef {\n const allowedTypes = [\n ComponentType.TextField,\n ComponentType.EmailAddressField,\n ComponentType.TelephoneNumberField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField,\n ComponentType.AutocompleteField,\n ComponentType.SelectField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.List,\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.FileUploadField,\n ComponentType.DatePartsField,\n ComponentType.DateTimeField,\n ComponentType.DateTimePartsField,\n ComponentType.DateField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with input fields\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n const allowedTypes = [\n ComponentType.TextField,\n ComponentType.EmailAddressField,\n ComponentType.NumberField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.YesNoField,\n ComponentType.FileUploadField,\n ComponentType.DateField,\n ComponentType.DateTimeField,\n ComponentType.DateTimePartsField,\n ComponentType.MonthYearField,\n ComponentType.TimeField,\n ComponentType.UkAddressField,\n ComponentType.WebsiteField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with selection fields\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with titles\n */\nexport function hasTitle(\n component?: Partial<ComponentDef>\n): component is Exclude<ComponentDef, InsetTextComponent | HtmlComponent> {\n const deniedTypes = [ComponentType.InsetText, ComponentType.Html]\n return !!component?.type && !deniedTypes.includes(component.type)\n}\n"],"mappings":"AAAA,SAASA,aAAa;AAatB;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjCC,SAAiC,EACM;EACvC,MAAMC,YAAY,GAAG,CACnBH,aAAa,CAACI,eAAe,EAC7BJ,aAAa,CAACK,SAAS,EACvBL,aAAa,CAACM,cAAc,EAC5BN,aAAa,CAACO,aAAa,EAC3BP,aAAa,CAACQ,kBAAkB,EAChCR,aAAa,CAACS,iBAAiB,EAC/BT,aAAa,CAACU,kBAAkB,EAChCV,aAAa,CAACW,WAAW,EACzBX,aAAa,CAACY,SAAS,EACvBZ,aAAa,CAACa,SAAS,EACvBb,aAAa,CAACc,UAAU,CACzB;EAED,OAAO,CAAC,CAACZ,SAAS,EAAEa,IAAI,IAAIZ,YAAY,CAACa,QAAQ,CAACd,SAAS,CAACa,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAC7Bf,SAAiC,EACE;EACnC,MAAMC,YAAY,GAAG,CACnBH,aAAa,CAACkB,OAAO,EACrBlB,aAAa,CAACmB,IAAI,EAClBnB,aAAa,CAACoB,SAAS,EACvBpB,aAAa,CAACqB,IAAI,CACnB;EAED,OAAO,CAAC,CAACnB,SAAS,EAAEa,IAAI,IAAIZ,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C3B;EAED,OAAO,CAAC,CAAC7B,SAAS,EAAEa,IAAI,IAAIZ,YAAY,CAACa,QAAQ,CAACd,SAAS,CAACa,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASiB,YAAYA,CAC1B9B,SAAiC,EACD;EAChC,MAAMC,YAAY,GAAG,CACnBH,aAAa,CAACwB,iBAAiB,EAC/BxB,aAAa,CAACqB,IAAI,EAClBrB,aAAa,CAAC0B,WAAW,EACzB1B,aAAa,CAACyB,WAAW,EACzBzB,aAAa,CAACI,eAAe,CAC9B;EAED,OAAO,CAAC,CAACF,SAAS,EAAEa,IAAI,IAAIZ,YAAY,CAACa,QAAQ,CAACd,SAAS,CAACa,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASkB,kBAAkBA,CAChC/B,SAAiC,EACI;EACrC,MAAMC,YAAY,GAAG,CACnBH,aAAa,CAACI,eAAe,EAC7BJ,aAAa,CAAC0B,WAAW,EACzB1B,aAAa,CAACyB,WAAW,EACzBzB,aAAa,CAACc,UAAU,CACzB;EAED,OAAO,CAAC,CAACZ,SAAS,EAAEa,IAAI,IAAIZ,YAAY,CAACa,QAAQ,CAACd,SAAS,CAACa,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASmB,QAAQA,CACtBhC,SAAiC,EACuC;EACxE,MAAMiC,WAAW,GAAG,CAACnC,aAAa,CAACoB,SAAS,EAAEpB,aAAa,CAACmB,IAAI,CAAC;EACjE,OAAO,CAAC,CAACjB,SAAS,EAAEa,IAAI,IAAI,CAACoB,WAAW,CAACnB,QAAQ,CAACd,SAAS,CAACa,IAAI,CAAC;AACnE","ignoreList":[]}
@@ -1,3 +1,4 @@
1
- export { ComponentTypes } from "./component-types.js";
1
+ export { ComponentTypes, ConditionalComponentTypes } from "./component-types.js";
2
+ export { hasConditionSupport, hasContentField, hasEditor, hasInputField, hasListField, hasSelectionFields, hasTitle } from "./helpers.js";
2
3
  export { ComponentType, ComponentSubType } from "./enums.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ComponentTypes","ComponentType","ComponentSubType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport { ComponentType, ComponentSubType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa,EAAEC,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ComponentTypes","ConditionalComponentTypes","hasConditionSupport","hasContentField","hasEditor","hasInputField","hasListField","hasSelectionFields","hasTitle","ComponentType","ComponentSubType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export {\n ComponentTypes,\n ConditionalComponentTypes\n} from '~/src/components/component-types.js'\nexport {\n hasConditionSupport,\n hasContentField,\n hasEditor,\n hasInputField,\n hasListField,\n hasSelectionFields,\n hasTitle\n} from '~/src/components/helpers.js'\n\nexport { ComponentType, ComponentSubType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SACEA,cAAc,EACdC,yBAAyB;AAE3B,SACEC,mBAAmB,EACnBC,eAAe,EACfC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ;AAGV,SAASC,aAAa,EAAEC,gBAAgB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import {\n type ComponentSubType,\n type ComponentType\n} from '~/src/components/enums.js'\n\nexport interface ConditionalComponent {\n name: string\n title: string\n subType: ComponentSubType.Field\n}\n\nexport interface ContentOptions {\n condition?: string\n}\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\ninterface TextFieldBase {\n type:\n | ComponentType.EmailAddressField\n | ComponentType.MultilineTextField\n | ComponentType.NumberField\n | ComponentType.TelephoneNumberField\n | ComponentType.TextField\n | ComponentType.UkAddressField\n | ComponentType.WebsiteField\n | ComponentType.YesNoField\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint?: string\n options: {\n hideTitle?: boolean\n required?: boolean\n optionalText?: boolean\n classes?: string\n allow?: string\n autocomplete?: string\n exposeToContext?: boolean\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n error?: unknown\n }\n}\n\ninterface NumberFieldBase {\n type: ComponentType\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint: string\n options: {\n prefix?: string\n suffix?: string\n exposeToContext?: boolean\n }\n schema: {\n min?: number\n max?: number\n precision?: number\n }\n}\n\ninterface ListFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.List\n | ComponentType.RadiosField\n | ComponentType.SelectField\n subType?: ComponentSubType.Content | ComponentSubType.ListField\n name: string\n title: string\n options: {\n type?: string\n hideTitle?: boolean\n required?: boolean\n optionalText?: boolean\n classes?: string\n bold?: boolean\n exposeToContext?: boolean\n allowPrePopulation?: boolean\n }\n list: string\n schema: object\n}\n\ninterface ContentFieldBase {\n type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText\n subType?: ComponentSubType.Content\n name: string\n title: string\n content: string\n options: ContentOptions\n schema?: object\n}\n\ninterface DateFieldBase {\n type:\n | ComponentType.DateField\n | ComponentType.DatePartsField\n | ComponentType.DateTimeField\n | ComponentType.DateTimePartsField\n | ComponentType.MonthYearField\n | ComponentType.TimeField\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint: string\n options: {\n hideTitle?: boolean\n required?: boolean\n optionalText?: boolean\n maxDaysInFuture?: number\n maxDaysInPast?: number\n exposeToContext?: boolean\n }\n schema: object\n}\n\n// Text Fields\nexport interface TextFieldComponent extends TextFieldBase {\n type: ComponentType.TextField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface EmailAddressFieldComponent extends TextFieldBase {\n type: ComponentType.EmailAddressField\n}\n\nexport interface NumberFieldComponent extends NumberFieldBase {\n type: ComponentType.NumberField\n}\n\nexport interface WebsiteFieldComponent extends TextFieldBase {\n type: ComponentType.WebsiteField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface TelephoneNumberFieldComponent extends TextFieldBase {\n type: ComponentType.TelephoneNumberField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface YesNoFieldComponent extends TextFieldBase {\n type: ComponentType.YesNoField\n}\n\nexport interface MultilineTextFieldComponent extends TextFieldBase {\n type: ComponentType.MultilineTextField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n rows?: number\n maxWords?: number\n }\n schema: {\n max?: number\n min?: number\n }\n}\n\nexport interface FileUploadFieldComponent {\n type: ComponentType.FileUploadField\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint: string\n options: {\n required?: boolean\n hideTitle?: boolean\n multiple?: boolean\n classes?: string\n exposeToContext?: boolean\n imageQualityPlayback?: boolean\n }\n schema: object\n}\n\nexport interface UkAddressFieldComponent extends TextFieldBase {\n type: ComponentType.UkAddressField\n}\n\n// Date Fields\nexport interface DateFieldComponent extends DateFieldBase {\n type: ComponentType.DateField\n}\n\nexport interface DateTimeFieldComponent extends DateFieldBase {\n type: ComponentType.DateTimeField\n}\n\nexport interface DatePartsFieldFieldComponent extends DateFieldBase {\n type: ComponentType.DatePartsField\n}\n\nexport interface MonthYearFieldComponent extends DateFieldBase {\n type: ComponentType.MonthYearField\n}\n\nexport interface DateTimePartsFieldComponent extends DateFieldBase {\n type: ComponentType.DateTimePartsField\n}\n\nexport interface TimeFieldComponent extends DateFieldBase {\n type: ComponentType.TimeField\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n}\n\nexport interface InsetTextComponent extends ContentFieldBase {\n type: ComponentType.InsetText\n}\n\n// List Fields\nexport interface ListComponent extends ListFieldBase {\n type: ComponentType.List\n}\n\nexport interface AutocompleteFieldComponent extends ListFieldBase {\n type: ComponentType.AutocompleteField\n subType?: ComponentSubType.ListField\n}\n\nexport interface CheckboxesFieldComponent extends ListFieldBase {\n type: ComponentType.CheckboxesField\n subType?: ComponentSubType.ListField\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n subType?: ComponentSubType.ListField\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n subType?: ComponentSubType.ListField\n options: ListFieldBase['options'] & { autocomplete?: string }\n}\n\nexport type ComponentDef =\n | InsetTextComponent\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | DateFieldComponent\n | DatePartsFieldFieldComponent\n | MonthYearFieldComponent\n | DateTimeFieldComponent\n | DateTimePartsFieldComponent\n | DetailsComponent\n | EmailAddressFieldComponent\n | FileUploadFieldComponent\n | HtmlComponent\n | ListComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | TelephoneNumberFieldComponent\n | TextFieldComponent\n | TimeFieldComponent\n | UkAddressFieldComponent\n | YesNoFieldComponent\n | WebsiteFieldComponent\n\n// Components that render inputs.\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | YesNoFieldComponent\n | FileUploadFieldComponent\n | DateFieldComponent\n | DateTimeFieldComponent\n | DateTimePartsFieldComponent\n | MonthYearFieldComponent\n | TimeFieldComponent\n | UkAddressFieldComponent\n | WebsiteFieldComponent\n\n// Components that render content.\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n | ListComponent\n\n// Components that render Lists\nexport type ListComponentsDef =\n | ListComponent\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import {\n type ComponentSubType,\n type ComponentType\n} from '~/src/components/enums.js'\n\nexport type ConditionalComponentType = Extract<\n ComponentType,\n | typeof ComponentType.CheckboxesField\n | typeof ComponentType.DateField\n | typeof ComponentType.DatePartsField\n | typeof ComponentType.DateTimeField\n | typeof ComponentType.DateTimePartsField\n | typeof ComponentType.EmailAddressField\n | typeof ComponentType.MultilineTextField\n | typeof ComponentType.NumberField\n | typeof ComponentType.TextField\n | typeof ComponentType.TimeField\n | typeof ComponentType.YesNoField\n>\n\nexport interface ContentOptions {\n condition?: string\n}\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\ninterface TextFieldBase {\n type:\n | ComponentType.EmailAddressField\n | ComponentType.MultilineTextField\n | ComponentType.NumberField\n | ComponentType.TelephoneNumberField\n | ComponentType.TextField\n | ComponentType.UkAddressField\n | ComponentType.WebsiteField\n | ComponentType.YesNoField\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint?: string\n options: {\n hideTitle?: boolean\n required?: boolean\n optionalText?: boolean\n classes?: string\n allow?: string\n autocomplete?: string\n exposeToContext?: boolean\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n error?: unknown\n }\n}\n\ninterface NumberFieldBase {\n type: ComponentType\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint: string\n options: {\n prefix?: string\n suffix?: string\n exposeToContext?: boolean\n }\n schema: {\n min?: number\n max?: number\n precision?: number\n }\n}\n\ninterface ListFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.List\n | ComponentType.RadiosField\n | ComponentType.SelectField\n subType?: ComponentSubType.Content | ComponentSubType.ListField\n name: string\n title: string\n options: {\n type?: string\n hideTitle?: boolean\n required?: boolean\n optionalText?: boolean\n classes?: string\n bold?: boolean\n exposeToContext?: boolean\n allowPrePopulation?: boolean\n }\n list: string\n schema: object\n}\n\ninterface ContentFieldBase {\n type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText\n subType?: ComponentSubType.Content\n name: string\n title: string\n content: string\n options: ContentOptions\n schema?: object\n}\n\ninterface DateFieldBase {\n type:\n | ComponentType.DateField\n | ComponentType.DatePartsField\n | ComponentType.DateTimeField\n | ComponentType.DateTimePartsField\n | ComponentType.MonthYearField\n | ComponentType.TimeField\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint: string\n options: {\n hideTitle?: boolean\n required?: boolean\n optionalText?: boolean\n maxDaysInFuture?: number\n maxDaysInPast?: number\n exposeToContext?: boolean\n }\n schema: object\n}\n\n// Text Fields\nexport interface TextFieldComponent extends TextFieldBase {\n type: ComponentType.TextField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface EmailAddressFieldComponent extends TextFieldBase {\n type: ComponentType.EmailAddressField\n}\n\nexport interface NumberFieldComponent extends NumberFieldBase {\n type: ComponentType.NumberField\n}\n\nexport interface WebsiteFieldComponent extends TextFieldBase {\n type: ComponentType.WebsiteField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface TelephoneNumberFieldComponent extends TextFieldBase {\n type: ComponentType.TelephoneNumberField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface YesNoFieldComponent extends TextFieldBase {\n type: ComponentType.YesNoField\n}\n\nexport interface MultilineTextFieldComponent extends TextFieldBase {\n type: ComponentType.MultilineTextField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n rows?: number\n maxWords?: number\n }\n schema: {\n max?: number\n min?: number\n }\n}\n\nexport interface FileUploadFieldComponent {\n type: ComponentType.FileUploadField\n subType?: ComponentSubType.Field\n name: string\n title: string\n hint: string\n options: {\n required?: boolean\n hideTitle?: boolean\n multiple?: boolean\n classes?: string\n exposeToContext?: boolean\n imageQualityPlayback?: boolean\n }\n schema: object\n}\n\nexport interface UkAddressFieldComponent extends TextFieldBase {\n type: ComponentType.UkAddressField\n}\n\n// Date Fields\nexport interface DateFieldComponent extends DateFieldBase {\n type: ComponentType.DateField\n}\n\nexport interface DateTimeFieldComponent extends DateFieldBase {\n type: ComponentType.DateTimeField\n}\n\nexport interface DatePartsFieldFieldComponent extends DateFieldBase {\n type: ComponentType.DatePartsField\n}\n\nexport interface MonthYearFieldComponent extends DateFieldBase {\n type: ComponentType.MonthYearField\n}\n\nexport interface DateTimePartsFieldComponent extends DateFieldBase {\n type: ComponentType.DateTimePartsField\n}\n\nexport interface TimeFieldComponent extends DateFieldBase {\n type: ComponentType.TimeField\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n}\n\nexport interface InsetTextComponent extends ContentFieldBase {\n type: ComponentType.InsetText\n}\n\n// List Fields\nexport interface ListComponent extends ListFieldBase {\n type: ComponentType.List\n}\n\nexport interface AutocompleteFieldComponent extends ListFieldBase {\n type: ComponentType.AutocompleteField\n subType?: ComponentSubType.ListField\n}\n\nexport interface CheckboxesFieldComponent extends ListFieldBase {\n type: ComponentType.CheckboxesField\n subType?: ComponentSubType.ListField\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n subType?: ComponentSubType.ListField\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n subType?: ComponentSubType.ListField\n options: ListFieldBase['options'] & { autocomplete?: string }\n}\n\nexport type ComponentDef =\n | InsetTextComponent\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | DateFieldComponent\n | DatePartsFieldFieldComponent\n | MonthYearFieldComponent\n | DateTimeFieldComponent\n | DateTimePartsFieldComponent\n | DetailsComponent\n | EmailAddressFieldComponent\n | FileUploadFieldComponent\n | HtmlComponent\n | ListComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | TelephoneNumberFieldComponent\n | TextFieldComponent\n | TimeFieldComponent\n | UkAddressFieldComponent\n | YesNoFieldComponent\n | WebsiteFieldComponent\n\n// Components that render inputs\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | YesNoFieldComponent\n | FileUploadFieldComponent\n | DateFieldComponent\n | DateTimeFieldComponent\n | DateTimePartsFieldComponent\n | MonthYearFieldComponent\n | TimeFieldComponent\n | UkAddressFieldComponent\n | WebsiteFieldComponent\n\n// Components that render content\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n | ListComponent\n\n// Components with editors\nexport type EditorComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | TelephoneNumberFieldComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | AutocompleteFieldComponent\n | SelectFieldComponent\n | RadiosFieldComponent\n | CheckboxesFieldComponent\n | ListComponent\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n | FileUploadFieldComponent\n | DatePartsFieldFieldComponent\n | DateTimeFieldComponent\n | DateTimePartsFieldComponent\n | DateFieldComponent\n\n// Components that render lists\nexport type ListComponentsDef =\n | ListComponent\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n\n// Components that have selection fields\nexport type SelectionComponentsDef =\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | YesNoFieldComponent\n\n// Components that have custom condition operators\nexport type ConditionalComponentsDef =\n | CheckboxesFieldComponent\n | DateFieldComponent\n | DatePartsFieldFieldComponent\n | DateTimeFieldComponent\n | DateTimePartsFieldComponent\n | EmailAddressFieldComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | TextFieldComponent\n | TimeFieldComponent\n | YesNoFieldComponent\n"],"mappings":"","ignoreList":[]}
@@ -1,17 +1,17 @@
1
- import { ComponentTypes } from "../components/component-types.js";
1
+ import { ConditionalComponentTypes } from "../components/component-types.js";
2
2
  export class ConditionField {
3
3
  name;
4
4
  type;
5
5
  display;
6
6
  constructor(name, type, display) {
7
7
  if (!name || typeof name !== 'string') {
8
- throw Error(`name ${name} is not valid`);
8
+ throw new Error("ConditionField param 'name' must be a string");
9
9
  }
10
- if (!ComponentTypes.find(componentType => componentType.type === type)) {
11
- throw Error(`type ${type} is not valid`);
10
+ if (!ConditionalComponentTypes.find(componentType => componentType.type === type)) {
11
+ throw new Error("ConditionField param 'type' must be from enum ConditionalComponentTypes");
12
12
  }
13
13
  if (!display || typeof display !== 'string') {
14
- throw Error(`display ${display} is not valid`);
14
+ throw new Error("ConditionField param 'display' must be a string");
15
15
  }
16
16
  this.name = name;
17
17
  this.type = type;
@@ -1 +1 @@
1
- {"version":3,"file":"condition-field.js","names":["ComponentTypes","ConditionField","name","type","display","constructor","Error","find","componentType","from","obj"],"sources":["../../../src/conditions/condition-field.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { type ComponentType } from '~/src/components/enums.js'\n\nexport class ConditionField {\n name: string\n type: ComponentType\n display: string\n\n constructor(name: string, type: ComponentType, display: string) {\n if (!name || typeof name !== 'string') {\n throw Error(`name ${name} is not valid`)\n }\n\n if (!ComponentTypes.find((componentType) => componentType.type === type)) {\n throw Error(`type ${type} is not valid`)\n }\n\n if (!display || typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n\n this.name = name\n this.type = type\n this.display = display\n }\n\n static from(obj: { name: string; type: ComponentType; display: string }) {\n return new ConditionField(obj.name, obj.type, obj.display)\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc;AAGvB,OAAO,MAAMC,cAAc,CAAC;EAC1BC,IAAI;EACJC,IAAI;EACJC,OAAO;EAEPC,WAAWA,CAACH,IAAY,EAAEC,IAAmB,EAAEC,OAAe,EAAE;IAC9D,IAAI,CAACF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACrC,MAAMI,KAAK,CAAC,QAAQJ,IAAI,eAAe,CAAC;IAC1C;IAEA,IAAI,CAACF,cAAc,CAACO,IAAI,CAAEC,aAAa,IAAKA,aAAa,CAACL,IAAI,KAAKA,IAAI,CAAC,EAAE;MACxE,MAAMG,KAAK,CAAC,QAAQH,IAAI,eAAe,CAAC;IAC1C;IAEA,IAAI,CAACC,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC3C,MAAME,KAAK,CAAC,WAAWF,OAAO,eAAe,CAAC;IAChD;IAEA,IAAI,CAACF,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;EAEA,OAAOK,IAAIA,CAACC,GAA2D,EAAE;IACvE,OAAO,IAAIT,cAAc,CAACS,GAAG,CAACR,IAAI,EAAEQ,GAAG,CAACP,IAAI,EAAEO,GAAG,CAACN,OAAO,CAAC;EAC5D;AACF","ignoreList":[]}
1
+ {"version":3,"file":"condition-field.js","names":["ConditionalComponentTypes","ConditionField","name","type","display","constructor","Error","find","componentType","from","obj"],"sources":["../../../src/conditions/condition-field.ts"],"sourcesContent":["import { ConditionalComponentTypes } from '~/src/components/component-types.js'\nimport { type ConditionalComponentType } from '~/src/components/types.js'\n\nexport class ConditionField {\n name\n type\n display\n\n constructor(\n name?: string,\n type?: ConditionalComponentType,\n display?: string\n ) {\n if (!name || typeof name !== 'string') {\n throw new Error(\"ConditionField param 'name' must be a string\")\n }\n\n if (\n !ConditionalComponentTypes.find(\n (componentType) => componentType.type === type\n )\n ) {\n throw new Error(\n \"ConditionField param 'type' must be from enum ConditionalComponentTypes\"\n )\n }\n\n if (!display || typeof display !== 'string') {\n throw new Error(\"ConditionField param 'display' must be a string\")\n }\n\n this.name = name\n this.type = type\n this.display = display\n }\n\n static from(obj: {\n name: string\n type: ConditionalComponentType\n display: string\n }) {\n return new ConditionField(obj.name, obj.type, obj.display)\n }\n}\n"],"mappings":"AAAA,SAASA,yBAAyB;AAGlC,OAAO,MAAMC,cAAc,CAAC;EAC1BC,IAAI;EACJC,IAAI;EACJC,OAAO;EAEPC,WAAWA,CACTH,IAAa,EACbC,IAA+B,EAC/BC,OAAgB,EAChB;IACA,IAAI,CAACF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACrC,MAAM,IAAII,KAAK,CAAC,8CAA8C,CAAC;IACjE;IAEA,IACE,CAACN,yBAAyB,CAACO,IAAI,CAC5BC,aAAa,IAAKA,aAAa,CAACL,IAAI,KAAKA,IAC5C,CAAC,EACD;MACA,MAAM,IAAIG,KAAK,CACb,yEACF,CAAC;IACH;IAEA,IAAI,CAACF,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC3C,MAAM,IAAIE,KAAK,CAAC,iDAAiD,CAAC;IACpE;IAEA,IAAI,CAACJ,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;EAEA,OAAOK,IAAIA,CAACC,GAIX,EAAE;IACD,OAAO,IAAIT,cAAc,CAACS,GAAG,CAACR,IAAI,EAAEQ,GAAG,CAACP,IAAI,EAAEO,GAAG,CAACN,OAAO,CAAC;EAC5D;AACF","ignoreList":[]}
@@ -1,54 +1,71 @@
1
1
  import { ComponentType } from "../components/enums.js";
2
- import { timeUnits, dateUnits, dateTimeUnits, ConditionValue, DateDirections, RelativeTimeValue } from "./condition-values.js";
2
+ import { timeUnits, dateUnits, dateTimeUnits, ConditionValue, RelativeTimeValue } from "./condition-values.js";
3
+ import { DateDirections, Operator, OperatorName } from "./enums.js";
3
4
  const defaultOperators = {
4
- is: inline('=='),
5
- 'is not': inline('!=')
5
+ [OperatorName.Is]: inline(Operator.Is),
6
+ [OperatorName.IsNot]: inline(Operator.IsNot)
6
7
  };
7
8
  function withDefaults(param) {
8
9
  return Object.assign({}, param, defaultOperators);
9
10
  }
10
- const textBasedFieldCustomisations = {
11
- 'is longer than': lengthIs('>'),
12
- 'is shorter than': lengthIs('<'),
13
- 'has length': lengthIs('==')
11
+ const textFieldOperators = {
12
+ [OperatorName.IsLongerThan]: lengthIs(Operator.IsMoreThan),
13
+ [OperatorName.IsShorterThan]: lengthIs(Operator.IsLessThan),
14
+ [OperatorName.HasLength]: lengthIs(Operator.Is)
14
15
  };
15
16
  const absoluteDateTimeOperators = {
16
- is: absoluteDateTime('=='),
17
- 'is not': absoluteDateTime('!='),
18
- 'is before': absoluteDateTime('<'),
19
- 'is after': absoluteDateTime('>')
17
+ [OperatorName.Is]: absoluteDateTime(Operator.Is),
18
+ [OperatorName.IsNot]: absoluteDateTime(Operator.IsNot),
19
+ [OperatorName.IsBefore]: absoluteDateTime(Operator.IsLessThan),
20
+ [OperatorName.IsAfter]: absoluteDateTime(Operator.IsMoreThan)
20
21
  };
21
22
  const relativeTimeOperators = units => ({
22
- 'is at least': relativeTime('<=', '>=', units),
23
- 'is at most': relativeTime('>=', '<=', units),
24
- 'is less than': relativeTime('>', '<', units),
25
- 'is more than': relativeTime('<', '>', units)
23
+ [OperatorName.IsAtLeast]: relativeTime(Operator.IsAtMost, Operator.IsAtLeast, units),
24
+ [OperatorName.IsAtMost]: relativeTime(Operator.IsAtLeast, Operator.IsAtMost, units),
25
+ [OperatorName.IsLessThan]: relativeTime(Operator.IsMoreThan, Operator.IsLessThan, units),
26
+ [OperatorName.IsMoreThan]: relativeTime(Operator.IsLessThan, Operator.IsMoreThan, units)
26
27
  });
27
28
  export const customOperators = {
28
29
  [ComponentType.CheckboxesField]: {
29
- contains: reverseInline('in'),
30
- 'does not contain': not(reverseInline('in'))
30
+ [OperatorName.Contains]: reverseInline(Operator.Contains),
31
+ [OperatorName.DoesNotContain]: not(reverseInline(Operator.Contains))
31
32
  },
32
33
  [ComponentType.NumberField]: withDefaults({
33
- 'is at least': inline('>='),
34
- 'is at most': inline('<='),
35
- 'is less than': inline('<'),
36
- 'is more than': inline('>')
34
+ [OperatorName.IsAtLeast]: inline(Operator.IsAtLeast),
35
+ [OperatorName.IsAtMost]: inline(Operator.IsAtMost),
36
+ [OperatorName.IsLessThan]: inline(Operator.IsLessThan),
37
+ [OperatorName.IsMoreThan]: inline(Operator.IsMoreThan)
37
38
  }),
38
- [ComponentType.DateField]: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateUnits)),
39
- [ComponentType.TimeField]: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(timeUnits)),
40
- [ComponentType.DatePartsField]: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateUnits)),
41
- [ComponentType.DateTimeField]: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateTimeUnits)),
42
- [ComponentType.DateTimePartsField]: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateTimeUnits)),
43
- [ComponentType.TextField]: withDefaults(textBasedFieldCustomisations),
44
- [ComponentType.MultilineTextField]: withDefaults(textBasedFieldCustomisations),
45
- [ComponentType.EmailAddressField]: withDefaults(textBasedFieldCustomisations)
39
+ [ComponentType.DateField]: {
40
+ ...absoluteDateTimeOperators,
41
+ ...relativeTimeOperators(dateUnits)
42
+ },
43
+ [ComponentType.TimeField]: {
44
+ ...absoluteDateTimeOperators,
45
+ ...relativeTimeOperators(timeUnits)
46
+ },
47
+ [ComponentType.DatePartsField]: {
48
+ ...absoluteDateTimeOperators,
49
+ ...relativeTimeOperators(dateUnits)
50
+ },
51
+ [ComponentType.DateTimeField]: {
52
+ ...absoluteDateTimeOperators,
53
+ ...relativeTimeOperators(dateTimeUnits)
54
+ },
55
+ [ComponentType.DateTimePartsField]: {
56
+ ...absoluteDateTimeOperators,
57
+ ...relativeTimeOperators(dateTimeUnits)
58
+ },
59
+ [ComponentType.TextField]: withDefaults(textFieldOperators),
60
+ [ComponentType.MultilineTextField]: withDefaults(textFieldOperators),
61
+ [ComponentType.EmailAddressField]: withDefaults(textFieldOperators),
62
+ [ComponentType.YesNoField]: defaultOperators
46
63
  };
47
64
  export function getOperatorNames(fieldType) {
48
65
  return Object.keys(getConditionals(fieldType)).sort();
49
66
  }
50
67
  export function getExpression(fieldType, fieldName, operator, value) {
51
- return getConditionals(fieldType)[operator].expression({
68
+ return getConditionals(fieldType)[operator]?.expression({
52
69
  type: fieldType,
53
70
  name: fieldName
54
71
  }, value);
@@ -57,55 +74,66 @@ export function getOperatorConfig(fieldType, operator) {
57
74
  return getConditionals(fieldType)[operator];
58
75
  }
59
76
  function getConditionals(fieldType) {
60
- return customOperators[fieldType] || defaultOperators;
77
+ if (fieldType in customOperators) {
78
+ return customOperators[fieldType];
79
+ }
80
+ return defaultOperators;
61
81
  }
62
82
  function inline(operator) {
63
83
  return {
64
- expression: (field, value) => `${field.name} ${operator} ${formatValue(field.type, value.value)}`
84
+ expression(field, value) {
85
+ return `${field.name} ${operator} ${formatValue(field, value)}`;
86
+ }
65
87
  };
66
88
  }
67
89
  function lengthIs(operator) {
68
90
  return {
69
- expression: (field, value) => `length(${field.name}) ${operator} ${value.value}`
91
+ expression(field, value) {
92
+ return `length(${field.name}) ${operator} ${formatValue(field, value)}`;
93
+ }
70
94
  };
71
95
  }
72
96
  function reverseInline(operator) {
73
97
  return {
74
- expression: (field, value) => `${formatValue(field.type, value.value)} ${operator} ${field.name}`
98
+ expression(field, value) {
99
+ return `${formatValue(field, value)} ${operator} ${field.name}`;
100
+ }
75
101
  };
76
102
  }
77
103
  function not(operatorDefinition) {
78
104
  return {
79
- expression: (field, value) => `not (${operatorDefinition.expression(field, value)})`
105
+ expression(field, value) {
106
+ return `not (${operatorDefinition.expression(field, value)})`;
107
+ }
80
108
  };
81
109
  }
82
- function formatValue(fieldType, value) {
83
- if (fieldType === ComponentType.YesNoField || fieldType === ComponentType.NumberField) {
84
- return value;
110
+ function formatValue(field, value) {
111
+ if ('value' in value && (field.type === ComponentType.YesNoField || field.type === ComponentType.NumberField)) {
112
+ return value.value;
85
113
  }
86
- return `'${value}'`;
114
+ return `'${value.toExpression()}'`;
87
115
  }
88
116
  export const absoluteDateOrTimeOperatorNames = Object.keys(absoluteDateTimeOperators);
89
117
  export const relativeDateOrTimeOperatorNames = Object.keys(relativeTimeOperators(dateTimeUnits));
90
118
  function absoluteDateTime(operator) {
91
119
  return {
92
- expression: (field, value) => {
93
- if (value instanceof ConditionValue) {
94
- return `${field.name} ${operator} '${value.toExpression()}'`;
120
+ expression(field, value) {
121
+ if (!(value instanceof ConditionValue)) {
122
+ throw new Error("Expression param 'value' must be ConditionValue instance");
95
123
  }
96
- throw Error('only Value types are supported');
124
+ return `${field.name} ${operator} '${formatValue(field, value)}'`;
97
125
  }
98
126
  };
99
127
  }
100
128
  function relativeTime(pastOperator, futureOperator, units) {
101
129
  return {
102
130
  units,
103
- expression: (field, value) => {
104
- if (value instanceof RelativeTimeValue) {
105
- const operator = value.direction === DateDirections.PAST ? pastOperator : futureOperator;
106
- return `${field.name} ${operator} ${value.toExpression()}`;
131
+ expression(field, value) {
132
+ if (!(value instanceof RelativeTimeValue)) {
133
+ throw new Error("Expression param 'value' must be RelativeTimeValue instance");
107
134
  }
108
- throw Error('time shift requires a TimeShiftValue');
135
+ const isPast = value.direction === DateDirections.PAST;
136
+ return `${field.name} ${isPast ? pastOperator : futureOperator} ${value.toExpression()}`;
109
137
  }
110
138
  };
111
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"condition-operators.js","names":["ComponentType","timeUnits","dateUnits","dateTimeUnits","ConditionValue","DateDirections","RelativeTimeValue","defaultOperators","is","inline","withDefaults","param","Object","assign","textBasedFieldCustomisations","lengthIs","absoluteDateTimeOperators","absoluteDateTime","relativeTimeOperators","units","relativeTime","customOperators","CheckboxesField","contains","reverseInline","not","NumberField","DateField","TimeField","DatePartsField","DateTimeField","DateTimePartsField","TextField","MultilineTextField","EmailAddressField","getOperatorNames","fieldType","keys","getConditionals","sort","getExpression","fieldName","operator","value","expression","type","name","getOperatorConfig","field","formatValue","operatorDefinition","YesNoField","absoluteDateOrTimeOperatorNames","relativeDateOrTimeOperatorNames","toExpression","Error","pastOperator","futureOperator","direction","PAST"],"sources":["../../../src/conditions/condition-operators.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionValueAbstract } from '~/src/conditions/condition-value-abstract.js'\nimport {\n timeUnits,\n dateUnits,\n dateTimeUnits,\n ConditionValue,\n DateDirections,\n RelativeTimeValue\n} from '~/src/conditions/condition-values.js'\n\ntype Operator = '==' | '!=' | '>=' | '<=' | '<' | '>'\n\nconst defaultOperators = {\n is: inline('=='),\n 'is not': inline('!=')\n}\n\nfunction withDefaults<T>(param: T) {\n return Object.assign({}, param, defaultOperators)\n}\n\nconst textBasedFieldCustomisations = {\n 'is longer than': lengthIs('>'),\n 'is shorter than': lengthIs('<'),\n 'has length': lengthIs('==')\n}\n\nconst absoluteDateTimeOperators = {\n is: absoluteDateTime('=='),\n 'is not': absoluteDateTime('!='),\n 'is before': absoluteDateTime('<'),\n 'is after': absoluteDateTime('>')\n}\n\nconst relativeTimeOperators = (units) => ({\n 'is at least': relativeTime('<=', '>=', units),\n 'is at most': relativeTime('>=', '<=', units),\n 'is less than': relativeTime('>', '<', units),\n 'is more than': relativeTime('<', '>', units)\n})\n\nexport const customOperators = {\n [ComponentType.CheckboxesField]: {\n contains: reverseInline('in'),\n 'does not contain': not(reverseInline('in'))\n },\n [ComponentType.NumberField]: withDefaults({\n 'is at least': inline('>='),\n 'is at most': inline('<='),\n 'is less than': inline('<'),\n 'is more than': inline('>')\n }),\n [ComponentType.DateField]: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateUnits)\n ),\n [ComponentType.TimeField]: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(timeUnits)\n ),\n [ComponentType.DatePartsField]: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateUnits)\n ),\n [ComponentType.DateTimeField]: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateTimeUnits)\n ),\n [ComponentType.DateTimePartsField]: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateTimeUnits)\n ),\n [ComponentType.TextField]: withDefaults(textBasedFieldCustomisations),\n [ComponentType.MultilineTextField]: withDefaults(\n textBasedFieldCustomisations\n ),\n [ComponentType.EmailAddressField]: withDefaults(textBasedFieldCustomisations)\n}\n\nexport function getOperatorNames(fieldType) {\n return Object.keys(getConditionals(fieldType)).sort()\n}\n\nexport function getExpression(\n fieldType: ComponentType,\n fieldName: string,\n operator: string,\n value: ConditionValueAbstract\n) {\n return getConditionals(fieldType)[operator].expression(\n { type: fieldType, name: fieldName },\n value\n )\n}\n\nexport function getOperatorConfig(fieldType: ComponentType, operator) {\n return getConditionals(fieldType)[operator]\n}\n\nfunction getConditionals(fieldType: ComponentType) {\n return customOperators[fieldType] || defaultOperators\n}\n\nfunction inline(operator: Operator) {\n return {\n expression: (field: ComponentDef, value) =>\n `${field.name} ${operator} ${formatValue(field.type, value.value)}`\n }\n}\n\nfunction lengthIs(operator: Operator) {\n return {\n expression: (field: ComponentDef, value) =>\n `length(${field.name}) ${operator} ${value.value}`\n }\n}\n\nfunction reverseInline(operator: 'in') {\n return {\n expression: (field: ComponentDef, value) =>\n `${formatValue(field.type, value.value)} ${operator} ${field.name}`\n }\n}\n\nfunction not(operatorDefinition) {\n return {\n expression: (field: ComponentDef, value) =>\n `not (${operatorDefinition.expression(field, value)})`\n }\n}\n\nfunction formatValue(fieldType: ComponentType, value) {\n if (\n fieldType === ComponentType.YesNoField ||\n fieldType === ComponentType.NumberField\n ) {\n return value\n }\n\n return `'${value}'`\n}\n\nexport const absoluteDateOrTimeOperatorNames = Object.keys(\n absoluteDateTimeOperators\n)\nexport const relativeDateOrTimeOperatorNames = Object.keys(\n relativeTimeOperators(dateTimeUnits)\n)\n\nfunction absoluteDateTime(operator: Operator) {\n return {\n expression: (field: ComponentDef, value) => {\n if (value instanceof ConditionValue) {\n return `${field.name} ${operator} '${value.toExpression()}'`\n }\n throw Error('only Value types are supported')\n }\n }\n}\n\nfunction relativeTime(pastOperator, futureOperator, units) {\n return {\n units,\n expression: (field: ComponentDef, value) => {\n if (value instanceof RelativeTimeValue) {\n const operator =\n value.direction === DateDirections.PAST\n ? pastOperator\n : futureOperator\n return `${field.name} ${operator} ${value.toExpression()}`\n }\n throw Error('time shift requires a TimeShiftValue')\n }\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa;AAGtB,SACEC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,iBAAiB;AAKnB,MAAMC,gBAAgB,GAAG;EACvBC,EAAE,EAAEC,MAAM,CAAC,IAAI,CAAC;EAChB,QAAQ,EAAEA,MAAM,CAAC,IAAI;AACvB,CAAC;AAED,SAASC,YAAYA,CAAIC,KAAQ,EAAE;EACjC,OAAOC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEF,KAAK,EAAEJ,gBAAgB,CAAC;AACnD;AAEA,MAAMO,4BAA4B,GAAG;EACnC,gBAAgB,EAAEC,QAAQ,CAAC,GAAG,CAAC;EAC/B,iBAAiB,EAAEA,QAAQ,CAAC,GAAG,CAAC;EAChC,YAAY,EAAEA,QAAQ,CAAC,IAAI;AAC7B,CAAC;AAED,MAAMC,yBAAyB,GAAG;EAChCR,EAAE,EAAES,gBAAgB,CAAC,IAAI,CAAC;EAC1B,QAAQ,EAAEA,gBAAgB,CAAC,IAAI,CAAC;EAChC,WAAW,EAAEA,gBAAgB,CAAC,GAAG,CAAC;EAClC,UAAU,EAAEA,gBAAgB,CAAC,GAAG;AAClC,CAAC;AAED,MAAMC,qBAAqB,GAAIC,KAAK,KAAM;EACxC,aAAa,EAAEC,YAAY,CAAC,IAAI,EAAE,IAAI,EAAED,KAAK,CAAC;EAC9C,YAAY,EAAEC,YAAY,CAAC,IAAI,EAAE,IAAI,EAAED,KAAK,CAAC;EAC7C,cAAc,EAAEC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAED,KAAK,CAAC;EAC7C,cAAc,EAAEC,YAAY,CAAC,GAAG,EAAE,GAA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ACe,SAAS,KAAKrD,cAAc,CAACsD,IAAI,GACnCH,YAAY,GACZC,cAAc;QACpB,OAAO,GAAGT,KAAK,CAACF,IAAI,IAAIJ,QAAQ,IAAIC,KAAK,CAACW,YAAY,CAAC,CAAC,EAAE;MAC5D;MACA,MAAMC,KAAK,CAAC,sCAAsC,CAAC;IACrD;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"condition-operators.js","names":["ComponentType","timeUnits","dateUnits","dateTimeUnits","ConditionValue","RelativeTimeValue","DateDirections","Operator","OperatorName","defaultOperators","Is","inline","IsNot","withDefaults","param","Object","assign","textFieldOperators","IsLongerThan","lengthIs","IsMoreThan","IsShorterThan","IsLessThan","HasLength","absoluteDateTimeOperators","absoluteDateTime","IsBefore","IsAfter","relativeTimeOperators","units","IsAtLeast","relativeTime","IsAtMost","customOperators","CheckboxesField","Contains","reverseInline","DoesNotContain","not","NumberField","DateField","TimeField","DatePartsField","DateTimeField","DateTimePartsField","TextField","MultilineTextField","EmailAddressField","YesNoField","getOperatorNames","fieldType","keys","getConditionals","sort","getExpression","fieldName","operator","value","expression","type","name","getOperatorConfig","field","formatValue","operatorDefinition","toExpression","absoluteDateOrTimeOperatorNames","relativeDateOrTimeOperatorNames","Error","pastOperator","futureOperator","isPast","direction","PAST"],"sources":["../../../src/conditions/condition-operators.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n type ConditionalComponentType,\n type ComponentDef\n} from '~/src/components/types.js'\nimport {\n timeUnits,\n dateUnits,\n dateTimeUnits,\n ConditionValue,\n RelativeTimeValue\n} from '~/src/conditions/condition-values.js'\nimport {\n DateDirections,\n Operator,\n OperatorName\n} from '~/src/conditions/enums.js'\nimport {\n type Conditionals,\n type DateUnits,\n type OperatorDefinition,\n type TimeUnits\n} from '~/src/conditions/types.js'\n\nconst defaultOperators = {\n [OperatorName.Is]: inline(Operator.Is),\n [OperatorName.IsNot]: inline(Operator.IsNot)\n}\n\nfunction withDefaults<T>(param: T) {\n return Object.assign({}, param, defaultOperators)\n}\n\nconst textFieldOperators = {\n [OperatorName.IsLongerThan]: lengthIs(Operator.IsMoreThan),\n [OperatorName.IsShorterThan]: lengthIs(Operator.IsLessThan),\n [OperatorName.HasLength]: lengthIs(Operator.Is)\n}\n\nconst absoluteDateTimeOperators = {\n [OperatorName.Is]: absoluteDateTime(Operator.Is),\n [OperatorName.IsNot]: absoluteDateTime(Operator.IsNot),\n [OperatorName.IsBefore]: absoluteDateTime(Operator.IsLessThan),\n [OperatorName.IsAfter]: absoluteDateTime(Operator.IsMoreThan)\n}\n\nconst relativeTimeOperators = (units: DateUnits | TimeUnits) => ({\n [OperatorName.IsAtLeast]: relativeTime(\n Operator.IsAtMost,\n Operator.IsAtLeast,\n units\n ),\n [OperatorName.IsAtMost]: relativeTime(\n Operator.IsAtLeast,\n Operator.IsAtMost,\n units\n ),\n [OperatorName.IsLessThan]: relativeTime(\n Operator.IsMoreThan,\n Operator.IsLessThan,\n units\n ),\n [OperatorName.IsMoreThan]: relativeTime(\n Operator.IsLessThan,\n Operator.IsMoreThan,\n units\n )\n})\n\nexport const customOperators = {\n [ComponentType.CheckboxesField]: {\n [OperatorName.Contains]: reverseInline(Operator.Contains),\n [OperatorName.DoesNotContain]: not(reverseInline(Operator.Contains))\n },\n [ComponentType.NumberField]: withDefaults({\n [OperatorName.IsAtLeast]: inline(Operator.IsAtLeast),\n [OperatorName.IsAtMost]: inline(Operator.IsAtMost),\n [OperatorName.IsLessThan]: inline(Operator.IsLessThan),\n [OperatorName.IsMoreThan]: inline(Operator.IsMoreThan)\n }),\n [ComponentType.DateField]: {\n ...absoluteDateTimeOperators,\n ...relativeTimeOperators(dateUnits)\n },\n [ComponentType.TimeField]: {\n ...absoluteDateTimeOperators,\n ...relativeTimeOperators(timeUnits)\n },\n [ComponentType.DatePartsField]: {\n ...absoluteDateTimeOperators,\n ...relativeTimeOperators(dateUnits)\n },\n [ComponentType.DateTimeField]: {\n ...absoluteDateTimeOperators,\n ...relativeTimeOperators(dateTimeUnits)\n },\n [ComponentType.DateTimePartsField]: {\n ...absoluteDateTimeOperators,\n ...relativeTimeOperators(dateTimeUnits)\n },\n [ComponentType.TextField]: withDefaults(textFieldOperators),\n [ComponentType.MultilineTextField]: withDefaults(textFieldOperators),\n [ComponentType.EmailAddressField]: withDefaults(textFieldOperators),\n [ComponentType.YesNoField]: defaultOperators\n} as const satisfies Record<ConditionalComponentType, Partial<Conditionals>>\n\nexport function getOperatorNames(fieldType: ConditionalComponentType) {\n return Object.keys(getConditionals(fieldType)).sort()\n}\n\nexport function getExpression(\n fieldType: ConditionalComponentType,\n fieldName: string,\n operator: OperatorName,\n value: ConditionValue | RelativeTimeValue\n) {\n return getConditionals(fieldType)[operator]?.expression(\n { type: fieldType, name: fieldName },\n value\n )\n}\n\nexport function getOperatorConfig(\n fieldType: ConditionalComponentType,\n operator: OperatorName\n) {\n return getConditionals(fieldType)[operator]\n}\n\nfunction getConditionals(\n fieldType: ConditionalComponentType\n): Partial<Conditionals> {\n if (fieldType in customOperators) {\n return customOperators[fieldType]\n }\n\n return defaultOperators\n}\n\nfunction inline(operator: Operator): OperatorDefinition {\n return {\n expression(field, value) {\n return `${field.name} ${operator} ${formatValue(field, value)}`\n }\n }\n}\n\nfunction lengthIs(operator: Operator): OperatorDefinition {\n return {\n expression(field, value) {\n return `length(${field.name}) ${operator} ${formatValue(field, value)}`\n }\n }\n}\n\nfunction reverseInline(operator: Operator.Contains): OperatorDefinition {\n return {\n expression(field, value) {\n return `${formatValue(field, value)} ${operator} ${field.name}`\n }\n }\n}\n\nfunction not(operatorDefinition: OperatorDefinition): OperatorDefinition {\n return {\n expression(field, value) {\n return `not (${operatorDefinition.expression(field, value)})`\n }\n }\n}\n\nfunction formatValue(\n field: Pick<ComponentDef, 'type'>,\n value: ConditionValue | RelativeTimeValue\n) {\n if (\n 'value' in value &&\n (field.type === ComponentType.YesNoField ||\n field.type === ComponentType.NumberField)\n ) {\n return value.value\n }\n\n return `'${value.toExpression()}'`\n}\n\nexport const absoluteDateOrTimeOperatorNames = Object.keys(\n absoluteDateTimeOperators\n)\n\nexport const relativeDateOrTimeOperatorNames = Object.keys(\n relativeTimeOperators(dateTimeUnits)\n)\n\nfunction absoluteDateTime(operator: Operator): OperatorDefinition {\n return {\n expression(field, value) {\n if (!(value instanceof ConditionValue)) {\n throw new Error(\n \"Expression param 'value' must be ConditionValue instance\"\n )\n }\n\n return `${field.name} ${operator} '${formatValue(field, value)}'`\n }\n }\n}\n\nfunction relativeTime(\n pastOperator: Operator,\n futureOperator: Operator,\n units: DateUnits | TimeUnits\n): OperatorDefinition {\n return {\n units,\n expression(field, value) {\n if (!(value instanceof RelativeTimeValue)) {\n throw new Error(\n \"Expression param 'value' must be RelativeTimeValue instance\"\n )\n }\n\n const isPast = value.direction === DateDirections.PAST\n return `${field.name} ${isPast ? pastOperator : futureOperator} ${value.toExpression()}`\n }\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa;AAKtB,SACEC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,cAAc,EACdC,iBAAiB;AAEnB,SACEC,cAAc,EACdC,QAAQ,EACRC,YAAY;AASd,MAAMC,gBAAgB,GAAG;EACvB,CAACD,YAAY,CAACE,EAAE,GAAGC,MAAM,CAACJ,QAAQ,CAACG,EAAE,CAAC;EACtC,CAACF,YAAY,CAACI,KAAK,GAAGD,MAAM,CAACJ,QAAQ,CAACK,KAAK;AAC7C,CAAC;AAED,SAASC,YAAYA,CAAIC,KAAQ,EAAE;EACjC,OAAOC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEF,KAAK,EAAEL,gBAAgB,CAAC;AACnD;AAEA,MAAMQ,kBAAkB,GAAG;EACzB,CAACT,YAAY,CAACU,YAAY,GAAGC,QAAQ,CAACZ,QAAQ,CAACa,UAAU,CAAC;EAC1D,CAACZ,YAAY,CAACa,aAAa,GAAGF,QAAQ,CAACZ,QAAQ,CAACe,UAAU,CAAC;EAC3D,CAACd,YAA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YAAYpD,iBAAiB,CAAC,EAAE;QACzC,MAAM,IAAI+D,KAAK,CACb,6DACF,CAAC;MACH;MAEA,MAAMG,MAAM,GAAGd,KAAK,CAACe,SAAS,KAAKlE,cAAc,CAACmE,IAAI;MACtD,OAAO,GAAGX,KAAK,CAACF,IAAI,IAAIW,MAAM,GAAGF,YAAY,GAAGC,cAAc,IAAIb,KAAK,CAACQ,YAAY,CAAC,CAAC,EAAE;IAC1F;EACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"condition-ref.js","names":["ConditionAbstract","ConditionRef","conditionName","conditionDisplayName","constructor","coordinator","Error","asFirstCondition","_asFirstCondition","conditionString","conditionExpression","clone"],"sources":["../../../src/conditions/condition-ref.ts"],"sourcesContent":["import { ConditionAbstract } from '~/src/conditions/condition-abstract.js'\nimport { type Coordinator } from '~/src/conditions/enums.js'\n\nexport class ConditionRef extends ConditionAbstract {\n conditionName: string\n conditionDisplayName: string\n\n constructor(\n conditionName: string,\n conditionDisplayName: string,\n coordinator: Coordinator | undefined\n ) {\n super(coordinator)\n\n if (typeof conditionName !== 'string') {\n throw new Error(\"ConditionRef param 'conditionName' must be a string\")\n }\n\n if (typeof conditionDisplayName !== 'string') {\n throw new Error(\n \"ConditionRef param 'conditionDisplayName' must be a string\"\n )\n }\n\n this.conditionName = conditionName\n this.conditionDisplayName = conditionDisplayName\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.conditionDisplayName}'`\n }\n\n conditionExpression() {\n return this.conditionName\n }\n\n clone() {\n return new ConditionRef(\n this.conditionName,\n this.conditionDisplayName,\n this.coordinator\n )\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB;AAG1B,OAAO,MAAMC,YAAY,SAASD,iBAAiB,CAAC;EAClDE,aAAa;EACbC,oBAAoB;EAEpBC,WAAWA,CACTF,aAAqB,EACrBC,oBAA4B,EAC5BE,WAAoC,EACpC;IACA,KAAK,CAACA,WAAW,CAAC;IAElB,IAAI,OAAOH,aAAa,KAAK,QAAQ,EAAE;MACrC,MAAM,IAAII,KAAK,CAAC,qDAAqD,CAAC;IACxE;IAEA,IAAI,OAAOH,oBAAoB,KAAK,QAAQ,EAAE;MAC5C,MAAM,IAAIG,KAAK,CACb,4DACF,CAAC;IACH;IAEA,IAAI,CAACJ,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACC,oBAAoB,GAAGA,oBAAoB;EAClD;EAEAI,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACC,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI;EACb;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAO,IAAI,IAAI,CAACN,oBAAoB,GAAG;EACzC;EAEAO,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACR,aAAa;EAC3B;EAEAS,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIV,YAAY,CACrB,IAAI,CAACC,aAAa,EAClB,IAAI,CAACC,oBAAoB,EACzB,IAAI,CAACE,WACP,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"condition-ref.js","names":["ConditionAbstract","ConditionRef","conditionName","conditionDisplayName","constructor","coordinator","Error","asFirstCondition","_asFirstCondition","conditionString","conditionExpression","clone"],"sources":["../../../src/conditions/condition-ref.ts"],"sourcesContent":["import { ConditionAbstract } from '~/src/conditions/condition-abstract.js'\nimport { type Coordinator } from '~/src/conditions/enums.js'\n\nexport class ConditionRef extends ConditionAbstract {\n conditionName\n conditionDisplayName\n\n constructor(\n conditionName: string,\n conditionDisplayName: string,\n coordinator: Coordinator | undefined\n ) {\n super(coordinator)\n\n if (typeof conditionName !== 'string') {\n throw new Error(\"ConditionRef param 'conditionName' must be a string\")\n }\n\n if (typeof conditionDisplayName !== 'string') {\n throw new Error(\n \"ConditionRef param 'conditionDisplayName' must be a string\"\n )\n }\n\n this.conditionName = conditionName\n this.conditionDisplayName = conditionDisplayName\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.conditionDisplayName}'`\n }\n\n conditionExpression() {\n return this.conditionName\n }\n\n clone() {\n return new ConditionRef(\n this.conditionName,\n this.conditionDisplayName,\n this.coordinator\n )\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB;AAG1B,OAAO,MAAMC,YAAY,SAASD,iBAAiB,CAAC;EAClDE,aAAa;EACbC,oBAAoB;EAEpBC,WAAWA,CACTF,aAAqB,EACrBC,oBAA4B,EAC5BE,WAAoC,EACpC;IACA,KAAK,CAACA,WAAW,CAAC;IAElB,IAAI,OAAOH,aAAa,KAAK,QAAQ,EAAE;MACrC,MAAM,IAAII,KAAK,CAAC,qDAAqD,CAAC;IACxE;IAEA,IAAI,OAAOH,oBAAoB,KAAK,QAAQ,EAAE;MAC5C,MAAM,IAAIG,KAAK,CACb,4DACF,CAAC;IACH;IAEA,IAAI,CAACJ,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACC,oBAAoB,GAAGA,oBAAoB;EAClD;EAEAI,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACC,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI;EACb;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAO,IAAI,IAAI,CAACN,oBAAoB,GAAG;EACzC;EAEAO,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACR,aAAa;EAC3B;EAEAS,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIV,YAAY,CACrB,IAAI,CAACC,aAAa,EAClB,IAAI,CAACC,oBAAoB,EACzB,IAAI,CAACE,WACP,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import { ConditionValueAbstract } from "./condition-value-abstract.js";
2
+ import { ConditionType, DateDirections } from "./enums.js";
2
3
  export class ConditionValue extends ConditionValueAbstract {
3
4
  type;
4
5
  value;
@@ -11,7 +12,7 @@ export class ConditionValue extends ConditionValueAbstract {
11
12
  throw new Error("ConditionValue param 'display' must be a string");
12
13
  }
13
14
  super();
14
- this.type = 'Value';
15
+ this.type = ConditionType.Value;
15
16
  this.value = value;
16
17
  this.display = display ?? value;
17
18
  }
@@ -28,11 +29,6 @@ export class ConditionValue extends ConditionValueAbstract {
28
29
  return ConditionValue.from(this);
29
30
  }
30
31
  }
31
- export let DateDirections = /*#__PURE__*/function (DateDirections) {
32
- DateDirections["FUTURE"] = "in the future";
33
- DateDirections["PAST"] = "in the past";
34
- return DateDirections;
35
- }({});
36
32
  export const dateUnits = {
37
33
  YEARS: {
38
34
  display: 'year(s)',
@@ -61,7 +57,10 @@ export const timeUnits = {
61
57
  value: 'seconds'
62
58
  }
63
59
  };
64
- export const dateTimeUnits = Object.assign({}, dateUnits, timeUnits);
60
+ export const dateTimeUnits = {
61
+ ...dateUnits,
62
+ ...timeUnits
63
+ };
65
64
  export class RelativeTimeValue extends ConditionValueAbstract {
66
65
  type;
67
66
  timePeriod;
@@ -79,7 +78,7 @@ export class RelativeTimeValue extends ConditionValueAbstract {
79
78
  throw new Error("RelativeTimeValue param 'direction' must be from enum DateDirections");
80
79
  }
81
80
  super();
82
- this.type = 'RelativeTime';
81
+ this.type = ConditionType.RelativeTime;
83
82
  this.timePeriod = timePeriod;
84
83
  this.timeUnit = timeUnit;
85
84
  this.direction = direction;
@@ -101,9 +100,9 @@ export class RelativeTimeValue extends ConditionValueAbstract {
101
100
  }
102
101
  export function conditionValueFrom(obj) {
103
102
  switch (obj.type) {
104
- case 'Value':
103
+ case ConditionType.Value:
105
104
  return ConditionValue.from(obj);
106
- case 'RelativeTime':
105
+ case ConditionType.RelativeTime:
107
106
  return RelativeTimeValue.from(obj);
108
107
  }
109
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"condition-values.js","names":["ConditionValueAbstract","ConditionValue","type","value","display","constructor","Error","toPresentationString","toExpression","from","obj","clone","DateDirections","dateUnits","YEARS","MONTHS","DAYS","timeUnits","HOURS","MINUTES","SECONDS","dateTimeUnits","Object","assign","RelativeTimeValue","timePeriod","timeUnit","direction","timeOnly","values","map","unit","includes","PAST","Number","conditionValueFrom"],"sources":["../../../src/conditions/condition-values.ts"],"sourcesContent":["import { ConditionValueAbstract } from '~/src/conditions/condition-value-abstract.js'\nimport {\n type DateTimeUnitValues,\n type DateUnits,\n type TimeUnits\n} from '~/src/conditions/types.js'\n\nexport class ConditionValue\n extends ConditionValueAbstract\n implements ConditionValueFrom\n{\n type: 'Value'\n value: string\n display: string\n\n constructor(value: string, display?: string) {\n if (!value || typeof value !== 'string') {\n throw new Error(\"ConditionValue param 'value' must be a string\")\n }\n\n if (display && typeof display !== 'string') {\n throw new Error(\"ConditionValue param 'display' must be a string\")\n }\n\n super()\n\n this.type = 'Value'\n this.value = value\n this.display = display ?? value\n }\n\n toPresentationString() {\n return this.display\n }\n\n toExpression() {\n return this.value\n }\n\n static from(obj: ConditionValue | ConditionValueFrom) {\n return new ConditionValue(obj.value, obj.display)\n }\n\n clone() {\n return ConditionValue.from(this)\n }\n}\n\nexport interface ConditionValueFrom {\n value: string\n display?: string\n}\n\nexport enum DateDirections {\n FUTURE = 'in the future',\n PAST = 'in the past'\n}\n\nexport const dateUnits: DateUnits = {\n YEARS: { display: 'year(s)', value: 'years' },\n MONTHS: { display: 'month(s)', value: 'months' },\n DAYS: { display: 'day(s)', value: 'days' }\n}\n\nexport const timeUnits: TimeUnits = {\n HOURS: { display: 'hour(s)', value: 'hours' },\n MINUTES: { display: 'minute(s)', value: 'minutes' },\n SECONDS: { display: 'second(s)', value: 'seconds' }\n}\n\nexport const dateTimeUnits: DateUnits & TimeUnits = Object.assign(\n {},\n dateUnits,\n timeUnits\n)\n\nexport class RelativeTimeValue\n extends ConditionValueAbstract\n implements RelativeTimeValueFrom\n{\n type: 'RelativeTime'\n timePeriod: string\n timeUnit: DateTimeUnitValues\n direction: DateDirections\n timeOnly: boolean\n\n constructor(\n timePeriod: string,\n timeUnit: DateTimeUnitValues,\n direction: DateDirections,\n timeOnly = false\n ) {\n if (typeof timePeriod !== 'string') {\n throw new Error(\"RelativeTimeValue param 'timePeriod' must be a string\")\n }\n\n if (\n !Object.values(dateTimeUnits)\n .map((unit) => unit.value)\n .includes(timeUnit)\n ) {\n throw new Error(\n \"RelativeTimeValue param 'dateTimeUnits' must only include DateTimeUnitValues keys\"\n )\n }\n\n if (!Object.values(DateDirections).includes(direction)) {\n throw new Error(\n \"RelativeTimeValue param 'direction' must be from enum DateDirections\"\n )\n }\n\n super()\n\n this.type = 'RelativeTime'\n this.timePeriod = timePeriod\n this.timeUnit = timeUnit\n this.direction = direction\n this.timeOnly = timeOnly\n }\n\n toPresentationString() {\n return `${this.timePeriod} ${this.timeUnit} ${this.direction}`\n }\n\n toExpression(): string {\n const timePeriod =\n this.direction === DateDirections.PAST\n ? 0 - Number(this.timePeriod)\n : this.timePeriod\n return this.timeOnly\n ? `timeForComparison(${timePeriod}, '${this.timeUnit}')`\n : `dateForComparison(${timePeriod}, '${this.timeUnit}')`\n }\n\n static from(obj: RelativeTimeValue | RelativeTimeValueFrom) {\n return new RelativeTimeValue(\n obj.timePeriod,\n obj.timeUnit,\n obj.direction,\n obj.timeOnly\n )\n }\n\n clone() {\n return RelativeTimeValue.from(this)\n }\n}\n\nexport interface RelativeTimeValueFrom {\n timePeriod: string\n timeUnit: DateTimeUnitValues\n direction: DateDirections\n timeOnly: boolean\n}\n\nexport function conditionValueFrom(\n obj:\n | ConditionValue\n | RelativeTimeValue\n | ({ type: 'Value' } & ConditionValueFrom)\n | ({ type: 'RelativeTime' } & RelativeTimeValueFrom)\n) {\n switch (obj.type) {\n case 'Value':\n return ConditionValue.from(obj)\n\n case 'RelativeTime':\n return RelativeTimeValue.from(obj)\n }\n}\n"],"mappings":"AAAA,SAASA,sBAAsB;AAO/B,OAAO,MAAMC,cAAc,SACjBD,sBAAsB,CAEhC;EACEE,IAAI;EACJC,KAAK;EACLC,OAAO;EAEPC,WAAWA,CAACF,KAAa,EAAEC,OAAgB,EAAE;IAC3C,IAAI,CAACD,KAAK,IA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GACd,IAAI,CAACE,SAAS,KAAKf,cAAc,CAACqB,IAAI,GAClC,CAAC,GAAGC,MAAM,CAAC,IAAI,CAACT,UAAU,CAAC,GAC3B,IAAI,CAACA,UAAU;IACrB,OAAO,IAAI,CAACG,QAAQ,GAChB,qBAAqBH,UAAU,MAAM,IAAI,CAACC,QAAQ,IAAI,GACtD,qBAAqBD,UAAU,MAAM,IAAI,CAACC,QAAQ,IAAI;EAC5D;EAEA,OAAOjB,IAAIA,CAACC,GAA8C,EAAE;IAC1D,OAAO,IAAIc,iBAAiB,CAC1Bd,GAAG,CAACe,UAAU,EACdf,GAAG,CAACgB,QAAQ,EACZhB,GAAG,CAACiB,SAAS,EACbjB,GAAG,CAACkB,QACN,CAAC;EACH;EAEAjB,KAAKA,CAAA,EAAG;IACN,OAAOa,iBAAiB,CAACf,IAAI,CAAC,IAAI,CAAC;EACrC;AACF;AASA,OAAO,SAAS0B,kBAAkBA,CAChCzB,GAIsD,EACtD;EACA,QAAQA,GAAG,CAACR,IAAI;IACd,KAAK,OAAO;MACV,OAAOD,cAAc,CAACQ,IAAI,CAACC,GAAG,CAAC;IAEjC,KAAK,cAAc;MACjB,OAAOc,iBAAiB,CAACf,IAAI,CAACC,GAAG,CAAC;EACtC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"condition-values.js","names":["ConditionValueAbstract","ConditionType","DateDirections","ConditionValue","type","value","display","constructor","Error","Value","toPresentationString","toExpression","from","obj","clone","dateUnits","YEARS","MONTHS","DAYS","timeUnits","HOURS","MINUTES","SECONDS","dateTimeUnits","RelativeTimeValue","timePeriod","timeUnit","direction","timeOnly","Object","values","map","unit","includes","RelativeTime","PAST","Number","conditionValueFrom"],"sources":["../../../src/conditions/condition-values.ts"],"sourcesContent":["import { ConditionValueAbstract } from '~/src/conditions/condition-value-abstract.js'\nimport { ConditionType, DateDirections } from '~/src/conditions/enums.js'\nimport {\n type DateTimeUnitValues,\n type DateUnits,\n type TimeUnits\n} from '~/src/conditions/types.js'\n\nexport class ConditionValue\n extends ConditionValueAbstract\n implements ConditionValueFrom\n{\n type: ConditionType.Value\n value: string\n display: string\n\n constructor(value: string, display?: string) {\n if (!value || typeof value !== 'string') {\n throw new Error(\"ConditionValue param 'value' must be a string\")\n }\n\n if (display && typeof display !== 'string') {\n throw new Error(\"ConditionValue param 'display' must be a string\")\n }\n\n super()\n\n this.type = ConditionType.Value\n this.value = value\n this.display = display ?? value\n }\n\n toPresentationString() {\n return this.display\n }\n\n toExpression() {\n return this.value\n }\n\n static from(obj: ConditionValue | ConditionValueFrom) {\n return new ConditionValue(obj.value, obj.display)\n }\n\n clone() {\n return ConditionValue.from(this)\n }\n}\n\nexport interface ConditionValueFrom {\n value: string\n display?: string\n}\n\nexport const dateUnits: DateUnits = {\n YEARS: { display: 'year(s)', value: 'years' },\n MONTHS: { display: 'month(s)', value: 'months' },\n DAYS: { display: 'day(s)', value: 'days' }\n} as const\n\nexport const timeUnits: TimeUnits = {\n HOURS: { display: 'hour(s)', value: 'hours' },\n MINUTES: { display: 'minute(s)', value: 'minutes' },\n SECONDS: { display: 'second(s)', value: 'seconds' }\n} as const\n\nexport const dateTimeUnits: DateUnits & TimeUnits = {\n ...dateUnits,\n ...timeUnits\n} as const\n\nexport class RelativeTimeValue\n extends ConditionValueAbstract\n implements RelativeTimeValueFrom\n{\n type: ConditionType.RelativeTime\n timePeriod: string\n timeUnit: DateTimeUnitValues\n direction: DateDirections\n timeOnly: boolean\n\n constructor(\n timePeriod: string,\n timeUnit: DateTimeUnitValues,\n direction: DateDirections,\n timeOnly = false\n ) {\n if (typeof timePeriod !== 'string') {\n throw new Error(\"RelativeTimeValue param 'timePeriod' must be a string\")\n }\n\n if (\n !Object.values(dateTimeUnits)\n .map((unit) => unit.value)\n .includes(timeUnit)\n ) {\n throw new Error(\n \"RelativeTimeValue param 'dateTimeUnits' must only include DateTimeUnitValues keys\"\n )\n }\n\n if (!Object.values(DateDirections).includes(direction)) {\n throw new Error(\n \"RelativeTimeValue param 'direction' must be from enum DateDirections\"\n )\n }\n\n super()\n\n this.type = ConditionType.RelativeTime\n this.timePeriod = timePeriod\n this.timeUnit = timeUnit\n this.direction = direction\n this.timeOnly = timeOnly\n }\n\n toPresentationString() {\n return `${this.timePeriod} ${this.timeUnit} ${this.direction}`\n }\n\n toExpression(): string {\n const timePeriod =\n this.direction === DateDirections.PAST\n ? 0 - Number(this.timePeriod)\n : this.timePeriod\n return this.timeOnly\n ? `timeForComparison(${timePeriod}, '${this.timeUnit}')`\n : `dateForComparison(${timePeriod}, '${this.timeUnit}')`\n }\n\n static from(obj: RelativeTimeValue | RelativeTimeValueFrom) {\n return new RelativeTimeValue(\n obj.timePeriod,\n obj.timeUnit,\n obj.direction,\n obj.timeOnly\n )\n }\n\n clone() {\n return RelativeTimeValue.from(this)\n }\n}\n\nexport interface RelativeTimeValueFrom {\n timePeriod: string\n timeUnit: DateTimeUnitValues\n direction: DateDirections\n timeOnly: boolean\n}\n\nexport function conditionValueFrom(\n obj:\n | ConditionValue\n | RelativeTimeValue\n | ({ type: ConditionType.Value } & ConditionValueFrom)\n | ({ type: ConditionType.RelativeTime } & RelativeTimeValueFrom)\n) {\n switch (obj.type) {\n case ConditionType.Value:\n return ConditionValue.from(obj)\n\n case ConditionType.RelativeTime:\n return RelativeTimeValue.from(obj)\n }\n}\n"],"mappings":"AAAA,SAASA,sBAAsB;AAC/B,SAASC,aAAa,EAAEC,cAAc;AAOtC,OAAO,MAAMC,cAAc,SACjBH,sBAAsB,CAEhC;EACEI,IAAI;EACJC,KAAK;EACLC,OAAO;EAEPC,WAAWA,CAACF,KAAa,EAAEC,OAAgB,EAAE;IAC3C,IAAI,CAACD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MACvC,MAAM,IAAIG,KAAK,CAAC,+CAA+C,CAAC;IAClE;IAEA,IAAIF,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC1C,MAAM,IAAIE,KAAK,CAAC,iDAAiD,CAAC;I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