@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.cjs.js CHANGED
@@ -511,7 +511,7 @@ function getComparableAmisVersion() {
511
511
  * @Author: baozhoutao@steedos.com
512
512
  * @Date: 2022-05-23 09:53:08
513
513
  * @LastEditors: baozhoutao@steedos.com
514
- * @LastEditTime: 2024-02-19 11:57:49
514
+ * @LastEditTime: 2024-02-21 17:19:30
515
515
  * @Description:
516
516
  */
517
517
 
@@ -597,7 +597,7 @@ function getNameTpl(field, ctx){
597
597
  if(ctx && ctx.isLookup){
598
598
  linkTarget = "target='_blank'";
599
599
  }
600
- if(ctx.isRelated){
600
+ if(ctx.isRelated && window.innerWidth >= 768){
601
601
  return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
602
602
  }else {
603
603
  return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
@@ -655,7 +655,7 @@ function getRelatedFieldTpl(field, ctx){
655
655
  const href = Router.getObjectDetailPath({
656
656
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
657
657
  });
658
- if(ctx.isRelated){
658
+ if(ctx.isRelated && window.innerWidth >= 768){
659
659
  labelTpl = `<a href="${href}" ${linkTarget} onclick="return false;">${labelTpl}</a>`;
660
660
  }else {
661
661
  labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
@@ -2312,7 +2312,7 @@ async function getTableColumns(fields, options){
2312
2312
  columnItem.defaultColor = null;
2313
2313
  }
2314
2314
 
2315
- if(((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && ___namespace.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2315
+ if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && ___namespace.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2316
2316
 
2317
2317
  const drawerRecordDetailSchema = {
2318
2318
  "type": "steedos-record-detail",
@@ -2340,16 +2340,17 @@ async function getTableColumns(fields, options){
2340
2340
  "drawer": {
2341
2341
  "type": "drawer",
2342
2342
  "title": "&nbsp;",
2343
- "headerClassName": "",
2343
+ "headerClassName": "hidden",
2344
2344
  "size": "lg",
2345
- "bodyClassName": "p-0 m-0 border-t",
2345
+ "bodyClassName": "p-0 m-0",
2346
2346
  "closeOnEsc": true,
2347
+ "closeOnOutside": true,
2347
2348
  "resizable": true,
2348
2349
  "actions": [],
2349
2350
  "body": [
2350
2351
  drawerRecordDetailSchema
2351
2352
  ],
2352
- "className": "app-popover",
2353
+ "className": "steedos-record-detail-drawer app-popover",
2353
2354
  "id": "u:fc5f055afa8c"
2354
2355
  },
2355
2356
  "preventDefault": true
@@ -2407,7 +2408,7 @@ function getMobileLines(tpls){
2407
2408
  let isNewLine = false;
2408
2409
  let isLeft = true;
2409
2410
  let lineChildrenClassName = "";
2410
- let lineClassName = "flex items-center justify-between";
2411
+ let lineClassName = "flex items-center justify-between mb-1";
2411
2412
  tpls.forEach(function(item){
2412
2413
  if(isNewLine && lines.length < maxLineCount){
2413
2414
  lines.push({
@@ -5707,44 +5708,46 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
5707
5708
  }
5708
5709
  });
5709
5710
 
5710
- return {
5711
- "type": "button",
5712
- "icon": "fa fa-angle-down",
5713
- "visibleOn": phoneMoreButtonsVisibleOn,
5714
- "onEvent": {
5715
- "click": {
5716
- "actions": [
5717
- {
5718
- "actionType": "drawer",
5719
- "drawer": {
5720
- "type": "drawer",
5721
- "title": i18next__default["default"].t('frontend_operation'),
5722
- "id": "object_actions_drawer_" + objectSchema.name,
5723
- "body": [
5724
- {
5725
- "type": "button-group",
5726
- "id": "u:fd837823be5b",
5727
- "vertical": true,
5728
- "tiled": true,
5729
- "buttons": dropdownButtons,
5730
- "btnLevel": "enhance",
5731
- "className": "w-full",
5732
- "btnClassName": "w-full",
5733
- "size": "lg"
5711
+ return [
5712
+ {
5713
+ "type": "button",
5714
+ "icon": "fa fa-angle-down",
5715
+ "visibleOn": phoneMoreButtonsVisibleOn,
5716
+ "onEvent": {
5717
+ "click": {
5718
+ "actions": [
5719
+ {
5720
+ "actionType": "drawer",
5721
+ "drawer": {
5722
+ "type": "drawer",
5723
+ "title": i18next__default["default"].t('frontend_operation'),
5724
+ "id": "object_actions_drawer_" + objectSchema.name,
5725
+ "body": [
5726
+ {
5727
+ "type": "button-group",
5728
+ "id": "u:fd837823be5b",
5729
+ "vertical": true,
5730
+ "tiled": true,
5731
+ "buttons": dropdownButtons,
5732
+ "btnLevel": "enhance",
5733
+ "className": "w-full",
5734
+ "btnClassName": "w-full",
5735
+ "size": "lg"
5736
+ }
5737
+ ],
5738
+ "position": "bottom",
5739
+ "closeOnOutside": true,
5740
+ "resizable": false,
5741
+ "className": "buttons-drawer",
5742
+ "bodyClassName": "m-none p-none",
5743
+ "actions": []
5734
5744
  }
5735
- ],
5736
- "position": "bottom",
5737
- "closeOnOutside": true,
5738
- "resizable": false,
5739
- "className": "buttons-drawer",
5740
- "bodyClassName": "m-none p-none",
5741
- "actions": []
5742
- }
5745
+ }
5746
+ ]
5743
5747
  }
5744
- ]
5748
+ }
5745
5749
  }
5746
- }
5747
- }
5750
+ ]
5748
5751
  }else {
5749
5752
  if(moreButtons.length > 0){
5750
5753
  const dropdownButtonsSchema = {
@@ -6813,6 +6816,33 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6813
6816
  amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
6814
6817
  }
6815
6818
 
6819
+ amisButtonsSchema.push(
6820
+ {
6821
+ "type": "button",
6822
+ "visibleOn": "${_inDrawer === true || _inRecordMini === true}",
6823
+ "className":"ant-dropdown-trigger slds-button slds-button_icon slds-button_icon-border-filled slds-button_icon-x-small slds-icon ml-1 flex",
6824
+ "onEvent": {
6825
+ "click": {
6826
+ "actions": [
6827
+ {
6828
+ "actionType": "custom",
6829
+ "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}`)"
6830
+ }
6831
+ ]
6832
+ }
6833
+ },
6834
+ "body": [
6835
+ {
6836
+ "type": "steedos-icon",
6837
+ "category": "utility",
6838
+ "name": "new_window",
6839
+ "colorVariant": "default",
6840
+ "className": "slds-button_icon slds-global-header__icon w-4"
6841
+ }
6842
+ ]
6843
+ }
6844
+ );
6845
+
6816
6846
  let backButtonsSchema = null;
6817
6847
 
6818
6848
  if(options.showBackButton != false){
@@ -6833,7 +6863,32 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
6833
6863
  "columns": [
6834
6864
  {
6835
6865
  "body": [
6836
- backButtonsSchema
6866
+ backButtonsSchema,
6867
+ {
6868
+ "type": "button",
6869
+ "visibleOn": "${_inDrawer === true}",
6870
+ "className":"flex mr-4",
6871
+ "onEvent": {
6872
+ "click": {
6873
+ "actions": [
6874
+ {
6875
+ "componentId": "",
6876
+ "args": {},
6877
+ "actionType": "closeDrawer"
6878
+ }
6879
+ ]
6880
+ }
6881
+ },
6882
+ "body": [
6883
+ {
6884
+ "type": "steedos-icon",
6885
+ "category": "utility",
6886
+ "name": "close",
6887
+ "colorVariant": "default",
6888
+ "className": "slds-button_icon slds-global-header__icon w-4"
6889
+ }
6890
+ ]
6891
+ }
6837
6892
  ,{
6838
6893
  "type": "tpl",
6839
6894
  "className": "block",
@@ -7048,10 +7103,10 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
7048
7103
  "md": "auto"
7049
7104
  }
7050
7105
  ],
7051
- "className": "flex justify-between"
7106
+ "className": "flex justify-between min-h-8 items-center"
7052
7107
  }
7053
7108
  ],
7054
- "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
7109
+ "className": "steedos-record-related-header py-2 px-3 bg-gray-50 border rounded"
7055
7110
  };
7056
7111
  return recordRelatedListHeader;
7057
7112
  }
@@ -11761,6 +11816,33 @@ async function getApi(object, recordId, fields, options){
11761
11816
  }
11762
11817
  }
11763
11818
 
11819
+ async function getAutoFill(field, refObject) {
11820
+ let autoFillMapping = field.auto_fill_mapping;
11821
+ if (autoFillMapping && autoFillMapping.length) {
11822
+ let fillMapping = {};
11823
+ let fieldsForApi = [];
11824
+ autoFillMapping.forEach(function (item) {
11825
+ fillMapping[item.to] = `\${${item.from}}`;
11826
+ fieldsForApi.push(item.from);
11827
+ });
11828
+ // let api = {
11829
+ // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
11830
+ // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
11831
+ // // "responseData": {
11832
+ // // "name": "${name}"
11833
+ // // },
11834
+ // "silent": false
11835
+ // }
11836
+ // return {
11837
+ // fillMapping,
11838
+ // // api
11839
+ // }
11840
+ // 因为autoFill中配置了api的话,在表单初始化(比如新建记录)时并不会触发执行autoFill,所以只能暂时不用api
11841
+ // 给amis报过问题了,见:https://github.com/baidu/amis/issues/9631
11842
+ return fillMapping;
11843
+ }
11844
+ }
11845
+
11764
11846
  async function lookupToAmis(field, readonly, ctx){
11765
11847
  if(!ctx){
11766
11848
  ctx = {};
@@ -11844,6 +11926,10 @@ async function lookupToAmis(field, readonly, ctx){
11844
11926
  amisSchema = ___namespace.defaultsDeep({}, pageAmisSchema, amisSchema);
11845
11927
  }
11846
11928
  }
11929
+ const autoFill = await getAutoFill(field);
11930
+ if(autoFill){
11931
+ amisSchema.autoFill = autoFill;
11932
+ }
11847
11933
  return amisSchema;
11848
11934
  }
11849
11935
 
@@ -12019,6 +12105,7 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
12019
12105
  {
12020
12106
  "type": "editor",
12021
12107
  "name": field.name,
12108
+ "labelClassName": "none",
12022
12109
  "language": "markdown",
12023
12110
  }
12024
12111
  ]
@@ -14516,7 +14603,9 @@ async function getButtonNew(props) {
14516
14603
  "actions": await getButtonActions(props, "new")
14517
14604
  }
14518
14605
  },
14519
- "level": "primary"
14606
+ "level": "link",
14607
+ "className": "text-gray-500",
14608
+ "size": "xs"
14520
14609
  };
14521
14610
  }
14522
14611
 
@@ -14526,6 +14615,7 @@ async function getButtonEdit(props, showAsInlineEditMode) {
14526
14615
  "label": "",
14527
14616
  "icon": `fa fa-${showAsInlineEditMode ? "expand-alt" : "pencil"}`,//inline edit模式时显示为放开按钮,只读时显示为笔按钮
14528
14617
  "level": "link",
14618
+ "className": "text-gray-400",
14529
14619
  "onEvent": {
14530
14620
  "click": {
14531
14621
  "actions": await getButtonActions(props, "edit")
@@ -14540,6 +14630,7 @@ async function getButtonView(props) {
14540
14630
  "label": "",
14541
14631
  "icon": "fa fa-expand-alt",//fa-external-link
14542
14632
  "level": "link",
14633
+ "className": "text-gray-400",
14543
14634
  "onEvent": {
14544
14635
  "click": {
14545
14636
  "actions": await getButtonActions(props, "readonly")
@@ -14552,6 +14643,7 @@ async function getButtonDelete(props) {
14552
14643
  return {
14553
14644
  "type": "dropdown-button",
14554
14645
  "level": "link",
14646
+ "btnClassName": "text-gray-400",
14555
14647
  "icon": "fa fa-trash-alt",
14556
14648
  "size": "xs",
14557
14649
  "hideCaret": true,
@@ -14786,6 +14878,10 @@ const getAmisInputTableSchema = async (props) => {
14786
14878
  "labelAlign": props.labelAlign,
14787
14879
  //控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
14788
14880
  "mode": props.mode || null,
14881
+ "visibleOn": props.$schema.visibleOn,
14882
+ "visible": props.$schema.visible,
14883
+ "hiddenOn": props.$schema.hiddenOn,
14884
+ "hidden": props.$schema.hidden,
14789
14885
  className
14790
14886
  };
14791
14887
  // console.log("===schema===", schema);
@@ -17460,11 +17556,15 @@ exports.getButtonVisible = getButtonVisible;
17460
17556
  exports.getButtonVisibleOn = getButtonVisibleOn;
17461
17557
  exports.getButtons = getButtons;
17462
17558
  exports.getCalendarSchema = getCalendarSchema;
17559
+ exports.getCreatedInfoTpl = getCreatedInfoTpl;
17560
+ exports.getDateTimeTpl = getDateTimeTpl;
17561
+ exports.getDateTpl = getDateTpl;
17463
17562
  exports.getDefaultRenderData = getDefaultRenderData;
17464
17563
  exports.getEnv = getEnv;
17465
17564
  exports.getEnvs = getEnvs;
17466
17565
  exports.getEvn = getEvn;
17467
17566
  exports.getField = getField;
17567
+ exports.getFieldTpl = getFieldTpl;
17468
17568
  exports.getFileSrc = getFileSrc;
17469
17569
  exports.getFlowFormSchema = getFlowFormSchema;
17470
17570
  exports.getFormPageInitSchema = getFormPageInitSchema;
@@ -17481,8 +17581,14 @@ exports.getListViewFilter = getListViewFilter;
17481
17581
  exports.getListViewItemButtons = getListViewItemButtons;
17482
17582
  exports.getListViewSort = getListViewSort;
17483
17583
  exports.getListviewInitSchema = getListviewInitSchema;
17584
+ exports.getLocationTpl = getLocationTpl;
17484
17585
  exports.getLookupSapceUserTreeSchema = getLookupSapceUserTreeSchema;
17586
+ exports.getLookupTpl = getLookupTpl;
17587
+ exports.getModifiedInfoTpl = getModifiedInfoTpl;
17588
+ exports.getNameTpl = getNameTpl;
17589
+ exports.getNameTplUrl = getNameTplUrl;
17485
17590
  exports.getNotifications = getNotifications;
17591
+ exports.getNumberTpl = getNumberTpl;
17486
17592
  exports.getObjectDetailButtons = getObjectDetailButtons;
17487
17593
  exports.getObjectDetailButtonsSchemas = getObjectDetailButtonsSchemas;
17488
17594
  exports.getObjectDetailMoreButtons = getObjectDetailMoreButtons;
@@ -17503,6 +17609,7 @@ exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
17503
17609
  exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
17504
17610
  exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
17505
17611
  exports.getPage = getPage;
17612
+ exports.getPasswordTpl = getPasswordTpl;
17506
17613
  exports.getRecord = getRecord;
17507
17614
  exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
17508
17615
  exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
@@ -17511,21 +17618,29 @@ exports.getRecordDetailSchema = getRecordDetailSchema;
17511
17618
  exports.getRecordPageInitSchema = getRecordPageInitSchema;
17512
17619
  exports.getRecordPermissions = getRecordPermissions;
17513
17620
  exports.getRecordServiceSchema = getRecordServiceSchema;
17621
+ exports.getRefObjectNameFieldName = getRefObjectNameFieldName;
17514
17622
  exports.getReferenceTo = getReferenceTo;
17515
17623
  exports.getReferenceToFieldSchema = getReferenceToFieldSchema;
17516
17624
  exports.getReferenceToSync = getReferenceToSync;
17625
+ exports.getRelatedFieldTpl = getRelatedFieldTpl;
17517
17626
  exports.getRelatedFieldValue = getRelatedFieldValue;
17518
17627
  exports.getRelatedListSchema = getRelatedListSchema;
17519
17628
  exports.getRelatedsCount = getRelatedsCount;
17520
17629
  exports.getRootUrl = getRootUrl;
17630
+ exports.getSelectMap = getSelectMap;
17631
+ exports.getSelectTpl = getSelectTpl;
17521
17632
  exports.getSelectUserSchema = getSelectUserSchema;
17522
17633
  exports.getSpaceUsersPickerAmisSchema = getSpaceUsersPickerAmisSchema;
17523
17634
  exports.getSpaceUsersPickerSchema = getSpaceUsersPickerSchema;
17524
17635
  exports.getSteedosAuth = getSteedosAuth;
17636
+ exports.getSwitchTpl = getSwitchTpl;
17525
17637
  exports.getTableSchema = getTableSchema;
17526
17638
  exports.getTenantId = getTenantId;
17639
+ exports.getTimeTpl = getTimeTpl;
17527
17640
  exports.getUISchema = getUISchema;
17528
17641
  exports.getUISchemaSync = getUISchemaSync$1;
17642
+ exports.getUiFieldTpl = getUiFieldTpl;
17643
+ exports.getUiFileSizeTpl = getUiFileSizeTpl;
17529
17644
  exports.getUserId = getUserId;
17530
17645
  exports.getViewSchema = getViewSchema;
17531
17646
  exports.isExpression = isExpression;