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

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

initial commit

  • Property mode set to 100644
File size: 5.4 KB
RevLine 
[6a3a178]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 */
27const DIR_DOCUMENT = new InjectionToken('cdk-dir-doc', {
28 providedIn: 'root',
29 factory: DIR_DOCUMENT_FACTORY,
30});
31/** @docs-private */
32function DIR_DOCUMENT_FACTORY() {
33 return inject(DOCUMENT);
34}
35
36/**
37 * @license
38 * Copyright Google LLC All Rights Reserved.
39 *
40 * Use of this source code is governed by an MIT-style license that can be
41 * found in the LICENSE file at https://angular.io/license
42 */
43/**
44 * The directionality (LTR / RTL) context for the application (or a subtree of it).
45 * Exposes the current direction and a stream of direction changes.
46 */
47class Directionality {
48 constructor(_document) {
49 /** The current 'ltr' or 'rtl' value. */
50 this.value = 'ltr';
51 /** Stream that emits whenever the 'ltr' / 'rtl' state changes. */
52 this.change = new EventEmitter();
53 if (_document) {
54 // TODO: handle 'auto' value -
55 // We still need to account for dir="auto".
56 // It looks like HTMLElemenet.dir is also "auto" when that's set to the attribute,
57 // but getComputedStyle return either "ltr" or "rtl". avoiding getComputedStyle for now
58 const bodyDir = _document.body ? _document.body.dir : null;
59 const htmlDir = _document.documentElement ? _document.documentElement.dir : null;
60 const value = bodyDir || htmlDir;
61 this.value = (value === 'ltr' || value === 'rtl') ? value : 'ltr';
62 }
63 }
64 ngOnDestroy() {
65 this.change.complete();
66 }
67}
68Directionality.ɵprov = i0.ɵɵdefineInjectable({ factory: function Directionality_Factory() { return new Directionality(i0.ɵɵinject(DIR_DOCUMENT, 8)); }, token: Directionality, providedIn: "root" });
69Directionality.decorators = [
70 { type: Injectable, args: [{ providedIn: 'root' },] }
71];
72Directionality.ctorParameters = () => [
73 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DIR_DOCUMENT,] }] }
74];
75
76/**
77 * @license
78 * Copyright Google LLC All Rights Reserved.
79 *
80 * Use of this source code is governed by an MIT-style license that can be
81 * found in the LICENSE file at https://angular.io/license
82 */
83/**
84 * Directive to listen for changes of direction of part of the DOM.
85 *
86 * Provides itself as Directionality such that descendant directives only need to ever inject
87 * Directionality to get the closest direction.
88 */
89class Dir {
90 constructor() {
91 /** Normalized direction that accounts for invalid/unsupported values. */
92 this._dir = 'ltr';
93 /** Whether the `value` has been set to its initial value. */
94 this._isInitialized = false;
95 /** Event emitted when the direction changes. */
96 this.change = new EventEmitter();
97 }
98 /** @docs-private */
99 get dir() { return this._dir; }
100 set dir(value) {
101 const old = this._dir;
102 const normalizedValue = value ? value.toLowerCase() : value;
103 this._rawDir = value;
104 this._dir = (normalizedValue === 'ltr' || normalizedValue === 'rtl') ? normalizedValue : 'ltr';
105 if (old !== this._dir && this._isInitialized) {
106 this.change.emit(this._dir);
107 }
108 }
109 /** Current layout direction of the element. */
110 get value() { return this.dir; }
111 /** Initialize once default value has been set. */
112 ngAfterContentInit() {
113 this._isInitialized = true;
114 }
115 ngOnDestroy() {
116 this.change.complete();
117 }
118}
119Dir.decorators = [
120 { type: Directive, args: [{
121 selector: '[dir]',
122 providers: [{ provide: Directionality, useExisting: Dir }],
123 host: { '[attr.dir]': '_rawDir' },
124 exportAs: 'dir',
125 },] }
126];
127Dir.propDecorators = {
128 change: [{ type: Output, args: ['dirChange',] }],
129 dir: [{ type: Input }]
130};
131
132/**
133 * @license
134 * Copyright Google LLC All Rights Reserved.
135 *
136 * Use of this source code is governed by an MIT-style license that can be
137 * found in the LICENSE file at https://angular.io/license
138 */
139class BidiModule {
140}
141BidiModule.decorators = [
142 { type: NgModule, args: [{
143 exports: [Dir],
144 declarations: [Dir],
145 },] }
146];
147
148/**
149 * @license
150 * Copyright Google LLC All Rights Reserved.
151 *
152 * Use of this source code is governed by an MIT-style license that can be
153 * found in the LICENSE file at https://angular.io/license
154 */
155
156/**
157 * Generated bundle index. Do not edit.
158 */
159
160export { BidiModule, DIR_DOCUMENT, Dir, Directionality, DIR_DOCUMENT_FACTORY as ɵangular_material_src_cdk_bidi_bidi_a };
161//# sourceMappingURL=bidi.js.map
Note: See TracBrowser for help on using the repository browser.