@genesislcap/expression-builder 14.260.1 → 14.260.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +145 -139
- package/dist/dts/config/combinators.d.ts +14 -3
- package/dist/dts/config/combinators.d.ts.map +1 -1
- package/dist/dts/main/expression-builder.d.ts +111 -2
- package/dist/dts/main/expression-builder.d.ts.map +1 -1
- package/dist/dts/types/public.types.d.ts +206 -43
- package/dist/dts/types/public.types.d.ts.map +1 -1
- package/dist/dts/utils/formatting.d.ts +8 -4
- package/dist/dts/utils/formatting.d.ts.map +1 -1
- package/dist/esm/config/combinators.js +14 -3
- package/dist/esm/main/expression-builder.js +40 -2
- package/dist/esm/utils/formatting.js +8 -4
- package/dist/expression-builder.api.json +1156 -2
- package/dist/expression-builder.d.ts +339 -52
- package/docs/api/expression-builder.config.base_logical_combinators.md +16 -0
- package/docs/api/expression-builder.config.logical_combinators.md +16 -0
- package/docs/api/expression-builder.config.md +8 -0
- package/docs/api/expression-builder.config.null_combinator.md +18 -0
- package/docs/api/expression-builder.expressionbuilder.config.md +61 -0
- package/docs/api/expression-builder.expressionbuilder.dispatchchangeevent.md +31 -0
- package/docs/api/expression-builder.expressionbuilder.md +40 -0
- package/docs/api/expression-builder.expressionbuilder.model.md +35 -0
- package/docs/api/expression-builder.expressionbuilder.styles.md +39 -0
- package/docs/api/expression-builder.formatdatestring.md +18 -0
- package/docs/api/expression-builder.formatdatetimestring.md +18 -0
- package/docs/api/expression-builder.md +13 -0
- package/docs/api/expression-builder.types._operator.md +23 -0
- package/docs/api/expression-builder.types.binaryoperator.md +20 -0
- package/docs/api/expression-builder.types.checkboxinput.md +19 -0
- package/docs/api/expression-builder.types.combinator.md +29 -0
- package/docs/api/expression-builder.types.config.md +25 -0
- package/docs/api/expression-builder.types.customelements.md +47 -0
- package/docs/api/expression-builder.types.customstyles.md +32 -0
- package/docs/api/expression-builder.types.dateinput.md +20 -0
- package/docs/api/expression-builder.types.datetimeinput.md +20 -0
- package/docs/api/expression-builder.types.field.md +24 -0
- package/docs/api/expression-builder.types.fieldtypes.md +18 -0
- package/docs/api/expression-builder.types.group.md +49 -0
- package/docs/api/expression-builder.types.md +26 -0
- package/docs/api/expression-builder.types.numberinput.md +20 -0
- package/docs/api/expression-builder.types.operator.md +18 -0
- package/docs/api/expression-builder.types.rule.md +45 -0
- package/docs/api/expression-builder.types.selectinput.md +20 -0
- package/docs/api/expression-builder.types.styles.md +25 -0
- package/docs/api/expression-builder.types.ternararyoperator.md +20 -0
- package/docs/api/expression-builder.types.textinput.md +20 -0
- package/docs/api/expression-builder.types.uniraryoperator.md +22 -0
- package/docs/api/expression-builder.types.variadicoperator.md +20 -0
- package/docs/api-report.md +29 -34
- package/package.json +2 -2
|
@@ -1,133 +1,256 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @beta
|
|
2
|
+
* By default the expression builder uses the basic html components such as buttons and inputs. If you want to integrate your
|
|
3
|
+
* own components from a design system or otherwise you can add the tag names for your elements here. For your custom components
|
|
4
|
+
* to work they must expose the same API as the underlying HTML element they're overriding.
|
|
5
|
+
*
|
|
6
|
+
* `checkbox`: Custom element tag for checkbox inputs
|
|
7
|
+
*
|
|
8
|
+
* `text`: Custom element tag for text inputs
|
|
9
|
+
*
|
|
10
|
+
* `number`: Custom element tag for number inputs
|
|
11
|
+
*
|
|
12
|
+
* `date`: Custom element tag for date inputs
|
|
13
|
+
*
|
|
14
|
+
* `datetimeLocal`: Custom element tag for datetime-local inputs
|
|
15
|
+
*
|
|
16
|
+
* `select`: Custom element tag for select inputs
|
|
17
|
+
*
|
|
18
|
+
* `option`: Custom element tag for option elements
|
|
19
|
+
*
|
|
20
|
+
* `button`: Custom element tag for button elements
|
|
21
|
+
*
|
|
22
|
+
* `radio`: Custom element tag for radio and radio group elements. When using a custom element for a radio you require a parent radio group component to semantically link the radios into a group. The parent radio group must expose the `change` event and `value` attribute.
|
|
23
|
+
*/
|
|
2
24
|
export type CustomElements = {
|
|
3
|
-
/** Custom element tag for checkbox inputs */
|
|
4
25
|
checkbox?: string;
|
|
5
|
-
/** Custom element tag for text inputs */
|
|
6
26
|
text?: string;
|
|
7
|
-
/** Custom element tag for number inputs */
|
|
8
27
|
number?: string;
|
|
9
|
-
/** Custom element tag for date inputs */
|
|
10
28
|
date?: string;
|
|
11
|
-
/** Custom element tag for datetime-local inputs */
|
|
12
29
|
datetimeLocal?: string;
|
|
13
|
-
/** Custom element tag for select inputs */
|
|
14
30
|
select?: string;
|
|
15
|
-
/** Custom element tag for option elements */
|
|
16
31
|
option?: string;
|
|
17
|
-
/** Custom element tag for button elements */
|
|
18
32
|
button?: string;
|
|
19
|
-
/** Custom element tag for radio and radio group elements
|
|
20
|
-
* Assume that the radio group still exposes change event and value attribute */
|
|
21
33
|
radio?: {
|
|
22
34
|
input: string;
|
|
23
35
|
group: string;
|
|
24
36
|
};
|
|
25
37
|
};
|
|
26
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* @beta
|
|
40
|
+
* Optional strings for configuring css to be applied inside of each constituent element's shadow DOM.
|
|
41
|
+
* To apply styles to components which are used inside of multiple different components (such as buttons which are used in groups,
|
|
42
|
+
* rules, and values) you must ensure the styling is set in each block. If your styling isn't showing the ensure that you're
|
|
43
|
+
* using more specific css rules to override the precedence of your rule.
|
|
44
|
+
*
|
|
45
|
+
* `rule`: Additional CSS for expression rule component
|
|
46
|
+
*
|
|
47
|
+
* `value`: Additional CSS for rule value component
|
|
48
|
+
*
|
|
49
|
+
* `field`: Additional CSS for rule field component
|
|
50
|
+
*
|
|
51
|
+
* `operator`: Additional CSS for rule operator component
|
|
52
|
+
*
|
|
53
|
+
* `group`: Additional CSS for expression group component
|
|
54
|
+
*
|
|
55
|
+
* @privateRemarks
|
|
56
|
+
* Use css layers to help with the precedence in future.
|
|
57
|
+
*/
|
|
27
58
|
export type CustomStyles = {
|
|
28
|
-
/** Additional CSS for expression rule component */
|
|
29
59
|
rule?: string;
|
|
30
|
-
/** Additional CSS for rule value component */
|
|
31
60
|
value?: string;
|
|
32
|
-
/** Additional CSS for rule field component */
|
|
33
61
|
field?: string;
|
|
34
|
-
/** Additional CSS for rule operator component */
|
|
35
62
|
operator?: string;
|
|
36
|
-
/** Additional CSS for expression group component */
|
|
37
63
|
group?: string;
|
|
38
64
|
};
|
|
39
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Configuration items for the expression builder styles.
|
|
67
|
+
*
|
|
68
|
+
* `customElements`: optional `Types.CustomElements` block for overriding the html tags used in the expression builder
|
|
69
|
+
*
|
|
70
|
+
* `customStyles`: optional `Types.CustomStyles` block to configure custom css for components.
|
|
71
|
+
*
|
|
72
|
+
* @beta
|
|
73
|
+
|
|
74
|
+
**/
|
|
40
75
|
export type Styles = {
|
|
41
|
-
/** Custom element tags for HTML elements */
|
|
42
76
|
customElements?: CustomElements;
|
|
43
|
-
/** Custom styles for components */
|
|
44
77
|
customStyles?: CustomStyles;
|
|
45
78
|
};
|
|
46
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* @beta
|
|
81
|
+
* The configuration object to set on an expression builder object. The expression builder always requires `operators`,
|
|
82
|
+
* `fields` and `combinators` to be configured.
|
|
83
|
+
*
|
|
84
|
+
* Specific implementations of the expression builder may expose these options via a different attribute and automatically
|
|
85
|
+
* configure some options. E.g. a rule (boolean) expression builder may configure boolean operators and combinators so the user
|
|
86
|
+
* doesn't have to.
|
|
87
|
+
*
|
|
88
|
+
* `operators`: Array of {@link Operator} objects
|
|
89
|
+
*
|
|
90
|
+
* `fields`: Array of {@link Field} objects
|
|
91
|
+
*
|
|
92
|
+
* `combinators`: Array of {@link Combinator} objects
|
|
93
|
+
*
|
|
94
|
+
* `model`: Optional {@link Group} model to hydrate
|
|
95
|
+
*
|
|
96
|
+
* `maxNesting`: If set and more than 0, is a 1-indexed config for the maximum nesting level of groups.
|
|
97
|
+
*
|
|
98
|
+
* `partialRuleValidationWarning`: If set a rule will highlight in an error colour when it's not complete (doesn't have a field + operator + (maybe value) selected)
|
|
99
|
+
*/
|
|
100
|
+
/** @beta **/
|
|
47
101
|
export type Config = {
|
|
48
102
|
operators: Operator[];
|
|
49
103
|
fields: Field[];
|
|
50
104
|
combinators: Combinator[];
|
|
51
|
-
/** Model to hydrate */
|
|
52
105
|
model?: Group;
|
|
53
|
-
/** If set and more than 0, is a 1-indexed config for the nesting of groups */
|
|
54
106
|
maxNesting?: number;
|
|
55
|
-
/** If set a rule will highlight in an error colour when it's not complete
|
|
56
|
-
* (doesn't have a field + operator + (maybe value) selected) */
|
|
57
107
|
partialRuleValidationWarning?: boolean;
|
|
58
108
|
};
|
|
59
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* The shared configuration properties of an operator
|
|
111
|
+
* @beta
|
|
112
|
+
*
|
|
113
|
+
* `applyTo`: Only allow this operator to be used on a field type (e.g. only allow this on an enum)
|
|
114
|
+
*
|
|
115
|
+
* `optgroup`: Group the operators inside of the select component
|
|
116
|
+
*
|
|
117
|
+
* `type`: The name of the operator (e.g. one_of)
|
|
118
|
+
*
|
|
119
|
+
* `tooltip`: Optional tooltip to display on mouse hover
|
|
120
|
+
*/
|
|
121
|
+
/** @beta **/
|
|
60
122
|
export type _Operator = {
|
|
61
123
|
applyTo: FieldTypes['type'][];
|
|
62
124
|
optgroup?: string | null;
|
|
63
125
|
type: string;
|
|
64
126
|
tooltip?: string;
|
|
65
127
|
};
|
|
66
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* An operator which doesn't have any value. Example `is_null`
|
|
130
|
+
* @beta
|
|
131
|
+
* **/
|
|
67
132
|
export type UniraryOperator = {
|
|
68
133
|
nbInputs: 0;
|
|
69
134
|
} & _Operator;
|
|
70
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* An operator which has one value. Example `greater_than`
|
|
137
|
+
* @beta **/
|
|
71
138
|
export type BinaryOperator = {
|
|
72
139
|
nbInputs: 1;
|
|
73
140
|
} & _Operator;
|
|
74
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* An operator which has two values. Example `between_inclusive`
|
|
143
|
+
* @beta **/
|
|
75
144
|
export type TernararyOperator = {
|
|
76
145
|
nbInputs: 2;
|
|
77
146
|
} & _Operator;
|
|
78
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* An operator which can have any number of values where `NumVals >= 1`, defaulting to 1. Example `one_of`.
|
|
149
|
+
* @beta **/
|
|
79
150
|
export type VariadicOperator = {
|
|
80
151
|
nbInputs: 'many';
|
|
81
152
|
} & _Operator;
|
|
82
|
-
/** @
|
|
153
|
+
/** @beta **/
|
|
83
154
|
export type Operator = UniraryOperator | BinaryOperator | TernararyOperator | VariadicOperator;
|
|
84
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Configuration for a text-type input, which has a string value and a text input.
|
|
157
|
+
* @beta **/
|
|
85
158
|
export type TextInput = {
|
|
86
159
|
type: 'string';
|
|
87
160
|
input: 'text';
|
|
88
161
|
validation?: (x: unknown) => string | null;
|
|
89
162
|
};
|
|
90
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Configuration for a number-type input, which has a number value and a number input.
|
|
165
|
+
* @beta **/
|
|
91
166
|
export type NumberInput = {
|
|
92
167
|
input: 'number';
|
|
93
168
|
type: 'int' | 'short' | 'double' | 'long' | 'bigdecimal';
|
|
94
169
|
validation?: (x: unknown) => string | null;
|
|
95
170
|
};
|
|
96
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Configuration for a boolean-type input, which has a boolean value and a checkbox.
|
|
173
|
+
* @beta **/
|
|
97
174
|
export type CheckboxInput = {
|
|
98
175
|
input: 'checkbox';
|
|
99
176
|
type: 'boolean';
|
|
100
177
|
};
|
|
101
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Configuration for an enum-type input, which as a string or number value, and uses a select input.
|
|
180
|
+
* @beta **/
|
|
102
181
|
export type SelectInput = {
|
|
103
182
|
input: 'select';
|
|
104
183
|
type: 'enum';
|
|
105
184
|
values: Record<string, string | number>;
|
|
106
185
|
};
|
|
107
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Configuration for a date input, which has s string value and a date field input
|
|
188
|
+
* @beta **/
|
|
108
189
|
export type DateInput = {
|
|
109
190
|
input: 'date';
|
|
110
191
|
type: 'date';
|
|
111
192
|
validation?: (x: unknown) => string | null;
|
|
112
193
|
};
|
|
113
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Configuration for a datetime input, which has s string value and a datetime field input
|
|
196
|
+
* @beta **/
|
|
114
197
|
export type DateTimeInput = {
|
|
115
198
|
input: 'datetime-local';
|
|
116
199
|
type: 'date-time';
|
|
117
200
|
validation?: (x: unknown) => string | null;
|
|
118
201
|
};
|
|
119
|
-
/**
|
|
202
|
+
/**
|
|
203
|
+
* Union of all input types
|
|
204
|
+
* @beta **/
|
|
120
205
|
export type FieldTypes = TextInput | NumberInput | CheckboxInput | SelectInput | DateInput | DateTimeInput;
|
|
121
|
-
/**
|
|
206
|
+
/**
|
|
207
|
+
* Configuration for the fields which the user can choose from per rule, the left hand side of each rule expression.
|
|
208
|
+
* @beta
|
|
209
|
+
*
|
|
210
|
+
* `optgroup`: Group the fields inside of the select component. This option currently isn't supported if you're using custom elements configured with {@link CustomElements}.
|
|
211
|
+
*
|
|
212
|
+
* `defaultValue`: Default value for the field. If set then the value of any rule operands is defaulted to this value, but the user can change the value to something else.
|
|
213
|
+
*
|
|
214
|
+
* `fieldId`: Id for the field
|
|
215
|
+
*
|
|
216
|
+
* `label`: Label for the field, what the user sees on the select input listbox.
|
|
217
|
+
*
|
|
218
|
+
* (not yet implemented) `operators`: Constrain the operators which can be used with this field (e.g. only allow starts_with on a string)
|
|
219
|
+
*/
|
|
220
|
+
/** @beta **/
|
|
122
221
|
export type Field = {
|
|
123
222
|
optgroup?: string | null;
|
|
124
|
-
data?: any;
|
|
125
223
|
defaultValue?: any;
|
|
126
224
|
fieldId: string;
|
|
127
225
|
label: string;
|
|
128
226
|
operators?: string[];
|
|
129
227
|
} & FieldTypes;
|
|
130
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* A combinator is a type of expression which can link two or more rules or groups. The most simple example is `AND` and `OR` which
|
|
230
|
+
* can take any number of expressions to produce one boolean value.
|
|
231
|
+
* @beta
|
|
232
|
+
*
|
|
233
|
+
* `type`: e.g., 'AND', 'OR', 'XOR', 'MULTIPLY', etc.
|
|
234
|
+
*
|
|
235
|
+
* `maxRules`: Controls number of nested rules. Max 1 only allows 1 rule, Max 2 allows 2 rules/groups, many allows any rules/groups
|
|
236
|
+
*
|
|
237
|
+
* `invisible`: If true then it won't appear on the component UI and is only selectable programmatically, or by default if it's the first and only value. If the only combinators are invisible then you're configuring the expression builder to not use combinators. Use the {@link NULL_COMBINATOR} for this purpose.
|
|
238
|
+
*
|
|
239
|
+
* `label`: Optional: Display label (if different from type)
|
|
240
|
+
*
|
|
241
|
+
* (not yet implemented) `description`: Optional: More details about the combinator
|
|
242
|
+
*
|
|
243
|
+
* (not yet implemented) `allowedFields`: Array of allowed field IDs (or `null` for all)
|
|
244
|
+
*
|
|
245
|
+
* (not yet implemented) `allowedOperators`: Explicit array of allowed operator types. (or `null` for all)
|
|
246
|
+
*
|
|
247
|
+
* (not yet implemented) `validator`: Optional: A validation function for the whole group. Null is valid, string is error message
|
|
248
|
+
*
|
|
249
|
+
* (not yet implemented) `allowLiterals`: Allow literal values instead of having to select a field
|
|
250
|
+
*
|
|
251
|
+
* (not yet implemented) `forceFieldOnly`: If the user selects a field they use it for it's value, without an operation on it
|
|
252
|
+
*/
|
|
253
|
+
/** @beta **/
|
|
131
254
|
export type Combinator = {
|
|
132
255
|
type: string;
|
|
133
256
|
maxRules: 1 | 2 | 'many';
|
|
@@ -140,7 +263,18 @@ export type Combinator = {
|
|
|
140
263
|
allowLiterals?: boolean;
|
|
141
264
|
forceFieldOnly?: boolean;
|
|
142
265
|
};
|
|
143
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* A rule is a single constituent element of a larger expression, and is the smallest whole part of an expression.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```
|
|
271
|
+
* FIELD : PROFILE_AGE
|
|
272
|
+
* OPERATOR : GREATER_THAN
|
|
273
|
+
* VALUE : 18
|
|
274
|
+
*
|
|
275
|
+
* If you're constructing a boolean expression then this rule could be used to restrict users who are 17 or younger.
|
|
276
|
+
* ```
|
|
277
|
+
@beta **/
|
|
144
278
|
export type Rule = {
|
|
145
279
|
field: Field | null;
|
|
146
280
|
} & ({
|
|
@@ -157,7 +291,36 @@ export type Rule = {
|
|
|
157
291
|
operator: VariadicOperator;
|
|
158
292
|
value: any[];
|
|
159
293
|
});
|
|
160
|
-
/**
|
|
294
|
+
/**
|
|
295
|
+
* A group forms the overall model of the expression builder, and is recursive to itself allowing for a nested tree.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```
|
|
299
|
+
* RULE 1
|
|
300
|
+
* FIELD : PROFILE_AGE
|
|
301
|
+
* OPERATOR : GREATER_THAN
|
|
302
|
+
* VALUE : 18
|
|
303
|
+
*
|
|
304
|
+
* COMBINATOR : OR
|
|
305
|
+
*
|
|
306
|
+
* GROUP 2
|
|
307
|
+
* RULE 2
|
|
308
|
+
* FIELD : PARENT_ROLE
|
|
309
|
+
* OPERATOR : ONE_OF
|
|
310
|
+
* VALUE : GIVES_PERMISSION
|
|
311
|
+
*
|
|
312
|
+
* COMBINATOR : AND
|
|
313
|
+
*
|
|
314
|
+
* RULE 3
|
|
315
|
+
* FIELD : GRANTS_CHILD_ACCESS
|
|
316
|
+
* OPERATOR : EQUALS
|
|
317
|
+
* VALUE : true
|
|
318
|
+
*
|
|
319
|
+
* If you're constructing a boolean expression then this rule could be used to restrict users who are 17 or younger, but
|
|
320
|
+
* allowing parents who have specific rights to be able to grant access too.
|
|
321
|
+
* ```
|
|
322
|
+
* @beta
|
|
323
|
+
*/
|
|
161
324
|
export type Group = {
|
|
162
325
|
combinator: Combinator;
|
|
163
326
|
children: (Rule | Group)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.types.d.ts","sourceRoot":"","sources":["../../../src/types/public.types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"public.types.d.ts","sourceRoot":"","sources":["../../../src/types/public.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;IASI;AACJ,MAAM,MAAM,MAAM,GAAG;IACnB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,aAAa;AACb,MAAM,MAAM,MAAM,GAAG;IACnB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,EAAE,UAAU,EAAE,CAAC;I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|
|
3
|
+
* `yyyy-mm-dd`.
|
|
4
4
|
* Uses UTC methods to ensure consistent output regardless of timezone.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* Used to convert a javascript date object into the required string format expected by the expression builder.
|
|
7
|
+
* @beta
|
|
6
8
|
*/
|
|
7
9
|
export declare const formatDateString: (date: Date) => string;
|
|
8
10
|
/**
|
|
9
11
|
* Gets the string representation from a `Date` which is the format a `datetime-local` input uses.
|
|
10
|
-
* `yyyy-mm-ddThh:mm:ss
|
|
12
|
+
* `yyyy-mm-ddThh:mm:ss`.
|
|
11
13
|
* Uses UTC methods to ensure consistent output regardless of timezone.
|
|
12
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* Used to convert a javascript date object into the required string format expected by the expression builder.
|
|
16
|
+
* @beta
|
|
13
17
|
*/
|
|
14
18
|
export declare const formatDateTimeString: (date: Date) => string;
|
|
15
19
|
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,SAAU,IAAI,WAK1C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,SAAU,IAAI,WAM9C,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Basic `AND` and `OR` logical combinators which can be used in the model config.
|
|
3
|
+
* @beta
|
|
4
|
+
* */
|
|
2
5
|
export const BASE_LOGICAL_COMBINATORS = [
|
|
3
6
|
{
|
|
4
7
|
type: 'AND',
|
|
@@ -9,7 +12,10 @@ export const BASE_LOGICAL_COMBINATORS = [
|
|
|
9
12
|
maxRules: 'many',
|
|
10
13
|
},
|
|
11
14
|
];
|
|
12
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* A set of boolean logic combinators which configure the expression builder to produce boolean expressions.
|
|
17
|
+
* @beta
|
|
18
|
+
* */
|
|
13
19
|
export const LOGICAL_COMBINATORS = [
|
|
14
20
|
...BASE_LOGICAL_COMBINATORS,
|
|
15
21
|
{
|
|
@@ -29,7 +35,12 @@ export const LOGICAL_COMBINATORS = [
|
|
|
29
35
|
maxRules: 2,
|
|
30
36
|
},
|
|
31
37
|
];
|
|
32
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* A combinator which has a null action.
|
|
40
|
+
*
|
|
41
|
+
* If configured as the only combinator then it configures the expression builder to only create a single rule.
|
|
42
|
+
* @beta
|
|
43
|
+
* */
|
|
33
44
|
export const NULL_COMBINATOR = {
|
|
34
45
|
type: 'NULL',
|
|
35
46
|
maxRules: 1,
|
|
@@ -9,10 +9,46 @@ import { ExpressionGroup } from './expression-group/expression-group';
|
|
|
9
9
|
import { ExpressionRule } from './expression-rule/expression-rule';
|
|
10
10
|
ExpressionGroup;
|
|
11
11
|
ExpressionRule;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Top level component to allow the user to build expressions. It produces a generic payload which doesn't have any system by itself
|
|
14
|
+
* to evaluate or execute the built expression.
|
|
15
|
+
*
|
|
16
|
+
* The basics required to work with this component:
|
|
17
|
+
*
|
|
18
|
+
* {@link ExpressionBuilder.config} property to configure and input data and models into the component.
|
|
19
|
+
*
|
|
20
|
+
* _Event_ change - `Types.Group` emits the model configuration on change. If you create a child component of the expression builder
|
|
21
|
+
* where you want to use a different (e.g. domain specific) model then it will likely override then emit event and instead emit
|
|
22
|
+
* it's own model. To check the underlying `Types.Group` model check the {@link ExpressionBuilder.model} property.
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
13
26
|
let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
14
27
|
constructor() {
|
|
15
28
|
super(...arguments);
|
|
29
|
+
/**
|
|
30
|
+
* model - `Types.Group` the current model which completely describes the state of the component.
|
|
31
|
+
*
|
|
32
|
+
* *IMPORTANT* you should not set this yourself via this property directly, you should always set it via the model property on the {@link ExpressionBuilder.config} block.
|
|
33
|
+
*
|
|
34
|
+
* You may want to read from this variable to get the most up to date state, for example if you create a child component which
|
|
35
|
+
* has a model which isn't valid for every single state (e.g. requires a complete rule) you can check this underlying model to
|
|
36
|
+
* verify what field or operator is selected.
|
|
37
|
+
*
|
|
38
|
+
* @beta
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const model = document.querySelector('expression-builder');
|
|
43
|
+
* // Once you have the model you can read it to check the applied config. While the primary use should be checking the updated model via
|
|
44
|
+
* the emited change event, you can use this to check more specific changes that a domain specific model might not.
|
|
45
|
+
*
|
|
46
|
+
* For example, imagine a RulExpressionBuilder which is an implementation specifically for a boolean logic expression. That component may not
|
|
47
|
+
* model a non-complete rule (a rule without a field, and operator, and value). In that case when it emits the event the payload will only change
|
|
48
|
+
* when the user has completely configured a new rule. But if you need to catch cases earlier when they've changed the field but before they've
|
|
49
|
+
* changed the value you can check the model here.
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
16
52
|
this.model = null;
|
|
17
53
|
this.ruleCount = 0;
|
|
18
54
|
this.groupCount = 0;
|
|
@@ -48,7 +84,7 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
48
84
|
this.dispatchChangeEvent(group);
|
|
49
85
|
}
|
|
50
86
|
/**
|
|
51
|
-
* @
|
|
87
|
+
* @beta
|
|
52
88
|
* Dispatches the provided model to the DOM.
|
|
53
89
|
*
|
|
54
90
|
* @remarks
|
|
@@ -78,6 +114,7 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
78
114
|
return `rule-${this.ruleCount}`;
|
|
79
115
|
}
|
|
80
116
|
// Behaviour
|
|
117
|
+
/** @internal */
|
|
81
118
|
connectedCallback() {
|
|
82
119
|
super.connectedCallback();
|
|
83
120
|
if (!this.config || !this.config.combinators || !this.config.operators || !this.config.fields) {
|
|
@@ -99,6 +136,7 @@ let ExpressionBuilder = class ExpressionBuilder extends GenesisElement {
|
|
|
99
136
|
combinator: this.config.combinators[0],
|
|
100
137
|
};
|
|
101
138
|
}
|
|
139
|
+
/** @internal */
|
|
102
140
|
disconnectedCallback() {
|
|
103
141
|
super.disconnectedCallback();
|
|
104
142
|
this.removeEventListener(Events.AddGroup, this.handleAddGroup);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gets the string representation from a `Date` which is the format a `date` input uses.
|
|
3
|
-
* `yyyy-mm-dd
|
|
3
|
+
* `yyyy-mm-dd`.
|
|
4
4
|
* Uses UTC methods to ensure consistent output regardless of timezone.
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* Used to convert a javascript date object into the required string format expected by the expression builder.
|
|
7
|
+
* @beta
|
|
6
8
|
*/
|
|
7
9
|
export const formatDateString = (date) => {
|
|
8
10
|
const year = date.getUTCFullYear();
|
|
@@ -12,9 +14,11 @@ export const formatDateString = (date) => {
|
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* Gets the string representation from a `Date` which is the format a `datetime-local` input uses.
|
|
15
|
-
* `yyyy-mm-ddThh:mm:ss
|
|
17
|
+
* `yyyy-mm-ddThh:mm:ss`.
|
|
16
18
|
* Uses UTC methods to ensure consistent output regardless of timezone.
|
|
17
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* Used to convert a javascript date object into the required string format expected by the expression builder.
|
|
21
|
+
* @beta
|
|
18
22
|
*/
|
|
19
23
|
export const formatDateTimeString = (date) => {
|
|
20
24
|
const datePart = formatDateString(date);
|