@schemx/vue 1.0.0-next.4 → 1.0.0-next.6

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 (38) hide show
  1. package/README.md +42 -38
  2. package/dist/analyze.html +1 -1
  3. package/dist/components/Col/index.d.ts +31 -0
  4. package/dist/components/Col/index.d.ts.map +1 -0
  5. package/dist/components/ConfigProvider/index.d.ts +13 -3
  6. package/dist/components/ConfigProvider/index.d.ts.map +1 -1
  7. package/dist/components/Dynamic/index.d.ts +17 -1
  8. package/dist/components/Dynamic/index.d.ts.map +1 -1
  9. package/dist/components/Group/index.d.ts +16 -1
  10. package/dist/components/Group/index.d.ts.map +1 -1
  11. package/dist/components/SchemaList/index.d.ts +58 -0
  12. package/dist/components/SchemaList/index.d.ts.map +1 -0
  13. package/dist/components/Wrapper/index.vue.d.ts +29 -0
  14. package/dist/components/Wrapper/index.vue.d.ts.map +1 -0
  15. package/dist/config/appConfig.d.ts +3 -3
  16. package/dist/config/appConfig.d.ts.map +1 -1
  17. package/dist/config/index.d.ts +1 -1
  18. package/dist/config/index.d.ts.map +1 -1
  19. package/dist/config/providerConfig.d.ts +10 -3
  20. package/dist/config/providerConfig.d.ts.map +1 -1
  21. package/dist/form.d.ts +2 -2
  22. package/dist/form.d.ts.map +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.ts +4 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.mjs +324 -78
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/style.css +1 -1
  30. package/dist/types/form.d.ts +3 -2
  31. package/dist/types/form.d.ts.map +1 -1
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/types/layout.d.ts +26 -0
  35. package/dist/types/layout.d.ts.map +1 -0
  36. package/dist/utils/colProvider.d.ts +20 -0
  37. package/dist/utils/colProvider.d.ts.map +1 -0
  38. package/package.json +5 -6
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export { default as schemxForm } from './form';
4
4
  export type { SchemxInstallOptions } from './form';
5
5
  /** 全局渲染器注册实例 */
6
6
  export { rendererRegistry } from './utils/rendererProvider';
7
+ /** 全局 Col 组件注册函数 */
8
+ export { registerCol } from './utils/colProvider';
7
9
  /** 全局预设规则注册实例 */
8
10
  export { presetRuleRegistry } from './utils/presetRuleProvider';
9
11
  /** Hooks */
@@ -13,6 +15,8 @@ export { WithRemoteOptions } from './hocs';
13
15
  /** 组件 */
14
16
  export { default as Field } from './components/Field';
15
17
  export { default as Group } from './components/Group';
18
+ export { default as Col } from './components/Col';
19
+ export { default as Wrapper } from './components/Wrapper/index.vue';
16
20
  export { default as ConfigProvider, type ConfigProviderProps, } from './components/ConfigProvider';
17
21
  /** schemx/core 导出 */
18
22
  export * from '@schemx/core';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,oBAAoB,CAAA;AAE3B,WAAW;AACX,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAC9C,YAAY,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAElD,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,iBAAiB;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,YAAY;AACZ,cAAc,SAAS,CAAA;AAEvB,WAAW;AACX,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAE1C,SAAS;AACT,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAA;AAEpC,qBAAqB;AACrB,cAAc,cAAc,CAAA;AAE5B,YAAY;AACZ,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,oBAAoB,CAAA;AAE3B,WAAW;AACX,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAC9C,YAAY,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAElD,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,oBAAoB;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,iBAAiB;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,YAAY;AACZ,cAAc,SAAS,CAAA;AAEvB,WAAW;AACX,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAE1C,SAAS;AACT,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAA;AAEpC,qBAAqB;AACrB,cAAc,cAAc,CAAA;AAE5B,YAAY;AACZ,cAAc,SAAS,CAAA"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./style.css";
2
- import { shallowRef, computed, getCurrentInstance, inject, provide, onScopeDispose, onUnmounted, ref, onMounted, watchEffect, watch, readonly, createVNode, h, createTextVNode, defineComponent, mergeProps, useAttrs, openBlock, createElementBlock, unref, renderSlot, createCommentVNode, createStaticVNode, Fragment, toDisplayString, useSlots, reactive, toRaw, normalizeClass, normalizeStyle, renderList, createBlock, createSlots, withCtx, nextTick } from "vue";
3
- import { isViewGroupSchema, isViewDynamicSchema, mergeSchemxConfig, createPresetRuleRegistry, createForm, createField, createWatch, isSchemxViewFieldSchema, isSchemxSchemas, defaultSchemxConfigKeys } from "@schemx/core";
2
+ import { shallowRef, computed, getCurrentInstance, inject, provide, onScopeDispose, onUnmounted, ref, onMounted, watchEffect, watch, readonly, createVNode, h, createTextVNode, defineComponent, mergeProps, useAttrs, openBlock, createElementBlock, unref, renderSlot, createCommentVNode, createStaticVNode, Fragment, toDisplayString, markRaw, toRaw, isVNode, useSlots, reactive, normalizeClass, normalizeStyle, createSlots, renderList, withCtx, normalizeProps, guardReactiveProps, createBlock, nextTick } from "vue";
3
+ import { isViewGroupSchema, isViewDynamicSchema, mergeSchemxConfig, createPresetRuleRegistry, createForm, createField, createWatch, isSchemxViewFieldSchema, getGlobalSchemxConfig, mergeAndResolveSchemxConfig, isSchemxSchemas, defaultSchemxConfigKeys } from "@schemx/core";
4
4
  export * from "@schemx/core";
5
5
  import classnames from "classnames";
6
6
  import { createFormStateAdapter, createRendererRegistry } from "@schemx/core/adapter";
@@ -349,7 +349,8 @@ function normalizeSchemxAppConfig(config) {
349
349
  validatorAdapters,
350
350
  defaultRendererType: config.defaultRendererType,
351
351
  rendererRegistry: config.rendererRegistry,
352
- presetRuleRegistry: config.presetRuleRegistry
352
+ presetRuleRegistry: config.presetRuleRegistry,
353
+ colComponent: config.colComponent
353
354
  });
354
355
  }
355
356
  function normalizeRendererProps(source) {
@@ -376,17 +377,24 @@ const SCHEMX_CONFIG_PROVIDER_KEY = Symbol(
376
377
  );
377
378
  function provideSchemxConfigProvider(config) {
378
379
  const parentConfig = inject(SCHEMX_CONFIG_PROVIDER_KEY, void 0);
379
- const mergedConfig = computed(
380
- () => mergeSchemxConfig(config.value, (parentConfig == null ? void 0 : parentConfig.value) ?? {})
381
- );
380
+ const mergedConfig = computed(() => {
381
+ const mergedCoreConfig = mergeSchemxConfig(config.value, (parentConfig == null ? void 0 : parentConfig.value) ?? {});
382
+ return {
383
+ ...mergedCoreConfig,
384
+ colComponent: config.value.colComponent ?? (parentConfig == null ? void 0 : parentConfig.value.colComponent)
385
+ };
386
+ });
382
387
  provide(SCHEMX_CONFIG_PROVIDER_KEY, mergedConfig);
383
388
  }
384
389
  function getSchemxConfigProvider() {
385
390
  var _a;
391
+ return (_a = getSchemxConfigProviderRef()) == null ? void 0 : _a.value;
392
+ }
393
+ function getSchemxConfigProviderRef() {
386
394
  if (getCurrentInstance() === null) {
387
395
  return void 0;
388
396
  }
389
- return (_a = inject(SCHEMX_CONFIG_PROVIDER_KEY, void 0)) == null ? void 0 : _a.value;
397
+ return inject(SCHEMX_CONFIG_PROVIDER_KEY, void 0);
390
398
  }
391
399
  const presetRuleRegistry = createPresetRuleRegistry();
392
400
  const rendererRegistry = createRendererRegistry("input");
@@ -1095,7 +1103,7 @@ const _hoisted_4 = {
1095
1103
  key: 4,
1096
1104
  class: "schemx-button__suffix"
1097
1105
  };
1098
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1106
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1099
1107
  ...{ name: "SchemxButton", inheritAttrs: false },
1100
1108
  __name: "index",
1101
1109
  props: {
@@ -1132,6 +1140,58 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1132
1140
  };
1133
1141
  }
1134
1142
  });
1143
+ const registeredColComponent = shallowRef();
1144
+ function registerCol(component) {
1145
+ registeredColComponent.value = component;
1146
+ }
1147
+ const Col = /* @__PURE__ */ defineComponent({
1148
+ name: "SchemxCol",
1149
+ inheritAttrs: false,
1150
+ props: {
1151
+ layout: {
1152
+ type: Object,
1153
+ required: false,
1154
+ default: void 0
1155
+ },
1156
+ component: {
1157
+ type: [Object, Function],
1158
+ required: false,
1159
+ default: void 0
1160
+ }
1161
+ },
1162
+ setup(props, {
1163
+ attrs,
1164
+ slots
1165
+ }) {
1166
+ const resolvedComponent = computed(() => {
1167
+ const component = props.component ?? registeredColComponent.value;
1168
+ return component ? markRaw(toRaw(component)) : void 0;
1169
+ });
1170
+ return () => {
1171
+ var _a;
1172
+ const component = resolvedComponent.value;
1173
+ if (!component) {
1174
+ return ((_a = slots.default) == null ? void 0 : _a.call(slots)) ?? null;
1175
+ }
1176
+ const layout = props.layout ?? {};
1177
+ const span = layout.block ? 24 : layout.span ?? 24;
1178
+ const offset = layout.block ? 0 : layout.offset ?? 0;
1179
+ const {
1180
+ class: attrsClass,
1181
+ style: attrsStyle,
1182
+ ...restAttrs
1183
+ } = attrs;
1184
+ return h(component, {
1185
+ ...restAttrs,
1186
+ class: ["schemx-col", attrsClass],
1187
+ style: attrsStyle,
1188
+ span,
1189
+ offset
1190
+ }, slots);
1191
+ };
1192
+ }
1193
+ });
1194
+ const Col$1 = Col;
1135
1195
  function createGroupSlotRenderers(options) {
1136
1196
  const {
1137
1197
  schema,
@@ -1200,6 +1260,11 @@ const Group = /* @__PURE__ */ defineComponent({
1200
1260
  type: [String, Object, Array],
1201
1261
  required: false,
1202
1262
  default: void 0
1263
+ },
1264
+ renderChildren: {
1265
+ type: Function,
1266
+ required: false,
1267
+ default: void 0
1203
1268
  }
1204
1269
  },
1205
1270
  setup(props, {
@@ -1273,7 +1338,7 @@ const Group = /* @__PURE__ */ defineComponent({
1273
1338
  readonly: Boolean(schema.readonly),
1274
1339
  toggle,
1275
1340
  slots,
1276
- renderChildren: () => schema.children.map(renderChild)
1341
+ renderChildren: () => props.renderChildren ? props.renderChildren(schema.children) : schema.children.map(renderChild)
1277
1342
  });
1278
1343
  const body = createVNode("div", {
1279
1344
  "id": bodyId,
@@ -1329,6 +1394,11 @@ const Dynamic = /* @__PURE__ */ defineComponent({
1329
1394
  viewSchemas: {
1330
1395
  type: Array,
1331
1396
  required: true
1397
+ },
1398
+ renderChildren: {
1399
+ type: Function,
1400
+ required: false,
1401
+ default: void 0
1332
1402
  }
1333
1403
  },
1334
1404
  /**
@@ -1369,18 +1439,113 @@ const Dynamic = /* @__PURE__ */ defineComponent({
1369
1439
  if (props.schema.visible === false) {
1370
1440
  return null;
1371
1441
  }
1372
- return props.schema.items.map((item) => createVNode(Fragment, {
1373
- "key": item.key
1374
- }, [item.children.map(renderItemSchema)]));
1442
+ return props.schema.items.map((item) => {
1443
+ const children = props.renderChildren ? props.renderChildren(item.children) : item.children.map(renderItemSchema);
1444
+ return createVNode(Fragment, {
1445
+ "key": item.key
1446
+ }, [children]);
1447
+ });
1375
1448
  };
1376
1449
  }
1377
1450
  });
1378
1451
  const Dynamic$1 = Dynamic;
1452
+ function _isSlot(s) {
1453
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
1454
+ }
1455
+ const SchemaList = /* @__PURE__ */ defineComponent({
1456
+ name: "SchemxSchemaList",
1457
+ inheritAttrs: false,
1458
+ props: {
1459
+ schemas: {
1460
+ type: Array,
1461
+ required: true
1462
+ },
1463
+ viewSchemas: {
1464
+ type: Array,
1465
+ required: true
1466
+ },
1467
+ colComponent: {
1468
+ type: [Object, Function],
1469
+ required: false,
1470
+ default: void 0
1471
+ },
1472
+ fieldClassResolver: {
1473
+ type: Function,
1474
+ required: false,
1475
+ default: void 0
1476
+ }
1477
+ },
1478
+ setup(props, {
1479
+ slots
1480
+ }) {
1481
+ const getFieldRenderKey = (schema) => `${schema.key}:${normalizeNameKey(schema.name)}`;
1482
+ const getSchemaRenderKey = (schema) => {
1483
+ if (isSchemxViewFieldSchema(schema)) {
1484
+ return getFieldRenderKey(schema);
1485
+ }
1486
+ return schema.key;
1487
+ };
1488
+ const renderChildren = (schemas) => {
1489
+ return h(SchemaList, {
1490
+ schemas,
1491
+ viewSchemas: props.viewSchemas,
1492
+ colComponent: props.colComponent
1493
+ }, slots);
1494
+ };
1495
+ const renderSchema = (schema) => {
1496
+ var _a;
1497
+ if (schema.visible === false) {
1498
+ return null;
1499
+ }
1500
+ let content;
1501
+ if (isViewGroupSchema(schema)) {
1502
+ content = createVNode(Group$1, {
1503
+ "key": schema.key,
1504
+ "schema": schema,
1505
+ "renderChildren": renderChildren
1506
+ }, slots);
1507
+ } else if (isViewDynamicSchema(schema)) {
1508
+ content = createVNode(Dynamic$1, {
1509
+ "key": schema.key,
1510
+ "schema": schema,
1511
+ "viewSchemas": props.viewSchemas,
1512
+ "renderChildren": renderChildren
1513
+ }, slots);
1514
+ } else {
1515
+ content = createVNode(Field$1, {
1516
+ "key": getFieldRenderKey(schema),
1517
+ "schema": schema,
1518
+ "class": (_a = props.fieldClassResolver) == null ? void 0 : _a.call(props, schema)
1519
+ }, slots);
1520
+ }
1521
+ if (!props.colComponent) {
1522
+ return content;
1523
+ }
1524
+ return createVNode(Col$1, {
1525
+ "key": getSchemaRenderKey(schema),
1526
+ "component": props.colComponent,
1527
+ "layout": schema.layout
1528
+ }, _isSlot(content) ? content : {
1529
+ default: () => [content]
1530
+ });
1531
+ };
1532
+ return () => {
1533
+ const children = props.schemas.map(renderSchema);
1534
+ if (!props.colComponent) {
1535
+ return children;
1536
+ }
1537
+ return createVNode("div", {
1538
+ "class": "schemx-row"
1539
+ }, [children]);
1540
+ };
1541
+ }
1542
+ });
1543
+ const SchemaList$1 = SchemaList;
1379
1544
  const _hoisted_1 = {
1380
1545
  key: 0,
1381
1546
  class: "schemx-actions"
1382
1547
  };
1383
- const _sfc_main = /* @__PURE__ */ defineComponent({
1548
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1384
1549
  ...{ name: "SchemxForm" },
1385
1550
  __name: "form",
1386
1551
  props: {
@@ -1394,6 +1559,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1394
1559
  resetter: { type: [Boolean, Object], default: true },
1395
1560
  class: { type: [Boolean, null, String, Object, Array], default: "" },
1396
1561
  style: { type: [Boolean, null, String, Object, Array], default: () => ({}) },
1562
+ colComponent: { default: void 0 },
1397
1563
  rendererProps: { default: void 0 },
1398
1564
  validatorAdapters: {},
1399
1565
  defaultRendererType: {},
@@ -1437,18 +1603,55 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1437
1603
  );
1438
1604
  };
1439
1605
  const isExternalForm = props.form !== void 0;
1606
+ const schemaConfigProps = computed(pickSchemaConfig);
1607
+ const appConfig = getSchemxAppConfig();
1608
+ const providerConfig = getSchemxConfigProviderRef();
1609
+ const coreConfig = getGlobalSchemxConfig();
1440
1610
  const formFallbackConfig = {
1441
1611
  schemaConfig: {
1442
1612
  visible: true,
1443
1613
  validationTrigger: ["blur", "change"]
1444
1614
  }
1445
1615
  };
1446
- const initialSchemaConfig = (isExternalForm ? mergeSchemxConfig({ schemaConfig: pickSchemaConfig() }, formFallbackConfig).schemaConfig : mergeVueSchemxConfig({ schemaConfig: pickSchemaConfig() }, formFallbackConfig).schemaConfig) ?? {};
1447
- const formSchemaConfig = reactive(initialSchemaConfig);
1616
+ const contextSchemaConfig = computed(() => {
1617
+ const mergedConfig = isExternalForm ? mergeSchemxConfig({ schemaConfig: schemaConfigProps.value }, formFallbackConfig) : mergeSchemxConfig(
1618
+ { schemaConfig: schemaConfigProps.value },
1619
+ (providerConfig == null ? void 0 : providerConfig.value) ?? {},
1620
+ appConfig,
1621
+ formFallbackConfig
1622
+ );
1623
+ return mergedConfig.schemaConfig ?? {};
1624
+ });
1625
+ const resolvedSchemaConfig = computed(
1626
+ () => mergeAndResolveSchemxConfig(
1627
+ { schemaConfig: schemaConfigProps.value },
1628
+ (providerConfig == null ? void 0 : providerConfig.value) ?? {},
1629
+ appConfig,
1630
+ formFallbackConfig,
1631
+ coreConfig
1632
+ ).schemaConfig
1633
+ );
1634
+ const initialContextSchemaConfig = contextSchemaConfig.value;
1635
+ const initialCoreSchemaConfig = isExternalForm ? initialContextSchemaConfig : resolvedSchemaConfig.value;
1636
+ const formSchemaConfig = reactive(
1637
+ initialContextSchemaConfig
1638
+ );
1639
+ const hasSchemaConfigKey = (config, key) => Object.prototype.hasOwnProperty.call(config, key);
1640
+ const replaceFormSchemaConfig = (nextSchemaConfig) => {
1641
+ for (const key of defaultSchemxConfigKeys) {
1642
+ if (!hasSchemaConfigKey(nextSchemaConfig, key)) {
1643
+ delete formSchemaConfig[key];
1644
+ }
1645
+ }
1646
+ Object.assign(formSchemaConfig, nextSchemaConfig);
1647
+ };
1648
+ const resolvedColComponent = computed(
1649
+ () => props.colComponent ?? (providerConfig == null ? void 0 : providerConfig.value.colComponent) ?? appConfig.colComponent ?? registeredColComponent.value
1650
+ );
1448
1651
  createFormConfigContext({ schemaConfig: formSchemaConfig });
1449
1652
  const providedForm = props.form ? props.form : useForm({
1450
1653
  schemas: props.schemas,
1451
- schemaConfig: initialSchemaConfig,
1654
+ schemaConfig: initialCoreSchemaConfig,
1452
1655
  initialValues: Object.keys(props.modelValue).length > 0 ? props.modelValue : props.initialValues,
1453
1656
  rendererProps: props.rendererProps,
1454
1657
  rendererRegistry: props.rendererRegistry,
@@ -1577,7 +1780,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1577
1780
  syncingFromModel = false;
1578
1781
  }
1579
1782
  },
1580
- { deep: true }
1783
+ { deep: true, immediate: isExternalForm }
1581
1784
  );
1582
1785
  const handleSubmit = () => formInstance.submit();
1583
1786
  const handleReset = () => {
@@ -1587,8 +1790,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1587
1790
  watch(
1588
1791
  formValues,
1589
1792
  (latestSnapshot) => {
1590
- if (syncingFromModel)
1793
+ if (syncingFromModel) {
1591
1794
  return;
1795
+ }
1592
1796
  emitModelValue(latestSnapshot);
1593
1797
  },
1594
1798
  { flush: "sync" }
@@ -1600,10 +1804,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1600
1804
  formInstance.setSchemas(schemas);
1601
1805
  }
1602
1806
  },
1603
- { deep: false, immediate: !!props.form }
1807
+ { immediate: isExternalForm }
1604
1808
  );
1605
1809
  const viewSchemas = useViewSchemas(formInstance);
1606
- const getFieldRenderKey = (schema) => `${schema.key}:${normalizeNameKey(schema.name)}`;
1607
1810
  const getFieldClass = (schema) => {
1608
1811
  const { isFirst, isLast } = getSectionPosition(
1609
1812
  viewSchemas.value,
@@ -1614,14 +1817,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1614
1817
  "schemx-field-wrapper--last": isLast
1615
1818
  };
1616
1819
  };
1617
- watch(
1618
- pickSchemaConfig,
1619
- (nextSchemaConfig) => {
1620
- Object.assign(formSchemaConfig, nextSchemaConfig);
1621
- formInstance.updateSchemaConfig(nextSchemaConfig);
1622
- },
1623
- { deep: false, immediate: isExternalForm }
1624
- );
1820
+ const syncInternalSchemaConfig = (nextSchemaConfig) => {
1821
+ replaceFormSchemaConfig(contextSchemaConfig.value);
1822
+ formInstance.updateSchemaConfig(nextSchemaConfig);
1823
+ };
1824
+ const syncExternalSchemaConfig = (nextSchemaConfig, previousSchemaConfig) => {
1825
+ const patch = { ...nextSchemaConfig };
1826
+ if (previousSchemaConfig !== void 0) {
1827
+ for (const key of defaultSchemxConfigKeys) {
1828
+ if (hasSchemaConfigKey(previousSchemaConfig, key) && !hasSchemaConfigKey(nextSchemaConfig, key)) {
1829
+ patch[key] = void 0;
1830
+ }
1831
+ }
1832
+ }
1833
+ replaceFormSchemaConfig(contextSchemaConfig.value);
1834
+ if (Object.keys(patch).length > 0) {
1835
+ formInstance.updateSchemaConfig(patch);
1836
+ }
1837
+ };
1838
+ if (isExternalForm) {
1839
+ watch(schemaConfigProps, syncExternalSchemaConfig, {
1840
+ deep: true,
1841
+ immediate: true
1842
+ });
1843
+ } else {
1844
+ watch(resolvedSchemaConfig, syncInternalSchemaConfig, { deep: true });
1845
+ }
1625
1846
  const exposed = {
1626
1847
  ...formInstance,
1627
1848
  submit: handleSubmit,
@@ -1633,58 +1854,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1633
1854
  class: normalizeClass(formRootClass.value),
1634
1855
  style: normalizeStyle(formRootStyle.value)
1635
1856
  }, [
1636
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(viewSchemas), (schema) => {
1637
- return openBlock(), createElementBlock(Fragment, {
1638
- key: schema.key
1639
- }, [
1640
- unref(isViewGroupSchema)(schema) ? (openBlock(), createBlock(unref(Group$1), {
1641
- key: 0,
1642
- schema
1643
- }, createSlots({ _: 2 }, [
1644
- renderList(fieldSlots.value, (_, slotName) => {
1645
- return {
1646
- name: slotName,
1647
- fn: withCtx((slotProps) => [
1648
- renderSlot(_ctx.$slots, slotName, mergeProps({ ref_for: true }, slotProps ?? {}))
1649
- ])
1650
- };
1651
- })
1652
- ]), 1032, ["schema"])) : unref(isViewDynamicSchema)(schema) ? (openBlock(), createBlock(unref(Dynamic$1), {
1653
- key: 1,
1654
- schema,
1655
- "view-schemas": unref(viewSchemas)
1656
- }, createSlots({ _: 2 }, [
1657
- renderList(fieldSlots.value, (_, slotName) => {
1658
- return {
1659
- name: slotName,
1660
- fn: withCtx((slotProps) => [
1661
- renderSlot(_ctx.$slots, slotName, mergeProps({ ref_for: true }, slotProps ?? {}))
1662
- ])
1663
- };
1664
- })
1665
- ]), 1032, ["schema", "view-schemas"])) : (openBlock(), createBlock(unref(Field$1), {
1666
- key: getFieldRenderKey(schema),
1667
- schema,
1668
- class: normalizeClass(getFieldClass(schema))
1669
- }, createSlots({ _: 2 }, [
1670
- renderList(fieldSlots.value, (_, slotName) => {
1671
- return {
1672
- name: slotName,
1673
- fn: withCtx((slotProps) => [
1674
- renderSlot(_ctx.$slots, slotName, mergeProps({ ref_for: true }, slotProps ?? {}))
1675
- ])
1676
- };
1677
- })
1678
- ]), 1032, ["schema", "class"]))
1679
- ], 64);
1680
- }), 128)),
1857
+ createVNode(unref(SchemaList$1), {
1858
+ schemas: unref(viewSchemas),
1859
+ "view-schemas": unref(viewSchemas),
1860
+ "col-component": resolvedColComponent.value,
1861
+ "field-class-resolver": getFieldClass
1862
+ }, createSlots({ _: 2 }, [
1863
+ renderList(fieldSlots.value, (_, slotName) => {
1864
+ return {
1865
+ name: slotName,
1866
+ fn: withCtx((slotProps) => [
1867
+ renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(slotProps ?? {})))
1868
+ ])
1869
+ };
1870
+ })
1871
+ ]), 1032, ["schemas", "view-schemas", "col-component"]),
1681
1872
  isActionsVisible.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
1682
1873
  isResetterVisible.value && unref(slots).resetter ? renderSlot(_ctx.$slots, "resetter", {
1683
1874
  form: unref(formInstance),
1684
1875
  loading: effectiveLoading.value,
1685
1876
  disabled: isResetterDisabled.value,
1686
1877
  reset: handleReset
1687
- }, void 0, void 0, 0) : isResetterVisible.value ? (openBlock(), createBlock(unref(_sfc_main$1), mergeProps({ key: 1 }, resetterButtonProps.value, {
1878
+ }, void 0, void 0, 0) : isResetterVisible.value ? (openBlock(), createBlock(unref(_sfc_main$2), mergeProps({ key: 1 }, resetterButtonProps.value, {
1688
1879
  class: "schemx-actions-button schemx-actions-button--reset",
1689
1880
  type: "button",
1690
1881
  disabled: isResetterDisabled.value,
@@ -1700,7 +1891,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1700
1891
  loading: effectiveLoading.value,
1701
1892
  disabled: isSubmitterDisabled.value,
1702
1893
  submit: handleSubmit
1703
- }, void 0, void 0, 2) : isSubmitterVisible.value ? (openBlock(), createBlock(unref(_sfc_main$1), mergeProps({ key: 3 }, submitterButtonProps.value, {
1894
+ }, void 0, void 0, 2) : isSubmitterVisible.value ? (openBlock(), createBlock(unref(_sfc_main$2), mergeProps({ key: 3 }, submitterButtonProps.value, {
1704
1895
  class: "schemx-actions-button schemx-actions-button--submit",
1705
1896
  type: "button",
1706
1897
  loading: effectiveLoading.value,
@@ -1720,11 +1911,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1720
1911
  function withInstall(comp, extra) {
1721
1912
  return Object.assign(comp, extra);
1722
1913
  }
1723
- const SchemxFormExport = withInstall(_sfc_main, {
1914
+ const SchemxFormExport = withInstall(_sfc_main$1, {
1724
1915
  /** Vue 插件安装方法 */
1725
1916
  install(app, options = {}) {
1726
1917
  provideSchemxAppConfig(app, options);
1727
- app.component("SchemxForm", _sfc_main);
1918
+ app.component("SchemxForm", _sfc_main$1);
1728
1919
  },
1729
1920
  /** Field 子组件引用 */
1730
1921
  Field: Field$1
@@ -1762,6 +1953,53 @@ function WithRemoteOptions(WrappedComponent) {
1762
1953
  }
1763
1954
  });
1764
1955
  }
1956
+ const _sfc_main = /* @__PURE__ */ defineComponent({
1957
+ ...{
1958
+ name: "SchemxWrapper",
1959
+ inheritAttrs: false
1960
+ },
1961
+ __name: "index",
1962
+ props: {
1963
+ readonly: { type: Boolean, default: false },
1964
+ disabled: { type: Boolean, default: false }
1965
+ },
1966
+ setup(__props) {
1967
+ const props = __props;
1968
+ const attrs = useAttrs();
1969
+ const slots = useSlots();
1970
+ const warnedReadonlySlot = ref(false);
1971
+ const rootClass = computed(() => [
1972
+ "schemx-wrapper",
1973
+ attrs.class,
1974
+ props.readonly && "schemx-wrapper--readonly",
1975
+ props.disabled && "schemx-wrapper--disabled"
1976
+ ]);
1977
+ const forwardedAttrs = computed(() => {
1978
+ const { class: _class, ...rest } = attrs;
1979
+ return rest;
1980
+ });
1981
+ const warnIfReadonlySlotIsMissing = (readonly2) => {
1982
+ if (!readonly2 || slots.readonly || warnedReadonlySlot.value || true) {
1983
+ return;
1984
+ }
1985
+ warnedReadonlySlot.value = true;
1986
+ console.warn("[schemx] SchemxWrapper is readonly but no #readonly slot was provided.");
1987
+ };
1988
+ onMounted(() => warnIfReadonlySlotIsMissing(props.readonly));
1989
+ watch(() => props.readonly, warnIfReadonlySlotIsMissing);
1990
+ return (_ctx, _cache) => {
1991
+ return openBlock(), createElementBlock("div", mergeProps(forwardedAttrs.value, { class: rootClass.value }), [
1992
+ props.readonly ? renderSlot(_ctx.$slots, "readonly", {
1993
+ readonly: props.readonly,
1994
+ disabled: props.disabled
1995
+ }, void 0, void 0, 0) : renderSlot(_ctx.$slots, "default", {
1996
+ readonly: props.readonly,
1997
+ disabled: props.disabled
1998
+ }, void 0, void 0, 1)
1999
+ ], 16);
2000
+ };
2001
+ }
2002
+ });
1765
2003
  const ConfigProvider = /* @__PURE__ */ defineComponent({
1766
2004
  name: "SchemxConfigProvider",
1767
2005
  inheritAttrs: false,
@@ -1789,6 +2027,10 @@ const ConfigProvider = /* @__PURE__ */ defineComponent({
1789
2027
  presetRuleRegistry: {
1790
2028
  type: Object,
1791
2029
  default: void 0
2030
+ },
2031
+ colComponent: {
2032
+ type: [Object, Function],
2033
+ default: void 0
1792
2034
  }
1793
2035
  },
1794
2036
  setup(props, {
@@ -1800,7 +2042,8 @@ const ConfigProvider = /* @__PURE__ */ defineComponent({
1800
2042
  validatorAdapters: props.validatorAdapters,
1801
2043
  defaultRendererType: props.defaultRendererType,
1802
2044
  rendererRegistry: props.rendererRegistry,
1803
- presetRuleRegistry: props.presetRuleRegistry
2045
+ presetRuleRegistry: props.presetRuleRegistry,
2046
+ colComponent: props.colComponent
1804
2047
  }));
1805
2048
  provideSchemxConfigProvider(config);
1806
2049
  return () => {
@@ -1811,15 +2054,18 @@ const ConfigProvider = /* @__PURE__ */ defineComponent({
1811
2054
  });
1812
2055
  const ConfigProvider$1 = ConfigProvider;
1813
2056
  export {
2057
+ Col$1 as Col,
1814
2058
  ConfigProvider$1 as ConfigProvider,
1815
2059
  Field$1 as Field,
1816
2060
  Group$1 as Group,
1817
2061
  WithRemoteOptions,
2062
+ _sfc_main as Wrapper,
1818
2063
  createFieldContext,
1819
2064
  createFormConfigContext,
1820
2065
  createFormContext,
1821
2066
  SchemxFormExport$1 as default,
1822
2067
  presetRuleRegistry,
2068
+ registerCol,
1823
2069
  rendererRegistry,
1824
2070
  SchemxFormExport$1 as schemxForm,
1825
2071
  useDictionary,