@mrchar/cumquat 0.0.0-stage → 0.1.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 +90 -2
- package/dist/components/index.d.ts +4372 -0
- package/dist/components/index.js +10364 -0
- package/dist/composables/index.d.ts +1962 -0
- package/dist/composables/index.js +4135 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +62 -4
- package/style.css +2 -0
- package/themes/basic.css +2777 -0
- package/themes/dark.css +41 -0
- package/themes/glass.css +265 -0
- package/themes/high-contrast.css +45 -0
- package/themes/light.css +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mrchar
|
|
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,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mrchar/cumquat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 组件库,核心理念是**逻辑与渲染解耦**:Headless 组合函数负责状态机与行为,`.vue` 组件只做默认渲染壳。所有异步能力通过统一协议接入,组件自身不发请求。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- **三层架构**:逻辑层(composables)→ 默认渲染层(components)→ 主题层(themes),单向依赖
|
|
8
|
+
- **三大异步协议**:
|
|
9
|
+
- `fetch` — 组件主动查询(分页/搜索/排序),自动注入查询参数、防抖、竞态处理、四态渲染
|
|
10
|
+
- `action` — 交互动作绑定 Promise,自动派生 loading/disabled,失败错误条或乐观回退
|
|
11
|
+
- `subscribe` — 被动订阅外部推送数据,失败保留旧数据并支持重试
|
|
12
|
+
- **统一契约**:`AsyncStateLike` / `ActionResult` / `SubscribeResult` 最小类型集合通信
|
|
13
|
+
- **资源池**:`useResources` 绑定服务器与 OpenAPI / Swagger 文档地址,即导出资源 list / detail / create / update / remove 方法与 `columns` / `properties` 字段元数据
|
|
14
|
+
- **竞选机制**:`type` / `format` 元数据自动推断渲染——Table 单元格竞选管展示,Form 字段竞选管录入;插槽 > 显式指定 > 竞选推断 > 兜底,`bias` 加成与注册表覆盖支持宿主扩展
|
|
15
|
+
- **语义化主题**:`cq-` 前缀语义 token + 5 套主题包(basic / light / dark / high-contrast / glass)
|
|
16
|
+
- **v-model 纯同步**:异步 props 全部可选,不传即普通组件
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add @mrchar/cumquat
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 使用
|
|
25
|
+
|
|
26
|
+
### 统一入口(命名空间导出)
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { composables, components } from '@mrchar/cumquat';
|
|
30
|
+
|
|
31
|
+
const { useFetch, useSubscribe, message } = composables;
|
|
32
|
+
const { Button, Table, Cumquat } = components;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 子路径入口
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// 仅组合函数
|
|
39
|
+
import { useFetch } from '@mrchar/cumquat/composables';
|
|
40
|
+
// 仅组件
|
|
41
|
+
import { Button } from '@mrchar/cumquat/components';
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 主题样式(纯 CSS,按需引入其一)
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
/* 宿主已有 Tailwind v4:扫描包内 dist 类名 + 引入主题 */
|
|
48
|
+
@import 'tailwindcss';
|
|
49
|
+
@source '../node_modules/@mrchar/cumquat/dist';
|
|
50
|
+
@import '@mrchar/cumquat/themes/basic.css';
|
|
51
|
+
@import '@mrchar/cumquat/themes/light.css'; /* 或 dark / high-contrast / glass */
|
|
52
|
+
|
|
53
|
+
/* 无 Tailwind:直接引入预编译样式(内含全部主题) */
|
|
54
|
+
@import '@mrchar/cumquat/style.css';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 快速示例
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<script setup lang="ts">
|
|
61
|
+
import { components } from '@mrchar/cumquat';
|
|
62
|
+
import type { components as c } from '@mrchar/cumquat';
|
|
63
|
+
|
|
64
|
+
const { Table, Dialog } = components;
|
|
65
|
+
|
|
66
|
+
const fetchUsers: c.Fetch<UserRow> = async (query) => {
|
|
67
|
+
const res = await fetch(`/api/users?page=${query.pagination?.currentPage ?? 1}`);
|
|
68
|
+
return res.json();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const confirmAction = async () => {
|
|
72
|
+
await api.delete(id);
|
|
73
|
+
};
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<Table :columns="columns" :fetch="fetchUsers" :pagination="{ pageSize: 20 }" />
|
|
78
|
+
<Dialog v-model:open="open" title="删除确认" :action="confirmAction">确定删除?</Dialog>
|
|
79
|
+
</template>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 文档
|
|
83
|
+
|
|
84
|
+
完整组件文档(含可编辑实时演示)位于仓库 [docs](https://github.com/mrchar/cumquat/tree/main/docs) 目录:
|
|
85
|
+
|
|
86
|
+
- [远程数据 Fetch](https://github.com/mrchar/cumquat/blob/main/docs/fetch.md) / [交互动作 Action](https://github.com/mrchar/cumquat/blob/main/docs/action.md) / [数据订阅 Subscribe](https://github.com/mrchar/cumquat/blob/main/docs/subscribe.md)
|
|
87
|
+
- [组件文档](https://github.com/mrchar/cumquat/tree/main/docs/components) — 每个组件页含可编辑实时演示
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
[MIT](./LICENSE)
|