@masterteam/formula-builder 0.0.22 → 0.0.24
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/README.md +72 -70
- package/assets/formula-builder.css +2 -2
- package/assets/i18n/ar.json +4 -1
- package/assets/i18n/en.json +4 -1
- package/fesm2022/masterteam-formula-builder.mjs +229 -16
- package/fesm2022/masterteam-formula-builder.mjs.map +1 -1
- package/package.json +3 -3
- package/types/masterteam-formula-builder.d.ts +63 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterteam/formula-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"directory": "../../../dist/masterteam/formula-builder",
|
|
6
6
|
"linkDirectory": true,
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"rxjs": "^7.8.2",
|
|
20
20
|
"tailwindcss": "^4.2.2",
|
|
21
21
|
"tailwindcss-primeui": "^0.6.1",
|
|
22
|
-
"@masterteam/
|
|
23
|
-
"@masterteam/
|
|
22
|
+
"@masterteam/icons": "^0.0.17",
|
|
23
|
+
"@masterteam/components": "^0.0.221"
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
@@ -80,6 +80,11 @@ interface FormulaBuilderNextTokensResponse {
|
|
|
80
80
|
version?: string;
|
|
81
81
|
generatedAt?: string;
|
|
82
82
|
}
|
|
83
|
+
/** A single selectable value of a lookup / status / lookup-matrix property. */
|
|
84
|
+
interface FormulaPropertyItem {
|
|
85
|
+
key: string;
|
|
86
|
+
name: string;
|
|
87
|
+
}
|
|
83
88
|
|
|
84
89
|
interface FormulaBuilderValue {
|
|
85
90
|
expression: string;
|
|
@@ -102,6 +107,8 @@ type SegmentMeta = PathSegment & {
|
|
|
102
107
|
interface FormulaBuilderUiConfig {
|
|
103
108
|
toolbarTabs?: readonly ToolbarTab[];
|
|
104
109
|
codeOnly?: boolean;
|
|
110
|
+
builderOnly?: boolean;
|
|
111
|
+
valueMode?: 'object' | 'expression';
|
|
105
112
|
hideToolbar?: boolean;
|
|
106
113
|
hideStatusBar?: boolean;
|
|
107
114
|
isProcessBuilder?: boolean;
|
|
@@ -138,6 +145,10 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
138
145
|
readonly toolbarTabs: _angular_core.InputSignal<readonly ToolbarTab[]>;
|
|
139
146
|
/** Force code editor mode and hide the mode toggle */
|
|
140
147
|
readonly codeOnly: _angular_core.InputSignal<boolean>;
|
|
148
|
+
/** Keep the block builder active and hide the code-mode toggle. */
|
|
149
|
+
readonly builderOnly: _angular_core.InputSignal<boolean>;
|
|
150
|
+
/** ControlValueAccessor output shape. `expression` emits the formula string. */
|
|
151
|
+
readonly valueMode: _angular_core.InputSignal<"object" | "expression">;
|
|
141
152
|
/** Use Process Builder current-only Formula Engine endpoints */
|
|
142
153
|
readonly isProcessBuilder: _angular_core.InputSignal<boolean>;
|
|
143
154
|
/** Emits validation result on change */
|
|
@@ -155,6 +166,7 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
155
166
|
readonly resolvedContextEntityTypeKey: _angular_core.Signal<string | undefined>;
|
|
156
167
|
readonly isModuleContext: _angular_core.Signal<boolean>;
|
|
157
168
|
readonly autocompleteProvider: (request: AutocompleteRequest) => Observable<AutocompleteResponse | null>;
|
|
169
|
+
private fetchAutocomplete$;
|
|
158
170
|
/** Editor mode */
|
|
159
171
|
readonly editorMode: _angular_core.WritableSignal<"builder" | "code">;
|
|
160
172
|
readonly isCodeMode: _angular_core.Signal<boolean>;
|
|
@@ -183,8 +195,8 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
183
195
|
private readonly propertyLoadingPath;
|
|
184
196
|
constructor();
|
|
185
197
|
ngOnDestroy(): void;
|
|
186
|
-
writeValue(value: FormulaBuilderValue | null): void;
|
|
187
|
-
registerOnChange(fn: (value: FormulaBuilderValue) => void): void;
|
|
198
|
+
writeValue(value: FormulaBuilderValue | string | null): void;
|
|
199
|
+
registerOnChange(fn: (value: FormulaBuilderValue | string) => void): void;
|
|
188
200
|
registerOnTouched(fn: () => void): void;
|
|
189
201
|
setDisabledState(isDisabled: boolean): void;
|
|
190
202
|
/** Handle formula change from editor */
|
|
@@ -204,6 +216,7 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
204
216
|
private exitCodeMode;
|
|
205
217
|
/** Clear the formula */
|
|
206
218
|
clear(): void;
|
|
219
|
+
private shouldUseCodeMode;
|
|
207
220
|
private resolveExpressionValue;
|
|
208
221
|
private applyFormulaValue;
|
|
209
222
|
private rebuildBuilderFromExpression;
|
|
@@ -255,11 +268,24 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
255
268
|
readonly propertyOptions: _angular_core.Signal<{
|
|
256
269
|
key: string;
|
|
257
270
|
name: any;
|
|
271
|
+
viewType: string | undefined;
|
|
258
272
|
}[]>;
|
|
259
273
|
readonly selectedProperty: _angular_core.Signal<{
|
|
260
274
|
key: string;
|
|
261
275
|
name: any;
|
|
276
|
+
viewType: string | undefined;
|
|
262
277
|
} | null>;
|
|
278
|
+
/** Selectable values of the chosen lookup/status/lookup-matrix property. */
|
|
279
|
+
readonly lookupItems: _angular_core.WritableSignal<FormulaPropertyItem[]>;
|
|
280
|
+
/** Whether the property-items request is in flight. */
|
|
281
|
+
readonly isLookupItemsLoading: _angular_core.WritableSignal<boolean>;
|
|
282
|
+
/** Currently selected lookup value key (the form inserted into the formula). */
|
|
283
|
+
readonly lookupValueKey: _angular_core.WritableSignal<string>;
|
|
284
|
+
private lookupItemsRequestId;
|
|
285
|
+
/** True when the selected field draws its values from a fixed lookup set. */
|
|
286
|
+
readonly isLookupProperty: _angular_core.Signal<boolean>;
|
|
287
|
+
/** Insert-value action is enabled once a lookup value has been picked. */
|
|
288
|
+
readonly canInsertLookupValue: _angular_core.Signal<boolean>;
|
|
263
289
|
readonly canInsertProperty: _angular_core.Signal<boolean>;
|
|
264
290
|
setPropertyScope(scope: string): void;
|
|
265
291
|
setPathSegmentValue(index: number, value: string | null): void;
|
|
@@ -273,9 +299,35 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
273
299
|
name: string;
|
|
274
300
|
}[];
|
|
275
301
|
insertSelectedProperty(insertBlock: (block: SmartBlock) => void): void;
|
|
302
|
+
/**
|
|
303
|
+
* Insert the picked lookup value as a string literal. The executable form
|
|
304
|
+
* carries the stable lookup KEY (locale-independent) while the chip shows
|
|
305
|
+
* the friendly NAME — e.g. `… == "completed"` rendered as `… == Completed`.
|
|
306
|
+
*/
|
|
307
|
+
insertSelectedLookupValue(insertBlock: (block: SmartBlock) => void): void;
|
|
308
|
+
/**
|
|
309
|
+
* Detect that the cursor (in the code editor) is positioned to type the
|
|
310
|
+
* right-hand value of a comparison against a property, e.g.
|
|
311
|
+
* `@Current::task_status == "in_`. Returns the compared property key, whether
|
|
312
|
+
* an opening quote was already typed, and the partial value typed so far.
|
|
313
|
+
*/
|
|
314
|
+
private detectLookupValueContext;
|
|
315
|
+
/**
|
|
316
|
+
* Avoid a wasted request for properties we already know aren't lookups; for
|
|
317
|
+
* keys whose view type isn't loaded yet, let property-items be the authority.
|
|
318
|
+
*/
|
|
319
|
+
private shouldFetchLookupItems;
|
|
320
|
+
private findLoadedPropertyViewType;
|
|
321
|
+
/**
|
|
322
|
+
* Build an autocomplete response from a lookup property's values. The inserted
|
|
323
|
+
* text carries the stable key wrapped in quotes (the opening quote is dropped
|
|
324
|
+
* when the user already typed one), matching the key-as-value contract used by
|
|
325
|
+
* the toolbar Value row.
|
|
326
|
+
*/
|
|
327
|
+
private buildLookupValueResponse;
|
|
276
328
|
getOperatorDisplayName(token: string): string;
|
|
277
329
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormulaBuilder, never>;
|
|
278
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormulaBuilder, "mt-formula-builder", never, { "propertiesByPath": { "alias": "propertiesByPath"; "required": false; "isSignal": true; }; "levelSchemaId": { "alias": "levelSchemaId"; "required": false; "isSignal": true; }; "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "contextEntityTypeKey": { "alias": "contextEntityTypeKey"; "required": false; "isSignal": true; }; "templateId": { "alias": "templateId"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "hideToolbar": { "alias": "hideToolbar"; "required": false; "isSignal": true; }; "hideStatusBar": { "alias": "hideStatusBar"; "required": false; "isSignal": true; }; "toolbarTabs": { "alias": "toolbarTabs"; "required": false; "isSignal": true; }; "codeOnly": { "alias": "codeOnly"; "required": false; "isSignal": true; }; "isProcessBuilder": { "alias": "isProcessBuilder"; "required": false; "isSignal": true; }; }, { "validationChange": "validationChange"; "tokensChange": "tokensChange"; }, never, never, true, never>;
|
|
330
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormulaBuilder, "mt-formula-builder", never, { "propertiesByPath": { "alias": "propertiesByPath"; "required": false; "isSignal": true; }; "levelSchemaId": { "alias": "levelSchemaId"; "required": false; "isSignal": true; }; "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "contextEntityTypeKey": { "alias": "contextEntityTypeKey"; "required": false; "isSignal": true; }; "templateId": { "alias": "templateId"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "hideToolbar": { "alias": "hideToolbar"; "required": false; "isSignal": true; }; "hideStatusBar": { "alias": "hideStatusBar"; "required": false; "isSignal": true; }; "toolbarTabs": { "alias": "toolbarTabs"; "required": false; "isSignal": true; }; "codeOnly": { "alias": "codeOnly"; "required": false; "isSignal": true; }; "builderOnly": { "alias": "builderOnly"; "required": false; "isSignal": true; }; "valueMode": { "alias": "valueMode"; "required": false; "isSignal": true; }; "isProcessBuilder": { "alias": "isProcessBuilder"; "required": false; "isSignal": true; }; }, { "validationChange": "validationChange"; "tokensChange": "tokensChange"; }, never, never, true, never>;
|
|
279
331
|
}
|
|
280
332
|
|
|
281
333
|
type FormulaApiMode$1 = 'default' | 'current-only';
|
|
@@ -287,9 +339,17 @@ declare class FormulaContextService {
|
|
|
287
339
|
private readonly contextCache;
|
|
288
340
|
private readonly propertiesCache;
|
|
289
341
|
private readonly nextTokensCache;
|
|
342
|
+
private readonly propertyItemsCache;
|
|
290
343
|
loadContext(schemaId: number, moduleId?: number, contextEntityTypeKey?: string, mode?: FormulaApiMode$1): Observable<FormulaBuilderContextResponse | null>;
|
|
291
344
|
getScopeProperties(schemaId: number, component: string | undefined, tablePath: string, moduleId?: number, mode?: FormulaApiMode$1): Observable<FormulaPropertyDescriptor[]>;
|
|
292
345
|
getNextTokens(schemaId: number, component: string, tablePath: string, moduleId?: number, mode?: FormulaApiMode$1): Observable<FormulaBuilderNextTokensResponse | null>;
|
|
346
|
+
/**
|
|
347
|
+
* Selectable values for a lookup / status / lookup-matrix property.
|
|
348
|
+
* The backend responds 400 (VAL_001) for any non-lookup property, which we
|
|
349
|
+
* swallow into an empty list — callers gate the value picker on a known
|
|
350
|
+
* lookup view type, so an empty result simply means "no picker".
|
|
351
|
+
*/
|
|
352
|
+
getPropertyItems(propertyKey: string, mode?: FormulaApiMode$1): Observable<FormulaPropertyItem[]>;
|
|
293
353
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormulaContextService, never>;
|
|
294
354
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormulaContextService>;
|
|
295
355
|
}
|