/* App.svelte generated by Svelte v4.2.19 */
import {
SvelteComponent,
action_destroyer,
append,
detach,
element,
init,
insert,
listen,
noop,
run_all,
safe_not_equal,
set_data,
space,
text as text_1
} from "svelte/internal";
import "svelte/internal/disclose-version";
import { clickToCopy } from "./clickToCopy.js";
function create_fragment(ctx) {
let p;
let clickToCopy_action;
let t1;
let textarea;
let t2;
let div;
let t3;
let t4;
let mounted;
let dispose;
return {
c() {
p = element("p");
p.textContent = "Click this text to copy it.";
t1 = space();
textarea = element("textarea");
t2 = space();
div = element("div");
t3 = text_1("Result: ");
t4 = text_1(/*text*/ ctx[0]);
},
m(target, anchor) {
insert(target, p, anchor);
insert(target, t1, anchor);
insert(target, textarea, anchor);
insert(target, t2, anchor);
insert(target, div, anchor);
append(div, t3);
append(div, t4);
if (!mounted) {
dispose = [
listen(window, "copysuccess", /*copySuccess*/ ctx[1]),
listen(window, "copyerror", /*copyError*/ ctx[2]),
action_destroyer(clickToCopy_action = clickToCopy.call(null, p)),
listen(textarea, "paste", /*paste_handler*/ ctx[3])
];
mounted = true;
}
},
p(ctx, [dirty]) {
if (dirty & /*text*/ 1) set_data(t4, /*text*/ ctx[0]);
},
i: noop,
o: noop,
d(detaching) {
if (detaching) {
detach(p);
detach(t1);
detach(textarea);
detach(t2);
detach(div);
}
mounted = false;
run_all(dispose);
}
};
}
function instance($$self, $$props, $$invalidate) {
let text = '';
function copySuccess() {
$$invalidate(0, text = "Success!");
}
function copyError(event) {
$$invalidate(0, text = `Error! ${event.detail}`);
}
const paste_handler = () => $$invalidate(0, text = '');
return [text, copySuccess, copyError, paste_handler];
}
class App extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
}
}
export default App;
/* Add a <style> tag to see compiled CSS */
- {
-
- css: undefined
- {
- type: "Script"
- start: 0
- end: 201
- context: "default"
-
} - module: undefined
}