infinity-ui-elements 1.6.16 → 1.7.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/dist/components/Skeleton/Skeleton.d.ts +49 -0
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton/Skeleton.stories.d.ts +46 -0
- package/dist/components/Skeleton/Skeleton.stories.d.ts.map +1 -0
- package/dist/components/Skeleton/index.d.ts +3 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +59 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2522,6 +2522,64 @@ const SearchableDropdown = React.forwardRef(({ className, items = [], sectionHea
|
|
|
2522
2522
|
});
|
|
2523
2523
|
SearchableDropdown.displayName = "SearchableDropdown";
|
|
2524
2524
|
|
|
2525
|
+
const variantDefaults = {
|
|
2526
|
+
rect: { height: 16, className: "w-full rounded-large" },
|
|
2527
|
+
text: { height: 12, className: "w-full rounded-large" },
|
|
2528
|
+
title: { height: 20, className: "w-full rounded-large" },
|
|
2529
|
+
circle: { height: 40, className: "rounded-full aspect-square" },
|
|
2530
|
+
};
|
|
2531
|
+
const roundedClassNames = {
|
|
2532
|
+
none: "rounded-none",
|
|
2533
|
+
small: "rounded-small",
|
|
2534
|
+
medium: "rounded-medium",
|
|
2535
|
+
large: "rounded-large",
|
|
2536
|
+
full: "rounded-full",
|
|
2537
|
+
};
|
|
2538
|
+
const animationClassNames = {
|
|
2539
|
+
pulse: "animate-skeleton",
|
|
2540
|
+
none: undefined,
|
|
2541
|
+
};
|
|
2542
|
+
const normalizeCssValue = (value) => {
|
|
2543
|
+
if (value === undefined || value === null) {
|
|
2544
|
+
return undefined;
|
|
2545
|
+
}
|
|
2546
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
2547
|
+
};
|
|
2548
|
+
const getLineWidths = (count, provided) => {
|
|
2549
|
+
if (provided && provided.length) {
|
|
2550
|
+
return Array.from({ length: count }, (_, index) => normalizeCssValue(provided[index] ?? provided[provided.length - 1]));
|
|
2551
|
+
}
|
|
2552
|
+
if (count === 1) {
|
|
2553
|
+
return ["100%"];
|
|
2554
|
+
}
|
|
2555
|
+
return Array.from({ length: count }, (_, index) => index === count - 1 ? "60%" : "100%");
|
|
2556
|
+
};
|
|
2557
|
+
const Skeleton = React.forwardRef(({ className, containerClassName, containerStyle, variant = "rect", animation = "pulse", lines = 1, lineWidths, lineGap = "0.5rem", width, height, rounded = "large", style, ...props }, ref) => {
|
|
2558
|
+
const resolvedLines = Math.max(1, lines);
|
|
2559
|
+
const baseVariant = variantDefaults[variant];
|
|
2560
|
+
const resolvedHeight = normalizeCssValue(height) ?? normalizeCssValue(baseVariant.height);
|
|
2561
|
+
const resolvedWidth = normalizeCssValue(width) ??
|
|
2562
|
+
(variant === "circle" ? resolvedHeight : undefined);
|
|
2563
|
+
const skeletonClasses = cn("block bg-surface-fill-neutral-subtle", animationClassNames[animation], variant !== "circle" && roundedClassNames[rounded], baseVariant.className, className);
|
|
2564
|
+
if ((variant === "text" || variant === "title") && resolvedLines > 1) {
|
|
2565
|
+
const widths = getLineWidths(resolvedLines, lineWidths);
|
|
2566
|
+
return (jsx("div", { ref: ref, className: cn("flex w-full flex-col", containerClassName, animation === "pulse" ? "animate-none" : undefined), style: {
|
|
2567
|
+
gap: normalizeCssValue(lineGap) ?? "0.5rem",
|
|
2568
|
+
...containerStyle,
|
|
2569
|
+
}, "aria-live": "polite", "aria-busy": "true", ...props, children: widths.map((lineWidth, index) => (jsx("span", { className: skeletonClasses, style: {
|
|
2570
|
+
height: resolvedHeight,
|
|
2571
|
+
width: lineWidth ?? resolvedWidth ?? "100%",
|
|
2572
|
+
...style,
|
|
2573
|
+
}, "aria-hidden": "true" }, `skeleton-line-${index}`))) }));
|
|
2574
|
+
}
|
|
2575
|
+
return (jsx("div", { ref: ref, className: skeletonClasses, style: {
|
|
2576
|
+
height: resolvedHeight,
|
|
2577
|
+
width: resolvedWidth ?? style?.width,
|
|
2578
|
+
...style,
|
|
2579
|
+
}, "aria-live": "polite", "aria-busy": "true", ...props }));
|
|
2580
|
+
});
|
|
2581
|
+
Skeleton.displayName = "Skeleton";
|
|
2582
|
+
|
|
2525
2583
|
const switchVariants = cva("relative inline-flex items-center shrink-0 cursor-pointer rounded-full transition-all duration-200", {
|
|
2526
2584
|
variants: {
|
|
2527
2585
|
size: {
|
|
@@ -3115,5 +3173,5 @@ const TextArea = React.forwardRef(({ label, helperText, errorText, successText,
|
|
|
3115
3173
|
});
|
|
3116
3174
|
TextArea.displayName = "TextArea";
|
|
3117
3175
|
|
|
3118
|
-
export { Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, SearchableDropdown, Select, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, dropdownVariants, getAvailableIcons, hasIcon, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants };
|
|
3176
|
+
export { Avatar, AvatarCell, Badge, Button, ButtonGroup, Checkbox, Counter, Divider, Dropdown, DropdownMenu, FormFooter, FormHeader, Icon, IconCell, Link, ListItem, Modal, NumberCell, Pagination, Radio, SearchableDropdown, Select, Skeleton, SlotCell, SpacerCell, Switch, TabItem, Table, TableDetailPanel, Tabs, Text, TextArea, TextField, Tooltip, avatarVariants, badgeVariants, buttonGroupVariants, buttonVariants, checkboxVariants, cn, counterVariants, dropdownVariants, getAvailableIcons, hasIcon, iconRegistry, linkVariants, listItemVariants, paginationVariants, radioVariants, selectVariants, switchVariants, tableCellVariants, tableHeaderVariants, tableVariants, textAreaVariants, textFieldVariants, tooltipVariants };
|
|
3119
3177
|
//# sourceMappingURL=index.esm.js.map
|