@bitrise/bitkit 13.150.0 → 13.150.1-alpha.11

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.150.0",
4
+ "version": "13.150.1-alpha.11",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -14,12 +14,12 @@ import {
14
14
  FormControl,
15
15
  FormErrorMessage,
16
16
  FormHelperText,
17
- FormLabel,
18
17
  useControllableState,
19
18
  useMultiStyleConfig,
20
19
  } from '@chakra-ui/react';
21
20
  import { FloatingFocusManager } from '@floating-ui/react-dom-interactions';
22
21
  import SearchInput from '../SearchInput/SearchInput';
22
+ import FormLabel from '../Form/FormLabel';
23
23
  import { DropdownEventArgs, DropdownProvider, useDropdownContext, useDropdownStyles } from './Dropdown.context';
24
24
  import { DropdownDetailedOption, DropdownGroup, DropdownOption, DropdownOptionProps } from './DropdownOption';
25
25
  import DropdownButton from './DropdownButton';
@@ -260,6 +260,8 @@ const Dropdown = forwardRef<Element, DropdownProps<string | null>>(
260
260
  formLabel: customFormLabel,
261
261
  helperText,
262
262
  iconName,
263
+ infoText,
264
+ infoTooltipProps,
263
265
  isError,
264
266
  isWarning,
265
267
  label,
@@ -335,12 +337,10 @@ const Dropdown = forwardRef<Element, DropdownProps<string | null>>(
335
337
  <>
336
338
  {name && formValue && <input name={name} type="hidden" value={formValue} />}
337
339
  <DropdownProvider context={dropdownCtx} styles={dropdownStyles}>
338
- <FormControl {...props} isDisabled={disabled} isInvalid={isError}>
339
- {label && (
340
- <FormLabel htmlFor={buttonId} marginBlockEnd="4">
341
- {label}
342
- </FormLabel>
343
- )}
340
+ <FormControl {...props} isDisabled={disabled} isInvalid={isError} isRequired>
341
+ <FormLabel infoText={infoText} infoTooltipProps={infoTooltipProps} htmlFor={buttonId}>
342
+ {label}
343
+ </FormLabel>
344
344
  <DropdownButton
345
345
  {...referenceProps}
346
346
  {...buttonProps}
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { ChakraProps } from '@chakra-ui/react';
3
3
  import { UseFloatingProps } from '@floating-ui/react-dom-interactions';
4
4
  import { TypeIconName } from '../Icon/Icon';
5
+ import { TooltipProps } from '../Tooltip/Tooltip';
5
6
 
6
7
  type DropdownInstance<T> = { value: T; name?: string };
7
8
 
@@ -22,9 +23,11 @@ export interface DropdownProps<T> extends ChakraProps {
22
23
  helperText?: ReactNode;
23
24
  iconName?: TypeIconName;
24
25
  id?: string;
26
+ infoText?: string;
27
+ infoTooltipProps?: TooltipProps;
25
28
  isError?: boolean;
26
29
  isWarning?: boolean;
27
- label?: ReactNode;
30
+ label?: string;
28
31
  name?: string;
29
32
  onBlur?: DropdownChangeEventHandler<T>;
30
33
  onChange?: DropdownChangeEventHandler<T>;
@@ -0,0 +1,58 @@
1
+ import { FormLabelProps as ChakraFormLabelProps, FormLabel as ChakraFormLabel, forwardRef } from '@chakra-ui/react';
2
+ import Text from '../Text/Text';
3
+ import Tooltip, { TooltipProps } from '../Tooltip/Tooltip';
4
+ import Box from '../Box/Box';
5
+ import Icon from '../Icon/Icon';
6
+
7
+ export interface FormLabelProps extends ChakraFormLabelProps {
8
+ children?: string;
9
+ infoText?: string;
10
+ infoTooltipProps?: TooltipProps;
11
+ maxLength?: number;
12
+ valueLength?: number;
13
+ withCounter?: boolean;
14
+ }
15
+
16
+ const FormLabel = forwardRef<FormLabelProps, 'label'>((props, ref) => {
17
+ const { infoText, infoTooltipProps, maxLength, valueLength, withCounter, ...rest } = props;
18
+
19
+ const showLabel = rest.children || !!infoText || (withCounter && maxLength);
20
+
21
+ if (!showLabel) {
22
+ return null;
23
+ }
24
+
25
+ return (
26
+ <Box alignItems="center" display="flex" gap="4" marginBlockEnd="4">
27
+ <ChakraFormLabel
28
+ optionalIndicator={
29
+ <Text as="span" color="text/secondary" fontSize="2" fontWeight="normal" marginInlineStart="4">
30
+ (optional)
31
+ </Text>
32
+ }
33
+ requiredIndicator={null}
34
+ {...rest}
35
+ ref={ref}
36
+ />
37
+
38
+ {!!infoText && (
39
+ <Tooltip label={infoText} placement="right" {...infoTooltipProps}>
40
+ <Icon color="icon/tertiary" name="Info" size="16" />
41
+ </Tooltip>
42
+ )}
43
+ {withCounter && maxLength && (
44
+ <Text
45
+ as="span"
46
+ color="text/secondary"
47
+ marginInlineStart="auto"
48
+ size="2"
49
+ sx={{ fontVariantNumeric: 'tabular-nums' }}
50
+ >
51
+ {valueLength}/{maxLength}
52
+ </Text>
53
+ )}
54
+ </Box>
55
+ );
56
+ });
57
+
58
+ export default FormLabel;
@@ -4,7 +4,6 @@ import {
4
4
  FormControlProps,
5
5
  FormErrorMessage,
6
6
  FormHelperText,
7
- FormLabel,
8
7
  forwardRef,
9
8
  Input as ChakraInput,
10
9
  InputLeftElement,
@@ -19,9 +18,8 @@ import {
19
18
  BoxProps,
20
19
  } from '@chakra-ui/react';
21
20
  import Icon, { TypeIconName } from '../../Icon/Icon';
22
- import Text from '../../Text/Text';
23
- import Box from '../../Box/Box';
24
- import Tooltip, { TooltipProps } from '../../Tooltip/Tooltip';
21
+ import { TooltipProps } from '../../Tooltip/Tooltip';
22
+ import FormLabel from '../FormLabel';
25
23
 
26
24
  type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
27
25
  type UsedChakraInputProps = Pick<
@@ -53,7 +51,7 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
53
51
  inputRef?: Ref<HTMLInputElement>;
54
52
  inputStyle?: SystemStyleObject;
55
53
  inputWrapperStyle?: BoxProps;
56
- label?: ReactNode;
54
+ label?: string;
57
55
  leftAddon?: ReactNode;
58
56
  leftAddonPlacement?: 'inside' | 'outside';
59
57
  leftIconColor?: IconProps['color'];
@@ -161,45 +159,20 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
161
159
  }
162
160
  };
163
161
 
164
- const showLabel = label || !!infoText || (withCounter && maxLength);
165
-
166
162
  const iconSize = size === 'lg' ? '24' : '16';
167
163
  const style = useMultiStyleConfig('Input');
168
164
 
169
165
  return (
170
166
  <FormControl {...formControlProps}>
171
- <Box alignItems="center" display={showLabel ? 'flex' : 'none'} gap="4" marginBlockEnd="4">
172
- {label && (
173
- <FormLabel
174
- optionalIndicator={
175
- <Text as="span" color="text.secondary" fontSize="2" fontWeight="normal" marginLeft="4">
176
- (Optional)
177
- </Text>
178
- }
179
- requiredIndicator={null}
180
- >
181
- {label}
182
- </FormLabel>
183
- )}
184
- {!!infoText && (
185
- <Tooltip label={infoText} placement="right" {...infoTooltipProps}>
186
- <Icon color="icon.tertiary" name="Info" size="16" />
187
- </Tooltip>
188
- )}
189
-
190
- {withCounter && maxLength && (
191
- <Text
192
- as="span"
193
- color="text.secondary"
194
- marginInlineStart="auto"
195
- size="2"
196
- sx={{ fontVariantNumeric: 'tabular-nums' }}
197
- >
198
- {valueLength}/{maxLength}
199
- </Text>
200
- )}
201
- </Box>
202
-
167
+ <FormLabel
168
+ infoText={infoText}
169
+ infoTooltipProps={infoTooltipProps}
170
+ maxLength={maxLength}
171
+ valueLength={valueLength}
172
+ withCounter={withCounter}
173
+ >
174
+ {label}
175
+ </FormLabel>
203
176
  <InputGroup sx={style.inputContainer} {...inputWrapperStyle}>
204
177
  {leftAddon && <LeftContentWrapper>{leftAddon}</LeftContentWrapper>}
205
178
  {!leftAddon && leftIconName && (
@@ -5,13 +5,14 @@ import {
5
5
  FormControlProps,
6
6
  FormErrorMessage,
7
7
  FormHelperText,
8
- FormLabel,
9
8
  useStyleConfig,
10
9
  } from '@chakra-ui/react';
11
10
  import Icon from '../../Icon/Icon';
12
11
  import Box from '../../Box/Box';
13
12
  import Tag from '../../Tag/Tag';
14
13
  import Text from '../../Text/Text';
14
+ import FormLabel from '../FormLabel';
15
+ import { TooltipProps } from '../../Tooltip/Tooltip';
15
16
 
16
17
  type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
17
18
  export interface TagsInputProps extends UsedFormControlProps {
@@ -26,11 +27,15 @@ export interface TagsInputProps extends UsedFormControlProps {
26
27
  errorText?: ReactNode;
27
28
  helperText?: ReactNode;
28
29
  isReadOnly?: boolean;
30
+ infoText?: string;
31
+ infoTooltipProps?: TooltipProps;
29
32
  }
30
33
 
31
34
  const TagsInput = ({
32
35
  errorText,
33
36
  helperText,
37
+ infoText,
38
+ infoTooltipProps,
34
39
  invalidValues = [],
35
40
  isReadOnly,
36
41
  label,
@@ -78,19 +83,9 @@ const TagsInput = ({
78
83
  return (
79
84
  <FormControl {...rest} isInvalid={isInvalid} isReadOnly={isReadOnly}>
80
85
  <Box alignItems="center" display={label || maxCount ? 'flex' : 'none'} gap="4" marginBlockEnd="4">
81
- {label && (
82
- <FormLabel
83
- htmlFor={id}
84
- optionalIndicator={
85
- <Text as="span" color="neutral.40" fontSize="2" fontWeight="normal" marginLeft="4px">
86
- (Optional)
87
- </Text>
88
- }
89
- requiredIndicator={false}
90
- >
91
- {label}
92
- </FormLabel>
93
- )}
86
+ <FormLabel infoText={infoText} infoTooltipProps={infoTooltipProps} htmlFor={id}>
87
+ {label}
88
+ </FormLabel>
94
89
 
95
90
  {maxCount && (
96
91
  <Text
@@ -1,18 +1,15 @@
1
- import { ChangeEvent, ReactNode, useState } from 'react';
1
+ import { ChangeEvent, useState } from 'react';
2
2
  import {
3
3
  FormControl,
4
4
  FormControlProps,
5
5
  FormErrorMessage,
6
6
  FormHelperText,
7
- FormLabel,
8
7
  forwardRef,
9
8
  Textarea as ChakraTextarea,
10
9
  TextareaProps as ChakraTextareaProps,
11
10
  } from '@chakra-ui/react';
12
- import Text from '../../Text/Text';
13
- import Box from '../../Box/Box';
14
- import Icon from '../../Icon/Icon';
15
- import Tooltip, { TooltipProps } from '../../Tooltip/Tooltip';
11
+ import { TooltipProps } from '../../Tooltip/Tooltip';
12
+ import FormLabel, { FormLabelProps } from '../FormLabel';
16
13
 
17
14
  type UsedFormControlProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'>;
18
15
  type UsedChakraTextProps = Pick<
@@ -36,7 +33,7 @@ export interface TextareaProps extends UsedFormControlProps, UsedChakraTextProps
36
33
  infoTooltipProps?: TooltipProps;
37
34
  isLoading?: boolean;
38
35
  helperText?: string;
39
- label?: ReactNode;
36
+ label?: FormLabelProps['children'];
40
37
  name?: string;
41
38
  onBlur?: ChakraTextareaProps['onBlur'];
42
39
  onChange?: ChakraTextareaProps['onChange'];
@@ -104,36 +101,15 @@ const Textarea = forwardRef<TextareaProps, 'div'>((props, ref) => {
104
101
 
105
102
  return (
106
103
  <FormControl {...formControlProps}>
107
- {label && (
108
- <Box alignItems="center" display="flex" gap="4" marginBlockEnd="4">
109
- <FormLabel
110
- optionalIndicator={
111
- <Text as="span" color="neutral.40" fontSize="2" fontWeight="normal" marginLeft="4px">
112
- (Optional)
113
- </Text>
114
- }
115
- requiredIndicator={null}
116
- >
117
- {label}
118
- </FormLabel>
119
- {!!infoText && (
120
- <Tooltip label={infoText} placement="right" {...infoTooltipProps}>
121
- <Icon color="neutral.50" name="Info" size="16" />
122
- </Tooltip>
123
- )}
124
- {withCounter && maxLength && (
125
- <Text
126
- as="span"
127
- color="neutral.40"
128
- marginInlineStart="auto"
129
- size="2"
130
- sx={{ fontVariantNumeric: 'tabular-nums' }}
131
- >
132
- {valueLength}/{maxLength}
133
- </Text>
134
- )}
135
- </Box>
136
- )}
104
+ <FormLabel
105
+ infoText={infoText}
106
+ infoTooltipProps={infoTooltipProps}
107
+ maxLength={maxLength}
108
+ valueLength={valueLength}
109
+ withCounter={withCounter}
110
+ >
111
+ {label}
112
+ </FormLabel>
137
113
 
138
114
  <ChakraTextarea {...textareaProps} onChange={onTextareaChange} />
139
115
  {errorText && <FormErrorMessage as="p">{errorText}</FormErrorMessage>}
@@ -1,27 +1,28 @@
1
- import { ReactNode } from 'react';
2
1
  import {
3
2
  FormControl,
4
3
  FormControlProps,
5
4
  FormErrorMessage,
6
5
  FormHelperText,
7
- FormLabel,
8
6
  forwardRef,
9
7
  Select as ChakraSelect,
10
8
  SelectProps as ChakraSelectProps,
11
9
  useMultiStyleConfig,
12
10
  } from '@chakra-ui/react';
13
11
  import Box from '../Box/Box';
14
- import Text from '../Text/Text';
15
12
  import Icon from '../Icon/Icon';
16
13
  import ProgressSpinner from '../ProgressSpinner/ProgressSpinner';
14
+ import FormLabel from '../Form/FormLabel';
15
+ import { TooltipProps } from '../Tooltip/Tooltip';
17
16
 
18
17
  export interface SelectProps extends Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> {
19
18
  'data-testid'?: string;
20
19
  errorText?: string;
21
20
  helperText?: string;
21
+ infoText?: string;
22
+ infoTooltipProps?: TooltipProps;
22
23
  isLoading?: boolean;
23
24
  isWarning?: boolean;
24
- label?: ReactNode;
25
+ label?: string;
25
26
  name?: string;
26
27
  onBlur?: ChakraSelectProps['onBlur'];
27
28
  onChange?: ChakraSelectProps['onChange'];
@@ -37,6 +38,8 @@ const Select = forwardRef<SelectProps, 'div'>((props, ref) => {
37
38
  defaultValue,
38
39
  errorText,
39
40
  helperText,
41
+ infoText,
42
+ infoTooltipProps,
40
43
  isDisabled,
41
44
  isInvalid,
42
45
  isLoading,
@@ -84,19 +87,9 @@ const Select = forwardRef<SelectProps, 'div'>((props, ref) => {
84
87
 
85
88
  return (
86
89
  <FormControl {...formControlProps}>
87
- {label && (
88
- <FormLabel
89
- marginBlockEnd="4"
90
- optionalIndicator={
91
- <Text as="span" color="neutral.40" fontSize="2" fontWeight="normal" marginLeft="4px">
92
- (Optional)
93
- </Text>
94
- }
95
- requiredIndicator={null}
96
- >
97
- {label}
98
- </FormLabel>
99
- )}
90
+ <FormLabel infoText={infoText} infoTooltipProps={infoTooltipProps}>
91
+ {label}
92
+ </FormLabel>
100
93
  <Box sx={style.selectContainer}>
101
94
  <ChakraSelect ref={ref} data-testid={dataTestid} {...selectProperties} sx={style.field}>
102
95
  {placeholder && (