| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- /**
- * @license
- * Copyright Google LLC All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core')) :
- typeof define === 'function' && define.amd ? define('@angular/cdk/bidi', ['exports', '@angular/common', '@angular/core'], factory) :
- (factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.bidi = {}),global.ng.common,global.ng.core));
- }(this, (function (exports,common,core) { 'use strict';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Injection token used to inject the document into Directionality.
- * This is used so that the value can be faked in tests.
- *
- * We can't use the real document in tests because changing the real `dir` causes geometry-based
- * tests in Safari to fail.
- *
- * We also can't re-provide the DOCUMENT token from platform-brower because the unit tests
- * themselves use things like `querySelector` in test code.
- *
- * This token is defined in a separate file from Directionality as a workaround for
- * https://github.com/angular/angular/issues/22559
- *
- * \@docs-private
- * @type {?}
- */
- var DIR_DOCUMENT = new core.InjectionToken('cdk-dir-doc', {
- providedIn: 'root',
- factory: DIR_DOCUMENT_FACTORY,
- });
- /**
- * \@docs-private
- * @return {?}
- */
- function DIR_DOCUMENT_FACTORY() {
- return core.inject(common.DOCUMENT);
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * The directionality (LTR / RTL) context for the application (or a subtree of it).
- * Exposes the current direction and a stream of direction changes.
- */
- var Directionality = /** @class */ (function () {
- function Directionality(_document) {
- /**
- * The current 'ltr' or 'rtl' value.
- */
- this.value = 'ltr';
- /**
- * Stream that emits whenever the 'ltr' / 'rtl' state changes.
- */
- this.change = new core.EventEmitter();
- if (_document) {
- // TODO: handle 'auto' value -
- // We still need to account for dir="auto".
- // It looks like HTMLElemenet.dir is also "auto" when that's set to the attribute,
- // but getComputedStyle return either "ltr" or "rtl". avoiding getComputedStyle for now
- /** @type {?} */
- var bodyDir = _document.body ? _document.body.dir : null;
- /** @type {?} */
- var htmlDir = _document.documentElement ? _document.documentElement.dir : null;
- /** @type {?} */
- var value = bodyDir || htmlDir;
- this.value = (value === 'ltr' || value === 'rtl') ? value : 'ltr';
- }
- }
- /**
- * @return {?}
- */
- Directionality.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- this.change.complete();
- };
- Directionality.decorators = [
- { type: core.Injectable, args: [{ providedIn: 'root' },] },
- ];
- /** @nocollapse */
- Directionality.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [DIR_DOCUMENT,] }] }
- ]; };
- /** @nocollapse */ Directionality.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function Directionality_Factory() { return new Directionality(core.ɵɵinject(DIR_DOCUMENT, 8)); }, token: Directionality, providedIn: "root" });
- return Directionality;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Directive to listen for changes of direction of part of the DOM.
- *
- * Provides itself as Directionality such that descendant directives only need to ever inject
- * Directionality to get the closest direction.
- */
- var Dir = /** @class */ (function () {
- function Dir() {
- /**
- * Normalized direction that accounts for invalid/unsupported values.
- */
- this._dir = 'ltr';
- /**
- * Whether the `value` has been set to its initial value.
- */
- this._isInitialized = false;
- /**
- * Event emitted when the direction changes.
- */
- this.change = new core.EventEmitter();
- }
- Object.defineProperty(Dir.prototype, "dir", {
- /** @docs-private */
- get: /**
- * \@docs-private
- * @return {?}
- */
- function () { return this._dir; },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- /** @type {?} */
- var old = this._dir;
- /** @type {?} */
- var normalizedValue = value ? value.toLowerCase() : value;
- this._rawDir = value;
- this._dir = (normalizedValue === 'ltr' || normalizedValue === 'rtl') ? normalizedValue : 'ltr';
- if (old !== this._dir && this._isInitialized) {
- this.change.emit(this._dir);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Dir.prototype, "value", {
- /** Current layout direction of the element. */
- get: /**
- * Current layout direction of the element.
- * @return {?}
- */
- function () { return this.dir; },
- enumerable: true,
- configurable: true
- });
- /** Initialize once default value has been set. */
- /**
- * Initialize once default value has been set.
- * @return {?}
- */
- Dir.prototype.ngAfterContentInit = /**
- * Initialize once default value has been set.
- * @return {?}
- */
- function () {
- this._isInitialized = true;
- };
- /**
- * @return {?}
- */
- Dir.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- this.change.complete();
- };
- Dir.decorators = [
- { type: core.Directive, args: [{
- selector: '[dir]',
- providers: [{ provide: Directionality, useExisting: Dir }],
- host: { '[attr.dir]': '_rawDir' },
- exportAs: 'dir',
- },] },
- ];
- Dir.propDecorators = {
- change: [{ type: core.Output, args: ['dirChange',] }],
- dir: [{ type: core.Input }]
- };
- return Dir;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var BidiModule = /** @class */ (function () {
- function BidiModule() {
- }
- BidiModule.decorators = [
- { type: core.NgModule, args: [{
- exports: [Dir],
- declarations: [Dir],
- },] },
- ];
- return BidiModule;
- }());
- exports.Directionality = Directionality;
- exports.DIR_DOCUMENT = DIR_DOCUMENT;
- exports.Dir = Dir;
- exports.BidiModule = BidiModule;
- exports.ɵa = DIR_DOCUMENT_FACTORY;
- Object.defineProperty(exports, '__esModule', { value: true });
- })));
- //# sourceMappingURL=cdk-bidi.umd.js.map
|