Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-aria/toggle

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-aria/toggle - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

7

dist/index.d.ts

@@ -79,2 +79,6 @@ import { InputBase, Validation, FocusableProps, FocusableDOMProps, AriaLabelingProps, AriaValidationProps } from '@solid-aria/types';

inputProps: Accessor<JSX.InputHTMLAttributes<HTMLInputElement>>;
/**
* State for the toggle element, as returned by `createToggleState`.
*/
state: ToggleState;
}

@@ -84,7 +88,6 @@ /**

* @param props - Props for the toggle element.
* @param state - State for the toggle element, as returned by `createToggleState`.
* @param inputRef - Ref to the HTML input element.
*/
declare function createToggle(props: AriaToggleProps, state: ToggleState, inputRef: Accessor<HTMLInputElement | undefined>): ToggleAria;
declare function createToggle(props: AriaToggleProps, inputRef: Accessor<HTMLInputElement | undefined>): ToggleAria;
export { AriaToggleProps, ToggleAria, ToggleState, createToggle, createToggleState };

@@ -6,3 +6,32 @@ // src/createToggle.ts

import { createMemo, mergeProps, splitProps } from "solid-js";
function createToggle(props, state, inputRef) {
// src/createToggleState.ts
import { createControllableBooleanSignal } from "@solid-aria/utils";
import { access } from "@solid-primitives/utils";
function createToggleState(props = {}) {
const [isSelected, setSelected] = createControllableBooleanSignal({
value: () => access(props.isSelected),
defaultValue: () => !!access(props.defaultSelected),
onChange: props.onChange
});
const updateSelected = (value) => {
if (!access(props.isReadOnly)) {
setSelected(value);
}
};
const toggleSelected = () => {
if (!access(props.isReadOnly)) {
setSelected(!isSelected());
}
};
return {
isSelected,
setSelected: updateSelected,
toggle: toggleSelected
};
}
// src/createToggle.ts
function createToggle(props, inputRef) {
const state = createToggleState(props);
const defaultProps = {

@@ -46,30 +75,4 @@ isDisabled: false,

});
return { inputProps };
return { inputProps, state };
}
// src/createToggleState.ts
import { createControllableBooleanSignal } from "@solid-aria/utils";
import { access } from "@solid-primitives/utils";
function createToggleState(props = {}) {
const [isSelected, setSelected] = createControllableBooleanSignal({
value: () => access(props.isSelected),
defaultValue: () => !!access(props.defaultSelected),
onChange: props.onChange
});
const updateSelected = (value) => {
if (!access(props.isReadOnly)) {
setSelected(value);
}
};
const toggleSelected = () => {
if (!access(props.isReadOnly)) {
setSelected(!isSelected());
}
};
return {
isSelected,
setSelected: updateSelected,
toggle: toggleSelected
};
}
export {

@@ -76,0 +79,0 @@ createToggle,

{
"name": "@solid-aria/toggle",
"version": "0.0.2",
"version": "0.0.3",
"private": false,

@@ -5,0 +5,0 @@ "description": "Primitives for building toggle components like checkboxes and switches.",

Sorry, the diff of this file is not supported yet

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