tiwari-shell 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.
- package/README.md +73 -0
- package/dist/components/Header/Header.d.ts +3 -0
- package/dist/components/Header/Header.d.ts.map +1 -0
- package/dist/components/Header/Header.js +6 -0
- package/dist/components/Header/index.d.ts +2 -0
- package/dist/components/Header/index.d.ts.map +1 -0
- package/dist/components/Header/index.js +1 -0
- package/dist/components/Layout/Layout.d.ts +3 -0
- package/dist/components/Layout/Layout.d.ts.map +1 -0
- package/dist/components/Layout/Layout.js +6 -0
- package/dist/components/Layout/index.d.ts +2 -0
- package/dist/components/Layout/index.d.ts.map +1 -0
- package/dist/components/Layout/index.js +1 -0
- package/dist/components/Sidebar/Sidebar.d.ts +3 -0
- package/dist/components/Sidebar/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar/Sidebar.js +26 -0
- package/dist/components/Sidebar/index.d.ts +2 -0
- package/dist/components/Sidebar/index.d.ts.map +1 -0
- package/dist/components/Sidebar/index.js +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useSidebarSelection.d.ts +3 -0
- package/dist/hooks/useSidebarSelection.d.ts.map +1 -0
- package/dist/hooks/useSidebarSelection.js +14 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/layout.d.ts +30 -0
- package/dist/types/layout.d.ts.map +1 -0
- package/dist/types/layout.js +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { HeaderProps } from "../../types/layout";
|
|
2
|
+
export default function Header({ userName, userImageSrc, searchPlaceholder, onSearchChange, onNotificationClick, onProfileClick, }: HeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=Header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/Header/Header.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,QAAiB,EACjB,YAAY,EACZ,iBAA4B,EAC5B,cAAc,EACd,mBAAmB,EACnB,cAAc,GACf,EAAE,WAAW,2CA2Cb"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Image from "next/image";
|
|
3
|
+
import { Bell, ChevronDown, Search } from "lucide-react";
|
|
4
|
+
export default function Header({ userName = "User", userImageSrc, searchPlaceholder = "Search", onSearchChange, onNotificationClick, onProfileClick, }) {
|
|
5
|
+
return (_jsxs("header", { className: "zs-header", children: [_jsxs("div", { className: "zs-header-search", children: [_jsx(Search, { size: 14, className: "zs-header-search-icon" }), _jsx("input", { type: "text", placeholder: searchPlaceholder, className: "zs-header-search-input", onChange: (event) => onSearchChange?.(event.target.value) })] }), _jsxs("div", { className: "zs-header-actions", children: [_jsx("button", { type: "button", "aria-label": "Notifications", className: "zs-header-icon-button", onClick: onNotificationClick, children: _jsx(Bell, { size: 18 }) }), _jsx("div", { className: "zs-header-divider" }), _jsxs("button", { type: "button", className: "zs-header-profile-button", onClick: onProfileClick, children: [_jsx(Image, { src: userImageSrc, alt: "User profile", width: 28, height: 28, className: "zs-header-profile-image" }), _jsx("span", { className: "zs-header-profile-name", children: userName }), _jsx(ChevronDown, { size: 16, className: "zs-header-profile-chevron" })] })] })] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Header } from "./Header";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,2CAQ9E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Header } from "../Header";
|
|
3
|
+
import { Sidebar } from "../Sidebar";
|
|
4
|
+
export default function AppLayout({ children, header, sidebar }) {
|
|
5
|
+
return (_jsxs("div", { className: "zs-layout-root", children: [_jsx(Sidebar, { ...sidebar }), _jsx(Header, { ...header }), _jsx("main", { className: "zs-layout-content", children: children })] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AppLayout } from "./Layout";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/Sidebar/Sidebar.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAuCvE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,OAAO,EACP,OAAwB,EACxB,QAAQ,GACT,EAAE,YAAY,2CA6Bd"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Image from "next/image";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useSidebarSelection } from "../../hooks/useSidebarSelection";
|
|
6
|
+
function SidebarItem({ item, isSelected, }) {
|
|
7
|
+
const className = [
|
|
8
|
+
"zs-sidebar-item",
|
|
9
|
+
isSelected ? "zs-sidebar-item-selected" : "zs-sidebar-item-default",
|
|
10
|
+
item.disabled ? "zs-sidebar-item-disabled" : "",
|
|
11
|
+
]
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join(" ");
|
|
14
|
+
const iconSrc = isSelected && item.activeIcon ? item.activeIcon : item.icon;
|
|
15
|
+
const textClassName = isSelected
|
|
16
|
+
? "zs-sidebar-item-label-active"
|
|
17
|
+
: "zs-sidebar-item-label";
|
|
18
|
+
if (!item.href || item.disabled) {
|
|
19
|
+
return (_jsxs("div", { "aria-disabled": "true", className: className, children: [_jsx(Image, { src: iconSrc, alt: item.label, width: 20, height: 20 }), _jsx("span", { className: textClassName, children: item.label })] }));
|
|
20
|
+
}
|
|
21
|
+
return (_jsxs(Link, { href: item.href, className: className, children: [_jsx(Image, { src: iconSrc, alt: item.label, width: 20, height: 20 }), _jsx("span", { className: textClassName, children: item.label })] }));
|
|
22
|
+
}
|
|
23
|
+
export default function Sidebar({ logoSrc, logoAlt = "Company icon", navItems, }) {
|
|
24
|
+
const isSelected = useSidebarSelection();
|
|
25
|
+
return (_jsxs("aside", { className: "zs-sidebar", children: [_jsx("div", { className: "zs-sidebar-logo-wrap", children: _jsx("div", { className: "zs-sidebar-logo-pill", children: _jsx(Image, { src: logoSrc, alt: logoAlt, width: 26, height: 26, className: "zs-sidebar-logo-image" }) }) }), _jsx("div", { className: "zs-sidebar-body", children: _jsx("nav", { className: "zs-sidebar-nav", children: navItems.map((item) => (_jsx(SidebarItem, { item: item, isSelected: isSelected(item) }, `${item.label}-${item.href ?? "disabled"}`))) }) })] }));
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Sidebar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Sidebar } from "./Sidebar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSidebarSelection } from "./useSidebarSelection";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSidebarSelection.d.ts","sourceRoot":"","sources":["../../src/hooks/useSidebarSelection.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,wBAAgB,mBAAmB,IAAI,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAcvE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePathname } from "next/navigation";
|
|
3
|
+
export function useSidebarSelection() {
|
|
4
|
+
const pathname = usePathname();
|
|
5
|
+
return (item) => {
|
|
6
|
+
if (item.href && pathname === item.href) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (!item.startsWith || item.startsWith.length === 0) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return item.startsWith.some((prefix) => pathname.startsWith(prefix));
|
|
13
|
+
};
|
|
14
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./styles/layout.css";
|
|
2
|
+
export { Header } from "./components/Header";
|
|
3
|
+
export { Sidebar } from "./components/Sidebar";
|
|
4
|
+
export { AppLayout } from "./components/Layout";
|
|
5
|
+
export { useSidebarSelection } from "./hooks";
|
|
6
|
+
export type { AppLayoutProps, HeaderProps, ImageSource, SidebarNavItem, SidebarProps } from "./types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { StaticImageData } from "next/image";
|
|
3
|
+
export type ImageSource = string | StaticImageData;
|
|
4
|
+
export interface HeaderProps {
|
|
5
|
+
userName?: string;
|
|
6
|
+
userImageSrc: ImageSource;
|
|
7
|
+
searchPlaceholder?: string;
|
|
8
|
+
onSearchChange?: (value: string) => void;
|
|
9
|
+
onNotificationClick?: () => void;
|
|
10
|
+
onProfileClick?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface SidebarNavItem {
|
|
13
|
+
label: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
icon: ImageSource;
|
|
16
|
+
activeIcon?: ImageSource;
|
|
17
|
+
startsWith?: string[];
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface SidebarProps {
|
|
21
|
+
logoSrc: ImageSource;
|
|
22
|
+
logoAlt?: string;
|
|
23
|
+
navItems: SidebarNavItem[];
|
|
24
|
+
}
|
|
25
|
+
export interface AppLayoutProps {
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
header: HeaderProps;
|
|
28
|
+
sidebar: SidebarProps;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/types/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,eAAe,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,WAAW,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tiwari-shell",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared shell layout components for Next.js applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist"],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"lucide-react": "^0.554.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"next": ">=14",
|
|
29
|
+
"react": ">=18.2.0",
|
|
30
|
+
"react-dom": ">=18.2.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@eslint/js": "^10.0.1",
|
|
34
|
+
"@types/node": "^24.12.3",
|
|
35
|
+
"@types/react": "^19.2.14",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
38
|
+
"eslint": "^10.3.0",
|
|
39
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
40
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
41
|
+
"globals": "^17.6.0",
|
|
42
|
+
"typescript": "~6.0.2",
|
|
43
|
+
"typescript-eslint": "^8.59.2",
|
|
44
|
+
"vite": "^8.0.12"
|
|
45
|
+
}
|
|
46
|
+
}
|