blob: a69944d8c0a7cf7250bec3570529bedc4fe6b297 [file] [log] [blame]
{"version":3,"sources":["src/cdk/cdk-clipboard.umd.js"],"names":["global","factory","exports","module","require","define","amd","self","ng","cdk","clipboard","common","core","this","i1","i0","PendingCopy","text","_document","textarea","_textarea","createElement","styles","style","position","top","opacity","left","setAttribute","value","body","appendChild","prototype","copy","successful","currentFocus","activeElement","select","setSelectionRange","length","execCommand","focus","_a","destroy","parentNode","removeChild","undefined","Clipboard","document","pendingCopy","beginCopy","ɵprov","ɵɵdefineInjectable","Clipboard_Factory","ɵɵinject","DOCUMENT","token","providedIn","decorators","type","Injectable","args","ctorParameters","Inject","ClipboardModule","CDK_COPY_TO_CLIPBOARD_CONFIG","InjectionToken","CKD_COPY_TO_CLIPBOARD_CONFIG","CdkCopyToClipboard","_clipboard","_ngZone","config","attempts","copied","EventEmitter","_pending","Set","_this","remainingAttempts_1","pending_1","add","attempt_1","_destroyed","_currentTimeout","delete","emit","runOutsideAngular","setTimeout","ngOnDestroy","clearTimeout","forEach","clear","Directive","selector","host","(click)","NgZone","Optional","propDecorators","Input","Output","NgModule","declarations","Object","defineProperty"],"mappings":"CAAC,SAAUA,EAAQC,GACI,iBAAZC,SAA0C,oBAAXC,OAAyBF,EAAQC,QAASE,QAAQ,mBAAoBA,QAAQ,kBAClG,mBAAXC,QAAyBA,OAAOC,IAAMD,OAAO,yBAA0B,CAAC,UAAW,kBAAmB,iBAAkBJ,GACrGA,IAAzBD,EAASA,GAAUO,MAAsBC,GAAKR,EAAOQ,IAAM,GAAIR,EAAOQ,GAAGC,IAAMT,EAAOQ,GAAGC,KAAO,GAAIT,EAAOQ,GAAGC,IAAIC,UAAY,IAAKV,EAAOQ,GAAGG,OAAQX,EAAOQ,GAAGI,MAHpK,CAIEC,MAAM,SAAWX,EAASY,EAAIC,GAAM;;;;;;;OAsBlC,IAAIC,EAA6B,WAC7B,SAASA,EAAYC,EAAMC,GACvBL,KAAKK,UAAYA,EACjB,IAAIC,EAAWN,K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,CAAEC,KAAM5C,EAAG6E,UAAW/B,KAAM,CAAC,CACjBgC,SAAU,uBACVC,KAAM,CACFC,UAAW,cAI/B3B,EAAmBN,eAAiB,WAAc,MAAO,CACrD,CAAEH,KAAMZ,GACR,CAAEY,KAAM5C,EAAGiF,QACX,CAAErC,UAAMb,EAAWY,WAAY,CAAC,CAAEC,KAAM5C,EAAGkF,UAAY,CAAEtC,KAAM5C,EAAGgD,OAAQF,KAAM,CAACM,QAErFC,EAAmB8B,eAAiB,CAChCjF,KAAM,CAAC,CAAE0C,KAAM5C,EAAGoF,MAAOtC,KAAM,CAAC,wBAChCW,SAAU,CAAC,CAAEb,KAAM5C,EAAGoF,MAAOtC,KAAM,CAAC,gCACpCY,OAAQ,CAAC,CAAEd,KAAM5C,EAAGqF,OAAQvC,KAAM,CAAC,gCAUnCG,EACA,SAASA,OAIGN,WAAa,CACzB,CAAEC,KAAM5C,EAAGsF,SAAUxC,KAAM,CAAC,CAChByC,aAAc,CAAClC,GACflE,QAAS,CAACkE;;;;;;;;AAgB1BlE,EAAQ+D,6BAA+BA,EACvC/D,EAAQiE,6BAA+BA,EACvCjE,EAAQkE,mBAAqBA,EAC7BlE,EAAQ6C,UAAYA,EACpB7C,EAAQ8D,gBAAkBA,EAC1B9D,EAAQc,YAAcA,EAEtBuF,OAAOC,eAAetG,EAAS,aAAc,CAAE2B,OAAO","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core')) :\n typeof define === 'function' && define.amd ? define('@angular/cdk/clipboard', ['exports', '@angular/common', '@angular/core'], factory) :\n (global = global || self, factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.clipboard = {}), global.ng.common, global.ng.core));\n}(this, (function (exports, i1, i0) { 'use strict';\n\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.io/license\n */\n /**\n * A pending copy-to-clipboard operation.\n *\n * The implementation of copying text to the clipboard modifies the DOM and\n * forces a relayout. This relayout can take too long if the string is large,\n * causing the execCommand('copy') to happen too long after the user clicked.\n * This results in the browser refusing to copy. This object lets the\n * relayout happen in a separate tick from copying by providing a copy function\n * that can be called later.\n *\n * Destroy must be called when no longer in use, regardless of whether `copy` is\n * called.\n */\n var PendingCopy = /** @class */ (function () {\n function PendingCopy(text, _document) {\n this._document = _document;\n var textarea = this._textarea = this._document.createElement('textarea');\n var styles = textarea.style;\n // Hide the element for display and accessibility. Set a fixed position so the page layout\n // isn't affected. We use `fixed` with `top: 0`, because focus is moved into the textarea\n // for a split second and if it's off-screen, some browsers will attempt to scroll it into view.\n styles.position = 'fixed';\n styles.top = styles.opacity = '0';\n styles.left = '-999em';\n textarea.setAttribute('aria-hidden', 'true');\n textarea.value = text;\n this._document.body.appendChild(textarea);\n }\n /** Finishes copying the text. */\n PendingCopy.prototype.copy = function () {\n var textarea = this._textarea;\n var successful = false;\n try { // Older browsers could throw if copy is not supported.\n if (textarea) {\n var currentFocus = this._document.activeElement;\n textarea.select();\n textarea.setSelectionRange(0, textarea.value.length);\n successful = this._document.execCommand('copy');\n if (currentFocus) {\n currentFocus.focus();\n }\n }\n }\n catch (_a) {\n // Discard error.\n // Initial setting of {@code successful} will represent failure here.\n }\n return successful;\n };\n /** Cleans up DOM changes used to perform the copy operation. */\n PendingCopy.prototype.destroy = function () {\n var textarea = this._textarea;\n if (textarea) {\n if (textarea.parentNode) {\n textarea.parentNode.removeChild(textarea);\n }\n this._textarea = undefined;\n }\n };\n return PendingCopy;\n }());\n\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.io/license\n */\n /**\n * A service for copying text to the clipboard.\n */\n var Clipboard = /** @class */ (function () {\n function Clipboard(document) {\n this._document = document;\n }\n /**\n * Copies the provided text into the user's clipboard.\n *\n * @param text The string to copy.\n * @returns Whether the operation was successful.\n */\n Clipboard.prototype.copy = function (text) {\n var pendingCopy = this.beginCopy(text);\n var successful = pendingCopy.copy();\n pendingCopy.destroy();\n return successful;\n };\n /**\n * Prepares a string to be copied later. This is useful for large strings\n * which take too long to successfully render and be copied in the same tick.\n *\n * The caller must call `destroy` on the returned `PendingCopy`.\n *\n * @param text The string to copy.\n * @returns the pending copy operation.\n */\n Clipboard.prototype.beginCopy = function (text) {\n return new PendingCopy(text, this._document);\n };\n return Clipboard;\n }());\n Clipboard.ɵprov = i0.ɵɵdefineInjectable({ factory: function Clipboard_Factory() { return new Clipboard(i0.ɵɵinject(i1.DOCUMENT)); }, token: Clipboard, providedIn: \"root\" });\n Clipboard.decorators = [\n { type: i0.Injectable, args: [{ providedIn: 'root' },] }\n ];\n Clipboard.ctorParameters = function () { return [\n { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] }\n ]; };\n\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.io/license\n */\n /** Injection token that can be used to provide the default options to `CdkCopyToClipboard`. */\n var CDK_COPY_TO_CLIPBOARD_CONFIG = new i0.InjectionToken('CDK_COPY_TO_CLIPBOARD_CONFIG');\n /**\n * @deprecated Use `CDK_COPY_TO_CLIPBOARD_CONFIG` instead.\n * @breaking-change 13.0.0\n */\n var CKD_COPY_TO_CLIPBOARD_CONFIG = CDK_COPY_TO_CLIPBOARD_CONFIG;\n /**\n * Provides behavior for a button that when clicked copies content into user's\n * clipboard.\n */\n var CdkCopyToClipboard = /** @class */ (function () {\n function CdkCopyToClipboard(_clipboard, _ngZone, config) {\n this._clipboard = _clipboard;\n this._ngZone = _ngZone;\n /** Content to be copied. */\n this.text = '';\n /**\n * How many times to attempt to copy the text. This may be necessary for longer text, because\n * the browser needs time to fill an intermediate textarea element and copy the content.\n */\n this.attempts = 1;\n /**\n * Emits when some text is copied to the clipboard. The\n * emitted value indicates whether copying was successful.\n */\n this.copied = new i0.EventEmitter();\n /** Copies that are currently being attempted. */\n this._pending = new Set();\n if (config && config.attempts != null) {\n this.attempts = config.attempts;\n }\n }\n /** Copies the current text to the clipboard. */\n CdkCopyToClipboard.prototype.copy = function (attempts) {\n var _this = this;\n if (attempts === void 0) { attempts = this.attempts; }\n if (attempts > 1) {\n var remainingAttempts_1 = attempts;\n var pending_1 = this._clipboard.beginCopy(this.text);\n this._pending.add(pending_1);\n var attempt_1 = function () {\n var successful = pending_1.copy();\n if (!successful && --remainingAttempts_1 && !_this._destroyed) {\n // We use 1 for the timeout since it's more predictable when flushing in unit tests.\n _this._currentTimeout = _this._ngZone.runOutsideAngular(function () { return setTimeout(attempt_1, 1); });\n }\n else {\n _this._currentTimeout = null;\n _this._pending.delete(pending_1);\n pending_1.destroy();\n _this.copied.emit(successful);\n }\n };\n attempt_1();\n }\n else {\n this.copied.emit(this._clipboard.copy(this.text));\n }\n };\n CdkCopyToClipboard.prototype.ngOnDestroy = function () {\n if (this._currentTimeout) {\n clearTimeout(this._currentTimeout);\n }\n this._pending.forEach(function (copy) { return copy.destroy(); });\n this._pending.clear();\n this._destroyed = true;\n };\n return CdkCopyToClipboard;\n }());\n CdkCopyToClipboard.decorators = [\n { type: i0.Directive, args: [{\n selector: '[cdkCopyToClipboard]',\n host: {\n '(click)': 'copy()',\n }\n },] }\n ];\n CdkCopyToClipboard.ctorParameters = function () { return [\n { type: Clipboard },\n { type: i0.NgZone },\n { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CKD_COPY_TO_CLIPBOARD_CONFIG,] }] }\n ]; };\n CdkCopyToClipboard.propDecorators = {\n text: [{ type: i0.Input, args: ['cdkCopyToClipboard',] }],\n attempts: [{ type: i0.Input, args: ['cdkCopyToClipboardAttempts',] }],\n copied: [{ type: i0.Output, args: ['cdkCopyToClipboardCopied',] }]\n };\n\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.io/license\n */\n var ClipboardModule = /** @class */ (function () {\n function ClipboardModule() {\n }\n return ClipboardModule;\n }());\n ClipboardModule.decorators = [\n { type: i0.NgModule, args: [{\n declarations: [CdkCopyToClipboard],\n exports: [CdkCopyToClipboard],\n },] }\n ];\n\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.io/license\n */\n\n /**\n * Generated bundle index. Do not edit.\n */\n\n exports.CDK_COPY_TO_CLIPBOARD_CONFIG = CDK_COPY_TO_CLIPBOARD_CONFIG;\n exports.CKD_COPY_TO_CLIPBOARD_CONFIG = CKD_COPY_TO_CLIPBOARD_CONFIG;\n exports.CdkCopyToClipboard = CdkCopyToClipboard;\n exports.Clipboard = Clipboard;\n exports.ClipboardModule = ClipboardModule;\n exports.PendingCopy = PendingCopy;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n//# sourceMappingURL=cdk-clipboard.umd.js.map\n"]}