@agnos-ui/react-headless 0.9.2 → 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;
package/config.cjs CHANGED
@@ -5,7 +5,7 @@ const types = require("@agnos-ui/core/types");
5
5
  const config = require("@agnos-ui/core/config");
6
6
  const tansu = require("@amadeus-it-group/tansu");
7
7
  const react = require("react");
8
- const widget = require("./widget-CHGwSEgq.cjs");
8
+ const widget = require("./widget-BkLUvh4T.cjs");
9
9
  const stores = require("./stores-DD819q-h.cjs");
10
10
  const widgetsConfigFactory = (WidgetsConfigContext2 = react.createContext(void 0)) => {
11
11
  const useWidgetContext2 = (widgetName, defaultConfig) => {
package/config.js CHANGED
@@ -4,7 +4,7 @@ import { createWidgetsConfig } from "@agnos-ui/core/config";
4
4
  export * from "@agnos-ui/core/config";
5
5
  import { computed } from "@amadeus-it-group/tansu";
6
6
  import { createContext, useContext, useMemo } from "react";
7
- import { u as useWidgetWithConfig } from "./widget-BiWY_QJE.js";
7
+ import { u as useWidgetWithConfig } from "./widget-DLB7vGCY.js";
8
8
  import { b as usePropsAsStore } from "./stores-DZalyTTa.js";
9
9
  const widgetsConfigFactory = (WidgetsConfigContext2 = createContext(void 0)) => {
10
10
  const useWidgetContext2 = (widgetName, defaultConfig) => {
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const collapse = require("@agnos-ui/core/components/collapse");
4
+ Object.keys(collapse).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
6
+ enumerable: true,
7
+ get: () => collapse[k]
8
+ });
9
+ });
@@ -0,0 +1 @@
1
+ export * from '@agnos-ui/core/components/collapse';
@@ -0,0 +1 @@
1
+ export * from "@agnos-ui/core/components/collapse";
@@ -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,6 +27,7 @@ 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/collapse/index';
30
31
  export * from './components/carousel/index';
31
32
  export * from './components/alert/index';
32
33
  export * from './components/accordion/index';
@@ -1,4 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const widget = require("../../widget-CHGwSEgq.cjs");
3
+ const widget = require("../../widget-BkLUvh4T.cjs");
4
+ const widget$1 = require("@agnos-ui/core/utils/widget");
4
5
  exports.useWidgetWithConfig = widget.useWidgetWithConfig;
6
+ Object.keys(widget$1).forEach((k) => {
7
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
8
+ enumerable: true,
9
+ get: () => widget$1[k]
10
+ });
11
+ });
@@ -1,4 +1,5 @@
1
- import { u } from "../../widget-BiWY_QJE.js";
1
+ import { u } from "../../widget-DLB7vGCY.js";
2
+ export * from "@agnos-ui/core/utils/widget";
2
3
  export {
3
4
  u as useWidgetWithConfig
4
5
  };
package/index.cjs CHANGED
@@ -15,7 +15,8 @@ const cssTransitions = require("@agnos-ui/core/services/transitions/cssTransitio
15
15
  const collapse = require("@agnos-ui/core/services/transitions/collapse");
16
16
  const baseTransitions = require("@agnos-ui/core/services/transitions/baseTransitions");
17
17
  const writables = require("@agnos-ui/core/utils/writables");
18
- const widget = require("./widget-CHGwSEgq.cjs");
18
+ const widget$1 = require("@agnos-ui/core/utils/widget");
19
+ const widget = require("./widget-BkLUvh4T.cjs");
19
20
  const stores$1 = require("@agnos-ui/core/utils/stores");
20
21
  const stores = require("./stores-DD819q-h.cjs");
21
22
  const func = require("@agnos-ui/core/utils/func");
@@ -25,7 +26,7 @@ const types = require("@agnos-ui/core/types");
25
26
  const config$1 = require("@agnos-ui/core/config");
26
27
  const config = require("./config.cjs");
27
28
  const tree = require("@agnos-ui/core/components/tree");
28
- const toasterProvider = require("./toasterProvider-BtIHSdiL.cjs");
29
+ const toasterProvider = require("./toasterProvider-BAKMnkH7.cjs");
29
30
  const toast = require("@agnos-ui/core/components/toast");
30
31
  const slider = require("@agnos-ui/core/components/slider");
31
32
  const select = require("@agnos-ui/core/components/select");
@@ -33,6 +34,7 @@ const rating = require("@agnos-ui/core/components/rating");
33
34
  const progressbar = require("@agnos-ui/core/components/progressbar");
34
35
  const pagination = require("@agnos-ui/core/components/pagination");
35
36
  const modal = require("@agnos-ui/core/components/modal");
37
+ const collapse$1 = require("@agnos-ui/core/components/collapse");
36
38
  const carousel = require("@agnos-ui/core/components/carousel");
37
39
  const alert = require("@agnos-ui/core/components/alert");
38
40
  const accordion = require("@agnos-ui/core/components/accordion");
@@ -146,6 +148,12 @@ Object.keys(writables).forEach((k) => {
146
148
  get: () => writables[k]
147
149
  });
148
150
  });
151
+ Object.keys(widget$1).forEach((k) => {
152
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
153
+ enumerable: true,
154
+ get: () => widget$1[k]
155
+ });
156
+ });
149
157
  Object.keys(stores$1).forEach((k) => {
150
158
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
151
159
  enumerable: true,
@@ -224,6 +232,12 @@ Object.keys(modal).forEach((k) => {
224
232
  get: () => modal[k]
225
233
  });
226
234
  });
235
+ Object.keys(collapse$1).forEach((k) => {
236
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
237
+ enumerable: true,
238
+ get: () => collapse$1[k]
239
+ });
240
+ });
227
241
  Object.keys(carousel).forEach((k) => {
228
242
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
229
243
  enumerable: true,
package/index.js CHANGED
@@ -13,7 +13,8 @@ export * from "@agnos-ui/core/services/transitions/cssTransitions";
13
13
  export * from "@agnos-ui/core/services/transitions/collapse";
14
14
  export * from "@agnos-ui/core/services/transitions/baseTransitions";
15
15
  export * from "@agnos-ui/core/utils/writables";
16
- import { u } from "./widget-BiWY_QJE.js";
16
+ export * from "@agnos-ui/core/utils/widget";
17
+ import { u } from "./widget-DLB7vGCY.js";
17
18
  export * from "@agnos-ui/core/utils/stores";
18
19
  import { u as u2, a, b } from "./stores-DZalyTTa.js";
19
20
  export * from "@agnos-ui/core/utils/func";
@@ -23,7 +24,7 @@ export * from "@agnos-ui/core/types";
23
24
  export * from "@agnos-ui/core/config";
24
25
  import { WidgetsConfigContext, WidgetsDefaultConfig, useWidget, useWidgetContext, widgetsConfigFactory } from "./config.js";
25
26
  export * from "@agnos-ui/core/components/tree";
26
- 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";
27
28
  export * from "@agnos-ui/core/components/toast";
28
29
  export * from "@agnos-ui/core/components/slider";
29
30
  export * from "@agnos-ui/core/components/select";
@@ -31,6 +32,7 @@ export * from "@agnos-ui/core/components/rating";
31
32
  export * from "@agnos-ui/core/components/progressbar";
32
33
  export * from "@agnos-ui/core/components/pagination";
33
34
  export * from "@agnos-ui/core/components/modal";
35
+ export * from "@agnos-ui/core/components/collapse";
34
36
  export * from "@agnos-ui/core/components/carousel";
35
37
  export * from "@agnos-ui/core/components/alert";
36
38
  export * from "@agnos-ui/core/components/accordion";
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.2",
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.2"
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]);
package/utils/widget.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { PropsConfig, Widget, WidgetFactory, WidgetProps, WidgetSlotContext } from '@agnos-ui/core/types';
2
+ export * from '@agnos-ui/core/utils/widget';
2
3
  /**
3
4
  * Create and attach an agnos-ui/core widget to the current react component.
4
5
  *
@@ -2,6 +2,7 @@
2
2
  const stores = require("@agnos-ui/core/utils/stores");
3
3
  const react = require("react");
4
4
  const stores$1 = require("./stores-DD819q-h.cjs");
5
+ require("@agnos-ui/core/utils/widget");
5
6
  function useWidgetWithConfig(factory, props = {}, propsConfig) {
6
7
  const coreWidget = react.useMemo(() => factory({ ...propsConfig, props: { ...propsConfig == null ? void 0 : propsConfig.props, ...props } }), []);
7
8
  const previousProps = react.useRef(props);
@@ -1,6 +1,7 @@
1
1
  import { findChangedProperties } from "@agnos-ui/core/utils/stores";
2
2
  import { useMemo, useRef } from "react";
3
3
  import { a as useObservablesProxy } from "./stores-DZalyTTa.js";
4
+ import "@agnos-ui/core/utils/widget";
4
5
  function useWidgetWithConfig(factory, props = {}, propsConfig) {
5
6
  const coreWidget = useMemo(() => factory({ ...propsConfig, props: { ...propsConfig == null ? void 0 : propsConfig.props, ...props } }), []);
6
7
  const previousProps = useRef(props);