@nocobase/client 2.0.46 → 2.0.48

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/es/index.mjs CHANGED
@@ -106,7 +106,7 @@ import { evaluators } from "@nocobase/evaluators/client";
106
106
  import * as formilyAntdV5 from "@formily/antd-v5";
107
107
  import { FormLayout, ArrayCollapse as ArrayCollapse$2, ArrayItems, ArrayBase, TreeSelect as TreeSelect$1, Input as Input$4, FormItem as FormItem$1, useFormLayout, ArrayTable, NumberPicker, Select as Select$2, FormButtonGroup } from "@formily/antd-v5";
108
108
  import * as nocobaseFlowEngine from "@nocobase/flow-engine";
109
- import { observer, useFlowEngine, createCollectionContextMeta, useFlowEngineContext, FlowEngine, FlowEngineProvider, FlowEngineGlobalsContextProvider, useFlowContext, FlowContextSelector, defineAction, tExpr, useFlowViewContext, parseValueToPath, VariableInput as VariableInput$1, createEphemeralContext, setupRunJSContexts, getRunJSDocFor, listSnippetsForContext, prepareRunJsCode, JSRunner, createSafeNavigator, createSafeWindow, createSafeDocument, shouldPreprocessRunJSTemplates, FlowContext, getRunJSScenesForContext, isRunJSValue, normalizeRunJSValue, useFlowModel, FlowModel, buildSubModelItems, buildSubModelItem, DisplayItemModel, FilterItem as FilterItem$2, FilterGroup as FilterGroup$3, EMPTY_COLUMN_UID, DragHandler as DragHandler$1, findModelUidPosition, buildLayoutSnapshot, getSlotKey, simulateLayoutForSlot, resolveDropIntent, DndProvider, Droppable, MemoFlowModelRenderer, AddSubModelButton, FlowSettingsButton, MultiRecordResource, getPageActive, VIEW_ACTIVATED_EVENT, getEmitterViewActivatedVersion, DATA_SOURCE_DIRTY_EVENT, parsePathnameToViewParams, FlowModelRenderer, observable as observable$1, defineFlow, useFlowModelById, reaction as reaction$1, ViewNavigation, EditableItemModel, FilterableItemModel, isCtxDateExpression, parseCtxDateExpression, isVariableExpression, serializeCtxDateValue, useFlowSettingsContext, pruneFilter, MobilePopup, resolveRunJSObjectValues, SingleRecordResource, escapeT, extractUsedVariablePaths, extractUsedVariablePathsFromRunJS, runjsWithSafeGlobals, createAssociationAwareObjectMetaFactory, createAssociationSubpathResolver, createCurrentRecordMetaFactory, createRecordResolveOnServerWithLocal, FormItem as FormItem$2, FieldModelRenderer, ModelRenderMode, buildWrapperFieldChildren, useFlowModelContext, FlowsFloatContextMenu, FlowModelProvider, FlowErrorFallback, createRecordMetaFactory, CollectionField as CollectionField$2, FlowModelContext, ElementProxy, autorun as autorun$1, largeField, FlowExitAllException, ActionScene, jioToJoiSchema, FlowRuntimeContext, extractPropertyPath, VariableTag, FlowStepContext, untracked as untracked$1, isBeforeRenderFlow, shouldHideEventInSettings, GLOBAL_EMBED_CONTAINER_ID, EMBED_REPLACING_DATA_KEY } from "@nocobase/flow-engine";
109
+ import { observer, useFlowEngine, createCollectionContextMeta, useFlowEngineContext, FlowEngine, FlowEngineProvider, FlowEngineGlobalsContextProvider, useFlowContext, FlowContextSelector, defineAction, tExpr, useFlowViewContext, parseValueToPath, VariableInput as VariableInput$1, createEphemeralContext, setupRunJSContexts, getRunJSDocFor, listSnippetsForContext, prepareRunJsCode, JSRunner, createSafeNavigator, createSafeWindow, createSafeDocument, shouldPreprocessRunJSTemplates, FlowContext, getRunJSScenesForContext, isRunJSValue, normalizeRunJSValue, useFlowModel, FlowModel, buildSubModelItems, buildSubModelItem, DisplayItemModel, FilterItem as FilterItem$2, FilterGroup as FilterGroup$3, EMPTY_COLUMN_UID, normalizeGridLayout, DragHandler as DragHandler$1, projectLayoutToLegacyRows, findModelUidLayoutPosition, buildLayoutSnapshot, resolveDropIntent, getSlotKey, simulateLayoutForSlot, isSameGridLayout, DndProvider, Droppable, MemoFlowModelRenderer, AddSubModelButton, FlowSettingsButton, MultiRecordResource, getPageActive, VIEW_ACTIVATED_EVENT, getEmitterViewActivatedVersion, DATA_SOURCE_DIRTY_EVENT, parsePathnameToViewParams, FlowModelRenderer, observable as observable$1, defineFlow, useFlowModelById, reaction as reaction$1, ViewNavigation, EditableItemModel, FilterableItemModel, isCtxDateExpression, parseCtxDateExpression, isVariableExpression, serializeCtxDateValue, pruneFilter, useFlowSettingsContext, MobilePopup, resolveRunJSObjectValues, SingleRecordResource, escapeT, extractUsedVariablePaths, extractUsedVariablePathsFromRunJS, runjsWithSafeGlobals, createAssociationAwareObjectMetaFactory, createAssociationSubpathResolver, createCurrentRecordMetaFactory, createRecordResolveOnServerWithLocal, FormItem as FormItem$2, FieldModelRenderer, ModelRenderMode, buildWrapperFieldChildren, useFlowModelContext, FlowsFloatContextMenu, FlowModelProvider, FlowErrorFallback, createRecordMetaFactory, CollectionField as CollectionField$2, FlowModelContext, ElementProxy, autorun as autorun$1, largeField, FlowExitAllException, ActionScene, jioToJoiSchema, FlowRuntimeContext, extractPropertyPath, VariableTag, FlowStepContext, untracked as untracked$1, isBeforeRenderFlow, shouldHideEventInSettings, GLOBAL_EMBED_CONTAINER_ID, EMBED_REPLACING_DATA_KEY } from "@nocobase/flow-engine";
110
110
  import { FieldModelRenderer as Hn } from "@nocobase/flow-engine";
111
111
  import ignore from "ignore";
112
112
  import cronstrue from "cronstrue";
@@ -9991,7 +9991,7 @@ function addAppVersion(e, t) {
9991
9991
  addAppVersion((n = e.properties) == null ? void 0 : n[o], t);
9992
9992
  }), e;
9993
9993
  }
9994
- const name = "@nocobase/client", version = "2.0.46", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9994
+ const name = "@nocobase/client", version = "2.0.48", license = "Apache-2.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
9995
9995
  "@ahooksjs/use-url-state": "3.5.1",
9996
9996
  "@ant-design/cssinjs": "^1.11.1",
9997
9997
  "@ant-design/icons": "^5.6.1",
@@ -10014,10 +10014,10 @@ const name = "@nocobase/client", version = "2.0.46", license = "Apache-2.0", mai
10014
10014
  "@formily/reactive-react": "^2.2.27",
10015
10015
  "@formily/shared": "^2.2.27",
10016
10016
  "@formily/validator": "^2.2.27",
10017
- "@nocobase/evaluators": "2.0.46",
10018
- "@nocobase/flow-engine": "2.0.46",
10019
- "@nocobase/sdk": "2.0.46",
10020
- "@nocobase/utils": "2.0.46",
10017
+ "@nocobase/evaluators": "2.0.48",
10018
+ "@nocobase/flow-engine": "2.0.48",
10019
+ "@nocobase/sdk": "2.0.48",
10020
+ "@nocobase/utils": "2.0.48",
10021
10021
  "@tanstack/react-table": "^8.21.3",
10022
10022
  "@types/tabulator-tables": "^6.2.6",
10023
10023
  "acorn-jsx": "^5.3.2",
@@ -30659,7 +30659,7 @@ const useStyles$a = genStyleHook("nb-markdown", (e, { isDarkTheme: t }) => {
30659
30659
  }, t ? i : r)
30660
30660
  };
30661
30661
  }), parseMarkdown$1 = _.memoize((e) => L(void 0, null, function* () {
30662
- return e && (yield import("./md-oH2RssNY.mjs")).default.render(e);
30662
+ return e && (yield import("./md-BbvRKckr.mjs")).default.render(e);
30663
30663
  }));
30664
30664
  function useParseMarkdown$1(e) {
30665
30665
  const [t, o] = useState(""), [n, r] = useState(!0);
@@ -71340,52 +71340,83 @@ class FilterManager {
71340
71340
  });
71341
71341
  }
71342
71342
  }
71343
- function Grid({ rows: e, sizes: t = {}, renderItem: o, rowGap: n = 16, colGap: r = 16, dragOverlayRect: i }) {
71344
- return Object.keys(e || {}).length === 0 ? /* @__PURE__ */ jsx("div", { style: { position: "relative" }, "data-grid-empty-container": !0, children: i && /* @__PURE__ */ jsx(GridDragOverlay, { rect: i }) }) : /* @__PURE__ */ jsxs("div", { style: { position: "relative", display: "flex", flexDirection: "column", gap: n }, children: [
71345
- i && /* @__PURE__ */ jsx(GridDragOverlay, { rect: i }),
71346
- Object.entries(e).map(([a, l]) => {
71347
- const c = l.length, u = t[a] || [], d = u.some((m) => m != null && m !== void 0), p = l.map((m, h) => {
71348
- var g;
71349
- if (d) {
71350
- const f = u.reduce((S, C) => S + (C || 0), 0), y = c - u.filter(Boolean).length, b = y > 0 ? (24 - f) / y : 0;
71351
- return (g = u[h]) != null ? g : b;
71352
- } else
71353
- return 24 / c;
71354
- });
71355
- return /* @__PURE__ */ jsx(Row, { gutter: r, "data-grid-row-id": a, children: l.map((m, h) => /* @__PURE__ */ jsx(
71356
- GridColumn,
71357
- {
71358
- rowKey: a,
71359
- columnIndex: h,
71360
- span: p[h],
71361
- rowGap: n,
71362
- cell: m,
71363
- renderItem: o
71364
- },
71365
- `${a}:${m.join("|") || "empty"}`
71366
- )) }, a);
71367
- })
71368
- ] });
71343
+ function Grid({
71344
+ rows: e = {},
71345
+ sizes: t = {},
71346
+ layout: o,
71347
+ renderItem: n,
71348
+ rowGap: r = 16,
71349
+ colGap: i = 16,
71350
+ dragOverlayRect: a
71351
+ }) {
71352
+ const l = o || normalizeGridLayout({ rows: e, sizes: t });
71353
+ return l.rows.length ? /* @__PURE__ */ jsxs("div", { style: { position: "relative", display: "flex", flexDirection: "column", gap: r }, "data-grid-root": !0, children: [
71354
+ a && /* @__PURE__ */ jsx(GridDragOverlay, { rect: a }),
71355
+ /* @__PURE__ */ jsx(GridRows, { rows: l.rows, renderItem: n, rowGap: r, colGap: i, parentPath: [] })
71356
+ ] }) : /* @__PURE__ */ jsx("div", { style: { position: "relative" }, "data-grid-root": !0, "data-grid-empty-container": !0, children: a && /* @__PURE__ */ jsx(GridDragOverlay, { rect: a }) });
71357
+ }
71358
+ function GridRows({ rows: e, renderItem: t, rowGap: o, colGap: n, parentPath: r }) {
71359
+ return /* @__PURE__ */ jsx(Fragment$1, { children: e.map((i) => {
71360
+ const a = i.cells.length, l = i.sizes || [], c = l.some((p) => p != null && p !== void 0), u = [...r, { rowId: i.id }], d = i.cells.map((p, m) => {
71361
+ var h;
71362
+ if (c) {
71363
+ const g = l.reduce((b, S) => b + (S || 0), 0), f = a - l.filter(Boolean).length, y = f > 0 ? (24 - g) / f : 0;
71364
+ return (h = l[m]) != null ? h : y;
71365
+ } else
71366
+ return 24 / a;
71367
+ });
71368
+ return /* @__PURE__ */ jsx(Row, { gutter: n, "data-grid-row-id": i.id, "data-grid-path": JSON.stringify(u), children: i.cells.map((p, m) => /* @__PURE__ */ jsx(
71369
+ GridColumn,
71370
+ {
71371
+ rowKey: i.id,
71372
+ columnIndex: m,
71373
+ span: d[m],
71374
+ rowGap: o,
71375
+ colGap: n,
71376
+ cell: p,
71377
+ path: [...u.slice(0, -1), { rowId: i.id, cellId: p.id }],
71378
+ renderItem: t
71379
+ },
71380
+ p.id
71381
+ )) }, i.id);
71382
+ }) });
71369
71383
  }
71370
71384
  const GridColumn = React.memo(function e({
71371
71385
  rowKey: t,
71372
71386
  columnIndex: o,
71373
71387
  span: n,
71374
71388
  rowGap: r,
71375
- cell: i,
71376
- renderItem: a
71389
+ colGap: i,
71390
+ cell: a,
71391
+ path: l,
71392
+ renderItem: c
71377
71393
  }) {
71378
- return /* @__PURE__ */ jsx(Col, { span: n, "data-grid-column-row-id": t, "data-grid-column-index": o, children: /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: r }, children: i.map((l, c) => l === EMPTY_COLUMN_UID ? null : /* @__PURE__ */ jsx(
71379
- "div",
71394
+ var d;
71395
+ const u = a.items || [];
71396
+ return /* @__PURE__ */ jsx(
71397
+ Col,
71380
71398
  {
71381
- "data-grid-item-row-id": t,
71399
+ span: n,
71400
+ "data-grid-column-row-id": t,
71382
71401
  "data-grid-column-index": o,
71383
- "data-grid-item-index": c,
71384
- "data-grid-item-uid": l,
71385
- children: a(l)
71386
- },
71387
- l
71388
- )) }) });
71402
+ "data-grid-path": JSON.stringify(l),
71403
+ children: /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: r }, children: [
71404
+ u.map((p, m) => p === EMPTY_COLUMN_UID ? null : /* @__PURE__ */ jsx(
71405
+ "div",
71406
+ {
71407
+ "data-grid-item-row-id": t,
71408
+ "data-grid-column-index": o,
71409
+ "data-grid-item-index": m,
71410
+ "data-grid-item-uid": p,
71411
+ "data-grid-path": JSON.stringify(l),
71412
+ children: c(p)
71413
+ },
71414
+ p
71415
+ )),
71416
+ (d = a.rows) != null && d.length ? /* @__PURE__ */ jsx(GridRows, { rows: a.rows, renderItem: c, rowGap: r, colGap: i, parentPath: l }) : null
71417
+ ] })
71418
+ }
71419
+ );
71389
71420
  });
71390
71421
  GridColumn.displayName = "GridColumn";
71391
71422
  function GridDragOverlay({ rect: e }) {
@@ -71419,6 +71450,10 @@ function GridDragOverlay({ rect: e }) {
71419
71450
  "empty-column": {
71420
71451
  border: "2px dashed var(--colorPrimary)",
71421
71452
  backgroundColor: "rgba(22, 119, 255, 0.04)"
71453
+ },
71454
+ "item-edge": {
71455
+ border: "2px solid var(--colorPrimary)",
71456
+ backgroundColor: "rgba(22, 119, 255, 0.12)"
71422
71457
  }
71423
71458
  };
71424
71459
  return /* @__PURE__ */ jsx("div", { style: x(x({}, t), o[e.type]) });
@@ -71484,6 +71519,25 @@ class GridModel extends FlowModel {
71484
71519
  ]);
71485
71520
  R(this, "dragState");
71486
71521
  R(this, "_memoItemFlowSettings");
71522
+ R(this, "updateDragPointerPosition", (o) => {
71523
+ if (!this.dragState)
71524
+ return;
71525
+ const n = getClientPoint(o);
71526
+ n && (this.dragState.pointerPosition = n);
71527
+ });
71528
+ R(this, "handleDragScroll", () => {
71529
+ this.dragState && this.scheduleSnapshotRefresh();
71530
+ });
71531
+ }
71532
+ bindDragDocumentListeners() {
71533
+ var a;
71534
+ const o = ((a = this.getDragContainer()) == null ? void 0 : a.ownerDocument) || (typeof document == "undefined" ? null : document);
71535
+ if (!o)
71536
+ return;
71537
+ const n = { capture: !0, passive: !0 }, r = { capture: !0 }, i = o.defaultView;
71538
+ return o.addEventListener("pointermove", this.updateDragPointerPosition, n), o.addEventListener("mousemove", this.updateDragPointerPosition, n), o.addEventListener("touchmove", this.updateDragPointerPosition, n), o.addEventListener("scroll", this.handleDragScroll, n), i == null || i.addEventListener("scroll", this.handleDragScroll, n), () => {
71539
+ o.removeEventListener("pointermove", this.updateDragPointerPosition, r), o.removeEventListener("mousemove", this.updateDragPointerPosition, r), o.removeEventListener("touchmove", this.updateDragPointerPosition, r), o.removeEventListener("scroll", this.handleDragScroll, r), i == null || i.removeEventListener("scroll", this.handleDragScroll, r);
71540
+ };
71487
71541
  }
71488
71542
  deriveRowOrder(o, n) {
71489
71543
  const r = [], i = /* @__PURE__ */ new Set();
@@ -71512,77 +71566,153 @@ class GridModel extends FlowModel {
71512
71566
  getItemFlowSettings() {
71513
71567
  return this._memoItemFlowSettings || (this._memoItemFlowSettings = x({ showBackground: !1, showDragHandle: !0 }, this.itemFlowSettings)), this._memoItemFlowSettings;
71514
71568
  }
71569
+ getItemUids() {
71570
+ return (this.subModels.items || []).map((o) => o.uid);
71571
+ }
71572
+ normalizeLayoutFromSource(o) {
71573
+ var r, i, a, l, c, u, d, p;
71574
+ const n = this.getStepParams(GRID_FLOW_KEY, GRID_STEP) || {};
71575
+ return normalizeGridLayout({
71576
+ layout: (i = (r = o == null ? void 0 : o.layout) != null ? r : this.props.layout) != null ? i : n.layout,
71577
+ rows: (l = (a = o == null ? void 0 : o.rows) != null ? a : this.props.rows) != null ? l : n.rows,
71578
+ sizes: (u = (c = o == null ? void 0 : o.sizes) != null ? c : this.props.sizes) != null ? u : n.sizes,
71579
+ rowOrder: (p = (d = o == null ? void 0 : o.rowOrder) != null ? d : this.props.rowOrder) != null ? p : n.rowOrder,
71580
+ itemUids: this.getItemUids(),
71581
+ gridUid: this.uid,
71582
+ logger: console
71583
+ });
71584
+ }
71585
+ getGridLayout() {
71586
+ return this.normalizeLayoutFromSource();
71587
+ }
71588
+ syncLayoutProps(o) {
71589
+ const n = projectLayoutToLegacyRows(o);
71590
+ this.setProps("layout", o), this.setProps("rows", n.rows), this.setProps("sizes", n.sizes), this.setProps("rowOrder", n.rowOrder);
71591
+ }
71592
+ setGridStepLayout(o) {
71593
+ this.setStepParams(GRID_FLOW_KEY, {
71594
+ [GRID_STEP]: {
71595
+ layout: o
71596
+ }
71597
+ });
71598
+ }
71599
+ findLayoutRowByPath(o, n) {
71600
+ if (!(n != null && n.length))
71601
+ return null;
71602
+ let r = o.rows;
71603
+ for (let i = 0; i < n.length; i += 1) {
71604
+ const a = n[i], l = r.find((u) => u.id === a.rowId);
71605
+ if (!l)
71606
+ return null;
71607
+ if (i === n.length - 1)
71608
+ return l;
71609
+ const c = l.cells.find((u) => u.id === a.cellId);
71610
+ r = (c == null ? void 0 : c.rows) || [];
71611
+ }
71612
+ return null;
71613
+ }
71614
+ collectCellItemsForResize(o) {
71615
+ return Array.isArray(o.items) ? [...o.items] : (o.rows || []).flatMap(
71616
+ (n) => n.cells.flatMap((r) => this.collectCellItemsForResize(r))
71617
+ );
71618
+ }
71619
+ buildResizedCells(o, n) {
71620
+ const r = /* @__PURE__ */ new Set();
71621
+ return n.map((i, a) => {
71622
+ const l = o.cells.findIndex((c, u) => !r.has(u) && _.isEqual(this.collectCellItemsForResize(c), i));
71623
+ if (l !== -1) {
71624
+ r.add(l);
71625
+ const c = o.cells[l];
71626
+ return c.rows && !c.items ? _.cloneDeep(c) : {
71627
+ id: c.id,
71628
+ items: [...i]
71629
+ };
71630
+ }
71631
+ return {
71632
+ id: `${o.id}:cell:${a}:${uid()}`,
71633
+ items: [...i]
71634
+ };
71635
+ });
71636
+ }
71637
+ getResizeRowPath(o) {
71638
+ if (!(o != null && o.length))
71639
+ return [];
71640
+ const n = o.map((r) => x({}, r));
71641
+ return delete n[n.length - 1].cellId, n;
71642
+ }
71643
+ getResizeContainerWidth(o) {
71644
+ var l, c, u;
71645
+ const n = this.getResizeRowPath(o), r = ((l = this.gridContainerRef.current) == null ? void 0 : l.clientWidth) || 0;
71646
+ if (!n.length)
71647
+ return r;
71648
+ const a = Array.from(((c = this.gridContainerRef.current) == null ? void 0 : c.querySelectorAll("[data-grid-row-id]")) || []).find((d) => {
71649
+ try {
71650
+ return _.isEqual(JSON.parse(d.dataset.gridPath || "[]"), n);
71651
+ } catch (p) {
71652
+ return !1;
71653
+ }
71654
+ });
71655
+ return ((u = a == null ? void 0 : a.parentElement) == null ? void 0 : u.clientWidth) || r;
71656
+ }
71657
+ resizeGridLayout({
71658
+ direction: o,
71659
+ resizeDistance: n,
71660
+ model: r
71661
+ }) {
71662
+ var f, y;
71663
+ const i = this.getGridLayout(), a = findModelUidLayoutPosition(i, r.uid);
71664
+ if (!a)
71665
+ return null;
71666
+ const l = this.findLayoutRowByPath(i, a.path);
71667
+ if (!l)
71668
+ return null;
71669
+ const c = this.getResizeContainerWidth(a.path), u = l.cells.map((b) => this.collectCellItemsForResize(b)), { newRows: d, newSizes: p, moveDistance: m } = recalculateGridSizes({
71670
+ position: {
71671
+ rowId: l.id,
71672
+ columnIndex: a.cellIndex,
71673
+ itemIndex: a.itemIndex
71674
+ },
71675
+ direction: o,
71676
+ resizeDistance: n,
71677
+ prevMoveDistance: this.prevMoveDistance,
71678
+ oldRows: { [l.id]: u },
71679
+ oldSizes: { [l.id]: l.sizes || [] },
71680
+ gutter: (y = (f = this.context.themeToken) == null ? void 0 : f.marginBlock) != null ? y : 16,
71681
+ gridContainerWidth: c
71682
+ }), h = _.cloneDeep(i), g = this.findLayoutRowByPath(h, a.path);
71683
+ return g ? (g.cells = this.buildResizedCells(l, d[l.id] || []), g.sizes = p[l.id] || [], {
71684
+ layout: normalizeGridLayout({
71685
+ layout: h,
71686
+ itemUids: this.getItemUids(),
71687
+ gridUid: this.uid,
71688
+ logger: console
71689
+ }),
71690
+ moveDistance: m
71691
+ }) : null;
71692
+ }
71515
71693
  onMount() {
71516
71694
  super.onMount(), this.emitter.on("onSubModelAdded", (o) => {
71517
- if (!o.isNew)
71518
- return;
71519
- this.resetRows(!0);
71520
- const n = findModelUidPosition(o.uid, this.props.rows || {});
71521
- if (n) {
71522
- const r = _.cloneDeep(this.props.sizes || {});
71523
- r[n.rowId] = [24];
71524
- const { rowOrder: i } = this.normalizeRowsWithOrder(this.props.rows || {}, this.props.rowOrder), a = this.orderSizesByRowOrder(r, i);
71525
- this.setStepParams(GRID_FLOW_KEY, GRID_STEP, {
71526
- rows: this.props.rows || {},
71527
- sizes: a,
71528
- rowOrder: i
71529
- }), this.setProps("sizes", a), this.setProps("rowOrder", i);
71530
- }
71695
+ o.isNew && (this.resetRows(!0), this.setGridStepLayout(this.props.layout));
71531
71696
  }), this.emitter.on("onSubModelDestroyed", (o) => {
71532
- var i, a, l, c;
71533
- const n = o.uid, r = findModelUidPosition(n, this.props.rows || {});
71534
- if (this.resetRows(!0), r) {
71535
- const u = this.props.rows || {}, d = _.cloneDeep(this.props.sizes || {});
71536
- ((i = u[r.rowId]) == null ? void 0 : i[r.columnIndex]) === void 0 && ((a = d[r.rowId]) == null || a.splice(r.columnIndex, 1)), u[r.rowId] === void 0 && delete d[r.rowId];
71537
- const { rowOrder: p } = this.normalizeRowsWithOrder(u, this.props.rowOrder), m = this.orderSizesByRowOrder(d, p);
71538
- this.setStepParams(GRID_FLOW_KEY, GRID_STEP, {
71539
- rows: u,
71540
- sizes: m,
71541
- rowOrder: p
71542
- }), this.setProps("sizes", m), this.setProps("rowOrder", p);
71543
- }
71544
- (l = this.context.filterManager) == null || l.removeFilterConfig({ targetId: n }), (c = this.context.filterManager) == null || c.removeFilterConfig({ filterId: n }), this.saveStepParams();
71697
+ var r, i;
71698
+ const n = o.uid;
71699
+ this.resetRows(!0), this.setGridStepLayout(this.props.layout), (r = this.context.filterManager) == null || r.removeFilterConfig({ targetId: n }), (i = this.context.filterManager) == null || i.removeFilterConfig({ filterId: n }), this.saveStepParams();
71545
71700
  }), this.emitter.on("onSubModelMoved", () => {
71546
71701
  this.resetRows(!0);
71547
71702
  }), this.emitter.on("onResizeLeft", ({ resizeDistance: o, model: n }) => {
71548
- var u;
71549
- const r = findModelUidPosition(n.uid, this.props.rows || {}), i = ((u = this.gridContainerRef.current) == null ? void 0 : u.clientWidth) || 0, { newRows: a, newSizes: l, moveDistance: c } = recalculateGridSizes({
71550
- position: r,
71551
- direction: "left",
71552
- resizeDistance: o,
71553
- prevMoveDistance: this.prevMoveDistance,
71554
- oldRows: this.props.rows || {},
71555
- oldSizes: this.props.sizes || {},
71556
- gutter: this.context.themeToken.marginBlock,
71557
- gridContainerWidth: i
71558
- });
71559
- this.prevMoveDistance = c, this.setProps("rows", a), this.setProps("sizes", l);
71703
+ const r = this.resizeGridLayout({ direction: "left", resizeDistance: o, model: n });
71704
+ r && (this.prevMoveDistance = r.moveDistance, this.syncLayoutProps(r.layout));
71560
71705
  }), this.emitter.on("onResizeRight", ({ resizeDistance: o, model: n }) => {
71561
- var u;
71562
- const r = findModelUidPosition(n.uid, this.props.rows || {}), i = ((u = this.gridContainerRef.current) == null ? void 0 : u.clientWidth) || 0, { newRows: a, newSizes: l, moveDistance: c } = recalculateGridSizes({
71563
- position: r,
71564
- direction: "right",
71565
- resizeDistance: o,
71566
- prevMoveDistance: this.prevMoveDistance,
71567
- oldRows: this.props.rows || {},
71568
- oldSizes: this.props.sizes || {},
71569
- gutter: this.context.themeToken.marginBlock,
71570
- gridContainerWidth: i
71571
- });
71572
- this.prevMoveDistance = c, this.setProps("rows", a), this.setProps("sizes", l);
71706
+ const r = this.resizeGridLayout({ direction: "right", resizeDistance: o, model: n });
71707
+ r && (this.prevMoveDistance = r.moveDistance, this.syncLayoutProps(r.layout));
71573
71708
  }), this.emitter.on("onResizeBottom", ({ resizeDistance: o, model: n }) => {
71574
71709
  }), this.emitter.on("onResizeEnd", () => {
71575
- this.prevMoveDistance = 0, this.saveGridLayout();
71710
+ this.prevMoveDistance = 0, this.saveGridLayout(this.props.layout);
71576
71711
  });
71577
71712
  }
71578
71713
  saveGridLayout(o) {
71579
- var c, u, d, p, m;
71580
- const n = (u = (c = o == null ? void 0 : o.rows) != null ? c : this.props.rows) != null ? u : {}, r = (d = o == null ? void 0 : o.rowOrder) != null ? d : this.props.rowOrder, { rows: i, rowOrder: a } = this.normalizeRowsWithOrder(n, r), l = this.orderSizesByRowOrder((m = (p = o == null ? void 0 : o.sizes) != null ? p : this.props.sizes) != null ? m : {}, a);
71581
- this.setStepParams(GRID_FLOW_KEY, GRID_STEP, {
71582
- rows: i,
71583
- sizes: l,
71584
- rowOrder: a
71585
- }), this.setProps("rowOrder", a), this.saveStepParams();
71714
+ const n = o && "version" in o ? normalizeGridLayout({ layout: o, itemUids: this.getItemUids(), gridUid: this.uid, logger: console }) : this.normalizeLayoutFromSource(o);
71715
+ this.setGridStepLayout(n), this.syncLayoutProps(n), this.saveStepParams();
71586
71716
  }
71587
71717
  mergeRowsWithItems(o) {
71588
71718
  const n = this.subModels.items || [];
@@ -71602,17 +71732,15 @@ class GridModel extends FlowModel {
71602
71732
  return a;
71603
71733
  }
71604
71734
  resetRows(o = !1) {
71605
- const n = this.getStepParams(GRID_FLOW_KEY, GRID_STEP) || {}, r = this.mergeRowsWithItems(n.rows || {}), { rows: i, rowOrder: a } = this.normalizeRowsWithOrder(r, n.rowOrder), l = this.orderSizesByRowOrder(n.sizes || {}, a);
71606
- this.setStepParams(GRID_FLOW_KEY, GRID_STEP, {
71607
- rows: i,
71608
- sizes: l,
71609
- rowOrder: a
71610
- }), o && (this.setProps("rows", i), this.setProps("sizes", l), this.setProps("rowOrder", a));
71735
+ const n = this.getStepParams(GRID_FLOW_KEY, GRID_STEP) || {}, r = this.normalizeLayoutFromSource(n);
71736
+ this.setGridStepLayout(r), o && this.syncLayoutProps(r);
71611
71737
  }
71612
71738
  computePointerPosition(o) {
71613
71739
  var a;
71614
71740
  if (!this.dragState)
71615
71741
  return null;
71742
+ if (this.dragState.pointerPosition)
71743
+ return this.dragState.pointerPosition;
71616
71744
  const n = this.dragState.pointerOrigin;
71617
71745
  if (n)
71618
71746
  return {
@@ -71644,42 +71772,60 @@ class GridModel extends FlowModel {
71644
71772
  this.dragState.slots = o.slots, this.dragState.containerRect = o.containerRect;
71645
71773
  }
71646
71774
  scheduleSnapshotRefresh() {
71647
- this.dragState && (this.dragState.refreshTimer && clearTimeout(this.dragState.refreshTimer), this.dragState.refreshTimer = setTimeout(() => {
71648
- this.dragState && (this.dragState.refreshTimer = null, this.updateLayoutSnapshot());
71649
- }, 16));
71775
+ this.dragState && (this.dragState.refreshTimer || (this.dragState.refreshTimer = setTimeout(() => {
71776
+ this.dragState && (this.dragState.refreshTimer = null, this.updateLayoutSnapshot(), this.refreshPreviewFromPointer());
71777
+ }, 16)));
71778
+ }
71779
+ refreshPreviewFromPointer() {
71780
+ if (!this.dragState)
71781
+ return;
71782
+ const o = this.dragState.pointerPosition || this.dragState.pointerOrigin;
71783
+ if (!o)
71784
+ return;
71785
+ const n = this.resolveDragSlot(o);
71786
+ this.applyPreview(n);
71650
71787
  }
71651
71788
  /**
71652
71789
  * 根据 slot 类型、位置和配置计算最终的 overlay 尺寸和位置
71653
71790
  */
71654
71791
  computeOverlayRect(o) {
71655
- var i, a, l, c, u, d, p, m, h;
71792
+ var i, a, l, c, u, d, p, m, h, g, f, y;
71656
71793
  const n = this.dragOverlayConfig, r = o.rect;
71657
71794
  switch (o.type) {
71658
71795
  case "column": {
71659
- const g = (i = n == null ? void 0 : n.columnInsert) == null ? void 0 : i[o.position], f = (a = g == null ? void 0 : g.height) != null ? a : r.height, y = (l = g == null ? void 0 : g.offsetTop) != null ? l : 0;
71796
+ const b = (i = n == null ? void 0 : n.columnInsert) == null ? void 0 : i[o.position], S = (a = b == null ? void 0 : b.height) != null ? a : r.height, C = (l = b == null ? void 0 : b.offsetTop) != null ? l : 0;
71660
71797
  return {
71661
- top: r.top + y,
71798
+ top: r.top + C,
71662
71799
  left: r.left,
71663
71800
  width: r.width,
71664
- height: f
71801
+ height: S
71665
71802
  };
71666
71803
  }
71667
71804
  case "column-edge": {
71668
- const g = (c = n == null ? void 0 : n.columnEdge) == null ? void 0 : c[o.direction], f = (u = g == null ? void 0 : g.width) != null ? u : r.width, y = (d = g == null ? void 0 : g.offsetLeft) != null ? d : 0;
71805
+ const b = (c = n == null ? void 0 : n.columnEdge) == null ? void 0 : c[o.direction], S = (u = b == null ? void 0 : b.width) != null ? u : r.width, C = (d = b == null ? void 0 : b.offsetLeft) != null ? d : 0;
71669
71806
  return {
71670
71807
  top: r.top,
71671
- left: r.left + y,
71672
- width: f,
71808
+ left: r.left + C,
71809
+ width: S,
71810
+ height: r.height
71811
+ };
71812
+ }
71813
+ case "item-edge": {
71814
+ const b = (p = n == null ? void 0 : n.columnEdge) == null ? void 0 : p[o.direction], S = (m = b == null ? void 0 : b.width) != null ? m : r.width, C = (h = b == null ? void 0 : b.offsetLeft) != null ? h : 0;
71815
+ return {
71816
+ top: r.top,
71817
+ left: r.left + C,
71818
+ width: S,
71673
71819
  height: r.height
71674
71820
  };
71675
71821
  }
71676
71822
  case "row-gap": {
71677
- const g = (p = n == null ? void 0 : n.rowGap) == null ? void 0 : p[o.position], f = (m = g == null ? void 0 : g.height) != null ? m : r.height, y = (h = g == null ? void 0 : g.offsetTop) != null ? h : 0;
71823
+ const b = (g = n == null ? void 0 : n.rowGap) == null ? void 0 : g[o.position], S = (f = b == null ? void 0 : b.height) != null ? f : r.height, C = (y = b == null ? void 0 : b.offsetTop) != null ? y : 0;
71678
71824
  return {
71679
- top: r.top + y,
71825
+ top: r.top + C,
71680
71826
  left: r.left,
71681
71827
  width: r.width,
71682
- height: f
71828
+ height: S
71683
71829
  };
71684
71830
  }
71685
71831
  case "empty-column":
@@ -71699,8 +71845,20 @@ class GridModel extends FlowModel {
71699
71845
  };
71700
71846
  }
71701
71847
  }
71848
+ getHitTestSlot(o) {
71849
+ return A(x({}, o), {
71850
+ // 命中区域与实际显示的 overlay 保持一致,避免鼠标仍在蓝框内时命中跳走
71851
+ rect: this.computeOverlayRect(o)
71852
+ });
71853
+ }
71854
+ resolveDragSlot(o) {
71855
+ var n;
71856
+ return (n = this.dragState) != null && n.slots.length ? resolveDropIntent(
71857
+ o,
71858
+ this.dragState.slots.map((r) => this.getHitTestSlot(r))
71859
+ ) : null;
71860
+ }
71702
71861
  applyPreview(o) {
71703
- var d, p;
71704
71862
  if (!this.dragState)
71705
71863
  return;
71706
71864
  if (!o) {
@@ -71714,40 +71872,49 @@ class GridModel extends FlowModel {
71714
71872
  slot: o,
71715
71873
  sourceUid: this.dragState.sourceUid,
71716
71874
  layout: this.dragState.snapshot,
71717
- generateRowId: uid
71875
+ generateRowId: uid,
71876
+ generatedIds: this.dragState.generatedIds,
71877
+ generateId: () => uid()
71718
71878
  });
71879
+ if (r.layout && this.dragState.snapshot.layout && isSameGridLayout(r.layout, this.dragState.snapshot.layout)) {
71880
+ this.applyPreview(null);
71881
+ return;
71882
+ }
71719
71883
  this.dragState.previewLayout = {
71720
71884
  rows: _.cloneDeep(r.rows),
71721
71885
  sizes: _.cloneDeep(r.sizes),
71722
- rowOrder: _.cloneDeep(r.rowOrder)
71886
+ rowOrder: _.cloneDeep(r.rowOrder),
71887
+ layout: _.cloneDeep(r.layout)
71723
71888
  };
71724
- const i = this.getDragContainer(), a = (d = i == null ? void 0 : i.scrollTop) != null ? d : 0, l = (p = i == null ? void 0 : i.scrollLeft) != null ? p : 0, c = this.computeOverlayRect(o), u = {
71725
- top: c.top - this.dragState.containerRect.top + a,
71726
- left: c.left - this.dragState.containerRect.left + l,
71727
- width: c.width,
71728
- height: c.height,
71889
+ const i = this.computeOverlayRect(o), a = {
71890
+ top: i.top - this.dragState.containerRect.top,
71891
+ left: i.left - this.dragState.containerRect.left,
71892
+ width: i.width,
71893
+ height: i.height,
71729
71894
  type: o.type
71730
71895
  };
71731
- this.setProps("dragOverlayRect", u), this.dragState.activeSlotKey = n;
71896
+ this.setProps("dragOverlayRect", a), this.dragState.activeSlotKey = n;
71732
71897
  }
71733
71898
  handleDragStart(o) {
71734
- var l;
71735
- const n = o.active.id, { rows: r, rowOrder: i } = this.normalizeRowsWithOrder(this.props.rows || {}, this.props.rowOrder), a = this.orderSizesByRowOrder(this.props.sizes || {}, i);
71899
+ var a;
71900
+ const n = o.active.id, r = this.normalizeLayoutFromSource(), i = projectLayoutToLegacyRows(r);
71736
71901
  this.dragState = {
71737
71902
  sourceUid: n,
71738
71903
  snapshot: {
71739
- rows: _.cloneDeep(r),
71740
- sizes: _.cloneDeep(a),
71741
- rowOrder: i
71904
+ rows: _.cloneDeep(i.rows),
71905
+ sizes: _.cloneDeep(i.sizes),
71906
+ rowOrder: _.cloneDeep(i.rowOrder),
71907
+ layout: _.cloneDeep(r)
71742
71908
  },
71743
71909
  slots: [],
71744
71910
  containerEl: this.gridContainerRef.current,
71745
71911
  containerRect: { top: 0, left: 0, width: 0, height: 0 },
71746
- pointerOrigin: (l = getClientPoint(o.activatorEvent)) != null ? l : void 0,
71912
+ pointerOrigin: (a = getClientPoint(o.activatorEvent)) != null ? a : void 0,
71747
71913
  activeSlotKey: null,
71748
71914
  previewLayout: void 0,
71749
- refreshTimer: null
71750
- }, this.setProps("dragOverlayRect", null), this.updateLayoutSnapshot(), this.scheduleSnapshotRefresh();
71915
+ refreshTimer: null,
71916
+ generatedIds: /* @__PURE__ */ new Map()
71917
+ }, this.dragState.cleanupListeners = this.bindDragDocumentListeners(), this.setProps("dragOverlayRect", null), this.updateLayoutSnapshot(), this.scheduleSnapshotRefresh();
71751
71918
  }
71752
71919
  handleDragMove(o) {
71753
71920
  if (!this.dragState)
@@ -71758,17 +71925,18 @@ class GridModel extends FlowModel {
71758
71925
  this.applyPreview(null);
71759
71926
  return;
71760
71927
  }
71761
- const r = resolveDropIntent(n, this.dragState.slots);
71928
+ const r = this.resolveDragSlot(n);
71762
71929
  this.applyPreview(r);
71763
71930
  }
71764
71931
  finishDrag() {
71765
- this.dragState && (this.dragState.refreshTimer && clearTimeout(this.dragState.refreshTimer), this.dragState = void 0, this.setProps("dragOverlayRect", null));
71932
+ var o, n;
71933
+ this.dragState && (this.dragState.refreshTimer && clearTimeout(this.dragState.refreshTimer), (n = (o = this.dragState).cleanupListeners) == null || n.call(o), this.dragState = void 0, this.setProps("dragOverlayRect", null));
71766
71934
  }
71767
71935
  handleDragEnd(o) {
71768
71936
  if (!this.dragState)
71769
71937
  return;
71770
71938
  const n = this.dragState.previewLayout;
71771
- n && (this.setProps("rows", _.cloneDeep(n.rows)), this.setProps("sizes", _.cloneDeep(n.sizes)), n.rowOrder && this.setProps("rowOrder", _.cloneDeep(n.rowOrder)), this.saveGridLayout(n)), this.finishDrag();
71939
+ n && (n.layout ? this.syncLayoutProps(_.cloneDeep(n.layout)) : (this.setProps("rows", _.cloneDeep(n.rows)), this.setProps("sizes", _.cloneDeep(n.sizes)), n.rowOrder && this.setProps("rowOrder", _.cloneDeep(n.rowOrder))), this.saveGridLayout(n)), this.finishDrag();
71772
71940
  }
71773
71941
  handleDragCancel(o) {
71774
71942
  this.finishDrag();
@@ -71783,32 +71951,52 @@ class GridModel extends FlowModel {
71783
71951
  */
71784
71952
  getVisibleLayout() {
71785
71953
  var h;
71786
- const o = this.props.rows || {}, n = this.props.sizes || {}, r = this.context.isMobileLayout ? transformRowsToSingleColumn(o) : o, i = this.context.isMobileLayout ? {} : n, { rows: a, rowOrder: l } = this.normalizeRowsWithOrder(r, this.props.rowOrder), c = this.orderSizesByRowOrder(i, l);
71954
+ const o = this.normalizeLayoutFromSource(), n = this.context.isMobileLayout ? normalizeGridLayout({
71955
+ rows: transformRowsToSingleColumn(projectLayoutToLegacyRows(o).rows),
71956
+ itemUids: this.getItemUids()
71957
+ }) : o, r = projectLayoutToLegacyRows(n), { rows: i, rowOrder: a } = this.normalizeRowsWithOrder(
71958
+ r.rows,
71959
+ r.rowOrder
71960
+ ), l = this.orderSizesByRowOrder(r.sizes, a);
71787
71961
  if (this.context.flowSettingsEnabled)
71788
- return { rows: a, sizes: c };
71789
- const u = ((h = this.subModels) == null ? void 0 : h.items) || [];
71790
- if (!u.length)
71791
- return { rows: r, sizes: i };
71792
- const d = new Map(u.map((g) => [g.uid, g])), p = {}, m = {};
71793
- return l.forEach((g) => {
71794
- const f = a[g], y = c[g] || [], b = [], S = [];
71795
- f.forEach((C, F) => {
71796
- C = C.filter((v) => {
71797
- var k;
71798
- return v === EMPTY_COLUMN_UID ? !1 : ((k = d.get(v)) == null ? void 0 : k.hidden) !== !0;
71799
- }), C.some((v) => {
71800
- if (v === EMPTY_COLUMN_UID)
71801
- return !1;
71802
- const k = d.get(v);
71803
- return !k || !k.hidden;
71804
- }) && (b.push(C), S.push(y[F]));
71805
- }), b.length > 0 && (p[g] = b, S.length > 0 && (m[g] = S));
71806
- }), { rows: p, sizes: m };
71962
+ return { layout: n, rows: i, sizes: l };
71963
+ const c = ((h = this.subModels) == null ? void 0 : h.items) || [];
71964
+ if (!c.length)
71965
+ return { layout: n, rows: r.rows, sizes: r.sizes };
71966
+ const u = new Map(c.map((g) => [g.uid, g])), d = (g) => g.map((f) => {
71967
+ const y = [], b = [];
71968
+ return f.cells.forEach((S, C) => {
71969
+ var I;
71970
+ const F = (I = f.sizes) == null ? void 0 : I[C], P = Number.isFinite(F) && F > 0 ? F : 1;
71971
+ if (S.rows) {
71972
+ const T = d(S.rows);
71973
+ T.length && (y.push(A(x({}, S), { rows: T })), b.push(P));
71974
+ return;
71975
+ }
71976
+ const v = (S.items || []).filter((T) => {
71977
+ var E;
71978
+ return T === EMPTY_COLUMN_UID ? !1 : ((E = u.get(T)) == null ? void 0 : E.hidden) !== !0;
71979
+ });
71980
+ v.some((T) => {
71981
+ const E = u.get(T);
71982
+ return !E || !E.hidden;
71983
+ }) && (y.push(A(x({}, S), { items: v })), b.push(P));
71984
+ }), y.length ? A(x({}, f), {
71985
+ cells: y,
71986
+ sizes: b
71987
+ }) : null;
71988
+ }).filter(Boolean), p = normalizeGridLayout({
71989
+ layout: {
71990
+ version: 2,
71991
+ rows: d(n.rows)
71992
+ }
71993
+ }), m = projectLayoutToLegacyRows(p);
71994
+ return { layout: p, rows: m.rows, sizes: m.sizes };
71807
71995
  }
71808
71996
  render() {
71809
- const { rows: o, sizes: n } = this.getVisibleLayout(), r = Object.keys(o || {}).length > 0;
71997
+ const { layout: o, rows: n, sizes: r } = this.getVisibleLayout(), i = Object.keys(n || {}).length > 0;
71810
71998
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
71811
- r && /* @__PURE__ */ jsx(
71999
+ i && /* @__PURE__ */ jsx(
71812
72000
  Space$1,
71813
72001
  {
71814
72002
  ref: this.gridContainerRef,
@@ -71827,51 +72015,52 @@ class GridModel extends FlowModel {
71827
72015
  {
71828
72016
  rowGap: this.props.rowGap,
71829
72017
  colGap: this.props.colGap,
71830
- rows: o,
71831
- sizes: n,
72018
+ layout: o,
72019
+ rows: n,
72020
+ sizes: r,
71832
72021
  dragOverlayRect: this.props.dragOverlayRect,
71833
- renderItem: (i) => {
71834
- var h, g, f, y, b, S;
71835
- const a = this.flowEngine.getModel(i);
71836
- if (!a)
72022
+ renderItem: (a) => {
72023
+ var g, f, y, b, S, C;
72024
+ const l = this.flowEngine.getModel(a);
72025
+ if (!l)
71837
72026
  return this.itemFallback;
71838
- const l = this.context.fieldKey, c = this.context.fieldIndex, u = this.context.getPropertyOptions("item"), d = (g = (h = this.context).getPropertyOptions) == null ? void 0 : g.call(h, "record"), p = (y = (f = this.context).getPropertyOptions) == null ? void 0 : y.call(f, "currentObject"), m = c == null ? a : (() => {
71839
- const C = a.createFork({}, `${l}:${i}`);
71840
- C.context.defineProperty("fieldIndex", {
72027
+ const c = this.context.fieldKey, u = this.context.fieldIndex, d = this.context.getPropertyOptions("item"), p = (f = (g = this.context).getPropertyOptions) == null ? void 0 : f.call(g, "record"), m = (b = (y = this.context).getPropertyOptions) == null ? void 0 : b.call(y, "currentObject"), h = u == null ? l : (() => {
72028
+ const F = l.createFork({}, `${c}:${a}`);
72029
+ F.context.defineProperty("fieldIndex", {
72030
+ get: () => u
72031
+ }), F.context.defineProperty("fieldKey", {
71841
72032
  get: () => c
71842
- }), C.context.defineProperty("fieldKey", {
71843
- get: () => l
71844
- }), C.context.defineProperty("record", {
72033
+ }), F.context.defineProperty("record", {
71845
72034
  get: () => this.context.record,
71846
72035
  cache: !1,
71847
- meta: d == null ? void 0 : d.meta,
71848
- resolveOnServer: d == null ? void 0 : d.resolveOnServer,
71849
- serverOnlyWhenContextParams: d == null ? void 0 : d.serverOnlyWhenContextParams
71850
- }), C.context.defineProperty("currentObject", {
72036
+ meta: p == null ? void 0 : p.meta,
72037
+ resolveOnServer: p == null ? void 0 : p.resolveOnServer,
72038
+ serverOnlyWhenContextParams: p == null ? void 0 : p.serverOnlyWhenContextParams
72039
+ }), F.context.defineProperty("currentObject", {
71851
72040
  get: () => this.context.currentObject,
71852
72041
  cache: !1,
71853
72042
  // meta: currentObjectOptions?.meta,
71854
- resolveOnServer: p == null ? void 0 : p.resolveOnServer,
71855
- serverOnlyWhenContextParams: p == null ? void 0 : p.serverOnlyWhenContextParams
72043
+ resolveOnServer: m == null ? void 0 : m.resolveOnServer,
72044
+ serverOnlyWhenContextParams: m == null ? void 0 : m.serverOnlyWhenContextParams
71856
72045
  });
71857
- const v = u || {}, { value: F } = v, P = te(v, ["value"]);
71858
- return C.context.defineProperty("item", A(x({}, P), {
72046
+ const k = d || {}, { value: P } = k, v = te(k, ["value"]);
72047
+ return F.context.defineProperty("item", A(x({}, v), {
71859
72048
  get: () => this.context.item,
71860
72049
  cache: !1
71861
- })), C;
72050
+ })), F;
71862
72051
  })();
71863
- return /* @__PURE__ */ jsx(Droppable, { model: m, children: /* @__PURE__ */ jsx(
72052
+ return /* @__PURE__ */ jsx(Droppable, { model: h, children: /* @__PURE__ */ jsx(
71864
72053
  MemoFlowModelRenderer,
71865
72054
  {
71866
- model: m,
71867
- fallback: a.skeleton || this.itemFallback,
72055
+ model: h,
72056
+ fallback: l.skeleton || this.itemFallback,
71868
72057
  showFlowSettings: this.context.flowSettingsEnabled ? this.getItemFlowSettings() : !1,
71869
72058
  showErrorFallback: !0,
71870
- settingsMenuLevel: (b = m == null ? void 0 : m.settingsMenuLevel) != null ? b : this.itemSettingsMenuLevel,
72059
+ settingsMenuLevel: (S = h == null ? void 0 : h.settingsMenuLevel) != null ? S : this.itemSettingsMenuLevel,
71871
72060
  showTitle: !0,
71872
72061
  extraToolbarItems: this.itemExtraToolbarItems
71873
72062
  },
71874
- `${m.uid}:${l}:${(m == null ? void 0 : m.use) || ((S = m == null ? void 0 : m.constructor) == null ? void 0 : S.name) || "m"}`
72063
+ `${h.uid}:${c}:${(h == null ? void 0 : h.use) || ((C = h == null ? void 0 : h.constructor) == null ? void 0 : C.name) || "m"}`
71875
72064
  ) });
71876
72065
  }
71877
72066
  }
@@ -71894,31 +72083,28 @@ GridModel.registerFlow({
71894
72083
  },
71895
72084
  grid: {
71896
72085
  uiSchema: {
71897
- rows: {
71898
- title: tExpr("Rows"),
72086
+ layout: {
72087
+ title: tExpr("Layout"),
71899
72088
  "x-decorator": "FormItem",
71900
72089
  "x-component": JsonEditor,
71901
72090
  "x-component-props": {
71902
72091
  autoSize: { minRows: 10, maxRows: 20 },
71903
- description: tExpr("Configure the rows and columns of the grid.")
72092
+ description: tExpr("Configure the nested layout of the grid.")
71904
72093
  }
71905
- },
71906
- sizes: {
71907
- title: tExpr("Sizes"),
71908
- "x-decorator": "FormItem",
71909
- "x-component": JsonEditor,
71910
- "x-component-props": {
71911
- rows: 5
71912
- },
71913
- description: tExpr(
71914
- "Configure the sizes of each row. The value is an array of numbers representing the width of each column in the row."
71915
- )
71916
72094
  }
71917
72095
  },
71918
72096
  handler(e, t) {
71919
72097
  return L(this, null, function* () {
71920
- const o = e.model.mergeRowsWithItems(t.rows || {}), { rows: n, rowOrder: r } = e.model.normalizeRowsWithOrder(o, t.rowOrder), i = e.model.orderSizesByRowOrder(t.sizes || {}, r);
71921
- e.model.setProps("rows", n), e.model.setProps("sizes", i), e.model.setProps("rowOrder", r);
72098
+ const o = e.model, n = normalizeGridLayout({
72099
+ layout: t.layout,
72100
+ rows: t.rows,
72101
+ sizes: t.sizes,
72102
+ rowOrder: t.rowOrder,
72103
+ itemUids: o.getItemUids(),
72104
+ gridUid: o.uid,
72105
+ logger: console
72106
+ });
72107
+ o.setGridStepLayout(n), o.syncLayoutProps(n);
71922
72108
  });
71923
72109
  }
71924
72110
  }
@@ -72036,8 +72222,8 @@ class BlockGridModel extends GridModel {
72036
72222
  R(this, "dragOverlayConfig", {
72037
72223
  // 列内插入
72038
72224
  columnInsert: {
72039
- before: { offsetTop: -24 },
72040
- after: { offsetTop: 24 }
72225
+ before: { offsetTop: -12 },
72226
+ after: { offsetTop: 12 }
72041
72227
  },
72042
72228
  // 列边缘
72043
72229
  columnEdge: {
@@ -72091,7 +72277,7 @@ BlockGridModel.registerFlow({
72091
72277
  }
72092
72278
  });
72093
72279
  const parseMarkdown = _.memoize((e) => L(void 0, null, function* () {
72094
- return e && (yield import("./md-BbvRKckr.mjs")).default.render(e);
72280
+ return e && (yield import("./md-oH2RssNY.mjs")).default.render(e);
72095
72281
  }));
72096
72282
  function useParseMarkdown(e) {
72097
72283
  const [t, o] = useState(""), [n, r] = useState(!0);
@@ -74900,14 +75086,14 @@ const FieldAssignValueInput = ({
74900
75086
  ), f = React.useMemo(() => {
74901
75087
  var pe, he, ye, Ce, me, ae, ce, ge, xe, Se, ke, Ie, be, we, je, Ee, ve, Fe;
74902
75088
  if (h) {
74903
- const Me = h, Pe = h.context, { collection: Oe, dataSource: _e, blockModel: Le } = Pe, Re = ((pe = h == null ? void 0 : h.getStepParams) == null ? void 0 : pe.call(h, "fieldSettings", "init")) || {}, Ae = ((he = h == null ? void 0 : h.context) == null ? void 0 : he.dataSourceManager) || ((Ce = (ye = d.model) == null ? void 0 : ye.context) == null ? void 0 : Ce.dataSourceManager), ze = getCollectionFromModel(d.model), De = Oe || (Re != null && Re.dataSourceKey && (Re != null && Re.collectionName) ? (me = Ae == null ? void 0 : Ae.getCollection) == null ? void 0 : me.call(Ae, Re.dataSourceKey, Re.collectionName) : void 0) || ze, qe = _e || (Re != null && Re.dataSourceKey ? (ae = Ae == null ? void 0 : Ae.getDataSource) == null ? void 0 : ae.call(Ae, Re.dataSourceKey) : void 0) || (De != null && De.dataSourceKey ? (ce = Ae == null ? void 0 : Ae.getDataSource) == null ? void 0 : ce.call(Ae, De.dataSourceKey) : void 0), Te = resolveAssignValueFieldPath(h), Ve = Te == null ? void 0 : Te.split(".").slice(-1)[0], Ue = Ve ? (ge = De == null ? void 0 : De.getField) == null ? void 0 : ge.call(De, Ve) : void 0, Ke = (Se = (xe = Me == null ? void 0 : Me.customFieldModelInstance) == null ? void 0 : xe.context) == null ? void 0 : Se.collectionField;
75089
+ const Me = h, Pe = h.context, { collection: Oe, dataSource: Ve, blockModel: Le } = Pe, Re = ((pe = h == null ? void 0 : h.getStepParams) == null ? void 0 : pe.call(h, "fieldSettings", "init")) || {}, Ae = ((he = h == null ? void 0 : h.context) == null ? void 0 : he.dataSourceManager) || ((Ce = (ye = d.model) == null ? void 0 : ye.context) == null ? void 0 : Ce.dataSourceManager), ze = getCollectionFromModel(d.model), De = Oe || (Re != null && Re.dataSourceKey && (Re != null && Re.collectionName) ? (me = Ae == null ? void 0 : Ae.getCollection) == null ? void 0 : me.call(Ae, Re.dataSourceKey, Re.collectionName) : void 0) || ze, qe = Ve || (Re != null && Re.dataSourceKey ? (ae = Ae == null ? void 0 : Ae.getDataSource) == null ? void 0 : ae.call(Ae, Re.dataSourceKey) : void 0) || (De != null && De.dataSourceKey ? (ce = Ae == null ? void 0 : Ae.getDataSource) == null ? void 0 : ce.call(Ae, De.dataSourceKey) : void 0), Te = resolveAssignValueFieldPath(h), _e = Te == null ? void 0 : Te.split(".").slice(-1)[0], Ue = _e ? (ge = De == null ? void 0 : De.getField) == null ? void 0 : ge.call(De, _e) : void 0, Ke = (Se = (xe = Me == null ? void 0 : Me.customFieldModelInstance) == null ? void 0 : xe.context) == null ? void 0 : Se.collectionField;
74904
75090
  return {
74905
75091
  itemModel: h,
74906
75092
  collection: De || null,
74907
75093
  dataSource: qe || null,
74908
75094
  blockModel: Le,
74909
75095
  fieldPath: Te || null,
74910
- fieldName: Ve || null,
75096
+ fieldName: _e || null,
74911
75097
  collectionField: Ue || Ke || null
74912
75098
  };
74913
75099
  }
@@ -74996,13 +75182,13 @@ const FieldAssignValueInput = ({
74996
75182
  [N, i]
74997
75183
  ), [V, z] = React.useState(null);
74998
75184
  React.useEffect(() => {
74999
- var Pe, Oe, _e, Le, Re, Ae, ze, De, qe, Te, Ve, Ue, Ke, nt, We, it, Ye, at, Je, lt, ct, ut, dt, pt, mt, ht, gt, ft, xt, yt, bt, St, Ct, vt, Ft, Pt, kt, It;
75185
+ var Pe, Oe, Ve, Le, Re, Ae, ze, De, qe, Te, _e, Ue, Ke, nt, We, it, Ye, at, Je, lt, ct, ut, dt, pt, mt, ht, gt, ft, xt, yt, bt, St, Ct, vt, Ft, Pt, kt, It;
75000
75186
  if (!C || !F)
75001
75187
  return;
75002
- const Y = h, X = ((Oe = (Pe = f == null ? void 0 : f.itemModel) == null ? void 0 : Pe.context) == null ? void 0 : Oe.engine) || ((Le = (_e = d.model) == null ? void 0 : _e.context) == null ? void 0 : Le.engine);
75188
+ const Y = h, X = ((Oe = (Pe = f == null ? void 0 : f.itemModel) == null ? void 0 : Pe.context) == null ? void 0 : Oe.engine) || ((Le = (Ve = d.model) == null ? void 0 : Ve.context) == null ? void 0 : Le.engine);
75003
75189
  if (!X)
75004
75190
  return;
75005
- const se = ((Re = Y == null ? void 0 : Y.context) == null ? void 0 : Re.dataSourceManager) || ((ze = (Ae = d.model) == null ? void 0 : Ae.context) == null ? void 0 : ze.dataSourceManager), re = y || getCollectionFromModel(Y) || getCollectionFromModel(d.model), { customFieldName: le, customFieldProps: ue, currentAllowMultiple: ie, originFieldModel: de, originProps: fe } = k, pe = (De = de == null ? void 0 : de.context) == null ? void 0 : De.collectionField, he = P || pe || void 0, ye = b || (re != null && re.dataSourceKey ? (qe = se == null ? void 0 : se.getDataSource) == null ? void 0 : qe.call(se, re.dataSourceKey) : null), me = (typeof (re == null ? void 0 : re.getFields) == "function" ? re.getFields() || [] : []).find((Be) => (Be == null ? void 0 : Be.name) === F) || (typeof (re == null ? void 0 : re.getField) == "function" ? re.getField(F) : void 0) || he, ae = me ? EditableItemModel.getDefaultBindingByField(((Te = f == null ? void 0 : f.itemModel) == null ? void 0 : Te.context) || ((Ve = d.model) == null ? void 0 : Ve.context), me) : null, ce = ae == null ? void 0 : ae.modelName, ge = resolveAssignValueFieldSettingsInit({
75191
+ const se = ((Re = Y == null ? void 0 : Y.context) == null ? void 0 : Re.dataSourceManager) || ((ze = (Ae = d.model) == null ? void 0 : Ae.context) == null ? void 0 : ze.dataSourceManager), re = y || getCollectionFromModel(Y) || getCollectionFromModel(d.model), { customFieldName: le, customFieldProps: ue, currentAllowMultiple: ie, originFieldModel: de, originProps: fe } = k, pe = (De = de == null ? void 0 : de.context) == null ? void 0 : De.collectionField, he = P || pe || void 0, ye = b || (re != null && re.dataSourceKey ? (qe = se == null ? void 0 : se.getDataSource) == null ? void 0 : qe.call(se, re.dataSourceKey) : null), me = (typeof (re == null ? void 0 : re.getFields) == "function" ? re.getFields() || [] : []).find((Be) => (Be == null ? void 0 : Be.name) === F) || (typeof (re == null ? void 0 : re.getField) == "function" ? re.getField(F) : void 0) || he, ae = me ? EditableItemModel.getDefaultBindingByField(((Te = f == null ? void 0 : f.itemModel) == null ? void 0 : Te.context) || ((_e = d.model) == null ? void 0 : _e.context), me) : null, ce = ae == null ? void 0 : ae.modelName, ge = resolveAssignValueFieldSettingsInit({
75006
75192
  collection: re,
75007
75193
  customFieldName: le,
75008
75194
  fieldPath: C,
@@ -75581,7 +75767,31 @@ const LinkageFilterItem = observer((e) => {
75581
75767
  }
75582
75768
  )
75583
75769
  ] });
75584
- }), dataScope = defineAction({
75770
+ }), PRESERVE_NULL = { __nocobaseDataScopeNull__: !0 };
75771
+ function isPreserveNull(e) {
75772
+ return e && typeof e == "object" && !Array.isArray(e) && e.__nocobaseDataScopeNull__ === !0 && Object.keys(e).length === 1;
75773
+ }
75774
+ function restorePreservedNull(e) {
75775
+ return isPreserveNull(e) ? null : Array.isArray(e) ? e.map((t) => restorePreservedNull(t)) : e && typeof e == "object" ? Object.keys(e).reduce((t, o) => (t[o] = restorePreservedNull(e[o]), t), {}) : e;
75776
+ }
75777
+ function markEmptyVariableValues(e, t) {
75778
+ if (!(!e || !t || typeof e != "object" || typeof t != "object")) {
75779
+ if ("path" in e && "operator" in e) {
75780
+ isVariableExpression(e.value) && (t.value === void 0 || t.value === null || t.value === "") && (t.value = PRESERVE_NULL);
75781
+ return;
75782
+ }
75783
+ Array.isArray(e.items) && Array.isArray(t.items) && e.items.forEach((o, n) => {
75784
+ markEmptyVariableValues(o, t.items[n]);
75785
+ });
75786
+ }
75787
+ }
75788
+ function normalizeDataScopeFilter(e, t) {
75789
+ const o = _.cloneDeep(t);
75790
+ markEmptyVariableValues(e, o);
75791
+ const n = pruneFilter(transformFilter(o));
75792
+ return restorePreservedNull(n);
75793
+ }
75794
+ const dataScope = defineAction({
75585
75795
  name: "dataScope",
75586
75796
  title: tExpr("Data scope"),
75587
75797
  uiMode: {
@@ -75611,14 +75821,15 @@ const LinkageFilterItem = observer((e) => {
75611
75821
  filter: { logic: "$and", items: [] }
75612
75822
  };
75613
75823
  },
75824
+ useRawParams: !0,
75614
75825
  handler(e, t) {
75615
75826
  return L(this, null, function* () {
75616
- var r;
75617
- const o = (r = e.model) == null ? void 0 : r.resource;
75827
+ var i;
75828
+ const o = (i = e.model) == null ? void 0 : i.resource;
75618
75829
  if (!o)
75619
75830
  return;
75620
- const n = pruneFilter(transformFilter(t.filter));
75621
- isEmptyFilter(n) ? o.removeFilterGroup(e.model.uid) : o.addFilterGroup(e.model.uid, n);
75831
+ const n = yield e.resolveJsonTemplate(t.filter), r = normalizeDataScopeFilter(t.filter, n);
75832
+ isEmptyFilter(r) ? o.removeFilterGroup(e.model.uid) : o.addFilterGroup(e.model.uid, r);
75622
75833
  });
75623
75834
  }
75624
75835
  });
@@ -79690,8 +79901,8 @@ class FormGridModel extends GridModel {
79690
79901
  R(this, "dragOverlayConfig", {
79691
79902
  // 列内插入
79692
79903
  columnInsert: {
79693
- before: { offsetTop: -12, height: 24 },
79694
- after: { offsetTop: 7, height: 24 }
79904
+ before: { offsetTop: -6, height: 24 },
79905
+ after: { offsetTop: 3, height: 24 }
79695
79906
  },
79696
79907
  // 列边缘
79697
79908
  columnEdge: {
@@ -79700,8 +79911,8 @@ class FormGridModel extends GridModel {
79700
79911
  },
79701
79912
  // 行间隙
79702
79913
  rowGap: {
79703
- above: { offsetTop: 0, height: 24 },
79704
- below: { offsetTop: -14, height: 24 }
79914
+ above: { offsetTop: -2, height: 24 },
79915
+ below: { offsetTop: -12, height: 24 }
79705
79916
  }
79706
79917
  });
79707
79918
  }
@@ -81554,8 +81765,8 @@ class DetailsGridModel extends GridModel {
81554
81765
  R(this, "dragOverlayConfig", {
81555
81766
  // 列内插入
81556
81767
  columnInsert: {
81557
- before: { offsetTop: -12, height: 24 },
81558
- after: { offsetTop: 7, height: 24 }
81768
+ before: { offsetTop: -6, height: 24 },
81769
+ after: { offsetTop: 3, height: 24 }
81559
81770
  },
81560
81771
  // 列边缘
81561
81772
  columnEdge: {
@@ -81564,8 +81775,8 @@ class DetailsGridModel extends GridModel {
81564
81775
  },
81565
81776
  // 行间隙
81566
81777
  rowGap: {
81567
- above: { offsetTop: 0, height: 24 },
81568
- below: { offsetTop: -14, height: 24 }
81778
+ above: { offsetTop: -2, height: 24 },
81779
+ below: { offsetTop: -12, height: 24 }
81569
81780
  }
81570
81781
  });
81571
81782
  }
@@ -84444,7 +84655,7 @@ const CustomWidth = ({ setOpen: e, t, handleChange: o, defaultValue: n }) => {
84444
84655
  get: () => (o == null ? void 0 : o.__index) || n
84445
84656
  });
84446
84657
  const c = this.context.prefixFieldPath ? this.fieldPath.replace(`${this.context.prefixFieldPath}.`, "") : this.fieldPath, u = get(o, c);
84447
- return /* @__PURE__ */ jsx(FormItem$2, A(x({}, omit(this.props, "title")), { value: u, noStyle: !0, children: /* @__PURE__ */ jsx(FieldModelRenderer, { model: a }) }), r.uid);
84658
+ return a.setProps({ value: u }), /* @__PURE__ */ jsx(FormItem$2, A(x({}, omit(this.props, "title")), { value: u, noStyle: !0, children: /* @__PURE__ */ jsx(FieldModelRenderer, { model: a }) }), r.uid);
84448
84659
  }) });
84449
84660
  }
84450
84661
  };
@@ -90237,9 +90448,11 @@ const He = class He extends FilterBlockModel {
90237
90448
  const o = this.context.blockGridModel;
90238
90449
  if (o != null && o.emitter) {
90239
90450
  const n = (r) => {
90240
- !(r != null && r.uid) || r.uid === this.uid || this.handleTargetBlockRemoved(r.uid);
90451
+ !(r != null && r.uid) || r.uid === this.uid || this.handleTargetBlockRemoved(r.uid).catch((i) => {
90452
+ console.error("Failed to handle destroyed target block in FilterFormBlockModel:", i);
90453
+ });
90241
90454
  };
90242
- o.emitter.on("onSubModelRemoved", n), this.removeTargetBlockListener = () => o.emitter.off("onSubModelRemoved", n);
90455
+ o.emitter.on("onSubModelDestroyed", n), this.removeTargetBlockListener = () => o.emitter.off("onSubModelDestroyed", n);
90243
90456
  }
90244
90457
  }
90245
90458
  onUnmount() {
@@ -91040,6 +91253,7 @@ FilterFormItemModel.registerFlow({
91040
91253
  class FilterFormGridModel extends GridModel {
91041
91254
  constructor() {
91042
91255
  super(...arguments);
91256
+ R(this, "fullLayoutBeforeCollapse");
91043
91257
  R(this, "itemSettingsMenuLevel", 2);
91044
91258
  R(this, "itemFlowSettings", {
91045
91259
  showBackground: !0,
@@ -91053,8 +91267,8 @@ class FilterFormGridModel extends GridModel {
91053
91267
  R(this, "dragOverlayConfig", {
91054
91268
  // 列内插入
91055
91269
  columnInsert: {
91056
- before: { offsetTop: -12, height: 24 },
91057
- after: { offsetTop: 7, height: 24 }
91270
+ before: { offsetTop: -6, height: 24 },
91271
+ after: { offsetTop: 3, height: 24 }
91058
91272
  },
91059
91273
  // 列边缘
91060
91274
  columnEdge: {
@@ -91063,8 +91277,8 @@ class FilterFormGridModel extends GridModel {
91063
91277
  },
91064
91278
  // 行间隙
91065
91279
  rowGap: {
91066
- above: { offsetTop: 0, height: 24 },
91067
- below: { offsetTop: -14, height: 24 }
91280
+ above: { offsetTop: -2, height: 24 },
91281
+ below: { offsetTop: -12, height: 24 }
91068
91282
  }
91069
91283
  });
91070
91284
  R(this, "loading", observable$1.ref(!1));
@@ -91080,11 +91294,13 @@ class FilterFormGridModel extends GridModel {
91080
91294
  * 避免拖拽排序或重新挂载后只拿到被裁剪过的运行时 rows。
91081
91295
  */
91082
91296
  getFullLayout() {
91083
- const o = this.getStepParams(GRID_FLOW_KEY, GRID_STEP) || {}, n = this.props.rows || {}, r = o.rows || {}, i = Object.keys(n).length, a = Object.keys(r).length, l = (h) => Object.values(h).reduce(
91084
- (g, f) => g + f.reduce((y, b) => y + b.length, 0),
91297
+ const o = this.getStepParams(GRID_FLOW_KEY, GRID_STEP) || {}, n = this.props.layout ? this.getGridLayout() : void 0, r = o.layout ? this.normalizeLayoutFromSource(o) : void 0, i = n ? projectLayoutToLegacyRows(n) : { rows: this.props.rows || {}, rowOrder: this.props.rowOrder }, a = r ? projectLayoutToLegacyRows(r) : { rows: o.rows || {}, rowOrder: o.rowOrder }, l = i.rows, c = a.rows || {}, u = Object.keys(l).length, d = Object.keys(c).length, p = (b) => Object.values(b).reduce(
91298
+ (S, C) => S + C.reduce((F, P) => F + P.length, 0),
91085
91299
  0
91086
- ), c = l(n), u = l(r), d = i > a || i === a && c >= u, p = this.mergeRowsWithItems(d ? n : r), m = d ? this.props.rowOrder || o.rowOrder : o.rowOrder || this.props.rowOrder;
91087
- return this.normalizeRowsWithOrder(p, m);
91300
+ ), m = p(l), h = p(c), g = u > d || u === d && m >= h, f = this.mergeRowsWithItems(g ? l : c), y = g ? i.rowOrder || this.props.rowOrder || o.rowOrder : a.rowOrder || o.rowOrder || this.props.rowOrder;
91301
+ return A(x({}, this.normalizeRowsWithOrder(f, y)), {
91302
+ layout: g ? n : r
91303
+ });
91088
91304
  }
91089
91305
  /**
91090
91306
  * 按“可视字段行数”裁剪布局,而不是只按 grid row 数裁剪。
@@ -91101,13 +91317,22 @@ class FilterFormGridModel extends GridModel {
91101
91317
  }), i;
91102
91318
  }
91103
91319
  toggleFormFieldsCollapse(o, n) {
91104
- const { rows: r, rowOrder: i } = this.getFullLayout();
91320
+ const { rows: r, rowOrder: i, layout: a } = this.getFullLayout();
91105
91321
  if (!o) {
91106
- this.setProps("rows", r), this.setProps("rowOrder", i);
91322
+ const u = this.fullLayoutBeforeCollapse || a;
91323
+ u ? this.syncLayoutProps(u) : (this.setProps("rows", r), this.setProps("rowOrder", i)), this.fullLayoutBeforeCollapse = void 0;
91107
91324
  return;
91108
91325
  }
91109
- const a = this.limitRowsByVisibleCount(r, i, n);
91110
- this.setProps("rows", a), this.setProps("rowOrder", i);
91326
+ this.fullLayoutBeforeCollapse || (this.fullLayoutBeforeCollapse = a || normalizeGridLayout({
91327
+ rows: r,
91328
+ rowOrder: i,
91329
+ itemUids: this.getItemUids()
91330
+ }));
91331
+ const l = this.limitRowsByVisibleCount(r, i, n), c = normalizeGridLayout({
91332
+ rows: l,
91333
+ rowOrder: i
91334
+ });
91335
+ this.syncLayoutProps(c), this.setProps("rowOrder", i);
91111
91336
  }
91112
91337
  onModelCreated(o) {
91113
91338
  return L(this, null, function* () {
@@ -92313,7 +92538,13 @@ class TableBlockModel extends CollectionBlockModel {
92313
92538
  onSuccess: (y) => {
92314
92539
  var F;
92315
92540
  const b = this.collection.getField(u);
92316
- l[u] = y[u], setNestedValue(this.resource.getData(), c, l);
92541
+ if (l[u] = y[u], typeof c == "number")
92542
+ this.resource.setItem(c, l);
92543
+ else {
92544
+ const P = _.cloneDeep(this.resource.getData());
92545
+ setNestedValue(P, c, l), this.resource.setData(P);
92546
+ }
92547
+ this.resource.emit("refresh");
92317
92548
  const S = p.subModels.field.createFork({}, `${c}`), C = createCurrentRecordMetaFactory(
92318
92549
  S.context,
92319
92550
  () => S.context.collection
@@ -92982,6 +93213,23 @@ TableJSFieldItemModel.define({
92982
93213
  // 提高排序到“字段类”列表的靠前位置,但不抢默认项
92983
93214
  sort: 110
92984
93215
  });
93216
+ function getRecordRenderSignature(e) {
93217
+ if (!e || typeof e != "object")
93218
+ return String(e);
93219
+ try {
93220
+ const t = /* @__PURE__ */ new WeakSet();
93221
+ return JSON.stringify(e, (o, n) => {
93222
+ if (n && typeof n == "object") {
93223
+ if (t.has(n))
93224
+ return "[Circular]";
93225
+ t.add(n);
93226
+ }
93227
+ return n;
93228
+ });
93229
+ } catch (t) {
93230
+ return String(e);
93231
+ }
93232
+ }
92985
93233
  class JSColumnModel extends TableCustomColumnModel {
92986
93234
  constructor() {
92987
93235
  super(...arguments);
@@ -93045,28 +93293,30 @@ class JSColumnModel extends TableCustomColumnModel {
93045
93293
  /* @__PURE__ */ jsx(Tooltip, { title: this.props.tooltip, children: /* @__PURE__ */ jsx(QuestionCircleOutlined, { style: { cursor: "pointer" } }) })
93046
93294
  ] }) : r,
93047
93295
  render: (i, a, l) => {
93048
- var m, h, g;
93049
- const c = (h = (m = this.context.collection) == null ? void 0 : m.getFilterByTK) == null ? void 0 : h.call(m, a), u = (g = c != null ? c : a == null ? void 0 : a.id) != null ? g : l, d = this.createFork({}, String(u)), p = createRecordMetaFactory(
93050
- () => d.context.collection,
93051
- d.context.t("Current record"),
93052
- (f) => {
93053
- var C, F, P, v;
93054
- const y = (C = f.collection) == null ? void 0 : C.name, b = (F = f.collection) == null ? void 0 : F.dataSourceKey, S = (v = (P = f.collection) == null ? void 0 : P.getFilterByTK) == null ? void 0 : v.call(P, f.record);
93055
- if (!(!y || typeof S == "undefined" || S === null))
93056
- return { collection: y, dataSourceKey: b, filterByTk: S };
93296
+ var g, f, y;
93297
+ const c = (f = (g = this.context.collection) == null ? void 0 : g.getFilterByTK) == null ? void 0 : f.call(g, a), u = (y = c != null ? c : a == null ? void 0 : a.id) != null ? y : l, d = getRecordRenderSignature(a), p = this.createFork({}, String(u));
93298
+ p.__recordRenderSignature !== d && (p.__recordRenderSignature = d, p.invalidateFlowCache("beforeRender"));
93299
+ const h = createRecordMetaFactory(
93300
+ () => p.context.collection,
93301
+ p.context.t("Current record"),
93302
+ (b) => {
93303
+ var P, v, k, I;
93304
+ const S = (P = b.collection) == null ? void 0 : P.name, C = (v = b.collection) == null ? void 0 : v.dataSourceKey, F = (I = (k = b.collection) == null ? void 0 : k.getFilterByTK) == null ? void 0 : I.call(k, b.record);
93305
+ if (!(!S || typeof F == "undefined" || F === null))
93306
+ return { collection: S, dataSourceKey: C, filterByTk: F };
93057
93307
  }
93058
93308
  );
93059
- return d.context.defineProperty("record", {
93309
+ return p.context.defineProperty("record", {
93060
93310
  get: () => a,
93061
93311
  cache: !1,
93062
93312
  resolveOnServer: createRecordResolveOnServerWithLocal(
93063
- () => d.context.collection,
93313
+ () => p.context.collection,
93064
93314
  () => a
93065
93315
  ),
93066
- meta: p
93067
- }), d.context.defineProperty("recordIndex", {
93316
+ meta: h
93317
+ }), p.context.defineProperty("recordIndex", {
93068
93318
  get: () => l
93069
- }), /* @__PURE__ */ jsx(MemoFlowModelRenderer, { model: d }, d.uid);
93319
+ }), /* @__PURE__ */ jsx(MemoFlowModelRenderer, { model: p }, `${p.uid}:${d}`);
93070
93320
  }
93071
93321
  });
93072
93322
  }
@@ -93169,7 +93419,11 @@ JSColumnModel.registerFlow({
93169
93419
  }
93170
93420
  e.onRefReady(e.ref, (u) => L(this, null, function* () {
93171
93421
  e.defineProperty("element", {
93172
- get: () => new ElementProxy(u)
93422
+ get: () => {
93423
+ var p;
93424
+ return new ElementProxy(((p = e.ref) == null ? void 0 : p.current) || u);
93425
+ },
93426
+ cache: !1
93173
93427
  });
93174
93428
  const d = createSafeNavigator();
93175
93429
  yield e.runjs(
@@ -94699,8 +94953,11 @@ class JSFieldModel extends FieldModel {
94699
94953
  constructor() {
94700
94954
  super(...arguments);
94701
94955
  R(this, "_mountedOnce", !1);
94956
+ // prevent first-mount double-run
94957
+ R(this, "_lastRenderedElement");
94958
+ R(this, "_pendingRenderedElement");
94959
+ R(this, "_lastRunJs");
94702
94960
  }
94703
- // prevent first-mount double-run
94704
94961
  getInputArgs() {
94705
94962
  var n, r, i, a, l, c;
94706
94963
  const o = this.context.collectionField;
@@ -94723,18 +94980,41 @@ class JSFieldModel extends FieldModel {
94723
94980
  * 说明:fork 实例在表格逐行渲染时会复用该逻辑,确保按值更新。
94724
94981
  */
94725
94982
  useHooksBeforeRender() {
94726
- var r;
94727
- const o = (r = this.getStepParams("jsSettings", "runJs")) == null ? void 0 : r.code, n = useRef(null);
94983
+ var n;
94984
+ const o = (n = this.getStepParams("jsSettings", "runJs")) == null ? void 0 : n.code;
94728
94985
  useEffect(() => {
94729
- const i = this.props.value, a = (typeof o == "string" && o.trim().length ? o : DEFAULT_CODE$1).trim(), l = n.current;
94730
- l && l.code === a && l.value === i || (n.current = { code: a, value: i }, this.applyFlow("jsSettings"));
94986
+ var r;
94987
+ this.refreshRenderedElement((r = this.context.ref) == null ? void 0 : r.current);
94731
94988
  }, [o, this.props.value]);
94732
94989
  }
94733
94990
  /**
94734
94991
  * 渲染一个占位容器,供 JS 脚本写入内容
94735
94992
  */
94993
+ getRunJsCode() {
94994
+ var n;
94995
+ const o = (n = this.getStepParams("jsSettings", "runJs")) == null ? void 0 : n.code;
94996
+ return (typeof o == "string" && o.trim().length ? o : DEFAULT_CODE$1).trim();
94997
+ }
94998
+ refreshRenderedElement(o) {
94999
+ if (!o || this._pendingRenderedElement === o)
95000
+ return;
95001
+ this._pendingRenderedElement = o;
95002
+ const n = this.context.ref;
95003
+ queueMicrotask(() => {
95004
+ if (this._pendingRenderedElement === o && (this._pendingRenderedElement = null), n.current !== o)
95005
+ return;
95006
+ const r = this.getRunJsCode(), i = this.props.value, a = this._lastRunJs;
95007
+ a && a.element === o && a.code === r && Object.is(a.value, i) || (this._lastRunJs = { code: r, value: i, element: o }, this.applyFlow("jsSettings"));
95008
+ });
95009
+ }
94736
95010
  render() {
94737
- return /* @__PURE__ */ jsx("span", { ref: this.context.ref, style: { display: "inline-block", maxWidth: "100%" } });
95011
+ const o = this.context.ref;
95012
+ return /* @__PURE__ */ jsx("span", { ref: (r) => {
95013
+ if (o.current = r, !r)
95014
+ return;
95015
+ const i = this._lastRenderedElement && this._lastRenderedElement !== r;
95016
+ this._lastRenderedElement = r, (i || !this._mountedOnce) && this.refreshRenderedElement(r);
95017
+ }, style: { display: "inline-block", maxWidth: "100%" } });
94738
95018
  }
94739
95019
  /**
94740
95020
  * 组件挂载后,如果容器引用已就绪,强制重跑一次 beforeRender flows 以把 HTML 写入当前 DOM。
@@ -94742,7 +95022,7 @@ class JSFieldModel extends FieldModel {
94742
95022
  */
94743
95023
  onMount() {
94744
95024
  var o;
94745
- this._mountedOnce && (o = this.context.ref) != null && o.current && this.rerender(), this._mountedOnce = !0;
95025
+ this._mountedOnce && (o = this.context.ref) != null && o.current && this.refreshRenderedElement(this.context.ref.current), this._mountedOnce = !0;
94746
95026
  }
94747
95027
  }
94748
95028
  JSFieldModel.define({
@@ -94796,7 +95076,11 @@ JSFieldModel.registerFlow({
94796
95076
  const { code: o, version: n } = resolveRunJsParams(e, t);
94797
95077
  e.onRefReady(e.ref, (r) => L(this, null, function* () {
94798
95078
  e.defineProperty("element", {
94799
- get: () => new ElementProxy(r)
95079
+ get: () => {
95080
+ var a;
95081
+ return new ElementProxy(((a = e.ref) == null ? void 0 : a.current) || r);
95082
+ },
95083
+ cache: !1
94800
95084
  }), e.defineProperty("value", {
94801
95085
  get: () => {
94802
95086
  var a;
@@ -97457,17 +97741,18 @@ const setTargetDataScope = defineAction({
97457
97741
  filter: { logic: "$and", items: [] }
97458
97742
  };
97459
97743
  },
97744
+ useRawParams: !0,
97460
97745
  handler(e, t) {
97461
97746
  return L(this, null, function* () {
97462
- const o = t.targetBlockUid;
97463
- if (!o)
97747
+ const o = yield e.resolveJsonTemplate(t), n = o.targetBlockUid;
97748
+ if (!n)
97464
97749
  return;
97465
- e.model.scheduleModelOperation(o, (r) => {
97466
- const i = r.resource;
97467
- if (!i)
97750
+ e.model.scheduleModelOperation(n, (i) => {
97751
+ const a = i.resource;
97752
+ if (!a)
97468
97753
  return;
97469
- const a = pruneFilter(transformFilter(t.filter));
97470
- isEmptyFilter(a) ? i.removeFilterGroup(`setTargetDataScope_${e.model.uid}`) : i.addFilterGroup(`setTargetDataScope_${e.model.uid}`, a), i.hasData() && i.refresh();
97754
+ const l = normalizeDataScopeFilter(t.filter, o.filter);
97755
+ isEmptyFilter(l) ? a.removeFilterGroup(`setTargetDataScope_${e.model.uid}`) : a.addFilterGroup(`setTargetDataScope_${e.model.uid}`, l), a.hasData() && a.refresh();
97471
97756
  });
97472
97757
  });
97473
97758
  }
@@ -101589,7 +101874,7 @@ const DefaultValue = connect((e) => {
101589
101874
  }, [l, r]), f = React.useRef(void 0);
101590
101875
  isEqual(f.current, g) || (f.current = g);
101591
101876
  const y = f.current, b = useMemo(() => {
101592
- var de, he, ye, Ce, me, ae, ce, ge, xe, Se, ke, Ie, be, we, je, Ee, ve, Fe, Me, Pe, Oe, _e, Le, Re, Ae, ze, De, qe;
101877
+ var de, he, ye, Ce, me, ae, ce, ge, xe, Se, ke, Ie, be, we, je, Ee, ve, Fe, Me, Pe, Oe, Ve, Le, Re, Ae, ze, De, qe;
101593
101878
  const k = l, I = (k == null ? void 0 : k.customFieldModelInstance) || ((de = k == null ? void 0 : k.subModels) == null ? void 0 : de.field), T = (I == null ? void 0 : I.props) || {}, E = (k == null ? void 0 : k.customFieldProps) || {}, fe = T, { value: N, defaultValue: j } = fe, M = te(fe, ["value", "defaultValue"]), pe = E, {
101594
101879
  value: w,
101595
101880
  defaultValue: B
@@ -101622,8 +101907,8 @@ const DefaultValue = connect((e) => {
101622
101907
  subModels: { fields: [le] }
101623
101908
  }), ie = (Ee = (je = ue.subModels) == null ? void 0 : je.fields) == null ? void 0 : Ee[0];
101624
101909
  if (ie && (ie._originalModel = I, ie._originalPropsFallback = k == null ? void 0 : k.customFieldProps, ie._fallbackCollectionField = (ve = k == null ? void 0 : k.context) == null ? void 0 : ve.collectionField, ie._originalOptionsFallback = snapshotOptions((Fe = I == null ? void 0 : I.getDataSource) == null ? void 0 : Fe.call(I)) || snapshotOptions((Me = I == null ? void 0 : I.props) == null ? void 0 : Me.options) || snapshotOptions((Pe = k == null ? void 0 : k.customFieldProps) == null ? void 0 : Pe.options)), D != null && D.dataSourceKey && (D != null && D.collectionName)) {
101625
- const Te = l.context.dataSourceManager, Ve = (Oe = Te == null ? void 0 : Te.getDataSource) == null ? void 0 : Oe.call(Te, D.dataSourceKey), Ue = (_e = Te == null ? void 0 : Te.getCollection) == null ? void 0 : _e.call(Te, D.dataSourceKey, D.collectionName);
101626
- Ve && ((Re = (Le = ue.context) == null ? void 0 : Le.defineProperty) == null || Re.call(Le, "dataSource", { get: () => Ve })), Ue && ((ze = (Ae = ue.context) == null ? void 0 : Ae.defineProperty) == null || ze.call(Ae, "collection", { get: () => Ue }));
101910
+ const Te = l.context.dataSourceManager, _e = (Oe = Te == null ? void 0 : Te.getDataSource) == null ? void 0 : Oe.call(Te, D.dataSourceKey), Ue = (Ve = Te == null ? void 0 : Te.getCollection) == null ? void 0 : Ve.call(Te, D.dataSourceKey, D.collectionName);
101911
+ _e && ((Re = (Le = ue.context) == null ? void 0 : Le.defineProperty) == null || Re.call(Le, "dataSource", { get: () => _e })), Ue && ((ze = (Ae = ue.context) == null ? void 0 : Ae.defineProperty) == null || ze.call(Ae, "collection", { get: () => Ue }));
101627
101912
  }
101628
101913
  return y && ((qe = (De = ue.context) == null ? void 0 : De.defineProperty) == null || qe.call(De, "flags", { value: y })), ue;
101629
101914
  }, [l, y]);