openxiangda 1.0.34 → 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.
Files changed (60) hide show
  1. package/README.md +18 -0
  2. package/lib/cli.js +410 -1
  3. package/lib/workspace-init.js +1 -0
  4. package/openxiangda-skills/SKILL.md +5 -3
  5. package/openxiangda-skills/references/best-practices.md +11 -6
  6. package/openxiangda-skills/references/component-guide.md +10 -11
  7. package/openxiangda-skills/references/connector-resources.md +3 -0
  8. package/openxiangda-skills/references/data-views.md +217 -0
  9. package/openxiangda-skills/references/forms/component-registry.md +4 -3
  10. package/openxiangda-skills/references/forms/form-schema.md +31 -2
  11. package/openxiangda-skills/references/pages/page-sdk.md +43 -0
  12. package/openxiangda-skills/references/style-system.md +14 -18
  13. package/openxiangda-skills/references/troubleshooting.md +13 -13
  14. package/openxiangda-skills/references/workspace-state.md +9 -0
  15. package/openxiangda-skills/skills/openxiangda-form/SKILL.md +3 -3
  16. package/openxiangda-skills/skills/openxiangda-page/SKILL.md +2 -2
  17. package/openxiangda-skills/skills/openxiangda-permission-settings/SKILL.md +1 -1
  18. package/package.json +1 -1
  19. package/packages/sdk/dist/components/index.cjs +944 -765
  20. package/packages/sdk/dist/components/index.cjs.map +1 -1
  21. package/packages/sdk/dist/components/index.d.mts +18 -2
  22. package/packages/sdk/dist/components/index.d.ts +18 -2
  23. package/packages/sdk/dist/components/index.mjs +938 -761
  24. package/packages/sdk/dist/components/index.mjs.map +1 -1
  25. package/packages/sdk/dist/runtime/index.cjs +114 -30
  26. package/packages/sdk/dist/runtime/index.cjs.map +1 -1
  27. package/packages/sdk/dist/runtime/index.d.mts +18 -1
  28. package/packages/sdk/dist/runtime/index.d.ts +18 -1
  29. package/packages/sdk/dist/runtime/index.mjs +114 -30
  30. package/packages/sdk/dist/runtime/index.mjs.map +1 -1
  31. package/packages/sdk/dist/styles/antd-theme.cjs +11 -3
  32. package/packages/sdk/dist/styles/antd-theme.cjs.map +1 -1
  33. package/packages/sdk/dist/styles/antd-theme.d.mts +2 -1
  34. package/packages/sdk/dist/styles/antd-theme.d.ts +2 -1
  35. package/packages/sdk/dist/styles/antd-theme.mjs +11 -3
  36. package/packages/sdk/dist/styles/antd-theme.mjs.map +1 -1
  37. package/packages/sdk/dist/styles/tailwind-preset.cjs +0 -1
  38. package/packages/sdk/dist/styles/tailwind-preset.cjs.map +1 -1
  39. package/packages/sdk/dist/styles/tailwind-preset.d.mts +0 -1
  40. package/packages/sdk/dist/styles/tailwind-preset.d.ts +0 -1
  41. package/packages/sdk/dist/styles/tailwind-preset.mjs +0 -1
  42. package/packages/sdk/dist/styles/tailwind-preset.mjs.map +1 -1
  43. package/packages/sdk/dist/styles/tokens.css +1 -0
  44. package/packages/sdk/src/build-source/scripts/build-forms.mjs +135 -50
  45. package/packages/sdk/src/build-source/scripts/build-pages.mjs +37 -10
  46. package/packages/sdk/src/build-source/scripts/register.mjs +2 -0
  47. package/packages/sdk/src/build-source/scripts/utils/form-api.mjs +1 -0
  48. package/packages/sdk/src/build-source/scripts/utils/load-config.mjs +3 -2
  49. package/packages/sdk/src/build-source/scripts/utils/register-payload.test.ts +2 -1
  50. package/packages/sdk/src/build-source/scripts/utils/tailwind-config.mjs +9 -7
  51. package/packages/sdk/src/build-source/scripts/utils/tailwind-config.test.ts +6 -4
  52. package/packages/sdk/src/build-source/src/cli.mjs +17 -0
  53. package/templates/sy-lowcode-app-workspace/app-workspace.config.ts +3 -3
  54. package/templates/sy-lowcode-app-workspace/examples/best-practices/decision-guide.md +4 -3
  55. package/templates/sy-lowcode-app-workspace/examples/best-practices/src/domain/role-governance/permissions.test.ts +1 -1
  56. package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/app-role/schema.ts +36 -18
  57. package/templates/sy-lowcode-app-workspace/examples/best-practices/src/forms/service-ticket/schema.ts +36 -18
  58. package/templates/sy-lowcode-app-workspace/postcss.config.cjs +0 -15
  59. package/templates/sy-lowcode-app-workspace/src/main.tsx +1 -12
  60. package/templates/sy-lowcode-app-workspace/src/shared/form-schema.ts +0 -1
@@ -1078,6 +1078,31 @@ var createPageSdk = (context) => {
1078
1078
  }
1079
1079
  })
1080
1080
  };
1081
+ const dataView = {
1082
+ query: (code, params = {}) => {
1083
+ const dataViewCode = String(code || "").trim();
1084
+ if (!dataViewCode) {
1085
+ throw new Error("\u6570\u636E\u89C6\u56FE code \u4E0D\u80FD\u4E3A\u7A7A");
1086
+ }
1087
+ return request({
1088
+ path: buildAppPath(
1089
+ context,
1090
+ params.appType,
1091
+ `/v1/data-views/${encodePathSegment(dataViewCode)}/query.json`
1092
+ ),
1093
+ method: "post",
1094
+ body: {
1095
+ fields: params.fields,
1096
+ filters: serializeSearchExpression(params.filters),
1097
+ conditionType: params.conditionType,
1098
+ searchKeyWord: params.searchKeyWord,
1099
+ currentPage: params.currentPage,
1100
+ pageSize: params.pageSize,
1101
+ order: Array.isArray(params.order) ? params.order : params.order ? [params.order] : void 0
1102
+ }
1103
+ });
1104
+ }
1105
+ };
1081
1106
  const notification = {
1082
1107
  sendByType: (params) => request({
1083
1108
  path: buildOpenXiangdaAppPath(
@@ -1141,6 +1166,7 @@ var createPageSdk = (context) => {
1141
1166
  permission,
1142
1167
  process,
1143
1168
  notification,
1169
+ dataView,
1144
1170
  dataSource: {
1145
1171
  run: async (name, params = {}) => {
1146
1172
  const descriptor = (context.page.dataSources || []).find(
@@ -1154,6 +1180,27 @@ var createPageSdk = (context) => {
1154
1180
  runtimeParams.formUuid || descriptor.formUuid || ""
1155
1181
  ).trim();
1156
1182
  switch (descriptor.type) {
1183
+ case "dataView.query": {
1184
+ const dataViewCode = String(
1185
+ runtimeParams.code || runtimeParams.dataViewCode || descriptor.code || descriptor.dataViewCode || descriptor.viewCode || descriptor.key || ""
1186
+ ).trim();
1187
+ const queryParams = {
1188
+ ...descriptor.params && typeof descriptor.params === "object" ? descriptor.params : {},
1189
+ ...runtimeParams,
1190
+ fields: runtimeParams.fields || descriptor.fields,
1191
+ filters: mergeSearchExpressions(
1192
+ descriptor.defaultFilter,
1193
+ runtimeParams.filters
1194
+ )
1195
+ };
1196
+ delete queryParams.code;
1197
+ delete queryParams.dataViewCode;
1198
+ delete queryParams.viewCode;
1199
+ return dataView.query(
1200
+ dataViewCode,
1201
+ queryParams
1202
+ );
1203
+ }
1157
1204
  case "form.list":
1158
1205
  return form.advancedSearch({
1159
1206
  ...runtimeParams,
@@ -1232,8 +1279,7 @@ var PageProvider = ({
1232
1279
  };
1233
1280
 
1234
1281
  // packages/sdk/src/styles/antd-theme.ts
1235
- var antdTheme = {
1236
- cssVar: { prefix: "sy-ant" },
1282
+ var baseTheme = {
1237
1283
  hashed: false,
1238
1284
  token: {
1239
1285
  colorPrimary: "#1677ff",
@@ -1261,6 +1307,14 @@ var antdTheme = {
1261
1307
  Card: { paddingLG: 24 }
1262
1308
  }
1263
1309
  };
1310
+ var antdTheme = {
1311
+ ...baseTheme,
1312
+ cssVar: { prefix: "ant" }
1313
+ };
1314
+ var legacyAntdTheme = {
1315
+ ...baseTheme,
1316
+ cssVar: { prefix: "sy-ant" }
1317
+ };
1264
1318
 
1265
1319
  // packages/sdk/src/runtime/react/createReactPage.tsx
1266
1320
  var import_jsx_runtime2 = require("react/jsx-runtime");
@@ -1281,6 +1335,21 @@ var MESSAGE_METHODS = [
1281
1335
  var createRuntimeRoot = (el) => {
1282
1336
  return (0, import_client2.createRoot)(el);
1283
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
+ };
1284
1353
  var isShadowRoot = (rootNode) => typeof ShadowRoot !== "undefined" && rootNode instanceof ShadowRoot;
1285
1354
  var getStyleContainer = (el) => {
1286
1355
  const rootNode = el.getRootNode?.();
@@ -1309,14 +1378,19 @@ var getRuntimeOverlayContainer = (el, portalContainer) => {
1309
1378
  getTargetContainer: () => getRuntimeRoot(el)
1310
1379
  };
1311
1380
  };
1312
- var createAntdConfig = (overlayContainer) => ({
1313
- locale: import_zh_CN.default,
1314
- prefixCls: "sy-ant",
1315
- iconPrefixCls: "sy-anticon",
1316
- theme: antdTheme,
1317
- getPopupContainer: overlayContainer.getPopupContainer,
1318
- getTargetContainer: overlayContainer.getTargetContainer
1319
- });
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
+ };
1320
1394
  var createPortalContainer = (el) => {
1321
1395
  const rootNode = el.getRootNode?.();
1322
1396
  const parent = isShadowRoot(rootNode) ? rootNode : el.ownerDocument?.body || document.body;
@@ -1366,11 +1440,12 @@ var registerAntdMessageApi = (api) => {
1366
1440
  }
1367
1441
  };
1368
1442
  };
1369
- var installRuntimePortalContainer = (el) => {
1443
+ var installRuntimePortalContainer = (el, cssIsolation) => {
1370
1444
  const globalScope = globalThis;
1371
- const portalContainer = createPortalContainer(el);
1445
+ const portalContainer = usesLegacyCssIsolation(cssIsolation) ? createPortalContainer(el) : null;
1372
1446
  const stack = Array.isArray(globalScope[PORTAL_CONTAINER_STACK_GLOBAL]) ? globalScope[PORTAL_CONTAINER_STACK_GLOBAL] : [];
1373
- stack.push(portalContainer);
1447
+ const stackTarget = portalContainer ?? el.ownerDocument?.body ?? document.body;
1448
+ stack.push(stackTarget);
1374
1449
  globalScope[PORTAL_CONTAINER_STACK_GLOBAL] = stack;
1375
1450
  globalScope[PORTAL_CONTAINER_RESOLVER_GLOBAL] = () => {
1376
1451
  for (let index = stack.length - 1; index >= 0; index -= 1) {
@@ -1384,42 +1459,43 @@ var installRuntimePortalContainer = (el) => {
1384
1459
  return {
1385
1460
  container: portalContainer,
1386
1461
  release: () => {
1387
- const position = stack.lastIndexOf(portalContainer);
1462
+ const position = stack.lastIndexOf(stackTarget);
1388
1463
  if (position >= 0) {
1389
1464
  stack.splice(position, 1);
1390
1465
  }
1391
- portalContainer.remove();
1466
+ portalContainer?.remove();
1392
1467
  }
1393
1468
  };
1394
1469
  };
1395
- var installAntdStaticHolder = (el, portalContainer) => {
1470
+ var installAntdStaticHolder = (el, portalContainer, cssIsolation) => {
1396
1471
  installAntdMessageProxy();
1472
+ const antdOptions = getAntdRuntimeOptions(cssIsolation);
1397
1473
  const getMessageContainer = () => {
1398
1474
  if (portalContainer?.isConnected) return portalContainer;
1399
- return getRuntimeRoot(el);
1475
+ return usesLegacyCssIsolation(cssIsolation) ? getRuntimeRoot(el) : document.body;
1400
1476
  };
1401
1477
  import_antd.ConfigProvider.config({
1402
- prefixCls: "sy-ant",
1403
- iconPrefixCls: "sy-anticon",
1404
- theme: antdTheme,
1478
+ prefixCls: antdOptions.prefixCls,
1479
+ iconPrefixCls: antdOptions.iconPrefixCls,
1480
+ theme: antdOptions.theme,
1405
1481
  holderRender: (children) => {
1406
1482
  if (!el.isConnected) {
1407
1483
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1408
1484
  import_antd.ConfigProvider,
1409
1485
  {
1410
- prefixCls: "sy-ant",
1411
- iconPrefixCls: "sy-anticon",
1412
- theme: antdTheme,
1486
+ prefixCls: antdOptions.prefixCls,
1487
+ iconPrefixCls: antdOptions.iconPrefixCls,
1488
+ theme: antdOptions.theme,
1413
1489
  children
1414
1490
  }
1415
1491
  );
1416
1492
  }
1417
1493
  const overlayContainer = getRuntimeOverlayContainer(el, portalContainer);
1418
- 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 }) });
1419
1495
  }
1420
1496
  });
1421
1497
  import_antd.message.config({
1422
- prefixCls: "sy-ant-message",
1498
+ prefixCls: antdOptions.messagePrefixCls,
1423
1499
  getContainer: getMessageContainer
1424
1500
  });
1425
1501
  };
@@ -1437,20 +1513,27 @@ var createReactPage = (AppComponent) => {
1437
1513
  let currentContainer = null;
1438
1514
  let releasePortalContainer = null;
1439
1515
  let portalContainer = null;
1516
+ let currentCssIsolation = null;
1440
1517
  const render = (el, context) => {
1441
- el.classList.add(NAMESPACE_ROOT_CLASS);
1442
- if (!root || currentContainer !== el || !portalContainer?.isConnected) {
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) {
1443
1525
  root?.unmount();
1444
1526
  releasePortalContainer?.();
1445
1527
  root = createRuntimeRoot(el);
1446
1528
  currentContainer = el;
1447
- const portalHandle = installRuntimePortalContainer(el);
1529
+ currentCssIsolation = cssIsolation;
1530
+ const portalHandle = installRuntimePortalContainer(el, cssIsolation);
1448
1531
  portalContainer = portalHandle.container;
1449
1532
  releasePortalContainer = portalHandle.release;
1450
1533
  }
1451
1534
  const overlayContainer = getRuntimeOverlayContainer(el, portalContainer);
1452
- installAntdStaticHolder(el, portalContainer);
1453
- const antdConfig = createAntdConfig(overlayContainer);
1535
+ installAntdStaticHolder(el, portalContainer, cssIsolation);
1536
+ const antdConfig = createAntdConfig(overlayContainer, cssIsolation);
1454
1537
  root.render(
1455
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, {}) }) }) }) }) })
1456
1539
  );
@@ -1469,6 +1552,7 @@ var createReactPage = (AppComponent) => {
1469
1552
  currentContainer = null;
1470
1553
  releasePortalContainer = null;
1471
1554
  portalContainer = null;
1555
+ currentCssIsolation = null;
1472
1556
  }
1473
1557
  };
1474
1558
  };