@zag-js/toast 1.35.2 → 1.36.0

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,6 +1,6 @@
1
1
  import * as _zag_js_core from '@zag-js/core';
2
2
  import { ToastGroupSchema } from './toast.types.mjs';
3
- export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, Type } from './toast.types.mjs';
3
+ export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, IntlTranslations, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, Type } from './toast.types.mjs';
4
4
  import { groupConnect } from './toast-group.connect.mjs';
5
5
  export { anatomy } from './toast.anatomy.mjs';
6
6
  export { connect } from './toast.connect.mjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _zag_js_core from '@zag-js/core';
2
2
  import { ToastGroupSchema } from './toast.types.js';
3
- export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, Type } from './toast.types.js';
3
+ export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, IntlTranslations, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, Type } from './toast.types.js';
4
4
  import { groupConnect } from './toast-group.connect.js';
5
5
  export { anatomy } from './toast.anatomy.js';
6
6
  export { connect } from './toast.connect.js';
@@ -1,6 +1,6 @@
1
1
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
2
 
3
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"title" | "description" | "group" | "root" | "actionTrigger" | "closeTrigger">;
4
- declare const parts: Record<"title" | "description" | "group" | "root" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger">;
4
+ declare const parts: Record<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
5
5
 
6
6
  export { anatomy, parts };
@@ -1,6 +1,6 @@
1
1
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
2
 
3
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"title" | "description" | "group" | "root" | "actionTrigger" | "closeTrigger">;
4
- declare const parts: Record<"title" | "description" | "group" | "root" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger">;
4
+ declare const parts: Record<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
5
5
 
6
6
  export { anatomy, parts };
@@ -39,6 +39,7 @@ var dom = __toESM(require("./toast.dom.js"));
39
39
  var import_toast2 = require("./toast.utils.js");
40
40
  function connect(service, normalize) {
41
41
  const { state, send, prop, scope, context, computed } = service;
42
+ const translations = prop("translations");
42
43
  const visible = state.hasTag("visible");
43
44
  const paused = state.hasTag("paused");
44
45
  const mounted = context.get("mounted");
@@ -140,7 +141,7 @@ function connect(service, normalize) {
140
141
  id: dom.getCloseTriggerId(scope),
141
142
  ...import_toast.parts.closeTrigger.attrs,
142
143
  type: "button",
143
- "aria-label": "Dismiss notification",
144
+ "aria-label": translations?.closeTriggerLabel,
144
145
  onClick(event) {
145
146
  if (event.defaultPrevented) return;
146
147
  send({ type: "DISMISS", src: "user" });
@@ -5,6 +5,7 @@ import * as dom from "./toast.dom.mjs";
5
5
  import { getGhostAfterStyle, getGhostBeforeStyle, getPlacementStyle } from "./toast.utils.mjs";
6
6
  function connect(service, normalize) {
7
7
  const { state, send, prop, scope, context, computed } = service;
8
+ const translations = prop("translations");
8
9
  const visible = state.hasTag("visible");
9
10
  const paused = state.hasTag("paused");
10
11
  const mounted = context.get("mounted");
@@ -106,7 +107,7 @@ function connect(service, normalize) {
106
107
  id: dom.getCloseTriggerId(scope),
107
108
  ...parts.closeTrigger.attrs,
108
109
  type: "button",
109
- "aria-label": "Dismiss notification",
110
+ "aria-label": translations?.closeTriggerLabel,
110
111
  onClick(event) {
111
112
  if (event.defaultPrevented) return;
112
113
  send({ type: "DISMISS", src: "user" });
@@ -45,6 +45,10 @@ var machine = (0, import_core.createMachine)({
45
45
  return {
46
46
  closable: true,
47
47
  ...props,
48
+ translations: {
49
+ closeTriggerLabel: "Dismiss notification",
50
+ ...props.translations
51
+ },
48
52
  duration: (0, import_toast.getToastDuration)(props.duration, props.type)
49
53
  };
50
54
  },
@@ -11,6 +11,10 @@ var machine = createMachine({
11
11
  return {
12
12
  closable: true,
13
13
  ...props,
14
+ translations: {
15
+ closeTriggerLabel: "Dismiss notification",
16
+ ...props.translations
17
+ },
14
18
  duration: getToastDuration(props.duration, props.type)
15
19
  };
16
20
  },
@@ -35,6 +35,9 @@ interface ActionOptions {
35
35
  */
36
36
  onClick: VoidFunction;
37
37
  }
38
+ interface IntlTranslations {
39
+ closeTriggerLabel?: string | undefined;
40
+ }
38
41
  interface Options<T = any> {
39
42
  /**
40
43
  * The title of the toast.
@@ -79,6 +82,10 @@ interface Options<T = any> {
79
82
  meta?: Record<string, any> | undefined;
80
83
  }
81
84
  interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
85
+ /**
86
+ * Specifies the localized strings that identifies the accessibility elements and their states
87
+ */
88
+ translations?: IntlTranslations | undefined;
82
89
  /**
83
90
  * The direction of the toast
84
91
  */
@@ -368,4 +375,4 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
368
375
  getActionTriggerProps: () => T["button"];
369
376
  }
370
377
 
371
- export type { ActionOptions, GroupProps, Options, Placement, PromiseOptions, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
378
+ export type { ActionOptions, GroupProps, IntlTranslations, Options, Placement, PromiseOptions, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
@@ -35,6 +35,9 @@ interface ActionOptions {
35
35
  */
36
36
  onClick: VoidFunction;
37
37
  }
38
+ interface IntlTranslations {
39
+ closeTriggerLabel?: string | undefined;
40
+ }
38
41
  interface Options<T = any> {
39
42
  /**
40
43
  * The title of the toast.
@@ -79,6 +82,10 @@ interface Options<T = any> {
79
82
  meta?: Record<string, any> | undefined;
80
83
  }
81
84
  interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
85
+ /**
86
+ * Specifies the localized strings that identifies the accessibility elements and their states
87
+ */
88
+ translations?: IntlTranslations | undefined;
82
89
  /**
83
90
  * The direction of the toast
84
91
  */
@@ -368,4 +375,4 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
368
375
  getActionTriggerProps: () => T["button"];
369
376
  }
370
377
 
371
- export type { ActionOptions, GroupProps, Options, Placement, PromiseOptions, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
378
+ export type { ActionOptions, GroupProps, IntlTranslations, Options, Placement, PromiseOptions, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/toast",
3
- "version": "1.35.2",
3
+ "version": "1.36.0",
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.35.2",
30
- "@zag-js/core": "1.35.2",
31
- "@zag-js/dom-query": "1.35.2",
32
- "@zag-js/dismissable": "1.35.2",
33
- "@zag-js/utils": "1.35.2",
34
- "@zag-js/types": "1.35.2"
29
+ "@zag-js/anatomy": "1.36.0",
30
+ "@zag-js/core": "1.36.0",
31
+ "@zag-js/dom-query": "1.36.0",
32
+ "@zag-js/dismissable": "1.36.0",
33
+ "@zag-js/utils": "1.36.0",
34
+ "@zag-js/types": "1.36.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"