source: trip-planner-front/node_modules/@angular/cdk/bundles/cdk-clipboard.umd.js@ 6c1585f

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

initial commit

  • Property mode set to 100644
File size: 11.4 KB
Line 
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core')) :
3 typeof define === 'function' && define.amd ? define('@angular/cdk/clipboard', ['exports', '@angular/common', '@angular/core'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.clipboard = {}), global.ng.common, global.ng.core));
5}(this, (function (exports, i1, i0) { 'use strict';
6
7 function _interopNamespace(e) {
8 if (e && e.__esModule) return e;
9 var n = Object.create(null);
10 if (e) {
11 Object.keys(e).forEach(function (k) {
12 if (k !== 'default') {
13 var d = Object.getOwnPropertyDescriptor(e, k);
14 Object.defineProperty(n, k, d.get ? d : {
15 enumerable: true,
16 get: function () {
17 return e[k];
18 }
19 });
20 }
21 });
22 }
23 n['default'] = e;
24 return Object.freeze(n);
25 }
26
27 var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28 var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
29
30 /**
31 * @license
32 * Copyright Google LLC All Rights Reserved.
33 *
34 * Use of this source code is governed by an MIT-style license that can be
35 * found in the LICENSE file at https://angular.io/license
36 */
37 /**
38 * A pending copy-to-clipboard operation.
39 *
40 * The implementation of copying text to the clipboard modifies the DOM and
41 * forces a relayout. This relayout can take too long if the string is large,
42 * causing the execCommand('copy') to happen too long after the user clicked.
43 * This results in the browser refusing to copy. This object lets the
44 * relayout happen in a separate tick from copying by providing a copy function
45 * that can be called later.
46 *
47 * Destroy must be called when no longer in use, regardless of whether `copy` is
48 * called.
49 */
50 var PendingCopy = /** @class */ (function () {
51 function PendingCopy(text, _document) {
52 this._document = _document;
53 var textarea = this._textarea = this._document.createElement('textarea');
54 var styles = textarea.style;
55 // Hide the element for display and accessibility. Set a fixed position so the page layout
56 // isn't affected. We use `fixed` with `top: 0`, because focus is moved into the textarea
57 // for a split second and if it's off-screen, some browsers will attempt to scroll it into view.
58 styles.position = 'fixed';
59 styles.top = styles.opacity = '0';
60 styles.left = '-999em';
61 textarea.setAttribute('aria-hidden', 'true');
62 textarea.value = text;
63 this._document.body.appendChild(textarea);
64 }
65 /** Finishes copying the text. */
66 PendingCopy.prototype.copy = function () {
67 var textarea = this._textarea;
68 var successful = false;
69 try { // Older browsers could throw if copy is not supported.
70 if (textarea) {
71 var currentFocus = this._document.activeElement;
72 textarea.select();
73 textarea.setSelectionRange(0, textarea.value.length);
74 successful = this._document.execCommand('copy');
75 if (currentFocus) {
76 currentFocus.focus();
77 }
78 }
79 }
80 catch (_a) {
81 // Discard error.
82 // Initial setting of {@code successful} will represent failure here.
83 }
84 return successful;
85 };
86 /** Cleans up DOM changes used to perform the copy operation. */
87 PendingCopy.prototype.destroy = function () {
88 var textarea = this._textarea;
89 if (textarea) {
90 if (textarea.parentNode) {
91 textarea.parentNode.removeChild(textarea);
92 }
93 this._textarea = undefined;
94 }
95 };
96 return PendingCopy;
97 }());
98
99 /**
100 * @license
101 * Copyright Google LLC All Rights Reserved.
102 *
103 * Use of this source code is governed by an MIT-style license that can be
104 * found in the LICENSE file at https://angular.io/license
105 */
106 /**
107 * A service for copying text to the clipboard.
108 */
109 var Clipboard = /** @class */ (function () {
110 function Clipboard(document) {
111 this._document = document;
112 }
113 /**
114 * Copies the provided text into the user's clipboard.
115 *
116 * @param text The string to copy.
117 * @returns Whether the operation was successful.
118 */
119 Clipboard.prototype.copy = function (text) {
120 var pendingCopy = this.beginCopy(text);
121 var successful = pendingCopy.copy();
122 pendingCopy.destroy();
123 return successful;
124 };
125 /**
126 * Prepares a string to be copied later. This is useful for large strings
127 * which take too long to successfully render and be copied in the same tick.
128 *
129 * The caller must call `destroy` on the returned `PendingCopy`.
130 *
131 * @param text The string to copy.
132 * @returns the pending copy operation.
133 */
134 Clipboard.prototype.beginCopy = function (text) {
135 return new PendingCopy(text, this._document);
136 };
137 return Clipboard;
138 }());
139 Clipboard.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function Clipboard_Factory() { return new Clipboard(i0__namespace.ɵɵinject(i1__namespace.DOCUMENT)); }, token: Clipboard, providedIn: "root" });
140 Clipboard.decorators = [
141 { type: i0.Injectable, args: [{ providedIn: 'root' },] }
142 ];
143 Clipboard.ctorParameters = function () { return [
144 { type: undefined, decorators: [{ type: i0.Inject, args: [i1.DOCUMENT,] }] }
145 ]; };
146
147 /**
148 * @license
149 * Copyright Google LLC All Rights Reserved.
150 *
151 * Use of this source code is governed by an MIT-style license that can be
152 * found in the LICENSE file at https://angular.io/license
153 */
154 /** Injection token that can be used to provide the default options to `CdkCopyToClipboard`. */
155 var CDK_COPY_TO_CLIPBOARD_CONFIG = new i0.InjectionToken('CDK_COPY_TO_CLIPBOARD_CONFIG');
156 /**
157 * @deprecated Use `CDK_COPY_TO_CLIPBOARD_CONFIG` instead.
158 * @breaking-change 13.0.0
159 */
160 var CKD_COPY_TO_CLIPBOARD_CONFIG = CDK_COPY_TO_CLIPBOARD_CONFIG;
161 /**
162 * Provides behavior for a button that when clicked copies content into user's
163 * clipboard.
164 */
165 var CdkCopyToClipboard = /** @class */ (function () {
166 function CdkCopyToClipboard(_clipboard, _ngZone, config) {
167 this._clipboard = _clipboard;
168 this._ngZone = _ngZone;
169 /** Content to be copied. */
170 this.text = '';
171 /**
172 * How many times to attempt to copy the text. This may be necessary for longer text, because
173 * the browser needs time to fill an intermediate textarea element and copy the content.
174 */
175 this.attempts = 1;
176 /**
177 * Emits when some text is copied to the clipboard. The
178 * emitted value indicates whether copying was successful.
179 */
180 this.copied = new i0.EventEmitter();
181 /** Copies that are currently being attempted. */
182 this._pending = new Set();
183 if (config && config.attempts != null) {
184 this.attempts = config.attempts;
185 }
186 }
187 /** Copies the current text to the clipboard. */
188 CdkCopyToClipboard.prototype.copy = function (attempts) {
189 var _this = this;
190 if (attempts === void 0) { attempts = this.attempts; }
191 if (attempts > 1) {
192 var remainingAttempts_1 = attempts;
193 var pending_1 = this._clipboard.beginCopy(this.text);
194 this._pending.add(pending_1);
195 var attempt_1 = function () {
196 var successful = pending_1.copy();
197 if (!successful && --remainingAttempts_1 && !_this._destroyed) {
198 // We use 1 for the timeout since it's more predictable when flushing in unit tests.
199 _this._currentTimeout = _this._ngZone.runOutsideAngular(function () { return setTimeout(attempt_1, 1); });
200 }
201 else {
202 _this._currentTimeout = null;
203 _this._pending.delete(pending_1);
204 pending_1.destroy();
205 _this.copied.emit(successful);
206 }
207 };
208 attempt_1();
209 }
210 else {
211 this.copied.emit(this._clipboard.copy(this.text));
212 }
213 };
214 CdkCopyToClipboard.prototype.ngOnDestroy = function () {
215 if (this._currentTimeout) {
216 clearTimeout(this._currentTimeout);
217 }
218 this._pending.forEach(function (copy) { return copy.destroy(); });
219 this._pending.clear();
220 this._destroyed = true;
221 };
222 return CdkCopyToClipboard;
223 }());
224 CdkCopyToClipboard.decorators = [
225 { type: i0.Directive, args: [{
226 selector: '[cdkCopyToClipboard]',
227 host: {
228 '(click)': 'copy()',
229 }
230 },] }
231 ];
232 CdkCopyToClipboard.ctorParameters = function () { return [
233 { type: Clipboard },
234 { type: i0.NgZone },
235 { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CKD_COPY_TO_CLIPBOARD_CONFIG,] }] }
236 ]; };
237 CdkCopyToClipboard.propDecorators = {
238 text: [{ type: i0.Input, args: ['cdkCopyToClipboard',] }],
239 attempts: [{ type: i0.Input, args: ['cdkCopyToClipboardAttempts',] }],
240 copied: [{ type: i0.Output, args: ['cdkCopyToClipboardCopied',] }]
241 };
242
243 /**
244 * @license
245 * Copyright Google LLC All Rights Reserved.
246 *
247 * Use of this source code is governed by an MIT-style license that can be
248 * found in the LICENSE file at https://angular.io/license
249 */
250 var ClipboardModule = /** @class */ (function () {
251 function ClipboardModule() {
252 }
253 return ClipboardModule;
254 }());
255 ClipboardModule.decorators = [
256 { type: i0.NgModule, args: [{
257 declarations: [CdkCopyToClipboard],
258 exports: [CdkCopyToClipboard],
259 },] }
260 ];
261
262 /**
263 * @license
264 * Copyright Google LLC All Rights Reserved.
265 *
266 * Use of this source code is governed by an MIT-style license that can be
267 * found in the LICENSE file at https://angular.io/license
268 */
269
270 /**
271 * Generated bundle index. Do not edit.
272 */
273
274 exports.CDK_COPY_TO_CLIPBOARD_CONFIG = CDK_COPY_TO_CLIPBOARD_CONFIG;
275 exports.CKD_COPY_TO_CLIPBOARD_CONFIG = CKD_COPY_TO_CLIPBOARD_CONFIG;
276 exports.CdkCopyToClipboard = CdkCopyToClipboard;
277 exports.Clipboard = Clipboard;
278 exports.ClipboardModule = ClipboardModule;
279 exports.PendingCopy = PendingCopy;
280
281 Object.defineProperty(exports, '__esModule', { value: true });
282
283})));
284//# sourceMappingURL=cdk-clipboard.umd.js.map
Note: See TracBrowser for help on using the repository browser.