@ngx-formbar/core 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/fesm2022/ngx-formbar-core.mjs +2429 -0
- package/fesm2022/ngx-formbar-core.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/form/ngxfb-form.component.d.ts +28 -0
- package/lib/composables/computed-value.d.ts +8 -0
- package/lib/composables/disabled.state.d.ts +36 -0
- package/lib/composables/dynamic-label.d.ts +9 -0
- package/lib/composables/dynamic-title.d.ts +9 -0
- package/lib/composables/hidden.state.d.ts +68 -0
- package/lib/composables/readonly.state.d.ts +19 -0
- package/lib/composables/testId.d.ts +16 -0
- package/lib/composables/update-strategy.d.ts +20 -0
- package/lib/composables/validators.d.ts +22 -0
- package/lib/config/config.d.ts +7 -0
- package/lib/config/provide-formbar.d.ts +38 -0
- package/lib/directives/ngxfb-abstract-control.directive.d.ts +53 -0
- package/lib/directives/ngxfb-block.directive.d.ts +124 -0
- package/lib/directives/ngxfb-control.directive.d.ts +203 -0
- package/lib/directives/ngxfb-group.directive.d.ts +253 -0
- package/lib/helper/control-container-view-providers.d.ts +33 -0
- package/lib/index.d.ts +23 -0
- package/lib/services/component-registration.service.d.ts +8 -0
- package/lib/services/configuration.service.d.ts +8 -0
- package/lib/services/expression.service.d.ts +148 -0
- package/lib/services/form.service.d.ts +10 -0
- package/lib/services/validator-registration.service.d.ts +10 -0
- package/lib/tokens/component-registrations.d.ts +2 -0
- package/lib/tokens/component-resolver.d.ts +3 -0
- package/lib/tokens/default-update-strategy.d.ts +3 -0
- package/lib/tokens/global-config.d.ts +5 -0
- package/lib/tokens/validator-registrations.d.ts +8 -0
- package/lib/tokens/validator-resolver.d.ts +3 -0
- package/lib/types/component-resolver.type.d.ts +4 -0
- package/lib/types/content.type.d.ts +137 -0
- package/lib/types/expression.type.d.ts +2 -0
- package/lib/types/form.type.d.ts +4 -0
- package/lib/types/functions.type.d.ts +4 -0
- package/lib/types/global-configuration.type.d.ts +4 -0
- package/lib/types/provide.type.d.ts +42 -0
- package/lib/types/registration.type.d.ts +18 -0
- package/lib/types/validation.type.d.ts +59 -0
- package/lib/types/validator-resolver.type.d.ts +6 -0
- package/package.json +52 -0
- package/public-api.d.ts +1 -0
- package/schematics/block/files/__componentName@dasherize__.component.html.template +1 -0
- package/schematics/block/files/__componentName@dasherize__.component.ts.template +29 -0
- package/schematics/block/files/__interfaceName@dasherize__.type.ts.template +6 -0
- package/schematics/block/index.d.ts +3 -0
- package/schematics/block/index.js +11 -0
- package/schematics/block/index.js.map +1 -0
- package/schematics/block/schema.json +62 -0
- package/schematics/collection.json +31 -0
- package/schematics/control/files/__componentName@dasherize__.component.html.template +0 -0
- package/schematics/control/files/__componentName@dasherize__.component.ts.template +29 -0
- package/schematics/control/files/__interfaceName@dasherize__.type.ts.template +6 -0
- package/schematics/control/index.d.ts +3 -0
- package/schematics/control/index.js +11 -0
- package/schematics/control/index.js.map +1 -0
- package/schematics/control/schema.json +61 -0
- package/schematics/group/files/__componentName@dasherize__.component.html.template +5 -0
- package/schematics/group/files/__componentName@dasherize__.component.ts.template +29 -0
- package/schematics/group/files/__interfaceName@dasherize__.type.ts.template +5 -0
- package/schematics/group/index.d.ts +3 -0
- package/schematics/group/index.js +11 -0
- package/schematics/group/index.js.map +1 -0
- package/schematics/group/schema.json +62 -0
- package/schematics/ng-add/files/config-registrations/async-validator-registrations.ts.template +4 -0
- package/schematics/ng-add/files/config-registrations/component-registrations.ts.template +4 -0
- package/schematics/ng-add/files/config-registrations/index.ts.template +3 -0
- package/schematics/ng-add/files/config-registrations/validator-registrations.ts.template +4 -0
- package/schematics/ng-add/files/helper/block.host-directive.ts.template +6 -0
- package/schematics/ng-add/files/helper/control.host-directive.ts.template +6 -0
- package/schematics/ng-add/files/helper/group.host-directive.ts.template +6 -0
- package/schematics/ng-add/files/helper/index.ts.template +4 -0
- package/schematics/ng-add/files/helper/view-provider.ts.template +9 -0
- package/schematics/ng-add/files/provider-config/config/__providerConfigFileName__.ts.template +9 -0
- package/schematics/ng-add/files/provider-config/inline/__providerConfigFileName__.ts.template +8 -0
- package/schematics/ng-add/files/provider-config/token/__providerConfigFileName__.ts.template +4 -0
- package/schematics/ng-add/files/schematics-config/__schematicConfigFileName__.json.template +1 -0
- package/schematics/ng-add/files/token-registrations/async-validator-registrations.ts.template +8 -0
- package/schematics/ng-add/files/token-registrations/component-registrations.ts.template +8 -0
- package/schematics/ng-add/files/token-registrations/index.ts.template +3 -0
- package/schematics/ng-add/files/token-registrations/validator-registrations.ts.template +8 -0
- package/schematics/ng-add/helper.d.ts +11 -0
- package/schematics/ng-add/helper.js +198 -0
- package/schematics/ng-add/helper.js.map +1 -0
- package/schematics/ng-add/index.d.ts +3 -0
- package/schematics/ng-add/index.js +68 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/rules/create-config-registration-files.rule.d.ts +3 -0
- package/schematics/ng-add/rules/create-config-registration-files.rule.js +32 -0
- package/schematics/ng-add/rules/create-config-registration-files.rule.js.map +1 -0
- package/schematics/ng-add/rules/create-formbar-registration-config.rule.d.ts +3 -0
- package/schematics/ng-add/rules/create-formbar-registration-config.rule.js +30 -0
- package/schematics/ng-add/rules/create-formbar-registration-config.rule.js.map +1 -0
- package/schematics/ng-add/rules/create-helper-files.rule.d.ts +6 -0
- package/schematics/ng-add/rules/create-helper-files.rule.js +22 -0
- package/schematics/ng-add/rules/create-helper-files.rule.js.map +1 -0
- package/schematics/ng-add/rules/create-schematics-config.rule.d.ts +3 -0
- package/schematics/ng-add/rules/create-schematics-config.rule.js +42 -0
- package/schematics/ng-add/rules/create-schematics-config.rule.js.map +1 -0
- package/schematics/ng-add/rules/create-token-registration-files.rule.d.ts +3 -0
- package/schematics/ng-add/rules/create-token-registration-files.rule.js +32 -0
- package/schematics/ng-add/rules/create-token-registration-files.rule.js.map +1 -0
- package/schematics/ng-add/rules/include-templates.rule.d.ts +3 -0
- package/schematics/ng-add/rules/include-templates.rule.js +11 -0
- package/schematics/ng-add/rules/include-templates.rule.js.map +1 -0
- package/schematics/ng-add/rules/install-dependencies.rule.d.ts +2 -0
- package/schematics/ng-add/rules/install-dependencies.rule.js +12 -0
- package/schematics/ng-add/rules/install-dependencies.rule.js.map +1 -0
- package/schematics/ng-add/rules/update-app-config.rule.d.ts +3 -0
- package/schematics/ng-add/rules/update-app-config.rule.js +48 -0
- package/schematics/ng-add/rules/update-app-config.rule.js.map +1 -0
- package/schematics/ng-add/rules/update-schematics-config.rule.d.ts +6 -0
- package/schematics/ng-add/rules/update-schematics-config.rule.js +28 -0
- package/schematics/ng-add/rules/update-schematics-config.rule.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +23 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +81 -0
- package/schematics/register/component-info.type.d.ts +11 -0
- package/schematics/register/component-info.type.js +3 -0
- package/schematics/register/component-info.type.js.map +1 -0
- package/schematics/register/discover-components.d.ts +19 -0
- package/schematics/register/discover-components.js +267 -0
- package/schematics/register/discover-components.js.map +1 -0
- package/schematics/register/index.d.ts +3 -0
- package/schematics/register/index.js +49 -0
- package/schematics/register/index.js.map +1 -0
- package/schematics/register/register-components.d.ts +3 -0
- package/schematics/register/register-components.js +38 -0
- package/schematics/register/register-components.js.map +1 -0
- package/schematics/register/schema.d.ts +14 -0
- package/schematics/register/schema.js +3 -0
- package/schematics/register/schema.js.map +1 -0
- package/schematics/register/schema.json +44 -0
- package/schematics/shared/ast/decorators.d.ts +9 -0
- package/schematics/shared/ast/decorators.js +182 -0
- package/schematics/shared/ast/decorators.js.map +1 -0
- package/schematics/shared/ast/imports.d.ts +3 -0
- package/schematics/shared/ast/imports.js +93 -0
- package/schematics/shared/ast/imports.js.map +1 -0
- package/schematics/shared/ast/parse.d.ts +3 -0
- package/schematics/shared/ast/parse.js +17 -0
- package/schematics/shared/ast/parse.js.map +1 -0
- package/schematics/shared/ast/registrations.d.ts +22 -0
- package/schematics/shared/ast/registrations.js +654 -0
- package/schematics/shared/ast/registrations.js.map +1 -0
- package/schematics/shared/ast/types.d.ts +3 -0
- package/schematics/shared/ast/types.js +58 -0
- package/schematics/shared/ast/types.js.map +1 -0
- package/schematics/shared/file.d.ts +4 -0
- package/schematics/shared/file.js +60 -0
- package/schematics/shared/file.js.map +1 -0
- package/schematics/shared/helper.d.ts +2 -0
- package/schematics/shared/helper.js +29 -0
- package/schematics/shared/helper.js.map +1 -0
- package/schematics/shared/rules/create-component.rule.d.ts +3 -0
- package/schematics/shared/rules/create-component.rule.js +15 -0
- package/schematics/shared/rules/create-component.rule.js.map +1 -0
- package/schematics/shared/rules/register-control.rule.d.ts +3 -0
- package/schematics/shared/rules/register-control.rule.js +30 -0
- package/schematics/shared/rules/register-control.rule.js.map +1 -0
- package/schematics/shared/rules/register-type-map.rule.d.ts +3 -0
- package/schematics/shared/rules/register-type-map.rule.js +46 -0
- package/schematics/shared/rules/register-type-map.rule.js.map +1 -0
- package/schematics/shared/rules/register-type-token.rule.d.ts +3 -0
- package/schematics/shared/rules/register-type-token.rule.js +49 -0
- package/schematics/shared/rules/register-type-token.rule.js.map +1 -0
- package/schematics/shared/rules/scaffold-and-register.rule.d.ts +3 -0
- package/schematics/shared/rules/scaffold-and-register.rule.js +134 -0
- package/schematics/shared/rules/scaffold-and-register.rule.js.map +1 -0
- package/schematics/shared/schema.d.ts +32 -0
- package/schematics/shared/schema.js +3 -0
- package/schematics/shared/schema.js.map +1 -0
- package/schematics/tests/generators.spec.d.ts +1 -0
- package/schematics/tests/generators.spec.js +450 -0
- package/schematics/tests/generators.spec.js.map +1 -0
- package/schematics/tests/helper.d.ts +20 -0
- package/schematics/tests/helper.js +275 -0
- package/schematics/tests/helper.js.map +1 -0
- package/schematics/tests/ng-add.spec.d.ts +1 -0
- package/schematics/tests/ng-add.spec.js +380 -0
- package/schematics/tests/ng-add.spec.js.map +1 -0
- package/schematics/tests/register.spec.d.ts +1 -0
- package/schematics/tests/register.spec.js +340 -0
- package/schematics/tests/register.spec.js.map +1 -0
- package/schematics/tests/workspace-setup.d.ts +21 -0
- package/schematics/tests/workspace-setup.js +255 -0
- package/schematics/tests/workspace-setup.js.map +1 -0
- package/shared/ast.d.ts +10 -0
- package/shared/ast.js +93 -0
- package/shared/ast.js.map +1 -0
- package/shared/constants.d.ts +16 -0
- package/shared/constants.js +20 -0
- package/shared/constants.js.map +1 -0
- package/shared/shared-config.type.d.ts +20 -0
- package/shared/shared-config.type.js +3 -0
- package/shared/shared-config.type.js.map +1 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const vitest_1 = require("vitest");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const workspace_setup_1 = require("./workspace-setup");
|
|
15
|
+
const helper_1 = require("./helper");
|
|
16
|
+
const find_module_1 = require("@schematics/angular/utility/find-module");
|
|
17
|
+
const registrations_1 = require("../shared/ast/registrations");
|
|
18
|
+
const parse_1 = require("../shared/ast/parse");
|
|
19
|
+
const imports_1 = require("../shared/ast/imports");
|
|
20
|
+
(0, vitest_1.describe)('register schematic', () => {
|
|
21
|
+
let appTree;
|
|
22
|
+
let runner;
|
|
23
|
+
const baseOptions = {
|
|
24
|
+
project: 'test-app',
|
|
25
|
+
};
|
|
26
|
+
const appConfigPathRaw = 'app.config.ts';
|
|
27
|
+
const formbarConfigPath = 'app/formbar.config.ts';
|
|
28
|
+
const schematicsConfigPath = 'app/formbar.config.json';
|
|
29
|
+
const registrationsPath = 'app/registrations/component-registrations.ts';
|
|
30
|
+
function runSchematic() {
|
|
31
|
+
return __awaiter(this, arguments, void 0, function* (options = {}) {
|
|
32
|
+
return runner.runSchematic('register', Object.assign(Object.assign({}, baseOptions), options), appTree);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
(0, vitest_1.beforeEach)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
runner = new testing_1.SchematicTestRunner('schematics', workspace_setup_1.COLLECTION_PATH);
|
|
37
|
+
appTree = yield (0, workspace_setup_1.setupWorkspace)(runner);
|
|
38
|
+
}));
|
|
39
|
+
it('finds and registers components anywhere, with and without helper', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const files = [
|
|
41
|
+
{
|
|
42
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
43
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
44
|
+
className: 'InlineComponent',
|
|
45
|
+
key: 'inline',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: (0, helper_1.app)('components/form/controls/helper.component.ts'),
|
|
49
|
+
content: (0, workspace_setup_1.createControlComponent)('helper', workspace_setup_1.helperProviders, 'HelperComponent'),
|
|
50
|
+
className: 'HelperComponent',
|
|
51
|
+
key: 'helper',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
path: (0, helper_1.app)('features/account/profile/controls/profile-inline.component.ts'),
|
|
55
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-inline', workspace_setup_1.inlineProviders, 'ProfileInlineComponent'),
|
|
56
|
+
className: 'ProfileInlineComponent',
|
|
57
|
+
key: 'profile-inline',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
path: (0, helper_1.app)('features/account/profile/controls/profile-helper.component.ts'),
|
|
61
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'ProfileHelperComponent'),
|
|
62
|
+
className: 'ProfileHelperComponent',
|
|
63
|
+
key: 'profile-helper',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
path: (0, helper_1.app)('root-inline.component.ts'),
|
|
67
|
+
content: (0, workspace_setup_1.createControlComponent)('root-inline', workspace_setup_1.inlineProviders, 'RootInlineComponent'),
|
|
68
|
+
className: 'RootInlineComponent',
|
|
69
|
+
key: 'root-inline',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
path: (0, helper_1.app)('root-helper.component.ts'),
|
|
73
|
+
content: (0, workspace_setup_1.createControlComponent)('root-helper', workspace_setup_1.helperProviders, 'RootHelperComponent'),
|
|
74
|
+
className: 'RootHelperComponent',
|
|
75
|
+
key: 'root-helper',
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
79
|
+
(0, workspace_setup_1.provideToken)(appTree, appConfigPathRaw, registrationsPath);
|
|
80
|
+
const tree = yield runSchematic();
|
|
81
|
+
assertRegisteredComponents(tree, files, (0, helper_1.src)(registrationsPath), registrations_1.componentRegistrationsMapProviderHasIdentifier);
|
|
82
|
+
}));
|
|
83
|
+
it('ignores invalid components', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const files = [
|
|
85
|
+
{
|
|
86
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
87
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
88
|
+
className: 'InlineComponent',
|
|
89
|
+
key: 'inline',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
path: (0, helper_1.app)('components/form/controls/helper.component.ts'),
|
|
93
|
+
content: (0, workspace_setup_1.createUnrelatedComponent)('helper', 'HelperComponent'),
|
|
94
|
+
className: 'HelperComponent',
|
|
95
|
+
key: 'helper',
|
|
96
|
+
shouldRegister: false,
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
100
|
+
(0, workspace_setup_1.provideToken)(appTree, appConfigPathRaw, registrationsPath);
|
|
101
|
+
const tree = yield runSchematic();
|
|
102
|
+
assertRegisteredComponents(tree, files, (0, helper_1.src)(registrationsPath), registrations_1.componentRegistrationsMapProviderHasIdentifier);
|
|
103
|
+
}));
|
|
104
|
+
it('respects exclude pattern', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
const files = [
|
|
106
|
+
{
|
|
107
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
108
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
109
|
+
className: 'InlineComponent',
|
|
110
|
+
key: 'inline',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: (0, helper_1.app)('components/form/controls/helper.component.ts'),
|
|
114
|
+
content: (0, workspace_setup_1.createControlComponent)('helper', workspace_setup_1.helperProviders, 'HelperComponent'),
|
|
115
|
+
className: 'HelperComponent',
|
|
116
|
+
key: 'helper',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
path: (0, helper_1.app)('features/account/profile/controls/profile-inline.component.ts'),
|
|
120
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-inline', workspace_setup_1.inlineProviders, 'ProfileInlineComponent'),
|
|
121
|
+
className: 'ProfileInlineComponent',
|
|
122
|
+
key: 'profile-inline',
|
|
123
|
+
shouldRegister: false,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
path: (0, helper_1.app)('features/account/profile/controls/profile-helper.component.ts'),
|
|
127
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'ProfileHelperComponent'),
|
|
128
|
+
className: 'ProfileHelperComponent',
|
|
129
|
+
key: 'profile-helper',
|
|
130
|
+
shouldRegister: false,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
path: (0, helper_1.app)('features/login/controls/password-input.component.ts'),
|
|
134
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'PasswordInputComponent'),
|
|
135
|
+
className: 'PasswordInputComponent',
|
|
136
|
+
key: 'password-input',
|
|
137
|
+
shouldRegister: false,
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
141
|
+
(0, workspace_setup_1.provideToken)(appTree, appConfigPathRaw, registrationsPath);
|
|
142
|
+
const tree = yield runSchematic({
|
|
143
|
+
exclude: ['**/account/**', (0, helper_1.app)('features/login/controls/**')],
|
|
144
|
+
});
|
|
145
|
+
assertRegisteredComponents(tree, files, (0, helper_1.src)(registrationsPath), registrations_1.componentRegistrationsMapProviderHasIdentifier);
|
|
146
|
+
}));
|
|
147
|
+
it('respects exclude pattern', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
const files = [
|
|
149
|
+
{
|
|
150
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
151
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
152
|
+
className: 'InlineComponent',
|
|
153
|
+
key: 'inline',
|
|
154
|
+
shouldRegister: false,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
path: (0, helper_1.app)('components/form/controls/helper.component.ts'),
|
|
158
|
+
content: (0, workspace_setup_1.createControlComponent)('helper', workspace_setup_1.helperProviders, 'HelperComponent'),
|
|
159
|
+
className: 'HelperComponent',
|
|
160
|
+
key: 'helper',
|
|
161
|
+
shouldRegister: false,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
path: (0, helper_1.app)('features/account/profile/controls/profile-inline.component.ts'),
|
|
165
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-inline', workspace_setup_1.inlineProviders, 'ProfileInlineComponent'),
|
|
166
|
+
className: 'ProfileInlineComponent',
|
|
167
|
+
key: 'profile-inline',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
path: (0, helper_1.app)('features/account/profile/controls/profile-helper.component.ts'),
|
|
171
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'ProfileHelperComponent'),
|
|
172
|
+
className: 'ProfileHelperComponent',
|
|
173
|
+
key: 'profile-helper',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
path: (0, helper_1.app)('features/login/controls/password-input.component.ts'),
|
|
177
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'PasswordInputComponent'),
|
|
178
|
+
className: 'PasswordInputComponent',
|
|
179
|
+
key: 'password-input',
|
|
180
|
+
shouldRegister: false,
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
184
|
+
(0, workspace_setup_1.provideToken)(appTree, appConfigPathRaw, registrationsPath);
|
|
185
|
+
const tree = yield runSchematic({
|
|
186
|
+
include: ['**/account/**'],
|
|
187
|
+
});
|
|
188
|
+
assertRegisteredComponents(tree, files, (0, helper_1.src)(registrationsPath), registrations_1.componentRegistrationsMapProviderHasIdentifier);
|
|
189
|
+
}));
|
|
190
|
+
it('registers components with the same name safely', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
const files = [
|
|
192
|
+
{
|
|
193
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
194
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
195
|
+
className: 'InlineComponent',
|
|
196
|
+
key: 'inline',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
path: (0, helper_1.app)('features/account/profile/controls/inline.component.ts'),
|
|
200
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
201
|
+
className: 'InlineComponent',
|
|
202
|
+
key: 'inline',
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
206
|
+
(0, workspace_setup_1.provideToken)(appTree, appConfigPathRaw, registrationsPath);
|
|
207
|
+
const tree = yield runSchematic();
|
|
208
|
+
const componentRegistrationsSf = (0, parse_1.parseTS)((0, helper_1.read)(tree, (0, helper_1.src)(registrationsPath)));
|
|
209
|
+
const controlsImportPath = (0, find_module_1.buildRelativePath)((0, helper_1.src)(registrationsPath), (0, helper_1.app)('components/form/controls/inline.component.ts')).replace('.ts', '');
|
|
210
|
+
const featureImportPath = (0, find_module_1.buildRelativePath)((0, helper_1.src)(registrationsPath), (0, helper_1.app)('features/account/profile/controls/inline.component.ts')).replace('.ts', '');
|
|
211
|
+
const controlImportCount = (0, helper_1.countNamedImport)(componentRegistrationsSf, controlsImportPath, 'InlineComponent');
|
|
212
|
+
const featureImportCount = (0, helper_1.countNamedImport)(componentRegistrationsSf, featureImportPath, 'InlineComponent');
|
|
213
|
+
const registrationsCount = (0, helper_1.countComponentRegistrationsMapProviderIdentifier)(componentRegistrationsSf, 'inline', 'InlineComponent');
|
|
214
|
+
(0, vitest_1.expect)(controlImportCount).toBe(1);
|
|
215
|
+
(0, vitest_1.expect)(featureImportCount).toBe(0);
|
|
216
|
+
(0, vitest_1.expect)(registrationsCount).toBe(1);
|
|
217
|
+
}));
|
|
218
|
+
it('does not duplicate registrations, if user already registered component under different key', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
|
+
const files = [
|
|
220
|
+
{
|
|
221
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
222
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
223
|
+
className: 'InlineComponent',
|
|
224
|
+
key: 'inline',
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
228
|
+
const controlsImportPath = (0, find_module_1.buildRelativePath)((0, helper_1.src)(registrationsPath), (0, helper_1.app)('components/form/controls/inline.component.ts')).replace('.ts', '');
|
|
229
|
+
(0, workspace_setup_1.provideToken)(appTree, appConfigPathRaw, registrationsPath, '["some-key", InlineComponent]', `import { InlineComponent } from '${controlsImportPath}'`);
|
|
230
|
+
const tree = yield runSchematic();
|
|
231
|
+
const componentRegistrationsSf = (0, parse_1.parseTS)((0, helper_1.read)(tree, (0, helper_1.src)(registrationsPath)));
|
|
232
|
+
const controlImportCount = (0, helper_1.countNamedImport)(componentRegistrationsSf, controlsImportPath, 'InlineComponent');
|
|
233
|
+
const newRegistrationsCount = (0, helper_1.countComponentRegistrationsMapProviderIdentifier)(componentRegistrationsSf, 'inline', 'InlineComponent');
|
|
234
|
+
const existingRegistrationsCount = (0, helper_1.countComponentRegistrationsMapProviderIdentifier)(componentRegistrationsSf, 'some-key', 'InlineComponent');
|
|
235
|
+
(0, vitest_1.expect)(controlImportCount).toBe(1);
|
|
236
|
+
(0, vitest_1.expect)(newRegistrationsCount).toBe(0);
|
|
237
|
+
(0, vitest_1.expect)(existingRegistrationsCount).toBe(1);
|
|
238
|
+
}));
|
|
239
|
+
it('uses schematics config file when passed as parameter', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
240
|
+
const files = [
|
|
241
|
+
{
|
|
242
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
243
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
244
|
+
className: 'InlineComponent',
|
|
245
|
+
key: 'inline',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
path: (0, helper_1.app)('components/form/controls/helper.component.ts'),
|
|
249
|
+
content: (0, workspace_setup_1.createControlComponent)('helper', workspace_setup_1.helperProviders, 'HelperComponent'),
|
|
250
|
+
className: 'HelperComponent',
|
|
251
|
+
key: 'helper',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
path: (0, helper_1.app)('components/form/controls/secret/secret.component.ts'),
|
|
255
|
+
content: (0, workspace_setup_1.createControlComponent)('secret', workspace_setup_1.helperProviders, 'SecretComponent'),
|
|
256
|
+
className: 'SecretComponent',
|
|
257
|
+
key: 'secret',
|
|
258
|
+
shouldRegister: false,
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
path: (0, helper_1.app)('features/login/controls/password-input.component.ts'),
|
|
262
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'PasswordInputComponent'),
|
|
263
|
+
className: 'PasswordInputComponent',
|
|
264
|
+
key: 'password-input',
|
|
265
|
+
shouldRegister: false,
|
|
266
|
+
},
|
|
267
|
+
];
|
|
268
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
269
|
+
const schematicsConfig = 'configurations/formbar.config.json';
|
|
270
|
+
const nonDefaultRegistrationsPath = 'app/feature/survey/form/component-registrations.ts';
|
|
271
|
+
const config = {
|
|
272
|
+
registrationType: 'config',
|
|
273
|
+
controlRegistrationsPath: nonDefaultRegistrationsPath,
|
|
274
|
+
discovery: {
|
|
275
|
+
include: ['**/components/form/controls/**'],
|
|
276
|
+
exclude: ['**/components/form/controls/secret/**'],
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
(0, helper_1.writeJson)(appTree, (0, helper_1.src)(schematicsConfig), config);
|
|
280
|
+
(0, workspace_setup_1.provideMap)(appTree, appConfigPathRaw, nonDefaultRegistrationsPath, formbarConfigPath);
|
|
281
|
+
const tree = yield runSchematic({
|
|
282
|
+
schematicsConfig,
|
|
283
|
+
});
|
|
284
|
+
assertRegisteredComponents(tree, files, (0, helper_1.src)(nonDefaultRegistrationsPath), registrations_1.directComponentRegistrationsHasIdentifier);
|
|
285
|
+
}));
|
|
286
|
+
it('finds schematics config file if no parameter was passed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
287
|
+
const files = [
|
|
288
|
+
{
|
|
289
|
+
path: (0, helper_1.app)('components/form/controls/inline.component.ts'),
|
|
290
|
+
content: (0, workspace_setup_1.createControlComponent)('inline', workspace_setup_1.inlineProviders, 'InlineComponent'),
|
|
291
|
+
className: 'InlineComponent',
|
|
292
|
+
key: 'inline',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
path: (0, helper_1.app)('components/form/controls/helper.component.ts'),
|
|
296
|
+
content: (0, workspace_setup_1.createControlComponent)('helper', workspace_setup_1.helperProviders, 'HelperComponent'),
|
|
297
|
+
className: 'HelperComponent',
|
|
298
|
+
key: 'helper',
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
path: (0, helper_1.app)('components/form/controls/secret/secret.component.ts'),
|
|
302
|
+
content: (0, workspace_setup_1.createControlComponent)('secret', workspace_setup_1.helperProviders, 'SecretComponent'),
|
|
303
|
+
className: 'SecretComponent',
|
|
304
|
+
key: 'secret',
|
|
305
|
+
shouldRegister: false,
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
path: (0, helper_1.app)('features/login/controls/password-input.component.ts'),
|
|
309
|
+
content: (0, workspace_setup_1.createControlComponent)('profile-helper', workspace_setup_1.helperProviders, 'PasswordInputComponent'),
|
|
310
|
+
className: 'PasswordInputComponent',
|
|
311
|
+
key: 'password-input',
|
|
312
|
+
shouldRegister: false,
|
|
313
|
+
},
|
|
314
|
+
];
|
|
315
|
+
(0, workspace_setup_1.addComponentFiles)(appTree, files);
|
|
316
|
+
const config = {
|
|
317
|
+
registrationType: 'config',
|
|
318
|
+
discovery: {
|
|
319
|
+
include: ['**/components/form/controls/**'],
|
|
320
|
+
exclude: ['**/components/form/controls/secret/**'],
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
(0, helper_1.writeJson)(appTree, (0, helper_1.src)(schematicsConfigPath), config);
|
|
324
|
+
(0, workspace_setup_1.provideMap)(appTree, appConfigPathRaw, registrationsPath, formbarConfigPath);
|
|
325
|
+
const tree = yield runSchematic();
|
|
326
|
+
assertRegisteredComponents(tree, files, (0, helper_1.src)(registrationsPath), registrations_1.directComponentRegistrationsHasIdentifier);
|
|
327
|
+
}));
|
|
328
|
+
});
|
|
329
|
+
function assertRegisteredComponents(tree, files, registrationsPath, hasRegistrationFn) {
|
|
330
|
+
const componentRegistrationsSf = (0, parse_1.parseTS)((0, helper_1.read)(tree, registrationsPath));
|
|
331
|
+
(0, helper_1.forEachAtLeastOnce)(files, ({ path, className, key, shouldRegister = true }) => {
|
|
332
|
+
const componentImportPath = (0, find_module_1.buildRelativePath)(registrationsPath, path).replace('.ts', '');
|
|
333
|
+
const importsComponent = (0, imports_1.hasNamedImport)(componentRegistrationsSf, componentImportPath, className);
|
|
334
|
+
const hasRegistration = hasRegistrationFn(componentRegistrationsSf, key, className);
|
|
335
|
+
const message = `${className} - ${key} - ${shouldRegister.toString()}`;
|
|
336
|
+
(0, vitest_1.expect)(importsComponent, message).toBe(shouldRegister);
|
|
337
|
+
(0, vitest_1.expect)(hasRegistration, message).toBe(shouldRegister);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=register.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.spec.js","sourceRoot":"","sources":["../../../../projects/core/automation/schematics/tests/register.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAsD;AACtD,gEAAuF;AAEvF,uDAW2B;AAC3B,qCAQkB;AAElB,yEAA4E;AAE5E,+DAGqC;AACrC,+CAA8C;AAC9C,mDAAuD;AAGvD,IAAA,iBAAQ,EAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,OAAqB,CAAC;IAC1B,IAAI,MAA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KAAK,EACL,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,EAAE,EAAE,EAAE;QAClD,MAAM,mBAAmB,GAAG,IAAA,+BAAiB,EAC3C,iBAAiB,EACjB,IAAI,CACL,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErB,MAAM,gBAAgB,GAAG,IAAA,wBAAc,EACrC,wBAAwB,EACxB,mBAAmB,EACnB,SAAS,CACV,CAAC;QACF,MAAM,eAAe,GAAG,iBAAiB,CACvC,wBAAwB,EACxB,GAAG,EACH,SAAS,CACV,CAAC;QACF,MAAM,OAAO,GAAG,GAAG,SAAS,MAAM,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC;QACvE,IAAA,eAAM,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACvD,IAAA,eAAM,EAAC,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxD,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
2
|
+
export declare const COLLECTION_PATH: string;
|
|
3
|
+
export declare function setupWorkspace(runner: SchematicTestRunner): Promise<UnitTestTree>;
|
|
4
|
+
export declare function provideToken(appTree: UnitTestTree, appConfigPathRaw: string, registrationsPath: string, initialRegistrations?: string, initialImports?: string): void;
|
|
5
|
+
export declare function provideTokenNoSplit(appTree: UnitTestTree, appConfigPathRaw: string, initialRegistrations?: string, initialImports?: string): void;
|
|
6
|
+
export declare function provideMapInlineNoSplit(appTree: UnitTestTree, appConfigPathRaw: string, initialRegistrations?: string, initialImports?: string): void;
|
|
7
|
+
export declare function provideMap(appTree: UnitTestTree, appConfigPathRaw: string, registrationsPath: string, formbarConfigPath: string, initialRegistrations?: string, initialImports?: string): void;
|
|
8
|
+
export declare function provideMapNoSplit(appTree: UnitTestTree, appConfigPathRaw: string, formbarConfigPath: string, initialRegistrations?: string, initialImports?: string): void;
|
|
9
|
+
export declare function addHelperIndexFile(appTree: UnitTestTree, helperPath: string): void;
|
|
10
|
+
export declare function addComponentFiles(appTree: UnitTestTree, files: TestComponentDetails[]): void;
|
|
11
|
+
export declare function createControlComponent(name: string, providersAndImports: [string, string], className: string): string;
|
|
12
|
+
export type TestComponentDetails = {
|
|
13
|
+
path: string;
|
|
14
|
+
content: string;
|
|
15
|
+
className: string;
|
|
16
|
+
key: string;
|
|
17
|
+
shouldRegister?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const inlineProviders: [string, string];
|
|
20
|
+
export declare const helperProviders: [string, string];
|
|
21
|
+
export declare function createUnrelatedComponent(name: string, className: string): string;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.helperProviders = exports.inlineProviders = exports.COLLECTION_PATH = void 0;
|
|
13
|
+
exports.setupWorkspace = setupWorkspace;
|
|
14
|
+
exports.provideToken = provideToken;
|
|
15
|
+
exports.provideTokenNoSplit = provideTokenNoSplit;
|
|
16
|
+
exports.provideMapInlineNoSplit = provideMapInlineNoSplit;
|
|
17
|
+
exports.provideMap = provideMap;
|
|
18
|
+
exports.provideMapNoSplit = provideMapNoSplit;
|
|
19
|
+
exports.addHelperIndexFile = addHelperIndexFile;
|
|
20
|
+
exports.addComponentFiles = addComponentFiles;
|
|
21
|
+
exports.createControlComponent = createControlComponent;
|
|
22
|
+
exports.createUnrelatedComponent = createUnrelatedComponent;
|
|
23
|
+
const path_1 = require("path");
|
|
24
|
+
const helper_1 = require("./helper");
|
|
25
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
26
|
+
exports.COLLECTION_PATH = (0, path_1.join)(__dirname, '../../../../../dist/core/schematics/collection.json');
|
|
27
|
+
function setupWorkspace(runner) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const workspaceOptions = {
|
|
30
|
+
name: 'workspace',
|
|
31
|
+
version: '19.0.0',
|
|
32
|
+
newProjectRoot: 'projects',
|
|
33
|
+
};
|
|
34
|
+
const workspaceTree = yield runner.runExternalSchematic('@schematics/angular', 'workspace', workspaceOptions);
|
|
35
|
+
const appOptions = {
|
|
36
|
+
name: 'test-app',
|
|
37
|
+
standalone: true,
|
|
38
|
+
};
|
|
39
|
+
return yield runner.runExternalSchematic('@schematics/angular', 'application', appOptions, workspaceTree);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function provideToken(appTree, appConfigPathRaw, registrationsPath, initialRegistrations = '', initialImports = '') {
|
|
43
|
+
const appConfigContent = [
|
|
44
|
+
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';",
|
|
45
|
+
"import { provideRouter } from '@angular/router';",
|
|
46
|
+
"import { appRoutes } from './app.routes';",
|
|
47
|
+
"import { provideHttpClient } from '@angular/common/http';",
|
|
48
|
+
"import { provideFormbar } from '@ngx-formbar/core';",
|
|
49
|
+
"import { formbarConfig } from './formbar.config';",
|
|
50
|
+
"import { componentRegistrationsProvider } from './registrations';",
|
|
51
|
+
'',
|
|
52
|
+
'export const appConfig: ApplicationConfig = {',
|
|
53
|
+
' providers: [',
|
|
54
|
+
' provideZoneChangeDetection({ eventCoalescing: true }),',
|
|
55
|
+
' provideRouter(appRoutes),',
|
|
56
|
+
' provideHttpClient(),',
|
|
57
|
+
' provideFormbar(formbarConfig),',
|
|
58
|
+
' componentRegistrationsProvider,',
|
|
59
|
+
' ],',
|
|
60
|
+
'};',
|
|
61
|
+
'',
|
|
62
|
+
].join('\n');
|
|
63
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.app)(appConfigPathRaw), appConfigContent);
|
|
64
|
+
const formbarConfigContent = [
|
|
65
|
+
"import { NGX_FW_COMPONENT_REGISTRATIONS } from '@ngx-formbar/core';",
|
|
66
|
+
initialImports,
|
|
67
|
+
'',
|
|
68
|
+
'export const componentRegistrationsProvider = {',
|
|
69
|
+
' provide: NGX_FW_COMPONENT_REGISTRATIONS,',
|
|
70
|
+
` useValue: new Map([${initialRegistrations}])`,
|
|
71
|
+
'};',
|
|
72
|
+
].join('\n');
|
|
73
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.src)(registrationsPath), formbarConfigContent);
|
|
74
|
+
}
|
|
75
|
+
function provideTokenNoSplit(appTree, appConfigPathRaw, initialRegistrations = '', initialImports = '') {
|
|
76
|
+
const appConfigContent = [
|
|
77
|
+
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';",
|
|
78
|
+
"import { provideRouter } from '@angular/router';",
|
|
79
|
+
"import { appRoutes } from './app.routes';",
|
|
80
|
+
"import { provideHttpClient } from '@angular/common/http';",
|
|
81
|
+
"import { provideFormbar, NGX_FW_COMPONENT_REGISTRATIONS } from '@ngx-formbar/core';",
|
|
82
|
+
initialImports,
|
|
83
|
+
'',
|
|
84
|
+
'export const appConfig: ApplicationConfig = {',
|
|
85
|
+
' providers: [',
|
|
86
|
+
' provideZoneChangeDetection({ eventCoalescing: true }),',
|
|
87
|
+
' provideRouter(appRoutes),',
|
|
88
|
+
' provideHttpClient(),',
|
|
89
|
+
' provideFormbar(),',
|
|
90
|
+
' {',
|
|
91
|
+
' provide: NGX_FW_COMPONENT_REGISTRATIONS,',
|
|
92
|
+
` useValue: new Map([${initialRegistrations}])`,
|
|
93
|
+
' }',
|
|
94
|
+
' ],',
|
|
95
|
+
'};',
|
|
96
|
+
'',
|
|
97
|
+
].join('\n');
|
|
98
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.app)(appConfigPathRaw), appConfigContent);
|
|
99
|
+
}
|
|
100
|
+
function provideMapInlineNoSplit(appTree, appConfigPathRaw, initialRegistrations = '', initialImports = '') {
|
|
101
|
+
const content = [
|
|
102
|
+
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';",
|
|
103
|
+
"import { provideRouter } from '@angular/router';",
|
|
104
|
+
"import { appRoutes } from './app.routes';",
|
|
105
|
+
"import { provideHttpClient } from '@angular/common/http';",
|
|
106
|
+
"import { provideFormbar } from '@ngx-formbar/core';",
|
|
107
|
+
initialImports,
|
|
108
|
+
'',
|
|
109
|
+
'export const appConfig: ApplicationConfig = {',
|
|
110
|
+
' providers: [',
|
|
111
|
+
' provideZoneChangeDetection({ eventCoalescing: true }),',
|
|
112
|
+
' provideRouter(appRoutes),',
|
|
113
|
+
' provideHttpClient(),',
|
|
114
|
+
' provideFormbar({',
|
|
115
|
+
` componentRegistrations: {${initialRegistrations}}`,
|
|
116
|
+
' }),',
|
|
117
|
+
' ],',
|
|
118
|
+
'};',
|
|
119
|
+
'',
|
|
120
|
+
].join('\n');
|
|
121
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.app)(appConfigPathRaw), content);
|
|
122
|
+
}
|
|
123
|
+
function provideMap(appTree, appConfigPathRaw, registrationsPath, formbarConfigPath, initialRegistrations = '', initialImports = '') {
|
|
124
|
+
const appConfigContent = [
|
|
125
|
+
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';",
|
|
126
|
+
"import { provideRouter } from '@angular/router';",
|
|
127
|
+
"import { appRoutes } from './app.routes';",
|
|
128
|
+
"import { provideHttpClient } from '@angular/common/http';",
|
|
129
|
+
"import { provideFormbar } from '@ngx-formbar/core';",
|
|
130
|
+
"import { formbarConfig } from './formbar.config';",
|
|
131
|
+
initialImports,
|
|
132
|
+
'',
|
|
133
|
+
'export const appConfig: ApplicationConfig = {',
|
|
134
|
+
' providers: [',
|
|
135
|
+
' provideZoneChangeDetection({ eventCoalescing: true }),',
|
|
136
|
+
' provideRouter(appRoutes),',
|
|
137
|
+
' provideHttpClient(),',
|
|
138
|
+
' provideFormbar(formbarConfig),',
|
|
139
|
+
' ],',
|
|
140
|
+
'};',
|
|
141
|
+
'',
|
|
142
|
+
].join('\n');
|
|
143
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.app)(appConfigPathRaw), appConfigContent);
|
|
144
|
+
const formbarConfigContent = [
|
|
145
|
+
"import { defineFormbarConfig } from '@ngx-formbar/core';",
|
|
146
|
+
"import { componentRegistrations } from './registrations';",
|
|
147
|
+
'',
|
|
148
|
+
'export const formbarConfig = defineFormbarConfig({',
|
|
149
|
+
' componentRegistrations,',
|
|
150
|
+
'});',
|
|
151
|
+
].join('\n');
|
|
152
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.src)(formbarConfigPath), formbarConfigContent);
|
|
153
|
+
const registrationsContent = [
|
|
154
|
+
"import { ComponentRegistrationConfig } from '@ngx-formbar/core';",
|
|
155
|
+
'',
|
|
156
|
+
`export const componentRegistrations: ComponentRegistrationConfig = {${initialRegistrations}};`,
|
|
157
|
+
].join('\n');
|
|
158
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.src)(registrationsPath), registrationsContent);
|
|
159
|
+
}
|
|
160
|
+
function provideMapNoSplit(appTree, appConfigPathRaw, formbarConfigPath, initialRegistrations = '', initialImports = '') {
|
|
161
|
+
const appConfigContent = [
|
|
162
|
+
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';",
|
|
163
|
+
"import { provideRouter } from '@angular/router';",
|
|
164
|
+
"import { appRoutes } from './app.routes';",
|
|
165
|
+
"import { provideHttpClient } from '@angular/common/http';",
|
|
166
|
+
"import { provideFormbar } from '@ngx-formbar/core';",
|
|
167
|
+
"import { formbarConfig } from './formbar.config';",
|
|
168
|
+
initialImports,
|
|
169
|
+
'',
|
|
170
|
+
'export const appConfig: ApplicationConfig = {',
|
|
171
|
+
' providers: [',
|
|
172
|
+
' provideZoneChangeDetection({ eventCoalescing: true }),',
|
|
173
|
+
' provideRouter(appRoutes),',
|
|
174
|
+
' provideHttpClient(),',
|
|
175
|
+
' provideFormbar(formbarConfig),',
|
|
176
|
+
' {',
|
|
177
|
+
' provide: NGX_FW_COMPONENT_REGISTRATIONS,',
|
|
178
|
+
` useValue: new Map([${initialRegistrations}])`,
|
|
179
|
+
' }',
|
|
180
|
+
' ],',
|
|
181
|
+
'};',
|
|
182
|
+
'',
|
|
183
|
+
].join('\n');
|
|
184
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.app)(appConfigPathRaw), appConfigContent);
|
|
185
|
+
const formbarConfigContent = [
|
|
186
|
+
"import { defineFormbarConfig } from '@ngx-formbar/core';",
|
|
187
|
+
'',
|
|
188
|
+
'export const formbarConfig = defineFormbarConfig({',
|
|
189
|
+
' componentRegistrations: {},',
|
|
190
|
+
'});',
|
|
191
|
+
].join('\n');
|
|
192
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.src)(formbarConfigPath), formbarConfigContent);
|
|
193
|
+
}
|
|
194
|
+
function addHelperIndexFile(appTree, helperPath) {
|
|
195
|
+
const index = [
|
|
196
|
+
"export { ngxfbBlockHostDirective } from './block.host-directive';",
|
|
197
|
+
"export { ngxfbControlHostDirective } from './control.host-directive';",
|
|
198
|
+
"export { controlContainerViewProviders } from './control-container.view-provider';",
|
|
199
|
+
"export { ngxfbGroupHostDirective } from './group.host-directive';",
|
|
200
|
+
].join('\n');
|
|
201
|
+
(0, helper_1.writeTs)(appTree, (0, helper_1.src)(`${helperPath}/index.ts`), index);
|
|
202
|
+
}
|
|
203
|
+
function addComponentFiles(appTree, files) {
|
|
204
|
+
for (const { path, content } of files) {
|
|
205
|
+
(0, helper_1.writeTs)(appTree, path, content);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function createControlComponent(name, providersAndImports, className) {
|
|
209
|
+
const classifiedName = (0, strings_1.classify)(name);
|
|
210
|
+
const [providers, imports] = providersAndImports;
|
|
211
|
+
return `import { Component } from '@angular/core';
|
|
212
|
+
import { NgxfbControlDirective } from '@ngx-formbar/core';
|
|
213
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
214
|
+
${imports}
|
|
215
|
+
|
|
216
|
+
@Component({
|
|
217
|
+
selector: 'app-${name}-control',
|
|
218
|
+
imports: [ReactiveFormsModule],
|
|
219
|
+
templateUrl: './${name}-control.component.html',
|
|
220
|
+
${providers}
|
|
221
|
+
})
|
|
222
|
+
export class ${className} {
|
|
223
|
+
private readonly control = inject(NgxfbControlDirective<${classifiedName}Control>);
|
|
224
|
+
}
|
|
225
|
+
`;
|
|
226
|
+
}
|
|
227
|
+
exports.inlineProviders = [
|
|
228
|
+
`viewProviders: [
|
|
229
|
+
{
|
|
230
|
+
provide: ControlContainer,
|
|
231
|
+
useFactory: () => inject(ControlContainer, { skipSelf: true }),
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
hostDirectives: [
|
|
235
|
+
{
|
|
236
|
+
directive: NgxfbControlDirective,
|
|
237
|
+
inputs: ['content', 'name'],
|
|
238
|
+
}
|
|
239
|
+
],`,
|
|
240
|
+
`import { ControlContainer } from '@angular/forms';`,
|
|
241
|
+
];
|
|
242
|
+
exports.helperProviders = [
|
|
243
|
+
`viewProviders: viewProviders,
|
|
244
|
+
hostDirectives: [
|
|
245
|
+
ngxfbControlHostDirective
|
|
246
|
+
],`,
|
|
247
|
+
`import { viewProviders } from '../shared/helper';
|
|
248
|
+
import { ngxfbControlHostDirective } from '../shared/helper';`,
|
|
249
|
+
];
|
|
250
|
+
function createUnrelatedComponent(name, className) {
|
|
251
|
+
return `import { Component } from '@angular/core';
|
|
252
|
+
@Component({ selector: 'app-${name}', template: '' })
|
|
253
|
+
export class ${className} {}`;
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=workspace-setup.js.map
|