UNPKG

@angular/material

Version:
1 lines 16.1 kB
{"version":3,"file":"button.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/button/button.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/button/button.html","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/button/fab.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/button/button-module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Component, Input, ViewEncapsulation} from '@angular/core';\nimport {MatButtonAppearance, MatButtonBase} from './button-base';\n\n/**\n * Classes that need to be set for each appearance of the button.\n * Note that we use a `Map` here to avoid issues with property renaming.\n */\nconst APPEARANCE_CLASSES: Map<MatButtonAppearance, readonly string[]> = new Map([\n ['text', ['mat-mdc-button']],\n ['filled', ['mdc-button--unelevated', 'mat-mdc-unelevated-button']],\n ['elevated', ['mdc-button--raised', 'mat-mdc-raised-button']],\n ['outlined', ['mdc-button--outlined', 'mat-mdc-outlined-button']],\n ['tonal', ['mat-tonal-button']],\n]);\n\n/**\n * Material Design button component. Users interact with a button to perform an action.\n * See https://m3.material.io/components/buttons/overview\n */\n@Component({\n selector: `\n button[matButton], a[matButton], button[mat-button], button[mat-raised-button],\n button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button],\n a[mat-flat-button], a[mat-stroked-button]\n `,\n templateUrl: 'button.html',\n styleUrls: ['button.css', 'button-high-contrast.css'],\n host: {\n 'class': 'mdc-button',\n },\n exportAs: 'matButton, matAnchor',\n encapsulation: ViewEncapsulation.None,\n})\nexport class MatButton extends MatButtonBase {\n /** Appearance of the button. */\n @Input('matButton')\n get appearance(): MatButtonAppearance | null {\n return this._appearance;\n }\n set appearance(value: MatButtonAppearance | '') {\n // Allow empty string so users can do `<button matButton></button>`\n // without having to write out `=\"text\"` every time.\n this.setAppearance(value || this._config?.defaultAppearance || 'text');\n }\n private _appearance: MatButtonAppearance | null = null;\n\n constructor() {\n super();\n const inferredAppearance = _inferAppearance(this._elementRef.nativeElement);\n\n // Only set the appearance if we managed to infer it from the static attributes, rather than\n // doing something like `setAppearance(inferredAppearance || 'text')`, because doing so can\n // cause the fallback appearance's classes to be set and then immediately replaced when\n // the input value is assigned.\n if (inferredAppearance) {\n this.setAppearance(inferredAppearance);\n }\n }\n\n /** Programmatically sets the appearance of the button. */\n setAppearance(appearance: MatButtonAppearance): void {\n if (appearance === this._appearance) {\n return;\n }\n\n const classList = this._elementRef.nativeElement.classList;\n const previousClasses = this._appearance ? APPEARANCE_CLASSES.get(this._appearance) : null;\n const newClasses = APPEARANCE_CLASSES.get(appearance)!;\n\n if ((typeof ngDevMode === 'undefined' || ngDevMode) && !newClasses) {\n throw new Error(`Unsupported MatButton appearance \"${appearance}\"`);\n }\n\n if (previousClasses) {\n classList.remove(...previousClasses);\n }\n\n classList.add(...newClasses);\n this._appearance = appearance;\n }\n}\n\n/** Infers the button's appearance from its static attributes. */\nfunction _inferAppearance(button: HTMLElement): MatButtonAppearance | null {\n if (button.hasAttribute('mat-raised-button')) {\n return 'elevated';\n }\n\n if (button.hasAttribute('mat-stroked-button')) {\n return 'outlined';\n }\n\n if (button.hasAttribute('mat-flat-button')) {\n return 'filled';\n }\n\n if (button.hasAttribute('mat-button')) {\n return 'text';\n }\n\n return null;\n}\n\n// tslint:disable:variable-name\n/**\n * Material Design button component for anchor elements. Anchor elements are used to provide\n * links for the user to navigate across different routes or pages.\n * See https://m3.material.io/components/buttons/overview\n */\nexport const MatAnchor = MatButton;\nexport type MatAnchor = MatButton;\n// tslint:enable:variable-name\n","<span\n class=\"mat-mdc-button-persistent-ripple\"\n [class.mdc-button__ripple]=\"!_isFab\"\n [class.mdc-fab__ripple]=\"_isFab\"\n></span>\n\n<ng-content\n select=\".material-icons:not([iconPositionEnd]), mat-icon:not([iconPositionEnd]), [matButtonIcon]:not([iconPositionEnd])\"\n>\n</ng-content>\n\n<span class=\"mdc-button__label\"><ng-content></ng-content></span>\n\n<ng-content\n select=\".material-icons[iconPositionEnd], mat-icon[iconPositionEnd], [matButtonIcon][iconPositionEnd]\"\n>\n</ng-content>\n\n@if (showProgress()) {\n <div class=\"mat-mdc-button-progress-indicator-container\">\n <ng-content select=\"[progressIndicator]\" />\n </div>\n}\n\n<!--\n The indicator can't be directly on the button, because MDC uses ::before for high contrast\n indication and it can't be on the ripple, because it has a border radius and overflow: hidden.\n-->\n<span class=\"mat-focus-indicator\"></span>\n\n<span class=\"mat-mdc-button-touch-target\"></span>\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n Component,\n InjectionToken,\n Input,\n ViewEncapsulation,\n booleanAttribute,\n inject,\n} from '@angular/core';\n\nimport {MatButtonBase} from './button-base';\nimport {ThemePalette} from '../core';\n\n/** Default FAB options that can be overridden. */\nexport interface MatFabDefaultOptions {\n /**\n * Default theme color of the button. This API is supported in M2 themes\n * only, it has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/button/styling.\n *\n * For information on applying color variants in M3, see\n * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants.\n */\n color?: ThemePalette;\n}\n\n/** Injection token to be used to override the default options for FAB. */\nexport const MAT_FAB_DEFAULT_OPTIONS = new InjectionToken<MatFabDefaultOptions>(\n 'mat-mdc-fab-default-options',\n {\n providedIn: 'root',\n factory: () => defaults,\n },\n);\n\n// Default FAB configuration.\nconst defaults: MatFabDefaultOptions = {\n // The FAB by default has its color set to accent.\n color: 'accent',\n};\n\n/**\n * Material Design floating action button (FAB) component. These buttons represent the primary\n * or most common action for users to interact with.\n * See https://m3.material.io/components/floating-action-button/overview\n *\n * The `MatFabButton` class has two appearances: normal and extended.\n */\n@Component({\n selector: `button[mat-fab], a[mat-fab], button[matFab], a[matFab]`,\n templateUrl: 'button.html',\n styleUrl: 'fab.css',\n host: {\n 'class': 'mdc-fab mat-mdc-fab-base mat-mdc-fab',\n '[class.mdc-fab--extended]': 'extended',\n '[class.mat-mdc-extended-fab]': 'extended',\n },\n exportAs: 'matButton, matAnchor',\n encapsulation: ViewEncapsulation.None,\n})\nexport class MatFabButton extends MatButtonBase {\n private _options = inject<MatFabDefaultOptions>(MAT_FAB_DEFAULT_OPTIONS, {optional: true});\n\n override _isFab = true;\n\n @Input({transform: booleanAttribute}) extended: boolean = false;\n\n constructor() {\n super();\n this._options = this._options || defaults;\n this.color = this._options!.color || defaults.color;\n }\n}\n\n/**\n * Material Design mini floating action button (FAB) component. These buttons represent the primary\n * or most common action for users to interact with.\n * See https://m3.material.io/components/floating-action-button/overview\n */\n@Component({\n selector: `button[mat-mini-fab], a[mat-mini-fab], button[matMiniFab], a[matMiniFab]`,\n templateUrl: 'button.html',\n styleUrl: 'fab.css',\n host: {\n 'class': 'mdc-fab mat-mdc-fab-base mdc-fab--mini mat-mdc-mini-fab',\n },\n exportAs: 'matButton, matAnchor',\n encapsulation: ViewEncapsulation.None,\n})\nexport class MatMiniFabButton extends MatButtonBase {\n private _options = inject<MatFabDefaultOptions>(MAT_FAB_DEFAULT_OPTIONS, {optional: true});\n\n override _isFab = true;\n\n constructor() {\n super();\n this._options = this._options || defaults;\n this.color = this._options!.color || defaults.color;\n }\n}\n\n// tslint:disable:variable-name\n/**\n * Material Design floating action button (FAB) component for anchor elements. Anchor elements\n * are used to provide links for the user to navigate across different routes or pages.\n * See https://m3.material.io/components/floating-action-button/overview\n *\n * The `MatFabAnchor` class has two appearances: normal and extended.\n */\nexport const MatFabAnchor = MatFabButton;\nexport type MatFabAnchor = MatFabButton;\n\n/**\n * Material Design mini floating action button (FAB) component for anchor elements. Anchor elements\n * are used to provide links for the user to navigate across different routes or pages.\n * See https://m3.material.io/components/floating-action-button/overview\n */\nexport const MatMiniFabAnchor = MatMiniFabButton;\nexport type MatMiniFabAnchor = MatMiniFabButton;\n// tslint:enable:variable-name\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {NgModule} from '@angular/core';\nimport {BidiModule} from '@angular/cdk/bidi';\nimport {MatRippleModule} from '../core';\nimport {MatButton} from './button';\nimport {MatFabButton, MatMiniFabButton} from './fab';\nimport {MatIconButton} from './icon-button';\n\n@NgModule({\n imports: [MatRippleModule, MatButton, MatMiniFabButton, MatIconButton, MatFabButton],\n exports: [BidiModule, MatButton, MatMiniFabButton, MatIconButton, MatFabButton],\n})\nexport class MatButtonModule {}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAM,kBAAkB,GAAgD,IAAI,GAAG,CAAC,CAC9E,CAAC,MAAM,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAC5B,CAAC,QAAQ,EAAE,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,CAAC,EACnE,CAAC,UAAU,EAAE,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC,EAC7D,CAAC,UAAU,EAAE,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,CAAC,EACjE,CAAC,OAAO,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAChC,CAAC;AAoBI,MAAO,SAAU,SAAQ,aAAa,CAAA;AAE1C,EAAA,IACI,UAAU,GAAA;IACZ,OAAO,IAAI,CAAC,WAAW;AACzB,EAAA;EACA,IAAI,UAAU,CAAC,KAA+B,EAAA;AAG5C,IAAA,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,iBAAiB,IAAI,MAAM,CAAC;AACxE,EAAA;AACQ,EAAA,WAAW,GAA+B,IAAI;AAEtD,EAAA,WAAA,GAAA;AACE,IAAA,KAAK,EAAE;IACP,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,a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