@molecule/app-rule-builder-angular 0.0.1-stage → 1.1.0

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.
Files changed (2) hide show
  1. package/README.md +719 -4
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,11 +1,726 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-11-21T12:47:11.116Z
7
+ -->
8
+
1
9
  # @molecule/app-rule-builder-angular
2
10
 
3
- Visual condition / rule builder — nested AND / OR groups of field-operator-value leaves, used for feature-flag targeting, automation triggers, segmentation, and IoT scenarios
11
+ Visual condition / rule builder for Angular.
12
+
13
+ Exports:
14
+
15
+ - `<RuleBuilder>` — controlled tree editor for AND / OR groups of
16
+ field-operator-value leaves.
17
+ - `RuleSchema`, `RuleField`, `RuleOperator`, `Rule`, `RuleGroup`,
18
+ `RuleLeaf`, `RuleLeafValue`, `RuleGroupOp`, `RuleFieldType` types.
19
+ - `defaultOperators`, `operatorsFor`, `operatorById`, `OP` operator
20
+ catalog helpers.
21
+ - `emptyGroup`, `emptyLeaf`, `replaceById`, `removeById`,
22
+ `appendToGroup`, `toggleGroupOp`, `makeId` pure tree utilities.
23
+
24
+ Used by feature-flag-manager (audience targeting),
25
+ ai-workflow-automator (trigger conditions), email-marketing
26
+ (segments), iot-device-manager + smart-home-dashboard (scenes /
27
+ automations).
28
+
29
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
30
+ > It is written to be read by coding agents as much as by people, and is generated from this
31
+ > package's source — edit `src/index.ts` JSDoc, not this file.
32
+
33
+ ## Quick Start
34
+
35
+ ```ts
36
+ import { Component } from '@angular/core'
37
+ import {
38
+ emptyGroup,
39
+ RuleBuilder,
40
+ type Rule,
41
+ type RuleSchema,
42
+ } from '@molecule/app-rule-builder-angular'
43
+
44
+ const schema: RuleSchema = {
45
+ fields: [
46
+ {
47
+ name: 'country',
48
+ label: 'Country',
49
+ type: 'select',
50
+ options: [{ value: 'US', label: 'United States' }],
51
+ },
52
+ { name: 'plan', label: 'Plan', type: 'text' },
53
+ { name: 'spend', label: 'Spend', type: 'number' },
54
+ ],
55
+ }
56
+
57
+ @Component({
58
+ selector: 'app-rules',
59
+ standalone: true,
60
+ imports: [RuleBuilder],
61
+ template: `<div mol-rule-builder [schema]="schema" [rules]="rules" [onChange]="changed"></div>`,
62
+ })
63
+ export class Rules {
64
+ readonly schema = schema
65
+ rules: Rule = emptyGroup('AND')
66
+
67
+ changed = (next: Rule): void => {
68
+ this.rules = next
69
+ }
70
+ }
71
+ ```
72
+
73
+ ## Type
74
+
75
+ `feature`
76
+
77
+ ## Installation
78
+
79
+ ```bash
80
+ npm install @molecule/app-rule-builder-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
81
+ ```
82
+
83
+ ## API
84
+
85
+ ### Interfaces
86
+
87
+ #### `RuleOperator`
88
+
89
+ Operator descriptor — `id` is what's stored on the leaf, `label` is
90
+ what's shown in the operator dropdown.
91
+
92
+ `arity` controls how many value inputs are rendered:
93
+
94
+ - `'unary'` — no value input (e.g. `is empty`, `exists`)
95
+ - `'binary'` — one value input (default)
96
+ - `'between'` — two value inputs (rendered as `from`/`to`)
97
+
98
+ ```typescript
99
+ interface RuleOperator {
100
+ /** Operator id stored on the leaf. */
101
+ id: string
102
+ /** Translated, human-readable label. */
103
+ label: string
104
+ /** Number of value inputs to render. Default `'binary'`. */
105
+ arity?: 'unary' | 'binary' | 'between'
106
+ }
107
+ ```
108
+
109
+ #### `RuleField`
110
+
111
+ Field descriptor in the schema — the rule builder uses it to render
112
+ the field dropdown, infer the value editor, and (when no explicit
113
+ `operators` list is given) pick a default operator catalog by `type`.
114
+
115
+ ```typescript
116
+ interface RuleField {
117
+ /** Stable field identifier stored on the leaf. */
118
+ name: string
119
+ /** Translated, human-readable label shown in the field dropdown. */
120
+ label: string
121
+ /** Built-in type used to pick the value editor + default operators. */
122
+ type: RuleFieldType
123
+ /**
124
+ * Operators valid for this field. Optional — when omitted, the
125
+ * builder uses the default catalog for `type` from `defaultOperators`.
126
+ */
127
+ operators?: RuleOperator[]
128
+ /**
129
+ * For `type: 'select'` — the option list rendered as a `<Select>`.
130
+ * Ignored for other types.
131
+ */
132
+ options?: Array<{ value: string; label: string }>
133
+ /** Optional placeholder for text/number/date inputs. */
134
+ placeholder?: string
135
+ }
136
+ ```
137
+
138
+ #### `RuleSchema`
139
+
140
+ Schema given to `<RuleBuilder>`. Currently only `fields` — kept as an
141
+ object so future schema-level config (max depth, group limit, etc.)
142
+ can be added without breaking the API.
143
+
144
+ ```typescript
145
+ interface RuleSchema {
146
+ /** Available fields, in the order they appear in the field dropdown. */
147
+ fields: RuleField[]
148
+ }
149
+ ```
150
+
151
+ #### `RuleLeaf`
152
+
153
+ Leaf rule — a single `field op value` predicate.
154
+
155
+ `value` is opaque to the builder for `text` / `number` / `select` /
156
+ `boolean` (it stores whatever the input produced — string for text /
157
+ select / date, number for number, boolean for boolean). For `between`
158
+ arity operators it's stored as a `[from, to]` two-element tuple.
159
+
160
+ ```typescript
161
+ interface RuleLeaf {
162
+ /** Discriminator. */
163
+ kind: 'leaf'
164
+ /** Stable id (uuid-ish) — used for element identity + delete identity. */
165
+ id: string
166
+ /** Field name from the schema. Empty string when unset. */
167
+ field: string
168
+ /** Operator id from the field's operator catalog. Empty when unset. */
169
+ op: string
170
+ /**
171
+ * Current value. `undefined` when unset. Encoding depends on the
172
+ * operator's `arity`:
173
+ * - `'unary'` — value is ignored.
174
+ * - `'binary'` — string | number | boolean.
175
+ * - `'between'` — `[from, to]` tuple.
176
+ */
177
+ value?: RuleLeafValue
178
+ }
179
+ ```
180
+
181
+ #### `RuleGroup`
182
+
183
+ Group rule — a logical conjunction (AND) or disjunction (OR) of
184
+ children. Children may themselves be groups, allowing arbitrary
185
+ nesting like `(A AND (B OR C) AND D)`.
186
+
187
+ ```typescript
188
+ interface RuleGroup {
189
+ /** Discriminator. */
190
+ kind: 'group'
191
+ /** Stable id. */
192
+ id: string
193
+ /** Logical operator joining the children. */
194
+ op: RuleGroupOp
195
+ /** Child rules — groups or leaves, in display order. */
196
+ children: Rule[]
197
+ }
198
+ ```
199
+
200
+ #### `RuleBuilderProps`
201
+
202
+ Public component props.
203
+
204
+ ```typescript
205
+ interface RuleBuilderProps {
206
+ /** Field catalog the user picks from. */
207
+ schema: RuleSchema
208
+ /** Current rule tree (controlled). */
209
+ rules: Rule
210
+ /**
211
+ * Called whenever the user mutates the tree — receives the full new
212
+ * root rule. Output is a deterministic JSON-serializable structure.
213
+ */
214
+ onChange: (next: Rule) => void
215
+ /** Optional extra root-level class. */
216
+ className?: string
217
+ }
218
+ ```
219
+
220
+ ### Types
221
+
222
+ #### `RuleGroupOp`
223
+
224
+ Logical join operator at a group level.
225
+
226
+ ```typescript
227
+ type RuleGroupOp = 'AND' | 'OR'
228
+ ```
229
+
230
+ #### `RuleFieldType`
231
+
232
+ Built-in field types supported by the default operator catalog and
233
+ value editors. Consumers can supply custom operator lists per field
234
+ if these don't fit.
235
+
236
+ ```typescript
237
+ type RuleFieldType = 'text' | 'number' | 'date' | 'select' | 'boolean'
238
+ ```
239
+
240
+ #### `RuleLeafValue`
241
+
242
+ Possible leaf value encodings. See `RuleLeaf.value`.
243
+
244
+ ```typescript
245
+ type RuleLeafValue = string | number | boolean | [string, string] | [number, number]
246
+ ```
247
+
248
+ #### `Rule`
249
+
250
+ Either a group or a leaf.
251
+
252
+ ```typescript
253
+ type Rule = RuleGroup | RuleLeaf
254
+ ```
255
+
256
+ ### Classes
257
+
258
+ #### `RuleBuilder`
259
+
260
+ Visual rule / predicate builder.
261
+
262
+ The host IS the outer `<div>` React renders (`div[mol-rule-builder]`),
263
+ matching React exactly. The page frame uses ClassMap tokens so the styling
264
+ library can be swapped without touching consumers; a recursive
265
+ `<ng-template>` renders each AND / OR group, so the tree nests to any depth.
266
+
267
+ The component is fully controlled — every interaction emits a new root rule
268
+ through the `onChange` input.
269
+
270
+ ```typescript
271
+ @Component({
272
+ selector: 'div[mol-rule-builder]',
273
+ standalone: true,
274
+ imports: [Button, Input, Select, NgTemplateOutlet],
275
+ inputs: ['schema', 'rules', 'onChange', 'className'],
276
+ host: {
277
+ '[class]': 'classes()',
278
+ 'data-mol-id': 'rule-builder',
279
+ },
280
+ template: `<ng-container
281
+ [ngTemplateOutlet]="groupTpl"
282
+ [ngTemplateOutletContext]="rootContext()"
283
+ ></ng-container>
284
+ <ng-template
285
+ #groupTpl
286
+ let-group
287
+ let-isRoot="isRoot"
288
+ let-onReplace="onReplace"
289
+ let-onRemove="onRemove"
290
+ >
291
+ <div
292
+ [class]="groupClasses()"
293
+ [style]="groupStyle()"
294
+ [attr.data-mol-id]="'rule-builder-group-' + group.id"
295
+ [attr.data-group-op]="group.op"
296
+ >
297
+ <div [class]="rowClasses()">
298
+ <button
299
+ mol-button
300
+ [variant]="'outline'"
301
+ [size]="'sm'"
302
+ (click)="toggle(group, onReplace)"
303
+ [attr.aria-label]="toggleLabel()"
304
+ [attr.data-mol-id]="'rule-builder-group-' + group.id + '-toggle'"
305
+ >
306
+ {{ opLabel(group) }}
307
+ </button>
308
+ <span [class]="helpClasses()">{{ helpText(group) }}</span>
309
+ @if (!isRoot) {
310
+ <button
311
+ mol-button
312
+ [variant]="'ghost'"
313
+ [size]="'sm'"
314
+ (click)="onRemove()"
315
+ [attr.aria-label]="removeGroupLabel()"
316
+ [attr.data-mol-id]="'rule-builder-group-' + group.id + '-remove'"
317
+ >
318
+ {{ removeGroupText() }}
319
+ </button>
320
+ }
321
+ </div>
322
+ <div [class]="childrenClasses()" [style]="childrenStyle()">
323
+ @for (child of group.children; track child.id) {
324
+ @if (isGroup(child)) {
325
+ <ng-container
326
+ [ngTemplateOutlet]="groupTpl"
327
+ [ngTemplateOutletContext]="groupContextOf(group, child, onReplace)"
328
+ ></ng-container>
329
+ } @else {
330
+ <ng-container
331
+ [ngTemplateOutlet]="leafTpl"
332
+ [ngTemplateOutletContext]="leafContextOf(group, child, onReplace)"
333
+ ></ng-container>
334
+ }
335
+ }
336
+ </div>
337
+ <div [class]="rowClasses()">
338
+ <button
339
+ mol-button
340
+ [variant]="'outline'"
341
+ [size]="'sm'"
342
+ (click)="addCondition(group, onReplace)"
343
+ [attr.data-mol-id]="'rule-builder-group-' + group.id + '-add-condition'"
344
+ >
345
+ {{ addConditionText() }}
346
+ </button>
347
+ <button
348
+ mol-button
349
+ [variant]="'ghost'"
350
+ [size]="'sm'"
351
+ (click)="addGroup(group, onReplace)"
352
+ [attr.data-mol-id]="'rule-builder-group-' + group.id + '-add-group'"
353
+ >
354
+ {{ addGroupText() }}
355
+ </button>
356
+ </div>
357
+ </div>
358
+ </ng-template>
359
+ <ng-template #leafTpl let-leaf let-onReplace="onReplace" let-onRemove="onRemove">
360
+ <div [class]="leafClasses()" [attr.data-mol-id]="'rule-builder-leaf-' + leaf.id">
361
+ <div
362
+ mol-select
363
+ [id]="leaf.id + '-field'"
364
+ [value]="leaf.field"
365
+ [options]="fieldOptions()"
366
+ (valueChange)="setField(leaf, onReplace, $event)"
367
+ [attr.aria-label]="fieldLabel()"
368
+ ></div>
369
+ @if (fieldOf(leaf); as field) {
370
+ <div
371
+ mol-select
372
+ [id]="leaf.id + '-op'"
373
+ [value]="leaf.op"
374
+ [options]="operatorOptions(field)"
375
+ (valueChange)="setOp(leaf, onReplace, $event)"
376
+ [attr.aria-label]="operatorLabel()"
377
+ ></div>
378
+ @if (opOf(field, leaf); as op) {
379
+ @if (arityOf(op) === 'between') {
380
+ <ng-container
381
+ [ngTemplateOutlet]="valueTpl"
382
+ [ngTemplateOutletContext]="valueContextOf(leaf, field, 'between', onReplace)"
383
+ ></ng-container>
384
+ } @else if (arityOf(op) === 'binary') {
385
+ <ng-container
386
+ [ngTemplateOutlet]="valueTpl"
387
+ [ngTemplateOutletContext]="valueContextOf(leaf, field, 'binary', onReplace)"
388
+ ></ng-container>
389
+ }
390
+ }
391
+ }
392
+ <button
393
+ mol-button
394
+ [variant]="'ghost'"
395
+ [size]="'sm'"
396
+ (click)="onRemove()"
397
+ [attr.aria-label]="removeConditionLabel()"
398
+ [attr.data-mol-id]="'rule-builder-leaf-' + leaf.id + '-remove'"
399
+ >
400
+ {{ removeConditionText() }}
401
+ </button>
402
+ </div>
403
+ </ng-template>
404
+ <ng-template
405
+ #valueTpl
406
+ let-id="id"
407
+ let-field="field"
408
+ let-arity="arity"
409
+ let-value="value"
410
+ let-onChange="onChange"
411
+ >
412
+ @if (arity === 'between') {
413
+ <span [class]="rowClasses()">
414
+ <div
415
+ mol-input
416
+ [id]="id + '-from'"
417
+ [type]="inputType(field)"
418
+ [value]="fromText(field, value)"
419
+ (change)="setFrom(field, value, onChange, $event)"
420
+ [attr.aria-label]="fromLabel()"
421
+ ></div>
422
+ <span>{{ separatorText() }}</span>
423
+ <div
424
+ mol-input
425
+ [id]="id + '-to'"
426
+ [type]="inputType(field)"
427
+ [value]="toText(field, value)"
428
+ (change)="setTo(field, value, onChange, $event)"
429
+ [attr.aria-label]="toLabel()"
430
+ ></div>
431
+ </span>
432
+ } @else if (field.type === 'select') {
433
+ <div
434
+ mol-select
435
+ [id]="id + '-value'"
436
+ [value]="selectValue(value)"
437
+ [options]="field.options ?? []"
438
+ (valueChange)="onChange($event)"
439
+ [attr.aria-label]="valueLabel()"
440
+ ></div>
441
+ } @else if (field.type === 'boolean') {
442
+ <div
443
+ mol-select
444
+ [id]="id + '-value'"
445
+ [value]="booleanValue(value)"
446
+ [options]="booleanOptions()"
447
+ (valueChange)="setBoolean(onChange, $event)"
448
+ [attr.aria-label]="valueLabel()"
449
+ ></div>
450
+ } @else {
451
+ <div
452
+ mol-input
453
+ [id]="id + '-value'"
454
+ [type]="inputType(field)"
455
+ [value]="valueText(value)"
456
+ [placeholder]="field.placeholder"
457
+ (change)="setRawValue(field, onChange, $event)"
458
+ [attr.aria-label]="valueLabel()"
459
+ ></div>
460
+ }
461
+ </ng-template>`,
462
+ })
463
+ export class RuleBuilder {
464
+ schema: RuleSchema = { fields: [] }
465
+ rules: Rule = { kind: 'leaf', id: '', field: '', op: '' }
466
+ onChange?: (next: Rule) => void
467
+ className?: string
468
+
469
+ private readonly i18n = useTranslation()
470
+
471
+ cm(): UIClassMap {
472
+ return getClassMap()
473
+ }
474
+
475
+ rootGroup(): RuleGroup {
476
+ return this.rules.kind === 'group'
477
+ ? this.rules
478
+ : { kind: 'group', id: 'root', op: 'AND', children: [this.rules] }
479
+ }
480
+
481
+ rootContext(): GroupContext {
482
+ return {
483
+ $implicit: this.rootGroup(),
484
+ isRoot: true,
485
+ onReplace: (next) => this.onChange?.(next),
486
+ onRemove: () => this.onChange?.(emptyGroup()),
487
+ }
488
+ }
489
+
490
+ isGroup(rule: Rule): rule is RuleGroup {
491
+ return rule.kind === 'group'
492
+ }
4
493
 
494
+ childReplace(
495
+ parent: RuleGroup,
496
+ child: Rule,
497
+ onReplace: (next: Rule) => void,
498
+ ): (next: Rule) => void {
499
+ return (next) => onReplace(replaceById(parent, child.id, next))
500
+ }
501
+
502
+ childRemove(parent: RuleGroup, child: Rule, onReplace: (next: Rule) => void): () => void {
503
+ return () => onReplace(removeById(parent, child.id))
504
+ }
505
+
506
+ groupContextOf(
507
+ parent: RuleGroup,
508
+ child: RuleGroup,
509
+ onReplace: (next: Rule) => void,
510
+ ): GroupContext {
511
+ return {
512
+ $implicit: child,
513
+ isRoot: false,
514
+ onReplace: this.childReplace(parent, child, onReplace),
515
+ onRemove: this.childRemove(parent, child, onReplace),
516
+ }
517
+ }
518
+
519
+ leafContextOf(parent: RuleGroup, child: RuleLeaf, onReplace: (next: Rule) => void): LeafContext {
520
+ return {
521
+ $implicit: child,
522
+ onReplace: this.childReplace(parent, child, onReplace),
523
+ onRemove: this.childRemove(parent, child, onReplace),
524
+ }
525
+ }
526
+ // … truncated — 46 more members: valueContextOf, toggle, addCondition, addGroup, fieldOf, opOf, arityOf, setField, setOp, inputType, tupleOf, fromText, toText, setFrom, setTo, selectValue, booleanValue, setBoolean, valueText, setRawValue, fieldOptions, operatorOptions, booleanOptions, classes, groupClasses, groupStyle, childrenClasses, childrenStyle, rowClasses, helpClasses, leafClasses, opLabel, helpText, toggleLabel, removeGroupLabel, removeGroupText, addConditionText, addGroupText, fieldLabel, operatorLabel, valueLabel, fromLabel, toLabel, separatorText, removeConditionLabel, removeConditionText; the full declaration is in node_modules/@molecule/app-rule-builder-angular/dist/rule-builder.component.d.ts
5
527
  ```
6
- npm install @molecule/app-rule-builder-angular
528
+
529
+ _(Member comments are left out to fit; the full declaration is in `node_modules/@molecule/app-rule-builder-angular/dist/rule-builder.component.d.ts`.)_
530
+
531
+ ### Functions
532
+
533
+ #### `operatorsFor(field)`
534
+
535
+ Resolve the operator catalog for `field`. Returns the field's own
536
+ `operators` override when provided, otherwise the built-in catalog
537
+ for the field's `type`.
538
+
539
+ ```typescript
540
+ function operatorsFor(field: RuleField): RuleOperator[]
7
541
  ```
8
542
 
9
- Part of the [Molecule](https://www.molecule.dev) package fleet. This page carries the manifest summary; the full generated documentation ships with the package's first committed version.
543
+ - `field` — Field descriptor from the schema.
544
+
545
+ **Returns:** Operator catalog applicable to this field.
546
+
547
+ #### `operatorById(field, opId)`
548
+
549
+ Look up a single operator descriptor by id within `field`'s catalog.
550
+
551
+ ```typescript
552
+ function operatorById(field: RuleField, opId: string): RuleOperator | undefined
553
+ ```
554
+
555
+ - `field` — Field descriptor.
556
+ - `opId` — Operator id to look up.
557
+
558
+ **Returns:** The operator descriptor, or `undefined` if `opId` isn't in the catalog.
559
+
560
+ #### `makeId()`
561
+
562
+ Generate a short non-cryptographic id. Sufficient for rendered element
563
+ identity and in-memory rule identity within a single editing session.
564
+
565
+ ```typescript
566
+ function makeId(): string
567
+ ```
568
+
569
+ **Returns:** A short random id.
570
+
571
+ #### `emptyLeaf()`
572
+
573
+ Build a fresh empty leaf — used when the user clicks "Add condition".
574
+
575
+ ```typescript
576
+ function emptyLeaf(): RuleLeaf
577
+ ```
578
+
579
+ **Returns:** A new leaf with all fields blank and a fresh id.
580
+
581
+ #### `emptyGroup(op)`
582
+
583
+ Build a fresh empty group — used when the user clicks "Add group".
584
+
585
+ ```typescript
586
+ function emptyGroup(op?: RuleGroupOp): RuleGroup
587
+ ```
588
+
589
+ - `op` — Initial group operator, defaults to `'AND'`.
590
+
591
+ **Returns:** A new group with one empty leaf already inside.
592
+
593
+ #### `replaceById(tree, targetId, replacement)`
594
+
595
+ Replace `target` (matched by id) anywhere in the tree with `replacement`.
596
+
597
+ ```typescript
598
+ function replaceById(tree: Rule, targetId: string, replacement: Rule): Rule
599
+ ```
600
+
601
+ - `tree` — Root of the rule tree.
602
+ - `targetId` — Id of the rule to replace.
603
+ - `replacement` — Replacement rule (same id is not required).
604
+
605
+ **Returns:** New tree with the replacement applied.
606
+
607
+ #### `removeById(tree, targetId)`
608
+
609
+ Remove the rule with id `targetId` from the tree. The root itself
610
+ cannot be removed — when `targetId` matches the root, the tree is
611
+ returned unchanged.
612
+
613
+ ```typescript
614
+ function removeById(tree: Rule, targetId: string): Rule
615
+ ```
616
+
617
+ - `tree` — Root of the rule tree.
618
+ - `targetId` — Id of the rule to remove.
619
+
620
+ **Returns:** New tree with the rule removed (or the original tree if no match).
621
+
622
+ #### `appendToGroup(tree, groupId, child)`
623
+
624
+ Append `child` to the children of the group identified by `groupId`.
625
+ If the id doesn't match any group, returns the tree unchanged.
626
+
627
+ ```typescript
628
+ function appendToGroup(tree: Rule, groupId: string, child: Rule): Rule
629
+ ```
630
+
631
+ - `tree` — Root of the rule tree.
632
+ - `groupId` — Id of the group to append to.
633
+ - `child` — Rule to append.
634
+
635
+ **Returns:** New tree with the child appended.
636
+
637
+ #### `toggleGroupOp(tree, groupId)`
638
+
639
+ Toggle a group's `op` between `'AND'` and `'OR'`.
640
+
641
+ ```typescript
642
+ function toggleGroupOp(tree: Rule, groupId: string): Rule
643
+ ```
644
+
645
+ - `tree` — Root of the rule tree.
646
+ - `groupId` — Id of the group to toggle.
647
+
648
+ **Returns:** New tree with the group's op flipped (or the original tree if no match).
649
+
650
+ ### Constants
651
+
652
+ #### `OP`
653
+
654
+ Operator id constants — exported so consumers can inspect leaves.
655
+
656
+ ```typescript
657
+ const OP: {
658
+ readonly Equals: 'eq'
659
+ readonly NotEquals: 'neq'
660
+ readonly Contains: 'contains'
661
+ readonly NotContains: 'notContains'
662
+ readonly StartsWith: 'startsWith'
663
+ readonly EndsWith: 'endsWith'
664
+ readonly GreaterThan: 'gt'
665
+ readonly GreaterThanOrEqual: 'gte'
666
+ readonly LessThan: 'lt'
667
+ readonly LessThanOrEqual: 'lte'
668
+ readonly Between: 'between'
669
+ readonly Before: 'before'
670
+ readonly After: 'after'
671
+ readonly IsTrue: 'isTrue'
672
+ readonly IsFalse: 'isFalse'
673
+ readonly IsEmpty: 'isEmpty'
674
+ readonly IsNotEmpty: 'isNotEmpty'
675
+ readonly In: 'in'
676
+ readonly NotIn: 'notIn'
677
+ }
678
+ ```
679
+
680
+ #### `defaultOperators`
681
+
682
+ Untranslated operator descriptors per field type.
683
+
684
+ `RuleBuilder` translates each `label` at render time; the strings
685
+ here are English fallbacks only, never shown directly.
686
+
687
+ ```typescript
688
+ const defaultOperators: Record<RuleFieldType, RuleOperator[]>
689
+ ```
690
+
691
+ ## Injection Notes
692
+
693
+ ### Requirements
694
+
695
+ Peer dependencies:
696
+
697
+ - `@angular/common` ^22.0.0
698
+ - `@angular/core` ^22.0.0
699
+ - `@angular/platform-browser` ^22.0.0
700
+ - `@molecule/app-angular` ^3.5.0
701
+ - `@molecule/app-ui` ^1.0.1
702
+ - `@molecule/app-ui-angular` ^1.1.0
703
+
704
+ ### Runtime Dependencies
705
+
706
+ - `@angular/common`
707
+ - `@angular/core`
708
+ - `@angular/platform-browser`
709
+ - `@molecule/app-angular`
710
+ - `@molecule/app-ui`
711
+ - `@molecule/app-ui-angular`
712
+
713
+ - `<RuleBuilder>` needs an i18n provider (`provideMolecule({ i18n })` or the
714
+ bonded `@molecule/app-i18n` provider) and a bonded ClassMap
715
+ (`setClassMap()`); rendering throws otherwise.
716
+ - Output is a plain JSON-serializable `Rule` tree — this package only
717
+ renders and edits it. Evaluation (matching rows/users against the tree)
718
+ is the app's job, typically server-side.
719
+ - Fully controlled: keep the tree in a component field and pass it back via
720
+ `rules`; start with `emptyGroup('AND')`. `onChange` receives the full new
721
+ root rule as an input, an ordinary function.
722
+ - Translations: registered companion bond `@molecule/app-locales-rule-builder`.
723
+
724
+ ## Translations
10
725
 
11
- License: Apache-2.0
726
+ Translation strings are provided by `@molecule/app-locales-rule-builder`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-rule-builder-angular",
3
- "version": "0.0.1-stage",
3
+ "version": "1.1.0",
4
4
  "description": "Visual condition / rule builder — nested AND / OR groups of field-operator-value leaves, used for feature-flag targeting, automation triggers, segmentation, and IoT scenarios",
5
5
  "homepage": "https://www.molecule.dev/packages/app-rule-builder-angular",
6
6
  "type": "module",
@@ -60,12 +60,12 @@
60
60
  "@angular/compiler-cli": "22.2.3",
61
61
  "@angular/core": "22.2.3",
62
62
  "@angular/platform-browser": "22.2.3",
63
- "@molecule/app-angular": "3.7.2",
63
+ "@molecule/app-angular": "3.9.0",
64
64
  "@molecule/app-framework-conformance": "0.0.0",
65
65
  "@molecule/app-i18n": "1.2.2",
66
66
  "@molecule/app-icons": "1.0.4",
67
- "@molecule/app-ui": "1.4.0",
68
- "@molecule/app-ui-angular": "1.2.1",
67
+ "@molecule/app-ui": "1.5.0",
68
+ "@molecule/app-ui-angular": "1.3.1",
69
69
  "@types/node": "26.6.5",
70
70
  "jsdom": "30.1.3",
71
71
  "rxjs": "7.8.2",