@ark-ui/react 0.0.0-rc-20230101180921 → 0.0.0-rc-20230102115543

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/dist/index.cjs CHANGED
@@ -162,6 +162,14 @@ const tagsInputField = require('./tags-input/tags-input-field.cjs');
162
162
  const tagsInputLabel = require('./tags-input/tags-input-label.cjs');
163
163
  const tagsInput$1 = require('@zag-js/tags-input');
164
164
  const useTagsInput = require('./tags-input/use-tags-input.cjs');
165
+ const toast = require('./toast/toast.cjs');
166
+ const toastCloseTrigger = require('./toast/toast-close-trigger.cjs');
167
+ const toastDescription = require('./toast/toast-description.cjs');
168
+ const toastGroup = require('./toast/toast-group.cjs');
169
+ const toastPlacements = require('./toast/toast-placements.cjs');
170
+ const toastProvider = require('./toast/toast-provider.cjs');
171
+ const toastTitle = require('./toast/toast-title.cjs');
172
+ const toast$1 = require('@zag-js/toast');
165
173
  const tooltip = require('./tooltip/tooltip.cjs');
166
174
  const tooltip$1 = require('@zag-js/tooltip');
167
175
  const tooltipArrow = require('./tooltip/tooltip-arrow.cjs');
@@ -394,6 +402,18 @@ Object.defineProperty(exports, 'tagsInputAnatomy', {
394
402
  get: () => tagsInput$1.anatomy
395
403
  });
396
404
  exports.useTagsInput = useTagsInput.useTagsInput;
405
+ exports.Toast = toast.Toast;
406
+ exports.ToastCloseTrigger = toastCloseTrigger.ToastCloseTrigger;
407
+ exports.ToastDescription = toastDescription.ToastDescription;
408
+ exports.ToastGroup = toastGroup.ToastGroup;
409
+ exports.ToastPlacements = toastPlacements.ToastPlacements;
410
+ exports.ToastProvider = toastProvider.ToastProvider;
411
+ exports.useToast = toastProvider.useToast;
412
+ exports.ToastTitle = toastTitle.ToastTitle;
413
+ Object.defineProperty(exports, 'toastAnatomy', {
414
+ enumerable: true,
415
+ get: () => toast$1.anatomy
416
+ });
397
417
  exports.Tooltip = tooltip.Tooltip;
398
418
  Object.defineProperty(exports, 'tooltipAnatomy', {
399
419
  enumerable: true,
package/dist/index.d.ts CHANGED
@@ -18,4 +18,5 @@ export * from './select';
18
18
  export * from './slider';
19
19
  export * from './tabs';
20
20
  export * from './tags-input';
21
+ export * from './toast';
21
22
  export * from './tooltip';
package/dist/index.mjs CHANGED
@@ -158,6 +158,14 @@ export { TagsInputField } from './tags-input/tags-input-field.mjs';
158
158
  export { TagsInputLabel } from './tags-input/tags-input-label.mjs';
159
159
  export { anatomy as tagsInputAnatomy } from '@zag-js/tags-input';
160
160
  export { useTagsInput } from './tags-input/use-tags-input.mjs';
161
+ export { Toast } from './toast/toast.mjs';
162
+ export { ToastCloseTrigger } from './toast/toast-close-trigger.mjs';
163
+ export { ToastDescription } from './toast/toast-description.mjs';
164
+ export { ToastGroup } from './toast/toast-group.mjs';
165
+ export { ToastPlacements } from './toast/toast-placements.mjs';
166
+ export { ToastProvider, useToast } from './toast/toast-provider.mjs';
167
+ export { ToastTitle } from './toast/toast-title.mjs';
168
+ export { anatomy as toastAnatomy } from '@zag-js/toast';
161
169
  export { Tooltip } from './tooltip/tooltip.mjs';
162
170
  export { anatomy as tooltipAnatomy } from '@zag-js/tooltip';
163
171
  export { TooltipArrow } from './tooltip/tooltip-arrow.mjs';
@@ -0,0 +1,8 @@
1
+ export { Toast, type ToastProps } from './toast';
2
+ export { ToastCloseTrigger, type ToastCloseTriggerProps } from './toast-close-trigger';
3
+ export { ToastDescription, type ToastDescriptionProps } from './toast-description';
4
+ export { ToastGroup, type ToastGroupProps } from './toast-group';
5
+ export { ToastPlacements, type ToastPlacementsProps } from './toast-placements';
6
+ export { ToastProvider, useToast, type ToastProviderProps } from './toast-provider';
7
+ export { ToastTitle, type ToastTitleProps } from './toast-title';
8
+ export { toastAnatomy } from './toast.anatomy';
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const React = require('react');
6
+ const toastItemContext = require('./toast-item-context.cjs');
7
+
8
+ const ToastCloseTrigger = (props) => {
9
+ const { closeTriggerProps } = toastItemContext.useToastItemContext();
10
+ const onlyChild = React.Children.only(props.children);
11
+ return React.cloneElement(onlyChild, closeTriggerProps);
12
+ };
13
+
14
+ exports.ToastCloseTrigger = ToastCloseTrigger;
@@ -0,0 +1,5 @@
1
+ import type { JSXElementConstructor, ReactElement } from 'react';
2
+ export declare type ToastCloseTriggerProps = {
3
+ children: ReactElement;
4
+ };
5
+ export declare const ToastCloseTrigger: (props: ToastCloseTriggerProps) => ReactElement<any, string | JSXElementConstructor<any>>;
@@ -0,0 +1,10 @@
1
+ import { Children, cloneElement } from 'react';
2
+ import { useToastItemContext } from './toast-item-context.mjs';
3
+
4
+ const ToastCloseTrigger = (props) => {
5
+ const { closeTriggerProps } = useToastItemContext();
6
+ const onlyChild = Children.only(props.children);
7
+ return cloneElement(onlyChild, closeTriggerProps);
8
+ };
9
+
10
+ export { ToastCloseTrigger };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const react = require('@polymorphic-factory/react');
7
+ const react$1 = require('@zag-js/react');
8
+ const factory = require('../factory.cjs');
9
+ const toastItemContext = require('./toast-item-context.cjs');
10
+
11
+ const ToastDescription = react.forwardRef((props, ref) => {
12
+ const { descriptionProps, description } = toastItemContext.useToastItemContext();
13
+ const mergedProps = react$1.mergeProps(descriptionProps, props);
14
+ return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.p, { ...mergedProps, ref, children: description });
15
+ });
16
+
17
+ exports.ToastDescription = ToastDescription;
@@ -0,0 +1,4 @@
1
+ import type { ComponentWithAs } from '@polymorphic-factory/react';
2
+ import { HTMLArkProps } from '../factory';
3
+ export declare type ToastDescriptionProps = HTMLArkProps<'p'>;
4
+ export declare const ToastDescription: ComponentWithAs<"p", ToastDescriptionProps>;
@@ -0,0 +1,13 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from '@polymorphic-factory/react';
3
+ import { mergeProps } from '@zag-js/react';
4
+ import { ark } from '../factory.mjs';
5
+ import { useToastItemContext } from './toast-item-context.mjs';
6
+
7
+ const ToastDescription = forwardRef((props, ref) => {
8
+ const { descriptionProps, description } = useToastItemContext();
9
+ const mergedProps = mergeProps(descriptionProps, props);
10
+ return /* @__PURE__ */ jsx(ark.p, { ...mergedProps, ref, children: description });
11
+ });
12
+
13
+ export { ToastDescription };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const react = require('@polymorphic-factory/react');
7
+ const react$1 = require('@zag-js/react');
8
+ const factory = require('../factory.cjs');
9
+ const runIfFn = require('../run-if-fn.cjs');
10
+ const toastProvider = require('./toast-provider.cjs');
11
+
12
+ const ToastGroup = react.forwardRef((props, ref) => {
13
+ const { children, placement, ...divProps } = props;
14
+ const { toastsByPlacement, getGroupProps } = toastProvider.useToast();
15
+ const mergedProps = react$1.mergeProps(getGroupProps({ placement }), divProps);
16
+ const view = runIfFn.runIfFn(children, toastsByPlacement[placement] ?? []);
17
+ return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: view }) });
18
+ });
19
+
20
+ exports.ToastGroup = ToastGroup;
@@ -0,0 +1,10 @@
1
+ import type { ComponentWithAs } from '@polymorphic-factory/react';
2
+ import type { Placement, Service } from '@zag-js/toast';
3
+ import type { ReactNode } from 'react';
4
+ import { HTMLArkProps } from '../factory';
5
+ import type { Assign } from '../types';
6
+ export declare type ToastGroupProps = Assign<HTMLArkProps<'div'>, {
7
+ placement: Placement;
8
+ children: ReactNode | ((toasts: Service[]) => ReactNode);
9
+ }>;
10
+ export declare const ToastGroup: ComponentWithAs<"div", ToastGroupProps>;
@@ -0,0 +1,16 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { forwardRef } from '@polymorphic-factory/react';
3
+ import { mergeProps } from '@zag-js/react';
4
+ import { ark } from '../factory.mjs';
5
+ import { runIfFn } from '../run-if-fn.mjs';
6
+ import { useToast } from './toast-provider.mjs';
7
+
8
+ const ToastGroup = forwardRef((props, ref) => {
9
+ const { children, placement, ...divProps } = props;
10
+ const { toastsByPlacement, getGroupProps } = useToast();
11
+ const mergedProps = mergeProps(getGroupProps({ placement }), divProps);
12
+ const view = runIfFn(children, toastsByPlacement[placement] ?? []);
13
+ return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: /* @__PURE__ */ jsx(Fragment, { children: view }) });
14
+ });
15
+
16
+ export { ToastGroup };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const createContext = require('../create-context.cjs');
6
+
7
+ const [ToastItemProvider, useToastItemContext] = createContext.createContext({
8
+ name: "ToastItemContext",
9
+ hookName: "useToastItemContext",
10
+ providerName: "<ToastItemProvider />"
11
+ });
12
+
13
+ exports.ToastItemProvider = ToastItemProvider;
14
+ exports.useToastItemContext = useToastItemContext;
@@ -0,0 +1,37 @@
1
+ import type { Type, Placement } from '@zag-js/toast/dist/toast.types';
2
+ import type { Provider, HTMLAttributes, DetailedHTMLProps, ButtonHTMLAttributes } from 'react';
3
+ import type { UseToastItemReturn } from './use-toast-item';
4
+ export declare type ToastItemContext = UseToastItemReturn;
5
+ export declare const ToastItemProvider: Provider<{
6
+ type: Type;
7
+ title: string | undefined;
8
+ description: string | undefined;
9
+ placement: Placement;
10
+ isVisible: boolean;
11
+ isPaused: boolean;
12
+ isRtl: boolean;
13
+ pause(): void;
14
+ resume(): void;
15
+ dismiss(): void;
16
+ rootProps: HTMLAttributes<HTMLElement>;
17
+ titleProps: HTMLAttributes<HTMLElement>;
18
+ descriptionProps: HTMLAttributes<HTMLElement>;
19
+ closeTriggerProps: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
20
+ render(): any;
21
+ }>, useToastItemContext: () => {
22
+ type: Type;
23
+ title: string | undefined;
24
+ description: string | undefined;
25
+ placement: Placement;
26
+ isVisible: boolean;
27
+ isPaused: boolean;
28
+ isRtl: boolean;
29
+ pause(): void;
30
+ resume(): void;
31
+ dismiss(): void;
32
+ rootProps: HTMLAttributes<HTMLElement>;
33
+ titleProps: HTMLAttributes<HTMLElement>;
34
+ descriptionProps: HTMLAttributes<HTMLElement>;
35
+ closeTriggerProps: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
36
+ render(): any;
37
+ };
@@ -0,0 +1,9 @@
1
+ import { createContext } from '../create-context.mjs';
2
+
3
+ const [ToastItemProvider, useToastItemContext] = createContext({
4
+ name: "ToastItemContext",
5
+ hookName: "useToastItemContext",
6
+ providerName: "<ToastItemProvider />"
7
+ });
8
+
9
+ export { ToastItemProvider, useToastItemContext };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const runIfFn = require('../run-if-fn.cjs');
7
+ const toastProvider = require('./toast-provider.cjs');
8
+
9
+ const ToastPlacements = (props) => {
10
+ const { children } = props;
11
+ const { toastsByPlacement } = toastProvider.useToast();
12
+ const view = runIfFn.runIfFn(children, Object.keys(toastsByPlacement));
13
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: view });
14
+ };
15
+
16
+ exports.ToastPlacements = ToastPlacements;
@@ -0,0 +1,6 @@
1
+ import type { Placement } from '@zag-js/toast';
2
+ import type { ReactNode } from 'react';
3
+ export declare type ToastPlacementsProps = {
4
+ children: (placements: Placement[]) => ReactNode;
5
+ };
6
+ export declare const ToastPlacements: (props: ToastPlacementsProps) => JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { runIfFn } from '../run-if-fn.mjs';
3
+ import { useToast } from './toast-provider.mjs';
4
+
5
+ const ToastPlacements = (props) => {
6
+ const { children } = props;
7
+ const { toastsByPlacement } = useToast();
8
+ const view = runIfFn(children, Object.keys(toastsByPlacement));
9
+ return /* @__PURE__ */ jsx(Fragment, { children: view });
10
+ };
11
+
12
+ export { ToastPlacements };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const react = require('@zag-js/react');
7
+ const toast = require('@zag-js/toast');
8
+ const React = require('react');
9
+ const createContext = require('../create-context.cjs');
10
+
11
+ function _interopNamespaceDefault(e) {
12
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
13
+ if (e) {
14
+ for (const k in e) {
15
+ if (k !== 'default') {
16
+ const d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: () => e[k]
20
+ });
21
+ }
22
+ }
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ const toast__namespace = /*#__PURE__*/_interopNamespaceDefault(toast);
29
+
30
+ const [ToastContextProvider, useToast] = createContext.createContext();
31
+ const ToastProvider = (props) => {
32
+ const { children, ...restProps } = props;
33
+ const [state, send] = react.useMachine(toast__namespace.group.machine({ id: React.useId(), ...restProps }));
34
+ const api = toast__namespace.group.connect(state, send, react.normalizeProps);
35
+ return /* @__PURE__ */ jsxRuntime.jsx(ToastContextProvider, { value: api, children });
36
+ };
37
+
38
+ exports.ToastContextProvider = ToastContextProvider;
39
+ exports.ToastProvider = ToastProvider;
40
+ exports.useToast = useToast;
@@ -0,0 +1,54 @@
1
+ import type { PromiseOptions, GroupProps } from '@zag-js/toast/dist/toast.types';
2
+ import * as toast from '@zag-js/toast';
3
+ import type { Provider, PropsWithChildren } from 'react';
4
+ import type { Optional } from '../types';
5
+ declare type GroupPublicContext = Parameters<typeof toast['group']['machine']>[0];
6
+ export declare type ToastContext = ReturnType<typeof toast['group']['connect']>;
7
+ export declare const ToastContextProvider: Provider<{
8
+ count: number;
9
+ toasts: toast.Service[];
10
+ toastsByPlacement: Partial<Record<toast.Placement, toast.Service[]>>;
11
+ isVisible(id: string): boolean;
12
+ create(options: Partial<toast.ToastOptions>): string | undefined;
13
+ upsert(options: Partial<toast.ToastOptions>): string | undefined;
14
+ dismiss(id?: string | undefined): void;
15
+ remove(id?: string | undefined): void;
16
+ dismissByPlacement(placement: toast.Placement): void;
17
+ update(id: string, options: Partial<toast.ToastOptions>): string | undefined;
18
+ loading(options: Partial<toast.ToastOptions>): string | undefined;
19
+ success(options: Partial<toast.ToastOptions>): string | undefined;
20
+ error(options: Partial<toast.ToastOptions>): string | undefined;
21
+ promise<T_1>(promise: Promise<T_1>, options: PromiseOptions<T_1>, shared?: Partial<toast.ToastOptions> | undefined): Promise<T_1>;
22
+ pause(id?: string | undefined): void;
23
+ resume(id?: string | undefined): void;
24
+ getGroupProps(options: GroupProps): {
25
+ [x: string]: any;
26
+ };
27
+ createPortal(): HTMLElement;
28
+ subscribe(fn: (toasts: any) => void): () => void;
29
+ }>, useToast: () => {
30
+ count: number;
31
+ toasts: toast.Service[];
32
+ toastsByPlacement: Partial<Record<toast.Placement, toast.Service[]>>;
33
+ isVisible(id: string): boolean;
34
+ create(options: Partial<toast.ToastOptions>): string | undefined;
35
+ upsert(options: Partial<toast.ToastOptions>): string | undefined;
36
+ dismiss(id?: string | undefined): void;
37
+ remove(id?: string | undefined): void;
38
+ dismissByPlacement(placement: toast.Placement): void;
39
+ update(id: string, options: Partial<toast.ToastOptions>): string | undefined;
40
+ loading(options: Partial<toast.ToastOptions>): string | undefined;
41
+ success(options: Partial<toast.ToastOptions>): string | undefined;
42
+ error(options: Partial<toast.ToastOptions>): string | undefined;
43
+ promise<T_1>(promise: Promise<T_1>, options: PromiseOptions<T_1>, shared?: Partial<toast.ToastOptions> | undefined): Promise<T_1>;
44
+ pause(id?: string | undefined): void;
45
+ resume(id?: string | undefined): void;
46
+ getGroupProps(options: GroupProps): {
47
+ [x: string]: any;
48
+ };
49
+ createPortal(): HTMLElement;
50
+ subscribe(fn: (toasts: any) => void): () => void;
51
+ };
52
+ export declare type ToastProviderProps = PropsWithChildren & Optional<GroupPublicContext, 'id'>;
53
+ export declare const ToastProvider: (props: ToastProviderProps) => JSX.Element;
54
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useMachine, normalizeProps } from '@zag-js/react';
3
+ import * as toast from '@zag-js/toast';
4
+ import { useId } from 'react';
5
+ import { createContext } from '../create-context.mjs';
6
+
7
+ const [ToastContextProvider, useToast] = createContext();
8
+ const ToastProvider = (props) => {
9
+ const { children, ...restProps } = props;
10
+ const [state, send] = useMachine(toast.group.machine({ id: useId(), ...restProps }));
11
+ const api = toast.group.connect(state, send, normalizeProps);
12
+ return /* @__PURE__ */ jsx(ToastContextProvider, { value: api, children });
13
+ };
14
+
15
+ export { ToastContextProvider, ToastProvider, useToast };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const react = require('@polymorphic-factory/react');
7
+ const react$1 = require('@zag-js/react');
8
+ const factory = require('../factory.cjs');
9
+ const toastItemContext = require('./toast-item-context.cjs');
10
+
11
+ const ToastTitle = react.forwardRef((props, ref) => {
12
+ const { titleProps, title } = toastItemContext.useToastItemContext();
13
+ const mergedProps = react$1.mergeProps(titleProps, props);
14
+ return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.h3, { ...mergedProps, ref, children: title });
15
+ });
16
+
17
+ exports.ToastTitle = ToastTitle;
@@ -0,0 +1,4 @@
1
+ import type { ComponentWithAs } from '@polymorphic-factory/react';
2
+ import { HTMLArkProps } from '../factory';
3
+ export declare type ToastTitleProps = HTMLArkProps<'h3'>;
4
+ export declare const ToastTitle: ComponentWithAs<"h3", ToastTitleProps>;
@@ -0,0 +1,13 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from '@polymorphic-factory/react';
3
+ import { mergeProps } from '@zag-js/react';
4
+ import { ark } from '../factory.mjs';
5
+ import { useToastItemContext } from './toast-item-context.mjs';
6
+
7
+ const ToastTitle = forwardRef((props, ref) => {
8
+ const { titleProps, title } = useToastItemContext();
9
+ const mergedProps = mergeProps(titleProps, props);
10
+ return /* @__PURE__ */ jsx(ark.h3, { ...mergedProps, ref, children: title });
11
+ });
12
+
13
+ export { ToastTitle };
@@ -0,0 +1 @@
1
+ export { anatomy as toastAnatomy } from '@zag-js/toast';
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const jsxRuntime = require('react/jsx-runtime');
6
+ const react = require('@polymorphic-factory/react');
7
+ const react$1 = require('@zag-js/react');
8
+ const createSplitProps = require('../create-split-props.cjs');
9
+ const factory = require('../factory.cjs');
10
+ const toastItemContext = require('./toast-item-context.cjs');
11
+ const useToastItem = require('./use-toast-item.cjs');
12
+
13
+ const Toast = react.forwardRef((props, ref) => {
14
+ const [useToastItemProps, divProps] = createSplitProps.createSplitProps()(props, ["toast"]);
15
+ const api = useToastItem.useToastItem(useToastItemProps);
16
+ const mergedProps = react$1.mergeProps(api.rootProps, divProps);
17
+ return /* @__PURE__ */ jsxRuntime.jsx(toastItemContext.ToastItemProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref }) });
18
+ });
19
+
20
+ exports.Toast = Toast;
@@ -0,0 +1,6 @@
1
+ import type { ComponentWithAs } from '@polymorphic-factory/react';
2
+ import { HTMLArkProps } from '../factory';
3
+ import type { Assign } from '../types';
4
+ import { UseToastItemProps } from './use-toast-item';
5
+ export declare type ToastProps = Assign<HTMLArkProps<'div'>, UseToastItemProps>;
6
+ export declare const Toast: ComponentWithAs<"div", ToastProps>;
@@ -0,0 +1,16 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from '@polymorphic-factory/react';
3
+ import { mergeProps } from '@zag-js/react';
4
+ import { createSplitProps } from '../create-split-props.mjs';
5
+ import { ark } from '../factory.mjs';
6
+ import { ToastItemProvider } from './toast-item-context.mjs';
7
+ import { useToastItem } from './use-toast-item.mjs';
8
+
9
+ const Toast = forwardRef((props, ref) => {
10
+ const [useToastItemProps, divProps] = createSplitProps()(props, ["toast"]);
11
+ const api = useToastItem(useToastItemProps);
12
+ const mergedProps = mergeProps(api.rootProps, divProps);
13
+ return /* @__PURE__ */ jsx(ToastItemProvider, { value: api, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }) });
14
+ });
15
+
16
+ export { Toast };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const react = require('@zag-js/react');
6
+ const toast = require('@zag-js/toast');
7
+
8
+ function _interopNamespaceDefault(e) {
9
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
10
+ if (e) {
11
+ for (const k in e) {
12
+ if (k !== 'default') {
13
+ const d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: () => e[k]
17
+ });
18
+ }
19
+ }
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ const toast__namespace = /*#__PURE__*/_interopNamespaceDefault(toast);
26
+
27
+ const useToastItem = (props) => {
28
+ const [state, send] = react.useActor(props.toast);
29
+ return toast__namespace.connect(state, send, react.normalizeProps);
30
+ };
31
+
32
+ exports.useToastItem = useToastItem;
@@ -0,0 +1,23 @@
1
+ import type { HTMLAttributes, DetailedHTMLProps, ButtonHTMLAttributes } from 'react';
2
+ import * as toast from '@zag-js/toast';
3
+ export declare type UseToastItemProps = {
4
+ toast: toast.Service;
5
+ };
6
+ export declare type UseToastItemReturn = ReturnType<typeof useToastItem>;
7
+ export declare const useToastItem: (props: UseToastItemProps) => {
8
+ type: toast.Type;
9
+ title: string | undefined;
10
+ description: string | undefined;
11
+ placement: toast.Placement;
12
+ isVisible: boolean;
13
+ isPaused: boolean;
14
+ isRtl: boolean;
15
+ pause(): void;
16
+ resume(): void;
17
+ dismiss(): void;
18
+ rootProps: HTMLAttributes<HTMLElement>;
19
+ titleProps: HTMLAttributes<HTMLElement>;
20
+ descriptionProps: HTMLAttributes<HTMLElement>;
21
+ closeTriggerProps: DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
22
+ render(): any;
23
+ };
@@ -0,0 +1,9 @@
1
+ import { useActor, normalizeProps } from '@zag-js/react';
2
+ import * as toast from '@zag-js/toast';
3
+
4
+ const useToastItem = (props) => {
5
+ const [state, send] = useActor(props.toast);
6
+ return toast.connect(state, send, normalizeProps);
7
+ };
8
+
9
+ export { useToastItem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ark-ui/react",
3
- "version": "0.0.0-rc-20230101180921",
3
+ "version": "0.0.0-rc-20230102115543",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/chakra-ui/ark#readme",