@agnos-ui/core 0.4.3 → 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/utils/stores.d.ts
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import type { ReadableSignal, StoreInput, StoresInputValues, WritableSignal } from '@amadeus-it-group/tansu';
|
|
2
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
|
+
*/
|
|
3
8
|
export type ToWritableSignal<P> = {
|
|
4
9
|
[K in keyof P as `${K & string}$`]-?: WritableSignal<P[K], P[K] | undefined>;
|
|
5
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
|
+
*/
|
|
6
18
|
export type ReadableSignals<T extends object> = {
|
|
7
19
|
[K in keyof T]?: ReadableSignal<T[K] | undefined>;
|
|
8
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
|
+
*/
|
|
9
27
|
export type WithoutDollar<S extends `${string}$`> = S extends `${infer U}$` ? U : never;
|
|
10
28
|
/**
|
|
11
29
|
*
|
|
@@ -24,10 +42,11 @@ export type WithoutDollar<S extends `${string}$`> = S extends `${infer U}$` ? U
|
|
|
24
42
|
* patch({a: 2, c: 2}) // will perform storeA$.set(2), c is ignored.
|
|
25
43
|
*
|
|
26
44
|
* ```
|
|
27
|
-
* @
|
|
28
|
-
* @
|
|
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.
|
|
29
48
|
*/
|
|
30
|
-
export declare function createPatch<T extends object>(stores: ToWritableSignal<T>):
|
|
49
|
+
export declare function createPatch<T extends object>(stores: ToWritableSignal<T>): (storesValues: Partial<T>) => void;
|
|
31
50
|
/**
|
|
32
51
|
* This utility function is designed to compare the first level of two objects.
|
|
33
52
|
*
|
|
@@ -35,9 +54,10 @@ export declare function createPatch<T extends object>(stores: ToWritableSignal<T
|
|
|
35
54
|
* and `obj2` are different, with the values from `obj2`, or null if objects
|
|
36
55
|
* are identical.
|
|
37
56
|
*
|
|
38
|
-
* @
|
|
39
|
-
* @param
|
|
40
|
-
* @
|
|
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.
|
|
41
61
|
*/
|
|
42
62
|
export declare function findChangedProperties<T extends Record<string, any>>(obj1: Partial<T>, obj2: Partial<T>): Partial<T> | null;
|
|
43
63
|
/**
|
|
@@ -48,6 +68,8 @@ export declare function findChangedProperties<T extends Record<string, any>>(obj
|
|
|
48
68
|
* returns the `invalidValue` symbol), an error is logged on the console and it is either not set (if it comes from the
|
|
49
69
|
* `set` or `update` functions), or the `defValue` is used instead (if the invalid value comes from the `config$` store).
|
|
50
70
|
*
|
|
71
|
+
* @template T - The type of the value.
|
|
72
|
+
*
|
|
51
73
|
* @param defValue - Default value used when both the own value and the config$ value are undefined.
|
|
52
74
|
* @param config$ - Store containing the default value used when the own value is undefined
|
|
53
75
|
* @param options - Object which can contain the following optional functions: normalizeValue and equal
|
|
@@ -63,31 +85,37 @@ export declare function writableWithDefault<T>(defValue: T, config$?: ReadableSi
|
|
|
63
85
|
export declare const isStore: (x: any) => x is ReadableSignal<any>;
|
|
64
86
|
/**
|
|
65
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.
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
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.
|
|
68
91
|
*/
|
|
69
92
|
export declare const toReadableStore: <T>(x: ReadableSignal<T> | T) => ReadableSignal<T>;
|
|
70
93
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
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.
|
|
74
99
|
*/
|
|
75
|
-
export declare const toWritableStore: <T>(x: WritableSignal<T> | T) => WritableSignal<T
|
|
100
|
+
export declare const toWritableStore: <T>(x: WritableSignal<T> | T) => WritableSignal<T>;
|
|
76
101
|
/**
|
|
77
|
-
*
|
|
102
|
+
* Normalizes configuration stores by converting them into readable signals.
|
|
78
103
|
*
|
|
79
|
-
* @
|
|
80
|
-
* @param
|
|
81
|
-
* @
|
|
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.
|
|
82
108
|
*/
|
|
83
109
|
export declare const normalizeConfigStores: <T extends object>(keys: (keyof T)[], config?: ReadableSignal<Partial<T>> | ValuesOrReadableSignals<T>) => ReadableSignals<T>;
|
|
84
110
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @
|
|
89
|
-
* @param
|
|
90
|
-
* @
|
|
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.
|
|
91
119
|
*/
|
|
92
120
|
export declare const mergeConfigStores: <T extends object>(keys: (keyof T)[], config1?: ReadableSignals<T>, config2?: ReadableSignals<T>) => ReadableSignals<T>;
|
|
93
121
|
/**
|
|
@@ -95,6 +123,8 @@ export declare const mergeConfigStores: <T extends object>(keys: (keyof T)[], co
|
|
|
95
123
|
* described in {@link writableWithDefault}. Keys in the returned object are the same as the ones present in `defConfig`,
|
|
96
124
|
* with the exta `$` suffix (showing that they are stores).
|
|
97
125
|
*
|
|
126
|
+
* @template T - The type of the default configuration object.
|
|
127
|
+
*
|
|
98
128
|
* @param defConfig - object containing, for each property, a default value to use in case `config$` does not provide the suitable default
|
|
99
129
|
* value for that property
|
|
100
130
|
* @param propsConfig - object defining the config and props
|
|
@@ -120,6 +150,8 @@ export declare const mergeConfigStores: <T extends object>(keys: (keyof T)[], co
|
|
|
120
150
|
export declare const writablesWithDefault: <T extends object>(defConfig: T, propsConfig?: PropsConfig<T>, options?: ConfigValidator<T>) => ToWritableSignal<T>;
|
|
121
151
|
/**
|
|
122
152
|
* Shortcut for calling both {@link writablesWithDefault} and {@link createPatch} in one call.
|
|
153
|
+
*
|
|
154
|
+
* @template T - The type of the properties configuration object.
|
|
123
155
|
* @param defConfig - object containing, for each property, a default value to use in case `config` does not provide the suitable default
|
|
124
156
|
* value for that property
|
|
125
157
|
* @param propsConfig - either a store of objects containing, for each property of `defConfig`, the default value or an object containing
|
|
@@ -144,10 +176,11 @@ export declare const writablesWithDefault: <T extends object>(defConfig: T, prop
|
|
|
144
176
|
* const [{propA$, propB$}, patch] = writablesForProps(defConfig, config, validation);
|
|
145
177
|
* ```
|
|
146
178
|
*/
|
|
147
|
-
export declare const writablesForProps: <T extends object>(defConfig: T, propsConfig?: PropsConfig<T>, options?: { [K in keyof T]
|
|
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>>];
|
|
148
180
|
/**
|
|
149
181
|
* Using input stores, this function builds an object containing the stores as readable and a global state.
|
|
150
182
|
*
|
|
183
|
+
* @template A - The type of the state object.
|
|
151
184
|
* @param inputStores - the input stores
|
|
152
185
|
* @returns the object containing the stores as readable and the global state
|
|
153
186
|
*/
|
|
@@ -156,22 +189,27 @@ export declare const stateStores: <A extends object>(inputStores: { [K in keyof
|
|
|
156
189
|
stores: { [K in keyof A as `${K & string}$`]: ReadableSignal<A[K]>; };
|
|
157
190
|
};
|
|
158
191
|
/**
|
|
159
|
-
* Creates a
|
|
160
|
-
*
|
|
161
|
-
* @
|
|
162
|
-
* @
|
|
163
|
-
*
|
|
164
|
-
* @
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
|
|
177
|
-
|
|
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>;
|
package/utils/stores.js
CHANGED
|
@@ -5,7 +5,7 @@ function createPatch(stores) {
|
|
|
5
5
|
return function(storesValues) {
|
|
6
6
|
batch(() => {
|
|
7
7
|
var _a;
|
|
8
|
-
for (const [name, value] of Object.entries(storesValues
|
|
8
|
+
for (const [name, value] of Object.entries(storesValues)) {
|
|
9
9
|
(_a = stores[`${name}$`]) == null ? void 0 : _a.set(value);
|
|
10
10
|
}
|
|
11
11
|
});
|
package/utils/writables.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const utils_writables = require("../writables-
|
|
3
|
+
const utils_writables = require("../writables-BPAJvaL_.cjs");
|
|
4
4
|
require("../types.cjs");
|
|
5
|
+
exports.createTypeEnum = utils_writables.createTypeEnum;
|
|
5
6
|
exports.testToNormalizeValue = utils_writables.testToNormalizeValue;
|
|
6
7
|
exports.typeArray = utils_writables.typeArray;
|
|
7
8
|
exports.typeBoolean = utils_writables.typeBoolean;
|
package/utils/writables.d.ts
CHANGED
|
@@ -3,11 +3,20 @@ import { INVALID_VALUE } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Check if a value respects a provided type guard.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
6
|
+
* @template T - The type that the filter function validates.
|
|
7
|
+
* @param filter - A function that takes a value and returns a boolean indicating
|
|
8
|
+
* whether the value is of type T.
|
|
9
|
+
* @returns A function that takes a value and returns the value if it passes the filter,
|
|
10
|
+
* otherwise returns `INVALID_VALUE`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const testToNormalizeValue: <T>(filter: (value: any) => value is T) => ((value: any) => T | typeof INVALID_VALUE);
|
|
13
|
+
/**
|
|
14
|
+
* A writable object with default options for handling numbers.
|
|
8
15
|
*/
|
|
9
|
-
export declare const testToNormalizeValue: <T>(filter: (value: any) => value is T) => (value: any) => typeof INVALID_VALUE | T;
|
|
10
16
|
export declare const typeNumber: WritableWithDefaultOptions<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Options for specifying the behavior of number range validation.
|
|
19
|
+
*/
|
|
11
20
|
export interface TypeNumberInRangeOptions {
|
|
12
21
|
/** If `true`, the range checking will be strict, excluding the minimum and maximum values. Default is `false`. */
|
|
13
22
|
strict?: boolean;
|
|
@@ -24,9 +33,49 @@ export interface TypeNumberInRangeOptions {
|
|
|
24
33
|
* @returns A type guard function that returns the clamp value or INVALID_VALUE depending on the provided options.
|
|
25
34
|
*/
|
|
26
35
|
export declare function typeNumberInRangeFactory(min: number, max: number, options?: TypeNumberInRangeOptions): WritableWithDefaultOptions<number>;
|
|
36
|
+
/**
|
|
37
|
+
* A writable object with default options for boolean values.
|
|
38
|
+
*
|
|
39
|
+
* This object provides a normalized way to handle boolean values
|
|
40
|
+
* using the `WritableWithDefaultOptions` interface. The `normalizeValue`
|
|
41
|
+
* function ensures that the value is properly validated and normalized
|
|
42
|
+
* as a boolean.
|
|
43
|
+
*/
|
|
27
44
|
export declare const typeBoolean: WritableWithDefaultOptions<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* A writable with default options that normalizes its value to a boolean or null.
|
|
47
|
+
*
|
|
48
|
+
* This writable uses a normalization function that allows null values and ensures
|
|
49
|
+
* the value is a boolean.
|
|
50
|
+
*/
|
|
28
51
|
export declare const typeBooleanOrNull: WritableWithDefaultOptions<boolean | null>;
|
|
52
|
+
/**
|
|
53
|
+
* A writable object with default options for string values.
|
|
54
|
+
*
|
|
55
|
+
* This object provides a normalized value for strings using the `testToNormalizeValue` function
|
|
56
|
+
* with the `isString` validator.
|
|
57
|
+
*/
|
|
29
58
|
export declare const typeString: WritableWithDefaultOptions<string>;
|
|
59
|
+
/**
|
|
60
|
+
* A writable object that holds a function type with default options.
|
|
61
|
+
*/
|
|
30
62
|
export declare const typeFunction: WritableWithDefaultOptions<(...args: any[]) => any>;
|
|
63
|
+
/**
|
|
64
|
+
* A writable object with default options for handling values of type `HTMLElement` or `null`.
|
|
65
|
+
*
|
|
66
|
+
* This object provides:
|
|
67
|
+
* - `normalizeValue`: A function to normalize the value, ensuring it is either an `HTMLElement` or `null`.
|
|
68
|
+
* - `equal`: A function to compare two values for equality using `Object.is`.
|
|
69
|
+
*/
|
|
31
70
|
export declare const typeHTMLElementOrNull: WritableWithDefaultOptions<HTMLElement | null>;
|
|
71
|
+
/**
|
|
72
|
+
* A writable object with default options for handling arrays.
|
|
73
|
+
*/
|
|
32
74
|
export declare const typeArray: WritableWithDefaultOptions<any[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Build an enum normalizer
|
|
77
|
+
* @template T - the enum type
|
|
78
|
+
* @param enumList - list of enum values to check
|
|
79
|
+
* @returns the enum normalizer
|
|
80
|
+
*/
|
|
81
|
+
export declare function createTypeEnum<T>(enumList: T[]): WritableWithDefaultOptions<T>;
|
package/utils/writables.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t, h, c, d, f, g, a, b, e } from "../writables-
|
|
1
|
+
import { i, t, h, c, d, f, g, a, b, e } from "../writables-DCiBdIBK.js";
|
|
2
2
|
import "../types.js";
|
|
3
3
|
export {
|
|
4
|
+
i as createTypeEnum,
|
|
4
5
|
t as testToNormalizeValue,
|
|
5
6
|
h as typeArray,
|
|
6
7
|
c as typeBoolean,
|
|
@@ -18,6 +18,9 @@ function clamp(value, max, min = 0) {
|
|
|
18
18
|
}
|
|
19
19
|
const isHTMLElement = (value) => value instanceof HTMLElement;
|
|
20
20
|
const allowNull = (isType) => (value) => value === null || isType(value);
|
|
21
|
+
function isFromEnum(list) {
|
|
22
|
+
return (value) => list.includes(value);
|
|
23
|
+
}
|
|
21
24
|
const testToNormalizeValue = (filter) => (value) => filter(value) ? value : types.INVALID_VALUE;
|
|
22
25
|
const numberNormalizeFn = testToNormalizeValue(isNumber);
|
|
23
26
|
const typeNumber = {
|
|
@@ -72,7 +75,13 @@ const typeArray = {
|
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
};
|
|
78
|
+
function createTypeEnum(enumList) {
|
|
79
|
+
return {
|
|
80
|
+
normalizeValue: testToNormalizeValue(isFromEnum(enumList))
|
|
81
|
+
};
|
|
82
|
+
}
|
|
75
83
|
exports.clamp = clamp;
|
|
84
|
+
exports.createTypeEnum = createTypeEnum;
|
|
76
85
|
exports.isNumber = isNumber;
|
|
77
86
|
exports.testToNormalizeValue = testToNormalizeValue;
|
|
78
87
|
exports.typeArray = typeArray;
|
|
@@ -17,6 +17,9 @@ function clamp(value, max, min = 0) {
|
|
|
17
17
|
}
|
|
18
18
|
const isHTMLElement = (value) => value instanceof HTMLElement;
|
|
19
19
|
const allowNull = (isType) => (value) => value === null || isType(value);
|
|
20
|
+
function isFromEnum(list) {
|
|
21
|
+
return (value) => list.includes(value);
|
|
22
|
+
}
|
|
20
23
|
const testToNormalizeValue = (filter) => (value) => filter(value) ? value : INVALID_VALUE;
|
|
21
24
|
const numberNormalizeFn = testToNormalizeValue(isNumber);
|
|
22
25
|
const typeNumber = {
|
|
@@ -71,6 +74,11 @@ const typeArray = {
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
};
|
|
77
|
+
function createTypeEnum(enumList) {
|
|
78
|
+
return {
|
|
79
|
+
normalizeValue: testToNormalizeValue(isFromEnum(enumList))
|
|
80
|
+
};
|
|
81
|
+
}
|
|
74
82
|
export {
|
|
75
83
|
typeNumber as a,
|
|
76
84
|
typeNumberInRangeFactory as b,
|
|
@@ -80,7 +88,8 @@ export {
|
|
|
80
88
|
typeFunction as f,
|
|
81
89
|
typeHTMLElementOrNull as g,
|
|
82
90
|
typeArray as h,
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
createTypeEnum as i,
|
|
92
|
+
clamp as j,
|
|
93
|
+
isNumber as k,
|
|
85
94
|
testToNormalizeValue as t
|
|
86
95
|
};
|