@bitrise/bitkit 13.216.0 → 13.218.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "13.216.0",
4
+ "version": "13.218.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -15,9 +15,11 @@ import {
15
15
  FormErrorMessage,
16
16
  FormHelperText,
17
17
  useControllableState,
18
+ useMergeRefs,
18
19
  useMultiStyleConfig,
19
20
  } from '@chakra-ui/react';
20
21
  import { FloatingFocusManager } from '@floating-ui/react-dom-interactions';
22
+ import ProgressSpinner from '../ProgressSpinner/ProgressSpinner';
21
23
  import SearchInput from '../SearchInput/SearchInput';
22
24
  import FormLabel from '../Form/FormLabel';
23
25
  import { AvatarProps } from '../Avatar/Avatar';
@@ -279,6 +281,7 @@ const Dropdown = forwardRef<Element, DropdownProps<string | null>>(
279
281
  name,
280
282
  onBlur,
281
283
  onChange,
284
+ onScrolledToBottom,
282
285
  placeholder,
283
286
  placement,
284
287
  readOnly,
@@ -350,6 +353,25 @@ const Dropdown = forwardRef<Element, DropdownProps<string | null>>(
350
353
  );
351
354
  const searchElement = search === false ? null : search || <DropdownSearch />;
352
355
  const buttonId = useId();
356
+
357
+ const internalRef = useCallback((node: HTMLDivElement | null) => {
358
+ if (!node) return;
359
+
360
+ const handleScroll = () => {
361
+ const { scrollTop, scrollHeight, clientHeight } = node;
362
+ if (scrollTop + clientHeight >= scrollHeight) {
363
+ onScrolledToBottom?.();
364
+ }
365
+ };
366
+
367
+ node.addEventListener('scroll', handleScroll);
368
+
369
+ // Cleanup when the element is unmounted or ref changes
370
+ return () => node.removeEventListener('scroll', handleScroll);
371
+ }, []);
372
+
373
+ const mergedRef = useMergeRefs(internalRef, optionsRef);
374
+
353
375
  return (
354
376
  <>
355
377
  {name && formValue && <input name={name} type="hidden" value={formValue} />}
@@ -391,8 +413,11 @@ const Dropdown = forwardRef<Element, DropdownProps<string | null>>(
391
413
  <FloatingFocusManager context={floatingContext} initialFocus={searchRef} returnFocus={returnFocus}>
392
414
  <chakra.div {...floatingProps} {...dataAttributes} sx={listStyles}>
393
415
  {searchElement}
394
- <chakra.div ref={optionsRef} __css={dropdownStyles.options} tabIndex={-1}>
416
+ <chakra.div ref={mergedRef} __css={dropdownStyles.options} tabIndex={-1}>
395
417
  {children}
418
+ <chakra.div display="flex" justifyContent="space-around">
419
+ <ProgressSpinner />
420
+ </chakra.div>
396
421
  </chakra.div>
397
422
  </chakra.div>
398
423
  </FloatingFocusManager>
@@ -27,9 +27,11 @@ export interface DropdownProps<T> extends ChakraProps {
27
27
  infoTooltipLabel?: string;
28
28
  infoTooltipProps?: TooltipProps;
29
29
  isError?: boolean;
30
+ isLoadingMore?: boolean;
30
31
  isWarning?: boolean;
31
32
  label?: string;
32
33
  name?: string;
34
+ onScrolledToBottom?(): void;
33
35
  onBlur?: DropdownChangeEventHandler<T>;
34
36
  onChange?: DropdownChangeEventHandler<T>;
35
37
  placeholder?: string;
@@ -65,13 +65,11 @@ const InputTheme = defineStyle({
65
65
  pointerEvents: 'none',
66
66
  top: '50%',
67
67
  transform: 'translateY(-50%)',
68
- left: '12',
69
68
  },
70
69
  rightIconWrapper: {
71
70
  pointerEvents: 'none',
72
71
  top: '50%',
73
72
  transform: 'translateY(-50%)',
74
- right: '12',
75
73
  },
76
74
  inputContainer: {
77
75
  position: 'relative',
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, ReactNode, Ref, useState } from 'react';
1
+ import { ChangeEvent, ReactNode, Ref, useCallback, useState } from 'react';
2
2
  import {
3
3
  FormControl,
4
4
  FormControlProps,
@@ -20,7 +20,7 @@ import {
20
20
  import Icon, { TypeIconName } from '../../Icon/Icon';
21
21
  import { TooltipProps } from '../../Tooltip/Tooltip';
22
22
  import FormLabel, { FormLabelProps } from '../FormLabel';
23
- import { getDataAttributes } from '../../../utils/utils';
23
+ import { getDataAttributes, rem } from '../../../utils/utils';
24
24
 
25
25
  type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
26
26
  type UsedChakraInputProps = Pick<
@@ -169,6 +169,22 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
169
169
  const iconSize = size === 'lg' ? '24' : '16';
170
170
  const style = useMultiStyleConfig('Input');
171
171
 
172
+ const [leftIconPos, setLeftIconPos] = useState(rem(12));
173
+
174
+ const leftAddonRef = useCallback((node: HTMLDivElement | null) => {
175
+ if (node) {
176
+ setLeftIconPos(rem(node.getBoundingClientRect().width + 12));
177
+ }
178
+ }, []);
179
+
180
+ const [rightIconPos, setRightIconPos] = useState(rem(12));
181
+
182
+ const rightAddonRef = useCallback((node: HTMLDivElement | null) => {
183
+ if (node) {
184
+ setRightIconPos(rem(node.getBoundingClientRect().width + 12));
185
+ }
186
+ }, []);
187
+
172
188
  return (
173
189
  <FormControl {...formControlProps}>
174
190
  <FormLabel
@@ -182,9 +198,9 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
182
198
  {label}
183
199
  </FormLabel>
184
200
  <InputGroup sx={style.inputContainer} {...inputWrapperStyle}>
185
- {leftAddon && <LeftContentWrapper>{leftAddon}</LeftContentWrapper>}
186
- {!leftAddon && leftIconName && (
187
- <InputLeftElement sx={style.leftIconWrapper}>
201
+ {leftAddon && <LeftContentWrapper ref={leftAddonRef}>{leftAddon}</LeftContentWrapper>}
202
+ {leftIconName && (
203
+ <InputLeftElement sx={style.leftIconWrapper} left={leftIconPos}>
188
204
  <Icon
189
205
  color={leftIconColor}
190
206
  name={leftIconName}
@@ -201,9 +217,13 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
201
217
  {...dataAttributes}
202
218
  onChange={onInputChange}
203
219
  />
204
- {rightAddon && <RightContentWrapper bottom="0">{rightAddon}</RightContentWrapper>}
205
- {!rightAddon && (rightIconName || isWarning || warningText || isInvalid) && (
206
- <InputRightElement sx={style.rightIconWrapper}>
220
+ {rightAddon && (
221
+ <RightContentWrapper ref={rightAddonRef} bottom="0">
222
+ {rightAddon}
223
+ </RightContentWrapper>
224
+ )}
225
+ {(rightIconName || isWarning || warningText || isInvalid) && (
226
+ <InputRightElement sx={style.rightIconWrapper} right={rightIconPos}>
207
227
  {rightIconName && !isWarning && !warningText && !isInvalid && (
208
228
  <Icon
209
229
  color={rightIconColor}