@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
|
@@ -2,24 +2,56 @@ import { ElementStyles } from '@microsoft/fast-element';
|
|
|
2
2
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
3
3
|
import { ViewTemplate } from '@microsoft/fast-element';
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Basic `AND` and `OR` logical combinators which can be used in the model config.
|
|
7
|
+
* @beta
|
|
8
|
+
* */
|
|
6
9
|
declare const BASE_LOGICAL_COMBINATORS: Combinator[];
|
|
7
10
|
|
|
8
11
|
/** @alpha **/
|
|
9
12
|
declare const BASE_OPERATORS: Operator[];
|
|
10
13
|
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* An operator which has one value. Example `greater_than`
|
|
16
|
+
* @beta **/
|
|
12
17
|
declare type BinaryOperator = {
|
|
13
18
|
nbInputs: 1;
|
|
14
19
|
} & _Operator;
|
|
15
20
|
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for a boolean-type input, which has a boolean value and a checkbox.
|
|
23
|
+
* @beta **/
|
|
17
24
|
declare type CheckboxInput = {
|
|
18
25
|
input: 'checkbox';
|
|
19
26
|
type: 'boolean';
|
|
20
27
|
};
|
|
21
28
|
|
|
22
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* 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
|
|
31
|
+
* can take any number of expressions to produce one boolean value.
|
|
32
|
+
* @beta
|
|
33
|
+
*
|
|
34
|
+
* `type`: e.g., 'AND', 'OR', 'XOR', 'MULTIPLY', etc.
|
|
35
|
+
*
|
|
36
|
+
* `maxRules`: Controls number of nested rules. Max 1 only allows 1 rule, Max 2 allows 2 rules/groups, many allows any rules/groups
|
|
37
|
+
*
|
|
38
|
+
* `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.
|
|
39
|
+
*
|
|
40
|
+
* `label`: Optional: Display label (if different from type)
|
|
41
|
+
*
|
|
42
|
+
* (not yet implemented) `description`: Optional: More details about the combinator
|
|
43
|
+
*
|
|
44
|
+
* (not yet implemented) `allowedFields`: Array of allowed field IDs (or `null` for all)
|
|
45
|
+
*
|
|
46
|
+
* (not yet implemented) `allowedOperators`: Explicit array of allowed operator types. (or `null` for all)
|
|
47
|
+
*
|
|
48
|
+
* (not yet implemented) `validator`: Optional: A validation function for the whole group. Null is valid, string is error message
|
|
49
|
+
*
|
|
50
|
+
* (not yet implemented) `allowLiterals`: Allow literal values instead of having to select a field
|
|
51
|
+
*
|
|
52
|
+
* (not yet implemented) `forceFieldOnly`: If the user selects a field they use it for it's value, without an operation on it
|
|
53
|
+
*/
|
|
54
|
+
/** @beta **/
|
|
23
55
|
declare type Combinator = {
|
|
24
56
|
type: string;
|
|
25
57
|
maxRules: 1 | 2 | 'many';
|
|
@@ -43,78 +75,232 @@ declare namespace Config {
|
|
|
43
75
|
}
|
|
44
76
|
export { Config }
|
|
45
77
|
|
|
46
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* @beta
|
|
80
|
+
* The configuration object to set on an expression builder object. The expression builder always requires `operators`,
|
|
81
|
+
* `fields` and `combinators` to be configured.
|
|
82
|
+
*
|
|
83
|
+
* Specific implementations of the expression builder may expose these options via a different attribute and automatically
|
|
84
|
+
* configure some options. E.g. a rule (boolean) expression builder may configure boolean operators and combinators so the user
|
|
85
|
+
* doesn't have to.
|
|
86
|
+
*
|
|
87
|
+
* `operators`: Array of {@link Operator} objects
|
|
88
|
+
*
|
|
89
|
+
* `fields`: Array of {@link Field} objects
|
|
90
|
+
*
|
|
91
|
+
* `combinators`: Array of {@link Combinator} objects
|
|
92
|
+
*
|
|
93
|
+
* `model`: Optional {@link Group} model to hydrate
|
|
94
|
+
*
|
|
95
|
+
* `maxNesting`: If set and more than 0, is a 1-indexed config for the maximum nesting level of groups.
|
|
96
|
+
*
|
|
97
|
+
* `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)
|
|
98
|
+
*/
|
|
99
|
+
/** @beta **/
|
|
47
100
|
declare type Config_2 = {
|
|
48
101
|
operators: Operator[];
|
|
49
102
|
fields: Field[];
|
|
50
103
|
combinators: Combinator[];
|
|
51
|
-
/** Model to hydrate */
|
|
52
104
|
model?: Group;
|
|
53
|
-
/** If set and more than 0, is a 1-indexed config for the nesting of groups */
|
|
54
105
|
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
106
|
partialRuleValidationWarning?: boolean;
|
|
58
107
|
};
|
|
59
108
|
|
|
60
|
-
/** @
|
|
109
|
+
/** @beta
|
|
110
|
+
* By default the expression builder uses the basic html components such as buttons and inputs. If you want to integrate your
|
|
111
|
+
* own components from a design system or otherwise you can add the tag names for your elements here. For your custom components
|
|
112
|
+
* to work they must expose the same API as the underlying HTML element they're overriding.
|
|
113
|
+
*
|
|
114
|
+
* `checkbox`: Custom element tag for checkbox inputs
|
|
115
|
+
*
|
|
116
|
+
* `text`: Custom element tag for text inputs
|
|
117
|
+
*
|
|
118
|
+
* `number`: Custom element tag for number inputs
|
|
119
|
+
*
|
|
120
|
+
* `date`: Custom element tag for date inputs
|
|
121
|
+
*
|
|
122
|
+
* `datetimeLocal`: Custom element tag for datetime-local inputs
|
|
123
|
+
*
|
|
124
|
+
* `select`: Custom element tag for select inputs
|
|
125
|
+
*
|
|
126
|
+
* `option`: Custom element tag for option elements
|
|
127
|
+
*
|
|
128
|
+
* `button`: Custom element tag for button elements
|
|
129
|
+
*
|
|
130
|
+
* `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.
|
|
131
|
+
*/
|
|
61
132
|
declare type CustomElements = {
|
|
62
|
-
/** Custom element tag for checkbox inputs */
|
|
63
133
|
checkbox?: string;
|
|
64
|
-
/** Custom element tag for text inputs */
|
|
65
134
|
text?: string;
|
|
66
|
-
/** Custom element tag for number inputs */
|
|
67
135
|
number?: string;
|
|
68
|
-
/** Custom element tag for date inputs */
|
|
69
136
|
date?: string;
|
|
70
|
-
/** Custom element tag for datetime-local inputs */
|
|
71
137
|
datetimeLocal?: string;
|
|
72
|
-
/** Custom element tag for select inputs */
|
|
73
138
|
select?: string;
|
|
74
|
-
/** Custom element tag for option elements */
|
|
75
139
|
option?: string;
|
|
76
|
-
/** Custom element tag for button elements */
|
|
77
140
|
button?: string;
|
|
78
|
-
/** Custom element tag for radio and radio group elements
|
|
79
|
-
* Assume that the radio group still exposes change event and value attribute */
|
|
80
141
|
radio?: {
|
|
81
142
|
input: string;
|
|
82
143
|
group: string;
|
|
83
144
|
};
|
|
84
145
|
};
|
|
85
146
|
|
|
86
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* @beta
|
|
149
|
+
* Optional strings for configuring css to be applied inside of each constituent element's shadow DOM.
|
|
150
|
+
* To apply styles to components which are used inside of multiple different components (such as buttons which are used in groups,
|
|
151
|
+
* rules, and values) you must ensure the styling is set in each block. If your styling isn't showing the ensure that you're
|
|
152
|
+
* using more specific css rules to override the precedence of your rule.
|
|
153
|
+
*
|
|
154
|
+
* `rule`: Additional CSS for expression rule component
|
|
155
|
+
*
|
|
156
|
+
* `value`: Additional CSS for rule value component
|
|
157
|
+
*
|
|
158
|
+
* `field`: Additional CSS for rule field component
|
|
159
|
+
*
|
|
160
|
+
* `operator`: Additional CSS for rule operator component
|
|
161
|
+
*
|
|
162
|
+
* `group`: Additional CSS for expression group component
|
|
163
|
+
*
|
|
164
|
+
* @privateRemarks
|
|
165
|
+
* Use css layers to help with the precedence in future.
|
|
166
|
+
*/
|
|
87
167
|
declare type CustomStyles = {
|
|
88
|
-
/** Additional CSS for expression rule component */
|
|
89
168
|
rule?: string;
|
|
90
|
-
/** Additional CSS for rule value component */
|
|
91
169
|
value?: string;
|
|
92
|
-
/** Additional CSS for rule field component */
|
|
93
170
|
field?: string;
|
|
94
|
-
/** Additional CSS for rule operator component */
|
|
95
171
|
operator?: string;
|
|
96
|
-
/** Additional CSS for expression group component */
|
|
97
172
|
group?: string;
|
|
98
173
|
};
|
|
99
174
|
|
|
100
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* Configuration for a date input, which has s string value and a date field input
|
|
177
|
+
* @beta **/
|
|
101
178
|
declare type DateInput = {
|
|
102
179
|
input: 'date';
|
|
103
180
|
type: 'date';
|
|
104
181
|
validation?: (x: unknown) => string | null;
|
|
105
182
|
};
|
|
106
183
|
|
|
107
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Configuration for a datetime input, which has s string value and a datetime field input
|
|
186
|
+
* @beta **/
|
|
108
187
|
declare type DateTimeInput = {
|
|
109
188
|
input: 'datetime-local';
|
|
110
189
|
type: 'date-time';
|
|
111
190
|
validation?: (x: unknown) => string | null;
|
|
112
191
|
};
|
|
113
192
|
|
|
114
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Top level component to allow the user to build expressions. It produces a generic payload which doesn't have any system by itself
|
|
195
|
+
* to evaluate or execute the built expression.
|
|
196
|
+
*
|
|
197
|
+
* The basics required to work with this component:
|
|
198
|
+
*
|
|
199
|
+
* {@link ExpressionBuilder.config} property to configure and input data and models into the component.
|
|
200
|
+
*
|
|
201
|
+
* _Event_ change - `Types.Group` emits the model configuration on change. If you create a child component of the expression builder
|
|
202
|
+
* where you want to use a different (e.g. domain specific) model then it will likely override then emit event and instead emit
|
|
203
|
+
* it's own model. To check the underlying `Types.Group` model check the {@link ExpressionBuilder.model} property.
|
|
204
|
+
*
|
|
205
|
+
* @beta
|
|
206
|
+
*/
|
|
115
207
|
export declare class ExpressionBuilder extends GenesisElement implements MetadataProvider {
|
|
208
|
+
/**
|
|
209
|
+
* config - `Types.Config` the configuration which is required to be set for the expression builder. All properties are
|
|
210
|
+
* defined under this single object to enforce that they're kept in sync with one another.
|
|
211
|
+
*
|
|
212
|
+
* If you want to set the expression of the expression builder you should do it via the `model` property on this object.
|
|
213
|
+
*
|
|
214
|
+
* If you're using a child class of this component with a specific model implementation you likely *don't* want to set this
|
|
215
|
+
* property directly. See example 3.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* Configuring the basic elements required by an expression builder instance
|
|
219
|
+
* ```ts
|
|
220
|
+
* const config: Types.Config = {
|
|
221
|
+
* fields: ...,
|
|
222
|
+
* combinators: ...,
|
|
223
|
+
* operators: ...,
|
|
224
|
+
* };
|
|
225
|
+
* document.querySelector('expression-builder').config = config;
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* Configuring the basic elements required by an expression builder instance, as well as inputting a model to hydrate
|
|
230
|
+
* ```ts
|
|
231
|
+
* const config: Types.Config = {
|
|
232
|
+
* fields: ...,
|
|
233
|
+
* combinators: ...,
|
|
234
|
+
* operators: ...,
|
|
235
|
+
* model: ...,
|
|
236
|
+
* };
|
|
237
|
+
* document.querySelector('expression-builder').config = config;
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* You may create your own child of the expression builder which automatically defines some of the properties, such
|
|
242
|
+
* as creating a rule builder which defines boolean operators and combinators. In this case you should use your own
|
|
243
|
+
* property name, and on change apply the user and your configurations back to the config property.
|
|
244
|
+
* ```ts
|
|
245
|
+
* const config: MyTypes.RuleConfig = {
|
|
246
|
+
* operators: ...,
|
|
247
|
+
* };
|
|
248
|
+
* // In the implementation of RuleExpressionBuilder it should listen to ruleConfigChanged and
|
|
249
|
+
* apply the missing combinators and opreators back to the config along with the user's configuration
|
|
250
|
+
* document.querySelector('rule-expression-builder').ruleConfig = config;
|
|
251
|
+
* ```
|
|
252
|
+
* @beta
|
|
253
|
+
*/
|
|
116
254
|
config: Config_2;
|
|
255
|
+
/**
|
|
256
|
+
* styles - `Types.Styles` optional configuration which allows you to set custom element tag names to be used, as well as
|
|
257
|
+
* custom css to be inserted into the shadow DOM.
|
|
258
|
+
* @example
|
|
259
|
+
* Bare bones example of using a custom select component
|
|
260
|
+
* ```ts
|
|
261
|
+
* const styles: Types.Styles = {
|
|
262
|
+
* customElements: {
|
|
263
|
+
* select: 'rapid-select',
|
|
264
|
+
* },
|
|
265
|
+
* styles: {
|
|
266
|
+
* // If you want to customise your `rapid-select` then you can do it here. The select input
|
|
267
|
+
* // is used in the value, field, and operator component, so you should set the styles for all of them for real
|
|
268
|
+
* value: `
|
|
269
|
+
* rapid-select {
|
|
270
|
+
* max-width: 180px;
|
|
271
|
+
* }
|
|
272
|
+
* `
|
|
273
|
+
* }
|
|
274
|
+
* }
|
|
275
|
+
* document.querySelector('expression-builder').styles = styles;
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @beta
|
|
279
|
+
*/
|
|
117
280
|
styles?: Styles;
|
|
281
|
+
/**
|
|
282
|
+
* model - `Types.Group` the current model which completely describes the state of the component.
|
|
283
|
+
*
|
|
284
|
+
* *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.
|
|
285
|
+
*
|
|
286
|
+
* 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
|
|
287
|
+
* has a model which isn't valid for every single state (e.g. requires a complete rule) you can check this underlying model to
|
|
288
|
+
* verify what field or operator is selected.
|
|
289
|
+
*
|
|
290
|
+
* @beta
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* const model = document.querySelector('expression-builder');
|
|
295
|
+
* // 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
|
|
296
|
+
* the emited change event, you can use this to check more specific changes that a domain specific model might not.
|
|
297
|
+
*
|
|
298
|
+
* For example, imagine a RulExpressionBuilder which is an implementation specifically for a boolean logic expression. That component may not
|
|
299
|
+
* 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
|
|
300
|
+
* 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
|
|
301
|
+
* changed the value you can check the model here.
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
118
304
|
model: ModelGroup | null;
|
|
119
305
|
private ruleCount;
|
|
120
306
|
private groupCount;
|
|
@@ -130,7 +316,7 @@ export declare class ExpressionBuilder extends GenesisElement implements Metadat
|
|
|
130
316
|
/** @internal */
|
|
131
317
|
modelChanged(_: Config_2, newModel: ModelGroup): void;
|
|
132
318
|
/**
|
|
133
|
-
* @
|
|
319
|
+
* @beta
|
|
134
320
|
* Dispatches the provided model to the DOM.
|
|
135
321
|
*
|
|
136
322
|
* @remarks
|
|
@@ -143,7 +329,9 @@ export declare class ExpressionBuilder extends GenesisElement implements Metadat
|
|
|
143
329
|
getGroupId(): string;
|
|
144
330
|
/** @internal */
|
|
145
331
|
getRuleId(): string;
|
|
332
|
+
/** @internal */
|
|
146
333
|
connectedCallback(): void;
|
|
334
|
+
/** @internal */
|
|
147
335
|
disconnectedCallback(): void;
|
|
148
336
|
private handleAddGroup;
|
|
149
337
|
private _handleAddGroup;
|
|
@@ -159,36 +347,84 @@ export declare class ExpressionBuilder extends GenesisElement implements Metadat
|
|
|
159
347
|
private _handleUpdateRuleData;
|
|
160
348
|
}
|
|
161
349
|
|
|
162
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Configuration for the fields which the user can choose from per rule, the left hand side of each rule expression.
|
|
352
|
+
* @beta
|
|
353
|
+
*
|
|
354
|
+
* `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}.
|
|
355
|
+
*
|
|
356
|
+
* `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.
|
|
357
|
+
*
|
|
358
|
+
* `fieldId`: Id for the field
|
|
359
|
+
*
|
|
360
|
+
* `label`: Label for the field, what the user sees on the select input listbox.
|
|
361
|
+
*
|
|
362
|
+
* (not yet implemented) `operators`: Constrain the operators which can be used with this field (e.g. only allow starts_with on a string)
|
|
363
|
+
*/
|
|
364
|
+
/** @beta **/
|
|
163
365
|
declare type Field = {
|
|
164
366
|
optgroup?: string | null;
|
|
165
|
-
data?: any;
|
|
166
367
|
defaultValue?: any;
|
|
167
368
|
fieldId: string;
|
|
168
369
|
label: string;
|
|
169
370
|
operators?: string[];
|
|
170
371
|
} & FieldTypes;
|
|
171
372
|
|
|
172
|
-
/**
|
|
373
|
+
/**
|
|
374
|
+
* Union of all input types
|
|
375
|
+
* @beta **/
|
|
173
376
|
declare type FieldTypes = TextInput | NumberInput | CheckboxInput | SelectInput | DateInput | DateTimeInput;
|
|
174
377
|
|
|
175
378
|
/**
|
|
176
379
|
* Gets the string representation from a `Date` which is the format a `date` input uses.
|
|
177
|
-
* `yyyy-mm-dd
|
|
380
|
+
* `yyyy-mm-dd`.
|
|
178
381
|
* Uses UTC methods to ensure consistent output regardless of timezone.
|
|
179
|
-
*
|
|
382
|
+
*
|
|
383
|
+
* Used to convert a javascript date object into the required string format expected by the expression builder.
|
|
384
|
+
* @beta
|
|
180
385
|
*/
|
|
181
386
|
export declare const formatDateString: (date: Date) => string;
|
|
182
387
|
|
|
183
388
|
/**
|
|
184
389
|
* Gets the string representation from a `Date` which is the format a `datetime-local` input uses.
|
|
185
|
-
* `yyyy-mm-ddThh:mm:ss
|
|
390
|
+
* `yyyy-mm-ddThh:mm:ss`.
|
|
186
391
|
* Uses UTC methods to ensure consistent output regardless of timezone.
|
|
187
|
-
*
|
|
392
|
+
*
|
|
393
|
+
* Used to convert a javascript date object into the required string format expected by the expression builder.
|
|
394
|
+
* @beta
|
|
188
395
|
*/
|
|
189
396
|
export declare const formatDateTimeString: (date: Date) => string;
|
|
190
397
|
|
|
191
|
-
/**
|
|
398
|
+
/**
|
|
399
|
+
* A group forms the overall model of the expression builder, and is recursive to itself allowing for a nested tree.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```
|
|
403
|
+
* RULE 1
|
|
404
|
+
* FIELD : PROFILE_AGE
|
|
405
|
+
* OPERATOR : GREATER_THAN
|
|
406
|
+
* VALUE : 18
|
|
407
|
+
*
|
|
408
|
+
* COMBINATOR : OR
|
|
409
|
+
*
|
|
410
|
+
* GROUP 2
|
|
411
|
+
* RULE 2
|
|
412
|
+
* FIELD : PARENT_ROLE
|
|
413
|
+
* OPERATOR : ONE_OF
|
|
414
|
+
* VALUE : GIVES_PERMISSION
|
|
415
|
+
*
|
|
416
|
+
* COMBINATOR : AND
|
|
417
|
+
*
|
|
418
|
+
* RULE 3
|
|
419
|
+
* FIELD : GRANTS_CHILD_ACCESS
|
|
420
|
+
* OPERATOR : EQUALS
|
|
421
|
+
* VALUE : true
|
|
422
|
+
*
|
|
423
|
+
* If you're constructing a boolean expression then this rule could be used to restrict users who are 17 or younger, but
|
|
424
|
+
* allowing parents who have specific rights to be able to grant access too.
|
|
425
|
+
* ```
|
|
426
|
+
* @beta
|
|
427
|
+
*/
|
|
192
428
|
declare type Group = {
|
|
193
429
|
combinator: Combinator;
|
|
194
430
|
children: (Rule | Group)[];
|
|
@@ -206,7 +442,10 @@ declare type GroupStructure = Omit<Group, 'children'> & {
|
|
|
206
442
|
children: (ModelRule | ModelGroup)[];
|
|
207
443
|
};
|
|
208
444
|
|
|
209
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* A set of boolean logic combinators which configure the expression builder to produce boolean expressions.
|
|
447
|
+
* @beta
|
|
448
|
+
* */
|
|
210
449
|
declare const LOGICAL_COMBINATORS: Combinator[];
|
|
211
450
|
|
|
212
451
|
/** @internal */
|
|
@@ -222,20 +461,39 @@ declare type ModelGroup = GroupMetadata & GroupStructure;
|
|
|
222
461
|
/** @internal **/
|
|
223
462
|
declare type ModelRule = Rule & RuleMetadata;
|
|
224
463
|
|
|
225
|
-
/**
|
|
464
|
+
/**
|
|
465
|
+
* A combinator which has a null action.
|
|
466
|
+
*
|
|
467
|
+
* If configured as the only combinator then it configures the expression builder to only create a single rule.
|
|
468
|
+
* @beta
|
|
469
|
+
* */
|
|
226
470
|
declare const NULL_COMBINATOR: Combinator;
|
|
227
471
|
|
|
228
|
-
/**
|
|
472
|
+
/**
|
|
473
|
+
* Configuration for a number-type input, which has a number value and a number input.
|
|
474
|
+
* @beta **/
|
|
229
475
|
declare type NumberInput = {
|
|
230
476
|
input: 'number';
|
|
231
477
|
type: 'int' | 'short' | 'double' | 'long' | 'bigdecimal';
|
|
232
478
|
validation?: (x: unknown) => string | null;
|
|
233
479
|
};
|
|
234
480
|
|
|
235
|
-
/** @
|
|
481
|
+
/** @beta **/
|
|
236
482
|
declare type Operator = UniraryOperator | BinaryOperator | TernararyOperator | VariadicOperator;
|
|
237
483
|
|
|
238
|
-
/**
|
|
484
|
+
/**
|
|
485
|
+
* The shared configuration properties of an operator
|
|
486
|
+
* @beta
|
|
487
|
+
*
|
|
488
|
+
* `applyTo`: Only allow this operator to be used on a field type (e.g. only allow this on an enum)
|
|
489
|
+
*
|
|
490
|
+
* `optgroup`: Group the operators inside of the select component
|
|
491
|
+
*
|
|
492
|
+
* `type`: The name of the operator (e.g. one_of)
|
|
493
|
+
*
|
|
494
|
+
* `tooltip`: Optional tooltip to display on mouse hover
|
|
495
|
+
*/
|
|
496
|
+
/** @beta **/
|
|
239
497
|
declare type _Operator = {
|
|
240
498
|
applyTo: FieldTypes['type'][];
|
|
241
499
|
optgroup?: string | null;
|
|
@@ -243,7 +501,18 @@ declare type _Operator = {
|
|
|
243
501
|
tooltip?: string;
|
|
244
502
|
};
|
|
245
503
|
|
|
246
|
-
/**
|
|
504
|
+
/**
|
|
505
|
+
* A rule is a single constituent element of a larger expression, and is the smallest whole part of an expression.
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* ```
|
|
509
|
+
* FIELD : PROFILE_AGE
|
|
510
|
+
* OPERATOR : GREATER_THAN
|
|
511
|
+
* VALUE : 18
|
|
512
|
+
*
|
|
513
|
+
* If you're constructing a boolean expression then this rule could be used to restrict users who are 17 or younger.
|
|
514
|
+
* ```
|
|
515
|
+
@beta **/
|
|
247
516
|
declare type Rule = {
|
|
248
517
|
field: Field | null;
|
|
249
518
|
} & ({
|
|
@@ -267,18 +536,27 @@ declare type RuleMetadata = {
|
|
|
267
536
|
config: Config_2;
|
|
268
537
|
};
|
|
269
538
|
|
|
270
|
-
/**
|
|
539
|
+
/**
|
|
540
|
+
* Configuration for an enum-type input, which as a string or number value, and uses a select input.
|
|
541
|
+
* @beta **/
|
|
271
542
|
declare type SelectInput = {
|
|
272
543
|
input: 'select';
|
|
273
544
|
type: 'enum';
|
|
274
545
|
values: Record<string, string | number>;
|
|
275
546
|
};
|
|
276
547
|
|
|
277
|
-
/**
|
|
548
|
+
/**
|
|
549
|
+
* Configuration items for the expression builder styles.
|
|
550
|
+
*
|
|
551
|
+
* `customElements`: optional `Types.CustomElements` block for overriding the html tags used in the expression builder
|
|
552
|
+
*
|
|
553
|
+
* `customStyles`: optional `Types.CustomStyles` block to configure custom css for components.
|
|
554
|
+
*
|
|
555
|
+
* @beta
|
|
556
|
+
|
|
557
|
+
**/
|
|
278
558
|
declare type Styles = {
|
|
279
|
-
/** Custom element tags for HTML elements */
|
|
280
559
|
customElements?: CustomElements;
|
|
281
|
-
/** Custom styles for components */
|
|
282
560
|
customStyles?: CustomStyles;
|
|
283
561
|
};
|
|
284
562
|
|
|
@@ -288,12 +566,16 @@ export declare const styles: ElementStyles;
|
|
|
288
566
|
/** @alpha **/
|
|
289
567
|
export declare const template: ViewTemplate<ExpressionBuilder, any>;
|
|
290
568
|
|
|
291
|
-
/**
|
|
569
|
+
/**
|
|
570
|
+
* An operator which has two values. Example `between_inclusive`
|
|
571
|
+
* @beta **/
|
|
292
572
|
declare type TernararyOperator = {
|
|
293
573
|
nbInputs: 2;
|
|
294
574
|
} & _Operator;
|
|
295
575
|
|
|
296
|
-
/**
|
|
576
|
+
/**
|
|
577
|
+
* Configuration for a text-type input, which has a string value and a text input.
|
|
578
|
+
* @beta **/
|
|
297
579
|
declare type TextInput = {
|
|
298
580
|
type: 'string';
|
|
299
581
|
input: 'text';
|
|
@@ -327,12 +609,17 @@ declare namespace Types {
|
|
|
327
609
|
}
|
|
328
610
|
export { Types }
|
|
329
611
|
|
|
330
|
-
/**
|
|
612
|
+
/**
|
|
613
|
+
* An operator which doesn't have any value. Example `is_null`
|
|
614
|
+
* @beta
|
|
615
|
+
* **/
|
|
331
616
|
declare type UniraryOperator = {
|
|
332
617
|
nbInputs: 0;
|
|
333
618
|
} & _Operator;
|
|
334
619
|
|
|
335
|
-
/**
|
|
620
|
+
/**
|
|
621
|
+
* An operator which can have any number of values where `NumVals >= 1`, defaulting to 1. Example `one_of`.
|
|
622
|
+
* @beta **/
|
|
336
623
|
declare type VariadicOperator = {
|
|
337
624
|
nbInputs: 'many';
|
|
338
625
|
} & _Operator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/expression-builder](./expression-builder.md) > [Config](./expression-builder.config.md) > [BASE\_LOGICAL\_COMBINATORS](./expression-builder.config.base_logical_combinators.md)
|
|
4
|
+
|
|
5
|
+
## Config.BASE\_LOGICAL\_COMBINATORS variable
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
Basic `AND` and `OR` logical combinators which can be used in the model config.
|
|
11
|
+
|
|
12
|
+
**Signature:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
BASE_LOGICAL_COMBINATORS: Combinator[]
|
|
16
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/expression-builder](./expression-builder.md) > [Config](./expression-builder.config.md) > [LOGICAL\_COMBINATORS](./expression-builder.config.logical_combinators.md)
|
|
4
|
+
|
|
5
|
+
## Config.LOGICAL\_COMBINATORS variable
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
A set of boolean logic combinators which configure the expression builder to produce boolean expressions.
|
|
11
|
+
|
|
12
|
+
**Signature:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
LOGICAL_COMBINATORS: Combinator[]
|
|
16
|
+
```
|
|
@@ -4,3 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
## Config namespace
|
|
6
6
|
|
|
7
|
+
## Variables
|
|
8
|
+
|
|
9
|
+
| Variable | Description |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [BASE\_LOGICAL\_COMBINATORS](./expression-builder.config.base_logical_combinators.md) | **_(BETA)_** Basic <code>AND</code> and <code>OR</code> logical combinators which can be used in the model config. |
|
|
12
|
+
| [LOGICAL\_COMBINATORS](./expression-builder.config.logical_combinators.md) | **_(BETA)_** A set of boolean logic combinators which configure the expression builder to produce boolean expressions. |
|
|
13
|
+
| [NULL\_COMBINATOR](./expression-builder.config.null_combinator.md) | <p>**_(BETA)_** A combinator which has a null action.</p><p>If configured as the only combinator then it configures the expression builder to only create a single rule.</p> |
|
|
14
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/expression-builder](./expression-builder.md) > [Config](./expression-builder.config.md) > [NULL\_COMBINATOR](./expression-builder.config.null_combinator.md)
|
|
4
|
+
|
|
5
|
+
## Config.NULL\_COMBINATOR variable
|
|
6
|
+
|
|
7
|
+
> This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
A combinator which has a null action.
|
|
11
|
+
|
|
12
|
+
If configured as the only combinator then it configures the expression builder to only create a single rule.
|
|
13
|
+
|
|
14
|
+
**Signature:**
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
NULL_COMBINATOR: Combinator
|
|
18
|
+
```
|