@os-design/core 1.0.277 → 1.0.278

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.
@@ -1,7 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import styled from '@emotion/styled';
3
3
  import { Close, CloseCircle, Down, Loading, Up } from '@os-design/icons';
4
- import { m, useIsMinWidth } from '@os-design/media';
4
+ import { useIsMinWidth } from '@os-design/media';
5
5
  import {
6
6
  type WithSize,
7
7
  ellipsisStyles,
@@ -12,11 +12,9 @@ import { ThemeOverrider, clr, useTheme } from '@os-design/theming';
12
12
  import {
13
13
  omitEmotionProps,
14
14
  useBrowserLayoutEffect,
15
- useEvent,
16
15
  useFontSize,
17
16
  useForwardedRef,
18
17
  useForwardedState,
19
- useResizeObserver,
20
18
  useSize,
21
19
  } from '@os-design/utils';
22
20
  import React, {
@@ -264,17 +262,10 @@ export const SelectContainer = styled(
264
262
  ${selectContainerUnborderedHoverStyles};
265
263
  `;
266
264
 
267
- interface SelectMenuProps {
268
- width: number;
269
- }
270
- const SelectMenu = styled(Menu, omitEmotionProps('width'))<SelectMenuProps>`
265
+ const SelectMenu = styled(Menu)`
271
266
  padding-top: 0;
272
267
  padding-bottom: 0;
273
268
  max-height: unset;
274
-
275
- ${m.min.xs} {
276
- width: ${(p) => p.width}px;
277
- }
278
269
  `;
279
270
 
280
271
  const NotFound = styled.div`
@@ -493,13 +484,12 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(
493
484
  onClose = () => {},
494
485
  onBlur = () => {},
495
486
  size,
496
- placement,
487
+ placement = 'bottom-full',
497
488
  ...rest
498
489
  },
499
490
  ref
500
491
  ) => {
501
492
  const [containerRef, mergedContainerRef] = useForwardedRef(ref);
502
- const [width, setWidth] = useState(0);
503
493
  const [opened, setOpened] = useState(autoOpen);
504
494
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
505
495
  const [forwardedValue, setForwardedValue] = useForwardedState<any>({
@@ -526,26 +516,6 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(
526
516
  if (!opened) onCloseRef.current();
527
517
  }, [opened]);
528
518
 
529
- /**
530
- * Detect the width of the container when the select was opened and update
531
- * it when either the container size or the window size has been changed.
532
- */
533
- const resizeHandler = useCallback(() => {
534
- window.requestAnimationFrame(() => {
535
- if (!opened || !containerRef.current) return;
536
- const nextWidth = containerRef.current.getBoundingClientRect().width;
537
- if (width === nextWidth) return;
538
- setWidth(nextWidth);
539
- });
540
- }, [opened, containerRef, width]);
541
- useBrowserLayoutEffect(() => resizeHandler(), [resizeHandler]);
542
- useResizeObserver(containerRef, resizeHandler);
543
- useEvent(
544
- (typeof window !== 'undefined' ? window : undefined) as EventTarget,
545
- 'resize',
546
- resizeHandler
547
- );
548
-
549
519
  // Replace the aria-haspopup attribute from menu to listbox
550
520
  useBrowserLayoutEffect(() => {
551
521
  if (!containerRef.current) return;
@@ -966,7 +936,6 @@ const Select = forwardRef<HTMLDivElement, SelectProps>(
966
936
  visible={opened}
967
937
  onClose={() => setOpened(false)}
968
938
  size={size}
969
- width={width}
970
939
  closeOnSelect={!multiple}
971
940
  modalTitle={placeholder}
972
941
  placement={placement}