@bitrise/bitkit 13.274.0 → 13.276.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
|
@@ -146,7 +146,10 @@ function findOption<T>(
|
|
|
146
146
|
return null;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
const DropdownLabelCacheContext = createContext<
|
|
149
|
+
const DropdownLabelCacheContext = createContext<{
|
|
150
|
+
map: Map<unknown, ReactNode>;
|
|
151
|
+
fallback?: (value: unknown) => ReactNode;
|
|
152
|
+
} | null>(null);
|
|
150
153
|
|
|
151
154
|
const useLabelCache = () => {
|
|
152
155
|
const contextCache = useContext(DropdownLabelCacheContext);
|
|
@@ -157,11 +160,18 @@ const useLabelCache = () => {
|
|
|
157
160
|
if (!localCache.current) {
|
|
158
161
|
localCache.current = new Map();
|
|
159
162
|
}
|
|
160
|
-
return localCache.current;
|
|
163
|
+
return { map: localCache.current };
|
|
161
164
|
};
|
|
162
165
|
|
|
163
|
-
export const DropdownLabelCache = ({
|
|
164
|
-
|
|
166
|
+
export const DropdownLabelCache = ({
|
|
167
|
+
children,
|
|
168
|
+
fallback,
|
|
169
|
+
}: {
|
|
170
|
+
children: ReactNode;
|
|
171
|
+
fallback?: (value: unknown) => ReactNode;
|
|
172
|
+
}) => {
|
|
173
|
+
const map = useMemo(() => new Map<unknown, ReactNode>(), []);
|
|
174
|
+
const value = useMemo(() => ({ map, fallback }), [map, fallback]);
|
|
165
175
|
|
|
166
176
|
return <DropdownLabelCacheContext.Provider value={value}>{children}</DropdownLabelCacheContext.Provider>;
|
|
167
177
|
};
|
|
@@ -228,7 +238,7 @@ function useDropdown<T>({
|
|
|
228
238
|
onSearch: () => setActiveIndex(null),
|
|
229
239
|
});
|
|
230
240
|
|
|
231
|
-
const labelCache = useLabelCache();
|
|
241
|
+
const { map: labelCache, fallback } = useLabelCache();
|
|
232
242
|
|
|
233
243
|
// clear map when value is changed from the outside
|
|
234
244
|
useEffect(() => {
|
|
@@ -330,7 +340,7 @@ function useDropdown<T>({
|
|
|
330
340
|
}}
|
|
331
341
|
size="sm"
|
|
332
342
|
>
|
|
333
|
-
{labelCache.get(formValueItem) || formValueItem}
|
|
343
|
+
{labelCache.get(formValueItem) || fallback?.(formValueItem) || formValueItem}
|
|
334
344
|
</Tag>
|
|
335
345
|
);
|
|
336
346
|
})}
|
|
@@ -8,6 +8,7 @@ import Tr, { RowProps } from './Tr';
|
|
|
8
8
|
export interface CheckableRowProps extends RowProps {
|
|
9
9
|
id: string;
|
|
10
10
|
isDisabled?: boolean;
|
|
11
|
+
isReversed?: boolean;
|
|
11
12
|
label: ReactNode;
|
|
12
13
|
name: string;
|
|
13
14
|
tooltipProps?: Omit<TooltipProps, 'children' | 'shouldWrapChildren'>;
|
|
@@ -15,7 +16,7 @@ export interface CheckableRowProps extends RowProps {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const CheckableRow = (props: CheckableRowProps) => {
|
|
18
|
-
const { children, id, isDisabled, label, name, tooltipProps, value, ...rest } = props;
|
|
19
|
+
const { children, id, isDisabled, isReversed, label, name, tooltipProps, value, ...rest } = props;
|
|
19
20
|
|
|
20
21
|
return (
|
|
21
22
|
<Tooltip isDisabled={!tooltipProps} placement="right" {...tooltipProps}>
|
|
@@ -35,15 +36,22 @@ const CheckableRow = (props: CheckableRowProps) => {
|
|
|
35
36
|
transform="scale(1)"
|
|
36
37
|
{...rest}
|
|
37
38
|
>
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
39
|
+
{!isReversed && (
|
|
40
|
+
<Td>
|
|
41
|
+
<Checkbox id={id} isDisabled={isDisabled} name={name} value={value} zIndex="1" />
|
|
42
|
+
</Td>
|
|
43
|
+
)}
|
|
41
44
|
<Td>
|
|
42
45
|
<LinkOverlay as="label" cursor={isDisabled ? 'not-allowed' : 'pointer'} htmlFor={id}>
|
|
43
46
|
{label}
|
|
44
47
|
</LinkOverlay>
|
|
45
48
|
</Td>
|
|
46
49
|
{children}
|
|
50
|
+
{!!isReversed && (
|
|
51
|
+
<Td textAlign="right">
|
|
52
|
+
<Checkbox id={id} isDisabled={isDisabled} name={name} value={value} zIndex="1" />
|
|
53
|
+
</Td>
|
|
54
|
+
)}
|
|
47
55
|
</LinkBox>
|
|
48
56
|
</Tooltip>
|
|
49
57
|
);
|