@enact/spotlight 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 +2 -2
- package/Accelerator/Accelerator.d.ts +0 -31
- package/Pause/Pause.d.ts +0 -33
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.d.ts +0 -89
- package/SpotlightRootDecorator/SpotlightRootDecorator.d.ts +0 -22
- package/Spottable/Spottable.d.ts +0 -75
- package/src/spotlight.d.ts +0 -122
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/spotlight",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.1",
|
|
4
4
|
"description": "A focus management library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@enact/core": "^4.6.
|
|
27
|
+
"@enact/core": "^4.6.1",
|
|
28
28
|
"classnames": "^2.3.2",
|
|
29
29
|
"prop-types": "^15.8.1",
|
|
30
30
|
"ramda": "^0.28.0",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Type definitions for spotlight/Accelerator
|
|
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 declare class Accelerator {
|
|
7
|
-
constructor /**
|
|
8
|
-
* Controls the frequency with which the acceleration will
|
|
9
|
-
"freeze". While frozen, the current target item cannot change, and all events are directed
|
|
10
|
-
to it.
|
|
11
|
-
*/(frequency: number[]);
|
|
12
|
-
/**
|
|
13
|
-
* Called with the current keydown event and callback, which will be called when the event is
|
|
14
|
-
allowed through.
|
|
15
|
-
*/
|
|
16
|
-
processKey(event: object, callback: Function): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Resets the Accelerator instance to the default values.
|
|
19
|
-
*/
|
|
20
|
-
reset(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Cancels the Accelerator.
|
|
23
|
-
*/
|
|
24
|
-
cancel(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Verifies that the Accelerator is active.
|
|
27
|
-
*/
|
|
28
|
-
isAccelerating(): boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default Accelerator;
|
package/Pause/Pause.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Type definitions for spotlight/Pause
|
|
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
|
-
* Acts as a semaphore for Spotlight pause state ensuring that only the last Pause instance can
|
|
8
|
-
resume Spotlight.
|
|
9
|
-
*
|
|
10
|
-
* _Note_ will always resume spotlight regardless of what last
|
|
11
|
-
paused spotlight and can be used as an escape hatch to force resumption.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export declare class Pause {
|
|
15
|
-
constructor
|
|
16
|
-
/**
|
|
17
|
-
* The name of the pause instance
|
|
18
|
-
*/(name: string);
|
|
19
|
-
/**
|
|
20
|
-
* Returns `true` when Spotlight is paused by this instance
|
|
21
|
-
*/
|
|
22
|
-
isPaused(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Pauses spotlight if not currently paused
|
|
25
|
-
*/
|
|
26
|
-
pause(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Resumes spotlight if this instance was the last to pause spotlight
|
|
29
|
-
*/
|
|
30
|
-
resume(): boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default Pause;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Type definitions for spotlight/SpotlightContainerDecorator
|
|
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 class name to apply to the default component to focus in a container.
|
|
8
|
-
*/
|
|
9
|
-
export declare const spotlightDefaultClass: string;
|
|
10
|
-
export interface SpotlightContainerDecoratorConfig extends Object {
|
|
11
|
-
/**
|
|
12
|
-
* When `true` , allows focus to move outside the container to the next spottable element when
|
|
13
|
-
holding 5 way keys.
|
|
14
|
-
*/
|
|
15
|
-
continue5WayHold?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The selector for the default spottable element within the container.
|
|
18
|
-
When an array of selectors is provided, the first selector that successfully matches a
|
|
19
|
-
node is used.
|
|
20
|
-
*/
|
|
21
|
-
defaultElement?: string | string[];
|
|
22
|
-
/**
|
|
23
|
-
* Directs which element receives focus when gaining focus from another container. If
|
|
24
|
-
`'default-element'` , the default focused item will be selected. If `'last-focused'` , the
|
|
25
|
-
container will focus the last focused item; if the container has never had focus, the default
|
|
26
|
-
element will receive focus. If `null` , the default 5-way behavior will be applied.
|
|
27
|
-
*/
|
|
28
|
-
enterTo?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Filter the navigable elements.
|
|
31
|
-
*/
|
|
32
|
-
navigableFilter?: Function;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the container will preserve the specified `spotlightId` when it unmounts.
|
|
35
|
-
*/
|
|
36
|
-
preserveId?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Restricts or prioritizes navigation when focus attempts to leave the container. It
|
|
39
|
-
can be either 'none', 'self-first', or 'self-only'. Specifying 'self-first' indicates that
|
|
40
|
-
elements within the container will have a higher likelihood to be chosen as the next
|
|
41
|
-
navigable element. Specifying 'self-only' indicates that elements in other containers
|
|
42
|
-
cannot be navigated to by using 5-way navigation - however, elements in other containers
|
|
43
|
-
can still receive focus by calling `Spotlight.focus(elem)` explicitly. Specifying 'none'
|
|
44
|
-
indicates there should be no restrictions when 5-way navigating the container.
|
|
45
|
-
*/
|
|
46
|
-
restrict?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface SpotlightContainerDecoratorProps {
|
|
49
|
-
/**
|
|
50
|
-
* When `true` , controls in the container cannot be navigated.
|
|
51
|
-
*/
|
|
52
|
-
spotlightDisabled?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Used to identify this component within the Spotlight system.
|
|
55
|
-
*
|
|
56
|
-
* If the value is `null` , an id will be generated.
|
|
57
|
-
To keep the container information for restoring focus, it is required to specify
|
|
58
|
-
a unique identifier.
|
|
59
|
-
*/
|
|
60
|
-
spotlightId?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Whether or not the container is in muted mode.
|
|
63
|
-
*
|
|
64
|
-
* In muted mode, `:focus` CSS styles will not be applied to the
|
|
65
|
-
Spottable controls giving them the appearance of not having focus
|
|
66
|
-
while they still have focus.
|
|
67
|
-
*/
|
|
68
|
-
spotlightMuted?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Restricts or prioritizes navigation when focus attempts to leave the container. It
|
|
71
|
-
can be either 'none', 'self-first', or 'self-only'. Specifying 'self-first' indicates that
|
|
72
|
-
elements within the container will have a higher likelihood to be chosen as the next
|
|
73
|
-
navigable element. Specifying 'self-only' indicates that elements in other containers
|
|
74
|
-
cannot be navigated to by using 5-way navigation - however, elements in other containers
|
|
75
|
-
can still receive focus by calling `Spotlight.focus(elem)` explicitly. Specifying 'none'
|
|
76
|
-
indicates there should be no restrictions when 5-way navigating the container.
|
|
77
|
-
*/
|
|
78
|
-
spotlightRestrict?: string;
|
|
79
|
-
}
|
|
80
|
-
export function SpotlightContainerDecorator<P>(
|
|
81
|
-
config: SpotlightContainerDecoratorConfig,
|
|
82
|
-
Component: React.ComponentType<P> | string
|
|
83
|
-
): React.ComponentType<P & SpotlightContainerDecoratorProps>;
|
|
84
|
-
|
|
85
|
-
export function SpotlightContainerDecorator<P>(
|
|
86
|
-
Component: React.ComponentType<P> | string
|
|
87
|
-
): React.ComponentType<P & SpotlightContainerDecoratorProps>;
|
|
88
|
-
|
|
89
|
-
export default SpotlightContainerDecorator;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Type definitions for spotlight/SpotlightRootDecorator
|
|
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 SpotlightRootDecoratorConfig extends Object {
|
|
7
|
-
/**
|
|
8
|
-
* When `true` , the contents of the component will not receive spotlight focus after being rendered.
|
|
9
|
-
*/
|
|
10
|
-
noAutoFocus?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface SpotlightRootDecoratorProps {}
|
|
13
|
-
export function SpotlightRootDecorator<P>(
|
|
14
|
-
config: SpotlightRootDecoratorConfig,
|
|
15
|
-
Component: React.ComponentType<P> | string
|
|
16
|
-
): React.ComponentType<P & SpotlightRootDecoratorProps>;
|
|
17
|
-
|
|
18
|
-
export function SpotlightRootDecorator<P>(
|
|
19
|
-
Component: React.ComponentType<P> | string
|
|
20
|
-
): React.ComponentType<P & SpotlightRootDecoratorProps>;
|
|
21
|
-
|
|
22
|
-
export default SpotlightRootDecorator;
|
package/Spottable/Spottable.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Type definitions for spotlight/Spottable
|
|
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 class name for spottable components. In general, you do not need to directly access this class
|
|
8
|
-
*/
|
|
9
|
-
export declare const spottableClass: string;
|
|
10
|
-
export interface SpottableConfig extends Object {
|
|
11
|
-
/**
|
|
12
|
-
* Whether or not the component should emulate mouse events as a response
|
|
13
|
-
to Spotlight 5-way events.
|
|
14
|
-
*/
|
|
15
|
-
emulateMouse?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface SpottableProps {
|
|
18
|
-
/**
|
|
19
|
-
* Whether or not the component is in a disabled state.
|
|
20
|
-
*/
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* The handler to force update the component.
|
|
24
|
-
*/
|
|
25
|
-
handleForceUpdate?: Function;
|
|
26
|
-
/**
|
|
27
|
-
* The handler to run when the component is removed while retaining focus.
|
|
28
|
-
*/
|
|
29
|
-
onSpotlightDisappear?: Function;
|
|
30
|
-
/**
|
|
31
|
-
* The handler to run when the 5-way down key is pressed.
|
|
32
|
-
*/
|
|
33
|
-
onSpotlightDown?: Function;
|
|
34
|
-
/**
|
|
35
|
-
* The handler to run when the 5-way left key is pressed.
|
|
36
|
-
*/
|
|
37
|
-
onSpotlightLeft?: Function;
|
|
38
|
-
/**
|
|
39
|
-
* The handler to run when the 5-way right key is pressed.
|
|
40
|
-
*/
|
|
41
|
-
onSpotlightRight?: Function;
|
|
42
|
-
/**
|
|
43
|
-
* The handler to run when the 5-way up key is pressed.
|
|
44
|
-
*/
|
|
45
|
-
onSpotlightUp?: Function;
|
|
46
|
-
/**
|
|
47
|
-
* An array of numbers representing keyCodes that should trigger mouse event
|
|
48
|
-
emulation when `emulateMouse` is `true` . If a keyCode equals a directional
|
|
49
|
-
key, then default 5-way navigation will be prevented when that key is pressed.
|
|
50
|
-
*/
|
|
51
|
-
selectionKeys?: number[];
|
|
52
|
-
/**
|
|
53
|
-
* When `true` , the component cannot be navigated using spotlight.
|
|
54
|
-
*/
|
|
55
|
-
spotlightDisabled?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Used to identify this component within the Spotlight system
|
|
58
|
-
*/
|
|
59
|
-
spotlightId?: string;
|
|
60
|
-
/**
|
|
61
|
-
* The tabIndex of the component. This value will default to -1 if left
|
|
62
|
-
unset and the control is spottable.
|
|
63
|
-
*/
|
|
64
|
-
tabIndex?: number;
|
|
65
|
-
}
|
|
66
|
-
export function Spottable<P>(
|
|
67
|
-
config: SpottableConfig,
|
|
68
|
-
Component: React.ComponentType<P> | string
|
|
69
|
-
): React.ComponentType<P & SpottableProps>;
|
|
70
|
-
|
|
71
|
-
export function Spottable<P>(
|
|
72
|
-
Component: React.ComponentType<P> | string
|
|
73
|
-
): React.ComponentType<P & SpottableProps>;
|
|
74
|
-
|
|
75
|
-
export default Spottable;
|
package/src/spotlight.d.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// Type definitions for spotlight
|
|
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
|
-
* Translates keyCodes into 5-way direction descriptions (e.g. `'down'` )
|
|
8
|
-
*/
|
|
9
|
-
export function getDirection(keyCode: number): string | false;
|
|
10
|
-
/**
|
|
11
|
-
* Provides 5-way navigation and focus support
|
|
12
|
-
* ```
|
|
13
|
-
import Spotlight from '@enact/Spotlight';
|
|
14
|
-
|
|
15
|
-
// get the currently focused component
|
|
16
|
-
const current = Spotlight.getCurrent();
|
|
17
|
-
|
|
18
|
-
// focus an element by CSS selector
|
|
19
|
-
Spotlight.focus('.my-custom-class');
|
|
20
|
-
|
|
21
|
-
// is `current` focusable?
|
|
22
|
-
const isFocused = Spotlight.isSpottable(current);
|
|
23
|
-
```
|
|
24
|
-
*/
|
|
25
|
-
export declare const Spotlight: {
|
|
26
|
-
/**
|
|
27
|
-
* Initializes Spotlight. This is generally handled by
|
|
28
|
-
.
|
|
29
|
-
*/
|
|
30
|
-
initialize(containerDefaults: object): void;
|
|
31
|
-
/**
|
|
32
|
-
* Terminates Spotlight. This is generally handled by .
|
|
33
|
-
*/
|
|
34
|
-
terminate(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Sets the config for spotlight or the specified containerID
|
|
37
|
-
*/
|
|
38
|
-
set(containerIdOrConfig: string | object, config?: object): void;
|
|
39
|
-
/**
|
|
40
|
-
* Adds the config for a new container. The container ID may be passed in the configuration
|
|
41
|
-
object. If no container ID is supplied, a new container ID will be generated.
|
|
42
|
-
*/
|
|
43
|
-
add(containerIdOrConfig: string | object, config?: object): string;
|
|
44
|
-
/**
|
|
45
|
-
* Removes a container from Spotlight
|
|
46
|
-
*/
|
|
47
|
-
remove(containerId: string): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Disables the selector rules of the specified container
|
|
50
|
-
*/
|
|
51
|
-
disableSelector(containerId: string): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Enables the selector rules of the specified container
|
|
54
|
-
*/
|
|
55
|
-
enableSelector(containerId: string): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Pauses Spotlight
|
|
58
|
-
*/
|
|
59
|
-
pause(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Resumes Spotlight
|
|
62
|
-
*/
|
|
63
|
-
resume(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Focuses the specified component ID, container ID, element selector, or the default
|
|
66
|
-
container.
|
|
67
|
-
*
|
|
68
|
-
* If Spotlight is in pointer mode, focus is not changed but `elem` will be set as the last
|
|
69
|
-
focused element of its spotlight containers.
|
|
70
|
-
*/
|
|
71
|
-
focus(elem?: string | React.ReactNode, containerOption?: object): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Moves focus to the next spottable control in the direction specified. Optionally, a source
|
|
74
|
-
element selector may be supplied as the starting point.
|
|
75
|
-
*/
|
|
76
|
-
move(direction: string, selector: string | void): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Sets or clears the default container that will receive focus.
|
|
79
|
-
*/
|
|
80
|
-
setDefaultContainer(containerId?: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Gets the currently active container.
|
|
83
|
-
*/
|
|
84
|
-
getActiveContainer(): string;
|
|
85
|
-
/**
|
|
86
|
-
* Sets the currently active container.
|
|
87
|
-
*
|
|
88
|
-
* Note: If the current container is restricted to 'self-only' and `containerId` is not
|
|
89
|
-
contained within the current container then the active container will not be updated.
|
|
90
|
-
*/
|
|
91
|
-
setActiveContainer(containerId?: string): void;
|
|
92
|
-
/**
|
|
93
|
-
* Gets the current pointer mode
|
|
94
|
-
*/
|
|
95
|
-
getPointerMode(): boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Sets the current pointer mode
|
|
98
|
-
*/
|
|
99
|
-
setPointerMode(pointerMode: boolean): void;
|
|
100
|
-
/**
|
|
101
|
-
* Gets the muted mode value of a spottable element.
|
|
102
|
-
*/
|
|
103
|
-
isMuted(elem: object): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Determines whether Spotlight is currently paused.
|
|
106
|
-
*/
|
|
107
|
-
isPaused(): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Determines whether an element is spottable.
|
|
110
|
-
*/
|
|
111
|
-
isSpottable(elem: object): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Returns the currently spotted control.
|
|
114
|
-
*/
|
|
115
|
-
getCurrent(): React.ReactNode;
|
|
116
|
-
/**
|
|
117
|
-
* Returns a list of spottable elements wrapped by the supplied container.
|
|
118
|
-
*/
|
|
119
|
-
getSpottableDescendants(containerId: string): React.ReactNode[];
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export default Spotlight;
|