@zag-js/toast 1.0.0 → 1.0.2

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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _zag_js_core from '@zag-js/core';
2
- import { Service, EventObject } from '@zag-js/core';
2
+ import { Service, Machine, EventObject } from '@zag-js/core';
3
3
  import { CommonProperties, Direction, DirectionProperty, Required, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
4
4
  import * as _zag_js_anatomy from '@zag-js/anatomy';
5
5
 
@@ -89,7 +89,7 @@ interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
89
89
  */
90
90
  gap?: number;
91
91
  }
92
- type ToastPropsWithDefault = "type" | "parent" | "duration" | "id";
92
+ type ToastPropsWithDefault = "type" | "parent" | "duration" | "id" | "removeDelay";
93
93
  type ToastSchema<O = any> = {
94
94
  props: RequiredBy<ToastProps<O>, ToastPropsWithDefault>;
95
95
  context: {
@@ -117,6 +117,7 @@ type ToastSchema<O = any> = {
117
117
  event: EventObject;
118
118
  };
119
119
  type ToastService = Service<ToastSchema>;
120
+ type ToastMachine = Machine<ToastSchema>;
120
121
  interface ToastStoreProps {
121
122
  /**
122
123
  * The placement of the toast
@@ -194,6 +195,7 @@ type ToastGroupSchema = {
194
195
  event: EventObject;
195
196
  };
196
197
  type ToastGroupService = Service<ToastGroupSchema>;
198
+ type ToastGroupMachine = Machine<ToastGroupSchema>;
197
199
  interface ToastStore<V = any> {
198
200
  /**
199
201
  * The attributes of the toast store
@@ -303,11 +305,11 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
303
305
  /**
304
306
  * The title of the toast.
305
307
  */
306
- title: O;
308
+ title?: O | undefined;
307
309
  /**
308
310
  * The description of the toast.
309
311
  */
310
- description: O;
312
+ description?: O | undefined;
311
313
  /**
312
314
  * The type of the toast.
313
315
  */
@@ -355,13 +357,13 @@ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"title" | "description" |
355
357
 
356
358
  declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
357
359
 
358
- declare const machine: _zag_js_core.MachineConfig<ToastSchema>;
360
+ declare const machine: _zag_js_core.Machine<ToastSchema>;
359
361
 
360
362
  declare function createToastStore<V = any>(props: ToastStoreProps): ToastStore<V>;
361
363
 
362
364
  declare const group: {
363
365
  connect: typeof groupConnect;
364
- machine: _zag_js_core.MachineConfig<ToastGroupSchema>;
366
+ machine: _zag_js_core.Machine<ToastGroupSchema>;
365
367
  };
366
368
 
367
- export { type ActionOptions, type ToastApi as Api, type ToastGroupApi as GroupApi, type ToastGroupProps as GroupProps, type ToastGroupService as GroupService, type Options, type Placement, type PromiseOptions, type ToastProps as Props, type ToastService as Service, type Status, type StatusChangeDetails, type ToastStore as Store, type ToastStoreProps as StoreProps, type Type, anatomy, connect, createToastStore as createStore, group, machine };
369
+ export { type ActionOptions, type ToastApi as Api, type ToastGroupApi as GroupApi, type ToastGroupMachine as GroupMachine, type ToastGroupProps as GroupProps, type ToastGroupService as GroupService, type ToastMachine as Machine, type Options, type Placement, type PromiseOptions, type ToastProps as Props, type ToastService as Service, type Status, type StatusChangeDetails, type ToastStore as Store, type ToastStoreProps as StoreProps, type Type, anatomy, connect, createToastStore as createStore, group, machine };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _zag_js_core from '@zag-js/core';
2
- import { Service, EventObject } from '@zag-js/core';
2
+ import { Service, Machine, EventObject } from '@zag-js/core';
3
3
  import { CommonProperties, Direction, DirectionProperty, Required, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
4
4
  import * as _zag_js_anatomy from '@zag-js/anatomy';
5
5
 
@@ -89,7 +89,7 @@ interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
89
89
  */
90
90
  gap?: number;
91
91
  }
92
- type ToastPropsWithDefault = "type" | "parent" | "duration" | "id";
92
+ type ToastPropsWithDefault = "type" | "parent" | "duration" | "id" | "removeDelay";
93
93
  type ToastSchema<O = any> = {
94
94
  props: RequiredBy<ToastProps<O>, ToastPropsWithDefault>;
95
95
  context: {
@@ -117,6 +117,7 @@ type ToastSchema<O = any> = {
117
117
  event: EventObject;
118
118
  };
119
119
  type ToastService = Service<ToastSchema>;
120
+ type ToastMachine = Machine<ToastSchema>;
120
121
  interface ToastStoreProps {
121
122
  /**
122
123
  * The placement of the toast
@@ -194,6 +195,7 @@ type ToastGroupSchema = {
194
195
  event: EventObject;
195
196
  };
196
197
  type ToastGroupService = Service<ToastGroupSchema>;
198
+ type ToastGroupMachine = Machine<ToastGroupSchema>;
197
199
  interface ToastStore<V = any> {
198
200
  /**
199
201
  * The attributes of the toast store
@@ -303,11 +305,11 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
303
305
  /**
304
306
  * The title of the toast.
305
307
  */
306
- title: O;
308
+ title?: O | undefined;
307
309
  /**
308
310
  * The description of the toast.
309
311
  */
310
- description: O;
312
+ description?: O | undefined;
311
313
  /**
312
314
  * The type of the toast.
313
315
  */
@@ -355,13 +357,13 @@ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"title" | "description" |
355
357
 
356
358
  declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
357
359
 
358
- declare const machine: _zag_js_core.MachineConfig<ToastSchema>;
360
+ declare const machine: _zag_js_core.Machine<ToastSchema>;
359
361
 
360
362
  declare function createToastStore<V = any>(props: ToastStoreProps): ToastStore<V>;
361
363
 
362
364
  declare const group: {
363
365
  connect: typeof groupConnect;
364
- machine: _zag_js_core.MachineConfig<ToastGroupSchema>;
366
+ machine: _zag_js_core.Machine<ToastGroupSchema>;
365
367
  };
366
368
 
367
- export { type ActionOptions, type ToastApi as Api, type ToastGroupApi as GroupApi, type ToastGroupProps as GroupProps, type ToastGroupService as GroupService, type Options, type Placement, type PromiseOptions, type ToastProps as Props, type ToastService as Service, type Status, type StatusChangeDetails, type ToastStore as Store, type ToastStoreProps as StoreProps, type Type, anatomy, connect, createToastStore as createStore, group, machine };
369
+ export { type ActionOptions, type ToastApi as Api, type ToastGroupApi as GroupApi, type ToastGroupMachine as GroupMachine, type ToastGroupProps as GroupProps, type ToastGroupService as GroupService, type ToastMachine as Machine, type Options, type Placement, type PromiseOptions, type ToastProps as Props, type ToastService as Service, type Status, type StatusChangeDetails, type ToastStore as Store, type ToastStoreProps as StoreProps, type Type, anatomy, connect, createToastStore as createStore, group, machine };
package/dist/index.js CHANGED
@@ -229,11 +229,9 @@ function groupConnect(service, normalize) {
229
229
  send({ type: "REGION.FOCUS", target: event.relatedTarget });
230
230
  },
231
231
  onBlur(event) {
232
- queueMicrotask(() => {
233
- if (refs.get("isFocusWithin") && !domQuery.contains(event.currentTarget, event.relatedTarget)) {
234
- send({ type: "REGION.BLUR" });
235
- }
236
- });
232
+ if (refs.get("isFocusWithin") && !domQuery.contains(event.currentTarget, event.relatedTarget)) {
233
+ queueMicrotask(() => send({ type: "REGION.BLUR" }));
234
+ }
237
235
  }
238
236
  });
239
237
  },
@@ -576,12 +574,10 @@ function connect(service, normalize) {
576
574
  var { not } = core.createGuards();
577
575
  var machine = core.createMachine({
578
576
  props({ props }) {
577
+ utils.ensureProps(props, ["id", "type", "parent", "removeDelay"], "toast");
579
578
  return {
579
+ closable: true,
580
580
  ...props,
581
- id: props.id,
582
- type: props.type,
583
- parent: props.parent,
584
- closable: props.closable ?? true,
585
581
  duration: getToastDuration(props.duration, props.type)
586
582
  };
587
583
  },
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { addDomEvent, raf, dataAttr, contains, MAX_Z_INDEX } from '@zag-js/dom-q
2
2
  import { createAnatomy } from '@zag-js/anatomy';
3
3
  import { createMachine, createGuards } from '@zag-js/core';
4
4
  import { trackDismissableBranch } from '@zag-js/dismissable';
5
- import { uuid, setRafTimeout, runIfFn } from '@zag-js/utils';
5
+ import { uuid, ensureProps, setRafTimeout, runIfFn } from '@zag-js/utils';
6
6
 
7
7
  // src/toast-group.connect.ts
8
8
  var anatomy = createAnatomy("toast").parts(
@@ -227,11 +227,9 @@ function groupConnect(service, normalize) {
227
227
  send({ type: "REGION.FOCUS", target: event.relatedTarget });
228
228
  },
229
229
  onBlur(event) {
230
- queueMicrotask(() => {
231
- if (refs.get("isFocusWithin") && !contains(event.currentTarget, event.relatedTarget)) {
232
- send({ type: "REGION.BLUR" });
233
- }
234
- });
230
+ if (refs.get("isFocusWithin") && !contains(event.currentTarget, event.relatedTarget)) {
231
+ queueMicrotask(() => send({ type: "REGION.BLUR" }));
232
+ }
235
233
  }
236
234
  });
237
235
  },
@@ -574,12 +572,10 @@ function connect(service, normalize) {
574
572
  var { not } = createGuards();
575
573
  var machine = createMachine({
576
574
  props({ props }) {
575
+ ensureProps(props, ["id", "type", "parent", "removeDelay"], "toast");
577
576
  return {
577
+ closable: true,
578
578
  ...props,
579
- id: props.id,
580
- type: props.type,
581
- parent: props.parent,
582
- closable: props.closable ?? true,
583
579
  duration: getToastDuration(props.duration, props.type)
584
580
  };
585
581
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/toast",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Core logic for the toast widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,12 +26,12 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.0.0",
30
- "@zag-js/dom-query": "1.0.0",
31
- "@zag-js/core": "1.0.0",
32
- "@zag-js/dismissable": "1.0.0",
33
- "@zag-js/utils": "1.0.0",
34
- "@zag-js/types": "1.0.0"
29
+ "@zag-js/anatomy": "1.0.2",
30
+ "@zag-js/core": "1.0.2",
31
+ "@zag-js/dom-query": "1.0.2",
32
+ "@zag-js/dismissable": "1.0.2",
33
+ "@zag-js/utils": "1.0.2",
34
+ "@zag-js/types": "1.0.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"