@zag-js/avatar
Advanced tools
Comparing version 0.11.1 to 0.11.2
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() { | ||
@@ -116,4 +101,4 @@ send({ type: "IMG.ERROR", src: "api" }); | ||
var import_core = require("@zag-js/core"); | ||
var import_mutation_observer = require("@zag-js/mutation-observer"); | ||
var import_utils = require("@zag-js/utils"); | ||
var import_mutation_observer = require("@zag-js/mutation-observer"); | ||
function machine(userContext) { | ||
@@ -120,0 +105,0 @@ const ctx = (0, import_utils.compact)(userContext); |
{ | ||
"name": "@zag-js/avatar", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Core logic for the avatar widget implemented as a state machine", | ||
@@ -31,8 +31,8 @@ "keywords": [ | ||
"dependencies": { | ||
"@zag-js/anatomy": "0.11.1", | ||
"@zag-js/mutation-observer": "0.11.1", | ||
"@zag-js/core": "0.11.1", | ||
"@zag-js/dom-query": "0.11.1", | ||
"@zag-js/utils": "0.11.1", | ||
"@zag-js/types": "0.11.1" | ||
"@zag-js/anatomy": "0.11.2", | ||
"@zag-js/mutation-observer": "0.11.2", | ||
"@zag-js/core": "0.11.2", | ||
"@zag-js/dom-query": "0.11.2", | ||
"@zag-js/utils": "0.11.2", | ||
"@zag-js/types": "0.11.2" | ||
}, | ||
@@ -39,0 +39,0 @@ "devDependencies": { |
import { dataAttr } from "@zag-js/dom-query" | ||
import { NormalizeProps, type PropTypes } from "@zag-js/types" | ||
import type { NormalizeProps, PropTypes } from "@zag-js/types" | ||
import { parts } from "./avatar.anatomy" | ||
import { dom } from "./avatar.dom" | ||
import { 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") | ||
@@ -12,25 +12,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() { | ||
@@ -37,0 +24,0 @@ send({ type: "IMG.ERROR", src: "api" }) |
import { createMachine } from "@zag-js/core" | ||
import { observeAttributes, observeChildren } from "@zag-js/mutation-observer" | ||
import { compact } from "@zag-js/utils" | ||
import { observeAttributes, observeChildren } from "@zag-js/mutation-observer" | ||
import { MachineContext, MachineState, UserDefinedContext } from "./avatar.types" | ||
import { dom } from "./avatar.dom" | ||
import type { MachineContext, MachineState, UserDefinedContext } from "./avatar.types" | ||
@@ -7,0 +7,0 @@ export function machine(userContext: UserDefinedContext) { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39414
597
+ Added@zag-js/anatomy@0.11.2(transitive)
+ Added@zag-js/core@0.11.2(transitive)
+ Added@zag-js/dom-query@0.11.2(transitive)
+ Added@zag-js/mutation-observer@0.11.2(transitive)
+ Added@zag-js/store@0.11.2(transitive)
+ Added@zag-js/types@0.11.2(transitive)
+ Added@zag-js/utils@0.11.2(transitive)
- Removed@zag-js/anatomy@0.11.1(transitive)
- Removed@zag-js/core@0.11.1(transitive)
- Removed@zag-js/dom-query@0.11.1(transitive)
- Removed@zag-js/mutation-observer@0.11.1(transitive)
- Removed@zag-js/store@0.11.1(transitive)
- Removed@zag-js/types@0.11.1(transitive)
- Removed@zag-js/utils@0.11.1(transitive)
Updated@zag-js/anatomy@0.11.2
Updated@zag-js/core@0.11.2
Updated@zag-js/dom-query@0.11.2
Updated@zag-js/types@0.11.2
Updated@zag-js/utils@0.11.2