@steedos-widgets/amis-lib 3.6.4-beta.1 → 3.6.4-beta.2

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.esm.js CHANGED
@@ -484,7 +484,7 @@ function getComparableAmisVersion() {
484
484
  * @Author: baozhoutao@steedos.com
485
485
  * @Date: 2022-05-23 09:53:08
486
486
  * @LastEditors: baozhoutao@steedos.com
487
- * @LastEditTime: 2024-02-19 11:57:49
487
+ * @LastEditTime: 2024-02-21 17:19:30
488
488
  * @Description:
489
489
  */
490
490
 
@@ -570,7 +570,7 @@ function getNameTpl(field, ctx){
570
570
  if(ctx && ctx.isLookup){
571
571
  linkTarget = "target='_blank'";
572
572
  }
573
- if(ctx.isRelated){
573
+ if(ctx.isRelated && window.innerWidth >= 768){
574
574
  return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
575
575
  }else {
576
576
  return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
@@ -628,7 +628,7 @@ function getRelatedFieldTpl(field, ctx){
628
628
  const href = Router.getObjectDetailPath({
629
629
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
630
630
  });
631
- if(ctx.isRelated){
631
+ if(ctx.isRelated && window.innerWidth >= 768){
632
632
  labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
633
633
  }else {
634
634
  labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
@@ -2285,7 +2285,7 @@ async function getTableColumns(fields, options){
2285
2285
  columnItem.defaultColor = null;
2286
2286
  }
2287
2287
 
2288
- if(((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && _$1.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2288
+ if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && _$1.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2289
2289
 
2290
2290
  const drawerRecordDetailSchema = {
2291
2291
  "type": "steedos-record-detail",
@@ -2313,16 +2313,17 @@ async function getTableColumns(fields, options){
2313
2313
  "drawer": {
2314
2314
  "type": "drawer",
2315
2315
  "title": "&nbsp;",
2316
- "headerClassName": "",
2316
+ "headerClassName": "hidden",
2317
2317
  "size": "lg",
2318
- "bodyClassName": "p-0 m-0 border-t",
2318
+ "bodyClassName": "p-0 m-0",
2319
2319
  "closeOnEsc": true,
2320
+ "closeOnOutside": true,
2320
2321
  "resizable": true,
2321
2322
  "actions": [],
2322
2323
  "body": [
2323
2324
  drawerRecordDetailSchema
2324
2325
  ],
2325
- "className": "app-popover",
2326
+ "className": "steedos-record-detail-drawer app-popover",
2326
2327
  "id": "u:fc5f055afa8c"
2327
2328
  },
2328
2329
  "preventDefault": true
@@ -2380,7 +2381,7 @@ function getMobileLines(tpls){
2380
2381
  let isNewLine = false;
2381
2382
  let isLeft = true;
2382
2383
  let lineChildrenClassName = "";
2383
- let lineClassName = "flex items-center justify-between";
2384
+ let lineClassName = "flex items-center justify-between mb-1";
2384
2385
  tpls.forEach(function(item){
2385
2386
  if(isNewLine && lines.length < maxLineCount){
2386
2387
  lines.push({
@@ -5680,44 +5681,46 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
5680
5681
  }
5681
5682
  });
5682
5683
 
5683
- return {
5684
- "type": "button",
5685
- "icon": "fa fa-angle-down",
5686
- "visibleOn": phoneMoreButtonsVisibleOn,
5687
- "onEvent": {
5688
- "click": {
5689
- "actions": [
5690
- {
5691
- "actionType": "drawer",
5692
- "drawer": {
5693
- "type": "drawer",
5694
- "title": i18next.t('frontend_operation'),
5695
- "id": "object_actions_drawer_" + objectSchema.name,
5696
- "body": [
5697
- {
5698
- "type": "button-group",
5699
- "id": "u:fd837823be5b",
5700
- "vertical": true,
5701
- "tiled": true,
5702
- "buttons": dropdownButtons,
5703
- "btnLevel": "enhance",
5704
- "className": "w-full",
5705
- "btnClassName": "w-full",
5706
- "size": "lg"
5684
+ return [
5685
+ {
5686
+ "type": "button",
5687
+ "icon": "fa fa-angle-down",
5688
+ "visibleOn": phoneMoreButtonsVisibleOn,
5689
+ "onEvent": {
5690
+ "click": {
5691
+ "actions": [
5692
+ {
5693
+ "actionType": "drawer",
5694
+ "drawer": {
5695
+ "type": "drawer",
5696
+ "title": i18next.t('frontend_operation'),
5697
+ "id": "object_actions_drawer_" + objectSchema.name,
5698
+ "body": [
5699
+ {
5700
+ "type": "button-group",
5701
+ "id": "u:fd837823be5b",
5702
+ "vertical": true,
5703
+ "tiled": true,
5704
+ "buttons": dropdownButtons,
5705
+ "btnLevel": "enhance",
5706
+ "className": "w-full",
5707
+ "btnClassName": "w-full",
5708
+ "size": "lg"
5709
+ }
5710
+ ],
5711
+ "position": "bottom",
5712
+ "closeOnOutside": true,
5713
+ "resizable": false,
5714
+ "className": "buttons-drawer",
5715
+ "bodyClassName": "m-none p-none",
5716
+ "actions": []
5707
5717
  }
5708
- ],
5709
- "position": "bottom",
5710
- "closeOnOutside": true,
5711
- "resizable": false,
5712
- "className": "buttons-drawer",
5713
- "bodyClassName": "m-none p-none",
5714
- "actions": []
5715
- }
5718
+ }
5719
+ ]
5716
5720
  }
5717
- ]
5721
+ }
5718
5722
  }
5719
- }
5720
- }
5723
+ ]
5721
5724
  }else {
5722
5725
  if(moreButtons.length > 0){
5723
5726
  const dropdownButtonsSchema = {
@@ -6786,6 +6789,33 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6786
6789
  amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6787
6790
  }
6788
6791
 
6792
+ amisButtonsSchema.push(
6793
+ {
6794
+ "type": "button",
6795
+ "visibleOn": "${_inDrawer === true || _inRecordMini === true}",
6796
+ "className":"ant-dropdown-trigger slds-button slds-button_icon slds-button_icon-border-filled slds-button_icon-x-small slds-icon ml-1 flex",
6797
+ "onEvent": {
6798
+ "click": {
6799
+ "actions": [
6800
+ {
6801
+ "actionType": "custom",
6802
+ "script": "const data = event.data; window.open(`/app/${data.app_id}/${data.objectName}/view/${data.recordId}?side_object=${data.side_object}&side_listview_id=${data.side_listview_id}`)"
6803
+ }
6804
+ ]
6805
+ }
6806
+ },
6807
+ "body": [
6808
+ {
6809
+ "type": "steedos-icon",
6810
+ "category": "utility",
6811
+ "name": "new_window",
6812
+ "colorVariant": "default",
6813
+ "className": "slds-button_icon slds-global-header__icon w-4"
6814
+ }
6815
+ ]
6816
+ }
6817
+ );
6818
+
6789
6819
  let backButtonsSchema = null;
6790
6820
 
6791
6821
  if(options.showBackButton != false){
@@ -6806,7 +6836,32 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6806
6836
  "columns": [
6807
6837
  {
6808
6838
  "body": [
6809
- backButtonsSchema
6839
+ backButtonsSchema,
6840
+ {
6841
+ "type": "button",
6842
+ "visibleOn": "${_inDrawer === true}",
6843
+ "className":"flex mr-4",
6844
+ "onEvent": {
6845
+ "click": {
6846
+ "actions": [
6847
+ {
6848
+ "componentId": "",
6849
+ "args": {},
6850
+ "actionType": "closeDrawer"
6851
+ }
6852
+ ]
6853
+ }
6854
+ },
6855
+ "body": [
6856
+ {
6857
+ "type": "steedos-icon",
6858
+ "category": "utility",
6859
+ "name": "close",
6860
+ "colorVariant": "default",
6861
+ "className": "slds-button_icon slds-global-header__icon w-4"
6862
+ }
6863
+ ]
6864
+ }
6810
6865
  ,{
6811
6866
  "type": "tpl",
6812
6867
  "className": "block",
@@ -7021,10 +7076,10 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
7021
7076
  "md": "auto"
7022
7077
  }
7023
7078
  ],
7024
- "className": "flex justify-between"
7079
+ "className": "flex justify-between min-h-8 items-center"
7025
7080
  }
7026
7081
  ],
7027
- "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
7082
+ "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border rounded"
7028
7083
  };
7029
7084
  return recordRelatedListHeader;
7030
7085
  }
@@ -11734,6 +11789,33 @@ async function getApi(object, recordId, fields, options){
11734
11789
  }
11735
11790
  }
11736
11791
 
11792
+ async function getAutoFill(field, refObject) {
11793
+ let autoFillMapping = field.auto_fill_mapping;
11794
+ if (autoFillMapping && autoFillMapping.length) {
11795
+ let fillMapping = {};
11796
+ let fieldsForApi = [];
11797
+ autoFillMapping.forEach(function (item) {
11798
+ fillMapping[item.to] = `\${${item.from}}`;
11799
+ fieldsForApi.push(item.from);
11800
+ });
11801
+ // let api = {
11802
+ // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
11803
+ // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
11804
+ // // "responseData": {
11805
+ // // "name": "${name}"
11806
+ // // },
11807
+ // "silent": false
11808
+ // }
11809
+ // return {
11810
+ // fillMapping,
11811
+ // // api
11812
+ // }
11813
+ // 因为autoFill中配置了api的话,在表单初始化(比如新建记录)时并不会触发执行autoFill,所以只能暂时不用api
11814
+ // 给amis报过问题了,见:https://github.com/baidu/amis/issues/9631
11815
+ return fillMapping;
11816
+ }
11817
+ }
11818
+
11737
11819
  async function lookupToAmis(field, readonly, ctx){
11738
11820
  if(!ctx){
11739
11821
  ctx = {};
@@ -11817,6 +11899,10 @@ async function lookupToAmis(field, readonly, ctx){
11817
11899
  amisSchema = _$1.defaultsDeep({}, pageAmisSchema, amisSchema);
11818
11900
  }
11819
11901
  }
11902
+ const autoFill = await getAutoFill(field);
11903
+ if(autoFill){
11904
+ amisSchema.autoFill = autoFill;
11905
+ }
11820
11906
  return amisSchema;
11821
11907
  }
11822
11908
 
@@ -11992,6 +12078,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
11992
12078
  {
11993
12079
  "type": "editor",
11994
12080
  "name": field.name,
12081
+ "labelClassName": "none",
11995
12082
  "language": "markdown",
11996
12083
  }
11997
12084
  ]
@@ -14489,7 +14576,9 @@ async function getButtonNew(props) {
14489
14576
  "actions": await getButtonActions(props, "new")
14490
14577
  }
14491
14578
  },
14492
- "level": "primary"
14579
+ "level": "link",
14580
+ "className": "text-gray-500",
14581
+ "size": "xs"
14493
14582
  };
14494
14583
  }
14495
14584
 
@@ -14499,6 +14588,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
14499
14588
  "label": "",
14500
14589
  "icon": `fa fa-${showAsInlineEditMode ? "expand-alt" : "pencil"}`,//inline edit模式时显示为放开按钮,只读时显示为笔按钮
14501
14590
  "level": "link",
14591
+ "className": "text-gray-400",
14502
14592
  "onEvent": {
14503
14593
  "click": {
14504
14594
  "actions": await getButtonActions(props, "edit")
@@ -14513,6 +14603,7 @@ async function getButtonView(props) {
14513
14603
  "label": "",
14514
14604
  "icon": "fa fa-expand-alt",//fa-external-link
14515
14605
  "level": "link",
14606
+ "className": "text-gray-400",
14516
14607
  "onEvent": {
14517
14608
  "click": {
14518
14609
  "actions": await getButtonActions(props, "readonly")
@@ -14525,6 +14616,7 @@ async function getButtonDelete(props) {
14525
14616
  return {
14526
14617
  "type": "dropdown-button",
14527
14618
  "level": "link",
14619
+ "btnClassName": "text-gray-400",
14528
14620
  "icon": "fa fa-trash-alt",
14529
14621
  "size": "xs",
14530
14622
  "hideCaret": true,
@@ -14759,6 +14851,10 @@ const getAmisInputTableSchema = async (props) => {
14759
14851
  "labelAlign": props.labelAlign,
14760
14852
  //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14761
14853
  "mode": props.mode || null,
14854
+ "visibleOn": props.$schema.visibleOn,
14855
+ "visible": props.$schema.visible,
14856
+ "hiddenOn": props.$schema.hiddenOn,
14857
+ "hidden": props.$schema.hidden,
14762
14858
  className
14763
14859
  };
14764
14860
  // console.log("===schema===", schema);
@@ -17404,5 +17500,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
17404
17500
  };
17405
17501
  };
17406
17502
 
17407
- export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getObjectRelatedListsMiniSchema, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailMiniSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
17503
+ export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getCreatedInfoTpl, getDateTimeTpl, getDateTpl, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFieldTpl, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLocationTpl, getLookupSapceUserTreeSchema, getLookupTpl, getModifiedInfoTpl, getNameTpl, getNameTplUrl, getNotifications, getNumberTpl, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getObjectRelatedListsMiniSchema, getPage, getPasswordTpl, getRecord, getRecordDetailHeaderSchema, getRecordDetailMiniSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRefObjectNameFieldName, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldTpl, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectMap, getSelectTpl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getSwitchTpl, getTableSchema, getTenantId, getTimeTpl, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUiFieldTpl, getUiFileSizeTpl, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
17408
17504
  //# sourceMappingURL=index.esm.js.map