@agnos-ui/core 0.4.4 → 0.5.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/README.md +2 -2
- package/{accordion-BnaSamoQ.js → accordion-BGv150k9.js} +10 -13
- package/{accordion-DmPT0O0j.cjs → accordion-Lp-LEbZ2.cjs} +10 -13
- package/{alert-CEFbEgvG.cjs → alert-Bq101evB.cjs} +1 -1
- package/{alert-DdGuK__c.js → alert-DJ2l7bcA.js} +1 -1
- package/{common-CO5b5G_J.js → common-Banw3FYN.js} +15 -14
- package/{common-nxv_hKNE.cjs → common-DvPjK7SS.cjs} +15 -14
- package/components/accordion/accordion.d.ts +35 -8
- package/components/accordion/index.cjs +1 -1
- package/components/accordion/index.js +1 -1
- package/components/alert/alert.d.ts +16 -1
- package/components/alert/common.d.ts +19 -1
- package/components/alert/index.cjs +1 -1
- package/components/alert/index.js +1 -1
- package/components/commonProps.d.ts +3 -0
- package/components/modal/index.cjs +1 -1
- package/components/modal/index.js +1 -1
- package/components/modal/modal.d.ts +3 -135
- package/components/pagination/index.cjs +1 -1
- package/components/pagination/index.js +1 -1
- package/components/pagination/pagination.d.ts +30 -217
- package/components/progressbar/index.cjs +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/progressbar/progressbar.d.ts +13 -3
- package/components/rating/index.cjs +1 -1
- package/components/rating/index.js +1 -1
- package/components/rating/rating.d.ts +26 -115
- package/components/select/index.cjs +1 -1
- package/components/select/index.js +1 -1
- package/components/select/select.d.ts +21 -148
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/components/slider/slider.d.ts +31 -126
- package/components/toast/index.cjs +1 -1
- package/components/toast/index.js +1 -1
- package/components/toast/toast.d.ts +16 -1
- package/config.d.ts +17 -1
- package/{directive-3-8yr-ZK.js → directive-CKEccryv.js} +11 -5
- package/{directive-j-xRk-h3.cjs → directive-DdlwGFtf.cjs} +11 -5
- package/index.cjs +13 -13
- package/index.js +15 -15
- package/{modal-D4d8sy85.cjs → modal-DDHcrykD.cjs} +10 -21
- package/{modal-CeTI4jxI.js → modal-DP-4I7vf.js} +11 -22
- package/package.json +6 -5
- package/{pagination-B9WFv70F.cjs → pagination-CBysiPUs.cjs} +23 -35
- package/{pagination-BpPHKQsH.js → pagination-DwDRot6q.js} +23 -35
- package/{progressbar-BybOg5FE.js → progressbar-CGmNq0cS.js} +3 -4
- package/{progressbar-DXCMeJvL.cjs → progressbar-DghzCJ6_.cjs} +3 -4
- package/{rating-D6Tv_4Vx.js → rating-Da38uaZz.js} +61 -54
- package/{rating-C2Y95r50.cjs → rating-DlfOuwuX.cjs} +61 -54
- package/{select-jUrt_lSn.js → select-CAEPqdz1.js} +92 -72
- package/{select-BBiF-m3N.cjs → select-LBVhNdrd.cjs} +92 -72
- package/services/extendWidget.d.ts +37 -4
- package/services/floatingUI.cjs +3 -2
- package/services/floatingUI.d.ts +28 -27
- package/services/floatingUI.js +3 -2
- package/services/focustrack.cjs +1 -1
- package/services/focustrack.d.ts +21 -0
- package/services/focustrack.js +1 -1
- package/services/hash.d.ts +2 -1
- package/services/intersection.cjs +1 -1
- package/services/intersection.d.ts +9 -13
- package/services/intersection.js +1 -1
- package/services/matchMedia.cjs +1 -1
- package/services/matchMedia.d.ts +2 -1
- package/services/matchMedia.js +1 -1
- package/services/navManager.cjs +1 -1
- package/services/navManager.d.ts +85 -41
- package/services/navManager.js +1 -1
- package/services/portal.cjs +1 -1
- package/services/portal.d.ts +3 -0
- package/services/portal.js +1 -1
- package/services/resizeObserver.cjs +2 -2
- package/services/resizeObserver.d.ts +2 -6
- package/services/resizeObserver.js +2 -2
- package/services/siblingsInert.cjs +3 -3
- package/services/siblingsInert.d.ts +3 -5
- package/services/siblingsInert.js +3 -3
- package/services/transitions/baseTransitions.cjs +4 -5
- package/services/transitions/baseTransitions.d.ts +21 -4
- package/services/transitions/baseTransitions.js +4 -5
- package/services/transitions/collapse.cjs +1 -1
- package/services/transitions/collapse.d.ts +6 -0
- package/services/transitions/collapse.js +1 -1
- package/services/transitions/cssTransitions.cjs +1 -1
- package/services/transitions/cssTransitions.d.ts +3 -0
- package/services/transitions/cssTransitions.js +1 -1
- package/services/transitions/simpleClassTransition.cjs +1 -1
- package/services/transitions/simpleClassTransition.d.ts +9 -2
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-ByDkbyr1.js → slider-DYrwS7Mv.js} +118 -116
- package/{slider-BdsZpxJr.cjs → slider-DlOAawbZ.cjs} +118 -116
- package/{toast-BzxextBQ.js → toast-CpvsibAI.js} +3 -3
- package/{toast-Dy3ck2cM.cjs → toast-D_uSrRZL.cjs} +3 -3
- package/types.cjs +0 -8
- package/types.d.ts +151 -19
- package/types.js +1 -9
- package/utils/directive.cjs +1 -1
- package/utils/directive.d.ts +81 -32
- package/utils/directive.js +1 -1
- package/utils/internal/checks.d.ts +6 -0
- package/utils/internal/dom.d.ts +5 -5
- package/utils/internal/promise.d.ts +9 -0
- package/utils/internal/sort.d.ts +2 -2
- package/utils/internal/ssrHTMLElement.d.ts +4 -0
- package/utils/stores.cjs +1 -1
- package/utils/stores.d.ts +80 -42
- package/utils/stores.js +1 -1
- package/utils/writables.cjs +2 -1
- package/utils/writables.d.ts +52 -3
- package/utils/writables.js +2 -1
- package/{writables-D46sFgGK.cjs → writables-BPAJvaL_.cjs} +9 -0
- package/{writables-DoU_XYTX.js → writables-DCiBdIBK.js} +11 -2
package/types.d.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import type { ReadableSignal, StoreOptions, SubscribableStore, WritableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
/**
|
|
3
|
+
* A type that maps each property of an object type `T` to either a `ReadableSignal` of that property type or the property type itself.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The object type whose properties are being mapped.
|
|
6
|
+
*/
|
|
2
7
|
export type ValuesOrReadableSignals<T extends object> = {
|
|
3
8
|
[K in keyof T]?: ReadableSignal<T[K] | undefined> | T[K];
|
|
4
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* A type that maps the properties of an object type `T` to either a `WritableSignal` of the property type or the property type itself.
|
|
12
|
+
*
|
|
13
|
+
* @template T - The object type whose properties are being mapped.
|
|
14
|
+
*/
|
|
5
15
|
export type ValuesOrWritableSignals<T extends object> = {
|
|
6
16
|
[K in keyof T]?: WritableSignal<T[K] | undefined> | T[K];
|
|
7
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Interface representing the configuration for properties.
|
|
20
|
+
*
|
|
21
|
+
* @template U - An object type representing the properties.
|
|
22
|
+
*/
|
|
8
23
|
export interface PropsConfig<U extends object> {
|
|
9
24
|
/**
|
|
10
25
|
* Object containing, for each property, either its initial value, or a store that will contain the value at any time.
|
|
@@ -17,7 +32,16 @@ export interface PropsConfig<U extends object> {
|
|
|
17
32
|
*/
|
|
18
33
|
config?: ReadableSignal<Partial<U>> | ValuesOrReadableSignals<Partial<U>>;
|
|
19
34
|
}
|
|
20
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Represents a generic widget with reactive state, stores, and various functionalities.
|
|
37
|
+
*
|
|
38
|
+
* @template Props - The type of the properties that can be passed to the widget.
|
|
39
|
+
* @template State - The type of the state managed by the widget.
|
|
40
|
+
* @template Api - The type of the API functions available for interacting with the widget.
|
|
41
|
+
* @template Actions - The type of the action handlers for user interactions.
|
|
42
|
+
* @template Directives - The type of the directives used in the widget's template.
|
|
43
|
+
*/
|
|
44
|
+
export interface Widget<Props extends object = object, State extends object = object, Api extends object = object, Directives extends object = object> {
|
|
21
45
|
/**
|
|
22
46
|
* the reactive state of the widget, combining all the values served by the stores
|
|
23
47
|
*/
|
|
@@ -36,47 +60,65 @@ export interface Widget<Props extends object = object, State extends object = ob
|
|
|
36
60
|
* directives to be used on html elements in the template of the widget or in the slots
|
|
37
61
|
*/
|
|
38
62
|
directives: Directives;
|
|
39
|
-
/**
|
|
40
|
-
* all the handlers that should be connected to user interactions i.e. click, keyboard and touch interactions.
|
|
41
|
-
* typically, the handlers are event listeners that call api functions to affect the widget state
|
|
42
|
-
*/
|
|
43
|
-
actions: Actions;
|
|
44
63
|
/**
|
|
45
64
|
* all the api functions to interact with the widget
|
|
46
65
|
*/
|
|
47
66
|
api: Api;
|
|
48
67
|
}
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Represents the context for a widget slot, providing access to the widget and its state.
|
|
70
|
+
*
|
|
71
|
+
* @template W - The type of the widget.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export interface WidgetSlotContext<W extends Widget> extends Pick<W, 'api' | 'directives'> {
|
|
51
75
|
/**
|
|
52
76
|
* the state of the widget
|
|
53
77
|
*/
|
|
54
78
|
state: WidgetState<W>;
|
|
55
|
-
/**
|
|
56
|
-
* the widget
|
|
57
|
-
*/
|
|
58
|
-
widget: ContextWidget<W>;
|
|
59
79
|
}
|
|
60
80
|
/**
|
|
61
|
-
*
|
|
81
|
+
* Extracts the state type from a widget type that contains a `state$` property.
|
|
62
82
|
*
|
|
63
|
-
* @
|
|
64
|
-
* @returns the
|
|
83
|
+
* @template T - A type that extends an object with a `state$` property of type `SubscribableStore<any>`.
|
|
84
|
+
* @returns The type of the state contained within the `state$` property if it extends an object, otherwise `never`.
|
|
65
85
|
*/
|
|
66
|
-
export declare const toSlotContextWidget: <W extends Widget>(w: W) => ContextWidget<W>;
|
|
67
86
|
export type WidgetState<T extends {
|
|
68
87
|
state$: SubscribableStore<any>;
|
|
69
88
|
}> = T extends {
|
|
70
89
|
state$: SubscribableStore<infer U extends object>;
|
|
71
90
|
} ? U : never;
|
|
91
|
+
/**
|
|
92
|
+
* Extracts the type of the argument expected by the `patch` method of a given type `T`.
|
|
93
|
+
*
|
|
94
|
+
* This utility type takes a generic type `T` which must have a `patch` method. The `patch` method
|
|
95
|
+
* should accept an argument that is a partial of some object type `U`. If `T` meets this condition,
|
|
96
|
+
* `WidgetProps` will resolve to the type `U`. Otherwise, it will resolve to `never`.
|
|
97
|
+
*
|
|
98
|
+
* @template T - A type that includes a `patch` method accepting a partial object.
|
|
99
|
+
*/
|
|
72
100
|
export type WidgetProps<T extends {
|
|
73
101
|
patch: (arg: any) => void;
|
|
74
102
|
}> = T extends {
|
|
75
103
|
patch: (arg: Partial<infer U extends object>) => void;
|
|
76
104
|
} ? U : never;
|
|
105
|
+
/**
|
|
106
|
+
* A factory function type for creating instances of a widget.
|
|
107
|
+
*
|
|
108
|
+
* @template W - The type of the widget that extends the base Widget type.
|
|
109
|
+
* @param props - Optional configuration properties for the widget.
|
|
110
|
+
* @returns An instance of the widget.
|
|
111
|
+
*/
|
|
77
112
|
export type WidgetFactory<W extends Widget> = (props?: PropsConfig<WidgetProps<W>>) => W;
|
|
78
113
|
/**
|
|
79
|
-
*
|
|
114
|
+
* Represents a server-side rendered HTML element with limited functionality.
|
|
115
|
+
*
|
|
116
|
+
* This interface extends a subset of the {@link HTMLElement} interface, providing
|
|
117
|
+
* methods to set and remove attributes, manipulate the element's classes, and
|
|
118
|
+
* partially manipulate the element's style.
|
|
119
|
+
*
|
|
120
|
+
* It inherits the {@link https://developer.mozilla.org/docs/Web/API/Element/setAttribute | setAttribute} and {@link https://developer.mozilla.org/docs/Web/API/Element/getAttribute | getAttribute} methods from the {@link HTMLElement} interface.
|
|
121
|
+
*
|
|
80
122
|
*/
|
|
81
123
|
export interface SSRHTMLElement extends Pick<HTMLElement, 'setAttribute' | 'removeAttribute'> {
|
|
82
124
|
/**
|
|
@@ -88,20 +130,72 @@ export interface SSRHTMLElement extends Pick<HTMLElement, 'setAttribute' | 'remo
|
|
|
88
130
|
*/
|
|
89
131
|
style: Partial<Record<StyleKey, StyleValue>>;
|
|
90
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Represents a directive function that can be applied to an SSRHTMLElement.
|
|
135
|
+
*
|
|
136
|
+
* @template T - The type of the arguments passed to the directive.
|
|
137
|
+
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
138
|
+
*
|
|
139
|
+
* @param node - The SSRHTMLElement to which the directive is applied.
|
|
140
|
+
* @param args - The arguments passed to the directive.
|
|
141
|
+
*
|
|
142
|
+
* @returns An optional object that may contain:
|
|
143
|
+
* - `update`: A function to update the directive with new arguments.
|
|
144
|
+
* - `destroy`: A function to clean up when the directive is no longer needed.
|
|
145
|
+
*/
|
|
91
146
|
export type Directive<T = void, U extends SSRHTMLElement = SSRHTMLElement> = (node: U, args: T) => void | {
|
|
92
147
|
update?: (args: T) => void;
|
|
93
148
|
destroy?: () => void;
|
|
94
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* Represents a tuple containing a directive and its associated parameter.
|
|
152
|
+
*
|
|
153
|
+
* @template T - The type of the parameter associated with the directive.
|
|
154
|
+
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
155
|
+
*/
|
|
95
156
|
export type DirectiveAndParam<T, U extends SSRHTMLElement = SSRHTMLElement> = [Directive<T, U>, T];
|
|
157
|
+
/**
|
|
158
|
+
* Represents a mapping of directives and their optional parameters.
|
|
159
|
+
*
|
|
160
|
+
* @template T - An array type representing the parameters for the directives.
|
|
161
|
+
* @template U - The type of the SSR HTML element, defaults to `SSRHTMLElement`.
|
|
162
|
+
*/
|
|
96
163
|
export type DirectivesAndOptParam<T extends any[], U extends SSRHTMLElement = SSRHTMLElement> = {
|
|
97
164
|
[K in keyof T]: Directive<void, U> | DirectiveAndParam<T[K], U>;
|
|
98
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* Represents the content that can be used in a slot.
|
|
168
|
+
* The content can be one of the following:
|
|
169
|
+
* - `undefined`
|
|
170
|
+
* - `null`
|
|
171
|
+
* - A `string`
|
|
172
|
+
* - A function that takes `props` of type `Props` and returns a `string`
|
|
173
|
+
*/
|
|
99
174
|
export type SlotContent<Props extends object = object> = undefined | null | string | ((props: Props) => string);
|
|
175
|
+
/**
|
|
176
|
+
* A unique symbol representing an invalid value.
|
|
177
|
+
* This can be used as a sentinel value to indicate that a variable or property
|
|
178
|
+
* does not hold a valid value.
|
|
179
|
+
*/
|
|
100
180
|
export declare const INVALID_VALUE: unique symbol;
|
|
181
|
+
/**
|
|
182
|
+
* A type alias for a function that normalizes a value of type `T`.
|
|
183
|
+
* The function takes a value of type `T` and returns either a normalized value of type `T`
|
|
184
|
+
* or a special constant `INVALID_VALUE` indicating that the value is invalid.
|
|
185
|
+
*
|
|
186
|
+
* @template T - The type of the value to be normalized.
|
|
187
|
+
* @param value - The value to be normalized.
|
|
188
|
+
* @returns The normalized value of type `T` or `INVALID_VALUE` if the value is invalid.
|
|
189
|
+
*/
|
|
101
190
|
export type NormalizeValue<T> = (value: T) => T | typeof INVALID_VALUE;
|
|
191
|
+
/**
|
|
192
|
+
* Interface representing options for a writable store with default values.
|
|
193
|
+
*
|
|
194
|
+
* @template T - The type of the value stored.
|
|
195
|
+
*/
|
|
102
196
|
export interface WritableWithDefaultOptions<T> {
|
|
103
197
|
/**
|
|
104
|
-
* the normalize value function. should return the
|
|
198
|
+
* the normalize value function. should return the {@link INVALID_VALUE} symbol when the provided value is invalid
|
|
105
199
|
*/
|
|
106
200
|
normalizeValue?: NormalizeValue<T>;
|
|
107
201
|
/**
|
|
@@ -109,11 +203,49 @@ export interface WritableWithDefaultOptions<T> {
|
|
|
109
203
|
*/
|
|
110
204
|
equal?: StoreOptions<T>['equal'];
|
|
111
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Represents a type that validates a configuration object.
|
|
208
|
+
*
|
|
209
|
+
* @template T - The type of the configuration object to be validated.
|
|
210
|
+
*
|
|
211
|
+
* This type maps each key of the configuration object `T` to an optional
|
|
212
|
+
* `WritableWithDefaultOptions` type, allowing for partial validation.
|
|
213
|
+
*/
|
|
112
214
|
export type ConfigValidator<T extends object> = {
|
|
113
|
-
[K in keyof T]
|
|
215
|
+
[K in keyof T]: WritableWithDefaultOptions<T[K]> | undefined;
|
|
114
216
|
};
|
|
217
|
+
/**
|
|
218
|
+
* Represents a value that can be assigned to an attribute.
|
|
219
|
+
*/
|
|
115
220
|
export type AttributeValue = string | number | boolean | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Represents a key of the CSSStyleDeclaration interface, excluding certain properties and methods.
|
|
223
|
+
*
|
|
224
|
+
* This is useful for scenarios where you need to work with CSS properties directly without
|
|
225
|
+
* dealing with the methods and other non-style properties of CSSStyleDeclaration.
|
|
226
|
+
*/
|
|
116
227
|
export type StyleKey = Exclude<keyof CSSStyleDeclaration, 'length' | 'item' | 'parentRule' | 'getPropertyValue' | 'getPropertyPriority' | 'setProperty' | 'removeProperty' | typeof Symbol.iterator | number | 'cssText'>;
|
|
228
|
+
/**
|
|
229
|
+
* Represents a value that can be used for styling purposes.
|
|
230
|
+
* @remarks
|
|
231
|
+
* This type can be a string representing a style value, or it can be undefined or null.
|
|
232
|
+
* It is useful for scenarios where a style value might be optional or not set.
|
|
233
|
+
*/
|
|
117
234
|
export type StyleValue = string | undefined | null;
|
|
235
|
+
/**
|
|
236
|
+
* A conditional type that checks if type `T` extends type `U`.
|
|
237
|
+
* @template T - The type to check.
|
|
238
|
+
* @template U - The type to check against.
|
|
239
|
+
* @returns `1` if `T` extends `U`, otherwise `0`.
|
|
240
|
+
*/
|
|
118
241
|
export type Extends<T, U> = T extends U ? 1 : 0;
|
|
242
|
+
/**
|
|
243
|
+
* Type utility to determine if a given type `T` is or extends `SlotContent<any>`.
|
|
244
|
+
*
|
|
245
|
+
* This utility uses conditional types to check if `T` extends `SlotContent<any>` or if `SlotContent<any>` extends `T`.
|
|
246
|
+
* If either condition is true, it returns `T`, otherwise it returns `0`.
|
|
247
|
+
*
|
|
248
|
+
* @template T - The type to be checked.
|
|
249
|
+
* @returns `T` if `T` is or extends `SlotContent<any>`, otherwise `0`.
|
|
250
|
+
*/
|
|
119
251
|
export type IsSlotContent<T> = Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0;
|
package/types.js
CHANGED
package/utils/directive.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("@amadeus-it-group/tansu");
|
|
4
4
|
require("esm-env");
|
|
5
|
-
const utils_directive = require("../directive-
|
|
5
|
+
const utils_directive = require("../directive-DdlwGFtf.cjs");
|
|
6
6
|
require("../func-Qd3cD9a3.cjs");
|
|
7
7
|
require("./stores.cjs");
|
|
8
8
|
exports.attributesData = utils_directive.attributesData;
|
package/utils/directive.d.ts
CHANGED
|
@@ -8,9 +8,14 @@ import type { AttributeValue, Directive, DirectivesAndOptParam, SSRHTMLElement,
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const isBrowserHTMLElement: (element: SSRHTMLElement) => element is HTMLElement;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* A higher-order directive function that conditionally applies a directive based on the environment.
|
|
12
|
+
* If running in a browser environment, it applies the given directive to the node.
|
|
13
|
+
* If not in a browser environment, it returns a no-op function.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type of the directive's argument.
|
|
16
|
+
* @template U - The type of the HTML element the directive is applied to.
|
|
17
|
+
* @param directive - The directive to be conditionally applied.
|
|
18
|
+
* @returns - A directive that applies the given directive in a browser environment, or a no-op in a non-browser environment.
|
|
14
19
|
*/
|
|
15
20
|
export declare const browserDirective: <T, U extends HTMLElement>(directive: Directive<T, U>) => Directive<T, SSRHTMLElement>;
|
|
16
21
|
/**
|
|
@@ -22,25 +27,33 @@ export declare const browserDirective: <T, U extends HTMLElement>(directive: Dir
|
|
|
22
27
|
* and will call the provided directive with the content of the provided store as its argument,
|
|
23
28
|
* calling its update method when the content of the store changes.
|
|
24
29
|
*
|
|
25
|
-
* @
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
30
|
+
* @template T - The type of the directive argument.
|
|
31
|
+
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
32
|
+
* @param directive - The directive to bind to the element.
|
|
33
|
+
* @param directiveArg$ - The signal to subscribe to for directive updates.
|
|
34
|
+
* @returns A directive that manages the lifecycle of the bound directive.
|
|
28
35
|
*/
|
|
29
36
|
export declare const bindDirective: <T, U extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<T, U>, directiveArg$: ReadableSignal<T>) => Directive<void, U>;
|
|
30
37
|
/**
|
|
31
38
|
* Returns a directive that ignores any argument passed to it and calls the provided directive without any
|
|
32
39
|
* argument.
|
|
33
40
|
*
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
41
|
+
* @template T - The type of the directive's argument.
|
|
42
|
+
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
43
|
+
* @param directive - The directive to bind without arguments.
|
|
44
|
+
* @returns A new directive that does not require any arguments.
|
|
36
45
|
*/
|
|
37
|
-
export declare const bindDirectiveNoArg: <T, U extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<T
|
|
46
|
+
export declare const bindDirectiveNoArg: <T, U extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<T, U>) => Directive<void, U>;
|
|
38
47
|
/**
|
|
39
|
-
* Maps the argument
|
|
48
|
+
* Maps the argument of a directive to a new value using a provided function.
|
|
49
|
+
*
|
|
50
|
+
* @template T - The type of the original argument.
|
|
51
|
+
* @template U - The type of the mapped argument.
|
|
52
|
+
* @template V - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
40
53
|
*
|
|
41
|
-
* @param directive - The directive to be
|
|
42
|
-
* @param fn - The function to map the argument.
|
|
43
|
-
* @returns A new directive
|
|
54
|
+
* @param directive - The original directive to be mapped.
|
|
55
|
+
* @param fn - The function to map the original argument to the new argument.
|
|
56
|
+
* @returns A new directive with the mapped argument.
|
|
44
57
|
*/
|
|
45
58
|
export declare const mapDirectiveArg: <T, U, V extends SSRHTMLElement = SSRHTMLElement>(directive: Directive<U, V>, fn: (arg: T) => U) => Directive<T, V>;
|
|
46
59
|
/**
|
|
@@ -57,13 +70,19 @@ export declare const directiveSubscribe: (store: ReadableSignal<any>, asyncUnsub
|
|
|
57
70
|
* Returns a directive that calls the provided function with the arguments passed to the directive
|
|
58
71
|
* on initialization and each time they are updated.
|
|
59
72
|
*
|
|
73
|
+
* @template T - The type of the argument that the update function accepts.
|
|
60
74
|
* @param update - Function called with the directive argument when the directive is initialized and when its argument is updated.
|
|
61
75
|
* @returns The resulting directive.
|
|
62
76
|
*/
|
|
63
77
|
export declare const directiveUpdate: <T>(update: (arg: T) => void) => Directive<T>;
|
|
64
78
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
79
|
+
* Creates a registration array that allows elements to be added and removed.
|
|
80
|
+
*
|
|
81
|
+
* @template T - The type of elements in the array.
|
|
82
|
+
* @returns An object that includes a readable signal of the array and a register function.
|
|
83
|
+
*
|
|
84
|
+
* The returned object has the following properties:
|
|
85
|
+
* - `register`: A function to add an element to the array. It takes an element of type `T` as a parameter and returns a function to remove the element from the array.
|
|
67
86
|
*/
|
|
68
87
|
export declare const registrationArray: <T>() => ReadableSignal<T[]> & {
|
|
69
88
|
register: (element: T) => () => void;
|
|
@@ -154,16 +173,28 @@ export declare const createBrowserStoreDirective: () => {
|
|
|
154
173
|
* All calls to the directives (to create, update and destroy them) are wrapped in a call to the
|
|
155
174
|
* batch function of tansu
|
|
156
175
|
*
|
|
157
|
-
* @
|
|
158
|
-
* @
|
|
176
|
+
* @template T - The type of the argument passed to the directive.
|
|
177
|
+
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
178
|
+
* @param args - The directives to merge.
|
|
179
|
+
* @returns A new directive that applies all the given directives.
|
|
180
|
+
*
|
|
181
|
+
* The returned directive has the following lifecycle methods:
|
|
182
|
+
* - `update(arg)`: Updates all merged directives with the given argument.
|
|
183
|
+
* - `destroy()`: Destroys all merged directives in reverse order.
|
|
159
184
|
*/
|
|
160
185
|
export declare const mergeDirectives: <T, U extends SSRHTMLElement = SSRHTMLElement>(...args: (Directive<T, U> | Directive<void, U>)[]) => Directive<T, U>;
|
|
161
186
|
/**
|
|
162
|
-
*
|
|
187
|
+
* Applies multiple directives to a given SSRHTMLElement and provides methods to update or destroy them.
|
|
163
188
|
*
|
|
164
|
-
* @
|
|
165
|
-
* @
|
|
166
|
-
*
|
|
189
|
+
* @template T - A tuple type representing the arguments for each directive.
|
|
190
|
+
* @template U - The type of the SSRHTMLElement, defaults to SSRHTMLElement.
|
|
191
|
+
*
|
|
192
|
+
* @param element - The SSRHTMLElement to which the directives will be applied.
|
|
193
|
+
* @param directives - An array of directives and their optional parameters.
|
|
194
|
+
*
|
|
195
|
+
* @returns An object containing:
|
|
196
|
+
* - `update`: A function to update the directives with new parameters.
|
|
197
|
+
* - `destroy`: A function to destroy all applied directives.
|
|
167
198
|
*/
|
|
168
199
|
export declare const multiDirective: <T extends any[], U extends SSRHTMLElement = SSRHTMLElement>(element: U, directives: DirectivesAndOptParam<T, U>) => {
|
|
169
200
|
update: (directives: DirectivesAndOptParam<any[], U>) => void;
|
|
@@ -177,6 +208,7 @@ export interface AttributesDirectiveProps {
|
|
|
177
208
|
* Events to be attached to an HTML element.
|
|
178
209
|
* @remarks
|
|
179
210
|
* Key-value pairs where keys are event types and values are event handlers.
|
|
211
|
+
xw
|
|
180
212
|
*/
|
|
181
213
|
events?: Partial<{
|
|
182
214
|
[K in keyof HTMLElementEventMap]: {
|
|
@@ -204,12 +236,17 @@ export interface AttributesDirectiveProps {
|
|
|
204
236
|
classNames?: Record<string, boolean | ReadableSignal<boolean>>;
|
|
205
237
|
}
|
|
206
238
|
/**
|
|
207
|
-
* Creates a directive
|
|
208
|
-
*
|
|
239
|
+
* Creates a directive that binds attributes, styles, class names, and events to a DOM node.
|
|
240
|
+
*
|
|
241
|
+
* @template T - The type of the arguments passed to the directive.
|
|
242
|
+
* @param propsFn - A function that takes a readable signal of type `T` and returns an object containing
|
|
243
|
+
* attributes, styles, class names, and events to bind to the node.
|
|
244
|
+
* @returns A directive function that can be used to bind the specified properties to a DOM node.
|
|
209
245
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
246
|
+
* The returned directive function takes a DOM node and arguments of type `T`, and sets up the bindings
|
|
247
|
+
* specified by the `propsFn` function. It returns an object with `update` and `destroy` methods:
|
|
248
|
+
* - `update(args: T)`: Updates the arguments passed to the directive.
|
|
249
|
+
* - `destroy()`: Cleans up all bindings and event listeners.
|
|
213
250
|
*/
|
|
214
251
|
export declare const createAttributesDirective: <T = void>(propsFn: (arg: ReadableSignal<T>) => AttributesDirectiveProps) => Directive<T>;
|
|
215
252
|
/**
|
|
@@ -219,6 +256,7 @@ export declare const createAttributesDirective: <T = void>(propsFn: (arg: Readab
|
|
|
219
256
|
* - The `classNames` value is an array of string representing the classes to be applied
|
|
220
257
|
* - The `style` value is a JSON representation of the styles to be applied
|
|
221
258
|
*
|
|
259
|
+
* @template T - The type of the directives array.
|
|
222
260
|
* @param directives - List of directives to generate attributes from. Each parameter can be the directive or an array with the directive and its parameter
|
|
223
261
|
* @returns JSON object with the `attributes`, `class` and `style` keys.
|
|
224
262
|
*/
|
|
@@ -232,15 +270,26 @@ export declare const attributesData: <T extends any[]>(...directives: Directives
|
|
|
232
270
|
*/
|
|
233
271
|
export declare const classDirective: Directive<string>;
|
|
234
272
|
/**
|
|
235
|
-
*
|
|
273
|
+
* Combines multiple directives into a single attributes object.
|
|
236
274
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
275
|
+
* This function processes an array of directives and optional parameters,
|
|
276
|
+
* extracting attributes, class names, and styles. It then combines these
|
|
277
|
+
* into a single attributes object, where class names are joined into a
|
|
278
|
+
* single string and styles are formatted as a CSS string.
|
|
279
|
+
*
|
|
280
|
+
* @template T - The type of the directives and optional parameters.
|
|
281
|
+
* @param directives - The directives and optional parameters to process.
|
|
282
|
+
* @returns An object containing the combined attributes.
|
|
239
283
|
*/
|
|
240
284
|
export declare function directiveAttributes<T extends any[]>(...directives: DirectivesAndOptParam<T>): Record<string, string>;
|
|
241
285
|
/**
|
|
242
|
-
*
|
|
286
|
+
* Generates a record of SSR (Server-Side Rendering) attributes based on the provided directives.
|
|
287
|
+
*
|
|
288
|
+
* This function behaves differently depending on the environment:
|
|
289
|
+
* - In a browser environment (`BROWSER` is true), it returns an empty object.
|
|
290
|
+
* - In a non-browser environment, it delegates to the `directiveAttributes` function.
|
|
243
291
|
*
|
|
244
|
-
* @
|
|
292
|
+
* @template T - A tuple type representing the directives and optional parameters.
|
|
293
|
+
* @returns A record of SSR attributes.
|
|
245
294
|
*/
|
|
246
|
-
export declare const ssrAttributes: (
|
|
295
|
+
export declare const ssrAttributes: <T extends any[]>(...directives: DirectivesAndOptParam<T>) => Record<string, string>;
|
package/utils/directive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@amadeus-it-group/tansu";
|
|
2
2
|
import "esm-env";
|
|
3
|
-
import { o, a, c, b, p, n, g, j, f, h, q, d, e, i, m, k, l, r, s } from "../directive-
|
|
3
|
+
import { o, a, c, b, p, n, g, j, f, h, q, d, e, i, m, k, l, r, s } from "../directive-CKEccryv.js";
|
|
4
4
|
import "../func-DR0n-ShK.js";
|
|
5
5
|
import "./stores.js";
|
|
6
6
|
export {
|
|
@@ -47,3 +47,9 @@ export declare const isHTMLElement: (value: any) => value is HTMLElement;
|
|
|
47
47
|
* @returns A type guard function that returns true for null values and calls the provided type guard for other values.
|
|
48
48
|
*/
|
|
49
49
|
export declare const allowNull: <T>(isType: (value: any) => value is T) => (value: any) => value is T | null;
|
|
50
|
+
/**
|
|
51
|
+
* Builds a new type guard to check if an element belongs to an enum list
|
|
52
|
+
* @param list - the list of all enum values
|
|
53
|
+
* @returns the type guard
|
|
54
|
+
*/
|
|
55
|
+
export declare function isFromEnum<T>(list: T[]): (value: any) => value is T;
|
package/utils/internal/dom.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
1
|
+
import type { ReadableSignal, UnsubscribeFunction, UnsubscribeObject } from '@amadeus-it-group/tansu';
|
|
2
2
|
import type { AttributeValue, SSRHTMLElement, StyleKey, StyleValue } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Returns the common ancestor of the provided DOM elements.
|
|
@@ -7,7 +7,7 @@ import type { AttributeValue, SSRHTMLElement, StyleKey, StyleValue } from '../..
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const computeCommonAncestor: (elements: HTMLElement[]) => HTMLElement | null;
|
|
9
9
|
/**
|
|
10
|
-
* Launch a reflow using a call to the provided html element
|
|
10
|
+
* Launch a reflow using a call to the provided html element getBoundingClientRect
|
|
11
11
|
* @param element - the html element
|
|
12
12
|
*/
|
|
13
13
|
export declare const reflow: (element?: SSRHTMLElement) => void;
|
|
@@ -15,7 +15,7 @@ export declare const reflow: (element?: SSRHTMLElement) => void;
|
|
|
15
15
|
* Attach the given css classes to the element
|
|
16
16
|
*
|
|
17
17
|
* @param element - the HTML element
|
|
18
|
-
* @param classes - the css
|
|
18
|
+
* @param classes - the css classes
|
|
19
19
|
*/
|
|
20
20
|
export declare const addClasses: (element: SSRHTMLElement, classes?: string[]) => void;
|
|
21
21
|
/**
|
|
@@ -53,7 +53,7 @@ export declare const generateId: () => string;
|
|
|
53
53
|
*
|
|
54
54
|
* @returns unsubscription method to remove the binding
|
|
55
55
|
*/
|
|
56
|
-
export declare function bindAttribute(node: SSRHTMLElement, attributeName: string, value$: ReadableSignal<AttributeValue>):
|
|
56
|
+
export declare function bindAttribute(node: SSRHTMLElement, attributeName: string, value$: ReadableSignal<AttributeValue>): UnsubscribeFunction & UnsubscribeObject;
|
|
57
57
|
/**
|
|
58
58
|
* Binds a value from a `ReadableSignal` to the specified CSS style property of an HTML element.
|
|
59
59
|
* When the value emitted by the signal changes, it updates the style property accordingly.
|
|
@@ -65,7 +65,7 @@ export declare function bindAttribute(node: SSRHTMLElement, attributeName: strin
|
|
|
65
65
|
*
|
|
66
66
|
* @returns unsubscription method to remove the binding
|
|
67
67
|
*/
|
|
68
|
-
export declare function bindStyle(node: SSRHTMLElement, styleName: StyleKey, value$: ReadableSignal<StyleValue>):
|
|
68
|
+
export declare function bindStyle(node: SSRHTMLElement, styleName: StyleKey, value$: ReadableSignal<StyleValue>): UnsubscribeFunction & UnsubscribeObject;
|
|
69
69
|
/**
|
|
70
70
|
* Binds a `ReadableSignal` of boolean to the specified className of an HTML element.
|
|
71
71
|
* The className is added when the value is true, removed otherwise
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the result of a promise that is still pending.
|
|
4
|
+
*/
|
|
2
5
|
export interface PromisePendingResult {
|
|
3
6
|
/** Pending status */
|
|
4
7
|
status: 'pending';
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A constant representing a pending promise result.
|
|
11
|
+
*/
|
|
6
12
|
export declare const promisePending: PromisePendingResult;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the state of a promise, which can be either fulfilled, rejected, or pending.
|
|
15
|
+
*/
|
|
7
16
|
export type PromiseState<T> = PromiseFulfilledResult<T> | PromiseRejectedResult | PromisePendingResult;
|
|
8
17
|
/**
|
|
9
18
|
* Create a readable promise state store from a promise.
|
package/utils/internal/sort.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* @param b - the second input
|
|
6
6
|
* @returns 1, 0 or -1 depending on the default compare
|
|
7
7
|
*/
|
|
8
|
-
export declare const compareDefault: (a: any, b: any) =>
|
|
8
|
+
export declare const compareDefault: (a: any, b: any) => -1 | 0 | 1;
|
|
9
9
|
/**
|
|
10
|
-
* A comparision function between DOM elements, based on
|
|
10
|
+
* A comparision function between DOM elements, based on {@link https://developer.mozilla.org/fr/docs/Web/API/Node/compareDocumentPosition | Node.compareDocumentPosition}.
|
|
11
11
|
*
|
|
12
12
|
* @param element1 - the first node
|
|
13
13
|
* @param element2 - the second node
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { SSRHTMLElement } 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
|
+
*/
|
|
2
6
|
export declare const ssrHTMLElementAttributesAndStyle: unique symbol;
|
|
3
7
|
/**
|
|
4
8
|
* Create an SSRHTMLElement
|
package/utils/stores.cjs
CHANGED
|
@@ -7,7 +7,7 @@ function createPatch(stores) {
|
|
|
7
7
|
return function(storesValues) {
|
|
8
8
|
tansu.batch(() => {
|
|
9
9
|
var _a;
|
|
10
|
-
for (const [name, value] of Object.entries(storesValues
|
|
10
|
+
for (const [name, value] of Object.entries(storesValues)) {
|
|
11
11
|
(_a = stores[`${name}$`]) == null ? void 0 : _a.set(value);
|
|
12
12
|
}
|
|
13
13
|
});
|