@bitrise/bitkit 13.211.0 → 13.213.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
|
@@ -41,6 +41,7 @@ type UsedChakraInputProps = Pick<
|
|
|
41
41
|
| 'placeholder'
|
|
42
42
|
| 'step'
|
|
43
43
|
>;
|
|
44
|
+
|
|
44
45
|
export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
|
|
45
46
|
badge?: FormLabelProps['badge'];
|
|
46
47
|
errorText?: ReactNode;
|
|
@@ -57,12 +58,12 @@ export interface InputProps extends UsedFormControlProps, UsedChakraInputProps {
|
|
|
57
58
|
leftAddonPlacement?: 'inside' | 'outside';
|
|
58
59
|
leftIconColor?: IconProps['color'];
|
|
59
60
|
leftIconName?: TypeIconName;
|
|
61
|
+
recommendedLength?: number;
|
|
60
62
|
rightAddon?: ReactNode;
|
|
61
63
|
rightAddonPlacement?: 'inside' | 'outside';
|
|
62
64
|
rightIconName?: TypeIconName;
|
|
63
65
|
rightIconColor?: IconProps['color'];
|
|
64
66
|
size?: 'lg' | 'md';
|
|
65
|
-
withCounter?: boolean;
|
|
66
67
|
warningText?: ReactNode;
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -75,7 +76,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
75
76
|
autoFocus,
|
|
76
77
|
badge,
|
|
77
78
|
defaultValue,
|
|
78
|
-
errorText,
|
|
79
|
+
errorText: errorTextProp,
|
|
79
80
|
helperText,
|
|
80
81
|
infoTooltipLabel,
|
|
81
82
|
infoTooltipProps,
|
|
@@ -100,6 +101,7 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
100
101
|
onChange,
|
|
101
102
|
pattern,
|
|
102
103
|
placeholder,
|
|
104
|
+
recommendedLength,
|
|
103
105
|
rightAddon,
|
|
104
106
|
rightAddonPlacement,
|
|
105
107
|
rightIconName,
|
|
@@ -110,10 +112,15 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
110
112
|
type,
|
|
111
113
|
value,
|
|
112
114
|
warningText,
|
|
113
|
-
withCounter,
|
|
114
115
|
...rest
|
|
115
116
|
} = props;
|
|
116
117
|
|
|
118
|
+
const [valueLength, setValueLength] = useState(value?.toString().length || 0);
|
|
119
|
+
|
|
120
|
+
const exceedsCharacterLimitError =
|
|
121
|
+
recommendedLength && valueLength > recommendedLength ? 'Text exceeds the character limit.' : undefined;
|
|
122
|
+
const errorText = errorTextProp || exceedsCharacterLimitError;
|
|
123
|
+
|
|
117
124
|
const formControlProps = {
|
|
118
125
|
isDisabled: isDisabled || isLoading,
|
|
119
126
|
isInvalid: isInvalid || !!errorText,
|
|
@@ -151,8 +158,6 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
151
158
|
const LeftContentWrapper = leftAddonPlacement === 'inside' ? InputLeftElement : InputLeftAddon;
|
|
152
159
|
const inputLeftPadding = leftIconName || (leftAddon && leftAddonPlacement === 'inside') ? '43px' : inputInlinePadding;
|
|
153
160
|
|
|
154
|
-
const [valueLength, setValueLength] = useState(value?.toString().length || 0);
|
|
155
|
-
|
|
156
161
|
const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
157
162
|
setValueLength(e.currentTarget.value.length);
|
|
158
163
|
|
|
@@ -170,9 +175,9 @@ const Input = forwardRef<InputProps, 'div'>((props, ref) => {
|
|
|
170
175
|
badge={badge}
|
|
171
176
|
infoTooltipLabel={infoTooltipLabel}
|
|
172
177
|
infoTooltipProps={infoTooltipProps}
|
|
173
|
-
maxLength={maxLength}
|
|
178
|
+
maxLength={maxLength || recommendedLength}
|
|
174
179
|
valueLength={valueLength}
|
|
175
|
-
withCounter={
|
|
180
|
+
withCounter={Boolean(maxLength || recommendedLength)}
|
|
176
181
|
>
|
|
177
182
|
{label}
|
|
178
183
|
</FormLabel>
|
|
@@ -2,23 +2,14 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
type UseTabsProps<T> = {
|
|
4
4
|
defaultId?: T;
|
|
5
|
-
|
|
5
|
+
onChange?: (id: T, index: number) => void;
|
|
6
6
|
tabIds: T[];
|
|
7
|
-
withHistory?: boolean;
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
const useTabs = <T extends string>(props: UseTabsProps<T>) => {
|
|
11
|
-
const { defaultId,
|
|
12
|
-
|
|
13
|
-
let searchParams = new URLSearchParams(window.location.search);
|
|
10
|
+
const { defaultId, onChange, tabIds } = props;
|
|
14
11
|
|
|
15
12
|
const defaultIndex = useMemo(() => {
|
|
16
|
-
if (withHistory && searchParams.get(queryKey)) {
|
|
17
|
-
const tabIndex = tabIds.indexOf(searchParams.get(queryKey) as T);
|
|
18
|
-
if (tabIndex !== -1) {
|
|
19
|
-
return tabIndex;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
13
|
if (defaultId) {
|
|
23
14
|
const tabIndex = tabIds.indexOf(defaultId);
|
|
24
15
|
if (tabIndex !== -1) {
|
|
@@ -35,11 +26,9 @@ const useTabs = <T extends string>(props: UseTabsProps<T>) => {
|
|
|
35
26
|
}, []);
|
|
36
27
|
|
|
37
28
|
useEffect(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
searchParams.set(queryKey, queryValue);
|
|
42
|
-
window.parent.history.replaceState(null, '', `?${decodeURIComponent(searchParams.toString())}`);
|
|
29
|
+
if (onChange) {
|
|
30
|
+
const id = tabIds[tabIndex];
|
|
31
|
+
onChange(id, tabIndex);
|
|
43
32
|
}
|
|
44
33
|
}, [tabIndex]);
|
|
45
34
|
|