@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.cjs.js
CHANGED
|
@@ -415,18 +415,24 @@ const Router = {
|
|
|
415
415
|
/*
|
|
416
416
|
* @Author: baozhoutao@steedos.com
|
|
417
417
|
* @Date: 2022-07-20 16:29:22
|
|
418
|
-
* @LastEditors:
|
|
419
|
-
* @LastEditTime: 2024-
|
|
418
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
419
|
+
* @LastEditTime: 2024-11-17 13:05:44
|
|
420
420
|
* @Description:
|
|
421
421
|
*/
|
|
422
422
|
|
|
423
|
-
function getImageFieldUrl(url) {
|
|
424
|
-
if (window.Meteor
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
423
|
+
function getImageFieldUrl(url, readonly) {
|
|
424
|
+
if (window.Meteor) {
|
|
425
|
+
if(window.Meteor.isCordova != true){
|
|
426
|
+
// '//'的位置
|
|
427
|
+
const doubleSlashIndex = url.indexOf('//');
|
|
428
|
+
const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
|
|
429
|
+
const rootUrl = url.substring(urlIndex);
|
|
430
|
+
return rootUrl;
|
|
431
|
+
}else {
|
|
432
|
+
if(readonly || url.startsWith('http')){
|
|
433
|
+
return `${url}?token=${window.btoa(JSON.stringify({ authToken : Builder.settings.context.authToken }))}`
|
|
434
|
+
}
|
|
435
|
+
}
|
|
430
436
|
}
|
|
431
437
|
return url;
|
|
432
438
|
}
|
|
@@ -435,13 +441,29 @@ if(typeof window != 'undefined'){
|
|
|
435
441
|
window.getImageFieldUrl = getImageFieldUrl;
|
|
436
442
|
}
|
|
437
443
|
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
// js color
|
|
447
|
+
|
|
448
|
+
function toGrayscale(r, g, b){
|
|
449
|
+
return (
|
|
450
|
+
0.2126 * r +
|
|
451
|
+
0.7152 * g +
|
|
452
|
+
0.0722 * b
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function isLight(r, g, b){
|
|
457
|
+
// 专业的亮度是 > 255 / 2. 此处的阈值调整为200
|
|
458
|
+
return toGrayscale(r, g, b) > 200
|
|
459
|
+
}
|
|
460
|
+
|
|
438
461
|
function getContrastColor(bgColor) {
|
|
439
462
|
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
440
463
|
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
441
464
|
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
442
465
|
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
443
|
-
|
|
444
|
-
return brightness < 128 ? "#ffffff" : "#000000";
|
|
466
|
+
return isLight(r, g, b) ? "#000000" : "#ffffff";
|
|
445
467
|
}
|
|
446
468
|
|
|
447
469
|
function getLookupListView(refObjectConfig) {
|
|
@@ -511,7 +533,7 @@ function getComparableAmisVersion() {
|
|
|
511
533
|
* @Author: baozhoutao@steedos.com
|
|
512
534
|
* @Date: 2022-05-23 09:53:08
|
|
513
535
|
* @LastEditors: baozhoutao@steedos.com
|
|
514
|
-
* @LastEditTime: 2024-
|
|
536
|
+
* @LastEditTime: 2024-11-17 13:10:08
|
|
515
537
|
* @Description:
|
|
516
538
|
*/
|
|
517
539
|
|
|
@@ -572,7 +594,7 @@ function getSelectMap(selectOptions){
|
|
|
572
594
|
if(optionColor && optionColor != "undefined"){
|
|
573
595
|
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
574
596
|
const color = getContrastColor(background);
|
|
575
|
-
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
597
|
+
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem;font-size:14px';
|
|
576
598
|
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
577
599
|
}else {
|
|
578
600
|
map[optionValue] = option.label;
|
|
@@ -933,12 +955,12 @@ function getScriptForRemoveUrlPrefixForImgFields(fields){
|
|
|
933
955
|
if(imgFieldValue instanceof Array){
|
|
934
956
|
formData[item] = imgFieldValue.map((value)=>{
|
|
935
957
|
let itemValue = value && value.split('/');
|
|
936
|
-
return itemValue[itemValue.length - 1];
|
|
958
|
+
return itemValue[itemValue.length - 1].split('?')[0];
|
|
937
959
|
});
|
|
938
960
|
}
|
|
939
961
|
}else{
|
|
940
962
|
let imgValue = imgFieldValue.split('/');
|
|
941
|
-
formData[item] = imgValue[imgValue.length - 1];
|
|
963
|
+
formData[item] = imgValue[imgValue.length - 1].split('?')[0];
|
|
942
964
|
}
|
|
943
965
|
}
|
|
944
966
|
})
|
|
@@ -1218,7 +1240,7 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
|
|
|
1218
1240
|
* @Author: baozhoutao@steedos.com
|
|
1219
1241
|
* @Date: 2022-10-28 14:15:09
|
|
1220
1242
|
* @LastEditors: baozhoutao@steedos.com
|
|
1221
|
-
* @LastEditTime: 2024-
|
|
1243
|
+
* @LastEditTime: 2024-11-14 10:50:01
|
|
1222
1244
|
* @Description:
|
|
1223
1245
|
*/
|
|
1224
1246
|
|
|
@@ -1277,6 +1299,7 @@ async function getLookupLinkOnClick(field, options) {
|
|
|
1277
1299
|
"title": " ",
|
|
1278
1300
|
"headerClassName": "hidden",
|
|
1279
1301
|
"size": "lg",
|
|
1302
|
+
"width": "70%",
|
|
1280
1303
|
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
1281
1304
|
"closeOnEsc": true,
|
|
1282
1305
|
"closeOnOutside": true,
|
|
@@ -1316,13 +1339,13 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
|
|
|
1316
1339
|
if(type === 'file'){
|
|
1317
1340
|
return window.Meteor?.isCordova ? {
|
|
1318
1341
|
"type": "control",
|
|
1319
|
-
"body": {
|
|
1342
|
+
"body": steedosField.multiple ? {
|
|
1320
1343
|
"type": "each",
|
|
1321
1344
|
"name": "_display." + steedosField.name,
|
|
1322
1345
|
"items": {
|
|
1323
1346
|
"type": "tpl",
|
|
1324
1347
|
"tpl": "${name}",
|
|
1325
|
-
"className": "antd-Button--link inline-block",
|
|
1348
|
+
"className": "antd-Button--link inline-block mr-2",
|
|
1326
1349
|
"onEvent": {
|
|
1327
1350
|
"click": {
|
|
1328
1351
|
"actions": [
|
|
@@ -1337,6 +1360,24 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
|
|
|
1337
1360
|
}
|
|
1338
1361
|
}
|
|
1339
1362
|
}
|
|
1363
|
+
} : {
|
|
1364
|
+
"type": "tpl",
|
|
1365
|
+
"tpl": "${_display." + steedosField.name + ".name}",
|
|
1366
|
+
"className": "antd-Button--link inline-block",
|
|
1367
|
+
"onEvent": {
|
|
1368
|
+
"click": {
|
|
1369
|
+
"actions": [
|
|
1370
|
+
{
|
|
1371
|
+
"script": `
|
|
1372
|
+
const data = event.data._display.${steedosField.name};
|
|
1373
|
+
Steedos.cordovaDownload(encodeURI(data.url), data.name);
|
|
1374
|
+
`,
|
|
1375
|
+
"actionType": "custom"
|
|
1376
|
+
}
|
|
1377
|
+
],
|
|
1378
|
+
"weight": 0
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1340
1381
|
}
|
|
1341
1382
|
} : {
|
|
1342
1383
|
// type: amisFieldType,
|
|
@@ -2351,6 +2392,7 @@ async function getColumnItemOnClick(field, options){
|
|
|
2351
2392
|
"title": " ",
|
|
2352
2393
|
"headerClassName": "hidden",
|
|
2353
2394
|
"size": "lg",
|
|
2395
|
+
"width": "70%",
|
|
2354
2396
|
"bodyClassName": "p-0 m-0 bg-gray-100",
|
|
2355
2397
|
"closeOnEsc": true,
|
|
2356
2398
|
"closeOnOutside": true,
|
|
@@ -3502,7 +3544,7 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3502
3544
|
var gridAndObjectFieldsName = ${JSON.stringify(gridAndObjectFieldsName)};
|
|
3503
3545
|
try{
|
|
3504
3546
|
${scriptStr}
|
|
3505
|
-
${getScriptForAddUrlPrefixForImgFields(fields)}
|
|
3547
|
+
${getScriptForAddUrlPrefixForImgFields(fields, true)}
|
|
3506
3548
|
${getScriptForRewriteValueForFileFields(fields)}
|
|
3507
3549
|
}catch(e){
|
|
3508
3550
|
console.error(e)
|
|
@@ -3566,7 +3608,7 @@ async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
|
3566
3608
|
/*
|
|
3567
3609
|
img/avatar字段值添加URL前缀使其在amis中正常显示图片。
|
|
3568
3610
|
*/
|
|
3569
|
-
function getScriptForAddUrlPrefixForImgFields(fields){
|
|
3611
|
+
function getScriptForAddUrlPrefixForImgFields(fields, readonly){
|
|
3570
3612
|
let imgFieldsKeys = [];
|
|
3571
3613
|
let imgFields = {};
|
|
3572
3614
|
fields.forEach((item)=>{
|
|
@@ -3594,12 +3636,12 @@ function getScriptForAddUrlPrefixForImgFields(fields){
|
|
|
3594
3636
|
if(fieldProps.multiple){
|
|
3595
3637
|
if(imgFieldDisplayValue instanceof Array){
|
|
3596
3638
|
data[item] = imgFieldDisplayValue.map((i)=>{
|
|
3597
|
-
const url = window.getImageFieldUrl(i.url);
|
|
3639
|
+
const url = window.getImageFieldUrl(i.url, ${readonly});
|
|
3598
3640
|
return url;
|
|
3599
3641
|
});
|
|
3600
3642
|
}
|
|
3601
3643
|
}else{
|
|
3602
|
-
const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
|
|
3644
|
+
const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url, ${readonly});
|
|
3603
3645
|
data[item] = url;
|
|
3604
3646
|
}
|
|
3605
3647
|
}
|
|
@@ -3695,7 +3737,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3695
3737
|
const fieldKeys = uiSchema && _.keys(uiSchema.fields);
|
|
3696
3738
|
|
|
3697
3739
|
if(data){
|
|
3698
|
-
${getScriptForAddUrlPrefixForImgFields(fields)}
|
|
3740
|
+
${getScriptForAddUrlPrefixForImgFields(fields, false)}
|
|
3699
3741
|
${getScriptForRewriteValueForFileFields(fields)}
|
|
3700
3742
|
|
|
3701
3743
|
_.each(dataKeys, function(key){
|
|
@@ -7765,7 +7807,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
7765
7807
|
let body = [
|
|
7766
7808
|
{
|
|
7767
7809
|
"type": "wrapper",
|
|
7768
|
-
"className": "p-4
|
|
7810
|
+
"className": "p-4",
|
|
7769
7811
|
"body": [
|
|
7770
7812
|
{
|
|
7771
7813
|
"type": "grid",
|
|
@@ -7863,7 +7905,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
7863
7905
|
"body": details,
|
|
7864
7906
|
"hiddenOn": "${recordLoaded != true}"
|
|
7865
7907
|
},
|
|
7866
|
-
"className": "steedos-record-compact-layouts p-4
|
|
7908
|
+
"className": "steedos-record-compact-layouts p-4 pb-2 border-t compact-layouts"
|
|
7867
7909
|
});
|
|
7868
7910
|
}
|
|
7869
7911
|
|
|
@@ -10929,7 +10971,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
10929
10971
|
};
|
|
10930
10972
|
const content = {
|
|
10931
10973
|
"type": "tabs",
|
|
10932
|
-
"className": "steedos-record-tabs bg-white p-4 sm:m-
|
|
10974
|
+
"className": "steedos-record-tabs bg-white p-4 sm:m-4 sm:shadow sm:rounded",
|
|
10933
10975
|
"contentClassName": "bg-none",
|
|
10934
10976
|
"tabs": [
|
|
10935
10977
|
detailed
|
|
@@ -13345,7 +13387,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
13345
13387
|
// }
|
|
13346
13388
|
// 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
|
|
13347
13389
|
convertData = {
|
|
13348
|
-
type: "input-
|
|
13390
|
+
type: "input-datetime-range",
|
|
13349
13391
|
inputFormat: "YYYY-MM-DD HH:mm",
|
|
13350
13392
|
format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
13351
13393
|
tpl: readonly ? getDateTimeTpl(field) : null,
|