ngx-t-forms 3.1.0 → 3.1.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/fesm2022/ngx-t-forms-api-endpoint-config.component-B9tCHtwV.mjs +411 -0
- package/fesm2022/ngx-t-forms-api-endpoint-config.component-B9tCHtwV.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-auto-complete-input-element.component-FhUHTsUF.mjs → ngx-t-forms-auto-complete-input-element.component-D2Vty1Aj.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-auto-complete-input-element.component-FhUHTsUF.mjs.map → ngx-t-forms-auto-complete-input-element.component-D2Vty1Aj.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-basic-input-input-element.component-BJKe9wIA.mjs → ngx-t-forms-basic-input-input-element.component-Dr2bhCnH.mjs} +3 -3
- package/fesm2022/{ngx-t-forms-basic-input-input-element.component-BJKe9wIA.mjs.map → ngx-t-forms-basic-input-input-element.component-Dr2bhCnH.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-calculated-field-rules.component-FQLTI7CX.mjs → ngx-t-forms-calculated-field-rules.component-DLBTjfMj.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-calculated-field-rules.component-FQLTI7CX.mjs.map → ngx-t-forms-calculated-field-rules.component-DLBTjfMj.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-chip-options-creator-editor.component-CJtbprXS.mjs → ngx-t-forms-chip-options-creator-editor.component-Bh6jMmtu.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-chip-options-creator-editor.component-CJtbprXS.mjs.map → ngx-t-forms-chip-options-creator-editor.component-Bh6jMmtu.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-conditional-display-config.component-ayrWl-c2.mjs +513 -0
- package/fesm2022/ngx-t-forms-conditional-display-config.component-ayrWl-c2.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-config-mscoa-additional-inputs.component-CU6R5h-x.mjs → ngx-t-forms-config-mscoa-additional-inputs.component-nOnJfMTo.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-config-mscoa-additional-inputs.component-CU6R5h-x.mjs.map → ngx-t-forms-config-mscoa-additional-inputs.component-nOnJfMTo.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-data-source-picker.component-C8MBbnfz.mjs → ngx-t-forms-data-source-picker.component-mmyhOBvA.mjs} +6 -6
- package/fesm2022/{ngx-t-forms-data-source-picker.component-C8MBbnfz.mjs.map → ngx-t-forms-data-source-picker.component-mmyhOBvA.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-date-picker-input-element.component-Dux6uy66.mjs → ngx-t-forms-date-picker-input-element.component-DmiBra1D.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-date-picker-input-element.component-Dux6uy66.mjs.map → ngx-t-forms-date-picker-input-element.component-DmiBra1D.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-date-range-picker-input-element.component-SMWrTm5X.mjs → ngx-t-forms-date-range-picker-input-element.component-Cke5qSzR.mjs} +11 -2
- package/fesm2022/ngx-t-forms-date-range-picker-input-element.component-Cke5qSzR.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-document-list-label-config-editor.component-uGM93dvc.mjs → ngx-t-forms-document-list-label-config-editor.component-C0xx4jrN.mjs} +3 -3
- package/fesm2022/{ngx-t-forms-document-list-label-config-editor.component-uGM93dvc.mjs.map → ngx-t-forms-document-list-label-config-editor.component-C0xx4jrN.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-document-picker.component-DIqaaBSl.mjs → ngx-t-forms-document-picker.component-DI7wtEv6.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-document-picker.component-DIqaaBSl.mjs.map → ngx-t-forms-document-picker.component-DI7wtEv6.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-editor-js-input.component-C1dI_7rU.mjs → ngx-t-forms-editor-input-element.component-DbogKrdk.mjs} +46 -191
- package/fesm2022/ngx-t-forms-editor-input-element.component-DbogKrdk.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-file-upload-input-element.component-CQsKz87N.mjs → ngx-t-forms-file-upload-input-element.component-DbwvZghJ.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-file-upload-input-element.component-CQsKz87N.mjs.map → ngx-t-forms-file-upload-input-element.component-DbwvZghJ.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-form-input-selector.component-Dj0jvBdm.mjs → ngx-t-forms-form-input-selector.component-CkuzNdjx.mjs} +2 -3
- package/fesm2022/{ngx-t-forms-form-input-selector.component-Dj0jvBdm.mjs.map → ngx-t-forms-form-input-selector.component-CkuzNdjx.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-form-json-view.component-DzJKFl4c.mjs → ngx-t-forms-form-json-view.component-DBCpa_rZ.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-form-json-view.component-DzJKFl4c.mjs.map → ngx-t-forms-form-json-view.component-DBCpa_rZ.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-form-section-stepper.component-DOvVtJGB.mjs → ngx-t-forms-form-section-stepper.component-jLj6vePZ.mjs} +4 -4
- package/fesm2022/{ngx-t-forms-form-section-stepper.component-DOvVtJGB.mjs.map → ngx-t-forms-form-section-stepper.component-jLj6vePZ.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-forms-builder-menu.component-CcqyQLf5.mjs → ngx-t-forms-forms-builder-menu.component-Iyd0grju.mjs} +4 -4
- package/fesm2022/{ngx-t-forms-forms-builder-menu.component-CcqyQLf5.mjs.map → ngx-t-forms-forms-builder-menu.component-Iyd0grju.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-geo-location.component-Bj_qIEqi.mjs → ngx-t-forms-geo-location.component-BUXRaPy0.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-geo-location.component-Bj_qIEqi.mjs.map → ngx-t-forms-geo-location.component-BUXRaPy0.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-header-template-editor.component-BLmAqiQA.mjs +158 -0
- package/fesm2022/ngx-t-forms-header-template-editor.component-BLmAqiQA.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-image-capture-input-element.component-lwp3IcDt.mjs → ngx-t-forms-image-capture-input-element.component-D6Ffuhbv.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-image-capture-input-element.component-lwp3IcDt.mjs.map → ngx-t-forms-image-capture-input-element.component-D6Ffuhbv.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-index-CKj1Oacc.mjs +2 -0
- package/fesm2022/ngx-t-forms-index-CKj1Oacc.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-input-custom.component-DiciFhSS.mjs → ngx-t-forms-input-custom.component-BMui37o-.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-input-custom.component-DiciFhSS.mjs.map → ngx-t-forms-input-custom.component-BMui37o-.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-input-editor.component-D12hrHOc.mjs → ngx-t-forms-input-editor.component-D60TpWzO.mjs} +3 -4
- package/fesm2022/{ngx-t-forms-input-editor.component-D12hrHOc.mjs.map → ngx-t-forms-input-editor.component-D60TpWzO.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-map-mat-options-keys-C2JpMTEc.mjs → ngx-t-forms-map-mat-options-keys-yfxnNDPs.mjs} +2 -3
- package/fesm2022/ngx-t-forms-map-mat-options-keys-yfxnNDPs.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-mat-chip-list-editor.component-C1Qrze7K.mjs → ngx-t-forms-mat-chip-list-editor.component-cfBBan80.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-mat-chip-list-editor.component-C1Qrze7K.mjs.map → ngx-t-forms-mat-chip-list-editor.component-cfBBan80.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-missing-form-configs.component-BaTR_jzc.mjs → ngx-t-forms-missing-form-configs.component-BcYuduah.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-missing-form-configs.component-BaTR_jzc.mjs.map → ngx-t-forms-missing-form-configs.component-BcYuduah.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-mscoa-chart-toolbar.component-Dni_bv_G.mjs → ngx-t-forms-mscoa-chart-toolbar.component-nLawxM9j.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-mscoa-chart-toolbar.component-Dni_bv_G.mjs.map → ngx-t-forms-mscoa-chart-toolbar.component-nLawxM9j.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-mscoa-config.component-B9G_WlEc.mjs +594 -0
- package/fesm2022/ngx-t-forms-mscoa-config.component-B9G_WlEc.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-mscoa-segment-config.component-BPQuzR5k.mjs → ngx-t-forms-mscoa-segment-config.component-DKEEZ8MD.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-mscoa-segment-config.component-BPQuzR5k.mjs.map → ngx-t-forms-mscoa-segment-config.component-DKEEZ8MD.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-multiple-input-input-element.component-hXWMRFjl.mjs → ngx-t-forms-multiple-input-input-element.component-B99ANTUL.mjs} +34 -30
- package/fesm2022/ngx-t-forms-multiple-input-input-element.component-B99ANTUL.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-ngx-t-forms-tQEbZK_e.mjs → ngx-t-forms-ngx-t-forms-9BfJdjl4.mjs} +2281 -759
- package/fesm2022/ngx-t-forms-ngx-t-forms-9BfJdjl4.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-paginated-selection-table-pYY2sWAb.mjs → ngx-t-forms-paginated-selection-table-Bm5-5VWe.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-paginated-selection-table-pYY2sWAb.mjs.map → ngx-t-forms-paginated-selection-table-Bm5-5VWe.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-payload-template-editor.component-DGCUsTYx.mjs → ngx-t-forms-payload-template-editor.component-2hwGuKAB.mjs} +11 -6
- package/fesm2022/ngx-t-forms-payload-template-editor.component-2hwGuKAB.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-pipeline-generator.component-D2stBXXC.mjs → ngx-t-forms-pipeline-generator.component-BvjT2zfL.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-pipeline-generator.component-D2stBXXC.mjs.map → ngx-t-forms-pipeline-generator.component-BvjT2zfL.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-quill-input.component-BsuOKfZT.mjs +731 -0
- package/fesm2022/ngx-t-forms-quill-input.component-BsuOKfZT.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-record-list-manager.component-CtCOIpai.mjs → ngx-t-forms-record-list-manager.component-BK5nwwDp.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-record-list-manager.component-CtCOIpai.mjs.map → ngx-t-forms-record-list-manager.component-BK5nwwDp.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-required-inputs.component-D9wIdOhg.mjs → ngx-t-forms-required-inputs.component-DiwMttVf.mjs} +2 -3
- package/fesm2022/{ngx-t-forms-required-inputs.component-D9wIdOhg.mjs.map → ngx-t-forms-required-inputs.component-DiwMttVf.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-rest-api-call-setup.component-Gy7Rtmue.mjs → ngx-t-forms-rest-api-call-setup.component-CBgG_f06.mjs} +249 -25
- package/fesm2022/ngx-t-forms-rest-api-call-setup.component-CBgG_f06.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-section-report.component-U9uQ_Ow9.mjs → ngx-t-forms-section-report.component-CyPpFiWS.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-section-report.component-U9uQ_Ow9.mjs.map → ngx-t-forms-section-report.component-CyPpFiWS.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-select-input-element.component-CxYTmuvV.mjs → ngx-t-forms-select-input-element.component-B2wr5_88.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-select-input-element.component-CxYTmuvV.mjs.map → ngx-t-forms-select-input-element.component-B2wr5_88.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-selection-options-editor.component-BLLejOLG.mjs → ngx-t-forms-selection-options-editor.component-BEZLG1Z8.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-selection-options-editor.component-BLLejOLG.mjs.map → ngx-t-forms-selection-options-editor.component-BEZLG1Z8.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-textarea-input-element.component-75VdPc6z.mjs → ngx-t-forms-textarea-input-element.component-Cmbd0krg.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-textarea-input-element.component-75VdPc6z.mjs.map → ngx-t-forms-textarea-input-element.component-Cmbd0krg.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-toggle-input-element.component-DQGvEJN-.mjs → ngx-t-forms-toggle-input-element.component-Dd_FcAoD.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-toggle-input-element.component-DQGvEJN-.mjs.map → ngx-t-forms-toggle-input-element.component-Dd_FcAoD.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-token-binding-menu.component-CLpjkUnf.mjs +109 -0
- package/fesm2022/ngx-t-forms-token-binding-menu.component-CLpjkUnf.mjs.map +1 -0
- package/fesm2022/ngx-t-forms-token-text-input.component-DY04Z0fn.mjs +296 -0
- package/fesm2022/ngx-t-forms-token-text-input.component-DY04Z0fn.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-validators-config.component-EM7RSWIz.mjs → ngx-t-forms-validators-config.component-Btmz2cKH.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-validators-config.component-EM7RSWIz.mjs.map → ngx-t-forms-validators-config.component-Btmz2cKH.mjs.map} +1 -1
- package/fesm2022/ngx-t-forms-workflow-adjudication.component-CT6sN9E4.mjs +2096 -0
- package/fesm2022/ngx-t-forms-workflow-adjudication.component-CT6sN9E4.mjs.map +1 -0
- package/fesm2022/ngx-t-forms.mjs +1 -1
- package/package.json +2 -2
- package/styles/_tokens.scss +6 -0
- package/types/ngx-t-forms.d.ts +155 -4
- package/fesm2022/ngx-t-forms-date-range-picker-input-element.component-SMWrTm5X.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-editor-input-element.component-CIELjDty.mjs +0 -417
- package/fesm2022/ngx-t-forms-editor-input-element.component-CIELjDty.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-editor-js-input.component-C1dI_7rU.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-getInputIcon-B4ADgevZ.mjs +0 -31
- package/fesm2022/ngx-t-forms-getInputIcon-B4ADgevZ.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-header-template-editor.component-DLldVmcN.mjs +0 -129
- package/fesm2022/ngx-t-forms-header-template-editor.component-DLldVmcN.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-index-C8NtLE16.mjs +0 -2
- package/fesm2022/ngx-t-forms-index-C8NtLE16.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-map-mat-options-keys-C2JpMTEc.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-multiple-input-input-element.component-hXWMRFjl.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-ngx-t-forms-tQEbZK_e.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-payload-template-editor.component-DGCUsTYx.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-rest-api-call-setup.component-Gy7Rtmue.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-token-transform-D_wsFbNc.mjs +0 -173
- package/fesm2022/ngx-t-forms-token-transform-D_wsFbNc.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-workflow-adjudication.component-C1Em-g9e.mjs +0 -1303
- package/fesm2022/ngx-t-forms-workflow-adjudication.component-C1Em-g9e.mjs.map +0 -1
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, output, inject, ElementRef, signal, computed, Input, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { v4 } from 'uuid';
|
|
4
|
+
import { CalculationFunctions, InputDataTypes, InputTypes } from 'ngx-t-forms-types';
|
|
5
|
+
import { CommonModule } from '@angular/common';
|
|
6
|
+
import { NgControl } from '@angular/forms';
|
|
7
|
+
import { MatFormFieldControl } from '@angular/material/form-field';
|
|
8
|
+
import * as i3 from '@angular/material/icon';
|
|
9
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
10
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
11
|
+
import * as i3$1 from '@angular/material/button-toggle';
|
|
12
|
+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
|
13
|
+
import { MatCardModule } from '@angular/material/card';
|
|
14
|
+
import * as i5 from '@angular/material/tooltip';
|
|
15
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
16
|
+
import { Subject } from 'rxjs';
|
|
17
|
+
import { P as PREDICATE_OPERATORS, r as referencedTokens, h as evaluatePredicate, p as parseConditions, i as emptyCondition, s as serializeConditions, j as deriveObservedInputs } from './ngx-t-forms-ngx-t-forms-9BfJdjl4.mjs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal editor implementing `MatFormFieldControl<ConditionalInputRule[]>` for
|
|
21
|
+
* authoring a form input's **conditional display** rule.
|
|
22
|
+
*
|
|
23
|
+
* ### Relationship to `validators-config`
|
|
24
|
+
*
|
|
25
|
+
* This is `validators-config` minus `message` and `canOverride`, and minus the
|
|
26
|
+
* multi-rule chip list. It reuses that editor's condition model verbatim —
|
|
27
|
+
* `parseConditions` / `serializeConditions` / `emptyCondition` /
|
|
28
|
+
* `deriveObservedInputs` / `PREDICATE_OPERATORS` — so an author who has written
|
|
29
|
+
* a validator already knows how to write a display rule, and the engine reads
|
|
30
|
+
* both through the same `readDep` dependency model.
|
|
31
|
+
*
|
|
32
|
+
* The one thing that differs is **polarity**, and the copy in the template leans
|
|
33
|
+
* on it hard because getting it backwards is the obvious authoring mistake:
|
|
34
|
+
*
|
|
35
|
+
* | | Expression `true` means |
|
|
36
|
+
* |---|---|
|
|
37
|
+
* | a validator | the entry is **invalid** |
|
|
38
|
+
* | a display rule | the field is **shown** |
|
|
39
|
+
*
|
|
40
|
+
* ### Why exactly one rule
|
|
41
|
+
*
|
|
42
|
+
* `conditionalInputConfig` is an array, and the engine combines multiple rules
|
|
43
|
+
* with AND. This editor deliberately authors a **single** rule: the guided
|
|
44
|
+
* builder already composes many conditions with All/Any inside one expression,
|
|
45
|
+
* so a second rule would add a second, less visible combination layer that means
|
|
46
|
+
* something subtly different. Keeping it to one makes the AND-across-rules
|
|
47
|
+
* semantics unreachable through the UI — it exists only for hand-authored
|
|
48
|
+
* configuration.
|
|
49
|
+
*
|
|
50
|
+
* ### Committing
|
|
51
|
+
*
|
|
52
|
+
* Unlike the validator editor there is no draft/Save cycle: with one rule and no
|
|
53
|
+
* message to compose, every change commits immediately. A half-built condition
|
|
54
|
+
* serialises to an empty expression, which the engine treats as *no rule* — so
|
|
55
|
+
* an incomplete edit leaves the field visible rather than making it vanish
|
|
56
|
+
* mid-authoring.
|
|
57
|
+
*
|
|
58
|
+
* NOTE: `MatFormFieldControl<T>` mandates plain mutable `value` / `disabled` /
|
|
59
|
+
* `required` / `placeholder` / `id` members, `@Input()` decorators, the
|
|
60
|
+
* `focused` / `touched` / `stateChanges` members, and the `useExisting`
|
|
61
|
+
* provider. These are framework wiring, not defects — the CLAUDE.md bans on
|
|
62
|
+
* `@Input()` / `useExisting` do not apply to MatFormFieldControl integration.
|
|
63
|
+
*/
|
|
64
|
+
class ConditionalDisplayConfigComponent {
|
|
65
|
+
constructor() {
|
|
66
|
+
/** Emits whenever a piece of `MatFormFieldControl` state changes. */
|
|
67
|
+
this.stateChanges = new Subject();
|
|
68
|
+
this.controlType = 'lib-conditional-display-config';
|
|
69
|
+
this.id = `lib-conditional-display-config-${ConditionalDisplayConfigComponent.nextId++}`;
|
|
70
|
+
this.placeholder = '';
|
|
71
|
+
this.focused = false;
|
|
72
|
+
this.touched = false;
|
|
73
|
+
this.required = false;
|
|
74
|
+
this.describedBy = '';
|
|
75
|
+
this.autofilled = undefined;
|
|
76
|
+
this.userAriaDescribedBy = undefined;
|
|
77
|
+
this.disableAutomaticLabeling = undefined;
|
|
78
|
+
/** Whether the editor is inert. Kept as `@Input()` for the MFC contract. */
|
|
79
|
+
this.disabled = false;
|
|
80
|
+
/** Current rule list. Kept as `@Input()` for the MFC contract. */
|
|
81
|
+
this.value = [];
|
|
82
|
+
/** Validation errors surfaced by the parent for error-state derivation. */
|
|
83
|
+
this.errors = [];
|
|
84
|
+
/** The input that owns this rule (for multiple-input scopes + self-labelling). */
|
|
85
|
+
this.mapToData = input(undefined, ...(ngDevMode ? [{ debugName: "mapToData" }] : /* istanbul ignore next */ []));
|
|
86
|
+
/** Available form inputs offered as variables. */
|
|
87
|
+
this.formInputs = input([], ...(ngDevMode ? [{ debugName: "formInputs" }] : /* istanbul ignore next */ []));
|
|
88
|
+
/** Emits the full rule list whenever it changes. */
|
|
89
|
+
this.valueChanged = output();
|
|
90
|
+
/** Operator choices shared with the validator + array-access builders. */
|
|
91
|
+
this.operators = PREDICATE_OPERATORS;
|
|
92
|
+
/** Aggregate choices for a list field, with non-technical labels. */
|
|
93
|
+
this.aggregates = [
|
|
94
|
+
{ value: CalculationFunctions.Sum, label: 'total' },
|
|
95
|
+
{ value: CalculationFunctions.Avg, label: 'average' },
|
|
96
|
+
{ value: CalculationFunctions.Min, label: 'lowest' },
|
|
97
|
+
{ value: CalculationFunctions.Max, label: 'highest' },
|
|
98
|
+
{ value: CalculationFunctions.Count, label: 'count' },
|
|
99
|
+
];
|
|
100
|
+
this.#elementRef = inject(ElementRef);
|
|
101
|
+
this.ngControl = inject(NgControl, { self: true, optional: true });
|
|
102
|
+
/** Guided builder model mirroring the current expression. */
|
|
103
|
+
this.#group = signal({ connector: '&&', conditions: [] }, ...(ngDevMode ? [{ debugName: "#group" }] : /* istanbul ignore next */ []));
|
|
104
|
+
this.group = this.#group.asReadonly();
|
|
105
|
+
/** Whether the rule is being edited as a raw expression instead of guided rows. */
|
|
106
|
+
this.#raw = signal(false, ...(ngDevMode ? [{ debugName: "#raw" }] : /* istanbul ignore next */ []));
|
|
107
|
+
this.raw = this.#raw.asReadonly();
|
|
108
|
+
/** The live expression text. Mirrors `value[0].expression`. */
|
|
109
|
+
this.#expression = signal('', ...(ngDevMode ? [{ debugName: "#expression" }] : /* istanbul ignore next */ []));
|
|
110
|
+
this.expression = this.#expression.asReadonly();
|
|
111
|
+
/** Chosen aggregate per referenced list variable (keyed by variable name). */
|
|
112
|
+
this.#functions = signal({}, ...(ngDevMode ? [{ debugName: "#functions" }] : /* istanbul ignore next */ []));
|
|
113
|
+
/**
|
|
114
|
+
* Fields the builder can reference: every primary input plus every
|
|
115
|
+
* multiple-input column. `inputId` resolves to the composite id for a sub-row
|
|
116
|
+
* field, which is exactly the key the engine's visibility map uses — the same
|
|
117
|
+
* resolution the validator editor already relies on.
|
|
118
|
+
*/
|
|
119
|
+
this.fieldOptions = computed(() => {
|
|
120
|
+
const self = this.mapToData();
|
|
121
|
+
const selfId = self?.id;
|
|
122
|
+
const options = [];
|
|
123
|
+
for (const input of this.formInputs()) {
|
|
124
|
+
if (!input.formControlName)
|
|
125
|
+
continue;
|
|
126
|
+
const group = input.multipleInputInEditId;
|
|
127
|
+
options.push({
|
|
128
|
+
variable: input.formControlName,
|
|
129
|
+
label: input.label || input.formControlName,
|
|
130
|
+
isSelf: input.id === selfId,
|
|
131
|
+
isMultiple: !!group,
|
|
132
|
+
numeric: this.#isNumeric(input),
|
|
133
|
+
inputId: group ? input.id : (input.originalId ?? input.id),
|
|
134
|
+
parentInputId: group,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return options;
|
|
138
|
+
}, ...(ngDevMode ? [{ debugName: "fieldOptions" }] : /* istanbul ignore next */ []));
|
|
139
|
+
/**
|
|
140
|
+
* Primary (scalar) fields, minus this input itself.
|
|
141
|
+
*
|
|
142
|
+
* A display rule that references its own field can never fire: the engine's
|
|
143
|
+
* self-edge guard resolves the owning input to `undefined` BEFORE the
|
|
144
|
+
* visibility gate (it has to, or evaluating `vis(X)` would recurse into
|
|
145
|
+
* `vis(X)`). Offering it would let an author build a rule that silently never
|
|
146
|
+
* matches, so it is not offered.
|
|
147
|
+
*/
|
|
148
|
+
this.directFields = computed(() => this.fieldOptions().filter((f) => !f.isMultiple && !f.isSelf), ...(ngDevMode ? [{ debugName: "directFields" }] : /* istanbul ignore next */ []));
|
|
149
|
+
/** Multiple-input columns, for the second dropdown group. */
|
|
150
|
+
this.listFields = computed(() => this.fieldOptions().filter((f) => f.isMultiple && !f.isSelf), ...(ngDevMode ? [{ debugName: "listFields" }] : /* istanbul ignore next */ []));
|
|
151
|
+
/** Field option keyed by its expression variable, for operand lookups. */
|
|
152
|
+
this.#fieldByVariable = computed(() => new Map(this.fieldOptions().map((f) => [f.variable, f])), ...(ngDevMode ? [{ debugName: "#fieldByVariable" }] : /* istanbul ignore next */ []));
|
|
153
|
+
/** Multiple-input columns actually referenced by the current expression. */
|
|
154
|
+
this.referencedListFields = computed(() => {
|
|
155
|
+
const tokens = referencedTokens(this.#expression());
|
|
156
|
+
return this.listFields().filter((f) => tokens.has(f.variable));
|
|
157
|
+
}, ...(ngDevMode ? [{ debugName: "referencedListFields" }] : /* istanbul ignore next */ []));
|
|
158
|
+
/**
|
|
159
|
+
* Multiple-input variables that MUST be aggregated: a list column compared
|
|
160
|
+
* against a non-list operand has to be reduced to a single value. In raw mode
|
|
161
|
+
* operand pairing cannot be analysed, so every referenced list column counts.
|
|
162
|
+
*/
|
|
163
|
+
this.requiredAggregateVariables = computed(() => {
|
|
164
|
+
if (this.#raw()) {
|
|
165
|
+
return new Set(this.referencedListFields().map((f) => f.variable));
|
|
166
|
+
}
|
|
167
|
+
const byVariable = this.#fieldByVariable();
|
|
168
|
+
const required = new Set();
|
|
169
|
+
for (const cond of this.#group().conditions) {
|
|
170
|
+
const left = byVariable.get(cond.field);
|
|
171
|
+
const right = cond.compareTo === 'field' ? byVariable.get(cond.value) : undefined;
|
|
172
|
+
const leftMultiple = !!left?.isMultiple;
|
|
173
|
+
const rightMultiple = !!right?.isMultiple;
|
|
174
|
+
if (leftMultiple && !rightMultiple)
|
|
175
|
+
required.add(cond.field);
|
|
176
|
+
if (rightMultiple && !leftMultiple && right)
|
|
177
|
+
required.add(right.variable);
|
|
178
|
+
}
|
|
179
|
+
return required;
|
|
180
|
+
}, ...(ngDevMode ? [{ debugName: "requiredAggregateVariables" }] : /* istanbul ignore next */ []));
|
|
181
|
+
/** Human-readable syntax error for the raw editor, or `null` when valid/empty. */
|
|
182
|
+
this.syntaxError = computed(() => {
|
|
183
|
+
const expression = this.#expression();
|
|
184
|
+
if (expression.trim() === '')
|
|
185
|
+
return null;
|
|
186
|
+
try {
|
|
187
|
+
evaluatePredicate(expression, {});
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
return error instanceof Error ? error.message : 'The expression syntax is invalid.';
|
|
192
|
+
}
|
|
193
|
+
}, ...(ngDevMode ? [{ debugName: "syntaxError" }] : /* istanbul ignore next */ []));
|
|
194
|
+
/** Whether the current expression can be edited in the guided builder. */
|
|
195
|
+
this.canUseGuided = computed(() => parseConditions(this.#expression(), this.#fieldNameSet()) !== null, ...(ngDevMode ? [{ debugName: "canUseGuided" }] : /* istanbul ignore next */ []));
|
|
196
|
+
/** Whether a rule is in force right now. */
|
|
197
|
+
this.hasRule = computed(() => this.#expression().trim() !== '', ...(ngDevMode ? [{ debugName: "hasRule" }] : /* istanbul ignore next */ []));
|
|
198
|
+
/**
|
|
199
|
+
* Whether the guided builder currently holds a condition that will be DROPPED
|
|
200
|
+
* on serialisation — no field chosen, or a field-vs-field comparison with no
|
|
201
|
+
* right-hand field. The template surfaces this as a one-line pending hint,
|
|
202
|
+
* because the alternative is a silently inert rule: the author adds a row,
|
|
203
|
+
* assumes the field is now conditional, and nothing tells them it is not.
|
|
204
|
+
*
|
|
205
|
+
* A typed value of `''` is NOT incomplete — `x === ""` is the legitimate
|
|
206
|
+
* "while the field is empty" rule.
|
|
207
|
+
*/
|
|
208
|
+
this.hasIncompleteCondition = computed(() => {
|
|
209
|
+
if (this.#raw())
|
|
210
|
+
return false;
|
|
211
|
+
return this.#group().conditions.some((cond) => cond.field.trim() === '' ||
|
|
212
|
+
(cond.compareTo === 'field' && cond.value.trim() === ''));
|
|
213
|
+
}, ...(ngDevMode ? [{ debugName: "hasIncompleteCondition" }] : /* istanbul ignore next */ []));
|
|
214
|
+
this.onTouched = () => { };
|
|
215
|
+
}
|
|
216
|
+
static { this.nextId = 0; }
|
|
217
|
+
#elementRef;
|
|
218
|
+
/** Guided builder model mirroring the current expression. */
|
|
219
|
+
#group;
|
|
220
|
+
/** Whether the rule is being edited as a raw expression instead of guided rows. */
|
|
221
|
+
#raw;
|
|
222
|
+
/** The live expression text. Mirrors `value[0].expression`. */
|
|
223
|
+
#expression;
|
|
224
|
+
/** Chosen aggregate per referenced list variable (keyed by variable name). */
|
|
225
|
+
#functions;
|
|
226
|
+
/**
|
|
227
|
+
* The list this editor last emitted. Used to tell an incoming `value` binding
|
|
228
|
+
* that is genuinely new (a different input opened for editing) from the echo
|
|
229
|
+
* of our own commit — re-seeding on the echo would rebuild the guided model
|
|
230
|
+
* from the serialised text on every keystroke and fight the user's edit.
|
|
231
|
+
*/
|
|
232
|
+
#lastCommitted;
|
|
233
|
+
/** Field option keyed by its expression variable, for operand lookups. */
|
|
234
|
+
#fieldByVariable;
|
|
235
|
+
/** Aggregates offered for a field: numeric columns get all, others only count. */
|
|
236
|
+
aggregatesFor(field) {
|
|
237
|
+
return field.numeric
|
|
238
|
+
? this.aggregates
|
|
239
|
+
: this.aggregates.filter((a) => a.value === CalculationFunctions.Count);
|
|
240
|
+
}
|
|
241
|
+
/** Whether a referenced list column is required to have an aggregate. */
|
|
242
|
+
isAggregateRequired(variable) {
|
|
243
|
+
return this.requiredAggregateVariables().has(variable);
|
|
244
|
+
}
|
|
245
|
+
// MatFormFieldControl reads these as plain getters during its own change
|
|
246
|
+
// detection, so they stay getters rather than `computed()` signals.
|
|
247
|
+
get empty() {
|
|
248
|
+
return !this.#currentRule();
|
|
249
|
+
}
|
|
250
|
+
get shouldLabelFloat() {
|
|
251
|
+
return this.focused || !this.empty;
|
|
252
|
+
}
|
|
253
|
+
get errorState() {
|
|
254
|
+
const ngControlError = this.ngControl?.errors != null;
|
|
255
|
+
const externalError = (this.errors?.length ?? 0) > 0 && this.touched;
|
|
256
|
+
return ngControlError || externalError;
|
|
257
|
+
}
|
|
258
|
+
setDescribedByIds(ids) {
|
|
259
|
+
this.describedBy = ids.join(' ');
|
|
260
|
+
const el = this.#elementRef.nativeElement;
|
|
261
|
+
const controlElement = el.querySelector('.lib-conditional-display-config__body');
|
|
262
|
+
controlElement?.setAttribute('aria-describedby', this.describedBy);
|
|
263
|
+
this.stateChanges.next();
|
|
264
|
+
}
|
|
265
|
+
onContainerClick() {
|
|
266
|
+
this.markAsTouched();
|
|
267
|
+
this.stateChanges.next();
|
|
268
|
+
}
|
|
269
|
+
markAsTouched() {
|
|
270
|
+
if (!this.touched) {
|
|
271
|
+
this.touched = true;
|
|
272
|
+
this.onTouched();
|
|
273
|
+
this.stateChanges.next();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** Tear down the MFC state stream so subscribers do not leak. */
|
|
277
|
+
ngOnDestroy() {
|
|
278
|
+
this.stateChanges.complete();
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Seeds the guided builder from the bound `value`.
|
|
282
|
+
*
|
|
283
|
+
* Runs in `ngOnChanges`, not from the template and not from a `value` setter,
|
|
284
|
+
* for two reasons:
|
|
285
|
+
*
|
|
286
|
+
* - **Signal writes.** Seeding writes `#group` / `#raw` / `#expression`.
|
|
287
|
+
* Doing that from a template getter throws NG0600 (writing to signals while
|
|
288
|
+
* Angular renders).
|
|
289
|
+
* - **Binding order.** The host template binds `[value]` *before*
|
|
290
|
+
* `[formInputs]`, and parsing an expression into guided rows needs the field
|
|
291
|
+
* list to recognise its variable names. A `value` setter would parse against
|
|
292
|
+
* an empty field set and drop every rule into Advanced mode. `ngOnChanges`
|
|
293
|
+
* runs after the whole binding pass, so both are present.
|
|
294
|
+
*/
|
|
295
|
+
ngOnChanges(changes) {
|
|
296
|
+
if (!changes['value'])
|
|
297
|
+
return;
|
|
298
|
+
if (this.value === this.#lastCommitted)
|
|
299
|
+
return; // our own echo
|
|
300
|
+
this.#seed();
|
|
301
|
+
}
|
|
302
|
+
#seed() {
|
|
303
|
+
const rule = this.#currentRule();
|
|
304
|
+
const expression = rule?.expression ?? '';
|
|
305
|
+
this.#expression.set(expression);
|
|
306
|
+
this.#functions.set(this.#functionsFromRule(rule));
|
|
307
|
+
const parsed = parseConditions(expression, this.#fieldNameSet());
|
|
308
|
+
if (parsed) {
|
|
309
|
+
this.#group.set(parsed);
|
|
310
|
+
this.#raw.set(false);
|
|
311
|
+
}
|
|
312
|
+
else if (expression.trim() !== '') {
|
|
313
|
+
// An expression the guided builder cannot represent (grouping, mixed
|
|
314
|
+
// connectors, negation) opens in Advanced and round-trips unchanged.
|
|
315
|
+
this.#raw.set(true);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this.#group.set({ connector: '&&', conditions: [] });
|
|
319
|
+
this.#raw.set(false);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
// ---- guided condition builder ------------------------------------------
|
|
323
|
+
/** Switch the All/Any connector joining the conditions. */
|
|
324
|
+
setConnector(connector) {
|
|
325
|
+
this.#applyGroup({ ...this.#group(), connector });
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Append a fresh, **field-less** condition.
|
|
329
|
+
*
|
|
330
|
+
* The validator editor defaults the field to the input being validated, which
|
|
331
|
+
* is nearly always what its author wants. Here the owning field is explicitly
|
|
332
|
+
* excluded (a rule cannot observe itself), so any default would be an
|
|
333
|
+
* arbitrary pick — and it would not be inert. `serializeConditions` treats a
|
|
334
|
+
* typed value of `''` as complete, because `x === ""` is a legitimate "is
|
|
335
|
+
* empty" rule, so a pre-filled field would turn a single click on "Add
|
|
336
|
+
* condition" into a live rule that starts hiding the field. Leaving the field
|
|
337
|
+
* unset serialises to nothing, so the rule only exists once the author has
|
|
338
|
+
* actually said what it is about.
|
|
339
|
+
*/
|
|
340
|
+
addCondition() {
|
|
341
|
+
const group = this.#group();
|
|
342
|
+
this.#applyGroup({
|
|
343
|
+
...group,
|
|
344
|
+
conditions: [...group.conditions, emptyCondition('')],
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/** Apply a partial change to the condition at `index`. */
|
|
348
|
+
updateCondition(index, patch) {
|
|
349
|
+
const group = this.#group();
|
|
350
|
+
const conditions = group.conditions.map((c, i) => (i === index ? { ...c, ...patch } : c));
|
|
351
|
+
this.#applyGroup({ ...group, conditions });
|
|
352
|
+
}
|
|
353
|
+
/** Flip a condition between comparing to a typed value and another field. */
|
|
354
|
+
toggleCompareTo(index) {
|
|
355
|
+
const condition = this.#group().conditions[index];
|
|
356
|
+
if (!condition)
|
|
357
|
+
return;
|
|
358
|
+
if (condition.compareTo === 'value') {
|
|
359
|
+
const field = this.fieldOptions().find((f) => f.variable !== condition.field && !f.isSelf);
|
|
360
|
+
this.updateCondition(index, { compareTo: 'field', value: field?.variable ?? '' });
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
this.updateCondition(index, { compareTo: 'value', value: '' });
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/** Remove the condition at `index`. */
|
|
367
|
+
removeCondition(index) {
|
|
368
|
+
const group = this.#group();
|
|
369
|
+
this.#applyGroup({ ...group, conditions: group.conditions.filter((_, i) => i !== index) });
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Choose (or clear, by re-clicking) the aggregate that reduces a referenced
|
|
373
|
+
* list field to a single value.
|
|
374
|
+
*/
|
|
375
|
+
setFunction(variable, fn) {
|
|
376
|
+
this.#functions.update((current) => {
|
|
377
|
+
const next = { ...current };
|
|
378
|
+
if (next[variable] === fn) {
|
|
379
|
+
delete next[variable];
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
next[variable] = fn;
|
|
383
|
+
}
|
|
384
|
+
return next;
|
|
385
|
+
});
|
|
386
|
+
// The expression text is unchanged, but the observed deps now carry the
|
|
387
|
+
// aggregate — re-commit so inputsObservedForChanges reflects the choice.
|
|
388
|
+
this.#commitExpression(this.#expression());
|
|
389
|
+
}
|
|
390
|
+
/** The aggregate currently chosen for a list variable, if any. */
|
|
391
|
+
currentFunction(variable) {
|
|
392
|
+
return this.#functions()[variable];
|
|
393
|
+
}
|
|
394
|
+
/** Replace the raw expression as the user types. */
|
|
395
|
+
onExpressionInput(event) {
|
|
396
|
+
this.#commitExpression(event.target.value);
|
|
397
|
+
}
|
|
398
|
+
/** Switch to the raw expression editor. */
|
|
399
|
+
useRaw() {
|
|
400
|
+
this.#raw.set(true);
|
|
401
|
+
}
|
|
402
|
+
/** Switch back to the guided builder, reparsing the current expression. */
|
|
403
|
+
useGuided() {
|
|
404
|
+
const parsed = parseConditions(this.#expression(), this.#fieldNameSet());
|
|
405
|
+
if (!parsed)
|
|
406
|
+
return;
|
|
407
|
+
this.#group.set(parsed);
|
|
408
|
+
this.#raw.set(false);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Remove the rule entirely — the field becomes unconditionally visible again.
|
|
412
|
+
*
|
|
413
|
+
* Commits an empty array rather than a rule with a blank expression, so the
|
|
414
|
+
* engine builds no visibility signal at all for this input and the form pays
|
|
415
|
+
* nothing for a rule that no longer exists.
|
|
416
|
+
*/
|
|
417
|
+
clearRule() {
|
|
418
|
+
this.#group.set({ connector: '&&', conditions: [] });
|
|
419
|
+
this.#functions.set({});
|
|
420
|
+
this.#expression.set('');
|
|
421
|
+
this.#raw.set(false);
|
|
422
|
+
this.#commit([]);
|
|
423
|
+
}
|
|
424
|
+
/** Read the value-event target as a string. */
|
|
425
|
+
inputValue(event) {
|
|
426
|
+
return event.target.value;
|
|
427
|
+
}
|
|
428
|
+
// ---- internal ----------------------------------------------------------
|
|
429
|
+
/** The single rule this editor owns, if one is bound. */
|
|
430
|
+
#currentRule() {
|
|
431
|
+
return this.value?.[0];
|
|
432
|
+
}
|
|
433
|
+
/** Set of field variable names the builder recognises (for parsing). */
|
|
434
|
+
#fieldNameSet() {
|
|
435
|
+
return new Set(this.fieldOptions().map((f) => f.variable));
|
|
436
|
+
}
|
|
437
|
+
/** Whether an input carries a numeric data type. */
|
|
438
|
+
#isNumeric(input) {
|
|
439
|
+
return input.dataType === InputDataTypes.Number || input.type === InputTypes.Number;
|
|
440
|
+
}
|
|
441
|
+
/** Recover the per-variable aggregate choices from a rule's observed inputs. */
|
|
442
|
+
#functionsFromRule(rule) {
|
|
443
|
+
const map = {};
|
|
444
|
+
for (const observed of rule?.inputsObservedForChanges ?? []) {
|
|
445
|
+
if (observed.function)
|
|
446
|
+
map[observed.variable] = observed.function;
|
|
447
|
+
}
|
|
448
|
+
return map;
|
|
449
|
+
}
|
|
450
|
+
/** Store a builder change: update the model, then serialise + commit. */
|
|
451
|
+
#applyGroup(next) {
|
|
452
|
+
this.#group.set(next);
|
|
453
|
+
this.#commitExpression(serializeConditions(next));
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Write an expression onto the rule, re-deriving its observed-input deps.
|
|
457
|
+
*
|
|
458
|
+
* An expression that serialises to nothing means the author has not finished —
|
|
459
|
+
* commit an empty list so the engine treats the input as unconditional. A
|
|
460
|
+
* half-built rule must never hide the field it is being written on.
|
|
461
|
+
*/
|
|
462
|
+
#commitExpression(expression) {
|
|
463
|
+
this.#expression.set(expression);
|
|
464
|
+
if (expression.trim() === '') {
|
|
465
|
+
this.#commit([]);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const fields = this.fieldOptions();
|
|
469
|
+
const existing = this.#currentRule();
|
|
470
|
+
const rule = {
|
|
471
|
+
// Preserve every legacy descriptive field an older form may carry; the
|
|
472
|
+
// engine ignores them, but an external consumer still renders them.
|
|
473
|
+
...existing,
|
|
474
|
+
id: existing?.id ?? v4(),
|
|
475
|
+
expression,
|
|
476
|
+
inputsObservedForChanges: deriveObservedInputs(expression, fields, this.#functions()),
|
|
477
|
+
};
|
|
478
|
+
this.#commit([rule]);
|
|
479
|
+
}
|
|
480
|
+
/** Single mutation path: store the new list and notify the parent. */
|
|
481
|
+
#commit(next) {
|
|
482
|
+
this.#lastCommitted = next;
|
|
483
|
+
this.value = next;
|
|
484
|
+
this.markAsTouched();
|
|
485
|
+
this.stateChanges.next();
|
|
486
|
+
this.valueChanged.emit([...next]);
|
|
487
|
+
}
|
|
488
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: ConditionalDisplayConfigComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
489
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.12", type: ConditionalDisplayConfigComponent, isStandalone: true, selector: "lib-conditional-display-config", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: false, isRequired: false, transformFunction: null }, errors: { classPropertyName: "errors", publicName: "errors", isSignal: false, isRequired: false, transformFunction: null }, mapToData: { classPropertyName: "mapToData", publicName: "mapToData", isSignal: true, isRequired: false, transformFunction: null }, formInputs: { classPropertyName: "formInputs", publicName: "formInputs", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChanged: "valueChanged" }, host: { properties: { "attr.id": "id" }, classAttribute: "lib-conditional-display-config" }, providers: [{ provide: MatFormFieldControl, useExisting: ConditionalDisplayConfigComponent }], usesOnChanges: true, ngImport: i0, template: "<section class=\"lib-conditional-display-config__body\">\n @if (!hasRule()) {\n <p class=\"lib-conditional-display-config__hint\">\n Appears only while a condition you define is true. Leave empty to always show.\n </p>\n }\n\n <div class=\"lib-conditional-display-config__condition-head\">\n <span class=\"lib-conditional-display-config__f-label\">Show this field when</span>\n @if (!raw() && group().conditions.length > 1) {\n <mat-button-toggle-group\n class=\"lib-conditional-display-config__seg\"\n [value]=\"group().connector\"\n hideSingleSelectionIndicator\n (change)=\"setConnector($event.value)\"\n aria-label=\"Combine conditions\"\n >\n <mat-button-toggle value=\"&&\">All</mat-button-toggle>\n <mat-button-toggle value=\"||\">Any</mat-button-toggle>\n </mat-button-toggle-group>\n }\n </div>\n\n @if (raw()) {\n <textarea\n class=\"lib-conditional-display-config__control lib-conditional-display-config__textarea lib-conditional-display-config__mono\"\n rows=\"2\"\n [value]=\"expression()\"\n [disabled]=\"disabled\"\n (input)=\"onExpressionInput($event)\"\n aria-label=\"Visibility expression\"\n placeholder='e.g. contactMethod === \"phone\"'\n ></textarea>\n @if (syntaxError(); as error) {\n <p class=\"lib-conditional-display-config__error\">\n <mat-icon class=\"lib-conditional-display-config__error-icon\">error_outline</mat-icon>\n <span>{{ error }}</span>\n </p>\n } @else {\n <p class=\"lib-conditional-display-config__sub-hint\">\n True = shown. Use field names with <code>===</code>, <code>></code>, <code>includes</code> \u2026\n </p>\n }\n } @else {\n\n @if (fieldOptions().length === 0) {\n <p class=\"lib-conditional-display-config__sub-hint\">\n No other fields available yet \u2014 switch to Advanced to type an expression.\n </p>\n }\n\n @for (cond of group().conditions; track $index; let first = $first) {\n @if (!first) {\n <span class=\"lib-conditional-display-config__connector\" aria-hidden=\"true\">\n {{ group().connector === '&&' ? 'and' : 'or' }}\n </span>\n }\n <div class=\"lib-conditional-display-config__cond\">\n <label class=\"lib-conditional-display-config__field\">\n <span class=\"lib-conditional-display-config__f-label\">Field</span>\n <select\n class=\"lib-conditional-display-config__control\"\n [class.lib-conditional-display-config__control--invalid]=\"!cond.field\"\n [disabled]=\"disabled\"\n (change)=\"updateCondition($index, { field: inputValue($event) })\"\n >\n <option value=\"\" disabled [selected]=\"!cond.field\">Choose\u2026</option>\n @if (directFields().length) {\n <optgroup label=\"Fields\">\n @for (f of directFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.field\">{{ f.label }}</option>\n }\n </optgroup>\n }\n @if (listFields().length) {\n <optgroup label=\"List fields\">\n @for (f of listFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.field\">{{ f.label }}</option>\n }\n </optgroup>\n }\n </select>\n </label>\n\n <label class=\"lib-conditional-display-config__field\">\n <span class=\"lib-conditional-display-config__f-label\">Condition</span>\n <select\n class=\"lib-conditional-display-config__control\"\n [disabled]=\"disabled\"\n (change)=\"updateCondition($index, { operator: inputValue($event) })\"\n >\n @for (op of operators; track op.value) {\n <option [value]=\"op.value\" [selected]=\"op.value === cond.operator\">{{ op.label }}</option>\n }\n </select>\n </label>\n\n <div class=\"lib-conditional-display-config__field lib-conditional-display-config__field--value\">\n <span class=\"lib-conditional-display-config__f-label\">\n {{ cond.compareTo === 'field' ? 'Other field' : 'Value' }}\n </span>\n <div class=\"lib-conditional-display-config__value\">\n @if (cond.compareTo === 'field') {\n <select\n class=\"lib-conditional-display-config__control\"\n [class.lib-conditional-display-config__control--invalid]=\"!cond.value\"\n [disabled]=\"disabled\"\n (change)=\"updateCondition($index, { value: inputValue($event) })\"\n >\n <option value=\"\" disabled [selected]=\"!cond.value\">Choose\u2026</option>\n @if (directFields().length) {\n <optgroup label=\"Fields\">\n @for (f of directFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.value\">{{ f.label }}</option>\n }\n </optgroup>\n }\n @if (listFields().length) {\n <optgroup label=\"List fields\">\n @for (f of listFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.value\">{{ f.label }}</option>\n }\n </optgroup>\n }\n </select>\n } @else {\n <input\n class=\"lib-conditional-display-config__control\"\n [value]=\"cond.value\"\n [disabled]=\"disabled\"\n (input)=\"updateCondition($index, { value: inputValue($event) })\"\n placeholder=\"leave empty for \u201Cis empty\u201D\"\n />\n }\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__icon-btn\"\n [disabled]=\"disabled\"\n (click)=\"toggleCompareTo($index)\"\n [attr.aria-label]=\"\n cond.compareTo === 'field' ? 'Compare to a typed value' : 'Compare to another field'\n \"\n [matTooltip]=\"\n cond.compareTo === 'field' ? 'Compare to a typed value' : 'Compare to another field'\n \"\n >\n <mat-icon>{{ cond.compareTo === 'field' ? 'edit' : 'link' }}</mat-icon>\n </button>\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__icon-btn\"\n [disabled]=\"disabled\"\n (click)=\"removeCondition($index)\"\n matTooltip=\"Remove condition\"\n aria-label=\"Remove condition\"\n >\n <mat-icon>close</mat-icon>\n </button>\n </div>\n </div>\n </div>\n }\n\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__link\"\n [disabled]=\"disabled\"\n (click)=\"addCondition()\"\n >\n <mat-icon>add</mat-icon> Add condition\n </button>\n }\n\n @if (hasIncompleteCondition()) {\n <p class=\"lib-conditional-display-config__sub-hint lib-conditional-display-config__sub-hint--pending\">\n <mat-icon class=\"lib-conditional-display-config__pending-icon\">pending</mat-icon>\n <span>Unfinished conditions are ignored \u2014 pick a field to activate the rule.</span>\n </p>\n }\n\n @if (referencedListFields().length) {\n <div class=\"lib-conditional-display-config__lists\">\n <span class=\"lib-conditional-display-config__f-label\">Combine each list</span>\n @for (f of referencedListFields(); track f.variable) {\n <div\n class=\"lib-conditional-display-config__list-row\"\n [class.lib-conditional-display-config__list-row--unset]=\"\n isAggregateRequired(f.variable) && !currentFunction(f.variable)\n \"\n >\n <span class=\"lib-conditional-display-config__list-name\">{{ f.label }}</span>\n <div class=\"lib-conditional-display-config__agg\" role=\"group\" [attr.aria-label]=\"'Combine ' + f.label\">\n @for (agg of aggregatesFor(f); track agg.value) {\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__agg-chip\"\n [class.lib-conditional-display-config__agg-chip--on]=\"currentFunction(f.variable) === agg.value\"\n [disabled]=\"disabled\"\n (click)=\"setFunction(f.variable, agg.value)\"\n >\n {{ agg.label }}\n </button>\n }\n </div>\n </div>\n }\n </div>\n }\n\n @if (hasRule()) {\n <p class=\"lib-conditional-display-config__summary\">\n While hidden, this field is removed from the form \u2014 nothing is submitted and\n its validation cannot block.\n </p>\n\n @if (!raw()) {\n <details class=\"lib-conditional-display-config__preview\">\n <summary class=\"lib-conditional-display-config__preview-summary\">Expression</summary>\n <code>{{ expression() }}</code>\n </details>\n }\n }\n\n <div class=\"lib-conditional-display-config__foot\">\n @if (raw()) {\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__link\"\n [disabled]=\"!canUseGuided()\"\n [matTooltip]=\"canUseGuided() ? '' : 'This expression is too advanced for the guided builder'\"\n (click)=\"useGuided()\"\n >\n <mat-icon>view_module</mat-icon> Guided\n </button>\n } @else {\n <button type=\"button\" class=\"lib-conditional-display-config__link\" (click)=\"useRaw()\">\n <mat-icon>code</mat-icon> Advanced\n </button>\n }\n\n @if (hasRule()) {\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__link lib-conditional-display-config__link--danger\"\n [disabled]=\"disabled\"\n matTooltip=\"Remove the rule \u2014 the field becomes always visible\"\n (click)=\"clearRule()\"\n >\n <mat-icon>visibility</mat-icon> Always show\n </button>\n }\n </div>\n</section>\n", styles: ["@charset \"UTF-8\";:host{display:block}.lib-conditional-display-config__body{display:flex;flex-direction:column;gap:.625rem;padding:.25rem 0 .125rem;min-width:0}.lib-conditional-display-config__hint,.lib-conditional-display-config__sub-hint{margin:0;font-size:.75rem;line-height:1.45;color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__sub-hint code{font-size:.6875rem;padding:0 .25rem;border-radius:var(--lib-forms-radius-sm, 4px);background:var(--lib-forms-surface-container)}.lib-conditional-display-config__sub-hint--pending{display:flex;align-items:center;gap:.375rem;color:var(--sem-warning, var(--lib-forms-on-surface-variant))}.lib-conditional-display-config__pending-icon{flex:none;font-size:.875rem;width:.875rem;height:.875rem}.lib-conditional-display-config__summary{margin:0;font-size:.6875rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__condition-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;min-height:1.5rem}.lib-conditional-display-config__f-label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__seg{--mat-standard-button-toggle-height: 1.625rem;font-size:.6875rem}.lib-conditional-display-config__cond{display:grid;grid-template-columns:repeat(auto-fit,minmax(8.5rem,1fr));gap:.5rem .625rem;min-width:0}.lib-conditional-display-config__field{display:flex;flex-direction:column;gap:.1875rem;min-width:0}.lib-conditional-display-config__connector{align-self:flex-start;font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-primary);padding:.125rem 0}.lib-conditional-display-config__control{width:100%;min-width:0;box-sizing:border-box;padding:.375rem .5rem;font:inherit;font-size:.8125rem;color:var(--lib-forms-on-surface);background:var(--lib-forms-surface-container-low);border:1px solid var(--lib-forms-outline-variant);border-radius:var(--lib-forms-radius-sm, 6px);transition:border-color .3s cubic-bezier(.16,1,.3,1),background-color .3s cubic-bezier(.16,1,.3,1)}select.lib-conditional-display-config__control{appearance:auto}.lib-conditional-display-config__control:hover:not(:disabled){border-color:var(--lib-forms-outline)}.lib-conditional-display-config__control:focus{outline:none;border-color:var(--lib-forms-primary)}.lib-conditional-display-config__control:disabled{opacity:.55}.lib-conditional-display-config__control--invalid:not(:focus){border-color:var(--sem-warning, var(--lib-forms-outline))}.lib-conditional-display-config__textarea{resize:vertical;min-height:3.25rem}.lib-conditional-display-config__mono{font-family:var(--lib-forms-font-mono, ui-monospace, monospace);font-size:.75rem}.lib-conditional-display-config__value{display:flex;align-items:center;gap:.25rem;min-width:0}.lib-conditional-display-config__value>.lib-conditional-display-config__control{flex:1 1 auto}.lib-conditional-display-config__icon-btn{flex:none;display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;border:none;border-radius:var(--lib-forms-radius-sm, 6px);background:transparent;color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:background-color .3s cubic-bezier(.16,1,.3,1),color .3s cubic-bezier(.16,1,.3,1)}.lib-conditional-display-config__icon-btn:hover:not(:disabled){background:var(--lib-forms-surface-container);color:var(--lib-forms-on-surface)}.lib-conditional-display-config__icon-btn:disabled{opacity:.45;cursor:default}.lib-conditional-display-config__icon-btn mat-icon{font-size:1rem;width:1rem;height:1rem}.lib-conditional-display-config__link{display:inline-flex;align-items:center;gap:.25rem;align-self:flex-start;padding:.25rem .375rem;border:none;border-radius:var(--lib-forms-radius-sm, 6px);background:transparent;font:inherit;font-size:.75rem;font-weight:500;color:var(--lib-forms-primary);cursor:pointer;transition:background-color .3s cubic-bezier(.16,1,.3,1)}.lib-conditional-display-config__link:hover:not(:disabled){background:var(--lib-forms-surface-container)}.lib-conditional-display-config__link:disabled{opacity:.45;cursor:default}.lib-conditional-display-config__link mat-icon{font-size:.9375rem;width:.9375rem;height:.9375rem}.lib-conditional-display-config__link--danger{color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__foot{display:flex;align-items:center;justify-content:space-between;gap:.5rem}.lib-conditional-display-config__error{display:flex;align-items:flex-start;gap:.375rem;margin:0;font-size:.75rem;line-height:1.45;color:var(--sem-error, var(--lib-forms-on-surface))}.lib-conditional-display-config__error-icon{flex:none;font-size:.9375rem;width:.9375rem;height:.9375rem}.lib-conditional-display-config__lists{display:flex;flex-direction:column;gap:.375rem}.lib-conditional-display-config__list-row{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.25rem .5rem}.lib-conditional-display-config__list-name{font-size:.75rem;color:var(--lib-forms-on-surface)}.lib-conditional-display-config__list-row--unset .lib-conditional-display-config__list-name:after{content:\"\\2014 choose one\";margin-left:.375rem;font-size:.6875rem;color:var(--sem-warning, var(--lib-forms-on-surface-variant))}.lib-conditional-display-config__agg{display:flex;flex-wrap:wrap;gap:.25rem}.lib-conditional-display-config__agg-chip{padding:.1875rem .5rem;border:1px solid var(--lib-forms-outline-variant);border-radius:999px;background:transparent;font:inherit;font-size:.6875rem;color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:background-color .3s cubic-bezier(.16,1,.3,1),color .3s cubic-bezier(.16,1,.3,1),border-color .3s cubic-bezier(.16,1,.3,1)}.lib-conditional-display-config__agg-chip:hover:not(:disabled){border-color:var(--lib-forms-outline)}.lib-conditional-display-config__agg-chip--on{background:var(--lib-forms-primary);border-color:var(--lib-forms-primary);color:var(--lib-forms-on-primary)}.lib-conditional-display-config__preview{min-width:0}.lib-conditional-display-config__preview-summary{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant);cursor:pointer;-webkit-user-select:none;user-select:none}.lib-conditional-display-config__preview code{display:block;margin-top:.25rem;padding:.375rem .5rem;overflow-x:auto;font-family:var(--lib-forms-font-mono, ui-monospace, monospace);font-size:.6875rem;color:var(--lib-forms-on-surface);background:var(--lib-forms-surface-container-low);border-radius:var(--lib-forms-radius-sm, 6px)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: MatButtonToggleModule }, { kind: "directive", type: i3$1.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled", "disabledInteractive", "hideSingleSelectionIndicator", "hideMultipleSelectionIndicator"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { kind: "component", type: i3$1.MatButtonToggle, selector: "mat-button-toggle", inputs: ["aria-label", "aria-labelledby", "id", "name", "value", "tabIndex", "disableRipple", "appearance", "checked", "disabled", "disabledInteractive"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { kind: "ngmodule", type: MatCardModule }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i5.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
490
|
+
}
|
|
491
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: ConditionalDisplayConfigComponent, decorators: [{
|
|
492
|
+
type: Component,
|
|
493
|
+
args: [{ selector: 'lib-conditional-display-config', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [
|
|
494
|
+
CommonModule,
|
|
495
|
+
MatIconModule,
|
|
496
|
+
MatButtonModule,
|
|
497
|
+
MatButtonToggleModule,
|
|
498
|
+
MatCardModule,
|
|
499
|
+
MatTooltipModule,
|
|
500
|
+
], providers: [{ provide: MatFormFieldControl, useExisting: ConditionalDisplayConfigComponent }], host: {
|
|
501
|
+
'class': 'lib-conditional-display-config',
|
|
502
|
+
'[attr.id]': 'id',
|
|
503
|
+
}, template: "<section class=\"lib-conditional-display-config__body\">\n @if (!hasRule()) {\n <p class=\"lib-conditional-display-config__hint\">\n Appears only while a condition you define is true. Leave empty to always show.\n </p>\n }\n\n <div class=\"lib-conditional-display-config__condition-head\">\n <span class=\"lib-conditional-display-config__f-label\">Show this field when</span>\n @if (!raw() && group().conditions.length > 1) {\n <mat-button-toggle-group\n class=\"lib-conditional-display-config__seg\"\n [value]=\"group().connector\"\n hideSingleSelectionIndicator\n (change)=\"setConnector($event.value)\"\n aria-label=\"Combine conditions\"\n >\n <mat-button-toggle value=\"&&\">All</mat-button-toggle>\n <mat-button-toggle value=\"||\">Any</mat-button-toggle>\n </mat-button-toggle-group>\n }\n </div>\n\n @if (raw()) {\n <textarea\n class=\"lib-conditional-display-config__control lib-conditional-display-config__textarea lib-conditional-display-config__mono\"\n rows=\"2\"\n [value]=\"expression()\"\n [disabled]=\"disabled\"\n (input)=\"onExpressionInput($event)\"\n aria-label=\"Visibility expression\"\n placeholder='e.g. contactMethod === \"phone\"'\n ></textarea>\n @if (syntaxError(); as error) {\n <p class=\"lib-conditional-display-config__error\">\n <mat-icon class=\"lib-conditional-display-config__error-icon\">error_outline</mat-icon>\n <span>{{ error }}</span>\n </p>\n } @else {\n <p class=\"lib-conditional-display-config__sub-hint\">\n True = shown. Use field names with <code>===</code>, <code>></code>, <code>includes</code> \u2026\n </p>\n }\n } @else {\n\n @if (fieldOptions().length === 0) {\n <p class=\"lib-conditional-display-config__sub-hint\">\n No other fields available yet \u2014 switch to Advanced to type an expression.\n </p>\n }\n\n @for (cond of group().conditions; track $index; let first = $first) {\n @if (!first) {\n <span class=\"lib-conditional-display-config__connector\" aria-hidden=\"true\">\n {{ group().connector === '&&' ? 'and' : 'or' }}\n </span>\n }\n <div class=\"lib-conditional-display-config__cond\">\n <label class=\"lib-conditional-display-config__field\">\n <span class=\"lib-conditional-display-config__f-label\">Field</span>\n <select\n class=\"lib-conditional-display-config__control\"\n [class.lib-conditional-display-config__control--invalid]=\"!cond.field\"\n [disabled]=\"disabled\"\n (change)=\"updateCondition($index, { field: inputValue($event) })\"\n >\n <option value=\"\" disabled [selected]=\"!cond.field\">Choose\u2026</option>\n @if (directFields().length) {\n <optgroup label=\"Fields\">\n @for (f of directFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.field\">{{ f.label }}</option>\n }\n </optgroup>\n }\n @if (listFields().length) {\n <optgroup label=\"List fields\">\n @for (f of listFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.field\">{{ f.label }}</option>\n }\n </optgroup>\n }\n </select>\n </label>\n\n <label class=\"lib-conditional-display-config__field\">\n <span class=\"lib-conditional-display-config__f-label\">Condition</span>\n <select\n class=\"lib-conditional-display-config__control\"\n [disabled]=\"disabled\"\n (change)=\"updateCondition($index, { operator: inputValue($event) })\"\n >\n @for (op of operators; track op.value) {\n <option [value]=\"op.value\" [selected]=\"op.value === cond.operator\">{{ op.label }}</option>\n }\n </select>\n </label>\n\n <div class=\"lib-conditional-display-config__field lib-conditional-display-config__field--value\">\n <span class=\"lib-conditional-display-config__f-label\">\n {{ cond.compareTo === 'field' ? 'Other field' : 'Value' }}\n </span>\n <div class=\"lib-conditional-display-config__value\">\n @if (cond.compareTo === 'field') {\n <select\n class=\"lib-conditional-display-config__control\"\n [class.lib-conditional-display-config__control--invalid]=\"!cond.value\"\n [disabled]=\"disabled\"\n (change)=\"updateCondition($index, { value: inputValue($event) })\"\n >\n <option value=\"\" disabled [selected]=\"!cond.value\">Choose\u2026</option>\n @if (directFields().length) {\n <optgroup label=\"Fields\">\n @for (f of directFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.value\">{{ f.label }}</option>\n }\n </optgroup>\n }\n @if (listFields().length) {\n <optgroup label=\"List fields\">\n @for (f of listFields(); track f.variable) {\n <option [value]=\"f.variable\" [selected]=\"f.variable === cond.value\">{{ f.label }}</option>\n }\n </optgroup>\n }\n </select>\n } @else {\n <input\n class=\"lib-conditional-display-config__control\"\n [value]=\"cond.value\"\n [disabled]=\"disabled\"\n (input)=\"updateCondition($index, { value: inputValue($event) })\"\n placeholder=\"leave empty for \u201Cis empty\u201D\"\n />\n }\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__icon-btn\"\n [disabled]=\"disabled\"\n (click)=\"toggleCompareTo($index)\"\n [attr.aria-label]=\"\n cond.compareTo === 'field' ? 'Compare to a typed value' : 'Compare to another field'\n \"\n [matTooltip]=\"\n cond.compareTo === 'field' ? 'Compare to a typed value' : 'Compare to another field'\n \"\n >\n <mat-icon>{{ cond.compareTo === 'field' ? 'edit' : 'link' }}</mat-icon>\n </button>\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__icon-btn\"\n [disabled]=\"disabled\"\n (click)=\"removeCondition($index)\"\n matTooltip=\"Remove condition\"\n aria-label=\"Remove condition\"\n >\n <mat-icon>close</mat-icon>\n </button>\n </div>\n </div>\n </div>\n }\n\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__link\"\n [disabled]=\"disabled\"\n (click)=\"addCondition()\"\n >\n <mat-icon>add</mat-icon> Add condition\n </button>\n }\n\n @if (hasIncompleteCondition()) {\n <p class=\"lib-conditional-display-config__sub-hint lib-conditional-display-config__sub-hint--pending\">\n <mat-icon class=\"lib-conditional-display-config__pending-icon\">pending</mat-icon>\n <span>Unfinished conditions are ignored \u2014 pick a field to activate the rule.</span>\n </p>\n }\n\n @if (referencedListFields().length) {\n <div class=\"lib-conditional-display-config__lists\">\n <span class=\"lib-conditional-display-config__f-label\">Combine each list</span>\n @for (f of referencedListFields(); track f.variable) {\n <div\n class=\"lib-conditional-display-config__list-row\"\n [class.lib-conditional-display-config__list-row--unset]=\"\n isAggregateRequired(f.variable) && !currentFunction(f.variable)\n \"\n >\n <span class=\"lib-conditional-display-config__list-name\">{{ f.label }}</span>\n <div class=\"lib-conditional-display-config__agg\" role=\"group\" [attr.aria-label]=\"'Combine ' + f.label\">\n @for (agg of aggregatesFor(f); track agg.value) {\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__agg-chip\"\n [class.lib-conditional-display-config__agg-chip--on]=\"currentFunction(f.variable) === agg.value\"\n [disabled]=\"disabled\"\n (click)=\"setFunction(f.variable, agg.value)\"\n >\n {{ agg.label }}\n </button>\n }\n </div>\n </div>\n }\n </div>\n }\n\n @if (hasRule()) {\n <p class=\"lib-conditional-display-config__summary\">\n While hidden, this field is removed from the form \u2014 nothing is submitted and\n its validation cannot block.\n </p>\n\n @if (!raw()) {\n <details class=\"lib-conditional-display-config__preview\">\n <summary class=\"lib-conditional-display-config__preview-summary\">Expression</summary>\n <code>{{ expression() }}</code>\n </details>\n }\n }\n\n <div class=\"lib-conditional-display-config__foot\">\n @if (raw()) {\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__link\"\n [disabled]=\"!canUseGuided()\"\n [matTooltip]=\"canUseGuided() ? '' : 'This expression is too advanced for the guided builder'\"\n (click)=\"useGuided()\"\n >\n <mat-icon>view_module</mat-icon> Guided\n </button>\n } @else {\n <button type=\"button\" class=\"lib-conditional-display-config__link\" (click)=\"useRaw()\">\n <mat-icon>code</mat-icon> Advanced\n </button>\n }\n\n @if (hasRule()) {\n <button\n type=\"button\"\n class=\"lib-conditional-display-config__link lib-conditional-display-config__link--danger\"\n [disabled]=\"disabled\"\n matTooltip=\"Remove the rule \u2014 the field becomes always visible\"\n (click)=\"clearRule()\"\n >\n <mat-icon>visibility</mat-icon> Always show\n </button>\n }\n </div>\n</section>\n", styles: ["@charset \"UTF-8\";:host{display:block}.lib-conditional-display-config__body{display:flex;flex-direction:column;gap:.625rem;padding:.25rem 0 .125rem;min-width:0}.lib-conditional-display-config__hint,.lib-conditional-display-config__sub-hint{margin:0;font-size:.75rem;line-height:1.45;color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__sub-hint code{font-size:.6875rem;padding:0 .25rem;border-radius:var(--lib-forms-radius-sm, 4px);background:var(--lib-forms-surface-container)}.lib-conditional-display-config__sub-hint--pending{display:flex;align-items:center;gap:.375rem;color:var(--sem-warning, var(--lib-forms-on-surface-variant))}.lib-conditional-display-config__pending-icon{flex:none;font-size:.875rem;width:.875rem;height:.875rem}.lib-conditional-display-config__summary{margin:0;font-size:.6875rem;line-height:1.5;color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__condition-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;min-height:1.5rem}.lib-conditional-display-config__f-label{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__seg{--mat-standard-button-toggle-height: 1.625rem;font-size:.6875rem}.lib-conditional-display-config__cond{display:grid;grid-template-columns:repeat(auto-fit,minmax(8.5rem,1fr));gap:.5rem .625rem;min-width:0}.lib-conditional-display-config__field{display:flex;flex-direction:column;gap:.1875rem;min-width:0}.lib-conditional-display-config__connector{align-self:flex-start;font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-primary);padding:.125rem 0}.lib-conditional-display-config__control{width:100%;min-width:0;box-sizing:border-box;padding:.375rem .5rem;font:inherit;font-size:.8125rem;color:var(--lib-forms-on-surface);background:var(--lib-forms-surface-container-low);border:1px solid var(--lib-forms-outline-variant);border-radius:var(--lib-forms-radius-sm, 6px);transition:border-color .3s cubic-bezier(.16,1,.3,1),background-color .3s cubic-bezier(.16,1,.3,1)}select.lib-conditional-display-config__control{appearance:auto}.lib-conditional-display-config__control:hover:not(:disabled){border-color:var(--lib-forms-outline)}.lib-conditional-display-config__control:focus{outline:none;border-color:var(--lib-forms-primary)}.lib-conditional-display-config__control:disabled{opacity:.55}.lib-conditional-display-config__control--invalid:not(:focus){border-color:var(--sem-warning, var(--lib-forms-outline))}.lib-conditional-display-config__textarea{resize:vertical;min-height:3.25rem}.lib-conditional-display-config__mono{font-family:var(--lib-forms-font-mono, ui-monospace, monospace);font-size:.75rem}.lib-conditional-display-config__value{display:flex;align-items:center;gap:.25rem;min-width:0}.lib-conditional-display-config__value>.lib-conditional-display-config__control{flex:1 1 auto}.lib-conditional-display-config__icon-btn{flex:none;display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;border:none;border-radius:var(--lib-forms-radius-sm, 6px);background:transparent;color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:background-color .3s cubic-bezier(.16,1,.3,1),color .3s cubic-bezier(.16,1,.3,1)}.lib-conditional-display-config__icon-btn:hover:not(:disabled){background:var(--lib-forms-surface-container);color:var(--lib-forms-on-surface)}.lib-conditional-display-config__icon-btn:disabled{opacity:.45;cursor:default}.lib-conditional-display-config__icon-btn mat-icon{font-size:1rem;width:1rem;height:1rem}.lib-conditional-display-config__link{display:inline-flex;align-items:center;gap:.25rem;align-self:flex-start;padding:.25rem .375rem;border:none;border-radius:var(--lib-forms-radius-sm, 6px);background:transparent;font:inherit;font-size:.75rem;font-weight:500;color:var(--lib-forms-primary);cursor:pointer;transition:background-color .3s cubic-bezier(.16,1,.3,1)}.lib-conditional-display-config__link:hover:not(:disabled){background:var(--lib-forms-surface-container)}.lib-conditional-display-config__link:disabled{opacity:.45;cursor:default}.lib-conditional-display-config__link mat-icon{font-size:.9375rem;width:.9375rem;height:.9375rem}.lib-conditional-display-config__link--danger{color:var(--lib-forms-on-surface-variant)}.lib-conditional-display-config__foot{display:flex;align-items:center;justify-content:space-between;gap:.5rem}.lib-conditional-display-config__error{display:flex;align-items:flex-start;gap:.375rem;margin:0;font-size:.75rem;line-height:1.45;color:var(--sem-error, var(--lib-forms-on-surface))}.lib-conditional-display-config__error-icon{flex:none;font-size:.9375rem;width:.9375rem;height:.9375rem}.lib-conditional-display-config__lists{display:flex;flex-direction:column;gap:.375rem}.lib-conditional-display-config__list-row{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.25rem .5rem}.lib-conditional-display-config__list-name{font-size:.75rem;color:var(--lib-forms-on-surface)}.lib-conditional-display-config__list-row--unset .lib-conditional-display-config__list-name:after{content:\"\\2014 choose one\";margin-left:.375rem;font-size:.6875rem;color:var(--sem-warning, var(--lib-forms-on-surface-variant))}.lib-conditional-display-config__agg{display:flex;flex-wrap:wrap;gap:.25rem}.lib-conditional-display-config__agg-chip{padding:.1875rem .5rem;border:1px solid var(--lib-forms-outline-variant);border-radius:999px;background:transparent;font:inherit;font-size:.6875rem;color:var(--lib-forms-on-surface-variant);cursor:pointer;transition:background-color .3s cubic-bezier(.16,1,.3,1),color .3s cubic-bezier(.16,1,.3,1),border-color .3s cubic-bezier(.16,1,.3,1)}.lib-conditional-display-config__agg-chip:hover:not(:disabled){border-color:var(--lib-forms-outline)}.lib-conditional-display-config__agg-chip--on{background:var(--lib-forms-primary);border-color:var(--lib-forms-primary);color:var(--lib-forms-on-primary)}.lib-conditional-display-config__preview{min-width:0}.lib-conditional-display-config__preview-summary{font-size:.625rem;font-weight:600;letter-spacing:.14em;text-transform:uppercase;color:var(--lib-forms-on-surface-variant);cursor:pointer;-webkit-user-select:none;user-select:none}.lib-conditional-display-config__preview code{display:block;margin-top:.25rem;padding:.375rem .5rem;overflow-x:auto;font-family:var(--lib-forms-font-mono, ui-monospace, monospace);font-size:.6875rem;color:var(--lib-forms-on-surface);background:var(--lib-forms-surface-container-low);border-radius:var(--lib-forms-radius-sm, 6px)}\n"] }]
|
|
504
|
+
}], propDecorators: { disabled: [{
|
|
505
|
+
type: Input
|
|
506
|
+
}], value: [{
|
|
507
|
+
type: Input
|
|
508
|
+
}], errors: [{
|
|
509
|
+
type: Input
|
|
510
|
+
}], mapToData: [{ type: i0.Input, args: [{ isSignal: true, alias: "mapToData", required: false }] }], formInputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "formInputs", required: false }] }], valueChanged: [{ type: i0.Output, args: ["valueChanged"] }] } });
|
|
511
|
+
|
|
512
|
+
export { ConditionalDisplayConfigComponent };
|
|
513
|
+
//# sourceMappingURL=ngx-t-forms-conditional-display-config.component-ayrWl-c2.mjs.map
|