ui-ingredients 0.0.47 → 0.0.49

Sign up to get free protection for your applications and to get access to all the features.
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. Feel free to use it, and contributions are welcome. Use with caution!
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
 
@@ -86,6 +86,7 @@ export function createField(props) {
86
86
  }
87
87
  function getHelperTextProps() {
88
88
  return {
89
+ ...parts.helperText.attrs,
89
90
  id: ids.helperText,
90
91
  'data-invalid': dataAttr(invalid),
91
92
  'data-disabled': dataAttr(disabled),
@@ -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: (node: HTMLElement) => void;
15
+ ref: Action<HTMLElement, undefined, Record<never, any>>;
15
16
  getPresenceProps: () => HTMLAttributes<HTMLElement>;
16
17
  readonly mounted: boolean;
17
18
  };
@@ -34,9 +34,9 @@ export function createPresence(props) {
34
34
  return true;
35
35
  return false;
36
36
  });
37
- function ref(node) {
37
+ const ref = (node) => {
38
38
  api.setNode(node);
39
- }
39
+ };
40
40
  return {
41
41
  ref,
42
42
  getPresenceProps,
@@ -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 locale = getLocaleContext();
8
- const environment = getEnvironmentContext();
9
- const id = uid();
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
- let [snapshot, send] = useMachine(toaster.machine);
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 IntrinsicElement = keyof {
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<T extends IntrinsicElement> = SvelteHTMLElements[T];
10
- type AsChildWithRef<Ref extends Action, Context = never> = [Context] extends [
11
- never
12
- ] ? Snippet<[ref: Ref, attrs: GenericObject]> : Snippet<[ref: Ref, attrs: GenericObject, context: Context]>;
13
- type AsChildWithoutRef<Context = never> = [Context] extends [never] ? Snippet<[attrs: GenericObject]> : Snippet<[attrs: GenericObject, context: Context]>;
14
- export type AsChild<Ref extends Action, Context = never> = [Ref] extends [never] ? AsChildWithoutRef<Context> : AsChildWithRef<Ref, Context>;
15
- type Children<T = never> = [T] extends [never] ? Snippet : Snippet<[context: T]>;
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<Element extends IntrinsicElement, Context = never, Ref extends Action = never> = PropsWithoutChildren<HtmlProps<Element>> & {
19
+ export type HtmlIngredientProps<TElement extends SvelteHTMLElement, TContext = never, TAction extends Action = never> = PropsWithoutChildren<HtmlProps<TElement>> & {
18
20
  this?: any;
19
- asChild?: AsChild<Ref, Context>;
20
- children?: Children<Context>;
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.47",
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.0-next.3",
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",