@enact/core 4.6.0 → 4.6.1
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/package.json +1 -1
- package/dispatcher/dispatcher.d.ts +0 -21
- package/handle/handle.d.ts +0 -618
- package/hoc/hoc.d.ts +0 -44
- package/index.d.ts +0 -0
- package/internal/ApiDecorator/ApiDecorator.d.ts +0 -0
- package/internal/Registry/Registry.d.ts +0 -0
- package/internal/deprecate/deprecate.d.ts +0 -0
- package/internal/prop-types/prop-types.d.ts +0 -0
- package/keymap/index.d.ts +0 -37
- package/kind/kind.d.ts +0 -90
- package/platform/platform.d.ts +0 -45
- package/snapshot/snapshot.d.ts +0 -32
- package/useChainRefs/useChainRefs.d.ts +0 -0
- package/useClass/useClass.d.ts +0 -0
- package/useHandlers/useHandlers.d.ts +0 -0
- package/usePublicClassNames/usePublicClassNames.d.ts +0 -0
- package/util/util.d.ts +0 -162
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/dispatcher
|
|
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
|
-
* Adds a new global event listener. Duplicate event handlers will be discarded.
|
|
8
|
-
*/
|
|
9
|
-
export function on(name: string, fn: Function, target: React.ReactNode): void;
|
|
10
|
-
/**
|
|
11
|
-
* Removes a global event listener.
|
|
12
|
-
*/
|
|
13
|
-
export function off(name: string, fn: Function, target: React.ReactNode): void;
|
|
14
|
-
/**
|
|
15
|
-
* Adds a new global event listener that removes itself after handling one event.
|
|
16
|
-
*/
|
|
17
|
-
export function once(
|
|
18
|
-
name: string,
|
|
19
|
-
fn: Function,
|
|
20
|
-
target?: React.ReactNode
|
|
21
|
-
): Function;
|
package/handle/handle.d.ts
DELETED
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/handle
|
|
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
|
-
* The signature for event handlers
|
|
8
|
-
*/
|
|
9
|
-
export interface EventHandler {
|
|
10
|
-
(event: any): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* The signature for event handling functions supported by `handle` and related functions
|
|
14
|
-
*/
|
|
15
|
-
export interface HandlerFunction {
|
|
16
|
-
(
|
|
17
|
-
event: any,
|
|
18
|
-
props: { [key: string]: any },
|
|
19
|
-
context: { [key: string]: any }
|
|
20
|
-
): void;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The signature for parameter `adapter`
|
|
24
|
-
*/
|
|
25
|
-
export interface EventAdapter {
|
|
26
|
-
(
|
|
27
|
-
event: any,
|
|
28
|
-
props: { [key: string]: any },
|
|
29
|
-
context: { [key: string]: any }
|
|
30
|
-
): any;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Allows generating event handlers by chaining input functions to filter or short-circuit the
|
|
34
|
-
handling flow. Any input function that returns a falsy value will stop the chain.
|
|
35
|
-
*
|
|
36
|
-
* The returned handler function has a `finally()` member that accepts a function and returns a new
|
|
37
|
-
handler function. The accepted function is called once the original handler completes regardless
|
|
38
|
-
of the returned value.
|
|
39
|
-
*/
|
|
40
|
-
export function handle(...handlers: HandlerFunction[]): EventHandler;
|
|
41
|
-
/**
|
|
42
|
-
* Calls the first handler whose condition passes. Each branch must be passed as an array with the
|
|
43
|
-
first element being the condition function and the second being the handler function. The same
|
|
44
|
-
arguments are passed to both the condition function and the handler function. The value returned
|
|
45
|
-
from the handler is returned.
|
|
46
|
-
*
|
|
47
|
-
* Example:
|
|
48
|
-
* ```
|
|
49
|
-
const handler = oneOf(
|
|
50
|
-
[forKey('enter'), handleEnter],
|
|
51
|
-
[forKey('left'), handleLeft],
|
|
52
|
-
[forKey('right'), handleRight]
|
|
53
|
-
);
|
|
54
|
-
```
|
|
55
|
-
*/
|
|
56
|
-
export function oneOf(
|
|
57
|
-
...handlers: [HandlerFunction, HandlerFunction][]
|
|
58
|
-
): HandlerFunction;
|
|
59
|
-
/**
|
|
60
|
-
* A function that always returns `true` . Optionally accepts a `handler` function which is called
|
|
61
|
-
before returning `true` .
|
|
62
|
-
*
|
|
63
|
-
* Example:
|
|
64
|
-
* ```
|
|
65
|
-
// Used to coerce an existing function into a handler
|
|
66
|
-
const coercedHandler = handle(
|
|
67
|
-
returnsTrue(doesSomething),
|
|
68
|
-
willAlwaysBeCalled
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// Used to emulate if/else blocks with `oneOf`
|
|
72
|
-
const ifElseHandler = oneOf(
|
|
73
|
-
[forKey('enter'), handleEnter],
|
|
74
|
-
[returnsTrue, handleOtherwise]
|
|
75
|
-
);
|
|
76
|
-
```
|
|
77
|
-
*/
|
|
78
|
-
export function returnsTrue(handler?: Function): HandlerFunction;
|
|
79
|
-
/**
|
|
80
|
-
* Allows handling to continue if the value of `prop` on the event strictly equals `value`
|
|
81
|
-
*
|
|
82
|
-
* Example:
|
|
83
|
-
* ```
|
|
84
|
-
import {forEventProp, handle} from '@enact/core/handle';
|
|
85
|
-
|
|
86
|
-
const logWhenXEqualsZero = handle(
|
|
87
|
-
forEventProp('x', 0),
|
|
88
|
-
(ev) => console.log('ev.x was equal to zero', ev)
|
|
89
|
-
);
|
|
90
|
-
```
|
|
91
|
-
*/
|
|
92
|
-
export function forEventProp(prop: string, value: any, ev: object): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Allows handling to continue if the value of `prop` on the event strictly equals `value`
|
|
95
|
-
*
|
|
96
|
-
* Example:
|
|
97
|
-
* ```
|
|
98
|
-
import {forEventProp, handle} from '@enact/core/handle';
|
|
99
|
-
|
|
100
|
-
const logWhenXEqualsZero = handle(
|
|
101
|
-
forEventProp('x', 0),
|
|
102
|
-
(ev) => console.log('ev.x was equal to zero', ev)
|
|
103
|
-
);
|
|
104
|
-
```
|
|
105
|
-
*/
|
|
106
|
-
export function forEventProp(prop: string): (value: any, ev: object) => boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Allows handling to continue if the value of `prop` on the event strictly equals `value`
|
|
109
|
-
*
|
|
110
|
-
* Example:
|
|
111
|
-
* ```
|
|
112
|
-
import {forEventProp, handle} from '@enact/core/handle';
|
|
113
|
-
|
|
114
|
-
const logWhenXEqualsZero = handle(
|
|
115
|
-
forEventProp('x', 0),
|
|
116
|
-
(ev) => console.log('ev.x was equal to zero', ev)
|
|
117
|
-
);
|
|
118
|
-
```
|
|
119
|
-
*/
|
|
120
|
-
export function forEventProp(
|
|
121
|
-
prop: string
|
|
122
|
-
): (value: any) => (ev: object) => boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Allows handling to continue if the value of `prop` on the event strictly equals `value`
|
|
125
|
-
*
|
|
126
|
-
* Example:
|
|
127
|
-
* ```
|
|
128
|
-
import {forEventProp, handle} from '@enact/core/handle';
|
|
129
|
-
|
|
130
|
-
const logWhenXEqualsZero = handle(
|
|
131
|
-
forEventProp('x', 0),
|
|
132
|
-
(ev) => console.log('ev.x was equal to zero', ev)
|
|
133
|
-
);
|
|
134
|
-
```
|
|
135
|
-
*/
|
|
136
|
-
export function forEventProp(prop: string, value: any): (ev: object) => boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Forwards the event to a function at `name` on `props` . If the specified prop is `undefined` or
|
|
139
|
-
is not a function, it is ignored. The return value of the forwarded function is ignored and
|
|
140
|
-
`true` is always returned instead.
|
|
141
|
-
*
|
|
142
|
-
* Example:
|
|
143
|
-
* ```
|
|
144
|
-
import {forward, handle} from '@enact/core/handle';
|
|
145
|
-
|
|
146
|
-
const forwardAndLog = handle(
|
|
147
|
-
forward('onClick'),
|
|
148
|
-
(ev) => console.log('event forwarded to onClick from props', ev)
|
|
149
|
-
);
|
|
150
|
-
```
|
|
151
|
-
*/
|
|
152
|
-
export function forward(name: string, ev: object, props: object): true;
|
|
153
|
-
/**
|
|
154
|
-
* Forwards the event to a function at `name` on `props` . If the specified prop is `undefined` or
|
|
155
|
-
is not a function, it is ignored. The return value of the forwarded function is ignored and
|
|
156
|
-
`true` is always returned instead.
|
|
157
|
-
*
|
|
158
|
-
* Example:
|
|
159
|
-
* ```
|
|
160
|
-
import {forward, handle} from '@enact/core/handle';
|
|
161
|
-
|
|
162
|
-
const forwardAndLog = handle(
|
|
163
|
-
forward('onClick'),
|
|
164
|
-
(ev) => console.log('event forwarded to onClick from props', ev)
|
|
165
|
-
);
|
|
166
|
-
```
|
|
167
|
-
*/
|
|
168
|
-
export function forward(name: string): (ev: object, props: object) => true;
|
|
169
|
-
/**
|
|
170
|
-
* Forwards the event to a function at `name` on `props` . If the specified prop is `undefined` or
|
|
171
|
-
is not a function, it is ignored. The return value of the forwarded function is ignored and
|
|
172
|
-
`true` is always returned instead.
|
|
173
|
-
*
|
|
174
|
-
* Example:
|
|
175
|
-
* ```
|
|
176
|
-
import {forward, handle} from '@enact/core/handle';
|
|
177
|
-
|
|
178
|
-
const forwardAndLog = handle(
|
|
179
|
-
forward('onClick'),
|
|
180
|
-
(ev) => console.log('event forwarded to onClick from props', ev)
|
|
181
|
-
);
|
|
182
|
-
```
|
|
183
|
-
*/
|
|
184
|
-
export function forward(name: string): (ev: object) => (props: object) => true;
|
|
185
|
-
/**
|
|
186
|
-
* Forwards the event to a function at `name` on `props` . If the specified prop is `undefined` or
|
|
187
|
-
is not a function, it is ignored. The return value of the forwarded function is ignored and
|
|
188
|
-
`true` is always returned instead.
|
|
189
|
-
*
|
|
190
|
-
* Example:
|
|
191
|
-
* ```
|
|
192
|
-
import {forward, handle} from '@enact/core/handle';
|
|
193
|
-
|
|
194
|
-
const forwardAndLog = handle(
|
|
195
|
-
forward('onClick'),
|
|
196
|
-
(ev) => console.log('event forwarded to onClick from props', ev)
|
|
197
|
-
);
|
|
198
|
-
```
|
|
199
|
-
*/
|
|
200
|
-
export function forward(name: string, ev: object): (props: object) => true;
|
|
201
|
-
/**
|
|
202
|
-
* Calls `event.preventDefault()` and returns `true` .
|
|
203
|
-
*
|
|
204
|
-
* Example:
|
|
205
|
-
* ```
|
|
206
|
-
import {handle, preventDefault} from '@enact/core/handle';
|
|
207
|
-
|
|
208
|
-
const preventAndLog = handle(
|
|
209
|
-
preventDefault,
|
|
210
|
-
(ev) => console.log('preventDefault called', ev)
|
|
211
|
-
);
|
|
212
|
-
```
|
|
213
|
-
*/
|
|
214
|
-
export function preventDefault(ev: object): true;
|
|
215
|
-
/**
|
|
216
|
-
* Calls `event.stopPropagation()` and returns `true`
|
|
217
|
-
*
|
|
218
|
-
* Example:
|
|
219
|
-
* ```
|
|
220
|
-
import {handle, stop} from '@enact/core/handle';
|
|
221
|
-
|
|
222
|
-
const stopAndLog = handle(
|
|
223
|
-
stop,
|
|
224
|
-
(ev) => console.log('stopPropagation called', ev)
|
|
225
|
-
);
|
|
226
|
-
```
|
|
227
|
-
*/
|
|
228
|
-
export function stop(ev: object): true;
|
|
229
|
-
/**
|
|
230
|
-
* Calls `event.stopImmediatePropagation()` and returns `true`
|
|
231
|
-
*
|
|
232
|
-
* Example:
|
|
233
|
-
* ```
|
|
234
|
-
import {handle, stopImmediate} from '@enact/core/handle';
|
|
235
|
-
|
|
236
|
-
const stopImmediateAndLog = handle(
|
|
237
|
-
stopImmediate,
|
|
238
|
-
(ev) => console.log('stopImmediatePropagation called', ev)
|
|
239
|
-
);
|
|
240
|
-
```
|
|
241
|
-
*/
|
|
242
|
-
export function stopImmediate(ev: object): true;
|
|
243
|
-
/**
|
|
244
|
-
* Allows event handling to continue if `event.keyCode === value` .
|
|
245
|
-
*
|
|
246
|
-
* Example:
|
|
247
|
-
* ```
|
|
248
|
-
import {forKeyCode, handle} from '@enact/core/handle';
|
|
249
|
-
|
|
250
|
-
const logForEscapeKey = handle(
|
|
251
|
-
forKeyCode(27),
|
|
252
|
-
(ev) => console.log('Escape key pressed down', ev)
|
|
253
|
-
);
|
|
254
|
-
```
|
|
255
|
-
*/
|
|
256
|
-
export function forKeyCode(value: number, ev: object): boolean;
|
|
257
|
-
/**
|
|
258
|
-
* Allows event handling to continue if `event.keyCode === value` .
|
|
259
|
-
*
|
|
260
|
-
* Example:
|
|
261
|
-
* ```
|
|
262
|
-
import {forKeyCode, handle} from '@enact/core/handle';
|
|
263
|
-
|
|
264
|
-
const logForEscapeKey = handle(
|
|
265
|
-
forKeyCode(27),
|
|
266
|
-
(ev) => console.log('Escape key pressed down', ev)
|
|
267
|
-
);
|
|
268
|
-
```
|
|
269
|
-
*/
|
|
270
|
-
export function forKeyCode(value: number): (ev: object) => boolean;
|
|
271
|
-
/**
|
|
272
|
-
* Allows handling to continue if the event's keyCode is mapped to `name` within
|
|
273
|
-
.
|
|
274
|
-
*
|
|
275
|
-
* Example:
|
|
276
|
-
* ```
|
|
277
|
-
import {forKey, handle} from '@enact/core/handle';
|
|
278
|
-
|
|
279
|
-
const logForEnterKey = handle(
|
|
280
|
-
forKey('enter'),
|
|
281
|
-
(ev) => console.log('Enter key pressed down', ev)
|
|
282
|
-
);
|
|
283
|
-
```
|
|
284
|
-
*/
|
|
285
|
-
export function forKey(name: string, ev: object): boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Allows handling to continue if the event's keyCode is mapped to `name` within
|
|
288
|
-
.
|
|
289
|
-
*
|
|
290
|
-
* Example:
|
|
291
|
-
* ```
|
|
292
|
-
import {forKey, handle} from '@enact/core/handle';
|
|
293
|
-
|
|
294
|
-
const logForEnterKey = handle(
|
|
295
|
-
forKey('enter'),
|
|
296
|
-
(ev) => console.log('Enter key pressed down', ev)
|
|
297
|
-
);
|
|
298
|
-
```
|
|
299
|
-
*/
|
|
300
|
-
export function forKey(name: string): (ev: object) => boolean;
|
|
301
|
-
/**
|
|
302
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
303
|
-
*
|
|
304
|
-
* Example:
|
|
305
|
-
* ```
|
|
306
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
307
|
-
|
|
308
|
-
const logWhenChecked = handle(
|
|
309
|
-
forProp('checked', true),
|
|
310
|
-
(ev) => console.log('checked prop is true', ev)
|
|
311
|
-
);
|
|
312
|
-
```
|
|
313
|
-
*/
|
|
314
|
-
export function forProp(
|
|
315
|
-
prop: string,
|
|
316
|
-
value: any,
|
|
317
|
-
ev: object,
|
|
318
|
-
props: object
|
|
319
|
-
): boolean;
|
|
320
|
-
/**
|
|
321
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
322
|
-
*
|
|
323
|
-
* Example:
|
|
324
|
-
* ```
|
|
325
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
326
|
-
|
|
327
|
-
const logWhenChecked = handle(
|
|
328
|
-
forProp('checked', true),
|
|
329
|
-
(ev) => console.log('checked prop is true', ev)
|
|
330
|
-
);
|
|
331
|
-
```
|
|
332
|
-
*/
|
|
333
|
-
export function forProp(
|
|
334
|
-
prop: string
|
|
335
|
-
): (value: any, ev: object, props: object) => boolean;
|
|
336
|
-
/**
|
|
337
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
338
|
-
*
|
|
339
|
-
* Example:
|
|
340
|
-
* ```
|
|
341
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
342
|
-
|
|
343
|
-
const logWhenChecked = handle(
|
|
344
|
-
forProp('checked', true),
|
|
345
|
-
(ev) => console.log('checked prop is true', ev)
|
|
346
|
-
);
|
|
347
|
-
```
|
|
348
|
-
*/
|
|
349
|
-
export function forProp(
|
|
350
|
-
prop: string
|
|
351
|
-
): (value: any) => (ev: object, props: object) => boolean;
|
|
352
|
-
/**
|
|
353
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
354
|
-
*
|
|
355
|
-
* Example:
|
|
356
|
-
* ```
|
|
357
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
358
|
-
|
|
359
|
-
const logWhenChecked = handle(
|
|
360
|
-
forProp('checked', true),
|
|
361
|
-
(ev) => console.log('checked prop is true', ev)
|
|
362
|
-
);
|
|
363
|
-
```
|
|
364
|
-
*/
|
|
365
|
-
export function forProp(
|
|
366
|
-
prop: string
|
|
367
|
-
): (value: any) => (ev: object) => (props: object) => boolean;
|
|
368
|
-
/**
|
|
369
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
370
|
-
*
|
|
371
|
-
* Example:
|
|
372
|
-
* ```
|
|
373
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
374
|
-
|
|
375
|
-
const logWhenChecked = handle(
|
|
376
|
-
forProp('checked', true),
|
|
377
|
-
(ev) => console.log('checked prop is true', ev)
|
|
378
|
-
);
|
|
379
|
-
```
|
|
380
|
-
*/
|
|
381
|
-
export function forProp(
|
|
382
|
-
prop: string
|
|
383
|
-
): (value: any, ev: object) => (props: object) => boolean;
|
|
384
|
-
/**
|
|
385
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
386
|
-
*
|
|
387
|
-
* Example:
|
|
388
|
-
* ```
|
|
389
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
390
|
-
|
|
391
|
-
const logWhenChecked = handle(
|
|
392
|
-
forProp('checked', true),
|
|
393
|
-
(ev) => console.log('checked prop is true', ev)
|
|
394
|
-
);
|
|
395
|
-
```
|
|
396
|
-
*/
|
|
397
|
-
export function forProp(
|
|
398
|
-
prop: string,
|
|
399
|
-
value: any
|
|
400
|
-
): (ev: object, props: object) => boolean;
|
|
401
|
-
/**
|
|
402
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
403
|
-
*
|
|
404
|
-
* Example:
|
|
405
|
-
* ```
|
|
406
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
407
|
-
|
|
408
|
-
const logWhenChecked = handle(
|
|
409
|
-
forProp('checked', true),
|
|
410
|
-
(ev) => console.log('checked prop is true', ev)
|
|
411
|
-
);
|
|
412
|
-
```
|
|
413
|
-
*/
|
|
414
|
-
export function forProp(
|
|
415
|
-
prop: string,
|
|
416
|
-
value: any
|
|
417
|
-
): (ev: object) => (props: object) => boolean;
|
|
418
|
-
/**
|
|
419
|
-
* Allows handling to continue if the value of `prop` on the props strictly equals `value` .
|
|
420
|
-
*
|
|
421
|
-
* Example:
|
|
422
|
-
* ```
|
|
423
|
-
import {forProp, handle} from '@enact/core/handle';
|
|
424
|
-
|
|
425
|
-
const logWhenChecked = handle(
|
|
426
|
-
forProp('checked', true),
|
|
427
|
-
(ev) => console.log('checked prop is true', ev)
|
|
428
|
-
);
|
|
429
|
-
```
|
|
430
|
-
*/
|
|
431
|
-
export function forProp(
|
|
432
|
-
prop: string,
|
|
433
|
-
value: any,
|
|
434
|
-
ev: object
|
|
435
|
-
): (props: object) => boolean;
|
|
436
|
-
/**
|
|
437
|
-
* Logs the event, props, and context optionally preceded by a custom message. Will only log in
|
|
438
|
-
development mode.
|
|
439
|
-
*
|
|
440
|
-
* Example:
|
|
441
|
-
* ```
|
|
442
|
-
import {forProp, handle, log} from '@enact/core/handle';
|
|
443
|
-
|
|
444
|
-
const logWhenChecked = handle(
|
|
445
|
-
forProp('checked', true),
|
|
446
|
-
log('checked props is true')
|
|
447
|
-
);
|
|
448
|
-
```
|
|
449
|
-
*/
|
|
450
|
-
export function log(message: string, ev: object, args?: any[]): true;
|
|
451
|
-
/**
|
|
452
|
-
* Logs the event, props, and context optionally preceded by a custom message. Will only log in
|
|
453
|
-
development mode.
|
|
454
|
-
*
|
|
455
|
-
* Example:
|
|
456
|
-
* ```
|
|
457
|
-
import {forProp, handle, log} from '@enact/core/handle';
|
|
458
|
-
|
|
459
|
-
const logWhenChecked = handle(
|
|
460
|
-
forProp('checked', true),
|
|
461
|
-
log('checked props is true')
|
|
462
|
-
);
|
|
463
|
-
```
|
|
464
|
-
*/
|
|
465
|
-
export function log(message: string): (ev: object, args?: any[]) => true;
|
|
466
|
-
/**
|
|
467
|
-
* Logs the event, props, and context optionally preceded by a custom message. Will only log in
|
|
468
|
-
development mode.
|
|
469
|
-
*
|
|
470
|
-
* Example:
|
|
471
|
-
* ```
|
|
472
|
-
import {forProp, handle, log} from '@enact/core/handle';
|
|
473
|
-
|
|
474
|
-
const logWhenChecked = handle(
|
|
475
|
-
forProp('checked', true),
|
|
476
|
-
log('checked props is true')
|
|
477
|
-
);
|
|
478
|
-
```
|
|
479
|
-
*/
|
|
480
|
-
export function log(message: string): (ev: object) => (args?: any[]) => true;
|
|
481
|
-
/**
|
|
482
|
-
* Logs the event, props, and context optionally preceded by a custom message. Will only log in
|
|
483
|
-
development mode.
|
|
484
|
-
*
|
|
485
|
-
* Example:
|
|
486
|
-
* ```
|
|
487
|
-
import {forProp, handle, log} from '@enact/core/handle';
|
|
488
|
-
|
|
489
|
-
const logWhenChecked = handle(
|
|
490
|
-
forProp('checked', true),
|
|
491
|
-
log('checked props is true')
|
|
492
|
-
);
|
|
493
|
-
```
|
|
494
|
-
*/
|
|
495
|
-
export function log(message: string, ev: object): (args?: any[]) => true;
|
|
496
|
-
/**
|
|
497
|
-
* Invokes a method by name on the component to which is bound.
|
|
498
|
-
*
|
|
499
|
-
* If the methods exists on the object, it is called with the event, props, and context and its
|
|
500
|
-
return value is returned.
|
|
501
|
-
*
|
|
502
|
-
* If the method does not exist or handle isn't bound to an instance, it returns `false` .
|
|
503
|
-
*
|
|
504
|
-
* Example:
|
|
505
|
-
* ```
|
|
506
|
-
import {call, handle, forProp} from '@enact/core/handle';
|
|
507
|
-
|
|
508
|
-
const incrementIfEnabled = handle(
|
|
509
|
-
forProp('disabled', false),
|
|
510
|
-
call('increment')
|
|
511
|
-
);
|
|
512
|
-
|
|
513
|
-
class Counter extends React.Component {
|
|
514
|
-
constructor () {
|
|
515
|
-
super();
|
|
516
|
-
|
|
517
|
-
this.handleIncrement = incrementIfEnabled.bind(this);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
render () {
|
|
521
|
-
// ...
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
```
|
|
525
|
-
*/
|
|
526
|
-
export function call(method: string): HandlerFunction;
|
|
527
|
-
/**
|
|
528
|
-
* Adapts an event with `adapter` before calling `handler` .
|
|
529
|
-
*
|
|
530
|
-
* The `adapter` function receives the same arguments as any handler. The value returned from
|
|
531
|
-
`adapter` is passed as the first argument to `handler` with the remaining arguments kept the
|
|
532
|
-
same. This is often useful to generate a custom event payload before forwarding on to a callback.
|
|
533
|
-
*
|
|
534
|
-
* Example:
|
|
535
|
-
* ```
|
|
536
|
-
import {adaptEvent, forward} from '@enact/core/handle';
|
|
537
|
-
|
|
538
|
-
// calls the onChange callback with an event payload containing a type and value member
|
|
539
|
-
const incrementAndChange = adaptEvent(
|
|
540
|
-
(ev, props) => ({
|
|
541
|
-
type: 'onChange',
|
|
542
|
-
value: props.value + 1
|
|
543
|
-
}),
|
|
544
|
-
forward('onChange')
|
|
545
|
-
)
|
|
546
|
-
```
|
|
547
|
-
*/
|
|
548
|
-
export function adaptEvent(
|
|
549
|
-
adapter: EventAdapter,
|
|
550
|
-
handler: HandlerFunction
|
|
551
|
-
): HandlerFunction;
|
|
552
|
-
/**
|
|
553
|
-
* Adapts an event with `adapter` before calling `handler` .
|
|
554
|
-
*
|
|
555
|
-
* The `adapter` function receives the same arguments as any handler. The value returned from
|
|
556
|
-
`adapter` is passed as the first argument to `handler` with the remaining arguments kept the
|
|
557
|
-
same. This is often useful to generate a custom event payload before forwarding on to a callback.
|
|
558
|
-
*
|
|
559
|
-
* Example:
|
|
560
|
-
* ```
|
|
561
|
-
import {adaptEvent, forward} from '@enact/core/handle';
|
|
562
|
-
|
|
563
|
-
// calls the onChange callback with an event payload containing a type and value member
|
|
564
|
-
const incrementAndChange = adaptEvent(
|
|
565
|
-
(ev, props) => ({
|
|
566
|
-
type: 'onChange',
|
|
567
|
-
value: props.value + 1
|
|
568
|
-
}),
|
|
569
|
-
forward('onChange')
|
|
570
|
-
)
|
|
571
|
-
```
|
|
572
|
-
*/
|
|
573
|
-
export function adaptEvent(
|
|
574
|
-
adapter: EventAdapter
|
|
575
|
-
): (handler: HandlerFunction) => HandlerFunction;
|
|
576
|
-
/**
|
|
577
|
-
* Creates a handler that will forward the event to a function at `name` on `props` .
|
|
578
|
-
*
|
|
579
|
-
* If `adapter` is not specified, a new event payload will be generated with a `type` member with
|
|
580
|
-
the `name` of the custom event. If `adapter` is specified, the `type` member is added to the
|
|
581
|
-
value returned by `adapter` .
|
|
582
|
-
*
|
|
583
|
-
* The `adapter` function receives the same arguments as any handler. The value returned from
|
|
584
|
-
`adapter` is passed as the first argument to `handler` with the remaining arguments kept the
|
|
585
|
-
same. This is often useful to generate a custom event payload before forwarding on to a callback.
|
|
586
|
-
*
|
|
587
|
-
* Example:
|
|
588
|
-
* ```
|
|
589
|
-
import {forwardCustom} from '@enact/core/handle';
|
|
590
|
-
|
|
591
|
-
// calls the onChange callback with the event: {type: 'onChange'}
|
|
592
|
-
const forwardChange = forwardCustom('onChange');
|
|
593
|
-
|
|
594
|
-
// calls the onChange callback with the event: {type: 'onChange', index}
|
|
595
|
-
const forwardChangeWithIndex = forwardCustom('onChange', (ev, {index}) => ({index}));
|
|
596
|
-
```
|
|
597
|
-
*/
|
|
598
|
-
export function forwardCustom(
|
|
599
|
-
name: string,
|
|
600
|
-
adapter?: EventAdapter
|
|
601
|
-
): HandlerFunction;
|
|
602
|
-
/**
|
|
603
|
-
* Accepts a handler and returns the logical complement of the value returned from the handler.
|
|
604
|
-
*
|
|
605
|
-
* Example:
|
|
606
|
-
* ```
|
|
607
|
-
import {forProp, forward, not, handle} from '@enact/core/handle';
|
|
608
|
-
|
|
609
|
-
// calls the onChange callback when disabled is not true
|
|
610
|
-
const handleChange = handle(
|
|
611
|
-
not(forProp('disabled', true)),
|
|
612
|
-
forward('onChange')
|
|
613
|
-
)
|
|
614
|
-
```
|
|
615
|
-
*/
|
|
616
|
-
export function not(handler: HandlerFunction): HandlerFunction;
|
|
617
|
-
|
|
618
|
-
export default handle;
|
package/hoc/hoc.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/hoc
|
|
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
|
-
* Constructs a higher-order component (HOC) using an optional set of default configuration parameters and
|
|
8
|
-
a factory method that accepts instance configuration parameters and a component to wrap. The
|
|
9
|
-
returned function can accept:
|
|
10
|
-
* * an instance config and a component constructor to wrap and return a renderable component, or
|
|
11
|
-
* * an instance config only and return a decorator function expecting a component constructor
|
|
12
|
-
*
|
|
13
|
-
* (like the next bullet), or
|
|
14
|
-
* * a component constructor and return a renderable component
|
|
15
|
-
*
|
|
16
|
-
* Example:
|
|
17
|
-
* ```
|
|
18
|
-
const Countable = hoc({prop: 'data-count'}, (config, Wrapped) => {
|
|
19
|
-
return class extends React.Component {
|
|
20
|
-
constructor (props) {
|
|
21
|
-
super(props);
|
|
22
|
-
this.state = {
|
|
23
|
-
count: 0
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
inc = () => this.setState({count: this.state.count + 1}),
|
|
27
|
-
render () {
|
|
28
|
-
const props = Object.assign({}, this.props, {
|
|
29
|
-
[config.prop]: this.state.count,
|
|
30
|
-
onClick: this.inc
|
|
31
|
-
});
|
|
32
|
-
return <Wrapped {...props} />
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const CountableAsDataNumber({prop: 'data-number'});
|
|
38
|
-
const CountableDiv('div');
|
|
39
|
-
const CountableDivAsDataNumber = CountableAsDataNumber('div');
|
|
40
|
-
```
|
|
41
|
-
*/
|
|
42
|
-
export function hoc(defaultConfig: object, hawk: Function): Function;
|
|
43
|
-
|
|
44
|
-
export default hoc;
|
package/index.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/keymap/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/keymap
|
|
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
|
-
* Registers `keyCode` for `name` .
|
|
8
|
-
*/
|
|
9
|
-
export function add(name: string, keyCode: number | number[]): void;
|
|
10
|
-
/**
|
|
11
|
-
* Registers `keyCode` for `name` .
|
|
12
|
-
*/
|
|
13
|
-
export function add(name: string): (keyCode: number | number[]) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Registers a set of key codes.
|
|
16
|
-
*/
|
|
17
|
-
export function addAll(set: { [key: string]: number | number[] }): void;
|
|
18
|
-
/**
|
|
19
|
-
* Unregisters `keyCode` from `name` .
|
|
20
|
-
*/
|
|
21
|
-
export function remove(name: string, keyCode: number | number[]): void;
|
|
22
|
-
/**
|
|
23
|
-
* Unregisters `keyCode` from `name` .
|
|
24
|
-
*/
|
|
25
|
-
export function remove(name: string): (keyCode: number | number[]) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Unregisters a set of key codes.
|
|
28
|
-
*/
|
|
29
|
-
export function removeAll(set: object): void;
|
|
30
|
-
/**
|
|
31
|
-
* Determines if `keyCode` is mapped to `name` .
|
|
32
|
-
*/
|
|
33
|
-
export function is(name: string, keyCode: number): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Determines if `keyCode` is mapped to `name` .
|
|
36
|
-
*/
|
|
37
|
-
export function is(name: string): (keyCode: number) => boolean;
|
package/kind/kind.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/kind
|
|
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
|
-
export interface RenderFunction {
|
|
7
|
-
(props: { [key: string]: any }, context: { [key: string]: any }): any;
|
|
8
|
-
}
|
|
9
|
-
export interface ComputedPropFunction {
|
|
10
|
-
(props: { [key: string]: any }, context: { [key: string]: any }): any;
|
|
11
|
-
}
|
|
12
|
-
export interface HandlerFunction {
|
|
13
|
-
(
|
|
14
|
-
event: any,
|
|
15
|
-
props: { [key: string]: any },
|
|
16
|
-
context: { [key: string]: any }
|
|
17
|
-
): void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Configuration for CSS class name mapping
|
|
21
|
-
*/
|
|
22
|
-
export interface StylesBlock {
|
|
23
|
-
css: { [key: string]: string };
|
|
24
|
-
className?: string;
|
|
25
|
-
publicClassNames?: boolean | string | string[];
|
|
26
|
-
}
|
|
27
|
-
export interface KindConfig {
|
|
28
|
-
name?: string;
|
|
29
|
-
functional?: boolean;
|
|
30
|
-
propTypes?: { [key: string]: Function };
|
|
31
|
-
defaultProps?: { [key: string]: any };
|
|
32
|
-
contextType?: object;
|
|
33
|
-
styles?: StylesBlock;
|
|
34
|
-
handlers?: { [key: string]: HandlerFunction };
|
|
35
|
-
computed?: { [key: string]: ComputedPropFunction };
|
|
36
|
-
render: RenderFunction;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new component with some helpful declarative syntactic sugar.
|
|
40
|
-
*
|
|
41
|
-
* Example:
|
|
42
|
-
* ```
|
|
43
|
-
import css from './Button.module.less';
|
|
44
|
-
const Button = kind({
|
|
45
|
-
name: 'Button',
|
|
46
|
-
// Return a functional component suitable for use with React hooks
|
|
47
|
-
functional: true,
|
|
48
|
-
// expect color and onClick properties but neither required
|
|
49
|
-
propTypes: {
|
|
50
|
-
color: PropTypes.string
|
|
51
|
-
},
|
|
52
|
-
// if no color is provided, it'll be green
|
|
53
|
-
defaultProps: {
|
|
54
|
-
color: 'green'
|
|
55
|
-
},
|
|
56
|
-
// expect backgroundColor via context
|
|
57
|
-
contextType: React.createContext({ backgroundColor }),
|
|
58
|
-
// configure styles with the static className to merge with user className
|
|
59
|
-
styles: {
|
|
60
|
-
// include the CSS modules map so 'button' can be resolved to the local name
|
|
61
|
-
css,
|
|
62
|
-
className: 'button'
|
|
63
|
-
},
|
|
64
|
-
// add event handlers that are cached between calls to prevent recreating each call. Any
|
|
65
|
-
// handlers are added to the props passed to `render()`. See core/handle.
|
|
66
|
-
handlers: {
|
|
67
|
-
onKeyDown: (evt, props) => { .... }
|
|
68
|
-
},
|
|
69
|
-
// add some computed properties, these are added to props passed to `render()`
|
|
70
|
-
computed: {
|
|
71
|
-
// border color will be the color prepended by 'light'
|
|
72
|
-
borderColor: ({color}) => 'light' + color,
|
|
73
|
-
// background color will be the contextual background color if specified
|
|
74
|
-
color: ({color}, context) => context.backgroundColor || color
|
|
75
|
-
},
|
|
76
|
-
// Render the thing, already!
|
|
77
|
-
render: ({color, borderColor, children, ...rest}) => (
|
|
78
|
-
<button
|
|
79
|
-
{...rest}
|
|
80
|
-
style={{backgroundColor: color, borderColor}}
|
|
81
|
-
>
|
|
82
|
-
{children}
|
|
83
|
-
</button>
|
|
84
|
-
)
|
|
85
|
-
});
|
|
86
|
-
```
|
|
87
|
-
*/
|
|
88
|
-
export function kind<Props>(config: KindConfig): React.ComponentType<Props>;
|
|
89
|
-
|
|
90
|
-
export default kind;
|
package/platform/platform.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/platform
|
|
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
|
-
export interface PlatformDescription {
|
|
7
|
-
/**
|
|
8
|
-
* Additional information about the detected platform
|
|
9
|
-
*/
|
|
10
|
-
extra?: object
|
|
11
|
-
/**
|
|
12
|
-
* `true` if the platform has native double-finger events
|
|
13
|
-
*/;
|
|
14
|
-
gesture: boolean
|
|
15
|
-
/**
|
|
16
|
-
* `true` only if `window` is `undefined`
|
|
17
|
-
*/;
|
|
18
|
-
node: boolean
|
|
19
|
-
/**
|
|
20
|
-
* The name of the platform, if detected
|
|
21
|
-
*/;
|
|
22
|
-
platformName?: string
|
|
23
|
-
/**
|
|
24
|
-
* `true` if the platform has native single-finger events
|
|
25
|
-
*/;
|
|
26
|
-
touch: boolean
|
|
27
|
-
/**
|
|
28
|
-
* `true` if the platform has a touch screen
|
|
29
|
-
*/;
|
|
30
|
-
touchscreen: boolean
|
|
31
|
-
/**
|
|
32
|
-
* `true` for any unknown system
|
|
33
|
-
*/;
|
|
34
|
-
unknown: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Returns the object.
|
|
38
|
-
*/
|
|
39
|
-
export function detect(): PlatformDescription;
|
|
40
|
-
/**
|
|
41
|
-
* Provides basic information about the running platform.
|
|
42
|
-
*/
|
|
43
|
-
export declare const platform: PlatformDescription;
|
|
44
|
-
|
|
45
|
-
export default platform;
|
package/snapshot/snapshot.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Type definitions for core/snapshot
|
|
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
|
-
* Determines if the `window` is available
|
|
8
|
-
*/
|
|
9
|
-
export function isWindowReady(): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Executes a callback, such as registering event handlers, when a valid `window` is available.
|
|
12
|
-
*
|
|
13
|
-
* During normal operation, the callback will be executed immediately. During a pre-rendering pass,
|
|
14
|
-
the callback is not be executed at all. When using snapshot, the callback is added to a queue
|
|
15
|
-
and is executed in order once the window is available.
|
|
16
|
-
*
|
|
17
|
-
* _Important Notes_
|
|
18
|
-
* * The callback should not alter the initial HTML state. If it does, it will invalidate the
|
|
19
|
-
*
|
|
20
|
-
* pre-render state and interfere with React rehydration.
|
|
21
|
-
* * The callback should be limited to module-scoped actions and not component instance actions. If
|
|
22
|
-
*
|
|
23
|
-
* the action is tied to a component, it should be invoked from within the component's lifecycle
|
|
24
|
-
methods.
|
|
25
|
-
*/
|
|
26
|
-
export function onWindowReady(callback: Function): void;
|
|
27
|
-
/**
|
|
28
|
-
* Executes all queued window callbacks.
|
|
29
|
-
*
|
|
30
|
-
* Requires that the window be, in fact, available and will throw an `Error` if not.
|
|
31
|
-
*/
|
|
32
|
-
export function windowReady(): void;
|
|
File without changes
|
package/useClass/useClass.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/util/util.d.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
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;
|