@agnos-ui/core 0.4.4 → 0.5.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.
Files changed (113) hide show
  1. package/README.md +2 -2
  2. package/{accordion-BnaSamoQ.js → accordion-BGv150k9.js} +10 -13
  3. package/{accordion-DmPT0O0j.cjs → accordion-Lp-LEbZ2.cjs} +10 -13
  4. package/{alert-CEFbEgvG.cjs → alert-Bq101evB.cjs} +1 -1
  5. package/{alert-DdGuK__c.js → alert-DJ2l7bcA.js} +1 -1
  6. package/{common-CO5b5G_J.js → common-Banw3FYN.js} +15 -14
  7. package/{common-nxv_hKNE.cjs → common-DvPjK7SS.cjs} +15 -14
  8. package/components/accordion/accordion.d.ts +35 -8
  9. package/components/accordion/index.cjs +1 -1
  10. package/components/accordion/index.js +1 -1
  11. package/components/alert/alert.d.ts +16 -1
  12. package/components/alert/common.d.ts +19 -1
  13. package/components/alert/index.cjs +1 -1
  14. package/components/alert/index.js +1 -1
  15. package/components/commonProps.d.ts +3 -0
  16. package/components/modal/index.cjs +1 -1
  17. package/components/modal/index.js +1 -1
  18. package/components/modal/modal.d.ts +3 -135
  19. package/components/pagination/index.cjs +1 -1
  20. package/components/pagination/index.js +1 -1
  21. package/components/pagination/pagination.d.ts +30 -217
  22. package/components/progressbar/index.cjs +1 -1
  23. package/components/progressbar/index.js +1 -1
  24. package/components/progressbar/progressbar.d.ts +13 -3
  25. package/components/rating/index.cjs +1 -1
  26. package/components/rating/index.js +1 -1
  27. package/components/rating/rating.d.ts +26 -115
  28. package/components/select/index.cjs +1 -1
  29. package/components/select/index.js +1 -1
  30. package/components/select/select.d.ts +21 -148
  31. package/components/slider/index.cjs +1 -1
  32. package/components/slider/index.js +1 -1
  33. package/components/slider/slider.d.ts +31 -126
  34. package/components/toast/index.cjs +1 -1
  35. package/components/toast/index.js +1 -1
  36. package/components/toast/toast.d.ts +16 -1
  37. package/config.d.ts +17 -1
  38. package/{directive-3-8yr-ZK.js → directive-CKEccryv.js} +11 -5
  39. package/{directive-j-xRk-h3.cjs → directive-DdlwGFtf.cjs} +11 -5
  40. package/index.cjs +13 -13
  41. package/index.js +15 -15
  42. package/{modal-D4d8sy85.cjs → modal-DDHcrykD.cjs} +10 -21
  43. package/{modal-CeTI4jxI.js → modal-DP-4I7vf.js} +11 -22
  44. package/package.json +6 -5
  45. package/{pagination-B9WFv70F.cjs → pagination-CBysiPUs.cjs} +23 -35
  46. package/{pagination-BpPHKQsH.js → pagination-DwDRot6q.js} +23 -35
  47. package/{progressbar-BybOg5FE.js → progressbar-CGmNq0cS.js} +3 -4
  48. package/{progressbar-DXCMeJvL.cjs → progressbar-DghzCJ6_.cjs} +3 -4
  49. package/{rating-D6Tv_4Vx.js → rating-Da38uaZz.js} +61 -54
  50. package/{rating-C2Y95r50.cjs → rating-DlfOuwuX.cjs} +61 -54
  51. package/{select-jUrt_lSn.js → select-CAEPqdz1.js} +92 -72
  52. package/{select-BBiF-m3N.cjs → select-LBVhNdrd.cjs} +92 -72
  53. package/services/extendWidget.d.ts +37 -4
  54. package/services/floatingUI.cjs +3 -2
  55. package/services/floatingUI.d.ts +28 -27
  56. package/services/floatingUI.js +3 -2
  57. package/services/focustrack.cjs +1 -1
  58. package/services/focustrack.d.ts +21 -0
  59. package/services/focustrack.js +1 -1
  60. package/services/hash.d.ts +2 -1
  61. package/services/intersection.cjs +1 -1
  62. package/services/intersection.d.ts +9 -13
  63. package/services/intersection.js +1 -1
  64. package/services/matchMedia.cjs +1 -1
  65. package/services/matchMedia.d.ts +2 -1
  66. package/services/matchMedia.js +1 -1
  67. package/services/navManager.cjs +1 -1
  68. package/services/navManager.d.ts +85 -41
  69. package/services/navManager.js +1 -1
  70. package/services/portal.cjs +1 -1
  71. package/services/portal.d.ts +3 -0
  72. package/services/portal.js +1 -1
  73. package/services/resizeObserver.cjs +2 -2
  74. package/services/resizeObserver.d.ts +2 -6
  75. package/services/resizeObserver.js +2 -2
  76. package/services/siblingsInert.cjs +3 -3
  77. package/services/siblingsInert.d.ts +3 -5
  78. package/services/siblingsInert.js +3 -3
  79. package/services/transitions/baseTransitions.cjs +4 -5
  80. package/services/transitions/baseTransitions.d.ts +21 -4
  81. package/services/transitions/baseTransitions.js +4 -5
  82. package/services/transitions/collapse.cjs +1 -1
  83. package/services/transitions/collapse.d.ts +6 -0
  84. package/services/transitions/collapse.js +1 -1
  85. package/services/transitions/cssTransitions.cjs +1 -1
  86. package/services/transitions/cssTransitions.d.ts +3 -0
  87. package/services/transitions/cssTransitions.js +1 -1
  88. package/services/transitions/simpleClassTransition.cjs +1 -1
  89. package/services/transitions/simpleClassTransition.d.ts +9 -2
  90. package/services/transitions/simpleClassTransition.js +1 -1
  91. package/{slider-ByDkbyr1.js → slider-DYrwS7Mv.js} +118 -116
  92. package/{slider-BdsZpxJr.cjs → slider-DlOAawbZ.cjs} +118 -116
  93. package/{toast-BzxextBQ.js → toast-CpvsibAI.js} +3 -3
  94. package/{toast-Dy3ck2cM.cjs → toast-D_uSrRZL.cjs} +3 -3
  95. package/types.cjs +0 -8
  96. package/types.d.ts +151 -19
  97. package/types.js +1 -9
  98. package/utils/directive.cjs +1 -1
  99. package/utils/directive.d.ts +81 -32
  100. package/utils/directive.js +1 -1
  101. package/utils/internal/checks.d.ts +6 -0
  102. package/utils/internal/dom.d.ts +5 -5
  103. package/utils/internal/promise.d.ts +9 -0
  104. package/utils/internal/sort.d.ts +2 -2
  105. package/utils/internal/ssrHTMLElement.d.ts +4 -0
  106. package/utils/stores.cjs +1 -1
  107. package/utils/stores.d.ts +80 -42
  108. package/utils/stores.js +1 -1
  109. package/utils/writables.cjs +2 -1
  110. package/utils/writables.d.ts +52 -3
  111. package/utils/writables.js +2 -1
  112. package/{writables-D46sFgGK.cjs → writables-BPAJvaL_.cjs} +9 -0
  113. 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
- * @param stores - object of stores
28
- * @returns the patch function
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>): <U extends Partial<T>>(storesValues?: void | U | undefined) => void;
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
- * @param obj1 - First object
39
- * @param obj2 - Second object
40
- * @returns the object with changed properties
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
- * @param x - either a store or a simple value
67
- * @returns either x if x is already a store, or readable(x) otherwise
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
- * If the provided argument is already a store, it is returned as is, otherwise, a writable store is created with the provided argument as its initial value.
72
- * @param x - either a writable store or a simple value
73
- * @returns either x if x is already a store, or writable(x) otherwise
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, T>;
100
+ export declare const toWritableStore: <T>(x: WritableSignal<T> | T) => WritableSignal<T>;
76
101
  /**
77
- * Extract and normalize config stores.
102
+ * Normalizes configuration stores by converting them into readable signals.
78
103
  *
79
- * @param keys - the keys of the stores to extract / normalize
80
- * @param config - the config stores
81
- * @returns the normalized config stores
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
- * Merge two stores configs into one
86
- *
87
- * @param keys - the keys of the stores to extract and merge from the two provided configs
88
- * @param config1 - the first config
89
- * @param config2 - the second config
90
- * @returns the merged config
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]?: WritableWithDefaultOptions<T[K]>; }) => [ToWritableSignal<T>, ReturnType<typeof createPatch<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 derived store that binds to multiple stores and triggers a callback when the value changes for any reason.
160
- * @param onChange$ - A readable signal containing a callback function to execute when the value changes.
161
- * @param stores - An array of Svelte stores, with the main store at index 0.
162
- * @param adjustValue - A function to adjust the value of the main store. By default, the value of the main store is returned.
163
- * @param equal - A function to determine if two values are equal. Used to compare the ajusted value with the current one.
164
- * @returns The derived store that reflects the combined state of the input stores.
165
- */
166
- 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, T>;
167
- /**
168
- * Creates a computed store that contains the adjusted value of the given store and that triggers a callback when the value changes from the set or update
169
- * method of the returned writable store.
170
- * @param store$ - store to be bound
171
- * @param onChange$ - A readable signal containing a callback function to execute when the value changes from the set or update method of the returned writable store.
172
- * @param adjustValue - A function to adjust the value of the store, called in a reactive context each time the value changes or any called dependency changes.
173
- * By default, the value of store$ is returned.
174
- * @param equal - A function to determine if two values are equal.
175
- * @returns A writable store that contains the adjusted value of the given store, with the set or update functions that trigger the onChange$ callback.
176
- */
177
- 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, T>;
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
  });
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const utils_writables = require("../writables-D46sFgGK.cjs");
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;
@@ -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
- * @param filter - the guard function
7
- * @returns a function that takes a value as input, checks if it respects the type guard and returns `INVALID_VALUE` otherwise
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>;
@@ -1,6 +1,7 @@
1
- import { t, h, c, d, f, g, a, b, e } from "../writables-DoU_XYTX.js";
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
- clamp as i,
84
- isNumber as j,
91
+ createTypeEnum as i,
92
+ clamp as j,
93
+ isNumber as k,
85
94
  testToNormalizeValue as t
86
95
  };