bidi.mjs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { _ as _resolveDirectionality, D as Directionality } from './directionality-CBXD4hga.mjs';
  2. export { a as DIR_DOCUMENT } from './directionality-CBXD4hga.mjs';
  3. import * as i0 from '@angular/core';
  4. import { EventEmitter, Directive, Output, Input, NgModule } from '@angular/core';
  5. import '@angular/common';
  6. /**
  7. * Directive to listen for changes of direction of part of the DOM.
  8. *
  9. * Provides itself as Directionality such that descendant directives only need to ever inject
  10. * Directionality to get the closest direction.
  11. */
  12. class Dir {
  13. /** Normalized direction that accounts for invalid/unsupported values. */
  14. _dir = 'ltr';
  15. /** Whether the `value` has been set to its initial value. */
  16. _isInitialized = false;
  17. /** Direction as passed in by the consumer. */
  18. _rawDir;
  19. /** Event emitted when the direction changes. */
  20. change = new EventEmitter();
  21. /** @docs-private */
  22. get dir() {
  23. return this._dir;
  24. }
  25. set dir(value) {
  26. const previousValue = this._dir;
  27. // Note: `_resolveDirectionality` resolves the language based on the browser's language,
  28. // whereas the browser does it based on the content of the element. Since doing so based
  29. // on the content can be expensive, for now we're doing the simpler matching.
  30. this._dir = _resolveDirectionality(value);
  31. this._rawDir = value;
  32. if (previousValue !== this._dir && this._isInitialized) {
  33. this.change.emit(this._dir);
  34. }
  35. }
  36. /** Current layout direction of the element. */
  37. get value() {
  38. return this.dir;
  39. }
  40. /** Initialize once default value has been set. */
  41. ngAfterContentInit() {
  42. this._isInitialized = true;
  43. }
  44. ngOnDestroy() {
  45. this.change.complete();
  46. }
  47. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: Dir, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  48. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: Dir, isStandalone: true, selector: "[dir]", inputs: { dir: "dir" }, outputs: { change: "dirChange" }, host: { properties: { "attr.dir": "_rawDir" } }, providers: [{ provide: Directionality, useExisting: Dir }], exportAs: ["dir"], ngImport: i0 });
  49. }
  50. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: Dir, decorators: [{
  51. type: Directive,
  52. args: [{
  53. selector: '[dir]',
  54. providers: [{ provide: Directionality, useExisting: Dir }],
  55. host: { '[attr.dir]': '_rawDir' },
  56. exportAs: 'dir',
  57. }]
  58. }], propDecorators: { change: [{
  59. type: Output,
  60. args: ['dirChange']
  61. }], dir: [{
  62. type: Input
  63. }] } });
  64. class BidiModule {
  65. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: BidiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  66. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: BidiModule, imports: [Dir], exports: [Dir] });
  67. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: BidiModule });
  68. }
  69. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: BidiModule, decorators: [{
  70. type: NgModule,
  71. args: [{
  72. imports: [Dir],
  73. exports: [Dir],
  74. }]
  75. }] });
  76. export { BidiModule, Dir, Directionality };
  77. //# sourceMappingURL=bidi.mjs.map