@enact/ui 4.1.2 → 4.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AnnounceDecorator/Announce.js +9 -9
- package/AnnounceDecorator/AnnounceDecorator.js +6 -4
- package/AnnounceDecorator/tests/Announce-specs.js +13 -5
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
- package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
- package/AnnounceDecorator/useAnnounce.js +1 -1
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +6 -4
- package/BodyText/tests/BodyText-specs.js +51 -37
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +11 -7
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +25 -0
- package/Cancelable/Cancelable.js +12 -11
- package/Cancelable/tests/Cancelable-specs.js +133 -70
- package/Changeable/Changeable.js +9 -9
- package/Changeable/tests/Changeable-specs.js +172 -110
- package/ComponentOverride/ComponentOverride.js +6 -4
- package/FloatingLayer/FloatingLayer.js +40 -49
- package/FloatingLayer/FloatingLayer.module.css +3 -0
- package/FloatingLayer/FloatingLayerContainer.js +2 -2
- package/FloatingLayer/FloatingLayerDecorator.js +6 -4
- package/FloatingLayer/Scrim.js +9 -7
- package/FloatingLayer/index.js +1 -1
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +17 -11
- package/FloatingLayer/useFloatingLayer.js +2 -2
- package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
- package/ForwardRef/ForwardRef.js +3 -3
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +6 -4
- package/Group/Group.d.ts +2 -2
- package/Group/Group.js +7 -4
- package/Group/GroupItem.js +6 -4
- package/Group/tests/Group-specs.js +73 -43
- package/Heading/Heading.d.ts +2 -1
- package/Heading/Heading.js +6 -4
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +6 -4
- package/Icon/tests/Icon-specs.js +54 -33
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +6 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/Image.js +6 -4
- package/Image/tests/Image-specs.js +41 -31
- package/ImageItem/ImageItem.js +8 -5
- package/ImageItem/tests/ImageItem-specs.js +75 -72
- package/Item/Item.js +6 -4
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/LabeledIcon.js +6 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Cell.js +6 -4
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +6 -4
- package/Layout/tests/Layout-specs.js +42 -30
- package/Marquee/MarqueeBase.js +7 -9
- package/Marquee/MarqueeController.js +9 -9
- package/Marquee/MarqueeDecorator.js +18 -13
- package/Marquee/index.d.ts +4 -1
- package/Marquee/index.js +2 -1
- package/Marquee/tests/Marquee-specs.js +254 -122
- package/Measurable/Measurable.js +4 -4
- package/Media/Media.js +10 -10
- package/Placeholder/PlaceholderControllerDecorator.js +9 -9
- package/Placeholder/PlaceholderDecorator.js +9 -9
- package/ProgressBar/ProgressBar.js +6 -4
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioControllerDecorator.js +9 -9
- package/RadioDecorator/RadioDecorator.js +12 -14
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/Repeater.js +6 -4
- package/Repeater/tests/Repeater-specs.js +90 -49
- package/Resizable/Resizable.js +10 -10
- package/Routable/Link.js +9 -7
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +10 -6
- package/Routable/Route.js +1 -1
- package/Routable/Router.js +14 -11
- package/Routable/tests/Routable-specs.js +29 -20
- package/Routable/tests/Router-specs.js +65 -41
- package/Routable/useLink.js +1 -1
- package/Routable/util.js +1 -1
- package/Scrollable/ScrollAnimator.js +2 -2
- package/Scrollable/ScrollThumb.js +3 -3
- package/Scrollable/Scrollable.js +14 -10
- package/Scrollable/ScrollableNative.js +14 -10
- package/Scrollable/Scrollbar.js +14 -8
- package/Scroller/Scroller.d.ts +2 -14
- package/Scroller/Scroller.js +8 -7
- package/Scroller/ScrollerBasic.js +18 -35
- package/Scroller/UiScrollerBase.js +9 -7
- package/Skinnable/Skinnable.js +6 -4
- package/Skinnable/tests/Skinnable-specs.js +104 -56
- package/Skinnable/tests/useSkins-specs.js +39 -44
- package/Skinnable/useSkins.js +1 -1
- package/Slider/Knob.js +6 -4
- package/Slider/PositionDecorator.js +9 -9
- package/Slider/Slider.d.ts +3 -3
- package/Slider/Slider.js +6 -4
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/SlotItem.js +6 -4
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/Slottable.js +3 -3
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Slottable/useSlots.js +6 -4
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +6 -4
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/ToggleIcon.js +6 -4
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/ToggleItem.js +6 -4
- package/ToggleItem/tests/ToggleItem-specs.js +54 -37
- package/Toggleable/Toggle.js +10 -10
- package/Toggleable/Toggleable.js +11 -17
- package/Toggleable/tests/Toggleable-specs.js +464 -324
- package/Toggleable/useToggle.js +4 -2
- package/Touchable/ClickAllow.js +2 -2
- package/Touchable/Drag.js +22 -22
- package/Touchable/Flick.js +22 -18
- package/Touchable/Hold.js +18 -23
- package/Touchable/Touch.js +2 -2
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/Touchable.js +7 -4
- package/Touchable/config.js +3 -3
- package/Touchable/tests/Touchable-specs.js +225 -109
- package/Touchable/tests/useTouch-specs.js +163 -86
- package/Touchable/useTouch.js +4 -4
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +22 -17
- package/Transition/tests/Transition-specs.js +116 -36
- package/ViewManager/Arranger.js +3 -3
- package/ViewManager/TransitionGroup.js +10 -9
- package/ViewManager/View.js +7 -7
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +24 -22
- package/ViewManager/tests/View-specs.js +141 -81
- package/ViewManager/tests/ViewManager-specs.js +486 -193
- package/VirtualList/UiVirtualListBase.js +26 -35
- package/VirtualList/VirtualList.d.ts +11 -29
- package/VirtualList/VirtualList.js +10 -9
- package/VirtualList/VirtualListBase.js +1 -1
- package/VirtualList/VirtualListBasic.js +44 -61
- package/VirtualList/tests/VirtualList-specs.js +81 -95
- package/internal/IdProvider/IdProvider.js +3 -3
- package/internal/IdProvider/Provider.js +2 -2
- package/internal/IdProvider/tests/useId-specs.js +37 -20
- package/internal/Pure/Pure.js +9 -9
- package/internal/localized-fonts/localized-fonts.js +1 -1
- package/internal/validators/validators.js +1 -1
- package/package.json +11 -11
- package/resolution/ResolutionDecorator.js +9 -9
- package/resolution/index.js +2 -2
- package/resolution/resolution.js +4 -2
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +68 -43
- package/useControlledState/useControlledState.js +2 -2
- package/useScroll/ScrollAnimator.js +2 -2
- package/useScroll/Scrollbar.js +7 -4
- package/useScroll/ScrollbarTrack.js +6 -4
- package/useScroll/useScroll.js +18 -29
package/Resizable/Resizable.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = exports.ResizeContext = exports.Resizable = void 0;
|
|
7
7
|
|
|
8
8
|
var _handle = require("@enact/core/handle");
|
|
9
9
|
|
|
@@ -17,9 +17,9 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
21
|
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
23
|
|
|
24
24
|
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; }
|
|
25
25
|
|
|
@@ -27,15 +27,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
27
27
|
|
|
28
28
|
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); } }
|
|
29
29
|
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
31
|
|
|
32
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
32
|
+
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); }
|
|
33
33
|
|
|
34
34
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
35
|
|
|
36
36
|
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); }; }
|
|
37
37
|
|
|
38
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
38
|
+
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); }
|
|
39
39
|
|
|
40
40
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
41
|
|
|
@@ -103,12 +103,12 @@ var defaultConfig = {
|
|
|
103
103
|
*/
|
|
104
104
|
|
|
105
105
|
var Resizable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
106
|
-
var _class
|
|
106
|
+
var _class;
|
|
107
107
|
|
|
108
108
|
var filter = config.filter,
|
|
109
109
|
resize = config.resize;
|
|
110
|
-
!resize ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, "resize is required by Resizable but was omitted when applied to ".concat(Wrapped.displayName)) :
|
|
111
|
-
return
|
|
110
|
+
!resize ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, "resize is required by Resizable but was omitted when applied to ".concat(Wrapped.displayName)) : (0, _invariant["default"])(false) : void 0;
|
|
111
|
+
return _class = /*#__PURE__*/function (_Component) {
|
|
112
112
|
_inherits(_class, _Component);
|
|
113
113
|
|
|
114
114
|
var _super = _createSuper(_class);
|
|
@@ -179,7 +179,7 @@ var Resizable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
|
179
179
|
}]);
|
|
180
180
|
|
|
181
181
|
return _class;
|
|
182
|
-
}(_react.Component), _class.displayName = 'Resizable', _class.contextType = ResizeContext,
|
|
182
|
+
}(_react.Component), _class.displayName = 'Resizable', _class.contextType = ResizeContext, _class;
|
|
183
183
|
});
|
|
184
184
|
exports.Resizable = Resizable;
|
|
185
185
|
var _default = Resizable;
|
package/Routable/Link.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Linkable = exports.LinkBase = exports.Link =
|
|
6
|
+
exports["default"] = exports.Linkable = exports.LinkBase = exports.Link = void 0;
|
|
7
7
|
|
|
8
8
|
var _kind = _interopRequireDefault(require("@enact/core/kind"));
|
|
9
9
|
|
|
@@ -21,21 +21,23 @@ var _useLink = _interopRequireDefault(require("./useLink"));
|
|
|
21
21
|
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
|
|
24
|
+
var _excluded = ["path"];
|
|
25
|
+
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
28
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
29
|
|
|
28
30
|
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); } }
|
|
29
31
|
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
32
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
33
|
|
|
32
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
34
|
+
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); }
|
|
33
35
|
|
|
34
36
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
37
|
|
|
36
38
|
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); }; }
|
|
37
39
|
|
|
38
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
40
|
+
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); }
|
|
39
41
|
|
|
40
42
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
43
|
|
|
@@ -43,9 +45,9 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
43
45
|
|
|
44
46
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
47
|
|
|
46
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
48
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
49
|
|
|
48
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
50
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
51
|
|
|
50
52
|
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; }
|
|
51
53
|
|
|
@@ -91,7 +93,7 @@ var LinkBase = (0, _kind["default"])({
|
|
|
91
93
|
},
|
|
92
94
|
render: function render(_ref) {
|
|
93
95
|
var path = _ref.path,
|
|
94
|
-
rest = _objectWithoutProperties(_ref,
|
|
96
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
95
97
|
|
|
96
98
|
/* eslint-disable jsx-a11y/anchor-has-content */
|
|
97
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", _objectSpread({
|
package/Routable/Routable.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface RoutableConfig extends Object {
|
|
|
18
18
|
/**
|
|
19
19
|
* The event to listen to for path changes.
|
|
20
20
|
*
|
|
21
|
-
* This defines the actual name of the
|
|
21
|
+
* This defines the actual name of the [navigate]
|
|
22
22
|
property.
|
|
23
23
|
*/
|
|
24
24
|
navigate: string;
|
|
@@ -60,7 +60,7 @@ export interface LinkProps extends Merge<LinkBaseProps, LinkableProps> {
|
|
|
60
60
|
disabled?: boolean;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* A component that is used to make a link to navigate among
|
|
63
|
+
* A component that is used to make a link to navigate among [ `Route` ] components.
|
|
64
64
|
*
|
|
65
65
|
* In the following example, `Sample` would render `Main` with two Links for `About` and `FAQ` .
|
|
66
66
|
If `About` is clicked, the content of `About` would be displayed under `Main` .
|
package/Routable/Routable.js
CHANGED
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "Linkable", {
|
|
|
15
15
|
return _Link.Linkable;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
exports.Routable = void 0;
|
|
18
19
|
Object.defineProperty(exports, "Route", {
|
|
19
20
|
enumerable: true,
|
|
20
21
|
get: function get() {
|
|
@@ -27,7 +28,7 @@ Object.defineProperty(exports, "RouteContext", {
|
|
|
27
28
|
return _util.RouteContext;
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
|
-
exports
|
|
31
|
+
exports["default"] = void 0;
|
|
31
32
|
|
|
32
33
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
33
34
|
|
|
@@ -49,11 +50,14 @@ var _util = require("./util");
|
|
|
49
50
|
|
|
50
51
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
51
52
|
|
|
53
|
+
var _excluded = ["index"],
|
|
54
|
+
_excluded2 = ["children", "handleNavigate", "index", "path"];
|
|
55
|
+
|
|
52
56
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
53
57
|
|
|
54
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
58
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
55
59
|
|
|
56
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
60
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
57
61
|
|
|
58
62
|
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; }
|
|
59
63
|
|
|
@@ -94,7 +98,7 @@ var defaultConfig = {
|
|
|
94
98
|
|
|
95
99
|
var Routable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
96
100
|
var navigate = config.navigate;
|
|
97
|
-
!navigate ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'navigate must be specified with Routable') :
|
|
101
|
+
!navigate ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'navigate must be specified with Routable') : (0, _invariant["default"])(false) : void 0;
|
|
98
102
|
return (0, _kind["default"])({
|
|
99
103
|
name: 'Routable',
|
|
100
104
|
propTypes:
|
|
@@ -125,7 +129,7 @@ var Routable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
|
125
129
|
}
|
|
126
130
|
}, navigate, function (_ref3, _ref4) {
|
|
127
131
|
var index = _ref3.index,
|
|
128
|
-
rest = _objectWithoutProperties(_ref3,
|
|
132
|
+
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
129
133
|
|
|
130
134
|
var path = _ref4.path,
|
|
131
135
|
handler = _ref4[navigate];
|
|
@@ -150,7 +154,7 @@ var Routable = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
|
|
|
150
154
|
handleNavigate = _ref6.handleNavigate,
|
|
151
155
|
index = _ref6.index,
|
|
152
156
|
path = _ref6.path,
|
|
153
|
-
rest = _objectWithoutProperties(_ref6,
|
|
157
|
+
rest = _objectWithoutProperties(_ref6, _excluded2);
|
|
154
158
|
|
|
155
159
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_util.RouteContext.Provider, {
|
|
156
160
|
value: {
|
package/Routable/Route.js
CHANGED
package/Routable/Router.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = exports.RouterBase = exports.Router = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
9
|
|
|
@@ -19,13 +19,16 @@ var _util = require("./util");
|
|
|
19
19
|
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _excluded = ["path", "children", "component"],
|
|
23
|
+
_excluded2 = ["component", "componentRef"];
|
|
24
|
+
|
|
25
|
+
var _class;
|
|
23
26
|
|
|
24
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
28
|
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
29
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
30
|
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
31
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
32
|
|
|
30
33
|
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; }
|
|
31
34
|
|
|
@@ -37,15 +40,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
37
40
|
|
|
38
41
|
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); } }
|
|
39
42
|
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
43
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
41
44
|
|
|
42
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
45
|
+
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); }
|
|
43
46
|
|
|
44
47
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
48
|
|
|
46
49
|
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); }; }
|
|
47
50
|
|
|
48
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
51
|
+
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); }
|
|
49
52
|
|
|
50
53
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
54
|
|
|
@@ -62,7 +65,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
62
65
|
* @ui
|
|
63
66
|
* @private
|
|
64
67
|
*/
|
|
65
|
-
var RouterBase = (
|
|
68
|
+
var RouterBase = (_class = /*#__PURE__*/function (_ReactComponent) {
|
|
66
69
|
_inherits(RouterBase, _ReactComponent);
|
|
67
70
|
|
|
68
71
|
var _super = _createSuper(RouterBase);
|
|
@@ -92,7 +95,7 @@ var RouterBase = (_temp = _class = /*#__PURE__*/function (_ReactComponent) {
|
|
|
92
95
|
path = _child$props.path,
|
|
93
96
|
grandchildren = _child$props.children,
|
|
94
97
|
component = _child$props.component,
|
|
95
|
-
rest = _objectWithoutProperties(_child$props,
|
|
98
|
+
rest = _objectWithoutProperties(_child$props, _excluded);
|
|
96
99
|
|
|
97
100
|
if (path && component) {
|
|
98
101
|
routes[path] = {
|
|
@@ -147,7 +150,7 @@ var RouterBase = (_temp = _class = /*#__PURE__*/function (_ReactComponent) {
|
|
|
147
150
|
var _this$props2 = this.props,
|
|
148
151
|
Component = _this$props2.component,
|
|
149
152
|
componentRef = _this$props2.componentRef,
|
|
150
|
-
rest = _objectWithoutProperties(_this$props2,
|
|
153
|
+
rest = _objectWithoutProperties(_this$props2, _excluded2);
|
|
151
154
|
|
|
152
155
|
var children = this.createChildren();
|
|
153
156
|
delete rest.path;
|
|
@@ -242,7 +245,7 @@ var RouterBase = (_temp = _class = /*#__PURE__*/function (_ReactComponent) {
|
|
|
242
245
|
routes: _propTypes2["default"].object
|
|
243
246
|
}, _class.defaultProps = {
|
|
244
247
|
component: 'div'
|
|
245
|
-
},
|
|
248
|
+
}, _class);
|
|
246
249
|
exports.RouterBase = RouterBase;
|
|
247
250
|
var Router = (0, _ForwardRef["default"])({
|
|
248
251
|
prop: 'componentRef'
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
4
|
|
|
5
|
-
var _react = require("react");
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
+
|
|
9
|
+
var _react2 = require("react");
|
|
6
10
|
|
|
7
11
|
var _Link = _interopRequireDefault(require("../Link"));
|
|
8
12
|
|
|
@@ -14,9 +18,9 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
14
18
|
|
|
15
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
20
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
21
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
22
|
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
24
|
|
|
21
25
|
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; }
|
|
22
26
|
|
|
@@ -28,26 +32,26 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
28
32
|
|
|
29
33
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
30
34
|
|
|
31
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr
|
|
35
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
32
36
|
|
|
33
37
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
38
|
|
|
35
39
|
describe('Routable', function () {
|
|
36
40
|
test('should render nothing for a partially valid path', function () {
|
|
37
|
-
function App() {
|
|
41
|
+
var App = function App() {
|
|
38
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
39
43
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
|
|
40
44
|
path: "./page2",
|
|
41
45
|
children: "Page 2"
|
|
42
46
|
})
|
|
43
47
|
});
|
|
44
|
-
}
|
|
48
|
+
};
|
|
45
49
|
|
|
46
|
-
function Page2() {
|
|
50
|
+
var Page2 = function Page2() {
|
|
47
51
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
48
|
-
|
|
52
|
+
"data-testid": "page2"
|
|
49
53
|
});
|
|
50
|
-
}
|
|
54
|
+
};
|
|
51
55
|
|
|
52
56
|
var Views = (0, _Routable["default"])({
|
|
53
57
|
navigate: 'onNavigate'
|
|
@@ -59,12 +63,12 @@ describe('Routable', function () {
|
|
|
59
63
|
});
|
|
60
64
|
|
|
61
65
|
function Sample(props) {
|
|
62
|
-
var _useState = (0,
|
|
66
|
+
var _useState = (0, _react2.useState)('/app'),
|
|
63
67
|
_useState2 = _slicedToArray(_useState, 2),
|
|
64
68
|
path = _useState2[0],
|
|
65
69
|
nav = _useState2[1];
|
|
66
70
|
|
|
67
|
-
var handleNavigate = (0,
|
|
71
|
+
var handleNavigate = (0, _react2.useCallback)(function (ev) {
|
|
68
72
|
return nav(ev.path);
|
|
69
73
|
}, [nav]);
|
|
70
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Views, _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -81,15 +85,20 @@ describe('Routable', function () {
|
|
|
81
85
|
}));
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Sample, {}));
|
|
89
|
+
|
|
90
|
+
var linkToSecondPage = _react.screen.getByText('Page 2'); // click once to navigate to new path
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
_userEvent["default"].click(linkToSecondPage);
|
|
94
|
+
|
|
95
|
+
var secondPage = _react.screen.getByTestId('page2');
|
|
96
|
+
|
|
97
|
+
expect(secondPage).toBeInTheDocument(); // clicking again should use the same base path "/app" for the same result
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
var actual = subject.find('#page2').length;
|
|
89
|
-
expect(actual).toBe(expected); // clicking again should use the same base path "/app" for the same result
|
|
99
|
+
_userEvent["default"].click(linkToSecondPage);
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
expect(actual).toBe(expected);
|
|
101
|
+
secondPage = _react.screen.getByTestId('page2');
|
|
102
|
+
expect(secondPage).toBeInTheDocument();
|
|
94
103
|
});
|
|
95
104
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _Route = _interopRequireDefault(require("../Route"));
|
|
6
8
|
|
|
@@ -43,66 +45,75 @@ describe('Router', function () {
|
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
test('should render a single component matching the {path}', function () {
|
|
46
|
-
|
|
48
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
47
49
|
routes: routes,
|
|
48
50
|
path: "/app"
|
|
49
51
|
}));
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
var view = _react.screen.getByRole('button');
|
|
54
|
+
|
|
55
|
+
expect(view).toBeInTheDocument();
|
|
53
56
|
});
|
|
54
57
|
test('should render an array of components matching the {path}', function () {
|
|
55
|
-
|
|
58
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
56
59
|
routes: routes,
|
|
57
60
|
path: "/app/home"
|
|
58
61
|
}));
|
|
62
|
+
|
|
63
|
+
var view = _react.screen.getAllByRole('button');
|
|
64
|
+
|
|
59
65
|
var expected = 2;
|
|
60
|
-
|
|
61
|
-
expect(actual).toBe(expected);
|
|
66
|
+
expect(view.length).toBe(expected);
|
|
62
67
|
});
|
|
63
68
|
test('should render an array of components matching the {path} as an array', function () {
|
|
64
|
-
|
|
69
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
65
70
|
routes: routes,
|
|
66
71
|
path: ['app', 'home']
|
|
67
72
|
}));
|
|
73
|
+
|
|
74
|
+
var view = _react.screen.getAllByRole('button');
|
|
75
|
+
|
|
68
76
|
var expected = 2;
|
|
69
|
-
|
|
70
|
-
expect(actual).toBe(expected);
|
|
77
|
+
expect(view.length).toBe(expected);
|
|
71
78
|
});
|
|
72
79
|
test('should render no children if {path} does not exist in {routes}', function () {
|
|
73
80
|
// Modify the console spy to silence error output with
|
|
74
81
|
// an empty mock implementation
|
|
75
82
|
console.error.mockImplementation();
|
|
76
|
-
|
|
83
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
77
84
|
routes: routes,
|
|
78
85
|
path: "/help"
|
|
79
86
|
}));
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
|
|
87
|
+
|
|
88
|
+
var view = _react.screen.queryByRole('button');
|
|
89
|
+
|
|
90
|
+
expect(view).toBeNull();
|
|
83
91
|
});
|
|
84
92
|
test('should render children into {component}', function () {
|
|
85
93
|
var component = function component(props) {
|
|
86
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
87
|
-
|
|
95
|
+
"data-testid": "div1",
|
|
88
96
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
89
|
-
|
|
97
|
+
"data-testid": "div2",
|
|
90
98
|
children: props.children
|
|
91
99
|
})
|
|
92
100
|
});
|
|
93
101
|
};
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.Router, {
|
|
96
104
|
routes: routes,
|
|
97
105
|
path: "/app/settings",
|
|
98
106
|
component: component
|
|
99
107
|
}));
|
|
108
|
+
|
|
109
|
+
var secondDiv = _react.screen.getByTestId('div2');
|
|
110
|
+
|
|
100
111
|
var expected = 2;
|
|
101
|
-
var actual =
|
|
112
|
+
var actual = secondDiv.childElementCount;
|
|
102
113
|
expect(actual).toBe(expected);
|
|
103
114
|
});
|
|
104
115
|
test('should render an array of components matching the {path} using JSX routes', function () {
|
|
105
|
-
|
|
116
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
106
117
|
path: "/app/home",
|
|
107
118
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
108
119
|
path: "app",
|
|
@@ -119,12 +130,15 @@ describe('Router', function () {
|
|
|
119
130
|
component: View
|
|
120
131
|
})]
|
|
121
132
|
}));
|
|
133
|
+
|
|
134
|
+
var view = _react.screen.getAllByRole('button');
|
|
135
|
+
|
|
122
136
|
var expected = 2;
|
|
123
|
-
var actual =
|
|
137
|
+
var actual = view.length;
|
|
124
138
|
expect(actual).toBe(expected);
|
|
125
139
|
});
|
|
126
140
|
test('should render a different component when the routes change for the same {path}', function () {
|
|
127
|
-
var
|
|
141
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
128
142
|
path: "/app",
|
|
129
143
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
130
144
|
path: "app",
|
|
@@ -140,28 +154,36 @@ describe('Router', function () {
|
|
|
140
154
|
path: "admin",
|
|
141
155
|
component: View
|
|
142
156
|
})]
|
|
143
|
-
}))
|
|
157
|
+
})),
|
|
158
|
+
rerender = _render.rerender;
|
|
144
159
|
|
|
145
160
|
var NewView = function NewView() {
|
|
146
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
161
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
162
|
+
"data-testid": "span"
|
|
163
|
+
});
|
|
147
164
|
};
|
|
148
165
|
|
|
149
|
-
|
|
150
|
-
path:
|
|
151
|
-
children:
|
|
166
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.Router, {
|
|
167
|
+
path: "/app",
|
|
168
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Route["default"], {
|
|
152
169
|
path: "app",
|
|
153
|
-
component: NewView
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
component: NewView,
|
|
171
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Route["default"], {
|
|
172
|
+
path: "app",
|
|
173
|
+
component: NewView
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
}));
|
|
177
|
+
|
|
178
|
+
var view = _react.screen.getByTestId('span');
|
|
179
|
+
|
|
180
|
+
expect(view).toBeInTheDocument();
|
|
159
181
|
});
|
|
160
182
|
test('should render nothing for an invalid path', function () {
|
|
161
183
|
// Modify the console spy to silence error output with
|
|
162
184
|
// an empty mock implementation
|
|
163
185
|
console.error.mockImplementation();
|
|
164
|
-
|
|
186
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
165
187
|
path: "/does/not/exist",
|
|
166
188
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
167
189
|
path: "app",
|
|
@@ -178,15 +200,16 @@ describe('Router', function () {
|
|
|
178
200
|
component: View
|
|
179
201
|
})]
|
|
180
202
|
}));
|
|
181
|
-
|
|
182
|
-
var
|
|
183
|
-
|
|
203
|
+
|
|
204
|
+
var view = _react.screen.queryByRole('button');
|
|
205
|
+
|
|
206
|
+
expect(view).toBeNull();
|
|
184
207
|
});
|
|
185
208
|
test('should render nothing for a partially valid path', function () {
|
|
186
209
|
// Modify the console spy to silence error output with
|
|
187
210
|
// an empty mock implementation
|
|
188
211
|
console.error.mockImplementation();
|
|
189
|
-
|
|
212
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
190
213
|
path: "/app/home/other",
|
|
191
214
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
192
215
|
path: "app",
|
|
@@ -203,8 +226,9 @@ describe('Router', function () {
|
|
|
203
226
|
component: View
|
|
204
227
|
})]
|
|
205
228
|
}));
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
|
|
229
|
+
|
|
230
|
+
var view = _react.screen.queryByRole('button');
|
|
231
|
+
|
|
232
|
+
expect(view).toBeNull();
|
|
209
233
|
});
|
|
210
234
|
});
|
package/Routable/useLink.js
CHANGED
package/Routable/util.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.toSegments = exports.stringifyRoutes = exports.resolve = exports.propTypes = exports.RouteContext = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|