@enact/ui 4.5.2 → 4.6.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.
Files changed (222) hide show
  1. package/AnnounceDecorator/Announce.js +1 -40
  2. package/AnnounceDecorator/AnnounceDecorator.js +3 -21
  3. package/AnnounceDecorator/tests/Announce-specs.js +2 -7
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
  6. package/AnnounceDecorator/useAnnounce.js +0 -6
  7. package/BodyText/BodyText.js +8 -28
  8. package/BodyText/tests/BodyText-specs.js +0 -19
  9. package/Button/Button.js +33 -63
  10. package/Button/tests/Button-specs.js +0 -26
  11. package/CHANGELOG.md +45 -0
  12. package/Cancelable/Cancelable.js +8 -47
  13. package/Cancelable/cancelHandler.js +5 -12
  14. package/Cancelable/modalHandler.js +3 -11
  15. package/Cancelable/tests/Cancelable-specs.js +3 -57
  16. package/Changeable/Changeable.js +2 -34
  17. package/Changeable/tests/Changeable-specs.js +20 -66
  18. package/ComponentOverride/ComponentOverride.js +1 -13
  19. package/FloatingLayer/FloatingLayer.js +17 -73
  20. package/FloatingLayer/FloatingLayerContainer.js +0 -15
  21. package/FloatingLayer/FloatingLayerDecorator.js +4 -17
  22. package/FloatingLayer/Scrim.js +9 -53
  23. package/FloatingLayer/index.js +0 -4
  24. package/FloatingLayer/package.json +3 -0
  25. package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
  26. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  27. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  28. package/FloatingLayer/useFloatingLayer.js +3 -14
  29. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  30. package/ForwardRef/ForwardRef.js +1 -10
  31. package/GridListImageItem/GridListImageItem.js +18 -51
  32. package/Group/Group.js +5 -36
  33. package/Group/GroupItem.js +16 -33
  34. package/Group/tests/Group-specs.js +0 -32
  35. package/Heading/Heading.js +8 -36
  36. package/Heading/tests/Heading-specs.js +81 -14
  37. package/Icon/Icon.js +19 -53
  38. package/Icon/tests/Icon-specs.js +0 -22
  39. package/IconButton/IconButton.js +24 -57
  40. package/IconButton/tests/IconButton-specs.js +0 -7
  41. package/Image/Image.js +17 -46
  42. package/Image/tests/Image-specs.js +0 -14
  43. package/ImageItem/ImageItem.js +18 -47
  44. package/ImageItem/tests/ImageItem-specs.js +0 -25
  45. package/Item/Item.js +9 -33
  46. package/Item/tests/Item-specs.js +0 -24
  47. package/LabeledIcon/LabeledIcon.js +22 -53
  48. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  49. package/Layout/Cell.js +18 -44
  50. package/Layout/Layout.js +23 -46
  51. package/Layout/tests/Layout-specs.js +10 -39
  52. package/Marquee/MarqueeBase.js +29 -63
  53. package/Marquee/MarqueeController.js +11 -72
  54. package/Marquee/MarqueeDecorator.js +70 -196
  55. package/Marquee/index.js +1 -5
  56. package/Marquee/tests/Marquee-specs.js +295 -87
  57. package/Measurable/Measurable.js +12 -34
  58. package/Measurable/tests/Measurable-specs.js +115 -0
  59. package/Media/Media.js +15 -65
  60. package/Media/tests/Media-specs.js +168 -0
  61. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  62. package/Placeholder/PlaceholderDecorator.js +7 -38
  63. package/Placeholder/index.js +1 -5
  64. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  65. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  66. package/ProgressBar/ProgressBar.js +14 -45
  67. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  68. package/RadioDecorator/RadioControllerDecorator.js +7 -29
  69. package/RadioDecorator/RadioDecorator.js +9 -42
  70. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  71. package/Repeater/Repeater.js +9 -33
  72. package/Repeater/tests/Repeater-specs.js +0 -38
  73. package/Resizable/Resizable.js +9 -37
  74. package/Resizable/tests/Resizable-specs.js +34 -0
  75. package/Routable/Link.js +11 -47
  76. package/Routable/Routable.js +12 -35
  77. package/Routable/Route.js +0 -6
  78. package/Routable/Router.js +15 -58
  79. package/Routable/tests/Routable-specs.js +7 -33
  80. package/Routable/tests/Router-specs.js +18 -44
  81. package/Routable/useLink.js +4 -8
  82. package/Routable/util.js +18 -24
  83. package/Scrollable/ScrollAnimator.js +49 -65
  84. package/Scrollable/ScrollThumb.js +2 -13
  85. package/Scrollable/Scrollable.js +180 -387
  86. package/Scrollable/ScrollableNative.js +189 -392
  87. package/Scrollable/Scrollbar.js +30 -102
  88. package/Scroller/Scroller.js +15 -39
  89. package/Scroller/ScrollerBasic.js +34 -89
  90. package/Scroller/UiScrollerBase.js +37 -84
  91. package/Scroller/tests/Scroller-specs.js +56 -0
  92. package/Skinnable/Skinnable.js +11 -38
  93. package/Skinnable/tests/Skinnable-specs.js +3 -74
  94. package/Skinnable/tests/useSkins-specs.js +1 -13
  95. package/Skinnable/tests/util-specs.js +0 -14
  96. package/Skinnable/useSkins.js +8 -15
  97. package/Skinnable/util.js +9 -20
  98. package/Slider/Knob.js +5 -24
  99. package/Slider/PositionDecorator.js +16 -54
  100. package/Slider/Slider.js +29 -67
  101. package/Slider/tests/Slider-specs.js +94 -7
  102. package/Slider/utils.js +0 -2
  103. package/SlotItem/SlotItem.js +23 -45
  104. package/SlotItem/tests/SlotItem-specs.js +0 -5
  105. package/Slottable/Slottable.js +4 -12
  106. package/Slottable/tests/Slottable-specs.js +19 -46
  107. package/Slottable/tests/useSlots-specs.js +27 -65
  108. package/Slottable/useSlots.js +8 -33
  109. package/Spinner/Spinner.js +16 -43
  110. package/Spinner/tests/Spinner-specs.js +0 -15
  111. package/ToggleIcon/ToggleIcon.js +10 -36
  112. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  113. package/ToggleItem/ToggleItem.js +24 -57
  114. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  115. package/Toggleable/Toggle.js +1 -15
  116. package/Toggleable/Toggleable.js +12 -45
  117. package/Toggleable/tests/Toggleable-specs.js +28 -96
  118. package/Toggleable/useToggle.js +3 -19
  119. package/Touchable/ClickAllow.js +5 -14
  120. package/Touchable/Drag.js +16 -54
  121. package/Touchable/Flick.js +11 -42
  122. package/Touchable/Hold.js +21 -68
  123. package/Touchable/Pinch.js +185 -0
  124. package/Touchable/Touch.js +71 -76
  125. package/Touchable/Touchable.js +95 -75
  126. package/Touchable/config.js +27 -24
  127. package/Touchable/tests/Touchable-specs.js +360 -119
  128. package/Touchable/tests/useTouch-specs.js +6 -80
  129. package/Touchable/useTouch.js +57 -65
  130. package/Transition/Transition.js +37 -118
  131. package/Transition/tests/Transition-specs.js +20 -60
  132. package/ViewManager/Arranger.js +10 -22
  133. package/ViewManager/TransitionGroup.js +32 -107
  134. package/ViewManager/View.js +35 -91
  135. package/ViewManager/ViewManager.js +20 -84
  136. package/ViewManager/tests/View-specs.js +0 -17
  137. package/ViewManager/tests/ViewManager-specs.js +236 -305
  138. package/ViewManager/tests/test-utils.js +0 -8
  139. package/VirtualList/UiVirtualListBase.js +265 -409
  140. package/VirtualList/VirtualList.js +29 -69
  141. package/VirtualList/VirtualListBase.js +0 -3
  142. package/VirtualList/VirtualListBasic.js +273 -431
  143. package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
  144. package/VirtualList/tests/VirtualGridList-specs.js +614 -0
  145. package/VirtualList/tests/VirtualList-native-specs.js +152 -0
  146. package/VirtualList/tests/VirtualList-specs.js +423 -95
  147. package/internal/IdProvider/IdProvider.js +7 -21
  148. package/internal/IdProvider/Provider.js +4 -17
  149. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  150. package/internal/IdProvider/tests/useId-specs.js +6 -20
  151. package/internal/IdProvider/useId.js +0 -6
  152. package/internal/Pure/Pure.js +3 -30
  153. package/internal/Pure/tests/Pure-specs.js +88 -0
  154. package/internal/localized-fonts/localized-fonts.js +33 -62
  155. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  156. package/internal/selection/selection.js +1 -6
  157. package/internal/selection/tests/selection-specs.js +6 -4
  158. package/internal/validators/tests/validators-specs.js +80 -0
  159. package/internal/validators/validators.js +14 -34
  160. package/package.json +9 -3
  161. package/resolution/ResolutionDecorator.js +4 -40
  162. package/resolution/index.js +0 -7
  163. package/resolution/resolution.js +42 -80
  164. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  165. package/resolution/tests/resolution-specs.js +2 -2
  166. package/useControlledState/tests/useControlledState-specs.js +15 -46
  167. package/useControlledState/useControlledState.js +11 -22
  168. package/useScroll/ScrollAnimator.js +49 -65
  169. package/useScroll/Scrollbar.js +22 -58
  170. package/useScroll/ScrollbarTrack.js +3 -19
  171. package/useScroll/useScroll.js +267 -454
  172. package/useScroll/utilDOM.js +8 -14
  173. package/useScroll/utilEvent.js +0 -4
  174. package/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
  175. package/BodyText/BodyText.d.ts +0 -66
  176. package/Button/Button.d.ts +0 -125
  177. package/Cancelable/Cancelable.d.ts +0 -64
  178. package/Changeable/Changeable.d.ts +0 -54
  179. package/ComponentOverride/ComponentOverride.d.ts +0 -52
  180. package/ForwardRef/ForwardRef.d.ts +0 -22
  181. package/GridListImageItem/GridListImageItem.d.ts +0 -85
  182. package/Group/Group.d.ts +0 -107
  183. package/Heading/Heading.d.ts +0 -90
  184. package/Icon/Icon.d.ts +0 -88
  185. package/IconButton/IconButton.d.ts +0 -115
  186. package/Image/Image.d.ts +0 -113
  187. package/ImageItem/ImageItem.d.ts +0 -83
  188. package/Item/Item.d.ts +0 -64
  189. package/LabeledIcon/LabeledIcon.d.ts +0 -130
  190. package/Layout/Layout.d.ts +0 -247
  191. package/Marquee/index.d.ts +0 -258
  192. package/Measurable/Measurable.d.ts +0 -26
  193. package/Media/Media.d.ts +0 -99
  194. package/Placeholder/index.d.ts +0 -53
  195. package/ProgressBar/ProgressBar.d.ts +0 -92
  196. package/RadioDecorator/RadioDecorator.d.ts +0 -35
  197. package/Repeater/Repeater.d.ts +0 -83
  198. package/Resizable/Resizable.d.ts +0 -31
  199. package/Routable/Routable.d.ts +0 -148
  200. package/Scrollable/Scrollable.d.ts +0 -0
  201. package/Scroller/Scroller.d.ts +0 -276
  202. package/Skinnable/Skinnable.d.ts +0 -94
  203. package/Slider/Slider.d.ts +0 -202
  204. package/SlotItem/SlotItem.d.ts +0 -118
  205. package/Slottable/Slottable.d.ts +0 -22
  206. package/Spinner/Spinner.d.ts +0 -95
  207. package/ToggleIcon/ToggleIcon.d.ts +0 -90
  208. package/ToggleItem/ToggleItem.d.ts +0 -134
  209. package/Toggleable/Toggleable.d.ts +0 -103
  210. package/Touchable/Touchable.d.ts +0 -175
  211. package/Transition/Transition.d.ts +0 -196
  212. package/ViewManager/ViewManager.d.ts +0 -191
  213. package/VirtualList/VirtualList.d.ts +0 -530
  214. package/index.d.ts +0 -0
  215. package/internal/IdProvider/IdProvider.d.ts +0 -0
  216. package/internal/Pure/Pure.d.ts +0 -0
  217. package/internal/localized-fonts/localized-fonts.d.ts +0 -53
  218. package/internal/selection/selection.d.ts +0 -0
  219. package/internal/validators/validators.d.ts +0 -0
  220. package/resolution/index.d.ts +0 -187
  221. package/useControlledState/useControlledState.d.ts +0 -0
  222. package/useScroll/useScroll.d.ts +0 -0
@@ -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; // Generate a single font-face rule
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
- } // Take our array and update each of its elements to be CSS "local()" strings
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
- }); // Join all our strings together with a comma, so it's a valid CSS `src` rule
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
- }; // Generate a collection of font-face rules, in multiple font-variants
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
- name = bitDefault ? fontName : fontName + ' ' + strLang;
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
- }); // Build Light
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
- }); // Build SemiBold
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
- }); // Build Bold
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
- language = matchLang && matchLang[1],
92
- matchScript = locale.match(/\b([a-z]{4})\b/i),
93
- script = matchScript && matchScript[1],
94
- matchReg = locale.match(/\b([A-Z]{2}|[0-9]{3})\b/),
95
- region = matchReg && matchReg[1];
96
- var fontDefinitionCss = ''; // Build all the fonts so they could be explicitly called
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
- _lang$split2 = _slicedToArray(_lang$split, 3),
109
- la = _lang$split2[0],
110
- sc = _lang$split2[1],
111
- re = _lang$split2[2]; // if script is not specified, fall back to second part representing region
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>"); // We're rendering without the DOM; return the font definition stylesheet element string.
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
- }); // Single mode
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
- }); // Radio Mode
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
- }); // Multiple mode
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
- _ref$valueName = _ref.valueName,
84
- valueName = _ref$valueName === void 0 ? 'value' : _ref$valueName,
85
- _ref$minName = _ref.minName,
86
- minName = _ref$minName === void 0 ? 'min' : _ref$minName,
87
- _ref$maxName = _ref.maxName,
88
- maxName = _ref$maxName === void 0 ? 'max' : _ref$maxName;
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
- _ref2$minName = _ref2.minName,
143
- minName = _ref2$minName === void 0 ? 'min' : _ref2$minName,
144
- _ref2$stepName = _ref2.stepName,
145
- stepName = _ref2$stepName === void 0 ? 'step' : _ref2$stepName,
146
- _ref2$valueName = _ref2.valueName,
147
- valueName = _ref2$valueName === void 0 ? 'value' : _ref2$valueName;
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.2",
3
+ "version": "4.6.1",
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,8 +31,8 @@
25
31
  }
26
32
  },
27
33
  "dependencies": {
28
- "@enact/core": "^4.5.2",
29
- "classnames": "^2.3.1",
34
+ "@enact/core": "^4.6.1",
35
+ "classnames": "^2.3.2",
30
36
  "direction": "^1.0.4",
31
37
  "invariant": "^2.2.4",
32
38
  "prop-types": "^15.8.1",