@enact/limestone 1.3.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/.github/workflows/ci-branch.yml +21 -0
  2. package/.github/workflows/ci-pull-request.yml +16 -0
  3. package/.github/workflows/ci-reusable.yml +73 -0
  4. package/ActionGuide/ActionGuide.d.ts +5 -4
  5. package/ActionGuide/ActionGuide.module.css +1 -1
  6. package/Alert/Alert.d.ts +13 -2
  7. package/Alert/Alert.js +39 -5
  8. package/Alert/Alert.module.css +48 -1
  9. package/Alert/tests/Alert-specs.js +91 -0
  10. package/BodyText/BodyText.d.ts +5 -4
  11. package/BodyText/BodyText.module.css +7 -7
  12. package/Button/Button.d.ts +17 -12
  13. package/Button/Button.js +1 -1
  14. package/Button/Button.module.css +195 -268
  15. package/Button/tests/Button-specs.js +26 -0
  16. package/CHANGELOG.md +254 -0
  17. package/Card/Card.d.ts +40 -12
  18. package/Card/Card.js +164 -28
  19. package/Card/Card.module.css +277 -58
  20. package/Card/tests/Card-specs.js +67 -3
  21. package/Checkbox/Checkbox.d.ts +8 -7
  22. package/Checkbox/Checkbox.js +3 -1
  23. package/Checkbox/Checkbox.module.css +213 -120
  24. package/Checkbox/tests/Checkbox-specs.js +1 -1
  25. package/CheckboxItem/CheckboxItem.d.ts +22 -7
  26. package/CheckboxItem/CheckboxItem.js +71 -4
  27. package/Chips/Chip.js +72 -13
  28. package/Chips/Chip.module.css +3 -3
  29. package/Chips/Chips.js +37 -17
  30. package/Chips/Chips.module.css +1 -1
  31. package/Chips/tests/Chip-specs.js +43 -13
  32. package/Chips/tests/Chips-specs.js +31 -21
  33. package/ColorPicker/ColorPicker.js +27 -25
  34. package/ContextualMenuDecorator/ContextualMenuDecorator.d.ts +4 -5
  35. package/ContextualPopupDecorator/ContextualPopup.module.css +34 -34
  36. package/ContextualPopupDecorator/ContextualPopupDecorator.js +567 -549
  37. package/DatePicker/DatePicker.d.ts +4 -5
  38. package/DayPicker/DayPicker.d.ts +8 -7
  39. package/DayPicker/DaySelectorDecorator.js +12 -7
  40. package/Dropdown/Dropdown.d.ts +11 -13
  41. package/Dropdown/Dropdown.module.css +13 -9
  42. package/Dropdown/DropdownList.js +80 -54
  43. package/FixedPopupPanels/FixedPopupPanels.d.ts +4 -2
  44. package/FixedPopupPanels/FixedPopupPanels.module.css +18 -18
  45. package/FlexiblePopupPanels/FlexiblePopupPanels.module.css +23 -23
  46. package/FlexiblePopupPanels/useNavButtonFocus.js +7 -10
  47. package/FormCheckboxItem/FormCheckboxItem.d.ts +5 -4
  48. package/Heading/Heading.d.ts +9 -8
  49. package/Heading/Heading.js +2 -2
  50. package/Heading/Heading.module.css +5 -5
  51. package/Icon/Icon.d.ts +15 -4
  52. package/Icon/Icon.js +49 -2
  53. package/Icon/Icon.module.css +1 -1
  54. package/Icon/IconList.js +27 -1
  55. package/IconItem/IconItem.d.ts +13 -12
  56. package/IconItem/IconItem.js +15 -0
  57. package/IconItem/IconItem.module.css +107 -1
  58. package/IconItem/tests/IconItem-specs.js +30 -1
  59. package/Image/Image.d.ts +5 -4
  60. package/Image/Image.js +6 -4
  61. package/ImageItem/ImageItem.d.ts +11 -10
  62. package/ImageItem/ImageItem.js +37 -31
  63. package/ImageItem/ImageItem.module.css +30 -30
  64. package/ImageItem/tests/ImageItem-specs.js +3 -10
  65. package/Input/Input.js +21 -3
  66. package/Input/Input.module.css +37 -8
  67. package/Input/InputField.js +79 -24
  68. package/Input/InputField.module.css +273 -41
  69. package/Input/InputFieldDecoratorIcon.js +1 -0
  70. package/Input/InputFieldSpotlightDecorator.js +257 -228
  71. package/Input/index.d.ts +120 -111
  72. package/Input/tests/Input-specs.js +26 -0
  73. package/Input/tests/InputField-specs.js +170 -3
  74. package/Input/tests/InputPopup-specs.js +1 -1
  75. package/Item/Item.d.ts +16 -9
  76. package/Item/Item.js +20 -2
  77. package/Item/Item.module.css +1 -1
  78. package/KeyGuide/KeyGuide.d.ts +8 -7
  79. package/KeyGuide/KeyGuide.js +29 -27
  80. package/KeyGuide/KeyGuide.module.css +25 -1
  81. package/Marquee/Marquee.d.ts +2 -4
  82. package/MediaOverlay/MediaOverlay.d.ts +12 -11
  83. package/MediaOverlay/MediaOverlay.js +43 -21
  84. package/MediaOverlay/MediaOverlay.module.css +114 -15
  85. package/MediaOverlay/tests/MediaOverlay-specs.js +29 -0
  86. package/MediaPlayer/MediaControls.js +195 -13
  87. package/MediaPlayer/MediaControls.module.css +3 -2
  88. package/MediaPlayer/MediaSlider.module.css +7 -20
  89. package/MediaPlayer/index.d.ts +59 -7
  90. package/MediaPlayer/tests/util-specs.js +4 -1
  91. package/PageViews/PageViews.js +232 -82
  92. package/PageViews/PageViews.module.css +3 -0
  93. package/PageViews/PageViewsRouter.js +100 -42
  94. package/PageViews/tests/PageViews-specs.js +171 -0
  95. package/Panels/Header.js +54 -34
  96. package/Panels/Header.module.css +83 -31
  97. package/Panels/Panel.module.css +1 -1
  98. package/Panels/index.d.ts +7 -8
  99. package/Picker/Picker.d.ts +4 -5
  100. package/Picker/Picker.module.css +2 -2
  101. package/Popup/Popup.js +245 -242
  102. package/Popup/Popup.module.css +24 -24
  103. package/PopupTabLayout/PopupTabLayout.d.ts +5 -7
  104. package/PopupTabLayout/PopupTabLayout.js +26 -18
  105. package/PopupTabLayout/PopupTabLayout.module.css +53 -16
  106. package/PopupTabLayout/PopupTabLayoutStateContext.js +8 -0
  107. package/ProgressBar/ProgressBar.d.ts +5 -4
  108. package/ProgressBar/ProgressBarTooltip.module.css +12 -12
  109. package/ProgressButton/ProgressButton.d.ts +4 -5
  110. package/QuickGuidePanels/QuickGuidePanels.module.css +2 -2
  111. package/RadioItem/RadioItem.d.ts +18 -5
  112. package/RadioItem/RadioItem.js +69 -2
  113. package/RadioItem/RadioItem.module.css +36 -36
  114. package/RangePicker/RangePicker.module.css +2 -2
  115. package/Scroller/EditableWrapper.js +28 -18
  116. package/Scroller/Scroller.d.ts +20 -16
  117. package/Scroller/Scroller.js +20 -13
  118. package/Scroller/Scroller.module.css +4 -4
  119. package/Scroller/useThemeScroller.js +3 -3
  120. package/Slider/Slider.d.ts +20 -14
  121. package/Slider/Slider.js +71 -14
  122. package/Slider/Slider.module.css +464 -91
  123. package/Slider/SliderBehaviorDecorator.js +16 -14
  124. package/Slider/tests/Slider-specs.js +53 -1
  125. package/Slider/utils.js +23 -7
  126. package/Spinner/Spinner.d.ts +5 -4
  127. package/Spinner/Spinner.js +10 -8
  128. package/Spinner/Spinner.module.css +9 -9
  129. package/Steps/Steps.d.ts +5 -4
  130. package/Steps/Steps.js +9 -5
  131. package/Switch/Switch.d.ts +8 -7
  132. package/Switch/Switch.module.css +100 -13
  133. package/SwitchItem/SwitchItem.d.ts +9 -6
  134. package/TabLayout/RefocusDecorator.js +26 -18
  135. package/TabLayout/TabGroup.js +3 -2
  136. package/TabLayout/TabGroup.module.css +2 -2
  137. package/TabLayout/TabLayout.d.ts +6 -0
  138. package/TabLayout/TabLayout.js +11 -1
  139. package/TabLayout/TabLayout.module.css +18 -0
  140. package/TabLayout/tests/TabGroup-specs.js +1 -1
  141. package/TabLayout/tests/TabLayout-specs.js +52 -0
  142. package/ThemeDecorator/AccessibilityDecorator.js +12 -11
  143. package/ThemeDecorator/I18nFontDecorator.js +6 -4
  144. package/ThemeDecorator/ThemeDecorator.d.ts +16 -10
  145. package/ThemeDecorator/ThemeDecorator.js +24 -9
  146. package/ThemeDecorator/fontGenerator.js +1 -1
  147. package/ThemeDecorator/screenTypes.json +1 -0
  148. package/TimePicker/TimePicker.module.css +1 -1
  149. package/TimePicker/TimePickerBase.js +5 -3
  150. package/TooltipDecorator/Tooltip.module.css +1 -2
  151. package/TooltipDecorator/TooltipDecorator.js +12 -7
  152. package/TooltipDecorator/tests/useTooltip-specs.js +5 -2
  153. package/TooltipDecorator/tests/util-specs.js +12 -0
  154. package/TooltipDecorator/useTooltip.js +1 -1
  155. package/TooltipDecorator/util.js +18 -11
  156. package/VideoPlayer/Feedback.js +3 -0
  157. package/VideoPlayer/Feedback.module.css +5 -9
  158. package/VideoPlayer/FeedbackIcons.js +1 -1
  159. package/VideoPlayer/FeedbackTooltip.module.css +55 -11
  160. package/VideoPlayer/VideoPlayer.d.ts +44 -18
  161. package/VideoPlayer/VideoPlayer.js +153 -47
  162. package/VideoPlayer/VideoPlayer.module.css +28 -11
  163. package/VirtualList/VirtualList.d.ts +9 -2
  164. package/VirtualList/VirtualList.js +51 -24
  165. package/VirtualList/tests/VirtualGridList-translate-specs.js +3 -0
  166. package/VirtualList/tests/VirtualList-specs.js +28 -1
  167. package/VirtualList/tests/VirtualList-translate-specs.js +4 -1
  168. package/VirtualList/useSpotlight.js +1 -1
  169. package/WizardPanels/WizardPanels.module.css +2 -2
  170. package/WizardPanels/index.d.ts +4 -2
  171. package/fonts/Limestone_Icons.ttf +0 -0
  172. package/internal/$L/$L.js +3 -3
  173. package/internal/AsyncRenderChildren/AsyncRenderChildren.js +9 -5
  174. package/internal/AsyncRenderChildren/tests/AsyncRenderChildren-specs.js +4 -1
  175. package/internal/DateComponentPicker/DateComponentPicker.module.css +2 -2
  176. package/internal/DateTime/DateTime.module.css +1 -0
  177. package/internal/DateTime/DateTimeDecorator.js +5 -4
  178. package/internal/Panels/PanelsRouter.js +48 -31
  179. package/internal/Panels/useAutoFocus.js +10 -6
  180. package/internal/Panels/useFocusOnTransition.js +4 -3
  181. package/internal/Picker/Picker.js +7 -5
  182. package/internal/Picker/Picker.module.css +2 -2
  183. package/internal/Picker/SpottablePicker.js +15 -13
  184. package/internal/SharedStateDecorator/SharedStateDecorator.js +78 -99
  185. package/internal/validators/validators.js +21 -2
  186. package/package.json +18 -15
  187. package/styles/colors-highcontrast.less +9 -1
  188. package/styles/colors.less +12 -7
  189. package/styles/motion-mixins.less +66 -0
  190. package/styles/motions.less +78 -0
  191. package/styles/variables.less +176 -150
  192. package/useScroll/HoverToScroll.js +23 -17
  193. package/useScroll/Scrollbar.js +14 -10
  194. package/useScroll/ScrollbarPlaceholder.js +3 -5
  195. package/useScroll/ScrollbarTrack.js +7 -5
  196. package/useScroll/ScrollbarTrack.module.css +8 -8
  197. package/useScroll/useEvent.js +14 -3
  198. package/useScroll/useScroll.js +12 -2
  199. package/useScroll/useScroll.module.css +6 -6
  200. package/.travis.yml +0 -40
@@ -9,7 +9,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11
11
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
12
- describe('CheckboxItem Specs', function () {
12
+ describe('Checkbox Specs', function () {
13
13
  test('should not include the selected class when not selected', function () {
14
14
  (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.CheckboxBase, {}));
15
15
  var checkboxElement = _react.screen.getByRole('checkbox');
@@ -1,14 +1,16 @@
1
1
  // Type definitions for limestone/CheckboxItem
2
2
 
3
3
  import { ToggleableProps as ui_Toggleable_ToggleableProps } from "@enact/ui/Toggleable";
4
- import { ItemProps as limestone_Item_ItemProps } from "limestone/Item";
5
4
  import * as React from "react";
5
+ import { ItemProps as limestone_Item_ItemProps } from "limestone/Item";
6
6
 
7
7
  type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
8
8
  type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
9
9
 
10
- export interface CheckboxItemBaseProps
11
- extends Omit<limestone_Item_ItemProps, "iconComponent"> {
10
+ export interface CheckboxItemBaseProps extends Omit<
11
+ limestone_Item_ItemProps,
12
+ "iconComponent"
13
+ > {
12
14
  /**
13
15
  * Customizes the component by mapping the supplied collection of CSS class names to the
14
16
  corresponding internal elements and states of this component.
@@ -77,14 +79,15 @@ export class CheckboxItemBase extends React.Component<
77
79
  Merge<React.HTMLProps<HTMLElement>, CheckboxItemBaseProps>
78
80
  > {}
79
81
 
80
- export interface CheckboxItemDecoratorProps
81
- extends ui_Toggleable_ToggleableProps {}
82
+ export interface CheckboxItemDecoratorProps extends ui_Toggleable_ToggleableProps {}
82
83
  export function CheckboxItemDecorator<P>(
83
84
  Component: React.ComponentType<P> | string,
84
85
  ): React.ComponentType<P & CheckboxItemDecoratorProps>;
85
86
 
86
- export interface CheckboxItemProps
87
- extends Merge<CheckboxItemBaseProps, CheckboxItemDecoratorProps> {}
87
+ export interface CheckboxItemProps extends Merge<
88
+ CheckboxItemBaseProps,
89
+ CheckboxItemDecoratorProps
90
+ > {}
88
91
  /**
89
92
  * A Limestone-styled item with a checkbox component.
90
93
  *
@@ -96,4 +99,16 @@ export class CheckboxItem extends React.Component<
96
99
  Merge<React.HTMLProps<HTMLElement>, CheckboxItemProps>
97
100
  > {}
98
101
 
102
+ export interface CheckboxItemGroupProps {}
103
+ /**
104
+ * A container that surrounds multiple CheckboxItems.
105
+ *
106
+ * A list of multiple CheckboxItems wrapped with a CheckboxItemGroup component gets
107
+ required audio guidance.
108
+ */
109
+
110
+ export class CheckboxItemGroup extends React.Component<
111
+ Merge<React.HTMLProps<HTMLElement>, CheckboxItemGroupProps>
112
+ > {}
113
+
99
114
  export default CheckboxItem;
@@ -3,19 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.CheckboxItemDecorator = exports.CheckboxItemBase = exports.CheckboxItem = void 0;
6
+ exports["default"] = exports.CheckboxItemGroup = exports.CheckboxItemDecorator = exports.CheckboxItemBase = exports.CheckboxItem = void 0;
7
7
  var _kind = _interopRequireDefault(require("@enact/core/kind"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _compose = _interopRequireDefault(require("ramda/src/compose"));
8
+ var _util = require("@enact/core/util");
9
+ var _Group = _interopRequireDefault(require("@enact/ui/Group"));
10
10
  var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));
11
11
  var _Slottable = _interopRequireDefault(require("@enact/ui/Slottable"));
12
12
  var _Toggleable = _interopRequireDefault(require("@enact/ui/Toggleable"));
13
+ var _IString = _interopRequireDefault(require("ilib/lib/IString"));
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+ var _compose = _interopRequireDefault(require("ramda/src/compose"));
16
+ var _$L = _interopRequireDefault(require("../internal/$L"));
13
17
  var _Checkbox = require("../Checkbox");
14
18
  var _Item = require("../Item");
15
19
  var _Skinnable = _interopRequireDefault(require("../Skinnable"));
16
20
  var _CheckboxItemModule = _interopRequireDefault(require("./CheckboxItem.module.css"));
17
21
  var _jsxRuntime = require("react/jsx-runtime");
18
- var _excluded = ["children", "css", "icon", "indeterminate", "indeterminateIcon", "selected", "slotBefore"];
22
+ var _excluded = ["children", "css", "icon", "indeterminate", "indeterminateIcon", "selected", "slotBefore"],
23
+ _excluded2 = ["children", "groupId", "itemProps"],
24
+ _excluded3 = ["children"];
19
25
  /**
20
26
  * Limestone styled item components with a toggleable checkbox.
21
27
  *
@@ -207,4 +213,65 @@ var CheckboxItemDecorator = exports.CheckboxItemDecorator = (0, _compose["defaul
207
213
  * @public
208
214
  */
209
215
  var CheckboxItem = exports.CheckboxItem = (0, _Pure["default"])(CheckboxItemDecorator(CheckboxItemBase));
216
+
217
+ /**
218
+ * A container that surrounds multiple CheckboxItems.
219
+ *
220
+ * A list of multiple CheckboxItems wrapped with a CheckboxItemGroup component gets
221
+ * required audio guidance.
222
+ *
223
+ * @class CheckboxItemGroup
224
+ * @memberof limestone/CheckboxItem
225
+ * @ui
226
+ * @public
227
+ */
228
+ var _CheckboxItemGroup = exports.CheckboxItemGroup = function CheckboxItemGroup(props) {
229
+ (0, _util.checkPropTypes)(_CheckboxItemGroup, props);
230
+ var children = props.children,
231
+ groupId = props.groupId,
232
+ itemProps = props.itemProps,
233
+ rest = _objectWithoutProperties(props, _excluded2);
234
+ if (typeof children[0] === 'string') {
235
+ // The case of multiple checkbox items are represented by string array instead of `CheckboxItem` components using `ui/Group`
236
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
237
+ role: "region",
238
+ "aria-labelledby": groupId || "checkboxItemGroup",
239
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Group["default"], _objectSpread(_objectSpread({}, rest), {}, {
240
+ id: groupId || "checkboxItemGroup",
241
+ "aria-label": new _IString["default"]((0, _$L["default"])('{total} items in total')).format({
242
+ 'total': children.length
243
+ }),
244
+ childComponent: CheckboxItem,
245
+ childSelect: "onToggle",
246
+ itemProps: _objectSpread({}, itemProps),
247
+ children: children
248
+ }))
249
+ });
250
+ } else {
251
+ // The case of multiple checkbox items are represented by `CheckboxItem` components
252
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
253
+ role: "region",
254
+ "aria-labelledby": groupId || "checkboxItemGroup",
255
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
256
+ role: "group",
257
+ id: groupId || "checkboxItemGroup",
258
+ "aria-label": new _IString["default"]((0, _$L["default"])('{total} items in total')).format({
259
+ 'total': children.length
260
+ }),
261
+ children: children.map(function (child, index) {
262
+ var _child$props = child.props,
263
+ itemValue = _child$props.children,
264
+ childRest = _objectWithoutProperties(_child$props, _excluded3);
265
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(CheckboxItem, _objectSpread(_objectSpread(_objectSpread({}, childRest), itemProps), {}, {
266
+ children: itemValue
267
+ }), index);
268
+ })
269
+ }))
270
+ });
271
+ }
272
+ };
273
+ _CheckboxItemGroup.propTypes = {
274
+ groupId: _propTypes["default"].string,
275
+ itemProps: _propTypes["default"].object
276
+ };
210
277
  var _default = exports["default"] = CheckboxItem;
package/Chips/Chip.js CHANGED
@@ -12,11 +12,15 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _compose = _interopRequireDefault(require("ramda/src/compose"));
13
13
  var _react = require("react");
14
14
  var _Button = _interopRequireDefault(require("../Button"));
15
+ var _Icon = _interopRequireDefault(require("../Icon"));
16
+ var _Image = _interopRequireDefault(require("../Image"));
17
+ var _$L = _interopRequireDefault(require("../internal/$L"));
15
18
  var _Skinnable = _interopRequireDefault(require("../Skinnable"));
16
19
  var _Chips = require("./Chips");
17
20
  var _ChipModule = _interopRequireDefault(require("./Chip.module.css"));
18
21
  var _jsxRuntime = require("react/jsx-runtime");
19
- var _excluded = ["children", "className", "deleteButton", "disabled", "icon", "id", "onClick", "ref"];
22
+ var _excluded = ["checked", "children", "className", "deleteButton", "disabled", "icon", "id", "imageSize", "isImage", "onClick", "ref"],
23
+ _excluded2 = ["children"];
20
24
  /**
21
25
  * The shape of the chip delete button for {@link limestone/Chips.Chip|Chip}.
22
26
  *
@@ -42,7 +46,8 @@ var chipDeleteButtonShape = exports.chipDeleteButtonShape = _propTypes["default"
42
46
  position: _propTypes["default"].oneOf(['top', 'bottom', 'right'])
43
47
  });
44
48
  var ChipDefaultProps = {
45
- disabled: false
49
+ disabled: false,
50
+ imageSize: 24
46
51
  };
47
52
 
48
53
  /**
@@ -56,6 +61,7 @@ var ChipDefaultProps = {
56
61
  * position: 'right'
57
62
  * }}
58
63
  * icon="check"
64
+ * id="chip"
59
65
  * >
60
66
  * Label
61
67
  * </Chip>
@@ -66,28 +72,37 @@ var ChipDefaultProps = {
66
72
  * @ui
67
73
  * @public
68
74
  */
69
- var ChipBase = exports.ChipBase = function ChipBase(props) {
75
+ var _ChipBase = exports.ChipBase = function ChipBase(props) {
70
76
  var _use = (0, _react.use)(_Chips.ChipsContext),
71
77
  handleChipDelete = _use.handleChipDelete,
72
78
  getNextTargetFromDeleteButton = _use.getNextTargetFromDeleteButton,
73
79
  registerChild = _use.registerChild;
74
80
  var chipProps = (0, _util.setDefaultProps)(props, ChipDefaultProps);
75
- var children = chipProps.children,
81
+ (0, _util.checkPropTypes)(_ChipBase, chipProps);
82
+ var checked = chipProps.checked,
83
+ children = chipProps.children,
76
84
  className = chipProps.className,
77
85
  deleteButton = chipProps.deleteButton,
78
86
  disabled = chipProps.disabled,
79
87
  icon = chipProps.icon,
80
88
  id = chipProps.id,
89
+ imageSize = chipProps.imageSize,
90
+ isImage = chipProps.isImage,
81
91
  onClick = chipProps.onClick,
82
92
  ref = chipProps.ref,
83
93
  rest = _objectWithoutProperties(chipProps, _excluded);
84
- var chipClassName = (0, _classnames["default"])(className, deleteButton === null || deleteButton === void 0 ? void 0 : deleteButton.position);
94
+ var ariaLabel = children + ' ' + (0, _$L["default"])('Chip') + ' ' + (0, _$L["default"])('button');
85
95
  var buttonClassName = (0, _classnames["default"])(_ChipModule["default"].deleteButtonContainer, _ChipModule["default"][(deleteButton === null || deleteButton === void 0 ? void 0 : deleteButton.position) || 'right']);
96
+ var chipClassName = (0, _classnames["default"])(className, deleteButton === null || deleteButton === void 0 ? void 0 : deleteButton.position);
97
+ var chipRef = (0, _react.useRef)(null);
86
98
  var containerRef = (0, _react.useRef)(null);
87
- var clientRef = (0, _react.useRef)(null);
88
99
  var deleteButtonRef = (0, _react.useRef)(null);
89
- var chipRef = clientRef || ref;
90
100
  var isHovering = (0, _react.useRef)(false);
101
+ (0, _react.useEffect)(function () {
102
+ if (!chipRef.current) {
103
+ chipRef.current = ref.current;
104
+ }
105
+ }, [ref]);
91
106
  (0, _react.useEffect)(function () {
92
107
  if (chipRef.current && registerChild) {
93
108
  registerChild(chipRef, id);
@@ -160,6 +175,24 @@ var ChipBase = exports.ChipBase = function ChipBase(props) {
160
175
  deleteButton.onDelete(ev);
161
176
  }
162
177
  }, [deleteButton, handleChipDelete, id]);
178
+ var iconComponent = (0, _react.useCallback)(function (_ref) {
179
+ var childComponent = _ref.children,
180
+ iconProps = _objectWithoutProperties(_ref, _excluded2);
181
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
182
+ children: [checked && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon["default"], _objectSpread(_objectSpread({}, iconProps), {}, {
183
+ children: "checkmark"
184
+ })), isImage && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image["default"], _objectSpread(_objectSpread({}, iconProps), {}, {
185
+ src: childComponent,
186
+ style: {
187
+ borderRadius: '999px',
188
+ width: "".concat(imageSize, "px"),
189
+ height: "".concat(imageSize, "px")
190
+ }
191
+ })), !isImage && childComponent && childComponent !== 'check' && childComponent !== 'checkmark' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon["default"], _objectSpread(_objectSpread({}, iconProps), {}, {
192
+ children: childComponent
193
+ }))]
194
+ });
195
+ }, [checked, imageSize, isImage]);
163
196
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, rest), {}, {
164
197
  className: _ChipModule["default"].chip,
165
198
  onMouseLeave: handleMouseLeave,
@@ -169,35 +202,39 @@ var ChipBase = exports.ChipBase = function ChipBase(props) {
169
202
  onKeyDown: handleKeyDown,
170
203
  ref: containerRef,
171
204
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
205
+ "aria-label": ariaLabel,
206
+ "aria-checked": checked,
172
207
  css: _ChipModule["default"],
173
208
  className: chipClassName,
174
209
  "data-chip-index": id,
175
210
  disabled: disabled,
176
- focusEffect: "static",
177
- icon: icon ? icon : null,
211
+ icon: icon ? icon : '',
212
+ iconComponent: iconComponent,
178
213
  size: "small",
179
214
  onFocus: handleFocus,
180
215
  onClick: onClick,
181
216
  ref: chipRef,
217
+ role: "checkbox",
182
218
  roundBorder: true,
183
219
  children: children
184
220
  }), deleteButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
185
221
  className: buttonClassName,
186
222
  ref: deleteButtonRef,
187
223
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
224
+ "aria-label": children + ' ' + (0, _$L["default"])("Delete"),
188
225
  css: _ChipModule["default"],
189
226
  backgroundOpacity: "transparent",
190
227
  disabled: disabled,
191
228
  icon: (deleteButton === null || deleteButton === void 0 ? void 0 : deleteButton.icon) || 'closex',
192
229
  size: "small",
193
230
  onClick: handleDelete,
231
+ role: "button",
194
232
  roundBorder: true
195
233
  })
196
234
  })]
197
235
  }));
198
236
  };
199
- ChipBase.displayName = 'Chip';
200
- ChipBase.propTypes = /** @lends limestone/Chips.Chip.prototype */{
237
+ _ChipBase.propTypes = /** @lends limestone/Chips.Chip.prototype */{
201
238
  /**
202
239
  * A label displayed in the chip content.
203
240
  *
@@ -214,6 +251,13 @@ ChipBase.propTypes = /** @lends limestone/Chips.Chip.prototype */{
214
251
  * @public
215
252
  */
216
253
  id: _propTypes["default"].string.isRequired,
254
+ /**
255
+ * Sets the chip as `checked` if `true`
256
+ *
257
+ * @type {Boolean}
258
+ * @public
259
+ */
260
+ checked: _propTypes["default"].bool,
217
261
  /**
218
262
  * Define the icon, delete handler, and position for the delete button.
219
263
  *
@@ -236,8 +280,23 @@ ChipBase.propTypes = /** @lends limestone/Chips.Chip.prototype */{
236
280
  * @type {String|Object}
237
281
  * @public
238
282
  */
239
- icon: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object])
283
+ icon: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]),
284
+ /**
285
+ * Sets the size of the image passed to the component.
286
+ *
287
+ * @type {Number}
288
+ * @public
289
+ */
290
+ imageSize: _propTypes["default"].number,
291
+ /**
292
+ * If `true` tells the component to use `Image` instead of `Icon` element inside `Chip`.
293
+ *
294
+ * @type {Boolean}
295
+ * @public
296
+ */
297
+ isImage: _propTypes["default"].bool
240
298
  };
299
+ _ChipBase.displayName = 'Chip';
241
300
 
242
301
  /**
243
302
  * Limestone-specific Chip behaviors to apply to {@link limestone/Chips.Chip|Chip}.
@@ -248,5 +307,5 @@ ChipBase.propTypes = /** @lends limestone/Chips.Chip.prototype */{
248
307
  * @public
249
308
  */
250
309
  var ChipDecorator = exports.ChipDecorator = (0, _compose["default"])(_Skinnable["default"]);
251
- var Chip = exports.Chip = ChipDecorator(ChipBase);
310
+ var Chip = exports.Chip = ChipDecorator(_ChipBase);
252
311
  var _default = exports["default"] = Chip;
@@ -13,15 +13,15 @@
13
13
  .chip .deleteButtonContainer.right {
14
14
  top: 50%;
15
15
  right: 0;
16
- transform: translateY(-50%) translateX(calc(100% + 0.25rem ));
16
+ transform: translateY(-50%) translateX(calc(100% + var(--primitive-spacing-12) ));
17
17
  }
18
18
  .chip .deleteButtonContainer.bottom {
19
- bottom: -0.25rem;
19
+ bottom: calc( var(--primitive-spacing-12) * -1);
20
20
  left: 50%;
21
21
  transform: translate(-50%, 100%);
22
22
  }
23
23
  .chip .deleteButtonContainer.top {
24
- top: calc(-100% - 0.25rem );
24
+ top: calc(-100% - var(--primitive-spacing-12) );
25
25
  left: 50%;
26
26
  transform: translateX(-50%);
27
27
  }
package/Chips/Chips.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = exports.ChipsDecorator = exports.ChipsContext = exports.ChipsBase = exports.Chips = void 0;
7
7
  var _util = require("@enact/core/util");
8
+ var _IString = _interopRequireDefault(require("ilib/lib/IString"));
8
9
  var _spotlight = _interopRequireDefault(require("@enact/spotlight"));
9
10
  var _SpotlightContainerDecorator = require("@enact/spotlight/SpotlightContainerDecorator");
10
11
  var _container = require("@enact/spotlight/src/container");
@@ -13,6 +14,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
13
14
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
15
  var _compose = _interopRequireDefault(require("ramda/src/compose"));
15
16
  var _react = require("react");
17
+ var _$L = _interopRequireDefault(require("../internal/$L"));
16
18
  var _ChipsModule = _interopRequireDefault(require("./Chips.module.css"));
17
19
  var _jsxRuntime = require("react/jsx-runtime");
18
20
  var _excluded = ["children", "className", "orientation"];
@@ -31,6 +33,9 @@ var ChipsContext = exports.ChipsContext = /*#__PURE__*/(0, _react.createContext)
31
33
  var ChipsDefaultProps = {
32
34
  orientation: 'vertical'
33
35
  };
36
+ var generateAriaId = function generateAriaId() {
37
+ return Math.random().toString(36).substring(2, 10);
38
+ };
34
39
 
35
40
  /**
36
41
  * A container that surrounds the chips.
@@ -40,7 +45,7 @@ var ChipsDefaultProps = {
40
45
  * <Chips>
41
46
  * {chips.map(({id, icon, children}) => {
42
47
  * return (
43
- * <Chip key={id} icon={icon} onClick={onClick}>
48
+ * <Chip key={id} id={id} icon={icon} onClick={onClick}>
44
49
  * {children}
45
50
  * </Chip>
46
51
  * );
@@ -53,8 +58,9 @@ var ChipsDefaultProps = {
53
58
  * @ui
54
59
  * @public
55
60
  */
56
- var ChipsBase = exports.ChipsBase = function ChipsBase(props) {
61
+ var _ChipsBase = exports.ChipsBase = function ChipsBase(props) {
57
62
  var chipsProps = (0, _util.setDefaultProps)(props, ChipsDefaultProps);
63
+ (0, _util.checkPropTypes)(_ChipsBase, chipsProps);
58
64
  var children = chipsProps.children,
59
65
  className = chipsProps.className,
60
66
  orientation = chipsProps.orientation,
@@ -62,6 +68,12 @@ var ChipsBase = exports.ChipsBase = function ChipsBase(props) {
62
68
  var chipsClassName = (0, _classnames["default"])(_ChipsModule["default"].chips, _ChipsModule["default"][orientation], className);
63
69
  var childRefs = (0, _react.useRef)([]);
64
70
  var containerRef = (0, _react.useRef)(null);
71
+ var ariaLabel = new _IString["default"]((0, _$L["default"])('{total} items in total')).format({
72
+ total: children === null || children === void 0 ? void 0 : children.length
73
+ });
74
+ var ariaId = (0, _react.useMemo)(function () {
75
+ return generateAriaId();
76
+ }, []);
65
77
  var getPreviousChip = (0, _react.useCallback)(function (id) {
66
78
  var currentIndex = childRefs.current.findIndex(function (child) {
67
79
  return child.id === id;
@@ -149,21 +161,28 @@ var ChipsBase = exports.ChipsBase = function ChipsBase(props) {
149
161
  });
150
162
  }
151
163
  }, [children]);
152
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
153
- className: chipsClassName,
154
- ref: containerRef,
155
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChipsContext, {
156
- value: {
157
- getNextTargetFromDeleteButton: getNextTargetFromDeleteButton,
158
- handleChipDelete: handleChipDelete,
159
- registerChild: registerChild
160
- },
161
- children: children
162
- })
163
- }));
164
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
165
+ role: "region",
166
+ "aria-labelledby": "".concat(ariaId, "_chips"),
167
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
168
+ "aria-label": ariaLabel,
169
+ className: chipsClassName,
170
+ id: "".concat(ariaId, "_chips"),
171
+ ref: containerRef,
172
+ role: "group"
173
+ }, rest), {}, {
174
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChipsContext, {
175
+ value: {
176
+ getNextTargetFromDeleteButton: getNextTargetFromDeleteButton,
177
+ handleChipDelete: handleChipDelete,
178
+ registerChild: registerChild
179
+ },
180
+ children: children
181
+ })
182
+ }))
183
+ });
164
184
  };
165
- ChipsBase.displayName = 'Chips';
166
- ChipsBase.propTypes = /** @lends limestone/Chips.Chips.prototype */{
185
+ _ChipsBase.propTypes = /** @lends limestone/Chips.Chips.prototype */{
167
186
  /**
168
187
  * {@link limestone/Chips.Chip|Chip} to be rendered
169
188
  *
@@ -180,6 +199,7 @@ ChipsBase.propTypes = /** @lends limestone/Chips.Chips.prototype */{
180
199
  */
181
200
  orientation: _propTypes["default"].oneOf(['horizontal', 'vertical'])
182
201
  };
202
+ _ChipsBase.displayName = 'Chips';
183
203
 
184
204
  /**
185
205
  * Applies Limestone specific behaviors to {@link limestone/Chips.Chips|Chips} components.
@@ -211,5 +231,5 @@ var ChipsDecorator = exports.ChipsDecorator = (0, _compose["default"])((0, _Spot
211
231
  * @ui
212
232
  * @public
213
233
  */
214
- var Chips = exports.Chips = ChipsDecorator(ChipsBase);
234
+ var Chips = exports.Chips = ChipsDecorator(_ChipsBase);
215
235
  var _default = exports["default"] = Chips;
@@ -1,6 +1,6 @@
1
1
  .chips {
2
2
  display: inline-flex;
3
- gap: 0.75rem;
3
+ gap: var(--primitive-spacing-36);
4
4
  }
5
5
  .chips.vertical {
6
6
  flex-direction: column;