@dashnex/ui 0.5.2

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 (75) hide show
  1. package/README.md +522 -0
  2. package/dashnex.json +1 -0
  3. package/dist/client.d.ts +10 -0
  4. package/dist/client.js +12 -0
  5. package/dist/components/Loading.d.ts +3 -0
  6. package/dist/components/Loading.js +4 -0
  7. package/dist/components/tailwind/alert.d.ts +28 -0
  8. package/dist/components/tailwind/alert.js +30 -0
  9. package/dist/components/tailwind/auth-layout.d.ts +4 -0
  10. package/dist/components/tailwind/auth-layout.js +4 -0
  11. package/dist/components/tailwind/avatar.d.ts +14 -0
  12. package/dist/components/tailwind/avatar.js +18 -0
  13. package/dist/components/tailwind/badge.d.ts +33 -0
  14. package/dist/components/tailwind/badge.js +33 -0
  15. package/dist/components/tailwind/button.d.ts +58 -0
  16. package/dist/components/tailwind/button.js +169 -0
  17. package/dist/components/tailwind/checkbox.d.ts +36 -0
  18. package/dist/components/tailwind/checkbox.js +83 -0
  19. package/dist/components/tailwind/combobox.d.ts +19 -0
  20. package/dist/components/tailwind/combobox.js +86 -0
  21. package/dist/components/tailwind/description-list.d.ts +3 -0
  22. package/dist/components/tailwind/description-list.js +11 -0
  23. package/dist/components/tailwind/dialog.d.ts +28 -0
  24. package/dist/components/tailwind/dialog.js +30 -0
  25. package/dist/components/tailwind/divider.d.ts +3 -0
  26. package/dist/components/tailwind/divider.js +5 -0
  27. package/dist/components/tailwind/dropdown.d.ts +32 -0
  28. package/dist/components/tailwind/dropdown.js +78 -0
  29. package/dist/components/tailwind/fieldset.d.ts +21 -0
  30. package/dist/components/tailwind/fieldset.js +24 -0
  31. package/dist/components/tailwind/heading.d.ts +6 -0
  32. package/dist/components/tailwind/heading.js +10 -0
  33. package/dist/components/tailwind/index.d.ts +27 -0
  34. package/dist/components/tailwind/index.js +28 -0
  35. package/dist/components/tailwind/input.d.ts +10 -0
  36. package/dist/components/tailwind/input.js +58 -0
  37. package/dist/components/tailwind/link.d.ts +11 -0
  38. package/dist/components/tailwind/link.js +13 -0
  39. package/dist/components/tailwind/listbox.d.ts +15 -0
  40. package/dist/components/tailwind/listbox.js +84 -0
  41. package/dist/components/tailwind/navbar.d.ts +14 -0
  42. package/dist/components/tailwind/navbar.js +42 -0
  43. package/dist/components/tailwind/pagination.d.ts +17 -0
  44. package/dist/components/tailwind/pagination.js +21 -0
  45. package/dist/components/tailwind/radio.d.ts +37 -0
  46. package/dist/components/tailwind/radio.js +86 -0
  47. package/dist/components/tailwind/select.d.ts +5 -0
  48. package/dist/components/tailwind/select.js +40 -0
  49. package/dist/components/tailwind/sidebar-layout.d.ts +5 -0
  50. package/dist/components/tailwind/sidebar-layout.js +18 -0
  51. package/dist/components/tailwind/sidebar.d.ts +18 -0
  52. package/dist/components/tailwind/sidebar.js +56 -0
  53. package/dist/components/tailwind/stacked-layout.d.ts +5 -0
  54. package/dist/components/tailwind/stacked-layout.js +18 -0
  55. package/dist/components/tailwind/switch.d.ts +36 -0
  56. package/dist/components/tailwind/switch.js +146 -0
  57. package/dist/components/tailwind/table.d.ts +16 -0
  58. package/dist/components/tailwind/table.js +40 -0
  59. package/dist/components/tailwind/text.d.ts +5 -0
  60. package/dist/components/tailwind/text.js +15 -0
  61. package/dist/components/tailwind/textarea.d.ts +6 -0
  62. package/dist/components/tailwind/textarea.js +36 -0
  63. package/dist/components/theme/index.d.ts +2 -0
  64. package/dist/components/theme/index.js +2 -0
  65. package/dist/components/theme/theme-provider.d.ts +14 -0
  66. package/dist/components/theme/theme-provider.js +83 -0
  67. package/dist/components/theme/theme-switcher.d.ts +1 -0
  68. package/dist/components/theme/theme-switcher.js +12 -0
  69. package/dist/pages/index.d.ts +2 -0
  70. package/dist/pages/index.js +1 -0
  71. package/dist/server.d.ts +8 -0
  72. package/dist/server.js +10 -0
  73. package/dist/tailwind.d.ts +1 -0
  74. package/dist/tailwind.js +1 -0
  75. package/package.json +73 -0
@@ -0,0 +1,83 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useEffect, useState } from 'react';
4
+ const ThemeContext = createContext(undefined);
5
+ export function ThemeProvider({ children }) {
6
+ const [mounted, setMounted] = useState(false);
7
+ const [theme, setThemeState] = useState('system');
8
+ const [isDark, setIsDark] = useState(false);
9
+ useEffect(() => {
10
+ setMounted(true);
11
+ const savedTheme = localStorage.theme;
12
+ if (savedTheme === 'light' || savedTheme === 'dark') {
13
+ setThemeState(savedTheme);
14
+ setIsDark(savedTheme === 'dark');
15
+ // Apply theme immediately
16
+ if (savedTheme === 'dark') {
17
+ document.documentElement.classList.add('dark');
18
+ }
19
+ else {
20
+ document.documentElement.classList.remove('dark');
21
+ }
22
+ }
23
+ else {
24
+ setThemeState('system');
25
+ const systemIsDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
26
+ setIsDark(systemIsDark);
27
+ // Apply system theme immediately
28
+ document.documentElement.classList.toggle('dark', systemIsDark);
29
+ }
30
+ }, []);
31
+ useEffect(() => {
32
+ if (!mounted)
33
+ return;
34
+ // Listen for system theme changes
35
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
36
+ const handleChange = () => {
37
+ if (theme === 'system') {
38
+ setIsDark(mediaQuery.matches);
39
+ document.documentElement.classList.toggle('dark', mediaQuery.matches);
40
+ }
41
+ };
42
+ mediaQuery.addEventListener('change', handleChange);
43
+ return () => mediaQuery.removeEventListener('change', handleChange);
44
+ }, [theme, mounted]);
45
+ const setTheme = (newTheme) => {
46
+ setThemeState(newTheme);
47
+ if (newTheme === 'light') {
48
+ localStorage.theme = 'light';
49
+ setIsDark(false);
50
+ document.documentElement.classList.remove('dark');
51
+ }
52
+ else if (newTheme === 'dark') {
53
+ localStorage.theme = 'dark';
54
+ setIsDark(true);
55
+ document.documentElement.classList.add('dark');
56
+ }
57
+ else {
58
+ localStorage.removeItem('theme');
59
+ const systemIsDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
60
+ setIsDark(systemIsDark);
61
+ document.documentElement.classList.toggle('dark', systemIsDark);
62
+ }
63
+ };
64
+ const toggleTheme = () => {
65
+ const newTheme = isDark ? 'light' : 'dark';
66
+ setTheme(newTheme);
67
+ };
68
+ const themeContextValue = {
69
+ theme,
70
+ isDark,
71
+ setTheme,
72
+ toggleTheme,
73
+ mounted
74
+ };
75
+ return (_jsx(ThemeContext.Provider, { value: themeContextValue, children: children }));
76
+ }
77
+ export function useTheme() {
78
+ const context = useContext(ThemeContext);
79
+ if (context === undefined) {
80
+ throw new Error('useTheme must be used within a ThemeProvider');
81
+ }
82
+ return context;
83
+ }
@@ -0,0 +1 @@
1
+ export declare function ThemeSwitcher(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Switch } from '../tailwind/switch.js';
4
+ import { useTheme } from './theme-provider.js';
5
+ export function ThemeSwitcher() {
6
+ const { isDark, toggleTheme, mounted } = useTheme();
7
+ // Don't render the switch until mounted to prevent controlled/uncontrolled warning
8
+ if (!mounted) {
9
+ return (_jsx(Switch, { className: "float-right", disabled: true }));
10
+ }
11
+ return (_jsx(Switch, { className: "float-right", checked: isDark, onChange: toggleTheme }));
12
+ }
@@ -0,0 +1,2 @@
1
+ import type { Page } from "@dashnex/types";
2
+ export declare const debugPages: Page[];
@@ -0,0 +1 @@
1
+ export const debugPages = [];
@@ -0,0 +1,8 @@
1
+ export * from './components/tailwind/index.js';
2
+ export * from './components/theme/index.js';
3
+ declare const _default: {
4
+ name: string;
5
+ version: string;
6
+ description: string;
7
+ };
8
+ export default _default;
package/dist/server.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from './components/tailwind/index.js';
2
+ export * from './components/theme/index.js';
3
+ import packageJson from '../package.json' with { type: 'json' };
4
+ import dashnexConfig from '../dashnex.json' with { type: 'json' };
5
+ export default {
6
+ name: packageJson.name,
7
+ version: packageJson.version,
8
+ description: packageJson.description,
9
+ ...dashnexConfig,
10
+ };
@@ -0,0 +1 @@
1
+ export * from './components/tailwind/index.js';
@@ -0,0 +1 @@
1
+ export * from './components/tailwind/index.js';
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@dashnex/ui",
3
+ "version": "0.5.2",
4
+ "description": "UI module for Dashnex framework providing UI components and utilities",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/dashnex/dashnex-ui.git"
8
+ },
9
+ "type": "module",
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/server.d.ts",
15
+ "default": "./dist/server.js"
16
+ },
17
+ "./client": {
18
+ "types": "./dist/client.d.ts",
19
+ "default": "./dist/client.js"
20
+ },
21
+ "./tailwind": {
22
+ "types": "./dist/tailwind.d.ts",
23
+ "default": "./dist/tailwind.js"
24
+ }
25
+ },
26
+ "keywords": [
27
+ "dashnex",
28
+ "ui",
29
+ "module"
30
+ ],
31
+ "author": "Dashnex Team",
32
+ "license": "UNLICENSED",
33
+ "dependencies": {
34
+ "@headlessui/react": "^2.2.9",
35
+ "@heroicons/react": "^2.2.0",
36
+ "clsx": "^2.1.1",
37
+ "framer-motion": "^12.29.0"
38
+ },
39
+ "peerDependencies": {
40
+ "next": "^16.1.4",
41
+ "react": "^19.2.3",
42
+ "react-dom": "^19.2.3"
43
+ },
44
+ "devDependencies": {
45
+ "@dashnex/types": "^0.5.2",
46
+ "@types/node": "^25.0.10",
47
+ "@types/react": "^19.2.9",
48
+ "@types/react-dom": "^19.2.3",
49
+ "autoprefixer": "^10.4.23",
50
+ "esbuild": "^0.27.2",
51
+ "esbuild-css-modules-plugin": "^3.1.5",
52
+ "esbuild-style-plugin": "^1.6.3",
53
+ "eslint": "^9.39.2",
54
+ "eslint-config-next": "^16.1.4",
55
+ "postcss": "^8.5.6",
56
+ "tailwindcss": "^4.1.18",
57
+ "typescript": "^5.9.3"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public",
61
+ "registry": "https://registry.npmjs.org/"
62
+ },
63
+ "files": [
64
+ "dist",
65
+ "migrations",
66
+ "dashnex.json"
67
+ ],
68
+ "scripts": {
69
+ "build": "tsc",
70
+ "dev": "tsc --watch",
71
+ "test": "echo 'Not implemented'"
72
+ }
73
+ }