create-sitecore-jss 22.2.0-canary.34 → 22.2.0-canary.36

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.
@@ -0,0 +1,21 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { FormsModule } from '@angular/forms';
4
+ import { TranslateModule } from '@ngx-translate/core';
5
+ import { RouterModule } from '@angular/router';
6
+ import { JssModule } from '@sitecore-jss/sitecore-jss-angular';
7
+ import { NavigationItemComponent } from './navigation/navigation-item.component';
8
+
9
+ /*
10
+ This module is imported by the generated app-components.module.ts.
11
+ You can use this module to provide shared Angular components that are not
12
+ JSS components, etc to the generated module.
13
+
14
+ Don't want code generation? See ./.gitignore for instructions to turn it off.
15
+ */
16
+ @NgModule({
17
+ imports: [CommonModule, TranslateModule, RouterModule, JssModule, FormsModule],
18
+ exports: [CommonModule, TranslateModule, RouterModule, FormsModule, NavigationItemComponent],
19
+ declarations: [NavigationItemComponent],
20
+ })
21
+ export class AppComponentsSharedModule {}
@@ -2,7 +2,7 @@
2
2
 
3
3
  <ng-template #default>
4
4
  <div class="component image {{ styles }}" [attr.id]="id" *ngIf="rendering.fields; else empty">
5
- <div className="component-content">
5
+ <div class="component-content">
6
6
  <ng-container *ngIf="isEditing || !rendering.fields.TargetUrl?.value?.href; else withLink">
7
7
  <img *scImage="rendering.fields.Image" />
8
8
  </ng-container>
@@ -28,7 +28,7 @@
28
28
  </ng-template>
29
29
 
30
30
  <ng-template #empty>
31
- <div className="component image {{ styles }}">
31
+ <div class="component image {{ styles }}">
32
32
  <div class="component-content">
33
33
  <span class="is-empty-hint">Image</span>
34
34
  </div>
@@ -0,0 +1,23 @@
1
+ <li [class]="cssClasses" [ngClass]="{ active: isActive }" tabIndex="0">
2
+ <div [ngClass]="{ 'navigation-title': true, child: hasChildren }" (click)="isActive = !isActive">
3
+ <a *scLink="linkField" (click)="onClick($event)">
4
+ <ng-container *ngIf="navItemFields.NavigationTitle"
5
+ ><span *scText="navItemFields.NavigationTitle"></span
6
+ ></ng-container>
7
+ <ng-container *ngIf="!navItemFields.NavigationTitle && navItemFields.Title">
8
+ <span *scText="navItemFields.Title"></span
9
+ ></ng-container>
10
+ <ng-container *ngIf="!navItemFields.NavigationTitle && !navItemFields.Title">{{
11
+ navItemFields.DisplayName
12
+ }}</ng-container>
13
+ </a>
14
+ </div>
15
+ <ul *ngIf="hasChildren" class="clearfix">
16
+ <app-navigation-item
17
+ *ngFor="let childNavItemFields of navItemFields.Children"
18
+ [navItemFields]="childNavItemFields"
19
+ [relativeLevel]="childrenRelativeLevel"
20
+ (childLinkClickEvent)="onClick($event)"
21
+ ></app-navigation-item>
22
+ </ul>
23
+ </li>
@@ -0,0 +1,65 @@
1
+ import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
2
+ import { LinkField } from '@sitecore-jss/sitecore-jss-angular';
3
+ import { Field } from '@sitecore-jss/sitecore-jss-angular';
4
+
5
+ export interface NavItemFields {
6
+ Id: string;
7
+ DisplayName: string;
8
+ Title: Field<string>;
9
+ NavigationTitle: Field<string>;
10
+ Href: string;
11
+ Querystring: string;
12
+ Children: Array<NavItemFields>;
13
+ Styles: string[];
14
+ }
15
+
16
+ @Component({
17
+ selector: 'app-navigation-item',
18
+ templateUrl: './navigation-item.component.html',
19
+ })
20
+ export class NavigationItemComponent implements OnInit {
21
+ @Input() navItemFields: NavItemFields;
22
+ @Input() relativeLevel: number;
23
+ @Output() childLinkClickEvent: EventEmitter<Event> = new EventEmitter<Event>();
24
+ cssClasses = '';
25
+ isActive = false;
26
+ linkField = {};
27
+ childrenRelativeLevel = 0;
28
+ hasChildren = false;
29
+
30
+ constructor() {}
31
+
32
+ ngOnInit() {
33
+ this.cssClasses = `${this.navItemFields.Styles.concat('rel-level' + this.relativeLevel).join(
34
+ ' '
35
+ )}`;
36
+ this.linkField = this.getLinkField(this.navItemFields);
37
+ this.hasChildren = this.navItemFields.Children && this.navItemFields.Children.length != 0;
38
+ this.childrenRelativeLevel = this.relativeLevel + 1;
39
+ }
40
+
41
+ onClick(event: Event) {
42
+ this.childLinkClickEvent.emit(event);
43
+ }
44
+
45
+ private getLinkField = (navItemFields: NavItemFields): LinkField => ({
46
+ value: {
47
+ href: navItemFields.Href,
48
+ title: this.getLinkTitle(navItemFields),
49
+ querystring: navItemFields.Querystring,
50
+ },
51
+ });
52
+
53
+ private getLinkTitle = (navItemFields: NavItemFields): string | undefined => {
54
+ let title;
55
+ if (navItemFields.NavigationTitle?.value) {
56
+ title = navItemFields.NavigationTitle.value.toString();
57
+ } else if (navItemFields.Title?.value) {
58
+ title = navItemFields.Title.value.toString();
59
+ } else {
60
+ title = navItemFields.DisplayName;
61
+ }
62
+
63
+ return title;
64
+ };
65
+ }
@@ -0,0 +1,26 @@
1
+ <div
2
+ class="component navigation {{ styles }} {{ this.rendering.params?.GridParameters }}"
3
+ [attr.id]="id"
4
+ >
5
+ <label class="menu-mobile-navigate-wrapper">
6
+ <input
7
+ type="checkbox"
8
+ class="menu-mobile-navigate"
9
+ [checked]="isOpenMenu"
10
+ (change)="toggleMenu($event)"
11
+ />
12
+ <div class="menu-humburger"></div>
13
+ <div class="component-content">
14
+ <nav>
15
+ <ul class="clearfix">
16
+ <app-navigation-item
17
+ *ngFor="let navItemFields of rendering.fields"
18
+ [navItemFields]="navItemFields"
19
+ [relativeLevel]="baseLevel"
20
+ (childLinkClickEvent)="toggleMenu($event, false)"
21
+ ></app-navigation-item>
22
+ </ul>
23
+ </nav>
24
+ </div>
25
+ </label>
26
+ </div>
@@ -0,0 +1,44 @@
1
+ import { Component, OnInit, OnDestroy } from '@angular/core';
2
+ import { Subscription } from 'rxjs';
3
+ import { SxaComponent } from '../sxa.component';
4
+ import { JssContextService } from '../../jss-context.service';
5
+
6
+ @Component({
7
+ selector: 'app-navigation',
8
+ templateUrl: './navigation.component.html',
9
+ })
10
+ export class NavigationComponent extends SxaComponent implements OnInit, OnDestroy {
11
+ isEditing = false;
12
+ private contextSubscription: Subscription;
13
+ isOpenMenu = false;
14
+ baseLevel = 1;
15
+
16
+ constructor(private jssContext: JssContextService) {
17
+ super();
18
+ }
19
+
20
+ ngOnInit() {
21
+ super.ngOnInit();
22
+ this.contextSubscription = this.jssContext.state.subscribe((newState) => {
23
+ this.isEditing = newState.sitecore && newState.sitecore.context.pageEditing;
24
+ });
25
+ }
26
+
27
+ ngOnDestroy() {
28
+ if (this.contextSubscription) {
29
+ this.contextSubscription.unsubscribe();
30
+ }
31
+ }
32
+
33
+ toggleMenu(event: Event, flag?: boolean) {
34
+ if (event && this.isEditing) {
35
+ event.preventDefault();
36
+ }
37
+
38
+ if (flag !== undefined) {
39
+ this.isOpenMenu = flag;
40
+ }
41
+
42
+ this.isOpenMenu = !this.isOpenMenu;
43
+ }
44
+ }
@@ -0,0 +1,12 @@
1
+ <div class="component title {{ styles }}" [attr.id]="id">
2
+ <div clas="component-content">
3
+ <div class="field-title">
4
+ <ng-container *ngIf="!pageEditing; else textOnly">
5
+ <a *scLink="link"></a>
6
+ </ng-container>
7
+ </div>
8
+ </div>
9
+ <ng-template #textOnly>
10
+ <span *scText="text"></span>
11
+ </ng-template>
12
+ </div>
@@ -0,0 +1,51 @@
1
+ import { Component, OnDestroy, OnInit } from '@angular/core';
2
+ import { LinkField, SxaTitleFields, TextField } from '@sitecore-jss/sitecore-jss-angular';
3
+ import { SxaComponent } from '../sxa.component';
4
+ import { Subscription } from 'rxjs';
5
+ import { JssContextService } from '../../jss-context.service';
6
+
7
+ @Component({
8
+ selector: 'app-title',
9
+ templateUrl: './title.component.html',
10
+ })
11
+ export class TitleComponent extends SxaComponent<SxaTitleFields> implements OnInit, OnDestroy {
12
+ text: TextField;
13
+ link: LinkField;
14
+ pageEditing?: boolean;
15
+
16
+ private contextSubscription: Subscription;
17
+
18
+ constructor(private jssContext: JssContextService) {
19
+ super();
20
+ }
21
+
22
+ ngOnInit() {
23
+ super.ngOnInit();
24
+ const datasource =
25
+ this.rendering.fields?.data?.datasource || this.rendering.fields?.data?.contextItem;
26
+ this.text = datasource.field?.jsonValue;
27
+ this.link = {
28
+ value: {
29
+ href: datasource?.url?.path,
30
+ title: datasource?.field?.jsonValue?.value,
31
+ text: datasource?.field?.jsonValue?.value,
32
+ },
33
+ };
34
+ this.contextSubscription = this.jssContext.state.subscribe(({ sitecore }) => {
35
+ this.pageEditing = sitecore.context.pageEditing;
36
+ if (sitecore.context.pageState !== 'normal') {
37
+ this.link.value.querystring = `sc_site=${datasource?.url?.siteName}`;
38
+ if (!this.text?.value) {
39
+ this.text.value = 'Title field';
40
+ this.link.value.href = '#';
41
+ }
42
+ }
43
+ });
44
+ }
45
+
46
+ ngOnDestroy() {
47
+ if (this.contextSubscription) {
48
+ this.contextSubscription.unsubscribe();
49
+ }
50
+ }
51
+ }
@@ -1,4 +1,3 @@
1
- <app-navigation></app-navigation>
2
1
  <div class="{{ mainClassPageEditing }}">
3
2
  <ng-container *ngIf="state === LayoutState.Layout">
4
3
  <app-scripts></app-scripts>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "22.2.0-canary.34",
3
+ "version": "22.2.0-canary.36",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -63,5 +63,5 @@
63
63
  "ts-node": "^10.9.1",
64
64
  "typescript": "~4.9.5"
65
65
  },
66
- "gitHead": "dca02e224cc8d58c205e533f808b4cda61367617"
66
+ "gitHead": "6c05bf93afe6709e8e730a1912b5eb9be9c65881"
67
67
  }