@enact/core 4.5.2 → 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.
Files changed (61) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dispatcher/dispatcher.js +15 -27
  3. package/dispatcher/listeners.js +0 -8
  4. package/dispatcher/tests/dispatcher-specs.js +0 -3
  5. package/handle/handle.js +40 -98
  6. package/handle/tests/handle-specs.js +21 -42
  7. package/hoc/hoc.js +2 -13
  8. package/hoc/tests/hoc-specs.js +0 -23
  9. package/internal/ApiDecorator/ApiDecorator.js +4 -34
  10. package/internal/ApiDecorator/tests/ApiDecorator-specs.js +69 -40
  11. package/internal/Registry/Registry.js +0 -7
  12. package/internal/Registry/tests/Registry-specs.js +26 -78
  13. package/internal/deprecate/deprecate.js +9 -22
  14. package/internal/deprecate/tests/deprecate-specs.js +38 -0
  15. package/internal/prop-types/prop-types.js +3 -20
  16. package/internal/prop-types/tests/prop-types-specs.js +265 -0
  17. package/keymap/index.js +2 -3
  18. package/keymap/keymap.js +10 -18
  19. package/keymap/tests/keymap-specs.js +0 -3
  20. package/kind/computed.js +2 -9
  21. package/kind/kind.js +14 -53
  22. package/kind/styles.js +6 -19
  23. package/kind/tests/computed-specs.js +4 -6
  24. package/kind/tests/kind-specs.js +9 -44
  25. package/kind/tests/styles-specs.js +12 -7
  26. package/kind/util.js +0 -2
  27. package/package.json +8 -2
  28. package/platform/platform.js +51 -57
  29. package/platform/tests/platform-specs.js +31 -3
  30. package/snapshot/snapshot.js +4 -9
  31. package/snapshot/tests/snapshot-specs.js +56 -0
  32. package/useChainRefs/tests/useChainRefs-specs.js +0 -14
  33. package/useChainRefs/useChainRefs.js +3 -11
  34. package/useClass/tests/useClass-specs.js +6 -21
  35. package/useClass/useClass.js +0 -8
  36. package/useHandlers/Handlers.js +0 -11
  37. package/useHandlers/tests/useHandlers-specs.js +11 -23
  38. package/useHandlers/useHandlers.js +0 -5
  39. package/usePublicClassNames/tests/usePublicClassNames-specs.js +21 -28
  40. package/usePublicClassNames/usePublicClassNames.js +4 -10
  41. package/util/Job.js +1 -43
  42. package/util/tests/Job-specs.js +48 -14
  43. package/util/tests/util-specs.js +125 -10
  44. package/util/util.js +15 -54
  45. package/dispatcher/dispatcher.d.ts +0 -21
  46. package/handle/handle.d.ts +0 -618
  47. package/hoc/hoc.d.ts +0 -44
  48. package/index.d.ts +0 -0
  49. package/internal/ApiDecorator/ApiDecorator.d.ts +0 -0
  50. package/internal/Registry/Registry.d.ts +0 -0
  51. package/internal/deprecate/deprecate.d.ts +0 -0
  52. package/internal/prop-types/prop-types.d.ts +0 -0
  53. package/keymap/index.d.ts +0 -37
  54. package/kind/kind.d.ts +0 -90
  55. package/platform/platform.d.ts +0 -45
  56. package/snapshot/snapshot.d.ts +0 -32
  57. package/useChainRefs/useChainRefs.d.ts +0 -0
  58. package/useClass/useClass.d.ts +0 -0
  59. package/useHandlers/useHandlers.d.ts +0 -0
  60. package/usePublicClassNames/usePublicClassNames.d.ts +0 -0
  61. package/util/util.d.ts +0 -162
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;
@@ -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;
@@ -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
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;