@researchdatabox/sails-ng-common 0.2.1 → 5.0.0-RC2
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/dist/src/config/base-field-component.model.d.ts +26 -0
- package/dist/src/config/base-field-component.model.js +29 -0
- package/dist/src/config/base-field-component.outline.d.ts +108 -0
- package/dist/src/config/base-field-component.outline.js +3 -0
- package/dist/src/config/component/accordion.model.d.ts +103 -0
- package/dist/src/config/component/accordion.model.js +127 -0
- package/dist/src/config/component/accordion.outline.d.ts +162 -0
- package/dist/src/config/component/accordion.outline.js +13 -0
- package/dist/src/config/component/action-row-layout.model.d.ts +28 -0
- package/dist/src/config/component/action-row-layout.model.js +35 -0
- package/dist/src/config/component/action-row-layout.outline.d.ts +36 -0
- package/dist/src/config/component/action-row-layout.outline.js +6 -0
- package/dist/src/config/component/cancel-button.model.d.ts +48 -0
- package/dist/src/config/component/cancel-button.model.js +58 -0
- package/dist/src/config/component/cancel-button.outline.d.ts +85 -0
- package/dist/src/config/component/cancel-button.outline.js +6 -0
- package/dist/src/config/component/checkbox-input.model.d.ts +67 -0
- package/dist/src/config/component/checkbox-input.model.js +79 -0
- package/dist/src/config/component/checkbox-input.outline.d.ts +93 -0
- package/dist/src/config/component/checkbox-input.outline.js +8 -0
- package/dist/src/config/component/checkbox-tree.model.d.ts +68 -0
- package/dist/src/config/component/checkbox-tree.model.js +80 -0
- package/dist/src/config/component/checkbox-tree.outline.d.ts +105 -0
- package/dist/src/config/component/checkbox-tree.outline.js +8 -0
- package/dist/src/config/component/content.model.d.ts +46 -0
- package/dist/src/config/component/content.model.js +56 -0
- package/dist/src/config/component/content.outline.d.ts +74 -0
- package/dist/src/config/component/content.outline.js +6 -0
- package/dist/src/config/component/data-location.model.d.ts +83 -0
- package/dist/src/config/component/data-location.model.js +95 -0
- package/dist/src/config/component/data-location.outline.d.ts +124 -0
- package/dist/src/config/component/data-location.outline.js +6 -0
- package/dist/src/config/component/date-input.model.d.ts +67 -0
- package/dist/src/config/component/date-input.model.js +80 -0
- package/dist/src/config/component/date-input.outline.d.ts +88 -0
- package/dist/src/config/component/date-input.outline.js +8 -0
- package/dist/src/config/component/default-layout.model.d.ts +22 -0
- package/dist/src/config/component/default-layout.model.js +30 -0
- package/dist/src/config/component/default-layout.outline.d.ts +29 -0
- package/dist/src/config/component/default-layout.outline.js +5 -0
- package/dist/src/config/component/delete-button.model.d.ts +46 -0
- package/dist/src/config/component/delete-button.model.js +48 -0
- package/dist/src/config/component/delete-button.outline.d.ts +89 -0
- package/dist/src/config/component/delete-button.outline.js +5 -0
- package/dist/src/config/component/dropdown-input.model.d.ts +65 -0
- package/dist/src/config/component/dropdown-input.model.js +78 -0
- package/dist/src/config/component/dropdown-input.outline.d.ts +92 -0
- package/dist/src/config/component/dropdown-input.outline.js +8 -0
- package/dist/src/config/component/file-upload.model.d.ts +67 -0
- package/dist/src/config/component/file-upload.model.js +81 -0
- package/dist/src/config/component/file-upload.outline.d.ts +99 -0
- package/dist/src/config/component/file-upload.outline.js +8 -0
- package/dist/src/config/component/group.model.d.ts +61 -0
- package/dist/src/config/component/group.model.js +75 -0
- package/dist/src/config/component/group.outline.d.ts +83 -0
- package/dist/src/config/component/group.outline.js +8 -0
- package/dist/src/config/component/inline-layout.model.d.ts +22 -0
- package/dist/src/config/component/inline-layout.model.js +29 -0
- package/dist/src/config/component/inline-layout.outline.d.ts +29 -0
- package/dist/src/config/component/inline-layout.outline.js +5 -0
- package/dist/src/config/component/integration-status.model.d.ts +49 -0
- package/dist/src/config/component/integration-status.model.js +65 -0
- package/dist/src/config/component/integration-status.outline.d.ts +61 -0
- package/dist/src/config/component/integration-status.outline.js +5 -0
- package/dist/src/config/component/map.model.d.ts +69 -0
- package/dist/src/config/component/map.model.js +86 -0
- package/dist/src/config/component/map.outline.d.ts +110 -0
- package/dist/src/config/component/map.outline.js +8 -0
- package/dist/src/config/component/pdf-list.model.d.ts +68 -0
- package/dist/src/config/component/pdf-list.model.js +71 -0
- package/dist/src/config/component/pdf-list.outline.d.ts +97 -0
- package/dist/src/config/component/pdf-list.outline.js +6 -0
- package/dist/src/config/component/publish-data-location-refresh.model.d.ts +39 -0
- package/dist/src/config/component/publish-data-location-refresh.model.js +52 -0
- package/dist/src/config/component/publish-data-location-refresh.outline.d.ts +58 -0
- package/dist/src/config/component/publish-data-location-refresh.outline.js +5 -0
- package/dist/src/config/component/publish-data-location-selector.model.d.ts +78 -0
- package/dist/src/config/component/publish-data-location-selector.model.js +104 -0
- package/dist/src/config/component/publish-data-location-selector.outline.d.ts +110 -0
- package/dist/src/config/component/publish-data-location-selector.outline.js +6 -0
- package/dist/src/config/component/question-tree.helper.d.ts +58 -0
- package/dist/src/config/component/question-tree.helper.js +291 -0
- package/dist/src/config/component/question-tree.model.d.ts +64 -0
- package/dist/src/config/component/question-tree.model.js +80 -0
- package/dist/src/config/component/question-tree.outline.d.ts +314 -0
- package/dist/src/config/component/question-tree.outline.js +9 -0
- package/dist/src/config/component/radio-input.model.d.ts +65 -0
- package/dist/src/config/component/radio-input.model.js +77 -0
- package/dist/src/config/component/radio-input.outline.d.ts +91 -0
- package/dist/src/config/component/radio-input.outline.js +8 -0
- package/dist/src/config/component/record-metadata-retriever.model.d.ts +41 -0
- package/dist/src/config/component/record-metadata-retriever.model.js +57 -0
- package/dist/src/config/component/record-metadata-retriever.outline.d.ts +53 -0
- package/dist/src/config/component/record-metadata-retriever.outline.js +5 -0
- package/dist/src/config/component/record-selector.model.d.ts +61 -0
- package/dist/src/config/component/record-selector.model.js +61 -0
- package/dist/src/config/component/record-selector.outline.d.ts +91 -0
- package/dist/src/config/component/record-selector.outline.js +6 -0
- package/dist/src/config/component/repeatable.model.d.ts +91 -0
- package/dist/src/config/component/repeatable.model.js +112 -0
- package/dist/src/config/component/repeatable.outline.d.ts +115 -0
- package/dist/src/config/component/repeatable.outline.js +10 -0
- package/dist/src/config/component/reusable.model.d.ts +42 -0
- package/dist/src/config/component/reusable.model.js +57 -0
- package/dist/src/config/component/reusable.outline.d.ts +55 -0
- package/dist/src/config/component/reusable.outline.js +6 -0
- package/dist/src/config/component/rich-text-editor.model.d.ts +65 -0
- package/dist/src/config/component/rich-text-editor.model.js +79 -0
- package/dist/src/config/component/rich-text-editor.outline.d.ts +92 -0
- package/dist/src/config/component/rich-text-editor.outline.js +8 -0
- package/dist/src/config/component/save-button.model.d.ts +49 -0
- package/dist/src/config/component/save-button.model.js +59 -0
- package/dist/src/config/component/save-button.outline.d.ts +90 -0
- package/dist/src/config/component/save-button.outline.js +6 -0
- package/dist/src/config/component/save-status.model.d.ts +42 -0
- package/dist/src/config/component/save-status.model.js +60 -0
- package/dist/src/config/component/save-status.outline.d.ts +58 -0
- package/dist/src/config/component/save-status.outline.js +6 -0
- package/dist/src/config/component/simple-input.model.d.ts +62 -0
- package/dist/src/config/component/simple-input.model.js +75 -0
- package/dist/src/config/component/simple-input.outline.d.ts +86 -0
- package/dist/src/config/component/simple-input.outline.js +9 -0
- package/dist/src/config/component/suggested-validation-summary.model.d.ts +45 -0
- package/dist/src/config/component/suggested-validation-summary.model.js +61 -0
- package/dist/src/config/component/suggested-validation-summary.outline.d.ts +57 -0
- package/dist/src/config/component/suggested-validation-summary.outline.js +5 -0
- package/dist/src/config/component/tab-content.model.d.ts +63 -0
- package/dist/src/config/component/tab-content.model.js +77 -0
- package/dist/src/config/component/tab-content.outline.d.ts +98 -0
- package/dist/src/config/component/tab-content.outline.js +8 -0
- package/dist/src/config/component/tab-nav-button.model.d.ts +45 -0
- package/dist/src/config/component/tab-nav-button.model.js +55 -0
- package/dist/src/config/component/tab-nav-button.outline.d.ts +70 -0
- package/dist/src/config/component/tab-nav-button.outline.js +6 -0
- package/dist/src/config/component/tab.model.d.ts +71 -0
- package/dist/src/config/component/tab.model.js +84 -0
- package/dist/src/config/component/tab.outline.d.ts +112 -0
- package/dist/src/config/component/tab.outline.js +9 -0
- package/dist/src/config/component/text-area.model.d.ts +63 -0
- package/dist/src/config/component/text-area.model.js +76 -0
- package/dist/src/config/component/text-area.outline.d.ts +87 -0
- package/dist/src/config/component/text-area.outline.js +8 -0
- package/dist/src/config/component/typeahead-input.model.d.ts +83 -0
- package/dist/src/config/component/typeahead-input.model.js +97 -0
- package/dist/src/config/component/typeahead-input.outline.d.ts +199 -0
- package/dist/src/config/component/typeahead-input.outline.js +10 -0
- package/dist/src/config/component/validation-summary.model.d.ts +42 -0
- package/dist/src/config/component/validation-summary.model.js +60 -0
- package/dist/src/config/component/validation-summary.outline.d.ts +63 -0
- package/dist/src/config/component/validation-summary.outline.js +6 -0
- package/dist/src/config/dictionary.model.d.ts +648 -0
- package/dist/src/config/dictionary.model.js +181 -0
- package/dist/src/config/dictionary.outline.d.ts +96 -0
- package/dist/src/config/dictionary.outline.js +3 -0
- package/dist/src/config/field-component.model.d.ts +7 -0
- package/dist/src/config/field-component.model.js +11 -0
- package/dist/src/config/field-component.outline.d.ts +20 -0
- package/dist/src/config/field-component.outline.js +3 -0
- package/dist/src/config/field-layout.model.d.ts +19 -0
- package/dist/src/config/field-layout.model.js +23 -0
- package/dist/src/config/field-layout.outline.d.ts +42 -0
- package/dist/src/config/field-layout.outline.js +3 -0
- package/dist/src/config/field-model.model.d.ts +21 -0
- package/dist/src/config/field-model.model.js +24 -0
- package/dist/src/config/field-model.outline.d.ts +63 -0
- package/dist/src/config/field-model.outline.js +3 -0
- package/dist/src/config/field.model.d.ts +12 -0
- package/dist/src/config/field.model.js +12 -0
- package/dist/src/config/field.outline.d.ts +19 -0
- package/dist/src/config/field.outline.js +3 -0
- package/dist/src/config/form-behaviour.outline.d.ts +128 -0
- package/dist/src/config/form-behaviour.outline.js +40 -0
- package/dist/src/config/form-component.model.d.ts +38 -0
- package/dist/src/config/form-component.model.js +36 -0
- package/dist/src/config/form-component.outline.d.ts +305 -0
- package/dist/src/config/form-component.outline.js +27 -0
- package/dist/src/config/form-config.model.d.ts +33 -0
- package/dist/src/config/form-config.model.js +36 -0
- package/dist/src/config/form-config.outline.d.ts +111 -0
- package/dist/src/config/form-config.outline.js +3 -0
- package/dist/src/config/form-override.model.d.ts +146 -0
- package/dist/src/config/form-override.model.js +1523 -0
- package/dist/src/config/form-override.outline.d.ts +15 -0
- package/dist/src/config/form-override.outline.js +3 -0
- package/dist/src/config/form-prehydrate.outline.d.ts +17 -0
- package/dist/src/config/form-prehydrate.outline.js +5 -0
- package/dist/src/config/form-types.model.d.ts +6 -0
- package/dist/src/config/form-types.model.js +23 -0
- package/dist/src/config/form-types.outline.d.ts +48 -0
- package/dist/src/config/form-types.outline.js +137 -0
- package/dist/src/config/helpers.d.ts +31 -0
- package/dist/src/config/helpers.js +122 -0
- package/dist/src/config/names/naming-helpers.d.ts +112 -0
- package/dist/src/config/names/naming-helpers.js +188 -0
- package/dist/src/config/names/query-helpers.d.ts +43 -0
- package/dist/src/config/names/query-helpers.js +59 -0
- package/dist/src/config/shared.outline.d.ts +54 -0
- package/dist/src/config/shared.outline.js +41 -0
- package/dist/src/config/visitor/base.model.d.ts +143 -0
- package/dist/src/config/visitor/base.model.js +336 -0
- package/dist/src/config/visitor/base.outline.d.ts +146 -0
- package/dist/src/config/visitor/base.outline.js +3 -0
- package/dist/src/config/visitor/common.model.d.ts +119 -0
- package/dist/src/config/visitor/common.model.js +422 -0
- package/dist/src/date-format-helpers.d.ts +1 -0
- package/dist/src/date-format-helpers.js +21 -0
- package/dist/src/handlebars-helpers.d.ts +258 -0
- package/dist/src/handlebars-helpers.js +715 -0
- package/dist/src/html-helpers.d.ts +15 -0
- package/dist/src/html-helpers.js +42 -0
- package/dist/src/index.d.ts +118 -3
- package/dist/src/index.js +127 -2
- package/dist/src/jsonata-helpers.d.ts +40 -0
- package/dist/src/jsonata-helpers.js +118 -0
- package/dist/src/logger.interface.d.ts +14 -0
- package/dist/src/logger.interface.js +3 -0
- package/dist/src/record.model.d.ts +23 -0
- package/dist/src/record.model.js +19 -1
- package/dist/src/report.model.d.ts +46 -0
- package/dist/src/status.model.d.ts +22 -0
- package/dist/src/status.model.js +28 -0
- package/dist/src/template.outline.d.ts +82 -0
- package/dist/src/template.outline.js +14 -0
- package/dist/src/translation-helpers.d.ts +26 -0
- package/dist/src/translation-helpers.js +71 -0
- package/dist/src/validation/form.model.d.ts +306 -24
- package/dist/src/validation/form.model.js +29 -1
- package/dist/src/validation/helpers.d.ts +15 -7
- package/dist/src/validation/helpers.js +49 -13
- package/dist/src/validation/validators-support.d.ts +39 -2
- package/dist/src/validation/validators-support.js +162 -12
- package/dist/src/validation/validators.d.ts +28 -0
- package/dist/src/validation/validators.js +531 -0
- package/package.json +51 -34
- package/LICENSE +0 -674
- package/dist/src/validation/index.d.ts +0 -3
- package/dist/src/validation/index.js +0 -20
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormStatus = exports.FormFieldComponentStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The status of a component.
|
|
6
|
+
*/
|
|
7
|
+
var FormFieldComponentStatus;
|
|
8
|
+
(function (FormFieldComponentStatus) {
|
|
9
|
+
FormFieldComponentStatus["INIT"] = "INIT";
|
|
10
|
+
FormFieldComponentStatus["INIT_VIEW_READY"] = "INIT_VIEW_READY";
|
|
11
|
+
FormFieldComponentStatus["READY"] = "READY";
|
|
12
|
+
FormFieldComponentStatus["BUSY"] = "BUSY";
|
|
13
|
+
FormFieldComponentStatus["ERROR"] = "ERROR";
|
|
14
|
+
})(FormFieldComponentStatus || (exports.FormFieldComponentStatus = FormFieldComponentStatus = {}));
|
|
15
|
+
/**
|
|
16
|
+
* The status of a form.
|
|
17
|
+
*/
|
|
18
|
+
var FormStatus;
|
|
19
|
+
(function (FormStatus) {
|
|
20
|
+
FormStatus["INIT"] = "INIT";
|
|
21
|
+
FormStatus["READY"] = "READY";
|
|
22
|
+
FormStatus["SAVING"] = "SAVING";
|
|
23
|
+
FormStatus["DELETING"] = "DELETING";
|
|
24
|
+
FormStatus["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
25
|
+
FormStatus["LOAD_ERROR"] = "LOAD_ERROR";
|
|
26
|
+
FormStatus["VALIDATION_PENDING"] = "VALIDATION_PENDING";
|
|
27
|
+
})(FormStatus || (exports.FormStatus = FormStatus = {}));
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhdHVzLm1vZGVsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N0YXR1cy5tb2RlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7R0FFRztBQUNILElBQVksd0JBTVg7QUFORCxXQUFZLHdCQUF3QjtJQUNsQyx5Q0FBYSxDQUFBO0lBQ2IsK0RBQW1DLENBQUE7SUFDbkMsMkNBQWUsQ0FBQTtJQUNmLHlDQUFhLENBQUE7SUFDYiwyQ0FBZSxDQUFBO0FBQ2pCLENBQUMsRUFOVyx3QkFBd0Isd0NBQXhCLHdCQUF3QixRQU1uQztBQUNEOztHQUVHO0FBQ0gsSUFBWSxVQVFYO0FBUkQsV0FBWSxVQUFVO0lBQ3BCLDJCQUFhLENBQUE7SUFDYiw2QkFBZSxDQUFBO0lBQ2YsK0JBQWlCLENBQUE7SUFDakIsbUNBQXFCLENBQUE7SUFDckIsbURBQXFDLENBQUE7SUFDckMsdUNBQXlCLENBQUE7SUFDekIsdURBQXlDLENBQUE7QUFDM0MsQ0FBQyxFQVJXLFVBQVUsMEJBQVYsVUFBVSxRQVFyQiJ9
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LineagePath } from "./config/names/naming-helpers";
|
|
2
|
+
export declare const templateCompileKind: readonly ["jsonata", "handlebars"];
|
|
3
|
+
export type TemplateCompileKind = typeof templateCompileKind[number];
|
|
4
|
+
export type TemplateCompileKey = LineagePath;
|
|
5
|
+
export type TemplateCompileKeyFormatted = string;
|
|
6
|
+
export type TemplateCompileValue = string;
|
|
7
|
+
/**
|
|
8
|
+
* One compile mapping builder input or output.
|
|
9
|
+
*/
|
|
10
|
+
export interface TemplateCompileItem {
|
|
11
|
+
/**
|
|
12
|
+
* The key to access the compiled value in the output mapping.
|
|
13
|
+
*
|
|
14
|
+
* Must be unique across all inputs for one call to the compiled mapping builder.
|
|
15
|
+
*/
|
|
16
|
+
key: TemplateCompileKey;
|
|
17
|
+
/**
|
|
18
|
+
* The value string in either the raw form or the compiled form.
|
|
19
|
+
*/
|
|
20
|
+
value: TemplateCompileValue;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One input to the compile mapping builder.
|
|
24
|
+
*/
|
|
25
|
+
export interface TemplateCompileInput extends TemplateCompileItem {
|
|
26
|
+
/**
|
|
27
|
+
* The kind indicates the format of the value.
|
|
28
|
+
*/
|
|
29
|
+
kind: TemplateCompileKind;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a string key that can be used on the server and client.
|
|
33
|
+
* @param key The array of names and indexes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildKeyString(key: TemplateCompileKey): TemplateCompileKeyFormatted;
|
|
36
|
+
/**
|
|
37
|
+
* The form config lineage path to use as the key for selecting the compiled template.
|
|
38
|
+
*/
|
|
39
|
+
export type DynamicScriptResponseEvaluateKey = TemplateCompileKey;
|
|
40
|
+
/**
|
|
41
|
+
* Context to pass to the template evaluator.
|
|
42
|
+
*/
|
|
43
|
+
export type DynamicScriptResponseEvaluateContext = unknown;
|
|
44
|
+
/**
|
|
45
|
+
* Provide the template library evaluator functions.
|
|
46
|
+
*/
|
|
47
|
+
export type DynamicScriptResponseEvaluateExtra = {
|
|
48
|
+
libraries?: {
|
|
49
|
+
jsonata?: Function;
|
|
50
|
+
handlebars?: Function;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The result of evaluating the template.
|
|
56
|
+
*/
|
|
57
|
+
export type DynamicScriptResponseEvaluateResult = unknown;
|
|
58
|
+
/**
|
|
59
|
+
* The evaluator function provided by the server to the client.
|
|
60
|
+
*/
|
|
61
|
+
export type DynamicScriptResponseEvaluate = (
|
|
62
|
+
/**
|
|
63
|
+
* The form config lineage path to use as the key for selecting the compiled template.
|
|
64
|
+
*/
|
|
65
|
+
key: DynamicScriptResponseEvaluateKey,
|
|
66
|
+
/**
|
|
67
|
+
* Context to pass to the template evaluator.
|
|
68
|
+
*/
|
|
69
|
+
context: DynamicScriptResponseEvaluateContext,
|
|
70
|
+
/**
|
|
71
|
+
* Provide the template library evaluator functions.
|
|
72
|
+
*/
|
|
73
|
+
extra?: DynamicScriptResponseEvaluateExtra) => DynamicScriptResponseEvaluateResult;
|
|
74
|
+
/**
|
|
75
|
+
* The type of the dynamic script asset response after import.
|
|
76
|
+
*/
|
|
77
|
+
export interface DynamicScriptResponse {
|
|
78
|
+
/**
|
|
79
|
+
* The evaluator function provided by the server to the client.
|
|
80
|
+
*/
|
|
81
|
+
evaluate: DynamicScriptResponseEvaluate;
|
|
82
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.templateCompileKind = void 0;
|
|
4
|
+
exports.buildKeyString = buildKeyString;
|
|
5
|
+
const naming_helpers_1 = require("./config/names/naming-helpers");
|
|
6
|
+
exports.templateCompileKind = ["jsonata", "handlebars"];
|
|
7
|
+
/**
|
|
8
|
+
* Build a string key that can be used on the server and client.
|
|
9
|
+
* @param key The array of names and indexes.
|
|
10
|
+
*/
|
|
11
|
+
function buildKeyString(key) {
|
|
12
|
+
return (key ?? [])?.map(i => (0, naming_helpers_1.normaliseVisual)(i))?.join('__');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVtcGxhdGUub3V0bGluZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZW1wbGF0ZS5vdXRsaW5lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQXlDQSx3Q0FFQztBQTNDRCxrRUFBMkU7QUFFOUQsUUFBQSxtQkFBbUIsR0FBRyxDQUFDLFNBQVMsRUFBRSxZQUFZLENBQVUsQ0FBQztBQW1DdEU7OztHQUdHO0FBQ0gsU0FBZ0IsY0FBYyxDQUFDLEdBQXVCO0lBQ2xELE9BQU8sQ0FBQyxHQUFHLElBQUksRUFBRSxDQUFDLEVBQUUsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsSUFBQSxnQ0FBZSxFQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQ2pFLENBQUMifQ==
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guess at whether the key is a natural language string.
|
|
3
|
+
* This is useful for translating only keys that are likely to be translation codes.
|
|
4
|
+
*
|
|
5
|
+
* TODO: The long-term goal is to have everything specify if it is natural langauge or translation code,
|
|
6
|
+
* to remove the need for this method.
|
|
7
|
+
*
|
|
8
|
+
* @param key The string to guess as natual language or not.
|
|
9
|
+
* @return True if the key is likely natural language and not a translation key.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isLikelyNaturalLanguage(key: string | null | undefined): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Guess at the parts of a full name.
|
|
14
|
+
*
|
|
15
|
+
* TODO: This is best-effort only, and is likely to be incorrect.
|
|
16
|
+
* The long-term goal is to not have to guess at names.
|
|
17
|
+
* This is needed while some form fields prompt for full names and others need parts of names.
|
|
18
|
+
*
|
|
19
|
+
* @param value Guess at the parts of this full name.
|
|
20
|
+
* @return Object with guessed values for full, first, and last names.
|
|
21
|
+
*/
|
|
22
|
+
export declare function guessNameParts(value: string): {
|
|
23
|
+
full: string;
|
|
24
|
+
first: string;
|
|
25
|
+
last: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLikelyNaturalLanguage = isLikelyNaturalLanguage;
|
|
4
|
+
exports.guessNameParts = guessNameParts;
|
|
5
|
+
/**
|
|
6
|
+
* Guess at whether the key is a natural language string.
|
|
7
|
+
* This is useful for translating only keys that are likely to be translation codes.
|
|
8
|
+
*
|
|
9
|
+
* TODO: The long-term goal is to have everything specify if it is natural langauge or translation code,
|
|
10
|
+
* to remove the need for this method.
|
|
11
|
+
*
|
|
12
|
+
* @param key The string to guess as natual language or not.
|
|
13
|
+
* @return True if the key is likely natural language and not a translation key.
|
|
14
|
+
*/
|
|
15
|
+
function isLikelyNaturalLanguage(key) {
|
|
16
|
+
const value = String(key ?? "").trim();
|
|
17
|
+
const containsSpace = value.includes(' ');
|
|
18
|
+
const startsCapitalLetter = value.length > 0 ? value[0].toLowerCase() !== value[0] : false;
|
|
19
|
+
// An empty string is not natural language.
|
|
20
|
+
// Treat default conversion of object to string as not natural language.
|
|
21
|
+
// Likely a translation code if contains '{{' or '}}'.
|
|
22
|
+
// Likely a translation code if starts with '@' and no spaces and does not start with a capital letter.
|
|
23
|
+
// Likely a translation code if contains '_' and no spaces and does not start with a capital letter.
|
|
24
|
+
if (!value ||
|
|
25
|
+
value.includes('[object Object]') ||
|
|
26
|
+
value.includes('{{') || value.includes('}}') ||
|
|
27
|
+
(value.startsWith('@') && !containsSpace && !startsCapitalLetter) ||
|
|
28
|
+
(value.includes('_') && !containsSpace && !startsCapitalLetter)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// Likely natural language if contains a space or starts with a capital letter.
|
|
32
|
+
if (containsSpace || startsCapitalLetter) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
// Likely a translation code if contains any of ':', '{', '}'.
|
|
36
|
+
if (value.includes(':') ||
|
|
37
|
+
value.includes('{') ||
|
|
38
|
+
value.includes('}')) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
// Otherwise, be conservative and say the translation key is not natural language.
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Guess at the parts of a full name.
|
|
46
|
+
*
|
|
47
|
+
* TODO: This is best-effort only, and is likely to be incorrect.
|
|
48
|
+
* The long-term goal is to not have to guess at names.
|
|
49
|
+
* This is needed while some form fields prompt for full names and others need parts of names.
|
|
50
|
+
*
|
|
51
|
+
* @param value Guess at the parts of this full name.
|
|
52
|
+
* @return Object with guessed values for full, first, and last names.
|
|
53
|
+
*/
|
|
54
|
+
function guessNameParts(value) {
|
|
55
|
+
let full = String(value ?? "").replace(/\s+/g, ' ').trim(), first = '', last = '';
|
|
56
|
+
if (!full) {
|
|
57
|
+
return { full, first, last };
|
|
58
|
+
}
|
|
59
|
+
// If there are no spaces, assume this is the last name.
|
|
60
|
+
if (!full.includes(' ')) {
|
|
61
|
+
last = full;
|
|
62
|
+
return { full, first, last };
|
|
63
|
+
}
|
|
64
|
+
// If there are spaces, assume the first 'word' is the first name, and the rest is the last name.
|
|
65
|
+
const words = full.split(' ').filter(w => !!w?.trim());
|
|
66
|
+
full = words.join(' ');
|
|
67
|
+
first = words[0];
|
|
68
|
+
last = words.slice(1).join(' ');
|
|
69
|
+
return { full, first, last };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNsYXRpb24taGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90cmFuc2xhdGlvbi1oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBVUEsMERBcUNDO0FBWUQsd0NBcUJDO0FBaEZEOzs7Ozs7Ozs7R0FTRztBQUNILFNBQWdCLHVCQUF1QixDQUFDLEdBQThCO0lBQ3BFLE1BQU0sS0FBSyxHQUFHLE1BQU0sQ0FBQyxHQUFHLElBQUksRUFBRSxDQUFDLENBQUMsSUFBSSxFQUFFLENBQUM7SUFFdkMsTUFBTSxhQUFhLEdBQUcsS0FBSyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUMxQyxNQUFNLG1CQUFtQixHQUFHLEtBQUssQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUMsV0FBVyxFQUFFLEtBQUssS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUM7SUFFM0YsMkNBQTJDO0lBQzNDLHdFQUF3RTtJQUN4RSxzREFBc0Q7SUFDdEQsdUdBQXVHO0lBQ3ZHLG9HQUFvRztJQUNwRyxJQUNFLENBQUMsS0FBSztRQUNOLEtBQUssQ0FBQyxRQUFRLENBQUMsaUJBQWlCLENBQUM7UUFDakMsS0FBSyxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsSUFBSSxLQUFLLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQztRQUM1QyxDQUFDLEtBQUssQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxhQUFhLElBQUksQ0FBQyxtQkFBbUIsQ0FBQztRQUNqRSxDQUFDLEtBQUssQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxhQUFhLElBQUksQ0FBQyxtQkFBbUIsQ0FBQyxFQUMvRCxDQUFDO1FBQ0QsT0FBTyxLQUFLLENBQUM7SUFDZixDQUFDO0lBRUQsK0VBQStFO0lBQy9FLElBQUksYUFBYSxJQUFJLG1CQUFtQixFQUFFLENBQUM7UUFDekMsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBRUQsOERBQThEO0lBQzlELElBQ0UsS0FBSyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUM7UUFDbkIsS0FBSyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUM7UUFDbkIsS0FBSyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsRUFDbkIsQ0FBQztRQUNELE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQztJQUVELGtGQUFrRjtJQUNsRixPQUFPLEtBQUssQ0FBQztBQUNmLENBQUM7QUFFRDs7Ozs7Ozs7O0dBU0c7QUFDSCxTQUFnQixjQUFjLENBQUMsS0FBYTtJQUMxQyxJQUFJLElBQUksR0FBRyxNQUFNLENBQUMsS0FBSyxJQUFJLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQUUsR0FBRyxDQUFDLENBQUMsSUFBSSxFQUFFLEVBQ3hELEtBQUssR0FBRyxFQUFFLEVBQ1YsSUFBSSxHQUFFLEVBQUUsQ0FBQztJQUVYLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUNWLE9BQU8sRUFBQyxJQUFJLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBQyxDQUFDO0lBQzdCLENBQUM7SUFFRCx3REFBd0Q7SUFDeEQsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUFDLEVBQUMsQ0FBQztRQUN2QixJQUFJLEdBQUcsSUFBSSxDQUFDO1FBQ1osT0FBTyxFQUFDLElBQUksRUFBRSxLQUFLLEVBQUUsSUFBSSxFQUFDLENBQUM7SUFDN0IsQ0FBQztJQUVELGlHQUFpRztJQUNqRyxNQUFNLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQztJQUN2RCxJQUFJLEdBQUcsS0FBSyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUN2QixLQUFLLEdBQUcsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBQ2pCLElBQUksR0FBRyxLQUFLLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUNoQyxPQUFPLEVBQUMsSUFBSSxFQUFFLEtBQUssRUFBRSxJQUFJLEVBQUMsQ0FBQztBQUM3QixDQUFDIn0=
|
|
@@ -1,41 +1,323 @@
|
|
|
1
|
+
import { LineagePath, LineagePaths, LineagePathsPartial } from "../config/names/naming-helpers";
|
|
2
|
+
/**
|
|
3
|
+
* The parameters for a validator error.
|
|
4
|
+
* The parameters are different for each validator.
|
|
5
|
+
*
|
|
6
|
+
* These can be used with the translation message id to create the translated text.
|
|
7
|
+
*
|
|
8
|
+
* For example:
|
|
9
|
+
* {actual: 2, requiredThreshold: 3}
|
|
10
|
+
*/
|
|
11
|
+
export type FormValidatorErrorParams = {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The map of validation errors.
|
|
16
|
+
*
|
|
17
|
+
* Typically, has a property that is the validation class, e.g. 'min', and
|
|
18
|
+
* value is a dictionary of message and params that are arbitrary values
|
|
19
|
+
* that can be used to render an error message template.
|
|
20
|
+
*
|
|
21
|
+
* This is similar to FormValidatorComponentErrors, but with the class as the key in a parent object.
|
|
22
|
+
*
|
|
23
|
+
* This is similar to the angular form ValidationErrors type (type ValidationErrors = { [key: string]: any;}).
|
|
24
|
+
*/
|
|
1
25
|
export type FormValidatorErrors = {
|
|
2
26
|
[key: string]: {
|
|
3
27
|
message: string;
|
|
4
|
-
params:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
28
|
+
params: FormValidatorErrorParams;
|
|
29
|
+
/**
|
|
30
|
+
* The validator class.
|
|
31
|
+
*
|
|
32
|
+
* Only set when the error key differs from the class, which happens when the same
|
|
33
|
+
* validator class is used more than once on a control. In that case the key is made
|
|
34
|
+
* unique so Angular's error merging keeps every instance, while this property carries
|
|
35
|
+
* the real class for display.
|
|
36
|
+
*/
|
|
37
|
+
class?: string;
|
|
38
|
+
} & FormValidatorTargetField;
|
|
8
39
|
};
|
|
9
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The map of validator config.
|
|
42
|
+
* The config is different for each validator.
|
|
43
|
+
*/
|
|
44
|
+
export type FormValidatorCreateConfig = {
|
|
45
|
+
class?: string;
|
|
46
|
+
message?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The key to use for this validator's entry in the merged errors object.
|
|
49
|
+
*
|
|
50
|
+
* Defaults to the class. Set to a unique value when the same class is used more than
|
|
51
|
+
* once on a control, so Angular's error merging does not overwrite earlier instances.
|
|
52
|
+
*
|
|
53
|
+
* @internal - This field is managed automatically by the framework. Do not set it
|
|
54
|
+
* manually in form configuration; doing so will produce an error key that does not
|
|
55
|
+
* match the validator class, breaking the display recovery in
|
|
56
|
+
* `getFormValidatorComponentErrors`.
|
|
57
|
+
*/
|
|
58
|
+
errorKey?: string;
|
|
10
59
|
[key: string]: unknown;
|
|
11
|
-
};
|
|
12
|
-
|
|
60
|
+
} & FormValidatorTargetField;
|
|
61
|
+
/**
|
|
62
|
+
* The interface that a form control must implement to be validated by a validator function.
|
|
63
|
+
* Some form controls are a collection of controls, these must provide a way to access the controls they contain.
|
|
64
|
+
*
|
|
65
|
+
* This is similar to the angular AbstractControl class, with only the properties needed for validation.
|
|
66
|
+
*
|
|
67
|
+
* @see https://angular.dev/api/forms/AbstractControl
|
|
68
|
+
*/
|
|
69
|
+
export interface FormValidatorControl {
|
|
70
|
+
/**
|
|
71
|
+
* The value of the control.
|
|
72
|
+
* @see https://angular.dev/api/forms/AbstractControl#value
|
|
73
|
+
*/
|
|
74
|
+
value: unknown;
|
|
75
|
+
/**
|
|
76
|
+
* Get the descendant control that matches the path.
|
|
77
|
+
* @see https://angular.dev/api/forms/AbstractControl#get
|
|
78
|
+
* @param path
|
|
79
|
+
*/
|
|
80
|
+
get<P extends string | LineagePath>(path: P): FormValidatorControl | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A simple form validator control that can be used on the server-side to mimic client-side controls.
|
|
84
|
+
*
|
|
85
|
+
* Do not use this on the client-side.
|
|
86
|
+
*/
|
|
87
|
+
export declare class SimpleServerFormValidatorControl implements FormValidatorControl {
|
|
13
88
|
value: unknown;
|
|
14
|
-
|
|
15
|
-
|
|
89
|
+
constructor(value: unknown);
|
|
90
|
+
get<P extends string | LineagePath>(path: P): FormValidatorControl | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The validator function.
|
|
94
|
+
*
|
|
95
|
+
* Accepts an AbstractControl and returns either validation errors or no errors (null).
|
|
96
|
+
*
|
|
97
|
+
* This is similar to the angular form ValidatorFn interface.
|
|
98
|
+
*/
|
|
99
|
+
export interface FormValidatorFn {
|
|
100
|
+
(control: FormValidatorControl): FormValidatorErrors | null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The asynchronous validation function.
|
|
104
|
+
*
|
|
105
|
+
* Accepts an AbstractControl and returns a promise that resolves with either validation errors or no errors (null).
|
|
106
|
+
*
|
|
107
|
+
* This is similar to the angular form AsyncValidatorFn interface.
|
|
108
|
+
*/
|
|
109
|
+
export interface FormAsyncValidatorFn {
|
|
110
|
+
(control: FormValidatorControl): Promise<FormValidatorErrors | null>;
|
|
111
|
+
}
|
|
112
|
+
export type FormValidatorFns = {
|
|
113
|
+
syncDefs: FormValidatorFn[];
|
|
114
|
+
asyncDefs: FormAsyncValidatorFn[];
|
|
16
115
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
116
|
+
/**
|
|
117
|
+
* The validation function creator.
|
|
118
|
+
*
|
|
119
|
+
* Takes one config argument, which contains config for the specific validator.
|
|
120
|
+
*
|
|
121
|
+
* Returns a form validator function.
|
|
122
|
+
*/
|
|
123
|
+
export type FormValidatorCreateFn = (config: FormValidatorCreateConfig | null | undefined) => FormValidatorFn;
|
|
124
|
+
/**
|
|
125
|
+
* The asynchronous validation function creator.
|
|
126
|
+
*
|
|
127
|
+
* Takes one config argument, which contains config for the specific validator.
|
|
128
|
+
*
|
|
129
|
+
* Returns a form async validator function.
|
|
130
|
+
*/
|
|
131
|
+
export type FormAsyncValidatorCreateFn = (config: FormValidatorCreateConfig | null | undefined) => FormAsyncValidatorFn;
|
|
132
|
+
/**
|
|
133
|
+
* The definition of a validator for a form or a form control, with no create function.
|
|
134
|
+
*/
|
|
135
|
+
export interface FormBaseValidatorDefinition {
|
|
136
|
+
/**
|
|
137
|
+
* The unique name of the form validator.
|
|
138
|
+
*/
|
|
139
|
+
class: string;
|
|
140
|
+
/**
|
|
141
|
+
* The message id to display when the validator fails.
|
|
142
|
+
*/
|
|
21
143
|
message: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The definition of a validator for a form or a form control.
|
|
147
|
+
*/
|
|
148
|
+
export interface FormSyncValidatorDefinition extends FormBaseValidatorDefinition {
|
|
149
|
+
/**
|
|
150
|
+
* The validation function creator.
|
|
151
|
+
*/
|
|
22
152
|
create: FormValidatorCreateFn;
|
|
23
153
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
154
|
+
/**
|
|
155
|
+
* The definition of an async validator for a form or a form control.
|
|
156
|
+
*/
|
|
157
|
+
export interface FormAsyncValidatorDefinition extends FormBaseValidatorDefinition {
|
|
158
|
+
/**
|
|
159
|
+
* The async validation function creator.
|
|
160
|
+
*/
|
|
161
|
+
createAsync: FormAsyncValidatorCreateFn;
|
|
28
162
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
163
|
+
/**
|
|
164
|
+
* The definition of a validator for a form or a form control.
|
|
165
|
+
*/
|
|
166
|
+
export type FormValidatorDefinition = FormSyncValidatorDefinition | FormAsyncValidatorDefinition;
|
|
167
|
+
/**
|
|
168
|
+
* The configuration block for a validator for a form or a form control.
|
|
169
|
+
*/
|
|
170
|
+
export interface FormValidatorConfig {
|
|
171
|
+
/**
|
|
172
|
+
* The 'class' key used to reference one validator definition.
|
|
173
|
+
* The optional message and config will be applied to the validator definition with this class.
|
|
174
|
+
*/
|
|
175
|
+
class: string;
|
|
176
|
+
/**
|
|
177
|
+
* The optional message id to display when the validator fails.
|
|
178
|
+
* This is only needed if the message to show is different to the validator definition.
|
|
179
|
+
*/
|
|
180
|
+
message?: string;
|
|
181
|
+
/**
|
|
182
|
+
* The optional validator config.
|
|
183
|
+
* Can be left out if the validator takes no config.
|
|
184
|
+
*/
|
|
185
|
+
config?: FormValidatorCreateConfig;
|
|
186
|
+
/**
|
|
187
|
+
* Zero or more validation group names this validator belongs to.
|
|
188
|
+
*
|
|
189
|
+
* Validation groups make it easier to run a subset of validators on a form.
|
|
190
|
+
* The validator will be enabled if any of the groups it is part of are enabled.
|
|
191
|
+
*
|
|
192
|
+
* Note that a validation group with 'initialMembership: "all"' will include all validators (that aren't excluded),
|
|
193
|
+
* even if the validators do not include the group name.
|
|
194
|
+
*/
|
|
195
|
+
groups?: FormFieldValidationGroup;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Allows specifying a field to 'own' any validation failures.
|
|
199
|
+
*/
|
|
200
|
+
export interface FormValidatorTargetField {
|
|
201
|
+
/**
|
|
202
|
+
* Lineage paths to a target field that will 'own' any validation failures.
|
|
203
|
+
*/
|
|
204
|
+
targetField?: LineagePathsPartial;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Form-level validator config that allows specifying a field to 'own' any validation failures.
|
|
208
|
+
*/
|
|
209
|
+
export interface FormValidatorTargetFieldConfig extends FormValidatorConfig, FormValidatorTargetField {
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* One validator error.
|
|
213
|
+
*/
|
|
214
|
+
export interface FormValidatorComponentErrors extends FormValidatorTargetField {
|
|
215
|
+
/**
|
|
216
|
+
* The message id for the validator.
|
|
217
|
+
*/
|
|
218
|
+
message: string;
|
|
219
|
+
/**
|
|
220
|
+
* The class of the validator.
|
|
221
|
+
*/
|
|
222
|
+
class: string;
|
|
223
|
+
/**
|
|
224
|
+
* The params for rendering the translated message.
|
|
225
|
+
*/
|
|
226
|
+
params: FormValidatorErrorParams;
|
|
35
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Form or form control errors from a validator.
|
|
230
|
+
*
|
|
231
|
+
* Controls can be nested, so validation errors can be nested.
|
|
232
|
+
* The nesting is how the client-side is able to reveal a form field when
|
|
233
|
+
* a link in the validation summary is clicked.
|
|
234
|
+
*
|
|
235
|
+
* If all errors arrays are empty, then the validation summary is treated as 'form is valid'.
|
|
236
|
+
*/
|
|
36
237
|
export interface FormValidatorSummaryErrors {
|
|
238
|
+
/**
|
|
239
|
+
* The id of the form control.
|
|
240
|
+
*
|
|
241
|
+
* This is used on the client-side for linking to the form control to reveal it.
|
|
242
|
+
* If this is not available, the validation error is rendered with the form field label and with no link.
|
|
243
|
+
*/
|
|
37
244
|
id: string | null;
|
|
245
|
+
/**
|
|
246
|
+
* The message id for the form control label.
|
|
247
|
+
*
|
|
248
|
+
* This is passed to the translation service to get the label text.
|
|
249
|
+
* If this is not available, the id is used, otherwise a default label is used.
|
|
250
|
+
*/
|
|
38
251
|
message: string | null;
|
|
252
|
+
/**
|
|
253
|
+
* The validation errors for the form control.
|
|
254
|
+
*
|
|
255
|
+
* These are rendered using the translation service - the message id can use the params to calculate the text to show.
|
|
256
|
+
* If there are no errors, then the form field is not shown in the error summary.
|
|
257
|
+
*/
|
|
39
258
|
errors: FormValidatorComponentErrors[];
|
|
40
|
-
|
|
259
|
+
/**
|
|
260
|
+
* The lineage paths to this form control.
|
|
261
|
+
*
|
|
262
|
+
* This enables revealing the parents, to be able to navigate to the form control.
|
|
263
|
+
*/
|
|
264
|
+
lineagePaths: LineagePaths;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Form validation groups, where the key is the name, and the value is the definition.
|
|
268
|
+
*/
|
|
269
|
+
export interface FormValidationGroups {
|
|
270
|
+
/**
|
|
271
|
+
* The key is the name of the validation group.
|
|
272
|
+
*/
|
|
273
|
+
[key: string]: FormValidationGroup;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* A form validation group,
|
|
277
|
+
* which describes the purpose or usage of the group and the initial membership of the group.
|
|
278
|
+
*/
|
|
279
|
+
export interface FormValidationGroup {
|
|
280
|
+
/**
|
|
281
|
+
* A short description of the purpose or usage of the validation group.
|
|
282
|
+
*/
|
|
283
|
+
description: string;
|
|
284
|
+
/**
|
|
285
|
+
* The approach this validation group uses to specify which validators are included.
|
|
286
|
+
*
|
|
287
|
+
* Default is "none".
|
|
288
|
+
*/
|
|
289
|
+
initialMembership?: FormValidationGroupMembership;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* The available form validation group membership approaches.
|
|
293
|
+
*
|
|
294
|
+
* Options:
|
|
295
|
+
* - 'all': Every known / available validator.
|
|
296
|
+
* - 'none': An empty array / no validators.
|
|
297
|
+
*/
|
|
298
|
+
export declare const formValidationGroupMembership: readonly ["all", "none"];
|
|
299
|
+
/**
|
|
300
|
+
* The type for the available form validation group membership approaches.
|
|
301
|
+
*/
|
|
302
|
+
export type FormValidationGroupMembership = typeof formValidationGroupMembership[number];
|
|
303
|
+
/**
|
|
304
|
+
* Specify the validation groups to include or exclude.
|
|
305
|
+
* All the validation groups used here must also be present in the form top-level validationGroups property.
|
|
306
|
+
* The groups will be added or removed from some list of validation groups.
|
|
307
|
+
*/
|
|
308
|
+
export interface FormFieldValidationGroup {
|
|
309
|
+
/**
|
|
310
|
+
* A list of the validation groups to include / add / enable.
|
|
311
|
+
*
|
|
312
|
+
* Default is empty array.
|
|
313
|
+
* Use when a validator should be included in a group with initial membership of none.
|
|
314
|
+
*/
|
|
315
|
+
include?: string[];
|
|
316
|
+
/**
|
|
317
|
+
* A list of the validation groups to exclude / remove / disable.
|
|
318
|
+
*
|
|
319
|
+
* Default is empty array.
|
|
320
|
+
* Use when a validator should be excluded from a group with initial membership of all.
|
|
321
|
+
*/
|
|
322
|
+
exclude?: string[];
|
|
41
323
|
}
|
|
@@ -1,3 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.formValidationGroupMembership = exports.SimpleServerFormValidatorControl = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
/**
|
|
6
|
+
* A simple form validator control that can be used on the server-side to mimic client-side controls.
|
|
7
|
+
*
|
|
8
|
+
* Do not use this on the client-side.
|
|
9
|
+
*/
|
|
10
|
+
class SimpleServerFormValidatorControl {
|
|
11
|
+
value;
|
|
12
|
+
constructor(value) {
|
|
13
|
+
this.value = value;
|
|
14
|
+
}
|
|
15
|
+
get(path) {
|
|
16
|
+
const result = (0, lodash_1.get)(this.value, path) ?? null;
|
|
17
|
+
// For debugging:
|
|
18
|
+
// console.debug(`SimpleServerFormValidatorControl.get path ${JSON.stringify(path)} with result ${JSON.stringify(result)} from value ${JSON.stringify(this.value)}`);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.SimpleServerFormValidatorControl = SimpleServerFormValidatorControl;
|
|
23
|
+
/**
|
|
24
|
+
* The available form validation group membership approaches.
|
|
25
|
+
*
|
|
26
|
+
* Options:
|
|
27
|
+
* - 'all': Every known / available validator.
|
|
28
|
+
* - 'none': An empty array / no validators.
|
|
29
|
+
*/
|
|
30
|
+
exports.formValidationGroupMembership = ["all", "none"];
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS5tb2RlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy92YWxpZGF0aW9uL2Zvcm0ubW9kZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsbUNBQXFDO0FBdUZyQzs7OztHQUlHO0FBQ0gsTUFBYSxnQ0FBZ0M7SUFDekMsS0FBSyxDQUFVO0lBRWYsWUFBWSxLQUFjO1FBQ3RCLElBQUksQ0FBQyxLQUFLLEdBQUcsS0FBSyxDQUFDO0lBQ3ZCLENBQUM7SUFFRCxHQUFHLENBQWlDLElBQU87UUFDdkMsTUFBTSxNQUFNLEdBQUcsSUFBQSxZQUFJLEVBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSxJQUFJLENBQUMsSUFBSSxJQUFJLENBQUM7UUFFOUMsaUJBQWlCO1FBQ2pCLHFLQUFxSztRQUVySyxPQUFPLE1BQU0sQ0FBQztJQUNsQixDQUFDO0NBQ0o7QUFmRCw0RUFlQztBQXNORDs7Ozs7O0dBTUc7QUFDVSxRQUFBLDZCQUE2QixHQUFHLENBQUMsS0FBSyxFQUFFLE1BQU0sQ0FBVSxDQUFDIn0=
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FormValidatorCreateConfig, FormValidatorErrorParams, FormValidatorErrors } from "./form.model";
|
|
2
|
+
/**
|
|
3
|
+
* Extract the length property in case it's an array or a string.
|
|
4
|
+
* Extract the size property in case it's a set.
|
|
5
|
+
* Return null else.
|
|
6
|
+
* @param value Either an array, set or undefined.
|
|
7
|
+
*/
|
|
2
8
|
export declare function formValidatorLengthOrSize(value: null | string | unknown[] | Set<unknown> | unknown): number | null;
|
|
3
|
-
export declare function formValidatorGetDefinitionItem(config:
|
|
4
|
-
export declare function formValidatorGetDefinitionString(config:
|
|
5
|
-
export declare function formValidatorGetDefinitionNumber(config:
|
|
6
|
-
export declare function formValidatorGetDefinitionBoolean(config:
|
|
7
|
-
export declare function formValidatorGetDefinitionRegexp(config:
|
|
8
|
-
export declare function formValidatorGetDefinitionArray(config:
|
|
9
|
+
export declare function formValidatorGetDefinitionItem(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: unknown): unknown;
|
|
10
|
+
export declare function formValidatorGetDefinitionString(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: string | undefined): string;
|
|
11
|
+
export declare function formValidatorGetDefinitionNumber(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: string | undefined): number;
|
|
12
|
+
export declare function formValidatorGetDefinitionBoolean(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: boolean | undefined): boolean;
|
|
13
|
+
export declare function formValidatorGetDefinitionRegexp(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: RegExp | undefined): RegExp;
|
|
14
|
+
export declare function formValidatorGetDefinitionArray(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: unknown[] | undefined): unknown[];
|
|
15
|
+
export declare function formValidatorGetDefinitionObject(config: FormValidatorCreateConfig | null | undefined, key: string, defaultValue?: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
16
|
+
export declare function formValidatorBuildError(config: FormValidatorCreateConfig | null | undefined, params?: FormValidatorErrorParams): FormValidatorErrors;
|