@steedos-widgets/amis-lib 6.3.10 → 6.3.11-beta.11
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/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +69 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +69 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +19 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/api.d.ts +1 -1
- package/dist/types/lib/converter/amis/fields/file.d.ts +46 -2
- package/dist/types/lib/converter/amis/util.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -388,18 +388,24 @@ const Router = {
|
|
|
388
388
|
/*
|
|
389
389
|
* @Author: baozhoutao@steedos.com
|
|
390
390
|
* @Date: 2022-07-20 16:29:22
|
|
391
|
-
* @LastEditors:
|
|
392
|
-
* @LastEditTime: 2024-
|
|
391
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
392
|
+
* @LastEditTime: 2024-11-17 13:05:44
|
|
393
393
|
* @Description:
|
|
394
394
|
*/
|
|
395
395
|
|
|
396
|
-
function getImageFieldUrl(url) {
|
|
397
|
-
if (window.Meteor
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
396
|
+
function getImageFieldUrl(url, readonly) {
|
|
397
|
+
if (window.Meteor) {
|
|
398
|
+
if(window.Meteor.isCordova != true){
|
|
399
|
+
// '//'的位置
|
|
400
|
+
const doubleSlashIndex = url.indexOf('//');
|
|
401
|
+
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
402
|
+
const rootUrl = url.substring(urlIndex);
|
|
403
|
+
return rootUrl;
|
|
404
|
+
}else {
|
|
405
|
+
if(readonly || url.startsWith('http')){
|
|
406
|
+
return `${url}?token=${window.btoa(JSON.stringify({ authToken : Builder.settings.context.authToken }))}`
|
|
407
|
+
}
|
|
408
|
+
}
|
|
403
409
|
}
|
|
404
410
|
return url;
|
|
405
411
|
}
|
|
@@ -408,13 +414,29 @@ if(typeof window != 'undefined'){
|
|
|
408
414
|
window.getImageFieldUrl = getImageFieldUrl;
|
|
409
415
|
}
|
|
410
416
|
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
// js color
|
|
420
|
+
|
|
421
|
+
function toGrayscale(r, g, b){
|
|
422
|
+
return (
|
|
423
|
+
0.2126 * r +
|
|
424
|
+
0.7152 * g +
|
|
425
|
+
0.0722 * b
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function isLight(r, g, b){
|
|
430
|
+
// 专业的亮度是 > 255 / 2. 此处的阈值调整为200
|
|
431
|
+
return toGrayscale(r, g, b) > 200
|
|
432
|
+
}
|
|
433
|
+
|
|
411
434
|
function getContrastColor(bgColor) {
|
|
412
435
|
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
413
436
|
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
414
437
|
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
415
438
|
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
416
|
-
|
|
417
|
-
return brightness < 128 ? "#ffffff" : "#000000";
|
|
439
|
+
return isLight(r, g, b) ? "#000000" : "#ffffff";
|
|
418
440
|
}
|
|
419
441
|
|
|
420
442
|
function getLookupListView(refObjectConfig) {
|
|
@@ -484,7 +506,7 @@ function getComparableAmisVersion() {
|
|
|
484
506
|
* @Author: baozhoutao@steedos.com
|
|
485
507
|
* @Date: 2022-05-23 09:53:08
|
|
486
508
|
* @LastEditors: baozhoutao@steedos.com
|
|
487
|
-
* @LastEditTime: 2024-
|
|
509
|
+
* @LastEditTime: 2024-11-17 13:10:08
|
|
488
510
|
* @Description:
|
|
489
511
|
*/
|
|
490
512
|
|
|
@@ -545,7 +567,7 @@ function getSelectMap(selectOptions){
|
|
|
545
567
|
if(optionColor && optionColor != "undefined"){
|
|
546
568
|
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
547
569
|
const color = getContrastColor(background);
|
|
548
|
-
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
570
|
+
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem;font-size:14px';
|
|
549
571
|
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
550
572
|
}else {
|
|
551
573
|
map[optionValue] = option.label;
|
|
@@ -906,12 +928,12 @@ function getScriptForRemoveUrlPrefixForImgFields(fields){
|
|
|
906
928
|
if(imgFieldValue instanceof Array){
|
|
907
929
|
formData[item] = imgFieldValue.map((value)=>{
|
|
908
930
|
let itemValue = value && value.split('/');
|
|
909
|
-
return itemValue[itemValue.length - 1];
|
|
931
|
+
return itemValue[itemValue.length - 1].split('?')[0];
|
|
910
932
|
});
|
|
911
933
|
}
|
|
912
934
|
}else{
|
|
913
935
|
let imgValue = imgFieldValue.split('/');
|
|
914
|
-
formData[item] = imgValue[imgValue.length - 1];
|
|
936
|
+
formData[item] = imgValue[imgValue.length - 1].split('?')[0];
|
|
915
937
|
}
|
|
916
938
|
}
|
|
917
939
|
})
|
|
@@ -1191,7 +1213,7 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
|
|
|
1191
1213
|
* @Author: baozhoutao@steedos.com
|
|
1192
1214
|
* @Date: 2022-10-28 14:15:09
|
|
1193
1215
|
* @LastEditors: baozhoutao@steedos.com
|
|
1194
|
-
* @LastEditTime: 2024-
|
|
1216
|
+
* @LastEditTime: 2024-11-14 10:50:01
|
|
1195
1217
|
* @Description:
|
|
1196
1218
|
*/
|
|
1197
1219
|
|
|
@@ -1250,6 +1272,7 @@ async function getLookupLinkOnClick(field, options) {
|
|
|
1250
1272
|
"title": " ",
|
|
1251
1273
|
"headerClassName": "hidden",
|
|
1252
1274
|
"size": "lg",
|
|
1275
|
+
"width": "70%",
|
|
1253
1276
|
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
1254
1277
|
"closeOnEsc": true,
|
|
1255
1278
|
"closeOnOutside": true,
|
|
@@ -1289,13 +1312,13 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
|
|
|
1289
1312
|
if(type === 'file'){
|
|
1290
1313
|
return window.Meteor?.isCordova ? {
|
|
1291
1314
|
"type": "control",
|
|
1292
|
-
"body": {
|
|
1315
|
+
"body": steedosField.multiple ? {
|
|
1293
1316
|
"type": "each",
|
|
1294
1317
|
"name": "_display." + steedosField.name,
|
|
1295
1318
|
"items": {
|
|
1296
1319
|
"type": "tpl",
|
|
1297
1320
|
"tpl": "${name}",
|
|
1298
|
-
"className": "antd-Button--link inline-block",
|
|
1321
|
+
"className": "antd-Button--link inline-block mr-2",
|
|
1299
1322
|
"onEvent": {
|
|
1300
1323
|
"click": {
|
|
1301
1324
|
"actions": [
|
|
@@ -1310,6 +1333,24 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
|
|
|
1310
1333
|
}
|
|
1311
1334
|
}
|
|
1312
1335
|
}
|
|
1336
|
+
} : {
|
|
1337
|
+
"type": "tpl",
|
|
1338
|
+
"tpl": "${_display." + steedosField.name + ".name}",
|
|
1339
|
+
"className": "antd-Button--link inline-block",
|
|
1340
|
+
"onEvent": {
|
|
1341
|
+
"click": {
|
|
1342
|
+
"actions": [
|
|
1343
|
+
{
|
|
1344
|
+
"script": `
|
|
1345
|
+
const data = event.data._display.${steedosField.name};
|
|
1346
|
+
Steedos.cordovaDownload(encodeURI(data.url), data.name);
|
|
1347
|
+
`,
|
|
1348
|
+
"actionType": "custom"
|
|
1349
|
+
}
|
|
1350
|
+
],
|
|
1351
|
+
"weight": 0
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1313
1354
|
}
|
|
1314
1355
|
} : {
|
|
1315
1356
|
// type: amisFieldType,
|
|
@@ -2324,6 +2365,7 @@ async function getColumnItemOnClick(field, options){
|
|
|
2324
2365
|
"title": " ",
|
|
2325
2366
|
"headerClassName": "hidden",
|
|
2326
2367
|
"size": "lg",
|
|
2368
|
+
"width": "70%",
|
|
2327
2369
|
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
2328
2370
|
"closeOnEsc": true,
|
|
2329
2371
|
"closeOnOutside": true,
|
|
@@ -3475,7 +3517,7 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3475
3517
|
var gridAndObjectFieldsName = ${JSON.stringify(gridAndObjectFieldsName)};
|
|
3476
3518
|
try{
|
|
3477
3519
|
${scriptStr}
|
|
3478
|
-
${getScriptForAddUrlPrefixForImgFields(fields)}
|
|
3520
|
+
${getScriptForAddUrlPrefixForImgFields(fields, true)}
|
|
3479
3521
|
${getScriptForRewriteValueForFileFields(fields)}
|
|
3480
3522
|
}catch(e){
|
|
3481
3523
|
console.error(e)
|
|
@@ -3539,7 +3581,7 @@ async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
|
3539
3581
|
/*
|
|
3540
3582
|
img/avatar字段值添加URL前缀使其在amis中正常显示图片。
|
|
3541
3583
|
*/
|
|
3542
|
-
function getScriptForAddUrlPrefixForImgFields(fields){
|
|
3584
|
+
function getScriptForAddUrlPrefixForImgFields(fields, readonly){
|
|
3543
3585
|
let imgFieldsKeys = [];
|
|
3544
3586
|
let imgFields = {};
|
|
3545
3587
|
fields.forEach((item)=>{
|
|
@@ -3567,12 +3609,12 @@ function getScriptForAddUrlPrefixForImgFields(fields){
|
|
|
3567
3609
|
if(fieldProps.multiple){
|
|
3568
3610
|
if(imgFieldDisplayValue instanceof Array){
|
|
3569
3611
|
data[item] = imgFieldDisplayValue.map((i)=>{
|
|
3570
|
-
const url = window.getImageFieldUrl(i.url);
|
|
3612
|
+
const url = window.getImageFieldUrl(i.url, ${readonly});
|
|
3571
3613
|
return url;
|
|
3572
3614
|
});
|
|
3573
3615
|
}
|
|
3574
3616
|
}else{
|
|
3575
|
-
const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
|
|
3617
|
+
const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url, ${readonly});
|
|
3576
3618
|
data[item] = url;
|
|
3577
3619
|
}
|
|
3578
3620
|
}
|
|
@@ -3668,7 +3710,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3668
3710
|
const fieldKeys = uiSchema && _.keys(uiSchema.fields);
|
|
3669
3711
|
|
|
3670
3712
|
if(data){
|
|
3671
|
-
${getScriptForAddUrlPrefixForImgFields(fields)}
|
|
3713
|
+
${getScriptForAddUrlPrefixForImgFields(fields, false)}
|
|
3672
3714
|
${getScriptForRewriteValueForFileFields(fields)}
|
|
3673
3715
|
|
|
3674
3716
|
_.each(dataKeys, function(key){
|
|
@@ -7738,7 +7780,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
7738
7780
|
let body = [
|
|
7739
7781
|
{
|
|
7740
7782
|
"type": "wrapper",
|
|
7741
|
-
"className": "p-4
|
|
7783
|
+
"className": "p-4",
|
|
7742
7784
|
"body": [
|
|
7743
7785
|
{
|
|
7744
7786
|
"type": "grid",
|
|
@@ -7836,7 +7878,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
7836
7878
|
"body": details,
|
|
7837
7879
|
"hiddenOn": "${recordLoaded != true}"
|
|
7838
7880
|
},
|
|
7839
|
-
"className": "steedos-record-compact-layouts p-4
|
|
7881
|
+
"className": "steedos-record-compact-layouts p-4 pb-2 border-t compact-layouts"
|
|
7840
7882
|
});
|
|
7841
7883
|
}
|
|
7842
7884
|
|
|
@@ -10902,7 +10944,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
10902
10944
|
};
|
|
10903
10945
|
const content = {
|
|
10904
10946
|
"type": "tabs",
|
|
10905
|
-
"className": "steedos-record-tabs bg-white p-4 sm:m-
|
|
10947
|
+
"className": "steedos-record-tabs bg-white p-4 sm:m-4 sm:shadow sm:rounded",
|
|
10906
10948
|
"contentClassName": "bg-none",
|
|
10907
10949
|
"tabs": [
|
|
10908
10950
|
detailed
|
|
@@ -13318,7 +13360,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
13318
13360
|
// }
|
|
13319
13361
|
// 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
|
|
13320
13362
|
convertData = {
|
|
13321
|
-
type: "input-
|
|
13363
|
+
type: "input-datetime-range",
|
|
13322
13364
|
inputFormat: "YYYY-MM-DD HH:mm",
|
|
13323
13365
|
format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
13324
13366
|
tpl: readonly ? getDateTimeTpl(field) : null,
|