@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7

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 (68) hide show
  1. package/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
  2. package/Accelerator/Accelerator.js +149 -156
  3. package/CHANGELOG.md +22 -0
  4. package/{build/Pause → Pause}/Pause.d.ts +0 -0
  5. package/Pause/Pause.js +102 -80
  6. package/Pause/tests/Pause-specs.js +65 -97
  7. package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
  8. package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
  9. package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
  10. package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
  11. package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
  12. package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
  13. package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
  14. package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
  15. package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
  16. package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
  17. package/Spottable/Spottable.js +448 -410
  18. package/Spottable/tests/Spottable-specs.js +90 -117
  19. package/package.json +3 -2
  20. package/src/container.js +718 -653
  21. package/src/navigate.js +406 -491
  22. package/src/pointer.js +86 -78
  23. package/{build/src → src}/spotlight.d.ts +0 -0
  24. package/src/spotlight.js +846 -885
  25. package/src/target.js +448 -474
  26. package/src/tests/container-specs.js +643 -1251
  27. package/src/tests/navigate-specs.js +77 -134
  28. package/src/tests/pointer-specs.js +126 -182
  29. package/src/tests/spotlight-specs.js +103 -133
  30. package/src/tests/target-specs.js +597 -960
  31. package/src/tests/utils.js +89 -67
  32. package/src/utils.js +155 -158
  33. package/build/Accelerator/Accelerator.js +0 -162
  34. package/build/Accelerator/package.json +0 -3
  35. package/build/CHANGELOG.md +0 -838
  36. package/build/Pause/Pause.js +0 -164
  37. package/build/Pause/package.json +0 -3
  38. package/build/Pause/tests/Pause-specs.js +0 -65
  39. package/build/README.md +0 -61
  40. package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
  41. package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
  42. package/build/SpotlightContainerDecorator/package.json +0 -3
  43. package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
  44. package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
  45. package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
  46. package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
  47. package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
  48. package/build/SpotlightRootDecorator/package.json +0 -3
  49. package/build/Spottable/Spottable.js +0 -491
  50. package/build/Spottable/package.json +0 -3
  51. package/build/Spottable/tests/Spottable-specs.js +0 -90
  52. package/build/package-lock.json +0 -229
  53. package/build/package.json +0 -28
  54. package/build/src/container.js +0 -1201
  55. package/build/src/navigate.js +0 -419
  56. package/build/src/pointer.js +0 -183
  57. package/build/src/spotlight.js +0 -896
  58. package/build/src/target.js +0 -507
  59. package/build/src/tests/container-specs.js +0 -653
  60. package/build/src/tests/navigate-specs.js +0 -87
  61. package/build/src/tests/pointer-specs.js +0 -130
  62. package/build/src/tests/spotlight-specs.js +0 -112
  63. package/build/src/tests/target-specs.js +0 -614
  64. package/build/src/tests/utils.js +0 -104
  65. package/build/src/utils.js +0 -180
  66. package/build/styles/debug.less +0 -97
  67. package/build/styles/mixins.less +0 -63
  68. package/docs/index.md +0 -364
@@ -1,104 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testScenario = exports.spottable = exports.someSpottablesAndContainers = exports.someSpottables = exports.someNodes = exports.someContainers = exports.node = exports.join = exports.generateContainerId = exports.container = void 0;
7
-
8
- var _ramda = _interopRequireDefault(require("ramda"));
9
-
10
- var _container = require("../container");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
- var join = _ramda["default"].unapply(_ramda["default"].join('\n'));
21
-
22
- exports.join = join;
23
-
24
- var testScenario = function testScenario(scenario, callback) {
25
- return function () {
26
- var rootId = 'test-root';
27
- var html = join("<div id=\"".concat(rootId, "\">"), scenario, '</div>');
28
- document.body.innerHTML = html;
29
- var root = document.getElementById(rootId);
30
-
31
- try {
32
- callback(root);
33
- } catch (e) {
34
- console.log(html); // eslint-disable-line no-console
35
-
36
- throw e;
37
- }
38
- };
39
- };
40
-
41
- exports.testScenario = testScenario;
42
- var _id = 1;
43
-
44
- var generateContainerId = function generateContainerId() {
45
- return "".concat(_container.containerAttribute, "=").concat(_id++);
46
- };
47
-
48
- exports.generateContainerId = generateContainerId;
49
-
50
- var coerceProps = function coerceProps(v) {
51
- if (typeof v === 'object') {
52
- return v;
53
- } else if (typeof v !== 'undefined') {
54
- return {
55
- children: v
56
- };
57
- }
58
- };
59
-
60
- var node = function node(props) {
61
- var children = '';
62
- var attributes = '';
63
- Object.keys(props).forEach(function (key) {
64
- if (key === 'children') {
65
- children = props.children;
66
- } else {
67
- var value = props[key];
68
- if (key === 'className') key = 'class';
69
- attributes += "".concat(key, "=\"").concat(value, "\" ");
70
- }
71
- });
72
- return "<div ".concat(attributes, ">").concat(children, "</div>");
73
- };
74
-
75
- exports.node = node;
76
-
77
- var spottable = function spottable(props) {
78
- return node(_objectSpread({
79
- className: 'spottable'
80
- }, coerceProps(props)));
81
- };
82
-
83
- exports.spottable = spottable;
84
-
85
- var container = function container(props) {
86
- var _objectSpread2;
87
-
88
- return node(_objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, _container.containerAttribute, _id++), _defineProperty(_objectSpread2, 'data-spotlight-container', true), _objectSpread2), coerceProps(props)));
89
- }; // eslint-disable-next-line react-hooks/rules-of-hooks
90
-
91
-
92
- exports.container = container;
93
-
94
- var someNodes = _ramda["default"].useWith(_ramda["default"].compose(_ramda["default"].join('\n'), _ramda["default"].map), [_ramda["default"].identity, _ramda["default"].range(0)]);
95
-
96
- exports.someNodes = someNodes;
97
- var someSpottables = someNodes(spottable);
98
- exports.someSpottables = someSpottables;
99
- var someContainers = someNodes(container);
100
- exports.someContainers = someContainers;
101
-
102
- var someSpottablesAndContainers = _ramda["default"].converge(_ramda["default"].concat, [someSpottables, someContainers]);
103
-
104
- exports.someSpottablesAndContainers = someSpottablesAndContainers;
@@ -1,180 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getContainerRect = getContainerRect;
7
- exports.getPointRect = getPointRect;
8
- exports.getRect = getRect;
9
- exports.getRects = getRects;
10
- exports.parseSelector = parseSelector;
11
- exports.matchSelector = exports.intersects = exports.contains = void 0;
12
-
13
- var _curry = _interopRequireDefault(require("ramda/src/curry"));
14
-
15
- var _warning = _interopRequireDefault(require("warning"));
16
-
17
- var _container = require("./container");
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
-
21
- var elementMatchesSelector = function elementMatchesSelector(selector) {
22
- var matchedNodes = (this.parentNode || this.document).querySelectorAll(selector);
23
- return [].slice.call(matchedNodes).indexOf(this) >= 0;
24
- };
25
-
26
- if (typeof window === 'object') {
27
- elementMatchesSelector = window.Element.prototype.matches || window.Element.prototype.matchesSelector || window.Element.prototype.mozMatchesSelector || window.Element.prototype.webkitMatchesSelector || window.Element.prototype.msMatchesSelector || window.Element.prototype.oMatchesSelector || elementMatchesSelector;
28
- }
29
-
30
- var matchSelector = (0, _curry["default"])(function (selector, elem) {
31
- if (typeof selector === 'string') {
32
- return elementMatchesSelector.call(elem, selector);
33
- } else if (typeof selector === 'object' && selector.length) {
34
- return selector.indexOf(elem) >= 0;
35
- } else if (typeof selector === 'object' && selector.nodeType === 1) {
36
- return elem === selector;
37
- }
38
-
39
- return false;
40
- });
41
- exports.matchSelector = matchSelector;
42
-
43
- function parseSelector(selector) {
44
- var result = [];
45
-
46
- try {
47
- if (typeof selector === 'string') {
48
- result = [].slice.call(document.querySelectorAll(selector));
49
- } else if (typeof selector === 'object' && selector.length) {
50
- result = [].slice.call(selector);
51
- } else if (typeof selector === 'object' && selector.nodeType === 1) {
52
- result = [selector];
53
- }
54
- } catch (ex) {
55
- process.env.NODE_ENV !== "production" ? (0, _warning["default"])(true, "parseSelector failed for selector: ".concat(selector)) : void 0;
56
- }
57
-
58
- return result;
59
- }
60
-
61
- var testIntersection = function testIntersection(type, containerRect, elementRect) {
62
- var L = containerRect.left,
63
- R = containerRect.right,
64
- T = containerRect.top,
65
- B = containerRect.bottom;
66
- var l = elementRect.left,
67
- r = elementRect.right,
68
- t = elementRect.top,
69
- b = elementRect.bottom;
70
- var right = r >= L && r <= R;
71
- var left = l >= L && l <= R;
72
- var top = t >= T && t <= B;
73
- var bottom = b >= T && b <= B;
74
-
75
- if (type === 'intersects') {
76
- var aroundV = t < T && b > B;
77
- var aroundH = l < L && r > R;
78
- return (top || bottom || aroundV) && (left || right || aroundH);
79
- } else if (type === 'contains') {
80
- return top && bottom && left && right;
81
- }
82
-
83
- return true;
84
- };
85
-
86
- var intersects = (0, _curry["default"])(function (containerRect, elementRect) {
87
- return testIntersection('intersects', containerRect, elementRect);
88
- });
89
- exports.intersects = intersects;
90
- var contains = (0, _curry["default"])(function (containerRect, elementRect) {
91
- return testIntersection('contains', containerRect, elementRect);
92
- });
93
- exports.contains = contains;
94
-
95
- function getRect(elem) {
96
- var cr = elem.getBoundingClientRect();
97
- var rect = {
98
- left: cr.left,
99
- top: cr.top,
100
- width: cr.width,
101
- height: cr.height
102
- };
103
- rect.element = elem;
104
- rect.right = rect.left + rect.width;
105
- rect.bottom = rect.top + rect.height;
106
- rect.center = {
107
- x: rect.left + Math.floor(rect.width / 2),
108
- y: rect.top + Math.floor(rect.height / 2)
109
- };
110
- rect.center.left = rect.center.right = rect.center.x;
111
- rect.center.top = rect.center.bottom = rect.center.y;
112
- return rect;
113
- }
114
-
115
- function getPointRect(position) {
116
- var x = position.x,
117
- y = position.y;
118
- return {
119
- left: x,
120
- top: y,
121
- width: 0,
122
- height: 0,
123
- right: x,
124
- bottom: y,
125
- center: {
126
- x: x,
127
- y: y,
128
- left: x,
129
- right: x,
130
- top: y,
131
- bottom: y
132
- }
133
- };
134
- }
135
-
136
- function getRects(candidates) {
137
- if (candidates && candidates.length > 0) {
138
- return candidates.map(getRect);
139
- }
140
-
141
- return [];
142
- }
143
-
144
- function getViewportRect() {
145
- var _window = window,
146
- width = _window.innerWidth,
147
- height = _window.innerHeight;
148
- var x = width / 2;
149
- var y = height / 2;
150
- return {
151
- left: 0,
152
- top: 0,
153
- width: width,
154
- height: height,
155
- right: width,
156
- bottom: height,
157
- center: {
158
- x: x,
159
- y: y,
160
- left: x,
161
- right: x,
162
- top: y,
163
- bottom: y
164
- }
165
- };
166
- }
167
-
168
- function getContainerRect(containerId) {
169
- var containerNode = (0, _container.getContainerNode)(containerId);
170
-
171
- if (!containerNode) {
172
- return null;
173
- }
174
-
175
- if (containerNode === document) {
176
- return getViewportRect();
177
- }
178
-
179
- return getRect(containerNode);
180
- }
@@ -1,97 +0,0 @@
1
- //
2
- // Spotlight Debug
3
- //
4
-
5
- :global {
6
- .debug.spotlight {
7
- @debug-color-up: hsla(0, 100%, 72%, 1);
8
- @debug-color-right: hsla(90, 100%, 72%, 1);
9
- @debug-color-down: hsla(180, 100%, 72%, 1);
10
- @debug-color-left: hsla(240, 100%, 72%, 1);
11
-
12
- .spottable-next-up,
13
- .spottable-next-right,
14
- .spottable-next-down,
15
- .spottable-next-left {
16
- // outline: 3px dotted transparent;
17
- // box-shadow: 0;
18
-
19
- &::after {
20
- content: '';
21
- position: absolute;
22
- top: 0;
23
- border-width: 0 1px 1px 0;
24
- border-style: solid;
25
- border-bottom-right-radius: 0.5ex;
26
- // font-family: "Moonstone Miso";
27
- font-size: 15px;
28
- line-height: 18px;
29
- padding: 0 1ex;
30
- left: 0;
31
-
32
- border-width: 0 1px 1px 1px;
33
- border-bottom-right-radius: 0.5ex;
34
- border-bottom-left-radius: 0.5ex;
35
- left: 50%;
36
- transform: translateX(-50%);
37
- }
38
- }
39
-
40
- .spottable-next-up { box-shadow: 0 12px 9px -3px @debug-color-up, 0 0 1px 3px @debug-color-up; &::after { content: 'Spotlight next: up'; color: @debug-color-up; }}
41
- .spottable-next-right { box-shadow: -12px 0 9px -3px @debug-color-right, 0 0 1px 3px @debug-color-right; &::after { content: 'Spotlight next: right'; color: @debug-color-right; }}
42
- .spottable-next-down { box-shadow: 0 -12px 9px -3px @debug-color-down, 0 0 1px 3px @debug-color-down; &::after { content: 'Spotlight next: down'; color: @debug-color-down; }}
43
- .spottable-next-left { box-shadow: 12px 0 9px -3px @debug-color-left, 0 0 1px 3px @debug-color-left; &::after { content: 'Spotlight next: left'; color: @debug-color-left; }}
44
-
45
-
46
- // Below are some alternative visuals still being worked out.
47
-
48
- //
49
- // Crisp shadow-arrows
50
- //
51
- // .spottable-next-up { box-shadow:
52
- // 0 3px 1px -1px @debug-color-up,
53
- // 0 12px 1px -3px @debug-color-up,
54
- // 0 21px 1px -9px @debug-color-up,
55
- // 0 30px 1px -15px @debug-color-up,
56
- // 0 39px 1px -21px @debug-color-up,
57
- // 0 0 1px 3px @debug-color-up;
58
- // &::after { content: 'Spotlight next: up'; color: @debug-color-up; }
59
- // }
60
- // .spottable-next-right { box-shadow:
61
- // -3px 0 1px -1px @debug-color-right,
62
- // -12px 0 1px -3px @debug-color-right,
63
- // -21px 0 1px -9px @debug-color-right,
64
- // -30px 0 1px -15px @debug-color-right,
65
- // -39px 0 1px -21px @debug-color-right,
66
- // 0 0 1px 3px @debug-color-right;
67
- // &::after { content: 'Spotlight next: right'; color: @debug-color-right; }
68
- // }
69
- // .spottable-next-down { box-shadow:
70
- // 0 -3px 1px -1px @debug-color-down,
71
- // 0 -12px 1px -3px @debug-color-down,
72
- // 0 -21px 1px -9px @debug-color-down,
73
- // 0 -30px 1px -15px @debug-color-down,
74
- // 0 -39px 1px -21px @debug-color-down,
75
- // 0 0 1px 3px @debug-color-down;
76
- // &::after { content: 'Spotlight next: down'; color: @debug-color-down; }
77
- // }
78
- // .spottable-next-left { box-shadow:
79
- // 3px 0 1px -1px @debug-color-left,
80
- // 12px 0 1px -3px @debug-color-left,
81
- // 21px 0 1px -9px @debug-color-left,
82
- // 30px 0 1px -15px @debug-color-left,
83
- // 39px 0 1px -21px @debug-color-left,
84
- // 0 0 1px 3px @debug-color-left;
85
- // &::after { content: 'Spotlight next: left'; color: @debug-color-left; }
86
- // }
87
-
88
- //
89
- // Plain Boxy Outlines
90
- //
91
- // .spottable-next-up { outline-color: @debug-color-up; &::after { content: 'Spotlight next: up'; color: @debug-color-up; }}
92
- // .spottable-next-right { outline-color: @debug-color-right; &::after { content: 'Spotlight next: right'; color: @debug-color-right; }}
93
- // .spottable-next-down { outline-color: @debug-color-down; &::after { content: 'Spotlight next: down'; color: @debug-color-down; }}
94
- // .spottable-next-left { outline-color: @debug-color-left; &::after { content: 'Spotlight next: left'; color: @debug-color-left; }}
95
- }
96
- }
97
-
@@ -1,63 +0,0 @@
1
- //
2
- // Spotlight Mixins
3
- //
4
-
5
- // Spottable elements
6
- .spottable(@rules; @target) when (isruleset(@rules)) and (@target = parent) {
7
- :global(.spottable) {
8
- @rules();
9
- }
10
- }
11
- .spottable(@rules) when (isruleset(@rules)) {
12
- &:global(.spottable) {
13
- @rules();
14
- }
15
- }
16
-
17
- // Focused Spottable elements
18
- .focus(@rules; @target) when (isruleset(@rules)) and (@target = parent) {
19
- :global(.non-touch-mode) & {
20
- .spottable({
21
- &:focus {
22
- @rules();
23
- }
24
- }, @target);
25
- }
26
-
27
- :global(.touch-mode) & {
28
- .spottable({
29
- &:active {
30
- @rules();
31
- }
32
- }, @target);
33
- }
34
- }
35
- .focus(@rules) when (isruleset(@rules)) {
36
- :global(.non-touch-mode) & {
37
- .spottable({
38
- &:focus {
39
- @rules();
40
- }
41
- });
42
- }
43
-
44
- :global(.touch-mode) & {
45
- .spottable({
46
- &:active {
47
- @rules();
48
- }
49
- });
50
- }
51
- }
52
-
53
- // Muted elements
54
- .muted(@rules; @target) when (isruleset(@rules)) and (@target = parent) {
55
- [data-spotlight-container-muted="true"] {
56
- @rules();
57
- }
58
- }
59
- .muted(@rules) when (isruleset(@rules)) {
60
- &[data-spotlight-container-muted="true"] {
61
- @rules();
62
- }
63
- }