@pactor-app/ui 1.1.0 → 1.3.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/README.md +27 -31
- package/dist/{chunk-BZSRLTQQ.js → chunk-7KC6DMKH.js} +8 -8
- package/dist/chunk-EVGIS2ZE.js +614 -0
- package/dist/{chunk-F3H23KYG.js → chunk-F42SGQNW.js} +31 -93
- package/dist/chunk-L4Z7MNYY.js +1197 -0
- package/dist/{chunk-6B5ZX7L3.js → chunk-P54Y23AP.js} +201 -597
- package/dist/{chunk-GV5R6TUT.js → chunk-TDVG7MZ5.js} +180 -49
- package/dist/{chunk-BVHAP22U.js → chunk-UKA7C3JP.js} +213 -486
- package/dist/chunk-WKJUCGV4.js +78 -0
- package/dist/components/index.cjs +1023 -695
- package/dist/components/index.d.cts +37 -19
- package/dist/components/index.d.ts +37 -19
- package/dist/components/index.js +20 -18
- package/dist/index.cjs +1359 -913
- package/dist/index.d.cts +3 -36
- package/dist/index.d.ts +3 -36
- package/dist/index.js +40 -47
- package/dist/interaction/index.cjs +17 -13
- package/dist/interaction/index.d.cts +13 -16
- package/dist/interaction/index.d.ts +13 -16
- package/dist/interaction/index.js +7 -7
- package/dist/layout/index.cjs +1084 -63
- package/dist/layout/index.d.cts +98 -20
- package/dist/layout/index.d.ts +98 -20
- package/dist/layout/index.js +18 -16
- package/dist/ui/index.cjs +1688 -533
- package/dist/ui/index.d.cts +130 -16
- package/dist/ui/index.d.ts +130 -16
- package/dist/ui/index.js +485 -26
- package/package.json +6 -5
- package/styles.css +936 -107
- package/dist/chunk-6JNCDPGS.js +0 -257
- package/dist/chunk-GL7IO22L.js +0 -225
- package/dist/chunk-RQHJBTEU.js +0 -10
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @pactor-app/ui
|
|
2
2
|
|
|
3
|
-
[Pactor](https://github.com/426-330/pactor)
|
|
3
|
+
[Pactor](https://github.com/426-330/pactor) 的**内置默认 UI 实现**(shadcn 风格):内含 components / interaction / layout 三层(vendored shadcn/ui 组件源码——Base UI 原语(`@base-ui/react`,shadcn 官方默认原语层)+ cva + tailwind-merge + lucide-react;12 组件 props 契约类型、交互核心 `OverlayManager` / `createUiBridge` / `registerInteractionActions` / `UiBridge`、布局类型与 `resolveLayout` 均为本包自有),并提供预建样式表。**这是 @pactor-app/app 的内置默认 UI 实现**。主入口导出三层全部公开 API,另提供子路径入口:`@pactor-app/ui/components`(DSL 组件适配层)/ `/interaction` / `/layout` / `/ui`(vendored shadcn 原语组件——宿主自写 React UI 用,如槽位内容与自定义组件)。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -26,33 +26,28 @@ createPactorApplication({
|
|
|
26
26
|
}).mount('#root');
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## 自定义覆盖点
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
业务可用 `createPactorApplication` 的细粒度选项逐槽位覆盖默认实现:
|
|
32
32
|
|
|
33
|
-
| 槽位 |
|
|
33
|
+
| 槽位 | 默认值 |
|
|
34
34
|
| --- | --- |
|
|
35
|
-
| `componentRegistry` | `
|
|
36
|
-
| `layoutRegistry` | `
|
|
37
|
-
| `interactionKit` | `{ Provider:
|
|
35
|
+
| `componentRegistry` | `createComponentRegistry`(components 层) |
|
|
36
|
+
| `layoutRegistry` | `createLayoutRegistry`(layout 层) |
|
|
37
|
+
| `interactionKit` | `{ Provider: InteractionProvider, OverlayHost: OverlayHost }`(interaction 层) |
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
import { shadcnUiKit } from '@pactor-app/ui';
|
|
41
|
-
|
|
42
|
-
createPactorApplication({
|
|
43
|
-
appId: 'risk-admin',
|
|
44
|
-
api: { baseURL: '/api/runtime' },
|
|
45
|
-
ui: shadcnUiKit, // 与不传 ui 的默认行为一致
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
每个槽位的取值优先级为:**显式细粒度选项 > `ui` 预设 > 内置 shadcn 默认**。例如只覆盖布局层、其余槽位保持 shadcn 预设:
|
|
39
|
+
各槽位独立合并,显式传入的选项优先于内置默认。例如只覆盖布局层、其余槽位保持内置默认:
|
|
50
40
|
|
|
51
41
|
```ts
|
|
42
|
+
import { createLayoutRegistry } from '@pactor-app/ui/layout';
|
|
43
|
+
|
|
52
44
|
createPactorApplication({
|
|
53
45
|
appId: 'risk-admin',
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
layoutRegistry: () => {
|
|
47
|
+
const registry = createLayoutRegistry();
|
|
48
|
+
registry.register('my-layout', MyLayout);
|
|
49
|
+
return registry;
|
|
50
|
+
},
|
|
56
51
|
});
|
|
57
52
|
```
|
|
58
53
|
|
|
@@ -66,43 +61,44 @@ import '@pactor-app/ui/styles.css';
|
|
|
66
61
|
|
|
67
62
|
主题契约为 shadcn 语义令牌:`--background` / `--foreground` / `--card` / `--popover` / `--primary` / `--secondary` / `--muted` / `--accent` / `--destructive` / `--border` / `--input` / `--ring` / `--radius`(另补充 `--success` / `--warning` / `--info` 供 Alert 四态),定义在 `:root`,组件工具类经 `var()` 运行时读取。换肤即覆盖变量;内置暗色皮肤经 `<html data-pactor-theme="dark">`(或任意容器)切换,与全仓约定一致。
|
|
68
63
|
|
|
64
|
+
**皮肤令牌契约(CSS 皮肤文件)**:组件全部颜色/阴影/圆角经令牌解析(无硬编码颜色),宿主在 `styles.css` 之后加载一个普通 CSS 文件即可完整换肤,运行时替换样式表节点即切换皮肤,无需重建。语义令牌之上还有组件级令牌(命名 `--<component>-<part>-<state>`,默认值经 `var()` 回退到语义令牌)覆盖 Switch/Slider/Radio/Progress/Pagination/Menu 系 hover 与选中/Bubble/Calendar/卡片阴影/弹层阴影色/模态遮罩;页面背景经 `--background`(纯色)+ `--background-image`(渐变/图片,默认 `none`)承接,字体族经 `--font-sans`。完整令牌清单与示例见 docs《主题与换肤》指南(docs/src/content/docs/guides/theming.md)。
|
|
65
|
+
|
|
69
66
|
**preflight 开启(shadcn 官方基线)**:样式表为完整 `tailwindcss`(含 preflight)+ `tw-animate-css` 动画层 + 官方 base layer 的预编译产物,与 [shadcn 官方主题脚手架](https://ui.shadcn.com/docs/theming)一致——导入 `styles.css` 即接受 shadcn 基线全局样式(box-sizing / 边距归零 / 元素字体继承等),宿主的自定义皮肤 CSS 须在其后导入。令牌组含 chart-1..5 与 sidebar 系列;radius 派生为基于 `--radius` 的乘法比例(0.6/0.8/1/1.4/1.8/2.2/2.6)。
|
|
70
67
|
|
|
71
68
|
## 独立使用(不经 @pactor-app/app)
|
|
72
69
|
|
|
73
|
-
以 `
|
|
70
|
+
以 `createComponentRegistry()` 创建组件注册表,与 @pactor-app/runtime 直接组合:
|
|
74
71
|
|
|
75
72
|
```tsx
|
|
76
73
|
import { createPageRuntime, PageRuntimeView } from '@pactor-app/runtime';
|
|
77
|
-
import {
|
|
74
|
+
import { createComponentRegistry } from '@pactor-app/ui/components';
|
|
78
75
|
import '@pactor-app/ui/styles.css';
|
|
79
76
|
|
|
80
77
|
const runtime = createPageRuntime(pageDsl, {
|
|
81
|
-
components:
|
|
78
|
+
components: createComponentRegistry(),
|
|
82
79
|
});
|
|
83
80
|
|
|
84
81
|
await runtime.initialized;
|
|
85
82
|
<PageRuntimeView runtime={runtime} />;
|
|
86
83
|
```
|
|
87
84
|
|
|
88
|
-
布局层(`
|
|
85
|
+
布局层(`createLayoutRegistry` / `registerBuiltinLayouts`)预注册五种内置布局:admin / blank / login / landing / chat;与交互层(`InteractionProvider` / `OverlayHost`)同样可独立组合。交互核心(`OverlayManager` / `createUiBridge` / `registerInteractionActions`)由本包 `@pactor-app/ui/interaction` 导出。
|
|
89
86
|
|
|
90
87
|
## 聚合 re-export
|
|
91
88
|
|
|
92
|
-
三层的公开 API
|
|
89
|
+
三层的公开 API 均可直接从本包导入:
|
|
93
90
|
|
|
94
91
|
```ts
|
|
95
92
|
import {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
shadcnUiKit,
|
|
93
|
+
createComponentRegistry,
|
|
94
|
+
createLayoutRegistry,
|
|
95
|
+
InteractionProvider,
|
|
96
|
+
OverlayHost,
|
|
101
97
|
// ...以及三层其余全部导出
|
|
102
98
|
} from '@pactor-app/ui';
|
|
103
99
|
```
|
|
104
100
|
|
|
105
|
-
契约类型(props / layout / interaction
|
|
101
|
+
契约类型(props / layout / interaction)与交互核心均为本包自有定义。
|
|
106
102
|
|
|
107
103
|
## 文档
|
|
108
104
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Button,
|
|
3
2
|
Dialog,
|
|
4
3
|
DialogClose,
|
|
5
4
|
DialogContent,
|
|
@@ -12,10 +11,11 @@ import {
|
|
|
12
11
|
DrawerContent,
|
|
13
12
|
DrawerHeader,
|
|
14
13
|
DrawerTitle
|
|
15
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-F42SGQNW.js";
|
|
16
15
|
import {
|
|
16
|
+
Button,
|
|
17
17
|
cn
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-WKJUCGV4.js";
|
|
19
19
|
|
|
20
20
|
// src/interaction/manager.ts
|
|
21
21
|
var OVERLAY_CANCEL_PAYLOAD = { success: false };
|
|
@@ -196,7 +196,7 @@ var toastTypeClass = {
|
|
|
196
196
|
info: "border-l-4 border-l-info",
|
|
197
197
|
warning: "border-l-4 border-l-warning"
|
|
198
198
|
};
|
|
199
|
-
function
|
|
199
|
+
function InteractionProvider({
|
|
200
200
|
bridge,
|
|
201
201
|
children
|
|
202
202
|
}) {
|
|
@@ -315,7 +315,7 @@ function toCssWidth(width) {
|
|
|
315
315
|
}
|
|
316
316
|
return typeof width === "number" ? `${width}px` : width;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function OverlayHost({ manager, resolvePage }) {
|
|
319
319
|
const renderer = useRenderer();
|
|
320
320
|
const stack = useSyncExternalStore(
|
|
321
321
|
(onChange) => manager.subscribe(onChange),
|
|
@@ -474,7 +474,7 @@ function PageOverlayBody({
|
|
|
474
474
|
if (!resolvePage) {
|
|
475
475
|
setError(
|
|
476
476
|
new Error(
|
|
477
|
-
`[@pactor-app/ui] page overlay\uFF08pageId: "${entry.page?.pageId}"\uFF09\u9700\u8981
|
|
477
|
+
`[@pactor-app/ui] page overlay\uFF08pageId: "${entry.page?.pageId}"\uFF09\u9700\u8981 OverlayHost \u6CE8\u5165 resolvePage`
|
|
478
478
|
)
|
|
479
479
|
);
|
|
480
480
|
return;
|
|
@@ -525,6 +525,6 @@ export {
|
|
|
525
525
|
OverlayManager,
|
|
526
526
|
createUiBridge,
|
|
527
527
|
registerInteractionActions,
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
InteractionProvider,
|
|
529
|
+
OverlayHost
|
|
530
530
|
};
|