@agnos-ui/react-headless
Advanced tools
Comparing version 0.0.1-alpha.6 to 0.0.1-alpha.7
@@ -13,2 +13,10 @@ import type { Widget, WidgetFactory, WidgetProps, WidgetState } from '@agnos-ui/core/types'; | ||
}; | ||
/** | ||
* A factory to create the use functions and react component to allow widgets to be context-aware. | ||
* | ||
* It can be used when extending the core and creating new widgets. | ||
* | ||
* @param widgetsConfigContext - the widgets config context | ||
* @returns the use functions and react component | ||
*/ | ||
export declare const widgetsConfigFactory: <Config extends { | ||
@@ -15,0 +23,0 @@ [widgetName: string]: object; |
@@ -8,2 +8,10 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
export * from '@agnos-ui/core/config'; | ||
/** | ||
* A factory to create the use functions and react component to allow widgets to be context-aware. | ||
* | ||
* It can be used when extending the core and creating new widgets. | ||
* | ||
* @param widgetsConfigContext - the widgets config context | ||
* @returns the use functions and react component | ||
*/ | ||
export const widgetsConfigFactory = (widgetsConfigContext = createContext(undefined)) => { | ||
@@ -27,3 +35,5 @@ const useWidgetContext = (widgetName, defaultConfig) => { | ||
* | ||
* @param adaptParentConfig - optional function that receives a 2-levels copy of the widgets default configuration | ||
* @param componentInputs - the react component inputs | ||
* @param componentInputs.children - the react component children | ||
* @param componentInputs.adaptParentConfig - optional function that receives a 2-levels copy of the widgets default configuration | ||
* defined at an upper level in the Svelte context hierarchy (or an empty object if there is none) and returns the widgets | ||
@@ -30,0 +40,0 @@ * default configuration to be used. |
@@ -1,9 +0,9 @@ | ||
export * from './components/accordion/accordion'; | ||
export * from './components/alert/alert'; | ||
export * from './components/modal/modal'; | ||
export * from './components/pagination/pagination'; | ||
export * from './components/progressbar/progressbar'; | ||
export * from './components/rating/rating'; | ||
export * from './components/select/select'; | ||
export * from './components/slider/slider'; | ||
export * from './components/accordion'; | ||
export * from './components/alert'; | ||
export * from './components/modal'; | ||
export * from './components/pagination'; | ||
export * from './components/progressbar'; | ||
export * from './components/rating'; | ||
export * from './components/select'; | ||
export * from './components/slider'; | ||
export * from './generated'; |
16
index.js
@@ -1,9 +0,9 @@ | ||
export * from './components/accordion/accordion'; | ||
export * from './components/alert/alert'; | ||
export * from './components/modal/modal'; | ||
export * from './components/pagination/pagination'; | ||
export * from './components/progressbar/progressbar'; | ||
export * from './components/rating/rating'; | ||
export * from './components/select/select'; | ||
export * from './components/slider/slider'; | ||
export * from './components/accordion'; | ||
export * from './components/alert'; | ||
export * from './components/modal'; | ||
export * from './components/pagination'; | ||
export * from './components/progressbar'; | ||
export * from './components/rating'; | ||
export * from './components/select'; | ||
export * from './components/slider'; | ||
export * from './generated'; |
@@ -42,4 +42,4 @@ { | ||
"dependencies": { | ||
"@agnos-ui/core": "0.0.1-alpha.6", | ||
"@amadeus-it-group/tansu": "0.0.24", | ||
"@agnos-ui/core": "0.0.1-alpha.7", | ||
"@amadeus-it-group/tansu": "1.0.0", | ||
"classnames": "^2.5.1" | ||
@@ -52,3 +52,3 @@ }, | ||
"sideEffects": false, | ||
"version": "0.0.1-alpha.6", | ||
"version": "0.0.1-alpha.7", | ||
"homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/", | ||
@@ -55,0 +55,0 @@ "bugs": "https://github.com/AmadeusITGroup/AgnosUI/issues", |
import type { SlotContent } from './types'; | ||
/** | ||
* The React Slot component, allowing to extensively customize widgets. | ||
* | ||
* The input slotContent can be a react component, a function or jsx. | ||
* | ||
* @param parameter - the react component parameter | ||
* @param parameter.slotContent - the slot content | ||
* @param parameter.props - the react component props | ||
* @returns the slot component | ||
*/ | ||
export declare const Slot: <Props extends object>({ slotContent, props }: { | ||
@@ -3,0 +13,0 @@ slotContent: SlotContent<Props>; |
10
slot.js
@@ -18,2 +18,12 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; | ||
const isReactComponent = (item) => item.prototype instanceof Component; | ||
/** | ||
* The React Slot component, allowing to extensively customize widgets. | ||
* | ||
* The input slotContent can be a react component, a function or jsx. | ||
* | ||
* @param parameter - the react component parameter | ||
* @param parameter.slotContent - the slot content | ||
* @param parameter.props - the react component props | ||
* @returns the slot component | ||
*/ | ||
export const Slot = ({ slotContent, props }) => { | ||
@@ -20,0 +30,0 @@ const isFunction = typeof slotContent === 'function'; |
import { mergeDirectives } from '@agnos-ui/core/utils/directive'; | ||
import { useCallback, useMemo, useRef } from 'react'; | ||
export * from '@agnos-ui/core/utils/directive'; | ||
/** | ||
* The useDirective function. | ||
* | ||
* Allows to attach a provided directive to the current react component. | ||
* | ||
* @param directive - the directive | ||
* @param args - the args to pass to the directive | ||
* @returns the ref callback | ||
*/ | ||
export function useDirective(directive, args) { | ||
@@ -18,2 +27,11 @@ const instance = useRef(); | ||
} | ||
/** | ||
* The useDirectives function. | ||
* | ||
* Allows to attach multiple directives to the current react component. | ||
* | ||
* @param directives - directives | ||
* @param args - the args to pass to the directives | ||
* @returns the ref callback | ||
*/ | ||
export function useDirectives(directives, args) { | ||
@@ -20,0 +38,0 @@ const mergedDirectives = useMemo(() => mergeDirectives(...directives), directives); |
import type { PropsWithChildren } from 'react'; | ||
/** | ||
* A Portal component, allowing to attach content to an external container. | ||
* | ||
* @param param - the react component inputs | ||
* @param param.children - the react component children | ||
* @param param.container - the container to attach the portal to | ||
* @returns the portal component | ||
*/ | ||
export declare const Portal: ({ children, container }: PropsWithChildren<{ | ||
container: Element | DocumentFragment | null | undefined; | ||
}>) => import("react/jsx-runtime").JSX.Element; |
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; | ||
import { createPortal } from 'react-dom'; | ||
/** | ||
* A Portal component, allowing to attach content to an external container. | ||
* | ||
* @param param - the react component inputs | ||
* @param param.children - the react component children | ||
* @param param.container - the container to attach the portal to | ||
* @returns the portal component | ||
*/ | ||
export const Portal = ({ children, container }) => container ? createPortal(children, container) : _jsx(_Fragment, { children: children }); |
import type { ReadableSignal } from '@amadeus-it-group/tansu'; | ||
export * from '@agnos-ui/core/utils/stores'; | ||
/** | ||
* Observe a readable store inside of a react component. | ||
* | ||
* @param store$ - the readable store | ||
* @returns the observed value of the store | ||
*/ | ||
export declare function useObservable<T>(store$: ReadableSignal<T>): T; | ||
/** | ||
* Turn react props into readable stores. | ||
* | ||
* @param props - the props | ||
* @returns the readable stores | ||
*/ | ||
export declare const usePropsAsStore: <T extends object>(props?: Partial<T> | undefined) => ReadableSignal<Partial<T>>; |
@@ -5,2 +5,8 @@ import { findChangedProperties } from '@agnos-ui/core/utils/stores'; | ||
export * from '@agnos-ui/core/utils/stores'; | ||
/** | ||
* Observe a readable store inside of a react component. | ||
* | ||
* @param store$ - the readable store | ||
* @returns the observed value of the store | ||
*/ | ||
export function useObservable(store$) { | ||
@@ -18,2 +24,8 @@ const [value, setValue] = useState(() => store$()); | ||
const propsEqual = (a, b) => !findChangedProperties(a, b); | ||
/** | ||
* Turn react props into readable stores. | ||
* | ||
* @param props - the props | ||
* @returns the readable stores | ||
*/ | ||
export const usePropsAsStore = (props) => { | ||
@@ -20,0 +32,0 @@ const storeRef = useRef(); |
import type { PropsConfig, Widget, WidgetFactory, WidgetProps, WidgetState } from '@agnos-ui/core/types'; | ||
/** | ||
* The useWidget function. | ||
* | ||
* Allows to create and attach an agnos-ui/core widget to the current react component. | ||
* | ||
* @param createWidget - the widget factory | ||
* @param props - the props | ||
* @param propsConfig - the props config | ||
* @returns the state and api to track and interact with the widget | ||
*/ | ||
export declare function useWidget<W extends Widget>(createWidget: WidgetFactory<W>, props?: Partial<WidgetProps<W>>, propsConfig?: PropsConfig<WidgetProps<W>>): [WidgetState<W>, W]; |
import { findChangedProperties } from '@agnos-ui/core/utils/stores'; | ||
import { useEffect, useMemo, useRef } from 'react'; | ||
import { useObservable } from './stores'; | ||
/** | ||
* The useWidget function. | ||
* | ||
* Allows to create and attach an agnos-ui/core widget to the current react component. | ||
* | ||
* @param createWidget - the widget factory | ||
* @param props - the props | ||
* @param propsConfig - the props config | ||
* @returns the state and api to track and interact with the widget | ||
*/ | ||
export function useWidget(createWidget, props = {}, propsConfig) { | ||
@@ -5,0 +15,0 @@ const api = useMemo(() => createWidget({ ...propsConfig, props: { ...propsConfig?.props, ...props } }), []); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29450
92
533
+ Added@agnos-ui/core@0.0.1-alpha.7(transitive)
+ Added@amadeus-it-group/tansu@1.0.0(transitive)
- Removed@agnos-ui/core@0.0.1-alpha.6(transitive)
- Removed@amadeus-it-group/tansu@0.0.24(transitive)
Updated@agnos-ui/core@0.0.1-alpha.7