source: trip-planner-front/node_modules/@angular/cdk/__ivy_ngcc__/fesm2015/bidi.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 7.1 KB
Line 
1import * as i0 from '@angular/core';
2import { InjectionToken, inject, EventEmitter, Injectable, Optional, Inject, Directive, Output, Input, NgModule } from '@angular/core';
3import { DOCUMENT } from '@angular/common';
4
5/**
6 * @license
7 * Copyright Google LLC All Rights Reserved.
8 *
9 * Use of this source code is governed by an MIT-style license that can be
10 * found in the LICENSE file at https://angular.io/license
11 */
12/**
13 * Injection token used to inject the document into Directionality.
14 * This is used so that the value can be faked in tests.
15 *
16 * We can't use the real document in tests because changing the real `dir` causes geometry-based
17 * tests in Safari to fail.
18 *
19 * We also can't re-provide the DOCUMENT token from platform-brower because the unit tests
20 * themselves use things like `querySelector` in test code.
21 *
22 * This token is defined in a separate file from Directionality as a workaround for
23 * https://github.com/angular/angular/issues/22559
24 *
25 * @docs-private
26 */
27import * as ɵngcc0 from '@angular/core';
28const DIR_DOCUMENT = new InjectionToken('cdk-dir-doc', {
29 providedIn: 'root',
30 factory: DIR_DOCUMENT_FACTORY,
31});
32/** @docs-private */
33function DIR_DOCUMENT_FACTORY() {
34 return inject(DOCUMENT);
35}
36
37/**
38 * @license
39 * Copyright Google LLC All Rights Reserved.
40 *
41 * Use of this source code is governed by an MIT-style license that can be
42 * found in the LICENSE file at https://angular.io/license
43 */
44/**
45 * The directionality (LTR / RTL) context for the application (or a subtree of it).
46 * Exposes the current direction and a stream of direction changes.
47 */
48class Directionality {
49 constructor(_document) {
50 /** The current 'ltr' or 'rtl' value. */
51 this.value = 'ltr';
52 /** Stream that emits whenever the 'ltr' / 'rtl' state changes. */
53 this.change = new EventEmitter();
54 if (_document) {
55 // TODO: handle 'auto' value -
56 // We still need to account for dir="auto".
57 // It looks like HTMLElemenet.dir is also "auto" when that's set to the attribute,
58 // but getComputedStyle return either "ltr" or "rtl". avoiding getComputedStyle for now
59 const bodyDir = _document.body ? _document.body.dir : null;
60 const htmlDir = _document.documentElement ? _document.documentElement.dir : null;
61 const value = bodyDir || htmlDir;
62 this.value = (value === 'ltr' || value === 'rtl') ? value : 'ltr';
63 }
64 }
65 ngOnDestroy() {
66 this.change.complete();
67 }
68}
69Directionality.ɵfac = function Directionality_Factory(t) { return new (t || Directionality)(ɵngcc0.ɵɵinject(DIR_DOCUMENT, 8)); };
70Directionality.ɵprov = i0.ɵɵdefineInjectable({ factory: function Directionality_Factory() { return new Directionality(i0.ɵɵinject(DIR_DOCUMENT, 8)); }, token: Directionality, providedIn: "root" });
71Directionality.ctorParameters = () => [
72 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DIR_DOCUMENT,] }] }
73];
74(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(Directionality, [{
75 type: Injectable,
76 args: [{ providedIn: 'root' }]
77 }], function () { return [{ type: undefined, decorators: [{
78 type: Optional
79 }, {
80 type: Inject,
81 args: [DIR_DOCUMENT]
82 }] }]; }, null); })();
83
84/**
85 * @license
86 * Copyright Google LLC All Rights Reserved.
87 *
88 * Use of this source code is governed by an MIT-style license that can be
89 * found in the LICENSE file at https://angular.io/license
90 */
91/**
92 * Directive to listen for changes of direction of part of the DOM.
93 *
94 * Provides itself as Directionality such that descendant directives only need to ever inject
95 * Directionality to get the closest direction.
96 */
97class Dir {
98 constructor() {
99 /** Normalized direction that accounts for invalid/unsupported values. */
100 this._dir = 'ltr';
101 /** Whether the `value` has been set to its initial value. */
102 this._isInitialized = false;
103 /** Event emitted when the direction changes. */
104 this.change = new EventEmitter();
105 }
106 /** @docs-private */
107 get dir() { return this._dir; }
108 set dir(value) {
109 const old = this._dir;
110 const normalizedValue = value ? value.toLowerCase() : value;
111 this._rawDir = value;
112 this._dir = (normalizedValue === 'ltr' || normalizedValue === 'rtl') ? normalizedValue : 'ltr';
113 if (old !== this._dir && this._isInitialized) {
114 this.change.emit(this._dir);
115 }
116 }
117 /** Current layout direction of the element. */
118 get value() { return this.dir; }
119 /** Initialize once default value has been set. */
120 ngAfterContentInit() {
121 this._isInitialized = true;
122 }
123 ngOnDestroy() {
124 this.change.complete();
125 }
126}
127Dir.ɵfac = function Dir_Factory(t) { return new (t || Dir)(); };
128Dir.ɵdir = /*@__PURE__*/ ɵngcc0.ɵɵdefineDirective({ type: Dir, selectors: [["", "dir", ""]], hostVars: 1, hostBindings: function Dir_HostBindings(rf, ctx) { if (rf & 2) {
129 ɵngcc0.ɵɵattribute("dir", ctx._rawDir);
130 } }, inputs: { dir: "dir" }, outputs: { change: "dirChange" }, exportAs: ["dir"], features: [ɵngcc0.ɵɵProvidersFeature([{ provide: Directionality, useExisting: Dir }])] });
131Dir.propDecorators = {
132 change: [{ type: Output, args: ['dirChange',] }],
133 dir: [{ type: Input }]
134};
135(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(Dir, [{
136 type: Directive,
137 args: [{
138 selector: '[dir]',
139 providers: [{ provide: Directionality, useExisting: Dir }],
140 host: { '[attr.dir]': '_rawDir' },
141 exportAs: 'dir'
142 }]
143 }], function () { return []; }, { change: [{
144 type: Output,
145 args: ['dirChange']
146 }], dir: [{
147 type: Input
148 }] }); })();
149
150/**
151 * @license
152 * Copyright Google LLC All Rights Reserved.
153 *
154 * Use of this source code is governed by an MIT-style license that can be
155 * found in the LICENSE file at https://angular.io/license
156 */
157class BidiModule {
158}
159BidiModule.ɵfac = function BidiModule_Factory(t) { return new (t || BidiModule)(); };
160BidiModule.ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: BidiModule });
161BidiModule.ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({});
162(function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(BidiModule, [{
163 type: NgModule,
164 args: [{
165 exports: [Dir],
166 declarations: [Dir]
167 }]
168 }], null, null); })();
169(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵngcc0.ɵɵsetNgModuleScope(BidiModule, { declarations: [Dir], exports: [Dir] }); })();
170
171/**
172 * @license
173 * Copyright Google LLC All Rights Reserved.
174 *
175 * Use of this source code is governed by an MIT-style license that can be
176 * found in the LICENSE file at https://angular.io/license
177 */
178
179/**
180 * Generated bundle index. Do not edit.
181 */
182
183export { BidiModule, DIR_DOCUMENT, Dir, Directionality, DIR_DOCUMENT_FACTORY as ɵangular_material_src_cdk_bidi_bidi_a };
184
185//# sourceMappingURL=bidi.js.map
Note: See TracBrowser for help on using the repository browser.