@agnos-ui/react-headless 0.8.0-next.1 → 0.8.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/components/toast/index.d.ts +2 -0
- package/components/toast/toasterProvider.d.ts +31 -0
- package/generated/components/carousel/index.cjs +9 -0
- package/generated/components/carousel/index.d.ts +1 -0
- package/generated/components/carousel/index.js +1 -0
- package/generated/components/toast/index.cjs +4 -0
- package/generated/components/toast/index.d.ts +1 -1
- package/generated/components/toast/index.js +6 -0
- package/generated/index.d.ts +4 -3
- package/index.cjs +14 -3
- package/index.js +9 -4
- package/package.json +4 -2
- package/toasterProvider-BtIHSdiL.cjs +37 -0
- package/toasterProvider-lT-AfOoK.js +38 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ToastProps } from '@agnos-ui/core/components/toast';
|
|
2
|
+
import type { ToasterProps } from '@agnos-ui/core/components/toast';
|
|
3
|
+
import type { PropsWithChildren } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Custom hook to create a toaster.
|
|
6
|
+
* @param options - Optional toaster properties.
|
|
7
|
+
* @returns An object containing toaster methods and properties.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useCreateToaster: <Props extends Partial<ToastProps>>(options?: ToasterProps) => {
|
|
10
|
+
toasts: import("@agnos-ui/core/components/toast").ToasterToast<Props>[];
|
|
11
|
+
options: ToasterProps;
|
|
12
|
+
addToast: (props: Props) => number;
|
|
13
|
+
removeToast: (id: number) => void;
|
|
14
|
+
eventsDirective: import("core/dist/types").Directive<number>;
|
|
15
|
+
closeAll: () => void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* ToasterProvider component to provide toaster context to its children.
|
|
19
|
+
* @param props - The properties object.
|
|
20
|
+
* @param [props.options] - Optional toaster properties.
|
|
21
|
+
* @param props.children - The children components.
|
|
22
|
+
* @returns The ToasterProvider component.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ToasterProvider: <Props extends Partial<ToastProps>>({ options, children }: PropsWithChildren<{
|
|
25
|
+
options?: ToasterProps;
|
|
26
|
+
}>) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* Custom hook to use the toaster context.
|
|
29
|
+
* @returns The toaster context.
|
|
30
|
+
*/
|
|
31
|
+
export declare const useToaster: <Props extends Partial<ToastProps>>() => ReturnType<typeof useCreateToaster<Props>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const carousel = require("@agnos-ui/core/components/carousel");
|
|
4
|
+
Object.keys(carousel).forEach((k) => {
|
|
5
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => carousel[k]
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@agnos-ui/core/components/carousel';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@agnos-ui/core/components/carousel";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const toasterProvider = require("../../../toasterProvider-BtIHSdiL.cjs");
|
|
3
4
|
const toast = require("@agnos-ui/core/components/toast");
|
|
5
|
+
exports.ToasterProvider = toasterProvider.ToasterProvider;
|
|
6
|
+
exports.useCreateToaster = toasterProvider.useCreateToaster;
|
|
7
|
+
exports.useToaster = toasterProvider.useToaster;
|
|
4
8
|
Object.keys(toast).forEach((k) => {
|
|
5
9
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
6
10
|
enumerable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from './../../../components/toast';
|
package/generated/index.d.ts
CHANGED
|
@@ -18,9 +18,6 @@ export * from './utils/func';
|
|
|
18
18
|
export * from './utils/directive';
|
|
19
19
|
export * from './types';
|
|
20
20
|
export * from './config';
|
|
21
|
-
export * from './utils/widget';
|
|
22
|
-
export * from './utils/portal';
|
|
23
|
-
export * from './slot';
|
|
24
21
|
export * from './components/tree/index';
|
|
25
22
|
export * from './components/toast/index';
|
|
26
23
|
export * from './components/slider/index';
|
|
@@ -29,5 +26,9 @@ export * from './components/rating/index';
|
|
|
29
26
|
export * from './components/progressbar/index';
|
|
30
27
|
export * from './components/pagination/index';
|
|
31
28
|
export * from './components/modal/index';
|
|
29
|
+
export * from './components/carousel/index';
|
|
32
30
|
export * from './components/alert/index';
|
|
33
31
|
export * from './components/accordion/index';
|
|
32
|
+
export * from './utils/widget';
|
|
33
|
+
export * from './utils/portal';
|
|
34
|
+
export * from './slot';
|
package/index.cjs
CHANGED
|
@@ -23,10 +23,8 @@ const directive = require("./directive-3diaW3tS.cjs");
|
|
|
23
23
|
const types = require("@agnos-ui/core/types");
|
|
24
24
|
const config$1 = require("@agnos-ui/core/config");
|
|
25
25
|
const config = require("./config.cjs");
|
|
26
|
-
const widget = require("./widget-CuLHUzFd.cjs");
|
|
27
|
-
const portal$1 = require("./portal-B0Q5KLrA.cjs");
|
|
28
|
-
const slot = require("./slot.cjs");
|
|
29
26
|
const tree = require("@agnos-ui/core/components/tree");
|
|
27
|
+
const toasterProvider = require("./toasterProvider-BtIHSdiL.cjs");
|
|
30
28
|
const toast = require("@agnos-ui/core/components/toast");
|
|
31
29
|
const slider = require("@agnos-ui/core/components/slider");
|
|
32
30
|
const select = require("@agnos-ui/core/components/select");
|
|
@@ -34,8 +32,12 @@ const rating = require("@agnos-ui/core/components/rating");
|
|
|
34
32
|
const progressbar = require("@agnos-ui/core/components/progressbar");
|
|
35
33
|
const pagination = require("@agnos-ui/core/components/pagination");
|
|
36
34
|
const modal = require("@agnos-ui/core/components/modal");
|
|
35
|
+
const carousel = require("@agnos-ui/core/components/carousel");
|
|
37
36
|
const alert = require("@agnos-ui/core/components/alert");
|
|
38
37
|
const accordion = require("@agnos-ui/core/components/accordion");
|
|
38
|
+
const widget = require("./widget-CuLHUzFd.cjs");
|
|
39
|
+
const portal$1 = require("./portal-B0Q5KLrA.cjs");
|
|
40
|
+
const slot = require("./slot.cjs");
|
|
39
41
|
exports.useObservable = stores.useObservable;
|
|
40
42
|
exports.useObservablesProxy = stores.useObservablesProxy;
|
|
41
43
|
exports.usePropsAsStore = stores.usePropsAsStore;
|
|
@@ -48,6 +50,9 @@ exports.WidgetsDefaultConfig = config.WidgetsDefaultConfig;
|
|
|
48
50
|
exports.useWidgetContext = config.useWidgetContext;
|
|
49
51
|
exports.useWidgetWithConfig = config.useWidgetWithConfig;
|
|
50
52
|
exports.widgetsConfigFactory = config.widgetsConfigFactory;
|
|
53
|
+
exports.ToasterProvider = toasterProvider.ToasterProvider;
|
|
54
|
+
exports.useCreateToaster = toasterProvider.useCreateToaster;
|
|
55
|
+
exports.useToaster = toasterProvider.useToaster;
|
|
51
56
|
exports.useWidget = widget.useWidget;
|
|
52
57
|
exports.Portal = portal$1.Portal;
|
|
53
58
|
exports.Slot = slot.Slot;
|
|
@@ -219,6 +224,12 @@ Object.keys(modal).forEach((k) => {
|
|
|
219
224
|
get: () => modal[k]
|
|
220
225
|
});
|
|
221
226
|
});
|
|
227
|
+
Object.keys(carousel).forEach((k) => {
|
|
228
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: () => carousel[k]
|
|
231
|
+
});
|
|
232
|
+
});
|
|
222
233
|
Object.keys(alert).forEach((k) => {
|
|
223
234
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
224
235
|
enumerable: true,
|
package/index.js
CHANGED
|
@@ -21,10 +21,8 @@ import { d, s, u as u2, a as a2 } from "./directive-CEErjM5c.js";
|
|
|
21
21
|
export * from "@agnos-ui/core/types";
|
|
22
22
|
export * from "@agnos-ui/core/config";
|
|
23
23
|
import { WidgetsConfigContext, WidgetsDefaultConfig, useWidgetContext, useWidgetWithConfig, widgetsConfigFactory } from "./config.js";
|
|
24
|
-
import { u as u3 } from "./widget-BP6z-zfB.js";
|
|
25
|
-
import { P } from "./portal-CX8X69NK.js";
|
|
26
|
-
import { Slot } from "./slot.js";
|
|
27
24
|
export * from "@agnos-ui/core/components/tree";
|
|
25
|
+
import { T, u as u3, a as a3 } from "./toasterProvider-lT-AfOoK.js";
|
|
28
26
|
export * from "@agnos-ui/core/components/toast";
|
|
29
27
|
export * from "@agnos-ui/core/components/slider";
|
|
30
28
|
export * from "@agnos-ui/core/components/select";
|
|
@@ -32,21 +30,28 @@ export * from "@agnos-ui/core/components/rating";
|
|
|
32
30
|
export * from "@agnos-ui/core/components/progressbar";
|
|
33
31
|
export * from "@agnos-ui/core/components/pagination";
|
|
34
32
|
export * from "@agnos-ui/core/components/modal";
|
|
33
|
+
export * from "@agnos-ui/core/components/carousel";
|
|
35
34
|
export * from "@agnos-ui/core/components/alert";
|
|
36
35
|
export * from "@agnos-ui/core/components/accordion";
|
|
36
|
+
import { u as u4 } from "./widget-BP6z-zfB.js";
|
|
37
|
+
import { P } from "./portal-CX8X69NK.js";
|
|
38
|
+
import { Slot } from "./slot.js";
|
|
37
39
|
export {
|
|
38
40
|
P as Portal,
|
|
39
41
|
Slot,
|
|
42
|
+
T as ToasterProvider,
|
|
40
43
|
WidgetsConfigContext,
|
|
41
44
|
WidgetsDefaultConfig,
|
|
42
45
|
d as directiveAttributes,
|
|
43
46
|
s as ssrAttributes,
|
|
47
|
+
u3 as useCreateToaster,
|
|
44
48
|
u2 as useDirective,
|
|
45
49
|
a2 as useDirectives,
|
|
46
50
|
u as useObservable,
|
|
47
51
|
a as useObservablesProxy,
|
|
48
52
|
b as usePropsAsStore,
|
|
49
|
-
|
|
53
|
+
a3 as useToaster,
|
|
54
|
+
u4 as useWidget,
|
|
50
55
|
useWidgetContext,
|
|
51
56
|
useWidgetWithConfig,
|
|
52
57
|
widgetsConfigFactory
|
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.8.0
|
|
4
|
+
"version": "0.8.0",
|
|
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.8.0
|
|
52
|
+
"@agnos-ui/core": "0.8.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@amadeus-it-group/tansu": "^2.0.0",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"accordion",
|
|
73
73
|
"AgnosUI",
|
|
74
74
|
"alert",
|
|
75
|
+
"carousel",
|
|
75
76
|
"collapse",
|
|
76
77
|
"components",
|
|
77
78
|
"modal",
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
"rating",
|
|
81
82
|
"slider",
|
|
82
83
|
"toast",
|
|
84
|
+
"tree",
|
|
83
85
|
"widgets"
|
|
84
86
|
]
|
|
85
87
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const toast = require("@agnos-ui/core/components/toast");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const stores = require("./stores-DD819q-h.cjs");
|
|
6
|
+
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);
|
|
10
|
+
const addToast = react.useCallback((props) => toaster.addToast(props), [toaster]);
|
|
11
|
+
const removeToast = toaster.removeToast;
|
|
12
|
+
const eventsDirective = toaster.eventsDirective;
|
|
13
|
+
const closeAll = toaster.closeAll;
|
|
14
|
+
return {
|
|
15
|
+
toasts,
|
|
16
|
+
options: toasterOptions,
|
|
17
|
+
addToast,
|
|
18
|
+
removeToast,
|
|
19
|
+
eventsDirective,
|
|
20
|
+
closeAll
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const ToasterContext = react.createContext(void 0);
|
|
24
|
+
const ToasterProvider = ({ options, children }) => {
|
|
25
|
+
const toaster = useCreateToaster(options);
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ToasterContext.Provider, { value: toaster, children });
|
|
27
|
+
};
|
|
28
|
+
const useToaster = () => {
|
|
29
|
+
const context = react.useContext(ToasterContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useToaster must be used within a ToasterProvider");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
};
|
|
35
|
+
exports.ToasterProvider = ToasterProvider;
|
|
36
|
+
exports.useCreateToaster = useCreateToaster;
|
|
37
|
+
exports.useToaster = useToaster;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Toaster } from "@agnos-ui/core/components/toast";
|
|
3
|
+
import { useMemo, useCallback, createContext, useContext } from "react";
|
|
4
|
+
import { u as useObservable } from "./stores-DZalyTTa.js";
|
|
5
|
+
const useCreateToaster = (options) => {
|
|
6
|
+
const toaster = useMemo(() => new Toaster(options), [options]);
|
|
7
|
+
const toasts = useObservable(toaster.toasts);
|
|
8
|
+
const toasterOptions = useObservable(toaster.options);
|
|
9
|
+
const addToast = useCallback((props) => toaster.addToast(props), [toaster]);
|
|
10
|
+
const removeToast = toaster.removeToast;
|
|
11
|
+
const eventsDirective = toaster.eventsDirective;
|
|
12
|
+
const closeAll = toaster.closeAll;
|
|
13
|
+
return {
|
|
14
|
+
toasts,
|
|
15
|
+
options: toasterOptions,
|
|
16
|
+
addToast,
|
|
17
|
+
removeToast,
|
|
18
|
+
eventsDirective,
|
|
19
|
+
closeAll
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const ToasterContext = createContext(void 0);
|
|
23
|
+
const ToasterProvider = ({ options, children }) => {
|
|
24
|
+
const toaster = useCreateToaster(options);
|
|
25
|
+
return /* @__PURE__ */ jsx(ToasterContext.Provider, { value: toaster, children });
|
|
26
|
+
};
|
|
27
|
+
const useToaster = () => {
|
|
28
|
+
const context = useContext(ToasterContext);
|
|
29
|
+
if (!context) {
|
|
30
|
+
throw new Error("useToaster must be used within a ToasterProvider");
|
|
31
|
+
}
|
|
32
|
+
return context;
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
ToasterProvider as T,
|
|
36
|
+
useToaster as a,
|
|
37
|
+
useCreateToaster as u
|
|
38
|
+
};
|