@steedos-widgets/amis-lib 3.6.4-beta.3 → 3.6.4-beta.5

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/dist/index.cjs.js CHANGED
@@ -1680,7 +1680,8 @@ i18next__default["default"]
1680
1680
  }
1681
1681
  });
1682
1682
 
1683
- async function getQuickEditSchema(field, options){
1683
+ async function getQuickEditSchema(object, columnField, options){
1684
+ let field = object.fields[columnField.name];
1684
1685
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
1685
1686
  let isAmisVersionforBatchEdit = false;
1686
1687
  if(window.amisRequire && window.amisRequire('amis')){
@@ -2148,7 +2149,7 @@ function getFieldWidth(width){
2148
2149
  }
2149
2150
  }
2150
2151
 
2151
- async function getTableColumns(fields, options){
2152
+ async function getTableColumns(object, fields, options){
2152
2153
  const columns = [];
2153
2154
  if(!options.isLookup && !options.isInputTable){
2154
2155
  if(!options.enable_tree){
@@ -2162,7 +2163,7 @@ async function getTableColumns(fields, options){
2162
2163
  continue;
2163
2164
  }
2164
2165
  //增加quickEdit属性,实现快速编辑
2165
- const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2166
+ const quickEditSchema = allowEdit ? await getQuickEditSchema(object, field, options) : allowEdit;
2166
2167
  let className = "";
2167
2168
  const bowserType = getBowserType();
2168
2169
  if(bowserType === "Safari"){
@@ -2676,7 +2677,7 @@ async function getTableOperation(ctx){
2676
2677
  "label": "xxx",
2677
2678
  "buttons": operationButtons,
2678
2679
  "placement": "bottomRight",
2679
- "overlayClassName": "shadow !min-w-[160px]",
2680
+ "overlayClassName": "border rounded !min-w-[160px]",
2680
2681
  "trigger": ["click"],
2681
2682
  "id": "u:c2140a365019",
2682
2683
  onOpenApi: {
@@ -2734,7 +2735,7 @@ async function getDefaultCrudCard(columns, options) {
2734
2735
  return card;
2735
2736
  }
2736
2737
 
2737
- async function getTableSchema$1(fields, options){
2738
+ async function getTableSchema$1(object, fields, options){
2738
2739
  if(!options){
2739
2740
  options = {};
2740
2741
  }
@@ -2756,7 +2757,7 @@ async function getTableSchema$1(fields, options){
2756
2757
  columns = await getMobileTableColumns(fields, options);
2757
2758
  }
2758
2759
  else {
2759
- columns = await getTableColumns(fields, options);
2760
+ columns = await getTableColumns(object, fields, options);
2760
2761
 
2761
2762
  if(listSchema.mode === "cards"){
2762
2763
  let card = listSchema.card;
@@ -5754,6 +5755,7 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
5754
5755
  type: "steedos-dropdown-button",
5755
5756
  label: "",
5756
5757
  buttons: moreButtons,
5758
+ "overlayClassName": "border rounded !min-w-[160px]",
5757
5759
  className: 'slds-icon ml-1',
5758
5760
  visibleOn: moreButtonsVisibleOn
5759
5761
  };
@@ -8844,7 +8846,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8844
8846
  crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
8845
8847
  }, options);
8846
8848
  tableOptions.amisData = createObject(options.amisData || {}, {});
8847
- const table = await getTableSchema$1(fields, tableOptions);
8849
+ const table = await getTableSchema$1(objectSchema, fields, tableOptions);
8848
8850
  // delete table.mode;
8849
8851
  //image与avatar需要在提交修改时特别处理
8850
8852
  const imageNames = ___default["default"].compact(___default["default"].map(___default["default"].filter(fields, (field) => ["image","avatar"].includes(field.type)), 'name'));
@@ -9111,7 +9113,7 @@ async function getObjectForm(objectSchema, ctx){
9111
9113
  body: {
9112
9114
  type: 'wrapper',
9113
9115
  className: 'p-0 m-0',
9114
- body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
9116
+ body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups, omitReadonlyFields: true})),
9115
9117
  hiddenOn: "${editFormInited != true}",
9116
9118
  },
9117
9119
  panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
@@ -9719,8 +9721,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9719
9721
  /*
9720
9722
  * @Author: baozhoutao@steedos.com
9721
9723
  * @Date: 2022-07-05 15:55:39
9722
- * @LastEditors: baozhoutao@steedos.com
9723
- * @LastEditTime: 2024-02-18 16:05:21
9724
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9725
+ * @LastEditTime: 2024-02-23 16:37:06
9724
9726
  * @Description:
9725
9727
  */
9726
9728
 
@@ -10068,6 +10070,7 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10068
10070
  let fields = [];
10069
10071
  for (const column of columns) {
10070
10072
  if (_$1.isString(column)) {
10073
+ let columnField;
10071
10074
  if (column.indexOf('.') > 0) {
10072
10075
  const fieldName = column.split('.')[0];
10073
10076
  const displayName = column.split('.')[1];
@@ -10075,23 +10078,30 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10075
10078
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)) {
10076
10079
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
10077
10080
  const rfFieldInfo = rfUiSchema.fields[displayName];
10078
- fields.push(Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx));
10081
+ columnField = Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx);
10079
10082
  }else if(filedInfo && filedInfo.type === 'object'){
10080
- fields.push(uiSchema.fields[column]);
10083
+ columnField = uiSchema.fields[column];
10081
10084
  }
10082
10085
  } else {
10083
10086
  if (uiSchema.fields[column]) {
10084
- fields.push(Object.assign({}, uiSchema.fields[column], ctx));
10087
+ columnField = Object.assign({}, uiSchema.fields[column], ctx);
10085
10088
  }
10086
10089
  else if(ctx.extra){
10087
10090
  // 配置列表视图extra_columns时允许字段是hidden的,hidden的字段在uiSchema.fields中不存在
10088
- fields.push({
10091
+ columnField = {
10089
10092
  extra: true,
10090
10093
  name: column
10091
- });
10094
+ };
10092
10095
  }
10093
10096
  }
10097
+ if(columnField){
10098
+ // 列上的字段不认uiSchema.fields中定义的amis属性
10099
+ columnField = Object.assign({}, columnField, {amis: undefined});
10100
+ fields.push(columnField);
10101
+ }
10102
+
10094
10103
  } else if (_$1.isObject(column)) {
10104
+ let columnField;
10095
10105
  if (column.field.indexOf('.') > 0) {
10096
10106
  const fieldName = column.field.split('.')[0];
10097
10107
  const displayName = column.field.split('.')[1];
@@ -10099,33 +10109,34 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10099
10109
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)) {
10100
10110
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
10101
10111
  const rfFieldInfo = rfUiSchema.fields[displayName];
10102
- fields.push(Object.assign({}, rfFieldInfo, ctx,
10112
+ columnField = Object.assign({}, rfFieldInfo, ctx,
10103
10113
  { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
10104
10114
  {
10105
10115
  width: column.width,
10106
- wrap: column.wrap, // wrap = true 是没效果的
10107
- amis: column.amis
10116
+ wrap: column.wrap // wrap = true 是没效果的
10108
10117
  }
10109
- ));
10118
+ );
10110
10119
  }
10111
10120
  } else {
10112
10121
  if (uiSchema.fields[column.field]) {
10113
- fields.push(
10114
- Object.assign({}, uiSchema.fields[column.field], ctx, {
10115
- width: column.width,
10116
- wrap: column.wrap, // wrap = true 是没效果的
10117
- amis: column.amis
10118
- })
10119
- );
10122
+ columnField = Object.assign({}, uiSchema.fields[column.field], ctx, {
10123
+ width: column.width,
10124
+ wrap: column.wrap // wrap = true 是没效果的
10125
+ });
10120
10126
  }
10121
10127
  else if(ctx.extra){
10122
10128
  // 配置列表视图extra_columns时允许字段是hidden的,hidden的字段在uiSchema.fields中不存在
10123
- fields.push({
10129
+ columnField = {
10124
10130
  extra: true,
10125
10131
  name: column.field
10126
- });
10132
+ };
10127
10133
  }
10128
10134
  }
10135
+ if(columnField){
10136
+ // 列上的字段不认uiSchema.fields中定义的amis属性,用列上配置的amis覆盖
10137
+ columnField = Object.assign({}, columnField, {amis: column.amis});
10138
+ fields.push(columnField);
10139
+ }
10129
10140
  }
10130
10141
  }
10131
10142
  return fields;
@@ -10239,7 +10250,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
10239
10250
  };
10240
10251
  const content = {
10241
10252
  "type": "tabs",
10242
- "className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
10253
+ "className": "steedos-record-tabs bg-white p-4 mt-2",
10243
10254
  "contentClassName": "bg-none",
10244
10255
  "tabs": [
10245
10256
  detailed
@@ -11455,7 +11466,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
11455
11466
  if(refObjectConfig.name === 'organizations'){
11456
11467
  labelFieldName = 'name';
11457
11468
  }
11458
- pickerSchema = await getTableSchema$1(tableFields, {
11469
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
11459
11470
  labelFieldName,
11460
11471
  top: top,
11461
11472
  isLookup: true,
@@ -12063,7 +12074,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
12063
12074
  actions: false
12064
12075
  });
12065
12076
  }else {
12066
- pickerSchema = await getTableSchema$1(tableFields, {
12077
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
12067
12078
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
12068
12079
  top: top,
12069
12080
  isLookup: true,
@@ -13210,15 +13221,15 @@ var index = /*#__PURE__*/Object.freeze({
13210
13221
  /*
13211
13222
  * @Author: baozhoutao@steedos.com
13212
13223
  * @Date: 2022-05-26 16:02:08
13213
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13214
- * @LastEditTime: 2023-11-29 17:48:27
13224
+ * @LastEditors: yinlianghui@hotoa.com yinlianghui@hotoa.com
13225
+ * @LastEditTime: 2024-02-25 14:13:10
13215
13226
  * @Description:
13216
13227
  */
13217
13228
 
13218
13229
  const getFieldSchemaArray = (formFields, ctx) => {
13219
13230
  let fieldSchemaArray = [];
13220
13231
  fieldSchemaArray.length = 0;
13221
- const recordId = ctx && ctx.recordId;
13232
+ ctx && ctx.recordId;
13222
13233
 
13223
13234
  ___namespace.forEach(formFields, (field) => {
13224
13235
  if (!field.group || field.group == 'null' || field.group == '-')
@@ -13231,9 +13242,7 @@ const getFieldSchemaArray = (formFields, ctx) => {
13231
13242
  }
13232
13243
 
13233
13244
  let forceHidden = false;
13234
- if(!recordId && field.readonly && !ctx.isEditor){
13235
- // 新建记录时,只读字段先隐藏,后续支持显示后,即任务:https://github.com/steedos/steedos-platform/issues/3164 完成后再放开
13236
- // 表单只读时所有字段都是readonly,设计器中如果forceHidden会造成整个表单在只读的时候显示为空白了,所以要排除掉
13245
+ if(ctx.omitReadonlyFields && field.readonly){
13237
13246
  forceHidden = true;
13238
13247
  }
13239
13248
 
@@ -13693,10 +13702,32 @@ async function getInputTableColumns(props) {
13693
13702
  // 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
13694
13703
 
13695
13704
  let fieldPrefix = props.fieldPrefix;
13696
- let fields = props.fields || [];
13705
+ let fields = _$1.cloneDeep(props.fields || []);
13697
13706
  if (fieldPrefix) {
13698
13707
  fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
13699
13708
  }
13709
+ if (inlineEditMode == true) {
13710
+ let popOverContainerSelector = "";
13711
+ let popOverContainer = props.popOverContainer && props.popOverContainer();
13712
+ //获取到当前input-table所处的popOverContainer(可能是modal-dialog中),
13713
+ //给所有的下拉框字段配置popOverContainerSelector,使下拉框组件的弹出框挂载到当前dialog上,防止被dialog遮挡
13714
+ if (popOverContainer) {
13715
+ let classList = Array.prototype.slice.call(popOverContainer.parentElement.classList);
13716
+ if (classList.includes('amis-dialog-widget')) {
13717
+ popOverContainerSelector = '.' + classList.join('.') + ' .antd-Modal-content';
13718
+ }
13719
+ }
13720
+ fields.forEach(function (field) {
13721
+ //lookup存在下拉框模式;弹出模式用的是picker组件,不认popOverContainerSelector属性,所以统一加上
13722
+ if (field.type == "select" || field.type == "lookup") {
13723
+ field.amis = {
13724
+ ...field.amis,
13725
+ popOverContainerSelector
13726
+ };
13727
+ }
13728
+ });
13729
+ }
13730
+
13700
13731
  if (columns && columns.length) {
13701
13732
  return columns.map(function (column) {
13702
13733
  let field, extendColumnProps = {};
@@ -13746,7 +13777,7 @@ async function getInputTableColumns(props) {
13746
13777
  }
13747
13778
  else {
13748
13779
  return fields.map(function (field) {
13749
- let tableCell = getInputTableCell(field, showAsInlineEditMode);
13780
+ let tableCell = getInputTableCell(field, showAsInlineEditMode);
13750
13781
  tableCell.className = " whitespace-nowrap ";
13751
13782
  return tableCell;
13752
13783
  }) || [];
@@ -14713,7 +14744,7 @@ async function getButtonDelete(props) {
14713
14744
  return {
14714
14745
  "type": "dropdown-button",
14715
14746
  "level": "link",
14716
- "btnClassName": "text-gray-400",
14747
+ "btnClassName": "text-gray-400 steedos-delete-button",
14717
14748
  "icon": "fa fa-trash-alt",
14718
14749
  "size": "xs",
14719
14750
  "hideCaret": true,
@@ -14876,11 +14907,11 @@ const getAmisInputTableSchema = async (props) => {
14876
14907
  }
14877
14908
  };
14878
14909
  if (buttonsForColumnOperations.length) {
14879
- inputTableSchema.columns.push({
14910
+ inputTableSchema.columns.unshift({
14880
14911
  "name": "__op__",
14881
14912
  "type": "operation",
14882
14913
  "buttons": buttonsForColumnOperations,
14883
- "width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
14914
+ "width": 1
14884
14915
  });
14885
14916
  }
14886
14917
  // if (showAsInlineEditMode) {
@@ -14929,6 +14960,18 @@ const getAmisInputTableSchema = async (props) => {
14929
14960
  }
14930
14961
  let className = "steedos-input-table";
14931
14962
 
14963
+ if (props.showIndex) {
14964
+ className += " steedos-show-index";
14965
+ }
14966
+
14967
+ if (buttonsForColumnOperations.length) {
14968
+ className += " steedos-has-operations";
14969
+ }
14970
+
14971
+ if (props.enableTree) {
14972
+ className += " steedos-tree-mode";
14973
+ }
14974
+
14932
14975
  if (typeof props.className == "object") {
14933
14976
  className = {
14934
14977
  [className]: "true",