art-bd-ui 1.0.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.
Files changed (162) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/components/buttons/button/button.js +43 -0
  3. package/dist/cjs/components/buttons/icon-button/icon-button.js +33 -0
  4. package/dist/cjs/components/buttons/toggle/toggle.js +34 -0
  5. package/dist/cjs/components/buttons/toggle-group/toggle-group.js +31 -0
  6. package/dist/cjs/components/forms/checkbox/checkbox.js +52 -0
  7. package/dist/cjs/components/forms/input/input.js +38 -0
  8. package/dist/cjs/components/forms/label/label.js +38 -0
  9. package/dist/cjs/components/forms/radio/radio.js +22 -0
  10. package/dist/cjs/components/forms/select/select.js +72 -0
  11. package/dist/cjs/components/forms/switch/switch.js +51 -0
  12. package/dist/cjs/components/forms/textarea/textarea.js +37 -0
  13. package/dist/cjs/components/layout/box/box.js +19 -0
  14. package/dist/cjs/components/layout/flex/flex.js +14 -0
  15. package/dist/cjs/components/layout/grid/grid.js +14 -0
  16. package/dist/cjs/components/media/aspect-ratio/aspect-ratio.js +31 -0
  17. package/dist/cjs/components/media/avatar/avatar.js +27 -0
  18. package/dist/cjs/components/media/icon/icon.js +27 -0
  19. package/dist/cjs/components/popovers/dialog/dialog.js +69 -0
  20. package/dist/cjs/components/popovers/drawer/drawer.js +82 -0
  21. package/dist/cjs/components/popovers/popover/popover.js +66 -0
  22. package/dist/cjs/components/popovers/sheet/sheet.js +94 -0
  23. package/dist/cjs/components/popovers/toast/toast.js +75 -0
  24. package/dist/cjs/components/popovers/tooltip/tooltip.js +45 -0
  25. package/dist/cjs/components/typography/heading/heading.js +55 -0
  26. package/dist/cjs/components/typography/text/text.js +57 -0
  27. package/dist/cjs/components/ui/alert/alert.js +34 -0
  28. package/dist/cjs/components/ui/badge/badge.js +31 -0
  29. package/dist/cjs/components/ui/button/button.js +42 -0
  30. package/dist/cjs/components/ui/calendar/calendar.js +24 -0
  31. package/dist/cjs/components/ui/command/command.js +83 -0
  32. package/dist/cjs/components/ui/data-table/components/cell.js +24 -0
  33. package/dist/cjs/components/ui/data-table/components/column-group.js +45 -0
  34. package/dist/cjs/components/ui/data-table/components/table-body.js +47 -0
  35. package/dist/cjs/components/ui/data-table/components/table-fallback.js +28 -0
  36. package/dist/cjs/components/ui/data-table/components/table-head.js +56 -0
  37. package/dist/cjs/components/ui/data-table/components/table-placeholder.js +18 -0
  38. package/dist/cjs/components/ui/data-table/data-table.js +97 -0
  39. package/dist/cjs/components/ui/data-table/hooks/contextHooks.js +75 -0
  40. package/dist/cjs/components/ui/data-table/hooks/useStickyColumns.js +98 -0
  41. package/dist/cjs/components/ui/data-table/utils.js +26 -0
  42. package/dist/cjs/components/ui/date-picker/date-picker.js +15 -0
  43. package/dist/cjs/components/ui/dropdown-menu/dropdown-menu.js +100 -0
  44. package/dist/cjs/components/ui/icon/icon.js +27 -0
  45. package/dist/cjs/components/ui/link/link.js +32 -0
  46. package/dist/cjs/components/ui/pagination/pagination.js +51 -0
  47. package/dist/cjs/components/ui/progress/progress.js +13 -0
  48. package/dist/cjs/components/ui/sidebar/sidebar.js +331 -0
  49. package/dist/cjs/components/ui/table/components/cell.js +30 -0
  50. package/dist/cjs/components/ui/table/components/row.js +25 -0
  51. package/dist/cjs/components/ui/table/components/table-body.js +13 -0
  52. package/dist/cjs/components/ui/table/components/table-caption.js +13 -0
  53. package/dist/cjs/components/ui/table/components/table-footer.js +13 -0
  54. package/dist/cjs/components/ui/table/components/table-head.js +30 -0
  55. package/dist/cjs/components/ui/table/components/table-header.js +13 -0
  56. package/dist/cjs/components/ui/table/table.js +36 -0
  57. package/dist/cjs/components/ui/tabs/tabs.js +47 -0
  58. package/dist/cjs/components/utility/empty-state/empty-state.js +29 -0
  59. package/dist/cjs/components/utility/separator/separator.js +14 -0
  60. package/dist/cjs/components/utility/skeleton/skeleton.js +13 -0
  61. package/dist/cjs/components/utility/status-controller/status-controller.js +12 -0
  62. package/dist/cjs/hooks/use-mobile.js +21 -0
  63. package/dist/cjs/hooks/useControlled.js +19 -0
  64. package/dist/cjs/hooks/useFirstMountState.js +16 -0
  65. package/dist/cjs/hooks/useForkRef.js +23 -0
  66. package/dist/cjs/hooks/useLatest.js +12 -0
  67. package/dist/cjs/hooks/usePrevious.js +14 -0
  68. package/dist/cjs/hooks/useScrollState.js +39 -0
  69. package/dist/cjs/hooks/useStateRef.js +12 -0
  70. package/dist/cjs/hooks/useUpdateEffect.js +17 -0
  71. package/dist/cjs/index.js +237 -0
  72. package/dist/cjs/lib/utils.js +16 -0
  73. package/dist/cjs/styles/responsive.js +84 -0
  74. package/dist/cjs/styles/typography.js +25 -0
  75. package/dist/cjs/utils/addIf.js +5 -0
  76. package/dist/cjs/utils/chain.js +30 -0
  77. package/dist/cjs/utils/getBoundingRect.js +19 -0
  78. package/dist/cjs/utils/mergeProps.js +42 -0
  79. package/dist/cjs/utils/mergeRefs.js +18 -0
  80. package/dist/cjs/utils/toggle.js +16 -0
  81. package/dist/esm/components/buttons/button/button.js +40 -0
  82. package/dist/esm/components/buttons/icon-button/icon-button.js +31 -0
  83. package/dist/esm/components/buttons/toggle/toggle.js +31 -0
  84. package/dist/esm/components/buttons/toggle-group/toggle-group.js +28 -0
  85. package/dist/esm/components/forms/checkbox/checkbox.js +50 -0
  86. package/dist/esm/components/forms/input/input.js +36 -0
  87. package/dist/esm/components/forms/label/label.js +36 -0
  88. package/dist/esm/components/forms/radio/radio.js +19 -0
  89. package/dist/esm/components/forms/select/select.js +61 -0
  90. package/dist/esm/components/forms/switch/switch.js +49 -0
  91. package/dist/esm/components/forms/textarea/textarea.js +35 -0
  92. package/dist/esm/components/layout/box/box.js +17 -0
  93. package/dist/esm/components/layout/flex/flex.js +12 -0
  94. package/dist/esm/components/layout/grid/grid.js +12 -0
  95. package/dist/esm/components/media/aspect-ratio/aspect-ratio.js +10 -0
  96. package/dist/esm/components/media/avatar/avatar.js +23 -0
  97. package/dist/esm/components/media/icon/icon.js +25 -0
  98. package/dist/esm/components/popovers/dialog/dialog.js +60 -0
  99. package/dist/esm/components/popovers/drawer/drawer.js +74 -0
  100. package/dist/esm/components/popovers/popover/popover.js +61 -0
  101. package/dist/esm/components/popovers/sheet/sheet.js +86 -0
  102. package/dist/esm/components/popovers/toast/toast.js +67 -0
  103. package/dist/esm/components/popovers/tooltip/tooltip.js +40 -0
  104. package/dist/esm/components/typography/heading/heading.js +53 -0
  105. package/dist/esm/components/typography/text/text.js +55 -0
  106. package/dist/esm/components/ui/alert/alert.js +30 -0
  107. package/dist/esm/components/ui/badge/badge.js +28 -0
  108. package/dist/esm/components/ui/button/button.js +40 -0
  109. package/dist/esm/components/ui/calendar/calendar.js +22 -0
  110. package/dist/esm/components/ui/command/command.js +73 -0
  111. package/dist/esm/components/ui/data-table/components/cell.js +22 -0
  112. package/dist/esm/components/ui/data-table/components/column-group.js +43 -0
  113. package/dist/esm/components/ui/data-table/components/table-body.js +45 -0
  114. package/dist/esm/components/ui/data-table/components/table-fallback.js +26 -0
  115. package/dist/esm/components/ui/data-table/components/table-head.js +54 -0
  116. package/dist/esm/components/ui/data-table/components/table-placeholder.js +16 -0
  117. package/dist/esm/components/ui/data-table/data-table.js +95 -0
  118. package/dist/esm/components/ui/data-table/hooks/contextHooks.js +60 -0
  119. package/dist/esm/components/ui/data-table/hooks/useStickyColumns.js +96 -0
  120. package/dist/esm/components/ui/data-table/utils.js +22 -0
  121. package/dist/esm/components/ui/date-picker/date-picker.js +13 -0
  122. package/dist/esm/components/ui/dropdown-menu/dropdown-menu.js +84 -0
  123. package/dist/esm/components/ui/icon/icon.js +25 -0
  124. package/dist/esm/components/ui/link/link.js +30 -0
  125. package/dist/esm/components/ui/pagination/pagination.js +43 -0
  126. package/dist/esm/components/ui/progress/progress.js +11 -0
  127. package/dist/esm/components/ui/sidebar/sidebar.js +306 -0
  128. package/dist/esm/components/ui/table/components/cell.js +28 -0
  129. package/dist/esm/components/ui/table/components/row.js +23 -0
  130. package/dist/esm/components/ui/table/components/table-body.js +11 -0
  131. package/dist/esm/components/ui/table/components/table-caption.js +11 -0
  132. package/dist/esm/components/ui/table/components/table-footer.js +11 -0
  133. package/dist/esm/components/ui/table/components/table-head.js +28 -0
  134. package/dist/esm/components/ui/table/components/table-header.js +11 -0
  135. package/dist/esm/components/ui/table/table.js +26 -0
  136. package/dist/esm/components/ui/tabs/tabs.js +23 -0
  137. package/dist/esm/components/utility/empty-state/empty-state.js +27 -0
  138. package/dist/esm/components/utility/separator/separator.js +12 -0
  139. package/dist/esm/components/utility/skeleton/skeleton.js +11 -0
  140. package/dist/esm/components/utility/status-controller/status-controller.js +10 -0
  141. package/dist/esm/hooks/use-mobile.js +19 -0
  142. package/dist/esm/hooks/useControlled.js +17 -0
  143. package/dist/esm/hooks/useFirstMountState.js +14 -0
  144. package/dist/esm/hooks/useForkRef.js +21 -0
  145. package/dist/esm/hooks/useLatest.js +10 -0
  146. package/dist/esm/hooks/usePrevious.js +12 -0
  147. package/dist/esm/hooks/useScrollState.js +37 -0
  148. package/dist/esm/hooks/useStateRef.js +10 -0
  149. package/dist/esm/hooks/useUpdateEffect.js +15 -0
  150. package/dist/esm/index.js +63 -0
  151. package/dist/esm/lib/utils.js +13 -0
  152. package/dist/esm/styles/responsive.js +81 -0
  153. package/dist/esm/styles/typography.js +21 -0
  154. package/dist/esm/utils/addIf.js +3 -0
  155. package/dist/esm/utils/chain.js +28 -0
  156. package/dist/esm/utils/getBoundingRect.js +16 -0
  157. package/dist/esm/utils/mergeProps.js +40 -0
  158. package/dist/esm/utils/mergeRefs.js +15 -0
  159. package/dist/esm/utils/toggle.js +14 -0
  160. package/dist/styles.css +1 -0
  161. package/dist/types/index.d.ts +1418 -0
  162. package/package.json +114 -0
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { __rest } from 'tslib';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useTableColumnContext } from '../hooks/contextHooks.js';
5
+ import '../../table/table.js';
6
+ import { TableHead } from '../../table/components/table-head.js';
7
+ import { TableCell } from '../../table/components/cell.js';
8
+
9
+ const Cell = (_a) => {
10
+ var _b;
11
+ var { variant = "body", sticky, columnId, colSpan = 1 } = _a, rest = __rest(_a, ["variant", "sticky", "columnId", "colSpan"]);
12
+ const Component = variant === "header" ? TableHead : TableCell;
13
+ const { columnConfig } = useTableColumnContext();
14
+ const columnInfo = columnId ? columnConfig[columnId] : undefined;
15
+ const finalSticky = sticky || ((columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.isStickyLeft) ? "left" : (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.isStickyRight) ? "right" : undefined);
16
+ const finalHasMinWidth = (_b = columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.hasMinWidth) !== null && _b !== void 0 ? _b : false;
17
+ const colSpanShift = finalHasMinWidth ? 1 : 0;
18
+ return jsx(Component, Object.assign({}, rest, { colSpan: colSpan + colSpanShift, sticky: finalSticky }));
19
+ };
20
+ Cell.displayName = "Table.Cell";
21
+
22
+ export { Cell };
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { memo, Fragment } from 'react';
4
+ import { useTableSelectionContext } from '../hooks/contextHooks.js';
5
+
6
+ /**
7
+ * The ColumnGroup component is used to apply column sizing for a table with a fixed layout.
8
+ *
9
+ * HTML tables with `table-layout: fixed` tend to ignore `min-width` and `max-width` properties,
10
+ * sizing columns based solely on the first row of cells. This component implements a workaround
11
+ * that allows for a faux `min-width` effect on columns, enabling flexible column widths
12
+ * while respecting minimum size constraints.
13
+ *
14
+ * The solution involves using a combination of <colgroup> and <col> elements, with the
15
+ * latter's style being conditionally set based on the column configurations provided.
16
+ * In cases where a `minWidth` is specified for a column, an additional empty <col> is rendered
17
+ * next to the one with the `minWidth` style. This tricks the table layout into respecting
18
+ * the minimum width while allowing the column to flex beyond it when extra space is available.
19
+ *
20
+ * For columns with a fixed width, a single <col> with the specified width is rendered.
21
+ * In the absence of width specifications, an empty <col> is rendered, allowing the table to auto-size.
22
+ *
23
+ * Read more -> https://css-tricks.com/faking-min-width-on-a-table-column/
24
+ */
25
+ const ColumnGroup = memo(({ columns }) => {
26
+ const { selectedRows } = useTableSelectionContext();
27
+ return (jsxs("colgroup", { children: [selectedRows && jsx("col", {}, "column_selection"), columns.map((column) => {
28
+ const columnStyles = column.style;
29
+ const testId = `column_${column.id}`;
30
+ if (columnStyles === null || columnStyles === void 0 ? void 0 : columnStyles.minWidth) {
31
+ return (jsxs(Fragment, { children: [jsx("col", { "data-testid": `${testId}_static`, style: { width: columnStyles.minWidth } }), jsx("col", { "data-testid": `${testId}_flexible` })] }, `${testId}-minWidth`));
32
+ }
33
+ else if (columnStyles === null || columnStyles === void 0 ? void 0 : columnStyles.width) {
34
+ return jsx("col", { "data-testid": testId, style: { width: columnStyles.width } }, `${testId}-width`);
35
+ }
36
+ else {
37
+ return jsx("col", { "data-testid": `${testId}_auto` }, `${testId}-auto`);
38
+ }
39
+ })] }));
40
+ });
41
+ ColumnGroup.displayName = "Table.ColumnGroup";
42
+
43
+ export { ColumnGroup };
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { memo } from 'react';
4
+ import _pick from 'lodash/pick';
5
+ import { Cell } from './cell.js';
6
+ import { useTableSelectionContext, useTableStickyContext, useTableDataContext, useTableRendererContext, useTableStyleContext } from '../hooks/contextHooks.js';
7
+ import 'clsx';
8
+ import { toggle } from '../../../../utils/toggle.js';
9
+ import { Checkbox } from '../../../forms/checkbox/checkbox.js';
10
+ import '../../table/table.js';
11
+ import { TableRow } from '../../table/components/row.js';
12
+ import { TableBody as TableBody$1 } from '../../table/components/table-body.js';
13
+
14
+ const DefaultColumnRenderer = memo(({ value }) => value);
15
+ const CheckboxCell = memo(({ id, isSelected }) => {
16
+ const { selectedRows = [], onSelect } = useTableSelectionContext();
17
+ const { stickyColumnsLeft } = useTableStickyContext();
18
+ return (jsx(Cell, { sticky: stickyColumnsLeft > 0 ? "left" : undefined, children: jsx(Checkbox, { checked: isSelected, onCheckedChange: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect(toggle(selectedRows, id), id) }) }, `body-checkbox-${id}`));
19
+ });
20
+ const DefaultRowRenderer = memo(({ row }) => {
21
+ const { rowId, rowDataKeys } = useTableDataContext();
22
+ const { columnRenderers } = useTableRendererContext();
23
+ const { colSpan: colSpanConfig, rowSpan: rowSpanConfig } = useTableStyleContext();
24
+ const { selectedRows } = useTableSelectionContext();
25
+ const withCheckbox = selectedRows !== undefined;
26
+ const id = typeof rowId === "function" ? rowId(row) : row[rowId];
27
+ const rowData = _pick(row, rowDataKeys);
28
+ const isSelected = !!(selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.includes(id));
29
+ return (jsxs(TableRow, { selected: isSelected, children: [withCheckbox && jsx(CheckboxCell, { id: id, isSelected: isSelected }), Object.entries(rowData).map(([columnKey, columnValue], index) => {
30
+ var _a, _b;
31
+ const ContentRenderer = (columnRenderers && columnRenderers[columnKey]) || DefaultColumnRenderer;
32
+ return (jsx(Cell, { columnId: columnKey, colSpan: (_a = colSpanConfig === null || colSpanConfig === void 0 ? void 0 : colSpanConfig[id]) === null || _a === void 0 ? void 0 : _a[columnKey], rowSpan: (_b = rowSpanConfig === null || rowSpanConfig === void 0 ? void 0 : rowSpanConfig[id]) === null || _b === void 0 ? void 0 : _b[columnKey], children: jsx(ContentRenderer, { dataKey: columnKey, value: columnValue, index: index + (withCheckbox ? 2 : 1), row: row }) }, `body-${columnKey}-cell-${id}`));
33
+ })] }));
34
+ });
35
+ const TableBody = memo(({ rows }) => {
36
+ const { rowId } = useTableDataContext();
37
+ const { rowRenderer: RowRenderer = DefaultRowRenderer } = useTableRendererContext();
38
+ return (jsx(TableBody$1, { children: rows.map((row) => {
39
+ const id = typeof rowId === "function" ? rowId(row) : row[rowId];
40
+ return jsx(RowRenderer, { row: row }, `body-row-${id}`);
41
+ }) }));
42
+ });
43
+ TableBody.displayName = "Table.TableBody";
44
+
45
+ export { TableBody };
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { memo, useMemo } from 'react';
4
+ import '../../table/table.js';
5
+ import { EmptyState } from '../../../utility/empty-state/empty-state.js';
6
+ import { Icon } from '../../../media/icon/icon.js';
7
+ import { TableBody } from '../../table/components/table-body.js';
8
+ import { TableRow } from '../../table/components/row.js';
9
+ import { TableCell } from '../../table/components/cell.js';
10
+
11
+ const NoData = (jsxs(EmptyState, { children: [jsx(EmptyState.Image, { children: jsx(Icon, { name: "file-warning", size: 80 }) }), jsx(EmptyState.Title, { children: "No Data" }), jsx(EmptyState.Description, { children: "Visit this page later" })] }));
12
+ const Error = (jsxs(EmptyState, { children: [jsx(EmptyState.Image, { children: jsx(Icon, { name: "bug", size: 80 }) }), jsx(EmptyState.Title, { children: "An error occurred!" }), jsx(EmptyState.Description, { children: "Please contact us for assistance or try again later." })] }));
13
+ const TableFallback = memo(({ type, columnsAmount, customFallback }) => {
14
+ const EmptyStateContent = useMemo(() => {
15
+ switch (type) {
16
+ case "error":
17
+ return Error;
18
+ case "empty":
19
+ return NoData;
20
+ }
21
+ }, [type]);
22
+ return (jsx(TableBody, { children: jsx(TableRow, { children: jsx(TableCell, { colSpan: columnsAmount, children: customFallback || EmptyStateContent }) }) }));
23
+ });
24
+ TableFallback.displayName = "Table.TableFallback";
25
+
26
+ export { TableFallback };
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { __rest } from 'tslib';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { memo, useMemo } from 'react';
5
+ import _difference from 'lodash/difference';
6
+ import _map from 'lodash/map';
7
+ import { convertHeadersToRows, collectColumnsWithoutChildren } from '../utils.js';
8
+ import { Cell } from './cell.js';
9
+ import { useTableDataContext, useTableStickyContext, useTableSelectionContext, useTableSortContext } from '../hooks/contextHooks.js';
10
+ import { Button } from '../../../buttons/button/button.js';
11
+ import { Checkbox } from '../../../forms/checkbox/checkbox.js';
12
+ import '../../table/table.js';
13
+ import 'clsx';
14
+ import { addIf } from '../../../../utils/addIf.js';
15
+ import { TableHeader } from '../../table/components/table-header.js';
16
+ import { TableRow } from '../../table/components/row.js';
17
+
18
+ const HeaderCell = (_a) => {
19
+ var { column, index } = _a, rest = __rest(_a, ["column", "index"]);
20
+ const { sortBy, sortDirection, onSortChange } = useTableSortContext();
21
+ const { id, label, sortable = false, align, style } = column;
22
+ const isActiveSort = sortBy === id;
23
+ return (jsx(Cell, Object.assign({}, rest, { variant: "header", columnId: id, align: align, style: style, children: sortable ? (jsx(Button, { variant: "ghost", rightIcon: isActiveSort
24
+ ? sortDirection === "desc"
25
+ ? "arrow-down-wide-narrow"
26
+ : "arrow-up-narrow-wide"
27
+ : "arrow-up-down", onClick: (e) => onSortChange && onSortChange(id, e), children: label })) : (label) })));
28
+ };
29
+ HeaderCell.displayName = "Table.HeaderCell";
30
+ const SelectAllCell = memo((props) => {
31
+ const { rows, rowId } = useTableDataContext();
32
+ const { stickyColumnsLeft } = useTableStickyContext();
33
+ const { selectedRows = [], onSelect } = useTableSelectionContext();
34
+ const rowsIds = useMemo(() => _map(rows, (row) => (typeof rowId === "function" ? rowId(row) : row[rowId])), [rowId, rows]);
35
+ const isAllSelected = rowsIds.length > 0 && _difference(rowsIds, selectedRows).length === 0;
36
+ return (jsx(Cell, Object.assign({}, props, { variant: "header", sticky: stickyColumnsLeft > 0 ? "left" : undefined, className: "w-[32px]", children: jsx(Checkbox, { checked: isAllSelected, indeterminate: !isAllSelected && selectedRows.length > 0, onCheckedChange: () => onSelect === null || onSelect === void 0 ? void 0 : onSelect(isAllSelected ? [] : rowsIds) }) })));
37
+ });
38
+ SelectAllCell.displayName = "Table.SelectAllCell";
39
+ const TableHead = memo(({ columns, withSelection }) => {
40
+ const headerRows = useMemo(() => convertHeadersToRows(columns), [columns]);
41
+ return (jsx(TableHeader, { children: headerRows.map((headerRow, headerRowIndex) => (jsxs(TableRow, { children: [withSelection && headerRowIndex === 0 && jsx(SelectAllCell, { rowSpan: headerRows.length }), headerRow.map((column, index) => {
42
+ const children = collectColumnsWithoutChildren(column.children || []);
43
+ const childCount = children.length;
44
+ const childrenWithMinWidth = children.filter((c) => { var _a; return (_a = c.style) === null || _a === void 0 ? void 0 : _a.minWidth; }).length;
45
+ return (jsx(HeaderCell, Object.assign({ index: index, column: column }, addIf(childCount > 0, {
46
+ colSpan: childCount + childrenWithMinWidth,
47
+ }), addIf(childCount === 0, {
48
+ rowSpan: headerRows.length - headerRowIndex,
49
+ })), `header-${column.id}`));
50
+ })] }, `header-row-${headerRowIndex}`))) }));
51
+ });
52
+ TableHead.displayName = "Table.TableHead";
53
+
54
+ export { TableHead };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { memo } from 'react';
4
+ import { Skeleton } from '../../../utility/skeleton/skeleton.js';
5
+ import '../../table/table.js';
6
+ import { TableBody } from '../../table/components/table-body.js';
7
+ import { TableRow } from '../../table/components/row.js';
8
+ import { TableCell } from '../../table/components/cell.js';
9
+
10
+ const TablePlaceholder = memo(({ columnsAmount, rowsAmount, customFallback }) => {
11
+ return (jsx(TableBody, { children: customFallback ||
12
+ Array.from({ length: rowsAmount }).map((_, rowIndex) => (jsx(TableRow, { children: jsx(TableCell, { colSpan: columnsAmount, children: jsx(Skeleton, { className: "h-4 w-full" }) }, `loading-cell-${columnsAmount}`) }, `loading-row-${rowIndex}`))) }));
13
+ });
14
+ TablePlaceholder.displayName = "Table.TablePlaceholder";
15
+
16
+ export { TablePlaceholder };
@@ -0,0 +1,95 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useRef, useMemo } from 'react';
4
+ import _map from 'lodash/map';
5
+ import { TableHead } from './components/table-head.js';
6
+ import { TableBody } from './components/table-body.js';
7
+ import { TableFallback } from './components/table-fallback.js';
8
+ import { TablePlaceholder } from './components/table-placeholder.js';
9
+ import { ColumnGroup } from './components/column-group.js';
10
+ import { useStickyColumns } from './hooks/useStickyColumns.js';
11
+ import { collectColumnsWithoutChildren, flattenColumns } from './utils.js';
12
+ import { TableColumnContext, TableRendererContext, TableSelectionContext, TableSortContext, TableStickyContext, TableStyleContext, TableDataContext } from './hooks/contextHooks.js';
13
+ import { Cell } from './components/cell.js';
14
+ import { StatusController } from '../../utility/status-controller/status-controller.js';
15
+ import 'clsx';
16
+ import { useStateRef } from '../../../hooks/useStateRef.js';
17
+ import { useScrollState } from '../../../hooks/useScrollState.js';
18
+ import { TableContainer, Table } from '../table/table.js';
19
+ import { cn } from '../../../lib/utils.js';
20
+ import { TableRow } from '../table/components/row.js';
21
+
22
+ const DataTableComponent = ({ columns, rows, rowId = "id", rowDataKeys,
23
+ // States API
24
+ isLoading = false, isError = false, errorFallback, emptyFallback, loadingFallback,
25
+ // Renderer API
26
+ columnRenderers, rowRenderer,
27
+ // Sticky API
28
+ stickyHeader = false, stickyColumnsLeft = 0, stickyColumnsRight = 0,
29
+ // Sort API
30
+ sortBy, sortDirection, onSortChange,
31
+ // Selection API
32
+ selectedRows, onSelect,
33
+ // Body Cells Configs
34
+ colSpan, rowSpan, }) => {
35
+ const containerRef = useRef(null);
36
+ const [tableElement, setTableRef] = useStateRef();
37
+ const { isScrolledToLeftCorner, isScrolledToRightCorner } = useScrollState(containerRef);
38
+ useStickyColumns(tableElement);
39
+ const mergedCells = !!colSpan || !!rowSpan || Object.values(columns).some((column) => column.children);
40
+ const columnsWithoutChildren = useMemo(() => collectColumnsWithoutChildren(columns), [columns]);
41
+ const columnsWithMinWidth = useMemo(() => columnsWithoutChildren.filter((column) => { var _a; return ((_a = column.style) === null || _a === void 0 ? void 0 : _a.minWidth) !== undefined; }).length, [columnsWithoutChildren]);
42
+ const columnsAmount = columnsWithoutChildren.length + columnsWithMinWidth + (selectedRows ? 1 : 0);
43
+ // Compute column configuration once
44
+ const columnConfig = useMemo(() => {
45
+ const flattenedColumns = flattenColumns(columns);
46
+ const config = {};
47
+ flattenedColumns.forEach((column, index) => {
48
+ var _a;
49
+ config[column.id] = {
50
+ index,
51
+ isStickyLeft: index < stickyColumnsLeft,
52
+ isStickyRight: index >= flattenedColumns.length - stickyColumnsRight,
53
+ hasMinWidth: ((_a = column.style) === null || _a === void 0 ? void 0 : _a.minWidth) !== undefined,
54
+ };
55
+ });
56
+ return config;
57
+ }, [columns, stickyColumnsLeft, stickyColumnsRight]);
58
+ // Memoize context values to prevent unnecessary re-renders
59
+ const dataContextValue = useMemo(() => ({ rowId: rowId, rows, rowDataKeys: _map(flattenColumns(columns), "id") }), [rowId, rowDataKeys]);
60
+ const columnContextValue = useMemo(() => ({ columnConfig }), [columnConfig]);
61
+ const rendererContextValue = useMemo(() => ({
62
+ rowRenderer,
63
+ columnRenderers,
64
+ }), [rowRenderer, columnRenderers]);
65
+ const selectionContextValue = useMemo(() => ({
66
+ selectedRows,
67
+ onSelect,
68
+ }), [selectedRows, onSelect]);
69
+ const sortContextValue = useMemo(() => ({
70
+ sortBy,
71
+ sortDirection,
72
+ onSortChange,
73
+ }), [sortBy, sortDirection, onSortChange]);
74
+ const stickyContextValue = useMemo(() => ({
75
+ stickyHeader,
76
+ stickyColumnsLeft,
77
+ stickyColumnsRight,
78
+ }), [stickyHeader, stickyColumnsLeft, stickyColumnsRight]);
79
+ const styleContextValue = useMemo(() => ({
80
+ colSpan,
81
+ rowSpan,
82
+ }), [colSpan, rowSpan]);
83
+ return (jsx(TableColumnContext.Provider, { value: columnContextValue, children: jsx(TableRendererContext.Provider, { value: rendererContextValue, children: jsx(TableSelectionContext.Provider, { value: selectionContextValue, children: jsx(TableSortContext.Provider, { value: sortContextValue, children: jsx(TableStickyContext.Provider, { value: stickyContextValue, children: jsx(TableStyleContext.Provider, { value: styleContextValue, children: jsx(TableDataContext.Provider, { value: dataContextValue, children: jsx(TableContainer, { ref: containerRef, className: "h-full", children: jsxs(Table, { ref: setTableRef, stickyHeader: stickyHeader, grid: mergedCells, className: cn("data-table", {
84
+ "h-full": isLoading || isError || !rows.length,
85
+ "left-corner-scrolled": isScrolledToLeftCorner,
86
+ "right-corner-scrolled": isScrolledToRightCorner,
87
+ }), children: [jsx(ColumnGroup, { columns: columnsWithoutChildren }), jsx(TableHead, { columns: columns, withSelection: !!selectedRows }), jsx(StatusController, { loading: isLoading, loadingFallback: jsx(TablePlaceholder, { rowsAmount: 16, columnsAmount: columnsAmount, customFallback: loadingFallback }), error: isError, errorFallback: jsx(TableFallback, { type: "error", columnsAmount: columnsAmount, customFallback: errorFallback }), empty: !rows.length, emptyFallback: jsx(TableFallback, { type: "empty", columnsAmount: columnsAmount, customFallback: emptyFallback }), children: jsx(TableBody, { rows: rows }) })] }) }) }) }) }) }) }) }) }));
88
+ };
89
+ DataTableComponent.displayName = "DataTable";
90
+ const DataTable = Object.assign(DataTableComponent, {
91
+ Row: TableRow,
92
+ Cell,
93
+ });
94
+
95
+ export { DataTable };
@@ -0,0 +1,60 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ const TableDataContext = createContext(undefined);
4
+ const useTableDataContext = () => {
5
+ const context = useContext(TableDataContext);
6
+ if (!context) {
7
+ throw new Error("useTableDataContext hook must be used within a TableDataContext.Provider");
8
+ }
9
+ return context;
10
+ };
11
+ const TableColumnContext = createContext(undefined);
12
+ const useTableColumnContext = () => {
13
+ const context = useContext(TableColumnContext);
14
+ if (!context) {
15
+ throw new Error("useTableColumnContext hook must be used within a TableColumnContext.Provider");
16
+ }
17
+ return context;
18
+ };
19
+ const TableRendererContext = createContext(undefined);
20
+ const useTableRendererContext = () => {
21
+ const context = useContext(TableRendererContext);
22
+ if (!context) {
23
+ throw new Error("useTableRendererContext hook must be used within a TableRendererContext.Provider");
24
+ }
25
+ return context;
26
+ };
27
+ const TableSelectionContext = createContext(undefined);
28
+ const useTableSelectionContext = () => {
29
+ const context = useContext(TableSelectionContext);
30
+ if (!context) {
31
+ throw new Error("useTableSelectionContext hook must be used within a TableSelectionContext.Provider");
32
+ }
33
+ return context;
34
+ };
35
+ const TableSortContext = createContext(undefined);
36
+ const useTableSortContext = () => {
37
+ const context = useContext(TableSortContext);
38
+ if (!context) {
39
+ throw new Error("useTableSortContext hook must be used within a TableSortContext.Provider");
40
+ }
41
+ return context;
42
+ };
43
+ const TableStickyContext = createContext(undefined);
44
+ const useTableStickyContext = () => {
45
+ const context = useContext(TableStickyContext);
46
+ if (!context) {
47
+ throw new Error("useTableStickyContext hook must be used within a TableStickyContext.Provider");
48
+ }
49
+ return context;
50
+ };
51
+ const TableStyleContext = createContext(undefined);
52
+ const useTableStyleContext = () => {
53
+ const context = useContext(TableStyleContext);
54
+ if (!context) {
55
+ throw new Error("useTableStyleContext hook must be used within a TableStyleContext.Provider");
56
+ }
57
+ return context;
58
+ };
59
+
60
+ export { TableColumnContext, TableDataContext, TableRendererContext, TableSelectionContext, TableSortContext, TableStickyContext, TableStyleContext, useTableColumnContext, useTableDataContext, useTableRendererContext, useTableSelectionContext, useTableSortContext, useTableStickyContext, useTableStyleContext };
@@ -0,0 +1,96 @@
1
+ import { useRef, useCallback, useEffect } from 'react';
2
+ import debounce from 'lodash/debounce';
3
+ import fastdom from 'fastdom';
4
+ import 'clsx';
5
+ import { getBoundingRect } from '../../../../utils/getBoundingRect.js';
6
+
7
+ function sortByDomNode(nodes, resolveKey = (i) => i) {
8
+ return nodes.slice().sort((aItem, zItem) => {
9
+ const a = resolveKey(aItem);
10
+ const z = resolveKey(zItem);
11
+ if (a === null || z === null)
12
+ return 0;
13
+ const position = a.compareDocumentPosition(z);
14
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING)
15
+ return -1;
16
+ if (position & Node.DOCUMENT_POSITION_PRECEDING)
17
+ return 1;
18
+ return 0;
19
+ });
20
+ }
21
+ const calculateLeftPositions = (cells) => {
22
+ let currentPosition = 0;
23
+ cells.forEach((cell) => {
24
+ const rect = getBoundingRect(cell);
25
+ cell.style.left = `${Math.floor(currentPosition)}px`;
26
+ currentPosition += rect.width;
27
+ });
28
+ };
29
+ const calculateRightPositions = (cells) => {
30
+ let currentPosition = 0;
31
+ // Process cells from right to left
32
+ for (let i = cells.length - 1; i >= 0; i--) {
33
+ const cell = cells[i];
34
+ const rect = getBoundingRect(cell);
35
+ cell.style.right = `${Math.floor(currentPosition)}px`;
36
+ currentPosition += rect.width;
37
+ }
38
+ };
39
+ const useStickyColumns = (tableElement) => {
40
+ const resizeObserverRef = useRef(null);
41
+ const rafIdRef = useRef(null);
42
+ const updateStickyPositions = useCallback(() => {
43
+ if (!tableElement)
44
+ return;
45
+ // Cancel any pending RAF
46
+ if (rafIdRef.current) {
47
+ cancelAnimationFrame(rafIdRef.current);
48
+ }
49
+ // Schedule the update in the next animation frame
50
+ rafIdRef.current = requestAnimationFrame(() => {
51
+ fastdom.measure(() => {
52
+ // Get all rows
53
+ const rows = Array.from(tableElement.getElementsByTagName("tr"));
54
+ rows.forEach((row) => {
55
+ // Find sticky cells in this row
56
+ const stickyCells = Array.from(row.querySelectorAll("[data-sticky]"));
57
+ // Split cells into left and right sticky cells
58
+ const leftStickyCells = stickyCells.filter((cell) => cell.getAttribute("data-sticky") === "left");
59
+ const rightStickyCells = stickyCells.filter((cell) => cell.getAttribute("data-sticky") === "right");
60
+ // Sort cells in DOM order within the row
61
+ const sortedLeftCells = sortByDomNode(leftStickyCells);
62
+ const sortedRightCells = sortByDomNode(rightStickyCells);
63
+ fastdom.mutate(() => {
64
+ calculateLeftPositions(sortedLeftCells);
65
+ calculateRightPositions(sortedRightCells);
66
+ });
67
+ });
68
+ });
69
+ });
70
+ }, [tableElement]);
71
+ useEffect(() => {
72
+ if (!tableElement)
73
+ return;
74
+ // Initial calculation
75
+ updateStickyPositions();
76
+ // Create debounced resize handler with trailing event
77
+ const debouncedResizeHandler = debounce(updateStickyPositions, 150, {
78
+ trailing: true,
79
+ });
80
+ // Create and configure ResizeObserver
81
+ resizeObserverRef.current = new ResizeObserver(debouncedResizeHandler);
82
+ resizeObserverRef.current.observe(tableElement);
83
+ return () => {
84
+ if (rafIdRef.current) {
85
+ cancelAnimationFrame(rafIdRef.current);
86
+ }
87
+ if (resizeObserverRef.current) {
88
+ resizeObserverRef.current.disconnect();
89
+ }
90
+ // Cancel any pending debounced calls
91
+ debouncedResizeHandler.cancel();
92
+ };
93
+ }, [tableElement, updateStickyPositions]);
94
+ };
95
+
96
+ export { useStickyColumns };
@@ -0,0 +1,22 @@
1
+ const convertHeadersToRows = (headers, level = 0, result = []) => {
2
+ headers.forEach((header) => {
3
+ if (result[level]) {
4
+ result[level].push(header);
5
+ }
6
+ else {
7
+ result[level] = [header];
8
+ }
9
+ if (header.children) {
10
+ convertHeadersToRows(header.children, level + 1, result);
11
+ }
12
+ });
13
+ return result;
14
+ };
15
+ const flattenColumns = (columns) => {
16
+ return columns.flatMap((column) => [column, ...(column.children ? flattenColumns(column.children) : [])]);
17
+ };
18
+ const collectColumnsWithoutChildren = (columns) => {
19
+ return flattenColumns(columns).filter((column) => !column.children);
20
+ };
21
+
22
+ export { collectColumnsWithoutChildren, convertHeadersToRows, flattenColumns };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { format } from 'date-fns';
4
+ import { cn } from '../../../lib/utils.js';
5
+ import { Button } from '../../buttons/button/button.js';
6
+ import { Calendar } from '../calendar/calendar.js';
7
+ import { Popover, PopoverTrigger, PopoverContent } from '../../popovers/popover/popover.js';
8
+
9
+ const DatePicker = ({ date, onChange, placeholder = "Pick a date" }) => {
10
+ return (jsxs(Popover, { children: [jsx(PopoverTrigger, { asChild: true, children: jsx(Button, { variant: "outline", leftIcon: "calendar", className: cn("w-[240px] justify-start text-left font-normal", !date && "text-muted-foreground"), children: date ? format(date, "PPP") : jsx("span", { children: placeholder }) }) }), jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: jsx(Calendar, { mode: "single", selected: date, onSelect: onChange, autoFocus: true }) })] }));
11
+ };
12
+
13
+ export { DatePicker };
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import { __rest } from 'tslib';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { Root, Portal, Trigger, Content, Group, Label, Item, CheckboxItem, ItemIndicator, RadioGroup, RadioItem, Separator, Sub, SubTrigger, SubContent } from '@radix-ui/react-dropdown-menu';
5
+ import { cn } from '../../../lib/utils.js';
6
+ import { Icon } from '../../media/icon/icon.js';
7
+
8
+ const DropdownMenu = (_a) => {
9
+ var props = __rest(_a, []);
10
+ return jsx(Root, Object.assign({ "data-slot": "dropdown-menu" }, props));
11
+ };
12
+ DropdownMenu.displayName = "DropdownMenu";
13
+ const DropdownMenuPortal = (_a) => {
14
+ var props = __rest(_a, []);
15
+ return (jsx(Portal, Object.assign({ "data-slot": "dropdown-menu-portal" }, props)));
16
+ };
17
+ DropdownMenuPortal.displayName = "DropdownMenuPortal";
18
+ const DropdownMenuTrigger = (_a) => {
19
+ var props = __rest(_a, []);
20
+ return (jsx(Trigger, Object.assign({ "data-slot": "dropdown-menu-trigger" }, props)));
21
+ };
22
+ DropdownMenuTrigger.displayName = "DropdownMenuTrigger";
23
+ const DropdownMenuContent = (_a) => {
24
+ var { className, sideOffset = 4 } = _a, props = __rest(_a, ["className", "sideOffset"]);
25
+ return (jsx(Portal, { children: jsx(Content, Object.assign({ "data-slot": "dropdown-menu-content", sideOffset: sideOffset, className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md", className) }, props)) }));
26
+ };
27
+ DropdownMenuContent.displayName = "DropdownMenuContent";
28
+ const DropdownMenuGroup = (_a) => {
29
+ var props = __rest(_a, []);
30
+ return (jsx(Group, Object.assign({ "data-slot": "dropdown-menu-group" }, props)));
31
+ };
32
+ DropdownMenuGroup.displayName = "DropdownMenuGroup";
33
+ const DropdownMenuItem = (_a) => {
34
+ var { className, inset, variant = "default" } = _a, props = __rest(_a, ["className", "inset", "variant"]);
35
+ return (jsx(Item, Object.assign({ "data-slot": "dropdown-menu-item", "data-inset": inset, "data-variant": variant, className: cn("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className) }, props)));
36
+ };
37
+ DropdownMenuItem.displayName = "DropdownMenuItem";
38
+ const DropdownMenuCheckboxItem = (_a) => {
39
+ var { className, children, checked } = _a, props = __rest(_a, ["className", "children", "checked"]);
40
+ return (jsxs(CheckboxItem, Object.assign({ "data-slot": "dropdown-menu-checkbox-item", className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), checked: checked }, props, { children: [jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: jsx(ItemIndicator, { children: jsx(Icon, { name: "check", className: "size-4" }) }) }), children] })));
41
+ };
42
+ DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem";
43
+ const DropdownMenuRadioGroup = (_a) => {
44
+ var props = __rest(_a, []);
45
+ return (jsx(RadioGroup, Object.assign({ "data-slot": "dropdown-menu-radio-group" }, props)));
46
+ };
47
+ DropdownMenuRadioGroup.displayName = "DropdownMenuRadioGroup";
48
+ const DropdownMenuRadioItem = (_a) => {
49
+ var { className, children } = _a, props = __rest(_a, ["className", "children"]);
50
+ return (jsxs(RadioItem, Object.assign({ "data-slot": "dropdown-menu-radio-item", className: cn("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className) }, props, { children: [jsx("span", { className: "pointer-events-none absolute left-2 flex size-3.5 items-center justify-center", children: jsx(ItemIndicator, { children: jsx(Icon, { name: "circle", className: "size-2 fill-current" }) }) }), children] })));
51
+ };
52
+ DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem";
53
+ const DropdownMenuLabel = (_a) => {
54
+ var { className, inset } = _a, props = __rest(_a, ["className", "inset"]);
55
+ return (jsx(Label, Object.assign({ "data-slot": "dropdown-menu-label", "data-inset": inset, className: cn("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8", className) }, props)));
56
+ };
57
+ DropdownMenuLabel.displayName = "DropdownMenuLabel";
58
+ const DropdownMenuSeparator = (_a) => {
59
+ var { className } = _a, props = __rest(_a, ["className"]);
60
+ return (jsx(Separator, Object.assign({ "data-slot": "dropdown-menu-separator", className: cn("bg-border -mx-1 my-1 h-px", className) }, props)));
61
+ };
62
+ DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
63
+ const DropdownMenuShortcut = (_a) => {
64
+ var { className } = _a, props = __rest(_a, ["className"]);
65
+ return (jsx("span", Object.assign({ "data-slot": "dropdown-menu-shortcut", className: cn("text-muted-foreground ml-auto text-xs tracking-widest", className) }, props)));
66
+ };
67
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
68
+ const DropdownMenuSub = (_a) => {
69
+ var props = __rest(_a, []);
70
+ return jsx(Sub, Object.assign({ "data-slot": "dropdown-menu-sub" }, props));
71
+ };
72
+ DropdownMenuSub.displayName = "DropdownMenuSub";
73
+ const DropdownMenuSubTrigger = (_a) => {
74
+ var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
75
+ return (jsxs(SubTrigger, Object.assign({ "data-slot": "dropdown-menu-sub-trigger", "data-inset": inset, className: cn("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8", className) }, props, { children: [children, jsx(Icon, { name: "chevron-right", className: "ml-auto size-4" })] })));
76
+ };
77
+ DropdownMenuSubTrigger.displayName = "DropdownMenuSubTrigger";
78
+ const DropdownMenuSubContent = (_a) => {
79
+ var { className } = _a, props = __rest(_a, ["className"]);
80
+ return (jsx(SubContent, Object.assign({ "data-slot": "dropdown-menu-sub-content", className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg", className) }, props)));
81
+ };
82
+ DropdownMenuSubContent.displayName = "DropdownMenuSubContent";
83
+
84
+ export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger };
@@ -0,0 +1,25 @@
1
+ import { __rest } from 'tslib';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef } from 'react';
4
+ import { DynamicIcon } from 'lucide-react/dynamic';
5
+ import { cva } from 'class-variance-authority';
6
+ import { cn } from '../../../lib/utils.js';
7
+
8
+ const iconVariants = cva("", {
9
+ variants: {
10
+ disabled: {
11
+ true: "text-muted-foreground cursor-not-allowed",
12
+ false: "",
13
+ },
14
+ },
15
+ defaultVariants: {
16
+ disabled: false,
17
+ },
18
+ });
19
+ const Icon = forwardRef((_a, ref) => {
20
+ var { color, size = 24, disabled = false, className } = _a, rest = __rest(_a, ["color", "size", "disabled", "className"]);
21
+ return (jsx(DynamicIcon, Object.assign({ ref: ref, color: color, "aria-disabled": disabled, size: size, className: cn(iconVariants({ disabled }), className) }, rest)));
22
+ });
23
+ Icon.displayName = "Icon";
24
+
25
+ export { Icon };