tw-react-components 0.0.148 → 0.0.150
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/index.esm.js +6 -7
- package/package.json +5 -6
- package/src/components/Layout/index.d.ts +3 -0
- package/index.cjs.d.ts +0 -1
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -2273
- package/index.cjs.mjs +0 -2
package/index.esm.js
CHANGED
|
@@ -16,7 +16,6 @@ import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, close
|
|
|
16
16
|
import { restrictToFirstScrollableAncestor } from '@dnd-kit/modifiers';
|
|
17
17
|
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
18
18
|
import { CSS } from '@dnd-kit/utilities';
|
|
19
|
-
import { useLocation, Link } from 'react-router-dom';
|
|
20
19
|
import { Slot } from '@radix-ui/react-slot';
|
|
21
20
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
22
21
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
@@ -1569,7 +1568,7 @@ function DataTable({ className, columns, rows, sorting, pagination, actions = []
|
|
|
1569
1568
|
: undefined, children: [column.header, sorting &&
|
|
1570
1569
|
!column.noSorting &&
|
|
1571
1570
|
(((_b = sorting.sorting) === null || _b === void 0 ? void 0 : _b.field) !== column.field ? (jsx(ArrowUpDownIcon, { className: "absolute top-1/2 float-right ml-1 hidden h-4 w-4 -translate-y-1/2 group-hover:inline-block" })) : ((_c = sorting.sorting) === null || _c === void 0 ? void 0 : _c.direction) === 'asc' ? (jsx(SortAscIcon, { className: "absolute top-1/2 float-right ml-1 inline-block h-4 w-4 -translate-y-1/2" })) : (jsx(SortDescIcon, { className: "absolute top-1/2 float-right ml-1 inline-block h-4 w-4 -translate-y-1/2" })))] }, columnIndex));
|
|
1572
|
-
}), actions.filter((action) => !action.hide).length > 0 &&
|
|
1571
|
+
}), actions.filter((action) => rows.some((item) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); })).length > 0 && jsx(Table.HeadCell, { align: "center", children: "Actions" })] }) }), jsxs(Table.Body, { className: "relative", children: [isLoading && (jsx(Table.Row, { children: jsx(Table.Cell, { className: cn('z-10 h-full w-full p-0', {
|
|
1573
1572
|
absolute: rows.length,
|
|
1574
1573
|
}), colSpan: columnsLength, children: jsx(Spinner, { className: "bg-white/50 py-4 dark:bg-slate-700/50" }) }) })), !isLoading && !rows.length && (jsx(Table.Row, { children: jsx(Table.Cell, { colSpan: columnsLength, children: jsx(Flex, { className: "text-slate-500", justify: "center", children: noDataMessage !== null && noDataMessage !== void 0 ? noDataMessage : 'No data' }) }) })), rows.map((item, rowIndex) => [
|
|
1575
1574
|
jsxs(Table.Row, { className: cn({
|
|
@@ -1577,7 +1576,7 @@ function DataTable({ className, columns, rows, sorting, pagination, actions = []
|
|
|
1577
1576
|
}, rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(item, rowIndex)), onClick: handleRowClicked(item, rowIndex), children: [rowExtraContent && (jsx(Table.Cell, { className: "w-min", align: "center", children: jsx(ExpandButton, { folded: !expandedRows[rowExtraContent.idGetter(item)], foldComponent: MinusIcon, unfoldComponent: PlusIcon, onClick: handleExpandRow(rowExtraContent.idGetter(item)) }) })), _columns.map((column, columnIndex) => {
|
|
1578
1577
|
var _a, _b, _c;
|
|
1579
1578
|
return (jsx(Table.Cell, { className: column.className, align: (_a = column.align) !== null && _a !== void 0 ? _a : 'left', children: (_c = (_b = column.render) === null || _b === void 0 ? void 0 : _b.call(column, item, rowIndex)) !== null && _c !== void 0 ? _c : defaultRender(item, column.field) }, columnIndex));
|
|
1580
|
-
}), actions.filter((action) => !action.hide).length > 0 && (jsx(Table.Cell, { className: "py-3", children: jsx(Flex, { align: "center", justify: "center", children: actions
|
|
1579
|
+
}), actions.filter((action) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); }).length > 0 && (jsx(Table.Cell, { className: "py-3", children: jsx(Flex, { align: "center", justify: "center", children: actions
|
|
1581
1580
|
.filter((action) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); })
|
|
1582
1581
|
.map((action, actionIndex) => {
|
|
1583
1582
|
var _a;
|
|
@@ -2039,14 +2038,14 @@ const Sidebar = Object.assign($Sidebar, {
|
|
|
2039
2038
|
const Navbar = ({ className, sidebarTriggerClassName, leftSlot, rightSlot, }) => (jsx(Block, { className: cn('border-b p-3 dark:border-slate-700', className), fullWidth: true, children: jsxs(Flex, { align: "center", justify: "between", children: [jsxs(Flex, { align: "center", children: [jsx(Sidebar.Trigger, { className: sidebarTriggerClassName }), leftSlot] }), rightSlot] }) }));
|
|
2040
2039
|
|
|
2041
2040
|
const Layout = (_a) => {
|
|
2042
|
-
var { children, className } = _a, _b = _a.sidebarProps, { basePath, header, items, extraContent, footer } = _b, sidebarProps = __rest(_b, ["basePath", "header", "items", "extraContent", "footer"]), { navbarProps } = _a;
|
|
2041
|
+
var { children, className } = _a, _b = _a.sidebarProps, { basePath, header, items, extraContent, footer } = _b, sidebarProps = __rest(_b, ["basePath", "header", "items", "extraContent", "footer"]), { navbarProps, Link, useLocation } = _a;
|
|
2043
2042
|
return (jsxs(Flex, { className: "h-screen w-screen gap-0 text-black dark:bg-slate-900 dark:text-white", children: [jsxs(Sidebar, Object.assign({ collapsible: "icon" }, sidebarProps, { children: [header && (jsx(Sidebar.Header, { children: jsx(Sidebar.Menu, { children: jsx(Sidebar.MenuItem, { children: header }) }) })), jsxs(Sidebar.Content, { className: "gap-0", children: [items
|
|
2044
2043
|
.filter((item) => !item.hidden)
|
|
2045
|
-
.map((item, index) => item.type === 'item' ? (jsx(Sidebar.Group, { children: jsx(Sidebar.Menu, { children: jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, item)) }) }, index)) : (jsxs(Sidebar.Group, { children: [item.title && jsx(Sidebar.GroupLabel, { children: item.title }), jsx(Sidebar.GroupContent, { children: jsx(Sidebar.Menu, { children: item.items
|
|
2044
|
+
.map((item, index) => item.type === 'item' ? (jsx(Sidebar.Group, { children: jsx(Sidebar.Menu, { children: jsx(RenderSideBarItem, Object.assign({ basePath: basePath, Link: Link, useLocation: useLocation }, item)) }) }, index)) : (jsxs(Sidebar.Group, { children: [item.title && jsx(Sidebar.GroupLabel, { children: item.title }), jsx(Sidebar.GroupContent, { children: jsx(Sidebar.Menu, { children: item.items
|
|
2046
2045
|
.filter((subItem) => !subItem.hidden)
|
|
2047
|
-
.map((subItem, index) => (jsx(RenderSideBarItem, Object.assign({ basePath: basePath }, subItem), index))) }) })] }, index))), extraContent] }), footer && (jsx(Sidebar.Footer, { children: jsx(Sidebar.Menu, { children: jsx(Sidebar.MenuItem, { children: footer }) }) })), jsx(Sidebar.Rail, {})] })), jsxs(Flex, { className: "gap-0 overflow-hidden", direction: "column", fullHeight: true, fullWidth: true, children: [navbarProps && jsx(Navbar, Object.assign({}, navbarProps)), jsx(Flex, { className: cn('overflow-hidden p-3', className), direction: "column", fullWidth: true, fullHeight: true, children: children })] })] }));
|
|
2046
|
+
.map((subItem, index) => (jsx(RenderSideBarItem, Object.assign({ basePath: basePath, Link: Link, useLocation: useLocation }, subItem), index))) }) })] }, index))), extraContent] }), footer && (jsx(Sidebar.Footer, { children: jsx(Sidebar.Menu, { children: jsx(Sidebar.MenuItem, { children: footer }) }) })), jsx(Sidebar.Rail, {})] })), jsxs(Flex, { className: "gap-0 overflow-hidden", direction: "column", fullHeight: true, fullWidth: true, children: [navbarProps && jsx(Navbar, Object.assign({}, navbarProps)), jsx(Flex, { className: cn('overflow-hidden p-3', className), direction: "column", fullWidth: true, fullHeight: true, children: children })] })] }));
|
|
2048
2047
|
};
|
|
2049
|
-
const RenderSideBarItem = ({ basePath = '/', pathname, title, Icon, items, }) => {
|
|
2048
|
+
const RenderSideBarItem = ({ basePath = '/', pathname, title, Icon, items, Link, useLocation }) => {
|
|
2050
2049
|
const location = useLocation();
|
|
2051
2050
|
const { open } = useSidebar();
|
|
2052
2051
|
const currentPath = useMemo(() => location.pathname.replace(basePath, '').replace(/^\/*/, ''), [basePath, location.pathname]);
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tw-react-components",
|
|
3
3
|
"description": "A set of React components build with TailwindCSS to make a nice dashboard.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.150",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://bacali95.github.io/tw-react-components",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"author": {
|
|
8
9
|
"name": "Nasreddine Bac Ali",
|
|
9
10
|
"email": "nasreddine.bacali95@gmail.com",
|
|
@@ -18,10 +19,8 @@
|
|
|
18
19
|
},
|
|
19
20
|
"exports": {
|
|
20
21
|
".": {
|
|
21
|
-
"
|
|
22
|
-
"types": "./index.esm.d.ts"
|
|
23
|
-
"import": "./index.cjs.mjs",
|
|
24
|
-
"default": "./index.cjs.js"
|
|
22
|
+
"import": "./index.esm.js",
|
|
23
|
+
"types": "./index.esm.d.ts"
|
|
25
24
|
},
|
|
26
25
|
"./css": {
|
|
27
26
|
"default": "./index.css"
|
|
@@ -32,6 +31,6 @@
|
|
|
32
31
|
"./package.json": "./package.json"
|
|
33
32
|
},
|
|
34
33
|
"module": "./index.esm.js",
|
|
35
|
-
"main": "./index.
|
|
34
|
+
"main": "./index.esm.js",
|
|
36
35
|
"types": "./index.esm.d.ts"
|
|
37
36
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LucideIcon } from 'lucide-react';
|
|
2
2
|
import { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react';
|
|
3
|
+
import type { LinkProps, useLocation } from 'react-router-dom';
|
|
3
4
|
import { NavbarProps } from '../Navbar';
|
|
4
5
|
import { Sidebar } from '../Sidebar';
|
|
5
6
|
export type SidebarItem = {
|
|
@@ -27,6 +28,8 @@ type Props = {
|
|
|
27
28
|
className?: string;
|
|
28
29
|
sidebarProps: SidebarProps;
|
|
29
30
|
navbarProps?: NavbarProps;
|
|
31
|
+
Link: FC<LinkProps>;
|
|
32
|
+
useLocation: typeof useLocation;
|
|
30
33
|
};
|
|
31
34
|
export declare const Layout: FC<PropsWithChildren<Props>>;
|
|
32
35
|
export {};
|
package/index.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|
package/index.cjs.default.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
exports._default = require('./index.cjs.js').default;
|