openxiangda 1.0.35 → 1.0.36
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 +2 -0
- package/lib/cli.js +1 -1
- package/openxiangda-skills/SKILL.md +1 -1
- package/openxiangda-skills/references/component-guide.md +10 -11
- package/openxiangda-skills/references/style-system.md +14 -18
- package/openxiangda-skills/references/troubleshooting.md +13 -13
- package/openxiangda-skills/skills/openxiangda-page/SKILL.md +2 -2
- package/package.json +1 -1
- package/packages/sdk/dist/runtime/index.cjs +67 -30
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.mjs +67 -30
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/styles/antd-theme.cjs +11 -3
- package/packages/sdk/dist/styles/antd-theme.cjs.map +1 -1
- package/packages/sdk/dist/styles/antd-theme.d.mts +2 -1
- package/packages/sdk/dist/styles/antd-theme.d.ts +2 -1
- package/packages/sdk/dist/styles/antd-theme.mjs +11 -3
- package/packages/sdk/dist/styles/antd-theme.mjs.map +1 -1
- package/packages/sdk/dist/styles/tailwind-preset.cjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.cjs.map +1 -1
- package/packages/sdk/dist/styles/tailwind-preset.d.mts +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.d.ts +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.mjs +0 -1
- package/packages/sdk/dist/styles/tailwind-preset.mjs.map +1 -1
- package/packages/sdk/dist/styles/tokens.css +1 -0
- package/packages/sdk/src/build-source/scripts/build-forms.mjs +135 -50
- package/packages/sdk/src/build-source/scripts/build-pages.mjs +37 -10
- package/packages/sdk/src/build-source/scripts/register.mjs +2 -0
- package/packages/sdk/src/build-source/scripts/utils/load-config.mjs +3 -2
- package/packages/sdk/src/build-source/scripts/utils/register-payload.test.ts +2 -1
- package/packages/sdk/src/build-source/scripts/utils/tailwind-config.mjs +9 -7
- package/packages/sdk/src/build-source/scripts/utils/tailwind-config.test.ts +6 -4
- package/packages/sdk/src/build-source/src/cli.mjs +17 -0
- package/templates/sy-lowcode-app-workspace/app-workspace.config.ts +3 -3
- package/templates/sy-lowcode-app-workspace/postcss.config.cjs +0 -15
- package/templates/sy-lowcode-app-workspace/src/main.tsx +1 -12
package/README.md
CHANGED
|
@@ -81,6 +81,8 @@ Use `openxiangda skill install --dest <skills-dir>` to target a different Codex
|
|
|
81
81
|
|
|
82
82
|
Create a new publishable app workspace with `openxiangda workspace init <dir>`. The command writes a minimal `sy-lowcode-app-workspace` template with React, Ant Design, the single `openxiangda` package, and the required `publish:all` / `openxiangda:publish` scripts. Use `--install` to run `pnpm install` immediately, or run it manually after creation.
|
|
83
83
|
|
|
84
|
+
New OpenXiangda code pages and form custom pages publish with `cssIsolation: "none"` by default, so Tailwind utilities and normal Ant Design styles apply without a `.sy-app-workspace` prefix. Explicit `namespace` and `shadow` settings are kept only for legacy compatibility.
|
|
85
|
+
|
|
84
86
|
Local workspace state is authoritative. If the current folder has no `.openxiangda/state.json` app binding, create a new app instead of searching the platform for a similar app name:
|
|
85
87
|
|
|
86
88
|
```bash
|
package/lib/cli.js
CHANGED
|
@@ -1482,7 +1482,7 @@ async function page(args) {
|
|
|
1482
1482
|
jsUrls: splitList(flags['js-urls']),
|
|
1483
1483
|
framework: flags.framework || 'react',
|
|
1484
1484
|
frameworkVersion: flags['framework-version'] || '',
|
|
1485
|
-
cssIsolation: flags['css-isolation'] || '
|
|
1485
|
+
cssIsolation: flags['css-isolation'] || 'none',
|
|
1486
1486
|
format: flags.format || 'esm',
|
|
1487
1487
|
},
|
|
1488
1488
|
menu: flags.menu
|
|
@@ -153,7 +153,7 @@ Workflow / automation / permissions:
|
|
|
153
153
|
Platform domain knowledge (read these first when generating forms or pages so the output matches the live platform behavior):
|
|
154
154
|
|
|
155
155
|
- `references/platform-data-model.md` — how the platform persists field values (JSONB, `{label, value}` for option fields, attachment shape, etc.). Use this whenever you write, render, or diagnose form data.
|
|
156
|
-
- `references/style-system.md` —
|
|
156
|
+
- `references/style-system.md` — style isolation defaults, legacy namespace compatibility, and flexible Tailwind/CSS guidance. Use this before writing substantial page or form CSS.
|
|
157
157
|
- `references/architecture-patterns.md` — CRUD data flow, `DataManagementList` pattern, recommended directory layout for `src/pages` and `src/forms`. Use this before scaffolding a new page or list view.
|
|
158
158
|
- `references/best-practices.md` — read this before implementing app-level business patterns; it points to `examples/best-practices/` and explains when to use status fields instead of workflow.
|
|
159
159
|
- `references/component-guide.md` — when to pick platform components vs. raw Ant Design vs. custom components, with the rules for option fields. Use this before introducing a new component.
|
|
@@ -102,19 +102,18 @@ export function CustomSelect({ options, className, ...rest }: CustomSelectProps)
|
|
|
102
102
|
return (
|
|
103
103
|
<Select
|
|
104
104
|
className={clsx('w-full rounded-md', className)}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{...rest}
|
|
105
|
+
getPopupContainer={(trigger) => trigger.parentElement ?? document.body}
|
|
106
|
+
options={options}
|
|
107
|
+
{...rest}
|
|
109
108
|
/>
|
|
110
109
|
);
|
|
111
110
|
}
|
|
112
111
|
```
|
|
113
112
|
|
|
114
|
-
要点:
|
|
115
|
-
- 透传 `...rest`,保留 antd 全部 API。
|
|
116
|
-
- `
|
|
117
|
-
- `
|
|
113
|
+
要点:
|
|
114
|
+
- 透传 `...rest`,保留 antd 全部 API。
|
|
115
|
+
- `getPopupContainer` 解决弹层被裁切问题(详见第 7 节常见错误)。
|
|
116
|
+
- 默认 `cssIsolation: "none"` 时不要额外给弹层加 `sy-app-workspace`;只有 legacy `namespace/shadow` 页面才需要给弹层或容器补 namespace class。
|
|
118
117
|
- 使用 `w-full`、`rounded-md`、`text-slate-600`、`border-slate-200` 等 Tailwind 原生类作为默认基线;如果组件视觉需要精调,可以继续使用 Tailwind 任意值或局部 CSS。
|
|
119
118
|
|
|
120
119
|
### 4.2 错误:从头实现选择器
|
|
@@ -171,7 +170,7 @@ function BadSelect({ options }) {
|
|
|
171
170
|
</ConfigProvider>
|
|
172
171
|
```
|
|
173
172
|
|
|
174
|
-
4. **谨慎**:直接覆盖组件内部 class(`.ant-select-selector { ... }`)属于私有 API
|
|
173
|
+
4. **谨慎**:直接覆盖组件内部 class(`.ant-select-selector { ... }`)属于私有 API,升级风险较高。确实需要时必须限定在页面根类下;legacy 页面也可以兼容限定在 `.sy-app-workspace` 下。优先考虑 `ConfigProvider`、`className`、组件 props 或 CSS 变量是否能解决。
|
|
175
174
|
|
|
176
175
|
---
|
|
177
176
|
|
|
@@ -208,7 +207,7 @@ export function ActionButton(props) {
|
|
|
208
207
|
| 用第三方富文本(TinyMCE 等) | 用 `EditorField` |
|
|
209
208
|
| 自己写列表 + 分页 + 导出 | 用 `DataManagementList` |
|
|
210
209
|
| 常规组件大量写 `style={{ color: '#333', padding: 16 }}` | 优先 Tailwind 原生工具类、任意值或局部 CSS;动态值和少量精调 inline style 可接受 |
|
|
211
|
-
| Select / Date / Modal 弹层错位、被滚动容器裁切 |
|
|
210
|
+
| Select / Date / Modal 弹层错位、被滚动容器裁切 | 默认加 `getPopupContainer={(trigger) => trigger.parentElement}`;legacy `namespace/shadow` 页面才额外使用 `sy-app-workspace` |
|
|
212
211
|
| 不分端,PC 组件直接放移动端 | 按端拆页 + 端内用对应 UI 库 |
|
|
213
212
|
| 无作用域覆盖 `.ant-xxx` 内部 class | 优先用 `className`、CSS 变量或 `ConfigProvider` 主题;必要覆盖时限定到页面命名空间 |
|
|
214
213
|
| 在自定义组件中不透传 `...rest` / `ref` | 透传 props 与 `forwardRef`,保留底层组件全部能力 |
|
|
@@ -220,5 +219,5 @@ export function ActionButton(props) {
|
|
|
220
219
|
- [ ] 涉及人员 / 部门 / 文件 / 图片 / 富文本 / 签名 / 地图 / 列表 → 用了平台组件?
|
|
221
220
|
- [ ] 自定义组件 → 基于 antd / antd-mobile 包装并透传 props?
|
|
222
221
|
- [ ] 样式 → 默认用 Tailwind 原生类 / 任意值 / 局部 CSS;平台 token 只在主题兼容或平台组件需要时使用,且作用域收敛?
|
|
223
|
-
- [ ] 弹层 →
|
|
222
|
+
- [ ] 弹层 → 默认使用正常容器;只有 legacy 隔离页面才额外设置 `sy-app-workspace` 样式作用域?
|
|
224
223
|
- [ ] 多端 → PC 用 antd、Mobile 用 antd-mobile,业务逻辑共享?
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
1. **业务页面默认写原生 Tailwind**:优先使用 `bg-white`、`border`、`border-slate-200`、`text-slate-600`、`shadow-sm`、`rounded-lg`、`p-4`、`gap-4`、`grid-cols-[240px_1fr]` 这类 Tailwind 原生类和任意值。
|
|
10
10
|
2. **不要强制平台 token**:不要把 `bg-container`、`text-secondary`、`rounded-form`、`shadow-card` 当默认示例或默认范式。历史项目或平台组件需要时可以兼容使用,但新业务页面不推荐主动依赖。
|
|
11
11
|
3. **不要直接套 shadcn token**:`bg-card`、`text-muted-foreground`、`text-foreground`、`bg-background` 等不是 Tailwind 原生类。除非项目已经在 `tailwind.config.cjs` 明确配置这些 token,否则必须改成 Tailwind 原生类或任意值。
|
|
12
|
-
4.
|
|
13
|
-
5. **
|
|
12
|
+
4. **默认不启用样式隔离**:新发布页面默认 `cssIsolation: "none"`,Tailwind 类按原样输出,不需要 `.sy-app-workspace` 前缀即可生效。
|
|
13
|
+
5. **legacy 隔离仅用于兼容**:历史页面或显式配置 `cssIsolation: "namespace" | "shadow"` 时,runtime 仍会保留 `.sy-app-workspace`、legacy portal 和旧样式前缀。
|
|
14
|
+
6. **CSS 作用域要收敛**:页面级 CSS 写在 `styles.css`,选择器优先限定在页面根类下,避免无意覆盖宿主平台或其他页面。
|
|
14
15
|
|
|
15
16
|
---
|
|
16
17
|
|
|
@@ -60,12 +61,12 @@ export function DashboardPage() {
|
|
|
60
61
|
### 2.4 局部 CSS
|
|
61
62
|
|
|
62
63
|
```css
|
|
63
|
-
.
|
|
64
|
+
.queue-booking-page {
|
|
64
65
|
min-height: 100%;
|
|
65
66
|
background: #f8fafc;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
.
|
|
69
|
+
.queue-booking-page .queue-booking-page__calendar-grid {
|
|
69
70
|
display: grid;
|
|
70
71
|
grid-template-columns: repeat(7, minmax(120px, 1fr));
|
|
71
72
|
gap: 12px;
|
|
@@ -113,11 +114,11 @@ module.exports = {
|
|
|
113
114
|
|
|
114
115
|
这个配置的作用:
|
|
115
116
|
|
|
116
|
-
- `openxiangdaPreset`
|
|
117
|
+
- `openxiangdaPreset` 保留平台组件 safelist、平台 token 兼容类和平台组件需要的工具类;不再强制 Tailwind 输出 `.sy-app-workspace` 前缀。
|
|
117
118
|
- `...openxiangdaContent` 确保平台组件内部 class 会被 Tailwind 扫描到。
|
|
118
119
|
- `blocklist` 避免 Tailwind 误生成日期字符串相关的异常类。
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
不要移除这些平台构建能力;自由写 Tailwind 原生类和保留平台组件兼容能力并不冲突。
|
|
121
122
|
|
|
122
123
|
---
|
|
123
124
|
|
|
@@ -160,21 +161,15 @@ body {
|
|
|
160
161
|
|
|
161
162
|
## 5. Ant Design 和弹层
|
|
162
163
|
|
|
163
|
-
PC 控件优先用 `antd`,移动端控件优先用 `antd-mobile
|
|
164
|
+
PC 控件优先用 `antd`,移动端控件优先用 `antd-mobile`。默认 `cssIsolation: "none"` 时使用 Ant Design 默认 `ant` class 和 `document.body` 弹层容器即可;只有 legacy `namespace/shadow` 页面才需要显式挂到当前隔离容器:
|
|
164
165
|
|
|
165
166
|
```tsx
|
|
166
|
-
<ConfigProvider
|
|
167
|
-
getPopupContainer={(trigger) =>
|
|
168
|
-
trigger?.closest('.sy-app-workspace') ??
|
|
169
|
-
(document.querySelector('.sy-app-workspace') as HTMLElement) ??
|
|
170
|
-
document.body
|
|
171
|
-
}
|
|
172
|
-
>
|
|
167
|
+
<ConfigProvider>
|
|
173
168
|
<App />
|
|
174
169
|
</ConfigProvider>
|
|
175
170
|
```
|
|
176
171
|
|
|
177
|
-
|
|
172
|
+
legacy 页面可使用 `getPopupContainer={(trigger) => trigger?.closest(".sy-app-workspace") ?? document.body}`。不要无作用域覆盖 `.ant-select-selector`、`.ant-modal` 等私有 class;确实需要覆盖时限定在页面根类下。
|
|
178
173
|
|
|
179
174
|
---
|
|
180
175
|
|
|
@@ -188,9 +183,10 @@ OpenXiangda 仍保留部分平台语义类和 CSS 变量,主要用于:
|
|
|
188
183
|
|
|
189
184
|
常见兼容类包括 `text-primary`、`text-secondary`、`bg-container`、`bg-layout`、`border-secondary`、`rounded-form`、`shadow-card` 等。AI 编写新业务页面时不要默认使用这些类;除非用户明确要求跟随平台变量主题,或当前项目已有一致的 token 体系。
|
|
190
185
|
|
|
191
|
-
|
|
186
|
+
如果需要统一主题,推荐把主题限制在应用根类下;兼容旧页面时也可以同时声明 `.sy-app-workspace`:
|
|
192
187
|
|
|
193
188
|
```css
|
|
189
|
+
.theme-brand,
|
|
194
190
|
.sy-app-workspace.theme-brand {
|
|
195
191
|
--sy-color-primary: #0f766e;
|
|
196
192
|
--sy-radius-md: 8px;
|
|
@@ -218,5 +214,5 @@ warning 不会阻断构建,但它通常意味着页面会出现“颜色、边
|
|
|
218
214
|
- [ ] 页面样式默认使用 Tailwind 原生类和任意值,而不是平台 token 类?
|
|
219
215
|
- [ ] 没有使用未配置的 shadcn token 类,例如 `bg-card`、`text-muted-foreground`、`text-foreground`?
|
|
220
216
|
- [ ] `tailwind.config.cjs` 保留 OpenXiangda preset、content 扫描和 blocklist?
|
|
221
|
-
- [ ] 业务 CSS
|
|
222
|
-
- [ ]
|
|
217
|
+
- [ ] 业务 CSS 限定在页面根类下,而不是全局裸覆盖?
|
|
218
|
+
- [ ] 只有 legacy `namespace/shadow` 页面才额外配置 `.sy-app-workspace` 弹层容器?
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
|
|
24
24
|
**症状**:Select / Dropdown / Popup / Modal 等组件的弹出层没有样式,直接跑到屏幕外,或呈现为无样式的裸 HTML。
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
**解决方案**:
|
|
29
|
-
1.
|
|
30
|
-
2.
|
|
31
|
-
3.
|
|
32
|
-
4.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```tsx
|
|
36
|
-
import { useRef } from 'react';
|
|
37
|
-
import { ConfigProvider } from 'antd';
|
|
26
|
+
**根因**:新页面默认 `cssIsolation: "none"`,弹层使用 `document.body` 和默认 Ant Design 样式即可。只有历史页面显式启用 `cssIsolation: "namespace" | "shadow"` 时,弹层渲染到 `document.body` 才可能脱离 legacy 样式作用域;移动端 Popup 也可能因 namespace 未被继承而失去样式。
|
|
27
|
+
|
|
28
|
+
**解决方案**:
|
|
29
|
+
1. 新页面优先保持 `cssIsolation: "none"`,不要为了修弹层问题手动加 `.sy-app-workspace`。
|
|
30
|
+
2. legacy `shadow` 页面优先迁移为 `none`;无法迁移时可使用 `namespace` 兼容模式。
|
|
31
|
+
3. legacy 页面为 antd `ConfigProvider` 配置 `getPopupContainer` 指向页面根容器。
|
|
32
|
+
4. 对于 legacy antd-mobile 页面,确保 `Popup` / `Modal` 的 `getContainer` 指向正确容器,并按需补 namespace class。
|
|
33
|
+
|
|
34
|
+
**legacy 示例**:
|
|
35
|
+
```tsx
|
|
36
|
+
import { useRef } from 'react';
|
|
37
|
+
import { ConfigProvider } from 'antd';
|
|
38
38
|
|
|
39
39
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
40
40
|
|
|
@@ -188,7 +188,7 @@ export default defineConfig({
|
|
|
188
188
|
**解决方案**:
|
|
189
189
|
1. 在 `vite.config.ts` 的 `optimizeDeps.include` 中显式添加 `antd-mobile`,避免运行时多次预构建。
|
|
190
190
|
2. 调整 Tailwind preflight 策略,确保不会覆盖 antd-mobile 的基础样式(必要时关闭 preflight 或使用 `important` 选择器)。
|
|
191
|
-
3.
|
|
191
|
+
3. 仅 legacy `namespace/shadow` 页面需要确保 antd-mobile 组件渲染在 `sy-app-workspace` namespace 容器内,弹层 `getContainer` 指向该容器;新页面默认不需要。
|
|
192
192
|
|
|
193
193
|
**示例**:
|
|
194
194
|
```typescript
|
|
@@ -60,7 +60,7 @@ Read these references only when editing page code:
|
|
|
60
60
|
- `../../references/pages/page-sdk.md`
|
|
61
61
|
- `../../references/notifications.md` — notification resources and `sdk.notification` usage. Read before adding reminders, alerts, or message templates to a page.
|
|
62
62
|
- `../../references/pages/publish-flow.md`
|
|
63
|
-
- `../../references/style-system.md` —
|
|
63
|
+
- `../../references/style-system.md` — style isolation defaults, Tailwind/CSS guidance, and legacy namespace compatibility. Read before writing substantial page CSS or Tailwind classes.
|
|
64
64
|
- `../../references/architecture-patterns.md` — CRUD data flow, `DataManagementList` pattern, and recommended `src/pages/<pageCode>/` layout. Read before scaffolding a new page or list view.
|
|
65
65
|
- `../../references/component-guide.md` — when to pick platform components, raw Ant Design, or custom components. Read before introducing a new component.
|
|
66
66
|
- `../../references/troubleshooting.md` — known failure modes (missing styles, `options` runtime errors, broken option rendering, etc.) and their fixes. Read when something does not behave as expected.
|
|
@@ -83,7 +83,7 @@ Read these references only when editing page code:
|
|
|
83
83
|
- Do not scatter hardcoded `/view/...&isRenderNav=false` URLs through page code. Use the runtime navigation API or the local route helper generated for the app shell.
|
|
84
84
|
- Platform menus should bind only the formal app-shell code page for user-facing entry points. Original forms, workflows, and native view pages may remain as development / maintenance resources or permission targets, but should not become the product navigation shell.
|
|
85
85
|
- For prod, explicitly run with `--profile prod`; never rely on the current profile for release operations.
|
|
86
|
-
- Follow the style system in `../../references/style-system.md`: default to native Tailwind utilities and arbitrary values for business pages (`bg-white`, `border`, `border-slate-200`, `text-slate-600`, `grid-cols-[240px_1fr]`, etc.).
|
|
86
|
+
- Follow the style system in `../../references/style-system.md`: default to native Tailwind utilities and arbitrary values for business pages (`bg-white`, `border`, `border-slate-200`, `text-slate-600`, `grid-cols-[240px_1fr]`, etc.). New pages default to `cssIsolation: "none"` and do not need `.sy-app-workspace`; keep namespace/shadow handling only for legacy pages that explicitly configure it. Do not treat platform token classes as the default authoring pattern, and do not use shadcn token classes such as `bg-card`, `text-muted-foreground`, or `text-foreground` unless the workspace explicitly configures them.
|
|
87
87
|
- For list / detail / CRUD pages, follow `../../references/architecture-patterns.md` (e.g. `DataManagementList`) before writing custom data-fetching loops.
|
|
88
88
|
- Query pages must use pagination with structured conditions. Do not fetch a large `pageSize` and filter in the browser; avoid default `searchKeyWord`, and build multi-field fuzzy search with explicit `filterGroup` + `OR`.
|
|
89
89
|
- Pick components per `../../references/component-guide.md`: prefer the platform component, fall back to Ant Design, and only build a custom component when neither fits.
|
package/package.json
CHANGED
|
@@ -1279,8 +1279,7 @@ var PageProvider = ({
|
|
|
1279
1279
|
};
|
|
1280
1280
|
|
|
1281
1281
|
// packages/sdk/src/styles/antd-theme.ts
|
|
1282
|
-
var
|
|
1283
|
-
cssVar: { prefix: "sy-ant" },
|
|
1282
|
+
var baseTheme = {
|
|
1284
1283
|
hashed: false,
|
|
1285
1284
|
token: {
|
|
1286
1285
|
colorPrimary: "#1677ff",
|
|
@@ -1308,6 +1307,14 @@ var antdTheme = {
|
|
|
1308
1307
|
Card: { paddingLG: 24 }
|
|
1309
1308
|
}
|
|
1310
1309
|
};
|
|
1310
|
+
var antdTheme = {
|
|
1311
|
+
...baseTheme,
|
|
1312
|
+
cssVar: { prefix: "ant" }
|
|
1313
|
+
};
|
|
1314
|
+
var legacyAntdTheme = {
|
|
1315
|
+
...baseTheme,
|
|
1316
|
+
cssVar: { prefix: "sy-ant" }
|
|
1317
|
+
};
|
|
1311
1318
|
|
|
1312
1319
|
// packages/sdk/src/runtime/react/createReactPage.tsx
|
|
1313
1320
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -1328,6 +1335,21 @@ var MESSAGE_METHODS = [
|
|
|
1328
1335
|
var createRuntimeRoot = (el) => {
|
|
1329
1336
|
return (0, import_client2.createRoot)(el);
|
|
1330
1337
|
};
|
|
1338
|
+
var normalizeCssIsolation = (value) => {
|
|
1339
|
+
if (value === "namespace" || value === "shadow") return value;
|
|
1340
|
+
return "none";
|
|
1341
|
+
};
|
|
1342
|
+
var usesLegacyCssIsolation = (cssIsolation) => cssIsolation === "namespace" || cssIsolation === "shadow";
|
|
1343
|
+
var getRuntimeCssIsolation = (context) => normalizeCssIsolation(context.page?.capabilities?.cssIsolation);
|
|
1344
|
+
var getAntdRuntimeOptions = (cssIsolation) => {
|
|
1345
|
+
const legacy = usesLegacyCssIsolation(cssIsolation);
|
|
1346
|
+
return {
|
|
1347
|
+
prefixCls: legacy ? "sy-ant" : "ant",
|
|
1348
|
+
iconPrefixCls: legacy ? "sy-anticon" : "anticon",
|
|
1349
|
+
messagePrefixCls: legacy ? "sy-ant-message" : "ant-message",
|
|
1350
|
+
theme: legacy ? legacyAntdTheme : antdTheme
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1331
1353
|
var isShadowRoot = (rootNode) => typeof ShadowRoot !== "undefined" && rootNode instanceof ShadowRoot;
|
|
1332
1354
|
var getStyleContainer = (el) => {
|
|
1333
1355
|
const rootNode = el.getRootNode?.();
|
|
@@ -1356,14 +1378,19 @@ var getRuntimeOverlayContainer = (el, portalContainer) => {
|
|
|
1356
1378
|
getTargetContainer: () => getRuntimeRoot(el)
|
|
1357
1379
|
};
|
|
1358
1380
|
};
|
|
1359
|
-
var createAntdConfig = (overlayContainer) =>
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1381
|
+
var createAntdConfig = (overlayContainer, cssIsolation) => {
|
|
1382
|
+
const antdOptions = getAntdRuntimeOptions(cssIsolation);
|
|
1383
|
+
return {
|
|
1384
|
+
locale: import_zh_CN.default,
|
|
1385
|
+
prefixCls: antdOptions.prefixCls,
|
|
1386
|
+
iconPrefixCls: antdOptions.iconPrefixCls,
|
|
1387
|
+
theme: antdOptions.theme,
|
|
1388
|
+
...usesLegacyCssIsolation(cssIsolation) ? {
|
|
1389
|
+
getPopupContainer: overlayContainer.getPopupContainer,
|
|
1390
|
+
getTargetContainer: overlayContainer.getTargetContainer
|
|
1391
|
+
} : {}
|
|
1392
|
+
};
|
|
1393
|
+
};
|
|
1367
1394
|
var createPortalContainer = (el) => {
|
|
1368
1395
|
const rootNode = el.getRootNode?.();
|
|
1369
1396
|
const parent = isShadowRoot(rootNode) ? rootNode : el.ownerDocument?.body || document.body;
|
|
@@ -1413,11 +1440,12 @@ var registerAntdMessageApi = (api) => {
|
|
|
1413
1440
|
}
|
|
1414
1441
|
};
|
|
1415
1442
|
};
|
|
1416
|
-
var installRuntimePortalContainer = (el) => {
|
|
1443
|
+
var installRuntimePortalContainer = (el, cssIsolation) => {
|
|
1417
1444
|
const globalScope = globalThis;
|
|
1418
|
-
const portalContainer = createPortalContainer(el);
|
|
1445
|
+
const portalContainer = usesLegacyCssIsolation(cssIsolation) ? createPortalContainer(el) : null;
|
|
1419
1446
|
const stack = Array.isArray(globalScope[PORTAL_CONTAINER_STACK_GLOBAL]) ? globalScope[PORTAL_CONTAINER_STACK_GLOBAL] : [];
|
|
1420
|
-
|
|
1447
|
+
const stackTarget = portalContainer ?? el.ownerDocument?.body ?? document.body;
|
|
1448
|
+
stack.push(stackTarget);
|
|
1421
1449
|
globalScope[PORTAL_CONTAINER_STACK_GLOBAL] = stack;
|
|
1422
1450
|
globalScope[PORTAL_CONTAINER_RESOLVER_GLOBAL] = () => {
|
|
1423
1451
|
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
@@ -1431,42 +1459,43 @@ var installRuntimePortalContainer = (el) => {
|
|
|
1431
1459
|
return {
|
|
1432
1460
|
container: portalContainer,
|
|
1433
1461
|
release: () => {
|
|
1434
|
-
const position = stack.lastIndexOf(
|
|
1462
|
+
const position = stack.lastIndexOf(stackTarget);
|
|
1435
1463
|
if (position >= 0) {
|
|
1436
1464
|
stack.splice(position, 1);
|
|
1437
1465
|
}
|
|
1438
|
-
portalContainer
|
|
1466
|
+
portalContainer?.remove();
|
|
1439
1467
|
}
|
|
1440
1468
|
};
|
|
1441
1469
|
};
|
|
1442
|
-
var installAntdStaticHolder = (el, portalContainer) => {
|
|
1470
|
+
var installAntdStaticHolder = (el, portalContainer, cssIsolation) => {
|
|
1443
1471
|
installAntdMessageProxy();
|
|
1472
|
+
const antdOptions = getAntdRuntimeOptions(cssIsolation);
|
|
1444
1473
|
const getMessageContainer = () => {
|
|
1445
1474
|
if (portalContainer?.isConnected) return portalContainer;
|
|
1446
|
-
return getRuntimeRoot(el);
|
|
1475
|
+
return usesLegacyCssIsolation(cssIsolation) ? getRuntimeRoot(el) : document.body;
|
|
1447
1476
|
};
|
|
1448
1477
|
import_antd.ConfigProvider.config({
|
|
1449
|
-
prefixCls:
|
|
1450
|
-
iconPrefixCls:
|
|
1451
|
-
theme:
|
|
1478
|
+
prefixCls: antdOptions.prefixCls,
|
|
1479
|
+
iconPrefixCls: antdOptions.iconPrefixCls,
|
|
1480
|
+
theme: antdOptions.theme,
|
|
1452
1481
|
holderRender: (children) => {
|
|
1453
1482
|
if (!el.isConnected) {
|
|
1454
1483
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1455
1484
|
import_antd.ConfigProvider,
|
|
1456
1485
|
{
|
|
1457
|
-
prefixCls:
|
|
1458
|
-
iconPrefixCls:
|
|
1459
|
-
theme:
|
|
1486
|
+
prefixCls: antdOptions.prefixCls,
|
|
1487
|
+
iconPrefixCls: antdOptions.iconPrefixCls,
|
|
1488
|
+
theme: antdOptions.theme,
|
|
1460
1489
|
children
|
|
1461
1490
|
}
|
|
1462
1491
|
);
|
|
1463
1492
|
}
|
|
1464
1493
|
const overlayContainer = getRuntimeOverlayContainer(el, portalContainer);
|
|
1465
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_cssinjs.StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.ConfigProvider, { ...createAntdConfig(overlayContainer), children }) });
|
|
1494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_cssinjs.StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.ConfigProvider, { ...createAntdConfig(overlayContainer, cssIsolation), children }) });
|
|
1466
1495
|
}
|
|
1467
1496
|
});
|
|
1468
1497
|
import_antd.message.config({
|
|
1469
|
-
prefixCls:
|
|
1498
|
+
prefixCls: antdOptions.messagePrefixCls,
|
|
1470
1499
|
getContainer: getMessageContainer
|
|
1471
1500
|
});
|
|
1472
1501
|
};
|
|
@@ -1484,20 +1513,27 @@ var createReactPage = (AppComponent) => {
|
|
|
1484
1513
|
let currentContainer = null;
|
|
1485
1514
|
let releasePortalContainer = null;
|
|
1486
1515
|
let portalContainer = null;
|
|
1516
|
+
let currentCssIsolation = null;
|
|
1487
1517
|
const render = (el, context) => {
|
|
1488
|
-
|
|
1489
|
-
if (
|
|
1518
|
+
const cssIsolation = getRuntimeCssIsolation(context);
|
|
1519
|
+
if (usesLegacyCssIsolation(cssIsolation)) {
|
|
1520
|
+
el.classList.add(NAMESPACE_ROOT_CLASS);
|
|
1521
|
+
} else {
|
|
1522
|
+
el.classList.remove(NAMESPACE_ROOT_CLASS);
|
|
1523
|
+
}
|
|
1524
|
+
if (!root || currentContainer !== el || currentCssIsolation !== cssIsolation || usesLegacyCssIsolation(cssIsolation) && !portalContainer?.isConnected) {
|
|
1490
1525
|
root?.unmount();
|
|
1491
1526
|
releasePortalContainer?.();
|
|
1492
1527
|
root = createRuntimeRoot(el);
|
|
1493
1528
|
currentContainer = el;
|
|
1494
|
-
|
|
1529
|
+
currentCssIsolation = cssIsolation;
|
|
1530
|
+
const portalHandle = installRuntimePortalContainer(el, cssIsolation);
|
|
1495
1531
|
portalContainer = portalHandle.container;
|
|
1496
1532
|
releasePortalContainer = portalHandle.release;
|
|
1497
1533
|
}
|
|
1498
1534
|
const overlayContainer = getRuntimeOverlayContainer(el, portalContainer);
|
|
1499
|
-
installAntdStaticHolder(el, portalContainer);
|
|
1500
|
-
const antdConfig = createAntdConfig(overlayContainer);
|
|
1535
|
+
installAntdStaticHolder(el, portalContainer, cssIsolation);
|
|
1536
|
+
const antdConfig = createAntdConfig(overlayContainer, cssIsolation);
|
|
1501
1537
|
root.render(
|
|
1502
1538
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_cssinjs.StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.ConfigProvider, { ...antdConfig, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.App, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RuntimeMessageBridge, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PageProvider, { context, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AppComponent, {}) }) }) }) }) })
|
|
1503
1539
|
);
|
|
@@ -1516,6 +1552,7 @@ var createReactPage = (AppComponent) => {
|
|
|
1516
1552
|
currentContainer = null;
|
|
1517
1553
|
releasePortalContainer = null;
|
|
1518
1554
|
portalContainer = null;
|
|
1555
|
+
currentCssIsolation = null;
|
|
1519
1556
|
}
|
|
1520
1557
|
};
|
|
1521
1558
|
};
|