@bitrise/bitkit 13.269.0 → 13.271.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
|
@@ -9,11 +9,11 @@ const CardTheme = {
|
|
|
9
9
|
_hover:
|
|
10
10
|
as === 'a' || as === 'button' || withHover
|
|
11
11
|
? {
|
|
12
|
-
backgroundColor: '
|
|
13
|
-
borderColor: '
|
|
12
|
+
backgroundColor: 'border/on-contrast',
|
|
13
|
+
borderColor: 'border/regular',
|
|
14
14
|
}
|
|
15
15
|
: undefined,
|
|
16
|
-
backgroundColor: '
|
|
16
|
+
backgroundColor: 'border/inverse',
|
|
17
17
|
border: '1px solid',
|
|
18
18
|
borderRadius: '8',
|
|
19
19
|
display: 'block',
|
|
@@ -22,13 +22,17 @@ const CardTheme = {
|
|
|
22
22
|
},
|
|
23
23
|
variants: {
|
|
24
24
|
elevated: {
|
|
25
|
-
borderColor: '
|
|
25
|
+
borderColor: 'border/minimal',
|
|
26
26
|
boxShadow: 'medium',
|
|
27
27
|
},
|
|
28
28
|
outline: {
|
|
29
|
-
borderColor: '
|
|
29
|
+
borderColor: 'border/regular',
|
|
30
30
|
boxShadow: 'none',
|
|
31
31
|
},
|
|
32
|
+
minElevated: {
|
|
33
|
+
borderColor: 'border/minimal',
|
|
34
|
+
boxShadow: 'small',
|
|
35
|
+
},
|
|
32
36
|
},
|
|
33
37
|
};
|
|
34
38
|
|
|
@@ -146,6 +146,26 @@ function findOption<T>(
|
|
|
146
146
|
return null;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
const DropdownLabelCacheContext = createContext<Map<unknown, ReactNode> | null>(null);
|
|
150
|
+
|
|
151
|
+
const useLabelCache = () => {
|
|
152
|
+
const contextCache = useContext(DropdownLabelCacheContext);
|
|
153
|
+
const localCache = useRef<Map<unknown, ReactNode> | null>(null);
|
|
154
|
+
if (contextCache) {
|
|
155
|
+
return contextCache;
|
|
156
|
+
}
|
|
157
|
+
if (!localCache.current) {
|
|
158
|
+
localCache.current = new Map();
|
|
159
|
+
}
|
|
160
|
+
return localCache.current;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const DropdownLabelCache = ({ children }: { children: ReactNode }) => {
|
|
164
|
+
const value = useMemo(() => new Map(), []);
|
|
165
|
+
|
|
166
|
+
return <DropdownLabelCacheContext.Provider value={value}>{children}</DropdownLabelCacheContext.Provider>;
|
|
167
|
+
};
|
|
168
|
+
|
|
149
169
|
function useDropdown<T>({
|
|
150
170
|
children,
|
|
151
171
|
defaultValue,
|
|
@@ -208,15 +228,13 @@ function useDropdown<T>({
|
|
|
208
228
|
onSearch: () => setActiveIndex(null),
|
|
209
229
|
});
|
|
210
230
|
|
|
211
|
-
|
|
212
|
-
const labelMapRef = useRef<Map<T, ReactNode>>();
|
|
213
|
-
if (!labelMapRef.current) labelMapRef.current = new Map();
|
|
231
|
+
const labelCache = useLabelCache();
|
|
214
232
|
|
|
215
233
|
// clear map when value is changed from the outside
|
|
216
234
|
useEffect(() => {
|
|
217
|
-
if (
|
|
218
|
-
const removed = [...
|
|
219
|
-
removed.forEach((remove) =>
|
|
235
|
+
if (Array.isArray(value)) {
|
|
236
|
+
const removed = [...labelCache.keys()].filter((key) => !value.includes(key));
|
|
237
|
+
removed.forEach((remove) => labelCache.delete(remove));
|
|
220
238
|
}
|
|
221
239
|
}, [value]);
|
|
222
240
|
|
|
@@ -225,10 +243,10 @@ function useDropdown<T>({
|
|
|
225
243
|
setFormValue((previous) => {
|
|
226
244
|
if (Array.isArray(previous)) {
|
|
227
245
|
if (previous.includes(args.value)) {
|
|
228
|
-
|
|
246
|
+
labelCache.delete(args.value);
|
|
229
247
|
return previous.filter((aPrevious) => aPrevious !== args.value) as T;
|
|
230
248
|
}
|
|
231
|
-
|
|
249
|
+
labelCache.set(args.value, args.label);
|
|
232
250
|
|
|
233
251
|
return [...previous, args.value] as T;
|
|
234
252
|
}
|
|
@@ -312,7 +330,7 @@ function useDropdown<T>({
|
|
|
312
330
|
}}
|
|
313
331
|
size="sm"
|
|
314
332
|
>
|
|
315
|
-
{
|
|
333
|
+
{labelCache.get(formValueItem) || formValueItem}
|
|
316
334
|
</Tag>
|
|
317
335
|
);
|
|
318
336
|
})}
|