@bloomreach/ng-sdk
Version:
Bloomreach SPA SDK for Angular
811 lines (796 loc) • 58.1 kB
JavaScript
import * as i1 from '@angular/common';
import { isPlatformBrowser, isPlatformServer, CommonModule } from '@angular/common';
import * as i1$1 from '@angular/common/http';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import * as i0 from '@angular/core';
import { Input, Component, Directive, Injectable, Optional, HostBinding, Pipe, makeStateKey, EventEmitter, PLATFORM_ID, TemplateRef, ContentChild, ViewChild, Output, Inject, NgModule } from '@angular/core';
import { isComponent, TYPE_CONTAINER_NO_MARKUP, TYPE_CONTAINER_UNORDERED_LIST, TYPE_CONTAINER_ORDERED_LIST, TYPE_CONTAINER_INLINE, TYPE_CONTAINER_ITEM_UNDEFINED, isContainerItem, isContainer, isPage, initialize, TYPE_MANAGE_CONTENT_BUTTON, TYPE_MANAGE_MENU_BUTTON } from '@bloomreach/spa-sdk';
import { BehaviorSubject, Subject, of, from } from 'rxjs';
import { filter, switchMap, take, mapTo, map } from 'rxjs/operators';
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrContainerItemUndefinedComponent {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerItemUndefinedComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.0", type: BrContainerItemUndefinedComponent, isStandalone: false, selector: "br-container-item-undefined", inputs: { component: "component" }, ngImport: i0, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n\n<div>{{ 'Component \"' + component.getType() + '\" is not defined.' }}</div>\n" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerItemUndefinedComponent, decorators: [{
type: Component,
args: [{ selector: 'br-container-item-undefined', standalone: false, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n\n<div>{{ 'Component \"' + component.getType() + '\" is not defined.' }}</div>\n" }]
}], propDecorators: { component: [{
type: Input
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrNodeDirective {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrNodeDirective, isStandalone: false, selector: "[brNode]", inputs: { component: ["brNode", "component"], template: ["brNodeTemplate", "template"] }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeDirective, decorators: [{
type: Directive,
args: [{
selector: '[brNode]',
standalone: false,
}]
}], propDecorators: { component: [{
type: Input,
args: ['brNode']
}], template: [{
type: Input,
args: ['brNodeTemplate']
}] } });
/*
* Copyright 2023-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrPageService {
constructor() {
this._mapping = {};
this.state$ = new BehaviorSubject(undefined);
}
get mapping() {
return this._mapping;
}
set mapping(mapping) {
this._mapping = mapping;
}
get node() {
return this._node;
}
set node(node) {
this._node = node;
}
get state() {
return this.state$;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrPageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrPageService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrPageService, decorators: [{
type: Injectable
}], ctorParameters: () => [] });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The brXM component.
*/
class BrComponentDirective {
constructor(container, template, node, page) {
this.container = container;
this.template = template;
this.node = node;
this.page = page;
// Constructor intentionally left empty
}
ngOnChanges(changes) {
if (!changes.component || changes.component.isFirstChange()) {
return;
}
this.ngOnDestroy();
this.ngOnInit();
}
ngOnDestroy() {
this.container.clear();
}
ngOnInit() {
const page = this.page?.state.getValue();
if (!page) {
return;
}
this.components?.forEach((component) => {
this.container.createEmbeddedView(this.page.node, {
component,
page,
$implicit: component,
template: this.template,
});
});
}
get context() {
if (this.node) {
return this.node.component;
}
return this.page?.state.getValue()?.getComponent();
}
get components() {
if (isComponent(this.component)) {
return [this.component];
}
if (!this.component) {
return this.context?.getChildren();
}
const component = this.context?.getComponent(...this.component.split('/'));
return component && [component];
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrComponentDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef, optional: true }, { token: BrNodeDirective, optional: true }, { token: BrPageService, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrComponentDirective, isStandalone: false, selector: "[brComponent]", inputs: { component: ["brComponent", "component"] }, usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrComponentDirective, decorators: [{
type: Directive,
args: [{
selector: '[brComponent]',
standalone: false,
}]
}], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef, decorators: [{
type: Optional
}] }, { type: BrNodeDirective, decorators: [{
type: Optional
}] }, { type: BrPageService, decorators: [{
type: Optional
}] }], propDecorators: { component: [{
type: Input,
args: ['brComponent']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrContainerBoxComponent {
get isPreview() {
return this.page?.isPreview();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: BrContainerBoxComponent, isStandalone: false, selector: "div.br-container-box", inputs: { component: "component", page: "page" }, host: { properties: { "class.hst-container": "this.isPreview" } }, ngImport: i0, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n@for (child of component.getChildren(); track $index) {\n<div [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</div>\n}", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: BrComponentDirective, selector: "[brComponent]", inputs: ["brComponent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerBoxComponent, decorators: [{
type: Component,
args: [{ selector: 'div.br-container-box', standalone: false, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n@for (child of component.getChildren(); track $index) {\n<div [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</div>\n}" }]
}], propDecorators: { component: [{
type: Input
}], page: [{
type: Input
}], isPreview: [{
type: HostBinding,
args: ['class.hst-container']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrContainerInlineComponent {
get isPreview() {
return this.page?.isPreview();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerInlineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: BrContainerInlineComponent, isStandalone: false, selector: "div.br-container-inline", inputs: { component: "component", page: "page" }, host: { properties: { "class.hst-container": "this.isPreview" } }, ngImport: i0, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n@for (child of component.getChildren(); track $index) {\n<span [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</span>\n}", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: BrComponentDirective, selector: "[brComponent]", inputs: ["brComponent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerInlineComponent, decorators: [{
type: Component,
args: [{ selector: 'div.br-container-inline', standalone: false, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n@for (child of component.getChildren(); track $index) {\n<span [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</span>\n}" }]
}], propDecorators: { component: [{
type: Input
}], page: [{
type: Input
}], isPreview: [{
type: HostBinding,
args: ['class.hst-container']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrContainerOrderedListComponent {
get isPreview() {
return this.page?.isPreview();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerOrderedListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: BrContainerOrderedListComponent, isStandalone: false, selector: "ol.br-container-ordered-list", inputs: { component: "component", page: "page" }, host: { properties: { "class.hst-container": "this.isPreview" } }, ngImport: i0, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n@for (child of component.getChildren(); track $index) {\n<li [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</li>\n}", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: BrComponentDirective, selector: "[brComponent]", inputs: ["brComponent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerOrderedListComponent, decorators: [{
type: Component,
args: [{ selector: 'ol.br-container-ordered-list', standalone: false, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n@for (child of component.getChildren(); track $index) {\n<li [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</li>\n}" }]
}], propDecorators: { component: [{
type: Input
}], page: [{
type: Input
}], isPreview: [{
type: HostBinding,
args: ['class.hst-container']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrContainerUnorderedListComponent {
get isPreview() {
return this.page?.isPreview();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerUnorderedListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: BrContainerUnorderedListComponent, isStandalone: false, selector: "ul.br-container-unordered-list", inputs: { component: "component", page: "page" }, host: { properties: { "class.hst-container": "this.isPreview" } }, ngImport: i0, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n\n@for (child of component.getChildren(); track $index) {\n<li [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</li>\n}", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: BrComponentDirective, selector: "[brComponent]", inputs: ["brComponent"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrContainerUnorderedListComponent, decorators: [{
type: Component,
args: [{ selector: 'ul.br-container-unordered-list', standalone: false, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n\n@for (child of component.getChildren(); track $index) {\n<li [ngClass]=\"{ 'hst-container-item': page.isPreview() }\">\n <ng-container [brComponent]=\"child\"></ng-container>\n</li>\n}" }]
}], propDecorators: { component: [{
type: Input
}], page: [{
type: Input
}], isPreview: [{
type: HostBinding,
args: ['class.hst-container']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrMetaDirective {
constructor(container, template) {
this.container = container;
this.template = template;
// Constructor intentionally left empty
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ngOnChanges(changes) {
this.clear?.();
this.container.clear();
const { head, tail } = this.render();
this.clear = head && tail && this.meta?.render(head, tail);
}
ngOnDestroy() {
this.clear?.();
this.container.clear();
}
render() {
if (!this.template) {
return {
head: this.container.element.nativeElement,
tail: this.container.element.nativeElement,
};
}
const embeddedViewRef = this.container.createEmbeddedView(this.template);
const [head] = embeddedViewRef.rootNodes;
const [tail] = embeddedViewRef.rootNodes.slice(-1);
return { head, tail };
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrMetaDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrMetaDirective, isStandalone: false, usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrMetaDirective, decorators: [{
type: Directive,
args: [{
standalone: false,
}]
}], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef, decorators: [{
type: Optional
}] }] });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrNodeComponentDirective {
constructor(container, injector, node, page) {
this.container = container;
this.injector = injector;
this.node = node;
this.page = page;
// Constructor intentionally left empty
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ngOnChanges(changes) {
this.clear?.();
this.container.clear();
const { head, tail } = this.render();
this.clear = head && tail && this.component?.getMeta()?.render(head, tail);
}
getMapping() {
return this.component && this.page.mapping[this.component.getName()];
}
render() {
if (this.node.template) {
return this.renderTemplate();
}
const component = this.getMapping();
if (!component) {
return this.renderChildren();
}
return this.renderMapping(component);
}
renderTemplate() {
const embeddedViewRef = this.container.createEmbeddedView(this.node.template, {
$implicit: this.component,
component: this.component,
page: this.page.state.getValue(),
});
const [head] = embeddedViewRef.rootNodes;
const [tail] = embeddedViewRef.rootNodes.slice(-1);
return { head, tail };
}
renderChildren() {
const nodes = this.component
?.getChildren()
?.map((component) => this.container.createEmbeddedView(this.page.node, {
component,
$implicit: component,
page: this.page.state.getValue(),
}))
.flatMap((view) => view.rootNodes);
const head = nodes?.[0] ?? this.container.element.nativeElement;
const tail = nodes?.[nodes.length - 1] ?? head;
return { head, tail };
}
renderMapping(component) {
const componentRef = this.container.createComponent(component);
componentRef.instance.component = this.component;
componentRef.instance.page = this.page.state.getValue();
return {
head: componentRef.location.nativeElement,
tail: componentRef.location.nativeElement,
};
}
ngOnDestroy() {
this.clear?.();
this.container.clear();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeComponentDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Injector }, { token: BrNodeDirective }, { token: BrPageService }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrNodeComponentDirective, isStandalone: false, selector: "[brNodeComponent]", inputs: { component: ["brNodeComponent", "component"] }, usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeComponentDirective, decorators: [{
type: Directive,
args: [{
selector: '[brNodeComponent]',
standalone: false,
}]
}], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.Injector }, { type: BrNodeDirective }, { type: BrPageService }], propDecorators: { component: [{
type: Input,
args: ['brNodeComponent']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrNodeContainerDirective extends BrNodeComponentDirective {
getMapping() {
const type = this.component?.getType();
if (type && type in this.page.mapping) {
return this.page.mapping[type];
}
switch (type) {
case TYPE_CONTAINER_INLINE:
return BrContainerInlineComponent;
case TYPE_CONTAINER_ORDERED_LIST:
return BrContainerOrderedListComponent;
case TYPE_CONTAINER_UNORDERED_LIST:
return BrContainerUnorderedListComponent;
case TYPE_CONTAINER_NO_MARKUP:
return undefined;
default:
return BrContainerBoxComponent;
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeContainerDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrNodeContainerDirective, isStandalone: false, selector: "[brNodeContainer]", inputs: { component: ["brNodeContainer", "component"] }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeContainerDirective, decorators: [{
type: Directive,
args: [{
selector: '[brNodeContainer]',
standalone: false,
}]
}], propDecorators: { component: [{
type: Input,
args: ['brNodeContainer']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrNodeContainerItemDirective extends BrNodeComponentDirective {
constructor(container, injector, node, page, changeDetectorRef) {
super(container, injector, node, page);
this.changeDetectorRef = changeDetectorRef;
this.onUpdate = this.onUpdate.bind(this);
}
ngOnChanges(changes) {
changes.component?.previousValue?.off('update', this.onUpdate);
super.ngOnChanges(changes);
this.component?.on('update', this.onUpdate);
}
ngOnDestroy() {
this.component?.off('update', this.onUpdate);
}
onUpdate() {
this.changeDetectorRef.markForCheck();
this.ngOnChanges({});
this.page.state.getValue()?.sync();
}
getMapping() {
const type = this.component?.getType();
if (type && type in this.page.mapping) {
return this.page.mapping[type];
}
return this.page.mapping[TYPE_CONTAINER_ITEM_UNDEFINED] ?? BrContainerItemUndefinedComponent;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeContainerItemDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.Injector }, { token: BrNodeDirective }, { token: BrPageService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrNodeContainerItemDirective, isStandalone: false, selector: "[brNodeContainerItem]", inputs: { component: ["brNodeContainerItem", "component"] }, usesInheritance: true, usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeContainerItemDirective, decorators: [{
type: Directive,
args: [{
selector: '[brNodeContainerItem]',
standalone: false,
}]
}], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.Injector }, { type: BrNodeDirective }, { type: BrPageService }, { type: i0.ChangeDetectorRef }], propDecorators: { component: [{
type: Input,
args: ['brNodeContainerItem']
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class BrNodeTypePipe {
transform(component) {
if (isContainerItem(component)) {
return 'container-item';
}
if (isContainer(component)) {
return 'container';
}
return 'component';
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeTypePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.0", ngImport: i0, type: BrNodeTypePipe, isStandalone: false, name: "brNodeType" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrNodeTypePipe, decorators: [{
type: Pipe,
args: [{
name: 'brNodeType',
standalone: false,
}]
}] });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The brXM page.
*/
class BrPageComponent {
constructor(httpClient, pageService, zone, platform, transferState) {
this.httpClient = httpClient;
this.pageService = pageService;
this.platform = platform;
this.transferState = transferState;
/**
* The brXM and Angular components mapping.
*/
this.mapping = {};
/**
* The TransferState key is used to transfer the state from the server-side to the client-side.
* By default, it equals to `brPage`.
* If `false` is passed then the state transferring feature will be disabled.
*/
this.stateKey = makeStateKey('brPage');
/**
* The current state of the page component.
*/
this.state = this.pageService.state;
/**
* Http error handling
*/
this.httpError = new EventEmitter();
this.afterContentChecked$ = new Subject();
this.request = this.request.bind(this);
this.state
.pipe(filter(isPage), switchMap((page) => this.afterContentChecked$.pipe(take(1), mapTo(page))))
.subscribe((page) => zone.runOutsideAngular(() => page.sync()));
this.state
.pipe(filter(() => this.isPlatformServer(this.platform)), filter(isPage))
.subscribe((page) => this.stateKey
&& this.transferState?.set(this.stateKey, page.toJSON()));
}
get context() {
const page = this.state.getValue();
const component = page?.getComponent();
const pageOrNBR = page || this.configuration?.NBRMode;
return {
component,
page,
$implicit: component,
template: pageOrNBR ? this.template : undefined,
};
}
ngOnChanges(changes) {
if (changes.configuration || changes.page) {
this.initialize(changes.page?.currentValue);
}
if (changes.mapping?.currentValue !== this.pageService.mapping) {
this.pageService.mapping = this.mapping;
}
if (changes.stateKey?.previousValue
&& this.isPlatformServer(this.platform)) {
if (changes.stateKey.currentValue
&& this.transferState?.hasKey(changes.stateKey.previousValue)) {
this.transferState?.set(changes.stateKey.currentValue, this.transferState?.get(changes.stateKey.previousValue, undefined));
}
this.transferState?.remove(changes.stateKey.previousValue);
}
}
ngAfterContentChecked() {
this.afterContentChecked$.next(null);
}
ngAfterContentInit() {
this.pageService.node = this.node;
}
ngOnDestroy() {
this.state.next(undefined);
this.state.complete();
this.afterContentChecked$.complete();
}
initialize(page) {
if (this.stateKey
&& this.isPlatformBrowser(this.platform)
&& this.transferState?.hasKey(this.stateKey)) {
page = page ?? this.transferState?.get(this.stateKey, undefined);
this.transferState?.remove(this.stateKey);
}
const configuration = {
httpClient: this.request,
...this.configuration,
};
const observable = page
? of(initialize(configuration, page))
: from(initialize(configuration));
observable.pipe(take(1)).subscribe((state) => {
this.state.next(state);
});
}
request(...[{ data: body, headers, method, url }]) {
return this.httpClient
.request(method, url, {
body,
headers: headers,
responseType: 'json',
})
.pipe(map((data) => ({ data })))
.toPromise()
.catch((error) => this.httpError.emit(error));
}
isPlatformBrowser(platform) {
return isPlatformBrowser(platform);
}
isPlatformServer(platform) {
return isPlatformServer(platform);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrPageComponent, deps: [{ token: i1$1.HttpClient }, { token: BrPageService }, { token: i0.NgZone }, { token: PLATFORM_ID }, { token: i0.TransferState, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.0", type: BrPageComponent, isStandalone: false, selector: "br-page", inputs: { configuration: "configuration", mapping: "mapping", page: "page", stateKey: "stateKey" }, outputs: { state: "state", httpError: "httpError" }, host: { attributes: { "ngSkipHydration": "true" } }, providers: [BrPageService], queries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true, static: true }], viewQueries: [{ propertyName: "node", first: true, predicate: ["brNode"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n\n<ng-template #brNode let-component let-template=\"template\">\n <ng-container [brNode]=\"component\" [brNodeTemplate]=\"template\">\n <ng-container [ngSwitch]=\"component | brNodeType\">\n <ng-container *ngSwitchCase=\"'container-item'\" [brNodeContainerItem]=\"component\"></ng-container>\n <ng-container *ngSwitchCase=\"'container'\" [brNodeContainer]=\"component\"></ng-container>\n <ng-container *ngSwitchDefault [brNodeComponent]=\"component\"></ng-container>\n </ng-container>\n </ng-container>\n</ng-template>\n\n@if (context?.template) {\n<ng-template [ngTemplateOutlet]=\"brNode\" [ngTemplateOutletContext]=\"context\"></ng-template>\n}", dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "directive", type: BrNodeComponentDirective, selector: "[brNodeComponent]", inputs: ["brNodeComponent"] }, { kind: "directive", type: BrNodeContainerDirective, selector: "[brNodeContainer]", inputs: ["brNodeContainer"] }, { kind: "directive", type: BrNodeContainerItemDirective, selector: "[brNodeContainerItem]", inputs: ["brNodeContainerItem"] }, { kind: "directive", type: BrNodeDirective, selector: "[brNode]", inputs: ["brNode", "brNodeTemplate"] }, { kind: "pipe", type: BrNodeTypePipe, name: "brNodeType" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrPageComponent, decorators: [{
type: Component,
args: [{ selector: 'br-page', providers: [BrPageService], host: { ngSkipHydration: 'true' }, standalone: false, template: "<!--\n Copyright 2020-2025 Bloomreach\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n https://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n -->\n\n<ng-template #brNode let-component let-template=\"template\">\n <ng-container [brNode]=\"component\" [brNodeTemplate]=\"template\">\n <ng-container [ngSwitch]=\"component | brNodeType\">\n <ng-container *ngSwitchCase=\"'container-item'\" [brNodeContainerItem]=\"component\"></ng-container>\n <ng-container *ngSwitchCase=\"'container'\" [brNodeContainer]=\"component\"></ng-container>\n <ng-container *ngSwitchDefault [brNodeComponent]=\"component\"></ng-container>\n </ng-container>\n </ng-container>\n</ng-template>\n\n@if (context?.template) {\n<ng-template [ngTemplateOutlet]=\"brNode\" [ngTemplateOutletContext]=\"context\"></ng-template>\n}" }]
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: BrPageService }, { type: i0.NgZone }, { type: undefined, decorators: [{
type: Inject,
args: [PLATFORM_ID]
}] }, { type: i0.TransferState, decorators: [{
type: Optional
}] }], propDecorators: { configuration: [{
type: Input
}], mapping: [{
type: Input
}], page: [{
type: Input
}], stateKey: [{
type: Input
}], state: [{
type: Output
}], httpError: [{
type: Output
}], node: [{
type: ViewChild,
args: ['brNode', { static: true }]
}], template: [{
type: ContentChild,
args: [TemplateRef, { static: true }]
}] } });
/*
* Copyright 2020-2025 Bloomreach
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The button directive that opens for editing a content.
*/
class BrManageContentButtonDirective extends BrMetaDirective {
constructor(container, template, page) {
super(container, template);
this.page = page;
}
ngOnChanges(changes) {
this.meta = this.page?.state.getValue()?.getButton(TYPE_MANAGE_CONTENT_BUTTON, this);
super.ngOnChanges(changes);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrManageContentButtonDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef, optional: true }, { token: BrPageComponent, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.0", type: BrManageContentButtonDirective, isStandalone: false, selector: "[brManageContentButton]", inputs: { content: ["brManageContentButton", "content"], documentTemplateQuery: "documentTemplateQuery", folderTemplateQuery: "folderTemplateQuery", path: "path", parameter: "parameter", pickerConfiguration: "pickerConfiguration", pickerEnableUpload: "pickerEnableUpload", pickerInitialPath: "pickerInitialPath", pickerRemembersLastVisited: "pickerRemembersLastVisited", pickerRootPath: "pickerRootPath", pickerSelectableNodeTypes: "pickerSelectableNodeTypes", relative: "relative", root: "root" }, usesInheritance: true, usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.0", ngImport: i0, type: BrManageContentButtonDirective, decorators: [{
type: Directive,
args: [{
selector: '[brManageC