ngx-t-forms 3.1.1 → 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-CZm3Z_7B.mjs → ngx-t-forms-api-endpoint-config.component-B9tCHtwV.mjs} +6 -6
- package/fesm2022/{ngx-t-forms-api-endpoint-config.component-CZm3Z_7B.mjs.map → ngx-t-forms-api-endpoint-config.component-B9tCHtwV.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-auto-complete-input-element.component-IciY6hb3.mjs → ngx-t-forms-auto-complete-input-element.component-D2Vty1Aj.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-auto-complete-input-element.component-IciY6hb3.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-CykKxWu0.mjs → ngx-t-forms-basic-input-input-element.component-Dr2bhCnH.mjs} +3 -3
- package/fesm2022/{ngx-t-forms-basic-input-input-element.component-CykKxWu0.mjs.map → ngx-t-forms-basic-input-input-element.component-Dr2bhCnH.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-calculated-field-rules.component-CwI-WEX7.mjs → ngx-t-forms-calculated-field-rules.component-DLBTjfMj.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-calculated-field-rules.component-CwI-WEX7.mjs.map → ngx-t-forms-calculated-field-rules.component-DLBTjfMj.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-chip-options-creator-editor.component-CO_3EQ_v.mjs → ngx-t-forms-chip-options-creator-editor.component-Bh6jMmtu.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-chip-options-creator-editor.component-CO_3EQ_v.mjs.map → ngx-t-forms-chip-options-creator-editor.component-Bh6jMmtu.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-conditional-display-config.component-Cmf7gDfO.mjs → ngx-t-forms-conditional-display-config.component-ayrWl-c2.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-conditional-display-config.component-Cmf7gDfO.mjs.map → ngx-t-forms-conditional-display-config.component-ayrWl-c2.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-config-mscoa-additional-inputs.component-BHiOEQe4.mjs → ngx-t-forms-config-mscoa-additional-inputs.component-nOnJfMTo.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-config-mscoa-additional-inputs.component-BHiOEQe4.mjs.map → ngx-t-forms-config-mscoa-additional-inputs.component-nOnJfMTo.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-data-source-picker.component-CN51SdCK.mjs → ngx-t-forms-data-source-picker.component-mmyhOBvA.mjs} +6 -6
- package/fesm2022/{ngx-t-forms-data-source-picker.component-CN51SdCK.mjs.map → ngx-t-forms-data-source-picker.component-mmyhOBvA.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-date-picker-input-element.component-c3OSDXWw.mjs → ngx-t-forms-date-picker-input-element.component-DmiBra1D.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-date-picker-input-element.component-c3OSDXWw.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-C-4fqOF0.mjs → ngx-t-forms-date-range-picker-input-element.component-Cke5qSzR.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-date-range-picker-input-element.component-C-4fqOF0.mjs.map → ngx-t-forms-date-range-picker-input-element.component-Cke5qSzR.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-document-list-label-config-editor.component-DLzba2AQ.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-DLzba2AQ.mjs.map → ngx-t-forms-document-list-label-config-editor.component-C0xx4jrN.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-document-picker.component-9clYsOcl.mjs → ngx-t-forms-document-picker.component-DI7wtEv6.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-document-picker.component-9clYsOcl.mjs.map → ngx-t-forms-document-picker.component-DI7wtEv6.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-editor-js-input.component-02HnmInT.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-BF7KbSPb.mjs → ngx-t-forms-file-upload-input-element.component-DbwvZghJ.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-file-upload-input-element.component-BF7KbSPb.mjs.map → ngx-t-forms-file-upload-input-element.component-DbwvZghJ.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-form-input-selector.component-vCj2SCxs.mjs → ngx-t-forms-form-input-selector.component-CkuzNdjx.mjs} +2 -3
- package/fesm2022/{ngx-t-forms-form-input-selector.component-vCj2SCxs.mjs.map → ngx-t-forms-form-input-selector.component-CkuzNdjx.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-form-json-view.component-Cmw1hHGZ.mjs → ngx-t-forms-form-json-view.component-DBCpa_rZ.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-form-json-view.component-Cmw1hHGZ.mjs.map → ngx-t-forms-form-json-view.component-DBCpa_rZ.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-form-section-stepper.component-CFdwgxRl.mjs → ngx-t-forms-form-section-stepper.component-jLj6vePZ.mjs} +4 -4
- package/fesm2022/{ngx-t-forms-form-section-stepper.component-CFdwgxRl.mjs.map → ngx-t-forms-form-section-stepper.component-jLj6vePZ.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-forms-builder-menu.component-DisrOv5x.mjs → ngx-t-forms-forms-builder-menu.component-Iyd0grju.mjs} +4 -4
- package/fesm2022/{ngx-t-forms-forms-builder-menu.component-DisrOv5x.mjs.map → ngx-t-forms-forms-builder-menu.component-Iyd0grju.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-geo-location.component-D-BhLdx6.mjs → ngx-t-forms-geo-location.component-BUXRaPy0.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-geo-location.component-D-BhLdx6.mjs.map → ngx-t-forms-geo-location.component-BUXRaPy0.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-header-template-editor.component-Z5frEhho.mjs → ngx-t-forms-header-template-editor.component-BLmAqiQA.mjs} +2 -3
- package/fesm2022/{ngx-t-forms-header-template-editor.component-Z5frEhho.mjs.map → ngx-t-forms-header-template-editor.component-BLmAqiQA.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-image-capture-input-element.component-CoJTXMbL.mjs → ngx-t-forms-image-capture-input-element.component-D6Ffuhbv.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-image-capture-input-element.component-CoJTXMbL.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-s1ryJQy4.mjs → ngx-t-forms-input-custom.component-BMui37o-.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-input-custom.component-s1ryJQy4.mjs.map → ngx-t-forms-input-custom.component-BMui37o-.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-input-editor.component-oIzCTmbx.mjs → ngx-t-forms-input-editor.component-D60TpWzO.mjs} +3 -4
- package/fesm2022/{ngx-t-forms-input-editor.component-oIzCTmbx.mjs.map → ngx-t-forms-input-editor.component-D60TpWzO.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-map-mat-options-keys-C1kxlZS_.mjs → ngx-t-forms-map-mat-options-keys-yfxnNDPs.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-map-mat-options-keys-C1kxlZS_.mjs.map → ngx-t-forms-map-mat-options-keys-yfxnNDPs.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-mat-chip-list-editor.component-wskkKr4y.mjs → ngx-t-forms-mat-chip-list-editor.component-cfBBan80.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-mat-chip-list-editor.component-wskkKr4y.mjs.map → ngx-t-forms-mat-chip-list-editor.component-cfBBan80.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-missing-form-configs.component-C1XuXRdn.mjs → ngx-t-forms-missing-form-configs.component-BcYuduah.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-missing-form-configs.component-C1XuXRdn.mjs.map → ngx-t-forms-missing-form-configs.component-BcYuduah.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-mscoa-chart-toolbar.component-BJrOTRuQ.mjs → ngx-t-forms-mscoa-chart-toolbar.component-nLawxM9j.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-mscoa-chart-toolbar.component-BJrOTRuQ.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-GyKF31Ve.mjs → ngx-t-forms-mscoa-segment-config.component-DKEEZ8MD.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-mscoa-segment-config.component-GyKF31Ve.mjs.map → ngx-t-forms-mscoa-segment-config.component-DKEEZ8MD.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-multiple-input-input-element.component-BrPJPR2R.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-DqAcUfN4.mjs → ngx-t-forms-ngx-t-forms-9BfJdjl4.mjs} +476 -44
- package/fesm2022/ngx-t-forms-ngx-t-forms-9BfJdjl4.mjs.map +1 -0
- package/fesm2022/{ngx-t-forms-paginated-selection-table-Bk77dBo9.mjs → ngx-t-forms-paginated-selection-table-Bm5-5VWe.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-paginated-selection-table-Bk77dBo9.mjs.map → ngx-t-forms-paginated-selection-table-Bm5-5VWe.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-payload-template-editor.component-CVzOTLYE.mjs → ngx-t-forms-payload-template-editor.component-2hwGuKAB.mjs} +2 -3
- package/fesm2022/{ngx-t-forms-payload-template-editor.component-CVzOTLYE.mjs.map → ngx-t-forms-payload-template-editor.component-2hwGuKAB.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-pipeline-generator.component-7Vfwaqnx.mjs → ngx-t-forms-pipeline-generator.component-BvjT2zfL.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-pipeline-generator.component-7Vfwaqnx.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-CfZdqKhY.mjs → ngx-t-forms-record-list-manager.component-BK5nwwDp.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-record-list-manager.component-CfZdqKhY.mjs.map → ngx-t-forms-record-list-manager.component-BK5nwwDp.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-required-inputs.component-CK7NIhbq.mjs → ngx-t-forms-required-inputs.component-DiwMttVf.mjs} +2 -3
- package/fesm2022/{ngx-t-forms-required-inputs.component-CK7NIhbq.mjs.map → ngx-t-forms-required-inputs.component-DiwMttVf.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-rest-api-call-setup.component-YChv7Arm.mjs → ngx-t-forms-rest-api-call-setup.component-CBgG_f06.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-rest-api-call-setup.component-YChv7Arm.mjs.map → ngx-t-forms-rest-api-call-setup.component-CBgG_f06.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-section-report.component-DhSaf85h.mjs → ngx-t-forms-section-report.component-CyPpFiWS.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-section-report.component-DhSaf85h.mjs.map → ngx-t-forms-section-report.component-CyPpFiWS.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-select-input-element.component-D5HFzh35.mjs → ngx-t-forms-select-input-element.component-B2wr5_88.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-select-input-element.component-D5HFzh35.mjs.map → ngx-t-forms-select-input-element.component-B2wr5_88.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-selection-options-editor.component-BhmmJOco.mjs → ngx-t-forms-selection-options-editor.component-BEZLG1Z8.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-selection-options-editor.component-BhmmJOco.mjs.map → ngx-t-forms-selection-options-editor.component-BEZLG1Z8.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-textarea-input-element.component-DWEADTsz.mjs → ngx-t-forms-textarea-input-element.component-Cmbd0krg.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-textarea-input-element.component-DWEADTsz.mjs.map → ngx-t-forms-textarea-input-element.component-Cmbd0krg.mjs.map} +1 -1
- package/fesm2022/{ngx-t-forms-toggle-input-element.component-XZi6kPnL.mjs → ngx-t-forms-toggle-input-element.component-Dd_FcAoD.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-toggle-input-element.component-XZi6kPnL.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-0_Y6bvtE.mjs → ngx-t-forms-validators-config.component-Btmz2cKH.mjs} +2 -2
- package/fesm2022/{ngx-t-forms-validators-config.component-0_Y6bvtE.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 +53 -1
- package/fesm2022/ngx-t-forms-editor-input-element.component-BGdZ4evj.mjs +0 -417
- package/fesm2022/ngx-t-forms-editor-input-element.component-BGdZ4evj.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-editor-js-input.component-02HnmInT.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-index-D8xr_Sxp.mjs +0 -2
- package/fesm2022/ngx-t-forms-index-D8xr_Sxp.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-multiple-input-input-element.component-BrPJPR2R.mjs.map +0 -1
- package/fesm2022/ngx-t-forms-ngx-t-forms-DqAcUfN4.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-Gkimmw-X.mjs +0 -1303
- package/fesm2022/ngx-t-forms-workflow-adjudication.component-Gkimmw-X.mjs.map +0 -1
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { ElementTypes } from 'ngx-t-forms-types';
|
|
2
|
-
import { g as getInputIcon } from './ngx-t-forms-getInputIcon-B4ADgevZ.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file Field → `$`-picker binding derivation, shared by every token-binding
|
|
6
|
-
* JSON editor (payload templates, header templates).
|
|
7
|
-
*
|
|
8
|
-
* Both editors offer the same gesture — type `$`, pick a form field, get its
|
|
9
|
-
* `{{token}}` inserted — over the same {@link JsonEditorComponent}. The only
|
|
10
|
-
* thing that differs is the document being edited, so the field list, the icon
|
|
11
|
-
* and kind labels, and the friendly-label ⇄ id aliasing live here rather than
|
|
12
|
-
* being copied per editor.
|
|
13
|
-
*
|
|
14
|
-
* Pure: no Angular DI, no signals. Callers wrap these in `computed()`.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Turns an element type into a short, friendly field-kind label — the muted
|
|
18
|
-
* second line in the picker that disambiguates same-named fields.
|
|
19
|
-
*
|
|
20
|
-
* @param element - The input's element type.
|
|
21
|
-
* @returns A spaced, capitalised label (e.g. `MultipleInput` → `Multiple Input`).
|
|
22
|
-
*/
|
|
23
|
-
function humanizeElement(element) {
|
|
24
|
-
return String(element)
|
|
25
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
26
|
-
.replace(/^./, (c) => c.toUpperCase());
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The inputs a token may bind to.
|
|
30
|
-
*
|
|
31
|
-
* Excludes what cannot carry a value at request time: a `SectionTitle` (layout
|
|
32
|
-
* only) and a MultipleInput **sub-row** input (`multipleInputInEditId`), whose
|
|
33
|
-
* control exists only while its row is open — a token bound to one would resolve
|
|
34
|
-
* empty for every closed row and hold the fetch idle forever.
|
|
35
|
-
*
|
|
36
|
-
* @param formInputs - Every input on the form being configured.
|
|
37
|
-
* @returns The bindable inputs, unfiltered by anything else.
|
|
38
|
-
*/
|
|
39
|
-
function bindableInputs(formInputs) {
|
|
40
|
-
return formInputs.filter((input) => input.element !== ElementTypes.SectionTitle && !input.multipleInputInEditId && !!input.id);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The bindable inputs as id/label pairs — the input to `buildTokenMaps`.
|
|
44
|
-
*
|
|
45
|
-
* @param formInputs - Every input on the form being configured.
|
|
46
|
-
* @returns One {@link TokenField} per bindable input, labelled by its display
|
|
47
|
-
* label (falling back to the raw id when none is authored).
|
|
48
|
-
*/
|
|
49
|
-
function bindableFields(formInputs) {
|
|
50
|
-
return bindableInputs(formInputs).map((input) => ({
|
|
51
|
-
id: input.id,
|
|
52
|
-
label: input.label?.trim() || input.id,
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* The bindings for the JSON editor's `$`-trigger picker.
|
|
57
|
-
*
|
|
58
|
-
* The picker shows the friendly label + field kind (never the raw id); the
|
|
59
|
-
* inserted token is the friendly `{{Label}}` when that label earned one, else the
|
|
60
|
-
* raw `{{id}}`. Each binding also aliases the *other* form, so a pasted or legacy
|
|
61
|
-
* `{{id}}` still renders as a valid (clickable) pill — and vice versa.
|
|
62
|
-
*
|
|
63
|
-
* @param formInputs - Every input on the form being configured.
|
|
64
|
-
* @param idToLabel - The `id → label` half of `buildTokenMaps`; only safe,
|
|
65
|
-
* uniquely-labelled fields appear in it, so anything absent keeps its raw id.
|
|
66
|
-
* @returns One {@link EditorBinding} per bindable input.
|
|
67
|
-
*/
|
|
68
|
-
function fieldEditorBindings(formInputs, idToLabel) {
|
|
69
|
-
return bindableInputs(formInputs).map((input) => {
|
|
70
|
-
const label = input.label?.trim() || input.id;
|
|
71
|
-
const display = idToLabel.get(input.id);
|
|
72
|
-
return {
|
|
73
|
-
label,
|
|
74
|
-
insert: display ? `{{${display}}}` : `{{${input.id}}}`,
|
|
75
|
-
searchText: `${input.id} ${input.label ?? ''}`,
|
|
76
|
-
icon: getInputIcon(input.element),
|
|
77
|
-
detail: humanizeElement(input.element),
|
|
78
|
-
aliases: display ? [input.id] : [label],
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @file Friendly-label ⇄ id token transform for the payload-template editor.
|
|
85
|
-
*
|
|
86
|
-
* The stored config always uses `{{inputId}}` tokens, but the editor shows the
|
|
87
|
-
* user-friendly field **label** inline (`{{Contract Type}}`). This module maps
|
|
88
|
-
* between the two forms on a per-field basis.
|
|
89
|
-
*
|
|
90
|
-
* ### Robustness (why this is safe despite arbitrary labels)
|
|
91
|
-
* The transform runs on the **parsed value** (objects/strings), never on raw
|
|
92
|
-
* JSON text — so `JSON.stringify`/`parse` handle escaping and a label with a
|
|
93
|
-
* quote can never corrupt the document. On top of that, a label only earns a
|
|
94
|
-
* friendly token when it is BOTH:
|
|
95
|
-
* - **safe** — contains none of `{ } " \` (which would break the `{{…}}`
|
|
96
|
-
* delimiters or a raw picker-insertion), and
|
|
97
|
-
* - **unique** — no other field shares it (so `label → id` is unambiguous).
|
|
98
|
-
*
|
|
99
|
-
* Any field failing either test keeps its raw `{{id}}` inline. The friendly view
|
|
100
|
-
* is therefore a lossless, best-effort layer that degrades to the id — it can
|
|
101
|
-
* never produce invalid JSON or an ambiguous mapping.
|
|
102
|
-
*/
|
|
103
|
-
/** Characters that make a label unusable as a `{{label}}` token. */
|
|
104
|
-
const UNSAFE_LABEL = /[{}"\\]/;
|
|
105
|
-
/** Matches a `{{token}}` occurrence inside a string (token captured, trimmed by the caller). */
|
|
106
|
-
const TOKEN_RE = /\{\{\s*([^{}]+?)\s*\}\}/g;
|
|
107
|
-
/**
|
|
108
|
-
* Builds the id⇄label token maps for a set of fields, applying the safety and
|
|
109
|
-
* uniqueness rules described in the file header.
|
|
110
|
-
*
|
|
111
|
-
* @param fields - The candidate fields (id + label).
|
|
112
|
-
* @returns The bidirectional maps; a field absent from them keeps its raw id.
|
|
113
|
-
*/
|
|
114
|
-
function buildTokenMaps(fields) {
|
|
115
|
-
const labelCounts = new Map();
|
|
116
|
-
for (const field of fields) {
|
|
117
|
-
const label = field.label?.trim();
|
|
118
|
-
if (!label || UNSAFE_LABEL.test(label))
|
|
119
|
-
continue;
|
|
120
|
-
labelCounts.set(label, (labelCounts.get(label) ?? 0) + 1);
|
|
121
|
-
}
|
|
122
|
-
const idToLabel = new Map();
|
|
123
|
-
const labelToId = new Map();
|
|
124
|
-
for (const field of fields) {
|
|
125
|
-
const label = field.label?.trim();
|
|
126
|
-
if (!label || UNSAFE_LABEL.test(label))
|
|
127
|
-
continue;
|
|
128
|
-
if (labelCounts.get(label) !== 1)
|
|
129
|
-
continue; // ambiguous → keep the raw id
|
|
130
|
-
if (label === field.id)
|
|
131
|
-
continue; // transform would be a no-op
|
|
132
|
-
idToLabel.set(field.id, label);
|
|
133
|
-
labelToId.set(label, field.id);
|
|
134
|
-
}
|
|
135
|
-
return { idToLabel, labelToId };
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Deep-walks a parsed JSON value, rewriting every `{{token}}` whose trimmed token
|
|
139
|
-
* is a key in `lookup` to `{{mappedValue}}`. Unmapped tokens are left untouched.
|
|
140
|
-
* Non-string leaves (numbers/booleans/null) pass through unchanged.
|
|
141
|
-
*
|
|
142
|
-
* @typeParam T - The value shape (preserved).
|
|
143
|
-
* @param value - The parsed template value (object / array / primitive / undefined).
|
|
144
|
-
* @param lookup - `idToLabel` for display, `labelToId` for save.
|
|
145
|
-
* @returns A structurally-cloned value with tokens rewritten (or the original when `lookup` is empty).
|
|
146
|
-
*/
|
|
147
|
-
function mapTemplateTokens(value, lookup) {
|
|
148
|
-
if (lookup.size === 0)
|
|
149
|
-
return value;
|
|
150
|
-
return walk(value, lookup);
|
|
151
|
-
}
|
|
152
|
-
function walk(node, lookup) {
|
|
153
|
-
if (typeof node === 'string') {
|
|
154
|
-
return node.replace(TOKEN_RE, (match, rawToken) => {
|
|
155
|
-
const mapped = lookup.get(rawToken.trim());
|
|
156
|
-
return mapped !== undefined ? `{{${mapped}}}` : match;
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
if (Array.isArray(node)) {
|
|
160
|
-
return node.map((item) => walk(item, lookup));
|
|
161
|
-
}
|
|
162
|
-
if (node !== null && typeof node === 'object') {
|
|
163
|
-
const out = {};
|
|
164
|
-
for (const [key, val] of Object.entries(node)) {
|
|
165
|
-
out[key] = walk(val, lookup);
|
|
166
|
-
}
|
|
167
|
-
return out;
|
|
168
|
-
}
|
|
169
|
-
return node;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export { bindableFields as a, buildTokenMaps as b, fieldEditorBindings as f, mapTemplateTokens as m };
|
|
173
|
-
//# sourceMappingURL=ngx-t-forms-token-transform-D_wsFbNc.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-t-forms-token-transform-D_wsFbNc.mjs","sources":["../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/_shared/field-bindings.ts","../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/payload-template-editor/token-transform.ts"],"sourcesContent":["/**\r\n * @file Field → `$`-picker binding derivation, shared by every token-binding\r\n * JSON editor (payload templates, header templates).\r\n *\r\n * Both editors offer the same gesture — type `$`, pick a form field, get its\r\n * `{{token}}` inserted — over the same {@link JsonEditorComponent}. The only\r\n * thing that differs is the document being edited, so the field list, the icon\r\n * and kind labels, and the friendly-label ⇄ id aliasing live here rather than\r\n * being copied per editor.\r\n *\r\n * Pure: no Angular DI, no signals. Callers wrap these in `computed()`.\r\n */\r\nimport { ElementTypes } from 'ngx-t-forms-types';\r\nimport type { FormColumnInputs } from 'ngx-t-forms-types';\r\n\r\nimport { getInputIcon } from '../../../../shared/functions/getInputIcon';\r\nimport type { EditorBinding } from '../json-editor/json-editor.component';\r\nimport type { TokenField } from '../payload-template-editor/token-transform';\r\n\r\n/**\r\n * Turns an element type into a short, friendly field-kind label — the muted\r\n * second line in the picker that disambiguates same-named fields.\r\n *\r\n * @param element - The input's element type.\r\n * @returns A spaced, capitalised label (e.g. `MultipleInput` → `Multiple Input`).\r\n */\r\nfunction humanizeElement(element: ElementTypes): string {\r\n return String(element)\r\n .replace(/([a-z])([A-Z])/g, '$1 $2')\r\n .replace(/^./, (c) => c.toUpperCase());\r\n}\r\n\r\n/**\r\n * The inputs a token may bind to.\r\n *\r\n * Excludes what cannot carry a value at request time: a `SectionTitle` (layout\r\n * only) and a MultipleInput **sub-row** input (`multipleInputInEditId`), whose\r\n * control exists only while its row is open — a token bound to one would resolve\r\n * empty for every closed row and hold the fetch idle forever.\r\n *\r\n * @param formInputs - Every input on the form being configured.\r\n * @returns The bindable inputs, unfiltered by anything else.\r\n */\r\nexport function bindableInputs(\r\n formInputs: readonly FormColumnInputs[],\r\n): readonly FormColumnInputs[] {\r\n return formInputs.filter(\r\n (input) => input.element !== ElementTypes.SectionTitle && !input.multipleInputInEditId && !!input.id,\r\n );\r\n}\r\n\r\n/**\r\n * The bindable inputs as id/label pairs — the input to `buildTokenMaps`.\r\n *\r\n * @param formInputs - Every input on the form being configured.\r\n * @returns One {@link TokenField} per bindable input, labelled by its display\r\n * label (falling back to the raw id when none is authored).\r\n */\r\nexport function bindableFields(formInputs: readonly FormColumnInputs[]): readonly TokenField[] {\r\n return bindableInputs(formInputs).map((input) => ({\r\n id: input.id,\r\n label: input.label?.trim() || input.id,\r\n }));\r\n}\r\n\r\n/**\r\n * The bindings for the JSON editor's `$`-trigger picker.\r\n *\r\n * The picker shows the friendly label + field kind (never the raw id); the\r\n * inserted token is the friendly `{{Label}}` when that label earned one, else the\r\n * raw `{{id}}`. Each binding also aliases the *other* form, so a pasted or legacy\r\n * `{{id}}` still renders as a valid (clickable) pill — and vice versa.\r\n *\r\n * @param formInputs - Every input on the form being configured.\r\n * @param idToLabel - The `id → label` half of `buildTokenMaps`; only safe,\r\n * uniquely-labelled fields appear in it, so anything absent keeps its raw id.\r\n * @returns One {@link EditorBinding} per bindable input.\r\n */\r\nexport function fieldEditorBindings(\r\n formInputs: readonly FormColumnInputs[],\r\n idToLabel: ReadonlyMap<string, string>,\r\n): readonly EditorBinding[] {\r\n return bindableInputs(formInputs).map((input) => {\r\n const label = input.label?.trim() || input.id;\r\n const display = idToLabel.get(input.id);\r\n return {\r\n label,\r\n insert: display ? `{{${display}}}` : `{{${input.id}}}`,\r\n searchText: `${input.id} ${input.label ?? ''}`,\r\n icon: getInputIcon(input.element),\r\n detail: humanizeElement(input.element),\r\n aliases: display ? [input.id] : [label],\r\n } satisfies EditorBinding;\r\n });\r\n}\r\n","/**\r\n * @file Friendly-label ⇄ id token transform for the payload-template editor.\r\n *\r\n * The stored config always uses `{{inputId}}` tokens, but the editor shows the\r\n * user-friendly field **label** inline (`{{Contract Type}}`). This module maps\r\n * between the two forms on a per-field basis.\r\n *\r\n * ### Robustness (why this is safe despite arbitrary labels)\r\n * The transform runs on the **parsed value** (objects/strings), never on raw\r\n * JSON text — so `JSON.stringify`/`parse` handle escaping and a label with a\r\n * quote can never corrupt the document. On top of that, a label only earns a\r\n * friendly token when it is BOTH:\r\n * - **safe** — contains none of `{ } \" \\` (which would break the `{{…}}`\r\n * delimiters or a raw picker-insertion), and\r\n * - **unique** — no other field shares it (so `label → id` is unambiguous).\r\n *\r\n * Any field failing either test keeps its raw `{{id}}` inline. The friendly view\r\n * is therefore a lossless, best-effort layer that degrades to the id — it can\r\n * never produce invalid JSON or an ambiguous mapping.\r\n */\r\n\r\n/** A field that can back a token: its stable `id` and its display `label`. */\r\nexport interface TokenField {\r\n readonly id: string;\r\n readonly label: string;\r\n}\r\n\r\n/** Bidirectional token maps (only safe, uniquely-labelled fields are included). */\r\nexport interface TokenMaps {\r\n /** `id → label` (drives the id→friendly display transform + picker insert). */\r\n readonly idToLabel: ReadonlyMap<string, string>;\r\n /** `label → id` (drives the friendly→id save transform). */\r\n readonly labelToId: ReadonlyMap<string, string>;\r\n}\r\n\r\n/** Characters that make a label unusable as a `{{label}}` token. */\r\nconst UNSAFE_LABEL = /[{}\"\\\\]/;\r\n\r\n/** Matches a `{{token}}` occurrence inside a string (token captured, trimmed by the caller). */\r\nconst TOKEN_RE = /\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g;\r\n\r\n/**\r\n * Builds the id⇄label token maps for a set of fields, applying the safety and\r\n * uniqueness rules described in the file header.\r\n *\r\n * @param fields - The candidate fields (id + label).\r\n * @returns The bidirectional maps; a field absent from them keeps its raw id.\r\n */\r\nexport function buildTokenMaps(fields: readonly TokenField[]): TokenMaps {\r\n const labelCounts = new Map<string, number>();\r\n for (const field of fields) {\r\n const label = field.label?.trim();\r\n if (!label || UNSAFE_LABEL.test(label)) continue;\r\n labelCounts.set(label, (labelCounts.get(label) ?? 0) + 1);\r\n }\r\n\r\n const idToLabel = new Map<string, string>();\r\n const labelToId = new Map<string, string>();\r\n for (const field of fields) {\r\n const label = field.label?.trim();\r\n if (!label || UNSAFE_LABEL.test(label)) continue;\r\n if (labelCounts.get(label) !== 1) continue; // ambiguous → keep the raw id\r\n if (label === field.id) continue; // transform would be a no-op\r\n idToLabel.set(field.id, label);\r\n labelToId.set(label, field.id);\r\n }\r\n return { idToLabel, labelToId };\r\n}\r\n\r\n/**\r\n * Deep-walks a parsed JSON value, rewriting every `{{token}}` whose trimmed token\r\n * is a key in `lookup` to `{{mappedValue}}`. Unmapped tokens are left untouched.\r\n * Non-string leaves (numbers/booleans/null) pass through unchanged.\r\n *\r\n * @typeParam T - The value shape (preserved).\r\n * @param value - The parsed template value (object / array / primitive / undefined).\r\n * @param lookup - `idToLabel` for display, `labelToId` for save.\r\n * @returns A structurally-cloned value with tokens rewritten (or the original when `lookup` is empty).\r\n */\r\nexport function mapTemplateTokens<T>(value: T, lookup: ReadonlyMap<string, string>): T {\r\n if (lookup.size === 0) return value;\r\n return walk(value, lookup) as T;\r\n}\r\n\r\nfunction walk(node: unknown, lookup: ReadonlyMap<string, string>): unknown {\r\n if (typeof node === 'string') {\r\n return node.replace(TOKEN_RE, (match, rawToken: string) => {\r\n const mapped = lookup.get(rawToken.trim());\r\n return mapped !== undefined ? `{{${mapped}}}` : match;\r\n });\r\n }\r\n if (Array.isArray(node)) {\r\n return node.map((item) => walk(item, lookup));\r\n }\r\n if (node !== null && typeof node === 'object') {\r\n const out: Record<string, unknown> = {};\r\n for (const [key, val] of Object.entries(node as Record<string, unknown>)) {\r\n out[key] = walk(val, lookup);\r\n }\r\n return out;\r\n }\r\n return node;\r\n}\r\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;AAWG;AAQH;;;;;;AAMG;AACH,SAAS,eAAe,CAAC,OAAqB,EAAA;IAC5C,OAAO,MAAM,CAAC,OAAO;AAClB,SAAA,OAAO,CAAC,iBAAiB,EAAE,OAAO;AAClC,SAAA,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1C;AAEA;;;;;;;;;;AAUG;AACG,SAAU,cAAc,CAC5B,UAAuC,EAAA;AAEvC,IAAA,OAAO,UAAU,CAAC,MAAM,CACtB,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,KAAK,YAAY,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CACrG;AACH;AAEA;;;;;;AAMG;AACG,SAAU,cAAc,CAAC,UAAuC,EAAA;AACpE,IAAA,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,MAAM;QAChD,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE;AACvC,KAAA,CAAC,CAAC;AACL;AAEA;;;;;;;;;;;;AAYG;AACG,SAAU,mBAAmB,CACjC,UAAuC,EACvC,SAAsC,EAAA;IAEtC,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;AAC9C,QAAA,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE;QAC7C,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,KAA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