@nocobase/client 0.16.0-alpha.5 → 0.16.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,8 @@ export interface ICollectionTemplate {
17
17
  divider?: boolean;
18
18
  /** 模板描述 */
19
19
  description?: string;
20
+ /**配置字段中的操作按钮 */
21
+ configureActions?: Record<string, ISchema>;
20
22
  }
21
23
  interface AvailableFieldInterfacesInclude {
22
24
  include?: any[];
package/es/index.mjs CHANGED
@@ -3531,7 +3531,7 @@ const BlockTemplate = observer(
3531
3531
  var _a, _b;
3532
3532
  fieldSchema["x-linkage-rules"] = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a["x-linkage-rules"]) || [];
3533
3533
  fieldSchema.setProperties((_b = data == null ? void 0 : data.data) == null ? void 0 : _b.properties);
3534
- onTemplateSuccess();
3534
+ onTemplateSuccess == null ? void 0 : onTemplateSuccess();
3535
3535
  };
3536
3536
  return template2 ? /* @__PURE__ */ jsx(BlockTemplateContext.Provider, { value: { dn, field, fieldSchema, template: template2 }, children: /* @__PURE__ */ jsx(RemoteSchemaComponent, { noForm: true, uid: template2 == null ? void 0 : template2.uid, onSuccess }) }) : null;
3537
3537
  },
@@ -34043,6 +34043,9 @@ const toValue$2 = (value, placeholder) => {
34043
34043
  }
34044
34044
  return value;
34045
34045
  };
34046
+ function isObject(value) {
34047
+ return typeof value === "object" && value !== null;
34048
+ }
34046
34049
  const ReadPrettyInternalViewer = observer(
34047
34050
  (props) => {
34048
34051
  var _a;
@@ -34063,7 +34066,8 @@ const ReadPrettyInternalViewer = observer(
34063
34066
  const isTreeCollection = targetCollection.template === "tree";
34064
34067
  const ellipsisWithTooltipRef = useRef();
34065
34068
  const renderRecords = () => toArr$3(props.value).map((record2, index2, arr) => {
34066
- const label = isTreeCollection ? transformNestedData(record2).map((o) => o == null ? void 0 : o[(fieldNames == null ? void 0 : fieldNames.label) || "label"]).join(" / ") : record2 == null ? void 0 : record2[(fieldNames == null ? void 0 : fieldNames.label) || "label"];
34069
+ const value = record2 == null ? void 0 : record2[(fieldNames == null ? void 0 : fieldNames.label) || "label"];
34070
+ const label = isTreeCollection ? transformNestedData(record2).map((o) => o == null ? void 0 : o[(fieldNames == null ? void 0 : fieldNames.label) || "label"]).join(" / ") : isObject(value) ? JSON.stringify(value) : value;
34067
34071
  const val = toValue$2(compile2(label), "N/A");
34068
34072
  const labelUiSchema = useLabelUiSchema$1(
34069
34073
  (record2 == null ? void 0 : record2.__collection) || (collectionField == null ? void 0 : collectionField.target),
@@ -37913,8 +37917,8 @@ const CollectionSelect = connect(
37913
37917
  }, others), {
37914
37918
  showSearch: true,
37915
37919
  filterOption: (input2, option) => {
37916
- var _a2;
37917
- return ((_a2 = option == null ? void 0 : option.label) != null ? _a2 : "").includes(input2);
37920
+ var _a2, _b;
37921
+ return ((_a2 = option == null ? void 0 : option.label.toLowerCase()) != null ? _a2 : "").includes(input2.toLocaleLowerCase()) || ((_b = option == null ? void 0 : option.value.toString().toLowerCase()) != null ? _b : "").includes(input2.toLocaleLowerCase());
37918
37922
  },
37919
37923
  options
37920
37924
  })
@@ -55473,6 +55477,7 @@ const url = {
55473
55477
  "x-component": "Input.URL"
55474
55478
  }
55475
55479
  },
55480
+ availableTypes: ["string"],
55476
55481
  schemaInitialize(schema3, { block }) {
55477
55482
  },
55478
55483
  properties: __spreadValues({}, defaultProps),
@@ -55783,9 +55788,6 @@ function areEqual(prevProps, nextProps) {
55783
55788
  }
55784
55789
  const PreviewFields = React.memo(PreviewCom, areEqual);
55785
55790
  PreviewFields.displayName = "PreviewFields";
55786
- function isObject(value) {
55787
- return Object.prototype.toString.call(value) === "[object Object]";
55788
- }
55789
55791
  const mapFields = ["lineString", "point", "circle", "polygon"];
55790
55792
  const PreviewTable$1 = (props) => {
55791
55793
  const { databaseView, schema: schema3, viewName, fields: fields2 } = props;
@@ -55844,7 +55846,7 @@ const PreviewTable$1 = (props) => {
55844
55846
  "x-component": schema22 && fieldSource ? "CollectionField" : "Input",
55845
55847
  "x-read-pretty": true,
55846
55848
  "x-collection-field": fieldSource == null ? void 0 : fieldSource.join("."),
55847
- default: isObject(content) ? JSON.stringify(content) : content
55849
+ default: item.interface === "json" ? JSON.stringify(content) : content
55848
55850
  }
55849
55851
  }
55850
55852
  };
@@ -57268,12 +57270,16 @@ const AddFieldAction = (props) => {
57268
57270
  const { exclude, include } = availableFieldInterfaces || {};
57269
57271
  const optionArr = [];
57270
57272
  getOptions$1().forEach((v) => {
57273
+ var _a;
57271
57274
  if (v.key === "systemInfo") {
57272
57275
  optionArr.push(__spreadProps(__spreadValues({}, v), {
57273
57276
  children: v.children.filter((v2) => {
57274
57277
  if (v2.value === "id") {
57275
57278
  return typeof record["autoGenId"] === "boolean" ? record["autoGenId"] : true;
57276
57279
  } else if (v2.value === "tableoid") {
57280
+ if (include == null ? void 0 : include.length) {
57281
+ return include.includes(v2.value);
57282
+ }
57277
57283
  return (database == null ? void 0 : database.dialect) === "postgres";
57278
57284
  } else {
57279
57285
  return typeof record[v2.value] === "boolean" ? record[v2.value] : true;
@@ -57284,19 +57290,20 @@ const AddFieldAction = (props) => {
57284
57290
  let children2 = [];
57285
57291
  if (include == null ? void 0 : include.length) {
57286
57292
  include.forEach((k) => {
57287
- const field = v.children.find((h) => [k, k.interface].includes(h.value));
57293
+ var _a2;
57294
+ const field = (_a2 = v == null ? void 0 : v.children) == null ? void 0 : _a2.find((h) => [k, k.interface].includes(h.value));
57288
57295
  field && children2.push(__spreadProps(__spreadValues({}, field), {
57289
57296
  targetScope: k == null ? void 0 : k.targetScope
57290
57297
  }));
57291
57298
  });
57292
57299
  } else if (exclude == null ? void 0 : exclude.length) {
57293
- children2 = v.children.filter((v2) => {
57300
+ children2 = (_a = v == null ? void 0 : v.children) == null ? void 0 : _a.filter((v2) => {
57294
57301
  return !exclude.includes(v2.value);
57295
57302
  });
57296
57303
  } else {
57297
- children2 = v.children;
57304
+ children2 = v == null ? void 0 : v.children;
57298
57305
  }
57299
- children2.length && optionArr.push(__spreadProps(__spreadValues({}, v), {
57306
+ (children2 == null ? void 0 : children2.length) && optionArr.push(__spreadProps(__spreadValues({}, v), {
57300
57307
  children: children2
57301
57308
  }));
57302
57309
  }
@@ -57332,7 +57339,7 @@ const AddFieldAction = (props) => {
57332
57339
  label: compile2(option.label),
57333
57340
  title: compile2(option.label),
57334
57341
  key: option.label,
57335
- children: option.children.filter((child) => !["o2o", "subTable", "linkTo"].includes(child.name)).map((child) => {
57342
+ children: option == null ? void 0 : option.children.filter((child) => !["o2o", "subTable", "linkTo"].includes(child.name)).map((child) => {
57336
57343
  return {
57337
57344
  role: "button",
57338
57345
  "aria-label": `${compile2(option.label)}-${child.name}`,
@@ -57345,7 +57352,7 @@ const AddFieldAction = (props) => {
57345
57352
  };
57346
57353
  }).filter((v) => {
57347
57354
  var _a;
57348
- return (_a = v.children) == null ? void 0 : _a.length;
57355
+ return (_a = v == null ? void 0 : v.children) == null ? void 0 : _a.length;
57349
57356
  });
57350
57357
  }, [getFieldOptions]);
57351
57358
  const menu = useMemo(() => {
@@ -58491,9 +58498,9 @@ const CurrentFields = (props) => {
58491
58498
  const { t } = useTranslation();
58492
58499
  const { setState } = useResourceActionContext();
58493
58500
  const { resource, targetKey } = props.collectionResource || {};
58494
- const { [targetKey]: filterByTk, titleField } = useRecord();
58501
+ const { [targetKey]: filterByTk, titleField, template: template2 } = useRecord();
58495
58502
  const [loadingRecord, setLoadingRecord] = React.useState(null);
58496
- const { refreshCM, isTitleField } = useCollectionManager();
58503
+ const { refreshCM, isTitleField, getTemplate } = useCollectionManager();
58497
58504
  const columns = [
58498
58505
  {
58499
58506
  dataIndex: ["uiSchema", "rawTitle"],
@@ -58676,16 +58683,17 @@ const InheritFields = (props) => {
58676
58683
  const CollectionFields = () => {
58677
58684
  const compile2 = useCompile();
58678
58685
  const field = useField();
58679
- const { name } = useRecord();
58686
+ const { name, template: template2 } = useRecord();
58680
58687
  const {
58681
58688
  data: { database }
58682
58689
  } = useCurrentAppInfo();
58683
- const { getInterface, getInheritCollections, getCollection, getCurrentCollectionFields } = useCollectionManager();
58690
+ const { getInterface, getInheritCollections, getCollection, getCurrentCollectionFields, getTemplate } = useCollectionManager();
58684
58691
  const form = useMemo(() => createForm(), []);
58685
58692
  const f = useAttach(form.createArrayField(__spreadProps(__spreadValues({}, field.props), { basePath: "" })));
58686
58693
  const { t } = useTranslation();
58687
58694
  const collectionResource = useResourceContext();
58688
58695
  const { refreshAsync } = useContext(ResourceActionContext);
58696
+ const targetTemplate = getTemplate(template2);
58689
58697
  const inherits = getInheritCollections(name);
58690
58698
  const columns = [
58691
58699
  {
@@ -58825,6 +58833,15 @@ const CollectionFields = () => {
58825
58833
  /* @__PURE__ */ jsx(Action, __spreadValues({}, deleteProps)),
58826
58834
  /* @__PURE__ */ jsx(SyncFieldsAction, __spreadValues({}, syncProps)),
58827
58835
  /* @__PURE__ */ jsx(SyncSQLFieldsAction, { refreshCMList: refreshAsync }),
58836
+ /* @__PURE__ */ jsx(
58837
+ SchemaComponent,
58838
+ {
58839
+ schema: {
58840
+ type: "object",
58841
+ properties: __spreadValues({}, targetTemplate.configureActions)
58842
+ }
58843
+ }
58844
+ ),
58828
58845
  /* @__PURE__ */ jsx(AddCollectionField, __spreadValues({}, addProps))
58829
58846
  ]
58830
58847
  }
package/lib/index.js CHANGED
@@ -4183,7 +4183,7 @@ const BlockTemplate = (0, import_react.observer)(
4183
4183
  var _a, _b;
4184
4184
  fieldSchema["x-linkage-rules"] = ((_a = data == null ? void 0 : data.data) == null ? void 0 : _a["x-linkage-rules"]) || [];
4185
4185
  fieldSchema.setProperties((_b = data == null ? void 0 : data.data) == null ? void 0 : _b.properties);
4186
- onTemplateSuccess();
4186
+ onTemplateSuccess == null ? void 0 : onTemplateSuccess();
4187
4187
  };
4188
4188
  return template2 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockTemplateContext.Provider, { value: { dn, field, fieldSchema, template: template2 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RemoteSchemaComponent, { noForm: true, uid: template2 == null ? void 0 : template2.uid, onSuccess }) }) : null;
4189
4189
  },
@@ -34695,6 +34695,9 @@ const toValue$2 = (value, placeholder) => {
34695
34695
  }
34696
34696
  return value;
34697
34697
  };
34698
+ function isObject(value) {
34699
+ return typeof value === "object" && value !== null;
34700
+ }
34698
34701
  const ReadPrettyInternalViewer = (0, import_react.observer)(
34699
34702
  (props) => {
34700
34703
  var _a;
@@ -34715,7 +34718,8 @@ const ReadPrettyInternalViewer = (0, import_react.observer)(
34715
34718
  const isTreeCollection = targetCollection.template === "tree";
34716
34719
  const ellipsisWithTooltipRef = (0, import_react2.useRef)();
34717
34720
  const renderRecords = () => (0, import_shared.toArr)(props.value).map((record2, index2, arr) => {
34718
- const label = isTreeCollection ? transformNestedData(record2).map((o) => o == null ? void 0 : o[(fieldNames == null ? void 0 : fieldNames.label) || "label"]).join(" / ") : record2 == null ? void 0 : record2[(fieldNames == null ? void 0 : fieldNames.label) || "label"];
34721
+ const value = record2 == null ? void 0 : record2[(fieldNames == null ? void 0 : fieldNames.label) || "label"];
34722
+ const label = isTreeCollection ? transformNestedData(record2).map((o) => o == null ? void 0 : o[(fieldNames == null ? void 0 : fieldNames.label) || "label"]).join(" / ") : isObject(value) ? JSON.stringify(value) : value;
34719
34723
  const val = toValue$2(compile2(label), "N/A");
34720
34724
  const labelUiSchema = useLabelUiSchema$1(
34721
34725
  (record2 == null ? void 0 : record2.__collection) || (collectionField == null ? void 0 : collectionField.target),
@@ -38565,8 +38569,8 @@ const CollectionSelect = (0, import_react.connect)(
38565
38569
  }, others), {
38566
38570
  showSearch: true,
38567
38571
  filterOption: (input2, option) => {
38568
- var _a2;
38569
- return ((_a2 = option == null ? void 0 : option.label) != null ? _a2 : "").includes(input2);
38572
+ var _a2, _b;
38573
+ return ((_a2 = option == null ? void 0 : option.label.toLowerCase()) != null ? _a2 : "").includes(input2.toLocaleLowerCase()) || ((_b = option == null ? void 0 : option.value.toString().toLowerCase()) != null ? _b : "").includes(input2.toLocaleLowerCase());
38570
38574
  },
38571
38575
  options
38572
38576
  })
@@ -56124,6 +56128,7 @@ const url = {
56124
56128
  "x-component": "Input.URL"
56125
56129
  }
56126
56130
  },
56131
+ availableTypes: ["string"],
56127
56132
  schemaInitialize(schema3, { block }) {
56128
56133
  },
56129
56134
  properties: __spreadValues({}, defaultProps),
@@ -56434,9 +56439,6 @@ function areEqual(prevProps, nextProps) {
56434
56439
  }
56435
56440
  const PreviewFields = import_react2.default.memo(PreviewCom, areEqual);
56436
56441
  PreviewFields.displayName = "PreviewFields";
56437
- function isObject(value) {
56438
- return Object.prototype.toString.call(value) === "[object Object]";
56439
- }
56440
56442
  const mapFields = ["lineString", "point", "circle", "polygon"];
56441
56443
  const PreviewTable$1 = (props) => {
56442
56444
  const { databaseView, schema: schema3, viewName, fields: fields2 } = props;
@@ -56495,7 +56497,7 @@ const PreviewTable$1 = (props) => {
56495
56497
  "x-component": schema22 && fieldSource ? "CollectionField" : "Input",
56496
56498
  "x-read-pretty": true,
56497
56499
  "x-collection-field": fieldSource == null ? void 0 : fieldSource.join("."),
56498
- default: isObject(content) ? JSON.stringify(content) : content
56500
+ default: item.interface === "json" ? JSON.stringify(content) : content
56499
56501
  }
56500
56502
  }
56501
56503
  };
@@ -57919,12 +57921,16 @@ const AddFieldAction = (props) => {
57919
57921
  const { exclude, include } = availableFieldInterfaces || {};
57920
57922
  const optionArr = [];
57921
57923
  getOptions$1().forEach((v) => {
57924
+ var _a;
57922
57925
  if (v.key === "systemInfo") {
57923
57926
  optionArr.push(__spreadProps(__spreadValues({}, v), {
57924
57927
  children: v.children.filter((v2) => {
57925
57928
  if (v2.value === "id") {
57926
57929
  return typeof record["autoGenId"] === "boolean" ? record["autoGenId"] : true;
57927
57930
  } else if (v2.value === "tableoid") {
57931
+ if (include == null ? void 0 : include.length) {
57932
+ return include.includes(v2.value);
57933
+ }
57928
57934
  return (database == null ? void 0 : database.dialect) === "postgres";
57929
57935
  } else {
57930
57936
  return typeof record[v2.value] === "boolean" ? record[v2.value] : true;
@@ -57935,19 +57941,20 @@ const AddFieldAction = (props) => {
57935
57941
  let children2 = [];
57936
57942
  if (include == null ? void 0 : include.length) {
57937
57943
  include.forEach((k) => {
57938
- const field = v.children.find((h) => [k, k.interface].includes(h.value));
57944
+ var _a2;
57945
+ const field = (_a2 = v == null ? void 0 : v.children) == null ? void 0 : _a2.find((h) => [k, k.interface].includes(h.value));
57939
57946
  field && children2.push(__spreadProps(__spreadValues({}, field), {
57940
57947
  targetScope: k == null ? void 0 : k.targetScope
57941
57948
  }));
57942
57949
  });
57943
57950
  } else if (exclude == null ? void 0 : exclude.length) {
57944
- children2 = v.children.filter((v2) => {
57951
+ children2 = (_a = v == null ? void 0 : v.children) == null ? void 0 : _a.filter((v2) => {
57945
57952
  return !exclude.includes(v2.value);
57946
57953
  });
57947
57954
  } else {
57948
- children2 = v.children;
57955
+ children2 = v == null ? void 0 : v.children;
57949
57956
  }
57950
- children2.length && optionArr.push(__spreadProps(__spreadValues({}, v), {
57957
+ (children2 == null ? void 0 : children2.length) && optionArr.push(__spreadProps(__spreadValues({}, v), {
57951
57958
  children: children2
57952
57959
  }));
57953
57960
  }
@@ -57983,7 +57990,7 @@ const AddFieldAction = (props) => {
57983
57990
  label: compile2(option.label),
57984
57991
  title: compile2(option.label),
57985
57992
  key: option.label,
57986
- children: option.children.filter((child) => !["o2o", "subTable", "linkTo"].includes(child.name)).map((child) => {
57993
+ children: option == null ? void 0 : option.children.filter((child) => !["o2o", "subTable", "linkTo"].includes(child.name)).map((child) => {
57987
57994
  return {
57988
57995
  role: "button",
57989
57996
  "aria-label": `${compile2(option.label)}-${child.name}`,
@@ -57996,7 +58003,7 @@ const AddFieldAction = (props) => {
57996
58003
  };
57997
58004
  }).filter((v) => {
57998
58005
  var _a;
57999
- return (_a = v.children) == null ? void 0 : _a.length;
58006
+ return (_a = v == null ? void 0 : v.children) == null ? void 0 : _a.length;
58000
58007
  });
58001
58008
  }, [getFieldOptions]);
58002
58009
  const menu = (0, import_react2.useMemo)(() => {
@@ -59142,9 +59149,9 @@ const CurrentFields = (props) => {
59142
59149
  const { t } = (0, import_react_i18next.useTranslation)();
59143
59150
  const { setState } = useResourceActionContext();
59144
59151
  const { resource, targetKey } = props.collectionResource || {};
59145
- const { [targetKey]: filterByTk, titleField } = useRecord();
59152
+ const { [targetKey]: filterByTk, titleField, template: template2 } = useRecord();
59146
59153
  const [loadingRecord, setLoadingRecord] = import_react2.default.useState(null);
59147
- const { refreshCM, isTitleField } = useCollectionManager();
59154
+ const { refreshCM, isTitleField, getTemplate } = useCollectionManager();
59148
59155
  const columns = [
59149
59156
  {
59150
59157
  dataIndex: ["uiSchema", "rawTitle"],
@@ -59327,16 +59334,17 @@ const InheritFields = (props) => {
59327
59334
  const CollectionFields = () => {
59328
59335
  const compile2 = useCompile();
59329
59336
  const field = (0, import_react.useField)();
59330
- const { name } = useRecord();
59337
+ const { name, template: template2 } = useRecord();
59331
59338
  const {
59332
59339
  data: { database }
59333
59340
  } = useCurrentAppInfo();
59334
- const { getInterface, getInheritCollections, getCollection, getCurrentCollectionFields } = useCollectionManager();
59341
+ const { getInterface, getInheritCollections, getCollection, getCurrentCollectionFields, getTemplate } = useCollectionManager();
59335
59342
  const form = (0, import_react2.useMemo)(() => (0, import_core2.createForm)(), []);
59336
59343
  const f = useAttach(form.createArrayField(__spreadProps(__spreadValues({}, field.props), { basePath: "" })));
59337
59344
  const { t } = (0, import_react_i18next.useTranslation)();
59338
59345
  const collectionResource = useResourceContext();
59339
59346
  const { refreshAsync } = (0, import_react2.useContext)(ResourceActionContext);
59347
+ const targetTemplate = getTemplate(template2);
59340
59348
  const inherits = getInheritCollections(name);
59341
59349
  const columns = [
59342
59350
  {
@@ -59476,6 +59484,15 @@ const CollectionFields = () => {
59476
59484
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Action, __spreadValues({}, deleteProps)),
59477
59485
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncFieldsAction, __spreadValues({}, syncProps)),
59478
59486
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SyncSQLFieldsAction, { refreshCMList: refreshAsync }),
59487
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59488
+ SchemaComponent,
59489
+ {
59490
+ schema: {
59491
+ type: "object",
59492
+ properties: __spreadValues({}, targetTemplate.configureActions)
59493
+ }
59494
+ }
59495
+ ),
59479
59496
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AddCollectionField, __spreadValues({}, addProps))
59480
59497
  ]
59481
59498
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/client",
3
- "version": "0.16.0-alpha.5",
3
+ "version": "0.16.0-alpha.6",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.mjs",
@@ -25,9 +25,9 @@
25
25
  "@formily/reactive-react": "^2.2.27",
26
26
  "@formily/shared": "^2.2.27",
27
27
  "@formily/validator": "^2.2.27",
28
- "@nocobase/evaluators": "0.16.0-alpha.5",
29
- "@nocobase/sdk": "0.16.0-alpha.5",
30
- "@nocobase/utils": "0.16.0-alpha.5",
28
+ "@nocobase/evaluators": "0.16.0-alpha.6",
29
+ "@nocobase/sdk": "0.16.0-alpha.6",
30
+ "@nocobase/utils": "0.16.0-alpha.6",
31
31
  "@types/requirejs": "^2.1.34",
32
32
  "ahooks": "^3.7.2",
33
33
  "antd": "^5.8.6",
@@ -76,5 +76,5 @@
76
76
  "dumi": "^2.2.0",
77
77
  "dumi-theme-nocobase": "^0.2.14"
78
78
  },
79
- "gitHead": "3badd2569e4658023897fa381ac4dd30e64d5bce"
79
+ "gitHead": "e8ad2328a8f85289cb19a7994d3fd726c7ae1720"
80
80
  }