@agnos-ui/react-headless 0.2.0 → 0.3.1

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.
Files changed (106) hide show
  1. package/components/accordion/accordion.d.ts +0 -10
  2. package/components/accordion/index.cjs +10 -0
  3. package/components/accordion/index.js +1 -1
  4. package/components/alert/alert.d.ts +0 -6
  5. package/components/alert/index.cjs +10 -0
  6. package/components/alert/index.js +1 -1
  7. package/components/modal/index.cjs +10 -0
  8. package/components/modal/index.js +1 -1
  9. package/components/modal/modal.d.ts +0 -6
  10. package/components/pagination/index.cjs +10 -0
  11. package/components/pagination/index.js +1 -1
  12. package/components/pagination/pagination.d.ts +0 -7
  13. package/components/progressbar/index.cjs +10 -0
  14. package/components/progressbar/index.js +1 -1
  15. package/components/progressbar/progressbar.d.ts +0 -6
  16. package/components/rating/index.cjs +10 -0
  17. package/components/rating/index.js +1 -1
  18. package/components/rating/rating.d.ts +0 -5
  19. package/components/select/index.cjs +10 -0
  20. package/components/select/index.js +1 -1
  21. package/components/select/select.d.ts +0 -7
  22. package/components/slider/index.cjs +10 -0
  23. package/components/slider/index.js +1 -1
  24. package/components/slider/slider.d.ts +0 -8
  25. package/components/toast/index.cjs +10 -0
  26. package/components/toast/index.js +1 -1
  27. package/components/toast/toast.d.ts +0 -6
  28. package/config.cjs +54 -0
  29. package/config.d.ts +2 -2
  30. package/config.js +45 -81
  31. package/directive-4SKmV5bk.cjs +47 -0
  32. package/directive-Kqp31pwt.js +48 -0
  33. package/generated/index.d.ts +4 -4
  34. package/generated/services/extendWidget.cjs +10 -0
  35. package/generated/services/extendWidget.js +1 -1
  36. package/generated/services/floatingUI.cjs +10 -0
  37. package/generated/services/floatingUI.js +1 -1
  38. package/generated/services/focustrack.cjs +10 -0
  39. package/generated/services/focustrack.js +1 -1
  40. package/generated/services/hash.cjs +10 -0
  41. package/generated/services/hash.js +1 -1
  42. package/generated/services/intersection.cjs +10 -0
  43. package/generated/services/intersection.js +1 -1
  44. package/generated/services/matchMedia.cjs +10 -0
  45. package/generated/services/matchMedia.d.ts +1 -0
  46. package/generated/services/matchMedia.js +1 -0
  47. package/generated/services/navManager.cjs +10 -0
  48. package/generated/services/navManager.js +1 -1
  49. package/generated/services/portal.cjs +10 -0
  50. package/generated/services/portal.js +1 -1
  51. package/generated/services/resizeObserver.cjs +10 -0
  52. package/generated/services/resizeObserver.js +1 -1
  53. package/generated/services/siblingsInert.cjs +10 -0
  54. package/generated/services/siblingsInert.js +1 -1
  55. package/generated/services/transitions/baseTransitions.cjs +10 -0
  56. package/generated/services/transitions/baseTransitions.js +1 -1
  57. package/generated/services/transitions/collapse.cjs +10 -0
  58. package/generated/services/transitions/collapse.js +1 -1
  59. package/generated/services/transitions/cssTransitions.cjs +10 -0
  60. package/generated/services/transitions/cssTransitions.js +1 -1
  61. package/generated/services/transitions/simpleClassTransition.cjs +10 -0
  62. package/generated/services/transitions/simpleClassTransition.js +1 -1
  63. package/generated/utils/directive.cjs +15 -0
  64. package/generated/utils/directive.js +8 -1
  65. package/generated/utils/portal.cjs +4 -0
  66. package/generated/utils/portal.js +4 -1
  67. package/generated/utils/stores.cjs +13 -0
  68. package/generated/utils/stores.js +6 -1
  69. package/generated/utils/widget.cjs +4 -0
  70. package/generated/utils/widget.js +4 -1
  71. package/generated/utils/writables.cjs +10 -0
  72. package/generated/utils/writables.js +1 -1
  73. package/index.cjs +246 -0
  74. package/index.js +50 -10
  75. package/package.json +22 -10
  76. package/portal-B0Q5KLrA.cjs +5 -0
  77. package/portal-CX8X69NK.js +6 -0
  78. package/slot.cjs +27 -0
  79. package/slot.js +21 -29
  80. package/stores-B8YEDwZq.js +27 -0
  81. package/stores-DLkDMqBY.cjs +26 -0
  82. package/types.cjs +10 -0
  83. package/types.js +1 -1
  84. package/utils/directive.d.ts +42 -5
  85. package/utils/stores.d.ts +1 -1
  86. package/widget-CqgI0B-w.cjs +18 -0
  87. package/widget-DAs9_HQ1.js +19 -0
  88. package/components/accordion/accordion.js +0 -3
  89. package/components/alert/alert.js +0 -3
  90. package/components/modal/modal.js +0 -3
  91. package/components/pagination/pagination.js +0 -3
  92. package/components/progressbar/progressbar.js +0 -3
  93. package/components/rating/rating.js +0 -3
  94. package/components/select/select.js +0 -3
  95. package/components/slider/slider.js +0 -3
  96. package/components/toast/toast.js +0 -3
  97. package/generated/config.js +0 -1
  98. package/generated/index.js +0 -22
  99. package/generated/services/transitions/bootstrap.d.ts +0 -1
  100. package/generated/services/transitions/bootstrap.js +0 -1
  101. package/generated/slot.js +0 -1
  102. package/generated/types.js +0 -1
  103. package/utils/directive.js +0 -39
  104. package/utils/portal.js +0 -11
  105. package/utils/stores.js +0 -38
  106. package/utils/widget.js +0 -26
@@ -1,11 +1 @@
1
1
  export * from '@agnos-ui/core/components/accordion';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type AccordionWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/accordion').AccordionWidget>;
4
- export type AccordionProps = WidgetProps<AccordionWidget>;
5
- export type AccordionState = WidgetState<AccordionWidget>;
6
- export type AccordionApi = AccordionWidget['api'];
7
- export type AccordionItemWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/accordion').AccordionItemWidget>;
8
- export type AccordionItemProps = WidgetProps<AccordionItemWidget>;
9
- export type AccordionItemState = WidgetState<AccordionItemWidget>;
10
- export type AccordionItemContext = AdaptSlotContentProps<import('@agnos-ui/core/components/accordion').AccordionItemContext>;
11
- export declare const createAccordion: WidgetFactory<AccordionWidget>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const accordion = require("@agnos-ui/core/components/accordion");
4
+ Object.keys(accordion).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => accordion[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './accordion';
1
+ export * from "@agnos-ui/core/components/accordion";
@@ -1,7 +1 @@
1
1
  export * from '@agnos-ui/core/components/alert';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type AlertWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/alert').AlertWidget>;
4
- export type AlertProps = WidgetProps<AlertWidget>;
5
- export type AlertState = WidgetState<AlertWidget>;
6
- export type AlertContext = AdaptSlotContentProps<import('@agnos-ui/core/components/alert').AlertContext>;
7
- export declare const createAlert: WidgetFactory<AlertWidget>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const alert = require("@agnos-ui/core/components/alert");
4
+ Object.keys(alert).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => alert[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './alert';
1
+ export * from "@agnos-ui/core/components/alert";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const modal = require("@agnos-ui/core/components/modal");
4
+ Object.keys(modal).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => modal[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './modal';
1
+ export * from "@agnos-ui/core/components/modal";
@@ -1,7 +1 @@
1
1
  export * from '@agnos-ui/core/components/modal';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, PropsConfig, WidgetProps, WidgetState } from '../../types';
3
- export type ModalWidget<Data> = AdaptWidgetSlots<import('@agnos-ui/core/components/modal').ModalWidget<Data>>;
4
- export type ModalProps<Data> = WidgetProps<ModalWidget<Data>>;
5
- export type ModalState<Data> = WidgetState<ModalWidget<Data>>;
6
- export type ModalContext<Data> = AdaptSlotContentProps<import('@agnos-ui/core/components/modal').ModalContext<Data>>;
7
- export declare const createModal: <Data>(propsConfig?: PropsConfig<ModalProps<Data>>) => ModalWidget<Data>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const pagination = require("@agnos-ui/core/components/pagination");
4
+ Object.keys(pagination).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => pagination[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './pagination';
1
+ export * from "@agnos-ui/core/components/pagination";
@@ -1,8 +1 @@
1
1
  export * from '@agnos-ui/core/components/pagination';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type PaginationWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/pagination').PaginationWidget>;
4
- export type PaginationProps = WidgetProps<PaginationWidget>;
5
- export type PaginationState = WidgetState<PaginationWidget>;
6
- export type PaginationContext = AdaptSlotContentProps<import('@agnos-ui/core/components/pagination').PaginationContext>;
7
- export type PaginationNumberContext = AdaptSlotContentProps<import('@agnos-ui/core/components/pagination').PaginationNumberContext>;
8
- export declare const createPagination: WidgetFactory<PaginationWidget>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const progressbar = require("@agnos-ui/core/components/progressbar");
4
+ Object.keys(progressbar).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => progressbar[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './progressbar';
1
+ export * from "@agnos-ui/core/components/progressbar";
@@ -1,7 +1 @@
1
1
  export * from '@agnos-ui/core/components/progressbar';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type ProgressbarWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/progressbar').ProgressbarWidget>;
4
- export type ProgressbarProps = WidgetProps<ProgressbarWidget>;
5
- export type ProgressbarState = WidgetState<ProgressbarWidget>;
6
- export type ProgressbarContext = AdaptSlotContentProps<import('@agnos-ui/core/components/progressbar').ProgressbarContext>;
7
- export declare const createProgressbar: WidgetFactory<ProgressbarWidget>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const rating = require("@agnos-ui/core/components/rating");
4
+ Object.keys(rating).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => rating[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './rating';
1
+ export * from "@agnos-ui/core/components/rating";
@@ -1,6 +1 @@
1
1
  export * from '@agnos-ui/core/components/rating';
2
- import type { AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type RatingWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/rating').RatingWidget>;
4
- export type RatingProps = WidgetProps<RatingWidget>;
5
- export type RatingState = WidgetState<RatingWidget>;
6
- export declare const createRating: WidgetFactory<RatingWidget>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const select = require("@agnos-ui/core/components/select");
4
+ Object.keys(select).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => select[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './select';
1
+ export * from "@agnos-ui/core/components/select";
@@ -1,8 +1 @@
1
1
  export * from '@agnos-ui/core/components/select';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, PropsConfig, WidgetProps, WidgetState } from '../../types';
3
- export type SelectWidget<Item> = AdaptWidgetSlots<import('@agnos-ui/core/components/select').SelectWidget<Item>>;
4
- export type SelectProps<Item> = WidgetProps<SelectWidget<Item>>;
5
- export type SelectState<Item> = WidgetState<SelectWidget<Item>>;
6
- export type SelectContext<Item> = AdaptSlotContentProps<import('@agnos-ui/core/components/select').SelectContext<Item>>;
7
- export type SelectItemContext<Item> = AdaptSlotContentProps<import('@agnos-ui/core/components/select').SelectItemContext<Item>>;
8
- export declare const createSelect: <Item>(propsConfig?: PropsConfig<SelectProps<Item>>) => SelectWidget<Item>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const slider = require("@agnos-ui/core/components/slider");
4
+ Object.keys(slider).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => slider[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './slider';
1
+ export * from "@agnos-ui/core/components/slider";
@@ -1,9 +1 @@
1
1
  export * from '@agnos-ui/core/components/slider';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type SliderWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/slider').SliderWidget>;
4
- export type SliderProps = WidgetProps<SliderWidget>;
5
- export type SliderState = WidgetState<SliderWidget>;
6
- export type SliderContext = AdaptSlotContentProps<import('@agnos-ui/core/components/slider').SliderContext>;
7
- export type SliderSlotLabelContext = AdaptSlotContentProps<import('@agnos-ui/core/components/slider').SliderSlotLabelContext>;
8
- export type SliderSlotHandleContext = AdaptSlotContentProps<import('@agnos-ui/core/components/slider').SliderSlotHandleContext>;
9
- export declare const createSlider: WidgetFactory<SliderWidget>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const toast = require("@agnos-ui/core/components/toast");
4
+ Object.keys(toast).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => toast[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from './toast';
1
+ export * from "@agnos-ui/core/components/toast";
@@ -1,7 +1 @@
1
1
  export * from '@agnos-ui/core/components/toast';
2
- import type { AdaptSlotContentProps, AdaptWidgetSlots, WidgetFactory, WidgetProps, WidgetState } from '../../types';
3
- export type ToastWidget = AdaptWidgetSlots<import('@agnos-ui/core/components/toast').ToastWidget>;
4
- export type ToastProps = WidgetProps<ToastWidget>;
5
- export type ToastState = WidgetState<ToastWidget>;
6
- export type ToastContext = AdaptSlotContentProps<import('@agnos-ui/core/components/toast').ToastContext>;
7
- export declare const createToast: WidgetFactory<ToastWidget>;
package/config.cjs ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const config = require("@agnos-ui/core/config");
5
+ const tansu = require("@amadeus-it-group/tansu");
6
+ const react = require("react");
7
+ const widget = require("./widget-CqgI0B-w.cjs");
8
+ const stores = require("./stores-DLkDMqBY.cjs");
9
+ const widgetsConfigFactory = (widgetsConfigContext2 = react.createContext(void 0)) => {
10
+ const useWidgetContext2 = (widgetName, defaultConfig) => {
11
+ const widgetsConfig = react.useContext(widgetsConfigContext2);
12
+ const defaultConfig$ = stores.usePropsAsStore(defaultConfig);
13
+ return react.useMemo(() => tansu.computed(() => ({ ...defaultConfig$(), ...widgetName ? widgetsConfig == null ? void 0 : widgetsConfig()[widgetName] : void 0 })), [widgetsConfig]);
14
+ };
15
+ const useWidgetWithConfig2 = (factory, props, widgetName, defaultProps) => widget.useWidget(factory, props, { config: useWidgetContext2(widgetName, defaultProps) });
16
+ const WidgetsDefaultConfig2 = ({ children, adaptParentConfig, ...props }) => {
17
+ const config$ = react.useContext(widgetsConfigContext2);
18
+ let storeRecreated = false;
19
+ const store$ = react.useMemo(() => {
20
+ const store = config.createWidgetsConfig(config$, adaptParentConfig);
21
+ store.set(props);
22
+ storeRecreated = true;
23
+ return store;
24
+ }, [config$, adaptParentConfig]);
25
+ react.useEffect(() => {
26
+ if (!storeRecreated) {
27
+ store$.set(props);
28
+ }
29
+ }, [props]);
30
+ return /* @__PURE__ */ jsxRuntime.jsx(widgetsConfigContext2.Provider, { value: store$, children });
31
+ };
32
+ return {
33
+ /**
34
+ * React context which can be used to provide or consume the widgets default configuration store.
35
+ */
36
+ widgetsConfigContext: widgetsConfigContext2,
37
+ useWidgetContext: useWidgetContext2,
38
+ useWidgetWithConfig: useWidgetWithConfig2,
39
+ WidgetsDefaultConfig: WidgetsDefaultConfig2
40
+ };
41
+ };
42
+ const { widgetsConfigContext, WidgetsDefaultConfig, useWidgetContext, useWidgetWithConfig } = widgetsConfigFactory();
43
+ exports.WidgetsDefaultConfig = WidgetsDefaultConfig;
44
+ exports.useWidgetContext = useWidgetContext;
45
+ exports.useWidgetWithConfig = useWidgetWithConfig;
46
+ exports.widgetsConfigContext = widgetsConfigContext;
47
+ exports.widgetsConfigFactory = widgetsConfigFactory;
48
+ Object.keys(config).forEach((k) => {
49
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
50
+ Object.defineProperty(exports, k, {
51
+ enumerable: true,
52
+ get: () => config[k]
53
+ });
54
+ });
package/config.d.ts CHANGED
@@ -25,8 +25,8 @@ export declare const widgetsConfigFactory: <Config extends {
25
25
  * React context which can be used to provide or consume the widgets default configuration store.
26
26
  */
27
27
  widgetsConfigContext: import("react").Context<WidgetsConfigStore<Config> | undefined>;
28
- useWidgetContext: <Props extends object>(widgetName: keyof Config | null, defaultConfig?: Partial<Props> | undefined) => import("@amadeus-it-group/tansu").ReadableSignal<Partial<Props>>;
29
- useWidgetWithConfig: <W extends Widget<object, object, object, object, object>>(factory: WidgetFactory<W>, props: Partial<WidgetProps<W>> | undefined, widgetName: keyof Config | null, defaultProps?: Partial<WidgetProps<W>> | undefined) => [WidgetState<W>, W];
28
+ useWidgetContext: <Props extends object>(widgetName: keyof Config | null, defaultConfig?: Partial<Props>) => import("@amadeus-it-group/tansu").ReadableSignal<Partial<Props>>;
29
+ useWidgetWithConfig: <W extends Widget<object, object, object, object, object>>(factory: WidgetFactory<W>, props: Partial<WidgetProps<W>> | undefined, widgetName: keyof Config | null, defaultProps?: Partial<WidgetProps<W>>) => [WidgetState<W>, W];
30
30
  WidgetsDefaultConfig: ({ children, adaptParentConfig, ...props }: DefaultConfigInput<Config>) => import("react/jsx-runtime").JSX.Element;
31
31
  };
32
32
  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: keyof CoreWidgetsConfig | null, defaultConfig?: Partial<Props> | undefined) => import("@amadeus-it-group/tansu").ReadableSignal<Partial<Props>>, useWidgetWithConfig: <W extends Widget<object, object, object, object, object>>(factory: WidgetFactory<W>, props: Partial<WidgetProps<W>> | undefined, widgetName: keyof CoreWidgetsConfig | null, defaultProps?: Partial<WidgetProps<W>> | undefined) => [WidgetState<W>, W];
package/config.js CHANGED
@@ -1,84 +1,48 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createWidgetsConfig } from '@agnos-ui/core/config';
3
- import { computed } from '@amadeus-it-group/tansu';
4
- import { createContext, useContext, useEffect, useMemo } from 'react';
5
- import { useWidget } from './utils/widget';
6
- import { usePropsAsStore } from './utils/stores';
7
- export * from '@agnos-ui/core/config';
8
- /**
9
- * A factory to create the use functions and react component to allow widgets to be context-aware.
10
- *
11
- * It can be used when extending the core and creating new widgets.
12
- *
13
- * @param widgetsConfigContext - the widgets config context
14
- * @returns the use functions and react component
15
- */
16
- export const widgetsConfigFactory = (widgetsConfigContext = createContext(undefined)) => {
17
- const useWidgetContext = (widgetName, defaultConfig) => {
18
- const widgetsConfig = useContext(widgetsConfigContext);
19
- const defaultConfig$ = usePropsAsStore(defaultConfig);
20
- return useMemo(() => computed(() => ({ ...defaultConfig$(), ...(widgetName ? widgetsConfig?.()[widgetName] : undefined) })), [widgetsConfig]);
21
- };
22
- const useWidgetWithConfig = (factory, props, widgetName, defaultProps) => useWidget(factory, props, { config: useWidgetContext(widgetName, defaultProps) });
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createWidgetsConfig } from "@agnos-ui/core/config";
3
+ export * from "@agnos-ui/core/config";
4
+ import { computed } from "@amadeus-it-group/tansu";
5
+ import { createContext, useContext, useMemo, useEffect } from "react";
6
+ import { u as useWidget } from "./widget-DAs9_HQ1.js";
7
+ import { a as usePropsAsStore } from "./stores-B8YEDwZq.js";
8
+ const widgetsConfigFactory = (widgetsConfigContext2 = createContext(void 0)) => {
9
+ const useWidgetContext2 = (widgetName, defaultConfig) => {
10
+ const widgetsConfig = useContext(widgetsConfigContext2);
11
+ const defaultConfig$ = usePropsAsStore(defaultConfig);
12
+ return useMemo(() => computed(() => ({ ...defaultConfig$(), ...widgetName ? widgetsConfig == null ? void 0 : widgetsConfig()[widgetName] : void 0 })), [widgetsConfig]);
13
+ };
14
+ const useWidgetWithConfig2 = (factory, props, widgetName, defaultProps) => useWidget(factory, props, { config: useWidgetContext2(widgetName, defaultProps) });
15
+ const WidgetsDefaultConfig2 = ({ children, adaptParentConfig, ...props }) => {
16
+ const config$ = useContext(widgetsConfigContext2);
17
+ let storeRecreated = false;
18
+ const store$ = useMemo(() => {
19
+ const store = createWidgetsConfig(config$, adaptParentConfig);
20
+ store.set(props);
21
+ storeRecreated = true;
22
+ return store;
23
+ }, [config$, adaptParentConfig]);
24
+ useEffect(() => {
25
+ if (!storeRecreated) {
26
+ store$.set(props);
27
+ }
28
+ }, [props]);
29
+ return /* @__PURE__ */ jsx(widgetsConfigContext2.Provider, { value: store$, children });
30
+ };
31
+ return {
23
32
  /**
24
- * React component that provides in the React context (for all AgnosUI descendant widgets) a new widgets default configuration
25
- * store that inherits from any widgets default configuration store already defined at an upper level in the React context hierarchy.
26
- * It contains its own set of widgets configuration properties that override the same properties form the parent configuration.
27
- *
28
- * @remarks
29
- * The configuration is computed from the parent configuration in two steps:
30
- * - first step: the parent configuration is transformed by the adaptParentConfig function (if specified).
31
- * If adaptParentConfig is not specified, this step is skipped.
32
- * - second step: the configuration from step 1 is merged (2-levels deep) with the properties of the component.
33
- *
34
- * @param componentInputs - the react component inputs
35
- * @param componentInputs.children - the react component children
36
- * @param componentInputs.adaptParentConfig - optional function that receives a 2-levels copy of the widgets default configuration
37
- * defined at an upper level in the Svelte context hierarchy (or an empty object if there is none) and returns the widgets
38
- * default configuration to be used.
39
- * It is called only if the configuration is needed, and was not yet computed for the current value of the parent configuration.
40
- * It is called in a tansu reactive context, so it can use any tansu store and will be called again if those stores change.
41
- *
42
- * @returns the resulting widgets default configuration store, which contains 3 additional properties that are stores:
43
- * parent$, adaptedParent$ (containing the value computed after the first step), and own$ (that contains only overridding properties).
44
- * The resulting store is writable, its set function is actually the set function of the own$ store.
45
- *
46
- * @example
47
- * ```tsx
48
- * <WidgetsDefaultConfig
49
- * adaptParentConfig={(parentConfig) => {
50
- * parentConfig.rating = parentConfig.rating ?? {};
51
- * parentConfig.rating.className = `${parentConfig.rating.className ?? ''} my-rating-extra-class`
52
- * return parentConfig;
53
- * }}
54
- * rating={{slotStar: MyCustomSlotStar}}
55
- * />
56
- * ```
33
+ * React context which can be used to provide or consume the widgets default configuration store.
57
34
  */
58
- const WidgetsDefaultConfig = ({ children, adaptParentConfig, ...props }) => {
59
- const config$ = useContext(widgetsConfigContext);
60
- let storeRecreated = false;
61
- const store$ = useMemo(() => {
62
- const store = createWidgetsConfig(config$, adaptParentConfig);
63
- store.set(props);
64
- storeRecreated = true;
65
- return store;
66
- }, [config$, adaptParentConfig]);
67
- useEffect(() => {
68
- if (!storeRecreated) {
69
- store$.set(props);
70
- }
71
- }, [props]);
72
- return _jsx(widgetsConfigContext.Provider, { value: store$, children: children });
73
- };
74
- return {
75
- /**
76
- * React context which can be used to provide or consume the widgets default configuration store.
77
- */
78
- widgetsConfigContext,
79
- useWidgetContext,
80
- useWidgetWithConfig,
81
- WidgetsDefaultConfig,
82
- };
35
+ widgetsConfigContext: widgetsConfigContext2,
36
+ useWidgetContext: useWidgetContext2,
37
+ useWidgetWithConfig: useWidgetWithConfig2,
38
+ WidgetsDefaultConfig: WidgetsDefaultConfig2
39
+ };
40
+ };
41
+ const { widgetsConfigContext, WidgetsDefaultConfig, useWidgetContext, useWidgetWithConfig } = widgetsConfigFactory();
42
+ export {
43
+ WidgetsDefaultConfig,
44
+ useWidgetContext,
45
+ useWidgetWithConfig,
46
+ widgetsConfigContext,
47
+ widgetsConfigFactory
83
48
  };
84
- export const { widgetsConfigContext, WidgetsDefaultConfig, useWidgetContext, useWidgetWithConfig } = widgetsConfigFactory();
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ const directive = require("@agnos-ui/core/utils/directive");
3
+ const esmEnv = require("esm-env");
4
+ const react = require("react");
5
+ const attributesMap = /* @__PURE__ */ new Map([
6
+ ["tabindex", "tabIndex"],
7
+ ["for", "htmlFor"]
8
+ ]);
9
+ function directiveAttributes(...directives) {
10
+ const reactAttributes = {};
11
+ const { attributes, style, classNames } = directive.attributesData(...directives);
12
+ for (const [name, value] of Object.entries(attributes)) {
13
+ reactAttributes[attributesMap.get(name) ?? name] = value;
14
+ }
15
+ if (classNames == null ? void 0 : classNames.length) {
16
+ reactAttributes.className = classNames.join(" ");
17
+ }
18
+ if (Object.keys(style).length) {
19
+ reactAttributes.style = style;
20
+ }
21
+ return reactAttributes;
22
+ }
23
+ const ssrAttributes = esmEnv.BROWSER ? () => ({}) : directiveAttributes;
24
+ const useDirective = esmEnv.BROWSER ? (directive2, args) => {
25
+ var _a, _b;
26
+ const instance = react.useRef();
27
+ const propsRef = react.useRef();
28
+ const ref = react.useCallback(
29
+ (element) => {
30
+ var _a2, _b2;
31
+ (_b2 = (_a2 = instance.current) == null ? void 0 : _a2.destroy) == null ? void 0 : _b2.call(_a2);
32
+ instance.current = void 0;
33
+ if (element) {
34
+ instance.current = directive2(element, propsRef.current);
35
+ }
36
+ },
37
+ [directive2]
38
+ );
39
+ propsRef.current = args;
40
+ (_b = (_a = instance.current) == null ? void 0 : _a.update) == null ? void 0 : _b.call(_a, args);
41
+ return { ref };
42
+ } : (directive2, args) => ssrAttributes([directive2, args]);
43
+ const useDirectives = esmEnv.BROWSER ? (...directives) => useDirective(directive.multiDirective, directives) : directiveAttributes;
44
+ exports.directiveAttributes = directiveAttributes;
45
+ exports.ssrAttributes = ssrAttributes;
46
+ exports.useDirective = useDirective;
47
+ exports.useDirectives = useDirectives;
@@ -0,0 +1,48 @@
1
+ import { attributesData, multiDirective } from "@agnos-ui/core/utils/directive";
2
+ import { BROWSER } from "esm-env";
3
+ import { useRef, useCallback } from "react";
4
+ const attributesMap = /* @__PURE__ */ new Map([
5
+ ["tabindex", "tabIndex"],
6
+ ["for", "htmlFor"]
7
+ ]);
8
+ function directiveAttributes(...directives) {
9
+ const reactAttributes = {};
10
+ const { attributes, style, classNames } = attributesData(...directives);
11
+ for (const [name, value] of Object.entries(attributes)) {
12
+ reactAttributes[attributesMap.get(name) ?? name] = value;
13
+ }
14
+ if (classNames == null ? void 0 : classNames.length) {
15
+ reactAttributes.className = classNames.join(" ");
16
+ }
17
+ if (Object.keys(style).length) {
18
+ reactAttributes.style = style;
19
+ }
20
+ return reactAttributes;
21
+ }
22
+ const ssrAttributes = BROWSER ? () => ({}) : directiveAttributes;
23
+ const useDirective = BROWSER ? (directive, args) => {
24
+ var _a, _b;
25
+ const instance = useRef();
26
+ const propsRef = useRef();
27
+ const ref = useCallback(
28
+ (element) => {
29
+ var _a2, _b2;
30
+ (_b2 = (_a2 = instance.current) == null ? void 0 : _a2.destroy) == null ? void 0 : _b2.call(_a2);
31
+ instance.current = void 0;
32
+ if (element) {
33
+ instance.current = directive(element, propsRef.current);
34
+ }
35
+ },
36
+ [directive]
37
+ );
38
+ propsRef.current = args;
39
+ (_b = (_a = instance.current) == null ? void 0 : _a.update) == null ? void 0 : _b.call(_a, args);
40
+ return { ref };
41
+ } : (directive, args) => ssrAttributes([directive, args]);
42
+ const useDirectives = BROWSER ? (...directives) => useDirective(multiDirective, directives) : directiveAttributes;
43
+ export {
44
+ useDirectives as a,
45
+ directiveAttributes as d,
46
+ ssrAttributes as s,
47
+ useDirective as u
48
+ };
@@ -2,19 +2,19 @@ export * from './services/siblingsInert';
2
2
  export * from './services/resizeObserver';
3
3
  export * from './services/portal';
4
4
  export * from './services/navManager';
5
+ export * from './services/matchMedia';
5
6
  export * from './services/intersection';
6
7
  export * from './services/hash';
7
8
  export * from './services/focustrack';
8
9
  export * from './services/floatingUI';
9
10
  export * from './services/extendWidget';
11
+ export * from './utils/writables';
12
+ export * from './utils/stores';
13
+ export * from './utils/directive';
10
14
  export * from './services/transitions/simpleClassTransition';
11
15
  export * from './services/transitions/cssTransitions';
12
16
  export * from './services/transitions/collapse';
13
- export * from './services/transitions/bootstrap';
14
17
  export * from './services/transitions/baseTransitions';
15
- export * from './utils/writables';
16
- export * from './utils/stores';
17
- export * from './utils/directive';
18
18
  export * from './types';
19
19
  export * from './config';
20
20
  export * from './utils/widget';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const extendWidget = require("@agnos-ui/core/services/extendWidget");
4
+ Object.keys(extendWidget).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => extendWidget[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from '@agnos-ui/core/services/extendWidget';
1
+ export * from "@agnos-ui/core/services/extendWidget";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const floatingUI = require("@agnos-ui/core/services/floatingUI");
4
+ Object.keys(floatingUI).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => floatingUI[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from '@agnos-ui/core/services/floatingUI';
1
+ export * from "@agnos-ui/core/services/floatingUI";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const focustrack = require("@agnos-ui/core/services/focustrack");
4
+ Object.keys(focustrack).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => focustrack[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from '@agnos-ui/core/services/focustrack';
1
+ export * from "@agnos-ui/core/services/focustrack";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const hash = require("@agnos-ui/core/services/hash");
4
+ Object.keys(hash).forEach((k) => {
5
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
6
+ Object.defineProperty(exports, k, {
7
+ enumerable: true,
8
+ get: () => hash[k]
9
+ });
10
+ });
@@ -1 +1 @@
1
- export * from '@agnos-ui/core/services/hash';
1
+ export * from "@agnos-ui/core/services/hash";