@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,98 @@
|
|
|
1
|
+
import type { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the result of a promise that is still pending.
|
|
4
|
+
*/
|
|
5
|
+
export interface PromisePendingResult {
|
|
6
|
+
/** Pending status */
|
|
7
|
+
status: 'pending';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A constant representing a pending promise result.
|
|
11
|
+
*/
|
|
12
|
+
export declare const promisePending: PromisePendingResult;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the state of a promise, which can be either fulfilled, rejected, or pending.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The type of the value promised
|
|
17
|
+
*/
|
|
18
|
+
export type PromiseState<T> = PromiseFulfilledResult<T> | PromiseRejectedResult | PromisePendingResult;
|
|
19
|
+
/**
|
|
20
|
+
* Create a readable promise state store from a promise.
|
|
21
|
+
*
|
|
22
|
+
* The state of the returned store tracks the state of the promise and the resolved value or rejection reason.
|
|
23
|
+
*
|
|
24
|
+
* @param value - the promise
|
|
25
|
+
* @returns the readable promise state store
|
|
26
|
+
*/
|
|
27
|
+
export declare const promiseStateStore: <T>(value: T) => ReadableSignal<Readonly<PromiseState<Awaited<T>>>>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a readable promise state store from a promise store.
|
|
30
|
+
*
|
|
31
|
+
* @param promiseStore$ - the promise store
|
|
32
|
+
* @returns the readable promise state store
|
|
33
|
+
*/
|
|
34
|
+
export declare const promiseStoreToPromiseStateStore: <T>(promiseStore$: ReadableSignal<T>) => ReadableSignal<PromiseState<Awaited<T>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a value store from a promise state store
|
|
37
|
+
*
|
|
38
|
+
* The returned value store is only updated if the promise is fulfilled.
|
|
39
|
+
*
|
|
40
|
+
* @param store$ - the promise state store
|
|
41
|
+
* @param initialValue - the initial value of the returned value store
|
|
42
|
+
* @param equal - an equal function to compare values
|
|
43
|
+
* @returns the value store
|
|
44
|
+
*/
|
|
45
|
+
export declare const promiseStateStoreToValueStore: <T>(store$: ReadableSignal<PromiseState<T>>, initialValue: T, equal?: (a: T, b: T) => boolean) => ReadableSignal<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a value store from a promise store
|
|
48
|
+
*
|
|
49
|
+
* The returned value store is only updated if the promise is fulfilled.
|
|
50
|
+
*
|
|
51
|
+
* @param promiseStore$ - the promise store
|
|
52
|
+
* @param initialValue - the initial value of the returned value store
|
|
53
|
+
* @param equal - an equal function to compare values
|
|
54
|
+
* @returns the value store
|
|
55
|
+
*/
|
|
56
|
+
export declare const promiseStoreToValueStore: <T>(promiseStore$: ReadableSignal<T>, initialValue: Awaited<T>, equal?: (a: Awaited<T>, b: Awaited<T>) => boolean) => ReadableSignal<Awaited<T>>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a promise from a readable store and a fulfilled condition function.
|
|
59
|
+
*
|
|
60
|
+
* The promise is fulfilled when the state of the store respects the provided condition function.
|
|
61
|
+
*
|
|
62
|
+
* @param store - the readable store
|
|
63
|
+
* @param condition - the condition function
|
|
64
|
+
* @returns the promise and an unsubscribe function
|
|
65
|
+
*/
|
|
66
|
+
export declare const promiseFromStore: <T>(store: ReadableSignal<T>, condition?: (value: T) => boolean) => {
|
|
67
|
+
promise: Promise<T>;
|
|
68
|
+
unsubscribe(): void;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Create a promise from an HTML element event.
|
|
72
|
+
*
|
|
73
|
+
* @param element - the event target
|
|
74
|
+
* @param event - the event to listen to
|
|
75
|
+
* @returns the promise and an unsubscribe function
|
|
76
|
+
*/
|
|
77
|
+
export declare const promiseFromEvent: (element: EventTarget, event: string) => {
|
|
78
|
+
promise: Promise<Event>;
|
|
79
|
+
unsubscribe(): void;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Create a promise that resolves once a timeout has been reached.
|
|
83
|
+
*
|
|
84
|
+
* @param delay - the delay in milli seconds
|
|
85
|
+
* @returns a promise and an unsubscribe function
|
|
86
|
+
*/
|
|
87
|
+
export declare const promiseFromTimeout: (delay: number) => {
|
|
88
|
+
promise: Promise<void>;
|
|
89
|
+
unsubscribe(): void;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Utility method to create a promise with resolve
|
|
93
|
+
* @returns a promise with resolve
|
|
94
|
+
*/
|
|
95
|
+
export declare const promiseWithResolve: () => {
|
|
96
|
+
promise: Promise<void>;
|
|
97
|
+
resolve: (value: void | Promise<void>) => void;
|
|
98
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function to remove the scrollbars on the body element. It can be reverted using the {@link revertScrollbars} function.
|
|
3
|
+
*/
|
|
4
|
+
export declare const removeScrollbars: () => void;
|
|
5
|
+
/**
|
|
6
|
+
* A function to revert the removal of scrollbars performed by the {@link removeScrollbars} function.
|
|
7
|
+
*/
|
|
8
|
+
export declare const revertScrollbars: () => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default comparision between two values, using the javascript < and > signs.
|
|
3
|
+
*
|
|
4
|
+
* @param a - the first input
|
|
5
|
+
* @param b - the second input
|
|
6
|
+
* @returns 1, 0 or -1 depending on the default compare
|
|
7
|
+
*/
|
|
8
|
+
export declare const compareDefault: (a: any, b: any) => -1 | 0 | 1;
|
|
9
|
+
/**
|
|
10
|
+
* A comparision function between DOM elements, based on {@link https://developer.mozilla.org/fr/docs/Web/API/Node/compareDocumentPosition | Node.compareDocumentPosition}.
|
|
11
|
+
*
|
|
12
|
+
* @param element1 - the first node
|
|
13
|
+
* @param element2 - the second node
|
|
14
|
+
* @returns 1, 0 or -1
|
|
15
|
+
*/
|
|
16
|
+
export declare const compareDomOrder: (element1: Node, element2: Node) => 0 | 1 | -1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SSRHTMLElement, StyleKeyCustomProperty, StyleKeyKebabCase, StyleValue } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A unique symbol used to represent the attributes and style of an SSR (Server-Side Rendering) HTML element.
|
|
4
|
+
* This symbol can be used as a key for storing or retrieving attributes and styles associated with an SSR HTML element.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ssrHTMLElementAttributesAndStyle: unique symbol;
|
|
7
|
+
/**
|
|
8
|
+
* Create an SSRHTMLElement
|
|
9
|
+
* @returns the created SSRHTMLElement
|
|
10
|
+
*/
|
|
11
|
+
export declare const ssrHTMLElement: () => SSRHTMLElement;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a style object to a CSS text string.
|
|
14
|
+
* @param style - The style object to convert.
|
|
15
|
+
* @returns The CSS text string representation of the style object.
|
|
16
|
+
*/
|
|
17
|
+
export declare const cssTextFromObject: (style: Partial<Record<StyleKeyKebabCase | StyleKeyCustomProperty, StyleValue>>) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the text direction of an element, using a call to `getComputedStyle`.
|
|
3
|
+
*
|
|
4
|
+
* @param element - the HTML element
|
|
5
|
+
* @returns the text direction of the element, 'ltr' or 'rtl'
|
|
6
|
+
*/
|
|
7
|
+
export declare const getTextDirection: (element: HTMLElement) => "ltr" | "rtl";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
interface TraversalFnOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Remove symbol to return to remove the value
|
|
4
|
+
*/
|
|
5
|
+
removeSymbol?: symbol;
|
|
6
|
+
/**
|
|
7
|
+
* index of the array, when looping on the elements
|
|
8
|
+
*/
|
|
9
|
+
index?: number;
|
|
10
|
+
}
|
|
11
|
+
type TraversalFn = (key: string, value: any, options: TraversalFnOptions) => any;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a JSON walker function that can be used to traverse and transform
|
|
14
|
+
* the properties of a JSON object.
|
|
15
|
+
*
|
|
16
|
+
* @param fn - The callback function called for each property in the JSON object.
|
|
17
|
+
* @returns A function that takes a JSON object as input and applies the provided
|
|
18
|
+
* callback function to each property.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const json = {
|
|
23
|
+
* name: 'John',
|
|
24
|
+
* age: 30,
|
|
25
|
+
* address: {
|
|
26
|
+
* city: 'New York',
|
|
27
|
+
* country: 'USA',
|
|
28
|
+
* },
|
|
29
|
+
* useless: '',
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* const transform = createTraversal((key, value, {removeSymbol}) => {
|
|
33
|
+
* if (key === 'age') {
|
|
34
|
+
* return value * 2; // Double the age
|
|
35
|
+
* }
|
|
36
|
+
* if (key === 'useless') {
|
|
37
|
+
* return removeSymbol;
|
|
38
|
+
* }
|
|
39
|
+
* return value;
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* const transformedJson = transform(json);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function createTraversal(fn: TraversalFn): (json: any) => any;
|
|
46
|
+
/**
|
|
47
|
+
* Utility method to create a promise with resolve
|
|
48
|
+
* @returns a promise with resolve
|
|
49
|
+
*/
|
|
50
|
+
export declare const promiseWithResolve: () => {
|
|
51
|
+
promise: Promise<void>;
|
|
52
|
+
resolve: (value: void | Promise<void>) => void;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
4
|
+
const types = require("../types.cjs");
|
|
5
|
+
const utils_func = require("./func.cjs");
|
|
6
|
+
const utils_id = require("./id.cjs");
|
|
7
|
+
function createPatch(stores) {
|
|
8
|
+
return function(storesValues) {
|
|
9
|
+
tansu.batch(() => {
|
|
10
|
+
for (const [name, value] of Object.entries(storesValues)) {
|
|
11
|
+
stores[`${name}$`]?.set(value);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function findChangedProperties(obj1, obj2) {
|
|
17
|
+
if (obj1 === obj2) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
let hasUpdate = false;
|
|
21
|
+
const changedValues = {};
|
|
22
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
|
|
23
|
+
for (const key of keys) {
|
|
24
|
+
const value = obj2[key];
|
|
25
|
+
if (obj1[key] !== value) {
|
|
26
|
+
changedValues[key] = value;
|
|
27
|
+
hasUpdate = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return hasUpdate ? changedValues : null;
|
|
31
|
+
}
|
|
32
|
+
function writableWithDefault(defValue, config$ = tansu.readable(void 0), options = {}, own$ = tansu.writable(void 0)) {
|
|
33
|
+
const { normalizeValue = utils_func.identity, equal = Object.is } = options;
|
|
34
|
+
const getDefValue = () => defValue;
|
|
35
|
+
const callNormalizeValue = (value, defValue2 = getDefValue) => {
|
|
36
|
+
const normalizedValue = value === void 0 ? void 0 : normalizeValue(value);
|
|
37
|
+
if (normalizedValue === types.INVALID_VALUE) {
|
|
38
|
+
console.error("Not using invalid value", value);
|
|
39
|
+
return defValue2();
|
|
40
|
+
}
|
|
41
|
+
if (normalizedValue === void 0) {
|
|
42
|
+
return defValue2();
|
|
43
|
+
}
|
|
44
|
+
return normalizedValue;
|
|
45
|
+
};
|
|
46
|
+
const validatedDefConfig$ = tansu.computed(() => callNormalizeValue(config$()), { equal });
|
|
47
|
+
const validatedOwnValue$ = tansu.computed(() => callNormalizeValue(own$(), validatedDefConfig$), { equal });
|
|
48
|
+
return tansu.asWritable(validatedOwnValue$, (value) => {
|
|
49
|
+
if (value !== void 0) {
|
|
50
|
+
const normalizedValue = normalizeValue(value);
|
|
51
|
+
if (normalizedValue === types.INVALID_VALUE) {
|
|
52
|
+
console.error("Not setting invalid value", value);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
value = normalizedValue;
|
|
56
|
+
}
|
|
57
|
+
own$.set(value);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const isStore = (x) => !!(x && typeof x === "function" && "subscribe" in x);
|
|
61
|
+
const toReadableStore = (x) => isStore(x) ? x : tansu.readable(x);
|
|
62
|
+
const toWritableStore = (x) => isStore(x) ? x : tansu.writable(x);
|
|
63
|
+
const normalizeConfigStores = (keys, config) => {
|
|
64
|
+
const res = {};
|
|
65
|
+
if (config) {
|
|
66
|
+
const configIsStore = isStore(config);
|
|
67
|
+
for (const key of keys) {
|
|
68
|
+
res[key] = configIsStore ? tansu.computed(() => config()[key]) : toReadableStore(config[key]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return res;
|
|
72
|
+
};
|
|
73
|
+
const mergeConfigStores = (keys, config1, config2) => {
|
|
74
|
+
const res = {};
|
|
75
|
+
for (const key of keys) {
|
|
76
|
+
const config1Store = config1?.[key];
|
|
77
|
+
const config2Store = config2?.[key];
|
|
78
|
+
res[key] = config1Store && config2Store ? tansu.computed(() => config1Store() ?? config2Store()) : config1Store || config2Store;
|
|
79
|
+
}
|
|
80
|
+
return res;
|
|
81
|
+
};
|
|
82
|
+
const writablesWithDefault = (defConfig, propsConfig, options) => {
|
|
83
|
+
const res = {};
|
|
84
|
+
const keys = Object.keys(defConfig);
|
|
85
|
+
const configStores = normalizeConfigStores(keys, propsConfig?.config);
|
|
86
|
+
const props = propsConfig?.props;
|
|
87
|
+
for (const key of keys) {
|
|
88
|
+
const propValue = props?.[key];
|
|
89
|
+
res[`${key}$`] = writableWithDefault(defConfig[key], configStores[key], options?.[key], toWritableStore(propValue));
|
|
90
|
+
}
|
|
91
|
+
return res;
|
|
92
|
+
};
|
|
93
|
+
const writablesForProps = (defConfig, propsConfig, options) => {
|
|
94
|
+
const stores = writablesWithDefault(defConfig, propsConfig, options);
|
|
95
|
+
return [stores, createPatch(stores)];
|
|
96
|
+
};
|
|
97
|
+
const stateStores = (inputStores) => {
|
|
98
|
+
const storesNames = [];
|
|
99
|
+
const storesArray = [];
|
|
100
|
+
const stores = {};
|
|
101
|
+
for (const [key, store] of Object.entries(inputStores)) {
|
|
102
|
+
if (key.endsWith("$")) {
|
|
103
|
+
storesNames.push(key.substring(0, key.length - 1));
|
|
104
|
+
storesArray.push(store);
|
|
105
|
+
stores[key] = tansu.asReadable(store);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
stores,
|
|
110
|
+
state$: tansu.computed(() => {
|
|
111
|
+
const values = storesArray.map(tansu.get);
|
|
112
|
+
const res = {};
|
|
113
|
+
storesNames.forEach((name, index) => {
|
|
114
|
+
res[name] = values[index];
|
|
115
|
+
});
|
|
116
|
+
return res;
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const bindableDerived = (onChange$, stores, adjustValue = (arg) => arg[0], equal = (currentValue, newValue) => newValue === currentValue) => {
|
|
121
|
+
let currentValue = stores[0]();
|
|
122
|
+
return tansu.asWritable(
|
|
123
|
+
tansu.derived(stores, {
|
|
124
|
+
derive(values) {
|
|
125
|
+
const newValue = adjustValue(values);
|
|
126
|
+
const rectifiedValue = !equal(values[0], newValue);
|
|
127
|
+
if (rectifiedValue) {
|
|
128
|
+
stores[0].set(newValue);
|
|
129
|
+
}
|
|
130
|
+
if (rectifiedValue || !equal(currentValue, newValue)) {
|
|
131
|
+
currentValue = newValue;
|
|
132
|
+
onChange$()(newValue);
|
|
133
|
+
}
|
|
134
|
+
return newValue;
|
|
135
|
+
},
|
|
136
|
+
equal
|
|
137
|
+
}),
|
|
138
|
+
stores[0].set.bind(stores[0])
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
const bindableProp = (store$, onChange$, adjustValue = utils_func.identity, equal = tansu.equal) => tansu.asWritable(
|
|
142
|
+
tansu.computed(() => adjustValue(store$()), { equal }),
|
|
143
|
+
(newValue) => {
|
|
144
|
+
const adjustedValue = adjustValue(newValue);
|
|
145
|
+
if (!equal(store$(), adjustedValue)) {
|
|
146
|
+
store$.set(adjustedValue);
|
|
147
|
+
onChange$()(adjustedValue);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
function idWithDefault(id$) {
|
|
152
|
+
const autoId$ = tansu.computed(() => utils_id.generateId());
|
|
153
|
+
return tansu.computed(() => id$() || autoId$());
|
|
154
|
+
}
|
|
155
|
+
const true$ = tansu.readable(true);
|
|
156
|
+
const false$ = tansu.readable(false);
|
|
157
|
+
exports.bindableDerived = bindableDerived;
|
|
158
|
+
exports.bindableProp = bindableProp;
|
|
159
|
+
exports.createPatch = createPatch;
|
|
160
|
+
exports.false$ = false$;
|
|
161
|
+
exports.findChangedProperties = findChangedProperties;
|
|
162
|
+
exports.idWithDefault = idWithDefault;
|
|
163
|
+
exports.isStore = isStore;
|
|
164
|
+
exports.mergeConfigStores = mergeConfigStores;
|
|
165
|
+
exports.normalizeConfigStores = normalizeConfigStores;
|
|
166
|
+
exports.stateStores = stateStores;
|
|
167
|
+
exports.toReadableStore = toReadableStore;
|
|
168
|
+
exports.toWritableStore = toWritableStore;
|
|
169
|
+
exports.true$ = true$;
|
|
170
|
+
exports.writableWithDefault = writableWithDefault;
|
|
171
|
+
exports.writablesForProps = writablesForProps;
|
|
172
|
+
exports.writablesWithDefault = writablesWithDefault;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import type { ReadableSignal, StoreInput, StoresInputValues, WritableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
import type { ConfigValidator, PropsConfig, ValuesOrReadableSignals, WritableWithDefaultOptions } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms the properties of a given type `P` into writable signals.
|
|
5
|
+
* Each property key in `P` is suffixed with a `$` and its type is converted to a `WritableSignal`.
|
|
6
|
+
* @template P - The original type whose properties are to be transformed.
|
|
7
|
+
*/
|
|
8
|
+
export type ToWritableSignal<P> = {
|
|
9
|
+
[K in keyof P as `${K & string}$`]-?: WritableSignal<P[K], P[K] | undefined>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Represents a collection of readable signals for an object type `T`.
|
|
13
|
+
* Each key in the object corresponds to a key in `T`, and the value is an optional `ReadableSignal`
|
|
14
|
+
* that can hold the value of the corresponding property in `T` or `undefined`.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The object type for which the readable signals are defined.
|
|
17
|
+
*/
|
|
18
|
+
export type ReadableSignals<T extends object> = {
|
|
19
|
+
[K in keyof T]?: ReadableSignal<T[K] | undefined>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A utility type that removes the trailing dollar sign (`$`) from a string type.
|
|
23
|
+
*
|
|
24
|
+
* @template S - A string type that ends with a dollar sign (`$`).
|
|
25
|
+
* @returns The string type without the trailing dollar sign (`$`), or `never` if the input type does not end with a dollar sign.
|
|
26
|
+
*/
|
|
27
|
+
export type WithoutDollar<S extends `${string}$`> = S extends `${infer U}$` ? U : never;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* Utility function designed to create a `patch` function related to the provided stores.
|
|
31
|
+
* Any key given to the patch function which is not in the original object will be ignored.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const storeA$ = writable(1);
|
|
37
|
+
* const storeB$ = writable(1);
|
|
38
|
+
* const patch = createPatch({a: storeA$, b: storeB$});
|
|
39
|
+
*
|
|
40
|
+
* patch({a: 2}) // will perform storeA$.set(2)
|
|
41
|
+
* patch({a: 2, b: 2}) // will perform storeA$.set(2) and storeB$.set(2) in the same batch.
|
|
42
|
+
* patch({a: 2, c: 2}) // will perform storeA$.set(2), c is ignored.
|
|
43
|
+
*
|
|
44
|
+
* ```
|
|
45
|
+
* @template T - The type of the object that the stores represent.
|
|
46
|
+
* @param stores - The stores to be updated.
|
|
47
|
+
* @returns - A function that takes partial values of the stores and updates them.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createPatch<T extends object>(stores: ToWritableSignal<T>): (storesValues: Partial<T>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* This utility function is designed to compare the first level of two objects.
|
|
52
|
+
*
|
|
53
|
+
* It returns a new object which has all the keys for which the values in `obj1`
|
|
54
|
+
* and `obj2` are different, with the values from `obj2`, or null if objects
|
|
55
|
+
* are identical.
|
|
56
|
+
*
|
|
57
|
+
* @template T - The type of the objects being compared.
|
|
58
|
+
* @param obj1 - The first partial object to compare.
|
|
59
|
+
* @param obj2 - The second partial object to compare.
|
|
60
|
+
* @returns A partial object containing the properties that have different values, or `null` if the objects are identical.
|
|
61
|
+
*/
|
|
62
|
+
export declare function findChangedProperties<T extends Record<string, any>>(obj1: Partial<T>, obj2: Partial<T>): Partial<T> | null;
|
|
63
|
+
/**
|
|
64
|
+
* Returns a writable store whose value is either its own value (when it is not undefined) or a default value
|
|
65
|
+
* that comes either from the `config$` store (when it is not undefined) or from `defValue`.
|
|
66
|
+
* If a normalizeValue function is passed in the options, it is called to normalize non-undefined values coming
|
|
67
|
+
* either from the `config$` store or from the `set` or `update` functions. If a value is invalid (i.e. normalizeValue
|
|
68
|
+
* returns the `invalidValue` symbol), an error is logged on the console and it is either not set (if it comes from the
|
|
69
|
+
* `set` or `update` functions), or the `defValue` is used instead (if the invalid value comes from the `config$` store).
|
|
70
|
+
*
|
|
71
|
+
* @template T - The type of the value.
|
|
72
|
+
*
|
|
73
|
+
* @param defValue - Default value used when both the own value and the config$ value are undefined.
|
|
74
|
+
* @param config$ - Store containing the default value used when the own value is undefined
|
|
75
|
+
* @param options - Object which can contain the following optional functions: normalizeValue and equal
|
|
76
|
+
* @param own$ - Store containing the own value
|
|
77
|
+
* @returns a writable store with the extra default value and normalization logic described above
|
|
78
|
+
*/
|
|
79
|
+
export declare function writableWithDefault<T>(defValue: T, config$?: ReadableSignal<T | undefined>, options?: WritableWithDefaultOptions<T>, own$?: WritableSignal<T | undefined>): WritableSignal<T, T | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true if the provided argument is a store (ReadableSignal).
|
|
82
|
+
* @param x - argument that is tested
|
|
83
|
+
* @returns true if the argument is a store (ReadableSignal)
|
|
84
|
+
*/
|
|
85
|
+
export declare const isStore: (x: any) => x is ReadableSignal<any>;
|
|
86
|
+
/**
|
|
87
|
+
* If the provided argument is already a store, it is returned as is, otherwise, a readable store is created with the provided argument as its initial value.
|
|
88
|
+
* @template T - The type of the value.
|
|
89
|
+
* @param x - The value to be converted to a readable store.
|
|
90
|
+
* @returns - The readable store containing the value.
|
|
91
|
+
*/
|
|
92
|
+
export declare const toReadableStore: <T>(x: ReadableSignal<T> | T) => ReadableSignal<T>;
|
|
93
|
+
/**
|
|
94
|
+
* Converts a value or a writable signal into a writable signal.
|
|
95
|
+
*
|
|
96
|
+
* @template T - The type of the value or signal.
|
|
97
|
+
* @param x - The value or writable signal to convert.
|
|
98
|
+
* @returns - The resulting writable signal.
|
|
99
|
+
*/
|
|
100
|
+
export declare const toWritableStore: <T>(x: WritableSignal<T> | T) => WritableSignal<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Normalizes configuration stores by converting them into readable signals.
|
|
103
|
+
*
|
|
104
|
+
* @template T - The type of the configuration object.
|
|
105
|
+
* @param keys - An array of keys to normalize from the configuration object.
|
|
106
|
+
* @param [config] - The configuration object or readable signals to normalize.
|
|
107
|
+
* @returns An object containing readable signals for each key in the configuration.
|
|
108
|
+
*/
|
|
109
|
+
export declare const normalizeConfigStores: <T extends object>(keys: (keyof T)[], config?: ReadableSignal<Partial<T>> | ValuesOrReadableSignals<T>) => ReadableSignals<T>;
|
|
110
|
+
/**
|
|
111
|
+
* Merges two configuration stores into one, prioritizing the first store's values
|
|
112
|
+
* when both stores have a value for the same key.
|
|
113
|
+
*
|
|
114
|
+
* @template T - The type of the configuration object.
|
|
115
|
+
* @param keys - The keys to merge from the configuration stores.
|
|
116
|
+
* @param [config1] - The first configuration store.
|
|
117
|
+
* @param [config2] - The second configuration store.
|
|
118
|
+
* @returns - The merged configuration store.
|
|
119
|
+
*/
|
|
120
|
+
export declare const mergeConfigStores: <T extends object>(keys: (keyof T)[], config1?: ReadableSignals<T>, config2?: ReadableSignals<T>) => ReadableSignals<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Returns an object containing, for each property of `defConfig`, a corresponding writable with the normalization and default value logic
|
|
123
|
+
* described in {@link writableWithDefault}. Keys in the returned object are the same as the ones present in `defConfig`,
|
|
124
|
+
* with the exta `$` suffix (showing that they are stores).
|
|
125
|
+
*
|
|
126
|
+
* @template T - The type of the default configuration object.
|
|
127
|
+
*
|
|
128
|
+
* @param defConfig - object containing, for each property, a default value to use in case `config$` does not provide the suitable default
|
|
129
|
+
* value for that property
|
|
130
|
+
* @param propsConfig - object defining the config and props
|
|
131
|
+
* @param options - object containing, for each property of `defConfig`, an optional object with the following optional functions: normalizeValue and equal
|
|
132
|
+
* @returns an object containing writables
|
|
133
|
+
*
|
|
134
|
+
* @example With a store
|
|
135
|
+
* ```ts
|
|
136
|
+
* const defConfig = {propA: 1};
|
|
137
|
+
* const validation = {propA: {normalizeValue: value => +value}};
|
|
138
|
+
* const config = writable({propA: 5});
|
|
139
|
+
* const {propA$} = writablesWithDefault(defConfig, {config}, validation);
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example With an object containing a value and a store
|
|
143
|
+
* ```ts
|
|
144
|
+
* const defConfig = {propA: 1, propB: 2};
|
|
145
|
+
* const validation = {propA: {normalizeValue: value => +value}};
|
|
146
|
+
* const config = {propA: 5, propB: writable(3)};
|
|
147
|
+
* const {propA$, propB$} = writablesWithDefault(defConfig, {config}, validation);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare const writablesWithDefault: <T extends object>(defConfig: T, propsConfig?: PropsConfig<T>, options?: ConfigValidator<T>) => ToWritableSignal<T>;
|
|
151
|
+
/**
|
|
152
|
+
* Shortcut for calling both {@link writablesWithDefault} and {@link createPatch} in one call.
|
|
153
|
+
*
|
|
154
|
+
* @template T - The type of the properties configuration object.
|
|
155
|
+
* @param defConfig - object containing, for each property, a default value to use in case `config` does not provide the suitable default
|
|
156
|
+
* value for that property
|
|
157
|
+
* @param propsConfig - either a store of objects containing, for each property of `defConfig`, the default value or an object containing
|
|
158
|
+
* for each property of `defConfig` either a store containing the default value or the default value itself
|
|
159
|
+
* @param options - object containing, for each property of `defConfig`, an optional object with the following optional functions: normalizeValue and equal
|
|
160
|
+
* @returns an array with two items: the first one containing the writables (returned by {@link writablesWithDefault}),
|
|
161
|
+
* and the second one containing the patch function (returned by {@link createPatch})
|
|
162
|
+
*
|
|
163
|
+
* @example With a store
|
|
164
|
+
* ```ts
|
|
165
|
+
* const defConfig = {propA: 1};
|
|
166
|
+
* const validation = {propA: {normalizeValue: value => +value}};
|
|
167
|
+
* const config$ = writable({propA: 5});
|
|
168
|
+
* const [{propA$}, patch] = writablesForProps(defConfig, config$, validation);
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @example With an object containing a value and a store
|
|
172
|
+
* ```ts
|
|
173
|
+
* const defConfig = {propA: 1, propB: 2};
|
|
174
|
+
* const validation = {propA: {normalizeValue: value => +value}};
|
|
175
|
+
* const config = {propA: 5, propB: writable(3)};
|
|
176
|
+
* const [{propA$, propB$}, patch] = writablesForProps(defConfig, config, validation);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare const writablesForProps: <T extends object>(defConfig: T, propsConfig?: PropsConfig<T>, options?: { [K in keyof T]: WritableWithDefaultOptions<T[K]> | undefined; }) => [ToWritableSignal<T>, ReturnType<typeof createPatch<T>>];
|
|
180
|
+
/**
|
|
181
|
+
* Using input stores, this function builds an object containing the stores as readable and a global state.
|
|
182
|
+
*
|
|
183
|
+
* @template A - The type of the state object.
|
|
184
|
+
* @param inputStores - the input stores
|
|
185
|
+
* @returns the object containing the stores as readable and the global state
|
|
186
|
+
*/
|
|
187
|
+
export declare const stateStores: <A extends object>(inputStores: { [K in keyof A as `${K & string}$`]: ReadableSignal<any>; }) => {
|
|
188
|
+
state$: ReadableSignal<A>;
|
|
189
|
+
stores: { [K in keyof A as `${K & string}$`]: ReadableSignal<A[K]>; };
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Creates a writable signal that derives its value from multiple stores and allows for custom adjustment and equality checks.
|
|
193
|
+
*
|
|
194
|
+
* @template T - The type of the derived value.
|
|
195
|
+
* @template U - A tuple type where the first element is a writable signal of type T and the rest are store inputs.
|
|
196
|
+
*
|
|
197
|
+
* @param onChange$ - A readable signal that emits a function to be called when the derived value changes.
|
|
198
|
+
* @param stores - A tuple of stores where the first element is a writable signal of type T and the rest are store inputs.
|
|
199
|
+
* @param adjustValue - A function to adjust the derived value based on the input values from the stores.
|
|
200
|
+
* @param equal - A function to compare the current and new values for equality.
|
|
201
|
+
*
|
|
202
|
+
* @returns A writable signal that derives its value from the provided stores and allows for custom adjustment and equality checks.
|
|
203
|
+
*/
|
|
204
|
+
export declare const bindableDerived: <T, U extends [WritableSignal<T>, ...StoreInput<any>[]]>(onChange$: ReadableSignal<(value: T) => void>, stores: U, adjustValue?: (arg: StoresInputValues<U>) => T, equal?: (currentValue: T, newValue: T) => boolean) => WritableSignal<T>;
|
|
205
|
+
/**
|
|
206
|
+
* Creates a bindable property that synchronizes a writable signal with an optional adjustment function and equality check.
|
|
207
|
+
*
|
|
208
|
+
* @template T - The type of the value being stored.
|
|
209
|
+
* @param store$ - The writable signal that holds the current value.
|
|
210
|
+
* @param onChange$ - A readable signal that triggers a callback when the value changes.
|
|
211
|
+
* @param [adjustValue] - An optional function to adjust the value before storing it. Defaults to the identity function.
|
|
212
|
+
* @param [equal] - An optional function to compare values for equality. Defaults to `tansuDefaultEqual`.
|
|
213
|
+
* @returns A writable signal that synchronizes with the provided store and triggers the onChange callback when updated.
|
|
214
|
+
*/
|
|
215
|
+
export declare const bindableProp: <T>(store$: WritableSignal<T, T | undefined>, onChange$: ReadableSignal<(newValue: T) => void>, adjustValue?: (value: T) => T, equal?: (a: T, b: T) => boolean) => WritableSignal<T>;
|
|
216
|
+
/**
|
|
217
|
+
* Wraps an id store in a computed so that undefined and empty values are replaced by a generated id.
|
|
218
|
+
*
|
|
219
|
+
* @param id$ - the id store to use
|
|
220
|
+
* @returns the id store with a default generation if the id is not provided
|
|
221
|
+
*/
|
|
222
|
+
export declare function idWithDefault(id$: ReadableSignal<string>): ReadableSignal<string>;
|
|
223
|
+
export declare const true$: ReadableSignal<true>;
|
|
224
|
+
export declare const false$: ReadableSignal<false>;
|