@svelte-put/async-stack
Advanced tools
Comparing version 1.0.0-next.1 to 1.0.0-next.2
{ | ||
"name": "@svelte-put/async-stack", | ||
"version": "1.0.0-next.1", | ||
"version": "1.0.0-next.2", | ||
"description": "type-safe and headless builder for async component stack", | ||
@@ -58,3 +58,3 @@ "type": "module", | ||
"peerDependencies": { | ||
"svelte": "^5.0.0-next.164" | ||
"svelte": "^5.0.0-next.172" | ||
}, | ||
@@ -61,0 +61,0 @@ "volta": { |
@@ -78,3 +78,3 @@ <div align="center"> | ||
[github.monorepo]: https://github.com/vnphanquang/svelte-put | ||
[github.changelog]: https://github.com/vnphanquang/svelte-put/blob/main/packages/async-stack/CHANGELOG.md | ||
[github.changelog]: https://github.com/vnphanquang/svelte-put/blob/next/packages/async-stack/CHANGELOG.md | ||
[github.issues]: https://github.com/vnphanquang/svelte-put/issues?q= | ||
@@ -81,0 +81,0 @@ |
@@ -201,21 +201,31 @@ import { mount } from 'svelte'; | ||
/** | ||
* pause a stack item, if it has a timeout | ||
* @param {string} id | ||
* pause a stack item, if it has a timeout. If no `id` is provided, | ||
* will pause all stack items with a timeout | ||
* @param {string} [id] | ||
* @returns {void} | ||
*/ | ||
pause(id) { | ||
const pushed = this.items.find((i) => i.config.id === id); | ||
return pushed?.pause(); | ||
if (!id) { | ||
this.items.forEach((i) => i.pause()); | ||
} else { | ||
const pushed = this.items.find((i) => i.config.id === id); | ||
pushed?.pause(); | ||
} | ||
} | ||
/** | ||
* resume a stack item, if it has been paused | ||
* @param {string} id | ||
* resume a stack item, if it has been paused. If no `id` is provided, | ||
* will resume all stack items with a timeout | ||
* @param {string} [id] | ||
* @returns {void} | ||
*/ | ||
resume(id) { | ||
const pushed = this.items.find((i) => i.config.id === id); | ||
return pushed?.resume(); | ||
if (!id) { | ||
this.items.forEach((i) => i.resume()); | ||
} else { | ||
const pushed = this.items.find((i) => i.config.id === id); | ||
return pushed?.resume(); | ||
} | ||
} | ||
} | ||
@@ -6,3 +6,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
export interface StackItemProps<Resolved> { | ||
export interface StackItemProps<Resolved = undefined> { | ||
/** the stack item instance injected by the stack */ | ||
@@ -9,0 +9,0 @@ item: Omit<StackItem<Component<StackItemProps<Resolved>>, Resolved>, '#internals'>; |
declare module '@svelte-put/async-stack' { | ||
import type { Component, ComponentProps } from 'svelte'; | ||
import type { ActionReturn } from 'svelte/action'; | ||
function stack(init?: StackItemCommonConfig<string, import("svelte").Component<any, any, string>> | undefined): StackBuilder; | ||
export function stack(init?: StackItemCommonConfig<string, import("svelte").Component<any, any, string>> | undefined): StackBuilder; | ||
@@ -19,3 +19,3 @@ class StackBuilder<VariantMap extends Record<string, import("svelte").Component<any>> = {}> { | ||
} | ||
class Stack<VariantMap extends Record<string, import("svelte").Component<any>> = {}> { | ||
export class Stack<VariantMap extends Record<string, import("svelte").Component<any>> = {}> { | ||
@@ -44,12 +44,14 @@ constructor(variantConfigMap: Record<keyof VariantMap, StackItemVariantConfig<string, import("svelte").Component>>, init?: StackItemCommonConfig<string, import("svelte").Component<any, any, string>> | undefined); | ||
/** | ||
* pause a stack item, if it has a timeout | ||
* pause a stack item, if it has a timeout. If no `id` is provided, | ||
* will pause all stack items with a timeout | ||
* */ | ||
pause(id: string): void; | ||
pause(id?: string | undefined): void; | ||
/** | ||
* resume a stack item, if it has been paused | ||
* resume a stack item, if it has been paused. If no `id` is provided, | ||
* will resume all stack items with a timeout | ||
* */ | ||
resume(id: string): void; | ||
resume(id?: string | undefined): void; | ||
#private; | ||
} | ||
class StackItem<UserComponent extends import("svelte").Component<any> = import("svelte").Component<any, any, string>, Resolved = ComponentResolved<UserComponent>> { | ||
export class StackItem<UserComponent extends import("svelte").Component<any> = import("svelte").Component<any, any, string>, Resolved = ComponentResolved<UserComponent>> { | ||
@@ -71,3 +73,3 @@ constructor(config: Required<StackItemInstanceConfig<string, UserComponent>>); | ||
} | ||
interface StackItemProps<Resolved> { | ||
export interface StackItemProps<Resolved = undefined> { | ||
/** the stack item instance injected by the stack */ | ||
@@ -77,3 +79,3 @@ item: Omit<StackItem<Component<StackItemProps<Resolved>>, Resolved>, '#internals'>; | ||
type ComponentResolved<UserComponent extends Component<any>> = | ||
export type ComponentResolved<UserComponent extends Component<any>> = | ||
ComponentProps<UserComponent> extends { item: { resolution: Promise<infer Resolved> } } | ||
@@ -153,5 +155,5 @@ ? Resolved | ||
export { stack, Stack, StackItem, StackItemProps, ComponentResolved }; | ||
export {}; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
Sorry, the diff of this file is not supported yet
26382
13
557