@gravitee/ui-schematics 12.11.1 → 12.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravitee/ui-schematics",
3
- "version": "12.11.1",
3
+ "version": "12.11.2",
4
4
  "description": "Gravitee.io - UI Schematics",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  limitations under the License.
16
16
 
17
17
  -->
18
- <span mat-dialog-title><%= name %> Dialog</span>
18
+ <span mat-dialog-title><%= name %></span>
19
19
 
20
20
  <mat-dialog-content>
21
21
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vel odio nec mi
@@ -1,18 +1,3 @@
1
- /*
2
- * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  /*
17
2
  * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
18
3
  *
@@ -36,20 +21,20 @@ import { HarnessLoader } from '@angular/cdk/testing';
36
21
  import { MatIconTestingModule } from '@angular/material/icon/testing';
37
22
  import { MatDialog, MatDialogModule } from '@angular/material/dialog';
38
23
 
39
- import { <%= classify(name) %>DialogHarness } from './<%= dasherize(name) %>-dialog.harness';
40
- import { <%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult } from './<%= dasherize(name) %>-dialog.component';
24
+ import { <%= classify(name) %>Harness } from './<%= dasherize(name) %>.harness';
25
+ import { <%= classify(name) %>Component, <%= classify(name) %>Data, <%= classify(name) %>Result } from './<%= dasherize(name) %>.component';
41
26
 
42
27
  @Component({
43
28
  selector: 'test-component',
44
29
  template: ``,
45
- imports: [<%= classify(name) %>DialogComponent, MatDialogModule, MatIconTestingModule],
30
+ imports: [<%= classify(name) %>Component, MatDialogModule, MatIconTestingModule],
46
31
  standalone: true,
47
32
  })
48
33
  class SpecDialogComponent {
49
34
  constructor(private readonly matDialog: MatDialog) {}
50
35
 
51
- public open(data?: <%= classify(name) %>DialogData) {
52
- return this.matDialog.open<<%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult>(<%= classify(name) %>DialogComponent, {
36
+ public open(data?: <%= classify(name) %>Data) {
37
+ return this.matDialog.open<<%= classify(name) %>Component, <%= classify(name) %>Data, <%= classify(name) %>Result>(<%= classify(name) %>Component, {
53
38
  data,
54
39
  role: 'dialog',
55
40
  id: 'test-dialog',
@@ -57,7 +42,7 @@ class SpecDialogComponent {
57
42
  }
58
43
  }
59
44
 
60
- describe('<%= classify(name) %>DialogComponent', () => {
45
+ describe('<%= classify(name) %>Component', () => {
61
46
  let fixture: ComponentFixture<SpecDialogComponent>;
62
47
  let loader: HarnessLoader;
63
48
 
@@ -74,9 +59,9 @@ describe('<%= classify(name) %>DialogComponent', () => {
74
59
  it('should open dialog', async () => {
75
60
  fixture.componentInstance.open();
76
61
 
77
- const dialog = await loader.getHarness(<%= classify(name) %>DialogHarness);
62
+ const dialog = await loader.getHarness(<%= classify(name) %>Harness);
78
63
 
79
- expect(await dialog.getTitleText()).toEqual('<%= classify(name) %> Dialog');
64
+ expect(await dialog.getTitleText()).toEqual('<%= name %>');
80
65
  expect(await dialog.getContentText()).toContain('Lorem');
81
66
  expect(await dialog.getActionsText()).toContain('My action');
82
67
  });
@@ -88,7 +73,7 @@ describe('<%= classify(name) %>DialogComponent', () => {
88
73
  .afterClosed()
89
74
  .subscribe(result => (dialogResult = result));
90
75
 
91
- const dialog = await loader.getHarness(<%= classify(name) %>DialogHarness);
76
+ const dialog = await loader.getHarness(<%= classify(name) %>Harness);
92
77
 
93
78
  await dialog.close();
94
79
  expect(dialogResult).toEqual(false);
@@ -101,7 +86,7 @@ describe('<%= classify(name) %>DialogComponent', () => {
101
86
  .afterClosed()
102
87
  .subscribe(result => (dialogResult = result));
103
88
 
104
- const dialog = await loader.getHarness(<%= classify(name) %>DialogHarness);
89
+ const dialog = await loader.getHarness(<%= classify(name) %>Harness);
105
90
 
106
91
  await dialog.confirmMyAction();
107
92
  expect(dialogResult).toEqual(true);
@@ -17,21 +17,21 @@ import { Component, Inject } from '@angular/core';
17
17
  import { MatButtonModule } from '@angular/material/button';
18
18
  import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
19
19
 
20
- export interface <%= classify(name) %>DialogData {}
20
+ export interface <%= classify(name) %>Data {}
21
21
 
22
- export type <%= classify(name) %>DialogResult = boolean;
22
+ export type <%= classify(name) %>Result = boolean;
23
23
 
24
24
  @Component({
25
- selector: '<%= dasherize(name) %>-dialog',
26
- templateUrl: './<%= dasherize(name) %>-dialog.component.html',
27
- styleUrls: ['./<%= dasherize(name) %>-dialog.component.scss'],
25
+ selector: '<%= dasherize(name) %>',
26
+ templateUrl: './<%= dasherize(name) %>.component.html',
27
+ styleUrls: ['./<%= dasherize(name) %>.component.scss'],
28
28
  standalone: true,
29
29
  imports: [MatDialogModule, MatButtonModule],
30
30
  })
31
- export class <%= classify(name) %>DialogComponent {
31
+ export class <%= classify(name) %>Component {
32
32
  constructor(
33
33
  @Inject(MAT_DIALOG_DATA)
34
- public data: <%= classify(name) %>DialogData,
35
- public dialogRef: MatDialogRef<<%= classify(name) %>DialogComponent, <%= classify(name) %>DialogResult>,
34
+ public data: <%= classify(name) %>Data,
35
+ public dialogRef: MatDialogRef<<%= classify(name) %>Component, <%= classify(name) %>Result>,
36
36
  ) {}
37
37
  }
@@ -17,13 +17,13 @@ import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular
17
17
  import { MatDialogSection } from '@angular/material/dialog/testing';
18
18
  import { MatButtonHarness } from '@angular/material/button/testing';
19
19
 
20
- export interface <%= classify(name) %>DialogHarnessOptions extends BaseHarnessFilters {}
20
+ export interface <%= classify(name) %>HarnessOptions extends BaseHarnessFilters {}
21
21
 
22
- export class <%= classify(name) %>DialogHarness extends ComponentHarness {
23
- public static readonly hostSelector = `<%= dasherize(name) %>-dialog`;
22
+ export class <%= classify(name) %>Harness extends ComponentHarness {
23
+ public static readonly hostSelector = `<%= dasherize(name) %>`;
24
24
 
25
- public static with(options: <%= classify(name) %>DialogHarnessOptions): HarnessPredicate<<%= classify(name) %>DialogHarness> {
26
- return new HarnessPredicate(<%= classify(name) %>DialogHarness, options);
25
+ public static with(options: <%= classify(name) %>HarnessOptions): HarnessPredicate<<%= classify(name) %>Harness> {
26
+ return new HarnessPredicate(<%= classify(name) %>Harness, options);
27
27
  }
28
28
 
29
29
  protected _title = this.locatorForOptional(MatDialogSection.TITLE);
@@ -19,20 +19,20 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
19
19
  import { MatIconTestingModule } from '@angular/material/icon/testing';
20
20
  import { action } from '@storybook/addon-actions';
21
21
 
22
- import { <%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult } from './<%= dasherize(name) %>-dialog.component';
22
+ import { <%= classify(name) %>Component, <%= classify(name) %>Data, <%= classify(name) %>Result } from './<%= dasherize(name) %>.component';
23
23
 
24
24
  @Component({
25
25
  selector: 'story-component',
26
26
  template: `<button id="open-dialog" (click)="open()">Open dialog</button>`,
27
- imports: [<%= classify(name) %>DialogComponent, MatDialogModule, MatIconTestingModule],
27
+ imports: [<%= classify(name) %>Component, MatDialogModule, MatIconTestingModule],
28
28
  standalone: true,
29
29
  })
30
30
  class StoryDialogComponent {
31
31
  constructor(private readonly matDialog: MatDialog) {}
32
32
 
33
- public open(data?: <%= classify(name) %>DialogData) {
33
+ public open(data?: <%= classify(name) %>Data) {
34
34
  return this.matDialog
35
- .open<<%= classify(name) %>DialogComponent, <%= classify(name) %>DialogData, <%= classify(name) %>DialogResult>(<%= classify(name) %>DialogComponent, {
35
+ .open<<%= classify(name) %>Component, <%= classify(name) %>Data, <%= classify(name) %>Result>(<%= classify(name) %>Component, {
36
36
  data,
37
37
  role: 'dialog',
38
38
  id: 'test-story-dialog',
@@ -45,7 +45,7 @@ class StoryDialogComponent {
45
45
  }
46
46
 
47
47
  export default {
48
- title: '<%= classify(name) %>DialogComponent story',
48
+ title: '<%= classify(name) %>Component story',
49
49
  component: StoryDialogComponent,
50
50
  } as Meta;
51
51
 
@@ -1,8 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createComponentForDialog = void 0;
4
+ /*
5
+ * Copyright (C) 2024 The Gravitee team (http://gravitee.io)
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const schematics_1 = require("@angular-devkit/schematics");
4
20
  const utils_1 = require("../utils");
5
21
  function createComponentForDialog(options) {
22
+ if (options.name.includes('dialog')) {
23
+ throw new schematics_1.SchematicsException('Component name should not contain "dialog". Dialog suffix will be added automatically.');
24
+ }
25
+ options.name = `${options.name}-dialog`;
6
26
  return (0, utils_1.createComponent)(options);
7
27
  }
8
28
  exports.createComponentForDialog = createComponentForDialog;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/ui-schematics/schematics/components/component-for-dialog/index.ts"],"names":[],"mappings":";;;AAiBA,oCAA2C;AAG3C,SAAgB,wBAAwB,CAAC,OAAe;IACtD,OAAO,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,4DAEC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../projects/ui-schematics/schematics/components/component-for-dialog/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2DAAuE;AAEvE,oCAA2C;AAG3C,SAAgB,wBAAwB,CAAC,OAAe;IACtD,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,gCAAmB,CAAC,wFAAwF,CAAC,CAAC;IAC1H,CAAC;IAED,OAAO,CAAC,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,SAAS,CAAC;IACxC,OAAO,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAPD,4DAOC"}