@nons-dev/uikit 0.1.7 → 0.1.9
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/core/config/index.ts +76 -0
- package/core/config/parser.ts +112 -0
- package/core/config/types.ts +41 -0
- package/core/config/validator.ts +68 -0
- package/dist/index.css +1 -1
- package/dist/index.js +1758 -1601
- package/dist/src/index.d.ts +2 -2
- package/locales/en.json +7 -0
- package/locales/fa.json +7 -0
- package/package.json +8 -1
- package/readme.md +67 -55
- package/scripts/vite-plugin-nons-config.ts +76 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { registry } from '../core/registry/registry';
|
|
2
2
|
export { bootstrapRegistry } from '../core/registry/bootstrap';
|
|
3
|
-
export { loadConfig, getConfig, getDirection, getDefaultLocale, getSupportedLocales, getFontFamily } from '../core/config';
|
|
4
|
-
export type { NonsConfig } from '../core/config/types';
|
|
3
|
+
export { loadConfig, getConfig, getDirection, getDefaultLocale, getSupportedLocales, getFontFamily, generateFullCSS } from '../core/config';
|
|
4
|
+
export type { NonsConfig, RawConfig } from '../core/config/types';
|
|
5
5
|
export { runtimeContext, hasPermission, setUILocale, setUIDirection } from '../core/runtime';
|
|
6
6
|
export { validateSchema, normalizeSchema } from '../core/schema-engine';
|
|
7
7
|
export type { SchemaNode } from '../core/types/schema';
|
package/locales/en.json
CHANGED
|
@@ -322,5 +322,12 @@
|
|
|
322
322
|
"demo_subtitle": "This card is fully rendered from a JSON specification and has real functionality.",
|
|
323
323
|
"input_placeholder": "Schema input...",
|
|
324
324
|
"submit": "Submit from Schema"
|
|
325
|
+
},
|
|
326
|
+
"sidepanel": {
|
|
327
|
+
"close": "Close",
|
|
328
|
+
"cancel": "Cancel",
|
|
329
|
+
"save": "Save",
|
|
330
|
+
"minimize": "Minimize",
|
|
331
|
+
"maximize": "Maximize"
|
|
325
332
|
}
|
|
326
333
|
}
|
package/locales/fa.json
CHANGED
|
@@ -322,5 +322,12 @@
|
|
|
322
322
|
"demo_subtitle": "این کادر به طور کامل از یک مشخصات JSON رندر شده است و عملکرد واقعی دارد.",
|
|
323
323
|
"input_placeholder": "ورودی اسکیما...",
|
|
324
324
|
"submit": "ثبت از اسکیما"
|
|
325
|
+
},
|
|
326
|
+
"sidepanel": {
|
|
327
|
+
"close": "بستن",
|
|
328
|
+
"cancel": "انصراف",
|
|
329
|
+
"save": "ذخیره",
|
|
330
|
+
"minimize": "کوچکنمایی",
|
|
331
|
+
"maximize": "بزرگنمایی"
|
|
325
332
|
}
|
|
326
333
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nons-dev/uikit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "BUSL-1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|
|
22
|
+
"core/config",
|
|
22
23
|
"generated/components.json",
|
|
23
24
|
"locales",
|
|
24
25
|
"scripts/cli.mjs",
|
|
26
|
+
"scripts/vite-plugin-nons-config.ts",
|
|
25
27
|
"readme.md"
|
|
26
28
|
],
|
|
27
29
|
"exports": {
|
|
@@ -33,6 +35,11 @@
|
|
|
33
35
|
"./style.css": {
|
|
34
36
|
"import": "./dist/index.css",
|
|
35
37
|
"default": "./dist/index.css"
|
|
38
|
+
},
|
|
39
|
+
"./plugin": {
|
|
40
|
+
"types": "./scripts/vite-plugin-nons-config.ts",
|
|
41
|
+
"import": "./scripts/vite-plugin-nons-config.ts",
|
|
42
|
+
"default": "./scripts/vite-plugin-nons-config.ts"
|
|
36
43
|
}
|
|
37
44
|
},
|
|
38
45
|
"scripts": {
|
package/readme.md
CHANGED
|
@@ -2,50 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
Schema-driven UI component library for the Nons platform — Vue 3, TypeScript, token-based design system.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
core/ Schema types, component registry, schema renderer, runtime context
|
|
10
|
-
ui/ Vue 3 components (primitives, composites, layouts, sections)
|
|
11
|
-
generated/ Auto-generated files from nons.config.yaml (tokens.css, theme.css, config.ts, locales/)
|
|
12
|
-
design-system/ CSS reset, global styles (imports generated/ tokens)
|
|
13
|
-
playground/ Demo/explorer app for component development and testing
|
|
14
|
-
plugins/ i18n, direction, permissions
|
|
15
|
-
adapters/ Data provider layer (mock API, storage abstraction)
|
|
16
|
-
locales/ Persian (fa) and English (en) translation YAML files
|
|
17
|
-
scripts/ CLI tools (generate, init, component discovery)
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nons-dev/uikit
|
|
18
9
|
```
|
|
19
10
|
|
|
20
11
|
## Quick Start
|
|
21
12
|
|
|
22
13
|
```bash
|
|
23
|
-
#
|
|
24
|
-
npm install @nons-dev/uikit
|
|
25
|
-
|
|
26
|
-
# Generate config file in your project root
|
|
14
|
+
# Generate config in your project root
|
|
27
15
|
npx @nons-dev/uikit init
|
|
28
16
|
|
|
29
|
-
# Edit nons.config.yaml
|
|
17
|
+
# Edit nons.config.yaml
|
|
18
|
+
```
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
import { bootstrapRegistry
|
|
20
|
+
```ts
|
|
21
|
+
import { bootstrapRegistry } from '@nons-dev/uikit'
|
|
33
22
|
import '@nons-dev/uikit/style.css'
|
|
34
23
|
```
|
|
35
24
|
|
|
36
|
-
|
|
25
|
+
For token/theme/font customization, use the Nons Vite plugin in your project:
|
|
37
26
|
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
```ts
|
|
28
|
+
// vite.config.ts
|
|
29
|
+
import { defineConfig } from 'vite'
|
|
30
|
+
import vue from '@vitejs/plugin-vue'
|
|
31
|
+
import { nonsConfigPlugin } from '@nons-dev/uikit/plugin'
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
plugins: [vue(), nonsConfigPlugin()],
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Architecture
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
nons.config.yaml Single source of truth for theme, tokens, locale, direction, font
|
|
42
|
+
core/ Schema types, component registry, schema renderer, runtime context
|
|
43
|
+
ui/ Vue 3 components (primitives, composites, layouts, sections)
|
|
44
|
+
design-system/ CSS reset, global styles, token defaults (shipped in dist/)
|
|
45
|
+
plugins/ i18n, direction, permissions
|
|
46
|
+
adapters/ Data provider layer (mock API, storage abstraction)
|
|
47
|
+
locales/ Persian (fa) and English (en) translation JSON files
|
|
48
|
+
scripts/ CLI tool (nons) and Vite plugin
|
|
44
49
|
```
|
|
45
50
|
|
|
46
51
|
## Config System
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
`nons.config.yaml` at your project root is the **single source of truth**:
|
|
49
54
|
|
|
50
55
|
```yaml
|
|
51
56
|
theme:
|
|
@@ -72,13 +77,11 @@ tokens:
|
|
|
72
77
|
light:
|
|
73
78
|
--color-primary: '#9FE870'
|
|
74
79
|
--color-danger: '#F31260'
|
|
75
|
-
# ... override any CSS custom property
|
|
76
80
|
dark:
|
|
77
81
|
--color-primary: '#9FE870'
|
|
78
82
|
--color-danger: '#f31260'
|
|
79
83
|
spacing:
|
|
80
84
|
--space-4: 16px
|
|
81
|
-
# ... typography, radius, shadows, z-index, opacity, button, alert
|
|
82
85
|
|
|
83
86
|
theme-mappings:
|
|
84
87
|
light:
|
|
@@ -89,61 +92,70 @@ theme-mappings:
|
|
|
89
92
|
--text-primary: var(--color-text-default)
|
|
90
93
|
```
|
|
91
94
|
|
|
92
|
-
Run `npx @nons-dev/uikit generate` to regenerate CSS variables from your config.
|
|
93
|
-
|
|
94
95
|
## CLI Commands
|
|
95
96
|
|
|
96
97
|
```bash
|
|
97
|
-
npx @nons-dev/uikit init # Create nons.config.yaml in project root
|
|
98
|
-
npx @nons-dev/uikit
|
|
98
|
+
npx @nons-dev/uikit init # Create nons.config.yaml + locales/ in project root
|
|
99
|
+
npx @nons-dev/uikit validate # Validate nons.config.yaml structure
|
|
99
100
|
npx @nons-dev/uikit list # List all components
|
|
100
101
|
npx @nons-dev/uikit show <name> # Show component details (props, events, slots)
|
|
101
102
|
npx @nons-dev/uikit schema <name> # Show schema JSON for a component
|
|
102
103
|
npx @nons-dev/uikit search <query> # Search components by name or description
|
|
103
104
|
```
|
|
104
105
|
|
|
105
|
-
## Customizing
|
|
106
|
+
## Customizing Tokens & Theme
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
npx @nons-dev/uikit generate
|
|
111
|
-
```
|
|
108
|
+
The default design tokens are built into `dist/index.css`. To override them:
|
|
112
109
|
|
|
113
|
-
|
|
110
|
+
1. Edit `nons.config.yaml` with your custom token values
|
|
111
|
+
2. Use the **Nons Vite plugin** to generate custom CSS at build time:
|
|
114
112
|
|
|
115
113
|
```ts
|
|
116
|
-
|
|
117
|
-
import '
|
|
118
|
-
import '
|
|
114
|
+
// vite.config.ts
|
|
115
|
+
import { defineConfig } from 'vite'
|
|
116
|
+
import vue from '@vitejs/plugin-vue'
|
|
117
|
+
import { nonsConfigPlugin } from '@nons-dev/uikit/plugin'
|
|
118
|
+
|
|
119
|
+
export default defineConfig({
|
|
120
|
+
plugins: [vue(), nonsConfigPlugin()],
|
|
121
|
+
})
|
|
119
122
|
```
|
|
120
123
|
|
|
121
|
-
The
|
|
124
|
+
The plugin creates virtual modules (`virtual:nons-config` for JS access, `virtual:nons-config:style` for CSS overrides). Custom token values are injected with the same specificity as defaults.
|
|
122
125
|
|
|
123
|
-
All visual values in the uikit reference CSS custom properties (`var(--color-primary)`), so changing a token
|
|
126
|
+
All visual values in the uikit reference CSS custom properties (`var(--color-primary)`), so changing a token propagates to every component.
|
|
124
127
|
|
|
125
|
-
##
|
|
128
|
+
## Development (UI Kit only)
|
|
126
129
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
```bash
|
|
131
|
+
npm install
|
|
132
|
+
npm run dev # Start Vite dev server (playground app)
|
|
133
|
+
npm run build # Type-check + library build + copy fonts
|
|
134
|
+
npm run preview # Preview production playground build
|
|
135
|
+
```
|
|
131
136
|
|
|
132
137
|
## Key Conventions
|
|
133
138
|
|
|
134
|
-
- **Zero-hardcoding** — all visual values via CSS custom properties
|
|
139
|
+
- **Zero-hardcoding** — all visual values via CSS custom properties
|
|
135
140
|
- **Config-driven** — theme, tokens, direction, locale all from `nons.config.yaml`
|
|
136
141
|
- **RTL-first** — `<html dir="rtl">`, logical properties (`inset-inline-start`, `margin-inline`)
|
|
137
|
-
- **Schema-driven** — every component has a registry key, contract,
|
|
142
|
+
- **Schema-driven** — every component has a registry key, contract, and metadata (53 components)
|
|
138
143
|
- **modelValue** — all form inputs use `modelValue` prop + `update:modelValue` emit
|
|
139
144
|
- **No external margins** — component spacing via parent layout `gap`
|
|
140
|
-
- **Flat UI** — no elevation shadows; separation via themed borders
|
|
145
|
+
- **Flat UI** — no elevation shadows; separation via themed borders
|
|
141
146
|
- **TypeScript strict** — `strict: true`, `noUncheckedIndexedAccess`, `noUnusedLocals`
|
|
142
147
|
|
|
143
148
|
## Dependencies
|
|
144
149
|
|
|
145
|
-
- Vue 3.5 (Composition API
|
|
150
|
+
- Vue 3.5 (Composition API)
|
|
146
151
|
- `@lucide/vue` icons
|
|
147
152
|
- Tabler Icons (CDN)
|
|
148
153
|
- Plain CSS only (no SCSS/Sass)
|
|
149
|
-
- Font files bundled in `dist/font/` (IRANSansX, Satoshi)
|
|
154
|
+
- Font files bundled in `dist/font/` (IRANSansX, Satoshi)
|
|
155
|
+
|
|
156
|
+
## Documentation
|
|
157
|
+
|
|
158
|
+
| Resource | Description |
|
|
159
|
+
|----------|-------------|
|
|
160
|
+
| [Style Guide](docs/STYLE-GUIDE.md) | Token-driven design, layout isolation, flat UI, component conventions |
|
|
161
|
+
| [Component Contracts](docs/component-contracts/) | Single source of truth for all component APIs, schemas, and states |
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as fs from 'node:fs'
|
|
2
|
+
import * as path from 'node:path'
|
|
3
|
+
import * as yaml from 'js-yaml'
|
|
4
|
+
import type { Plugin, ResolvedConfig } from 'vite'
|
|
5
|
+
import type { RawConfig } from '../core/config/types'
|
|
6
|
+
import { generateFullCSS } from '../core/config/parser'
|
|
7
|
+
|
|
8
|
+
const CONFIG_VIRTUAL = 'virtual:nons-config'
|
|
9
|
+
const CONFIG_CSS_VIRTUAL = 'virtual:nons-config:style'
|
|
10
|
+
const RESOLVED_CONFIG_VIRTUAL = '\0' + CONFIG_VIRTUAL
|
|
11
|
+
const RESOLVED_CONFIG_CSS_VIRTUAL = '\0' + CONFIG_CSS_VIRTUAL
|
|
12
|
+
|
|
13
|
+
let loadedConfig: RawConfig | null = null
|
|
14
|
+
|
|
15
|
+
export function loadConfigFromYaml(filePath: string): RawConfig {
|
|
16
|
+
const raw = fs.readFileSync(filePath, 'utf-8')
|
|
17
|
+
const config = yaml.load(raw) as RawConfig
|
|
18
|
+
loadedConfig = config
|
|
19
|
+
return config
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getLoadedConfig(): RawConfig | null {
|
|
23
|
+
return loadedConfig
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function nonsConfigPlugin(configPath?: string): Plugin {
|
|
27
|
+
const resolvedPath = configPath || path.resolve(process.cwd(), 'nons.config.yaml')
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
name: 'nons-config',
|
|
31
|
+
|
|
32
|
+
configResolved(_config: ResolvedConfig) {
|
|
33
|
+
if (fs.existsSync(resolvedPath)) {
|
|
34
|
+
loadConfigFromYaml(resolvedPath)
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
resolveId(id: string) {
|
|
39
|
+
if (id === CONFIG_VIRTUAL) return RESOLVED_CONFIG_VIRTUAL
|
|
40
|
+
if (id === CONFIG_CSS_VIRTUAL) return RESOLVED_CONFIG_CSS_VIRTUAL
|
|
41
|
+
return null
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
load(id: string) {
|
|
45
|
+
if (id === RESOLVED_CONFIG_VIRTUAL) {
|
|
46
|
+
if (!loadedConfig) {
|
|
47
|
+
this.error('nons.config.yaml not found at ' + resolvedPath)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
const runtimeConfig = {
|
|
51
|
+
theme: loadedConfig.theme,
|
|
52
|
+
brand: loadedConfig.brand,
|
|
53
|
+
direction: loadedConfig.direction,
|
|
54
|
+
locale: loadedConfig.locale,
|
|
55
|
+
font: {
|
|
56
|
+
fa: loadedConfig.font?.fa,
|
|
57
|
+
en: loadedConfig.font?.en,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
return `export const nonsConfig = ${JSON.stringify(runtimeConfig, null, 2)}`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (id === RESOLVED_CONFIG_CSS_VIRTUAL) {
|
|
64
|
+
if (!loadedConfig) {
|
|
65
|
+
this.error('nons.config.yaml not found at ' + resolvedPath)
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
return generateFullCSS(loadedConfig)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return null
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|