@steedos-widgets/sortable 1.3.4-beta.15 → 1.3.4-beta.16

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.
@@ -56813,6 +56813,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
56813
56813
  }
56814
56814
 
56815
56815
  function getObjectFooterToolbar(mainObject, formFactor, options) {
56816
+ // crud card模式与table模式两种情况下showPageInput默认值不一样,所以需要显式设置为false
56816
56817
  if (formFactor === 'SMALL') {
56817
56818
  // return [
56818
56819
  // "load-more",
@@ -56822,15 +56823,17 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
56822
56823
  "switch-per-page",
56823
56824
  {
56824
56825
  "type": "pagination",
56825
- "maxButtons": 5
56826
+ "maxButtons": 5,
56827
+ "showPageInput": false
56826
56828
  }
56827
56829
  ]
56828
56830
  }else {
56829
56831
  return [
56830
- "statistics",
56832
+ // "statistics",
56831
56833
  {
56832
56834
  "type": "pagination",
56833
- "maxButtons": 5
56835
+ "maxButtons": 5,
56836
+ "showPageInput": false
56834
56837
  }
56835
56838
  ]
56836
56839
  }
@@ -56839,7 +56842,11 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
56839
56842
  if(options && options.isRelated){
56840
56843
  return [
56841
56844
  "statistics",
56842
- "pagination"
56845
+ {
56846
+ "type": "pagination",
56847
+ "maxButtons": 10,
56848
+ "showPageInput": false
56849
+ }
56843
56850
  ]
56844
56851
 
56845
56852
  }
@@ -56847,7 +56854,11 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
56847
56854
  return [
56848
56855
  "switch-per-page",
56849
56856
  "statistics",
56850
- "pagination"
56857
+ {
56858
+ "type": "pagination",
56859
+ "maxButtons": 10,
56860
+ "showPageInput": false
56861
+ }
56851
56862
  ]
56852
56863
  }
56853
56864
  }
@@ -57730,15 +57741,17 @@ async function lookupToAmisSelect(field, readonly, ctx){
57730
57741
  var optionsFilters = [["${valueFieldKey}", optionsFiltersOp, []]];
57731
57742
  if (defaultValue && !api.data.$term) {
57732
57743
  const defaultValueOptionsQueryData = ${JSON.stringify(defaultValueOptionsQueryData)};
57733
- const defaultValueOptionsQuery = defaultValueOptionsQueryData.query.replace(/^{/,"").replace(/}$/,"");
57744
+ const defaultValueOptionsQuery = defaultValueOptionsQueryData?.query?.replace(/^{/,"").replace(/}$/,"");
57734
57745
  // 字段值单独请求,没值的时候在请求中返回空
57735
57746
  optionsFilters = [["${valueFieldKey}", optionsFiltersOp, defaultValue]];
57736
57747
  if(filters.length > 0){
57737
57748
  optionsFilters = [filters, optionsFilters];
57738
57749
  }
57739
- api.data.query = "{"+api.data.query.replace(/^{/,"").replace(/}$/,"")+","+defaultValueOptionsQuery+"}";
57740
- api.data.query = api.data.query.replace(/{__options_filters}/g, JSON.stringify(optionsFilters))
57750
+ if(defaultValueOptionsQuery){
57751
+ api.data.query = "{"+api.data.query.replace(/^{/,"").replace(/}$/,"")+","+defaultValueOptionsQuery+"}";
57752
+ }
57741
57753
  }
57754
+ api.data.query = api.data.query.replace(/{__options_filters}/g, JSON.stringify(optionsFilters));
57742
57755
  return api;
57743
57756
  `;
57744
57757
  referenceTo ? referenceTo.labelField.name : '';
@@ -58563,7 +58576,20 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
58563
58576
  type: getAmisStaticFieldType('number', readonly),
58564
58577
  min: field.min,
58565
58578
  max: field.max,
58566
- precision: field.scale
58579
+ precision: field.scale,
58580
+ suffix: "%",
58581
+ pipeIn: (value, data) => {
58582
+ if(value){
58583
+ return value*100;
58584
+ }
58585
+ return value;
58586
+ },
58587
+ pipeOut: (value, oldValue, data) => {
58588
+ if(value){
58589
+ return value/100;
58590
+ }
58591
+ return value;
58592
+ },
58567
58593
  };
58568
58594
  }
58569
58595
  break;
@@ -59042,7 +59068,7 @@ async function getQuickEditSchema(field, options){
59042
59068
  break;
59043
59069
  case "percent":
59044
59070
  TempDisplayField = `
59045
- _display["${field.name}"] = (event.data.value * 100).toFixed(${field.scale}) + '%';
59071
+ _display["${field.name}"] = event.data.value.toFixed(${field.scale}) + '%';
59046
59072
  `;
59047
59073
  quickEditSchema.body[0].onEvent["change"] = quickEditOnEvent(TempDisplayField);
59048
59074
  break;
@@ -59673,23 +59699,86 @@ async function getTableOperation(ctx){
59673
59699
  }
59674
59700
  }
59675
59701
 
59702
+ async function getDefaultCrudCard(columns, options) {
59703
+ let labelFieldName = options?.labelFieldName || "name";
59704
+ let titleColumn, bodyColumns = [];
59705
+ columns.forEach(function (item) {
59706
+ delete item.quickEdit;
59707
+ delete item.width;
59708
+ if (item.name === labelFieldName) {
59709
+ titleColumn = item;
59710
+ }
59711
+ else {
59712
+ if (item.name !== "_index") {
59713
+ bodyColumns.push(item);
59714
+ }
59715
+ }
59716
+ });
59717
+ let card = {
59718
+ "header": {
59719
+ "title": titleColumn.tpl
59720
+ },
59721
+ body: bodyColumns,
59722
+ // useCardLabel: false,
59723
+ toolbar: []
59724
+ };
59725
+ let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
59726
+ if(!hideToolbarOperation){
59727
+ let toolbarOperation = await getTableOperation(options);
59728
+ if (toolbarOperation) {
59729
+ toolbarOperation.className += " inline-block w-auto";
59730
+ }
59731
+ card.toolbar.push(toolbarOperation);
59732
+ }
59733
+ return card;
59734
+ }
59735
+
59676
59736
  async function getTableSchema$1(fields, options){
59677
59737
  if(!options){
59678
59738
  options = {};
59679
59739
  }
59680
59740
  let { isLookup, hiddenColumnOperation } = options;
59741
+ const defaults = options.defaults;
59742
+ const listSchema = (defaults && defaults.listSchema) || {};
59743
+
59681
59744
  let columns = [];
59682
59745
  let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
59683
59746
  if(isLookup){
59684
59747
  // 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
59685
59748
  useMobileColumns = false;
59686
59749
  }
59750
+ if(listSchema.mode && listSchema.mode !== "table"){
59751
+ // 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
59752
+ useMobileColumns = false;
59753
+ }
59687
59754
  if(useMobileColumns){
59688
59755
  columns = await getMobileTableColumns(fields, options);
59689
59756
  }
59690
59757
  else {
59691
59758
  columns = await getTableColumns(fields, options);
59692
59759
 
59760
+ if(listSchema.mode === "cards"){
59761
+ let card = listSchema.card;
59762
+ if(!card){
59763
+ card = await getDefaultCrudCard(columns, options);
59764
+ }
59765
+ return {
59766
+ mode: "cards",
59767
+ name: "thelist",
59768
+ headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
59769
+ className: "",
59770
+ draggable: false,
59771
+ defaultParams: getDefaultParams(options),
59772
+ card: card,
59773
+ syncLocation: false,
59774
+ keepItemSelectionOnPageChange: true,
59775
+ checkOnItemClick: isLookup ? true : false,
59776
+ labelTpl: `\${${options.labelFieldName}}`,
59777
+ autoFillHeight: false, // 自动高度效果不理想,先关闭
59778
+ columnsTogglable: false
59779
+ }
59780
+ }
59781
+
59693
59782
  if(!isLookup && !hiddenColumnOperation){
59694
59783
  columns.push(await getTableOperation(options));
59695
59784
  }
@@ -59784,8 +59873,8 @@ function isObject(obj) {
59784
59873
  /*
59785
59874
  * @Author: baozhoutao@steedos.com
59786
59875
  * @Date: 2022-07-05 15:55:39
59787
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
59788
- * @LastEditTime: 2023-09-21 17:35:06
59876
+ * @LastEditors: liaodaxue
59877
+ * @LastEditTime: 2023-10-20 11:38:25
59789
59878
  * @Description:
59790
59879
  */
59791
59880
 
@@ -60082,8 +60171,8 @@ async function getListSchema(
60082
60171
  "filtersFunction": listview_filters,
60083
60172
  "sort": sort,
60084
60173
  "ctx": ctx,
60085
- "requestAdaptor": listView.requestAdaptor,
60086
- "adaptor": listView.adaptor,
60174
+ "requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
60175
+ "adaptor": listView.adaptor || ctx.adaptor,
60087
60176
  "headerToolbarItems": ctx.headerToolbarItems,
60088
60177
  "filterVisible": ctx.filterVisible,
60089
60178
  "rowClassNameExpr": ctx.rowClassNameExpr,
@@ -65217,7 +65306,7 @@ var PLACEHOLDER_ID = 'placeholder';
65217
65306
  var empty = [];
65218
65307
  function MultipleContainers(props) {
65219
65308
  var _this = this;
65220
- var _a = props.adjustScale, adjustScale = _a === void 0 ? false : _a; props.itemCount; var cancelDrop = props.cancelDrop, _c = props.columns, columns = _c === void 0 ? 1 : _c, _d = props.handle, handle = _d === void 0 ? true : _d, containerStyle = props.containerStyle, _e = props.coordinateGetter, coordinateGetter$1 = _e === void 0 ? coordinateGetter : _e, _f = props.getItemStyles, getItemStyles = _f === void 0 ? function () { return ({}); } : _f, _g = props.wrapperStyle, wrapperStyle = _g === void 0 ? function () { return ({}); } : _g, _h = props.minimal, minimal = _h === void 0 ? false : _h, modifiers = props.modifiers, renderItem = props.renderItem, _j = props.strategy, strategy = _j === void 0 ? verticalListSortingStrategy : _j, _k = props.addable, addable = _k === void 0 ? false : _k, _l = props.trashable, trashable = _l === void 0 ? false : _l, _m = props.vertical, vertical = _m === void 0 ? false : _m, scrollable = props.scrollable, _o = props.boardSource, boardSource = _o === void 0 ? [] : _o, _p = props.cardSource, cardSource = _p === void 0 ? [] : _p, defaultValue = props.defaultValue, amisOnChange = props.onChange, amisData = props.data, amisDispatchEvent = props.dispatchEvent, amisRender = props.render, _q = props.cardSchema, cardSchema = _q === void 0 ? [{
65309
+ var _a = props.adjustScale, adjustScale = _a === void 0 ? false : _a; props.itemCount; var cancelDrop = props.cancelDrop, _c = props.columns, columns = _c === void 0 ? 1 : _c, _d = props.handle, handle = _d === void 0 ? true : _d, containerStyle = props.containerStyle, _e = props.coordinateGetter, coordinateGetter$1 = _e === void 0 ? coordinateGetter : _e, _f = props.getItemStyles, getItemStyles = _f === void 0 ? function () { return ({}); } : _f, _g = props.wrapperStyle, wrapperStyle = _g === void 0 ? function () { return ({}); } : _g, _h = props.minimal, minimal = _h === void 0 ? false : _h, modifiers = props.modifiers, renderItem = props.renderItem, _j = props.strategy, strategy = _j === void 0 ? verticalListSortingStrategy : _j, _k = props.addable, addable = _k === void 0 ? false : _k, _l = props.trashable, trashable = _l === void 0 ? false : _l, _m = props.vertical, vertical = _m === void 0 ? false : _m, scrollable = props.scrollable, _o = props.boardSource, boardSource = _o === void 0 ? [] : _o, _p = props.cardSource, cardSource = _p === void 0 ? [] : _p, value = props.value, amisOnChange = props.onChange, amisData = props.data, amisDispatchEvent = props.dispatchEvent, amisRender = props.render, _q = props.cardSchema, cardSchema = _q === void 0 ? [{
65221
65310
  "type": "tpl",
65222
65311
  "tpl": "${label}",
65223
65312
  "inline": false,
@@ -65225,10 +65314,10 @@ function MultipleContainers(props) {
65225
65314
  "type": "tpl",
65226
65315
  "tpl": "${label}",
65227
65316
  }] : _r, _s = props.boardFooter, boardFooter = _s === void 0 ? [] : _s, _t = props.wrapperClassName, wrapperClassName = _t === void 0 ? "gap-2" : _t, _u = props.boardClassName, boardClassName = _u === void 0 ? "border rounded" : _u, _v = props.cardClassName, cardClassName = _v === void 0 ? "" : _v;
65228
- defaultValue && delete (defaultValue.$$id);
65317
+ // defaultValue && delete(defaultValue.$$id);
65229
65318
  var _w = __read(react.exports.useState(function () {
65230
65319
  var _a;
65231
- return (_a = defaultValue) !== null && _a !== void 0 ? _a : {
65320
+ return (_a = value) !== null && _a !== void 0 ? _a : {
65232
65321
  A: ['A1', 'A2'],
65233
65322
  B: ['B1', 'B2'],
65234
65323
  C: ['C1', 'C2'],