@kupola/kupola 1.2.0 → 1.3.1

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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -286
  3. package/adapters/axios.d.ts +34 -0
  4. package/adapters/axios.js +122 -0
  5. package/adapters/navios-http.d.ts +110 -0
  6. package/adapters/navios-http.js +151 -0
  7. package/dist/css/accessibility.css +119 -0
  8. package/dist/css/animations.css +224 -0
  9. package/dist/css/brand-themes.css +300 -0
  10. package/dist/css/colors_and_type.css +441 -0
  11. package/dist/css/components-ext.css +4165 -0
  12. package/dist/css/components.css +1483 -0
  13. package/dist/css/responsive.css +697 -0
  14. package/dist/css/scaffold.css +145 -0
  15. package/dist/css/states.css +316 -0
  16. package/dist/css/theme-dark.css +296 -0
  17. package/dist/css/theme-light.css +296 -0
  18. package/dist/css/utilities.css +171 -0
  19. package/dist/kupola.cjs.js +219 -161
  20. package/dist/kupola.cjs.js.map +1 -1
  21. package/dist/kupola.esm.js +6643 -5709
  22. package/dist/kupola.esm.js.map +1 -1
  23. package/dist/kupola.umd.js +219 -161
  24. package/dist/kupola.umd.js.map +1 -1
  25. package/dist/plugins/vite-plugin-kupola.js +120 -0
  26. package/dist/types/kupola.d.ts +421 -323
  27. package/js/calendar.js +334 -25
  28. package/js/carousel.js +182 -48
  29. package/js/collapse.js +148 -34
  30. package/js/color-picker.js +416 -108
  31. package/js/component.js +8 -19
  32. package/js/countdown.js +9 -8
  33. package/js/data-bind.js +73 -16
  34. package/js/datepicker.js +488 -110
  35. package/js/depends.js +710 -0
  36. package/js/dialog.js +4 -2
  37. package/js/drawer.js +172 -8
  38. package/js/dropdown.js +272 -17
  39. package/js/dynamic-tags.js +156 -40
  40. package/js/fileupload.js +9 -8
  41. package/js/form.js +280 -254
  42. package/js/global-events.js +281 -188
  43. package/js/heatmap.js +10 -7
  44. package/js/i18n.js +18 -10
  45. package/js/icons.js +141 -161
  46. package/js/image-preview.js +146 -2
  47. package/js/initializer.js +113 -71
  48. package/js/kupola-core.js +123 -45
  49. package/js/kupola-lifecycle.js +13 -11
  50. package/js/message.js +8 -1
  51. package/js/modal.js +207 -59
  52. package/js/notification.js +8 -1
  53. package/js/numberinput.js +9 -8
  54. package/js/pagination.js +263 -0
  55. package/js/registry.js +29 -12
  56. package/js/select.js +482 -27
  57. package/js/slide-captcha.js +11 -2
  58. package/js/slider.js +442 -25
  59. package/js/statcard.js +9 -7
  60. package/js/table.js +1210 -0
  61. package/js/tag.js +268 -14
  62. package/js/theme.js +14 -43
  63. package/js/timepicker.js +335 -66
  64. package/js/tooltip.js +317 -86
  65. package/js/utils.js +6 -2
  66. package/js/validation.js +6 -2
  67. package/js/virtual-list.js +11 -7
  68. package/js/web-components.js +288 -0
  69. package/package.json +77 -67
  70. package/plugins/vite-plugin-kupola.js +120 -0
  71. package/types/kupola.d.ts +421 -323
  72. package/CHANGELOG.md +0 -130
  73. package/INTEGRATION.md +0 -440
  74. package/PROJECT_SUMMARY.md +0 -312
  75. package/SKILL.md +0 -572
  76. package/dist/utils/utils/Kupola.cs +0 -77
  77. package/dist/utils/utils/Kupola.java +0 -104
  78. package/dist/utils/utils/kupola.go +0 -120
  79. package/dist/utils/utils/kupola.js +0 -63
  80. package/dist/utils/utils/kupola.py +0 -1392
  81. package/dist/utils/utils/kupola.rb +0 -69
  82. package/js/composition-api.js +0 -458
  83. package/js/error-handler.js +0 -181
  84. package/js/http.js +0 -419
  85. package/js/kupola-devtools.js +0 -598
  86. package/js/performance.js +0 -250
  87. package/js/router.js +0 -396
  88. package/js/security.js +0 -189
  89. package/js/test-utils.js +0 -251
  90. package/templates/base.html +0 -30
  91. package/templates/base_dashboard.html +0 -99
  92. package/utils/Kupola.cs +0 -77
  93. package/utils/Kupola.java +0 -104
  94. package/utils/kupola.go +0 -120
  95. package/utils/kupola.js +0 -63
  96. package/utils/kupola.py +0 -1392
  97. package/utils/kupola.rb +0 -69
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KUPOLA
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 CHANGED
@@ -1,286 +1,330 @@
1
- # Kupola
2
-
3
- A lightweight UI toolkit for any web project. No heavy frontend frameworks required. Works seamlessly with Flask, Django, Gin, Spring Boot, ASP.NET Core, Express, Ruby on Rails, and any backend framework that outputs HTML.
4
-
5
- ## Features
6
-
7
- - **50+ Components**: Buttons, inputs, cards, modals, datepickers, timepickers, heatmap, virtual list, stat cards, image components, and more
8
- - **Dual Themes**: Dark-first design with light theme support
9
- - **11 Brand Colors**: Switchable brand colors
10
- - **Responsive Design**: Works on PC, Pad, and Phone
11
- - **Accessibility**: WCAG AA compliant
12
- - **Form Validation**: Built-in validation with custom rules
13
- - **Data Binding**: Two-way data binding system (Proxy-based)
14
- - **No Dependencies**: Pure HTML/CSS/JavaScript
15
- - **Multi-language Support**: Helper functions for Python, Go, Java, C#, Node.js, Ruby
16
-
17
- ## Quick Start
18
-
19
- ### 1. Copy Files
20
-
21
- Copy the `kupola` directory to your project:
22
-
23
- ```
24
- your-project/
25
- ├── kupola/
26
- │ ├── css/
27
- │ ├── js/
28
- │ └── icons/
29
- └── index.html
30
- ```
31
-
32
- ### 2. Include CSS
33
-
34
- ```html
35
- <link rel="stylesheet" href="kupola/css/kupola.css">
36
- ```
37
-
38
- ### 3. Include JavaScript
39
-
40
- ```html
41
- <script src="kupola/js/kupola-core.js"></script>
42
- ```
43
-
44
- ### 4. Start Using Components
45
-
46
- ```html
47
- <button class="ds-btn ds-btn--brand">Click Me</button>
48
- <input type="text" class="ds-input" placeholder="Enter text">
49
- <div class="ds-card">
50
- <div class="ds-card__header">
51
- <h3 class="ds-card__title">Card Title</h3>
52
- </div>
53
- <div class="ds-card__body">Card content</div>
54
- </div>
55
- ```
56
-
57
- ## Framework Integration
58
-
59
- ### Python (Flask/Django)
60
-
61
- ```python
62
- from kupola import button, card
63
-
64
- html = card("Welcome", "Hello Kupola!", "") + button("Submit", "brand", "md")
65
- ```
66
-
67
- ### Go (Gin/Echo)
68
-
69
- ```go
70
- import "kupola"
71
-
72
- html := kupola.Card("Welcome", "Hello Kupola!", "") + kupola.Button("Submit", "brand", "md")
73
- ```
74
-
75
- ### Java (Spring Boot)
76
-
77
- ```java
78
- import com.kupola.Kupola;
79
-
80
- String html = Kupola.card("Welcome", "Hello Kupola!", "") + Kupola.button("Submit", "brand", "md");
81
- ```
82
-
83
- ### C# (ASP.NET Core)
84
-
85
- ```csharp
86
- using Kupola;
87
-
88
- string html = Components.Card("Welcome", "Hello Kupola!", "") + Components.Button("Submit", "brand", "md");
89
- ```
90
-
91
- ### Node.js (Express/Koa)
92
-
93
- ```javascript
94
- import { button, card } from './kupola/utils/kupola.js';
95
-
96
- const html = card('Welcome', 'Hello Kupola!', '') + button('Submit', 'brand', 'md');
97
- ```
98
-
99
- ### Ruby (Ruby on Rails)
100
-
101
- ```ruby
102
- require './utils/kupola.rb'
103
-
104
- html = Kupola.card('Welcome', 'Hello Kupola!', '') + Kupola.button('Submit', 'brand', 'md')
105
- ```
106
-
107
- ## Basic Usage Examples
108
-
109
- ### Buttons
110
-
111
- ```html
112
- <button class="ds-btn ds-btn--brand">Primary</button>
113
- <button class="ds-btn ds-btn--secondary">Secondary</button>
114
- <button class="ds-btn ds-btn--outline">Outline</button>
115
- <button class="ds-btn ds-btn--ghost">Ghost</button>
116
- <button class="ds-btn ds-btn--danger">Danger</button>
117
- ```
118
-
119
- ### Inputs
120
-
121
- ```html
122
- <input type="text" class="ds-input" placeholder="Text input">
123
- <input type="password" class="ds-input" placeholder="Password">
124
- <input type="email" class="ds-input" placeholder="Email">
125
- <textarea class="ds-textarea" placeholder="Textarea"></textarea>
126
- ```
127
-
128
- ### Cards
129
-
130
- ```html
131
- <div class="ds-card">
132
- <div class="ds-card__header">
133
- <h3 class="ds-card__title">Card Title</h3>
134
- <p class="ds-card__subtitle">Subtitle</p>
135
- </div>
136
- <div class="ds-card__body">Card content goes here</div>
137
- <div class="ds-card__footer">Footer actions</div>
138
- </div>
139
- ```
140
-
141
- ### Forms
142
-
143
- ```html
144
- <form class="ds-form">
145
- <div class="ds-form-item">
146
- <label class="ds-form-item__label">Name</label>
147
- <input type="text" class="ds-input" placeholder="Enter name">
148
- </div>
149
- <div class="ds-form-item">
150
- <label class="ds-form-item__label">Email</label>
151
- <input type="email" class="ds-input" data-validate="email" placeholder="Enter email">
152
- </div>
153
- <button type="submit" class="ds-btn ds-btn--brand">Submit</button>
154
- </form>
155
- ```
156
-
157
- ### Data Binding
158
-
159
- ```html
160
- <input type="text" data-bind="user.name:value" placeholder="Name">
161
- <span data-bind="user.name:text"></span>
162
- <input type="checkbox" data-bind="user.active:checked">
163
- ```
164
-
165
- ```javascript
166
- kupolaData.data.user = { name: 'John', active: true };
167
- kupolaData.data.user.name = 'Jane'; // Auto updates all bound elements
168
- ```
169
-
170
- ### Theme Switching
171
-
172
- ```javascript
173
- setTheme('light'); // Switch to light theme
174
- setTheme('dark'); // Switch to dark theme
175
- setBrand('zengqing'); // Set brand color to 曾青
176
- ```
177
-
178
- ## Project Structure
179
-
180
- ```
181
- kupola/
182
- ├── css/ # CSS stylesheets
183
- │ ├── kupola.css # Main CSS bundle
184
- │ ├── components.css # Component styles
185
- │ ├── components-ext.css # Extended component styles
186
- │ ├── theme-dark.css # Dark theme tokens
187
- │ ├── theme-light.css # Light theme tokens
188
- │ └── ... # Other stylesheets
189
- ├── js/ # JavaScript modules (40+)
190
- │ ├── kupola-core.js # Core framework
191
- │ ├── kupola-lifecycle.js # Lifecycle management
192
- │ ├── kupola-devtools.js # Development tools
193
- │ ├── component.js # Base component class
194
- │ ├── router.js # Client-side router
195
- │ ├── http.js # HTTP client
196
- │ ├── data-bind.js # Data binding
197
- │ ├── validation.js # Form validation
198
- │ ├── theme.js # Theme/brand switching
199
- │ └── ... # UI components
200
- ├── icons/ # 120+ SVG icons
201
- ├── dist/ # Build output
202
- │ ├── kupola.esm.js # ES Module format
203
- │ ├── kupola.cjs.js # CommonJS format
204
- │ ├── kupola.umd.js # UMD format
205
- │ └── types/kupola.d.ts # TypeScript types
206
- ├── src/ # Build entry points
207
- ├── utils/ # Multi-language utility functions
208
- │ ├── kupola.py # Python component generation
209
- │ ├── kupola.go # Go component generation
210
- │ ├── Kupola.java # Java component generation
211
- │ ├── Kupola.cs # C# component generation
212
- │ ├── kupola.js # Node.js component generation
213
- │ └── kupola.rb # Ruby component generation
214
- ├── templates/ # HTML templates
215
- │ ├── base.html # Base template
216
- │ └── base_dashboard.html # Dashboard base template
217
- ├── dashboard/ # Dashboard template
218
- ├── casepages/ # Component showcase pages
219
- ├── test/ # Test files
220
- ├── examples/ # Usage examples
221
- ├── docs/ # Documentation
222
- ├── INTEGRATION.md # Integration guide
223
- └── package.json # Build scripts
224
- ```
225
-
226
- ## Build
227
-
228
- ```bash
229
- cd kupola
230
- npm install
231
- npm run build # Production build (Vite)
232
- npm run build:rollup # Alternative build (Rollup)
233
- npm run dev # Development server
234
- ```
235
-
236
- ## Documentation
237
-
238
- - [Integration Guide](INTEGRATION.md) - Framework integration examples
239
- - [API Documentation](docs/api.md) - API reference
240
- - [showcase.html](dashboard/showcase.html) - Interactive component showcase
241
- - [Case Pages](casepages/) - Component usage examples
242
-
243
- ## Browser Support
244
-
245
- Chrome, Firefox, Safari, Edge (latest versions)
246
-
247
- ## License
248
-
249
- MIT License
250
-
251
- ## Migration Notice
252
-
253
- This project was previously known as **Nimbus Design System**. It has been renamed to **Kupola** with the following changes:
254
-
255
- ### Name Changes
256
-
257
- | Old Name | New Name |
258
- |----------|----------|
259
- | `NimbusComponent` | `KupolaComponent` |
260
- | `NimbusHttp` | `KupolaHttp` |
261
- | `NimbusRouter` | `KupolaRouter` |
262
- | `NimbusLifecycle` | `KupolaLifecycle` |
263
- | `window.nimbusData` | `window.kupolaData` |
264
- | `window.nimbusRegistry` | `window.kupolaRegistry` |
265
-
266
- ### File Changes
267
-
268
- | Old Path | New Path |
269
- |----------|----------|
270
- | `js/nimbus-core.js` | `js/kupola-core.js` |
271
- | `js/nimbus-lifecycle.js` | `js/kupola-lifecycle.js` |
272
- | `js/nimbus-devtools.js` | `js/kupola-devtools.js` |
273
- | `css/nimbus.css` | `css/kupola.css` |
274
- | `types/nimbus.d.ts` | `types/kupola.d.ts` |
275
- | `dist/nimbus.esm.js` | `dist/kupola.esm.js` |
276
- | `dist/nimbus.cjs.js` | `dist/kupola.cjs.js` |
277
- | `dist/nimbus.umd.js` | `dist/kupola.umd.js` |
278
-
279
- ### Removed Files
280
-
281
- - `build.js` / `watch.js` - Legacy build scripts (replaced by Vite)
282
- - `dev-server.js` - Unused development server
283
- - `DOCS.md` - Outdated documentation
284
- - `components/` - Legacy HTML components
285
- - `common/` - Empty directory
286
- - Temporary scripts: `rename-project.cjs`, `fix-remaining.cjs`, etc.
1
+ # Kupola
2
+
3
+ > A lightweight, dependency-free declarative UI component system for server-side rendered web applications.
4
+ >
5
+ > 零外部框架依赖的声明式 UI 组件系统,适用于任何服务端渲染 Web 应用。
6
+
7
+ [![License](https://img.shields.io/github/license/kupola-cn/kupola)](https://github.com/kupola-cn/kupola/blob/main/LICENSE)
8
+ [![npm](https://img.shields.io/npm/v/@kupola/kupola)](https://www.npmjs.com/package/@kupola/kupola)
9
+ [![bundle size (gzip)](https://img.shields.io/badge/gzip-88%20KB-blue)](https://bundlephobia.com/package/@kupola/kupola)
10
+ [![GitHub stars](https://img.shields.io/github/stars/kupola-cn/kupola)](https://github.com/kupola-cn/kupola/stargazers)
11
+
12
+ **HTMX** (data fetching) + **Alpine.js** (declarative interaction) + **Bootstrap** (component richness) — in one zero-dependency package.
13
+
14
+ ---
15
+
16
+ ## 🌐 Languages / 语言
17
+
18
+ - [English](#english)
19
+ - [中文](#中文)
20
+
21
+ ---
22
+
23
+ <a id="english"></a>
24
+ ## ✨ Features
25
+
26
+ - **50+ UI Components** — Buttons, inputs, cards, modals, datepickers, timepickers, heatmap, virtual list, stat cards, and more
27
+ - **Declarative Data Dependencies** — `useDeps()` with auto-caching, retry, refresh, and transform
28
+ - **HTTP Client Plugin System** — Plug in Axios, @navios/http, or any HTTP client; interceptors preserved
29
+ - **Reactive Data Binding** — Two-way binding with `ref()` / `store()` (Proxy-based)
30
+ - **Dual Themes** — Dark-first design with light theme support
31
+ - **11 Brand Colors** — Switchable brand themes inspired by Chinese traditional colors
32
+ - **Responsive** PC, Pad, and Phone
33
+ - **Accessible** — WCAG AA compliant
34
+ - **Form Validation** — Built-in validation with custom rules
35
+ - **Zero Dependencies** — Pure HTML/CSS/JavaScript, ~88 KB gzipped
36
+ - **Backend Agnostic** — Works with Flask, Django, FastAPI, Gin, Spring Boot, ASP.NET, Express, Rails, Actix-web, and any backend that outputs HTML
37
+ - **TypeScript Ready** — Full type definitions included
38
+
39
+ ---
40
+
41
+ ## 🚀 Quick Start
42
+
43
+ ### npm
44
+
45
+ ```bash
46
+ npm install @kupola/kupola
47
+ ```
48
+
49
+ ```html
50
+ <link rel="stylesheet" href="node_modules/@kupola/kupola/dist/css/kupola.css">
51
+ <script src="node_modules/@kupola/kupola/dist/kupola.esm.js" type="module"></script>
52
+ ```
53
+
54
+ ### CDN
55
+
56
+ ```html
57
+ <!-- ESM (modern browsers) -->
58
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/css/kupola.css">
59
+ <script src="https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola.esm.js" type="module"></script>
60
+
61
+ <!-- UMD (legacy) -->
62
+ <script src="https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola.umd.js"></script>
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 📦 Usage
68
+
69
+ ### Components (HTML-only, no JS needed)
70
+
71
+ ```html
72
+ <button class="ds-btn ds-btn--brand">Primary</button>
73
+ <button class="ds-btn ds-btn--outline">Outline</button>
74
+
75
+ <div class="ds-card">
76
+ <div class="ds-card__header">
77
+ <h3 class="ds-card__title">Card Title</h3>
78
+ </div>
79
+ <div class="ds-card__body">Card content</div>
80
+ </div>
81
+ ```
82
+
83
+ ### Data Binding
84
+
85
+ ```html
86
+ <input type="text" data-bind="user.name:value" placeholder="Name">
87
+ <span data-bind="user.name:text"></span>
88
+ ```
89
+
90
+ ```js
91
+ kupolaData.data.user = { name: 'John' };
92
+ kupolaData.data.user.name = 'Jane'; // Auto-updates all bound elements
93
+ ```
94
+
95
+ ### Declarative Data Dependencies
96
+
97
+ ```html
98
+ <div data-deps="users:fetch:/api/users">
99
+ <template data-each="users">
100
+ <span data-bind="item.name:text"></span>
101
+ </template>
102
+ </div>
103
+ ```
104
+
105
+ ```js
106
+ import { useDeps } from 'kupola';
107
+ useDeps({ users: { url: '/api/users', staleTime: 60000 } });
108
+ ```
109
+
110
+ ### HTTP Client Plugin (Axios Example)
111
+
112
+ ```js
113
+ import { configureHttpClient } from 'kupola';
114
+ import { createAxiosAdapter } from 'kupola/adapters/axios';
115
+ import axios from 'axios';
116
+
117
+ const api = axios.create({ baseURL: '/api' });
118
+ api.interceptors.request.use(config => {
119
+ config.headers.Authorization = `Bearer ${getToken()}`;
120
+ return config;
121
+ });
122
+
123
+ // All useDeps() requests now go through Axios
124
+ configureHttpClient(createAxiosAdapter(api));
125
+ ```
126
+
127
+ ### HTTP Client Plugin (@navios/http Example)
128
+
129
+ ```js
130
+ import { configureHttpClient } from 'kupola';
131
+ import { createNaviosAdapter } from 'kupola/adapters/navios-http';
132
+ import { create } from '@navios/http';
133
+
134
+ const client = create({ baseURL: '/api' });
135
+ client.interceptors.request.use(config => {
136
+ config.headers['Authorization'] = `Bearer ${getToken()}`;
137
+ return config;
138
+ });
139
+
140
+ configureHttpClient(createNaviosAdapter(client));
141
+ ```
142
+
143
+ ---
144
+
145
+ ## 📖 Documentation
146
+
147
+ - [Usage Guide](docs/usage-guide.md) Getting started and API reference
148
+ - [Integration Guide](INTEGRATION.md) — Framework integration examples
149
+ - [Kupola vs Vue/React](docs/kupola-vs-vue-react.md) — Architecture comparison
150
+ - [Contributing](CONTRIBUTING.md) — How to contribute
151
+
152
+ ---
153
+
154
+ ## 🛠️ Development
155
+
156
+ ```bash
157
+ npm install # Install dependencies
158
+ npm run dev # Dev server (Vite, hot reload)
159
+ npm run build # Production build
160
+ npm run lint # Lint code
161
+ npm run test # Run tests
162
+ ```
163
+
164
+ ---
165
+
166
+ ## 🌐 Browser Support
167
+
168
+ Chrome, Firefox, Safari, Edge (latest)
169
+
170
+ ---
171
+
172
+ <a id="中文"></a>
173
+ ## 核心特性
174
+
175
+ - **50+ UI 组件** 按钮、输入框、卡片、模态框、日期选择器、时间选择器、热力图、虚拟列表、统计卡片等
176
+ - **声明式数据依赖** — `useDeps()` 自动缓存、重试、刷新、数据转换
177
+ - **HTTP 客户端插件** — 无缝集成 Axios、@navios/http 或任意 HTTP 客户端,保留拦截器
178
+ - **响应式数据绑定** — 基于 Proxy 的双向绑定,`ref()` / `store()`
179
+ - **双主题** — 暗色优先设计,支持亮色主题切换
180
+ - **11 种品牌色** — 灵感源自中国传统色的可切换品牌主题
181
+ - **响应式** — 适配 PC、平板、手机
182
+ - **无障碍** 符合 WCAG AA 标准
183
+ - **表单验证** 内置验证系统,支持自定义规则
184
+ - **零依赖** 纯 HTML/CSS/JavaScript,gzip 后约 88 KB
185
+ - **后端无关** — 支持 Flask、Django、FastAPI、Gin、Spring Boot、ASP.NET、Express、Rails、Actix-web 等任何输出 HTML 的后端
186
+ - **TypeScript 支持** — 完整类型定义
187
+
188
+ ---
189
+
190
+ ## 🚀 快速开始
191
+
192
+ ### npm 安装
193
+
194
+ ```bash
195
+ npm install @kupola/kupola
196
+ ```
197
+
198
+ ```html
199
+ <link rel="stylesheet" href="node_modules/@kupola/kupola/dist/css/kupola.css">
200
+ <script src="node_modules/@kupola/kupola/dist/kupola.esm.js" type="module"></script>
201
+ ```
202
+
203
+ ### CDN 引入
204
+
205
+ ```html
206
+ <!-- ESM(现代浏览器) -->
207
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/css/kupola.css">
208
+ <script src="https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola.esm.js" type="module"></script>
209
+
210
+ <!-- UMD(传统方式) -->
211
+ <script src="https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola.umd.js"></script>
212
+ ```
213
+
214
+ ---
215
+
216
+ ## 📦 使用示例
217
+
218
+ ### 组件(纯 HTML,无需 JS)
219
+
220
+ ```html
221
+ <button class="ds-btn ds-btn--brand">主要按钮</button>
222
+ <button class="ds-btn ds-btn--outline">描边按钮</button>
223
+
224
+ <div class="ds-card">
225
+ <div class="ds-card__header">
226
+ <h3 class="ds-card__title">卡片标题</h3>
227
+ </div>
228
+ <div class="ds-card__body">卡片内容</div>
229
+ </div>
230
+ ```
231
+
232
+ ### 数据绑定
233
+
234
+ ```html
235
+ <input type="text" data-bind="user.name:value" placeholder="姓名">
236
+ <span data-bind="user.name:text"></span>
237
+ ```
238
+
239
+ ```js
240
+ kupolaData.data.user = { name: '张三' };
241
+ kupolaData.data.user.name = '李四'; // 所有绑定元素自动更新
242
+ ```
243
+
244
+ ### 声明式数据依赖
245
+
246
+ ```html
247
+ <div data-deps="users:fetch:/api/users">
248
+ <template data-each="users">
249
+ <span data-bind="item.name:text"></span>
250
+ </template>
251
+ </div>
252
+ ```
253
+
254
+ ```js
255
+ import { useDeps } from 'kupola';
256
+ useDeps({ users: { url: '/api/users', staleTime: 60000 } });
257
+ ```
258
+
259
+ ### HTTP 客户端插件(Axios 示例)
260
+
261
+ ```js
262
+ import { configureHttpClient } from 'kupola';
263
+ import { createAxiosAdapter } from 'kupola/adapters/axios';
264
+ import axios from 'axios';
265
+
266
+ const api = axios.create({ baseURL: '/api' });
267
+ api.interceptors.request.use(config => {
268
+ config.headers.Authorization = `Bearer ${getToken()}`;
269
+ return config;
270
+ });
271
+
272
+ // 之后所有 useDeps() 请求自动走 Axios + 拦截器
273
+ configureHttpClient(createAxiosAdapter(api));
274
+ ```
275
+
276
+ ---
277
+
278
+ ## 📖 文档
279
+
280
+ - [使用指南](docs/usage-guide.md) — 入门与 API 参考
281
+ - [集成指南](INTEGRATION.md) 后端框架集成示例
282
+ - [Kupola 与 Vue/React 对比](docs/kupola-vs-vue-react.md) 架构对比
283
+ - [贡献指南](CONTRIBUTING.md) 如何参与贡献
284
+
285
+ ---
286
+
287
+ ## 🛠️ 开发
288
+
289
+ ```bash
290
+ npm install # 安装依赖
291
+ npm run dev # 开发服务器(Vite,热更新)
292
+ npm run build # 生产构建
293
+ npm run lint # 代码检查
294
+ npm run test # 运行测试
295
+ ```
296
+
297
+ ---
298
+
299
+ ## 🌐 浏览器支持
300
+
301
+ Chrome、Firefox、Safari、Edge(最新版本)
302
+
303
+ ---
304
+
305
+ ## 🤝 Contributing / 贡献
306
+
307
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
308
+
309
+ ---
310
+
311
+ ## 🙏 Acknowledgments / 致谢
312
+
313
+ Kupola is built with the help of these excellent open-source tools:
314
+
315
+ **Build & Dev Tooling:**
316
+ - [Vite](https://vitejs.dev/) — Next generation frontend tooling
317
+ - [Rollup](https://rollupjs.org/) — ES module bundler
318
+ - [ESLint](https://eslint.org/) — JavaScript linter
319
+ - [Prettier](https://prettier.io/) — Code formatter
320
+ - [Jest](https://jestjs.io/) — JavaScript testing framework
321
+
322
+ **HTTP Client Adapters (optional, user-installed):**
323
+ - [Axios](https://axios-http.com/) — Promise based HTTP client
324
+ - [@navios/http](https://www.npmjs.com/package/@navios/http) — Lightweight fetch-based Axios replacement
325
+
326
+ ---
327
+
328
+ ## 📄 License
329
+
330
+ [MIT](LICENSE) © Kupola Team