@enact/limestone 1.9.3 → 1.10.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/.github/workflows/ci-reusable.yml +2 -2
- package/ActionGuide/ActionGuide.module.css +4 -0
- package/Alert/Alert.d.ts +9 -0
- package/Alert/Alert.js +35 -4
- package/Alert/Alert.module.css +12 -1
- package/Alert/tests/Alert-specs.js +91 -0
- package/BodyText/BodyText.module.css +21 -0
- package/Button/Button.module.css +72 -40
- package/Button/tests/Button-specs.js +26 -0
- package/CHANGELOG.md +74 -0
- package/Card/Card.d.ts +4 -4
- package/Card/Card.js +10 -8
- package/Card/Card.module.css +31 -7
- package/Card/tests/Card-specs.js +39 -5
- package/Checkbox/Checkbox.module.css +4 -0
- package/CheckboxItem/CheckboxItem.js +6 -4
- package/Chips/Chip.js +12 -6
- package/Chips/Chip.module.css +3 -0
- package/Chips/Chips.js +12 -6
- package/Chips/tests/Chip-specs.js +25 -5
- package/Chips/tests/Chips-specs.js +12 -2
- package/ColorPicker/ColorPicker.js +27 -25
- package/ContextualPopupDecorator/ContextualPopupDecorator.js +32 -22
- package/DayPicker/DaySelectorDecorator.js +12 -7
- package/Dropdown/Dropdown.module.css +4 -0
- package/Dropdown/DropdownList.js +74 -53
- package/FlexiblePopupPanels/useNavButtonFocus.js +7 -10
- package/Heading/Heading.d.ts +1 -1
- package/Heading/Heading.js +2 -2
- package/Heading/Heading.module.css +16 -0
- package/Icon/Icon.d.ts +1 -0
- package/Icon/Icon.js +1 -0
- package/Icon/Icon.module.css +12 -0
- package/Icon/IconList.js +2 -0
- package/IconItem/IconItem.module.css +19 -3
- package/IconItem/tests/IconItem-specs.js +30 -1
- package/Image/Image.js +6 -4
- package/ImageItem/ImageItem.module.css +17 -0
- package/Input/Input.js +12 -1
- package/Input/Input.module.css +25 -9
- package/Input/InputField.js +75 -24
- package/Input/InputField.module.css +280 -45
- package/Input/InputFieldDecoratorIcon.js +1 -0
- package/Input/InputFieldSpotlightDecorator.js +53 -8
- package/Input/index.d.ts +105 -93
- package/Input/tests/Input-specs.js +26 -0
- package/Input/tests/InputField-specs.js +149 -3
- package/Input/tests/InputPopup-specs.js +1 -1
- package/Item/Item.module.css +2 -1
- package/KeyGuide/KeyGuide.js +29 -27
- package/KeyGuide/KeyGuide.module.css +10 -0
- package/MediaOverlay/MediaOverlay.module.css +16 -4
- package/MediaOverlay/tests/MediaOverlay-specs.js +29 -0
- package/MediaPlayer/MediaControls.module.css +3 -0
- package/MediaPlayer/Times.module.css +4 -0
- package/MediaPlayer/tests/util-specs.js +4 -1
- package/PageViews/PageViews.js +134 -69
- package/PageViews/PageViews.module.css +7 -0
- package/PageViews/PageViewsRouter.js +91 -42
- package/PageViews/tests/PageViews-specs.js +87 -0
- package/Panels/Header.js +6 -4
- package/Panels/Header.module.css +37 -31
- package/Popup/Popup.js +5 -4
- package/PopupTabLayout/PopupTabLayout.js +11 -9
- package/PopupTabLayout/PopupTabLayout.module.css +18 -0
- package/RadioItem/RadioItem.js +7 -5
- package/RadioItem/RadioItem.module.css +5 -0
- package/Scroller/EditableWrapper.js +19 -15
- package/Scroller/Scroller.js +11 -10
- package/Scroller/Scroller.module.css +10 -0
- package/Scroller/tests/Scroller-specs.js +91 -2
- package/Scroller/useThemeScroller.js +6 -3
- package/Slider/Slider.d.ts +4 -0
- package/Slider/Slider.js +40 -16
- package/Slider/Slider.module.css +150 -3
- package/Slider/SliderBehaviorDecorator.js +16 -14
- package/Slider/tests/Slider-specs.js +51 -0
- package/Slider/utils.js +23 -7
- package/Spinner/Spinner.js +10 -8
- package/Steps/Steps.module.css +3 -0
- package/Switch/Switch.module.css +15 -1
- package/TabLayout/RefocusDecorator.js +14 -12
- package/TabLayout/TabGroup.module.css +1 -1
- package/TabLayout/tests/TabGroup-specs.js +1 -1
- package/ThemeDecorator/AccessibilityDecorator.js +12 -11
- package/ThemeDecorator/I18nFontDecorator.js +6 -4
- package/ThemeDecorator/ThemeDecorator.d.ts +7 -0
- package/ThemeDecorator/ThemeDecorator.js +24 -9
- package/TimePicker/TimePicker.module.css +3 -0
- package/TimePicker/TimePickerBase.js +5 -3
- package/TooltipDecorator/Tooltip.module.css +4 -0
- package/TooltipDecorator/TooltipDecorator.js +12 -7
- package/TooltipDecorator/tests/useTooltip-specs.js +5 -2
- package/VideoPlayer/Feedback.module.css +3 -0
- package/VideoPlayer/FeedbackTooltip.module.css +7 -0
- package/VideoPlayer/MediaTitle.module.css +8 -0
- package/VideoPlayer/VideoPlayer.js +25 -24
- package/VirtualList/VirtualList.js +20 -18
- package/VirtualList/useSpotlight.js +1 -1
- package/fonts/Limestone_Icons.ttf +0 -0
- package/internal/AsyncRenderChildren/AsyncRenderChildren.js +9 -5
- package/internal/AsyncRenderChildren/tests/AsyncRenderChildren-specs.js +4 -1
- package/internal/DateTime/DateTime.module.css +3 -0
- package/internal/DateTime/DateTimeDecorator.js +5 -4
- package/internal/Panels/PanelsRouter.js +35 -29
- package/internal/Panels/useAutoFocus.js +10 -6
- package/internal/Panels/useFocusOnTransition.js +4 -3
- package/internal/Picker/Picker.js +7 -5
- package/internal/Picker/Picker.module.css +22 -0
- package/internal/Picker/SpottablePicker.js +15 -13
- package/internal/SharedStateDecorator/SharedStateDecorator.js +6 -4
- package/package.json +15 -12
- package/styles/colors.less +1 -0
- package/styles/variables.less +118 -26
- package/useScroll/HoverToScroll.js +15 -12
- package/useScroll/Scrollbar.js +14 -10
- package/useScroll/ScrollbarPlaceholder.js +4 -1
- package/useScroll/ScrollbarTrack.js +7 -5
- package/useScroll/useEvent.js +7 -2
- package/useScroll/useScroll.js +10 -2
|
@@ -7,6 +7,7 @@ exports["default"] = exports.InputSpotlightDecorator = void 0;
|
|
|
7
7
|
var _handle = require("@enact/core/handle");
|
|
8
8
|
var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
|
|
9
9
|
var _keymap = require("@enact/core/keymap");
|
|
10
|
+
var _util = require("@enact/core/util");
|
|
10
11
|
var _spotlight = require("@enact/spotlight");
|
|
11
12
|
var _Pause = _interopRequireDefault(require("@enact/spotlight/Pause"));
|
|
12
13
|
var _Spottable = _interopRequireDefault(require("@enact/spotlight/Spottable"));
|
|
@@ -20,6 +21,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
20
21
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
23
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
25
|
+
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."); }
|
|
26
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
27
|
+
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; }
|
|
28
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
29
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
23
30
|
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
24
31
|
var isBubbling = function isBubbling(ev) {
|
|
25
32
|
return ev.currentTarget !== ev.target;
|
|
@@ -48,7 +55,7 @@ var defaultConfig = {
|
|
|
48
55
|
* @type {Boolean}
|
|
49
56
|
* @default false
|
|
50
57
|
* @memberof limestone/Input/InputSpotlightDecorator.InputSpotlightDecorator.defaultConfig
|
|
51
|
-
|
|
58
|
+
*/
|
|
52
59
|
noLockPointer: false
|
|
53
60
|
};
|
|
54
61
|
|
|
@@ -73,8 +80,11 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
73
80
|
var forwardKeyUp = (0, _handle.forward)('onKeyUp');
|
|
74
81
|
|
|
75
82
|
// eslint-disable-next-line no-shadow
|
|
76
|
-
var
|
|
83
|
+
var _InputSpotlightDecorator = function InputSpotlightDecorator(_ref) {
|
|
77
84
|
var props = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
85
|
+
(0, _util.checkPropTypes)(_InputSpotlightDecorator, props);
|
|
86
|
+
var _props$caretToEndOnFo = props.caretToEndOnFocus,
|
|
87
|
+
caretToEndOnFocus = _props$caretToEndOnFo === void 0 ? false : _props$caretToEndOnFo;
|
|
78
88
|
var downTarget = (0, _react.useRef)(null);
|
|
79
89
|
var focused = (0, _react.useRef)(null);
|
|
80
90
|
var node = (0, _react.useRef)(null);
|
|
@@ -86,6 +96,10 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
86
96
|
var paused = (0, _react.useMemo)(function () {
|
|
87
97
|
return new _Pause["default"]('InputSpotlightDecorator');
|
|
88
98
|
}, []);
|
|
99
|
+
var _useState = (0, _react.useState)(false),
|
|
100
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
101
|
+
active = _useState2[0],
|
|
102
|
+
setActive = _useState2[1];
|
|
89
103
|
var setDownTarget = (0, _react.useCallback)(function (ev) {
|
|
90
104
|
var repeat = ev.repeat,
|
|
91
105
|
target = ev.target;
|
|
@@ -93,6 +107,13 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
93
107
|
downTarget.current = target;
|
|
94
108
|
}
|
|
95
109
|
}, []);
|
|
110
|
+
var moveCaretToEnd = (0, _react.useCallback)(function (inputNode) {
|
|
111
|
+
if (caretToEndOnFocus && inputNode && SELECTABLE_TYPES.test(inputNode.type)) {
|
|
112
|
+
var length = inputNode.value.length;
|
|
113
|
+
inputNode.setSelectionRange(length, length);
|
|
114
|
+
inputNode.scrollLeft = inputNode.dir === 'rtl' ? 0 : inputNode.scrollWidth;
|
|
115
|
+
}
|
|
116
|
+
}, [caretToEndOnFocus]);
|
|
96
117
|
var updateFocus = (0, _react.useCallback)(function () {
|
|
97
118
|
// focus node if `InputSpotlightDecorator` is pausing Spotlight or if Spotlight is paused
|
|
98
119
|
if (node.current && _spotlight.Spotlight.getCurrent() !== node.current && (paused.isPaused() || !_spotlight.Spotlight.isPaused())) {
|
|
@@ -103,16 +124,29 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
103
124
|
} else {
|
|
104
125
|
node.current.focus();
|
|
105
126
|
}
|
|
127
|
+
|
|
128
|
+
// Move caret to end if caretToEndOnFocus is enabled and we're focusing an input
|
|
129
|
+
if (focused.current === 'input') {
|
|
130
|
+
if (fromMouse.current) {
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
moveCaretToEnd(node.current);
|
|
133
|
+
}, 0);
|
|
134
|
+
} else {
|
|
135
|
+
moveCaretToEnd(node.current);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
106
138
|
}
|
|
107
139
|
var focusChanged = focused.current !== prevStatus.current.focused;
|
|
108
140
|
if (focusChanged) {
|
|
109
141
|
if (focused.current === 'input') {
|
|
142
|
+
setActive(true);
|
|
110
143
|
(0, _handle.forwardCustom)('onActivate')(null, props);
|
|
111
144
|
if (!noLockPointer) {
|
|
112
145
|
(0, _pointer.lockPointer)(node.current);
|
|
113
146
|
}
|
|
114
147
|
paused.pause();
|
|
115
148
|
} else if (prevStatus.current.focused === 'input') {
|
|
149
|
+
setActive(false);
|
|
116
150
|
(0, _handle.forwardCustom)('onDeactivate')(null, props);
|
|
117
151
|
if (!noLockPointer) {
|
|
118
152
|
(0, _pointer.releasePointer)(prevStatus.current.node);
|
|
@@ -124,7 +158,7 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
124
158
|
focused: focused.current,
|
|
125
159
|
node: node.current
|
|
126
160
|
};
|
|
127
|
-
}, [paused, props]);
|
|
161
|
+
}, [moveCaretToEnd, paused, props]);
|
|
128
162
|
var blur = (0, _react.useCallback)(function () {
|
|
129
163
|
if (focused.current || node.current) {
|
|
130
164
|
focused.current = null;
|
|
@@ -251,8 +285,9 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
251
285
|
spotlightDisabled = props.spotlightDisabled;
|
|
252
286
|
setDownTarget(ev);
|
|
253
287
|
// focus the <input> whenever clicking on any part of the component to ensure both that
|
|
254
|
-
// the <input> has focus and Spotlight is paused.
|
|
255
|
-
|
|
288
|
+
// the <input> has focus and Spotlight is paused. Skip when the target is a decorative
|
|
289
|
+
// icon so it doesn't activate the input.
|
|
290
|
+
if (!disabled && !spotlightDisabled && !ev.target.closest('[data-input-icon]')) {
|
|
256
291
|
focusInput(ev.currentTarget, true);
|
|
257
292
|
}
|
|
258
293
|
forwardMouseDown(ev, props);
|
|
@@ -290,9 +325,11 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
290
325
|
}, [focusDecorator, focusInput, props]);
|
|
291
326
|
var componentProps = Object.assign({}, props);
|
|
292
327
|
delete componentProps.autoFocus;
|
|
328
|
+
delete componentProps.caretToEndOnFocus;
|
|
293
329
|
delete componentProps.onActivate;
|
|
294
330
|
delete componentProps.onDeactivate;
|
|
295
331
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
332
|
+
active: active,
|
|
296
333
|
onBlur: onBlur,
|
|
297
334
|
onFocus: onFocus,
|
|
298
335
|
onKeyDown: onKeyDown,
|
|
@@ -300,8 +337,8 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
300
337
|
onMouseDown: onMouseDown
|
|
301
338
|
}));
|
|
302
339
|
};
|
|
303
|
-
|
|
304
|
-
|
|
340
|
+
_InputSpotlightDecorator.displayName = 'InputSpotlightDecorator';
|
|
341
|
+
_InputSpotlightDecorator.propTypes = /** @lends limestone/Input/InputSpotlightDecorator.InputSpotlightDecorator.prototype */{
|
|
305
342
|
/**
|
|
306
343
|
* Focuses the <input> when the decorator is focused via 5-way.
|
|
307
344
|
*
|
|
@@ -310,6 +347,14 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
310
347
|
* @public
|
|
311
348
|
*/
|
|
312
349
|
autoFocus: _propTypes["default"].bool,
|
|
350
|
+
/**
|
|
351
|
+
* Moves the caret to the end of the text when the input receives focus.
|
|
352
|
+
*
|
|
353
|
+
* @type {Boolean}
|
|
354
|
+
* @default false
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
caretToEndOnFocus: _propTypes["default"].bool,
|
|
313
358
|
/**
|
|
314
359
|
* Applies a disabled style and the control becomes non-interactive.
|
|
315
360
|
*
|
|
@@ -359,6 +404,6 @@ var InputSpotlightDecorator = exports.InputSpotlightDecorator = (0, _hoc["defaul
|
|
|
359
404
|
*/
|
|
360
405
|
spotlightDisabled: _propTypes["default"].bool
|
|
361
406
|
};
|
|
362
|
-
return
|
|
407
|
+
return _InputSpotlightDecorator;
|
|
363
408
|
});
|
|
364
409
|
var _default = exports["default"] = InputSpotlightDecorator;
|
package/Input/index.d.ts
CHANGED
|
@@ -9,99 +9,6 @@ import { SpottableProps as spotlight_Spottable_SpottableProps } from "@enact/spo
|
|
|
9
9
|
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
10
10
|
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
11
11
|
|
|
12
|
-
export interface InputFieldBaseProps {
|
|
13
|
-
/**
|
|
14
|
-
* Passed by AnnounceDecorator for accessibility.
|
|
15
|
-
*/
|
|
16
|
-
announce?: Function;
|
|
17
|
-
/**
|
|
18
|
-
* Disables InputField and becomes non-interactive.
|
|
19
|
-
*/
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Blurs the input when the "enter" key is pressed.
|
|
23
|
-
*/
|
|
24
|
-
dismissOnEnter?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* The icon to be placed at the end of the input.
|
|
27
|
-
*/
|
|
28
|
-
iconAfter?: string;
|
|
29
|
-
/**
|
|
30
|
-
* The icon to be placed at the beginning of the input.
|
|
31
|
-
*/
|
|
32
|
-
iconBefore?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Indicates is invalid and shows
|
|
35
|
-
, if set.
|
|
36
|
-
*/
|
|
37
|
-
invalid?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* The tooltip text to be displayed when the input is
|
|
40
|
-
.
|
|
41
|
-
*
|
|
42
|
-
* If this value is _falsy_ , the tooltip will be shown with the default message.
|
|
43
|
-
*/
|
|
44
|
-
invalidMessage?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Called before the input value is changed.
|
|
47
|
-
*
|
|
48
|
-
* The change can be prevented by calling `preventDefault` on the event.
|
|
49
|
-
*/
|
|
50
|
-
onBeforeChange?: Function;
|
|
51
|
-
/**
|
|
52
|
-
* Called when blurred.
|
|
53
|
-
*/
|
|
54
|
-
onBlur?: Function;
|
|
55
|
-
/**
|
|
56
|
-
* Called when the input value is changed.
|
|
57
|
-
*
|
|
58
|
-
* The event payload includes the current `value` as well as a `stopPropagation()` method
|
|
59
|
-
which may be called to stop the original `onChange` event from the `<input>` from
|
|
60
|
-
bubbling.
|
|
61
|
-
*/
|
|
62
|
-
onChange?: Function;
|
|
63
|
-
/**
|
|
64
|
-
* Called when clicked.
|
|
65
|
-
*/
|
|
66
|
-
onClick?: Function;
|
|
67
|
-
/**
|
|
68
|
-
* Called when focused.
|
|
69
|
-
*/
|
|
70
|
-
onFocus?: Function;
|
|
71
|
-
/**
|
|
72
|
-
* Called when a key is pressed down.
|
|
73
|
-
*/
|
|
74
|
-
onKeyDown?: Function;
|
|
75
|
-
/**
|
|
76
|
-
* Text to display when is not set.
|
|
77
|
-
*/
|
|
78
|
-
placeholder?: string;
|
|
79
|
-
/**
|
|
80
|
-
* The size of the input field.
|
|
81
|
-
*/
|
|
82
|
-
size?: "large" | "small";
|
|
83
|
-
/**
|
|
84
|
-
* The type of input.
|
|
85
|
-
*
|
|
86
|
-
* Accepted values correspond to the standard HTML5 input types.
|
|
87
|
-
*/
|
|
88
|
-
type?: string;
|
|
89
|
-
/**
|
|
90
|
-
* The value of the input.
|
|
91
|
-
*/
|
|
92
|
-
value?: string | number;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* A Limestone styled input component.
|
|
96
|
-
*
|
|
97
|
-
* It supports start and end icons, but it does not support Spotlight. Apps should use
|
|
98
|
-
.
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
export class InputFieldBase extends React.Component<
|
|
102
|
-
Merge<React.HTMLProps<HTMLElement>, InputFieldBaseProps>
|
|
103
|
-
> {}
|
|
104
|
-
|
|
105
12
|
export interface InputPopupBaseProps {
|
|
106
13
|
/**
|
|
107
14
|
* Passed by AnnounceDecorator for accessibility.
|
|
@@ -158,6 +65,10 @@ and when `numberInputField` is `'auto'` .
|
|
|
158
65
|
* This value will override `minLength` and `maxLength` .
|
|
159
66
|
*/
|
|
160
67
|
length?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Wraps the `InputField` 's value display in a marquee.
|
|
70
|
+
*/
|
|
71
|
+
marqueeInputField?: boolean;
|
|
161
72
|
/**
|
|
162
73
|
* The maximum length of number input fields.
|
|
163
74
|
*
|
|
@@ -260,6 +171,107 @@ export class InputPopupBase extends React.Component<
|
|
|
260
171
|
Merge<React.HTMLProps<HTMLElement>, InputPopupBaseProps>
|
|
261
172
|
> {}
|
|
262
173
|
|
|
174
|
+
export interface InputFieldBaseProps {
|
|
175
|
+
/**
|
|
176
|
+
* Passed by AnnounceDecorator for accessibility.
|
|
177
|
+
*/
|
|
178
|
+
announce?: Function;
|
|
179
|
+
/**
|
|
180
|
+
* Moves the caret to the end of the text when the input receives focus.
|
|
181
|
+
*/
|
|
182
|
+
caretToEndOnFocus?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Disables InputField and becomes non-interactive.
|
|
185
|
+
*/
|
|
186
|
+
disabled?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Blurs the input when the "enter" key is pressed.
|
|
189
|
+
*/
|
|
190
|
+
dismissOnEnter?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* The icon to be placed at the end of the input.
|
|
193
|
+
*/
|
|
194
|
+
iconAfter?: string;
|
|
195
|
+
/**
|
|
196
|
+
* The icon to be placed at the beginning of the input.
|
|
197
|
+
*/
|
|
198
|
+
iconBefore?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Indicates is invalid and shows
|
|
201
|
+
, if set.
|
|
202
|
+
*/
|
|
203
|
+
invalid?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* The tooltip text to be displayed when the input is
|
|
206
|
+
.
|
|
207
|
+
*
|
|
208
|
+
* If this value is _falsy_ , the tooltip will be shown with the default message.
|
|
209
|
+
*/
|
|
210
|
+
invalidMessage?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Wraps the input's value/placeholder display in a marquee.
|
|
213
|
+
*/
|
|
214
|
+
marqueeContent?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Called before the input value is changed.
|
|
217
|
+
*
|
|
218
|
+
* The change can be prevented by calling `preventDefault` on the event.
|
|
219
|
+
*/
|
|
220
|
+
onBeforeChange?: Function;
|
|
221
|
+
/**
|
|
222
|
+
* Called when blurred.
|
|
223
|
+
*/
|
|
224
|
+
onBlur?: Function;
|
|
225
|
+
/**
|
|
226
|
+
* Called when the input value is changed.
|
|
227
|
+
*
|
|
228
|
+
* The event payload includes the current `value` as well as a `stopPropagation()` method
|
|
229
|
+
which may be called to stop the original `onChange` event from the `<input>` from
|
|
230
|
+
bubbling.
|
|
231
|
+
*/
|
|
232
|
+
onChange?: Function;
|
|
233
|
+
/**
|
|
234
|
+
* Called when clicked.
|
|
235
|
+
*/
|
|
236
|
+
onClick?: Function;
|
|
237
|
+
/**
|
|
238
|
+
* Called when focused.
|
|
239
|
+
*/
|
|
240
|
+
onFocus?: Function;
|
|
241
|
+
/**
|
|
242
|
+
* Called when a key is pressed down.
|
|
243
|
+
*/
|
|
244
|
+
onKeyDown?: Function;
|
|
245
|
+
/**
|
|
246
|
+
* Text to display when is not set.
|
|
247
|
+
*/
|
|
248
|
+
placeholder?: string;
|
|
249
|
+
/**
|
|
250
|
+
* The size of the input field.
|
|
251
|
+
*/
|
|
252
|
+
size?: "large" | "small";
|
|
253
|
+
/**
|
|
254
|
+
* The type of input.
|
|
255
|
+
*
|
|
256
|
+
* Accepted values correspond to the standard HTML5 input types.
|
|
257
|
+
*/
|
|
258
|
+
type?: string;
|
|
259
|
+
/**
|
|
260
|
+
* The value of the input.
|
|
261
|
+
*/
|
|
262
|
+
value?: string | number;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* A Limestone styled input component.
|
|
266
|
+
*
|
|
267
|
+
* It supports start and end icons, but it does not support Spotlight. Apps should use
|
|
268
|
+
.
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
export class InputFieldBase extends React.Component<
|
|
272
|
+
Merge<React.HTMLProps<HTMLElement>, InputFieldBaseProps>
|
|
273
|
+
> {}
|
|
274
|
+
|
|
263
275
|
export interface InputFieldDecoratorProps extends Merge<
|
|
264
276
|
ui_Changeable_ChangeableProps,
|
|
265
277
|
limestone_Skinnable_SkinnableProps
|
|
@@ -534,4 +534,30 @@ describe('Input specs', function () {
|
|
|
534
534
|
expect(buttonSubmit).toBeNull();
|
|
535
535
|
});
|
|
536
536
|
});
|
|
537
|
+
describe('marqueeInputField', function () {
|
|
538
|
+
test('should not render a marquee node in the InputField by default', function () {
|
|
539
|
+
var _render = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
|
|
540
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input["default"], {
|
|
541
|
+
open: true,
|
|
542
|
+
value: "hello"
|
|
543
|
+
})
|
|
544
|
+
})),
|
|
545
|
+
baseElement = _render.baseElement;
|
|
546
|
+
var marqueeText = baseElement.querySelector('.marqueeText');
|
|
547
|
+
expect(marqueeText).toBeNull();
|
|
548
|
+
});
|
|
549
|
+
test('should render a marquee node in the InputField when marqueeInputField is true', function () {
|
|
550
|
+
var _render2 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(FloatingLayerController, {
|
|
551
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input["default"], {
|
|
552
|
+
open: true,
|
|
553
|
+
marqueeInputField: true,
|
|
554
|
+
value: "hello"
|
|
555
|
+
})
|
|
556
|
+
})),
|
|
557
|
+
baseElement = _render2.baseElement;
|
|
558
|
+
var marqueeText = baseElement.querySelector('.marqueeText');
|
|
559
|
+
expect(marqueeText).not.toBeNull();
|
|
560
|
+
expect(marqueeText.querySelector('.marquee')).not.toBeNull();
|
|
561
|
+
});
|
|
562
|
+
});
|
|
537
563
|
});
|
|
@@ -25,7 +25,7 @@ describe('InputField Specs', function () {
|
|
|
25
25
|
var inputField = _react.screen.getByLabelText('hello Input field');
|
|
26
26
|
var expected = 'hello';
|
|
27
27
|
var actual = inputField.textContent;
|
|
28
|
-
expect(actual).
|
|
28
|
+
expect(actual).toContain(expected);
|
|
29
29
|
});
|
|
30
30
|
test('should callback onChange with `onChange` type when the text changes', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
31
31
|
var handleChange = jest.fn();
|
|
@@ -175,13 +175,13 @@ describe('InputField Specs', function () {
|
|
|
175
175
|
var inputField = _react.screen.getByLabelText('hello Input field');
|
|
176
176
|
var actual = inputField.textContent;
|
|
177
177
|
var expected = 'hello';
|
|
178
|
-
expect(actual).
|
|
178
|
+
expect(actual).toContain(expected);
|
|
179
179
|
});
|
|
180
180
|
test('should have dir equal to rtl when there is rtl text', function () {
|
|
181
181
|
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
182
182
|
value: "\u05E9\u05D5\u05E2\u05DC \u05D4\u05D7\u05D5\u05DD \u05D4\u05D6\u05E8\u05D9\u05D6 \u05E7\u05E4\u05E5 \u05DE\u05E2\u05DC \u05D4\u05DB\u05DC\u05D1 \u05D4\u05E2\u05E6\u05DC\u05DF.\u05E6\u05D9\u05E4\u05D5\u05E8 \u05E2\u05E4\u05D4 \u05D4\u05E9\u05E2\u05D5\u05E2\u05D9\u05EA \u05E2\u05DD \u05E9\u05E7\u05D9"
|
|
183
183
|
}));
|
|
184
|
-
var inputField = _react.screen.
|
|
184
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
185
185
|
var expectedAttribute = 'dir';
|
|
186
186
|
var expectedValue = 'rtl';
|
|
187
187
|
expect(inputField).toHaveAttribute(expectedAttribute, expectedValue);
|
|
@@ -310,4 +310,150 @@ describe('InputField Specs', function () {
|
|
|
310
310
|
expect(key).toBe('ArrowLeft');
|
|
311
311
|
expect(actual).toMatchObject(expected);
|
|
312
312
|
}));
|
|
313
|
+
describe('marqueeContent', function () {
|
|
314
|
+
test('should not render a marquee node by default', function () {
|
|
315
|
+
var _render2 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
316
|
+
value: "hello"
|
|
317
|
+
})),
|
|
318
|
+
baseElement = _render2.baseElement;
|
|
319
|
+
var marqueeText = baseElement.querySelector('.marqueeText');
|
|
320
|
+
expect(marqueeText).toBeNull();
|
|
321
|
+
});
|
|
322
|
+
test('should render a marquee node when marqueeContent is true', function () {
|
|
323
|
+
var _render3 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
324
|
+
marqueeContent: true,
|
|
325
|
+
value: "hello"
|
|
326
|
+
})),
|
|
327
|
+
baseElement = _render3.baseElement;
|
|
328
|
+
var marqueeText = baseElement.querySelector('.marqueeText');
|
|
329
|
+
expect(marqueeText).not.toBeNull();
|
|
330
|
+
expect(marqueeText.querySelector('.marquee')).not.toBeNull();
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
describe('moveCaretToEnd', function () {
|
|
334
|
+
test('should move caret to end of value on mouse focus when caretToEndOnFocus is true', function () {
|
|
335
|
+
jest.useFakeTimers();
|
|
336
|
+
var value = 'hello';
|
|
337
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
338
|
+
caretToEndOnFocus: true,
|
|
339
|
+
value: value
|
|
340
|
+
}));
|
|
341
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
342
|
+
var setSelectionRange = jest.spyOn(inputField, 'setSelectionRange');
|
|
343
|
+
_react.fireEvent.mouseDown(inputField);
|
|
344
|
+
(0, _react.act)(function () {
|
|
345
|
+
return jest.runOnlyPendingTimers();
|
|
346
|
+
});
|
|
347
|
+
expect(setSelectionRange).toHaveBeenCalledWith(value.length, value.length);
|
|
348
|
+
jest.useRealTimers();
|
|
349
|
+
});
|
|
350
|
+
test('should set scrollLeft to scrollWidth for LTR input when caretToEndOnFocus is true', function () {
|
|
351
|
+
jest.useFakeTimers();
|
|
352
|
+
var value = 'hello';
|
|
353
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
354
|
+
caretToEndOnFocus: true,
|
|
355
|
+
value: value
|
|
356
|
+
}));
|
|
357
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
358
|
+
var scrollLeft = 0;
|
|
359
|
+
Object.defineProperty(inputField, 'scrollLeft', {
|
|
360
|
+
get: function get() {
|
|
361
|
+
return scrollLeft;
|
|
362
|
+
},
|
|
363
|
+
set: function set(v) {
|
|
364
|
+
scrollLeft = v;
|
|
365
|
+
},
|
|
366
|
+
configurable: true
|
|
367
|
+
});
|
|
368
|
+
Object.defineProperty(inputField, 'scrollWidth', {
|
|
369
|
+
get: function get() {
|
|
370
|
+
return 200;
|
|
371
|
+
},
|
|
372
|
+
configurable: true
|
|
373
|
+
});
|
|
374
|
+
_react.fireEvent.mouseDown(inputField);
|
|
375
|
+
(0, _react.act)(function () {
|
|
376
|
+
return jest.runOnlyPendingTimers();
|
|
377
|
+
});
|
|
378
|
+
expect(scrollLeft).toBe(200);
|
|
379
|
+
jest.useRealTimers();
|
|
380
|
+
});
|
|
381
|
+
test('should set scrollLeft to 0 for RTL input when caretToEndOnFocus is true', function () {
|
|
382
|
+
jest.useFakeTimers();
|
|
383
|
+
var rtlValue = 'שועל החום הזריז';
|
|
384
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
385
|
+
caretToEndOnFocus: true,
|
|
386
|
+
value: rtlValue
|
|
387
|
+
}));
|
|
388
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
389
|
+
var scrollLeft = 999;
|
|
390
|
+
Object.defineProperty(inputField, 'scrollLeft', {
|
|
391
|
+
get: function get() {
|
|
392
|
+
return scrollLeft;
|
|
393
|
+
},
|
|
394
|
+
set: function set(v) {
|
|
395
|
+
scrollLeft = v;
|
|
396
|
+
},
|
|
397
|
+
configurable: true
|
|
398
|
+
});
|
|
399
|
+
Object.defineProperty(inputField, 'scrollWidth', {
|
|
400
|
+
get: function get() {
|
|
401
|
+
return 200;
|
|
402
|
+
},
|
|
403
|
+
configurable: true
|
|
404
|
+
});
|
|
405
|
+
_react.fireEvent.mouseDown(inputField);
|
|
406
|
+
(0, _react.act)(function () {
|
|
407
|
+
return jest.runOnlyPendingTimers();
|
|
408
|
+
});
|
|
409
|
+
expect(scrollLeft).toBe(0);
|
|
410
|
+
jest.useRealTimers();
|
|
411
|
+
});
|
|
412
|
+
test('should not move caret when caretToEndOnFocus is not set', function () {
|
|
413
|
+
jest.useFakeTimers();
|
|
414
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
415
|
+
value: "hello"
|
|
416
|
+
}));
|
|
417
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
418
|
+
var setSelectionRange = jest.spyOn(inputField, 'setSelectionRange');
|
|
419
|
+
_react.fireEvent.mouseDown(inputField);
|
|
420
|
+
(0, _react.act)(function () {
|
|
421
|
+
return jest.runOnlyPendingTimers();
|
|
422
|
+
});
|
|
423
|
+
expect(setSelectionRange).not.toHaveBeenCalled();
|
|
424
|
+
jest.useRealTimers();
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
describe('decorator icons', function () {
|
|
428
|
+
test('should render iconBefore and iconAfter with data-input-icon attribute', function () {
|
|
429
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
430
|
+
iconBefore: "plus",
|
|
431
|
+
iconAfter: "minus"
|
|
432
|
+
}));
|
|
433
|
+
var icons = document.querySelectorAll('[data-input-icon]');
|
|
434
|
+
expect(icons).toHaveLength(2);
|
|
435
|
+
});
|
|
436
|
+
test('should not activate the input when iconBefore is clicked', function () {
|
|
437
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
438
|
+
iconBefore: "plus",
|
|
439
|
+
value: "hello"
|
|
440
|
+
}));
|
|
441
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
442
|
+
var icon = document.querySelector('[data-input-icon]');
|
|
443
|
+
var focusSpy = jest.spyOn(inputField, 'focus');
|
|
444
|
+
_react.fireEvent.mouseDown(icon);
|
|
445
|
+
expect(focusSpy).not.toHaveBeenCalled();
|
|
446
|
+
});
|
|
447
|
+
test('should not activate the input when iconAfter is clicked', function () {
|
|
448
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_.InputField, {
|
|
449
|
+
iconAfter: "minus",
|
|
450
|
+
value: "hello"
|
|
451
|
+
}));
|
|
452
|
+
var inputField = _react.screen.getByPlaceholderText('');
|
|
453
|
+
var icon = document.querySelector('[data-input-icon]');
|
|
454
|
+
var focusSpy = jest.spyOn(inputField, 'focus');
|
|
455
|
+
_react.fireEvent.mouseDown(icon);
|
|
456
|
+
expect(focusSpy).not.toHaveBeenCalled();
|
|
457
|
+
});
|
|
458
|
+
});
|
|
313
459
|
});
|
|
@@ -47,7 +47,7 @@ describe('InputPopup Specs', function () {
|
|
|
47
47
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.InputPopup, {
|
|
48
48
|
defaultValue: strDefaultValue,
|
|
49
49
|
open: true,
|
|
50
|
-
value: strValue
|
|
50
|
+
value: strValue || strDefaultValue
|
|
51
51
|
})
|
|
52
52
|
}));
|
|
53
53
|
var actual = _react.screen.getByDisplayValue(strValue);
|
package/Item/Item.module.css
CHANGED
|
@@ -120,7 +120,8 @@
|
|
|
120
120
|
line-height: 1.5em;
|
|
121
121
|
}
|
|
122
122
|
.item:global(.largeText) .label {
|
|
123
|
-
font-size: var(--primitive-font-size-
|
|
123
|
+
font-size: var(--primitive-font-size-58);
|
|
124
|
+
line-height: 1.2em;
|
|
124
125
|
}
|
|
125
126
|
.item.large {
|
|
126
127
|
/* Needed to prevent global class being added in the DOM */
|