mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
29 lines
794 B
TypeScript
29 lines
794 B
TypeScript
import type { Action } from 'svelte/action';
|
|
|
|
type Props = {
|
|
onChange: (selectionStart: number) => void;
|
|
};
|
|
|
|
export const selectionStart: Action<HTMLInputElement, Props> = (node, { onChange }) => {
|
|
const handler = () => {
|
|
onChange(node.selectionStart);
|
|
};
|
|
node.addEventListener('click', handler);
|
|
node.addEventListener('keydown', handler);
|
|
node.addEventListener('keyup', handler);
|
|
|
|
return {
|
|
update({ onChange }) {
|
|
const handler = () => {
|
|
onChange(node.selectionStart);
|
|
};
|
|
node.addEventListener('click', handler);
|
|
node.addEventListener('keydown', handler);
|
|
node.addEventListener('keyup', handler);
|
|
},
|
|
destroy() {
|
|
onChange(-1);
|
|
}
|
|
};
|
|
};
|