@defra/forms-model 3.0.10 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/component-types.js +201 -219
- package/dist/browser/components/component-types.js.map +1 -1
- package/dist/browser/components/conditional-component-types.js +9 -27
- package/dist/browser/components/conditional-component-types.js.map +1 -1
- package/dist/browser/components/enums.js +27 -45
- package/dist/browser/components/enums.js.map +1 -1
- package/dist/browser/components/index.js +3 -35
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/components/types.js +1 -15
- package/dist/browser/conditions/condition-abstract.js +42 -60
- package/dist/browser/conditions/condition-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-field.js +23 -41
- package/dist/browser/conditions/condition-field.js.map +1 -1
- package/dist/browser/conditions/condition-group-def.js +23 -42
- package/dist/browser/conditions/condition-group-def.js.map +1 -1
- package/dist/browser/conditions/condition-group.js +43 -61
- package/dist/browser/conditions/condition-group.js.map +1 -1
- package/dist/browser/conditions/condition-model.js +185 -196
- package/dist/browser/conditions/condition-model.js.map +1 -1
- package/dist/browser/conditions/condition-operators.js +103 -124
- package/dist/browser/conditions/condition-operators.js.map +1 -1
- package/dist/browser/conditions/condition-ref.js +29 -47
- package/dist/browser/conditions/condition-ref.js.map +1 -1
- package/dist/browser/conditions/condition-value-abstract.js +19 -37
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-value-registration.js +15 -34
- package/dist/browser/conditions/condition-value-registration.js.map +1 -1
- package/dist/browser/conditions/condition-values.js +98 -118
- package/dist/browser/conditions/condition-values.js.map +1 -1
- package/dist/browser/conditions/condition.js +36 -51
- package/dist/browser/conditions/condition.js.map +1 -1
- package/dist/browser/conditions/enums.js +5 -23
- package/dist/browser/conditions/enums.js.map +1 -1
- package/dist/browser/conditions/helpers.js +6 -25
- package/dist/browser/conditions/helpers.js.map +1 -1
- package/dist/browser/conditions/index.js +10 -143
- package/dist/browser/conditions/index.js.map +1 -1
- package/dist/browser/conditions/inline-condition-model.js +372 -394
- package/dist/browser/conditions/inline-condition-model.js.map +1 -1
- package/dist/browser/conditions/inline-condition-operators.js +103 -124
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -1
- package/dist/browser/conditions/inline-condition-values.js +123 -145
- package/dist/browser/conditions/inline-condition-values.js.map +1 -1
- package/dist/browser/conditions/types.js +1 -15
- package/dist/browser/conditions/types.js.map +1 -1
- package/dist/browser/data-model/conditions-wrapper.js +27 -45
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -1
- package/dist/browser/data-model/enums.js +6 -24
- package/dist/browser/data-model/enums.js.map +1 -1
- package/dist/browser/data-model/index.js +3 -35
- package/dist/browser/data-model/index.js.map +1 -1
- package/dist/browser/data-model/input-wrapper.js +28 -46
- package/dist/browser/data-model/input-wrapper.js.map +1 -1
- package/dist/browser/data-model/types.js +7 -25
- package/dist/browser/data-model/types.js.map +1 -1
- package/dist/browser/form/form-configuration.js +16 -35
- package/dist/browser/form/form-configuration.js.map +1 -1
- package/dist/browser/form/index.js +1 -23
- package/dist/browser/form/index.js.map +1 -1
- package/dist/browser/index.js +8 -97
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/migration/index.js +1 -23
- package/dist/browser/migration/index.js.map +1 -1
- package/dist/browser/migration/migration.0-2.js +42 -60
- package/dist/browser/migration/migration.0-2.js.map +1 -1
- package/dist/browser/migration/migration.1-2.js +83 -99
- package/dist/browser/migration/migration.1-2.js.map +1 -1
- package/dist/browser/migration/types.js +1 -15
- package/dist/browser/migration/whichMigrations.js +20 -36
- package/dist/browser/migration/whichMigrations.js.map +1 -1
- package/dist/browser/schema/index.js +1 -29
- package/dist/browser/schema/index.js.map +1 -1
- package/dist/browser/schema/schema.js +231 -249
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/utils/helpers.js +22 -43
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/logger.js +24 -43
- package/dist/browser/utils/logger.js.map +1 -1
- package/dist/module/components/component-types.js +1 -5
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/conditional-component-types.js +1 -5
- package/dist/module/components/conditional-component-types.js.map +1 -1
- package/dist/module/components/enums.js +1 -5
- package/dist/module/components/enums.js.map +1 -1
- package/dist/module/components/index.js +3 -24
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/types.js +1 -1
- package/dist/module/conditions/condition-abstract.js +3 -8
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -8
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +1 -6
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +4 -9
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-model.js +20 -25
- package/dist/module/conditions/condition-model.js.map +1 -1
- package/dist/module/conditions/condition-operators.js +15 -23
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -7
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +3 -8
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -6
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +12 -20
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +9 -14
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/enums.js +1 -5
- package/dist/module/conditions/enums.js.map +1 -1
- package/dist/module/conditions/helpers.js +2 -7
- package/dist/module/conditions/helpers.js.map +1 -1
- package/dist/module/conditions/index.js +10 -139
- package/dist/module/conditions/index.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +15 -26
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-operators.js +15 -23
- package/dist/module/conditions/inline-condition-operators.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +9 -17
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/conditions/types.js +1 -1
- package/dist/module/conditions/types.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -8
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/enums.js +1 -5
- package/dist/module/data-model/enums.js.map +1 -1
- package/dist/module/data-model/index.js +3 -24
- package/dist/module/data-model/index.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +3 -8
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/data-model/types.js +1 -5
- package/dist/module/data-model/types.js.map +1 -1
- package/dist/module/form/form-configuration.js +1 -6
- package/dist/module/form/form-configuration.js.map +1 -1
- package/dist/module/form/index.js +1 -10
- package/dist/module/form/index.js.map +1 -1
- package/dist/module/index.js +8 -91
- package/dist/module/index.js.map +1 -1
- package/dist/module/migration/index.js +1 -10
- package/dist/module/migration/index.js.map +1 -1
- package/dist/module/migration/migration.0-2.js +1 -5
- package/dist/module/migration/migration.0-2.js.map +1 -1
- package/dist/module/migration/migration.1-2.js +3 -6
- package/dist/module/migration/migration.1-2.js.map +1 -1
- package/dist/module/migration/types.js +1 -1
- package/dist/module/migration/whichMigrations.js +5 -9
- package/dist/module/migration/whichMigrations.js.map +1 -1
- package/dist/module/schema/index.js +1 -16
- package/dist/module/schema/index.js.map +1 -1
- package/dist/module/schema/schema.js +163 -167
- package/dist/module/schema/schema.js.map +1 -1
- package/dist/module/utils/helpers.js +5 -13
- package/dist/module/utils/helpers.js.map +1 -1
- package/dist/module/utils/logger.js +1 -6
- package/dist/module/utils/logger.js.map +1 -1
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/conditional-component-types.d.ts +1 -1
- package/dist/types/components/conditional-component-types.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/conditions/condition-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-field.d.ts +1 -1
- package/dist/types/conditions/condition-field.d.ts.map +1 -1
- package/dist/types/conditions/condition-group-def.d.ts +2 -2
- package/dist/types/conditions/condition-group-def.d.ts.map +1 -1
- package/dist/types/conditions/condition-group.d.ts +2 -2
- package/dist/types/conditions/condition-group.d.ts.map +1 -1
- package/dist/types/conditions/condition-model.d.ts +5 -5
- package/dist/types/conditions/condition-model.d.ts.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +2 -2
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/conditions/condition-ref.d.ts +2 -2
- package/dist/types/conditions/condition-ref.d.ts.map +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-values.d.ts +3 -3
- package/dist/types/conditions/condition-values.d.ts.map +1 -1
- package/dist/types/conditions/condition.d.ts +4 -4
- package/dist/types/conditions/condition.d.ts.map +1 -1
- package/dist/types/conditions/index.d.ts +10 -10
- package/dist/types/conditions/index.d.ts.map +1 -1
- package/dist/types/conditions/types.d.ts +3 -3
- package/dist/types/conditions/types.d.ts.map +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/index.d.ts +3 -3
- package/dist/types/data-model/index.d.ts.map +1 -1
- package/dist/types/data-model/input-wrapper.d.ts +2 -2
- package/dist/types/data-model/input-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/types.d.ts +3 -3
- package/dist/types/data-model/types.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migration/index.d.ts +1 -1
- package/dist/types/migration/index.d.ts.map +1 -1
- package/dist/types/migration/migration.0-2.d.ts +1 -1
- package/dist/types/migration/migration.0-2.d.ts.map +1 -1
- package/dist/types/migration/migration.1-2.d.ts +1 -1
- package/dist/types/migration/migration.1-2.d.ts.map +1 -1
- package/dist/types/migration/whichMigrations.d.ts +1 -1
- package/dist/types/migration/whichMigrations.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/component-types.ts +1 -1
- package/src/components/conditional-component-types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/conditions/condition-abstract.ts +1 -1
- package/src/conditions/condition-field.ts +2 -2
- package/src/conditions/condition-group-def.ts +1 -1
- package/src/conditions/condition-group.ts +3 -3
- package/src/conditions/condition-model.ts +9 -9
- package/src/conditions/condition-operators.ts +6 -3
- package/src/conditions/condition-ref.ts +2 -2
- package/src/conditions/condition-value-abstract.ts +1 -1
- package/src/conditions/condition-values.ts +3 -3
- package/src/conditions/condition.ts +6 -6
- package/src/conditions/index.ts +10 -10
- package/src/conditions/inline-condition-model.ts +3 -3
- package/src/conditions/inline-condition-operators.ts +1 -1
- package/src/conditions/types.ts +3 -3
- package/src/data-model/conditions-wrapper.ts +2 -2
- package/src/data-model/index.ts +3 -3
- package/src/data-model/input-wrapper.ts +3 -3
- package/src/data-model/types.ts +3 -3
- package/src/form/index.ts +1 -1
- package/src/index.ts +11 -11
- package/src/migration/index.ts +1 -1
- package/src/migration/migration.0-2.ts +1 -1
- package/src/migration/migration.1-2.ts +2 -2
- package/src/migration/whichMigrations.ts +3 -3
- package/src/schema/index.ts +1 -1
@@ -1,132 +1,111 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
import { timeUnits, dateUnits, dateTimeUnits, ConditionValue, DateDirections, RelativeTimeValue } from "./condition-values.js";
|
2
|
+
const defaultOperators = {
|
3
|
+
is: inline('=='),
|
4
|
+
'is not': inline('!=')
|
5
|
+
};
|
6
|
+
function withDefaults(param) {
|
7
|
+
return Object.assign({}, param, defaultOperators);
|
8
|
+
}
|
9
|
+
const textBasedFieldCustomisations = {
|
10
|
+
'is longer than': lengthIs('>'),
|
11
|
+
'is shorter than': lengthIs('<'),
|
12
|
+
'has length': lengthIs('==')
|
13
|
+
};
|
14
|
+
const absoluteDateTimeOperators = {
|
15
|
+
is: absoluteDateTime('=='),
|
16
|
+
'is not': absoluteDateTime('!='),
|
17
|
+
'is before': absoluteDateTime('<'),
|
18
|
+
'is after': absoluteDateTime('>')
|
19
|
+
};
|
20
|
+
const relativeTimeOperators = units => ({
|
21
|
+
'is at least': relativeTime('<=', '>=', units),
|
22
|
+
'is at most': relativeTime('>=', '<=', units),
|
23
|
+
'is less than': relativeTime('>', '<', units),
|
24
|
+
'is more than': relativeTime('<', '>', units)
|
25
|
+
});
|
26
|
+
export const customOperators = {
|
27
|
+
CheckboxesField: {
|
28
|
+
contains: reverseInline('in'),
|
29
|
+
'does not contain': not(reverseInline('in'))
|
30
|
+
},
|
31
|
+
NumberField: withDefaults({
|
32
|
+
'is at least': inline('>='),
|
33
|
+
'is at most': inline('<='),
|
34
|
+
'is less than': inline('<'),
|
35
|
+
'is more than': inline('>')
|
36
|
+
}),
|
37
|
+
DateField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateUnits)),
|
38
|
+
TimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(timeUnits)),
|
39
|
+
DatePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateUnits)),
|
40
|
+
DateTimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateTimeUnits)),
|
41
|
+
DateTimePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateTimeUnits)),
|
42
|
+
TextField: withDefaults(textBasedFieldCustomisations),
|
43
|
+
MultilineTextField: withDefaults(textBasedFieldCustomisations),
|
44
|
+
EmailAddressField: withDefaults(textBasedFieldCustomisations)
|
45
|
+
};
|
46
|
+
export function getOperatorNames(fieldType) {
|
47
|
+
return Object.keys(getConditionals(fieldType)).sort();
|
48
|
+
}
|
49
|
+
export function getExpression(fieldType, fieldName, operator, value) {
|
50
|
+
return getConditionals(fieldType)[operator].expression({
|
51
|
+
type: fieldType,
|
52
|
+
name: fieldName
|
53
|
+
}, value);
|
54
|
+
}
|
55
|
+
export function getOperatorConfig(fieldType, operator) {
|
56
|
+
return getConditionals(fieldType)[operator];
|
57
|
+
}
|
58
|
+
function getConditionals(fieldType) {
|
59
|
+
return customOperators[fieldType] || defaultOperators;
|
60
|
+
}
|
61
|
+
function inline(operator) {
|
62
|
+
return {
|
63
|
+
expression: (field, value) => `${field.name} ${operator} ${formatValue(field.type, value.value)}`
|
25
64
|
};
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
'is longer than': lengthIs('>'),
|
31
|
-
'is shorter than': lengthIs('<'),
|
32
|
-
'has length': lengthIs('==')
|
65
|
+
}
|
66
|
+
function lengthIs(operator) {
|
67
|
+
return {
|
68
|
+
expression: (field, value) => `length(${field.name}) ${operator} ${value.value}`
|
33
69
|
};
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'is after': absoluteDateTime('>')
|
70
|
+
}
|
71
|
+
function reverseInline(operator) {
|
72
|
+
return {
|
73
|
+
expression: (field, value) => `${formatValue(field.type, value.value)} ${operator} ${field.name}`
|
39
74
|
};
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
'is more than': relativeTime('<', '>', units)
|
45
|
-
});
|
46
|
-
const customOperators = _exports.customOperators = {
|
47
|
-
CheckboxesField: {
|
48
|
-
contains: reverseInline('in'),
|
49
|
-
'does not contain': not(reverseInline('in'))
|
50
|
-
},
|
51
|
-
NumberField: withDefaults({
|
52
|
-
'is at least': inline('>='),
|
53
|
-
'is at most': inline('<='),
|
54
|
-
'is less than': inline('<'),
|
55
|
-
'is more than': inline('>')
|
56
|
-
}),
|
57
|
-
DateField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateUnits)),
|
58
|
-
TimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.timeUnits)),
|
59
|
-
DatePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateUnits)),
|
60
|
-
DateTimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateTimeUnits)),
|
61
|
-
DateTimePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(_conditionValues.dateTimeUnits)),
|
62
|
-
TextField: withDefaults(textBasedFieldCustomisations),
|
63
|
-
MultilineTextField: withDefaults(textBasedFieldCustomisations),
|
64
|
-
EmailAddressField: withDefaults(textBasedFieldCustomisations)
|
75
|
+
}
|
76
|
+
function not(operatorDefinition) {
|
77
|
+
return {
|
78
|
+
expression: (field, value) => `not (${operatorDefinition.expression(field, value)})`
|
65
79
|
};
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
return getConditionals(fieldType)[operator].expression({
|
71
|
-
type: fieldType,
|
72
|
-
name: fieldName
|
73
|
-
}, value);
|
74
|
-
}
|
75
|
-
function getOperatorConfig(fieldType, operator) {
|
76
|
-
return getConditionals(fieldType)[operator];
|
77
|
-
}
|
78
|
-
function getConditionals(fieldType) {
|
79
|
-
return customOperators[fieldType] || defaultOperators;
|
80
|
-
}
|
81
|
-
function inline(operator) {
|
82
|
-
return {
|
83
|
-
expression: (field, value) => `${field.name} ${operator} ${formatValue(field.type, value.value)}`
|
84
|
-
};
|
85
|
-
}
|
86
|
-
function lengthIs(operator) {
|
87
|
-
return {
|
88
|
-
expression: (field, value) => `length(${field.name}) ${operator} ${value.value}`
|
89
|
-
};
|
90
|
-
}
|
91
|
-
function reverseInline(operator) {
|
92
|
-
return {
|
93
|
-
expression: (field, value) => `${formatValue(field.type, value.value)} ${operator} ${field.name}`
|
94
|
-
};
|
95
|
-
}
|
96
|
-
function not(operatorDefinition) {
|
97
|
-
return {
|
98
|
-
expression: (field, value) => `not (${operatorDefinition.expression(field, value)})`
|
99
|
-
};
|
80
|
+
}
|
81
|
+
function formatValue(fieldType, value) {
|
82
|
+
if (fieldType === 'NumberField' || fieldType === 'YesNoField') {
|
83
|
+
return value;
|
100
84
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
return {
|
111
|
-
expression: (field, value) => {
|
112
|
-
if (value instanceof _conditionValues.ConditionValue) {
|
113
|
-
return `${field.name} ${operator} '${value.toExpression()}'`;
|
114
|
-
}
|
115
|
-
throw Error('only Value types are supported');
|
85
|
+
return `'${value}'`;
|
86
|
+
}
|
87
|
+
export const absoluteDateOrTimeOperatorNames = Object.keys(absoluteDateTimeOperators);
|
88
|
+
export const relativeDateOrTimeOperatorNames = Object.keys(relativeTimeOperators(dateTimeUnits));
|
89
|
+
function absoluteDateTime(operator) {
|
90
|
+
return {
|
91
|
+
expression: (field, value) => {
|
92
|
+
if (value instanceof ConditionValue) {
|
93
|
+
return `${field.name} ${operator} '${value.toExpression()}'`;
|
116
94
|
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
95
|
+
throw Error('only Value types are supported');
|
96
|
+
}
|
97
|
+
};
|
98
|
+
}
|
99
|
+
function relativeTime(pastOperator, futureOperator, units) {
|
100
|
+
return {
|
101
|
+
units,
|
102
|
+
expression: (field, value) => {
|
103
|
+
if (value instanceof RelativeTimeValue) {
|
104
|
+
const operator = value.direction === DateDirections.PAST ? pastOperator : futureOperator;
|
105
|
+
return `${field.name} ${operator} ${value.toExpression()}`;
|
128
106
|
}
|
129
|
-
|
130
|
-
|
131
|
-
}
|
107
|
+
throw Error('time shift requires a TimeShiftValue');
|
108
|
+
}
|
109
|
+
};
|
110
|
+
}
|
132
111
|
//# sourceMappingURL=condition-operators.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-operators.js","names":["defaultOperators","is","inline","withDefaults","param","Object","assign","textBasedFieldCustomisations","lengthIs","absoluteDateTimeOperators","absoluteDateTime","relativeTimeOperators","units","relativeTime","customOperators","
|
1
|
+
{"version":3,"file":"condition-operators.js","names":["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","absoluteDateOrTimeOperatorNames","relativeDateOrTimeOperatorNames","toExpression","Error","pastOperator","futureOperator","direction","PAST"],"sources":["../../../src/conditions/condition-operators.ts"],"sourcesContent":["import {\n type ComponentType,\n type ComponentDef\n} from '~/src/components/types.js'\nimport { 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 CheckboxesField: {\n contains: reverseInline('in'),\n 'does not contain': not(reverseInline('in'))\n },\n NumberField: withDefaults({\n 'is at least': inline('>='),\n 'is at most': inline('<='),\n 'is less than': inline('<'),\n 'is more than': inline('>')\n }),\n DateField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateUnits)\n ),\n TimeField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(timeUnits)\n ),\n DatePartsField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateUnits)\n ),\n DateTimeField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateTimeUnits)\n ),\n DateTimePartsField: Object.assign(\n {},\n absoluteDateTimeOperators,\n relativeTimeOperators(dateTimeUnits)\n ),\n TextField: withDefaults(textBasedFieldCustomisations),\n MultilineTextField: withDefaults(textBasedFieldCustomisations),\n 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 (fieldType === 'NumberField' || fieldType === 'YesNoField') {\n return value\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":"AAKA,SACEA,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,EAA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AC5C,OAAO;IACLE,UAAU,EAAEA,CAACI,KAAmB,EAAEL,KAAK,KAAK;MAC1C,IAAIA,KAAK,YAAYvC,cAAc,EAAE;QACnC,OAAQ,GAAE4C,KAAK,CAACF,IAAK,IAAGJ,QAAS,KAAIC,KAAK,CAACU,YAAY,CAAC,CAAE,GAAE;MAC9D;MACA,MAAMC,KAAK,CAAC,gCAAgC,CAAC;IAC/C;EACF,CAAC;AACH;AAEA,SAASlC,YAAYA,CAACmC,YAAY,EAAEC,cAAc,EAAErC,KAAK,EAAE;EACzD,OAAO;IACLA,KAAK;IACLyB,UAAU,EAAEA,CAACI,KAAmB,EAAEL,KAAK,KAAK;MAC1C,IAAIA,KAAK,YAAYrC,iBAAiB,EAAE;QACtC,MAAMoC,QAAQ,GACZC,KAAK,CAACc,SAAS,KAAKpD,cAAc,CAACqD,IAAI,GACnCH,YAAY,GACZC,cAAc;QACpB,OAAQ,GAAER,KAAK,CAACF,IAAK,IAAGJ,QAAS,IAAGC,KAAK,CAACU,YAAY,CAAC,CAAE,EAAC;MAC5D;MACA,MAAMC,KAAK,CAAC,sCAAsC,CAAC;IACrD;EACF,CAAC;AACH"}
|
@@ -1,51 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _conditionAbstract) {
|
14
|
-
"use strict";
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
_exports.ConditionRef = void 0;
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
20
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
21
|
-
class ConditionRef extends _conditionAbstract.ConditionAbstract {
|
22
|
-
constructor(conditionName, conditionDisplayName, coordinator) {
|
23
|
-
super(coordinator);
|
24
|
-
_defineProperty(this, "conditionName", void 0);
|
25
|
-
_defineProperty(this, "conditionDisplayName", void 0);
|
26
|
-
if (typeof conditionName !== 'string') {
|
27
|
-
throw Error(`condition name ${conditionName} is not valid`);
|
28
|
-
}
|
29
|
-
if (typeof conditionDisplayName !== 'string') {
|
30
|
-
throw Error(`condition display name ${conditionDisplayName} is not valid`);
|
31
|
-
}
|
32
|
-
this.conditionName = conditionName;
|
33
|
-
this.conditionDisplayName = conditionDisplayName;
|
34
|
-
}
|
35
|
-
asFirstCondition() {
|
36
|
-
this._asFirstCondition();
|
37
|
-
return this;
|
38
|
-
}
|
39
|
-
conditionString() {
|
40
|
-
return `'${this.conditionDisplayName}'`;
|
41
|
-
}
|
42
|
-
conditionExpression() {
|
43
|
-
return this.conditionName;
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
import { ConditionAbstract } from "./condition-abstract.js";
|
5
|
+
export class ConditionRef extends ConditionAbstract {
|
6
|
+
constructor(conditionName, conditionDisplayName, coordinator) {
|
7
|
+
super(coordinator);
|
8
|
+
_defineProperty(this, "conditionName", void 0);
|
9
|
+
_defineProperty(this, "conditionDisplayName", void 0);
|
10
|
+
if (typeof conditionName !== 'string') {
|
11
|
+
throw Error(`condition name ${conditionName} is not valid`);
|
44
12
|
}
|
45
|
-
|
46
|
-
|
13
|
+
if (typeof conditionDisplayName !== 'string') {
|
14
|
+
throw Error(`condition display name ${conditionDisplayName} is not valid`);
|
47
15
|
}
|
16
|
+
this.conditionName = conditionName;
|
17
|
+
this.conditionDisplayName = conditionDisplayName;
|
18
|
+
}
|
19
|
+
asFirstCondition() {
|
20
|
+
this._asFirstCondition();
|
21
|
+
return this;
|
22
|
+
}
|
23
|
+
conditionString() {
|
24
|
+
return `'${this.conditionDisplayName}'`;
|
25
|
+
}
|
26
|
+
conditionExpression() {
|
27
|
+
return this.conditionName;
|
28
|
+
}
|
29
|
+
clone() {
|
30
|
+
return new ConditionRef(this.conditionName, this.conditionDisplayName, this.coordinator);
|
48
31
|
}
|
49
|
-
|
50
|
-
});
|
32
|
+
}
|
51
33
|
//# sourceMappingURL=condition-ref.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-ref.js","names":["
|
1
|
+
{"version":3,"file":"condition-ref.js","names":["ConditionAbstract","ConditionRef","constructor","conditionName","conditionDisplayName","coordinator","_defineProperty","Error","asFirstCondition","_asFirstCondition","conditionString","conditionExpression","clone"],"sources":["../../../src/conditions/condition-ref.ts"],"sourcesContent":["import { ConditionAbstract } from '~/src/conditions/condition-abstract.js'\nimport { 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 Error(`condition name ${conditionName} is not valid`)\n }\n\n if (typeof conditionDisplayName !== 'string') {\n throw Error(`condition display name ${conditionDisplayName} is not valid`)\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;EAIlDE,WAAWA,CACTC,aAAqB,EACrBC,oBAA4B,EAC5BC,WAAoC,EACpC;IACA,KAAK,CAACA,WAAW,CAAC;IAAAC,eAAA;IAAAA,eAAA;IAElB,IAAI,OAAOH,aAAa,KAAK,QAAQ,EAAE;MACrC,MAAMI,KAAK,CAAE,kBAAiBJ,aAAc,eAAc,CAAC;IAC7D;IAEA,IAAI,OAAOC,oBAAoB,KAAK,QAAQ,EAAE;MAC5C,MAAMG,KAAK,CAAE,0BAAyBH,oBAAqB,eAAc,CAAC;IAC5E;IAEA,IAAI,CAACD,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,OAAQ,IAAG,IAAI,CAACN,oBAAqB,GAAE;EACzC;EAEAO,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACR,aAAa;EAC3B;EAEAS,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIX,YAAY,CACrB,IAAI,CAACE,aAAa,EAClB,IAAI,CAACC,oBAAoB,EACzB,IAAI,CAACC,WACP,CAAC;EACH;AACF"}
|
@@ -1,41 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
factory(mod.exports, global.conditionValueRegistration);
|
11
|
-
global.conditionValueAbstract = mod.exports;
|
12
|
-
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _conditionValueRegistration) {
|
14
|
-
"use strict";
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
_exports.ConditionValueAbstract = void 0;
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
20
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
21
|
-
class ConditionValueAbstract {
|
22
|
-
constructor(registration) {
|
23
|
-
_defineProperty(this, "type", void 0);
|
24
|
-
if (new.target === ConditionValueAbstract) {
|
25
|
-
throw new TypeError('Cannot construct ConditionValue instances directly');
|
26
|
-
}
|
27
|
-
if (!(registration instanceof _conditionValueRegistration.Registration)) {
|
28
|
-
throw new TypeError('You must register your value type! Call registerValueType!');
|
29
|
-
}
|
30
|
-
this.type = registration.type;
|
31
|
-
}
|
32
|
-
toPresentationString() {
|
33
|
-
throw new Error('Unsupported Operation. Method toPresentationString have not been implemented');
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
import { Registration } from "./condition-value-registration.js";
|
5
|
+
export class ConditionValueAbstract {
|
6
|
+
constructor(registration) {
|
7
|
+
_defineProperty(this, "type", void 0);
|
8
|
+
if (new.target === ConditionValueAbstract) {
|
9
|
+
throw new TypeError('Cannot construct ConditionValue instances directly');
|
34
10
|
}
|
35
|
-
|
36
|
-
throw new
|
11
|
+
if (!(registration instanceof Registration)) {
|
12
|
+
throw new TypeError('You must register your value type! Call registerValueType!');
|
37
13
|
}
|
14
|
+
this.type = registration.type;
|
15
|
+
}
|
16
|
+
toPresentationString() {
|
17
|
+
throw new Error('Unsupported Operation. Method toPresentationString have not been implemented');
|
18
|
+
}
|
19
|
+
toExpression() {
|
20
|
+
throw new Error('Unsupported Operation. Method toExpression have not been implemented');
|
38
21
|
}
|
39
|
-
|
40
|
-
});
|
22
|
+
}
|
41
23
|
//# sourceMappingURL=condition-value-abstract.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-value-abstract.js","names":["ConditionValueAbstract","constructor","registration","_defineProperty","new","target","TypeError","
|
1
|
+
{"version":3,"file":"condition-value-abstract.js","names":["Registration","ConditionValueAbstract","constructor","registration","_defineProperty","new","target","TypeError","type","toPresentationString","Error","toExpression"],"sources":["../../../src/conditions/condition-value-abstract.ts"],"sourcesContent":["import { Registration } from '~/src/conditions/condition-value-registration.js'\n\nexport class ConditionValueAbstract {\n type: string\n\n constructor(registration: Registration) {\n if (new.target === ConditionValueAbstract) {\n throw new TypeError('Cannot construct ConditionValue instances directly')\n }\n\n if (!(registration instanceof Registration)) {\n throw new TypeError(\n 'You must register your value type! Call registerValueType!'\n )\n }\n\n this.type = registration.type\n }\n\n toPresentationString() {\n throw new Error(\n 'Unsupported Operation. Method toPresentationString have not been implemented'\n )\n }\n\n toExpression() {\n throw new Error(\n 'Unsupported Operation. Method toExpression have not been implemented'\n )\n }\n}\n"],"mappings":";;;AAAA,SAASA,YAAY;AAErB,OAAO,MAAMC,sBAAsB,CAAC;EAGlCC,WAAWA,CAACC,YAA0B,EAAE;IAAAC,eAAA;IACtC,IAAIC,GAAG,CAACC,MAAM,KAAKL,sBAAsB,EAAE;MACzC,MAAM,IAAIM,SAAS,CAAC,oDAAoD,CAAC;IAC3E;IAEA,IAAI,EAAEJ,YAAY,YAAYH,YAAY,CAAC,EAAE;MAC3C,MAAM,IAAIO,SAAS,CACjB,4DACF,CAAC;IACH;IAEA,IAAI,CAACC,IAAI,GAAGL,YAAY,CAACK,IAAI;EAC/B;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,MAAM,IAAIC,KAAK,CACb,8EACF,CAAC;EACH;EAEAC,YAAYA,CAAA,EAAG;IACb,MAAM,IAAID,KAAK,CACb,sEACF,CAAC;EACH;AACF"}
|
@@ -1,37 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
factory(mod.exports);
|
11
|
-
global.conditionValueRegistration = mod.exports;
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
const conditionValueFactories = {};
|
5
|
+
export class Registration {
|
6
|
+
constructor(type, factory) {
|
7
|
+
_defineProperty(this, "type", void 0);
|
8
|
+
conditionValueFactories[type] = factory;
|
9
|
+
this.type = type;
|
12
10
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
_exports.__esModule = true;
|
17
|
-
_exports.Registration = void 0;
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
20
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
21
|
-
const conditionValueFactories = {};
|
22
|
-
class Registration {
|
23
|
-
constructor(type, factory) {
|
24
|
-
_defineProperty(this, "type", void 0);
|
25
|
-
conditionValueFactories[type] = factory;
|
26
|
-
this.type = type;
|
27
|
-
}
|
28
|
-
static register(type, factory) {
|
29
|
-
return new Registration(type, factory);
|
30
|
-
}
|
31
|
-
static conditionValueFrom(obj) {
|
32
|
-
return conditionValueFactories[obj.type](obj);
|
33
|
-
}
|
11
|
+
static register(type, factory) {
|
12
|
+
return new Registration(type, factory);
|
34
13
|
}
|
35
|
-
|
36
|
-
|
14
|
+
static conditionValueFrom(obj) {
|
15
|
+
return conditionValueFactories[obj.type](obj);
|
16
|
+
}
|
17
|
+
}
|
37
18
|
//# sourceMappingURL=condition-value-registration.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-value-registration.js","names":["conditionValueFactories","Registration","constructor","type","factory","_defineProperty","register","conditionValueFrom","obj"
|
1
|
+
{"version":3,"file":"condition-value-registration.js","names":["conditionValueFactories","Registration","constructor","type","factory","_defineProperty","register","conditionValueFrom","obj"],"sources":["../../../src/conditions/condition-value-registration.ts"],"sourcesContent":["const conditionValueFactories = {}\n\nexport class Registration {\n type: string\n\n constructor(type: string, factory: (obj: any) => Registration) {\n conditionValueFactories[type] = factory\n this.type = type\n }\n\n static register(type: string, factory: (obj: any) => Registration) {\n return new Registration(type, factory)\n }\n\n static conditionValueFrom(obj: { type: string; [prop: string]: any }) {\n return conditionValueFactories[obj.type](obj)\n }\n}\n"],"mappings":";;;AAAA,MAAMA,uBAAuB,GAAG,CAAC,CAAC;AAElC,OAAO,MAAMC,YAAY,CAAC;EAGxBC,WAAWA,CAACC,IAAY,EAAEC,OAAmC,EAAE;IAAAC,eAAA;IAC7DL,uBAAuB,CAACG,IAAI,CAAC,GAAGC,OAAO;IACvC,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAEA,OAAOG,QAAQA,CAACH,IAAY,EAAEC,OAAmC,EAAE;IACjE,OAAO,IAAIH,YAAY,CAACE,IAAI,EAAEC,OAAO,CAAC;EACxC;EAEA,OAAOG,kBAAkBA,CAACC,GAA0C,EAAE;IACpE,OAAOR,uBAAuB,CAACQ,GAAG,CAACL,IAAI,CAAC,CAACK,GAAG,CAAC;EAC/C;AACF"}
|