@enact/ui 4.5.2 → 4.6.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 +1 -40
- package/AnnounceDecorator/AnnounceDecorator.js +3 -21
- package/AnnounceDecorator/tests/Announce-specs.js +2 -7
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
- package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
- package/AnnounceDecorator/useAnnounce.js +0 -6
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +30 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +18 -51
- package/Group/Group.js +5 -36
- package/Group/GroupItem.js +16 -33
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +8 -36
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +17 -55
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +17 -46
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +18 -47
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +9 -33
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.d.ts +2 -2
- package/LabeledIcon/LabeledIcon.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +70 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +295 -87
- package/Measurable/Measurable.js +12 -34
- package/Measurable/tests/Measurable-specs.js +115 -0
- package/Media/Media.js +15 -65
- package/Media/tests/Media-specs.js +168 -0
- package/Placeholder/PlaceholderControllerDecorator.js +7 -43
- package/Placeholder/PlaceholderDecorator.js +7 -38
- package/Placeholder/index.js +1 -5
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +14 -45
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +1 -29
- package/RadioDecorator/RadioDecorator.js +4 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +9 -37
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +11 -47
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +12 -35
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +15 -58
- package/Routable/tests/Routable-specs.js +7 -33
- package/Routable/tests/Router-specs.js +18 -44
- package/Routable/useLink.js +4 -8
- package/Routable/util.js +18 -24
- package/Scrollable/ScrollAnimator.js +49 -65
- package/Scrollable/ScrollThumb.js +2 -13
- package/Scrollable/Scrollable.js +180 -387
- package/Scrollable/ScrollableNative.js +189 -392
- package/Scrollable/Scrollbar.js +30 -102
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- package/Scroller/tests/Scroller-specs.js +56 -0
- package/Skinnable/Skinnable.js +11 -38
- package/Skinnable/tests/Skinnable-specs.js +3 -74
- package/Skinnable/tests/useSkins-specs.js +1 -13
- package/Skinnable/tests/util-specs.js +0 -14
- package/Skinnable/useSkins.js +8 -15
- package/Skinnable/util.js +9 -20
- package/Slider/Knob.js +5 -24
- package/Slider/PositionDecorator.js +16 -54
- package/Slider/Slider.d.ts +2 -2
- package/Slider/Slider.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.d.ts +1 -1
- package/SlotItem/SlotItem.js +17 -43
- package/SlotItem/tests/SlotItem-specs.js +0 -5
- package/Slottable/Slottable.js +4 -12
- package/Slottable/tests/Slottable-specs.js +19 -46
- package/Slottable/tests/useSlots-specs.js +27 -65
- package/Slottable/useSlots.js +8 -33
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +16 -43
- package/Spinner/tests/Spinner-specs.js +0 -15
- package/ToggleIcon/ToggleIcon.js +10 -36
- package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
- package/ToggleItem/ToggleItem.d.ts +3 -3
- package/ToggleItem/ToggleItem.js +18 -55
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Touch.js +37 -65
- package/Touchable/Touchable.js +32 -71
- package/Touchable/config.js +8 -22
- package/Touchable/tests/Touchable-specs.js +270 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +17 -34
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +32 -107
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.d.ts +1 -1
- package/ViewManager/ViewManager.js +20 -84
- package/ViewManager/tests/View-specs.js +0 -17
- package/ViewManager/tests/ViewManager-specs.js +236 -305
- package/ViewManager/tests/test-utils.js +0 -8
- package/VirtualList/UiVirtualListBase.js +259 -409
- package/VirtualList/VirtualList.d.ts +4 -4
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +273 -431
- package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
- package/VirtualList/tests/VirtualGridList-specs.js +614 -0
- package/VirtualList/tests/VirtualList-native-specs.js +152 -0
- package/VirtualList/tests/VirtualList-specs.js +423 -95
- package/internal/IdProvider/IdProvider.js +7 -21
- package/internal/IdProvider/Provider.js +4 -17
- package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
- package/internal/IdProvider/tests/useId-specs.js +6 -20
- package/internal/IdProvider/useId.js +0 -6
- package/internal/Pure/Pure.js +3 -30
- package/internal/Pure/tests/Pure-specs.js +88 -0
- package/internal/localized-fonts/localized-fonts.js +33 -62
- package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
- package/internal/selection/selection.js +1 -6
- package/internal/selection/tests/selection-specs.js +6 -4
- package/internal/validators/tests/validators-specs.js +80 -0
- package/internal/validators/validators.js +14 -34
- package/package.json +9 -3
- package/resolution/ResolutionDecorator.js +4 -40
- package/resolution/index.js +0 -7
- package/resolution/resolution.js +42 -80
- package/resolution/tests/ResolutionDecorator-specs.js +4 -11
- package/resolution/tests/resolution-specs.js +2 -2
- package/useControlledState/tests/useControlledState-specs.js +15 -46
- package/useControlledState/useControlledState.js +11 -22
- package/useScroll/ScrollAnimator.js +49 -65
- package/useScroll/Scrollbar.js +22 -58
- package/useScroll/ScrollbarTrack.js +3 -19
- package/useScroll/useScroll.js +267 -454
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
package/Item/Item.js
CHANGED
|
@@ -4,37 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.ItemDecorator = exports.ItemBase = exports.Item = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
|
-
|
|
10
8
|
var _kind = _interopRequireDefault(require("@enact/core/kind"));
|
|
11
|
-
|
|
12
9
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _compose = _interopRequireDefault(require("ramda/src/compose"));
|
|
15
|
-
|
|
16
11
|
var _Touchable = _interopRequireDefault(require("../Touchable"));
|
|
17
|
-
|
|
18
12
|
var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
|
|
19
|
-
|
|
20
13
|
var _ItemModule = _interopRequireDefault(require("./Item.module.css"));
|
|
21
|
-
|
|
22
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
-
|
|
24
15
|
var _excluded = ["component", "componentRef", "disabled", "children"];
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
-
|
|
28
17
|
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; }
|
|
29
|
-
|
|
30
18
|
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; }
|
|
31
|
-
|
|
32
19
|
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; }
|
|
33
|
-
|
|
34
20
|
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; }
|
|
35
|
-
|
|
36
21
|
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; }
|
|
37
|
-
|
|
38
22
|
/**
|
|
39
23
|
* A basic list item component structure without any behaviors applied to it.
|
|
40
24
|
*
|
|
@@ -47,9 +31,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
47
31
|
*/
|
|
48
32
|
var ItemBase = (0, _kind["default"])({
|
|
49
33
|
name: 'ui:Item',
|
|
50
|
-
propTypes:
|
|
51
|
-
/** @lends ui/Item.ItemBase.prototype */
|
|
52
|
-
{
|
|
34
|
+
propTypes: /** @lends ui/Item.ItemBase.prototype */{
|
|
53
35
|
/**
|
|
54
36
|
* The node to be displayed as the main content of the item.
|
|
55
37
|
*
|
|
@@ -57,7 +39,6 @@ var ItemBase = (0, _kind["default"])({
|
|
|
57
39
|
* @public
|
|
58
40
|
*/
|
|
59
41
|
children: _propTypes2["default"].node,
|
|
60
|
-
|
|
61
42
|
/**
|
|
62
43
|
* The type of component to use to render the item. May be a DOM node name (e.g 'div',
|
|
63
44
|
* 'span', etc.) or a custom component.
|
|
@@ -67,15 +48,13 @@ var ItemBase = (0, _kind["default"])({
|
|
|
67
48
|
* @public
|
|
68
49
|
*/
|
|
69
50
|
component: _propTypes["default"].renderable,
|
|
70
|
-
|
|
71
51
|
/**
|
|
72
|
-
* Called with a reference to
|
|
52
|
+
* Called with a reference to {@link ui/Item.ItemBase#component|component}
|
|
73
53
|
*
|
|
74
54
|
* @type {Object|Function}
|
|
75
55
|
* @private
|
|
76
56
|
*/
|
|
77
57
|
componentRef: _propTypes["default"].ref,
|
|
78
|
-
|
|
79
58
|
/**
|
|
80
59
|
* Customizes the component by mapping the supplied collection of CSS class names to the
|
|
81
60
|
* corresponding internal elements and states of this component.
|
|
@@ -89,7 +68,6 @@ var ItemBase = (0, _kind["default"])({
|
|
|
89
68
|
* @public
|
|
90
69
|
*/
|
|
91
70
|
css: _propTypes2["default"].object,
|
|
92
|
-
|
|
93
71
|
/**
|
|
94
72
|
* Applies a disabled state to the item.
|
|
95
73
|
*
|
|
@@ -98,7 +76,6 @@ var ItemBase = (0, _kind["default"])({
|
|
|
98
76
|
* @public
|
|
99
77
|
*/
|
|
100
78
|
disabled: _propTypes2["default"].bool,
|
|
101
|
-
|
|
102
79
|
/**
|
|
103
80
|
* Applies inline styling to the item.
|
|
104
81
|
*
|
|
@@ -120,7 +97,7 @@ var ItemBase = (0, _kind["default"])({
|
|
|
120
97
|
computed: {
|
|
121
98
|
className: function className(_ref) {
|
|
122
99
|
var inline = _ref.inline,
|
|
123
|
-
|
|
100
|
+
styler = _ref.styler;
|
|
124
101
|
return styler.append({
|
|
125
102
|
inline: inline
|
|
126
103
|
});
|
|
@@ -128,11 +105,10 @@ var ItemBase = (0, _kind["default"])({
|
|
|
128
105
|
},
|
|
129
106
|
render: function render(_ref2) {
|
|
130
107
|
var Component = _ref2.component,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
108
|
+
componentRef = _ref2.componentRef,
|
|
109
|
+
disabled = _ref2.disabled,
|
|
110
|
+
children = _ref2.children,
|
|
111
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
136
112
|
delete rest.inline;
|
|
137
113
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread(_objectSpread({
|
|
138
114
|
ref: componentRef
|
|
@@ -143,6 +119,7 @@ var ItemBase = (0, _kind["default"])({
|
|
|
143
119
|
}));
|
|
144
120
|
}
|
|
145
121
|
});
|
|
122
|
+
|
|
146
123
|
/**
|
|
147
124
|
* A higher-order component that adds touch support to the component it wraps.
|
|
148
125
|
*
|
|
@@ -152,11 +129,11 @@ var ItemBase = (0, _kind["default"])({
|
|
|
152
129
|
* @mixes ui/Touchable.Touchable
|
|
153
130
|
* @public
|
|
154
131
|
*/
|
|
155
|
-
|
|
156
132
|
exports.ItemBase = ItemBase;
|
|
157
133
|
var ItemDecorator = (0, _compose["default"])((0, _ForwardRef["default"])({
|
|
158
134
|
prop: 'componentRef'
|
|
159
135
|
}), _Touchable["default"]);
|
|
136
|
+
|
|
160
137
|
/**
|
|
161
138
|
* A minimally-styled ready-to-use list item component with touch support.
|
|
162
139
|
*
|
|
@@ -168,7 +145,6 @@ var ItemDecorator = (0, _compose["default"])((0, _ForwardRef["default"])({
|
|
|
168
145
|
* @ui
|
|
169
146
|
* @public
|
|
170
147
|
*/
|
|
171
|
-
|
|
172
148
|
exports.ItemDecorator = ItemDecorator;
|
|
173
149
|
var Item = ItemDecorator(ItemBase);
|
|
174
150
|
exports.Item = Item;
|
package/Item/tests/Item-specs.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("@testing-library/jest-dom");
|
|
4
|
-
|
|
5
4
|
var _react = require("@testing-library/react");
|
|
6
|
-
|
|
7
5
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
-
|
|
9
6
|
var _Item = _interopRequireDefault(require("../Item"));
|
|
10
|
-
|
|
11
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
|
|
13
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
|
|
15
9
|
var tap = function tap(node) {
|
|
16
10
|
_react.fireEvent.mouseDown(node);
|
|
17
|
-
|
|
18
11
|
_react.fireEvent.mouseUp(node);
|
|
19
12
|
};
|
|
20
|
-
|
|
21
13
|
describe('Item', function () {
|
|
22
14
|
test('should render an item', function () {
|
|
23
15
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item["default"], {
|
|
24
16
|
children: "I am an item"
|
|
25
17
|
}));
|
|
26
|
-
|
|
27
18
|
var actual = _react.screen.getByText('I am an item');
|
|
28
|
-
|
|
29
19
|
expect(actual).toBeInTheDocument();
|
|
30
20
|
});
|
|
31
21
|
test('should render a disabled item', function () {
|
|
@@ -33,9 +23,7 @@ describe('Item', function () {
|
|
|
33
23
|
disabled: true,
|
|
34
24
|
children: "I am a disabled item"
|
|
35
25
|
}));
|
|
36
|
-
|
|
37
26
|
var actual = _react.screen.getByText('I am a disabled item');
|
|
38
|
-
|
|
39
27
|
expect(actual).toHaveAttribute('disabled');
|
|
40
28
|
});
|
|
41
29
|
test('should render an inline item', function () {
|
|
@@ -43,9 +31,7 @@ describe('Item', function () {
|
|
|
43
31
|
inline: true,
|
|
44
32
|
children: "I am an inline item"
|
|
45
33
|
}));
|
|
46
|
-
|
|
47
34
|
var actual = _react.screen.getByText('I am an inline item');
|
|
48
|
-
|
|
49
35
|
var expected = 'inline';
|
|
50
36
|
expect(actual).toHaveClass(expected);
|
|
51
37
|
});
|
|
@@ -56,9 +42,7 @@ describe('Item', function () {
|
|
|
56
42
|
onTap: handleClick,
|
|
57
43
|
children: "I am a normal item"
|
|
58
44
|
}));
|
|
59
|
-
|
|
60
45
|
var item = _react.screen.getByText('I am a normal item');
|
|
61
|
-
|
|
62
46
|
tap(item);
|
|
63
47
|
var expected = 1;
|
|
64
48
|
expect(handleClick).toHaveBeenCalledTimes(expected);
|
|
@@ -70,9 +54,7 @@ describe('Item', function () {
|
|
|
70
54
|
onTap: handleClick,
|
|
71
55
|
children: "I am a disabled item"
|
|
72
56
|
}));
|
|
73
|
-
|
|
74
57
|
var item = _react.screen.getByText('I am a disabled item');
|
|
75
|
-
|
|
76
58
|
tap(item);
|
|
77
59
|
expect(handleClick).not.toHaveBeenCalled();
|
|
78
60
|
});
|
|
@@ -82,11 +64,8 @@ describe('Item', function () {
|
|
|
82
64
|
onClick: handleClick,
|
|
83
65
|
children: "I am a normal Item"
|
|
84
66
|
}));
|
|
85
|
-
|
|
86
67
|
var item = _react.screen.getByText('I am a normal Item');
|
|
87
|
-
|
|
88
68
|
_userEvent["default"].click(item);
|
|
89
|
-
|
|
90
69
|
var expected = 1;
|
|
91
70
|
expect(handleClick).toHaveBeenCalledTimes(expected);
|
|
92
71
|
});
|
|
@@ -97,11 +76,8 @@ describe('Item', function () {
|
|
|
97
76
|
onClick: handleClick,
|
|
98
77
|
children: "I am a disabled Item"
|
|
99
78
|
}));
|
|
100
|
-
|
|
101
79
|
var item = _react.screen.getByText('I am a disabled Item');
|
|
102
|
-
|
|
103
80
|
_userEvent["default"].click(item);
|
|
104
|
-
|
|
105
81
|
expect(handleClick).not.toHaveBeenCalled();
|
|
106
82
|
});
|
|
107
83
|
});
|
|
@@ -68,7 +68,7 @@ also receive the `flip` and `size` props as set on the component.
|
|
|
68
68
|
* Enables this component to be used in an "inline" context.
|
|
69
69
|
*
|
|
70
70
|
* This is useful for when you have several of these components in a row and are not using a
|
|
71
|
-
|
|
71
|
+
or flex-box configuration.
|
|
72
72
|
*/
|
|
73
73
|
inline?: boolean;
|
|
74
74
|
/**
|
|
@@ -89,7 +89,7 @@ also receive the `flip` and `size` props as set on the component.
|
|
|
89
89
|
* The size of the icon.
|
|
90
90
|
*
|
|
91
91
|
* Applies the CSS class which can be customized by
|
|
92
|
-
|
|
92
|
+
.
|
|
93
93
|
*/
|
|
94
94
|
size?: string;
|
|
95
95
|
}
|
|
@@ -4,43 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.LabeledIconDecorator = exports.LabeledIconBase = exports.LabeledIcon = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
|
-
|
|
10
8
|
var _kind = _interopRequireDefault(require("@enact/core/kind"));
|
|
11
|
-
|
|
12
9
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _compose = _interopRequireDefault(require("ramda/src/compose"));
|
|
15
|
-
|
|
16
11
|
var _react = require("react");
|
|
17
|
-
|
|
18
12
|
var _ComponentOverride = _interopRequireDefault(require("../ComponentOverride"));
|
|
19
|
-
|
|
20
13
|
var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
|
|
21
|
-
|
|
22
14
|
var _Layout = require("../Layout");
|
|
23
|
-
|
|
24
15
|
var _Slottable = _interopRequireDefault(require("../Slottable"));
|
|
25
|
-
|
|
26
16
|
var _LabeledIconModule = _interopRequireDefault(require("./LabeledIcon.module.css"));
|
|
27
|
-
|
|
28
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
|
|
30
18
|
var _excluded = ["css", "children", "componentRef", "disabled", "flip", "icon", "iconComponent", "orientation", "size"];
|
|
31
|
-
|
|
32
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
|
-
|
|
34
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; }
|
|
35
|
-
|
|
36
21
|
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; }
|
|
37
|
-
|
|
38
22
|
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; }
|
|
39
|
-
|
|
40
23
|
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; }
|
|
41
|
-
|
|
42
24
|
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; }
|
|
43
|
-
|
|
44
25
|
/**
|
|
45
26
|
* An icon component with a label.
|
|
46
27
|
*
|
|
@@ -51,9 +32,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
51
32
|
*/
|
|
52
33
|
var LabeledIconBase = (0, _kind["default"])({
|
|
53
34
|
name: 'ui:LabeledIcon',
|
|
54
|
-
propTypes:
|
|
55
|
-
/** @lends ui/LabeledIcon.LabeledIconBase.prototype */
|
|
56
|
-
{
|
|
35
|
+
propTypes: /** @lends ui/LabeledIcon.LabeledIconBase.prototype */{
|
|
57
36
|
/**
|
|
58
37
|
* The label.
|
|
59
38
|
*
|
|
@@ -64,7 +43,6 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
64
43
|
* @public
|
|
65
44
|
*/
|
|
66
45
|
children: _propTypes2["default"].node,
|
|
67
|
-
|
|
68
46
|
/**
|
|
69
47
|
* Called with a reference to the root component.
|
|
70
48
|
*
|
|
@@ -75,7 +53,6 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
75
53
|
* @public
|
|
76
54
|
*/
|
|
77
55
|
componentRef: _propTypes["default"].ref,
|
|
78
|
-
|
|
79
56
|
/**
|
|
80
57
|
* Customizes the component by mapping the supplied collection of CSS class names to the
|
|
81
58
|
* corresponding internal elements and states of this component.
|
|
@@ -100,7 +77,6 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
100
77
|
* @public
|
|
101
78
|
*/
|
|
102
79
|
css: _propTypes2["default"].object,
|
|
103
|
-
|
|
104
80
|
/**
|
|
105
81
|
* Disables the component and becomes non-interactive.
|
|
106
82
|
*
|
|
@@ -109,7 +85,6 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
109
85
|
* @public
|
|
110
86
|
*/
|
|
111
87
|
disabled: _propTypes2["default"].bool,
|
|
112
|
-
|
|
113
88
|
/**
|
|
114
89
|
* Flip the icon horizontally, vertically or both.
|
|
115
90
|
*
|
|
@@ -117,7 +92,6 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
117
92
|
* @public
|
|
118
93
|
*/
|
|
119
94
|
flip: _propTypes2["default"].string,
|
|
120
|
-
|
|
121
95
|
/**
|
|
122
96
|
* The icon.
|
|
123
97
|
*
|
|
@@ -128,7 +102,6 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
128
102
|
* @public
|
|
129
103
|
*/
|
|
130
104
|
icon: _propTypes["default"].renderableOverride,
|
|
131
|
-
|
|
132
105
|
/**
|
|
133
106
|
* The component used to render the `icon`.
|
|
134
107
|
*
|
|
@@ -139,19 +112,17 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
139
112
|
* @type {Component}
|
|
140
113
|
*/
|
|
141
114
|
iconComponent: _propTypes["default"].component,
|
|
142
|
-
|
|
143
115
|
/**
|
|
144
116
|
* Enables this component to be used in an "inline" context.
|
|
145
117
|
*
|
|
146
118
|
* This is useful for when you have several of these components in a row and are not using a
|
|
147
|
-
*
|
|
119
|
+
* {@link ui/Layout|Layout} or flex-box configuration.
|
|
148
120
|
*
|
|
149
121
|
* @type {Boolean}
|
|
150
122
|
* @default false
|
|
151
123
|
* @public
|
|
152
124
|
*/
|
|
153
125
|
inline: _propTypes2["default"].bool,
|
|
154
|
-
|
|
155
126
|
/**
|
|
156
127
|
* The position of the label in relation to the icon element.
|
|
157
128
|
*
|
|
@@ -170,12 +141,11 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
170
141
|
* @public
|
|
171
142
|
*/
|
|
172
143
|
labelPosition: _propTypes2["default"].oneOf(['above', 'after', 'before', 'below', 'left', 'right']),
|
|
173
|
-
|
|
174
144
|
/**
|
|
175
145
|
* The size of the icon.
|
|
176
146
|
*
|
|
177
147
|
* Applies the CSS class which can be customized by
|
|
178
|
-
*
|
|
148
|
+
* {@link /docs/developer-guide/theming/|theming}.
|
|
179
149
|
*
|
|
180
150
|
* @type {String}
|
|
181
151
|
* @public
|
|
@@ -194,8 +164,8 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
194
164
|
computed: {
|
|
195
165
|
className: function className(_ref) {
|
|
196
166
|
var inline = _ref.inline,
|
|
197
|
-
|
|
198
|
-
|
|
167
|
+
labelPosition = _ref.labelPosition,
|
|
168
|
+
styler = _ref.styler;
|
|
199
169
|
return styler.append(labelPosition, {
|
|
200
170
|
inline: inline
|
|
201
171
|
});
|
|
@@ -208,35 +178,34 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
208
178
|
},
|
|
209
179
|
render: function render(_ref3) {
|
|
210
180
|
var css = _ref3.css,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
181
|
+
children = _ref3.children,
|
|
182
|
+
componentRef = _ref3.componentRef,
|
|
183
|
+
disabled = _ref3.disabled,
|
|
184
|
+
flip = _ref3.flip,
|
|
185
|
+
icon = _ref3.icon,
|
|
186
|
+
Icon = _ref3.iconComponent,
|
|
187
|
+
orientation = _ref3.orientation,
|
|
188
|
+
size = _ref3.size,
|
|
189
|
+
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
221
190
|
delete rest.inline;
|
|
222
|
-
var iconClassName = css.icon;
|
|
191
|
+
var iconClassName = css.icon;
|
|
192
|
+
|
|
193
|
+
// Rearrange the props to support custom JSX components
|
|
223
194
|
// `icon` is normally passed to `iconComponent` as children, but if `icon` is instead a
|
|
224
195
|
// rendered JSX component, it should become a child of `Cell.icon` and iconComponent should
|
|
225
196
|
// use Cell's default value. We must also reposition the `icon` class
|
|
226
|
-
|
|
227
197
|
if ( /*#__PURE__*/(0, _react.isValidElement)(icon)) {
|
|
228
198
|
icon = (0, _ComponentOverride["default"])({
|
|
229
199
|
component: icon,
|
|
230
200
|
className: iconClassName,
|
|
231
201
|
disabled: disabled,
|
|
232
202
|
size: size
|
|
233
|
-
});
|
|
203
|
+
});
|
|
204
|
+
// Removing size and iconComponent from CellBase
|
|
234
205
|
// eslint-disable-next-line no-undefined
|
|
235
|
-
|
|
236
206
|
size = Icon = undefined;
|
|
237
207
|
iconClassName = null;
|
|
238
208
|
}
|
|
239
|
-
|
|
240
209
|
delete rest.inline;
|
|
241
210
|
delete rest.labelPosition;
|
|
242
211
|
return _Layout.LayoutBase.inline(_objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -267,21 +236,22 @@ var LabeledIconBase = (0, _kind["default"])({
|
|
|
267
236
|
}));
|
|
268
237
|
}
|
|
269
238
|
});
|
|
239
|
+
|
|
270
240
|
/**
|
|
271
|
-
* A higher-order component that adds
|
|
241
|
+
* A higher-order component that adds {@link ui/Slottable.Slottable|slot} support to {@link ui/LabeledIcon.LabeledIconBase|LabeledIconBase}
|
|
272
242
|
*
|
|
273
243
|
* @hoc
|
|
274
244
|
* @memberof ui/LabeledIcon
|
|
275
245
|
* @mixes ui/Slottable.Slottable
|
|
276
246
|
* @public
|
|
277
247
|
*/
|
|
278
|
-
|
|
279
248
|
exports.LabeledIconBase = LabeledIconBase;
|
|
280
249
|
var LabeledIconDecorator = (0, _compose["default"])((0, _ForwardRef["default"])({
|
|
281
250
|
prop: 'componentRef'
|
|
282
251
|
}), (0, _Slottable["default"])({
|
|
283
252
|
slots: ['icon']
|
|
284
253
|
}));
|
|
254
|
+
|
|
285
255
|
/**
|
|
286
256
|
* An icon component with a label without any behaviors applied to it.
|
|
287
257
|
*
|
|
@@ -300,7 +270,6 @@ var LabeledIconDecorator = (0, _compose["default"])((0, _ForwardRef["default"])(
|
|
|
300
270
|
* @ui
|
|
301
271
|
* @public
|
|
302
272
|
*/
|
|
303
|
-
|
|
304
273
|
exports.LabeledIconDecorator = LabeledIconDecorator;
|
|
305
274
|
var LabeledIcon = LabeledIconDecorator(LabeledIconBase);
|
|
306
275
|
exports.LabeledIcon = LabeledIcon;
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("@testing-library/jest-dom");
|
|
4
|
-
|
|
5
4
|
var _react = require("@testing-library/react");
|
|
6
|
-
|
|
7
5
|
var _LabeledIcon = _interopRequireDefault(require("../LabeledIcon"));
|
|
8
|
-
|
|
9
6
|
var _Icon = _interopRequireDefault(require("../../Icon"));
|
|
10
|
-
|
|
11
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
|
|
13
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
|
|
15
9
|
var iconName = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
16
10
|
"data-testid": "iconName",
|
|
17
11
|
children: "anIconName"
|
|
18
12
|
});
|
|
19
13
|
var iconLabel = 'A real label';
|
|
20
|
-
|
|
21
14
|
var iconComponent = function iconComponent(_ref) {
|
|
22
15
|
var children = _ref.children;
|
|
23
16
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
24
17
|
children: children
|
|
25
18
|
});
|
|
26
19
|
};
|
|
27
|
-
|
|
28
20
|
describe('LabeledIcon Specs', function () {
|
|
29
21
|
test('should insert the icon source into the icon when using the prop approach', function () {
|
|
30
22
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabeledIcon["default"], {
|
|
@@ -32,9 +24,7 @@ describe('LabeledIcon Specs', function () {
|
|
|
32
24
|
iconComponent: iconComponent,
|
|
33
25
|
children: iconLabel
|
|
34
26
|
}));
|
|
35
|
-
|
|
36
27
|
var icon = _react.screen.getByTestId('iconName');
|
|
37
|
-
|
|
38
28
|
var expected = 'anIconName';
|
|
39
29
|
expect(icon).toHaveClass('icon');
|
|
40
30
|
expect(icon.textContent).toBe(expected);
|
|
@@ -46,9 +36,7 @@ describe('LabeledIcon Specs', function () {
|
|
|
46
36
|
children: iconName
|
|
47
37
|
}), iconLabel]
|
|
48
38
|
}));
|
|
49
|
-
|
|
50
39
|
var icon = _react.screen.getByTestId('iconName');
|
|
51
|
-
|
|
52
40
|
var expected = 'anIconName';
|
|
53
41
|
expect(icon).toHaveClass('icon');
|
|
54
42
|
expect(icon.textContent).toBe(expected);
|
|
@@ -63,9 +51,7 @@ describe('LabeledIcon Specs', function () {
|
|
|
63
51
|
})
|
|
64
52
|
}), iconLabel]
|
|
65
53
|
}));
|
|
66
|
-
|
|
67
54
|
var customIcon = _react.screen.getByTestId('customIcon');
|
|
68
|
-
|
|
69
55
|
expect(customIcon).toBeInTheDocument();
|
|
70
56
|
});
|
|
71
57
|
test('should return a DOM node reference for `componentRef`', function () {
|