@solid-primitives/active-element
Advanced tools
Comparing version 2.0.10 to 2.0.11
@@ -1,2 +0,3 @@ | ||
import { createHydrateSignal } from '@solid-primitives/utils'; | ||
import { isServer } from 'solid-js/web'; | ||
import { createHydratableSignal } from '@solid-primitives/utils'; | ||
import { makeEventListener, createEventListener } from '@solid-primitives/event-listener'; | ||
@@ -7,2 +8,5 @@ | ||
function makeActiveElementListener(callback) { | ||
if (isServer) { | ||
return () => void 0; | ||
} | ||
const handleChange = () => callback(getActiveElement()); | ||
@@ -14,3 +18,6 @@ const clear1 = makeEventListener(window, "blur", handleChange, true); | ||
function createActiveElement() { | ||
const [active, setActive] = createHydrateSignal(null, getActiveElement); | ||
if (isServer) { | ||
return () => null; | ||
} | ||
const [active, setActive] = createHydratableSignal(null, getActiveElement); | ||
makeActiveElementListener(setActive); | ||
@@ -20,2 +27,5 @@ return active; | ||
function makeFocusListener(target, callback, useCapture = true) { | ||
if (isServer) { | ||
return () => void 0; | ||
} | ||
const clear1 = makeEventListener(target, "blur", callback.bind(void 0, false), useCapture); | ||
@@ -26,3 +36,6 @@ const clear2 = makeEventListener(target, "focus", callback.bind(void 0, true), useCapture); | ||
function createFocusSignal(target) { | ||
const [isActive, setIsActive] = createHydrateSignal( | ||
if (isServer) { | ||
return () => false; | ||
} | ||
const [isActive, setIsActive] = createHydratableSignal( | ||
false, | ||
@@ -36,2 +49,5 @@ () => document.activeElement === target | ||
var focus = (target, props) => { | ||
if (isServer) { | ||
return; | ||
} | ||
const callback = props(); | ||
@@ -38,0 +54,0 @@ callback(document.activeElement === target); |
{ | ||
"name": "@solid-primitives/active-element", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "A reactive document.activeElement. Check which element is currently focused.", | ||
@@ -30,38 +30,7 @@ "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>", | ||
"type": "module", | ||
"main": "./dist/server.cjs", | ||
"module": "./dist/server.js", | ||
"browser": { | ||
"./dist/server.js": "./dist/index.js", | ||
"./dist/server.cjs": "./dist/index.cjs" | ||
}, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"browser": {}, | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
"worker": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"browser": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": "./dist/index.cjs" | ||
}, | ||
"deno": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"node": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"import": { | ||
@@ -80,7 +49,7 @@ "types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"@solid-primitives/event-listener": "^2.2.8", | ||
"@solid-primitives/utils": "^5.4.0" | ||
"@solid-primitives/event-listener": "^2.2.9", | ||
"@solid-primitives/utils": "^5.5.1" | ||
}, | ||
"peerDependencies": { | ||
"solid-js": "^1.6.0" | ||
"solid-js": "^1.6.12" | ||
}, | ||
@@ -91,3 +60,3 @@ "typesVersions": {}, | ||
"page": "vite build dev", | ||
"build": "jiti ../../scripts/build.ts --ssr", | ||
"build": "jiti ../../scripts/build.ts", | ||
"test": "vitest -c ../../configs/vitest.config.ts", | ||
@@ -94,0 +63,0 @@ "test:ssr": "pnpm run test --mode ssr" |
Sorry, the diff of this file is not supported yet
13867
6
172