@design-factory/angular 21.0.4 → 21.1.0-next.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/drawer/README.md +54 -0
- package/fesm2022/design-factory-angular-drawer.mjs +202 -67
- package/fesm2022/design-factory-angular-drawer.mjs.map +1 -1
- package/fesm2022/design-factory-angular-internals.mjs +439 -17
- package/fesm2022/design-factory-angular-internals.mjs.map +1 -1
- package/fesm2022/design-factory-angular-sidenav.mjs +223 -210
- package/fesm2022/design-factory-angular-sidenav.mjs.map +1 -1
- package/fesm2022/design-factory-angular-theme.mjs +198 -0
- package/fesm2022/design-factory-angular-theme.mjs.map +1 -0
- package/fesm2022/design-factory-angular-topnav.mjs +1538 -0
- package/fesm2022/design-factory-angular-topnav.mjs.map +1 -0
- package/node_modules/@agnos-ui/core/README.md +5 -0
- package/node_modules/@agnos-ui/core/accordion-BC_9xn23.cjs +314 -0
- package/node_modules/@agnos-ui/core/accordion-Ca_0T8Bc.js +315 -0
- package/node_modules/@agnos-ui/core/alert-AhaliJ17.cjs +9 -0
- package/node_modules/@agnos-ui/core/alert-Cb9FhbFQ.js +10 -0
- package/node_modules/@agnos-ui/core/collapse-COriZO7o.cjs +94 -0
- package/node_modules/@agnos-ui/core/collapse-CP79atna.js +95 -0
- package/node_modules/@agnos-ui/core/common-B5jS-Ih_.cjs +73 -0
- package/node_modules/@agnos-ui/core/common-DFyZvkII.js +74 -0
- package/node_modules/@agnos-ui/core/components/accordion/accordion.d.ts +333 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.cjs +7 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/accordion/index.js +7 -0
- package/node_modules/@agnos-ui/core/components/alert/alert.d.ts +37 -0
- package/node_modules/@agnos-ui/core/components/alert/common.d.ts +138 -0
- package/node_modules/@agnos-ui/core/components/alert/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/alert/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/alert/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/carousel/carousel.d.ts +247 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.cjs +292 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/carousel/index.js +292 -0
- package/node_modules/@agnos-ui/core/components/collapse/collapse.d.ts +135 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/collapse/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/commonProps.d.ts +11 -0
- package/node_modules/@agnos-ui/core/components/drawer/drawer.d.ts +279 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/drawer/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/modal/index.cjs +8 -0
- package/node_modules/@agnos-ui/core/components/modal/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/modal/index.js +8 -0
- package/node_modules/@agnos-ui/core/components/modal/modal.d.ts +245 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/pagination/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/pagination/pagination.d.ts +313 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/progressbar/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/progressbar/progressbar.d.ts +91 -0
- package/node_modules/@agnos-ui/core/components/rating/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/rating/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/rating/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/rating/rating.d.ts +191 -0
- package/node_modules/@agnos-ui/core/components/slider/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/slider/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/slider/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/slider/slider-utils.d.ts +25 -0
- package/node_modules/@agnos-ui/core/components/slider/slider.d.ts +383 -0
- package/node_modules/@agnos-ui/core/components/toast/index.cjs +7 -0
- package/node_modules/@agnos-ui/core/components/toast/index.d.ts +2 -0
- package/node_modules/@agnos-ui/core/components/toast/index.js +7 -0
- package/node_modules/@agnos-ui/core/components/toast/toast.d.ts +66 -0
- package/node_modules/@agnos-ui/core/components/toast/toaster.d.ts +128 -0
- package/node_modules/@agnos-ui/core/components/tree/index.cjs +5 -0
- package/node_modules/@agnos-ui/core/components/tree/index.d.ts +1 -0
- package/node_modules/@agnos-ui/core/components/tree/index.js +5 -0
- package/node_modules/@agnos-ui/core/components/tree/tree.d.ts +143 -0
- package/node_modules/@agnos-ui/core/config.cjs +36 -0
- package/node_modules/@agnos-ui/core/config.d.ts +117 -0
- package/node_modules/@agnos-ui/core/config.js +36 -0
- package/node_modules/@agnos-ui/core/directive-Bsreu2z1.js +523 -0
- package/node_modules/@agnos-ui/core/directive-DCaXmRe_.cjs +522 -0
- package/node_modules/@agnos-ui/core/drawer-BbFAHV07.cjs +328 -0
- package/node_modules/@agnos-ui/core/drawer-C6Qa0xEu.js +329 -0
- package/node_modules/@agnos-ui/core/index.cjs +134 -0
- package/node_modules/@agnos-ui/core/index.d.ts +29 -0
- package/node_modules/@agnos-ui/core/index.js +134 -0
- package/node_modules/@agnos-ui/core/isFocusable-Ckwus82R.js +32 -0
- package/node_modules/@agnos-ui/core/isFocusable-DfzDLeAN.cjs +31 -0
- package/node_modules/@agnos-ui/core/modal-BsNuHhT7.cjs +252 -0
- package/node_modules/@agnos-ui/core/modal-CgzY8ezz.js +253 -0
- package/node_modules/@agnos-ui/core/package.json +57 -0
- package/node_modules/@agnos-ui/core/pagination-ZxGaNWZz.js +255 -0
- package/node_modules/@agnos-ui/core/pagination-xbcOHnhd.cjs +254 -0
- package/node_modules/@agnos-ui/core/progressbar-CRbMKp4b.cjs +86 -0
- package/node_modules/@agnos-ui/core/progressbar-CSEIFnlD.js +87 -0
- package/node_modules/@agnos-ui/core/promise-CxCD3NYv.cjs +118 -0
- package/node_modules/@agnos-ui/core/promise-D-RZVPuv.js +119 -0
- package/node_modules/@agnos-ui/core/rating-BIdiiPUo.js +184 -0
- package/node_modules/@agnos-ui/core/rating-qx1xaBmz.cjs +183 -0
- package/node_modules/@agnos-ui/core/scrollbars-CT87iv_6.cjs +30 -0
- package/node_modules/@agnos-ui/core/scrollbars-CcxSrnCx.js +31 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.cjs +41 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.d.ts +31 -0
- package/node_modules/@agnos-ui/core/services/extendWidget.js +41 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.cjs +111 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.d.ts +76 -0
- package/node_modules/@agnos-ui/core/services/floatingUI.js +111 -0
- package/node_modules/@agnos-ui/core/services/focusElement.cjs +46 -0
- package/node_modules/@agnos-ui/core/services/focusElement.d.ts +9 -0
- package/node_modules/@agnos-ui/core/services/focusElement.js +46 -0
- package/node_modules/@agnos-ui/core/services/focustrack.cjs +47 -0
- package/node_modules/@agnos-ui/core/services/focustrack.d.ts +40 -0
- package/node_modules/@agnos-ui/core/services/focustrack.js +47 -0
- package/node_modules/@agnos-ui/core/services/hash.cjs +15 -0
- package/node_modules/@agnos-ui/core/services/hash.d.ts +3 -0
- package/node_modules/@agnos-ui/core/services/hash.js +15 -0
- package/node_modules/@agnos-ui/core/services/intersection.cjs +53 -0
- package/node_modules/@agnos-ui/core/services/intersection.d.ts +30 -0
- package/node_modules/@agnos-ui/core/services/intersection.js +53 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.cjs +14 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.d.ts +8 -0
- package/node_modules/@agnos-ui/core/services/matchMedia.js +14 -0
- package/node_modules/@agnos-ui/core/services/navManager.cjs +166 -0
- package/node_modules/@agnos-ui/core/services/navManager.d.ts +144 -0
- package/node_modules/@agnos-ui/core/services/navManager.js +166 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.cjs +60 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.d.ts +42 -0
- package/node_modules/@agnos-ui/core/services/pointerdownPosition.js +60 -0
- package/node_modules/@agnos-ui/core/services/portal.cjs +42 -0
- package/node_modules/@agnos-ui/core/services/portal.d.ts +16 -0
- package/node_modules/@agnos-ui/core/services/portal.js +42 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.cjs +54 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.d.ts +18 -0
- package/node_modules/@agnos-ui/core/services/resizeObserver.js +54 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.cjs +44 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.d.ts +16 -0
- package/node_modules/@agnos-ui/core/services/siblingsInert.js +44 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.cjs +186 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.d.ts +166 -0
- package/node_modules/@agnos-ui/core/services/transitions/baseTransitions.js +186 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.cjs +40 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.d.ts +49 -0
- package/node_modules/@agnos-ui/core/services/transitions/collapse.js +40 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.cjs +32 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.d.ts +25 -0
- package/node_modules/@agnos-ui/core/services/transitions/cssTransitions.js +32 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.cjs +37 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.d.ts +47 -0
- package/node_modules/@agnos-ui/core/services/transitions/simpleClassTransition.js +37 -0
- package/node_modules/@agnos-ui/core/slider-B93hE0ag.cjs +807 -0
- package/node_modules/@agnos-ui/core/slider-Cjiq9FgI.js +808 -0
- package/node_modules/@agnos-ui/core/textDirection-cNgt24LJ.js +4 -0
- package/node_modules/@agnos-ui/core/textDirection-zqcZ5-eK.cjs +3 -0
- package/node_modules/@agnos-ui/core/toaster-BQWqxYv-.cjs +190 -0
- package/node_modules/@agnos-ui/core/toaster-BzEkshT2.js +191 -0
- package/node_modules/@agnos-ui/core/tree-DY04XPPg.cjs +228 -0
- package/node_modules/@agnos-ui/core/tree-HwcvZ0_p.js +229 -0
- package/node_modules/@agnos-ui/core/types.cjs +6 -0
- package/node_modules/@agnos-ui/core/types.d.ts +246 -0
- package/node_modules/@agnos-ui/core/types.js +6 -0
- package/node_modules/@agnos-ui/core/utils/directive.cjs +28 -0
- package/node_modules/@agnos-ui/core/utils/directive.d.ts +352 -0
- package/node_modules/@agnos-ui/core/utils/directive.js +28 -0
- package/node_modules/@agnos-ui/core/utils/func.cjs +7 -0
- package/node_modules/@agnos-ui/core/utils/func.d.ts +11 -0
- package/node_modules/@agnos-ui/core/utils/func.js +7 -0
- package/node_modules/@agnos-ui/core/utils/id.cjs +5 -0
- package/node_modules/@agnos-ui/core/utils/id.d.ts +6 -0
- package/node_modules/@agnos-ui/core/utils/id.js +5 -0
- package/node_modules/@agnos-ui/core/utils/internal/assign.d.ts +10 -0
- package/node_modules/@agnos-ui/core/utils/internal/checks.d.ts +57 -0
- package/node_modules/@agnos-ui/core/utils/internal/dom.d.ts +75 -0
- package/node_modules/@agnos-ui/core/utils/internal/isFocusable.d.ts +9 -0
- package/node_modules/@agnos-ui/core/utils/internal/math.d.ts +5 -0
- package/node_modules/@agnos-ui/core/utils/internal/promise.d.ts +98 -0
- package/node_modules/@agnos-ui/core/utils/internal/scrollbars.d.ts +8 -0
- package/node_modules/@agnos-ui/core/utils/internal/sort.d.ts +16 -0
- package/node_modules/@agnos-ui/core/utils/internal/ssrHTMLElement.d.ts +17 -0
- package/node_modules/@agnos-ui/core/utils/internal/textDirection.d.ts +7 -0
- package/node_modules/@agnos-ui/core/utils/internal/traversal.d.ts +54 -0
- package/node_modules/@agnos-ui/core/utils/stores.cjs +172 -0
- package/node_modules/@agnos-ui/core/utils/stores.d.ts +224 -0
- package/node_modules/@agnos-ui/core/utils/stores.js +172 -0
- package/node_modules/@agnos-ui/core/utils/widget.cjs +8 -0
- package/node_modules/@agnos-ui/core/utils/widget.d.ts +11 -0
- package/node_modules/@agnos-ui/core/utils/widget.js +8 -0
- package/node_modules/@agnos-ui/core/utils/writables.cjs +16 -0
- package/node_modules/@agnos-ui/core/utils/writables.d.ts +95 -0
- package/node_modules/@agnos-ui/core/utils/writables.js +16 -0
- package/node_modules/@agnos-ui/core/writables-DYGjj5T3.js +103 -0
- package/node_modules/@agnos-ui/core/writables-Dt68gADJ.cjs +102 -0
- package/package.json +25 -6
- package/schematics/collection.json +1 -1
- package/types/design-factory-angular-drawer.d.ts +71 -13
- package/types/design-factory-angular-internals.d.ts +220 -31
- package/types/design-factory-angular-sidenav.d.ts +15 -7
- package/types/design-factory-angular-theme.d.ts +122 -0
- package/types/design-factory-angular-topnav.d.ts +435 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ArrowOptions, AutoUpdateOptions, ComputePositionConfig, Derivable, MiddlewareData, Placement, Strategy } from '@floating-ui/dom';
|
|
2
|
+
import type { Directive, PropsConfig, SSRHTMLElement, Widget } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the properties for configuring Floating UI.
|
|
5
|
+
*/
|
|
6
|
+
export interface FloatingUIProps {
|
|
7
|
+
/**
|
|
8
|
+
* Options to use when calling computePosition from Floating UI
|
|
9
|
+
*/
|
|
10
|
+
computePositionOptions: ComputePositionConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Options to use when calling autoUpdate from Floating UI
|
|
13
|
+
*/
|
|
14
|
+
autoUpdateOptions: AutoUpdateOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Options to use when calling the arrow middleware from Floating UI
|
|
17
|
+
*/
|
|
18
|
+
arrowOptions: Omit<ArrowOptions, 'element'> | Derivable<Omit<ArrowOptions, 'element'>>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents the state of a floating UI element.
|
|
22
|
+
*/
|
|
23
|
+
export interface FloatingUIState {
|
|
24
|
+
/**
|
|
25
|
+
* The x coordinate of the floating ui
|
|
26
|
+
*/
|
|
27
|
+
x: number | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The y coordinate of the floating ui
|
|
30
|
+
*/
|
|
31
|
+
y: number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The strategy used to position the floating element
|
|
34
|
+
*/
|
|
35
|
+
strategy: Strategy | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The final chosen placement of the floating element
|
|
38
|
+
*/
|
|
39
|
+
placement: Placement | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Object containing data returned from all middleware, keyed by their name
|
|
42
|
+
*/
|
|
43
|
+
middlewareData: MiddlewareData | undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Interface representing the directives used to enable floating ui.
|
|
47
|
+
*/
|
|
48
|
+
export interface FloatingUIDirectives {
|
|
49
|
+
/**
|
|
50
|
+
* Directive to attach to the reference element
|
|
51
|
+
*/
|
|
52
|
+
referenceDirective: Directive<void, SSRHTMLElement>;
|
|
53
|
+
/**
|
|
54
|
+
* Directive to attach to the floating element
|
|
55
|
+
*/
|
|
56
|
+
floatingDirective: Directive<void, SSRHTMLElement>;
|
|
57
|
+
/**
|
|
58
|
+
* Directive to attach to the arrow element
|
|
59
|
+
*/
|
|
60
|
+
arrowDirective: Directive<void, SSRHTMLElement>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Represents the type returned by the `createFloatingUI` function.
|
|
64
|
+
*
|
|
65
|
+
* This type is used to define the structure and behavior of the Floating UI component.
|
|
66
|
+
*/
|
|
67
|
+
export type FloatingUI = Widget<FloatingUIProps, FloatingUIState, object, FloatingUIDirectives>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a floating UI service.
|
|
70
|
+
*
|
|
71
|
+
* The returned service includes the patch method to patch the states, the stores to track the states and directives to apply.
|
|
72
|
+
*
|
|
73
|
+
* @param propsConfig - the props config for the floating UI service
|
|
74
|
+
* @returns the floating UI service
|
|
75
|
+
*/
|
|
76
|
+
export declare const createFloatingUI: (propsConfig?: PropsConfig<FloatingUIProps>) => FloatingUI;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { computed, derived } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { arrow, autoUpdate, computePosition } from "@floating-ui/dom";
|
|
3
|
+
import { i as createBrowserStoreDirective, s as mergeDirectives, o as directiveSubscribe } from "../directive-Bsreu2z1.js";
|
|
4
|
+
import { a as promiseStoreToValueStore } from "../promise-D-RZVPuv.js";
|
|
5
|
+
import { writablesForProps, stateStores } from "../utils/stores.js";
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
computePositionOptions: {},
|
|
8
|
+
autoUpdateOptions: {},
|
|
9
|
+
arrowOptions: {}
|
|
10
|
+
};
|
|
11
|
+
const createFloatingUI = (propsConfig) => {
|
|
12
|
+
const [
|
|
13
|
+
{ autoUpdateOptions$, computePositionOptions$: computePositionInputOptions$, arrowOptions$: arrowInputOptions$ },
|
|
14
|
+
patch
|
|
15
|
+
] = writablesForProps(defaultConfig, propsConfig);
|
|
16
|
+
const { directive: floatingDirective, element$: floatingElement$ } = createBrowserStoreDirective();
|
|
17
|
+
const { directive: referenceDirective, element$: referenceElement$ } = createBrowserStoreDirective();
|
|
18
|
+
const { directive: arrowDirective, element$: arrowElement$ } = createBrowserStoreDirective();
|
|
19
|
+
const arrowOptions$ = computed(() => {
|
|
20
|
+
const arrowElement = arrowElement$();
|
|
21
|
+
if (!arrowElement) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const arrowInputOptions = arrowInputOptions$();
|
|
25
|
+
return typeof arrowInputOptions === "function" ? (state) => ({ ...arrowInputOptions(state), element: arrowElement }) : { ...arrowInputOptions, element: arrowElement };
|
|
26
|
+
});
|
|
27
|
+
const computePositionOptions$ = computed(() => {
|
|
28
|
+
let options = computePositionInputOptions$();
|
|
29
|
+
const arrowOptions = arrowOptions$();
|
|
30
|
+
if (arrowOptions) {
|
|
31
|
+
options = {
|
|
32
|
+
...options,
|
|
33
|
+
middleware: [...options.middleware ?? [], arrow(arrowOptions)]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return options;
|
|
37
|
+
});
|
|
38
|
+
const promisePosition$ = derived(
|
|
39
|
+
[floatingElement$, referenceElement$, computePositionOptions$, autoUpdateOptions$],
|
|
40
|
+
([floatingElement, referenceElement, computePositionOptions, autoUpdateOptions], set) => {
|
|
41
|
+
if (floatingElement && referenceElement) {
|
|
42
|
+
const clean = autoUpdate(
|
|
43
|
+
referenceElement,
|
|
44
|
+
floatingElement,
|
|
45
|
+
() => {
|
|
46
|
+
set(computePosition(referenceElement, floatingElement, computePositionOptions));
|
|
47
|
+
},
|
|
48
|
+
autoUpdateOptions
|
|
49
|
+
);
|
|
50
|
+
return () => {
|
|
51
|
+
set(null);
|
|
52
|
+
clean();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
},
|
|
57
|
+
null
|
|
58
|
+
);
|
|
59
|
+
const position$ = promiseStoreToValueStore(promisePosition$, null);
|
|
60
|
+
const placement$ = computed(() => position$()?.placement);
|
|
61
|
+
const middlewareData$ = computed(() => position$()?.middlewareData);
|
|
62
|
+
const x$ = computed(() => position$()?.x);
|
|
63
|
+
const y$ = computed(() => position$()?.y);
|
|
64
|
+
const strategy$ = computed(() => position$()?.strategy);
|
|
65
|
+
const arrowX$ = computed(() => middlewareData$()?.arrow?.x);
|
|
66
|
+
const arrowY$ = computed(() => middlewareData$()?.arrow?.y);
|
|
67
|
+
const floatingStyleApplyAction$ = computed(() => {
|
|
68
|
+
const floatingElement = floatingElement$();
|
|
69
|
+
if (floatingElement) {
|
|
70
|
+
floatingElement.style.left = `${x$() ?? 0}px`;
|
|
71
|
+
floatingElement.style.top = `${y$() ?? 0}px`;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const arrowStyleApplyAction$ = computed(() => {
|
|
75
|
+
const arrowElement = arrowElement$();
|
|
76
|
+
if (arrowElement) {
|
|
77
|
+
const arrowX = arrowX$();
|
|
78
|
+
const arrowY = arrowY$();
|
|
79
|
+
arrowElement.style.left = arrowX != null ? `${arrowX}px` : "";
|
|
80
|
+
arrowElement.style.top = arrowY != null ? `${arrowY}px` : "";
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
patch,
|
|
85
|
+
...stateStores({
|
|
86
|
+
x$,
|
|
87
|
+
y$,
|
|
88
|
+
strategy$,
|
|
89
|
+
placement$,
|
|
90
|
+
middlewareData$
|
|
91
|
+
}),
|
|
92
|
+
directives: {
|
|
93
|
+
/**
|
|
94
|
+
* Directive to be used on the reference element from where the floating element will be positioned
|
|
95
|
+
*/
|
|
96
|
+
referenceDirective,
|
|
97
|
+
/**
|
|
98
|
+
* Directive to be used on the floating element
|
|
99
|
+
*/
|
|
100
|
+
floatingDirective: mergeDirectives(floatingDirective, directiveSubscribe(floatingStyleApplyAction$)),
|
|
101
|
+
/**
|
|
102
|
+
* Directive to be used on the arrow element, if any
|
|
103
|
+
*/
|
|
104
|
+
arrowDirective: mergeDirectives(arrowDirective, directiveSubscribe(arrowStyleApplyAction$))
|
|
105
|
+
},
|
|
106
|
+
api: {}
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
export {
|
|
110
|
+
createFloatingUI
|
|
111
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utils_directive = require("../directive-DCaXmRe_.cjs");
|
|
4
|
+
const isFocusable = require("../isFocusable-DfzDLeAN.cjs");
|
|
5
|
+
const stack = [];
|
|
6
|
+
let stackProcessPlanned = false;
|
|
7
|
+
const processStack = () => {
|
|
8
|
+
stackProcessPlanned = false;
|
|
9
|
+
const candidates = [];
|
|
10
|
+
while (stack.length > 0) {
|
|
11
|
+
const top = stack[stack.length - 1];
|
|
12
|
+
if (top.element) {
|
|
13
|
+
candidates.push(top.element);
|
|
14
|
+
break;
|
|
15
|
+
} else {
|
|
16
|
+
if (top.previousElement) {
|
|
17
|
+
candidates.push(top.previousElement);
|
|
18
|
+
}
|
|
19
|
+
stack.pop();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (const candidate of candidates) {
|
|
23
|
+
if (isFocusable.isFocusable(candidate)) {
|
|
24
|
+
candidate.focus();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const planProcessStack = () => {
|
|
30
|
+
if (!stackProcessPlanned) {
|
|
31
|
+
stackProcessPlanned = true;
|
|
32
|
+
setTimeout(processStack, 0);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const focusElement = utils_directive.browserDirective((element) => {
|
|
36
|
+
const stackEntry = { element, previousElement: document.activeElement };
|
|
37
|
+
stack.push(stackEntry);
|
|
38
|
+
planProcessStack();
|
|
39
|
+
return {
|
|
40
|
+
destroy() {
|
|
41
|
+
stackEntry.element = null;
|
|
42
|
+
planProcessStack();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
exports.focusElement = focusElement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Directive } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Directive to focus an element and manage focus stack.
|
|
4
|
+
* When the element is destroyed, focus returns to the previous focusable element in the stack.
|
|
5
|
+
*
|
|
6
|
+
* @param element - The HTML element to focus.
|
|
7
|
+
* @returns An object with a destroy method to remove the element from the focus stack.
|
|
8
|
+
*/
|
|
9
|
+
export declare const focusElement: Directive;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { d as browserDirective } from "../directive-Bsreu2z1.js";
|
|
2
|
+
import { i as isFocusable } from "../isFocusable-Ckwus82R.js";
|
|
3
|
+
const stack = [];
|
|
4
|
+
let stackProcessPlanned = false;
|
|
5
|
+
const processStack = () => {
|
|
6
|
+
stackProcessPlanned = false;
|
|
7
|
+
const candidates = [];
|
|
8
|
+
while (stack.length > 0) {
|
|
9
|
+
const top = stack[stack.length - 1];
|
|
10
|
+
if (top.element) {
|
|
11
|
+
candidates.push(top.element);
|
|
12
|
+
break;
|
|
13
|
+
} else {
|
|
14
|
+
if (top.previousElement) {
|
|
15
|
+
candidates.push(top.previousElement);
|
|
16
|
+
}
|
|
17
|
+
stack.pop();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const candidate of candidates) {
|
|
21
|
+
if (isFocusable(candidate)) {
|
|
22
|
+
candidate.focus();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const planProcessStack = () => {
|
|
28
|
+
if (!stackProcessPlanned) {
|
|
29
|
+
stackProcessPlanned = true;
|
|
30
|
+
setTimeout(processStack, 0);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const focusElement = browserDirective((element) => {
|
|
34
|
+
const stackEntry = { element, previousElement: document.activeElement };
|
|
35
|
+
stack.push(stackEntry);
|
|
36
|
+
planProcessStack();
|
|
37
|
+
return {
|
|
38
|
+
destroy() {
|
|
39
|
+
stackEntry.element = null;
|
|
40
|
+
planProcessStack();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
focusElement
|
|
46
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
4
|
+
const utils_directive = require("../directive-DCaXmRe_.cjs");
|
|
5
|
+
const esmEnv = require("esm-env");
|
|
6
|
+
const evtFocusIn = "focusin";
|
|
7
|
+
const evtFocusOut = "focusout";
|
|
8
|
+
const activeElement$ = !esmEnv.BROWSER ? tansu.readable(null) : tansu.readable(null, {
|
|
9
|
+
onUse({ set }) {
|
|
10
|
+
function setActiveElement() {
|
|
11
|
+
set(document.activeElement);
|
|
12
|
+
}
|
|
13
|
+
setActiveElement();
|
|
14
|
+
const container = document.documentElement;
|
|
15
|
+
function onFocusOut() {
|
|
16
|
+
setTimeout(setActiveElement);
|
|
17
|
+
}
|
|
18
|
+
container.addEventListener(evtFocusIn, setActiveElement, { capture: true });
|
|
19
|
+
container.addEventListener(evtFocusOut, onFocusOut, { capture: true });
|
|
20
|
+
return () => {
|
|
21
|
+
container.removeEventListener(evtFocusIn, setActiveElement, { capture: true });
|
|
22
|
+
container.removeEventListener(evtFocusOut, onFocusOut, { capture: true });
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
equal: Object.is
|
|
26
|
+
});
|
|
27
|
+
function createHasFocus() {
|
|
28
|
+
const { elements$, directive } = utils_directive.createBrowserStoreArrayDirective();
|
|
29
|
+
const hasFocus$ = tansu.computed(() => {
|
|
30
|
+
const activeElement = activeElement$();
|
|
31
|
+
if (!activeElement) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
for (const element of elements$()) {
|
|
35
|
+
if (element === activeElement || element.contains(activeElement)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
directive,
|
|
43
|
+
hasFocus$
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.activeElement$ = activeElement$;
|
|
47
|
+
exports.createHasFocus = createHasFocus;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
import type { Directive } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* A readable store that tracks the currently active (focused) element in the document.
|
|
5
|
+
*
|
|
6
|
+
* This store is only active in a browser environment. When not in a browser environment,
|
|
7
|
+
* it will be a readable store with a `null` value.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { activeElement$ } from './focustrack';
|
|
12
|
+
*
|
|
13
|
+
* activeElement$.subscribe((element) => {
|
|
14
|
+
* console.log('Active element:', element);
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The store updates whenever the active element changes, such as when the user focuses
|
|
19
|
+
* on a different input field or clicks on a different part of the document.
|
|
20
|
+
*/
|
|
21
|
+
export declare const activeElement$: ReadableSignal<Element | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Interface representing an element that can have focus tracking.
|
|
24
|
+
*/
|
|
25
|
+
export interface HasFocus {
|
|
26
|
+
/**
|
|
27
|
+
* Directive to put on some elements.
|
|
28
|
+
*/
|
|
29
|
+
directive: Directive;
|
|
30
|
+
/**
|
|
31
|
+
* Store that contains true if the activeElement is one of the elements which has the directive,
|
|
32
|
+
* or any of their descendants.
|
|
33
|
+
*/
|
|
34
|
+
hasFocus$: ReadableSignal<boolean>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a HasFocus
|
|
38
|
+
* @returns a HasFocus
|
|
39
|
+
*/
|
|
40
|
+
export declare function createHasFocus(): HasFocus;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readable, computed } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { h as createBrowserStoreArrayDirective } from "../directive-Bsreu2z1.js";
|
|
3
|
+
import { BROWSER } from "esm-env";
|
|
4
|
+
const evtFocusIn = "focusin";
|
|
5
|
+
const evtFocusOut = "focusout";
|
|
6
|
+
const activeElement$ = !BROWSER ? readable(null) : readable(null, {
|
|
7
|
+
onUse({ set }) {
|
|
8
|
+
function setActiveElement() {
|
|
9
|
+
set(document.activeElement);
|
|
10
|
+
}
|
|
11
|
+
setActiveElement();
|
|
12
|
+
const container = document.documentElement;
|
|
13
|
+
function onFocusOut() {
|
|
14
|
+
setTimeout(setActiveElement);
|
|
15
|
+
}
|
|
16
|
+
container.addEventListener(evtFocusIn, setActiveElement, { capture: true });
|
|
17
|
+
container.addEventListener(evtFocusOut, onFocusOut, { capture: true });
|
|
18
|
+
return () => {
|
|
19
|
+
container.removeEventListener(evtFocusIn, setActiveElement, { capture: true });
|
|
20
|
+
container.removeEventListener(evtFocusOut, onFocusOut, { capture: true });
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
equal: Object.is
|
|
24
|
+
});
|
|
25
|
+
function createHasFocus() {
|
|
26
|
+
const { elements$, directive } = createBrowserStoreArrayDirective();
|
|
27
|
+
const hasFocus$ = computed(() => {
|
|
28
|
+
const activeElement = activeElement$();
|
|
29
|
+
if (!activeElement) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
for (const element of elements$()) {
|
|
33
|
+
if (element === activeElement || element.contains(activeElement)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
directive,
|
|
41
|
+
hasFocus$
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
activeElement$,
|
|
46
|
+
createHasFocus
|
|
47
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
4
|
+
const hash$ = tansu.readable("", {
|
|
5
|
+
onUse({ set }) {
|
|
6
|
+
function handleHashChange() {
|
|
7
|
+
const hash = location.hash;
|
|
8
|
+
set(hash ? hash.substring(1) : "");
|
|
9
|
+
}
|
|
10
|
+
handleHashChange();
|
|
11
|
+
window.addEventListener("hashchange", handleHashChange);
|
|
12
|
+
return () => window.removeEventListener("hashchange", handleHashChange);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
exports.hash$ = hash$;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readable } from "@amadeus-it-group/tansu";
|
|
2
|
+
const hash$ = readable("", {
|
|
3
|
+
onUse({ set }) {
|
|
4
|
+
function handleHashChange() {
|
|
5
|
+
const hash = location.hash;
|
|
6
|
+
set(hash ? hash.substring(1) : "");
|
|
7
|
+
}
|
|
8
|
+
handleHashChange();
|
|
9
|
+
window.addEventListener("hashchange", handleHashChange);
|
|
10
|
+
return () => window.removeEventListener("hashchange", handleHashChange);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export {
|
|
14
|
+
hash$
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
4
|
+
const utils_func = require("../utils/func.cjs");
|
|
5
|
+
const utils_stores = require("../utils/stores.cjs");
|
|
6
|
+
const defaultValues = {
|
|
7
|
+
elements: [],
|
|
8
|
+
options: void 0
|
|
9
|
+
};
|
|
10
|
+
const createIntersection = (config) => {
|
|
11
|
+
const [{ elements$, options$ }, patch] = utils_stores.writablesForProps(defaultValues, config);
|
|
12
|
+
const visibleElements$ = tansu.derived(
|
|
13
|
+
[elements$, options$],
|
|
14
|
+
([elements, options], set) => {
|
|
15
|
+
if (elements.length) {
|
|
16
|
+
const visibleElements = /* @__PURE__ */ new Map();
|
|
17
|
+
const observer = new IntersectionObserver((entries) => {
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
const { target, isIntersecting } = entry;
|
|
20
|
+
if (isIntersecting) {
|
|
21
|
+
visibleElements.set(target, entry);
|
|
22
|
+
} else {
|
|
23
|
+
visibleElements.delete(target);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
set(visibleElements);
|
|
27
|
+
}, options);
|
|
28
|
+
for (const element of elements) {
|
|
29
|
+
observer.observe(element);
|
|
30
|
+
}
|
|
31
|
+
return () => {
|
|
32
|
+
observer.disconnect();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return utils_func.noop;
|
|
36
|
+
},
|
|
37
|
+
/* @__PURE__ */ new Map()
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
/**
|
|
41
|
+
* Readable of observed elements
|
|
42
|
+
*/
|
|
43
|
+
elements$: tansu.asReadable(elements$),
|
|
44
|
+
/**
|
|
45
|
+
* Store of map that contains the visible elements (for the key) and the corresponding entries
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry | MDN documentation}
|
|
48
|
+
*/
|
|
49
|
+
visibleElements$: tansu.asReadable(visibleElements$),
|
|
50
|
+
patch
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.createIntersection = createIntersection;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
import type { PropsConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the properties for the Intersection service.
|
|
5
|
+
*/
|
|
6
|
+
export interface IntersectionProps {
|
|
7
|
+
/**
|
|
8
|
+
* elements to observe
|
|
9
|
+
*/
|
|
10
|
+
elements: HTMLElement[];
|
|
11
|
+
/**
|
|
12
|
+
* IntersectionObserverInit used in the {@link IntersectionObserver}
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options | MDN documentation}
|
|
15
|
+
*/
|
|
16
|
+
options: Partial<IntersectionObserverInit> | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create an intersection service.
|
|
20
|
+
*
|
|
21
|
+
* The returned service includes the patch method to set the elements to observe / intersection options and the states to track the visible elements.
|
|
22
|
+
*
|
|
23
|
+
* @param config - the props config for the intersection service
|
|
24
|
+
* @returns the intersection service
|
|
25
|
+
*/
|
|
26
|
+
export declare const createIntersection: (config?: PropsConfig<IntersectionProps>) => {
|
|
27
|
+
elements$: ReadableSignal<HTMLElement[]>;
|
|
28
|
+
visibleElements$: ReadableSignal<Map<Element, IntersectionObserverEntry>>;
|
|
29
|
+
patch: (storesValues: Partial<IntersectionProps>) => void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { derived, asReadable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { noop } from "../utils/func.js";
|
|
3
|
+
import { writablesForProps } from "../utils/stores.js";
|
|
4
|
+
const defaultValues = {
|
|
5
|
+
elements: [],
|
|
6
|
+
options: void 0
|
|
7
|
+
};
|
|
8
|
+
const createIntersection = (config) => {
|
|
9
|
+
const [{ elements$, options$ }, patch] = writablesForProps(defaultValues, config);
|
|
10
|
+
const visibleElements$ = derived(
|
|
11
|
+
[elements$, options$],
|
|
12
|
+
([elements, options], set) => {
|
|
13
|
+
if (elements.length) {
|
|
14
|
+
const visibleElements = /* @__PURE__ */ new Map();
|
|
15
|
+
const observer = new IntersectionObserver((entries) => {
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
const { target, isIntersecting } = entry;
|
|
18
|
+
if (isIntersecting) {
|
|
19
|
+
visibleElements.set(target, entry);
|
|
20
|
+
} else {
|
|
21
|
+
visibleElements.delete(target);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
set(visibleElements);
|
|
25
|
+
}, options);
|
|
26
|
+
for (const element of elements) {
|
|
27
|
+
observer.observe(element);
|
|
28
|
+
}
|
|
29
|
+
return () => {
|
|
30
|
+
observer.disconnect();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return noop;
|
|
34
|
+
},
|
|
35
|
+
/* @__PURE__ */ new Map()
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
/**
|
|
39
|
+
* Readable of observed elements
|
|
40
|
+
*/
|
|
41
|
+
elements$: asReadable(elements$),
|
|
42
|
+
/**
|
|
43
|
+
* Store of map that contains the visible elements (for the key) and the corresponding entries
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry | MDN documentation}
|
|
46
|
+
*/
|
|
47
|
+
visibleElements$: asReadable(visibleElements$),
|
|
48
|
+
patch
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
createIntersection
|
|
53
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
4
|
+
const esmEnv = require("esm-env");
|
|
5
|
+
const utils_directive = require("../directive-DCaXmRe_.cjs");
|
|
6
|
+
const utils_stores = require("../utils/stores.cjs");
|
|
7
|
+
const createMatchMedia = (query) => esmEnv.BROWSER ? tansu.readable(false, {
|
|
8
|
+
onUse({ set }) {
|
|
9
|
+
const mql = window.matchMedia(query.trim());
|
|
10
|
+
set(mql.matches);
|
|
11
|
+
return utils_directive.addEvent(mql, "change", (val) => set(val.matches));
|
|
12
|
+
}
|
|
13
|
+
}) : utils_stores.false$;
|
|
14
|
+
exports.createMatchMedia = createMatchMedia;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
/**
|
|
3
|
+
* Create a store tracking the state of a {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia | matchMedia} query.
|
|
4
|
+
*
|
|
5
|
+
* @param query - the query to match
|
|
6
|
+
* @returns a readable store tracking the match media query state
|
|
7
|
+
*/
|
|
8
|
+
export declare const createMatchMedia: (query: string) => ReadableSignal<boolean>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readable } from "@amadeus-it-group/tansu";
|
|
2
|
+
import { BROWSER } from "esm-env";
|
|
3
|
+
import { w as addEvent } from "../directive-Bsreu2z1.js";
|
|
4
|
+
import { false$ } from "../utils/stores.js";
|
|
5
|
+
const createMatchMedia = (query) => BROWSER ? readable(false, {
|
|
6
|
+
onUse({ set }) {
|
|
7
|
+
const mql = window.matchMedia(query.trim());
|
|
8
|
+
set(mql.matches);
|
|
9
|
+
return addEvent(mql, "change", (val) => set(val.matches));
|
|
10
|
+
}
|
|
11
|
+
}) : false$;
|
|
12
|
+
export {
|
|
13
|
+
createMatchMedia
|
|
14
|
+
};
|