@nocobase/client 1.6.0-alpha.11 → 1.6.0-alpha.12

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
@@ -10283,10 +10283,10 @@ const BodyRowComponent$1 = React.memo((e) => {
10283
10283
  });
10284
10284
  BodyRowComponent$1.displayName = "BodyRowComponent";
10285
10285
  const InternalBodyCellComponent$1 = React.memo((e) => {
10286
- const d = e, { record: t, schema: n, rowIndex: o, isSubTable: r } = d, i = K(d, ["record", "schema", "rowIndex", "isSubTable"]), a = n == null ? void 0 : n[LinkageRuleDataKeyMap.style], [l, c] = useState({}), u = useMemo(() => x(x({}, e.style), l), [e.style, l]);
10286
+ const p = e, { record: t, schema: n, rowIndex: o, isSubTable: r } = p, i = K(p, ["record", "schema", "rowIndex", "isSubTable"]), a = n == null ? void 0 : n[LinkageRuleDataKeyMap.style], [l, c] = useState({}), u = !!(n != null && n.properties) && Object.values(n.properties).some((m) => m["x-read-pretty"] === !0), d = useMemo(() => x(x({}, e.style), l), [e.style, l]);
10287
10287
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10288
- !_.isEmpty(a) && /* @__PURE__ */ jsx(GetStyleRules, { record: t, schema: n, onStyleChange: c }),
10289
- /* @__PURE__ */ jsx("td", P(x({}, i), { className: cls(e.className, cellClass$1), style: u, children: e.children }))
10288
+ !_.isEmpty(a) && /* @__PURE__ */ jsx(GetStyleRules, { record: t, schema: n, onStyleChange: u ? c : _.noop }),
10289
+ /* @__PURE__ */ jsx("td", P(x({}, i), { className: cls(e.className, cellClass$1), style: d, children: e.children }))
10290
10290
  ] });
10291
10291
  });
10292
10292
  InternalBodyCellComponent$1.displayName = "InternalBodyCellComponent";
@@ -11761,24 +11761,272 @@ function useDetailsWithPaginationDecoratorProps(e) {
11761
11761
  parseVariableLoading: o
11762
11762
  };
11763
11763
  }
11764
- const DetailsBlockContext = createContext({});
11764
+ const useSpecialCase = () => {
11765
+ const e = useForm(), t = useFieldSchema(), { getField: n } = useCollection_deprecated(), { getCollectionField: o } = useCollectionManager_deprecated(), r = useMemo(() => n(t.name), [t.name, n]), i = useCallback(() => isSpecialCaseField({ collectionField: r, fieldSchema: t, getCollectionField: o }), [r, t, o]), a = useCallback(
11766
+ (l) => {
11767
+ const c = getParentFieldSchema(t);
11768
+ if (c) {
11769
+ const u = e.query(c.name).take();
11770
+ if (u) {
11771
+ const d = _.isEmpty(l) ? [] : _.map(
11772
+ transformValue(l, { field: u, subFieldSchema: t }),
11773
+ (p) => markRecordAsNew(p)
11774
+ );
11775
+ isSubset(d, u.initialValue) || u.setInitialValue(d);
11776
+ }
11777
+ }
11778
+ },
11779
+ [t, e]
11780
+ );
11781
+ return {
11782
+ /**
11783
+ * 特殊情况指的是:当前字段是 `对一` 字段且存在于 `对多` 字段的 `子表格` 或 `子表单` 中
11784
+ * 详细说明见:https://nocobase.feishu.cn/docx/EmNEdEBOnoQohUx2UmBcqIQ5nyh#CUdLdy6OpoPKjyx9DLPc3lqknVc
11785
+ */
11786
+ isSpecialCase: i,
11787
+ setDefaultValue: a
11788
+ };
11789
+ };
11790
+ function getParentFieldSchema(e) {
11791
+ for (; e != null && e.parent; )
11792
+ if (e = e.parent, isSubMode(e))
11793
+ return e;
11794
+ return e;
11795
+ }
11796
+ function isSpecialCaseField({
11797
+ collectionField: e,
11798
+ fieldSchema: t,
11799
+ getCollectionField: n
11800
+ }) {
11801
+ if (!t.default || !t.default.includes("$context"))
11802
+ return !1;
11803
+ if (e && ["hasOne", "belongsTo"].includes(e.type) && t) {
11804
+ const o = getParentFieldSchema(t);
11805
+ if (o && o["x-collection-field"]) {
11806
+ const r = n(o["x-collection-field"]);
11807
+ if (["hasMany", "belongsToMany"].includes(r == null ? void 0 : r.type))
11808
+ return !0;
11809
+ }
11810
+ }
11811
+ return !1;
11812
+ }
11813
+ function transformValue(e, t) {
11814
+ const { field: n, subFieldSchema: o } = t, r = n.value;
11815
+ let i = null;
11816
+ return Array.isArray(e) ? i = e.map((l) => ({
11817
+ [o.name]: l
11818
+ })) : i = [
11819
+ {
11820
+ [o.name]: e
11821
+ }
11822
+ ], _.assignWith([...r], i, (l, c) => (!l && c && (c.__notFromDatabase = !0), _.assign(x({}, r[0]), c)));
11823
+ }
11824
+ const useSubTableSpecialCase = ({ rootField: e, rootSchema: t }) => {
11825
+ const { hasUsedVariable: n } = useHasUsedVariable();
11826
+ useEffect(() => {
11827
+ if (_.isEmpty(e.value) && n("$context", t)) {
11828
+ const o = e.value, r = [markRecordAsNew({})];
11829
+ e.value = r, setTimeout(() => {
11830
+ JSON.stringify(e.value) === JSON.stringify(r) && (e.value = o);
11831
+ });
11832
+ }
11833
+ }, [e, t, n]);
11834
+ };
11835
+ function isSubset(e, t) {
11836
+ if (e.length !== t.length)
11837
+ return !1;
11838
+ for (let n = 0; n < e.length; n++) {
11839
+ const o = e[n], r = t[n];
11840
+ if (!_.isMatch(_.omitBy(r, _.isNil), _.omitBy(o, _.isNil)))
11841
+ return !1;
11842
+ }
11843
+ return !0;
11844
+ }
11845
+ const checkSchema = (e, t) => {
11846
+ if (e["x-decorator"] === "FormItem") {
11847
+ const o = e.default;
11848
+ if (o && typeof o == "string" && isVariable$1(o) && o.includes(t))
11849
+ return !0;
11850
+ }
11851
+ let n = !1;
11852
+ return e.mapProperties((o) => {
11853
+ checkSchema(o, t) && (n = !0);
11854
+ }), n;
11855
+ };
11856
+ function useHasUsedVariable() {
11857
+ return { hasUsedVariable: useCallback((t, n) => checkSchema(n, t), []) };
11858
+ }
11859
+ const BaseVariableContext = React.createContext(null), BaseVariableProvider = (e) => /* @__PURE__ */ jsx(BaseVariableContext.Provider, { value: e, children: e.children }), getChildren$2 = (e, {
11860
+ collectionField: t,
11861
+ uiSchema: n,
11862
+ depth: o,
11863
+ maxDepth: r,
11864
+ noDisabled: i,
11865
+ loadChildren: a,
11866
+ compile: l,
11867
+ isDisabled: c,
11868
+ targetFieldSchema: u,
11869
+ getCollectionField: d,
11870
+ deprecated: p
11871
+ }) => e.map((h) => !h.target || h.target === "chinaRegions" ? {
11872
+ key: h.name,
11873
+ value: h.name,
11874
+ label: l(h.title),
11875
+ disabled: p || (i ? !1 : c({ option: h, collectionField: t, uiSchema: n, targetFieldSchema: u, getCollectionField: d })),
11876
+ isLeaf: !0,
11877
+ depth: o
11878
+ } : o >= r ? null : {
11879
+ key: h.name,
11880
+ value: h.name,
11881
+ label: l(h.title),
11882
+ isLeaf: !1,
11883
+ field: h,
11884
+ depth: o,
11885
+ disabled: p || (i ? !1 : c({ option: h, collectionField: t, uiSchema: n, targetFieldSchema: u, getCollectionField: d })),
11886
+ loadChildren: a
11887
+ }).filter(Boolean), getLabelWithTooltip = (e, t) => t ? /* @__PURE__ */ jsx(Tooltip, { placement: "left", title: t, zIndex: 9999, children: /* @__PURE__ */ jsx(
11888
+ "span",
11889
+ {
11890
+ style: {
11891
+ position: "relative",
11892
+ display: "inline-block",
11893
+ marginLeft: -14,
11894
+ paddingLeft: 14,
11895
+ marginRight: -80,
11896
+ paddingRight: 80,
11897
+ zIndex: 1
11898
+ },
11899
+ children: e
11900
+ }
11901
+ ) }) : e, useBaseVariable = ({
11902
+ collectionField: e,
11903
+ uiSchema: t,
11904
+ targetFieldSchema: n,
11905
+ maxDepth: o = 3,
11906
+ name: r,
11907
+ title: i,
11908
+ collectionName: a,
11909
+ noChildren: l = !1,
11910
+ // TODO: 等整理完完整测试用例后,再开启该功能
11911
+ noDisabled: c = !0,
11912
+ dataSource: u,
11913
+ returnFields: d = (h) => h,
11914
+ deprecated: p,
11915
+ tooltip: m
11916
+ }) => {
11917
+ const h = useCompile(), g = useGetFilterOptions(), { isDisabled: f } = useContext(BaseVariableContext) || {}, C = useCollectionManager(), b = (y) => {
11918
+ var F;
11919
+ if (!((F = y.field) != null && F.target))
11920
+ return Promise.resolve(void 0);
11921
+ const v = y.field.target;
11922
+ return new Promise((I) => {
11923
+ setTimeout(() => {
11924
+ const k = (getChildren$2(d(g(v, u, !0), y), {
11925
+ collectionField: e,
11926
+ uiSchema: t,
11927
+ targetFieldSchema: n,
11928
+ depth: y.depth + 1,
11929
+ maxDepth: o,
11930
+ noDisabled: c,
11931
+ loadChildren: b,
11932
+ compile: h,
11933
+ isDisabled: f || isDisabledDefault,
11934
+ getCollectionField: C.getCollectionField,
11935
+ deprecated: p
11936
+ }) || []).sort((D, j) => D.isLeaf && !j.isLeaf ? -1 : !D.isLeaf && j.isLeaf ? 1 : 0).sort((D, j) => D.disabled && !j.disabled ? 1 : !D.disabled && j.disabled ? -1 : 0);
11937
+ if (k.length === 0) {
11938
+ y.disabled = !0, y.isLeaf = !0, I();
11939
+ return;
11940
+ }
11941
+ y.children = k, I();
11942
+ }, 5);
11943
+ });
11944
+ };
11945
+ return useMemo(() => ({
11946
+ label: getLabelWithTooltip(i, m),
11947
+ value: r,
11948
+ key: r,
11949
+ isLeaf: l,
11950
+ field: {
11951
+ target: a
11952
+ },
11953
+ depth: 0,
11954
+ loadChildren: b,
11955
+ children: [],
11956
+ disabled: !!p,
11957
+ deprecated: p
11958
+ }), [t == null ? void 0 : t["x-component"]]);
11959
+ };
11960
+ function isDisabledDefault(e) {
11961
+ var a, l;
11962
+ const { option: t, collectionField: n, uiSchema: o, targetFieldSchema: r, getCollectionField: i } = e;
11963
+ return !o || !n ? !0 : n.interface === "json" ? !1 : !n.target && ["hasMany", "belongsToMany"].includes(t.type) ? !0 : !n.target && ["hasOne", "belongsTo"].includes(t.type) || t.target && isSpecialCaseField({ collectionField: n, fieldSchema: r, getCollectionField: i }) ? !1 : ["hasOne", "belongsTo"].includes(n.type) && ["hasMany", "belongsToMany"].includes(t.type) ? !0 : ["hasOne", "belongsTo"].includes(n.type) && ["hasOne", "belongsTo"].includes(t.type) || ["hasMany", "belongsToMany"].includes(n.type) && t.target ? !1 : ["input", "markdown", "richText", "textarea", "username"].includes(n.interface) ? !["string", "number"].includes((a = t.schema) == null ? void 0 : a.type) : n.interface && t.interface ? n.interface !== t.interface : (o == null ? void 0 : o["x-component"]) !== ((l = t.schema) == null ? void 0 : l["x-component"]);
11964
+ }
11965
+ const CurrentRecordContext = createContext(null), CurrentRecordContextProvider = (e) => {
11966
+ const t = useMemo(() => ({
11967
+ recordData: e.recordData,
11968
+ collectionName: e.collectionName
11969
+ }), [e.recordData, e.collectionName]);
11970
+ return /* @__PURE__ */ jsxs(CurrentRecordContext.Provider, { value: t, children: [
11971
+ " ",
11972
+ e.children,
11973
+ " "
11974
+ ] });
11975
+ }, useCurrentRecord = () => useContext(CurrentRecordContext), useCurrentRecordContext = () => {
11976
+ const e = useCurrentRecord(), { name: t } = useBlockContext() || {}, n = useCollection(), o = useCollectionRecordData(), { formRecord: r, collectionName: i } = useFormBlockContext();
11977
+ let a = r != null && r.data ? i : n == null ? void 0 : n.name;
11978
+ return a = (e == null ? void 0 : e.collectionName) || a, {
11979
+ /** 变量值 */
11980
+ currentRecordCtx: (e == null ? void 0 : e.recordData) || (r == null ? void 0 : r.data) || o,
11981
+ /** 用于判断是否需要显示配置项 */
11982
+ shouldDisplayCurrentRecord: !_.isEmpty(_.omit(o, ["__collectionName", "__parent"])) || !!(r != null && r.data),
11983
+ /** 当前记录对应的 collection name */
11984
+ collectionName: a,
11985
+ /** 块类型 */
11986
+ blockType: t,
11987
+ dataSource: n == null ? void 0 : n.dataSource
11988
+ };
11989
+ }, useCurrentRecordVariable = (e = {}) => {
11990
+ const { t } = useTranslation(), { currentRecordCtx: n, shouldDisplayCurrentRecord: o, collectionName: r, blockType: i, dataSource: a } = useCurrentRecordContext();
11991
+ return {
11992
+ /** 变量配置 */
11993
+ currentRecordSettings: useBaseVariable({
11994
+ collectionField: e.collectionField,
11995
+ uiSchema: e.schema,
11996
+ name: "$nRecord",
11997
+ title: t("Current record"),
11998
+ collectionName: r,
11999
+ noDisabled: e.noDisabled,
12000
+ targetFieldSchema: e.targetFieldSchema,
12001
+ deprecated: i === "form",
12002
+ tooltip: i === "form" ? t('This variable has been deprecated and can be replaced with "Current form"') : "",
12003
+ dataSource: a
12004
+ }),
12005
+ /** 变量值 */
12006
+ currentRecordCtx: n,
12007
+ /** 用于判断是否需要显示配置项 */
12008
+ shouldDisplayCurrentRecord: o,
12009
+ /** 当前记录对应的 collection name */
12010
+ collectionName: r
12011
+ };
12012
+ }, DetailsBlockContext = createContext({});
11765
12013
  DetailsBlockContext.displayName = "DetailsBlockContext";
11766
12014
  const InternalDetailsBlockProvider = (e) => {
11767
- var p, m, h;
12015
+ var m, h, g;
11768
12016
  const { action: t, readPretty: n } = e, o = useField(), r = useMemo(
11769
12017
  () => createForm({
11770
12018
  readPretty: n
11771
12019
  }),
11772
12020
  [n]
11773
- ), { resource: i, service: a } = useBlockRequestContext(), l = useCollectionParentRecord(), c = (t === "list" ? (m = (p = a == null ? void 0 : a.data) == null ? void 0 : p.data) == null ? void 0 : m[0] : (h = a == null ? void 0 : a.data) == null ? void 0 : h.data) || {}, u = useRef(), d = useMemo(() => ({
12021
+ ), i = useCollection(), { resource: a, service: l } = useBlockRequestContext(), c = useCollectionParentRecord(), u = (t === "list" ? (h = (m = l == null ? void 0 : l.data) == null ? void 0 : m.data) == null ? void 0 : h[0] : (g = l == null ? void 0 : l.data) == null ? void 0 : g.data) || {}, d = useRef(), p = useMemo(() => ({
11774
12022
  action: t,
11775
12023
  form: r,
11776
12024
  field: o,
11777
- service: a,
11778
- resource: i,
11779
- formBlockRef: u
11780
- }), [t, o, r, i, a]);
11781
- return a.loading && !o.loaded ? /* @__PURE__ */ jsx(Spin, {}) : (o.loaded = !0, /* @__PURE__ */ jsx(DetailsBlockContext.Provider, { value: d, children: /* @__PURE__ */ jsx("div", { ref: u, children: /* @__PURE__ */ jsx(RecordProvider, { isNew: !1, record: c, parent: l == null ? void 0 : l.data, children: e.children }) }) }));
12025
+ service: l,
12026
+ resource: a,
12027
+ formBlockRef: d
12028
+ }), [t, o, r, a, l]);
12029
+ return l.loading && !o.loaded ? /* @__PURE__ */ jsx(Spin, {}) : (o.loaded = !0, /* @__PURE__ */ jsx(CurrentRecordContextProvider, { recordData: u, collectionName: i == null ? void 0 : i.name, children: /* @__PURE__ */ jsx(DetailsBlockContext.Provider, { value: p, children: /* @__PURE__ */ jsx("div", { ref: d, children: /* @__PURE__ */ jsx(RecordProvider, { isNew: !1, record: u, parent: c == null ? void 0 : c.data, children: e.children }) }) }) }));
11782
12030
  }, useCompatDetailsBlockParams = (e) => {
11783
12031
  const t = useFieldSchema();
11784
12032
  let n, o = !1;
@@ -13869,7 +14117,7 @@ const useFormItemInitializerFields = (e) => {
13869
14117
  label: R,
13870
14118
  type: "subMenu",
13871
14119
  children: [
13872
- ...getChildren$2({
14120
+ ...getChildren$1({
13873
14121
  name: e,
13874
14122
  association: S,
13875
14123
  collections: k,
@@ -14287,7 +14535,7 @@ const useFormItemInitializerFields = (e) => {
14287
14535
  }
14288
14536
  }
14289
14537
  };
14290
- }, getChildren$2 = ({
14538
+ }, getChildren$1 = ({
14291
14539
  name: e,
14292
14540
  association: t,
14293
14541
  collections: n,
@@ -18955,207 +19203,6 @@ const DialogFooter = (e) => {
18955
19203
  };
18956
19204
  FormDialog.Footer = DialogFooter;
18957
19205
  FormDialog.Portal = createPortalProvider("form-dialog");
18958
- const useSpecialCase = () => {
18959
- const e = useForm(), t = useFieldSchema(), { getField: n } = useCollection_deprecated(), { getCollectionField: o } = useCollectionManager_deprecated(), r = useMemo(() => n(t.name), [t.name, n]), i = useCallback(() => isSpecialCaseField({ collectionField: r, fieldSchema: t, getCollectionField: o }), [r, t, o]), a = useCallback(
18960
- (l) => {
18961
- const c = getParentFieldSchema(t);
18962
- if (c) {
18963
- const u = e.query(c.name).take();
18964
- if (u) {
18965
- const d = _.isEmpty(l) ? [] : _.map(
18966
- transformValue(l, { field: u, subFieldSchema: t }),
18967
- (p) => markRecordAsNew(p)
18968
- );
18969
- isSubset(d, u.initialValue) || u.setInitialValue(d);
18970
- }
18971
- }
18972
- },
18973
- [t, e]
18974
- );
18975
- return {
18976
- /**
18977
- * 特殊情况指的是:当前字段是 `对一` 字段且存在于 `对多` 字段的 `子表格` 或 `子表单` 中
18978
- * 详细说明见:https://nocobase.feishu.cn/docx/EmNEdEBOnoQohUx2UmBcqIQ5nyh#CUdLdy6OpoPKjyx9DLPc3lqknVc
18979
- */
18980
- isSpecialCase: i,
18981
- setDefaultValue: a
18982
- };
18983
- };
18984
- function getParentFieldSchema(e) {
18985
- for (; e != null && e.parent; )
18986
- if (e = e.parent, isSubMode(e))
18987
- return e;
18988
- return e;
18989
- }
18990
- function isSpecialCaseField({
18991
- collectionField: e,
18992
- fieldSchema: t,
18993
- getCollectionField: n
18994
- }) {
18995
- if (!t.default || !t.default.includes("$context"))
18996
- return !1;
18997
- if (e && ["hasOne", "belongsTo"].includes(e.type) && t) {
18998
- const o = getParentFieldSchema(t);
18999
- if (o && o["x-collection-field"]) {
19000
- const r = n(o["x-collection-field"]);
19001
- if (["hasMany", "belongsToMany"].includes(r == null ? void 0 : r.type))
19002
- return !0;
19003
- }
19004
- }
19005
- return !1;
19006
- }
19007
- function transformValue(e, t) {
19008
- const { field: n, subFieldSchema: o } = t, r = n.value;
19009
- let i = null;
19010
- return Array.isArray(e) ? i = e.map((l) => ({
19011
- [o.name]: l
19012
- })) : i = [
19013
- {
19014
- [o.name]: e
19015
- }
19016
- ], _.assignWith([...r], i, (l, c) => (!l && c && (c.__notFromDatabase = !0), _.assign(x({}, r[0]), c)));
19017
- }
19018
- const useSubTableSpecialCase = ({ rootField: e, rootSchema: t }) => {
19019
- const { hasUsedVariable: n } = useHasUsedVariable();
19020
- useEffect(() => {
19021
- if (_.isEmpty(e.value) && n("$context", t)) {
19022
- const o = e.value, r = [markRecordAsNew({})];
19023
- e.value = r, setTimeout(() => {
19024
- JSON.stringify(e.value) === JSON.stringify(r) && (e.value = o);
19025
- });
19026
- }
19027
- }, [e, t, n]);
19028
- };
19029
- function isSubset(e, t) {
19030
- if (e.length !== t.length)
19031
- return !1;
19032
- for (let n = 0; n < e.length; n++) {
19033
- const o = e[n], r = t[n];
19034
- if (!_.isMatch(_.omitBy(r, _.isNil), _.omitBy(o, _.isNil)))
19035
- return !1;
19036
- }
19037
- return !0;
19038
- }
19039
- const checkSchema = (e, t) => {
19040
- if (e["x-decorator"] === "FormItem") {
19041
- const o = e.default;
19042
- if (o && typeof o == "string" && isVariable$1(o) && o.includes(t))
19043
- return !0;
19044
- }
19045
- let n = !1;
19046
- return e.mapProperties((o) => {
19047
- checkSchema(o, t) && (n = !0);
19048
- }), n;
19049
- };
19050
- function useHasUsedVariable() {
19051
- return { hasUsedVariable: useCallback((t, n) => checkSchema(n, t), []) };
19052
- }
19053
- const BaseVariableContext = React.createContext(null), BaseVariableProvider = (e) => /* @__PURE__ */ jsx(BaseVariableContext.Provider, { value: e, children: e.children }), getChildren$1 = (e, {
19054
- collectionField: t,
19055
- uiSchema: n,
19056
- depth: o,
19057
- maxDepth: r,
19058
- noDisabled: i,
19059
- loadChildren: a,
19060
- compile: l,
19061
- isDisabled: c,
19062
- targetFieldSchema: u,
19063
- getCollectionField: d,
19064
- deprecated: p
19065
- }) => e.map((h) => !h.target || h.target === "chinaRegions" ? {
19066
- key: h.name,
19067
- value: h.name,
19068
- label: l(h.title),
19069
- disabled: p || (i ? !1 : c({ option: h, collectionField: t, uiSchema: n, targetFieldSchema: u, getCollectionField: d })),
19070
- isLeaf: !0,
19071
- depth: o
19072
- } : o >= r ? null : {
19073
- key: h.name,
19074
- value: h.name,
19075
- label: l(h.title),
19076
- isLeaf: !1,
19077
- field: h,
19078
- depth: o,
19079
- disabled: p || (i ? !1 : c({ option: h, collectionField: t, uiSchema: n, targetFieldSchema: u, getCollectionField: d })),
19080
- loadChildren: a
19081
- }).filter(Boolean), getLabelWithTooltip = (e, t) => t ? /* @__PURE__ */ jsx(Tooltip, { placement: "left", title: t, zIndex: 9999, children: /* @__PURE__ */ jsx(
19082
- "span",
19083
- {
19084
- style: {
19085
- position: "relative",
19086
- display: "inline-block",
19087
- marginLeft: -14,
19088
- paddingLeft: 14,
19089
- marginRight: -80,
19090
- paddingRight: 80,
19091
- zIndex: 1
19092
- },
19093
- children: e
19094
- }
19095
- ) }) : e, useBaseVariable = ({
19096
- collectionField: e,
19097
- uiSchema: t,
19098
- targetFieldSchema: n,
19099
- maxDepth: o = 3,
19100
- name: r,
19101
- title: i,
19102
- collectionName: a,
19103
- noChildren: l = !1,
19104
- // TODO: 等整理完完整测试用例后,再开启该功能
19105
- noDisabled: c = !0,
19106
- dataSource: u,
19107
- returnFields: d = (h) => h,
19108
- deprecated: p,
19109
- tooltip: m
19110
- }) => {
19111
- const h = useCompile(), g = useGetFilterOptions(), { isDisabled: f } = useContext(BaseVariableContext) || {}, C = useCollectionManager(), b = (y) => {
19112
- var F;
19113
- if (!((F = y.field) != null && F.target))
19114
- return Promise.resolve(void 0);
19115
- const v = y.field.target;
19116
- return new Promise((I) => {
19117
- setTimeout(() => {
19118
- const k = (getChildren$1(d(g(v, u, !0), y), {
19119
- collectionField: e,
19120
- uiSchema: t,
19121
- targetFieldSchema: n,
19122
- depth: y.depth + 1,
19123
- maxDepth: o,
19124
- noDisabled: c,
19125
- loadChildren: b,
19126
- compile: h,
19127
- isDisabled: f || isDisabledDefault,
19128
- getCollectionField: C.getCollectionField,
19129
- deprecated: p
19130
- }) || []).sort((D, j) => D.isLeaf && !j.isLeaf ? -1 : !D.isLeaf && j.isLeaf ? 1 : 0).sort((D, j) => D.disabled && !j.disabled ? 1 : !D.disabled && j.disabled ? -1 : 0);
19131
- if (k.length === 0) {
19132
- y.disabled = !0, y.isLeaf = !0, I();
19133
- return;
19134
- }
19135
- y.children = k, I();
19136
- }, 5);
19137
- });
19138
- };
19139
- return useMemo(() => ({
19140
- label: getLabelWithTooltip(i, m),
19141
- value: r,
19142
- key: r,
19143
- isLeaf: l,
19144
- field: {
19145
- target: a
19146
- },
19147
- depth: 0,
19148
- loadChildren: b,
19149
- children: [],
19150
- disabled: !!p,
19151
- deprecated: p
19152
- }), [t == null ? void 0 : t["x-component"]]);
19153
- };
19154
- function isDisabledDefault(e) {
19155
- var a, l;
19156
- const { option: t, collectionField: n, uiSchema: o, targetFieldSchema: r, getCollectionField: i } = e;
19157
- return !o || !n ? !0 : n.interface === "json" ? !1 : !n.target && ["hasMany", "belongsToMany"].includes(t.type) ? !0 : !n.target && ["hasOne", "belongsTo"].includes(t.type) || t.target && isSpecialCaseField({ collectionField: n, fieldSchema: r, getCollectionField: i }) ? !1 : ["hasOne", "belongsTo"].includes(n.type) && ["hasMany", "belongsToMany"].includes(t.type) ? !0 : ["hasOne", "belongsTo"].includes(n.type) && ["hasOne", "belongsTo"].includes(t.type) || ["hasMany", "belongsToMany"].includes(n.type) && t.target ? !1 : ["input", "markdown", "richText", "textarea", "username"].includes(n.interface) ? !["string", "number"].includes((a = t.schema) == null ? void 0 : a.type) : n.interface && t.interface ? n.interface !== t.interface : (o == null ? void 0 : o["x-component"]) !== ((l = t.schema) == null ? void 0 : l["x-component"]);
19158
- }
19159
19206
  const useAPITokenVariable = ({
19160
19207
  noDisabled: e
19161
19208
  } = {}) => {
@@ -20102,42 +20149,6 @@ const ParentCollectionProvider = (e) => {
20102
20149
  dataSource: r,
20103
20150
  defaultValue: i
20104
20151
  };
20105
- }, useCurrentRecordContext = () => {
20106
- const { name: e } = useBlockContext() || {}, t = useCollection(), n = useCollectionRecordData(), { formRecord: o, collectionName: r } = useFormBlockContext(), i = o != null && o.data ? r : t == null ? void 0 : t.name;
20107
- return {
20108
- /** 变量值 */
20109
- currentRecordCtx: (o == null ? void 0 : o.data) || n,
20110
- /** 用于判断是否需要显示配置项 */
20111
- shouldDisplayCurrentRecord: !_.isEmpty(_.omit(n, ["__collectionName", "__parent"])) || !!(o != null && o.data),
20112
- /** 当前记录对应的 collection name */
20113
- collectionName: i,
20114
- /** 块类型 */
20115
- blockType: e,
20116
- dataSource: t == null ? void 0 : t.dataSource
20117
- };
20118
- }, useCurrentRecordVariable = (e = {}) => {
20119
- const { t } = useTranslation(), { currentRecordCtx: n, shouldDisplayCurrentRecord: o, collectionName: r, blockType: i, dataSource: a } = useCurrentRecordContext();
20120
- return {
20121
- /** 变量配置 */
20122
- currentRecordSettings: useBaseVariable({
20123
- collectionField: e.collectionField,
20124
- uiSchema: e.schema,
20125
- name: "$nRecord",
20126
- title: t("Current record"),
20127
- collectionName: r,
20128
- noDisabled: e.noDisabled,
20129
- targetFieldSchema: e.targetFieldSchema,
20130
- deprecated: i === "form",
20131
- tooltip: i === "form" ? t('This variable has been deprecated and can be replaced with "Current form"') : "",
20132
- dataSource: a
20133
- }),
20134
- /** 变量值 */
20135
- currentRecordCtx: n,
20136
- /** 用于判断是否需要显示配置项 */
20137
- shouldDisplayCurrentRecord: o,
20138
- /** 当前记录对应的 collection name */
20139
- collectionName: r
20140
- };
20141
20152
  }, useVariableOptions = ({
20142
20153
  collectionField: e,
20143
20154
  form: t,
@@ -21956,7 +21967,7 @@ const FormLinkageRules = withDynamicSchemaProps(
21956
21967
  { label: i("Required"), value: ActionType.Required, selected: !1, schema: {} },
21957
21968
  { label: i("Not required"), value: ActionType.InRequired, selected: !1, schema: {} },
21958
21969
  { label: i("Value"), value: ActionType.Value, selected: !1, schema: {} }
21959
- ].filter((u) => t ? [ActionType.Visible, ActionType.None].includes(u.value) : u), l = (u, d) => {
21970
+ ].filter((u) => t ? [ActionType.Visible, ActionType.None, ActionType.Hidden].includes(u.value) : u), l = (u, d) => {
21960
21971
  var f, C;
21961
21972
  const p = o(u.interface);
21962
21973
  if (!p)
@@ -22358,7 +22369,7 @@ const SchemaSettingsSwitchItem = (e) => {
22358
22369
  });
22359
22370
  SchemaSettingsActionModalItem.displayName = "SchemaSettingsActionModalItem";
22360
22371
  const SchemaSettingsModalItem = (e) => {
22361
- const N = e, {
22372
+ const E = e, {
22362
22373
  hidden: t,
22363
22374
  title: n,
22364
22375
  components: o,
@@ -22369,8 +22380,8 @@ const SchemaSettingsModalItem = (e) => {
22369
22380
  initialValues: c,
22370
22381
  width: u = "fit-content",
22371
22382
  noRecord: d = !1,
22372
- ModalContextProvider: p = (E) => /* @__PURE__ */ jsx(Fragment, { children: E.children })
22373
- } = N, m = K(N, [
22383
+ ModalContextProvider: p = (V) => /* @__PURE__ */ jsx(Fragment, { children: V.children })
22384
+ } = E, m = K(E, [
22374
22385
  "hidden",
22375
22386
  "title",
22376
22387
  "components",
@@ -22382,31 +22393,31 @@ const SchemaSettingsModalItem = (e) => {
22382
22393
  "width",
22383
22394
  "noRecord",
22384
22395
  "ModalContextProvider"
22385
- ]), h = useContext(SchemaOptionsContext), g = useCollection(), f = useAPIClient(), C = useApp(), { theme: b } = useGlobalTheme(), S = useBlockRequestContext(), y = useFormActiveFields(), { locale: v } = useContext(ConfigProvider.ConfigContext), F = useDataSourceManager(), I = useDataSourceKey(), R = useCollectionRecord(), { association: k } = useDataBlockProps() || {}, D = useFormBlockContext(), j = useBlockContext(), { getOperators: O } = useOperators(), L = useLocationSearch(), M = useVariables$1(), { formValue: w, collection: $, parent: B } = useSubFormValue(), T = useCurrentPopupRecord(), z = useParentPopupRecord();
22396
+ ]), h = useContext(SchemaOptionsContext), g = useCollection(), f = useAPIClient(), C = useApp(), { theme: b } = useGlobalTheme(), S = useBlockRequestContext(), y = useFormActiveFields(), { locale: v } = useContext(ConfigProvider.ConfigContext), F = useDataSourceManager(), I = useDataSourceKey(), R = useCollectionRecord(), { association: k } = useDataBlockProps() || {}, D = useCurrentRecord(), j = useFormBlockContext(), O = useBlockContext(), { getOperators: L } = useOperators(), M = useLocationSearch(), w = useVariables$1(), { formValue: $, collection: B, parent: T } = useSubFormValue(), z = useCurrentPopupRecord(), N = useParentPopupRecord();
22386
22397
  return t ? null : /* @__PURE__ */ jsx(
22387
22398
  SchemaSettingsItem,
22388
22399
  P(x({
22389
22400
  title: n
22390
22401
  }, m), {
22391
22402
  onClick: () => q(void 0, null, function* () {
22392
- const E = l ? yield l() : c, V = _.isFunction(e.schema) ? e.schema() : e.schema;
22403
+ const V = l ? yield l() : c, G = _.isFunction(e.schema) ? e.schema() : e.schema;
22393
22404
  FormDialog(
22394
- { title: V.title || n, width: u },
22395
- () => /* @__PURE__ */ jsx(p, { children: /* @__PURE__ */ jsx(CollectOperators, { defaultOperators: O(), children: /* @__PURE__ */ jsx(VariablesContext.Provider, { value: M, children: /* @__PURE__ */ jsx(BlockContext.Provider, { value: j, children: /* @__PURE__ */ jsx(
22405
+ { title: G.title || n, width: u },
22406
+ () => /* @__PURE__ */ jsx(p, { children: /* @__PURE__ */ jsx(CollectOperators, { defaultOperators: L(), children: /* @__PURE__ */ jsx(VariablesContext.Provider, { value: w, children: /* @__PURE__ */ jsx(BlockContext.Provider, { value: O, children: /* @__PURE__ */ jsx(
22396
22407
  VariablePopupRecordProvider,
22397
22408
  {
22398
- recordData: T == null ? void 0 : T.value,
22399
- collection: T == null ? void 0 : T.collection,
22409
+ recordData: z == null ? void 0 : z.value,
22410
+ collection: z == null ? void 0 : z.collection,
22400
22411
  parent: {
22401
- recordData: z == null ? void 0 : z.value,
22402
- collection: z == null ? void 0 : z.collection
22412
+ recordData: N == null ? void 0 : N.value,
22413
+ collection: N == null ? void 0 : N.collection
22403
22414
  },
22404
- children: /* @__PURE__ */ jsx(CollectionRecordProvider, { record: d ? null : R, children: /* @__PURE__ */ jsx(FormBlockContext$1.Provider, { value: D, children: /* @__PURE__ */ jsx(SubFormProvider, { value: { value: w, collection: $, parent: B }, children: /* @__PURE__ */ jsx(
22415
+ children: /* @__PURE__ */ jsx(CollectionRecordProvider, { record: d ? null : R, children: /* @__PURE__ */ jsx(CurrentRecordContextProvider, P(x({}, D), { children: /* @__PURE__ */ jsx(FormBlockContext$1.Provider, { value: j, children: /* @__PURE__ */ jsx(SubFormProvider, { value: { value: $, collection: B, parent: T }, children: /* @__PURE__ */ jsx(
22405
22416
  FormActiveFieldsProvider,
22406
22417
  {
22407
22418
  name: "form",
22408
22419
  getActiveFieldsName: y == null ? void 0 : y.getActiveFieldsName,
22409
- children: /* @__PURE__ */ jsx(LocationSearchContext.Provider, { value: L, children: /* @__PURE__ */ jsx(BlockRequestContext_deprecated.Provider, { value: S, children: /* @__PURE__ */ jsx(DataSourceApplicationProvider, { dataSourceManager: F, dataSource: I, children: /* @__PURE__ */ jsx(
22420
+ children: /* @__PURE__ */ jsx(LocationSearchContext.Provider, { value: M, children: /* @__PURE__ */ jsx(BlockRequestContext_deprecated.Provider, { value: S, children: /* @__PURE__ */ jsx(DataSourceApplicationProvider, { dataSourceManager: F, dataSource: I, children: /* @__PURE__ */ jsx(
22410
22421
  AssociationOrCollectionProvider,
22411
22422
  {
22412
22423
  allowNull: !0,
@@ -22417,22 +22428,22 @@ const SchemaSettingsModalItem = (e) => {
22417
22428
  {
22418
22429
  layout: "vertical",
22419
22430
  className: css`
22420
- // screen > 576px
22421
- @media (min-width: 576px) {
22422
- min-width: 520px;
22423
- }
22431
+ // screen > 576px
22432
+ @media (min-width: 576px) {
22433
+ min-width: 520px;
22434
+ }
22424
22435
 
22425
- // screen <= 576px
22426
- @media (max-width: 576px) {
22427
- min-width: 320px;
22428
- }
22429
- `,
22436
+ // screen <= 576px
22437
+ @media (max-width: 576px) {
22438
+ min-width: 320px;
22439
+ }
22440
+ `,
22430
22441
  children: /* @__PURE__ */ jsx(ApplicationContext.Provider, { value: C, children: /* @__PURE__ */ jsx(APIClientProvider, { apiClient: f, children: /* @__PURE__ */ jsx(ConfigProvider, { locale: v, children: /* @__PURE__ */ jsx(
22431
22442
  SchemaComponent,
22432
22443
  {
22433
22444
  components: o,
22434
22445
  scope: r,
22435
- schema: V
22446
+ schema: G
22436
22447
  }
22437
22448
  ) }) }) })
22438
22449
  }
@@ -22440,15 +22451,15 @@ const SchemaSettingsModalItem = (e) => {
22440
22451
  }
22441
22452
  ) }) }) })
22442
22453
  }
22443
- ) }) }) })
22454
+ ) }) }) })) })
22444
22455
  }
22445
22456
  ) }) }) }) }),
22446
22457
  b
22447
22458
  ).open({
22448
- initialValues: E,
22459
+ initialValues: V,
22449
22460
  effects: i
22450
- }).then((G) => (a(G), G)).catch((G) => {
22451
- console.error(G);
22461
+ }).then((U) => (a(U), U)).catch((U) => {
22462
+ console.error(U);
22452
22463
  });
22453
22464
  }),
22454
22465
  children: e.children || e.title
@@ -27514,7 +27525,15 @@ const formItemWrapCss = css`
27514
27525
  }
27515
27526
  `
27516
27527
  ),
27517
- children: /* @__PURE__ */ jsx(ACLCollectionFieldProvider, { children: /* @__PURE__ */ jsx(FormItem$1, P(x({ className: l }, e), { extra: a, wrapperStyle: r })) })
27528
+ children: /* @__PURE__ */ jsx(ACLCollectionFieldProvider, { children: /* @__PURE__ */ jsx(
27529
+ FormItem$1,
27530
+ P(x({
27531
+ className: l
27532
+ }, e), {
27533
+ extra: a,
27534
+ wrapperStyle: x(x({}, r.backgroundColor ? { paddingLeft: "5px", paddingRight: "5px" } : {}), r)
27535
+ })
27536
+ ) })
27518
27537
  }
27519
27538
  ) });
27520
27539
  }),
@@ -30051,6 +30070,10 @@ const getVariableComponentWithScope = (e) => (t) => {
30051
30070
  return P(x({}, t), {
30052
30071
  collectionName: e
30053
30072
  });
30073
+ },
30074
+ useVisible() {
30075
+ const { collection: e } = useCurrentPopupRecord() || {}, t = useCollection();
30076
+ return !e || (e == null ? void 0 : e.name) === (t == null ? void 0 : t.name);
30054
30077
  }
30055
30078
  },
30056
30079
  {
@@ -35114,7 +35137,7 @@ function addAppVersion(e, t) {
35114
35137
  addAppVersion((o = e.properties) == null ? void 0 : o[n], t);
35115
35138
  }), e;
35116
35139
  }
35117
- const name = "@nocobase/client", version = "1.6.0-alpha.11", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
35140
+ const name = "@nocobase/client", version = "1.6.0-alpha.12", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
35118
35141
  "@ahooksjs/use-url-state": "3.5.1",
35119
35142
  "@ant-design/cssinjs": "^1.11.1",
35120
35143
  "@ant-design/icons": "^5.1.4",
@@ -35136,9 +35159,9 @@ const name = "@nocobase/client", version = "1.6.0-alpha.11", license = "AGPL-3.0
35136
35159
  "@formily/reactive-react": "^2.2.27",
35137
35160
  "@formily/shared": "^2.2.27",
35138
35161
  "@formily/validator": "^2.2.27",
35139
- "@nocobase/evaluators": "1.6.0-alpha.11",
35140
- "@nocobase/sdk": "1.6.0-alpha.11",
35141
- "@nocobase/utils": "1.6.0-alpha.11",
35162
+ "@nocobase/evaluators": "1.6.0-alpha.12",
35163
+ "@nocobase/sdk": "1.6.0-alpha.12",
35164
+ "@nocobase/utils": "1.6.0-alpha.12",
35142
35165
  ahooks: "^3.7.2",
35143
35166
  antd: "5.12.8",
35144
35167
  "antd-style": "3.7.1",
@@ -36316,7 +36339,8 @@ const ReadPrettyInternal = observer$1(
36316
36339
  children: m.label
36317
36340
  })
36318
36341
  )
36319
- )
36342
+ ),
36343
+ maxTagCount: "responsive"
36320
36344
  }, u)
36321
36345
  );
36322
36346
  }, filterOption = (e, t) => {
@@ -36371,7 +36395,8 @@ const ReadPrettyInternal = observer$1(
36371
36395
  var p;
36372
36396
  (p = e.onChange) == null || p.call(e, d === void 0 ? null : d);
36373
36397
  },
36374
- mode: l
36398
+ mode: l,
36399
+ maxTagCount: "responsive"
36375
36400
  })
36376
36401
  );
36377
36402
  },
@@ -38142,7 +38167,7 @@ connect(
38142
38167
  })
38143
38168
  )
38144
38169
  );
38145
- const UPLOAD_PLACEHOLDER = [
38170
+ const publicPath = window.__nocobase_dev_public_path__ || window.__nocobase_public_path__ || "/", UPLOAD_PLACEHOLDER = [
38146
38171
  {
38147
38172
  ext: /\.docx?$/i,
38148
38173
  icon: "/file-placeholder/docx-200-200.png"
@@ -38199,7 +38224,10 @@ const UPLOAD_PLACEHOLDER = [
38199
38224
  ext: /\.(zip|rar|arj|z|gz|iso|jar|ace|tar|uue|dmg|pkg|lzh|cab)$/i,
38200
38225
  icon: "/file-placeholder/zip-200-200.png"
38201
38226
  }
38202
- ], UNKNOWN_FILE_ICON = "/file-placeholder/unknown-200-200.png", FILE_SIZE_LIMIT_DEFAULT = 1024 * 1024 * 20;
38227
+ ].map((e) => ({
38228
+ ext: e.ext,
38229
+ icon: publicPath + e.icon.slice(1)
38230
+ })), UNKNOWN_FILE_ICON = publicPath + "file-placeholder/unknown-200-200.png", FILE_SIZE_LIMIT_DEFAULT = 1024 * 1024 * 20;
38203
38231
  class AttachmentFileTypes {
38204
38232
  constructor() {
38205
38233
  A(this, "types", []);