Socket
Socket
Sign inDemoInstall

@zag-js/avatar

Package Overview
Dependencies
Maintainers
1
Versions
627
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/avatar - npm Package Compare versions

Comparing version 0.0.0-dev-20230713105642 to 0.0.0-dev-20230713124852

27

dist/index.d.ts
import * as _zag_js_anatomy from '@zag-js/anatomy';
import { RequiredBy, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
import { PropTypes, RequiredBy, CommonProperties, Context, NormalizeProps } from '@zag-js/types';
import * as _zag_js_core from '@zag-js/core';

@@ -12,13 +12,3 @@ import { StateMachine } from '@zag-js/core';

};
type PrivateContext = Context<{}>;
type ComputedContext = Readonly<{}>;
type UserDefinedContext = RequiredBy<PublicContext, "id">;
type MachineContext = PublicContext & PrivateContext & ComputedContext;
type MachineState = {
value: "loading" | "error" | "loaded";
};
type State = StateMachine.State<MachineContext, MachineState>;
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
type PublicApi<T extends PropTypes = PropTypes> = {
/**

@@ -48,5 +38,16 @@ * Whether the image is loaded.

};
type PrivateContext = Context<{}>;
type ComputedContext = Readonly<{}>;
type UserDefinedContext = RequiredBy<PublicContext, "id">;
type MachineContext = PublicContext & PrivateContext & ComputedContext;
type MachineState = {
value: "loading" | "error" | "loaded";
};
type State = StateMachine.State<MachineContext, MachineState>;
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T>;
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
export { UserDefinedContext as Context, anatomy, connect, machine };
export { UserDefinedContext as Context, PublicApi, anatomy, connect, machine };

@@ -52,25 +52,10 @@ "use strict";

return {
/**
* Whether the image is loaded.
*/
isLoaded,
/**
* Whether the fallback is shown.
*/
showFallback,
/**
* Function to set new src.
*/
setSrc(src) {
send({ type: "SRC.SET", src });
},
/**
* Function to set loaded state.
*/
setLoaded() {
send({ type: "IMG.LOADED", src: "api" });
},
/**
* Function to set error state.
*/
setError() {

@@ -77,0 +62,0 @@ send({ type: "IMG.ERROR", src: "api" });

{
"name": "@zag-js/avatar",
"version": "0.0.0-dev-20230713105642",
"version": "0.0.0-dev-20230713124852",
"description": "Core logic for the avatar widget implemented as a state machine",

@@ -31,8 +31,8 @@ "keywords": [

"dependencies": {
"@zag-js/anatomy": "0.0.0-dev-20230713105642",
"@zag-js/mutation-observer": "0.0.0-dev-20230713105642",
"@zag-js/core": "0.0.0-dev-20230713105642",
"@zag-js/dom-query": "0.0.0-dev-20230713105642",
"@zag-js/utils": "0.0.0-dev-20230713105642",
"@zag-js/types": "0.0.0-dev-20230713105642"
"@zag-js/anatomy": "0.0.0-dev-20230713124852",
"@zag-js/mutation-observer": "0.0.0-dev-20230713124852",
"@zag-js/core": "0.0.0-dev-20230713124852",
"@zag-js/dom-query": "0.0.0-dev-20230713124852",
"@zag-js/utils": "0.0.0-dev-20230713124852",
"@zag-js/types": "0.0.0-dev-20230713124852"
},

@@ -39,0 +39,0 @@ "devDependencies": {

@@ -5,5 +5,5 @@ import { dataAttr } from "@zag-js/dom-query"

import { dom } from "./avatar.dom"
import type { Send, State } from "./avatar.types"
import type { PublicApi, Send, State } from "./avatar.types"
export function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>) {
export function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): PublicApi<T> {
const isLoaded = state.matches("loaded")

@@ -13,25 +13,12 @@ const showFallback = !isLoaded

return {
/**
* Whether the image is loaded.
*/
isLoaded,
/**
* Whether the fallback is shown.
*/
showFallback,
/**
* Function to set new src.
*/
setSrc(src: string) {
send({ type: "SRC.SET", src })
},
/**
* Function to set loaded state.
*/
setLoaded() {
send({ type: "IMG.LOADED", src: "api" })
},
/**
* Function to set error state.
*/
setError() {

@@ -38,0 +25,0 @@ send({ type: "IMG.ERROR", src: "api" })

import type { StateMachine as S } from "@zag-js/core"
import type { CommonProperties, Context, RequiredBy } from "@zag-js/types"
import type { CommonProperties, Context, PropTypes, RequiredBy } from "@zag-js/types"

@@ -9,2 +9,28 @@ type PublicContext = CommonProperties & {

export type PublicApi<T extends PropTypes = PropTypes> = {
/**
* Whether the image is loaded.
*/
isLoaded: boolean
/**
* Whether the fallback is shown.
*/
showFallback: boolean
/**
* Function to set new src.
*/
setSrc(src: string): void
/**
* Function to set loaded state.
*/
setLoaded(): void
/**
* Function to set error state.
*/
setError(): void
rootProps: T["element"]
imageProps: T["img"]
fallbackProps: T["element"]
}
type PrivateContext = Context<{}>

@@ -11,0 +37,0 @@

export { anatomy } from "./avatar.anatomy"
export { connect } from "./avatar.connect"
export { machine } from "./avatar.machine"
export type { UserDefinedContext as Context } from "./avatar.types"
export type { UserDefinedContext as Context, PublicApi } from "./avatar.types"

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