@nukleus-sports/ui-web 0.2.1 → 0.3.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/index.cjs +41 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -235,11 +235,13 @@ __export(src_exports, {
|
|
|
235
235
|
columnSize: () => columnSize,
|
|
236
236
|
createClickableSortableHeader: () => createClickableSortableHeader,
|
|
237
237
|
createSortableHeader: () => createSortableHeader,
|
|
238
|
+
fitContain: () => fitContain,
|
|
238
239
|
showUndoToast: () => showUndoToast,
|
|
239
240
|
taskColumnSize: () => taskColumnSize,
|
|
240
241
|
textareaVariants: () => textareaVariants,
|
|
241
242
|
toast: () => import_sonner2.toast,
|
|
242
243
|
toggleVariants: () => toggleVariants,
|
|
244
|
+
useElementSize: () => useElementSize,
|
|
243
245
|
useFormField: () => useFormField,
|
|
244
246
|
useInfiniteList: () => useInfiniteList,
|
|
245
247
|
useSidebar: () => useSidebar
|
|
@@ -6507,6 +6509,43 @@ function useInfiniteList(items, options = {}) {
|
|
|
6507
6509
|
const visibleItems = (0, import_react5.useMemo)(() => items.slice(0, effectiveCount), [items, effectiveCount]);
|
|
6508
6510
|
return { visibleItems, sentinelRef, hasMore, displayCount: effectiveCount };
|
|
6509
6511
|
}
|
|
6512
|
+
|
|
6513
|
+
// src/hooks/use-element-size.ts
|
|
6514
|
+
var import_react6 = require("react");
|
|
6515
|
+
function useElementSize(ref) {
|
|
6516
|
+
const [size, setSize] = (0, import_react6.useState)({ width: 0, height: 0 });
|
|
6517
|
+
(0, import_react6.useEffect)(() => {
|
|
6518
|
+
const el = ref.current;
|
|
6519
|
+
if (!el) return;
|
|
6520
|
+
const update = () => {
|
|
6521
|
+
const { width, height } = el.getBoundingClientRect();
|
|
6522
|
+
setSize(
|
|
6523
|
+
(prev) => prev.width === width && prev.height === height ? prev : { width, height }
|
|
6524
|
+
);
|
|
6525
|
+
};
|
|
6526
|
+
update();
|
|
6527
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
6528
|
+
const observer = new ResizeObserver(update);
|
|
6529
|
+
observer.observe(el);
|
|
6530
|
+
return () => observer.disconnect();
|
|
6531
|
+
}, [ref]);
|
|
6532
|
+
return size;
|
|
6533
|
+
}
|
|
6534
|
+
function fitContain(box, natural) {
|
|
6535
|
+
if (box.width <= 0 || box.height <= 0 || natural.width <= 0 || natural.height <= 0) {
|
|
6536
|
+
return { width: 0, height: 0 };
|
|
6537
|
+
}
|
|
6538
|
+
if (box.width * natural.height <= box.height * natural.width) {
|
|
6539
|
+
return {
|
|
6540
|
+
width: Math.floor(box.width),
|
|
6541
|
+
height: Math.floor(box.width * natural.height / natural.width)
|
|
6542
|
+
};
|
|
6543
|
+
}
|
|
6544
|
+
return {
|
|
6545
|
+
width: Math.floor(box.height * natural.width / natural.height),
|
|
6546
|
+
height: Math.floor(box.height)
|
|
6547
|
+
};
|
|
6548
|
+
}
|
|
6510
6549
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6511
6550
|
0 && (module.exports = {
|
|
6512
6551
|
Accordion,
|
|
@@ -6714,11 +6753,13 @@ function useInfiniteList(items, options = {}) {
|
|
|
6714
6753
|
columnSize,
|
|
6715
6754
|
createClickableSortableHeader,
|
|
6716
6755
|
createSortableHeader,
|
|
6756
|
+
fitContain,
|
|
6717
6757
|
showUndoToast,
|
|
6718
6758
|
taskColumnSize,
|
|
6719
6759
|
textareaVariants,
|
|
6720
6760
|
toast,
|
|
6721
6761
|
toggleVariants,
|
|
6762
|
+
useElementSize,
|
|
6722
6763
|
useFormField,
|
|
6723
6764
|
useInfiniteList,
|
|
6724
6765
|
useSidebar
|