@solid-primitives/selection
Advanced tools
+6
-3
@@ -0,1 +1,2 @@ | ||
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
@@ -43,3 +44,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var getParent = (node) => node === null || (node == null ? void 0 : node.contentEditable) === "true" ? node : getParent(node.parentNode || null); | ||
| var getRangeArgs = (offset, texts) => texts.reduce(([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length], [null, offset]); | ||
| var getRangeArgs = (offset, texts) => texts.reduce( | ||
| ([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length], | ||
| [null, offset] | ||
| ); | ||
| var createSelection = () => { | ||
@@ -49,6 +53,5 @@ const [selection, setSelection] = (0, import_solid_js.createSignal)([null, NaN, NaN]); | ||
| const selectionHandler = () => { | ||
| var _a, _b; | ||
| const active = document.activeElement; | ||
| if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) { | ||
| return setSelection([active, (_a = active.selectionStart) != null ? _a : NaN, (_b = active.selectionEnd) != null ? _b : NaN]); | ||
| return setSelection([active, active.selectionStart ?? NaN, active.selectionEnd ?? NaN]); | ||
| } | ||
@@ -55,0 +58,0 @@ const selection2 = window.getSelection(); |
+5
-3
@@ -19,3 +19,6 @@ // src/index.ts | ||
| var getParent = (node) => node === null || (node == null ? void 0 : node.contentEditable) === "true" ? node : getParent(node.parentNode || null); | ||
| var getRangeArgs = (offset, texts) => texts.reduce(([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length], [null, offset]); | ||
| var getRangeArgs = (offset, texts) => texts.reduce( | ||
| ([node, pos], text) => node ? [node, pos] : pos <= text.data.length ? [text, pos] : [null, pos - text.data.length], | ||
| [null, offset] | ||
| ); | ||
| var createSelection = () => { | ||
@@ -25,6 +28,5 @@ const [selection, setSelection] = createSignal([null, NaN, NaN]); | ||
| const selectionHandler = () => { | ||
| var _a, _b; | ||
| const active = document.activeElement; | ||
| if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) { | ||
| return setSelection([active, (_a = active.selectionStart) != null ? _a : NaN, (_b = active.selectionEnd) != null ? _b : NaN]); | ||
| return setSelection([active, active.selectionStart ?? NaN, active.selectionEnd ?? NaN]); | ||
| } | ||
@@ -31,0 +33,0 @@ const selection2 = window.getSelection(); |
+19
-18
| { | ||
| "name": "@solid-primitives/selection", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "selection primitive.", | ||
@@ -32,8 +32,2 @@ "author": "Alex Lohr <alex.lohr@logmein.com>", | ||
| ], | ||
| "scripts": { | ||
| "start": "vite serve dev --host", | ||
| "dev": "yarn start", | ||
| "build": "tsup", | ||
| "test": "uvu -r solid-register" | ||
| }, | ||
| "keywords": [ | ||
@@ -44,16 +38,23 @@ "solid", | ||
| "devDependencies": { | ||
| "jsdom": "^19.0.0", | ||
| "prettier": "^2.6.0", | ||
| "solid-register": "^0.1.5", | ||
| "tslib": "^2.3.1", | ||
| "tsup": "^5.12.1", | ||
| "typescript": "^4.6.2", | ||
| "unocss": "0.28.1", | ||
| "uvu": "^0.5.3", | ||
| "vite": "2.8.6", | ||
| "vite-plugin-solid": "2.2.6" | ||
| "jsdom": "^20.0.0", | ||
| "prettier": "^2.7.1", | ||
| "solid-js": "^1.5.1", | ||
| "solid-register": "^0.2.5", | ||
| "tslib": "^2.4.0", | ||
| "tsup": "^6.2.2", | ||
| "typescript": "^4.7.4", | ||
| "unocss": "^0.44.7", | ||
| "uvu": "^0.5.6", | ||
| "vite": "^3.0.7", | ||
| "vite-plugin-solid": "^2.3.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "solid-js": ">=1.0.0" | ||
| }, | ||
| "scripts": { | ||
| "start": "vite serve dev --host", | ||
| "dev": "npm run start", | ||
| "build": "tsup", | ||
| "test": "uvu -r solid-register" | ||
| } | ||
| } | ||
| } |
+8
-15
@@ -7,3 +7,3 @@ <p> | ||
| [](https://lerna.js.org/) | ||
| [](https://turborepo.org/) | ||
| [](https://bundlephobia.com/package/@solid-primitives/selection) | ||
@@ -36,7 +36,7 @@ [](https://www.npmjs.com/package/@solid-primitives/selection) | ||
| // select the second to fourth letter inside a contentEditable div: | ||
| setSelection([document.querySelector('div[contenteditable]'), 1, 3]); | ||
| setSelection([document.querySelector("div[contenteditable]"), 1, 3]); | ||
| selection(); // [HTMLDivElement, 1, 3] | ||
| // change the selection to a cursor behind the fourth letter inside the first input: | ||
| setSelection([document.querySelector('input'), 3, 3]); | ||
| setSelection([document.querySelector("input"), 3, 3]); | ||
| selection(); // [HTMLInputElement, 3, 3] | ||
@@ -56,5 +56,5 @@ | ||
| const ibanMask = anyMaskToFn('aa99999999999999999999'); | ||
| const ibanMask = anyMaskToFn("aa99999999999999999999"); | ||
| const inputMaskHandler = (ev) => { | ||
| const inputMaskHandler = ev => { | ||
| const [node, start, end] = selection(); | ||
@@ -68,3 +68,3 @@ if (ev.currentTarget === node) { | ||
| return <div contenteditable onInput={inputMaskHandler}></div> | ||
| return <div contenteditable onInput={inputMaskHandler}></div>; | ||
| ``` | ||
@@ -79,3 +79,3 @@ | ||
| ```ts | ||
| import { getTextNodes } from '@solid-primitives/select'; | ||
| import { getTextNodes } from "@solid-primitives/select"; | ||
@@ -93,9 +93,2 @@ getTextNodes(div); // [Text, Text, Text] | ||
| <details> | ||
| <summary><b>Expand Changelog</b></summary> | ||
| 0.0.100 | ||
| Initial release as a Stage-0 primitive. | ||
| </details> | ||
| See [CHANGELOG.md](./CHANGELOG.md) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
194
2.65%14620
-0.77%11
10%89
-7.29%1
Infinity%