@enact/ui 5.6.0 → 5.7.0
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/AnnounceDecorator/Announce.js +8 -8
- package/AnnounceDecorator/AnnounceDecorator.js +5 -5
- package/BodyText/BodyText.js +5 -5
- package/BodyText/tests/BodyText-specs.js +2 -1
- package/Button/Button.js +5 -5
- package/CHANGELOG.md +18 -0
- package/Cancelable/Cancelable.js +9 -9
- package/Cancelable/tests/Cancelable-specs.js +5 -5
- package/Card/Card.js +5 -5
- package/Card/tests/Card-specs.js +2 -1
- package/Changeable/Changeable.js +9 -9
- package/ComponentOverride/ComponentOverride.js +15 -11
- package/FloatingLayer/FloatingLayer.js +10 -10
- package/FloatingLayer/FloatingLayerContainer.js +3 -3
- package/FloatingLayer/FloatingLayerDecorator.js +5 -5
- package/FloatingLayer/Scrim.js +9 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +4 -4
- package/FloatingLayer/useFloatingLayer.js +3 -4
- package/ForwardRef/ForwardRef.js +5 -5
- package/Group/Group.js +5 -5
- package/Group/GroupItem.js +5 -5
- package/Group/tests/Group-specs.js +2 -1
- package/Heading/Heading.js +5 -5
- package/Icon/Icon.js +5 -5
- package/Icon/tests/Icon-specs.js +2 -1
- package/Image/Image.js +5 -5
- package/Image/tests/Image-specs.js +2 -1
- package/ImageItem/ImageItem.js +5 -5
- package/ImageItem/tests/ImageItem-specs.js +6 -5
- package/Item/Item.js +5 -5
- package/LabeledIcon/LabeledIcon.js +5 -5
- package/Layout/Cell.js +5 -5
- package/Layout/Layout.js +5 -5
- package/Layout/tests/Layout-specs.js +9 -9
- package/Marquee/Marquee.module.css +44 -0
- package/Marquee/MarqueeBase.js +134 -21
- package/Marquee/MarqueeController.js +4 -4
- package/Marquee/MarqueeDecorator.js +219 -27
- package/Marquee/index.d.ts +60 -12
- package/Marquee/tests/Marquee-specs.js +3 -3
- package/Marquee/tests/Marquee-vertical-specs.js +1358 -0
- package/Marquee/useMarqueeController.js +4 -4
- package/Marquee/utils.js +22 -0
- package/Marquee/verticalMeasure.js +118 -0
- package/Measurable/Measurable.js +8 -9
- package/Measurable/tests/Measurable-specs.js +7 -6
- package/Media/Media.js +10 -10
- package/Placeholder/PlaceholderControllerDecorator.js +9 -9
- package/Placeholder/PlaceholderDecorator.js +9 -9
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -4
- package/ProgressBar/ProgressBar.js +5 -5
- package/Repeater/Repeater.js +5 -5
- package/Repeater/tests/Repeater-specs.js +6 -5
- package/Resizable/Resizable.js +4 -4
- package/Resizable/tests/Resizable-specs.js +2 -1
- package/Resizable/tests/useResize-specs.js +4 -4
- package/Resizable/useResize.js +3 -3
- package/Routable/Link.js +9 -9
- package/Routable/Routable.js +5 -5
- package/Routable/Router.js +9 -9
- package/Routable/tests/Routable-specs.js +7 -8
- package/Routable/tests/Router-specs.js +1 -1
- package/Scroller/Scroller.js +4 -4
- package/Scroller/ScrollerBasic.js +10 -10
- package/Skinnable/Skinnable.js +5 -5
- package/Skinnable/tests/Skinnable-specs.js +4 -4
- package/Skinnable/tests/useSkins-specs.js +4 -4
- package/Slider/Knob.js +5 -5
- package/Slider/PositionDecorator.js +8 -8
- package/Slider/Slider.js +5 -5
- package/Slottable/Slottable.js +4 -4
- package/Slottable/useSlots.js +5 -5
- package/Spinner/Spinner.js +5 -5
- package/ToggleIcon/ToggleIcon.js +5 -5
- package/Toggleable/Toggle.js +5 -5
- package/Toggleable/Toggleable.js +9 -9
- package/Toggleable/useToggle.js +5 -5
- package/Touchable/ClickAllow.js +3 -3
- package/Touchable/Drag.js +6 -6
- package/Touchable/Flick.js +5 -5
- package/Touchable/Hold.js +5 -5
- package/Touchable/Pinch.js +6 -6
- package/Touchable/Touch.js +3 -3
- package/Touchable/Touchable.js +5 -5
- package/Touchable/config.js +4 -4
- package/Touchable/tests/Touchable-specs.js +1 -1
- package/Touchable/tests/useTouch-specs.js +5 -5
- package/Touchable/useTouch.js +7 -8
- package/Transition/Transition.js +14 -13
- package/Transition/tests/Transition-specs.js +9 -9
- package/ViewManager/Arranger.js +4 -4
- package/ViewManager/TransitionGroup.js +7 -7
- package/ViewManager/View.js +9 -9
- package/ViewManager/ViewManager.js +11 -10
- package/ViewManager/tests/ViewManager-specs.js +6 -6
- package/VirtualList/VirtualList.js +4 -4
- package/VirtualList/VirtualListBasic.js +67 -47
- package/VirtualList/tests/VirtualGridList-native-specs.js +5 -5
- package/VirtualList/tests/VirtualGridList-specs.js +16 -15
- package/VirtualList/tests/VirtualList-native-specs.js +164 -16
- package/VirtualList/tests/VirtualList-specs.js +16 -15
- package/internal/IdProvider/IdProvider.js +4 -4
- package/internal/IdProvider/Provider.js +3 -3
- package/internal/IdProvider/tests/IdProvider-specs.js +4 -4
- package/internal/IdProvider/tests/useId-specs.js +16 -8
- package/internal/Pure/Pure.js +9 -9
- package/internal/Pure/tests/Pure-specs.js +8 -8
- package/internal/localized-fonts/localized-fonts.js +3 -4
- package/package.json +6 -6
- package/resolution/ResolutionDecorator.js +71 -87
- package/resolution/index.js +2 -1
- package/resolution/tests/resolution-specs.js +7 -8
- package/useControlledState/tests/useControlledState-specs.js +3 -4
- package/useControlledState/useControlledState.js +3 -4
- package/useScroll/ScrollAnimator.js +3 -3
- package/useScroll/Scrollbar.js +5 -5
- package/useScroll/ScrollbarTrack.js +5 -5
- package/useScroll/scrollMotion.js +126 -0
- package/useScroll/tests/scrollMotion-specs.js +215 -0
- package/useScroll/tests/useScroll-specs.js +430 -9
- package/useScroll/useScroll.js +156 -92
|
@@ -12,20 +12,15 @@ var _resolution = require("./resolution");
|
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
14
|
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; }
|
|
15
|
-
function _objectSpread(
|
|
16
|
-
function _defineProperty(
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
function
|
|
20
|
-
function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
25
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
26
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
27
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
28
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /*
|
|
15
|
+
function _objectSpread(r) { for (var t = 1; t < arguments.length; t++) { var o = null != arguments[t] ? arguments[t] : {}; t % 2 ? ownKeys(Object(o), !0).forEach(function (t) { _defineProperty(r, t, o[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : ownKeys(Object(o)).forEach(function (e) { Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(o, e)); }); } return r; }
|
|
16
|
+
function _defineProperty(r, t, o) { return (t = _toPropertyKey(t)) in r ? Object.defineProperty(r, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = o, r; }
|
|
17
|
+
function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
|
|
18
|
+
function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
19
|
+
function _slicedToArray(e, i) { return _iterableToArrayLimit(e, i) || _unsupportedIterableToArray(e, i) || _nonIterableRest(); }
|
|
20
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); var o = {}.toString.call(t).slice(8, -1); return "Object" === o && t.constructor && (o = t.constructor.name), "Map" === o || "Set" === o ? Array.from(t) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(t, e) : void 0; } }
|
|
22
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
23
|
+
function _iterableToArrayLimit(r, t) { var e = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (Array.isArray(r) && (null == e || e === ("undefined" != typeof Symbol && [][Symbol.iterator]) || e === []["@@iterator"])) return r; if (null != e) { var l, n, i, a, u = [], o = !0, f = !1; try { if (i = (e = e.call(r)).next, 0 === t) { if (Object(e) !== e) return; o = !1; } else for (; !(o = (l = i.call(e)).done) && (u.push(l.value), u.length !== t); o = !0); } catch (r) { f = !0, n = r; } finally { try { if (!o && null != e["return"] && (a = e["return"](), Object(a) !== a)) return; } finally { if (f) throw n; } } return u; } } /*
|
|
29
24
|
* Exports the {@link ui/resolution.ResolutionDecorator} higher-order component (HOC).
|
|
30
25
|
*
|
|
31
26
|
* not jsdoc module on purpose
|
|
@@ -100,86 +95,75 @@ var defaultConfig = {
|
|
|
100
95
|
* @public
|
|
101
96
|
*/
|
|
102
97
|
var ResolutionDecorator = exports.ResolutionDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
103
|
-
var _Class;
|
|
104
98
|
if (config.screenTypes) {
|
|
105
99
|
(0, _resolution.defineScreenTypes)(config.screenTypes);
|
|
106
100
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (config.orientationHandling) _resolution.config.orientationHandling = config.orientationHandling;
|
|
123
|
-
if (config.linearScaling) _resolution.config.linearScaling = config.linearScaling;
|
|
124
|
-
(0, _resolution.init)({
|
|
125
|
-
measurementNode: typeof window !== 'undefined' && window
|
|
126
|
-
});
|
|
127
|
-
_this.state = {
|
|
128
|
-
resolutionClasses: ''
|
|
129
|
-
};
|
|
130
|
-
return _this;
|
|
131
|
-
}
|
|
132
|
-
_inherits(_Class, _Component);
|
|
133
|
-
return _createClass(_Class, [{
|
|
134
|
-
key: "componentDidMount",
|
|
135
|
-
value: function componentDidMount() {
|
|
136
|
-
var _document$getElements;
|
|
137
|
-
if (config.dynamic) window.addEventListener('resize', this.handleResize);
|
|
138
|
-
this.rootNode = ((_document$getElements = document.getElementsByClassName((0, _resolution.getResolutionClasses)())) === null || _document$getElements === void 0 ? void 0 : _document$getElements[0]) || null;
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
key: "componentDidUpdate",
|
|
142
|
-
value: function componentDidUpdate(prevProps) {
|
|
143
|
-
(0, _util.checkPropTypes)(this, this.props, prevProps);
|
|
144
|
-
}
|
|
145
|
-
}, {
|
|
146
|
-
key: "componentWillUnmount",
|
|
147
|
-
value: function componentWillUnmount() {
|
|
148
|
-
if (config.dynamic) window.removeEventListener('resize', this.handleResize);
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
key: "didClassesChange",
|
|
152
|
-
value:
|
|
153
|
-
/*
|
|
154
|
-
* Compare our current version of the resolved resolution class names with a fresh
|
|
155
|
-
* initialization of RI.
|
|
156
|
-
*
|
|
157
|
-
* @returns {String|undefined} A string of new class names or undefined when there is no change.
|
|
158
|
-
* @private
|
|
159
|
-
*/
|
|
160
|
-
function didClassesChange() {
|
|
161
|
-
var prevClassNames = (0, _resolution.getResolutionClasses)();
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line no-shadow
|
|
103
|
+
function ResolutionDecorator(props) {
|
|
104
|
+
(0, _util.checkPropTypes)(ResolutionDecorator, props);
|
|
105
|
+
var rootNodeRef = (0, _react.useRef)(null);
|
|
106
|
+
|
|
107
|
+
// Constructor work must finish before the first render reads resolution classes.
|
|
108
|
+
// The version is only a render trigger. Classes are read from `getResolutionClasses`,
|
|
109
|
+
// and each change increments the version so a repeated class string still re-renders.
|
|
110
|
+
var _useReducer = (0, _react.useReducer)(function (version) {
|
|
111
|
+
return version + 1;
|
|
112
|
+
}, 0, function (version) {
|
|
113
|
+
if (config.fontSizeHandling) _resolution.config.fontSizeHandling = config.fontSizeHandling;
|
|
114
|
+
if (config.orientationHandling) _resolution.config.orientationHandling = config.orientationHandling;
|
|
115
|
+
if (config.linearScaling) _resolution.config.linearScaling = config.linearScaling;
|
|
162
116
|
(0, _resolution.init)({
|
|
163
|
-
measurementNode:
|
|
117
|
+
measurementNode: typeof window !== 'undefined' && window
|
|
164
118
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
119
|
+
return version;
|
|
120
|
+
}),
|
|
121
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
122
|
+
forceRender = _useReducer2[1];
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
* Compare our current version of the resolved resolution class names with a fresh
|
|
126
|
+
* initialization of RI.
|
|
127
|
+
*
|
|
128
|
+
* @returns {String|undefined} A string of new class names or undefined when there is no change.
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
var didClassesChange = (0, _react.useCallback)(function () {
|
|
132
|
+
var prevClassNames = (0, _resolution.getResolutionClasses)();
|
|
133
|
+
(0, _resolution.init)({
|
|
134
|
+
measurementNode: rootNodeRef.current
|
|
135
|
+
});
|
|
136
|
+
var classNames = (0, _resolution.getResolutionClasses)();
|
|
137
|
+
if (prevClassNames !== classNames) {
|
|
138
|
+
return classNames;
|
|
169
139
|
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (this.props.className) classes += (classes ? ' ' : '') + this.props.className;
|
|
176
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, this.props), {}, {
|
|
177
|
-
className: classes
|
|
178
|
-
}));
|
|
140
|
+
}, []);
|
|
141
|
+
var handleResize = (0, _react.useCallback)(function () {
|
|
142
|
+
var classNames = didClassesChange();
|
|
143
|
+
if (classNames) {
|
|
144
|
+
forceRender();
|
|
179
145
|
}
|
|
180
|
-
}]);
|
|
181
|
-
|
|
146
|
+
}, [didClassesChange]);
|
|
147
|
+
(0, _react.useLayoutEffect)(function () {
|
|
148
|
+
var _document$getElements;
|
|
149
|
+
if (config.dynamic) window.addEventListener('resize', handleResize);
|
|
150
|
+
rootNodeRef.current = ((_document$getElements = document.getElementsByClassName((0, _resolution.getResolutionClasses)())) === null || _document$getElements === void 0 ? void 0 : _document$getElements[0]) || null;
|
|
151
|
+
return function () {
|
|
152
|
+
if (config.dynamic) window.removeEventListener('resize', handleResize);
|
|
153
|
+
};
|
|
154
|
+
}, [handleResize]);
|
|
155
|
+
|
|
156
|
+
// Check if the classes are different from our previous classes
|
|
157
|
+
var classes = (0, _resolution.getResolutionClasses)();
|
|
158
|
+
if (props.className) classes += (classes ? ' ' : '') + props.className;
|
|
159
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, props), {}, {
|
|
160
|
+
className: classes
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
ResolutionDecorator.displayName = 'ResolutionDecorator';
|
|
164
|
+
ResolutionDecorator.propTypes = /** @lends ui/resolution.ResolutionDecorator.prototype */{
|
|
182
165
|
className: _propTypes["default"].string
|
|
183
|
-
}
|
|
166
|
+
};
|
|
167
|
+
return ResolutionDecorator;
|
|
184
168
|
});
|
|
185
169
|
var _default = exports["default"] = ResolutionDecorator;
|
package/resolution/index.js
CHANGED
|
@@ -27,7 +27,8 @@ Object.keys(ri).forEach(function (key) {
|
|
|
27
27
|
});
|
|
28
28
|
var _ResolutionDecorator = _interopRequireDefault(require("./ResolutionDecorator"));
|
|
29
29
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
30
|
-
|
|
30
|
+
var e;
|
|
31
|
+
function _interopRequireWildcard(t, r) { if (!r && t && t.__esModule) return t; var n, a, o = Object.defineProperty, f = { __proto__: null, "default": t }; if (Object(t) !== t) return f; if (e || "function" != typeof WeakMap || (e = new WeakMap()), e) { if (e.has(t)) return e.get(t); e.set(t, f); } for (a in t) "default" !== a && {}.hasOwnProperty.call(t, a) && ((n = o && Object.getOwnPropertyDescriptor(t, a)) && (n.get || n.set) ? o(f, a, n) : f[a] = t[a]); return f; }
|
|
31
32
|
/**
|
|
32
33
|
* Provides resolution independence utilities for responsive applications.
|
|
33
34
|
*
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var _resolution = require("../resolution.js");
|
|
4
4
|
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; }
|
|
5
|
-
function _objectSpread(
|
|
6
|
-
function _defineProperty(
|
|
7
|
-
function _toPropertyKey(
|
|
8
|
-
function _toPrimitive(t,
|
|
9
|
-
function _slicedToArray(
|
|
5
|
+
function _objectSpread(r) { for (var t = 1; t < arguments.length; t++) { var o = null != arguments[t] ? arguments[t] : {}; t % 2 ? ownKeys(Object(o), !0).forEach(function (t) { _defineProperty(r, t, o[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : ownKeys(Object(o)).forEach(function (e) { Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(o, e)); }); } return r; }
|
|
6
|
+
function _defineProperty(r, t, o) { return (t = _toPropertyKey(t)) in r ? Object.defineProperty(r, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = o, r; }
|
|
7
|
+
function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
|
|
8
|
+
function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
9
|
+
function _slicedToArray(e, i) { return _iterableToArrayLimit(e, i) || _unsupportedIterableToArray(e, i) || _nonIterableRest(); }
|
|
10
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
function _unsupportedIterableToArray(
|
|
11
|
+
function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); var o = {}.toString.call(t).slice(8, -1); return "Object" === o && t.constructor && (o = t.constructor.name), "Map" === o || "Set" === o ? Array.from(t) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(t, e) : void 0; } }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
-
function _iterableToArrayLimit(r,
|
|
14
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
function _iterableToArrayLimit(r, t) { var e = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (Array.isArray(r) && (null == e || e === ("undefined" != typeof Symbol && [][Symbol.iterator]) || e === []["@@iterator"])) return r; if (null != e) { var l, n, i, a, u = [], o = !0, f = !1; try { if (i = (e = e.call(r)).next, 0 === t) { if (Object(e) !== e) return; o = !1; } else for (; !(o = (l = i.call(e)).done) && (u.push(l.value), u.length !== t); o = !0); } catch (r) { f = !0, n = r; } finally { try { if (!o && null != e["return"] && (a = e["return"](), Object(a) !== a)) return; } finally { if (f) throw n; } } return u; } }
|
|
15
14
|
describe('Resolution Specs', function () {
|
|
16
15
|
var screenTypes = [{
|
|
17
16
|
name: 'vga',
|
|
@@ -6,12 +6,11 @@ var _react2 = require("react");
|
|
|
6
6
|
var _useControlledState3 = _interopRequireDefault(require("../useControlledState"));
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function _slicedToArray(
|
|
9
|
+
function _slicedToArray(e, i) { return _iterableToArrayLimit(e, i) || _unsupportedIterableToArray(e, i) || _nonIterableRest(); }
|
|
10
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
function _unsupportedIterableToArray(
|
|
11
|
+
function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); var o = {}.toString.call(t).slice(8, -1); return "Object" === o && t.constructor && (o = t.constructor.name), "Map" === o || "Set" === o ? Array.from(t) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(t, e) : void 0; } }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
-
function _iterableToArrayLimit(r,
|
|
14
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
function _iterableToArrayLimit(r, t) { var e = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (Array.isArray(r) && (null == e || e === ("undefined" != typeof Symbol && [][Symbol.iterator]) || e === []["@@iterator"])) return r; if (null != e) { var l, n, i, a, u = [], o = !0, f = !1; try { if (i = (e = e.call(r)).next, 0 === t) { if (Object(e) !== e) return; o = !1; } else for (; !(o = (l = i.call(e)).done) && (u.push(l.value), u.length !== t); o = !0); } catch (r) { f = !0, n = r; } finally { try { if (!o && null != e["return"] && (a = e["return"](), Object(a) !== a)) return; } finally { if (f) throw n; } } return u; } }
|
|
15
14
|
describe('useControlledState', function () {
|
|
16
15
|
var data;
|
|
17
16
|
function Component(props) {
|
|
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
exports.useControlledState = useControlledState;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
function _slicedToArray(
|
|
9
|
+
function _slicedToArray(e, i) { return _iterableToArrayLimit(e, i) || _unsupportedIterableToArray(e, i) || _nonIterableRest(); }
|
|
10
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
function _unsupportedIterableToArray(
|
|
11
|
+
function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); var o = {}.toString.call(t).slice(8, -1); return "Object" === o && t.constructor && (o = t.constructor.name), "Map" === o || "Set" === o ? Array.from(t) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? _arrayLikeToArray(t, e) : void 0; } }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
-
function _iterableToArrayLimit(r,
|
|
14
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
function _iterableToArrayLimit(r, t) { var e = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (Array.isArray(r) && (null == e || e === ("undefined" != typeof Symbol && [][Symbol.iterator]) || e === []["@@iterator"])) return r; if (null != e) { var l, n, i, a, u = [], o = !0, f = !1; try { if (i = (e = e.call(r)).next, 0 === t) { if (Object(e) !== e) return; o = !1; } else for (; !(o = (l = i.call(e)).done) && (u.push(l.value), u.length !== t); o = !0); } catch (r) { f = !0, n = r; } finally { try { if (!o && null != e["return"] && (a = e["return"](), Object(a) !== a)) return; } finally { if (f) throw n; } } return u; } }
|
|
15
14
|
function nop() {}
|
|
16
15
|
|
|
17
16
|
// Generate a handler that hides the controlled value from users, supports functional callbacks,
|
|
@@ -9,10 +9,10 @@ var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
|
|
|
9
9
|
var _utilAnimation = _interopRequireDefault(require("./utilAnimation"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
11
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
-
function _defineProperties(
|
|
12
|
+
function _defineProperties(r, t) { for (var o = 0; o < t.length; o++) { var i = t[o]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(r, _toPropertyKey(i.key), i); } }
|
|
13
13
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
-
function _toPropertyKey(
|
|
15
|
-
function _toPrimitive(t,
|
|
14
|
+
function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
|
|
15
|
+
function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
16
16
|
var
|
|
17
17
|
// Use eases library
|
|
18
18
|
timingFunctions = {
|
package/useScroll/Scrollbar.js
CHANGED
|
@@ -23,11 +23,11 @@ var _excluded = ["className", "clientSize", "corner", "css", "minThumbSize", "sc
|
|
|
23
23
|
_excluded2 = ["corner", "css", "minThumbSize", "vertical"];
|
|
24
24
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
25
25
|
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; }
|
|
26
|
-
function _objectSpread(
|
|
27
|
-
function _defineProperty(
|
|
28
|
-
function _toPropertyKey(
|
|
29
|
-
function _toPrimitive(t,
|
|
30
|
-
function _objectWithoutProperties(
|
|
26
|
+
function _objectSpread(r) { for (var t = 1; t < arguments.length; t++) { var o = null != arguments[t] ? arguments[t] : {}; t % 2 ? ownKeys(Object(o), !0).forEach(function (t) { _defineProperty(r, t, o[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : ownKeys(Object(o)).forEach(function (e) { Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(o, e)); }); } return r; }
|
|
27
|
+
function _defineProperty(r, t, o) { return (t = _toPropertyKey(t)) in r ? Object.defineProperty(r, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = o, r; }
|
|
28
|
+
function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
|
|
29
|
+
function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
30
|
+
function _objectWithoutProperties(t, r) { if (null == t) return {}; var o, n, i = _objectWithoutPropertiesLoose(t, r); if (Object.getOwnPropertySymbols) { var l = Object.getOwnPropertySymbols(t); for (n = 0; n < l.length; n++) o = l[n], -1 === r.indexOf(o) && {}.propertyIsEnumerable.call(t, o) && (i[o] = t[o]); } return i; }
|
|
31
31
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
32
32
|
var scrollbarTrackHidingDelay = 900; // 900ms + 100ms(fade out duration) = 1000ms.
|
|
33
33
|
|
|
@@ -21,11 +21,11 @@ var _excluded = ["ref", "vertical"];
|
|
|
21
21
|
*/
|
|
22
22
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
23
23
|
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; }
|
|
24
|
-
function _objectSpread(
|
|
25
|
-
function _defineProperty(
|
|
26
|
-
function _toPropertyKey(
|
|
27
|
-
function _toPrimitive(t,
|
|
28
|
-
function _objectWithoutProperties(
|
|
24
|
+
function _objectSpread(r) { for (var t = 1; t < arguments.length; t++) { var o = null != arguments[t] ? arguments[t] : {}; t % 2 ? ownKeys(Object(o), !0).forEach(function (t) { _defineProperty(r, t, o[t]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : ownKeys(Object(o)).forEach(function (e) { Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(o, e)); }); } return r; }
|
|
25
|
+
function _defineProperty(r, t, o) { return (t = _toPropertyKey(t)) in r ? Object.defineProperty(r, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = o, r; }
|
|
26
|
+
function _toPropertyKey(r) { var o = _toPrimitive(r, "string"); return "symbol" == typeof o ? o : o + ""; }
|
|
27
|
+
function _toPrimitive(t, e) { if ("object" != typeof t || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); }
|
|
28
|
+
function _objectWithoutProperties(t, r) { if (null == t) return {}; var o, n, i = _objectWithoutPropertiesLoose(t, r); if (Object.getOwnPropertySymbols) { var l = Object.getOwnPropertySymbols(t); for (n = 0; n < l.length; n++) o = l[n], -1 === r.indexOf(o) && {}.propertyIsEnumerable.call(t, o) && (i[o] = t[o]); } return i; }
|
|
29
29
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
30
30
|
var _ScrollbarTrack = function ScrollbarTrack(props) {
|
|
31
31
|
(0, _util.checkPropTypes)(_ScrollbarTrack, props);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startNativeScroll = exports.resolveScrollMotion = exports.cancelScrollMotion = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Optional scroll-motion timing for `useScroll`.
|
|
9
|
+
*
|
|
10
|
+
* A theme passes `getScrollMotion`, which returns `{delay, duration, ease}` from its motion
|
|
11
|
+
* tokens. Every animated scroll that does not already have its own duration (a flick) or a
|
|
12
|
+
* shortened repeat (a held key) uses that timing. Translate mode eases through `timingFunction`;
|
|
13
|
+
* native mode interpolates and applies each frame with an instant `scrollTo`, so the browser's
|
|
14
|
+
* own smooth-scroll timing is not used.
|
|
15
|
+
*
|
|
16
|
+
* @module ui/useScroll/scrollMotion
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
var clampProgress = function clampProgress(progress) {
|
|
21
|
+
return Math.min(Math.max(progress, 0), 1);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Matches ScrollAnimator: a held key scrolls linearly, a single step uses the curve.
|
|
25
|
+
var createTimingFunction = function createTimingFunction(ease) {
|
|
26
|
+
return function (source, target, duration, curTime, keyPressed) {
|
|
27
|
+
if (!duration) return target;
|
|
28
|
+
var progress = keyPressed ? curTime / duration : ease(clampProgress(curTime / duration));
|
|
29
|
+
return (target - source) * progress + source;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the motion for one `start()`. An explicit duration, a held key, or a key repeat keeps
|
|
35
|
+
* the scroller's existing timing, so flicks and key-repeat stay short.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} options
|
|
38
|
+
* @param {Number} [options.duration] Duration passed to `start`, when the caller set one.
|
|
39
|
+
* @param {Boolean} [options.keyPressed] Whether a key is being held.
|
|
40
|
+
* @param {Boolean} [options.repeat] Whether this scroll is a key repeat.
|
|
41
|
+
* @param {Function} [options.getScrollMotion] Theme getter, called at scroll start.
|
|
42
|
+
* @returns {Object|null} `{delay, duration, ease, timingFunction}`, or `null`.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
var resolveScrollMotion = exports.resolveScrollMotion = function resolveScrollMotion() {
|
|
46
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
47
|
+
duration = _ref.duration,
|
|
48
|
+
keyPressed = _ref.keyPressed,
|
|
49
|
+
repeat = _ref.repeat,
|
|
50
|
+
getScrollMotion = _ref.getScrollMotion;
|
|
51
|
+
if (duration != null || keyPressed || repeat || typeof getScrollMotion !== 'function') return null;
|
|
52
|
+
var motion = getScrollMotion();
|
|
53
|
+
if (!motion || typeof motion.duration !== 'number' || typeof motion.ease !== 'function') return null;
|
|
54
|
+
return {
|
|
55
|
+
delay: motion.delay > 0 ? motion.delay : 0,
|
|
56
|
+
duration: motion.duration,
|
|
57
|
+
ease: motion.ease,
|
|
58
|
+
timingFunction: createTimingFunction(motion.ease)
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Stops a delayed or in-progress motion scroll. Safe to call when nothing is running.
|
|
64
|
+
*
|
|
65
|
+
* @param {Object} state The scroller's mutable state.
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
var cancelScrollMotion = exports.cancelScrollMotion = function cancelScrollMotion(state) {
|
|
69
|
+
if (!state) return;
|
|
70
|
+
if (state.motionDelay) {
|
|
71
|
+
clearTimeout(state.motionDelay);
|
|
72
|
+
state.motionDelay = null;
|
|
73
|
+
}
|
|
74
|
+
if (state.motionFrame) {
|
|
75
|
+
window.cancelAnimationFrame(state.motionFrame);
|
|
76
|
+
state.motionFrame = null;
|
|
77
|
+
}
|
|
78
|
+
state.motionAnimating = false;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Animates a native scroll in logical coordinates. `scrollTo` must apply RTL itself.
|
|
83
|
+
* `motionAnimating` is cleared before the final position so the resulting `scrollend` is accepted.
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} state
|
|
86
|
+
* @param {Object} animation
|
|
87
|
+
* @param {Number} animation.fromX
|
|
88
|
+
* @param {Number} animation.fromY
|
|
89
|
+
* @param {Number} animation.toX
|
|
90
|
+
* @param {Number} animation.toY
|
|
91
|
+
* @param {Number} animation.duration
|
|
92
|
+
* @param {Function} animation.ease
|
|
93
|
+
* @param {Function} animation.scrollTo
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
var startNativeScroll = exports.startNativeScroll = function startNativeScroll(state, _ref2) {
|
|
97
|
+
var fromX = _ref2.fromX,
|
|
98
|
+
fromY = _ref2.fromY,
|
|
99
|
+
toX = _ref2.toX,
|
|
100
|
+
toY = _ref2.toY,
|
|
101
|
+
duration = _ref2.duration,
|
|
102
|
+
ease = _ref2.ease,
|
|
103
|
+
scrollTo = _ref2.scrollTo;
|
|
104
|
+
cancelScrollMotion(state);
|
|
105
|
+
if (fromX === toX && fromY === toY) return;
|
|
106
|
+
var startTime = performance.now();
|
|
107
|
+
var frameId = 0;
|
|
108
|
+
var _step = function step(now) {
|
|
109
|
+
if (state.motionFrame !== frameId) return;
|
|
110
|
+
var elapsed = now - startTime;
|
|
111
|
+
var t = duration > 0 ? Math.min(elapsed / duration, 1) : 1;
|
|
112
|
+
if (t < 1) {
|
|
113
|
+
var progress = ease(t);
|
|
114
|
+
scrollTo(fromX + (toX - fromX) * progress, fromY + (toY - fromY) * progress);
|
|
115
|
+
frameId = window.requestAnimationFrame(_step);
|
|
116
|
+
state.motionFrame = frameId;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
state.motionFrame = null;
|
|
120
|
+
state.motionAnimating = false;
|
|
121
|
+
scrollTo(toX, toY);
|
|
122
|
+
};
|
|
123
|
+
state.motionAnimating = true;
|
|
124
|
+
frameId = window.requestAnimationFrame(_step);
|
|
125
|
+
state.motionFrame = frameId;
|
|
126
|
+
};
|