New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/active-element

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/active-element

A reactive document.activeElement. Check which element is currently focused.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
increased by141.07%
Maintainers
2
Weekly downloads
 
Created
Source

@solid-primitives/active-element

lerna size size stage

Installation

npm install @solid-primitives/active-element
# or
yarn add @solid-primitives/active-element

createActiveElement

A reactive document.activeElement. Check which element is currently focused.

How to use it

import { createActiveElement } from "@solid-primitives/active-element";

const [activeEl, clear] = createActiveElement();

createEffect(() => {
  console.log(activeEl());
});

// clear all event listeners
clear();

Types

function createActiveElement(): [getter: Accessor<null | Element>, clear: ClearListeners];

createIsElementActive

Pass in an element, and see if it's focused.

How to use it

import { createIsElementActive } from "@solid-primitives/active-element";

const [isFocused, clear] = createIsElementActive(() => el);
// "stop" and "start" are for adding and removing event listeners

// you can also use signals for ref
const [ref, setRef] = createSignal<Element>();
const [isFocused] = createIsElementActive(ref);
// this way if the element changes,
// the "isFocused" will start checking the new element

// clear all event listeners
clear();

As Directive

import { isElementActive } from "@solid-primitives/active-element";
// prevent tree-shaking
isElementActive;

const [active, setActive] = createSignal(false)

<input use:isElementActive={setActive} />

Types

function createIsElementActive(
  target: MaybeAccessor<Element>
): [getter: Accessor<boolean>, clear: ClearListeners];

type IsElementActiveProps = (isActive: boolean) => void;

Demo

https://codesandbox.io/s/solid-primitives-active-element-q4kul?file=/index.tsx

Changelog

Expand Changelog

1.0.0

Initial release as a Stage-2 primitive.

1.0.1

Updated event listener and util dependencies.

Keywords

FAQs

Package last updated on 12 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc