@masterteam/formula-builder 0.0.21 → 0.0.23
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/assets/formula-builder.css +1 -1
- package/assets/i18n/ar.json +4 -1
- package/assets/i18n/en.json +4 -1
- package/fesm2022/masterteam-formula-builder.mjs +233 -9
- package/fesm2022/masterteam-formula-builder.mjs.map +1 -1
- package/package.json +3 -3
- package/types/masterteam-formula-builder.d.ts +63 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterteam/formula-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"directory": "../../../dist/masterteam/formula-builder",
|
|
6
6
|
"linkDirectory": true,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"rxjs": "^7.8.2",
|
|
20
20
|
"tailwindcss": "^4.2.2",
|
|
21
21
|
"tailwindcss-primeui": "^0.6.1",
|
|
22
|
-
"@masterteam/components": "^0.0.
|
|
22
|
+
"@masterteam/components": "^0.0.208",
|
|
23
23
|
"@masterteam/icons": "^0.0.17"
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"tslib": "^2.8.1"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|
|
@@ -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;
|
|
@@ -155,6 +160,7 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
155
160
|
readonly resolvedContextEntityTypeKey: _angular_core.Signal<string | undefined>;
|
|
156
161
|
readonly isModuleContext: _angular_core.Signal<boolean>;
|
|
157
162
|
readonly autocompleteProvider: (request: AutocompleteRequest) => Observable<AutocompleteResponse | null>;
|
|
163
|
+
private fetchAutocomplete$;
|
|
158
164
|
/** Editor mode */
|
|
159
165
|
readonly editorMode: _angular_core.WritableSignal<"builder" | "code">;
|
|
160
166
|
readonly isCodeMode: _angular_core.Signal<boolean>;
|
|
@@ -207,6 +213,16 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
207
213
|
private resolveExpressionValue;
|
|
208
214
|
private applyFormulaValue;
|
|
209
215
|
private rebuildBuilderFromExpression;
|
|
216
|
+
/**
|
|
217
|
+
* Resolve friendly display labels on property tokens from the loaded property
|
|
218
|
+
* map (table path -> [{ key, name }]). This lets the visual builder render
|
|
219
|
+
* "Start Date" instead of the raw "@Current::dema_qa_portfolio_startdate" key
|
|
220
|
+
* after a code->blocks switch or when hydrating an expression-only formula.
|
|
221
|
+
* Pure and loop-safe: returns the SAME array reference when nothing changed,
|
|
222
|
+
* and only touches `display` — never `value` — so the executable expression
|
|
223
|
+
* and validation are unaffected.
|
|
224
|
+
*/
|
|
225
|
+
private enrichTokenDisplays;
|
|
210
226
|
private syncBuilderFromExpression;
|
|
211
227
|
private setBuilderTokens;
|
|
212
228
|
readonly propertyScope: _angular_core.WritableSignal<string>;
|
|
@@ -245,11 +261,24 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
245
261
|
readonly propertyOptions: _angular_core.Signal<{
|
|
246
262
|
key: string;
|
|
247
263
|
name: any;
|
|
264
|
+
viewType: string | undefined;
|
|
248
265
|
}[]>;
|
|
249
266
|
readonly selectedProperty: _angular_core.Signal<{
|
|
250
267
|
key: string;
|
|
251
268
|
name: any;
|
|
269
|
+
viewType: string | undefined;
|
|
252
270
|
} | null>;
|
|
271
|
+
/** Selectable values of the chosen lookup/status/lookup-matrix property. */
|
|
272
|
+
readonly lookupItems: _angular_core.WritableSignal<FormulaPropertyItem[]>;
|
|
273
|
+
/** Whether the property-items request is in flight. */
|
|
274
|
+
readonly isLookupItemsLoading: _angular_core.WritableSignal<boolean>;
|
|
275
|
+
/** Currently selected lookup value key (the form inserted into the formula). */
|
|
276
|
+
readonly lookupValueKey: _angular_core.WritableSignal<string>;
|
|
277
|
+
private lookupItemsRequestId;
|
|
278
|
+
/** True when the selected field draws its values from a fixed lookup set. */
|
|
279
|
+
readonly isLookupProperty: _angular_core.Signal<boolean>;
|
|
280
|
+
/** Insert-value action is enabled once a lookup value has been picked. */
|
|
281
|
+
readonly canInsertLookupValue: _angular_core.Signal<boolean>;
|
|
253
282
|
readonly canInsertProperty: _angular_core.Signal<boolean>;
|
|
254
283
|
setPropertyScope(scope: string): void;
|
|
255
284
|
setPathSegmentValue(index: number, value: string | null): void;
|
|
@@ -263,6 +292,32 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
263
292
|
name: string;
|
|
264
293
|
}[];
|
|
265
294
|
insertSelectedProperty(insertBlock: (block: SmartBlock) => void): void;
|
|
295
|
+
/**
|
|
296
|
+
* Insert the picked lookup value as a string literal. The executable form
|
|
297
|
+
* carries the stable lookup KEY (locale-independent) while the chip shows
|
|
298
|
+
* the friendly NAME — e.g. `… == "completed"` rendered as `… == Completed`.
|
|
299
|
+
*/
|
|
300
|
+
insertSelectedLookupValue(insertBlock: (block: SmartBlock) => void): void;
|
|
301
|
+
/**
|
|
302
|
+
* Detect that the cursor (in the code editor) is positioned to type the
|
|
303
|
+
* right-hand value of a comparison against a property, e.g.
|
|
304
|
+
* `@Current::task_status == "in_`. Returns the compared property key, whether
|
|
305
|
+
* an opening quote was already typed, and the partial value typed so far.
|
|
306
|
+
*/
|
|
307
|
+
private detectLookupValueContext;
|
|
308
|
+
/**
|
|
309
|
+
* Avoid a wasted request for properties we already know aren't lookups; for
|
|
310
|
+
* keys whose view type isn't loaded yet, let property-items be the authority.
|
|
311
|
+
*/
|
|
312
|
+
private shouldFetchLookupItems;
|
|
313
|
+
private findLoadedPropertyViewType;
|
|
314
|
+
/**
|
|
315
|
+
* Build an autocomplete response from a lookup property's values. The inserted
|
|
316
|
+
* text carries the stable key wrapped in quotes (the opening quote is dropped
|
|
317
|
+
* when the user already typed one), matching the key-as-value contract used by
|
|
318
|
+
* the toolbar Value row.
|
|
319
|
+
*/
|
|
320
|
+
private buildLookupValueResponse;
|
|
266
321
|
getOperatorDisplayName(token: string): string;
|
|
267
322
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormulaBuilder, never>;
|
|
268
323
|
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>;
|
|
@@ -277,9 +332,17 @@ declare class FormulaContextService {
|
|
|
277
332
|
private readonly contextCache;
|
|
278
333
|
private readonly propertiesCache;
|
|
279
334
|
private readonly nextTokensCache;
|
|
335
|
+
private readonly propertyItemsCache;
|
|
280
336
|
loadContext(schemaId: number, moduleId?: number, contextEntityTypeKey?: string, mode?: FormulaApiMode$1): Observable<FormulaBuilderContextResponse | null>;
|
|
281
337
|
getScopeProperties(schemaId: number, component: string | undefined, tablePath: string, moduleId?: number, mode?: FormulaApiMode$1): Observable<FormulaPropertyDescriptor[]>;
|
|
282
338
|
getNextTokens(schemaId: number, component: string, tablePath: string, moduleId?: number, mode?: FormulaApiMode$1): Observable<FormulaBuilderNextTokensResponse | null>;
|
|
339
|
+
/**
|
|
340
|
+
* Selectable values for a lookup / status / lookup-matrix property.
|
|
341
|
+
* The backend responds 400 (VAL_001) for any non-lookup property, which we
|
|
342
|
+
* swallow into an empty list — callers gate the value picker on a known
|
|
343
|
+
* lookup view type, so an empty result simply means "no picker".
|
|
344
|
+
*/
|
|
345
|
+
getPropertyItems(propertyKey: string, mode?: FormulaApiMode$1): Observable<FormulaPropertyItem[]>;
|
|
283
346
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormulaContextService, never>;
|
|
284
347
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<FormulaContextService>;
|
|
285
348
|
}
|