@enact/core 4.6.1 → 4.6.2
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/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/dispatcher/dispatcher.d.ts +21 -0
- package/handle/handle.d.ts +618 -0
- package/handle/tests/handle-specs.js +3 -1
- package/hoc/hoc.d.ts +43 -0
- package/hoc/tests/hoc-specs.js +3 -1
- package/index.d.ts +0 -0
- package/internal/ApiDecorator/ApiDecorator.d.ts +0 -0
- package/internal/ApiDecorator/ApiDecorator.js +4 -2
- package/internal/ApiDecorator/tests/ApiDecorator-specs.js +3 -1
- package/internal/Registry/Registry.d.ts +0 -0
- package/internal/Registry/tests/Registry-specs.js +4 -2
- package/internal/deprecate/deprecate.d.ts +0 -0
- package/internal/prop-types/prop-types.d.ts +0 -0
- package/internal/prop-types/tests/prop-types-specs.js +3 -1
- package/keymap/index.d.ts +37 -0
- package/kind/kind.d.ts +90 -0
- package/kind/kind.js +4 -2
- package/kind/tests/kind-specs.js +5 -3
- package/package.json +1 -1
- package/platform/platform.d.ts +45 -0
- package/platform/platform.js +4 -2
- package/snapshot/snapshot.d.ts +30 -0
- package/useChainRefs/tests/useChainRefs-specs.js +1 -1
- package/useChainRefs/useChainRefs.d.ts +0 -0
- package/useClass/tests/useClass-specs.js +3 -1
- package/useClass/useClass.d.ts +0 -0
- package/useHandlers/Handlers.js +3 -1
- package/useHandlers/tests/useHandlers-specs.js +3 -1
- package/useHandlers/useHandlers.d.ts +0 -0
- package/usePublicClassNames/usePublicClassNames.d.ts +0 -0
- package/util/Job.js +3 -1
- package/util/util.d.ts +162 -0
package/util/util.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Type definitions for core/util
|
|
2
|
+
|
|
3
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
4
|
+
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Provides a convenient way to manage timed execution of functions.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export declare class Job {
|
|
11
|
+
constructor
|
|
12
|
+
/**
|
|
13
|
+
* Function to execute as the requested job.
|
|
14
|
+
*/(
|
|
15
|
+
fn: Function
|
|
16
|
+
/**
|
|
17
|
+
* The number of milliseconds to wait before starting the job.
|
|
18
|
+
*/,
|
|
19
|
+
timeout: number
|
|
20
|
+
);
|
|
21
|
+
/**
|
|
22
|
+
* Starts the job.
|
|
23
|
+
*/
|
|
24
|
+
start(args?: any[]): void;
|
|
25
|
+
/**
|
|
26
|
+
* Starts the job in `timeout` milliseconds
|
|
27
|
+
*/
|
|
28
|
+
startAfter(timeout: number, args?: any[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* Stops the job.
|
|
31
|
+
*/
|
|
32
|
+
stop(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Executes the job immediately, then prevents any other calls to `throttle()` from running
|
|
35
|
+
until the `timeout` configured at construction passes.
|
|
36
|
+
*/
|
|
37
|
+
throttle(...args: any[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Executes the job immediately, then prevents any other calls to `throttle()` from running for
|
|
40
|
+
`timeout` milliseconds.
|
|
41
|
+
*/
|
|
42
|
+
throttleUntil(timeout: number, args?: any[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Executes job when the CPU is idle.
|
|
45
|
+
*/
|
|
46
|
+
idle(args?: any[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* Executes job when the CPU is idle, or when the timeout is reached, whichever occurs first.
|
|
49
|
+
*/
|
|
50
|
+
idleUntil(timeout: number, args?: any[]): void;
|
|
51
|
+
/**
|
|
52
|
+
* Executes job before the next repaint.
|
|
53
|
+
*/
|
|
54
|
+
startRaf(args?: any[]): void;
|
|
55
|
+
/**
|
|
56
|
+
* Executes job before the next repaint after a given amount of timeout.
|
|
57
|
+
*/
|
|
58
|
+
startRafAfter(timeout: number, args?: any[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* Starts the job when `promise` resolves.
|
|
61
|
+
*
|
|
62
|
+
* The job execution is tied to the resolution of the last `Promise` passed. Like other methods
|
|
63
|
+
on `Job` , calling `promise()` again with a new `Promise` will block execution of the job
|
|
64
|
+
until that new `Promise` resolves. Any previous `Promise` s will still resolve normally but
|
|
65
|
+
will not trigger job execution.
|
|
66
|
+
*
|
|
67
|
+
* Unlike other methods on `Job` , `promise()` returns a `Promise` which is the result of calling
|
|
68
|
+
`then()` on the passed `promise` . That `Promise` resolves with either the result of job
|
|
69
|
+
execution or `undefined` if `Promise` was superseded by a subsequent `Promise` passed as
|
|
70
|
+
described above.
|
|
71
|
+
*/
|
|
72
|
+
promise(promise: Promise): Promise;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Capitalizes a given string (not locale-aware).
|
|
77
|
+
*/
|
|
78
|
+
export function cap(str: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Limits `value` to be between `min` and `max` .
|
|
81
|
+
*
|
|
82
|
+
* If `min` is greater than `max` , `min` is returned.
|
|
83
|
+
*/
|
|
84
|
+
export function clamp(min: number, max: number, value: number): number;
|
|
85
|
+
/**
|
|
86
|
+
* If `arg` is a function, return it. Otherwise returns a function that returns `arg` .
|
|
87
|
+
*
|
|
88
|
+
* Example:
|
|
89
|
+
* ```
|
|
90
|
+
const returnsZero = coerceFunction(0);
|
|
91
|
+
const returnsArg = coerceFunction(() => 0);
|
|
92
|
+
```
|
|
93
|
+
*/
|
|
94
|
+
export function coerceFunction(arg: any): Function;
|
|
95
|
+
/**
|
|
96
|
+
* If `arg` is array-like, return it. Otherwise returns a single element array containing `arg` .
|
|
97
|
+
*
|
|
98
|
+
* Example:
|
|
99
|
+
* ```
|
|
100
|
+
const returnsArray = coerceArray(0); // [0]
|
|
101
|
+
const returnsArg = coerceArray([0]); // [0]
|
|
102
|
+
const returnsObjArg = coerceArray({0: 'zeroth', length: 1});
|
|
103
|
+
```
|
|
104
|
+
*/
|
|
105
|
+
export function coerceArray(array: any): Array<any>;
|
|
106
|
+
/**
|
|
107
|
+
* Loosely determines if `tag` is a renderable component (either a string or a function).
|
|
108
|
+
*/
|
|
109
|
+
export function isRenderable(tag: any): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Removes ARIA-related props from `props` and returns them in a new object.
|
|
112
|
+
*
|
|
113
|
+
* Specifically, it removes the `role` prop and any prop prefixed with `aria-` . This is useful when
|
|
114
|
+
redirecting ARIA-related props from a non-focusable root element to a focusable child element.
|
|
115
|
+
*/
|
|
116
|
+
export function extractAriaProps(props: object): object;
|
|
117
|
+
/**
|
|
118
|
+
* Gets the current timestamp of either `window.performance.now` or `Date.now`
|
|
119
|
+
*/
|
|
120
|
+
export function perfNow(): number;
|
|
121
|
+
/**
|
|
122
|
+
* Merges two class name maps into one.
|
|
123
|
+
*
|
|
124
|
+
* The resulting map will only contain the class names defined in the `baseMap` and will be appended
|
|
125
|
+
with the value from `additiveMap` if it exists. Further, `allowedClassNames` may optionally limit
|
|
126
|
+
which keys will be merged from `additiveMap` into `baseMap` .
|
|
127
|
+
*
|
|
128
|
+
* Example:
|
|
129
|
+
* ```
|
|
130
|
+
// merges all matching class names from additiveMap1 with baseMap1
|
|
131
|
+
const newMap1 = mergeClassNameMaps(baseMap1, additiveMap1);
|
|
132
|
+
|
|
133
|
+
// merge only 'a' and 'b' class names from additiveMap2 with baseMap2
|
|
134
|
+
const newMap2 = mergeClassNameMaps(baseMap2, additiveMap2, ['a', 'b']);
|
|
135
|
+
```
|
|
136
|
+
*/
|
|
137
|
+
export function mergeClassNameMaps(
|
|
138
|
+
baseMap: object,
|
|
139
|
+
additiveMap: object,
|
|
140
|
+
allowedClassNames?: string[]
|
|
141
|
+
): object;
|
|
142
|
+
/**
|
|
143
|
+
* Creates a function that memoizes the result of `fn` .
|
|
144
|
+
*
|
|
145
|
+
* Note that this function is a naive implementation and only checks the first argument for
|
|
146
|
+
memoization.
|
|
147
|
+
*/
|
|
148
|
+
export function memoize(fn: Function): Function;
|
|
149
|
+
/**
|
|
150
|
+
* Maps over the `children` , discarding any `null` children before and after calling the callback.
|
|
151
|
+
*
|
|
152
|
+
* A replacement for `React.Children.map` .
|
|
153
|
+
*/
|
|
154
|
+
export function mapAndFilterChildren(
|
|
155
|
+
children: any,
|
|
156
|
+
callback: Function,
|
|
157
|
+
filter?: Function
|
|
158
|
+
): any;
|
|
159
|
+
/**
|
|
160
|
+
* Performs shallow comparison for given objects.
|
|
161
|
+
*/
|
|
162
|
+
export function shallowEqual(a: Obejct, b: Obejct): boolean;
|