@lumx/react 3.6.7 → 3.6.8

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 (41) hide show
  1. package/_internal/types.d.ts +29 -29
  2. package/index.d.ts +45 -45
  3. package/index.js +28 -16
  4. package/index.js.map +1 -1
  5. package/package.json +4 -4
  6. package/src/components/alert-dialog/AlertDialog.tsx +2 -12
  7. package/src/components/autocomplete/Autocomplete.test.tsx +1 -1
  8. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +1 -1
  9. package/src/components/badge/Badge.test.tsx +1 -1
  10. package/src/components/button/Button.test.tsx +2 -2
  11. package/src/components/button/IconButton.test.tsx +1 -1
  12. package/src/components/chip/Chip.test.tsx +22 -5
  13. package/src/components/chip/Chip.tsx +9 -5
  14. package/src/components/date-picker/DatePickerControlled.tsx +5 -4
  15. package/src/components/generic-block/GenericBlock.test.tsx +9 -9
  16. package/src/components/grid-column/GridColumn.tsx +32 -34
  17. package/src/components/icon/Icon.test.tsx +1 -1
  18. package/src/components/input-helper/InputHelper.test.tsx +1 -1
  19. package/src/components/link/Link.test.tsx +3 -3
  20. package/src/components/link-preview/LinkPreview.test.tsx +1 -2
  21. package/src/components/message/Message.test.tsx +1 -1
  22. package/src/components/mosaic/Mosaic.tsx +5 -4
  23. package/src/components/popover/Popover.tsx +13 -20
  24. package/src/components/select/Select.test.tsx +3 -3
  25. package/src/components/select/SelectMultiple.stories.tsx +56 -58
  26. package/src/components/select/SelectMultiple.test.tsx +4 -4
  27. package/src/components/side-navigation/SideNavigation.test.tsx +2 -2
  28. package/src/components/slideshow/SlideshowControls.stories.tsx +4 -9
  29. package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
  30. package/src/components/tabs/TabProvider.test.tsx +1 -1
  31. package/src/components/thumbnail/Thumbnail.stories.tsx +5 -5
  32. package/src/constants.ts +2 -2
  33. package/src/stories/decorators/withCombinations.tsx +76 -74
  34. package/src/utils/date/getFirstDayOfWeek.ts +2 -1
  35. package/src/utils/date/getMonthCalendar.test.ts +4 -0
  36. package/src/utils/date/getMonthCalendar.ts +10 -2
  37. package/src/utils/focus/constants.ts +4 -2
  38. package/src/utils/focus/getFirstAndLastFocusable.test.ts +19 -19
  39. package/src/utils/focus/getFocusableElements.test.ts +13 -13
  40. package/src/utils/type.ts +17 -13
  41. package/src/utils/utils.test.ts +5 -5
package/index.js CHANGED
@@ -410,12 +410,12 @@ const TOOLTIP_LONG_PRESS_DELAY = {
410
410
  /**
411
411
  * Optional global `window` instance (not defined when running SSR).
412
412
  */
413
- const WINDOW = typeof window !== `undefined` ? window : undefined;
413
+ const WINDOW = typeof window !== 'undefined' ? window : undefined;
414
414
 
415
415
  /**
416
416
  * Optional global `document` instance (not defined when running SSR).
417
417
  */
418
- const DOCUMENT = typeof document !== `undefined` ? document : undefined;
418
+ const DOCUMENT = typeof document !== 'undefined' ? document : undefined;
419
419
 
420
420
  const _excluded = ["prefix"];
421
421
 
@@ -1725,7 +1725,7 @@ function useStopPropagation(handler) {
1725
1725
  }, [handler]);
1726
1726
  }
1727
1727
 
1728
- const _excluded$c = ["after", "before", "children", "className", "color", "disabled", "isClickable", "isDisabled", "isHighlighted", "isSelected", "onAfterClick", "onBeforeClick", "onClick", "size", "theme"];
1728
+ const _excluded$c = ["after", "before", "children", "className", "color", "disabled", "isClickable", "isDisabled", "isHighlighted", "isSelected", "onAfterClick", "onBeforeClick", "onClick", "size", "theme", "href"];
1729
1729
 
1730
1730
  /**
1731
1731
  * Chip sizes.
@@ -1768,7 +1768,7 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
1768
1768
  className,
1769
1769
  color,
1770
1770
  disabled,
1771
- isClickable,
1771
+ isClickable: propIsClickable,
1772
1772
  isDisabled = disabled,
1773
1773
  isHighlighted,
1774
1774
  isSelected,
@@ -1776,12 +1776,15 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
1776
1776
  onBeforeClick,
1777
1777
  onClick,
1778
1778
  size,
1779
- theme
1779
+ theme,
1780
+ href
1780
1781
  } = props,
1781
1782
  forwardedProps = _objectWithoutProperties(props, _excluded$c);
1782
1783
  const hasAfterClick = isFunction(onAfterClick);
1783
1784
  const hasBeforeClick = isFunction(onBeforeClick);
1784
1785
  const hasOnClick = isFunction(onClick);
1786
+ const isButton = hasOnClick && !href;
1787
+ const isClickable = Boolean(hasOnClick) || Boolean(href) || propIsClickable;
1785
1788
 
1786
1789
  // Adapt color to the theme.
1787
1790
  const chipColor = color || (theme === Theme.light ? ColorPalette.dark : ColorPalette.light);
@@ -1790,10 +1793,14 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
1790
1793
  return (
1791
1794
  /*#__PURE__*/
1792
1795
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
1793
- React.createElement("a", _extends({}, forwardedProps, {
1796
+ React.createElement("a", _extends({
1797
+ role: isButton ? 'button' : undefined,
1798
+ tabIndex: isClickable ? 0 : undefined
1799
+ }, forwardedProps, {
1800
+ href: href,
1794
1801
  ref: ref,
1795
1802
  className: classnames(className, handleBasicClasses({
1796
- clickable: Boolean(hasOnClick) || isClickable,
1803
+ clickable: isClickable,
1797
1804
  color: chipColor,
1798
1805
  isDisabled,
1799
1806
  hasAfter: Boolean(after),
@@ -1804,9 +1811,7 @@ const Chip = /*#__PURE__*/forwardRef((props, ref) => {
1804
1811
  size,
1805
1812
  unselected: Boolean(!isSelected)
1806
1813
  })),
1807
- role: hasOnClick ? 'button' : undefined,
1808
- tabIndex: isDisabled || !hasOnClick ? -1 : 0,
1809
- "aria-disabled": hasOnClick && isDisabled || undefined,
1814
+ "aria-disabled": isClickable && isDisabled || undefined,
1810
1815
  onClick: hasOnClick ? onClick : undefined,
1811
1816
  onKeyDown: hasOnClick ? onEnterPressed(onClick) : undefined
1812
1817
  }), before &&
@@ -2172,6 +2177,9 @@ const getWeekDays = locale => {
2172
2177
  return weekDays;
2173
2178
  };
2174
2179
 
2180
+ /** Up to 6 rows can appear in a month calendar => 4 weeks + 1 start of month partial week + 1 send of month partial week */
2181
+ const MONTH_ROW_COUNT = 6;
2182
+
2175
2183
  /**
2176
2184
  * Get month calendar.
2177
2185
  * A list of weeks with days indexed by week day number
@@ -2187,7 +2195,8 @@ const getMonthCalendar = function (locale) {
2187
2195
  const lastDayOfWeek = last(weekDays);
2188
2196
  const weeks = [];
2189
2197
  let week = {};
2190
- while (iterDate.getMonth() === month) {
2198
+ let rowCount = 0;
2199
+ while (rowCount < MONTH_ROW_COUNT) {
2191
2200
  const weekDayNumber = iterDate.getDay();
2192
2201
  const day = {
2193
2202
  date: new Date(iterDate.getTime())
@@ -2197,9 +2206,12 @@ const getMonthCalendar = function (locale) {
2197
2206
  if (rangeMinDate && iterDate <= rangeMinDate || rangeMaxDate && iterDate >= rangeMaxDate) {
2198
2207
  day.isOutOfRange = true;
2199
2208
  }
2200
- week[weekDayNumber] = day;
2209
+ if (iterDate.getMonth() === month) {
2210
+ week[weekDayNumber] = day;
2211
+ }
2201
2212
  if (weekDayNumber === lastDayOfWeek.number) {
2202
2213
  weeks.push(week);
2214
+ rowCount += 1;
2203
2215
  week = {};
2204
2216
  }
2205
2217
  iterDate.setDate(iterDate.getDate() + 1);
@@ -2337,7 +2349,7 @@ const DatePickerControlled = /*#__PURE__*/forwardRef((props, ref) => {
2337
2349
  month: 'long'
2338
2350
  });
2339
2351
 
2340
- // Year can only be validatd by pressing Enter key or on Blur. The below handles the press Enter key case
2352
+ // Year can only be validated by pressing Enter key or on Blur. The below handles the press Enter key case
2341
2353
  const handleKeyPress = React.useMemo(() => onEnterPressed(updateMonthOffset), [updateMonthOffset]);
2342
2354
 
2343
2355
  // Required to update year in the TextField when the user changes year by using prev next month arrows
@@ -2661,10 +2673,10 @@ function useCallbackOnEscape(callback) {
2661
2673
  }
2662
2674
 
2663
2675
  /** CSS selector listing all tabbable elements. */
2664
- const TABBABLE_ELEMENTS_SELECTOR = `a[href], button, textarea, input:not([type="hidden"]):not([hidden]), [tabindex]`;
2676
+ const TABBABLE_ELEMENTS_SELECTOR = 'a[href], button, textarea, input:not([type="hidden"]):not([hidden]), [tabindex]';
2665
2677
 
2666
2678
  /** CSS selector matching element that are disabled (should not receive focus). */
2667
- const DISABLED_SELECTOR = `[hidden], [tabindex="-1"], [disabled]:not([disabled="false"]), [aria-disabled]:not([aria-disabled="false"])`;
2679
+ const DISABLED_SELECTOR = '[hidden], [tabindex="-1"], [disabled]:not([disabled="false"]), [aria-disabled]:not([aria-disabled="false"])';
2668
2680
 
2669
2681
  const isNotDisabled = element => !element.matches(DISABLED_SELECTOR);
2670
2682
  function getFocusableElements(element) {
@@ -11041,7 +11053,7 @@ const useFocusWithin = _ref => {
11041
11053
  * This is to easily find elements that have been tempered with,
11042
11054
  * and not elements whose focus was already initially blocked.
11043
11055
  * */
11044
- const BLOCKED_FOCUS_CLASSNAME = `focus-blocked`;
11056
+ const BLOCKED_FOCUS_CLASSNAME = 'focus-blocked';
11045
11057
 
11046
11058
  /**
11047
11059
  * Manage how slides must behave when visible or not.