@enact/ui 4.5.2 → 4.5.4
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.js +6 -26
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.js +26 -56
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +10 -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.js +17 -50
- package/Group/Group.js +4 -35
- package/Group/GroupItem.js +15 -32
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +7 -35
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.js +14 -48
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.js +12 -50
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +16 -45
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +17 -46
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +8 -32
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.js +19 -50
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +11 -37
- package/Layout/Layout.js +14 -37
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +62 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +258 -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 +0 -4
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +13 -44
- 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 +7 -35
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +8 -44
- package/Routable/Routable.js +10 -33
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +13 -56
- 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 +179 -386
- package/Scrollable/ScrollableNative.js +188 -391
- package/Scrollable/Scrollbar.js +28 -100
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- 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.js +26 -64
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.js +15 -41
- 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.js +15 -42
- 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.js +15 -52
- 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 +31 -106
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.js +19 -83
- 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 +256 -406
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +270 -428
- package/VirtualList/tests/VirtualList-specs.js +9 -37
- 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 +7 -22
- 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 +8 -2
- 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 +325 -502
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
|
@@ -1,80 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
4
|
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."); }
|
|
6
|
-
|
|
7
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
6
|
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; }
|
|
10
|
-
|
|
11
7
|
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; }
|
|
12
|
-
|
|
13
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
9
|
var fontMap = {};
|
|
16
|
-
var currentLocale = null;
|
|
10
|
+
var currentLocale = null;
|
|
17
11
|
|
|
12
|
+
// Generate a single font-face rule
|
|
18
13
|
var buildFont = function buildFont(config) {
|
|
19
14
|
if (!config && !config.name) {
|
|
20
15
|
return '';
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
var strOut = '@font-face { \n' + " font-family: \"".concat(config.name, "\";\n");
|
|
24
|
-
|
|
25
18
|
if (config.weight) {
|
|
26
19
|
strOut += " font-weight: ".concat(config.weight, ";\n");
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
if (config.localName) {
|
|
30
22
|
// Accept a string or an array. If it's a string convert it into an array
|
|
31
23
|
if (typeof config.localName === 'string') {
|
|
32
24
|
config.localName = [config.localName];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
}
|
|
26
|
+
// Take our array and update each of its elements to be CSS "local()" strings
|
|
36
27
|
config.localName = config.localName.map(function (f) {
|
|
37
28
|
return "local(\"".concat(f, "\")");
|
|
38
|
-
});
|
|
39
|
-
|
|
29
|
+
});
|
|
30
|
+
// Join all our strings together with a comma, so it's a valid CSS `src` rule
|
|
40
31
|
strOut += " src: ".concat(config.localName.join(', '), ";\n");
|
|
41
32
|
}
|
|
42
|
-
|
|
43
33
|
if (config.unicodeRange) {
|
|
44
34
|
strOut += " unicode-range: ".concat(config.unicodeRange, ";\n");
|
|
45
35
|
}
|
|
46
|
-
|
|
47
36
|
strOut += '} \n';
|
|
48
37
|
return strOut;
|
|
49
|
-
};
|
|
50
|
-
|
|
38
|
+
};
|
|
51
39
|
|
|
40
|
+
// Generate a collection of font-face rules, in multiple font-variants
|
|
52
41
|
var buildFontSet = function buildFontSet(fontName, fonts, strLang, bitDefault) {
|
|
53
42
|
var strOut = '',
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
name = bitDefault ? fontName : fontName + ' ' + strLang;
|
|
56
44
|
if (fonts[strLang].regular) {
|
|
57
45
|
// Build Regular
|
|
58
46
|
strOut += buildFont({
|
|
59
47
|
name: name,
|
|
60
48
|
localName: fonts[strLang].regular,
|
|
61
49
|
unicodeRange: fonts[strLang].unicodeRange
|
|
62
|
-
});
|
|
50
|
+
});
|
|
63
51
|
|
|
52
|
+
// Build Light
|
|
64
53
|
strOut += buildFont({
|
|
65
54
|
name: name,
|
|
66
55
|
localName: fonts[strLang].light || fonts[strLang].regular,
|
|
67
56
|
weight: 300,
|
|
68
57
|
unicodeRange: fonts[strLang].unicodeRange
|
|
69
|
-
});
|
|
58
|
+
});
|
|
70
59
|
|
|
60
|
+
// Build SemiBold
|
|
71
61
|
strOut += buildFont({
|
|
72
62
|
name: name,
|
|
73
63
|
localName: fonts[strLang].semibold || fonts[strLang].bold || fonts[strLang].regular,
|
|
74
64
|
weight: 600,
|
|
75
65
|
unicodeRange: fonts[strLang].unicodeRange
|
|
76
|
-
});
|
|
66
|
+
});
|
|
77
67
|
|
|
68
|
+
// Build Bold
|
|
78
69
|
strOut += buildFont({
|
|
79
70
|
name: name,
|
|
80
71
|
localName: fonts[strLang].bold || fonts[strLang].regular,
|
|
@@ -82,22 +73,20 @@ var buildFontSet = function buildFontSet(fontName, fonts, strLang, bitDefault) {
|
|
|
82
73
|
unicodeRange: fonts[strLang].unicodeRange
|
|
83
74
|
});
|
|
84
75
|
}
|
|
85
|
-
|
|
86
76
|
return strOut;
|
|
87
77
|
};
|
|
88
|
-
|
|
89
78
|
var buildFontDefinitionCss = function buildFontDefinitionCss(locale, buildOverrides) {
|
|
90
79
|
var matchLang = locale.match(/\b([a-z]{2})\b/),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var fontDefinitionCss = '';
|
|
97
|
-
|
|
80
|
+
language = matchLang && matchLang[1],
|
|
81
|
+
matchScript = locale.match(/\b([a-z]{4})\b/i),
|
|
82
|
+
script = matchScript && matchScript[1],
|
|
83
|
+
matchReg = locale.match(/\b([A-Z]{2}|[0-9]{3})\b/),
|
|
84
|
+
region = matchReg && matchReg[1];
|
|
85
|
+
var fontDefinitionCss = '';
|
|
86
|
+
|
|
87
|
+
// Build all the fonts so they could be explicitly called
|
|
98
88
|
for (var fontName in fontMap) {
|
|
99
89
|
var fonts = fontMap[fontName];
|
|
100
|
-
|
|
101
90
|
for (var lang in fonts) {
|
|
102
91
|
if (!buildOverrides) {
|
|
103
92
|
fontDefinitionCss += buildFontSet(fontName, fonts, lang);
|
|
@@ -105,63 +94,55 @@ var buildFontDefinitionCss = function buildFontDefinitionCss(locale, buildOverri
|
|
|
105
94
|
// Set up the override for locale-specific font.
|
|
106
95
|
// la = language, sc = script, re = region; `la-RE` or `zh-Hans-HK`
|
|
107
96
|
var _lang$split = lang.split('-'),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
_lang$split2 = _slicedToArray(_lang$split, 3),
|
|
98
|
+
la = _lang$split2[0],
|
|
99
|
+
sc = _lang$split2[1],
|
|
100
|
+
re = _lang$split2[2];
|
|
113
101
|
|
|
102
|
+
// if script is not specified, fall back to second part representing region
|
|
114
103
|
if (!re && sc && sc.length === 2) {
|
|
115
104
|
re = sc;
|
|
116
105
|
sc = null;
|
|
117
106
|
}
|
|
118
|
-
|
|
119
107
|
var matchesRegion = re ? re === region : true;
|
|
120
108
|
var matchesScript = sc ? sc === script : true;
|
|
121
|
-
|
|
122
109
|
if (la === language && matchesRegion && matchesScript) {
|
|
123
110
|
fontDefinitionCss += buildFontSet(fontName, fonts, lang, true);
|
|
124
111
|
}
|
|
125
112
|
}
|
|
126
113
|
}
|
|
127
114
|
}
|
|
128
|
-
|
|
129
115
|
return fontDefinitionCss;
|
|
130
116
|
};
|
|
131
|
-
|
|
132
117
|
var insertFontDefinitionCss = function insertFontDefinitionCss(styleId, fontDefinitionCss) {
|
|
133
118
|
if (typeof document !== 'undefined') {
|
|
134
119
|
// Normal execution in a browser window
|
|
135
120
|
var styleElem = document.getElementById(styleId);
|
|
136
|
-
|
|
137
121
|
if (!styleElem) {
|
|
138
122
|
styleElem = document.createElement('style');
|
|
139
123
|
styleElem.setAttribute('id', styleId);
|
|
140
124
|
styleElem.setAttribute('type', 'text/css');
|
|
141
125
|
document.head.appendChild(styleElem);
|
|
142
126
|
}
|
|
143
|
-
|
|
144
127
|
styleElem.innerHTML = fontDefinitionCss;
|
|
145
128
|
} else {
|
|
146
|
-
var tag = "<style type=\"text/css\" id=\"".concat(styleId, "\">").concat(fontDefinitionCss, "</style>");
|
|
129
|
+
var tag = "<style type=\"text/css\" id=\"".concat(styleId, "\">").concat(fontDefinitionCss, "</style>");
|
|
147
130
|
|
|
131
|
+
// We're rendering without the DOM; return the font definition stylesheet element string.
|
|
148
132
|
return tag;
|
|
149
133
|
}
|
|
150
134
|
};
|
|
151
|
-
|
|
152
135
|
function fontGenerator(locale) {
|
|
153
136
|
var styleId = 'localized-fonts';
|
|
154
|
-
|
|
155
137
|
if (typeof document !== 'undefined' && document.getElementById(styleId)) {
|
|
156
138
|
return;
|
|
157
139
|
}
|
|
158
|
-
|
|
159
140
|
return insertFontDefinitionCss(styleId, buildFontDefinitionCss(locale));
|
|
160
141
|
}
|
|
161
|
-
|
|
162
142
|
function fontOverrideGenerator(locale) {
|
|
163
143
|
return insertFontDefinitionCss('localized-fonts-override', buildFontDefinitionCss(locale, true));
|
|
164
144
|
}
|
|
145
|
+
|
|
165
146
|
/**
|
|
166
147
|
* Generates locale-specific font rules allowing any locale to have its own custom font. Each
|
|
167
148
|
* locale-font from the configuration block (defined in this file) is generated at run-time. If the
|
|
@@ -201,24 +182,20 @@ function fontOverrideGenerator(locale) {
|
|
|
201
182
|
*
|
|
202
183
|
* @public
|
|
203
184
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
185
|
function generateFontRules(locale) {
|
|
207
186
|
if (!locale || locale === currentLocale) {
|
|
208
187
|
return;
|
|
209
188
|
}
|
|
210
|
-
|
|
211
189
|
currentLocale = locale;
|
|
212
190
|
return fontGenerator(locale);
|
|
213
191
|
}
|
|
214
|
-
|
|
215
192
|
function generateFontOverrideRules(locale) {
|
|
216
193
|
if (!locale) {
|
|
217
194
|
return;
|
|
218
195
|
}
|
|
219
|
-
|
|
220
196
|
return fontOverrideGenerator(locale);
|
|
221
197
|
}
|
|
198
|
+
|
|
222
199
|
/**
|
|
223
200
|
* Adds a localed font to the font map
|
|
224
201
|
*
|
|
@@ -239,15 +216,13 @@ function generateFontOverrideRules(locale) {
|
|
|
239
216
|
*
|
|
240
217
|
* @public
|
|
241
218
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
219
|
function addLocalizedFont(name, fonts) {
|
|
245
220
|
fontMap[name] = fonts;
|
|
246
|
-
|
|
247
221
|
if (currentLocale) {
|
|
248
222
|
fontGenerator(currentLocale);
|
|
249
223
|
}
|
|
250
224
|
}
|
|
225
|
+
|
|
251
226
|
/**
|
|
252
227
|
* Removes a localized font from the font map
|
|
253
228
|
*
|
|
@@ -255,16 +230,12 @@ function addLocalizedFont(name, fonts) {
|
|
|
255
230
|
*
|
|
256
231
|
* @public
|
|
257
232
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
233
|
function removeLocalizedFont(name) {
|
|
261
234
|
delete fontMap[name];
|
|
262
|
-
|
|
263
235
|
if (currentLocale) {
|
|
264
236
|
fontGenerator(currentLocale);
|
|
265
237
|
}
|
|
266
238
|
}
|
|
267
|
-
|
|
268
239
|
module.exports = generateFontRules;
|
|
269
240
|
module.exports.generateFontRules = generateFontRules;
|
|
270
241
|
module.exports.generateFontOverrideRules = generateFontOverrideRules;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
var _localizedFonts = require("../localized-fonts");
|
|
5
|
+
describe('localized-fonts', function () {
|
|
6
|
+
beforeEach(function () {
|
|
7
|
+
var fontName = 'Enact';
|
|
8
|
+
var fonts = {
|
|
9
|
+
'ja': {
|
|
10
|
+
regular: 'LG Smart UI JP'
|
|
11
|
+
},
|
|
12
|
+
'ur': {
|
|
13
|
+
regular: ['LG Smart UI Urdu', 'LGSmartUIUrdu'] // This needs 2 references because the "full name" differs from the "family name". To target this font file directly in all OSs we must also include the "postscript name" in addition to the "full name".
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
(0, _localizedFonts.addLocalizedFont)(fontName, fonts);
|
|
18
|
+
});
|
|
19
|
+
test('should add \'ja\' font rules when calling generateFontRules', function () {
|
|
20
|
+
(0, _localizedFonts.generateFontRules)('ja');
|
|
21
|
+
var innerHTMLString = document.head.innerHTML.toString();
|
|
22
|
+
var expected1 = innerHTMLString.includes("id=\"localized-fonts\"");
|
|
23
|
+
var expected2 = innerHTMLString.includes('Enact ja');
|
|
24
|
+
expect(expected1).toBeTruthy();
|
|
25
|
+
expect(expected2).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
test('should add \'localized-fonts-override\' styles when calling generateFontOverrideRules', function () {
|
|
28
|
+
(0, _localizedFonts.generateFontOverrideRules)('ur');
|
|
29
|
+
var innerHTMLString = document.head.innerHTML.toString();
|
|
30
|
+
var expected = innerHTMLString.includes("id=\"localized-fonts-override\"");
|
|
31
|
+
expect(expected).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.select = exports.isSelected = void 0;
|
|
7
|
-
|
|
8
7
|
var _curry = _interopRequireDefault(require("ramda/src/curry"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Determines if `item` is selected
|
|
14
11
|
*
|
|
@@ -21,6 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
21
18
|
var isSelected = (0, _curry["default"])(function (item, selected) {
|
|
22
19
|
return item === selected || Array.isArray(selected) && selected.indexOf(item) >= 0;
|
|
23
20
|
});
|
|
21
|
+
|
|
24
22
|
/**
|
|
25
23
|
* Selects or deselects an `item` based on the `mode` and returns a copy of `selected` with the new
|
|
26
24
|
* selected state.
|
|
@@ -37,7 +35,6 @@ var isSelected = (0, _curry["default"])(function (item, selected) {
|
|
|
37
35
|
* @returns {*|Array} The updated selection
|
|
38
36
|
* @private
|
|
39
37
|
*/
|
|
40
|
-
|
|
41
38
|
exports.isSelected = isSelected;
|
|
42
39
|
var select = (0, _curry["default"])(function (mode, item, selected) {
|
|
43
40
|
if (mode === 'radio') {
|
|
@@ -55,7 +52,6 @@ var select = (0, _curry["default"])(function (mode, item, selected) {
|
|
|
55
52
|
// already selected or select it if not.
|
|
56
53
|
var updated = Array.isArray(selected) ? selected.slice() : [selected];
|
|
57
54
|
var index = updated.indexOf(item);
|
|
58
|
-
|
|
59
55
|
if (index >= 0) {
|
|
60
56
|
if (updated.length === 1) {
|
|
61
57
|
// item should be deselected and is the only item in the array so return null
|
|
@@ -71,7 +67,6 @@ var select = (0, _curry["default"])(function (mode, item, selected) {
|
|
|
71
67
|
return a - b;
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
|
-
|
|
75
70
|
return updated;
|
|
76
71
|
}
|
|
77
72
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _selection = require("../selection");
|
|
4
|
-
|
|
5
4
|
describe('selection', function () {
|
|
6
5
|
// isSelected
|
|
7
6
|
test('should return true when item strictly equals selection', function () {
|
|
@@ -23,8 +22,9 @@ describe('selection', function () {
|
|
|
23
22
|
var expected = false;
|
|
24
23
|
var actual = (0, _selection.isSelected)(1, [2]);
|
|
25
24
|
expect(actual).toBe(expected);
|
|
26
|
-
});
|
|
25
|
+
});
|
|
27
26
|
|
|
27
|
+
// Single mode
|
|
28
28
|
test('should select item when there is no selection in "single" mode', function () {
|
|
29
29
|
var item = 0;
|
|
30
30
|
var selection = null;
|
|
@@ -64,8 +64,9 @@ describe('selection', function () {
|
|
|
64
64
|
var expected = null;
|
|
65
65
|
var actual = (0, _selection.select)(mode, item, selection);
|
|
66
66
|
expect(actual).toBe(expected);
|
|
67
|
-
});
|
|
67
|
+
});
|
|
68
68
|
|
|
69
|
+
// Radio Mode
|
|
69
70
|
test('should select item when there is no selection in "radio" mode', function () {
|
|
70
71
|
var item = 0;
|
|
71
72
|
var selection = null;
|
|
@@ -105,8 +106,9 @@ describe('selection', function () {
|
|
|
105
106
|
var expected = item;
|
|
106
107
|
var actual = (0, _selection.select)(mode, item, selection);
|
|
107
108
|
expect(actual).toBe(expected);
|
|
108
|
-
});
|
|
109
|
+
});
|
|
109
110
|
|
|
111
|
+
// Multiple mode
|
|
110
112
|
test('should select item when there is no selection in "multiple" mode', function () {
|
|
111
113
|
var item = 0;
|
|
112
114
|
var selection = null;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _validators = require("../validators");
|
|
4
|
+
describe('validators', function () {
|
|
5
|
+
describe('warn', function () {
|
|
6
|
+
test('should throw a console warning', function () {
|
|
7
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
8
|
+
(0, _validators.warn)('Warning!');
|
|
9
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
describe('validateRange', function () {
|
|
13
|
+
test('should throw a console warning when \'value\' is less than \'min\'', function () {
|
|
14
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
15
|
+
(0, _validators.validateRange)(10, 11, 20, 'component', 'value', 'min', 'max');
|
|
16
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
17
|
+
});
|
|
18
|
+
test('should throw a console warning when \'value\' is greater than \'max\'', function () {
|
|
19
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
20
|
+
(0, _validators.validateRange)(21, 1, 20, 'component', 'value', 'min', 'max');
|
|
21
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
22
|
+
});
|
|
23
|
+
test('should throw a console warning when \'min\' is greater than \'max\'', function () {
|
|
24
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
25
|
+
(0, _validators.validateRange)(10, 21, 20, 'component', 'value', 'min', 'max');
|
|
26
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('validateStepped', function () {
|
|
30
|
+
test('should throw a console warning when \'value\' is not evenly divisible by \'step\'', function () {
|
|
31
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
32
|
+
(0, _validators.validateStepped)(11, 20, 2, 'component', 'value', 'step');
|
|
33
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('validateRangeOnce', function () {
|
|
37
|
+
var thingSpy;
|
|
38
|
+
beforeEach(function () {
|
|
39
|
+
thingSpy = jest.fn().mockReturnValue('ANY_THING_SPY_VALUE');
|
|
40
|
+
});
|
|
41
|
+
test('should throw a console warning when \'value\' is lower than \'min\'', function () {
|
|
42
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
43
|
+
var validateFn = (0, _validators.validateRangeOnce)(thingSpy, {
|
|
44
|
+
component: 'ANY_COMPONENT'
|
|
45
|
+
});
|
|
46
|
+
var normalizedValues = validateFn({
|
|
47
|
+
value: 1,
|
|
48
|
+
min: 2,
|
|
49
|
+
max: 10
|
|
50
|
+
});
|
|
51
|
+
var expected = 'Warning: ANY_COMPONENT value (1) less than min (2)';
|
|
52
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
53
|
+
expect(thingSpy).toHaveBeenCalled();
|
|
54
|
+
expect(consoleSpy.mock.calls[0][0]).toBe(expected);
|
|
55
|
+
expect(normalizedValues).toBe('ANY_THING_SPY_VALUE');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('validateSteppedOnce', function () {
|
|
59
|
+
var thingSpy;
|
|
60
|
+
beforeEach(function () {
|
|
61
|
+
thingSpy = jest.fn().mockReturnValue('ANY_THING_SPY_VALUE');
|
|
62
|
+
});
|
|
63
|
+
test('should throw a console warning when \'value\' is not evenly divisible by \'step\'', function () {
|
|
64
|
+
var consoleSpy = jest.spyOn(console, 'warn').mockImplementation(function () {});
|
|
65
|
+
var validateFn = (0, _validators.validateSteppedOnce)(thingSpy, {
|
|
66
|
+
component: 'ANY_COMPONENT'
|
|
67
|
+
});
|
|
68
|
+
var normalizedValues = validateFn({
|
|
69
|
+
value: 11,
|
|
70
|
+
min: 2,
|
|
71
|
+
step: 2
|
|
72
|
+
});
|
|
73
|
+
var expected = 'Warning: ANY_COMPONENT value (11) must be evenly divisible by step (2)';
|
|
74
|
+
expect(consoleSpy).toHaveBeenCalled();
|
|
75
|
+
expect(thingSpy).toHaveBeenCalled();
|
|
76
|
+
expect(consoleSpy.mock.calls[0][0]).toBe(expected);
|
|
77
|
+
expect(normalizedValues).toBe('ANY_THING_SPY_VALUE');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.warn = exports.validateSteppedOnce = exports.validateStepped = exports.validateRangeOnce = exports.validateRange = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Exports various utilities for performing dev-time validations
|
|
10
9
|
*
|
|
@@ -29,6 +28,7 @@ var warn = function warn(msg) {
|
|
|
29
28
|
console.warn(msg); // eslint-disable-line no-console
|
|
30
29
|
}
|
|
31
30
|
};
|
|
31
|
+
|
|
32
32
|
/**
|
|
33
33
|
* Issues a warning to the console if `value` is not within the range
|
|
34
34
|
* `min` to `max` or if `min` is less than `max`. In production mode,
|
|
@@ -47,18 +47,13 @@ var warn = function warn(msg) {
|
|
|
47
47
|
* @memberof ui/internal/validators
|
|
48
48
|
* @private
|
|
49
49
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
50
|
exports.warn = warn;
|
|
53
|
-
|
|
54
51
|
var validateRange = function validateRange(value, min, max, component) {
|
|
55
52
|
var valueName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'value';
|
|
56
53
|
var minName = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'min';
|
|
57
54
|
var maxName = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'max';
|
|
58
|
-
|
|
59
55
|
if (process.env.NODE_ENV !== "production") {
|
|
60
56
|
var warned = false;
|
|
61
|
-
|
|
62
57
|
if (value < min) {
|
|
63
58
|
warn("Warning: ".concat(component, " ").concat(valueName, " (").concat(value, ") less than ").concat(minName, " (").concat(min, ")"));
|
|
64
59
|
warned = true;
|
|
@@ -66,40 +61,35 @@ var validateRange = function validateRange(value, min, max, component) {
|
|
|
66
61
|
warn("Warning: ".concat(component, " ").concat(valueName, " (").concat(value, ") greater than ").concat(maxName, " (").concat(max, ")"));
|
|
67
62
|
warned = true;
|
|
68
63
|
}
|
|
69
|
-
|
|
70
64
|
if (min > max) {
|
|
71
65
|
warn("Warning: ".concat(component, " ").concat(minName, " (").concat(min, ") greater than ").concat(maxName, " (").concat(max, ")"));
|
|
72
66
|
warned = true;
|
|
73
67
|
}
|
|
74
|
-
|
|
75
68
|
return warned;
|
|
76
69
|
}
|
|
77
70
|
};
|
|
78
|
-
|
|
79
71
|
exports.validateRange = validateRange;
|
|
80
|
-
|
|
81
72
|
var validateRangeOnce = function validateRangeOnce(thing, _ref) {
|
|
82
73
|
var component = _ref.component,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
_ref$valueName = _ref.valueName,
|
|
75
|
+
valueName = _ref$valueName === void 0 ? 'value' : _ref$valueName,
|
|
76
|
+
_ref$minName = _ref.minName,
|
|
77
|
+
minName = _ref$minName === void 0 ? 'min' : _ref$minName,
|
|
78
|
+
_ref$maxName = _ref.maxName,
|
|
79
|
+
maxName = _ref$maxName === void 0 ? 'max' : _ref$maxName;
|
|
90
80
|
if (process.env.NODE_ENV !== "production") {
|
|
91
81
|
var displayed;
|
|
92
82
|
return function (props) {
|
|
93
83
|
if (!displayed) {
|
|
94
84
|
displayed = validateRange(props[valueName], props[minName], props[maxName], component, valueName, minName, maxName);
|
|
95
85
|
}
|
|
96
|
-
|
|
97
86
|
return thing(props);
|
|
98
87
|
};
|
|
99
88
|
} else {
|
|
100
89
|
return thing;
|
|
101
90
|
}
|
|
102
91
|
};
|
|
92
|
+
|
|
103
93
|
/**
|
|
104
94
|
* Issues a warning to the console if `value`, adjusted for `min` is not evenly
|
|
105
95
|
* divisible by `step`. In production mode, no action is taken.
|
|
@@ -116,14 +106,10 @@ var validateRangeOnce = function validateRangeOnce(thing, _ref) {
|
|
|
116
106
|
* @memberof ui/internal/validators
|
|
117
107
|
* @private
|
|
118
108
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
109
|
exports.validateRangeOnce = validateRangeOnce;
|
|
122
|
-
|
|
123
110
|
var validateStepped = function validateStepped(value, min, step, component) {
|
|
124
111
|
var valueName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'value';
|
|
125
112
|
var stepName = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'step';
|
|
126
|
-
|
|
127
113
|
if (process.env.NODE_ENV !== "production") {
|
|
128
114
|
// Ignore fractional steps as floating point math can give inconsistent results (1 % 0.1 != 0)
|
|
129
115
|
if (step && step === Math.floor(step) && (value - min) % step !== 0) {
|
|
@@ -131,33 +117,27 @@ var validateStepped = function validateStepped(value, min, step, component) {
|
|
|
131
117
|
return true;
|
|
132
118
|
}
|
|
133
119
|
}
|
|
134
|
-
|
|
135
120
|
return false;
|
|
136
121
|
};
|
|
137
|
-
|
|
138
122
|
exports.validateStepped = validateStepped;
|
|
139
|
-
|
|
140
123
|
var validateSteppedOnce = function validateSteppedOnce(thing, _ref2) {
|
|
141
124
|
var component = _ref2.component,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
125
|
+
_ref2$minName = _ref2.minName,
|
|
126
|
+
minName = _ref2$minName === void 0 ? 'min' : _ref2$minName,
|
|
127
|
+
_ref2$stepName = _ref2.stepName,
|
|
128
|
+
stepName = _ref2$stepName === void 0 ? 'step' : _ref2$stepName,
|
|
129
|
+
_ref2$valueName = _ref2.valueName,
|
|
130
|
+
valueName = _ref2$valueName === void 0 ? 'value' : _ref2$valueName;
|
|
149
131
|
if (process.env.NODE_ENV !== "production") {
|
|
150
132
|
var displayed;
|
|
151
133
|
return function (args) {
|
|
152
134
|
if (!displayed) {
|
|
153
135
|
displayed = validateStepped(args[valueName], args[minName], args[stepName], component, valueName, stepName);
|
|
154
136
|
}
|
|
155
|
-
|
|
156
137
|
return thing(args);
|
|
157
138
|
};
|
|
158
139
|
} else {
|
|
159
140
|
return thing;
|
|
160
141
|
}
|
|
161
142
|
};
|
|
162
|
-
|
|
163
143
|
exports.validateSteppedOnce = validateSteppedOnce;
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.4",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/enactjs/enact.git",
|
|
8
|
+
"directory": "packages/ui"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://enactjs.com",
|
|
5
11
|
"main": "index.js",
|
|
6
12
|
"scripts": {
|
|
7
13
|
"clean": "enact clean",
|
|
@@ -25,7 +31,7 @@
|
|
|
25
31
|
}
|
|
26
32
|
},
|
|
27
33
|
"dependencies": {
|
|
28
|
-
"@enact/core": "^4.5.
|
|
34
|
+
"@enact/core": "^4.5.4",
|
|
29
35
|
"classnames": "^2.3.1",
|
|
30
36
|
"direction": "^1.0.4",
|
|
31
37
|
"invariant": "^2.2.4",
|