@undefine-ui/design-system 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/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/index.cjs +6976 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1551 -0
- package/dist/index.d.ts +1551 -0
- package/dist/index.js +6831 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Undefine
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @undefine-ui/design-system
|
|
2
|
+
|
|
3
|
+
React component library + MUI theme layer extracted from the Define design system.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @undefine-ui/design-system
|
|
9
|
+
# peer deps you will already have in most React + MUI apps
|
|
10
|
+
pnpm add @mui/material @mui/x-data-grid @emotion/react @emotion/styled react react-dom react-hook-form
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Providers
|
|
16
|
+
|
|
17
|
+
Every consumer app needs the same provider stack that the showcase uses:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { SettingsProvider, defaultSettings, ThemeProvider } from '@undefine-ui/design-system';
|
|
21
|
+
|
|
22
|
+
export function DesignSystemApp({ children }: { children: React.ReactNode }) {
|
|
23
|
+
return (
|
|
24
|
+
<SettingsProvider settings={defaultSettings}>
|
|
25
|
+
<ThemeProvider>{children}</ThemeProvider>
|
|
26
|
+
</SettingsProvider>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `SettingsProvider` exposes the design-system preferences (mode, contrast, fonts, nav layout) through the `useSettings` hook. Provide your own `settings` object if you want different defaults or if you persist user choices.
|
|
32
|
+
- `ThemeProvider` wraps MUI’s CssVarsProvider with the Define theme (`createTheme`). It accepts any React children and automatically injects `CssBaseline`.
|
|
33
|
+
- Both providers are exported from the package root so you can colocate them with your router/root layout.
|
|
34
|
+
|
|
35
|
+
### Theming hooks
|
|
36
|
+
|
|
37
|
+
If you need to read or update theme settings at runtime:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { useSettings } from '@undefine-ui/design-system';
|
|
41
|
+
|
|
42
|
+
const ThemeSwitcher = () => {
|
|
43
|
+
const { colorScheme, onUpdateField } = useSettings();
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<ToggleButtonGroup
|
|
47
|
+
value={colorScheme}
|
|
48
|
+
onChange={(_, value) => value && onUpdateField('colorScheme', value)}
|
|
49
|
+
>
|
|
50
|
+
{/* buttons */}
|
|
51
|
+
</ToggleButtonGroup>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`useSettings` is a thin wrapper around React context, so it must be used inside `SettingsProvider`.
|
|
57
|
+
|
|
58
|
+
### Component imports
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import {
|
|
62
|
+
CopyButton,
|
|
63
|
+
Field,
|
|
64
|
+
Form,
|
|
65
|
+
Icon,
|
|
66
|
+
LoadingScreen,
|
|
67
|
+
Table,
|
|
68
|
+
Upload
|
|
69
|
+
} from '@undefine-ui/design-system';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Storybook (`pnpm dev:storybook`) documents each component and token surface.
|
|
73
|
+
|
|
74
|
+
## Export surface
|
|
75
|
+
|
|
76
|
+
Everything is re-exported from `src/index.ts`. Key groups:
|
|
77
|
+
|
|
78
|
+
| Group | Exports |
|
|
79
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| Components | `CopyButton`, `HookForm` helpers (`Form`, `Field`, `RHFSwitch`, etc.), `Icon`, `Logo`, `LoadingScreen`, `Table`, `Upload` |
|
|
81
|
+
| Hooks | `useBoolean`, `useCopyToClipboard`, `useEventListener`, `useLocalStorage`, `useResponsive`, `useSettings` |
|
|
82
|
+
| Contexts | `SettingsProvider`, `SettingsContext`, `defaultSettings`, `SettingsValueProps` |
|
|
83
|
+
| Theme | `ThemeProvider`, `createTheme`, `colorSchemes`, `components`, `palette`, `radius`, `shadows`, `customSpacing`, utilities such as `varAlpha`, `bgGradient`, `hideScrollX/Y` |
|
|
84
|
+
| Utilities | `changeCase` helpers, `formatNumber`, generic `helpers` |
|
|
85
|
+
|
|
86
|
+
You can also import the theme pieces directly to compose your own MUI theme or to extend tokens in Storybook.
|
|
87
|
+
|
|
88
|
+
## Customising the theme
|
|
89
|
+
|
|
90
|
+
- Call `createTheme(settings)` to get the configured `Theme` object (useful for tests or SSR).
|
|
91
|
+
- Theme tokens live under `src/theme/core`. If you need to override palette/typography/etc., spread the exports into your own `extendTheme` call.
|
|
92
|
+
- `updateCoreWithSettings` and `updateComponentsWithSettings` are exported for advanced scenarios (e.g., you want to override the default settings object before rendering).
|
|
93
|
+
|
|
94
|
+
## Scripts
|
|
95
|
+
|
|
96
|
+
- `pnpm build` – bundle ESM/CJS output + `.d.ts` into `dist/`
|
|
97
|
+
- `pnpm storybook` – run Storybook locally
|
|
98
|
+
- `pnpm build-storybook` – static Storybook output
|
|
99
|
+
- `pnpm test` – run Vitest (once specs are added)
|