ui-ingredients 0.0.47 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/field/create-field.svelte.js +1 -0
- package/dist/presence/create-presence.svelte.d.ts +2 -1
- package/dist/presence/create-presence.svelte.js +2 -2
- package/dist/toast/create-toaster.svelte.js +3 -11
- package/dist/toast/toaster.svelte +11 -1
- package/dist/types.d.ts +13 -11
- package/package.json +2 -2
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Headless component library for [Svelte](https://svelte.dev/) powered by [zag](https://zagjs.com/)
|
4
4
|
|
5
|
-
> ⚠️ This project is in early development.
|
5
|
+
> ⚠️ This project is currently in the early stages of development. You're welcome to use it and we encourage contributions. Please use with caution as it is still evolving!
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { Action } from 'svelte/action';
|
1
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
2
3
|
export interface PresenceStrategyProps {
|
3
4
|
/** @default false */
|
@@ -11,7 +12,7 @@ export interface CreatePresenceProps extends PresenceStrategyProps {
|
|
11
12
|
export interface CreatePresenceReturn extends ReturnType<typeof createPresence> {
|
12
13
|
}
|
13
14
|
export declare function createPresence(props: CreatePresenceProps): {
|
14
|
-
ref:
|
15
|
+
ref: Action<HTMLElement, undefined, Record<never, any>>;
|
15
16
|
getPresenceProps: () => HTMLAttributes<HTMLElement>;
|
16
17
|
readonly mounted: boolean;
|
17
18
|
};
|
@@ -1,18 +1,10 @@
|
|
1
|
-
import { getEnvironmentContext } from '../environment-provider/index.js';
|
2
|
-
import { getLocaleContext } from '../locale-provider/index.js';
|
3
1
|
import { normalizeProps, reflect } from '@zag-js/svelte';
|
4
2
|
import * as toast from '@zag-js/toast';
|
5
3
|
import { uid } from 'uid';
|
6
4
|
export function createToaster(props) {
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const machine = $derived(toast.group.machine({
|
11
|
-
...props,
|
12
|
-
id: props?.id ?? id,
|
13
|
-
dir: locale?.dir,
|
14
|
-
getRootNode: environment?.getRootNode,
|
15
|
-
}));
|
5
|
+
const id_ = uid();
|
6
|
+
const id = $derived(props?.id ?? id_);
|
7
|
+
const machine = $derived(toast.group.machine({ ...props, id }));
|
16
8
|
return reflect(() => ({
|
17
9
|
machine,
|
18
10
|
...toast.group.connect(machine, machine.send, normalizeProps),
|
@@ -10,6 +10,8 @@
|
|
10
10
|
</script>
|
11
11
|
|
12
12
|
<script lang="ts">
|
13
|
+
import {getEnvironmentContext} from '../environment-provider/context.svelte.js';
|
14
|
+
import {getLocaleContext} from '../locale-provider/context.svelte.js';
|
13
15
|
import {mergeProps} from '../merge-props.js';
|
14
16
|
import {Portal} from '../portal/index.js';
|
15
17
|
import {normalizeProps, useMachine} from '@zag-js/svelte';
|
@@ -18,7 +20,15 @@
|
|
18
20
|
|
19
21
|
let {this: e, toaster, children, ...props}: ToasterProps = $props();
|
20
22
|
|
21
|
-
|
23
|
+
const locale = getLocaleContext();
|
24
|
+
const environment = getEnvironmentContext();
|
25
|
+
|
26
|
+
let [snapshot, send] = useMachine(toaster.machine, {
|
27
|
+
context: {
|
28
|
+
dir: locale?.dir,
|
29
|
+
getRootNode: environment?.getRootNode,
|
30
|
+
},
|
31
|
+
});
|
22
32
|
|
23
33
|
let placement = $derived(snapshot.context.placement);
|
24
34
|
let api = $derived(toast.group.connect(snapshot, send, normalizeProps));
|
package/dist/types.d.ts
CHANGED
@@ -3,20 +3,22 @@ import type { Action } from 'svelte/action';
|
|
3
3
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
4
4
|
export type GenericObject = Record<string, any>;
|
5
5
|
export type Assign<Target extends GenericObject, Source extends GenericObject> = Source & Omit<Target, keyof Source>;
|
6
|
-
export type
|
6
|
+
export type SvelteHTMLElement = keyof {
|
7
7
|
[K in keyof SvelteHTMLElements as string extends K ? never : number extends K ? never : K]: string;
|
8
8
|
};
|
9
|
-
export type HtmlProps<
|
10
|
-
type
|
11
|
-
|
12
|
-
] ? Snippet<[
|
13
|
-
type AsChildWithoutRef<
|
14
|
-
export type AsChild<
|
15
|
-
|
9
|
+
export type HtmlProps<TElement extends SvelteHTMLElement> = SvelteHTMLElements[TElement];
|
10
|
+
type AsChildWithAction<TAction extends Action, TContext = never> = [
|
11
|
+
TContext
|
12
|
+
] extends [never] ? Snippet<[action: TAction, attrs: GenericObject]> : Snippet<[action: TAction, attrs: GenericObject, context: TContext]>;
|
13
|
+
type AsChildWithoutRef<TContext = never> = [TContext] extends [never] ? Snippet<[attrs: GenericObject]> : Snippet<[attrs: GenericObject, context: TContext]>;
|
14
|
+
export type AsChild<TAction extends Action, Context = never> = [
|
15
|
+
TAction
|
16
|
+
] extends [never] ? AsChildWithoutRef<Context> : AsChildWithAction<TAction, Context>;
|
17
|
+
type Children<TContext = never> = [TContext] extends [never] ? Snippet : Snippet<[context: TContext]>;
|
16
18
|
type PropsWithoutChildren<T> = Omit<T, 'children'>;
|
17
|
-
export type HtmlIngredientProps<
|
19
|
+
export type HtmlIngredientProps<TElement extends SvelteHTMLElement, TContext = never, TAction extends Action = never> = PropsWithoutChildren<HtmlProps<TElement>> & {
|
18
20
|
this?: any;
|
19
|
-
asChild?: AsChild<
|
20
|
-
children?: Children<
|
21
|
+
asChild?: AsChild<TAction, TContext>;
|
22
|
+
children?: Children<TContext>;
|
21
23
|
};
|
22
24
|
export {};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "ui-ingredients",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.49",
|
5
5
|
"packageManager": "pnpm@9.7.0",
|
6
6
|
"svelte": "./dist/index.js",
|
7
7
|
"types": "./dist/index.d.ts",
|
@@ -141,7 +141,7 @@
|
|
141
141
|
"@sveltejs/package": "2.3.5",
|
142
142
|
"@sveltejs/vite-plugin-svelte": "4.0.0-next.6",
|
143
143
|
"@testing-library/jest-dom": "6.5.0",
|
144
|
-
"@testing-library/svelte": "5.2.
|
144
|
+
"@testing-library/svelte": "5.2.1",
|
145
145
|
"@untitled-theme/icons-svelte": "0.10.7",
|
146
146
|
"autoprefixer": "10.4.20",
|
147
147
|
"globals": "15.9.0",
|