ronds-metadata 1.2.34 → 1.2.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-04 13:45:31
7
- * @LastEditTime: 2023-04-06 10:38:34
7
+ * @LastEditTime: 2023-04-18 16:27:45
8
8
  */
9
9
  import React from 'react';
10
10
  import { DndProvider } from 'react-dnd';
@@ -32,19 +32,24 @@ var FormGenerator = function FormGenerator(props) {
32
32
 
33
33
  var typesRef = React.useRef({});
34
34
  React.useEffect(function () {
35
- var robot = new FormRobot(); // const name = robot.input('name').label('名称').require().placeholder('请输入名称').valueOf();
36
- // const age = robot.input('age').label('年龄').defaultValue(1).valueOf();
37
- // const address = robot.textarea('address').label('地址').help('详细地址').valueOf();
38
- // const sex = robot.select('sex').label('性别').valueOf();
39
- // const birthday = robot.date('birthday').label('出身年月').require().valueOf();
40
- // const detail = robot.object([name, age], 'detail').valueOf();
41
- // const arr = robot.create([name, age, address, sex, birthday, detail]).grid(2).toString();
35
+ var robot = new FormRobot();
42
36
 
43
- var project = robot.select('project').label('归档标签库').valueOf();
44
- var group = robot.select('group').label('标签组').valueOf();
45
- var label = robot.select('label').label('标签').valueOf();
37
+ var name = robot.input('name').label('名称').require().placeholder('请输入名称').valueOf();
46
38
 
47
- var _res = robot.create([project, group, label]).toString();
39
+ var age = robot.input('age').label('年龄').defaultValue(1).valueOf();
40
+ var address = robot.textarea('address').showCount().label('地址').help('详细地址').valueOf();
41
+ var sex = robot.select('sex').label('性别').enum([{
42
+ key: '1',
43
+ value: '男'
44
+ }, {
45
+ key: '2',
46
+ value: '女'
47
+ }]).valueOf();
48
+
49
+ var birthday = robot.date('birthday').label('出身年月').require().valueOf();
50
+
51
+ var detail = robot.object([name, age], 'detail').valueOf();
52
+ var arr = robot.create([name, age, address, sex, birthday, detail]).grid(2).toString();
48
53
  }, []);
49
54
  React.useEffect(function () {
50
55
  if (defaultSchema) {
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-08 14:45:46
7
- * @LastEditTime: 2023-04-06 10:38:43
7
+ * @LastEditTime: 2023-04-18 15:56:59
8
8
  */
9
9
  import { deepClone } from '../../utils';
10
10
  import { basicComps, complexComps, layoutComps } from './settings';
@@ -85,7 +85,7 @@ export var transFG2Schema = function transFG2Schema(nodes, settings, _types, sch
85
85
  };
86
86
  }
87
87
 
88
- var _prop = renderProp(nodes[i], settings[nodes[i].id] ? settings[nodes[i].id] : nodes[i].param.setting);
88
+ var _prop = renderProp(nodes[i], settings && settings[nodes[i].id] ? settings[nodes[i].id] : nodes[i].param.setting);
89
89
 
90
90
  props.push(_prop);
91
91
  }
@@ -105,7 +105,9 @@ export var transFG2Schema = function transFG2Schema(nodes, settings, _types, sch
105
105
  var _type = transFG2Schema(__types__[typeKeys[_i]].nodes, // 没有传入内部类的情况 不需要传
106
106
  _types && settings["".concat(typeKeys[_i], "_ref")], undefined, "".concat(__types__[typeKeys[_i]].id, "_ref"));
107
107
 
108
- types.push(_type[0]);
108
+ if (_type) {
109
+ types.push(_type[0]);
110
+ }
109
111
  }
110
112
  }
111
113
 
@@ -7,7 +7,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
7
7
  /*
8
8
  * @Author: wangxian
9
9
  * @Date: 2021-09-18 14:15:04
10
- * @LastEditTime: 2023-02-24 15:32:47
10
+ * @LastEditTime: 2023-04-18 17:15:39
11
11
  */
12
12
  import React from 'react';
13
13
  import Input from './DataCell/Input';
@@ -102,9 +102,15 @@ export function assign(pathArr, val, obj) {
102
102
  var len = pathArr.length - 1;
103
103
  pathArr.reduce(function (cur, key, index) {
104
104
  if (index === len) {
105
- cur[key] = val;
105
+ if (cur.hasOwnProperty(key)) {
106
+ Object.assign(cur[key], val);
107
+ } else {
108
+ cur[key] = val;
109
+ }
106
110
  } else {
107
- cur[key] = {};
111
+ if (!cur.hasOwnProperty(key)) {
112
+ cur[key] = {};
113
+ }
108
114
  }
109
115
 
110
116
  return cur[key];
@@ -161,6 +161,8 @@ export declare class FormRobot implements IFormRobot {
161
161
  disabled<T>(this: T): Omit<T, 'disabled'> & IReturnMethod;
162
162
  br<T>(this: T): Omit<T, 'br'> & IReturnMethod;
163
163
  hidden<T>(this: T): Omit<T, 'hidden'> & IReturnMethod;
164
+ showCount<T>(this: T): Omit<T, 'showCount'> & IReturnMethod;
165
+ maxLength<T>(this: T, _value: number): Omit<T, 'maxLength'> & IReturnMethod;
164
166
  enum<T>(this: T, _value: {
165
167
  key: number | string;
166
168
  value: string;
@@ -263,14 +263,32 @@ export var FormRobot = /*#__PURE__*/function () {
263
263
 
264
264
  return new FormRobot(_data);
265
265
  } // textarea
266
- // select
266
+
267
+ }, {
268
+ key: "showCount",
269
+ value: function showCount() {
270
+ var _init = this._hasInitData ? this._data : {};
271
+
272
+ var _data = renderSetting(_init, 'text.showCount', true);
273
+
274
+ return new FormRobot(_data);
275
+ }
276
+ }, {
277
+ key: "maxLength",
278
+ value: function maxLength(_value) {
279
+ var _init = this._hasInitData ? this._data : {};
280
+
281
+ var _data = renderSetting(_init, 'text.maxLength', _value);
282
+
283
+ return new FormRobot(_data);
284
+ } // select
267
285
 
268
286
  }, {
269
287
  key: "enum",
270
288
  value: function _enum(_value) {
271
289
  var _init = this._hasInitData ? this._data : {};
272
290
 
273
- var _data = renderSetting(_init, 'enum', _value);
291
+ var _data = renderSetting(_init, 'enum.value', _value);
274
292
 
275
293
  return new FormRobot(_data);
276
294
  } //*********************************提供的扩展规则完善表单__END************************************//
@@ -1,13 +1,13 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
2
 
4
3
  /*
5
4
  * @Author: wangxian
6
5
  * @Date: 2023-03-21 15:44:45
7
- * @LastEditTime: 2023-04-04 17:21:07
6
+ * @LastEditTime: 2023-04-18 18:53:34
8
7
  */
9
8
  import { deepClone } from '../../utils';
10
9
  import { basicComps, layoutComps } from './../../comps/FormGenerator/settings/index';
10
+ import { assign } from '../../comps/MetadataForm/utils';
11
11
  export var renderBasicFormProps = function renderBasicFormProps(_id, _type) {
12
12
  var _basicComps = deepClone(basicComps);
13
13
 
@@ -34,9 +34,21 @@ export var renderLayoutFormProps = function renderLayoutFormProps(_arr, _id, _ty
34
34
  });
35
35
  };
36
36
  export var renderSetting = function renderSetting(_init, _type, _value) {
37
+ var _init$param;
38
+
39
+ var _setting = (_init === null || _init === void 0 ? void 0 : (_init$param = _init.param) === null || _init$param === void 0 ? void 0 : _init$param.setting) || {};
40
+
41
+ if (_type.indexOf('.') > -1) {
42
+ var _arr = _type.split('.');
43
+
44
+ assign(_arr, _value, _setting);
45
+ } else {
46
+ _setting[_type] = _value;
47
+ }
48
+
37
49
  var _ = _objectSpread(_objectSpread({}, _init), {}, {
38
50
  param: _objectSpread(_objectSpread({}, _init === null || _init === void 0 ? void 0 : _init.param), {}, {
39
- setting: _objectSpread(_objectSpread({}, _init.param.setting), {}, _defineProperty({}, _type, _value))
51
+ setting: _objectSpread(_objectSpread({}, _init.param.setting), _setting)
40
52
  })
41
53
  });
42
54
 
package/es/utils.js CHANGED
@@ -7,7 +7,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
7
  /*
8
8
  * @Author: wangxian
9
9
  * @Date: 2021-09-18 14:15:04
10
- * @LastEditTime: 2023-04-13 09:51:21
10
+ * @LastEditTime: 2023-04-20 15:15:56
11
11
  */
12
12
  import saveAs from 'file-saver';
13
13
  import { asBlob } from 'html-docx-js-typescript';
@@ -201,6 +201,27 @@ function _handleMd2Doc() {
201
201
  switch (_context.prev = _context.next) {
202
202
  case 0:
203
203
  md = new MarkdownIt();
204
+
205
+ md.renderer.rules.image = function (tokens, index, options, env, self) {
206
+ var token = tokens[index];
207
+
208
+ if (!token || !token.attrGet('src')) {
209
+ // 如果 token 不存在,或者缺少必要的属性,则直接返回空字符串
210
+ return '';
211
+ }
212
+
213
+ var src = token.attrGet('src');
214
+ var width = '900'; // 自定义宽度
215
+
216
+ var height = 'auto'; // 自适应高度
217
+ // 添加自定义宽高属性
218
+
219
+ token.attrSet('width', width);
220
+ token.attrSet('height', height); // 渲染图片标签
221
+
222
+ return self.renderToken(tokens, index, options);
223
+ };
224
+
204
225
  html = md.render(mdText);
205
226
  opt = {
206
227
  margin: {
@@ -208,14 +229,14 @@ function _handleMd2Doc() {
208
229
  },
209
230
  orientation: 'landscape'
210
231
  };
211
- _context.next = 5;
232
+ _context.next = 6;
212
233
  return asBlob(html, opt);
213
234
 
214
- case 5:
235
+ case 6:
215
236
  blob = _context.sent;
216
237
  saveAs(blob, "".concat(fileName, ".doc"));
217
238
 
218
- case 7:
239
+ case 8:
219
240
  case "end":
220
241
  return _context.stop();
221
242
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.2.34",
4
+ "version": "1.2.35",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",