@steedos-widgets/amis-lib 1.2.9 → 1.2.10
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 +44 -53
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +45 -54
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +44 -53
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/tpl.d.ts +1 -0
- package/dist/types/lib/converter/amis/util.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$1 from 'lodash';
|
|
2
|
-
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, toArray, mergeWith, map,
|
|
2
|
+
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, get, toArray, mergeWith, map, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
|
|
3
3
|
import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
|
|
4
4
|
import isPlainObject from 'lodash/isPlainObject';
|
|
5
5
|
|
|
@@ -382,11 +382,28 @@ const Router = {
|
|
|
382
382
|
|
|
383
383
|
};
|
|
384
384
|
|
|
385
|
+
/*
|
|
386
|
+
* @Author: baozhoutao@steedos.com
|
|
387
|
+
* @Date: 2022-07-20 16:29:22
|
|
388
|
+
* @LastEditors: Please set LastEditors
|
|
389
|
+
* @LastEditTime: 2023-05-18 15:22:51
|
|
390
|
+
* @Description:
|
|
391
|
+
*/
|
|
392
|
+
|
|
393
|
+
function getContrastColor(bgColor) {
|
|
394
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
395
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
396
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
397
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
398
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
399
|
+
return brightness < 128 ? "#ffffff" : "#000000";
|
|
400
|
+
}
|
|
401
|
+
|
|
385
402
|
/*
|
|
386
403
|
* @Author: baozhoutao@steedos.com
|
|
387
404
|
* @Date: 2022-05-23 09:53:08
|
|
388
|
-
* @LastEditors:
|
|
389
|
-
* @LastEditTime: 2023-
|
|
405
|
+
* @LastEditors: Please set LastEditors
|
|
406
|
+
* @LastEditTime: 2023-05-18 16:34:39
|
|
390
407
|
* @Description:
|
|
391
408
|
*/
|
|
392
409
|
|
|
@@ -439,6 +456,21 @@ async function getRefObjectNameFieldName(field){
|
|
|
439
456
|
function getSelectTpl(field){
|
|
440
457
|
return `<div>\${_display.${field.name}}</div>`
|
|
441
458
|
}
|
|
459
|
+
function getSelectMap(selectOptions){
|
|
460
|
+
let map = {};
|
|
461
|
+
forEach(selectOptions,(option)=>{
|
|
462
|
+
const optionValue = option.value + '';
|
|
463
|
+
if(option.color){
|
|
464
|
+
const background = option.color.charAt(0) === '#' ? option.color : '#'+option.color;
|
|
465
|
+
const color = getContrastColor(background);
|
|
466
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
467
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
468
|
+
}else {
|
|
469
|
+
map[optionValue] = option.label;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return map;
|
|
473
|
+
}
|
|
442
474
|
|
|
443
475
|
function getNameTplUrl(field, ctx){
|
|
444
476
|
if(ctx.objectName === 'cms_files'){
|
|
@@ -3398,8 +3430,8 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3398
3430
|
},
|
|
3399
3431
|
"body":[{
|
|
3400
3432
|
"type": "button",
|
|
3401
|
-
"visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
|
|
3402
|
-
"className":"flex mr-
|
|
3433
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
3434
|
+
"className":"flex mr-4",
|
|
3403
3435
|
"onEvent": {
|
|
3404
3436
|
"click": {
|
|
3405
3437
|
"actions": [
|
|
@@ -3416,7 +3448,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
3416
3448
|
"category": "utility",
|
|
3417
3449
|
"name": "back",
|
|
3418
3450
|
"colorVariant": "default",
|
|
3419
|
-
"className": "slds-button_icon slds-global-header__icon"
|
|
3451
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
3420
3452
|
}
|
|
3421
3453
|
]
|
|
3422
3454
|
}]
|
|
@@ -4384,7 +4416,7 @@ const getSetListviewSortButtonSchema = ()=>{
|
|
|
4384
4416
|
{
|
|
4385
4417
|
"dialog": {
|
|
4386
4418
|
"type": "dialog",
|
|
4387
|
-
"title": "
|
|
4419
|
+
"title": "默认排序规则",
|
|
4388
4420
|
"data": {
|
|
4389
4421
|
"&": "$$",
|
|
4390
4422
|
"targetObjectName": "${objectName}",
|
|
@@ -5984,23 +6016,6 @@ const getAmisFileSchema = (steedosField, readonly)=>{
|
|
|
5984
6016
|
return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
|
|
5985
6017
|
};
|
|
5986
6018
|
|
|
5987
|
-
/*
|
|
5988
|
-
* @Author: baozhoutao@steedos.com
|
|
5989
|
-
* @Date: 2022-07-20 16:29:22
|
|
5990
|
-
* @LastEditors: Please set LastEditors
|
|
5991
|
-
* @LastEditTime: 2023-05-11 11:19:54
|
|
5992
|
-
* @Description:
|
|
5993
|
-
*/
|
|
5994
|
-
|
|
5995
|
-
function getContrastColor(bgColor) {
|
|
5996
|
-
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
5997
|
-
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
5998
|
-
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
5999
|
-
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
6000
|
-
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
6001
|
-
return brightness >= 128 ? "#000000" : "#ffffff";
|
|
6002
|
-
}
|
|
6003
|
-
|
|
6004
6019
|
const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
|
|
6005
6020
|
// const Lookup = require('./lookup');
|
|
6006
6021
|
|
|
@@ -6191,19 +6206,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
6191
6206
|
// break;
|
|
6192
6207
|
case 'select':
|
|
6193
6208
|
if(readonly){
|
|
6194
|
-
const
|
|
6195
|
-
let map = {};
|
|
6196
|
-
_$1.forEach(selectOptions,(option)=>{
|
|
6197
|
-
const optionValue = option.value + '';
|
|
6198
|
-
if(option.color){
|
|
6199
|
-
const background = '#'+option.color;
|
|
6200
|
-
const color = getContrastColor(background);
|
|
6201
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
6202
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
6203
|
-
}else {
|
|
6204
|
-
map[optionValue] = option.label;
|
|
6205
|
-
}
|
|
6206
|
-
});
|
|
6209
|
+
const map = getSelectMap(field.options);
|
|
6207
6210
|
convertData = {
|
|
6208
6211
|
type: "static-mapping",
|
|
6209
6212
|
name: field.name,
|
|
@@ -6902,7 +6905,8 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
6902
6905
|
data.global = "${global}";
|
|
6903
6906
|
data.context = "${context}";
|
|
6904
6907
|
data.defaultData = "${defaultData}";
|
|
6905
|
-
|
|
6908
|
+
data._master = "${_master}";
|
|
6909
|
+
|
|
6906
6910
|
return {
|
|
6907
6911
|
method: "post",
|
|
6908
6912
|
url: getApi$2() + '&objectName=${objectName}' ,
|
|
@@ -6968,7 +6972,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
6968
6972
|
formInitialValuesFun = new Function("return " + formInitialValuesFun)();
|
|
6969
6973
|
}
|
|
6970
6974
|
if(typeof formInitialValuesFun === "function"){
|
|
6971
|
-
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
|
|
6975
|
+
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global, master: api.body._master })
|
|
6972
6976
|
}
|
|
6973
6977
|
}
|
|
6974
6978
|
catch(ex){
|
|
@@ -7624,19 +7628,7 @@ async function getTableColumns(fields, options){
|
|
|
7624
7628
|
}, field.amis, {name: field.name}));
|
|
7625
7629
|
}
|
|
7626
7630
|
else if(field.type === 'select'){
|
|
7627
|
-
const
|
|
7628
|
-
let map = {};
|
|
7629
|
-
forEach(selectOptions,(option)=>{
|
|
7630
|
-
const optionValue = option.value + '';
|
|
7631
|
-
if(option.color){
|
|
7632
|
-
const background = '#'+option.color;
|
|
7633
|
-
const color = getContrastColor(background);
|
|
7634
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
7635
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
7636
|
-
}else {
|
|
7637
|
-
map[optionValue] = option.label;
|
|
7638
|
-
}
|
|
7639
|
-
});
|
|
7631
|
+
const map = getSelectMap(field.options);
|
|
7640
7632
|
columns.push(Object.assign({}, {
|
|
7641
7633
|
type: "mapping",
|
|
7642
7634
|
name: field.name,
|
|
@@ -8189,11 +8181,10 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8189
8181
|
if(api.data.$self._isRelated){
|
|
8190
8182
|
const self = api.data.$self;
|
|
8191
8183
|
const relatedKey = self.relatedKey;
|
|
8192
|
-
const recordId = self.recordId;
|
|
8193
8184
|
const refField = self.uiSchema.fields[relatedKey];
|
|
8194
8185
|
const masterRecord = self._master.record;
|
|
8195
8186
|
const masterObjectName = self._master.objectName;
|
|
8196
|
-
let relatedValue = recordId;
|
|
8187
|
+
let relatedValue = self._master.recordId;
|
|
8197
8188
|
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
8198
8189
|
relatedValue = masterRecord[refField.reference_to_field]
|
|
8199
8190
|
}
|