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

@aria-ui/core

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aria-ui/core - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

6

CHANGELOG.md
# @aria-ui/core
## 0.0.6
### Patch Changes
- d4e70a4: The default value for a context needs to be assigned when creating the context.
## 0.0.5

@@ -4,0 +10,0 @@

121

dist/index.d.ts

@@ -1,3 +0,2 @@

import { Signal } from '@preact/signals-core';
export { ReadonlySignal, Signal, batch, computed as createComputed, signal as createSignal, untracked } from '@preact/signals-core';
import { Signal as Signal$1, ReadonlySignal as ReadonlySignal$1, batch as batch$1, untracked as untracked$1, signal, computed } from '@preact/signals-core';
import { AriaAttributes } from '@dddstack/ariatype-aria-attributes';

@@ -8,2 +7,4 @@ import { AriaRole } from '@dddstack/ariatype-aria-roles';

* Any HTML element that has implemented the `addConnectedCallback` method.
*
* @group Elements
*/

@@ -22,2 +23,4 @@ interface ConnectableElement extends HTMLElement {

* {@link ConnectableElement} interface.
*
* @group Elements
*/

@@ -46,3 +49,75 @@ declare class BaseElement extends HTMLElement implements ConnectableElement {

/**
* A mutable signal that can be used to manage reactive state changes.
*
* This is a re-export of `Signal` type from `@preact/signals-core`.
*
* @group Signals
*/
type Signal<T> = Signal$1<T>;
/**
* A read-only signal, providing a way to observe state changes without the
* ability to modify the state.
*
* This is a re-export of `ReadonlySignal` type from `@preact/signals-core`.
*
* @group Signals
*/
type ReadonlySignal<T> = ReadonlySignal$1<T>;
/**
* Groups multiple signal updates into a single batch, optimizing performance by reducing the number of updates.
*
* This is a re-export of `batch` from `@preact/signals-core`.
*
* @group Signals
*/
declare const batch: typeof batch$1;
/**
* Executes a given computation without automatically tracking its dependencies,
* useful for avoiding unnecessary re-computations.
*
* This is a re-export of `untracked` from `@preact/signals-core`.
*
* @group Signals
*/
declare const untracked: typeof untracked$1;
/**
* Creates and returns a new signal with the given initial value. Signals are
* reactive data sources that can be read and written to, allowing components to
* reactively update when their values change.
*
* This is an alias for `signal` from `@preact/signals-core`.
*
* @group Signals
*/
declare const createSignal: typeof signal;
/**
* Creates a computed signal that automatically updates its value based on the
* reactive dependencies it uses. Computed signals are read-only and are used to
* derive state from other signals, recalculating their value when dependencies
* change.
*
* This is an alias for `computed` from `@preact/signals-core`.
*
* @group Signals
*/
declare const createComputed: typeof computed;
/**
* Registers a callback to be called when the given element is connected to the
* DOM. It will track which signals are accessed and re-run their callback when
* those signals change. The callback can return a cleanup function that will be
* called when the effect is destroyed.
*
* The effect will be destroyed and all signals it was subscribed to will be
* unsubscribed from, when the element is disconnected from the DOM. You can also
* manually destroy the effect by calling the returned function.
*
* @group Signals
*/
declare function useEffect(element: ConnectableElement, callback: () => VoidFunction | void): () => void;
/**
* Extracts the value type from a signal type.
*
* @group Signals
*/
type SignalValue<S> = S extends Signal<infer T> ? T : never;

@@ -52,2 +127,4 @@

* A context is a way to provide and consume signals in a HTML tree.
*
* @group Contexts
*/

@@ -64,16 +141,35 @@ interface Context<T> {

* @param element The element to consume the signal from.
* @param defaultValue The default value to return if the signal is not provided.
* @returns A signal that is double bound to the provided signal.
*/
consume(element: ConnectableElement, defaultValue: T): Signal<T>;
consume(element: ConnectableElement): Signal<T>;
}
/**
* Creates a new context.
*
* @param key The key to use for the context.
* @param defaultValue The default value to return if the signal is not provided.
*
* @group Contexts
*/
declare function createContext<T>(key: string | symbol): Context<T>;
declare function createContext<T>(key: string | symbol, defaultValue: T): Context<T>;
/**
* @group DOM
*/
declare function useEventListener<K extends keyof HTMLElementEventMap>(element: ConnectableElement, type: K, listener: (event: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
/**
* @group DOM
*/
declare function useStyle<K extends keyof CSSStyleDeclaration>(element: ConnectableElement, key: K, compute: () => CSSStyleDeclaration[K]): () => void;
/**
* @group DOM
*/
declare function useAttribute(element: ConnectableElement, key: string, compute: () => string | number | undefined): () => void;
/**
* @group DOM
*/
declare function useAriaAttribute<K extends keyof AriaAttributes>(element: ConnectableElement, key: K, compute: () => AriaAttributes[K]): () => void;
/**
* @group DOM
*/
declare function useAriaRole(element: ConnectableElement, compute: () => AriaRole | undefined): () => void;

@@ -84,10 +180,19 @@

* present in the first object will be included in the result.
*
* @group Props and States
*/
declare function assignProps<T extends object>(defaultProps: Readonly<T>, props?: Partial<T>): Readonly<T>;
/**
* A plain object containing signals.
*
* @group Props and States
*/
type SingalState<T extends object> = {
[K in keyof T]: Signal<T[K]>;
[K in keyof T]: Signal$1<T[K]>;
};
/**
* Maps every signal in the given object to its current value.
*
* @group Props and States
*/

@@ -97,5 +202,7 @@ declare function mapValues<T extends object>(signals: SingalState<T>): T;

* Maps every value in the given object to a signal.
*
* @group Props and States
*/
declare function mapSignals<T extends object>(values: T): SingalState<T>;
export { BaseElement, type ConnectableElement, type Context, type SignalValue, type SingalState, assignProps, createContext, mapSignals, mapValues, useAriaAttribute, useAriaRole, useAttribute, useEffect, useEventListener, useStyle };
export { BaseElement, type ConnectableElement, type Context, type ReadonlySignal, type Signal, type SignalValue, type SingalState, assignProps, batch, createComputed, createContext, createSignal, mapSignals, mapValues, untracked, useAriaAttribute, useAriaRole, useAttribute, useEffect, useEventListener, useStyle };

26

dist/index.js

@@ -55,8 +55,12 @@ // src/base-element.ts

import {
batch,
batch as _batch,
untracked as _untracked,
computed,
effect,
signal,
untracked
signal
} from "@preact/signals-core";
var batch = _batch;
var untracked = _untracked;
var createSignal = signal;
var createComputed = computed;
function useEffect(element, callback) {

@@ -85,4 +89,5 @@ let cleanup = void 0;

var ContextImpl = class {
constructor(key) {
constructor(key, defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
this.provide = this.provide.bind(this);

@@ -99,4 +104,4 @@ this.consume = this.consume.bind(this);

}
consume(element, defaultValue) {
const consumer = signal(defaultValue);
consume(element) {
const consumer = createSignal(this.defaultValue);
let dispose = void 0;

@@ -135,5 +140,6 @@ element.addConnectedCallback(() => {

}
function createContext(key) {
function createContext(key, defaultValue) {
return new ContextImpl(
typeof key === "string" ? `aria-ui/context/${key}` : key
typeof key === "string" ? `aria-ui/context/${key}` : key,
defaultValue
);

@@ -212,5 +218,5 @@ }

batch,
computed as createComputed,
createComputed,
createContext,
signal as createSignal,
createSignal,
mapSignals,

@@ -217,0 +223,0 @@ mapValues,

{
"name": "@aria-ui/core",
"type": "module",
"version": "0.0.5",
"version": "0.0.6",
"private": false,
"sideEffects": false,
"main": "dist/index.js",
"main": "src/index.ts",
"scripts": {
"build": "tsup"
},
"dependencies": {

@@ -18,9 +21,7 @@ "@dddstack/ariatype-aria-attributes": "^2.0.0",

"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsup"
},
"module": "dist/index.js",
"types": "dist/index.d.ts"
}
"access": "public",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts"
}
}

@@ -19,52 +19,106 @@ # @aria-ui/core

## Classes
## Contexts
### BaseElement
### Context\<T\>
Base class for all custom elements in Aria UI. It implements the [ConnectableElement](README.md#connectableelement) interface.
A context is a way to provide and consume signals in a HTML tree.
#### Methods
##### consume()
```ts
new BaseElement(): BaseElement
consume(element: ConnectableElement): Signal<T>
```
## Interfaces
Receives the signal from a parent element.
### ConnectableElement
##### provide()
Any HTML element that has implemented the `addConnectedCallback` method.
```ts
provide(element: ConnectableElement, signal: Signal<T>): void
```
| Property | Type | Description |
| :-- | :-- | :-- |
| `addConnectedCallback` | (`callback`: () => `void` \| `VoidFunction`) => `void` | Registers a callback to be called when the element is connected to the DOM.<br />This callback can return a cleanup function that will be called when the<br />element is disconnected from the DOM. |
Provides a signal to all children of the element.
### Context\<T\>
### createContext()
A context is a way to provide and consume signals in a HTML tree.
```ts
function createContext<T>(key: string | symbol, defaultValue: T): Context<T>;
```
#### Methods
Creates a new context.
##### consume()
## DOM
### useAriaAttribute()
```ts
consume(element: ConnectableElement, defaultValue: T): Signal<T>
function useAriaAttribute<K>(
element: ConnectableElement,
key: K,
compute: () => AriaAttributes[K],
): () => void;
```
Receives the signal from a parent element.
### useAriaRole()
##### provide()
```ts
function useAriaRole(
element: ConnectableElement,
compute: () => undefined | AriaRole,
): () => void;
```
### useAttribute()
```ts
provide(element: ConnectableElement, signal: Signal<T>): void
function useAttribute(
element: ConnectableElement,
key: string,
compute: () => undefined | string | number,
): () => void;
```
Provides a signal to all children of the element.
### useEventListener()
## Type Aliases
```ts
function useEventListener<K>(
element: ConnectableElement,
type: K,
listener: (event: HTMLElementEventMap[K]) => void,
options?: boolean | AddEventListenerOptions,
): void;
```
### SignalValue\<S\>
### useStyle()
```ts
type SignalValue<S>: S extends Signal<infer T> ? T : never;
function useStyle<K>(
element: ConnectableElement,
key: K,
compute: () => CSSStyleDeclaration[K],
): () => void;
```
## Elements
### BaseElement
Base class for all custom elements in Aria UI. It implements the [ConnectableElement](README.md#connectableelement) interface.
```ts
new BaseElement(): BaseElement
```
### ConnectableElement
Any HTML element that has implemented the `addConnectedCallback` method.
| Property | Type | Description |
| :-- | :-- | :-- |
| `addConnectedCallback` | (`callback`: () => `void` \| `VoidFunction`) => `void` | Registers a callback to be called when the element is connected to the DOM.<br />This callback can return a cleanup function that will be called when the<br />element is disconnected from the DOM. |
## Props and States
### SingalState\<T\>

@@ -76,3 +130,3 @@

## Functions
A plain object containing signals.

@@ -90,10 +144,2 @@ ### assignProps()

### createContext()
```ts
function createContext<T>(key: string | symbol): Context<T>;
```
Creates a new context.
### mapSignals()

@@ -115,59 +161,83 @@

### useAriaAttribute()
## Signals
### ReadonlySignal\<T\>
```ts
function useAriaAttribute<K>(
element: ConnectableElement,
key: K,
compute: () => AriaAttributes[K],
): () => void;
type ReadonlySignal<T>: _ReadonlySignal<T>;
```
### useAriaRole()
A read-only signal, providing a way to observe state changes without the ability to modify the state.
This is a re-export of `ReadonlySignal` type from `@preact/signals-core`.
### Signal\<T\>
```ts
function useAriaRole(
element: ConnectableElement,
compute: () => undefined | AriaRole,
): () => void;
type Signal<T>: _Signal<T>;
```
### useAttribute()
A mutable signal that can be used to manage reactive state changes.
This is a re-export of `Signal` type from `@preact/signals-core`.
### SignalValue\<S\>
```ts
function useAttribute(
element: ConnectableElement,
key: string,
compute: () => undefined | string | number,
): () => void;
type SignalValue<S>: S extends Signal<infer T> ? T : never;
```
### useEffect()
Extracts the value type from a signal type.
### batch()
```ts
function useEffect(
element: ConnectableElement,
callback: () => void | VoidFunction,
): () => void;
function batch<T>(callback: () => T): T;
```
### useEventListener()
Groups multiple signal updates into a single batch, optimizing performance by reducing the number of updates.
This is a re-export of `batch` from `@preact/signals-core`.
### createComputed()
```ts
function useEventListener<K>(
element: ConnectableElement,
type: K,
listener: (event: HTMLElementEventMap[K]) => void,
options?: boolean | AddEventListenerOptions,
): void;
function createComputed<T>(compute: () => T): ReadonlySignal<T>;
```
### useStyle()
Creates a computed signal that automatically updates its value based on the reactive dependencies it uses. Computed signals are read-only and are used to derive state from other signals, recalculating their value when dependencies change.
This is an alias for `computed` from `@preact/signals-core`.
### createSignal()
```ts
function useStyle<K>(
function createSignal<T>(value: T): Signal<T>;
```
Creates and returns a new signal with the given initial value. Signals are reactive data sources that can be read and written to, allowing components to reactively update when their values change.
This is an alias for `signal` from `@preact/signals-core`.
### untracked()
```ts
function untracked<T>(callback: () => T): T;
```
Executes a given computation without automatically tracking its dependencies, useful for avoiding unnecessary re-computations.
This is a re-export of `untracked` from `@preact/signals-core`.
### useEffect()
```ts
function useEffect(
element: ConnectableElement,
key: K,
compute: () => CSSStyleDeclaration[K],
callback: () => void | VoidFunction,
): () => void;
```
Registers a callback to be called when the given element is connected to the DOM. It will track which signals are accessed and re-run their callback when those signals change. The callback can return a cleanup function that will be called when the effect is destroyed.
The effect will be destroyed and all signals it was subscribed to will be unsubscribed from, when the element is disconnected from the DOM. You can also manually destroy the effect by calling the returned function.

@@ -6,2 +6,4 @@ import type { ConnectableElement } from "./connectable-element"

* {@link ConnectableElement} interface.
*
* @group Elements
*/

@@ -8,0 +10,0 @@ export class BaseElement extends HTMLElement implements ConnectableElement {

/**
* Any HTML element that has implemented the `addConnectedCallback` method.
*
* @group Elements
*/

@@ -4,0 +6,0 @@ export interface ConnectableElement extends HTMLElement {

@@ -15,2 +15,4 @@ import type { ConnectableElement } from "./connectable-element"

* A context is a way to provide and consume signals in a HTML tree.
*
* @group Contexts
*/

@@ -27,10 +29,12 @@ export interface Context<T> {

* @param element The element to consume the signal from.
* @param defaultValue The default value to return if the signal is not provided.
* @returns A signal that is double bound to the provided signal.
*/
consume(element: ConnectableElement, defaultValue: T): Signal<T>
consume(element: ConnectableElement): Signal<T>
}
class ContextImpl<T> implements Context<T> {
public constructor(private readonly key: string | symbol) {
public constructor(
private readonly key: string | symbol,
private readonly defaultValue: T,
) {
this.provide = this.provide.bind(this)

@@ -49,4 +53,4 @@ this.consume = this.consume.bind(this)

public consume(element: ConnectableElement, defaultValue: T): Signal<T> {
const consumer = createSignal<T>(defaultValue)
public consume(element: ConnectableElement): Signal<T> {
const consumer = createSignal<T>(this.defaultValue)
let dispose: VoidFunction | undefined = undefined

@@ -94,7 +98,16 @@

* Creates a new context.
*
* @param key The key to use for the context.
* @param defaultValue The default value to return if the signal is not provided.
*
* @group Contexts
*/
export function createContext<T>(key: string | symbol): Context<T> {
export function createContext<T>(
key: string | symbol,
defaultValue: T,
): Context<T> {
return new ContextImpl<T>(
typeof key === "string" ? `aria-ui/context/${key}` : key,
defaultValue,
)
}

@@ -7,2 +7,5 @@ import type { AriaAttributes } from "@dddstack/ariatype-aria-attributes"

/**
* @group DOM
*/
export function useEventListener<K extends keyof HTMLElementEventMap>(

@@ -22,2 +25,5 @@ element: ConnectableElement,

/**
* @group DOM
*/
export function useStyle<K extends keyof CSSStyleDeclaration>(

@@ -33,2 +39,5 @@ element: ConnectableElement,

/**
* @group DOM
*/
export function useAttribute(

@@ -49,2 +58,5 @@ element: ConnectableElement,

/**
* @group DOM
*/
export function useAriaAttribute<K extends keyof AriaAttributes>(

@@ -58,2 +70,5 @@ element: ConnectableElement,

/**
* @group DOM
*/
export function useAriaRole(

@@ -60,0 +75,0 @@ element: ConnectableElement,

@@ -6,2 +6,4 @@ import { getObjectKeys } from "./types"

* present in the first object will be included in the result.
*
* @group Props and States
*/

@@ -8,0 +10,0 @@ export function assignProps<T extends object>(

import {
type ReadonlySignal,
type Signal,
batch,
batch as _batch,
untracked as _untracked,
computed,
effect,
signal,
untracked,
type ReadonlySignal as _ReadonlySignal,
type Signal as _Signal,
} from "@preact/signals-core"

@@ -13,5 +13,75 @@

export type { Signal, ReadonlySignal }
export { signal as createSignal, computed as createComputed, batch, untracked }
/**
* A mutable signal that can be used to manage reactive state changes.
*
* This is a re-export of `Signal` type from `@preact/signals-core`.
*
* @group Signals
*/
export type Signal<T> = _Signal<T>
/**
* A read-only signal, providing a way to observe state changes without the
* ability to modify the state.
*
* This is a re-export of `ReadonlySignal` type from `@preact/signals-core`.
*
* @group Signals
*/
export type ReadonlySignal<T> = _ReadonlySignal<T>
/**
* Groups multiple signal updates into a single batch, optimizing performance by reducing the number of updates.
*
* This is a re-export of `batch` from `@preact/signals-core`.
*
* @group Signals
*/
export const batch = _batch
/**
* Executes a given computation without automatically tracking its dependencies,
* useful for avoiding unnecessary re-computations.
*
* This is a re-export of `untracked` from `@preact/signals-core`.
*
* @group Signals
*/
export const untracked = _untracked
/**
* Creates and returns a new signal with the given initial value. Signals are
* reactive data sources that can be read and written to, allowing components to
* reactively update when their values change.
*
* This is an alias for `signal` from `@preact/signals-core`.
*
* @group Signals
*/
export const createSignal = signal
/**
* Creates a computed signal that automatically updates its value based on the
* reactive dependencies it uses. Computed signals are read-only and are used to
* derive state from other signals, recalculating their value when dependencies
* change.
*
* This is an alias for `computed` from `@preact/signals-core`.
*
* @group Signals
*/
export const createComputed = computed
/**
* Registers a callback to be called when the given element is connected to the
* DOM. It will track which signals are accessed and re-run their callback when
* those signals change. The callback can return a cleanup function that will be
* called when the effect is destroyed.
*
* The effect will be destroyed and all signals it was subscribed to will be
* unsubscribed from, when the element is disconnected from the DOM. You can also
* manually destroy the effect by calling the returned function.
*
* @group Signals
*/
export function useEffect(

@@ -37,2 +107,7 @@ element: ConnectableElement,

/**
* Extracts the value type from a signal type.
*
* @group Signals
*/
export type SignalValue<S> = S extends Signal<infer T> ? T : never

@@ -6,2 +6,7 @@ import type { Signal } from "@preact/signals-core"

/**
* A plain object containing signals.
*
* @group Props and States
*/
export type SingalState<T extends object> = {

@@ -13,2 +18,4 @@ [K in keyof T]: Signal<T[K]>

* Maps every signal in the given object to its current value.
*
* @group Props and States
*/

@@ -25,2 +32,4 @@ export function mapValues<T extends object>(signals: SingalState<T>): T {

* Maps every value in the given object to a signal.
*
* @group Props and States
*/

@@ -27,0 +36,0 @@ export function mapSignals<T extends object>(values: T): SingalState<T> {

@@ -5,2 +5,4 @@ import type { ConnectableElement } from "./connectable-element";

* {@link ConnectableElement} interface.
*
* @group Elements
*/

@@ -7,0 +9,0 @@ export declare class BaseElement extends HTMLElement implements ConnectableElement {

/**
* Any HTML element that has implemented the `addConnectedCallback` method.
*
* @group Elements
*/

@@ -4,0 +6,0 @@ export interface ConnectableElement extends HTMLElement {

@@ -5,2 +5,4 @@ import type { ConnectableElement } from "./connectable-element";

* A context is a way to provide and consume signals in a HTML tree.
*
* @group Contexts
*/

@@ -17,11 +19,15 @@ export interface Context<T> {

* @param element The element to consume the signal from.
* @param defaultValue The default value to return if the signal is not provided.
* @returns A signal that is double bound to the provided signal.
*/
consume(element: ConnectableElement, defaultValue: T): Signal<T>;
consume(element: ConnectableElement): Signal<T>;
}
/**
* Creates a new context.
*
* @param key The key to use for the context.
* @param defaultValue The default value to return if the signal is not provided.
*
* @group Contexts
*/
export declare function createContext<T>(key: string | symbol): Context<T>;
export declare function createContext<T>(key: string | symbol, defaultValue: T): Context<T>;
//# sourceMappingURL=context.d.ts.map
import type { AriaAttributes } from "@dddstack/ariatype-aria-attributes";
import type { AriaRole } from "@dddstack/ariatype-aria-roles";
import type { ConnectableElement } from "./connectable-element";
/**
* @group DOM
*/
export declare function useEventListener<K extends keyof HTMLElementEventMap>(element: ConnectableElement, type: K, listener: (event: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
/**
* @group DOM
*/
export declare function useStyle<K extends keyof CSSStyleDeclaration>(element: ConnectableElement, key: K, compute: () => CSSStyleDeclaration[K]): () => void;
/**
* @group DOM
*/
export declare function useAttribute(element: ConnectableElement, key: string, compute: () => string | number | undefined): () => void;
/**
* @group DOM
*/
export declare function useAriaAttribute<K extends keyof AriaAttributes>(element: ConnectableElement, key: K, compute: () => AriaAttributes[K]): () => void;
/**
* @group DOM
*/
export declare function useAriaRole(element: ConnectableElement, compute: () => AriaRole | undefined): () => void;
//# sourceMappingURL=dom.d.ts.map
/**
* Merge two objects, with the second object taking precedence. Only keys
* present in the first object will be included in the result.
*
* @group Props and States
*/
export declare function assignProps<T extends object>(defaultProps: Readonly<T>, props?: Partial<T>): Readonly<T>;
//# sourceMappingURL=props.d.ts.map

@@ -1,7 +0,77 @@

import { type ReadonlySignal, type Signal, batch, computed, signal, untracked } from "@preact/signals-core";
import { batch as _batch, untracked as _untracked, computed, signal, type ReadonlySignal as _ReadonlySignal, type Signal as _Signal } from "@preact/signals-core";
import type { ConnectableElement } from "./connectable-element";
export type { Signal, ReadonlySignal };
export { signal as createSignal, computed as createComputed, batch, untracked };
/**
* A mutable signal that can be used to manage reactive state changes.
*
* This is a re-export of `Signal` type from `@preact/signals-core`.
*
* @group Signals
*/
export type Signal<T> = _Signal<T>;
/**
* A read-only signal, providing a way to observe state changes without the
* ability to modify the state.
*
* This is a re-export of `ReadonlySignal` type from `@preact/signals-core`.
*
* @group Signals
*/
export type ReadonlySignal<T> = _ReadonlySignal<T>;
/**
* Groups multiple signal updates into a single batch, optimizing performance by reducing the number of updates.
*
* This is a re-export of `batch` from `@preact/signals-core`.
*
* @group Signals
*/
export declare const batch: typeof _batch;
/**
* Executes a given computation without automatically tracking its dependencies,
* useful for avoiding unnecessary re-computations.
*
* This is a re-export of `untracked` from `@preact/signals-core`.
*
* @group Signals
*/
export declare const untracked: typeof _untracked;
/**
* Creates and returns a new signal with the given initial value. Signals are
* reactive data sources that can be read and written to, allowing components to
* reactively update when their values change.
*
* This is an alias for `signal` from `@preact/signals-core`.
*
* @group Signals
*/
export declare const createSignal: typeof signal;
/**
* Creates a computed signal that automatically updates its value based on the
* reactive dependencies it uses. Computed signals are read-only and are used to
* derive state from other signals, recalculating their value when dependencies
* change.
*
* This is an alias for `computed` from `@preact/signals-core`.
*
* @group Signals
*/
export declare const createComputed: typeof computed;
/**
* Registers a callback to be called when the given element is connected to the
* DOM. It will track which signals are accessed and re-run their callback when
* those signals change. The callback can return a cleanup function that will be
* called when the effect is destroyed.
*
* The effect will be destroyed and all signals it was subscribed to will be
* unsubscribed from, when the element is disconnected from the DOM. You can also
* manually destroy the effect by calling the returned function.
*
* @group Signals
*/
export declare function useEffect(element: ConnectableElement, callback: () => VoidFunction | void): () => void;
/**
* Extracts the value type from a signal type.
*
* @group Signals
*/
export type SignalValue<S> = S extends Signal<infer T> ? T : never;
//# sourceMappingURL=signals.d.ts.map
import type { Signal } from "@preact/signals-core";
/**
* A plain object containing signals.
*
* @group Props and States
*/
export type SingalState<T extends object> = {

@@ -7,2 +12,4 @@ [K in keyof T]: Signal<T[K]>;

* Maps every signal in the given object to its current value.
*
* @group Props and States
*/

@@ -12,4 +19,6 @@ export declare function mapValues<T extends object>(signals: SingalState<T>): T;

* Maps every value in the given object to a signal.
*
* @group Props and States
*/
export declare function mapSignals<T extends object>(values: T): SingalState<T>;
//# sourceMappingURL=singal-state.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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