@zag-js/toast 2.0.0-next.1 → 2.0.0-next.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.
@@ -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<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger">;
4
- declare const parts: Record<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"description" | "group" | "title" | "root" | "actionTrigger" | "closeTrigger">;
4
+ declare const parts: Record<"description" | "group" | "title" | "root" | "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<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger">;
4
- declare const parts: Record<"group" | "title" | "root" | "description" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"description" | "group" | "title" | "root" | "actionTrigger" | "closeTrigger">;
4
+ declare const parts: Record<"description" | "group" | "title" | "root" | "actionTrigger" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
5
5
 
6
6
  export { anatomy, parts };
@@ -34,12 +34,16 @@ __export(toast_connect_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(toast_connect_exports);
36
36
  var import_dom_query = require("@zag-js/dom-query");
37
+ var import_utils = require("@zag-js/utils");
37
38
  var import_toast = require("./toast.anatomy.js");
38
39
  var dom = __toESM(require("./toast.dom.js"));
39
40
  var import_toast2 = require("./toast.utils.js");
41
+ var defaultTranslations = {
42
+ closeTriggerLabel: "Dismiss notification"
43
+ };
40
44
  function connect(service, normalize) {
41
45
  const { state, send, prop, scope, context, computed } = service;
42
- const translations = prop("translations");
46
+ const translations = (0, import_utils.mergeWithDefault)(defaultTranslations, prop("translations"));
43
47
  const visible = state.hasTag("visible");
44
48
  const paused = state.hasTag("paused");
45
49
  const mounted = context.get("mounted");
@@ -1,11 +1,15 @@
1
1
  // src/toast.connect.ts
2
2
  import { dataAttr } from "@zag-js/dom-query";
3
+ import { mergeWithDefault } from "@zag-js/utils";
3
4
  import { parts } from "./toast.anatomy.mjs";
4
5
  import * as dom from "./toast.dom.mjs";
5
6
  import { getGhostAfterStyle, getGhostBeforeStyle, getPlacementStyle } from "./toast.utils.mjs";
7
+ var defaultTranslations = {
8
+ closeTriggerLabel: "Dismiss notification"
9
+ };
6
10
  function connect(service, normalize) {
7
11
  const { state, send, prop, scope, context, computed } = service;
8
- const translations = prop("translations");
12
+ const translations = mergeWithDefault(defaultTranslations, prop("translations"));
9
13
  const visible = state.hasTag("visible");
10
14
  const paused = state.hasTag("paused");
11
15
  const mounted = context.get("mounted");
@@ -45,10 +45,6 @@ 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
- },
52
48
  duration: (0, import_toast.getToastDuration)(props.duration, props.type)
53
49
  };
54
50
  },
@@ -11,10 +11,6 @@ var machine = createMachine({
11
11
  return {
12
12
  closable: true,
13
13
  ...props,
14
- translations: {
15
- closeTriggerLabel: "Dismiss notification",
16
- ...props.translations
17
- },
18
14
  duration: getToastDuration(props.duration, props.type)
19
15
  };
20
16
  },
@@ -148,7 +148,8 @@ interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
148
148
  }
149
149
  type ToastPropsWithDefault = "type" | "parent" | "duration" | "id" | "removeDelay";
150
150
  type ToastSchema<O = any> = {
151
- props: RequiredBy<ToastProps<O>, Extract<ToastPropsWithDefault, keyof ToastProps<O>>>;
151
+ props: ToastProps<O>;
152
+ defaultPropKey: Extract<ToastPropsWithDefault, keyof ToastProps<O>>;
152
153
  context: {
153
154
  mounted: boolean;
154
155
  initialHeight: number;
@@ -232,6 +233,7 @@ interface ToastGroupProps extends DirectionProperty, CommonProperties {
232
233
  type ToastGroupSchema = {
233
234
  state: "stack" | "overlap";
234
235
  props: ToastGroupProps;
236
+ defaultPropKey: never;
235
237
  context: {
236
238
  toasts: RequiredBy<ToastProps, Extract<ToastPropsWithDefault, keyof ToastProps>>[];
237
239
  heights: ToastHeight[];
@@ -148,7 +148,8 @@ interface ToastProps<T = any> extends Omit<CommonProperties, "id">, Options<T> {
148
148
  }
149
149
  type ToastPropsWithDefault = "type" | "parent" | "duration" | "id" | "removeDelay";
150
150
  type ToastSchema<O = any> = {
151
- props: RequiredBy<ToastProps<O>, Extract<ToastPropsWithDefault, keyof ToastProps<O>>>;
151
+ props: ToastProps<O>;
152
+ defaultPropKey: Extract<ToastPropsWithDefault, keyof ToastProps<O>>;
152
153
  context: {
153
154
  mounted: boolean;
154
155
  initialHeight: number;
@@ -232,6 +233,7 @@ interface ToastGroupProps extends DirectionProperty, CommonProperties {
232
233
  type ToastGroupSchema = {
233
234
  state: "stack" | "overlap";
234
235
  props: ToastGroupProps;
236
+ defaultPropKey: never;
235
237
  context: {
236
238
  toasts: RequiredBy<ToastProps, Extract<ToastPropsWithDefault, keyof ToastProps>>[];
237
239
  heights: ToastHeight[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/toast",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.2",
4
4
  "description": "Core logic for the toast widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,12 +29,12 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/anatomy": "2.0.0-next.1",
33
- "@zag-js/core": "2.0.0-next.1",
34
- "@zag-js/dom-query": "2.0.0-next.1",
35
- "@zag-js/dismissable": "2.0.0-next.1",
36
- "@zag-js/types": "2.0.0-next.1",
37
- "@zag-js/utils": "2.0.0-next.1"
32
+ "@zag-js/anatomy": "2.0.0-next.2",
33
+ "@zag-js/core": "2.0.0-next.2",
34
+ "@zag-js/dom-query": "2.0.0-next.2",
35
+ "@zag-js/dismissable": "2.0.0-next.2",
36
+ "@zag-js/utils": "2.0.0-next.2",
37
+ "@zag-js/types": "2.0.0-next.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "clean-package": "2.2.0"
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "scripts": {
70
70
  "build": "tsup",
71
- "lint": "eslint src",
71
+ "lint": "oxlint src",
72
72
  "typecheck": "tsc --noEmit"
73
73
  }
74
74
  }