@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,3 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Accelerator = exports["default"] = void 0;
7
+
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+
1
10
  /**
2
11
  * Provides the {@link spotlight/Accelerator.Accelerator} class.
3
12
  *
@@ -9,161 +18,145 @@
9
18
  * @class Accelerator
10
19
  * @memberof spotlight/Accelerator
11
20
  */
12
- class Accelerator {
13
- /**
14
- * @constructor
15
- * @param {Number[]} frequency - Controls the frequency with which the acceleration will
16
- * "freeze". While frozen, the current target item cannot change, and all events are directed
17
- * to it.
18
- * @memberof spotlight/Accelerator.Accelerator.prototype
19
- */
20
- constructor (frequency = [3, 3, 3, 2, 2, 2, 1]) {
21
-
22
- /*
23
- * Whether the instance is currently in an accelerating state.
24
- *
25
- * @type {Boolean}
26
- * @default false
27
- */
28
- this.accelerating = false;
29
-
30
- /*
31
- * The current count of skipped events.
32
- *
33
- * @type {Number}
34
- * @default 0
35
- */
36
- this.skipped = 0;
37
-
38
- /*
39
- * The timestamp of the last evaluated event.
40
- *
41
- * @type {Number}
42
- * @default 0
43
- */
44
- this.time = 0;
45
-
46
- /*
47
- * The keyCode of the last evaluated event.
48
- *
49
- * @type {Number}
50
- * @default 0
51
- */
52
- this.keyCode = 0;
53
-
54
- /*
55
- * Whether the instance is in a state of being canceled.
56
- *
57
- * @type {Boolean}
58
- * @default false
59
- */
60
- this.canceled = false;
61
-
62
- /*
63
- * Controls the frequency with which the acceleration will "freeze". While frozen,
64
- * the current target item cannot change, and all events are directed to it.
65
- *
66
- * @type {Number[]}
67
- * @default [3, 3, 3, 2, 2, 2, 1]
68
- * @public
69
- */
70
- this.frequency = frequency;
71
- }
72
-
73
- /**
74
- * Called with the current keydown event and callback, which will be called when the event is
75
- * allowed through.
76
- *
77
- * @function
78
- * @param {Object} event - The current event to validate.
79
- * @param {Function} callback - The callback to execute.
80
- * @returns {Boolean} `true` if the event was consumed by processKey and callback was not called
81
- * @public
82
- * @memberof spotlight/Accelerator.Accelerator.prototype
83
- */
84
- processKey = (event, callback) => {
85
- switch (event.type) {
86
- case 'keydown':
87
- if (event.keyCode !== this.keyCode) {
88
- this.reset();
89
- this.time = Date.now();
90
- this.keyCode = event.keyCode;
91
- return callback(event);
92
- } else if (this.canceled) {
93
-
94
- // Prevent skipped keydown events from bubbling
95
- event.preventDefault();
96
- return true;
97
- } else {
98
- let elapsedTime = Date.now() - this.time,
99
- seconds = Math.floor(elapsedTime / 1000),
100
- toSkip = 0;
101
-
102
- seconds = seconds > this.frequency.length - 1 ? this.frequency.length - 1 : seconds;
103
-
104
- toSkip = this.frequency[seconds] - 1;
105
- if (toSkip < 0) {
106
- toSkip = 0;
107
- }
108
-
109
- this.accelerating = !(seconds === 0 && this.skipped === 0);
110
-
111
- if (this.skipped >= toSkip) {
112
- this.skipped = 0;
113
- return callback(event);
114
- } else {
115
- this.skipped++;
116
- // Prevent skipped keydown events from bubbling
117
- event.preventDefault();
118
- return true;
119
- }
120
- }
121
- case 'keyup':
122
- this.reset();
123
- return callback(event);
124
- }
125
- };
126
-
127
- /**
128
- * Resets the Accelerator instance to the default values.
129
- *
130
- * @function
131
- * @returns {undefined}
132
- * @public
133
- * @memberof spotlight/Accelerator.Accelerator.prototype
134
- */
135
- reset = () => {
136
- this.skipped = 0;
137
- this.time = 0;
138
- this.keyCode = 0;
139
- this.canceled = false;
140
- this.accelerating = false;
141
- };
142
-
143
- /**
144
- * Cancels the Accelerator.
145
- *
146
- * @function
147
- * @returns {undefined}
148
- * @public
149
- * @memberof spotlight/Accelerator.Accelerator.prototype
150
- */
151
- cancel = () => {
152
- this.canceled = true;
153
- };
154
-
155
- /**
156
- * Verifies that the Accelerator is active.
157
- *
158
- * @function
159
- * @returns {Boolean} `true` if the Accelerator is active; otherwise, `false`.
160
- * @public
161
- * @memberof spotlight/Accelerator.Accelerator.prototype
162
- */
163
- isAccelerating = () => {
164
- return this.accelerating;
165
- };
21
+ var Accelerator =
22
+ /**
23
+ * @constructor
24
+ * @param {Number[]} frequency - Controls the frequency with which the acceleration will
25
+ * "freeze". While frozen, the current target item cannot change, and all events are directed
26
+ * to it.
27
+ * @memberof spotlight/Accelerator.Accelerator.prototype
28
+ */
29
+ function Accelerator() {
30
+ var _this = this;
31
+
32
+ var frequency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [3, 3, 3, 2, 2, 2, 1];
33
+
34
+ _classCallCheck(this, Accelerator);
35
+
36
+ this.processKey = function (event, callback) {
37
+ switch (event.type) {
38
+ case 'keydown':
39
+ if (event.keyCode !== _this.keyCode) {
40
+ _this.reset();
41
+
42
+ _this.time = Date.now();
43
+ _this.keyCode = event.keyCode;
44
+ return callback(event);
45
+ } else if (_this.canceled) {
46
+ // Prevent skipped keydown events from bubbling
47
+ event.preventDefault();
48
+ return true;
49
+ } else {
50
+ var elapsedTime = Date.now() - _this.time,
51
+ seconds = Math.floor(elapsedTime / 1000),
52
+ toSkip = 0;
53
+
54
+ seconds = seconds > _this.frequency.length - 1 ? _this.frequency.length - 1 : seconds;
55
+ toSkip = _this.frequency[seconds] - 1;
56
+
57
+ if (toSkip < 0) {
58
+ toSkip = 0;
59
+ }
60
+
61
+ _this.accelerating = !(seconds === 0 && _this.skipped === 0);
62
+
63
+ if (_this.skipped >= toSkip) {
64
+ _this.skipped = 0;
65
+ return callback(event);
66
+ } else {
67
+ _this.skipped++; // Prevent skipped keydown events from bubbling
68
+
69
+ event.preventDefault();
70
+ return true;
71
+ }
72
+ }
73
+
74
+ case 'keyup':
75
+ _this.reset();
76
+
77
+ return callback(event);
78
+ }
79
+ };
80
+
81
+ this.reset = function () {
82
+ _this.skipped = 0;
83
+ _this.time = 0;
84
+ _this.keyCode = 0;
85
+ _this.canceled = false;
86
+ _this.accelerating = false;
87
+ };
88
+
89
+ this.cancel = function () {
90
+ _this.canceled = true;
91
+ };
92
+
93
+ this.isAccelerating = function () {
94
+ return _this.accelerating;
95
+ };
96
+
97
+ /*
98
+ * Whether the instance is currently in an accelerating state.
99
+ *
100
+ * @type {Boolean}
101
+ * @default false
102
+ */
103
+ this.accelerating = false;
104
+ /*
105
+ * The current count of skipped events.
106
+ *
107
+ * @type {Number}
108
+ * @default 0
109
+ */
110
+
111
+ this.skipped = 0;
112
+ /*
113
+ * The timestamp of the last evaluated event.
114
+ *
115
+ * @type {Number}
116
+ * @default 0
117
+ */
118
+
119
+ this.time = 0;
120
+ /*
121
+ * The keyCode of the last evaluated event.
122
+ *
123
+ * @type {Number}
124
+ * @default 0
125
+ */
126
+
127
+ this.keyCode = 0;
128
+ /*
129
+ * Whether the instance is in a state of being canceled.
130
+ *
131
+ * @type {Boolean}
132
+ * @default false
133
+ */
134
+
135
+ this.canceled = false;
136
+ /*
137
+ * Controls the frequency with which the acceleration will "freeze". While frozen,
138
+ * the current target item cannot change, and all events are directed to it.
139
+ *
140
+ * @type {Number[]}
141
+ * @default [3, 3, 3, 2, 2, 2, 1]
142
+ * @public
143
+ */
144
+
145
+ this.frequency = frequency;
166
146
  }
147
+ /**
148
+ * Called with the current keydown event and callback, which will be called when the event is
149
+ * allowed through.
150
+ *
151
+ * @function
152
+ * @param {Object} event - The current event to validate.
153
+ * @param {Function} callback - The callback to execute.
154
+ * @returns {Boolean} `true` if the event was consumed by processKey and callback was not called
155
+ * @public
156
+ * @memberof spotlight/Accelerator.Accelerator.prototype
157
+ */
158
+ ;
167
159
 
168
- export default Accelerator;
169
- export {Accelerator};
160
+ exports.Accelerator = Accelerator;
161
+ var _default = Accelerator;
162
+ exports["default"] = _default;
package/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact spotlight module, newest changes on the top.
4
4
 
5
+ ## [3.4.9-experimental-7] - 2021-11-24
6
+
7
+ ### Fixed
8
+
9
+ - `spotlight/SpotlightRootDecorator` to show focus when last input type is `none`
10
+
11
+ ## [3.4.9-experimental-6] - 2021-04-07
12
+
13
+ ### Fixed
14
+
15
+ - `spotlight/SpotlightRootDecorator` to not change to none touch mode when tapping VKB button
16
+
17
+ ## [3.4.9-experimental-5] - 2021-03-17
18
+
19
+ No significant changes.
20
+
21
+ ## [3.4.9-experimental-4] - 2021-02-23
22
+
23
+ ### Fixed
24
+
25
+ - `spotlight/SpotlightRootDecorator` to refer the last input type from webos
26
+
5
27
  ## [3.4.9-experimental-3] - 2021-01-26
6
28
 
7
29
  ### Fixed
File without changes
package/Pause/Pause.js CHANGED
@@ -1,3 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isPaused = isPaused;
7
+ exports.pause = pause;
8
+ exports.resume = _resume;
9
+ exports.Pause = exports["default"] = void 0;
10
+
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+
13
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14
+
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
16
+
1
17
  /**
2
18
  * Provides a class which allows consumers to safely pause and resume spotlight without resuming
3
19
  * another consumer's pause.
@@ -42,23 +58,19 @@
42
58
  * @exports pause
43
59
  * @exports resume
44
60
  */
61
+ var paused = false; // Private, exported methods used by Spotlight to set and query the pause state from its public API
45
62
 
46
- let paused = false;
47
-
48
- // Private, exported methods used by Spotlight to set and query the pause state from its public API
49
-
50
- function pause () {
51
- paused = true;
63
+ function pause() {
64
+ paused = true;
52
65
  }
53
66
 
54
- function resume () {
55
- paused = false;
67
+ function _resume() {
68
+ paused = false;
56
69
  }
57
70
 
58
- function isPaused () {
59
- return paused !== false;
71
+ function isPaused() {
72
+ return paused !== false;
60
73
  }
61
-
62
74
  /**
63
75
  * Acts as a semaphore for Spotlight pause state ensuring that only the last Pause instance can
64
76
  * resume Spotlight.
@@ -70,73 +82,83 @@ function isPaused () {
70
82
  * @memberof spotlight/Pause
71
83
  * @public
72
84
  */
73
- class Pause {
74
-
75
- /**
76
- * Accepts a name for the instance
77
- *
78
- * The `name` is not used but may be useful for debugging which instance has currently paused
79
- * Spotlight.
80
- *
81
- * @param {String} name The name of the pause instance
82
- * @memberof spotlight/Pause.Pause.prototype
83
- * @constructor
84
- * @public
85
- */
86
- constructor (name) {
87
- this.name = name;
88
- }
89
-
90
- toString () {
91
- return `Pause<${this.name}>`;
92
- }
93
-
94
- /**
95
- * Returns `true` when Spotlight is paused by this instance
96
- *
97
- * @returns {Boolean}
98
- * @memberof spotlight/Pause.Pause.prototype
99
- * @public
100
- */
101
- isPaused () {
102
- return paused === this;
103
- }
104
-
105
- /**
106
- * Pauses spotlight if not currently paused
107
- *
108
- * @returns {undefined}
109
- * @memberof spotlight/Pause.Pause.prototype
110
- * @public
111
- */
112
- pause () {
113
- if (!isPaused()) {
114
- paused = this;
115
- }
116
- }
117
-
118
- /**
119
- * Resumes spotlight if this instance was the last to pause spotlight
120
- *
121
- * @returns {Boolean} `true` if spotlight was resumed
122
- * @memberof spotlight/Pause.Pause.prototype
123
- * @public
124
- */
125
- resume () {
126
- if (this.isPaused()) {
127
- resume();
128
-
129
- return true;
130
- }
131
-
132
- return false;
133
- }
134
- }
135
85
 
136
- export default Pause;
137
- export {
138
- Pause,
139
- isPaused,
140
- pause,
141
- resume
142
- };
86
+
87
+ var Pause = /*#__PURE__*/function () {
88
+ /**
89
+ * Accepts a name for the instance
90
+ *
91
+ * The `name` is not used but may be useful for debugging which instance has currently paused
92
+ * Spotlight.
93
+ *
94
+ * @param {String} name The name of the pause instance
95
+ * @memberof spotlight/Pause.Pause.prototype
96
+ * @constructor
97
+ * @public
98
+ */
99
+ function Pause(name) {
100
+ _classCallCheck(this, Pause);
101
+
102
+ this.name = name;
103
+ }
104
+
105
+ _createClass(Pause, [{
106
+ key: "toString",
107
+ value: function toString() {
108
+ return "Pause<".concat(this.name, ">");
109
+ }
110
+ /**
111
+ * Returns `true` when Spotlight is paused by this instance
112
+ *
113
+ * @returns {Boolean}
114
+ * @memberof spotlight/Pause.Pause.prototype
115
+ * @public
116
+ */
117
+
118
+ }, {
119
+ key: "isPaused",
120
+ value: function isPaused() {
121
+ return paused === this;
122
+ }
123
+ /**
124
+ * Pauses spotlight if not currently paused
125
+ *
126
+ * @returns {undefined}
127
+ * @memberof spotlight/Pause.Pause.prototype
128
+ * @public
129
+ */
130
+
131
+ }, {
132
+ key: "pause",
133
+ value: function pause() {
134
+ if (!isPaused()) {
135
+ paused = this;
136
+ }
137
+ }
138
+ /**
139
+ * Resumes spotlight if this instance was the last to pause spotlight
140
+ *
141
+ * @returns {Boolean} `true` if spotlight was resumed
142
+ * @memberof spotlight/Pause.Pause.prototype
143
+ * @public
144
+ */
145
+
146
+ }, {
147
+ key: "resume",
148
+ value: function resume() {
149
+ if (this.isPaused()) {
150
+ _resume();
151
+
152
+ return true;
153
+ }
154
+
155
+ return false;
156
+ }
157
+ }]);
158
+
159
+ return Pause;
160
+ }();
161
+
162
+ exports.Pause = Pause;
163
+ var _default = Pause;
164
+ exports["default"] = _default;