@agnos-ui/react-headless 0.8.1 → 0.9.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/config.cjs +6 -5
- package/config.d.ts +3 -3
- package/config.js +6 -5
- package/generated/index.d.ts +1 -1
- package/generated/utils/widget.cjs +2 -2
- package/generated/utils/widget.js +2 -2
- package/index.cjs +3 -3
- package/index.js +10 -10
- package/package.json +2 -2
- package/utils/widget.d.ts +4 -5
- package/{widget-BP6z-zfB.js → widget-BiWY_QJE.js} +3 -3
- package/{widget-CuLHUzFd.cjs → widget-CHGwSEgq.cjs} +3 -3
package/config.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const types = require("@agnos-ui/core/types");
|
|
4
5
|
const config = require("@agnos-ui/core/config");
|
|
5
6
|
const tansu = require("@amadeus-it-group/tansu");
|
|
6
7
|
const react = require("react");
|
|
7
|
-
const widget = require("./widget-
|
|
8
|
+
const widget = require("./widget-CHGwSEgq.cjs");
|
|
8
9
|
const stores = require("./stores-DD819q-h.cjs");
|
|
9
10
|
const widgetsConfigFactory = (WidgetsConfigContext2 = react.createContext(void 0)) => {
|
|
10
11
|
const useWidgetContext2 = (widgetName, defaultConfig) => {
|
|
@@ -15,7 +16,7 @@ const widgetsConfigFactory = (WidgetsConfigContext2 = react.createContext(void 0
|
|
|
15
16
|
[defaultConfig$, widgetName, widgetsConfig]
|
|
16
17
|
);
|
|
17
18
|
};
|
|
18
|
-
const
|
|
19
|
+
const useWidget2 = (factory, props, defaultProps) => widget.useWidgetWithConfig(factory, props, { config: useWidgetContext2(factory[types.FACTORY_WIDGET_NAME], defaultProps) });
|
|
19
20
|
const WidgetsDefaultConfig2 = ({ children, adaptParentConfig, ...props }) => {
|
|
20
21
|
const config$ = react.useContext(WidgetsConfigContext2);
|
|
21
22
|
const store$ = react.useMemo(() => config.createWidgetsConfig(config$, adaptParentConfig), [config$, adaptParentConfig]);
|
|
@@ -28,15 +29,15 @@ const widgetsConfigFactory = (WidgetsConfigContext2 = react.createContext(void 0
|
|
|
28
29
|
*/
|
|
29
30
|
WidgetsConfigContext: WidgetsConfigContext2,
|
|
30
31
|
useWidgetContext: useWidgetContext2,
|
|
31
|
-
|
|
32
|
+
useWidget: useWidget2,
|
|
32
33
|
WidgetsDefaultConfig: WidgetsDefaultConfig2
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
|
-
const { WidgetsConfigContext, WidgetsDefaultConfig, useWidgetContext,
|
|
36
|
+
const { WidgetsConfigContext, WidgetsDefaultConfig, useWidgetContext, useWidget } = widgetsConfigFactory();
|
|
36
37
|
exports.WidgetsConfigContext = WidgetsConfigContext;
|
|
37
38
|
exports.WidgetsDefaultConfig = WidgetsDefaultConfig;
|
|
39
|
+
exports.useWidget = useWidget;
|
|
38
40
|
exports.useWidgetContext = useWidgetContext;
|
|
39
|
-
exports.useWidgetWithConfig = useWidgetWithConfig;
|
|
40
41
|
exports.widgetsConfigFactory = widgetsConfigFactory;
|
|
41
42
|
Object.keys(config).forEach((k) => {
|
|
42
43
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
package/config.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export declare const widgetsConfigFactory: <Config extends Record<string, object
|
|
|
19
19
|
* React context which can be used to provide or consume the widgets default configuration store.
|
|
20
20
|
*/
|
|
21
21
|
WidgetsConfigContext: import("react").Context<WidgetsConfigStore<Config> | undefined>;
|
|
22
|
-
useWidgetContext: <Props extends object>(widgetName
|
|
23
|
-
|
|
22
|
+
useWidgetContext: <Props extends object>(widgetName?: string, defaultConfig?: Partial<Props>) => import("@amadeus-it-group/tansu").ReadableSignal<Partial<Props>>;
|
|
23
|
+
useWidget: <W extends Widget>(factory: WidgetFactory<W>, props?: Partial<WidgetProps<W>>, defaultProps?: Partial<WidgetProps<W>>) => import("@agnos-ui/core/types").WidgetSlotContext<W>;
|
|
24
24
|
WidgetsDefaultConfig: ({ children, adaptParentConfig, ...props }: DefaultConfigInput<Config>) => import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
};
|
|
26
|
-
export declare const WidgetsConfigContext: import("react").Context<WidgetsConfigStore<WidgetsConfig> | undefined>, WidgetsDefaultConfig: ({ children, adaptParentConfig, ...props }: DefaultConfigInput<WidgetsConfig>) => import("react/jsx-runtime").JSX.Element, useWidgetContext: <Props extends object>(widgetName
|
|
26
|
+
export declare const WidgetsConfigContext: import("react").Context<WidgetsConfigStore<WidgetsConfig> | undefined>, WidgetsDefaultConfig: ({ children, adaptParentConfig, ...props }: DefaultConfigInput<WidgetsConfig>) => import("react/jsx-runtime").JSX.Element, useWidgetContext: <Props extends object>(widgetName?: string, defaultConfig?: Partial<Props> | undefined) => import("@amadeus-it-group/tansu").ReadableSignal<Partial<Props>>, useWidget: <W extends Widget>(factory: WidgetFactory<W>, props?: Partial<WidgetProps<W>> | undefined, defaultProps?: Partial<WidgetProps<W>> | undefined) => import("@agnos-ui/core/types").WidgetSlotContext<W>;
|
package/config.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FACTORY_WIDGET_NAME } from "@agnos-ui/core/types";
|
|
2
3
|
import { createWidgetsConfig } from "@agnos-ui/core/config";
|
|
3
4
|
export * from "@agnos-ui/core/config";
|
|
4
5
|
import { computed } from "@amadeus-it-group/tansu";
|
|
5
6
|
import { createContext, useContext, useMemo } from "react";
|
|
6
|
-
import { u as
|
|
7
|
+
import { u as useWidgetWithConfig } from "./widget-BiWY_QJE.js";
|
|
7
8
|
import { b as usePropsAsStore } from "./stores-DZalyTTa.js";
|
|
8
9
|
const widgetsConfigFactory = (WidgetsConfigContext2 = createContext(void 0)) => {
|
|
9
10
|
const useWidgetContext2 = (widgetName, defaultConfig) => {
|
|
@@ -14,7 +15,7 @@ const widgetsConfigFactory = (WidgetsConfigContext2 = createContext(void 0)) =>
|
|
|
14
15
|
[defaultConfig$, widgetName, widgetsConfig]
|
|
15
16
|
);
|
|
16
17
|
};
|
|
17
|
-
const
|
|
18
|
+
const useWidget2 = (factory, props, defaultProps) => useWidgetWithConfig(factory, props, { config: useWidgetContext2(factory[FACTORY_WIDGET_NAME], defaultProps) });
|
|
18
19
|
const WidgetsDefaultConfig2 = ({ children, adaptParentConfig, ...props }) => {
|
|
19
20
|
const config$ = useContext(WidgetsConfigContext2);
|
|
20
21
|
const store$ = useMemo(() => createWidgetsConfig(config$, adaptParentConfig), [config$, adaptParentConfig]);
|
|
@@ -27,15 +28,15 @@ const widgetsConfigFactory = (WidgetsConfigContext2 = createContext(void 0)) =>
|
|
|
27
28
|
*/
|
|
28
29
|
WidgetsConfigContext: WidgetsConfigContext2,
|
|
29
30
|
useWidgetContext: useWidgetContext2,
|
|
30
|
-
|
|
31
|
+
useWidget: useWidget2,
|
|
31
32
|
WidgetsDefaultConfig: WidgetsDefaultConfig2
|
|
32
33
|
};
|
|
33
34
|
};
|
|
34
|
-
const { WidgetsConfigContext, WidgetsDefaultConfig, useWidgetContext,
|
|
35
|
+
const { WidgetsConfigContext, WidgetsDefaultConfig, useWidgetContext, useWidget } = widgetsConfigFactory();
|
|
35
36
|
export {
|
|
36
37
|
WidgetsConfigContext,
|
|
37
38
|
WidgetsDefaultConfig,
|
|
39
|
+
useWidget,
|
|
38
40
|
useWidgetContext,
|
|
39
|
-
useWidgetWithConfig,
|
|
40
41
|
widgetsConfigFactory
|
|
41
42
|
};
|
package/generated/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './services/transitions/cssTransitions';
|
|
|
13
13
|
export * from './services/transitions/collapse';
|
|
14
14
|
export * from './services/transitions/baseTransitions';
|
|
15
15
|
export * from './utils/writables';
|
|
16
|
+
export * from './utils/widget';
|
|
16
17
|
export * from './utils/stores';
|
|
17
18
|
export * from './utils/func';
|
|
18
19
|
export * from './utils/directive';
|
|
@@ -29,6 +30,5 @@ export * from './components/modal/index';
|
|
|
29
30
|
export * from './components/carousel/index';
|
|
30
31
|
export * from './components/alert/index';
|
|
31
32
|
export * from './components/accordion/index';
|
|
32
|
-
export * from './utils/widget';
|
|
33
33
|
export * from './utils/portal';
|
|
34
34
|
export * from './slot';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const widget = require("../../widget-
|
|
4
|
-
exports.
|
|
3
|
+
const widget = require("../../widget-CHGwSEgq.cjs");
|
|
4
|
+
exports.useWidgetWithConfig = widget.useWidgetWithConfig;
|
package/index.cjs
CHANGED
|
@@ -15,6 +15,7 @@ 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
19
|
const stores$1 = require("@agnos-ui/core/utils/stores");
|
|
19
20
|
const stores = require("./stores-DD819q-h.cjs");
|
|
20
21
|
const func = require("@agnos-ui/core/utils/func");
|
|
@@ -35,9 +36,9 @@ const modal = require("@agnos-ui/core/components/modal");
|
|
|
35
36
|
const carousel = require("@agnos-ui/core/components/carousel");
|
|
36
37
|
const alert = require("@agnos-ui/core/components/alert");
|
|
37
38
|
const accordion = require("@agnos-ui/core/components/accordion");
|
|
38
|
-
const widget = require("./widget-CuLHUzFd.cjs");
|
|
39
39
|
const portal$1 = require("./portal-B0Q5KLrA.cjs");
|
|
40
40
|
const slot = require("./slot.cjs");
|
|
41
|
+
exports.useWidgetWithConfig = widget.useWidgetWithConfig;
|
|
41
42
|
exports.useObservable = stores.useObservable;
|
|
42
43
|
exports.useObservablesProxy = stores.useObservablesProxy;
|
|
43
44
|
exports.usePropsAsStore = stores.usePropsAsStore;
|
|
@@ -47,13 +48,12 @@ exports.useDirective = directive.useDirective;
|
|
|
47
48
|
exports.useDirectives = directive.useDirectives;
|
|
48
49
|
exports.WidgetsConfigContext = config.WidgetsConfigContext;
|
|
49
50
|
exports.WidgetsDefaultConfig = config.WidgetsDefaultConfig;
|
|
51
|
+
exports.useWidget = config.useWidget;
|
|
50
52
|
exports.useWidgetContext = config.useWidgetContext;
|
|
51
|
-
exports.useWidgetWithConfig = config.useWidgetWithConfig;
|
|
52
53
|
exports.widgetsConfigFactory = config.widgetsConfigFactory;
|
|
53
54
|
exports.ToasterProvider = toasterProvider.ToasterProvider;
|
|
54
55
|
exports.useCreateToaster = toasterProvider.useCreateToaster;
|
|
55
56
|
exports.useToaster = toasterProvider.useToaster;
|
|
56
|
-
exports.useWidget = widget.useWidget;
|
|
57
57
|
exports.Portal = portal$1.Portal;
|
|
58
58
|
exports.Slot = slot.Slot;
|
|
59
59
|
Object.keys(siblingsInert).forEach((k) => {
|
package/index.js
CHANGED
|
@@ -13,16 +13,17 @@ 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
17
|
export * from "@agnos-ui/core/utils/stores";
|
|
17
|
-
import { u, a, b } from "./stores-DZalyTTa.js";
|
|
18
|
+
import { u as u2, a, b } from "./stores-DZalyTTa.js";
|
|
18
19
|
export * from "@agnos-ui/core/utils/func";
|
|
19
20
|
export * from "@agnos-ui/core/utils/directive";
|
|
20
|
-
import { d, s, u as
|
|
21
|
+
import { d, s, u as u3, a as a2 } from "./directive-CEErjM5c.js";
|
|
21
22
|
export * from "@agnos-ui/core/types";
|
|
22
23
|
export * from "@agnos-ui/core/config";
|
|
23
|
-
import { WidgetsConfigContext, WidgetsDefaultConfig,
|
|
24
|
+
import { WidgetsConfigContext, WidgetsDefaultConfig, useWidget, useWidgetContext, widgetsConfigFactory } from "./config.js";
|
|
24
25
|
export * from "@agnos-ui/core/components/tree";
|
|
25
|
-
import { T, u as
|
|
26
|
+
import { T, u as u4, a as a3 } from "./toasterProvider-lT-AfOoK.js";
|
|
26
27
|
export * from "@agnos-ui/core/components/toast";
|
|
27
28
|
export * from "@agnos-ui/core/components/slider";
|
|
28
29
|
export * from "@agnos-ui/core/components/select";
|
|
@@ -33,7 +34,6 @@ export * from "@agnos-ui/core/components/modal";
|
|
|
33
34
|
export * from "@agnos-ui/core/components/carousel";
|
|
34
35
|
export * from "@agnos-ui/core/components/alert";
|
|
35
36
|
export * from "@agnos-ui/core/components/accordion";
|
|
36
|
-
import { u as u4 } from "./widget-BP6z-zfB.js";
|
|
37
37
|
import { P } from "./portal-CX8X69NK.js";
|
|
38
38
|
import { Slot } from "./slot.js";
|
|
39
39
|
export {
|
|
@@ -44,15 +44,15 @@ export {
|
|
|
44
44
|
WidgetsDefaultConfig,
|
|
45
45
|
d as directiveAttributes,
|
|
46
46
|
s as ssrAttributes,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
u4 as useCreateToaster,
|
|
48
|
+
u3 as useDirective,
|
|
49
49
|
a2 as useDirectives,
|
|
50
|
-
|
|
50
|
+
u2 as useObservable,
|
|
51
51
|
a as useObservablesProxy,
|
|
52
52
|
b as usePropsAsStore,
|
|
53
53
|
a3 as useToaster,
|
|
54
|
-
|
|
54
|
+
useWidget,
|
|
55
55
|
useWidgetContext,
|
|
56
|
-
useWidgetWithConfig,
|
|
56
|
+
u as useWidgetWithConfig,
|
|
57
57
|
widgetsConfigFactory
|
|
58
58
|
};
|
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.
|
|
4
|
+
"version": "0.9.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.
|
|
52
|
+
"@agnos-ui/core": "0.9.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@amadeus-it-group/tansu": "^2.0.0",
|
package/utils/widget.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { PropsConfig, Widget, WidgetFactory, WidgetProps, WidgetSlotContext } from '@agnos-ui/core/types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Create and attach an agnos-ui/core widget to the current react component.
|
|
4
4
|
*
|
|
5
|
-
* Allows to create and attach an agnos-ui/core widget to the current react component.
|
|
6
5
|
* @template W - The type of the widget.
|
|
7
|
-
* @param
|
|
6
|
+
* @param factory - the widget factory
|
|
8
7
|
* @param props - the props
|
|
9
8
|
* @param propsConfig - the props config
|
|
10
|
-
* @returns the state and
|
|
9
|
+
* @returns the state, api and directives to track and interact with the widget
|
|
11
10
|
*/
|
|
12
|
-
export declare function
|
|
11
|
+
export declare function useWidgetWithConfig<W extends Widget>(factory: WidgetFactory<W>, props?: Partial<WidgetProps<W>>, propsConfig?: PropsConfig<WidgetProps<W>>): WidgetSlotContext<W>;
|
|
@@ -1,8 +1,8 @@
|
|
|
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
|
-
function
|
|
5
|
-
const coreWidget = useMemo(() =>
|
|
4
|
+
function useWidgetWithConfig(factory, props = {}, propsConfig) {
|
|
5
|
+
const coreWidget = useMemo(() => factory({ ...propsConfig, props: { ...propsConfig == null ? void 0 : propsConfig.props, ...props } }), []);
|
|
6
6
|
const previousProps = useRef(props);
|
|
7
7
|
useMemo(() => {
|
|
8
8
|
const changedProps = findChangedProperties(previousProps.current, props);
|
|
@@ -15,5 +15,5 @@ function useWidget(createWidget, props = {}, propsConfig) {
|
|
|
15
15
|
return { state, api: coreWidget.api, directives: coreWidget.directives };
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
useWidgetWithConfig as u
|
|
19
19
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
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
|
-
function
|
|
6
|
-
const coreWidget = react.useMemo(() =>
|
|
5
|
+
function useWidgetWithConfig(factory, props = {}, propsConfig) {
|
|
6
|
+
const coreWidget = react.useMemo(() => factory({ ...propsConfig, props: { ...propsConfig == null ? void 0 : propsConfig.props, ...props } }), []);
|
|
7
7
|
const previousProps = react.useRef(props);
|
|
8
8
|
react.useMemo(() => {
|
|
9
9
|
const changedProps = stores.findChangedProperties(previousProps.current, props);
|
|
@@ -15,4 +15,4 @@ function useWidget(createWidget, props = {}, propsConfig) {
|
|
|
15
15
|
const state = stores$1.useObservablesProxy(coreWidget.stores);
|
|
16
16
|
return { state, api: coreWidget.api, directives: coreWidget.directives };
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
18
|
+
exports.useWidgetWithConfig = useWidgetWithConfig;
|