@enact/ui 4.9.0-alpha.1 → 4.9.0-alpha.3

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 CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact ui module, newest changes on the top.
4
4
 
5
+ ## [4.9.0-alpha.3] - 2024-06-05
6
+
7
+ ### Changed
8
+
9
+ - `ui/Placeholder.PlaceholderControllerDecorator` and `ui/ViewManager` to have sibling DOM node as alternative to findDOMNode API which will be removed in React 19
10
+
11
+ ## [4.0.15] - 2024-05-28
12
+
13
+ No significant changes.
14
+
15
+ ## [4.9.0-alpha.2] - 2024-05-24
16
+
17
+ No significant changes.
18
+
19
+ ## [4.0.14] - 2024-05-14
20
+
21
+ No significant changes.
22
+
23
+ ## [4.7.11] - 2024-05-13
24
+
25
+ No significant changes.
26
+
5
27
  ## [4.9.0-alpha.1] - 2024-04-09
6
28
 
7
29
  ### Added
package/Layout/Cell.js CHANGED
@@ -11,7 +11,8 @@ var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
11
11
  var _resolution = _interopRequireDefault(require("../resolution"));
12
12
  var _LayoutModule = _interopRequireDefault(require("./Layout.module.css"));
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
- var _excluded = ["component", "componentCss", "componentRef"];
14
+ var _excluded = ["component", "componentCss", "componentRef"],
15
+ _excluded2 = ["key"];
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
17
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
18
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -192,10 +193,13 @@ var CellBase = exports.CellBase = (0, _kind["default"])({
192
193
  delete rest.grow;
193
194
  delete rest.shrink;
194
195
  delete rest.size;
196
+ var _rest = _objectSpread({}, rest),
197
+ key = _rest.key,
198
+ restProps = _objectWithoutProperties(_rest, _excluded2);
195
199
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread({
196
200
  css: componentCss,
197
201
  ref: componentRef
198
- }, rest));
202
+ }, restProps), key);
199
203
  }
200
204
  });
201
205
 
@@ -3,38 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.MarqueeControllerContext = exports.MarqueeController = void 0;
7
- var _handle = require("@enact/core/handle");
6
+ exports.MarqueeController = void 0;
7
+ Object.defineProperty(exports, "MarqueeControllerContext", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _useMarqueeController2.MarqueeControllerContext;
11
+ }
12
+ });
13
+ exports["default"] = void 0;
8
14
  var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
9
- var _util = require("@enact/core/util");
10
- var _react = require("react");
15
+ var _useMarqueeController2 = require("./useMarqueeController");
11
16
  var _jsxRuntime = require("react/jsx-runtime");
12
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
20
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
- 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, _toPropertyKey(descriptor.key), descriptor); } }
18
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
21
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
20
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
22
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
24
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
25
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
27
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
- var STATE = {
29
- inactive: 0,
30
- // Marquee is not necessary (render or focus not happened)
31
- active: 1,
32
- // Marquee in progress, awaiting complete
33
- ready: 2 // Marquee completed or not needed, but state is active
34
- };
35
- var MarqueeControllerContext = exports.MarqueeControllerContext = /*#__PURE__*/(0, _react.createContext)(null);
36
-
37
- /**
22
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
38
23
  * Default configuration parameters for {@link ui/Marquee.MarqueeController}.
39
24
  *
40
25
  * @type {Object}
@@ -62,266 +47,20 @@ var defaultConfig = {
62
47
  * @public
63
48
  */
64
49
  var MarqueeController = exports.MarqueeController = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
65
- var _class;
66
50
  var marqueeOnFocus = config.marqueeOnFocus;
67
- var forwardBlur = (0, _handle.forward)('onBlur');
68
- var forwardFocus = (0, _handle.forward)('onFocus');
69
- return _class = /*#__PURE__*/function (_Component) {
70
- _inherits(_class, _Component);
71
- var _super = _createSuper(_class);
72
- function _class(props) {
73
- var _this;
74
- _classCallCheck(this, _class);
75
- _this = _super.call(this, props);
76
- _this.cancelJob = new _util.Job(function () {
77
- return _this.doCancel();
78
- }, 30);
79
- /*
80
- * Registers `component` with a set of handlers for `start` and `stop`.
81
- *
82
- * @param {Object} component A component, typically a React component instance, on
83
- * which handlers will be dispatched.
84
- * @param {Object} handlers An object containing `start` and `stop` functions
85
- *
86
- * @returns {undefined}
87
- */
88
- _this.handleRegister = function (component, handlers) {
89
- var needsStart = !_this.allInactive() || _this.isFocused;
90
- _this.controlled.push(_objectSpread(_objectSpread({}, handlers), {}, {
91
- state: STATE.inactive,
92
- component: component
93
- }));
94
- if (needsStart) {
95
- _this.dispatch('start');
96
- }
97
- };
98
- /*
99
- * Unregisters `component` for synchronization
100
- *
101
- * @param {Object} component A previously registered component
102
- *
103
- * @returns {undefined}
104
- */
105
- _this.handleUnregister = function (component) {
106
- var wasRunning = false;
107
- for (var i = 0; i < _this.controlled.length; i++) {
108
- if (_this.controlled[i].component === component) {
109
- wasRunning = _this.controlled[i].state === STATE.active;
110
- _this.controlled.splice(i, 1);
111
- break;
112
- }
113
- }
114
- if (wasRunning && !_this.anyRunning()) {
115
- _this.dispatch('start');
116
- }
117
- };
118
- /*
119
- * Handler for the `start` context function
120
- *
121
- * @param {Object} component A previously registered component
122
- *
123
- * @returns {undefined}
124
- */
125
- _this.handleStart = function (component) {
126
- _this.cancelJob.stop();
127
- if (!_this.anyRunning()) {
128
- _this.markAll(STATE.ready);
129
- _this.dispatch('start', component);
130
- }
131
- };
132
- /*
133
- * Handler for the `cancel` context function
134
- *
135
- * @param {Object} component A previously registered component
136
- *
137
- * @returns {undefined}
138
- */
139
- _this.handleCancel = function () {
140
- if (_this.anyRunning()) {
141
- _this.cancelJob.start();
142
- }
143
- };
144
- _this.doCancel = function () {
145
- if (_this.isHovered || _this.isFocused) {
146
- return;
147
- }
148
- _this.markAll(STATE.inactive);
149
- _this.dispatch('stop');
150
- };
151
- /*
152
- * Handler for the `complete` context function
153
- *
154
- * @param {Object} component A previously registered component
155
- *
156
- * @returns {undefined}
157
- */
158
- _this.handleComplete = function (component) {
159
- var complete = _this.markReady(component);
160
- if (complete) {
161
- _this.markAll(STATE.ready);
162
- _this.dispatch('start');
163
- }
164
- };
165
- _this.handleEnter = function () {
166
- _this.isHovered = true;
167
- if (!_this.anyRunning()) {
168
- _this.dispatch('start');
169
- }
170
- _this.cancelJob.stop();
171
- };
172
- _this.handleLeave = function () {
173
- _this.isHovered = false;
174
- _this.cancelJob.start();
175
- };
176
- /*
177
- * Handler for the focus event
178
- */
179
- _this.handleFocus = function (ev) {
180
- _this.isFocused = true;
181
- if (!_this.anyRunning()) {
182
- _this.dispatch('start');
183
- }
184
- _this.cancelJob.stop();
185
- forwardFocus(ev, _this.props);
186
- };
187
- /*
188
- * Handler for the blur event
189
- */
190
- _this.handleBlur = function (ev) {
191
- _this.isFocused = false;
192
- if (_this.anyRunning()) {
193
- _this.cancelJob.start();
194
- }
195
- forwardBlur(ev, _this.props);
196
- };
197
- _this.controlled = [];
198
- _this.isFocused = false;
199
- _this.childContext = {
200
- cancel: _this.handleCancel,
201
- complete: _this.handleComplete,
202
- enter: _this.handleEnter,
203
- leave: _this.handleLeave,
204
- register: _this.handleRegister,
205
- start: _this.handleStart,
206
- unregister: _this.handleUnregister
207
- };
208
- return _this;
51
+ return function (props) {
52
+ var _useMarqueeController = (0, _useMarqueeController2.useMarqueeController)(props),
53
+ handleBlur = _useMarqueeController.handleBlur,
54
+ handleFocus = _useMarqueeController.handleFocus,
55
+ provideMarqueeControllerContext = _useMarqueeController.provideMarqueeControllerContext;
56
+ var wrappedProps = props;
57
+ if (marqueeOnFocus) {
58
+ wrappedProps = _objectSpread(_objectSpread({}, props), {}, {
59
+ onBlur: handleBlur,
60
+ onFocus: handleFocus
61
+ });
209
62
  }
210
- _createClass(_class, [{
211
- key: "componentWillUnmount",
212
- value: function componentWillUnmount() {
213
- this.cancelJob.stop();
214
- }
215
- }, {
216
- key: "dispatch",
217
- value:
218
- /*
219
- * Invokes the `action` handler for each synchronized component except the invoking
220
- * `component`.
221
- *
222
- * @param {String} action `'start'` or `'stop'`
223
- * @param {Object} component A previously registered component
224
- *
225
- * @returns {undefined}
226
- */
227
- function dispatch(action, component) {
228
- this.controlled.forEach(function (controlled) {
229
- var controlledComponent = controlled.component,
230
- handler = controlled[action];
231
- if (component !== controlledComponent && typeof handler === 'function') {
232
- var complete = handler.call(controlledComponent);
233
-
234
- // Returning `true` from a start request means that the marqueeing is
235
- // unnecessary and is therefore not awaiting a finish
236
- if (action === 'start' && complete) {
237
- controlled.state = STATE.ready;
238
- } else if (action === 'start') {
239
- controlled.state = STATE.active;
240
- }
241
- } else if (action === 'start' && component === controlledComponent) {
242
- controlled.state = STATE.active;
243
- }
244
- });
245
- }
246
-
247
- /*
248
- * Marks all components with the passed-in state
249
- *
250
- * @param {Enum} state The state to set
251
- *
252
- * @returns {undefined}
253
- */
254
- }, {
255
- key: "markAll",
256
- value: function markAll(state) {
257
- this.controlled.forEach(function (c) {
258
- c.state = state;
259
- });
260
- }
261
-
262
- /*
263
- * Marks `component` as ready for next marquee action
264
- *
265
- * @param {Object} component A previously registered component
266
- *
267
- * @returns {Boolean} `true` if no components are STATE.active
268
- */
269
- }, {
270
- key: "markReady",
271
- value: function markReady(component) {
272
- var complete = true;
273
- this.controlled.forEach(function (c) {
274
- if (c.component === component) {
275
- c.state = STATE.ready;
276
- }
277
- complete = complete && c.state !== STATE.active;
278
- });
279
- return complete;
280
- }
281
-
282
- /*
283
- * Checks that all components are inactive
284
- *
285
- * @returns {Boolean} `true` if any components should be running
286
- */
287
- }, {
288
- key: "allInactive",
289
- value: function allInactive() {
290
- var activeOrReady = this.controlled.reduce(function (res, component) {
291
- return res || !(component.state === STATE.inactive);
292
- }, false);
293
- return !activeOrReady;
294
- }
295
-
296
- /*
297
- * Checks for any components currently marqueeing
298
- *
299
- * @returns {Boolean} `true` if any component is marqueeing
300
- */
301
- }, {
302
- key: "anyRunning",
303
- value: function anyRunning() {
304
- return this.controlled.reduce(function (res, component) {
305
- return res || component.state === STATE.active;
306
- }, false);
307
- }
308
- }, {
309
- key: "render",
310
- value: function render() {
311
- var props = this.props;
312
- if (marqueeOnFocus) {
313
- props = _objectSpread(_objectSpread({}, this.props), {}, {
314
- onBlur: this.handleBlur,
315
- onFocus: this.handleFocus
316
- });
317
- }
318
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarqueeControllerContext.Provider, {
319
- value: this.childContext,
320
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, props))
321
- });
322
- }
323
- }]);
324
- return _class;
325
- }(_react.Component), _class.displayName = 'MarqueeController', _class;
63
+ return provideMarqueeControllerContext( /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, wrappedProps)));
64
+ };
326
65
  });
327
66
  var _default = exports["default"] = MarqueeController;
@@ -5,6 +5,24 @@ import * as React from "react";
5
5
  type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
6
6
  type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
7
7
 
8
+ export interface MarqueeControllerConfig extends Object {
9
+ /**
10
+ * When `true` , any `onFocus` events that bubble to the controller will start the contained
11
+ `Marquee` instances. This is useful when a component contains `Marquee` instances that need to be
12
+ started when sibling components are focused.
13
+ */
14
+ marqueeOnFocus?: boolean;
15
+ }
16
+ export interface MarqueeControllerProps {}
17
+ export function MarqueeController<P>(
18
+ config: MarqueeControllerConfig,
19
+ Component: React.ComponentType<P> | string,
20
+ ): React.ComponentType<P & MarqueeControllerProps>;
21
+
22
+ export function MarqueeController<P>(
23
+ Component: React.ComponentType<P> | string,
24
+ ): React.ComponentType<P & MarqueeControllerProps>;
25
+
8
26
  export interface MarqueeBaseProps {
9
27
  /**
10
28
  * Text alignment value of the marquee
@@ -89,24 +107,6 @@ export class MarqueeBase extends React.Component<
89
107
  Merge<React.HTMLProps<HTMLElement>, MarqueeBaseProps>
90
108
  > {}
91
109
 
92
- export interface MarqueeControllerConfig extends Object {
93
- /**
94
- * When `true` , any `onFocus` events that bubble to the controller will start the contained
95
- `Marquee` instances. This is useful when a component contains `Marquee` instances that need to be
96
- started when sibling components are focused.
97
- */
98
- marqueeOnFocus?: boolean;
99
- }
100
- export interface MarqueeControllerProps {}
101
- export function MarqueeController<P>(
102
- config: MarqueeControllerConfig,
103
- Component: React.ComponentType<P> | string,
104
- ): React.ComponentType<P & MarqueeControllerProps>;
105
-
106
- export function MarqueeController<P>(
107
- Component: React.ComponentType<P> | string,
108
- ): React.ComponentType<P & MarqueeControllerProps>;
109
-
110
110
  export interface MarqueeProps
111
111
  extends Merge<MarqueeBaseProps, MarqueeDecoratorProps> {}
112
112
  /**