Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@solid-primitives/selection

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/selection - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+6
-3
dist/index.cjs

@@ -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();

@@ -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();

{
"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"
}
}
}

@@ -7,3 +7,3 @@ <p>

[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=for-the-badge)](https://lerna.js.org/)
[![turborepo](https://img.shields.io/badge/built%20with-turborepo-cc00ff.svg?style=for-the-badge&logo=turborepo)](https://turborepo.org/)
[![size](https://img.shields.io/bundlephobia/minzip/@solid-primitives/selection?style=for-the-badge&label=size)](https://bundlephobia.com/package/@solid-primitives/selection)

@@ -36,7 +36,7 @@ [![version](https://img.shields.io/npm/v/@solid-primitives/selection?style=for-the-badge)](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)