@swan-io/lake 12.3.0 → 12.4.1
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
package/src/components/Icon.d.ts
CHANGED
|
@@ -44,8 +44,12 @@ export type VirtualizedListProps<T, ExtraInfo> = {
|
|
|
44
44
|
isLoading: boolean;
|
|
45
45
|
count: number;
|
|
46
46
|
};
|
|
47
|
+
onColumnResize?: (values: {
|
|
48
|
+
id: string;
|
|
49
|
+
width: number;
|
|
50
|
+
}) => void;
|
|
47
51
|
};
|
|
48
|
-
export declare const VirtualizedList: <T, ExtraInfo>({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold, onEndReached, onEndReachedThreshold, loading, extraInfo, keyExtractor, marginHorizontal, renderEmptyList, getRowLink, }: VirtualizedListProps<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare const VirtualizedList: <T, ExtraInfo>({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold, onEndReached, onEndReachedThreshold, loading, extraInfo, keyExtractor, marginHorizontal, renderEmptyList, onColumnResize, getRowLink, }: VirtualizedListProps<T, ExtraInfo>) => import("react/jsx-runtime").JSX.Element;
|
|
49
53
|
type VirtualizedListPlaceholderProps = {
|
|
50
54
|
count: number;
|
|
51
55
|
rowHeight: number;
|
|
@@ -5,6 +5,7 @@ import { StyleSheet, View } from "react-native";
|
|
|
5
5
|
import { commonStyles } from "../constants/commonStyles";
|
|
6
6
|
import { backgroundColor as backgroundColorVariants, colors, spacings } from "../constants/design";
|
|
7
7
|
import { useHover } from "../hooks/useHover";
|
|
8
|
+
import { Pressable } from "./Pressable";
|
|
8
9
|
import { ScrollView } from "./ScrollView";
|
|
9
10
|
import { Space } from "./Space";
|
|
10
11
|
const HORIZONTAL_ROW_PADDING = 16;
|
|
@@ -164,8 +165,108 @@ const styles = StyleSheet.create({
|
|
|
164
165
|
smallPlaceholderRow: {
|
|
165
166
|
width: "10%",
|
|
166
167
|
},
|
|
168
|
+
resizeHandleZone: {
|
|
169
|
+
position: "absolute",
|
|
170
|
+
cursor: "ew-resize",
|
|
171
|
+
top: 0,
|
|
172
|
+
bottom: 0,
|
|
173
|
+
width: spacings[24],
|
|
174
|
+
},
|
|
175
|
+
resizeHandleZoneStart: {
|
|
176
|
+
right: 0,
|
|
177
|
+
alignItems: "flex-end",
|
|
178
|
+
},
|
|
179
|
+
resizeHandleZoneEnd: {
|
|
180
|
+
right: "auto",
|
|
181
|
+
left: 0,
|
|
182
|
+
alignItems: "flex-start",
|
|
183
|
+
},
|
|
184
|
+
resizeHandleLeft: {
|
|
185
|
+
right: "auto",
|
|
186
|
+
left: 0,
|
|
187
|
+
},
|
|
188
|
+
resizeHandle: {
|
|
189
|
+
backgroundColor: colors.gray[200],
|
|
190
|
+
height: "100%",
|
|
191
|
+
opacity: 0,
|
|
192
|
+
transitionDuration: "200ms",
|
|
193
|
+
transitionProperty: "opacity",
|
|
194
|
+
width: 3,
|
|
195
|
+
},
|
|
196
|
+
resizeHandleActive: {
|
|
197
|
+
opacity: 1,
|
|
198
|
+
},
|
|
167
199
|
});
|
|
168
|
-
|
|
200
|
+
const ResizeHandle = ({ id, end = false, width, onResize, scrollViewRef }) => {
|
|
201
|
+
const ref = useRef(null);
|
|
202
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
203
|
+
const widthRef = useRef(width);
|
|
204
|
+
const onResizeRef = useRef(onResize);
|
|
205
|
+
useLayoutEffect(() => {
|
|
206
|
+
widthRef.current = width;
|
|
207
|
+
onResizeRef.current = onResize;
|
|
208
|
+
}, [width, onResize]);
|
|
209
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies(scrollViewRef.current.element.style): _
|
|
210
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies(scrollViewRef.current?.element): _
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
const element = ref.current;
|
|
213
|
+
if (element != null) {
|
|
214
|
+
let startX = null;
|
|
215
|
+
let startWidth = null;
|
|
216
|
+
const onMouseMove = (event) => {
|
|
217
|
+
var _a;
|
|
218
|
+
if (startX != null && startWidth != null) {
|
|
219
|
+
(_a = onResizeRef.current) === null || _a === void 0 ? void 0 : _a.call(onResizeRef, {
|
|
220
|
+
id,
|
|
221
|
+
width: Math.max(24, startWidth + (event.clientX - startX) * (end ? -1 : 1)),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const onMouseUp = (event) => {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
if (((_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.element) != null) {
|
|
228
|
+
scrollViewRef.current.element.style.webkitUserSelect = "";
|
|
229
|
+
}
|
|
230
|
+
if (startX != null && startWidth != null) {
|
|
231
|
+
(_b = onResizeRef.current) === null || _b === void 0 ? void 0 : _b.call(onResizeRef, {
|
|
232
|
+
id,
|
|
233
|
+
width: Math.max(24, startWidth + (event.clientX - startX) * (end ? -1 : 1)),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
startX = null;
|
|
237
|
+
document.documentElement.removeEventListener("mousemove", onMouseMove);
|
|
238
|
+
setIsDragging(false);
|
|
239
|
+
};
|
|
240
|
+
const onMouseDown = (event) => {
|
|
241
|
+
var _a;
|
|
242
|
+
if (((_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.element) != null) {
|
|
243
|
+
scrollViewRef.current.element.style.webkitUserSelect = "none";
|
|
244
|
+
}
|
|
245
|
+
startX = event.clientX;
|
|
246
|
+
startWidth = widthRef.current;
|
|
247
|
+
document.documentElement.addEventListener("mousemove", onMouseMove);
|
|
248
|
+
document.documentElement.addEventListener("mouseup", onMouseUp);
|
|
249
|
+
setIsDragging(true);
|
|
250
|
+
};
|
|
251
|
+
element.addEventListener("mousedown", onMouseDown);
|
|
252
|
+
return () => {
|
|
253
|
+
var _a;
|
|
254
|
+
if (((_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.element) != null) {
|
|
255
|
+
scrollViewRef.current.element.style.webkitUserSelect = "";
|
|
256
|
+
}
|
|
257
|
+
setIsDragging(false);
|
|
258
|
+
element.removeEventListener("mousedown", onMouseDown);
|
|
259
|
+
document.documentElement.removeEventListener("mousemove", onMouseMove);
|
|
260
|
+
document.documentElement.removeEventListener("mouseup", onMouseUp);
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}, [id, end]);
|
|
264
|
+
return (_jsx(Pressable, { ref: ref, role: "none", style: [
|
|
265
|
+
styles.resizeHandleZone,
|
|
266
|
+
end ? styles.resizeHandleZoneEnd : styles.resizeHandleZoneStart,
|
|
267
|
+
], children: ({ hovered }) => (_jsx(View, { style: [styles.resizeHandle, (hovered || isDragging) && styles.resizeHandleActive] })) }));
|
|
268
|
+
};
|
|
269
|
+
export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns, stickedToEndColumns, headerHeight, rowHeight, renderThreshold = 1000, onEndReached, onEndReachedThreshold = 200, loading, extraInfo, keyExtractor, marginHorizontal, renderEmptyList, onColumnResize, getRowLink, }) => {
|
|
169
270
|
// Used for unique IDs generation (usefull for header IDs and cells aria-describedBy pointing to them)
|
|
170
271
|
const viewId = useId();
|
|
171
272
|
const scrollViewRef = useRef(null);
|
|
@@ -301,7 +402,7 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
|
|
|
301
402
|
], children: columns.map(({ id, width, title, renderTitle }, index) => {
|
|
302
403
|
const columnId = `${viewId}_${id}`;
|
|
303
404
|
const paddingLeft = index === 0 ? stickedToStartFirstCellLeftPadding : 0;
|
|
304
|
-
return (
|
|
405
|
+
return (_jsxs(View, { style: [styles.headerCell, { width: width + paddingLeft, paddingLeft }], id: columnId, children: [renderTitle({ title, extraInfo, id }), _jsx(ResizeHandle, { width: width, id: id, onResize: onColumnResize, scrollViewRef: scrollViewRef })] }, columnId));
|
|
305
406
|
}) })))
|
|
306
407
|
.toNull(), _jsx(View, { style: [
|
|
307
408
|
styles.cellsContainer,
|
|
@@ -311,11 +412,11 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
|
|
|
311
412
|
const columnId = `${viewId}_${id}`;
|
|
312
413
|
const paddingLeft = index === 0 ? centerFirstCellLeftPadding : 0;
|
|
313
414
|
const paddingRight = index === columns.length - 1 ? centerLastCellLeftPadding : 0;
|
|
314
|
-
return (
|
|
415
|
+
return (_jsxs(View, { style: [
|
|
315
416
|
styles.headerCell,
|
|
316
417
|
grow && styles.grow,
|
|
317
418
|
{ width: width + paddingLeft + paddingRight, paddingLeft, paddingRight },
|
|
318
|
-
], id: columnId, children: renderTitle({ title, extraInfo, id }) }, columnId));
|
|
419
|
+
], id: columnId, children: [renderTitle({ title, extraInfo, id }), _jsx(ResizeHandle, { width: width, id: id, onResize: onColumnResize, scrollViewRef: scrollViewRef })] }, columnId));
|
|
319
420
|
}) }), Option.fromNullable(stickedToEndColumns)
|
|
320
421
|
.map(columns => (_jsx(View, { style: [
|
|
321
422
|
styles.cellsContainer,
|
|
@@ -325,7 +426,7 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
|
|
|
325
426
|
], children: columns.map(({ id, width, title, renderTitle }, index) => {
|
|
326
427
|
const columnId = `${viewId}_${id}`;
|
|
327
428
|
const paddingRight = index === columns.length - 1 ? stickedToEndLastCellRightPadding : 0;
|
|
328
|
-
return (
|
|
429
|
+
return (_jsxs(View, { style: [styles.headerCell, { width: width + paddingRight, paddingRight }], id: columnId, children: [renderTitle({ title, extraInfo, id }), _jsx(ResizeHandle, { end: true, width: width, id: id, onResize: onColumnResize, scrollViewRef: scrollViewRef })] }, columnId));
|
|
329
430
|
}) })))
|
|
330
431
|
.toNull()] }));
|
|
331
432
|
}, [
|
|
@@ -344,6 +445,7 @@ export const VirtualizedList = ({ variant, data, stickedToStartColumns, columns,
|
|
|
344
445
|
centerFirstCellLeftPadding,
|
|
345
446
|
centerLastCellLeftPadding,
|
|
346
447
|
stickedToEndLastCellRightPadding,
|
|
448
|
+
onColumnResize,
|
|
347
449
|
]);
|
|
348
450
|
const startColumnShadow = useMemo(() => {
|
|
349
451
|
if (stickedToStartColumnsWidth === 0) {
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"form-new-filled": "M7.5 10.75a.75.75 0 1 1 1.5 0 .75.75 0 0 1-1.5 0Zm.75 4.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM3 6.25C3 4.45 4.46 3 6.25 3h11.5C19.55 3 21 4.46 21 6.25v5.77a6.46 6.46 0 0 0-3.05-1 .75.75 0 0 0-.7-1.02h-4.5a.75.75 0 0 0 0 1.5H15a6.5 6.5 0 0 0-2.98 9.5H6.25A3.25 3.25 0 0 1 3 17.75V6.25Zm3 4.5a2.25 2.25 0 1 0 4.5 0 2.25 2.25 0 0 0-4.5 0ZM8.25 14a2.25 2.25 0 1 0 0 4.5 2.25 2.25 0 0 0 0-4.5ZM6 6.25c0 .41.34.75.75.75h10.5a.75.75 0 0 0 0-1.5H6.75a.75.75 0 0 0-.75.75ZM23 17.5a5.5 5.5 0 1 0-11 0 5.5 5.5 0 0 0 11 0Zm-5 .5v2.5a.5.5 0 1 1-1 0V18h-2.5a.5.5 0 0 1 0-1H17v-2.5a.5.5 0 1 1 1 0V17h2.5a.5.5 0 0 1 0 1H18Z",
|
|
102
102
|
"form-new-regular": "M6.25 3A3.25 3.25 0 0 0 3 6.25v11.5C3 19.55 4.46 21 6.25 21h5.77c-.3-.46-.53-.97-.7-1.5H6.24c-.97 0-1.75-.78-1.75-1.75V6.25c0-.97.78-1.75 1.75-1.75h11.5c.97 0 1.75.78 1.75 1.75v5.06c.53.18 1.04.42 1.5.71V6.25C21 4.45 19.54 3 17.75 3H6.25Zm11.25 8c.15 0 .3 0 .45.02a.75.75 0 0 0-.7-1.02h-4.5a.75.75 0 0 0 0 1.5H15c.77-.32 1.61-.5 2.5-.5ZM6.75 6a.75.75 0 0 0 0 1.5h10.5a.75.75 0 0 0 0-1.5H6.75ZM6 10.75a2.25 2.25 0 1 1 4.5 0 2.25 2.25 0 0 1-4.5 0ZM8.25 10a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 4a2.25 2.25 0 1 0 0 4.5 2.25 2.25 0 0 0 0-4.5Zm-.75 2.25a.75.75 0 1 1 1.5 0 .75.75 0 0 1-1.5 0ZM23 17.5a5.5 5.5 0 1 0-11 0 5.5 5.5 0 0 0 11 0Zm-5 .5v2.5a.5.5 0 1 1-1 0V18h-2.5a.5.5 0 0 1 0-1H17v-2.5a.5.5 0 1 1 1 0V17h2.5a.5.5 0 0 1 0 1H18Z",
|
|
103
103
|
"gavel-regular": "M14.14 2.98a2.25 2.25 0 0 0-3.41-.27L7.26 6.18c-1 1-.83 2.67.35 3.46l2 1.34-6.87 6.74a2.5 2.5 0 1 0 3.53 3.57l6.88-6.88 1.21 1.92a2.25 2.25 0 0 0 3.5.38l3.43-3.44c.98-.98.85-2.6-.27-3.4l-3.89-2.84a.75.75 0 0 1-.16-.16l-2.83-3.9Zm-2.35.8a.75.75 0 0 1 1.14.08l.46.63-4.32 4.32-.63-.42a.75.75 0 0 1-.12-1.15l3.47-3.47Zm-1.45 5.88 3.94-3.94 1.47 2.03c.14.2.31.36.5.5l1.96 1.42-3.85 3.85-1.06-1.65a2.25 2.25 0 0 0-.65-.67l-2.3-1.54Zm4.84 5.16 4.26-4.26.7.51c.37.28.41.82.09 1.14l-3.44 3.44a.75.75 0 0 1-1.16-.13l-.45-.7Zm-2.86-1.7-7.1 7.1a1 1 0 1 1-1.43-1.43l7.1-6.96.93.62c.09.06.16.13.22.22l.28.45ZM14.75 19a.75.75 0 0 0 0 1.5h-2a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-2a.75.75 0 0 0 0-1.5h-4.5Z",
|
|
104
|
+
"gift-regular": "M14.5 2a3.25 3.25 0 0 1 2.74 5h2.51c.69 0 1.25.56 1.25 1.25v3.5c0 .6-.43 1.1-1 1.22v5.78a3.25 3.25 0 0 1-3.07 3.24l-.18.01h-9.5a3.25 3.25 0 0 1-3.24-3.07L4 18.75v-5.78c-.57-.11-1-.62-1-1.22v-3.5C3 7.56 3.56 7 4.25 7h2.51A3.25 3.25 0 0 1 12 3.17C12.6 2.46 13.5 2 14.5 2Zm-3.25 11H5.5v5.75c0 .92.7 1.67 1.6 1.74l.15.01h4V13Zm7.25 0h-5.75v7.5h4c.92 0 1.67-.7 1.74-1.6l.01-.15V13Zm-7.25-4.5H4.5v3h6.75v-3Zm8.25 3v-3h-6.75v3h6.75Zm-5-8c-.97 0-1.75.78-1.75 1.75V7H14.64a1.75 1.75 0 0 0-.14-3.5Zm-5 0A1.75 1.75 0 0 0 9.36 7H11.25V5.1c-.08-.9-.83-1.61-1.75-1.61Z",
|
|
104
105
|
"hand-right-regular": "M12 4v6.25a.75.75 0 0 0 1.5 0V5.22c0-.24.2-.47.5-.48.26 0 .5.25.5.5v7.5a.75.75 0 0 0 1.3.52 2.23 2.23 0 0 1 .12-.12c.1-.08.23-.2.4-.32.36-.25.81-.5 1.3-.58.54-.1 1.05-.04 1.4.14.2.1.36.26.44.53l-1.66 1.24a.76.76 0 0 0-.08.07l-2.18 2.17c-.93.94-1.7 2.02-2.3 3.2-.28.56-.85.91-1.47.91H9.04a1.5 1.5 0 0 1-1.33-.71C6.98 18.53 6 16.5 6 14.75V7c0-.27.22-.5.5-.5.29 0 .5.23.5.5v3.5a.75.75 0 0 0 1.5 0V5.25c0-.28.22-.5.5-.5.29 0 .5.22.5.5v5a.75.75 0 0 0 1.5 0V4c0-.28.21-.5.5-.5.29 0 .5.22.5.5Zm1.99-.76c-.21 0-.42.04-.6.1Zm-.6.1A1.98 1.98 0 0 0 11.49 2c-.9 0-1.61.58-1.88 1.34a2 2 0 0 0-2.6 1.73A2 2 0 0 0 4.5 7v7.74c0 2.18 1.17 4.51 1.92 5.8A3 3 0 0 0 9.04 22h2.73c1.19 0 2.28-.67 2.81-1.74.52-1.04 1.2-1.98 2.02-2.8l2.14-2.14 1.96-1.47c.19-.14.3-.37.3-.6 0-1.06-.53-1.8-1.3-2.2a3.76 3.76 0 0 0-2.33-.29c-.52.1-.99.29-1.37.5V5.25c0-1.06-.89-2.01-2.01-2",
|
|
105
106
|
"heart-pulse-regular": "M12.82 5.58 12 6.4l-.82-.82A5.37 5.37 0 0 0 2.25 11h1.6a3.88 3.88 0 0 1 6.27-4.36L11.47 8c.3.3.79.29 1.08-.02l1.33-1.34A3.88 3.88 0 0 1 20.15 11h1.6a5.37 5.37 0 0 0-8.93-5.42Zm-1.35 15.5L4.89 14.5h2.12L12 19.47l4.99-4.98h2.12l-6.58 6.58c-.3.29-.77.29-1.06 0ZM9.42 8.4a.75.75 0 0 0-1.35.02L6.38 12H2.75a.75.75 0 0 0 0 1.5h4.1c.3 0 .56-.17.69-.43l1.23-2.6 2.56 5.11a.75.75 0 0 0 1.28.1l2.7-3.73 1.13 1.3c.14.16.34.25.56.25h4.25a.75.75 0 0 0 0-1.5h-3.91l-1.53-1.74a.75.75 0 0 0-1.17.05l-2.52 3.5-2.7-5.4Z",
|
|
106
107
|
"home-person-regular": "M13.45 2.53c-.84-.7-2.06-.7-2.9 0L3.8 8.23c-.5.42-.8 1.05-.8 1.71v9.31c0 .97.78 1.75 1.75 1.75h3.5c.97 0 1.75-.78 1.75-1.75v-5c0-.14.11-.25.25-.25h3.5c.14 0 .25.1.25.25v3.39c.41-.34.93-.57 1.5-.63v-.7a3.48 3.48 0 0 1-.29-3.02c-.3-.48-.85-.8-1.46-.8h-3.5c-.97 0-1.75.79-1.75 1.76v5c0 .14-.11.25-.25.25h-3.5a.25.25 0 0 1-.25-.25v-9.3c0-.23.1-.44.27-.58l6.75-5.7a.75.75 0 0 1 .96 0l6.75 5.7c.17.14.27.35.27.57v1.2a3.5 3.5 0 0 1 1.5.91v-2.1c0-.67-.3-1.3-.8-1.73l-6.75-5.69ZM21 14.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm2 5.38c0 1.55-1.29 3.12-4.5 3.12S14 21.44 14 19.87v-.1c0-.98.8-1.77 1.77-1.77h5.46c.98 0 1.77.8 1.77 1.77v.1Z",
|