@fkui/logic 6.37.0 → 6.38.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/lib/types/index.d.ts +140 -1
- package/lib/types/tsdoc-metadata.json +1 -1
- package/package.json +3 -3
package/lib/types/index.d.ts
CHANGED
|
@@ -123,6 +123,15 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
123
123
|
values: string | string[] | number | number[];
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Constructs a tuple type of a specific length `N`.
|
|
128
|
+
* Used internally for recursion depth tracking.
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
* @since v6.38.0
|
|
132
|
+
*/
|
|
133
|
+
export declare type BuildDepth<N extends number, T extends unknown[] = []> = T["length"] extends N ? T : BuildDepth<N, [...T, unknown]>;
|
|
134
|
+
|
|
126
135
|
/**
|
|
127
136
|
* A string of 4-5 digits where last digit may be separated by hyphen, for
|
|
128
137
|
* example "5678-1"
|
|
@@ -147,6 +156,16 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
147
156
|
timeLimitSeconds?: number;
|
|
148
157
|
}
|
|
149
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Global registry interface.
|
|
161
|
+
* Consumers (the main project) will merge their specific key types into this.
|
|
162
|
+
*
|
|
163
|
+
* @public
|
|
164
|
+
* @since v6.38.0
|
|
165
|
+
*/
|
|
166
|
+
export declare interface CustomTranslationRegistry {
|
|
167
|
+
}
|
|
168
|
+
|
|
150
169
|
/**
|
|
151
170
|
* A string in format YYYY-MM-DD, for example 2021-02-03
|
|
152
171
|
*
|
|
@@ -613,6 +632,17 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
613
632
|
*/
|
|
614
633
|
export declare function isVisibleInViewport(element: Element): boolean;
|
|
615
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Joins two path segments.
|
|
637
|
+
*
|
|
638
|
+
* We use generic constraints (`extends ValidKey`) here instead of conditional
|
|
639
|
+
* checks to keep it clean. If K or P is not a string/number, TS will error.
|
|
640
|
+
*
|
|
641
|
+
* @public
|
|
642
|
+
* @since v6.38.0
|
|
643
|
+
*/
|
|
644
|
+
export declare type Join<K extends ValidKey, P extends ValidKey> = `${K}.${P}`;
|
|
645
|
+
|
|
616
646
|
/**
|
|
617
647
|
* @public
|
|
618
648
|
*/
|
|
@@ -658,6 +688,20 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
658
688
|
constructor(message?: string);
|
|
659
689
|
}
|
|
660
690
|
|
|
691
|
+
/**
|
|
692
|
+
* Recursively generates a union of all dot-notation paths for object `T`.
|
|
693
|
+
*
|
|
694
|
+
* It uses `PathMap` to calculate paths for properties and then extracts
|
|
695
|
+
* the values using `[keyof T]`.
|
|
696
|
+
*
|
|
697
|
+
* @public
|
|
698
|
+
* @since v6.38.0
|
|
699
|
+
* @typeParam T - The object or array to inspect.
|
|
700
|
+
* @typeParam Depth - The maximum recursion depth (defaults to 6).
|
|
701
|
+
* @returns A union of string paths (e.g., `"user" | "user.name"`).
|
|
702
|
+
*/
|
|
703
|
+
export declare type NestedKeys<T, Depth extends number = 6> = [Depth] extends [never] ? never : T extends object ? PathMap<T, Depth>[keyof T & ValidKey] : never;
|
|
704
|
+
|
|
661
705
|
/**
|
|
662
706
|
* @public
|
|
663
707
|
*/
|
|
@@ -734,6 +778,25 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
734
778
|
*/
|
|
735
779
|
export declare function parsePostalCode(value: string): PostalCodeString | undefined;
|
|
736
780
|
|
|
781
|
+
/**
|
|
782
|
+
* Internal helper: "Flattens" the object one level deep.
|
|
783
|
+
*
|
|
784
|
+
* This generates a mapped type where the keys are the property names,
|
|
785
|
+
* and the values are the calculated paths (current key + nested paths).
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* ```ts
|
|
789
|
+
* // Input: { user: { name: string } }
|
|
790
|
+
* // Output: { user: "user" | "user.name" }
|
|
791
|
+
* ```
|
|
792
|
+
*
|
|
793
|
+
* @public
|
|
794
|
+
* @since v6.38.0
|
|
795
|
+
*/
|
|
796
|
+
export declare type PathMap<T, Depth extends number> = {
|
|
797
|
+
[K in keyof T & ValidKey]: T[K] extends object ? `${K}` | Join<K, NestedKeys<T[K], Prev<Depth>>> : `${K}`;
|
|
798
|
+
};
|
|
799
|
+
|
|
737
800
|
/**
|
|
738
801
|
* Describes the event that is dispatched during input if no instant validation.
|
|
739
802
|
*
|
|
@@ -809,6 +872,14 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
809
872
|
*/
|
|
810
873
|
export declare type PostalCodeString = string;
|
|
811
874
|
|
|
875
|
+
/**
|
|
876
|
+
* Computes `N - 1` at the type level.
|
|
877
|
+
*
|
|
878
|
+
* @public
|
|
879
|
+
* @since v6.38.0
|
|
880
|
+
*/
|
|
881
|
+
export declare type Prev<N extends number> = BuildDepth<N> extends [...infer R, unknown] ? R["length"] : never;
|
|
882
|
+
|
|
812
883
|
/**
|
|
813
884
|
* Save current active element focus on the stack and set focus on element
|
|
814
885
|
*
|
|
@@ -824,6 +895,18 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
824
895
|
*/
|
|
825
896
|
export declare function removeFocusListener(elements: HTMLElement[], listener: ((event: Event) => unknown) | (() => unknown)): void;
|
|
826
897
|
|
|
898
|
+
/**
|
|
899
|
+
* Resolves the valid translation keys.
|
|
900
|
+
* If the consumer has defined `Keys` in the registry, use that.
|
|
901
|
+
* Otherwise, fallback to `string` (loose typing).
|
|
902
|
+
*
|
|
903
|
+
* @public
|
|
904
|
+
* @since v6.38.0
|
|
905
|
+
*/
|
|
906
|
+
export declare type ResolveTranslationKey = CustomTranslationRegistry extends {
|
|
907
|
+
Keys: infer K;
|
|
908
|
+
} ? K : string;
|
|
909
|
+
|
|
827
910
|
/**
|
|
828
911
|
* Restore focus to a previous element. Use this in combination with {@link saveFocus}
|
|
829
912
|
*
|
|
@@ -955,8 +1038,54 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
955
1038
|
|
|
956
1039
|
/**
|
|
957
1040
|
* @public
|
|
1041
|
+
* @typeParam Key - The valid translation keys. Defaults to `string` for loose typing,
|
|
1042
|
+
* but can be set to a specific union of strings (e.g., via `NestedKeys<Schema>`)
|
|
1043
|
+
* to enforce strict key validation and autocompletion.
|
|
958
1044
|
*/
|
|
959
|
-
export declare
|
|
1045
|
+
export declare interface TranslateFunction<Key = ResolveTranslationKey> {
|
|
1046
|
+
/**
|
|
1047
|
+
* Returns the translation for the key.
|
|
1048
|
+
*
|
|
1049
|
+
* @param key - The translation key.
|
|
1050
|
+
*/
|
|
1051
|
+
(key: Key): string;
|
|
1052
|
+
/**
|
|
1053
|
+
* Returns the translation for the key or the default value if no
|
|
1054
|
+
* translation exists.
|
|
1055
|
+
*
|
|
1056
|
+
* @param key - The translation key.
|
|
1057
|
+
* @param defaultValue - The default value.
|
|
1058
|
+
*/
|
|
1059
|
+
(key: Key, defaultValue: string): string;
|
|
1060
|
+
/**
|
|
1061
|
+
* Returns the translation for the key. The translation is interpolated
|
|
1062
|
+
* with the given arguments.
|
|
1063
|
+
*
|
|
1064
|
+
* @param key - The translation key.
|
|
1065
|
+
* @param args - The interpolation arguments.
|
|
1066
|
+
*/
|
|
1067
|
+
(key: Key, args: Record<string, unknown>): string;
|
|
1068
|
+
/**
|
|
1069
|
+
* Returns the translation for the key or the default value if no
|
|
1070
|
+
* translation exists. The translation is interpolated with the given
|
|
1071
|
+
* arguments.
|
|
1072
|
+
*
|
|
1073
|
+
* @param key - The translation key.
|
|
1074
|
+
* @param defaultValue - The default value.
|
|
1075
|
+
* @param args - The interpolation arguments.
|
|
1076
|
+
*/
|
|
1077
|
+
(key: Key, defaultValue: string, args: Record<string, unknown>): string;
|
|
1078
|
+
/**
|
|
1079
|
+
* Returns the translation for the key or the default value if no
|
|
1080
|
+
* translation exists. The translation is interpolated with the given
|
|
1081
|
+
* arguments.
|
|
1082
|
+
*
|
|
1083
|
+
* @param key - The translation key.
|
|
1084
|
+
* @param defaultValue - The default value.
|
|
1085
|
+
* @param args - The interpolation arguments.
|
|
1086
|
+
*/
|
|
1087
|
+
(key: Key, defaultValue?: string | Record<string, unknown>, args?: Record<string, unknown>): string;
|
|
1088
|
+
}
|
|
960
1089
|
|
|
961
1090
|
/**
|
|
962
1091
|
* @public
|
|
@@ -1380,6 +1509,16 @@ export declare interface AllowListValidatorConfig extends ValidatorOptions {
|
|
|
1380
1509
|
*/
|
|
1381
1510
|
export declare type ValidityNativeEvent = "input" | "change" | "blur" | "validate";
|
|
1382
1511
|
|
|
1512
|
+
/**
|
|
1513
|
+
* Helper type: aliases valid keys to strictly string.
|
|
1514
|
+
* This filters out `symbol`, which cannot be used in template literals.
|
|
1515
|
+
* Only allows "string-key": "value" pairs
|
|
1516
|
+
*
|
|
1517
|
+
* @public
|
|
1518
|
+
* @since v6.38.0
|
|
1519
|
+
*/
|
|
1520
|
+
export declare type ValidKey = string;
|
|
1521
|
+
|
|
1383
1522
|
/**
|
|
1384
1523
|
* @public
|
|
1385
1524
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fkui/logic",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.38.0",
|
|
4
4
|
"description": "Logic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fkui",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"watch": "rollup --config --watch"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@fkui/date": "^6.
|
|
64
|
+
"@fkui/date": "^6.38.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">= 20",
|
|
68
68
|
"npm": ">= 7"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "ea8e50d8567159581a628106e93ac0e7c1d43a1b"
|
|
71
71
|
}
|