@masterteam/formula-builder 0.0.28 → 0.0.30
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
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
# @masterteam/formula-builder
|
|
2
|
-
|
|
3
|
-
A powerful Formula Builder component for Angular 20+ with Tailwind CSS 4.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- ✅ **Visual Block Editor** - Make.com-inspired formula editing experience
|
|
8
|
-
- ✅ **42+ Built-in Functions** - Math, Logic, Aggregation, Hierarchy, Date, String
|
|
9
|
-
- ✅ **Real-time Validation** - Syntax checking with error highlighting
|
|
10
|
-
- ✅ **Context-aware Autocomplete** - Smart suggestions as you type
|
|
11
|
-
- ✅ **Drag & Drop** - Visual block manipulation with Angular CDK
|
|
12
|
-
- ✅ **Property References** - @PropertyKey, *.PropertyKey, $.Parent.PropertyKey
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pnpm add @masterteam/formula-builder
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { FormulaBuilder, type FormulaBuilderValue } from '@masterteam/formula-builder';
|
|
24
|
-
import { FormsModule } from '@angular/forms';
|
|
25
|
-
|
|
26
|
-
@Component({
|
|
27
|
-
imports: [FormsModule, FormulaBuilder],
|
|
28
|
-
template: `
|
|
29
|
-
<mt-formula-builder
|
|
30
|
-
[(ngModel)]="formulaState"
|
|
31
|
-
[levelSchemaId]="levelSchemaId"
|
|
32
|
-
(validationChange)="onValidation($event)"
|
|
33
|
-
/>
|
|
34
|
-
`
|
|
35
|
-
})
|
|
36
|
-
export class MyComponent {
|
|
37
|
-
formulaState: FormulaBuilderValue = { expression: '', builder: [] };
|
|
38
|
-
levelSchemaId = 6;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## API
|
|
43
|
-
|
|
44
|
-
### Inputs
|
|
45
|
-
|
|
46
|
-
| Input | Type | Description |
|
|
47
|
-
|-------|------|-------------|
|
|
48
|
-
| `ngModel` / `formControl` | `FormulaBuilderValue` | Form value `{ expression, builder }` (builder is token JSON array) |
|
|
49
|
-
| `propertiesByPath` | `Record<string, { key: string; name?: string }[]>` | Scoped properties (optional) |
|
|
50
|
-
| `levelSchemaId` | `number` | Level schema ID for validation context |
|
|
51
|
-
| `templateId` | `number` | Template ID for validation context |
|
|
52
|
-
| `placeholder` | `string` | Placeholder text |
|
|
53
|
-
| `hideToolbar` | `boolean` | Hide the top toolbar |
|
|
54
|
-
| `hideStatusBar` | `boolean` | Hide the status bar |
|
|
55
|
-
| `toolbarTabs` | `ToolbarTab[]` | Visible toolbar tabs, e.g. `['functions', 'operators']` |
|
|
56
|
-
| `functionCategories` | `FunctionCategoryGroup[]` | Optional host-owned catalog; overrides API context functions when provided |
|
|
57
|
-
| `operators` | `OperatorDefinition[]` | Operators shown in the toolbar; defaults to the shared formula operator catalog |
|
|
58
|
-
| `codeOnly` | `boolean` | Force code mode and hide the mode toggle |
|
|
59
|
-
| `builderOnly` | `boolean` | Force block builder mode and hide the code-mode toggle |
|
|
60
|
-
| `valueMode` | `'object' \| 'expression'` | Emit `{ expression, builder }` by default, or emit the expression string for legacy string contracts |
|
|
61
|
-
| `isProcessBuilder` | `boolean` | Use Process Builder current-only Formula Engine endpoints |
|
|
62
|
-
|
|
63
|
-
### Builder Mode Display Contract
|
|
64
|
-
|
|
65
|
-
Lookup/status value chips keep the executable literal as the stable backend key and use the block `display` value only for the friendly label. Builder-only hosts can show readable labels without changing the serialized formula expression.
|
|
66
|
-
|
|
67
|
-
### Outputs
|
|
68
|
-
|
|
69
|
-
| Output | Type | Description |
|
|
70
|
-
|--------|------|-------------|
|
|
71
|
-
| `validationChange` | `ValidationResult` | Emits validation results |
|
|
72
|
-
| `tokensChange` | `FormulaToken[]` | Emits when tokens change |
|
|
73
|
-
|
|
74
|
-
## Development
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
pnpm build:formula-builder
|
|
78
|
-
```
|
|
1
|
+
# @masterteam/formula-builder
|
|
2
|
+
|
|
3
|
+
A powerful Formula Builder component for Angular 20+ with Tailwind CSS 4.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **Visual Block Editor** - Make.com-inspired formula editing experience
|
|
8
|
+
- ✅ **42+ Built-in Functions** - Math, Logic, Aggregation, Hierarchy, Date, String
|
|
9
|
+
- ✅ **Real-time Validation** - Syntax checking with error highlighting
|
|
10
|
+
- ✅ **Context-aware Autocomplete** - Smart suggestions as you type
|
|
11
|
+
- ✅ **Drag & Drop** - Visual block manipulation with Angular CDK
|
|
12
|
+
- ✅ **Property References** - @PropertyKey, *.PropertyKey, $.Parent.PropertyKey
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @masterteam/formula-builder
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { FormulaBuilder, type FormulaBuilderValue } from '@masterteam/formula-builder';
|
|
24
|
+
import { FormsModule } from '@angular/forms';
|
|
25
|
+
|
|
26
|
+
@Component({
|
|
27
|
+
imports: [FormsModule, FormulaBuilder],
|
|
28
|
+
template: `
|
|
29
|
+
<mt-formula-builder
|
|
30
|
+
[(ngModel)]="formulaState"
|
|
31
|
+
[levelSchemaId]="levelSchemaId"
|
|
32
|
+
(validationChange)="onValidation($event)"
|
|
33
|
+
/>
|
|
34
|
+
`
|
|
35
|
+
})
|
|
36
|
+
export class MyComponent {
|
|
37
|
+
formulaState: FormulaBuilderValue = { expression: '', builder: [] };
|
|
38
|
+
levelSchemaId = 6;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### Inputs
|
|
45
|
+
|
|
46
|
+
| Input | Type | Description |
|
|
47
|
+
|-------|------|-------------|
|
|
48
|
+
| `ngModel` / `formControl` | `FormulaBuilderValue` | Form value `{ expression, builder }` (builder is token JSON array) |
|
|
49
|
+
| `propertiesByPath` | `Record<string, { key: string; name?: string }[]>` | Scoped properties (optional) |
|
|
50
|
+
| `levelSchemaId` | `number` | Level schema ID for validation context |
|
|
51
|
+
| `templateId` | `number` | Template ID for validation context |
|
|
52
|
+
| `placeholder` | `string` | Placeholder text |
|
|
53
|
+
| `hideToolbar` | `boolean` | Hide the top toolbar |
|
|
54
|
+
| `hideStatusBar` | `boolean` | Hide the status bar |
|
|
55
|
+
| `toolbarTabs` | `ToolbarTab[]` | Visible toolbar tabs, e.g. `['functions', 'operators']` |
|
|
56
|
+
| `functionCategories` | `FunctionCategoryGroup[]` | Optional host-owned catalog; overrides API context functions when provided |
|
|
57
|
+
| `operators` | `OperatorDefinition[]` | Operators shown in the toolbar; defaults to the shared formula operator catalog |
|
|
58
|
+
| `codeOnly` | `boolean` | Force code mode and hide the mode toggle |
|
|
59
|
+
| `builderOnly` | `boolean` | Force block builder mode and hide the code-mode toggle |
|
|
60
|
+
| `valueMode` | `'object' \| 'expression'` | Emit `{ expression, builder }` by default, or emit the expression string for legacy string contracts |
|
|
61
|
+
| `isProcessBuilder` | `boolean` | Use Process Builder current-only Formula Engine endpoints |
|
|
62
|
+
|
|
63
|
+
### Builder Mode Display Contract
|
|
64
|
+
|
|
65
|
+
Lookup/status value chips keep the executable literal as the stable backend key and use the block `display` value only for the friendly label. Builder-only hosts can show readable labels without changing the serialized formula expression.
|
|
66
|
+
|
|
67
|
+
### Outputs
|
|
68
|
+
|
|
69
|
+
| Output | Type | Description |
|
|
70
|
+
|--------|------|-------------|
|
|
71
|
+
| `validationChange` | `ValidationResult` | Emits validation results |
|
|
72
|
+
| `tokensChange` | `FormulaToken[]` | Emits when tokens change |
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pnpm build:formula-builder
|
|
78
|
+
```
|
package/assets/i18n/ar.json
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"formulaBuilder": {
|
|
3
|
-
"placeholder": "أدخل الصيغة...",
|
|
4
|
-
"codeMode": "وضع الكود",
|
|
5
|
-
"errors": {
|
|
6
|
-
"validationFailed": "فشل التحقق"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"insert
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"select
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"formulaBuilder": {
|
|
3
|
+
"placeholder": "أدخل الصيغة...",
|
|
4
|
+
"codeMode": "وضع الكود",
|
|
5
|
+
"errors": {
|
|
6
|
+
"validationFailed": "فشل التحقق",
|
|
7
|
+
"required": "الصيغة مطلوبة"
|
|
8
|
+
},
|
|
9
|
+
"actions": {
|
|
10
|
+
"insert": "إدراج",
|
|
11
|
+
"insert-value": "إدراج القيمة",
|
|
12
|
+
"clear": "مسح"
|
|
13
|
+
},
|
|
14
|
+
"properties": {
|
|
15
|
+
"path": "المسار",
|
|
16
|
+
"field": "الحقل",
|
|
17
|
+
"value": "القيمة",
|
|
18
|
+
"no-path-configured": "لا يوجد مسار محدد",
|
|
19
|
+
"direct-access": "وصول مباشر",
|
|
20
|
+
"add-segment": "إضافة جزء",
|
|
21
|
+
"select": "اختر",
|
|
22
|
+
"select-value": "اختر القيمة"
|
|
23
|
+
},
|
|
24
|
+
"operatorNames": {
|
|
25
|
+
"level": "المستوى",
|
|
26
|
+
"current": "الحالي",
|
|
27
|
+
"host": "المضيف",
|
|
28
|
+
"parent": "الأصل",
|
|
29
|
+
"children": "الأبناء",
|
|
30
|
+
"descendants": "المتفرعات",
|
|
31
|
+
"modules": "الوحدات",
|
|
32
|
+
"schedule": "الجدول الزمني",
|
|
33
|
+
"phasegate": "بوابة المرحلة",
|
|
34
|
+
"taskbaseline": "خط الأساس للمهام"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/assets/i18n/en.json
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"formulaBuilder": {
|
|
3
|
-
"placeholder": "Enter formula...",
|
|
4
|
-
"codeMode": "Code mode",
|
|
5
|
-
"errors": {
|
|
6
|
-
"validationFailed": "Validation failed"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"insert
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"select
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"formulaBuilder": {
|
|
3
|
+
"placeholder": "Enter formula...",
|
|
4
|
+
"codeMode": "Code mode",
|
|
5
|
+
"errors": {
|
|
6
|
+
"validationFailed": "Validation failed",
|
|
7
|
+
"required": "Formula is required"
|
|
8
|
+
},
|
|
9
|
+
"actions": {
|
|
10
|
+
"insert": "Insert",
|
|
11
|
+
"insert-value": "Insert value",
|
|
12
|
+
"clear": "Clear"
|
|
13
|
+
},
|
|
14
|
+
"properties": {
|
|
15
|
+
"path": "Path",
|
|
16
|
+
"field": "Field",
|
|
17
|
+
"value": "Value",
|
|
18
|
+
"no-path-configured": "No path configured",
|
|
19
|
+
"direct-access": "Direct Access",
|
|
20
|
+
"add-segment": "Add Segment",
|
|
21
|
+
"select": "Select",
|
|
22
|
+
"select-value": "Select value"
|
|
23
|
+
},
|
|
24
|
+
"operatorNames": {
|
|
25
|
+
"level": "Level",
|
|
26
|
+
"current": "Current",
|
|
27
|
+
"host": "Host",
|
|
28
|
+
"parent": "Parent",
|
|
29
|
+
"children": "Children",
|
|
30
|
+
"descendants": "Descendants",
|
|
31
|
+
"modules": "Modules",
|
|
32
|
+
"schedule": "Schedule",
|
|
33
|
+
"phasegate": "Phase Gate",
|
|
34
|
+
"taskbaseline": "Task Baseline"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|