@lumx/react 3.8.2-alpha.1 → 3.9.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 (38) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +55 -41
  3. package/index.js.map +1 -1
  4. package/package.json +4 -5
  5. package/src/components/alert-dialog/AlertDialog.test.tsx +1 -1
  6. package/src/components/alert-dialog/AlertDialog.tsx +3 -2
  7. package/src/components/checkbox/Checkbox.tsx +4 -3
  8. package/src/components/date-picker/DatePickerControlled.tsx +2 -3
  9. package/src/components/image-lightbox/ImageLightbox.test.tsx +10 -18
  10. package/src/components/image-lightbox/internal/ImageSlide.tsx +2 -2
  11. package/src/components/message/Message.tsx +1 -1
  12. package/src/components/navigation/NavigationSection.tsx +4 -3
  13. package/src/components/notification/constants.ts +1 -1
  14. package/src/components/radio-button/RadioButton.tsx +4 -3
  15. package/src/components/select/Select.test.tsx +1 -1
  16. package/src/components/select/SelectMultiple.test.tsx +1 -1
  17. package/src/components/select/WithSelectContext.tsx +4 -3
  18. package/src/components/side-navigation/SideNavigationItem.test.tsx +1 -1
  19. package/src/components/side-navigation/SideNavigationItem.tsx +2 -2
  20. package/src/components/slider/Slider.test.tsx +1 -1
  21. package/src/components/slider/Slider.tsx +3 -2
  22. package/src/components/switch/Switch.test.tsx +1 -1
  23. package/src/components/switch/Switch.tsx +4 -3
  24. package/src/components/tabs/state.ts +4 -6
  25. package/src/components/text-field/TextField.tsx +6 -15
  26. package/src/components/tooltip/Tooltip.test.tsx +1 -1
  27. package/src/components/tooltip/Tooltip.tsx +4 -4
  28. package/src/components/uploader/Uploader.tsx +3 -2
  29. package/src/components/user-block/UserBlock.stories.tsx +1 -1
  30. package/src/components/user-block/UserBlock.tsx +2 -2
  31. package/src/hooks/useId.test.tsx +23 -0
  32. package/src/hooks/useId.ts +15 -0
  33. package/src/hooks/{useElementSizeDependentOfWindowSize.ts → useSizeOnWindowResize.ts} +1 -3
  34. package/src/hooks/useSlideshowControls.ts +7 -4
  35. package/src/stories/generated/UserBlock/Demos.stories.tsx +1 -0
  36. package/src/utils/date/formatDayNumber.test.ts +12 -0
  37. package/src/utils/date/formatDayNumber.ts +5 -0
  38. package/src/utils/unref.ts +0 -0
@@ -1,8 +1,8 @@
1
- import { useState, useCallback, useEffect, useMemo } from 'react';
1
+ import { useState, useCallback, useEffect } from 'react';
2
2
 
3
3
  import { useInterval } from '@lumx/react/hooks/useInterval';
4
- import uniqueId from 'lodash/uniqueId';
5
4
  import { AUTOPLAY_DEFAULT_INTERVAL } from '@lumx/react/components/slideshow/constants';
5
+ import { useId } from '@lumx/react/hooks/useId';
6
6
 
7
7
  export interface UseSlideshowControlsOptions {
8
8
  /** default active index to be displayed */
@@ -193,8 +193,11 @@ export const useSlideshowControls = ({
193
193
  onChange(currentIndex);
194
194
  }, [currentIndex, onChange]);
195
195
 
196
- const slideshowId = useMemo(() => id || uniqueId('slideshow'), [id]);
197
- const slideshowSlidesId = useMemo(() => slidesId || uniqueId('slideshow-slides'), [slidesId]);
196
+ const generatedSlideshowId = useId();
197
+ const slideshowId = id || generatedSlideshowId;
198
+
199
+ const generatedSlidesId = useId();
200
+ const slideshowSlidesId = slidesId || generatedSlidesId;
198
201
 
199
202
  const toggleAutoPlay = () => {
200
203
  if (isSlideshowAutoPlaying) {
@@ -7,4 +7,5 @@ export { App as Extended } from './extended';
7
7
  export { App as SizeL } from './size-l';
8
8
  export { App as SizeM } from './size-m';
9
9
  export { App as SizeS } from './size-s';
10
+ export { App as SizeXs } from './size-xs';
10
11
  export { App as Vertical } from './vertical';
@@ -0,0 +1,12 @@
1
+ import { formatDayNumber } from '@lumx/react/utils/date/formatDayNumber';
2
+
3
+ describe(formatDayNumber, () => {
4
+ it('should format ', () => {
5
+ // Standard numerical formatting.
6
+ expect(formatDayNumber('en', new Date('2024-05-11'))).toEqual('11');
7
+ // Keep only the numerical part (if any). Raw formatted day number here is '11日'.
8
+ expect(formatDayNumber('ja', new Date('2024-05-11'))).toEqual('11');
9
+ // Else Keep the non-numerical formatting
10
+ expect(formatDayNumber('ar-eg', new Date('2024-05-11'))).toEqual('١١');
11
+ });
12
+ });
@@ -0,0 +1,5 @@
1
+ export function formatDayNumber(locale: string, date: Date): string {
2
+ const formattedDate = date.toLocaleDateString(locale, { day: 'numeric' });
3
+ if (formattedDate.match(/\d/)) return formattedDate.replace(/\D*(\d+)\D*/g, '$1');
4
+ return formattedDate;
5
+ }
File without changes