linkedunion-design-kit 1.9.2 → 1.9.4

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.
Files changed (142) hide show
  1. package/dist/app/layout.jsx +13 -0
  2. package/dist/app/page.jsx +25 -0
  3. package/dist/build/types/app/layout.d.ts +12 -0
  4. package/dist/build/types/app/layout.js +22 -0
  5. package/dist/build/types/app/page.d.ts +12 -0
  6. package/dist/build/types/app/page.js +22 -0
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.js +4 -0
  9. package/dist/src/components/Accordion/Accordion.stories.jsx +33 -0
  10. package/dist/src/components/Accordion/accordion.jsx +59 -0
  11. package/dist/src/components/Alerts/Alert/alert.jsx +152 -0
  12. package/dist/src/components/Alerts/Alert/alert.stories.jsx +344 -0
  13. package/dist/src/components/Alerts/AlertDialog/alert-dialog.jsx +170 -0
  14. package/dist/src/components/Alerts/AlertDialog/alert-dialog.stories.jsx +552 -0
  15. package/dist/src/components/AppIcons/AndroidIcon.jsx +24 -0
  16. package/dist/src/components/AppIcons/AppIcon.jsx +29 -0
  17. package/dist/src/components/AppIcons/AppIcon.stories.jsx +223 -0
  18. package/dist/src/components/AppIcons/AppleIcon.jsx +31 -0
  19. package/dist/src/components/AppIcons/PlayStoreIcon.jsx +29 -0
  20. package/dist/src/components/Avatar/Avatar/Avatar.jsx +45 -0
  21. package/dist/src/components/Avatar/Avatar/Avatar.stories.jsx +95 -0
  22. package/dist/src/components/Avatar/Avatar/Avatar.test.jsx +9 -0
  23. package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.jsx +17 -0
  24. package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.stories.jsx +32 -0
  25. package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.jsx +20 -0
  26. package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.stories.jsx +50 -0
  27. package/dist/src/components/Badge/Badge.jsx +54 -0
  28. package/dist/src/components/Badge/Badge.stories.jsx +201 -0
  29. package/dist/src/components/Button/Button/Button.d.ts +7 -6
  30. package/dist/src/components/Button/Button/Button.js +32 -9
  31. package/dist/src/components/Button/Button/Button.jsx +101 -0
  32. package/dist/src/components/Button/Button/Button.stories.jsx +283 -0
  33. package/dist/src/components/Button/Button/Button.test.jsx +73 -0
  34. package/dist/src/components/Button/IconButton/IconButton.jsx +63 -0
  35. package/dist/src/components/Button/IconButton/IconButton.stories.jsx +128 -0
  36. package/dist/src/components/Button/IconButton/IconButton.test.jsx +28 -0
  37. package/dist/src/components/Button/index.js +3 -3
  38. package/dist/src/components/Card/MultipleNews/MultiNews.jsx +80 -0
  39. package/dist/src/components/Card/MultipleNews/MultiNews.stories.jsx +104 -0
  40. package/dist/src/components/Card/PostByCategory/PostByCategory.jsx +60 -0
  41. package/dist/src/components/Card/PostByCategory/PostByCategory.stories.jsx +106 -0
  42. package/dist/src/components/Card/SinglePost/SinglePost.jsx +26 -0
  43. package/dist/src/components/Card/SinglePost/SinglePost.stories.jsx +68 -0
  44. package/dist/src/components/Card/card.jsx +36 -0
  45. package/dist/src/components/Card/contactProfile/ContactProfile.jsx +60 -0
  46. package/dist/src/components/Card/contactProfile/ContactProfile.stories.jsx +103 -0
  47. package/dist/src/components/Card/photoAlbum/PhotoAlbum.jsx +41 -0
  48. package/dist/src/components/Card/photoAlbum/PhotoAlbum.stories.jsx +69 -0
  49. package/dist/src/components/Card/photoGallery/PhotoGallery.jsx +17 -0
  50. package/dist/src/components/Card/photoGallery/PhotoGallery.stories.jsx +39 -0
  51. package/dist/src/components/Checkbox/checkbox.jsx +47 -0
  52. package/dist/src/components/Checkbox/checkbox.stories.jsx +113 -0
  53. package/dist/src/components/ColorPicker/ColorPicker.jsx +67 -0
  54. package/dist/src/components/ColorPicker/ColorPicker.stories.jsx +138 -0
  55. package/dist/src/components/Colors/color.jsx +5 -0
  56. package/dist/src/components/Colors/color.stories.jsx +20 -0
  57. package/dist/src/components/Colors/color.test.jsx +23 -0
  58. package/dist/src/components/Dropdown/Combobox/Combobox.jsx +198 -0
  59. package/dist/src/components/Dropdown/Combobox/Combobox.stories.jsx +289 -0
  60. package/dist/src/components/Dropdown/Combobox/utils/renderBadge.jsx +7 -0
  61. package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.jsx +102 -0
  62. package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.stories.jsx +464 -0
  63. package/dist/src/components/Dropdown/DropdownMenu/SelectAllSection.jsx +19 -0
  64. package/dist/src/components/Dropdown/Select.stories.jsx +201 -0
  65. package/dist/src/components/Dropdown/select.jsx +93 -0
  66. package/dist/src/components/Icons/LUIcon.jsx +41 -0
  67. package/dist/src/components/Icons/LUIcon.test.jsx +308 -0
  68. package/dist/src/components/Icons/stories/IconDropdown.jsx +67 -0
  69. package/dist/src/components/Icons/stories/IconGallery.jsx +77 -0
  70. package/dist/src/components/Icons/stories/InteractiveIconSelector.jsx +86 -0
  71. package/dist/src/components/Icons/stories/LUIcon.stories.jsx +108 -0
  72. package/dist/src/components/ImageUploader/ImageUploader.stories.jsx +50 -0
  73. package/dist/src/components/ImageUploader/imageUploader.jsx +94 -0
  74. package/dist/src/components/Images/LuImage.jsx +19 -0
  75. package/dist/src/components/Images/LuImage.stories.jsx +154 -0
  76. package/dist/src/components/Images/LuImage.test.jsx +44 -0
  77. package/dist/src/components/Input/Input.stories.jsx +250 -0
  78. package/dist/src/components/Input/input.jsx +110 -0
  79. package/dist/src/components/Label/Label.jsx +32 -0
  80. package/dist/src/components/Label/Label.stories.jsx +30 -0
  81. package/dist/src/components/Pagination/pagination.d.ts +33 -0
  82. package/dist/src/components/Pagination/pagination.js +68 -0
  83. package/dist/src/components/Pagination/pagination.jsx +68 -0
  84. package/dist/src/components/Pagination/pagination.stories.d.ts +74 -0
  85. package/dist/src/components/Pagination/pagination.stories.js +168 -0
  86. package/dist/src/components/Pagination/pagination.stories.jsx +114 -0
  87. package/dist/src/components/RadioGroup/RadioGroup.stories.jsx +146 -0
  88. package/dist/src/components/RadioGroup/radio-group.jsx +49 -0
  89. package/dist/src/components/Skeleton/skeleton.d.ts +117 -0
  90. package/dist/src/components/Skeleton/skeleton.js +140 -0
  91. package/dist/src/components/Skeleton/skeleton.stories.d.ts +153 -0
  92. package/dist/src/components/Skeleton/skeleton.stories.js +404 -0
  93. package/dist/src/components/Slider/Slider.stories.jsx +159 -0
  94. package/dist/src/components/Slider/slider.jsx +31 -0
  95. package/dist/src/components/SweetAlert/SweetAlert.jsx +147 -0
  96. package/dist/src/components/SweetAlert/SweetAlert.stories.jsx +505 -0
  97. package/dist/src/components/Switch/Switch.stories.jsx +66 -0
  98. package/dist/src/components/Switch/switch.jsx +61 -0
  99. package/dist/src/components/Table/Table.d.ts +26 -0
  100. package/dist/src/components/Table/Table.js +186 -0
  101. package/dist/src/components/Table/Table.jsx +221 -0
  102. package/dist/src/components/Table/Table.stories.d.ts +51 -0
  103. package/dist/src/components/Table/Table.stories.js +408 -0
  104. package/dist/src/components/Table/Table.stories.jsx +652 -0
  105. package/dist/src/components/Table/index.d.ts +20 -0
  106. package/dist/src/components/Table/index.js +20 -0
  107. package/dist/src/components/Tabs/Tabs.stories.jsx +29 -0
  108. package/dist/src/components/Tabs/tabs.jsx +32 -0
  109. package/dist/src/components/Title/Title.jsx +8 -0
  110. package/dist/src/components/Title/Title.stories.jsx +37 -0
  111. package/dist/src/components/Title/Title.test.jsx +24 -0
  112. package/dist/src/components/ToolTip/Tooltip.jsx +18 -0
  113. package/dist/src/components/ToolTip/Tooltip.stories.jsx +25 -0
  114. package/dist/src/components/Typography/Body/Body.stories.jsx +34 -0
  115. package/dist/src/components/Typography/Body/body.jsx +52 -0
  116. package/dist/src/components/Typography/Caption/Caption.stories.jsx +24 -0
  117. package/dist/src/components/Typography/Caption/caption.jsx +25 -0
  118. package/dist/src/components/Typography/Display/Display.stories.jsx +24 -0
  119. package/dist/src/components/Typography/Display/display.jsx +39 -0
  120. package/dist/src/components/Typography/Heading/Heading.stories.jsx +37 -0
  121. package/dist/src/components/Typography/Heading/heading.jsx +53 -0
  122. package/dist/src/components/ui/avatar.d.ts +3 -10
  123. package/dist/src/components/ui/avatar.js +12 -27
  124. package/dist/src/components/ui/avatar.jsx +27 -0
  125. package/dist/src/components/ui/button.d.ts +10 -0
  126. package/dist/src/components/ui/button.js +56 -0
  127. package/dist/src/components/ui/button.jsx +45 -0
  128. package/dist/src/components/ui/collapsible.d.ts +5 -0
  129. package/dist/src/components/ui/collapsible.js +5 -0
  130. package/dist/src/components/ui/collapsible.jsx +5 -0
  131. package/dist/src/components/ui/command.jsx +67 -0
  132. package/dist/src/components/ui/dialog.jsx +66 -0
  133. package/dist/src/components/ui/popover.jsx +33 -0
  134. package/dist/src/components/ui/tooltip.jsx +38 -0
  135. package/dist/src/components/ui/typography.jsx +56 -0
  136. package/dist/src/utils/colors.js +11 -11
  137. package/dist/src/utils/iconList.d.ts +4 -0
  138. package/dist/src/utils/iconList.js +4 -0
  139. package/dist/styles/global.css +209 -67
  140. package/package.json +1 -1
  141. package/dist/src/components/Avatar/Avatar/Avatar1.stories.d.ts +0 -17
  142. package/dist/src/components/Avatar/Avatar/Avatar1.stories.js +0 -68
@@ -0,0 +1,66 @@
1
+ import { size, Switch, variant } from "./switch";
2
+ export default {
3
+ title: "Components/Switch",
4
+ component: Switch,
5
+ tags: ["autodocs"],
6
+ };
7
+ var Template = function (args) { return <Switch {...args}></Switch>; };
8
+ export var _Switch = Template.bind({});
9
+ _Switch.args = {
10
+ size: "md",
11
+ variant: "default",
12
+ defaultChecked: false,
13
+ onCheckedChange: function (checked) {
14
+ return console.log("Switch is ".concat(checked ? "on" : "off"));
15
+ },
16
+ };
17
+ _Switch.argTypes = {
18
+ variant: {
19
+ control: { type: "select" },
20
+ options: Object.keys(variant),
21
+ description: "Switch variant",
22
+ table: {
23
+ defaultValue: { summary: "default" },
24
+ type: { summary: "string" },
25
+ },
26
+ },
27
+ size: {
28
+ control: { type: "select" },
29
+ options: Object.keys(size),
30
+ description: "Switch size",
31
+ table: {
32
+ defaultValue: { summary: "md" },
33
+ type: { summary: "string" },
34
+ },
35
+ },
36
+ defaultChecked: {
37
+ control: { type: "boolean" },
38
+ description: "Initial checked state for uncontrolled switch",
39
+ table: {
40
+ defaultValue: { summary: "false" },
41
+ type: { summary: "boolean" },
42
+ },
43
+ },
44
+ checked: {
45
+ control: { type: "boolean" },
46
+ description: "Controlled checked state (e.g., checked={field.value} for form libraries)",
47
+ table: {
48
+ type: { summary: "boolean" },
49
+ },
50
+ },
51
+ onCheckedChange: {
52
+ action: "checked changed",
53
+ description: "Callback function when switch state changes",
54
+ table: {
55
+ type: { summary: "(checked: boolean) => void" },
56
+ },
57
+ },
58
+ disabled: {
59
+ control: { type: "boolean" },
60
+ description: "Disables the switch",
61
+ table: {
62
+ defaultValue: { summary: "false" },
63
+ type: { summary: "boolean" },
64
+ },
65
+ },
66
+ };
@@ -0,0 +1,61 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import * as React from "react";
13
+ import * as SwitchPrimitive from "@radix-ui/react-switch";
14
+ import { cva } from "class-variance-authority";
15
+ import { cn } from "../../lib/utils";
16
+ export var size = {
17
+ sm: "h-4 w-6",
18
+ md: "w-12 h-6", // default
19
+ lg: "h-6 w-14",
20
+ };
21
+ export var variant = {
22
+ default: "data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 focus-visible:ring-ring/50 focus-visible:border-ring",
23
+ primary: "data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80 focus-visible:ring-ring/50 focus-visible:border-ring",
24
+ success: "data-[state=checked]:bg-green-500 data-[state=unchecked]:bg-input focus-visible:ring-green-500",
25
+ danger: "data-[state=checked]:bg-red-500 data-[state=unchecked]:bg-input focus-visible:ring-red-500",
26
+ };
27
+ var switchVariants = cva("peer inline-flex shrink-0 items-center !rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", {
28
+ variants: {
29
+ size: size,
30
+ variant: variant,
31
+ },
32
+ defaultVariants: {
33
+ size: "md",
34
+ variant: "default",
35
+ },
36
+ });
37
+ var thumbVariants = cva("pointer-events-none block !rounded-full ring-0 transition-transform", {
38
+ variants: {
39
+ size: {
40
+ sm: "size-3",
41
+ md: "size-4", // default
42
+ lg: "size-5",
43
+ },
44
+ },
45
+ defaultVariants: {
46
+ size: "md",
47
+ },
48
+ });
49
+ // Define translate distance for each size
50
+ var thumbTranslateVariants = {
51
+ sm: "data-[state=unchecked]:translate-x-0 data-[state=checked]:translate-x-2",
52
+ md: "data-[state=unchecked]:translate-x-0.5 data-[state=checked]:translate-x-7",
53
+ lg: "data-[state=unchecked]:translate-x-0.5 data-[state=checked]:translate-x-8",
54
+ };
55
+ function Switch(_a) {
56
+ var className = _a.className, size = _a.size, variant = _a.variant, props = __rest(_a, ["className", "size", "variant"]);
57
+ return (<SwitchPrimitive.Root data-slot="switch" className={cn(switchVariants({ size: size, variant: variant }), className)} {...props}>
58
+ <SwitchPrimitive.Thumb data-slot="switch-thumb" className={cn(thumbVariants({ size: size }), size ? thumbTranslateVariants[size] : "", "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground")}/>
59
+ </SwitchPrimitive.Root>);
60
+ }
61
+ export { Switch };
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ import { tableSize } from "./index";
3
+ type TableSize = keyof typeof tableSize;
4
+ declare const Table: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableElement> & {
5
+ size?: TableSize;
6
+ columnMinWidth?: number;
7
+ columns?: Array<{
8
+ key: string;
9
+ header: string;
10
+ }>;
11
+ hasActionColumn?: boolean;
12
+ } & React.RefAttributes<HTMLTableElement>>;
13
+ declare const TableHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
14
+ declare const TableBody: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
15
+ declare const TableFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
16
+ declare const TableRow: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableRowElement> & {
17
+ collapsibleContent?: React.ReactNode;
18
+ showTrigger?: boolean;
19
+ data?: Record<string, unknown>;
20
+ } & React.RefAttributes<HTMLTableRowElement>>;
21
+ declare const TableHead: React.ForwardRefExoticComponent<React.ThHTMLAttributes<HTMLTableCellElement> & {
22
+ size?: TableSize;
23
+ } & React.RefAttributes<HTMLTableCellElement>>;
24
+ declare const TableCell: React.ForwardRefExoticComponent<React.TdHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>>;
25
+ declare const TableCaption: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableCaptionElement> & React.RefAttributes<HTMLTableCaptionElement>>;
26
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
@@ -0,0 +1,186 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
+ if (ar || !(i in from)) {
26
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
+ ar[i] = from[i];
28
+ }
29
+ }
30
+ return to.concat(ar || Array.prototype.slice.call(from));
31
+ };
32
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
33
+ import * as React from "react";
34
+ import { cn } from "../../lib/utils";
35
+ import { tableSize, tableBodySize, tableFooterSize, collapsibleIconSize, } from "./index";
36
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "../ui/collapsible";
37
+ import LUIcon from "../Icons/LUIcon";
38
+ var TableSizeContext = React.createContext("sm");
39
+ var TableSectionContext = React.createContext("body");
40
+ var TableResponsiveContext = React.createContext({
41
+ visibleCount: 0,
42
+ totalColumns: 0,
43
+ columnMinWidth: 160,
44
+ isResponsive: false,
45
+ columns: [],
46
+ hasActionColumn: false,
47
+ });
48
+ var Table = React.forwardRef(function (_a, ref) {
49
+ var className = _a.className, _b = _a.size, size = _b === void 0 ? "sm" : _b, _c = _a.columnMinWidth, columnMinWidth = _c === void 0 ? 160 : _c, _d = _a.columns, columns = _d === void 0 ? [] : _d, _e = _a.hasActionColumn, hasActionColumn = _e === void 0 ? false : _e, props = __rest(_a, ["className", "size", "columnMinWidth", "columns", "hasActionColumn"]);
50
+ var totalColumns = columns.length + (hasActionColumn ? 1 : 0);
51
+ var isResponsive = totalColumns > 0;
52
+ // Calculate initial visible count based on responsive settings
53
+ var getInitialVisibleCount = function () {
54
+ if (!isResponsive || totalColumns === 0) {
55
+ return totalColumns;
56
+ }
57
+ // For SSR compatibility, assume a default width if window is not available
58
+ var windowWidth = typeof window !== "undefined" ? window.innerWidth : 1200;
59
+ var calculated = Math.floor(windowWidth / columnMinWidth);
60
+ // Ensure at least 1 data column is visible (account for trigger column)
61
+ return Math.max(1, Math.min(totalColumns, calculated - 1));
62
+ };
63
+ var _f = React.useState(getInitialVisibleCount), visibleCount = _f[0], setVisibleCount = _f[1];
64
+ React.useEffect(function () {
65
+ if (!isResponsive || totalColumns === 0) {
66
+ setVisibleCount(totalColumns);
67
+ return;
68
+ }
69
+ var calculate = function () {
70
+ var count = Math.floor(window.innerWidth / columnMinWidth);
71
+ // Ensure at least 1 data column is visible (plus the trigger column)
72
+ setVisibleCount(Math.max(1, Math.min(totalColumns, count - 1)));
73
+ };
74
+ calculate();
75
+ window.addEventListener("resize", calculate);
76
+ return function () { return window.removeEventListener("resize", calculate); };
77
+ }, [isResponsive, totalColumns, columnMinWidth]);
78
+ return (_jsx(TableSizeContext.Provider, { value: size, children: _jsx(TableResponsiveContext.Provider, { value: {
79
+ visibleCount: visibleCount,
80
+ totalColumns: totalColumns,
81
+ columnMinWidth: columnMinWidth,
82
+ isResponsive: isResponsive,
83
+ columns: columns,
84
+ hasActionColumn: hasActionColumn,
85
+ }, children: _jsx("div", { className: "relative w-full overflow-auto", children: _jsx("table", __assign({ ref: ref, className: cn("w-full caption-bottom", className) }, props)) }) }) }));
86
+ });
87
+ Table.displayName = "Table";
88
+ var TableHeader = React.forwardRef(function (_a, ref) {
89
+ var _b;
90
+ var className = _a.className, props = __rest(_a, ["className"]);
91
+ var headerSize = (_b = React.useContext(TableSizeContext)) !== null && _b !== void 0 ? _b : "sm";
92
+ return (_jsx(TableSectionContext.Provider, { value: "header", children: _jsx("thead", __assign({ ref: ref, className: cn("[&_tr]:border-b bg-gray-100 overflow-hidden", className), "data-table-size": headerSize }, props)) }));
93
+ });
94
+ TableHeader.displayName = "TableHeader";
95
+ var TableBody = React.forwardRef(function (_a, ref) {
96
+ var _b;
97
+ var className = _a.className, props = __rest(_a, ["className"]);
98
+ var contextSize = (_b = React.useContext(TableSizeContext)) !== null && _b !== void 0 ? _b : "sm";
99
+ return (_jsx(TableSectionContext.Provider, { value: "body", children: _jsx("tbody", __assign({ ref: ref, className: cn(tableBodySize[contextSize], "[&_tr:last-child]:border-0 text-black", className), "data-table-body-size": contextSize }, props)) }));
100
+ });
101
+ TableBody.displayName = "TableBody";
102
+ var TableFooter = React.forwardRef(function (_a, ref) {
103
+ var _b;
104
+ var className = _a.className, props = __rest(_a, ["className"]);
105
+ var footerSize = (_b = React.useContext(TableSizeContext)) !== null && _b !== void 0 ? _b : "sm";
106
+ return (_jsx(TableSectionContext.Provider, { value: "footer", children: _jsx("tfoot", __assign({ ref: ref, className: cn(tableFooterSize[footerSize], "border-t bg-gray-100 font-medium [&>tr]:last:border-b-0", className), "data-table-footer-size": footerSize }, props)) }));
107
+ });
108
+ TableFooter.displayName = "TableFooter";
109
+ var TableRow = React.forwardRef(function (_a, ref) {
110
+ var className = _a.className, children = _a.children, collapsibleContent = _a.collapsibleContent, showTrigger = _a.showTrigger, data = _a.data, props = __rest(_a, ["className", "children", "collapsibleContent", "showTrigger", "data"]);
111
+ var bodySize = React.useContext(TableSizeContext);
112
+ var _b = useTableResponsive(), visibleCount = _b.visibleCount, isResponsive = _b.isResponsive, columns = _b.columns, hasActionColumn = _b.hasActionColumn;
113
+ var section = React.useContext(TableSectionContext);
114
+ var childrenArray = React.useMemo(function () { return React.Children.toArray(children); }, [children]);
115
+ var hasDefinedColumns = Array.isArray(columns) && columns.length > 0;
116
+ var hasHiddenColumns = hasDefinedColumns && visibleCount < columns.length;
117
+ var slicedChildren = React.useMemo(function () {
118
+ if (!isResponsive || !hasHiddenColumns)
119
+ return childrenArray;
120
+ if (hasActionColumn) {
121
+ // Show first (visibleCount - 1) columns + the last column (actions)
122
+ var firstColumns = childrenArray.slice(0, visibleCount - 1);
123
+ var lastColumn = childrenArray[childrenArray.length - 1];
124
+ return __spreadArray(__spreadArray([], firstColumns, true), [lastColumn], false);
125
+ }
126
+ return childrenArray.slice(0, visibleCount);
127
+ }, [
128
+ childrenArray,
129
+ isResponsive,
130
+ hasHiddenColumns,
131
+ visibleCount,
132
+ hasActionColumn,
133
+ ]);
134
+ // Auto-generate collapsible content for responsive tables
135
+ var autoCollapsibleContent = React.useMemo(function () {
136
+ if (!isResponsive || !data || !columns || columns.length === 0) {
137
+ return null;
138
+ }
139
+ var hiddenColumns;
140
+ if (hasActionColumn) {
141
+ // Hide columns from (visibleCount - 1) to (columns.length - 2), excluding the last action column
142
+ hiddenColumns = columns.slice(visibleCount - 1, columns.length - 1);
143
+ }
144
+ else {
145
+ hiddenColumns = columns.slice(visibleCount);
146
+ }
147
+ if (hiddenColumns.length === 0)
148
+ return null;
149
+ return (_jsx(Table, { className: "w-full", children: _jsx(TableBody, { children: hiddenColumns.map(function (col) { return (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium w-1/3 border-r border-gray-200", children: col.header }), _jsx(TableCell, { className: "w-2/3", children: String(data[col.key]) })] }, col.key)); }) }) }));
150
+ }, [isResponsive, data, columns, visibleCount, hasActionColumn]);
151
+ var finalCollapsibleContent = collapsibleContent || autoCollapsibleContent;
152
+ var finalShowTrigger = showTrigger !== null && showTrigger !== void 0 ? showTrigger : autoCollapsibleContent !== null;
153
+ // State to track if collapsible is open
154
+ var _c = React.useState(false), isOpen = _c[0], setIsOpen = _c[1];
155
+ if (section === "header") {
156
+ return (_jsxs("tr", __assign({ ref: ref, className: cn(tableBodySize[bodySize !== null && bodySize !== void 0 ? bodySize : "sm"], "border-b border-gray-200", className) }, props, { children: [isResponsive && hasHiddenColumns && (_jsx("th", { className: "p-2 align-middle w-[52px] bg-gray-100" })), slicedChildren] })));
157
+ }
158
+ if (finalCollapsibleContent) {
159
+ return (_jsx(Collapsible, { asChild: true, onOpenChange: setIsOpen, children: _jsxs(_Fragment, { children: [_jsxs("tr", __assign({ ref: ref, className: cn(tableBodySize[bodySize !== null && bodySize !== void 0 ? bodySize : "sm"], "border-b border-gray-200 cursor-pointer transition-colors hover:bg-gray-50 data-[state=selected]:bg-gray-50 odd:bg-white even:bg-gray-50 group", className) }, props, { children: [isResponsive && (_jsx("td", { className: "p-2 align-middle w-[52px]", children: finalShowTrigger && (_jsx(CollapsibleTrigger, { asChild: true, children: _jsx(LUIcon, { icon: isOpen ? "angle-up" : "angle-right", size: collapsibleIconSize[bodySize], color: "blue" }) })) })), slicedChildren] })), _jsx(CollapsibleContent, { asChild: true, children: _jsx("tr", { className: "bg-gray-50", children: _jsx("td", { colSpan: visibleCount + (isResponsive ? 1 : 0), className: "p-0", children: finalCollapsibleContent }) }) })] }) }));
160
+ }
161
+ return (_jsx("tr", __assign({ ref: ref, className: cn(tableBodySize[bodySize !== null && bodySize !== void 0 ? bodySize : "sm"], "border-b border-gray-200 cursor-pointer transition-colors hover:bg-gray-50 data-[state=selected]:bg-gray-50 odd:bg-white even:bg-gray-50 group", className) }, props, { children: slicedChildren })));
162
+ });
163
+ TableRow.displayName = "TableRow";
164
+ var TableHead = React.forwardRef(function (_a, ref) {
165
+ var _b;
166
+ var className = _a.className, size = _a.size, children = _a.children, props = __rest(_a, ["className", "size", "children"]);
167
+ var contextSize = React.useContext(TableSizeContext);
168
+ var headSize = (_b = size !== null && size !== void 0 ? size : contextSize) !== null && _b !== void 0 ? _b : "sm";
169
+ return (_jsx("th", __assign({ ref: ref, className: cn(tableSize[headSize], "py-0 px-3 text-left align-middle font-semibold text-gray-950 bg-gray-100 first:rounded-tl-lg last:rounded-tr-lg [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className) }, props, { children: _jsx("div", { className: "flex items-center gap-2", children: children }) })));
170
+ });
171
+ TableHead.displayName = "TableHead";
172
+ var TableCell = React.forwardRef(function (_a, ref) {
173
+ var className = _a.className, props = __rest(_a, ["className"]);
174
+ return (_jsx("td", __assign({ ref: ref, className: cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] first-of-type:border-l-2 first-of-type:border-l-transparent group-hover:first-of-type:border-l-blue-600 group-data-[state=selected]:first-of-type:border-l-blue-600", className) }, props)));
175
+ });
176
+ TableCell.displayName = "TableCell";
177
+ var TableCaption = React.forwardRef(function (_a, ref) {
178
+ var className = _a.className, props = __rest(_a, ["className"]);
179
+ return (_jsx("caption", __assign({ ref: ref, className: cn("mt-4 text-sm text-muted-foreground", className) }, props)));
180
+ });
181
+ TableCaption.displayName = "TableCaption";
182
+ var useTableResponsive = function () {
183
+ var context = React.useContext(TableResponsiveContext);
184
+ return context;
185
+ };
186
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
@@ -0,0 +1,221 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import * as React from "react";
22
+ import { cn } from "../../lib/utils";
23
+ import { tableSize, tableBodySize, tableFooterSize, collapsibleIconSize, } from "./index";
24
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "../ui/collapsible";
25
+ import LUIcon from "../Icons/LUIcon";
26
+ var TableSizeContext = React.createContext("sm");
27
+ var TableSectionContext = React.createContext("body");
28
+ var TableResponsiveContext = React.createContext({
29
+ visibleCount: 0,
30
+ totalColumns: 0,
31
+ columnMinWidth: 160,
32
+ isResponsive: false,
33
+ columns: [],
34
+ hasActionColumn: false,
35
+ });
36
+ var Table = React.forwardRef(function (_a, ref) {
37
+ var className = _a.className, _b = _a.size, size = _b === void 0 ? "sm" : _b, _c = _a.columnMinWidth, columnMinWidth = _c === void 0 ? 160 : _c, _d = _a.columns, columns = _d === void 0 ? [] : _d, _e = _a.hasActionColumn, hasActionColumn = _e === void 0 ? false : _e, props = __rest(_a, ["className", "size", "columnMinWidth", "columns", "hasActionColumn"]);
38
+ var totalColumns = columns.length + (hasActionColumn ? 1 : 0);
39
+ var isResponsive = totalColumns > 0;
40
+ // Calculate initial visible count based on responsive settings
41
+ var getInitialVisibleCount = function () {
42
+ if (!isResponsive || totalColumns === 0) {
43
+ return totalColumns;
44
+ }
45
+ // For SSR compatibility, assume a default width if window is not available
46
+ var windowWidth = typeof window !== "undefined" ? window.innerWidth : 1200;
47
+ var calculated = Math.floor(windowWidth / columnMinWidth);
48
+ // Ensure at least 1 data column is visible (account for trigger column)
49
+ return Math.max(1, Math.min(totalColumns, calculated - 1));
50
+ };
51
+ var _f = React.useState(getInitialVisibleCount), visibleCount = _f[0], setVisibleCount = _f[1];
52
+ React.useEffect(function () {
53
+ if (!isResponsive || totalColumns === 0) {
54
+ setVisibleCount(totalColumns);
55
+ return;
56
+ }
57
+ var calculate = function () {
58
+ var count = Math.floor(window.innerWidth / columnMinWidth);
59
+ // Ensure at least 1 data column is visible (plus the trigger column)
60
+ setVisibleCount(Math.max(1, Math.min(totalColumns, count - 1)));
61
+ };
62
+ calculate();
63
+ window.addEventListener("resize", calculate);
64
+ return function () { return window.removeEventListener("resize", calculate); };
65
+ }, [isResponsive, totalColumns, columnMinWidth]);
66
+ return (<TableSizeContext.Provider value={size}>
67
+ <TableResponsiveContext.Provider value={{
68
+ visibleCount: visibleCount,
69
+ totalColumns: totalColumns,
70
+ columnMinWidth: columnMinWidth,
71
+ isResponsive: isResponsive,
72
+ columns: columns,
73
+ hasActionColumn: hasActionColumn,
74
+ }}>
75
+ <div className="relative w-full overflow-auto">
76
+ <table ref={ref} className={cn("w-full caption-bottom", className)} {...props}/>
77
+ </div>
78
+ </TableResponsiveContext.Provider>
79
+ </TableSizeContext.Provider>);
80
+ });
81
+ Table.displayName = "Table";
82
+ var TableHeader = React.forwardRef(function (_a, ref) {
83
+ var _b;
84
+ var className = _a.className, props = __rest(_a, ["className"]);
85
+ var headerSize = (_b = React.useContext(TableSizeContext)) !== null && _b !== void 0 ? _b : "sm";
86
+ return (<TableSectionContext.Provider value="header">
87
+ <thead ref={ref} className={cn("[&_tr]:border-b bg-gray-100 overflow-hidden", className)} data-table-size={headerSize} {...props}/>
88
+ </TableSectionContext.Provider>);
89
+ });
90
+ TableHeader.displayName = "TableHeader";
91
+ var TableBody = React.forwardRef(function (_a, ref) {
92
+ var _b;
93
+ var className = _a.className, props = __rest(_a, ["className"]);
94
+ var contextSize = (_b = React.useContext(TableSizeContext)) !== null && _b !== void 0 ? _b : "sm";
95
+ return (<TableSectionContext.Provider value="body">
96
+ <tbody ref={ref} className={cn(tableBodySize[contextSize], "[&_tr:last-child]:border-0 text-black", className)} data-table-body-size={contextSize} {...props}/>
97
+ </TableSectionContext.Provider>);
98
+ });
99
+ TableBody.displayName = "TableBody";
100
+ var TableFooter = React.forwardRef(function (_a, ref) {
101
+ var _b;
102
+ var className = _a.className, props = __rest(_a, ["className"]);
103
+ var footerSize = (_b = React.useContext(TableSizeContext)) !== null && _b !== void 0 ? _b : "sm";
104
+ return (<TableSectionContext.Provider value="footer">
105
+ <tfoot ref={ref} className={cn(tableFooterSize[footerSize], "border-t bg-gray-100 font-medium [&>tr]:last:border-b-0", className)} data-table-footer-size={footerSize} {...props}/>
106
+ </TableSectionContext.Provider>);
107
+ });
108
+ TableFooter.displayName = "TableFooter";
109
+ var TableRow = React.forwardRef(function (_a, ref) {
110
+ var className = _a.className, children = _a.children, collapsibleContent = _a.collapsibleContent, showTrigger = _a.showTrigger, data = _a.data, props = __rest(_a, ["className", "children", "collapsibleContent", "showTrigger", "data"]);
111
+ var bodySize = React.useContext(TableSizeContext);
112
+ var _b = useTableResponsive(), visibleCount = _b.visibleCount, isResponsive = _b.isResponsive, columns = _b.columns, hasActionColumn = _b.hasActionColumn;
113
+ var section = React.useContext(TableSectionContext);
114
+ var childrenArray = React.useMemo(function () { return React.Children.toArray(children); }, [children]);
115
+ var hasDefinedColumns = Array.isArray(columns) && columns.length > 0;
116
+ var hasHiddenColumns = hasDefinedColumns && visibleCount < columns.length;
117
+ var slicedChildren = React.useMemo(function () {
118
+ if (!isResponsive || !hasHiddenColumns)
119
+ return childrenArray;
120
+ if (hasActionColumn) {
121
+ // Show first (visibleCount - 1) columns + the last column (actions)
122
+ var firstColumns = childrenArray.slice(0, visibleCount - 1);
123
+ var lastColumn = childrenArray[childrenArray.length - 1];
124
+ return __spreadArray(__spreadArray([], firstColumns, true), [lastColumn], false);
125
+ }
126
+ return childrenArray.slice(0, visibleCount);
127
+ }, [
128
+ childrenArray,
129
+ isResponsive,
130
+ hasHiddenColumns,
131
+ visibleCount,
132
+ hasActionColumn,
133
+ ]);
134
+ // Auto-generate collapsible content for responsive tables
135
+ var autoCollapsibleContent = React.useMemo(function () {
136
+ if (!isResponsive || !data || !columns || columns.length === 0) {
137
+ return null;
138
+ }
139
+ var hiddenColumns;
140
+ if (hasActionColumn) {
141
+ // Hide columns from (visibleCount - 1) to (columns.length - 2), excluding the last action column
142
+ hiddenColumns = columns.slice(visibleCount - 1, columns.length - 1);
143
+ }
144
+ else {
145
+ hiddenColumns = columns.slice(visibleCount);
146
+ }
147
+ if (hiddenColumns.length === 0)
148
+ return null;
149
+ return (<Table className="w-full">
150
+ <TableBody>
151
+ {hiddenColumns.map(function (col) { return (<TableRow key={col.key}>
152
+ <TableCell className="font-medium w-1/3 border-r border-gray-200">
153
+ {col.header}
154
+ </TableCell>
155
+ <TableCell className="w-2/3">{String(data[col.key])}</TableCell>
156
+ </TableRow>); })}
157
+ </TableBody>
158
+ </Table>);
159
+ }, [isResponsive, data, columns, visibleCount, hasActionColumn]);
160
+ var finalCollapsibleContent = collapsibleContent || autoCollapsibleContent;
161
+ var finalShowTrigger = showTrigger !== null && showTrigger !== void 0 ? showTrigger : autoCollapsibleContent !== null;
162
+ // State to track if collapsible is open
163
+ var _c = React.useState(false), isOpen = _c[0], setIsOpen = _c[1];
164
+ if (section === "header") {
165
+ return (<tr ref={ref} className={cn(tableBodySize[bodySize !== null && bodySize !== void 0 ? bodySize : "sm"], "border-b border-gray-200", className)} {...props}>
166
+ {isResponsive && hasHiddenColumns && (<th className="p-2 align-middle w-[52px] bg-gray-100"></th>)}
167
+ {slicedChildren}
168
+ </tr>);
169
+ }
170
+ if (finalCollapsibleContent) {
171
+ return (<Collapsible asChild onOpenChange={setIsOpen}>
172
+ <>
173
+ <tr ref={ref} className={cn(tableBodySize[bodySize !== null && bodySize !== void 0 ? bodySize : "sm"], "border-b border-gray-200 cursor-pointer transition-colors hover:bg-gray-50 data-[state=selected]:bg-gray-50 odd:bg-white even:bg-gray-50 group", className)} {...props}>
174
+ {isResponsive && (<td className="p-2 align-middle w-[52px]">
175
+ {finalShowTrigger && (<CollapsibleTrigger asChild>
176
+ <LUIcon icon={isOpen ? "angle-up" : "angle-right"} size={collapsibleIconSize[bodySize]} color="blue"/>
177
+ </CollapsibleTrigger>)}
178
+ </td>)}
179
+ {slicedChildren}
180
+ </tr>
181
+
182
+ <CollapsibleContent asChild>
183
+ <tr className="bg-gray-50">
184
+ <td colSpan={visibleCount + (isResponsive ? 1 : 0)} className="p-0">
185
+ {finalCollapsibleContent}
186
+ </td>
187
+ </tr>
188
+ </CollapsibleContent>
189
+ </>
190
+ </Collapsible>);
191
+ }
192
+ return (<tr ref={ref} className={cn(tableBodySize[bodySize !== null && bodySize !== void 0 ? bodySize : "sm"], "border-b border-gray-200 cursor-pointer transition-colors hover:bg-gray-50 data-[state=selected]:bg-gray-50 odd:bg-white even:bg-gray-50 group", className)} {...props}>
193
+ {slicedChildren}
194
+ </tr>);
195
+ });
196
+ TableRow.displayName = "TableRow";
197
+ var TableHead = React.forwardRef(function (_a, ref) {
198
+ var _b;
199
+ var className = _a.className, size = _a.size, children = _a.children, props = __rest(_a, ["className", "size", "children"]);
200
+ var contextSize = React.useContext(TableSizeContext);
201
+ var headSize = (_b = size !== null && size !== void 0 ? size : contextSize) !== null && _b !== void 0 ? _b : "sm";
202
+ return (<th ref={ref} className={cn(tableSize[headSize], "py-0 px-3 text-left align-middle font-semibold text-gray-950 bg-gray-100 first:rounded-tl-lg last:rounded-tr-lg [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className)} {...props}>
203
+ <div className="flex items-center gap-2">{children}</div>
204
+ </th>);
205
+ });
206
+ TableHead.displayName = "TableHead";
207
+ var TableCell = React.forwardRef(function (_a, ref) {
208
+ var className = _a.className, props = __rest(_a, ["className"]);
209
+ return (<td ref={ref} className={cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] first-of-type:border-l-2 first-of-type:border-l-transparent group-hover:first-of-type:border-l-blue-600 group-data-[state=selected]:first-of-type:border-l-blue-600", className)} {...props}/>);
210
+ });
211
+ TableCell.displayName = "TableCell";
212
+ var TableCaption = React.forwardRef(function (_a, ref) {
213
+ var className = _a.className, props = __rest(_a, ["className"]);
214
+ return (<caption ref={ref} className={cn("mt-4 text-sm text-muted-foreground", className)} {...props}/>);
215
+ });
216
+ TableCaption.displayName = "TableCaption";
217
+ var useTableResponsive = function () {
218
+ var context = React.useContext(TableResponsiveContext);
219
+ return context;
220
+ };
221
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
@@ -0,0 +1,51 @@
1
+ import React from "react";
2
+ import type { Meta } from "@storybook/react";
3
+ import { Table } from "./Table";
4
+ declare const _default: Meta<typeof Table>;
5
+ export default _default;
6
+ export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, React.HTMLAttributes<HTMLTableElement> & {
7
+ size?: "sm" | "md" | "lg";
8
+ columnMinWidth?: number;
9
+ columns?: Array<{
10
+ key: string;
11
+ header: string;
12
+ }>;
13
+ hasActionColumn?: boolean;
14
+ } & React.RefAttributes<HTMLTableElement>>;
15
+ export declare const TableSizes: () => import("react/jsx-runtime").JSX.Element;
16
+ export declare const CheckBoxInSmallTable: () => import("react/jsx-runtime").JSX.Element;
17
+ export declare const CheckBoxInMediumTable: () => import("react/jsx-runtime").JSX.Element;
18
+ export declare const CheckBoxInLargeTable: () => import("react/jsx-runtime").JSX.Element;
19
+ export declare const SortingTable: () => import("react/jsx-runtime").JSX.Element;
20
+ export declare const BadgesInTable: {
21
+ (): import("react/jsx-runtime").JSX.Element;
22
+ parameters: {
23
+ docs: {
24
+ description: {
25
+ story: string;
26
+ };
27
+ };
28
+ };
29
+ };
30
+ export declare const DropdownInTable: {
31
+ (): import("react/jsx-runtime").JSX.Element;
32
+ parameters: {
33
+ docs: {
34
+ description: {
35
+ story: string;
36
+ };
37
+ };
38
+ };
39
+ };
40
+ export declare const ActionButtonInTable: {
41
+ (): import("react/jsx-runtime").JSX.Element;
42
+ parameters: {
43
+ docs: {
44
+ description: {
45
+ story: string;
46
+ };
47
+ };
48
+ };
49
+ };
50
+ export declare const AvatarInTable: () => import("react/jsx-runtime").JSX.Element;
51
+ export declare const ResponsiveTable: () => import("react/jsx-runtime").JSX.Element;