@steedos-widgets/amis-lib 1.2.6-beta.17 → 1.2.6-beta.19

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
@@ -1350,21 +1350,6 @@ const parseSingleExpression = function (func, formData, dataPath, global, userSe
1350
1350
  }
1351
1351
  };
1352
1352
 
1353
- /*
1354
- * @Author: baozhoutao@steedos.com
1355
- * @Date: 2022-08-04 10:42:49
1356
- * @LastEditors: baozhoutao@steedos.com
1357
- * @LastEditTime: 2022-08-25 10:28:47
1358
- * @Description:
1359
- */
1360
- var config = {
1361
- listView: {
1362
- newRecordMode: 'modal',
1363
- editRecordMode: 'modal',
1364
- perPage: 20
1365
- }
1366
- };
1367
-
1368
1353
  /*
1369
1354
  * @Author: baozhoutao@steedos.com
1370
1355
  * @Date: 2022-11-01 15:51:00
@@ -2380,6 +2365,166 @@ const execute = (button, props) => {
2380
2365
 
2381
2366
  const executeButton = execute;
2382
2367
 
2368
+
2369
+ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2370
+ const { name } = objectSchema;
2371
+ const buttons = getObjectDetailButtons(objectSchema, {});
2372
+ const moreButtons = getObjectDetailMoreButtons(objectSchema, {
2373
+ recordId: recordId,
2374
+ objectName: name
2375
+ });
2376
+ let amisButtonsSchema = ___default.map(buttons, (button) => {
2377
+ return {
2378
+ type: 'steedos-object-button',
2379
+ name: button.name,
2380
+ objectName: button.objectName,
2381
+ visibleOn: getButtonVisibleOn$1(button),
2382
+ className: `button_${button.name}`
2383
+ }
2384
+ });
2385
+ let dropdownButtons = ___default.map(moreButtons, (button) => {
2386
+ return {
2387
+ type: 'steedos-object-button',
2388
+ name: button.name,
2389
+ objectName: button.objectName,
2390
+ visibleOn: getButtonVisibleOn$1(button),
2391
+ }
2392
+ });
2393
+ return {
2394
+ buttons: amisButtonsSchema,
2395
+ moreButtons: dropdownButtons
2396
+ };
2397
+ };
2398
+
2399
+ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2400
+ const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
2401
+ if(ctx.formFactor === 'SMALL'){
2402
+ return {
2403
+ "type": "button",
2404
+ "icon": "fa fa-angle-down",
2405
+ "onEvent": {
2406
+ "click": {
2407
+ "actions": [
2408
+ {
2409
+ "actionType": "drawer",
2410
+ "drawer": {
2411
+ "type": "drawer",
2412
+ "title": "操作",
2413
+ "body": [
2414
+ {
2415
+ "type": "button-group",
2416
+ "id": "u:fd837823be5b",
2417
+ "vertical": true,
2418
+ "tiled": true,
2419
+ "buttons": [
2420
+ ...___default.map(buttons, (button)=>{
2421
+ button.className += ' w-full';
2422
+ return button;
2423
+ }),
2424
+ ...___default.map(moreButtons, (button)=>{
2425
+ button.className += ' w-full';
2426
+ return button;
2427
+ })
2428
+ ],
2429
+ "btnLevel": "enhance",
2430
+ "className": "w-full",
2431
+ "btnClassName": "w-full",
2432
+ "size": "lg"
2433
+ }
2434
+ ],
2435
+ "id": "u:9815f7366b9f",
2436
+ "position": "bottom",
2437
+ "closeOnOutside": true,
2438
+ "resizable": false,
2439
+ "className": "buttons-drawer",
2440
+ "bodyClassName": "m-none p-none",
2441
+ "actions": []
2442
+ }
2443
+ }
2444
+ ]
2445
+ }
2446
+ },
2447
+ "id": "u:ee7c7929e6ae"
2448
+ }
2449
+ }else {
2450
+ if(moreButtons.length > 0){
2451
+ const dropdownButtonsSchema = {
2452
+ type: "steedos-dropdown-button",
2453
+ label: "",
2454
+ buttons: moreButtons,
2455
+ className: 'slds-icon'
2456
+ };
2457
+ buttons.push(dropdownButtonsSchema);
2458
+ }
2459
+ return buttons;
2460
+ }
2461
+ };
2462
+
2463
+
2464
+ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2465
+ const buttons = getListViewButtons(objectSchema, ctx);
2466
+ if(ctx.formFactor === 'SMALL'){
2467
+ return {
2468
+ "type": "button",
2469
+ "icon": "fa fa-angle-down",
2470
+ "onEvent": {
2471
+ "click": {
2472
+ "actions": [
2473
+ {
2474
+ "actionType": "drawer",
2475
+ "drawer": {
2476
+ "type": "drawer",
2477
+ "title": "操作",
2478
+ "body": [
2479
+ {
2480
+ "type": "button-group",
2481
+ "id": "u:fd837823be5b",
2482
+ "vertical": true,
2483
+ "tiled": true,
2484
+ "buttons": [
2485
+ ...___default.map(buttons, (button)=>{
2486
+ return {
2487
+ type: 'steedos-object-button',
2488
+ name: button.name,
2489
+ objectName: button.objectName,
2490
+ visibleOn: getButtonVisibleOn$1(button),
2491
+ className: `button_${button.name} w-full`
2492
+ }
2493
+ })
2494
+ ],
2495
+ "btnLevel": "enhance",
2496
+ "className": "w-full",
2497
+ "btnClassName": "w-full",
2498
+ "size": "lg"
2499
+ }
2500
+ ],
2501
+ "id": "u:9815f7366b9f",
2502
+ "position": "bottom",
2503
+ "closeOnOutside": true,
2504
+ "resizable": false,
2505
+ "className": "buttons-drawer",
2506
+ "bodyClassName": "m-none p-none",
2507
+ "actions": []
2508
+ }
2509
+ }
2510
+ ]
2511
+ }
2512
+ },
2513
+ "id": "u:ee7c7929e6ae"
2514
+ }
2515
+ }else {
2516
+ return ___default.map(buttons, (button) => {
2517
+ return {
2518
+ type: 'steedos-object-button',
2519
+ name: button.name,
2520
+ objectName: button.objectName,
2521
+ visibleOn: getButtonVisibleOn$1(button),
2522
+ className: `button_${button.name}`
2523
+ }
2524
+ });
2525
+ }
2526
+ };
2527
+
2383
2528
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2384
2529
  // const amisListViewId = `listview_${objectSchema.name}`;
2385
2530
  return {
@@ -2862,17 +3007,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2862
3007
  }
2863
3008
  );
2864
3009
 
2865
- const buttons = getListViewButtons(objectSchema, {});
2866
- let amisButtonsSchema = map(buttons, (button) => {
2867
- return {
2868
- type: 'steedos-object-button',
2869
- name: button.name,
2870
- objectName: button.objectName,
2871
- visibleOn: getButtonVisibleOn$1(button),
2872
- className: `button_${button.name}`
2873
- }
2874
- });
2875
-
3010
+ let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
2876
3011
  const reg = new RegExp('_', 'g');
2877
3012
  const standardIcon = icon && icon.replace(reg, '-');
2878
3013
  return {
@@ -3054,7 +3189,10 @@ async function getObjectListHeaderFieldsFilterBar(objectSchema, listViewName, ct
3054
3189
  * @returns amisSchema
3055
3190
  */
3056
3191
  function getObjectListHeader$1(objectSchema, listViewName, ctx) {
3057
- let firstLineSchema = getObjectListHeaderFirstLine(objectSchema);
3192
+ if (!ctx) {
3193
+ ctx = {};
3194
+ }
3195
+ let firstLineSchema = getObjectListHeaderFirstLine(objectSchema, listViewName, ctx);
3058
3196
  let body = [firstLineSchema];
3059
3197
  let headerSchema = [{
3060
3198
  "type": "wrapper",
@@ -3075,35 +3213,11 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3075
3213
  const { showRecordTitle = true } = options || {};
3076
3214
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
3077
3215
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
3078
- const buttons = getObjectDetailButtons(objectSchema, {});
3079
- const moreButtons = getObjectDetailMoreButtons(objectSchema, {
3080
- recordId: recordId,
3081
- objectName: name
3082
- });
3083
- let amisButtonsSchema = map(buttons, (button) => {
3084
- return {
3085
- type: 'steedos-object-button',
3086
- name: button.name,
3087
- objectName: button.objectName,
3088
- visibleOn: getButtonVisibleOn$1(button),
3089
- className: `button_${button.name}`
3090
- }
3091
- });
3092
- let dropdownButtons = map(moreButtons, (button) => {
3093
- return {
3094
- type: 'steedos-object-button',
3095
- name: button.name,
3096
- objectName: button.objectName,
3097
- visibleOn: getButtonVisibleOn$1(button),
3098
- }
3099
- });
3100
- const dropdownButtonsSchema = {
3101
- type: "steedos-dropdown-button",
3102
- label: "",
3103
- buttons: dropdownButtons,
3104
- className: 'slds-icon'
3105
- };
3106
- amisButtonsSchema.push(dropdownButtonsSchema);
3216
+
3217
+ let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
3218
+
3219
+ // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
3220
+
3107
3221
  const reg = new RegExp('_', 'g');
3108
3222
  const standardIcon = icon && icon.replace(reg, '-');
3109
3223
 
@@ -4862,11 +4976,12 @@ async function lookupToAmisSelect(field, readonly, ctx){
4862
4976
  autoComplete: apiInfo,
4863
4977
  searchable: true,
4864
4978
  };
4979
+ //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
4865
4980
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
4866
4981
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
4867
4982
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
4868
4983
  <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
4869
- <use xlink:href='\${context.rootUrl}/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
4984
+ <use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
4870
4985
  </svg>
4871
4986
  </span>
4872
4987
  </span>
@@ -6348,7 +6463,7 @@ async function getObjectCRUD(objectSchema, fields, options){
6348
6463
  }),
6349
6464
  filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
6350
6465
  };
6351
- if(options.formFactor !== 'SMALL'){
6466
+ if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
6352
6467
  Object.assign(bodyProps, {
6353
6468
  bulkActions: options.bulkActions != false ? bulkActions : false
6354
6469
  });
@@ -6681,6 +6796,21 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6681
6796
  }
6682
6797
  }
6683
6798
 
6799
+ /*
6800
+ * @Author: baozhoutao@steedos.com
6801
+ * @Date: 2022-08-04 10:42:49
6802
+ * @LastEditors: baozhoutao@steedos.com
6803
+ * @LastEditTime: 2022-08-25 10:28:47
6804
+ * @Description:
6805
+ */
6806
+ var config = {
6807
+ listView: {
6808
+ newRecordMode: 'modal',
6809
+ editRecordMode: 'modal',
6810
+ perPage: 20
6811
+ }
6812
+ };
6813
+
6684
6814
  async function getTableColumns(fields, options){
6685
6815
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
6686
6816
  for (const field of fields) {
@@ -6896,8 +7026,9 @@ async function getMobileTableColumns(fields, options){
6896
7026
  const url = getNameTplUrl(nameField, options);
6897
7027
 
6898
7028
  const columnLines = getMobileLines(tpls);
6899
-
6900
- columns.push({
7029
+
7030
+
7031
+ let column = {
6901
7032
  name: nameField.name,
6902
7033
  label: nameField.label,
6903
7034
  sortable: nameField.sortable,
@@ -6906,13 +7037,66 @@ async function getMobileTableColumns(fields, options){
6906
7037
  actionType: "link",
6907
7038
  link: url,
6908
7039
  innerClassName: "steedos-listview-item block text-gray-500",
6909
- body:{
7040
+ body: {
6910
7041
  "type": "wrapper",
6911
7042
  "body": columnLines,
6912
7043
  "size": "none",
6913
7044
  "className": "p-1"
6914
7045
  }
6915
- });
7046
+ };
7047
+
7048
+ if(options.objectName === 'cms_files'){
7049
+ if(window.Meteor?.isCordova){
7050
+ column = {
7051
+ ...column,
7052
+ actionType: "",
7053
+ link: "",
7054
+ onEvent: {
7055
+ "click": {
7056
+ "actions": [
7057
+ {
7058
+ "script": `
7059
+ let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
7060
+ Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
7061
+ `,
7062
+ "actionType": "custom"
7063
+ }
7064
+ ],
7065
+ "weight": 0
7066
+ }
7067
+ }
7068
+ };
7069
+ }else {
7070
+ column = {
7071
+ ...column,
7072
+ actionType: "",
7073
+ link: "",
7074
+ onEvent: {
7075
+ "click": {
7076
+ "actions": [
7077
+ {
7078
+ "args": {
7079
+ "api": {
7080
+ "url": url,
7081
+ "method": "get",
7082
+ "headers": {
7083
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7084
+ }
7085
+ }
7086
+ },
7087
+ "actionType": "download"
7088
+ }
7089
+ ],
7090
+ "weight": 0
7091
+ }
7092
+ }
7093
+ };
7094
+ }
7095
+
7096
+ }
7097
+
7098
+ columns.push(column);
7099
+
6916
7100
 
6917
7101
  return columns;
6918
7102
  }
@@ -7031,7 +7215,7 @@ async function getTableSchema$1(fields, options){
7031
7215
  options = {};
7032
7216
  }
7033
7217
  let columns = [];
7034
- if(options.formFactor === 'SMALL'){
7218
+ if(options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1){
7035
7219
  columns = await getMobileTableColumns(fields, options);
7036
7220
  }
7037
7221
  else {
@@ -8003,7 +8187,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8003
8187
  * @Author: baozhoutao@steedos.com
8004
8188
  * @Date: 2022-07-05 15:55:39
8005
8189
  * @LastEditors: Please set LastEditors
8006
- * @LastEditTime: 2023-04-20 11:43:14
8190
+ * @LastEditTime: 2023-05-08 16:34:25
8007
8191
  * @Description:
8008
8192
  */
8009
8193
 
@@ -8257,7 +8441,7 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
8257
8441
  }
8258
8442
  function getRelatedListProps(uiSchema, listViewName, ctx) {
8259
8443
  if (ctx.columns) {
8260
- const sort = getListViewSort(ctx.sort);
8444
+ const sort = getListViewSort({sort: ctx.sort});
8261
8445
  let { filters , filtersFunction} = ctx;
8262
8446
  if(!filtersFunction && filters){
8263
8447
  filtersFunction = str2function(
@@ -9100,7 +9284,10 @@ async function getListviewInitSchema(objectApiName, listViewName, ctx) {
9100
9284
  const defaults = ctx.defaults || {};
9101
9285
  if(!defaults.headerSchema){
9102
9286
  //传入isListviewInit是区别于对象列表类型的微页面,即getListPageInitSchema函数中该属性为false
9103
- const headerSchema = await getObjectListHeader$1(uiSchema);
9287
+ const headerSchema = await getObjectListHeader$1(uiSchema, listViewName, {
9288
+ onlySecordLine: true,
9289
+ isListviewInit: true
9290
+ });
9104
9291
  defaults.headerSchema = headerSchema;
9105
9292
  }
9106
9293
  ctx.defaults = defaults;
@@ -11729,5 +11916,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
11729
11916
  };
11730
11917
  };
11731
11918
 
11732
- export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
11919
+ export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, 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, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
11733
11920
  //# sourceMappingURL=index.esm.js.map