@agnos-ui/react-headless 0.9.3 → 0.9.4

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.
@@ -6,7 +6,7 @@ import type { PropsWithChildren } from 'react';
6
6
  * @param options - Optional toaster properties.
7
7
  * @returns An object containing toaster methods and properties.
8
8
  */
9
- export declare const useCreateToaster: <Props extends Partial<ToastProps>>(options?: ToasterProps) => {
9
+ export declare const useCreateToaster: <Props extends Partial<ToastProps>>(options?: Partial<ToasterProps>) => {
10
10
  toasts: import("@agnos-ui/core/components/toast").ToasterToast<Props>[];
11
11
  options: ToasterProps;
12
12
  addToast: (props: Props) => number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const toasterProvider = require("../../../toasterProvider-BtIHSdiL.cjs");
3
+ const toasterProvider = require("../../../toasterProvider-BAKMnkH7.cjs");
4
4
  const toast = require("@agnos-ui/core/components/toast");
5
5
  exports.ToasterProvider = toasterProvider.ToasterProvider;
6
6
  exports.useCreateToaster = toasterProvider.useCreateToaster;
@@ -1,4 +1,4 @@
1
- import { T, u, a } from "../../../toasterProvider-lT-AfOoK.js";
1
+ import { T, u, a } from "../../../toasterProvider-Gcu1qGgO.js";
2
2
  export * from "@agnos-ui/core/components/toast";
3
3
  export {
4
4
  T as ToasterProvider,
@@ -27,8 +27,8 @@ export * from './components/rating/index';
27
27
  export * from './components/progressbar/index';
28
28
  export * from './components/pagination/index';
29
29
  export * from './components/modal/index';
30
- export * from './components/carousel/index';
31
30
  export * from './components/collapse/index';
31
+ export * from './components/carousel/index';
32
32
  export * from './components/alert/index';
33
33
  export * from './components/accordion/index';
34
34
  export * from './utils/portal';
package/index.cjs CHANGED
@@ -26,7 +26,7 @@ const types = require("@agnos-ui/core/types");
26
26
  const config$1 = require("@agnos-ui/core/config");
27
27
  const config = require("./config.cjs");
28
28
  const tree = require("@agnos-ui/core/components/tree");
29
- const toasterProvider = require("./toasterProvider-BtIHSdiL.cjs");
29
+ const toasterProvider = require("./toasterProvider-BAKMnkH7.cjs");
30
30
  const toast = require("@agnos-ui/core/components/toast");
31
31
  const slider = require("@agnos-ui/core/components/slider");
32
32
  const select = require("@agnos-ui/core/components/select");
@@ -34,8 +34,8 @@ const rating = require("@agnos-ui/core/components/rating");
34
34
  const progressbar = require("@agnos-ui/core/components/progressbar");
35
35
  const pagination = require("@agnos-ui/core/components/pagination");
36
36
  const modal = require("@agnos-ui/core/components/modal");
37
- const carousel = require("@agnos-ui/core/components/carousel");
38
37
  const collapse$1 = require("@agnos-ui/core/components/collapse");
38
+ const carousel = require("@agnos-ui/core/components/carousel");
39
39
  const alert = require("@agnos-ui/core/components/alert");
40
40
  const accordion = require("@agnos-ui/core/components/accordion");
41
41
  const portal$1 = require("./portal-B0Q5KLrA.cjs");
@@ -232,16 +232,16 @@ Object.keys(modal).forEach((k) => {
232
232
  get: () => modal[k]
233
233
  });
234
234
  });
235
- Object.keys(carousel).forEach((k) => {
235
+ Object.keys(collapse$1).forEach((k) => {
236
236
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
237
237
  enumerable: true,
238
- get: () => carousel[k]
238
+ get: () => collapse$1[k]
239
239
  });
240
240
  });
241
- Object.keys(collapse$1).forEach((k) => {
241
+ Object.keys(carousel).forEach((k) => {
242
242
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
243
243
  enumerable: true,
244
- get: () => collapse$1[k]
244
+ get: () => carousel[k]
245
245
  });
246
246
  });
247
247
  Object.keys(alert).forEach((k) => {
package/index.js CHANGED
@@ -24,7 +24,7 @@ export * from "@agnos-ui/core/types";
24
24
  export * from "@agnos-ui/core/config";
25
25
  import { WidgetsConfigContext, WidgetsDefaultConfig, useWidget, useWidgetContext, widgetsConfigFactory } from "./config.js";
26
26
  export * from "@agnos-ui/core/components/tree";
27
- import { T, u as u4, a as a3 } from "./toasterProvider-lT-AfOoK.js";
27
+ import { T, u as u4, a as a3 } from "./toasterProvider-Gcu1qGgO.js";
28
28
  export * from "@agnos-ui/core/components/toast";
29
29
  export * from "@agnos-ui/core/components/slider";
30
30
  export * from "@agnos-ui/core/components/select";
@@ -32,8 +32,8 @@ export * from "@agnos-ui/core/components/rating";
32
32
  export * from "@agnos-ui/core/components/progressbar";
33
33
  export * from "@agnos-ui/core/components/pagination";
34
34
  export * from "@agnos-ui/core/components/modal";
35
- export * from "@agnos-ui/core/components/carousel";
36
35
  export * from "@agnos-ui/core/components/collapse";
36
+ export * from "@agnos-ui/core/components/carousel";
37
37
  export * from "@agnos-ui/core/components/alert";
38
38
  export * from "@agnos-ui/core/components/accordion";
39
39
  import { P } from "./portal-CX8X69NK.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agnos-ui/react-headless",
3
3
  "description": "Headless component library for React.",
4
- "version": "0.9.3",
4
+ "version": "0.9.4",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
7
7
  "module": "./index.js",
@@ -49,7 +49,7 @@
49
49
  }
50
50
  },
51
51
  "dependencies": {
52
- "@agnos-ui/core": "0.9.3"
52
+ "@agnos-ui/core": "0.9.4"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@amadeus-it-group/tansu": "^2.0.0",
@@ -1,12 +1,22 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const toast = require("@agnos-ui/core/components/toast");
4
+ const stores = require("@agnos-ui/core/utils/stores");
4
5
  const react = require("react");
5
- const stores = require("./stores-DD819q-h.cjs");
6
+ const stores$1 = require("./stores-DD819q-h.cjs");
6
7
  const useCreateToaster = (options) => {
7
- const toaster = react.useMemo(() => new toast.Toaster(options), [options]);
8
- const toasts = stores.useObservable(toaster.toasts);
9
- const toasterOptions = stores.useObservable(toaster.options);
8
+ const toaster = react.useMemo(() => new toast.Toaster(options), []);
9
+ options = options ?? {};
10
+ const previousOptions = react.useRef(options);
11
+ react.useMemo(() => {
12
+ const changedOptions = stores.findChangedProperties(previousOptions.current, options);
13
+ previousOptions.current = options;
14
+ if (changedOptions) {
15
+ toaster.options.update((v) => ({ ...v, ...changedOptions }));
16
+ }
17
+ }, [toaster.options, options]);
18
+ const toasts = stores$1.useObservable(toaster.toasts);
19
+ const toasterOptions = stores$1.useObservable(toaster.options);
10
20
  const addToast = react.useCallback((props) => toaster.addToast(props), [toaster]);
11
21
  const removeToast = toaster.removeToast;
12
22
  const eventsDirective = toaster.eventsDirective;
@@ -1,9 +1,19 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Toaster } from "@agnos-ui/core/components/toast";
3
- import { useMemo, useCallback, createContext, useContext } from "react";
3
+ import { findChangedProperties } from "@agnos-ui/core/utils/stores";
4
+ import { useMemo, useRef, useCallback, createContext, useContext } from "react";
4
5
  import { u as useObservable } from "./stores-DZalyTTa.js";
5
6
  const useCreateToaster = (options) => {
6
- const toaster = useMemo(() => new Toaster(options), [options]);
7
+ const toaster = useMemo(() => new Toaster(options), []);
8
+ options = options ?? {};
9
+ const previousOptions = useRef(options);
10
+ useMemo(() => {
11
+ const changedOptions = findChangedProperties(previousOptions.current, options);
12
+ previousOptions.current = options;
13
+ if (changedOptions) {
14
+ toaster.options.update((v) => ({ ...v, ...changedOptions }));
15
+ }
16
+ }, [toaster.options, options]);
7
17
  const toasts = useObservable(toaster.toasts);
8
18
  const toasterOptions = useObservable(toaster.options);
9
19
  const addToast = useCallback((props) => toaster.addToast(props), [toaster]);