@pk-design/react-tailwind 1.1.6 → 1.2.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/dist/react-tailwind.cjs.js +54 -653
- package/dist/react-tailwind.cjs.js.map +1 -1
- package/dist/react-tailwind.css +1 -1
- package/dist/react-tailwind.css.map +1 -1
- package/dist/react-tailwind.es.js +55 -654
- package/dist/react-tailwind.es.js.map +1 -1
- package/dist/types/components/VirtualizedDataTable/VirtualizedRow.d.ts +5 -3
- package/dist/types/index.d.ts +1 -0
- package/package.json +8 -5
|
@@ -4,6 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var tailwindMerge = require('tailwind-merge');
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var react = require('@headlessui/react');
|
|
7
|
+
var reactWindow = require('react-window');
|
|
7
8
|
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
9
10
|
var n = Object.create(null);
|
|
@@ -160,19 +161,19 @@ TextContent.displayName = 'TextContent';
|
|
|
160
161
|
*/
|
|
161
162
|
const THEMED_BTN_CLASS = {
|
|
162
163
|
primary: {
|
|
163
|
-
default: 'text-white bg-
|
|
164
|
-
outlined: 'text-
|
|
165
|
-
plain: 'text-
|
|
164
|
+
default: 'text-white bg-[var(--ui-primary)] hover:bg-[var(--ui-primary-hover)] focus:outline-[var(--ui-primary-ring)] disabled:bg-[var(--ui-primary-disabled)]',
|
|
165
|
+
outlined: 'text-[var(--ui-primary-text)] hover:text-white border border-[var(--ui-primary)] hover:bg-[var(--ui-primary)] focus:outline-[var(--ui-primary-ring)] disabled:text-[var(--ui-primary-disabled)] disabled:border-[var(--ui-primary-disabled)]',
|
|
166
|
+
plain: 'text-[var(--ui-primary-text)] hover:bg-black/5 dark:hover:bg-gray-700 focus:outline-[var(--ui-primary-ring)] disabled:text-[var(--ui-primary-disabled)]',
|
|
166
167
|
},
|
|
167
168
|
danger: {
|
|
168
|
-
default: 'text-white bg-
|
|
169
|
-
outlined: 'text-
|
|
170
|
-
plain: 'text-
|
|
169
|
+
default: 'text-white bg-[var(--ui-danger)] hover:bg-[var(--ui-danger-hover)] focus:outline-[var(--ui-danger-ring)] disabled:bg-[var(--ui-danger-disabled)]',
|
|
170
|
+
outlined: 'text-[var(--ui-danger-text)] hover:text-white border border-[var(--ui-danger)] hover:bg-[var(--ui-danger)] focus:outline-[var(--ui-danger-ring)] disabled:text-[var(--ui-danger-disabled)] disabled:border-[var(--ui-danger-disabled)]',
|
|
171
|
+
plain: 'text-[var(--ui-danger-text)] hover:bg-black/5 dark:hover:bg-gray-700 focus:outline-[var(--ui-danger-ring)] disabled:text-[var(--ui-danger-disabled)]',
|
|
171
172
|
},
|
|
172
173
|
secondary: {
|
|
173
|
-
default: 'text-gray-700 bg-white border border-gray-300 hover:bg-gray-100 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 focus:outline-
|
|
174
|
-
outlined: 'text-gray-700 hover:text-white border border-gray-500 hover:bg-gray-700 dark:border-gray-500 dark:text-gray-200 dark:hover:text-white dark:hover:bg-gray-600 focus:outline-
|
|
175
|
-
plain: 'text-gray-700 hover:bg-black/5 dark:text-gray-200 dark:hover:bg-gray-700 focus:outline-
|
|
174
|
+
default: 'text-gray-700 bg-white border border-gray-300 hover:bg-gray-100 dark:bg-gray-800 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 focus:outline-[var(--ui-focus-ring)] disabled:bg-gray-200 dark:disabled:bg-gray-700',
|
|
175
|
+
outlined: 'text-gray-700 hover:text-white border border-gray-500 hover:bg-gray-700 dark:border-gray-500 dark:text-gray-200 dark:hover:text-white dark:hover:bg-gray-600 focus:outline-[var(--ui-focus-ring)] disabled:text-gray-400 disabled:border-gray-400',
|
|
176
|
+
plain: 'text-gray-700 hover:bg-black/5 dark:text-gray-200 dark:hover:bg-gray-700 focus:outline-[var(--ui-focus-ring)] disabled:text-gray-400',
|
|
176
177
|
},
|
|
177
178
|
};
|
|
178
179
|
/**
|
|
@@ -235,10 +236,10 @@ const AlertTypeIconMap = {
|
|
|
235
236
|
info: SvgInfo,
|
|
236
237
|
};
|
|
237
238
|
const TypeClassMap = {
|
|
238
|
-
success: 'bg-
|
|
239
|
-
danger: 'bg-
|
|
240
|
-
warning: 'bg-
|
|
241
|
-
info: 'bg-
|
|
239
|
+
success: 'bg-[var(--ui-success-light)] ring-[var(--ui-success-ring-subtle)] text-[var(--ui-success-text)]',
|
|
240
|
+
danger: 'bg-[var(--ui-danger-light)] ring-[var(--ui-danger-ring-subtle)] text-[var(--ui-danger-text)]',
|
|
241
|
+
warning: 'bg-[var(--ui-warning-light)] ring-[var(--ui-warning-ring-subtle)] text-[var(--ui-warning-text)]',
|
|
242
|
+
info: 'bg-[var(--ui-info-light)] ring-[var(--ui-info-ring-subtle)] text-[var(--ui-info-text)]',
|
|
242
243
|
};
|
|
243
244
|
const Alert = (props) => {
|
|
244
245
|
const { type = 'info', className = '', message, children, removable = false, onRemove = () => { }, ...restProps } = props;
|
|
@@ -248,11 +249,11 @@ const Alert = (props) => {
|
|
|
248
249
|
Alert.displayName = 'Alert';
|
|
249
250
|
|
|
250
251
|
const ThemeClassMap = {
|
|
251
|
-
success: 'bg-
|
|
252
|
-
danger: 'bg-
|
|
253
|
-
warning: 'bg-
|
|
254
|
-
info: 'bg-
|
|
255
|
-
secondary: 'bg-gray-50 dark:bg-gray-
|
|
252
|
+
success: 'bg-[var(--ui-success-light)] text-[var(--ui-success-text)] ring-[var(--ui-success-ring-subtle)]',
|
|
253
|
+
danger: 'bg-[var(--ui-danger-light)] text-[var(--ui-danger-text)] ring-[var(--ui-danger-ring-subtle)]',
|
|
254
|
+
warning: 'bg-[var(--ui-warning-light)] text-[var(--ui-warning-text)] ring-[var(--ui-warning-ring-subtle)]',
|
|
255
|
+
info: 'bg-[var(--ui-info-light)] text-[var(--ui-info-text)] ring-[var(--ui-info-ring-subtle)]',
|
|
256
|
+
secondary: 'bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-200 ring-[var(--ui-secondary-ring-subtle)]',
|
|
256
257
|
};
|
|
257
258
|
const Badge = React.forwardRef((props, ref) => {
|
|
258
259
|
const { theme = 'info', className = '', children, removable = false, rounded = false, onRemove = () => { }, ...restProps } = props;
|
|
@@ -394,7 +395,7 @@ const Checkbox = React.forwardRef((props, ref) => {
|
|
|
394
395
|
...rest } = props;
|
|
395
396
|
const generatedId = React.useId();
|
|
396
397
|
const checkboxId = (_a = id !== null && id !== void 0 ? id : name) !== null && _a !== void 0 ? _a : generatedId;
|
|
397
|
-
return (jsxRuntime.jsxs("div", { className: buildClassName(wrapperClass), children: [jsxRuntime.jsxs("div", { className: buildClassName('flex items-center', containerClass), children: [jsxRuntime.jsxs("label", { htmlFor: checkboxId, className: buildClassName('inline-flex items-center relative select-none', disabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'), children: [jsxRuntime.jsx("input", { ref: ref, ...rest, id: checkboxId, name: name, type: "checkbox", disabled: disabled, "aria-checked": rest.checked, className: buildClassName('peer size-4.5 cursor-pointer transition-all appearance-none rounded', 'border focus:ring-2 focus:ring-offset-2', 'checked:bg-
|
|
398
|
+
return (jsxRuntime.jsxs("div", { className: buildClassName(wrapperClass), children: [jsxRuntime.jsxs("div", { className: buildClassName('flex items-center', containerClass), children: [jsxRuntime.jsxs("label", { htmlFor: checkboxId, className: buildClassName('inline-flex items-center relative select-none', disabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'), children: [jsxRuntime.jsx("input", { ref: ref, ...rest, id: checkboxId, name: name, type: "checkbox", disabled: disabled, "aria-checked": rest.checked, className: buildClassName('peer size-4.5 cursor-pointer transition-all appearance-none rounded', 'border focus:ring-2 focus:ring-offset-2', 'checked:bg-[var(--ui-primary)] checked:border-[var(--ui-primary)]', 'focus:ring-[var(--ui-focus-ring)] dark:focus:ring-offset-gray-900', disabled
|
|
398
399
|
? 'border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 pointer-events-none'
|
|
399
400
|
: 'bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500 hover:shadow-md', className) }), jsxRuntime.jsx("span", { className: "absolute text-white opacity-0 peer-checked:opacity-100 \n top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2", children: jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-3.25 w-3.25", viewBox: "0 0 20 20", fill: "currentColor", stroke: "currentColor", strokeWidth: "1", children: jsxRuntime.jsx("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })] }), label && (jsxRuntime.jsx(Label, { htmlFor: checkboxId, className: buildClassName(disabled
|
|
400
401
|
? 'cursor-not-allowed text-gray-400 dark:text-gray-500'
|
|
@@ -866,8 +867,8 @@ function buildInputClass(className, { isFocusWithin = false, disabled = false }
|
|
|
866
867
|
return buildClassName('transition-all', 'block w-full rounded-lg bg-white px-3.5 py-2 text-base sm:text-sm/6', 'text-gray-900 outline outline-1 -outline-offset-1', 'outline-gray-300 dark:outline-gray-600', 'invalid:group-[.has-error]:outline-red-500', disabled
|
|
867
868
|
? 'pointer-events-none bg-gray-100 dark:bg-gray-800 dark:text-gray-600 dark:placeholder-gray-600 placeholder-gray-400 outline-gray-200 dark:outline-gray-700'
|
|
868
869
|
: 'bg-white dark:bg-gray-700 dark:text-white outline-gray-300 dark:outline-gray-600 dark:placeholder-gray-400 placeholder-gray-400', isFocusWithin
|
|
869
|
-
? 'focus-within:outline-
|
|
870
|
-
: 'focus:outline-
|
|
870
|
+
? 'focus-within:outline-[var(--ui-focus-ring)] focus-within:outline-2 focus-within:-outline-offset-2'
|
|
871
|
+
: 'focus:outline-[var(--ui-focus-ring)] focus:outline-2 focus:-outline-offset-2', className);
|
|
871
872
|
}
|
|
872
873
|
const Input = React.forwardRef((props, ref) => {
|
|
873
874
|
const { name, id = name, type, label, labelHint, className, labelClass, labelWrapperClass, containerClass, error, showErrorMessage = true, rightGroup, leftGroup, ...inputProps } = props;
|
|
@@ -893,9 +894,9 @@ const Radio = React.forwardRef((props, ref) => {
|
|
|
893
894
|
...rest } = props;
|
|
894
895
|
const generatedId = React.useId();
|
|
895
896
|
const radioId = (_a = id !== null && id !== void 0 ? id : name) !== null && _a !== void 0 ? _a : generatedId;
|
|
896
|
-
return (jsxRuntime.jsxs("div", { className: buildClassName(wrapperClass), children: [jsxRuntime.jsxs("div", { className: buildClassName('flex items-center gap-2', containerClass), children: [jsxRuntime.jsx("div", { className: "grid place-items-center", children: jsxRuntime.jsx("input", { ref: ref, ...rest, id: radioId, name: name, type: "radio", disabled: disabled, "aria-checked": rest.checked, className: buildClassName('peer transition-all col-start-1 row-start-1 appearance-none shrink-0 size-4.5 rounded-full', 'border focus:ring-2 focus:ring-offset-2', 'checked:border-5 checked:bg-white', 'focus:ring-
|
|
897
|
+
return (jsxRuntime.jsxs("div", { className: buildClassName(wrapperClass), children: [jsxRuntime.jsxs("div", { className: buildClassName('flex items-center gap-2', containerClass), children: [jsxRuntime.jsx("div", { className: "grid place-items-center", children: jsxRuntime.jsx("input", { ref: ref, ...rest, id: radioId, name: name, type: "radio", disabled: disabled, "aria-checked": rest.checked, className: buildClassName('peer transition-all col-start-1 row-start-1 appearance-none shrink-0 size-4.5 rounded-full', 'border focus:ring-2 focus:ring-offset-2', 'checked:border-5 checked:bg-white', 'focus:ring-[var(--ui-focus-ring)] dark:focus:ring-offset-gray-800', disabled
|
|
897
898
|
? 'border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 pointer-events-none'
|
|
898
|
-
: buildClassName('bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500', 'checked:border-
|
|
899
|
+
: buildClassName('bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500', 'checked:border-[var(--ui-primary)] checked:hover:border-[var(--ui-primary)]'), className) }) }), label && (jsxRuntime.jsx(Label, { htmlFor: radioId, className: buildClassName(disabled
|
|
899
900
|
? 'cursor-not-allowed text-gray-400 dark:text-gray-500'
|
|
900
901
|
: 'cursor-pointer text-gray-600 dark:text-gray-300', labelClass), children: label }))] }), error && (jsxRuntime.jsx("div", { className: "mt-1", children: jsxRuntime.jsx(TextContent, { error: true, small: true, children: error }) }))] }));
|
|
901
902
|
});
|
|
@@ -1314,13 +1315,13 @@ function buildTabClass({ selected, variant, }) {
|
|
|
1314
1315
|
*/
|
|
1315
1316
|
case 'underline':
|
|
1316
1317
|
return buildClassName('px-3 py-1.5 text-sm font-medium transition relative', 'text-gray-600 dark:text-gray-300', 'hover:text-gray-900 dark:hover:text-white', selected &&
|
|
1317
|
-
'text-gray-900 dark:text-white after:absolute after:left-0 after:right-0 after:-bottom-1 after:h-0.5 after:bg-
|
|
1318
|
+
'text-gray-900 dark:text-white after:absolute after:left-0 after:right-0 after:-bottom-1 after:h-0.5 after:bg-[var(--ui-primary)]');
|
|
1318
1319
|
/**
|
|
1319
1320
|
* SEGMENTED
|
|
1320
1321
|
*/
|
|
1321
1322
|
case 'segmented':
|
|
1322
1323
|
return buildClassName('px-3 py-1.5 text-sm font-medium rounded-lg transition', selected
|
|
1323
|
-
? 'bg-
|
|
1324
|
+
? 'bg-[var(--ui-primary)] text-white'
|
|
1324
1325
|
: 'text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700');
|
|
1325
1326
|
/**
|
|
1326
1327
|
* SOLID
|
|
@@ -1344,29 +1345,22 @@ const Textarea = React.forwardRef((props, ref) => {
|
|
|
1344
1345
|
* Icons for each toast type
|
|
1345
1346
|
*/
|
|
1346
1347
|
const iconMap = {
|
|
1347
|
-
success: jsxRuntime.jsx(SvgCircleCheck, { className: "size-5 text-
|
|
1348
|
-
error: jsxRuntime.jsx(SvgCircleAlert, { className: "size-5 text-
|
|
1349
|
-
info: jsxRuntime.jsx(SvgInfo, { className: "size-5 text-
|
|
1350
|
-
warning: jsxRuntime.jsx(SvgTriangleAlert, { className: "size-5 text-
|
|
1348
|
+
success: jsxRuntime.jsx(SvgCircleCheck, { className: "size-5 text-[var(--ui-success)]" }),
|
|
1349
|
+
error: jsxRuntime.jsx(SvgCircleAlert, { className: "size-5 text-[var(--ui-danger)]" }),
|
|
1350
|
+
info: jsxRuntime.jsx(SvgInfo, { className: "size-5 text-[var(--ui-info)]" }),
|
|
1351
|
+
warning: jsxRuntime.jsx(SvgTriangleAlert, { className: "size-5 text-[var(--ui-warning)]" }),
|
|
1351
1352
|
};
|
|
1352
|
-
/**
|
|
1353
|
-
* Subtle icon + text color adjustments
|
|
1354
|
-
*/
|
|
1355
1353
|
const textColorMap = {
|
|
1356
|
-
success: 'text-
|
|
1357
|
-
error: 'text-
|
|
1358
|
-
info: 'text-
|
|
1359
|
-
warning: 'text-
|
|
1354
|
+
success: 'text-[var(--ui-success-text)]',
|
|
1355
|
+
error: 'text-[var(--ui-danger-text)]',
|
|
1356
|
+
info: 'text-[var(--ui-info-text)]',
|
|
1357
|
+
warning: 'text-[var(--ui-warning-text)]',
|
|
1360
1358
|
};
|
|
1361
|
-
/**
|
|
1362
|
-
* Pleasant colored *top border only*
|
|
1363
|
-
* No background color — soft neutral surface
|
|
1364
|
-
*/
|
|
1365
1359
|
const borderStyle = {
|
|
1366
|
-
success: 'border-t-4 border-
|
|
1367
|
-
error: 'border-t-4 border-
|
|
1368
|
-
info: 'border-t-4 border-
|
|
1369
|
-
warning: 'border-t-4 border-
|
|
1360
|
+
success: 'border-t-4 border-[var(--ui-success)]',
|
|
1361
|
+
error: 'border-t-4 border-[var(--ui-danger)]',
|
|
1362
|
+
info: 'border-t-4 border-[var(--ui-info)]',
|
|
1363
|
+
warning: 'border-t-4 border-[var(--ui-warning)]',
|
|
1370
1364
|
};
|
|
1371
1365
|
const Toast = ({ message, type, onClose, className, id, isTop = true, }) => {
|
|
1372
1366
|
const enterFrom = isTop ? 'opacity-0 -translate-y-3 scale-95' : 'opacity-0 translate-y-3 scale-95';
|
|
@@ -1441,604 +1435,8 @@ const ToastProvider = ({ children, placement = 'top-center' }) => {
|
|
|
1441
1435
|
return (jsxRuntime.jsxs(ToastContext.Provider, { value: { showToast, closeToast }, children: [children, jsxRuntime.jsx("div", { className: buildClassName('fixed z-50 flex flex-col gap-3 pointer-events-none', placementClass[placement]), children: toasts.map((toast, index) => (jsxRuntime.jsx("div", { className: "pointer-events-auto", onMouseEnter: () => toast.pauseOnHover && clearTimer(toast.id), onMouseLeave: () => toast.pauseOnHover && scheduleClose(toast), children: jsxRuntime.jsx(Toast, { ...toast, isTop: placement.startsWith('top'), onClose: () => closeToast(toast.id) }) }, toast.id))) })] }));
|
|
1442
1436
|
};
|
|
1443
1437
|
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
if (e !== void 0)
|
|
1447
|
-
switch (typeof e) {
|
|
1448
|
-
case "number":
|
|
1449
|
-
return e;
|
|
1450
|
-
case "string": {
|
|
1451
|
-
if (e.endsWith("px"))
|
|
1452
|
-
return parseFloat(e);
|
|
1453
|
-
break;
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
function Ie({
|
|
1458
|
-
box: e,
|
|
1459
|
-
defaultHeight: t,
|
|
1460
|
-
defaultWidth: s,
|
|
1461
|
-
disabled: r,
|
|
1462
|
-
element: n,
|
|
1463
|
-
mode: o,
|
|
1464
|
-
style: i
|
|
1465
|
-
}) {
|
|
1466
|
-
const { styleHeight: f, styleWidth: l } = React.useMemo(
|
|
1467
|
-
() => ({
|
|
1468
|
-
styleHeight: oe(i?.height),
|
|
1469
|
-
styleWidth: oe(i?.width)
|
|
1470
|
-
}),
|
|
1471
|
-
[i?.height, i?.width]
|
|
1472
|
-
), [c, d] = React.useState({
|
|
1473
|
-
height: t,
|
|
1474
|
-
width: s
|
|
1475
|
-
}), a = r || f !== void 0 || o === "only-width" || f !== void 0 && l !== void 0;
|
|
1476
|
-
return q(() => {
|
|
1477
|
-
if (n === null || a)
|
|
1478
|
-
return;
|
|
1479
|
-
const u = new ResizeObserver((I) => {
|
|
1480
|
-
for (const m of I) {
|
|
1481
|
-
const { contentRect: b, target: g } = m;
|
|
1482
|
-
n === g && d((w) => w.height === b.height && w.width === b.width ? w : {
|
|
1483
|
-
height: b.height,
|
|
1484
|
-
width: b.width
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
});
|
|
1488
|
-
return u.observe(n, { box: e }), () => {
|
|
1489
|
-
u?.unobserve(n);
|
|
1490
|
-
};
|
|
1491
|
-
}, [e, a, n, f, l]), React.useMemo(
|
|
1492
|
-
() => ({
|
|
1493
|
-
height: f ?? c.height,
|
|
1494
|
-
width: l ?? c.width
|
|
1495
|
-
}),
|
|
1496
|
-
[c, f, l]
|
|
1497
|
-
);
|
|
1498
|
-
}
|
|
1499
|
-
function ae(e) {
|
|
1500
|
-
const t = React.useRef(() => {
|
|
1501
|
-
throw new Error("Cannot call during render.");
|
|
1502
|
-
});
|
|
1503
|
-
return q(() => {
|
|
1504
|
-
t.current = e;
|
|
1505
|
-
}, [e]), React.useCallback((s) => t.current?.(s), [t]);
|
|
1506
|
-
}
|
|
1507
|
-
function Z({
|
|
1508
|
-
containerElement: e,
|
|
1509
|
-
direction: t,
|
|
1510
|
-
isRtl: s,
|
|
1511
|
-
scrollOffset: r
|
|
1512
|
-
}) {
|
|
1513
|
-
return r;
|
|
1514
|
-
}
|
|
1515
|
-
function $(e, t = "Assertion error") {
|
|
1516
|
-
if (!e)
|
|
1517
|
-
throw console.error(t), Error(t);
|
|
1518
|
-
}
|
|
1519
|
-
function Y(e, t) {
|
|
1520
|
-
if (e === t)
|
|
1521
|
-
return true;
|
|
1522
|
-
if (!!e != !!t || ($(e !== void 0), $(t !== void 0), Object.keys(e).length !== Object.keys(t).length))
|
|
1523
|
-
return false;
|
|
1524
|
-
for (const s in e)
|
|
1525
|
-
if (!Object.is(t[s], e[s]))
|
|
1526
|
-
return false;
|
|
1527
|
-
return true;
|
|
1528
|
-
}
|
|
1529
|
-
function fe({
|
|
1530
|
-
cachedBounds: e,
|
|
1531
|
-
itemCount: t,
|
|
1532
|
-
itemSize: s
|
|
1533
|
-
}) {
|
|
1534
|
-
if (t === 0)
|
|
1535
|
-
return 0;
|
|
1536
|
-
if (typeof s == "number")
|
|
1537
|
-
return t * s;
|
|
1538
|
-
{
|
|
1539
|
-
const r = e.get(
|
|
1540
|
-
e.size === 0 ? 0 : e.size - 1
|
|
1541
|
-
);
|
|
1542
|
-
$(r !== void 0, "Unexpected bounds cache miss");
|
|
1543
|
-
const n = (r.scrollOffset + r.size) / e.size;
|
|
1544
|
-
return t * n;
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
function we({
|
|
1548
|
-
align: e,
|
|
1549
|
-
cachedBounds: t,
|
|
1550
|
-
index: s,
|
|
1551
|
-
itemCount: r,
|
|
1552
|
-
itemSize: n,
|
|
1553
|
-
containerScrollOffset: o,
|
|
1554
|
-
containerSize: i
|
|
1555
|
-
}) {
|
|
1556
|
-
if (s < 0 || s >= r)
|
|
1557
|
-
throw RangeError(`Invalid index specified: ${s}`, {
|
|
1558
|
-
cause: `Index ${s} is not within the range of 0 - ${r - 1}`
|
|
1559
|
-
});
|
|
1560
|
-
const f = fe({
|
|
1561
|
-
cachedBounds: t,
|
|
1562
|
-
itemCount: r,
|
|
1563
|
-
itemSize: n
|
|
1564
|
-
}), l = t.get(s), c = Math.max(
|
|
1565
|
-
0,
|
|
1566
|
-
Math.min(f - i, l.scrollOffset)
|
|
1567
|
-
), d = Math.max(
|
|
1568
|
-
0,
|
|
1569
|
-
l.scrollOffset - i + l.size
|
|
1570
|
-
);
|
|
1571
|
-
switch (e === "smart" && (o >= d && o <= c ? e = "auto" : e = "center"), e) {
|
|
1572
|
-
case "start":
|
|
1573
|
-
return c;
|
|
1574
|
-
case "end":
|
|
1575
|
-
return d;
|
|
1576
|
-
case "center":
|
|
1577
|
-
return l.scrollOffset <= i / 2 ? 0 : l.scrollOffset + l.size / 2 >= f - i / 2 ? f - i : l.scrollOffset + l.size / 2 - i / 2;
|
|
1578
|
-
case "auto":
|
|
1579
|
-
default:
|
|
1580
|
-
return o >= d && o <= c ? o : o < d ? d : c;
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
function ie({
|
|
1584
|
-
cachedBounds: e,
|
|
1585
|
-
containerScrollOffset: t,
|
|
1586
|
-
containerSize: s,
|
|
1587
|
-
itemCount: r,
|
|
1588
|
-
overscanCount: n
|
|
1589
|
-
}) {
|
|
1590
|
-
const o = r - 1;
|
|
1591
|
-
let i = 0, f = -1, l = 0, c = -1, d = 0;
|
|
1592
|
-
for (; d < o; ) {
|
|
1593
|
-
const a = e.get(d);
|
|
1594
|
-
if (a.scrollOffset + a.size > t)
|
|
1595
|
-
break;
|
|
1596
|
-
d++;
|
|
1597
|
-
}
|
|
1598
|
-
for (i = d, l = Math.max(0, i - n); d < o; ) {
|
|
1599
|
-
const a = e.get(d);
|
|
1600
|
-
if (a.scrollOffset + a.size >= t + s)
|
|
1601
|
-
break;
|
|
1602
|
-
d++;
|
|
1603
|
-
}
|
|
1604
|
-
return f = Math.min(o, d), c = Math.min(r - 1, f + n), i < 0 && (i = 0, f = -1, l = 0, c = -1), {
|
|
1605
|
-
startIndexVisible: i,
|
|
1606
|
-
stopIndexVisible: f,
|
|
1607
|
-
startIndexOverscan: l,
|
|
1608
|
-
stopIndexOverscan: c
|
|
1609
|
-
};
|
|
1610
|
-
}
|
|
1611
|
-
function me({
|
|
1612
|
-
itemCount: e,
|
|
1613
|
-
itemProps: t,
|
|
1614
|
-
itemSize: s
|
|
1615
|
-
}) {
|
|
1616
|
-
const r = /* @__PURE__ */ new Map();
|
|
1617
|
-
return {
|
|
1618
|
-
get(n) {
|
|
1619
|
-
for ($(n < e, `Invalid index ${n}`); r.size - 1 < n; ) {
|
|
1620
|
-
const i = r.size;
|
|
1621
|
-
let f;
|
|
1622
|
-
switch (typeof s) {
|
|
1623
|
-
case "function": {
|
|
1624
|
-
f = s(i, t);
|
|
1625
|
-
break;
|
|
1626
|
-
}
|
|
1627
|
-
case "number": {
|
|
1628
|
-
f = s;
|
|
1629
|
-
break;
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
if (i === 0)
|
|
1633
|
-
r.set(i, {
|
|
1634
|
-
size: f,
|
|
1635
|
-
scrollOffset: 0
|
|
1636
|
-
});
|
|
1637
|
-
else {
|
|
1638
|
-
const l = r.get(i - 1);
|
|
1639
|
-
$(
|
|
1640
|
-
l !== void 0,
|
|
1641
|
-
`Unexpected bounds cache miss for index ${n}`
|
|
1642
|
-
), r.set(i, {
|
|
1643
|
-
scrollOffset: l.scrollOffset + l.size,
|
|
1644
|
-
size: f
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
const o = r.get(n);
|
|
1649
|
-
return $(
|
|
1650
|
-
o !== void 0,
|
|
1651
|
-
`Unexpected bounds cache miss for index ${n}`
|
|
1652
|
-
), o;
|
|
1653
|
-
},
|
|
1654
|
-
set(n, o) {
|
|
1655
|
-
r.set(n, o);
|
|
1656
|
-
},
|
|
1657
|
-
get size() {
|
|
1658
|
-
return r.size;
|
|
1659
|
-
}
|
|
1660
|
-
};
|
|
1661
|
-
}
|
|
1662
|
-
function Oe({
|
|
1663
|
-
itemCount: e,
|
|
1664
|
-
itemProps: t,
|
|
1665
|
-
itemSize: s
|
|
1666
|
-
}) {
|
|
1667
|
-
return React.useMemo(
|
|
1668
|
-
() => me({
|
|
1669
|
-
itemCount: e,
|
|
1670
|
-
itemProps: t,
|
|
1671
|
-
itemSize: s
|
|
1672
|
-
}),
|
|
1673
|
-
[e, t, s]
|
|
1674
|
-
);
|
|
1675
|
-
}
|
|
1676
|
-
function ye({
|
|
1677
|
-
containerSize: e,
|
|
1678
|
-
itemSize: t
|
|
1679
|
-
}) {
|
|
1680
|
-
let s;
|
|
1681
|
-
switch (typeof t) {
|
|
1682
|
-
case "string": {
|
|
1683
|
-
$(
|
|
1684
|
-
t.endsWith("%"),
|
|
1685
|
-
`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`
|
|
1686
|
-
), $(
|
|
1687
|
-
e !== void 0,
|
|
1688
|
-
"Container size must be defined if a percentage item size is specified"
|
|
1689
|
-
), s = e * parseInt(t) / 100;
|
|
1690
|
-
break;
|
|
1691
|
-
}
|
|
1692
|
-
default: {
|
|
1693
|
-
s = t;
|
|
1694
|
-
break;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
return s;
|
|
1698
|
-
}
|
|
1699
|
-
function ee({
|
|
1700
|
-
containerElement: e,
|
|
1701
|
-
containerStyle: t,
|
|
1702
|
-
defaultContainerSize: s = 0,
|
|
1703
|
-
direction: r,
|
|
1704
|
-
isRtl: n = false,
|
|
1705
|
-
itemCount: o,
|
|
1706
|
-
itemProps: i,
|
|
1707
|
-
itemSize: f,
|
|
1708
|
-
onResize: l,
|
|
1709
|
-
overscanCount: c
|
|
1710
|
-
}) {
|
|
1711
|
-
const [d, a] = React.useState({
|
|
1712
|
-
startIndexVisible: 0,
|
|
1713
|
-
startIndexOverscan: 0,
|
|
1714
|
-
stopIndexVisible: -1,
|
|
1715
|
-
stopIndexOverscan: -1
|
|
1716
|
-
}), {
|
|
1717
|
-
startIndexVisible: u,
|
|
1718
|
-
startIndexOverscan: I,
|
|
1719
|
-
stopIndexVisible: m,
|
|
1720
|
-
stopIndexOverscan: b
|
|
1721
|
-
} = {
|
|
1722
|
-
startIndexVisible: Math.min(o - 1, d.startIndexVisible),
|
|
1723
|
-
startIndexOverscan: Math.min(o - 1, d.startIndexOverscan),
|
|
1724
|
-
stopIndexVisible: Math.min(o - 1, d.stopIndexVisible),
|
|
1725
|
-
stopIndexOverscan: Math.min(o - 1, d.stopIndexOverscan)
|
|
1726
|
-
}, { height: g = s, width: w = s } = Ie({
|
|
1727
|
-
defaultHeight: s ,
|
|
1728
|
-
defaultWidth: void 0,
|
|
1729
|
-
element: e,
|
|
1730
|
-
mode: "only-height" ,
|
|
1731
|
-
style: t
|
|
1732
|
-
}), y = React.useRef({
|
|
1733
|
-
height: 0,
|
|
1734
|
-
width: 0
|
|
1735
|
-
}), V = g , h = ye({ containerSize: V, itemSize: f });
|
|
1736
|
-
React.useLayoutEffect(() => {
|
|
1737
|
-
if (typeof l == "function") {
|
|
1738
|
-
const p = y.current;
|
|
1739
|
-
(p.height !== g || p.width !== w) && (l({ height: g, width: w }, { ...p }), p.height = g, p.width = w);
|
|
1740
|
-
}
|
|
1741
|
-
}, [g, l, w]);
|
|
1742
|
-
const z = Oe({
|
|
1743
|
-
itemCount: o,
|
|
1744
|
-
itemProps: i,
|
|
1745
|
-
itemSize: h
|
|
1746
|
-
}), k = React.useCallback(
|
|
1747
|
-
(p) => z.get(p),
|
|
1748
|
-
[z]
|
|
1749
|
-
), S = React.useCallback(
|
|
1750
|
-
() => fe({
|
|
1751
|
-
cachedBounds: z,
|
|
1752
|
-
itemCount: o,
|
|
1753
|
-
itemSize: h
|
|
1754
|
-
}),
|
|
1755
|
-
[z, o, h]
|
|
1756
|
-
), W = React.useCallback(
|
|
1757
|
-
(p) => {
|
|
1758
|
-
const T = Z({
|
|
1759
|
-
containerElement: e,
|
|
1760
|
-
direction: r,
|
|
1761
|
-
isRtl: n,
|
|
1762
|
-
scrollOffset: p
|
|
1763
|
-
});
|
|
1764
|
-
return ie({
|
|
1765
|
-
cachedBounds: z,
|
|
1766
|
-
containerScrollOffset: T,
|
|
1767
|
-
containerSize: V,
|
|
1768
|
-
itemCount: o,
|
|
1769
|
-
overscanCount: c
|
|
1770
|
-
});
|
|
1771
|
-
},
|
|
1772
|
-
[
|
|
1773
|
-
z,
|
|
1774
|
-
e,
|
|
1775
|
-
V,
|
|
1776
|
-
r,
|
|
1777
|
-
n,
|
|
1778
|
-
o,
|
|
1779
|
-
c
|
|
1780
|
-
]
|
|
1781
|
-
);
|
|
1782
|
-
q(() => {
|
|
1783
|
-
const p = (e?.scrollTop ) ?? 0;
|
|
1784
|
-
a(W(p));
|
|
1785
|
-
}, [e, r, W]), q(() => {
|
|
1786
|
-
if (!e)
|
|
1787
|
-
return;
|
|
1788
|
-
const p = () => {
|
|
1789
|
-
a((T) => {
|
|
1790
|
-
const { scrollLeft: R, scrollTop: v } = e, x = Z({
|
|
1791
|
-
containerElement: e,
|
|
1792
|
-
direction: r,
|
|
1793
|
-
isRtl: n,
|
|
1794
|
-
scrollOffset: v
|
|
1795
|
-
}), A = ie({
|
|
1796
|
-
cachedBounds: z,
|
|
1797
|
-
containerScrollOffset: x,
|
|
1798
|
-
containerSize: V,
|
|
1799
|
-
itemCount: o,
|
|
1800
|
-
overscanCount: c
|
|
1801
|
-
});
|
|
1802
|
-
return Y(A, T) ? T : A;
|
|
1803
|
-
});
|
|
1804
|
-
};
|
|
1805
|
-
return e.addEventListener("scroll", p), () => {
|
|
1806
|
-
e.removeEventListener("scroll", p);
|
|
1807
|
-
};
|
|
1808
|
-
}, [
|
|
1809
|
-
z,
|
|
1810
|
-
e,
|
|
1811
|
-
V,
|
|
1812
|
-
r,
|
|
1813
|
-
o,
|
|
1814
|
-
c
|
|
1815
|
-
]);
|
|
1816
|
-
const O = ae(
|
|
1817
|
-
({
|
|
1818
|
-
align: p = "auto",
|
|
1819
|
-
containerScrollOffset: T,
|
|
1820
|
-
index: R
|
|
1821
|
-
}) => {
|
|
1822
|
-
let v = we({
|
|
1823
|
-
align: p,
|
|
1824
|
-
cachedBounds: z,
|
|
1825
|
-
containerScrollOffset: T,
|
|
1826
|
-
containerSize: V,
|
|
1827
|
-
index: R,
|
|
1828
|
-
itemCount: o,
|
|
1829
|
-
itemSize: h
|
|
1830
|
-
});
|
|
1831
|
-
if (e) {
|
|
1832
|
-
if (v = Z({
|
|
1833
|
-
containerElement: e,
|
|
1834
|
-
direction: r,
|
|
1835
|
-
isRtl: n,
|
|
1836
|
-
scrollOffset: v
|
|
1837
|
-
}), typeof e.scrollTo != "function") {
|
|
1838
|
-
const x = W(v);
|
|
1839
|
-
Y(d, x) || a(x);
|
|
1840
|
-
}
|
|
1841
|
-
return v;
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
|
-
);
|
|
1845
|
-
return {
|
|
1846
|
-
getCellBounds: k,
|
|
1847
|
-
getEstimatedSize: S,
|
|
1848
|
-
scrollToIndex: O,
|
|
1849
|
-
startIndexOverscan: I,
|
|
1850
|
-
startIndexVisible: u,
|
|
1851
|
-
stopIndexOverscan: b,
|
|
1852
|
-
stopIndexVisible: m
|
|
1853
|
-
};
|
|
1854
|
-
}
|
|
1855
|
-
function de(e) {
|
|
1856
|
-
return React.useMemo(() => e, Object.values(e));
|
|
1857
|
-
}
|
|
1858
|
-
function ue(e, t) {
|
|
1859
|
-
const {
|
|
1860
|
-
ariaAttributes: s,
|
|
1861
|
-
style: r,
|
|
1862
|
-
...n
|
|
1863
|
-
} = e, {
|
|
1864
|
-
ariaAttributes: o,
|
|
1865
|
-
style: i,
|
|
1866
|
-
...f
|
|
1867
|
-
} = t;
|
|
1868
|
-
return Y(s, o) && Y(r, i) && Y(n, f);
|
|
1869
|
-
}
|
|
1870
|
-
function ze(e) {
|
|
1871
|
-
return e != null && typeof e == "object" && "getAverageRowHeight" in e && typeof e.getAverageRowHeight == "function";
|
|
1872
|
-
}
|
|
1873
|
-
const te = "data-react-window-index";
|
|
1874
|
-
function Ae({
|
|
1875
|
-
children: e,
|
|
1876
|
-
className: t,
|
|
1877
|
-
defaultHeight: s = 0,
|
|
1878
|
-
listRef: r,
|
|
1879
|
-
onResize: n,
|
|
1880
|
-
onRowsRendered: o,
|
|
1881
|
-
overscanCount: i = 3,
|
|
1882
|
-
rowComponent: f,
|
|
1883
|
-
rowCount: l,
|
|
1884
|
-
rowHeight: c,
|
|
1885
|
-
rowProps: d,
|
|
1886
|
-
tagName: a = "div",
|
|
1887
|
-
style: u,
|
|
1888
|
-
...I
|
|
1889
|
-
}) {
|
|
1890
|
-
const m = de(d), b = React.useMemo(
|
|
1891
|
-
() => React.memo(f, ue),
|
|
1892
|
-
[f]
|
|
1893
|
-
), [g, w] = React.useState(null), y = ze(c), V = React.useMemo(() => y ? (v) => c.getRowHeight(v) ?? c.getAverageRowHeight() : c, [y, c]), {
|
|
1894
|
-
getCellBounds: h,
|
|
1895
|
-
getEstimatedSize: z,
|
|
1896
|
-
scrollToIndex: k,
|
|
1897
|
-
startIndexOverscan: S,
|
|
1898
|
-
startIndexVisible: W,
|
|
1899
|
-
stopIndexOverscan: O,
|
|
1900
|
-
stopIndexVisible: p
|
|
1901
|
-
} = ee({
|
|
1902
|
-
containerElement: g,
|
|
1903
|
-
containerStyle: u,
|
|
1904
|
-
defaultContainerSize: s,
|
|
1905
|
-
direction: "vertical",
|
|
1906
|
-
itemCount: l,
|
|
1907
|
-
itemProps: m,
|
|
1908
|
-
itemSize: V,
|
|
1909
|
-
onResize: n,
|
|
1910
|
-
overscanCount: i
|
|
1911
|
-
});
|
|
1912
|
-
React.useImperativeHandle(
|
|
1913
|
-
r,
|
|
1914
|
-
() => ({
|
|
1915
|
-
get element() {
|
|
1916
|
-
return g;
|
|
1917
|
-
},
|
|
1918
|
-
scrollToRow({
|
|
1919
|
-
align: v = "auto",
|
|
1920
|
-
behavior: x = "auto",
|
|
1921
|
-
index: A
|
|
1922
|
-
}) {
|
|
1923
|
-
const M = k({
|
|
1924
|
-
align: v,
|
|
1925
|
-
containerScrollOffset: g?.scrollTop ?? 0,
|
|
1926
|
-
index: A
|
|
1927
|
-
});
|
|
1928
|
-
typeof g?.scrollTo == "function" && g.scrollTo({
|
|
1929
|
-
behavior: x,
|
|
1930
|
-
top: M
|
|
1931
|
-
});
|
|
1932
|
-
}
|
|
1933
|
-
}),
|
|
1934
|
-
[g, k]
|
|
1935
|
-
), q(() => {
|
|
1936
|
-
if (!g)
|
|
1937
|
-
return;
|
|
1938
|
-
const v = Array.from(g.children).filter((x, A) => {
|
|
1939
|
-
if (x.hasAttribute("aria-hidden"))
|
|
1940
|
-
return false;
|
|
1941
|
-
const M = `${S + A}`;
|
|
1942
|
-
return x.setAttribute(te, M), true;
|
|
1943
|
-
});
|
|
1944
|
-
if (y)
|
|
1945
|
-
return c.observeRowElements(v);
|
|
1946
|
-
}, [
|
|
1947
|
-
g,
|
|
1948
|
-
y,
|
|
1949
|
-
c,
|
|
1950
|
-
S,
|
|
1951
|
-
O
|
|
1952
|
-
]), React.useEffect(() => {
|
|
1953
|
-
S >= 0 && O >= 0 && o && o(
|
|
1954
|
-
{
|
|
1955
|
-
startIndex: W,
|
|
1956
|
-
stopIndex: p
|
|
1957
|
-
},
|
|
1958
|
-
{
|
|
1959
|
-
startIndex: S,
|
|
1960
|
-
stopIndex: O
|
|
1961
|
-
}
|
|
1962
|
-
);
|
|
1963
|
-
}, [
|
|
1964
|
-
o,
|
|
1965
|
-
S,
|
|
1966
|
-
W,
|
|
1967
|
-
O,
|
|
1968
|
-
p
|
|
1969
|
-
]);
|
|
1970
|
-
const T = React.useMemo(() => {
|
|
1971
|
-
const v = [];
|
|
1972
|
-
if (l > 0)
|
|
1973
|
-
for (let x = S; x <= O; x++) {
|
|
1974
|
-
const A = h(x);
|
|
1975
|
-
v.push(
|
|
1976
|
-
/* @__PURE__ */ React.createElement(
|
|
1977
|
-
b,
|
|
1978
|
-
{
|
|
1979
|
-
...m,
|
|
1980
|
-
ariaAttributes: {
|
|
1981
|
-
"aria-posinset": x + 1,
|
|
1982
|
-
"aria-setsize": l,
|
|
1983
|
-
role: "listitem"
|
|
1984
|
-
},
|
|
1985
|
-
key: x,
|
|
1986
|
-
index: x,
|
|
1987
|
-
style: {
|
|
1988
|
-
position: "absolute",
|
|
1989
|
-
left: 0,
|
|
1990
|
-
transform: `translateY(${A.scrollOffset}px)`,
|
|
1991
|
-
// In case of dynamic row heights, don't specify a height style
|
|
1992
|
-
// otherwise a default/estimated height would mask the actual height
|
|
1993
|
-
height: y ? void 0 : A.size,
|
|
1994
|
-
width: "100%"
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
)
|
|
1998
|
-
);
|
|
1999
|
-
}
|
|
2000
|
-
return v;
|
|
2001
|
-
}, [
|
|
2002
|
-
b,
|
|
2003
|
-
h,
|
|
2004
|
-
y,
|
|
2005
|
-
l,
|
|
2006
|
-
m,
|
|
2007
|
-
S,
|
|
2008
|
-
O
|
|
2009
|
-
]), R = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2010
|
-
"div",
|
|
2011
|
-
{
|
|
2012
|
-
"aria-hidden": true,
|
|
2013
|
-
style: {
|
|
2014
|
-
height: z(),
|
|
2015
|
-
width: "100%",
|
|
2016
|
-
zIndex: -1
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
);
|
|
2020
|
-
return React.createElement(
|
|
2021
|
-
a,
|
|
2022
|
-
{
|
|
2023
|
-
role: "list",
|
|
2024
|
-
...I,
|
|
2025
|
-
className: t,
|
|
2026
|
-
ref: w,
|
|
2027
|
-
style: {
|
|
2028
|
-
position: "relative",
|
|
2029
|
-
maxHeight: "100%",
|
|
2030
|
-
flexGrow: 1,
|
|
2031
|
-
overflowY: "auto",
|
|
2032
|
-
...u
|
|
2033
|
-
}
|
|
2034
|
-
},
|
|
2035
|
-
T,
|
|
2036
|
-
e,
|
|
2037
|
-
R
|
|
2038
|
-
);
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
const VirtualizedRow = ({ index, style, items, columns, gridTemplate, }) => {
|
|
1438
|
+
const VirtualizedRow = ({ index, style, data }) => {
|
|
1439
|
+
const { items, columns, gridTemplate } = data;
|
|
2042
1440
|
const item = items[index];
|
|
2043
1441
|
return (jsxRuntime.jsx("div", { role: "row", className: "grid border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 group", style: {
|
|
2044
1442
|
...style,
|
|
@@ -2060,14 +1458,21 @@ const VirtualizedRow = ({ index, style, items, columns, gridTemplate, }) => {
|
|
|
2060
1458
|
const useGridTemplate = (columns) => React.useMemo(() => columns.map((col) => (col.width ? `${col.width}px` : '1fr')).join(' '), [columns]);
|
|
2061
1459
|
const VirtualizedDataTable = ({ items, columns, sorting = {}, onSort, loading = false, emptyMessage = 'No data available', containerClass = '', wrapperClass = '', rowHeight = 48, maxHeight = 400, }) => {
|
|
2062
1460
|
const scrollRef = React.useRef(null);
|
|
1461
|
+
const outerRef = React.useRef(null);
|
|
2063
1462
|
const headerRef = React.useRef(null);
|
|
2064
1463
|
const gridTemplate = useGridTemplate(columns);
|
|
2065
|
-
/** Sync body → header
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
1464
|
+
/** Sync horizontal scroll of the virtualized body → header */
|
|
1465
|
+
React.useEffect(() => {
|
|
1466
|
+
const el = outerRef.current;
|
|
1467
|
+
if (!el)
|
|
1468
|
+
return;
|
|
1469
|
+
const handler = () => {
|
|
1470
|
+
if (headerRef.current)
|
|
1471
|
+
headerRef.current.scrollLeft = el.scrollLeft;
|
|
1472
|
+
};
|
|
1473
|
+
el.addEventListener('scroll', handler);
|
|
1474
|
+
return () => el.removeEventListener('scroll', handler);
|
|
1475
|
+
}, []);
|
|
2071
1476
|
const handleSort = React.useCallback((column) => {
|
|
2072
1477
|
if (column.sortable)
|
|
2073
1478
|
onSort === null || onSort === void 0 ? void 0 : onSort(column);
|
|
@@ -2099,11 +1504,7 @@ const VirtualizedDataTable = ({ items, columns, sorting = {}, onSort, loading =
|
|
|
2099
1504
|
/* -------------------------------------------------------
|
|
2100
1505
|
* MAIN (virtualized body)
|
|
2101
1506
|
* ------------------------------------------------------- */
|
|
2102
|
-
return (jsxRuntime.jsx("div", { className: buildClassName('w-full rounded-lg relative', containerClass), children: jsxRuntime.jsxs("div", { className: buildClassName('rounded-lg border border-gray-200 dark:border-gray-800 overflow-hidden', wrapperClass), children: [Header, jsxRuntime.jsx("
|
|
2103
|
-
height: maxHeight,
|
|
2104
|
-
overflowY: 'auto',
|
|
2105
|
-
overflowX: 'auto',
|
|
2106
|
-
}, children: jsxRuntime.jsx(Ae, { listRef: scrollRef, rowComponent: VirtualizedRow, rowCount: items.length, rowHeight: rowHeight, rowProps: { items, columns, gridTemplate }, onScroll: (e) => handleScrollSync(e.currentTarget.scrollLeft) }) })] }) }));
|
|
1507
|
+
return (jsxRuntime.jsx("div", { className: buildClassName('w-full rounded-lg relative', containerClass), children: jsxRuntime.jsxs("div", { className: buildClassName('rounded-lg border border-gray-200 dark:border-gray-800 overflow-hidden', wrapperClass), children: [Header, jsxRuntime.jsx(reactWindow.FixedSizeList, { ref: scrollRef, outerRef: outerRef, height: maxHeight, width: "100%", itemCount: items.length, itemSize: rowHeight, itemData: { items, columns, gridTemplate }, children: VirtualizedRow })] }) }));
|
|
2107
1508
|
};
|
|
2108
1509
|
|
|
2109
1510
|
const useIsMobile = () => {
|