@wibetter/json-editor 5.0.7 → 5.0.8

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/lib/index.css CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * @wibetter/json-editor v5.0.5
2
+ * @wibetter/json-editor v5.0.7
3
3
  * author: wibetter
4
4
  * build tool: AKFun
5
- * build time: Fri Dec 20 2024 23:28:02 GMT+0800 (中国标准时间)
5
+ * build time: Tue Dec 24 2024 14:45:50 GMT+0800 (中国标准时间)
6
6
  * build tool info: https://github.com/wibetter/akfun
7
7
  */
8
8
  /*!*********************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * @wibetter/json-editor v5.0.5
2
+ * @wibetter/json-editor v5.0.7
3
3
  * author: wibetter
4
4
  * build tool: AKFun
5
- * build time: Fri Dec 20 2024 23:28:02 GMT+0800 (中国标准时间)
5
+ * build time: Tue Dec 24 2024 14:45:50 GMT+0800 (中国标准时间)
6
6
  * build tool info: https://github.com/wibetter/akfun
7
7
  */
8
8
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -787,15 +787,19 @@
787
787
  __webpack_require__(
788
788
  /*! $renderers/SelectSchema/index */ './src/renderers/SelectSchema/index.js',
789
789
  );
790
- /* harmony import */ var $renderers_DynamicConfigSchema_index__WEBPACK_IMPORTED_MODULE_25__ =
790
+ /* harmony import */ var $renderers_InputImageSchema_index__WEBPACK_IMPORTED_MODULE_25__ =
791
+ __webpack_require__(
792
+ /*! $renderers/InputImageSchema/index */ './src/renderers/InputImageSchema/index.js',
793
+ );
794
+ /* harmony import */ var $renderers_DynamicConfigSchema_index__WEBPACK_IMPORTED_MODULE_26__ =
791
795
  __webpack_require__(
792
796
  /*! $renderers/DynamicConfigSchema/index */ './src/renderers/DynamicConfigSchema/index.js',
793
797
  );
794
- /* harmony import */ var $renderers_SohuDataSourceSchema_index__WEBPACK_IMPORTED_MODULE_26__ =
798
+ /* harmony import */ var $renderers_SohuDataSourceSchema_index__WEBPACK_IMPORTED_MODULE_27__ =
795
799
  __webpack_require__(
796
800
  /*! $renderers/SohuDataSourceSchema/index */ './src/renderers/SohuDataSourceSchema/index.js',
797
801
  );
798
- /* harmony import */ var $renderers_SohuEventSchema_index__WEBPACK_IMPORTED_MODULE_27__ =
802
+ /* harmony import */ var $renderers_SohuEventSchema_index__WEBPACK_IMPORTED_MODULE_28__ =
799
803
  __webpack_require__(
800
804
  /*! $renderers/SohuEventSchema/index */ './src/renderers/SohuEventSchema/index.js',
801
805
  );
@@ -866,7 +870,7 @@
866
870
  );
867
871
  case 'dynamic-config':
868
872
  return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createElement(
869
- $renderers_DynamicConfigSchema_index__WEBPACK_IMPORTED_MODULE_25__[
873
+ $renderers_DynamicConfigSchema_index__WEBPACK_IMPORTED_MODULE_26__[
870
874
  'default'
871
875
  ],
872
876
  _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(
@@ -879,7 +883,7 @@
879
883
  );
880
884
  case 'sohu-source':
881
885
  return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createElement(
882
- $renderers_SohuDataSourceSchema_index__WEBPACK_IMPORTED_MODULE_26__[
886
+ $renderers_SohuDataSourceSchema_index__WEBPACK_IMPORTED_MODULE_27__[
883
887
  'default'
884
888
  ],
885
889
  _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(
@@ -892,7 +896,7 @@
892
896
  );
893
897
  case 'sohu-event':
894
898
  return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createElement(
895
- $renderers_SohuEventSchema_index__WEBPACK_IMPORTED_MODULE_27__[
899
+ $renderers_SohuEventSchema_index__WEBPACK_IMPORTED_MODULE_28__[
896
900
  'default'
897
901
  ],
898
902
  _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(
@@ -1139,6 +1143,19 @@
1139
1143
  },
1140
1144
  ),
1141
1145
  );
1146
+ case 'input-image':
1147
+ return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createElement(
1148
+ $renderers_InputImageSchema_index__WEBPACK_IMPORTED_MODULE_25__[
1149
+ 'default'
1150
+ ],
1151
+ _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(
1152
+ {},
1153
+ newProps,
1154
+ {
1155
+ key: curNodeKey,
1156
+ },
1157
+ ),
1158
+ );
1142
1159
  case 'json':
1143
1160
  return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createElement(
1144
1161
  $renderers_JsonFormSchema_index__WEBPACK_IMPORTED_MODULE_21__[
@@ -6447,6 +6464,318 @@
6447
6464
  /***/
6448
6465
  },
6449
6466
 
6467
+ /***/ './src/renderers/InputImageSchema/index.js':
6468
+ /*!*************************************************!*\
6469
+ !*** ./src/renderers/InputImageSchema/index.js ***!
6470
+ \*************************************************/
6471
+ /***/ function (
6472
+ __unused_webpack_module,
6473
+ __webpack_exports__,
6474
+ __webpack_require__,
6475
+ ) {
6476
+ 'use strict';
6477
+ __webpack_require__.r(__webpack_exports__);
6478
+ /* harmony import */ var _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ =
6479
+ __webpack_require__(
6480
+ /*! @babel/runtime/helpers/inheritsLoose */ '@babel/runtime/helpers/inheritsLoose',
6481
+ );
6482
+ /* harmony import */ var _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_0___default =
6483
+ /*#__PURE__*/ __webpack_require__.n(
6484
+ _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__,
6485
+ );
6486
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ =
6487
+ __webpack_require__(/*! react */ 'react');
6488
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default =
6489
+ /*#__PURE__*/ __webpack_require__.n(
6490
+ react__WEBPACK_IMPORTED_MODULE_1__,
6491
+ );
6492
+ /* harmony import */ var mobx_react__WEBPACK_IMPORTED_MODULE_2__ =
6493
+ __webpack_require__(/*! mobx-react */ 'mobx-react');
6494
+ /* harmony import */ var mobx_react__WEBPACK_IMPORTED_MODULE_2___default =
6495
+ /*#__PURE__*/ __webpack_require__.n(
6496
+ mobx_react__WEBPACK_IMPORTED_MODULE_2__,
6497
+ );
6498
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ =
6499
+ __webpack_require__(/*! prop-types */ 'prop-types');
6500
+ /* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default =
6501
+ /*#__PURE__*/ __webpack_require__.n(
6502
+ prop_types__WEBPACK_IMPORTED_MODULE_3__,
6503
+ );
6504
+ /* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4__ =
6505
+ __webpack_require__(/*! antd */ 'antd');
6506
+ /* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4___default =
6507
+ /*#__PURE__*/ __webpack_require__.n(
6508
+ antd__WEBPACK_IMPORTED_MODULE_4__,
6509
+ );
6510
+ /* harmony import */ var _ant_design_icons__WEBPACK_IMPORTED_MODULE_5__ =
6511
+ __webpack_require__(/*! @ant-design/icons */ '@ant-design/icons');
6512
+ /* harmony import */ var _ant_design_icons__WEBPACK_IMPORTED_MODULE_5___default =
6513
+ /*#__PURE__*/ __webpack_require__.n(
6514
+ _ant_design_icons__WEBPACK_IMPORTED_MODULE_5__,
6515
+ );
6516
+ /* harmony import */ var _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_6__ =
6517
+ __webpack_require__(
6518
+ /*! @wibetter/json-utils */ '@wibetter/json-utils',
6519
+ );
6520
+ /* harmony import */ var _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_6___default =
6521
+ /*#__PURE__*/ __webpack_require__.n(
6522
+ _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_6__,
6523
+ );
6524
+ /* harmony import */ var $mixins_index__WEBPACK_IMPORTED_MODULE_7__ =
6525
+ __webpack_require__(/*! $mixins/index */ './src/mixins/index.js');
6526
+
6527
+ var InputImageSchema = /*#__PURE__*/ (function (
6528
+ _React$PureComponent,
6529
+ ) {
6530
+ function InputImageSchema(props) {
6531
+ var _this;
6532
+ _this = _React$PureComponent.call(this, props) || this;
6533
+ _this.handleImageChange = function (fileInfo) {
6534
+ var _this$props = _this.props,
6535
+ keyRoute = _this$props.keyRoute,
6536
+ updateFormValueData = _this$props.updateFormValueData;
6537
+ if (fileInfo.file.status === 'uploading') {
6538
+ _this.setState({
6539
+ loading: true,
6540
+ });
6541
+ return;
6542
+ }
6543
+ if (fileInfo.file.status === 'done') {
6544
+ var responseData = fileInfo.file.response || {};
6545
+ if (responseData.url) {
6546
+ updateFormValueData(keyRoute, responseData.url);
6547
+ }
6548
+ } else if (fileInfo.file.status === 'error') {
6549
+ antd__WEBPACK_IMPORTED_MODULE_4__.message.error(
6550
+ fileInfo.file.name +
6551
+ ' \u56FE\u7247\u4E0A\u4F20\u5931\u8D25\u3002',
6552
+ );
6553
+ }
6554
+ _this.setState({
6555
+ loading: false,
6556
+ });
6557
+ };
6558
+ _this.state = {
6559
+ loading: false,
6560
+ };
6561
+ // 这边绑定是必要的,这样 `this` 才能在回调函数中使用
6562
+ _this.handleImageChange = _this.handleImageChange.bind(_this);
6563
+ return _this;
6564
+ }
6565
+
6566
+ // 方式1:在class组件中声明静态属性static,且必须是contextType,确保当前组件可以使用全局context中的数据(this.context不为空)
6567
+ // static contextType = ThemeContext;
6568
+ _babel_runtime_helpers_inheritsLoose__WEBPACK_IMPORTED_MODULE_0___default()(
6569
+ InputImageSchema,
6570
+ _React$PureComponent,
6571
+ );
6572
+ var _proto = InputImageSchema.prototype;
6573
+ _proto.componentWillMount = function componentWillMount() {
6574
+ // 从web缓存中获取数值
6575
+ $mixins_index__WEBPACK_IMPORTED_MODULE_7__.catchJsonDataByWebCache.call(
6576
+ this,
6577
+ );
6578
+ };
6579
+ _proto.componentWillReceiveProps =
6580
+ function componentWillReceiveProps(nextProps) {
6581
+ if (nextProps.keyRoute !== this.props.keyRoute) {
6582
+ /** 当key值路径发生变化时重新从web缓存中获取数值 */
6583
+ $mixins_index__WEBPACK_IMPORTED_MODULE_7__.catchJsonDataByWebCache.call(
6584
+ this,
6585
+ nextProps.keyRoute,
6586
+ );
6587
+ }
6588
+ };
6589
+ _proto.render = function render() {
6590
+ var _targetJsonSchema$lis;
6591
+ var _this$props2 = this.props,
6592
+ nodeKey = _this$props2.nodeKey,
6593
+ jsonKey = _this$props2.jsonKey,
6594
+ keyRoute = _this$props2.keyRoute,
6595
+ targetJsonSchema = _this$props2.targetJsonSchema,
6596
+ pageScreen = _this$props2.pageScreen,
6597
+ getJSONDataByKeyRoute = _this$props2.getJSONDataByKeyRoute;
6598
+ var options = this.props.options || {};
6599
+ var loading = this.state.loading;
6600
+ // 从jsonData中获取对应的数值
6601
+ var curJsonData = keyRoute && getJSONDataByKeyRoute(keyRoute);
6602
+ var readOnly = targetJsonSchema.readOnly || false; // 是否只读(默认可编辑)
6603
+ var isRequired = targetJsonSchema.isRequired || false; // 是否必填(默认非必填)
6604
+
6605
+ var uploadProps = {
6606
+ name: 'file',
6607
+ // targetJsonSchema.name || jsonKey || 'imgFile',
6608
+ action: targetJsonSchema.uploadAction || options.uploadAction,
6609
+ accept: targetJsonSchema.accept || options.uploadAccept,
6610
+ // multiple: targetJsonSchema.multiple ?? false,
6611
+ maxCount: targetJsonSchema.multiple
6612
+ ? targetJsonSchema.maxCount || 1
6613
+ : 1,
6614
+ // showUploadList: false,
6615
+ listType:
6616
+ (_targetJsonSchema$lis = targetJsonSchema.listType) != null
6617
+ ? _targetJsonSchema$lis
6618
+ : 'picture-card',
6619
+ headers: {
6620
+ authorization:
6621
+ targetJsonSchema.authorization || 'authorization-content',
6622
+ },
6623
+ onChange: this.handleImageChange,
6624
+ };
6625
+ return /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6626
+ 'div',
6627
+ {
6628
+ className:
6629
+ pageScreen === 'wideScreen'
6630
+ ? 'wide-screen-element-warp'
6631
+ : 'mobile-screen-element-warp',
6632
+ key: nodeKey,
6633
+ id: nodeKey,
6634
+ },
6635
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6636
+ 'div',
6637
+ {
6638
+ className: 'element-title',
6639
+ },
6640
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6641
+ 'span',
6642
+ {
6643
+ className: 'title-text warning-text',
6644
+ },
6645
+ readOnly ? '[只读]' : '',
6646
+ ),
6647
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6648
+ antd__WEBPACK_IMPORTED_MODULE_4__.Tooltip,
6649
+ {
6650
+ title:
6651
+ pageScreen === 'wideScreen'
6652
+ ? targetJsonSchema.description
6653
+ : '',
6654
+ placement: 'top',
6655
+ },
6656
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6657
+ 'span',
6658
+ {
6659
+ className: 'title-text',
6660
+ title:
6661
+ pageScreen === 'wideScreen' &&
6662
+ targetJsonSchema.title &&
6663
+ targetJsonSchema.title.length > (readOnly ? 4 : 6)
6664
+ ? targetJsonSchema.title
6665
+ : '',
6666
+ },
6667
+ targetJsonSchema.title,
6668
+ targetJsonSchema.showKey &&
6669
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6670
+ 'span',
6671
+ null,
6672
+ '\uFF08',
6673
+ (0,
6674
+ _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_6__.truncate)(
6675
+ jsonKey,
6676
+ {
6677
+ length: 15,
6678
+ },
6679
+ ),
6680
+ '\uFF09',
6681
+ ),
6682
+ ),
6683
+ ),
6684
+ pageScreen === 'mobileScreen' &&
6685
+ targetJsonSchema.description &&
6686
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6687
+ antd__WEBPACK_IMPORTED_MODULE_4__.Tooltip,
6688
+ {
6689
+ title: targetJsonSchema.description,
6690
+ placement: 'top',
6691
+ },
6692
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6693
+ _ant_design_icons__WEBPACK_IMPORTED_MODULE_5__.InfoCircleOutlined,
6694
+ {
6695
+ className: 'info-icon',
6696
+ },
6697
+ ),
6698
+ ),
6699
+ ),
6700
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6701
+ 'div',
6702
+ {
6703
+ className: 'content-item',
6704
+ },
6705
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6706
+ 'div',
6707
+ {
6708
+ className: 'form-item-box',
6709
+ },
6710
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6711
+ antd__WEBPACK_IMPORTED_MODULE_4__.Upload,
6712
+ uploadProps,
6713
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6714
+ 'button',
6715
+ {
6716
+ style: {
6717
+ border: 0,
6718
+ background: 'none',
6719
+ cursor: 'pointer',
6720
+ },
6721
+ type: 'button',
6722
+ },
6723
+ loading
6724
+ ? /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6725
+ _ant_design_icons__WEBPACK_IMPORTED_MODULE_5__.LoadingOutlined,
6726
+ null,
6727
+ )
6728
+ : /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6729
+ _ant_design_icons__WEBPACK_IMPORTED_MODULE_5__.PlusOutlined,
6730
+ null,
6731
+ ),
6732
+ /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1__.createElement(
6733
+ 'div',
6734
+ {
6735
+ style: {
6736
+ marginTop: 8,
6737
+ },
6738
+ },
6739
+ '\u4E0A\u4F20\u56FE\u7247',
6740
+ ),
6741
+ ),
6742
+ ),
6743
+ ),
6744
+ ),
6745
+ );
6746
+ };
6747
+ return InputImageSchema;
6748
+ })(react__WEBPACK_IMPORTED_MODULE_1__.PureComponent);
6749
+ InputImageSchema.propTypes = {
6750
+ parentType: prop_types__WEBPACK_IMPORTED_MODULE_3___default().any,
6751
+ jsonKey: prop_types__WEBPACK_IMPORTED_MODULE_3___default().string,
6752
+ indexRoute: prop_types__WEBPACK_IMPORTED_MODULE_3___default().any,
6753
+ keyRoute: prop_types__WEBPACK_IMPORTED_MODULE_3___default().any,
6754
+ nodeKey: prop_types__WEBPACK_IMPORTED_MODULE_3___default().string,
6755
+ targetJsonSchema:
6756
+ prop_types__WEBPACK_IMPORTED_MODULE_3___default().any,
6757
+ onChange: prop_types__WEBPACK_IMPORTED_MODULE_3___default().any,
6758
+ };
6759
+ /* harmony default export */ __webpack_exports__['default'] = (0,
6760
+ mobx_react__WEBPACK_IMPORTED_MODULE_2__.inject)(function (stores) {
6761
+ return {
6762
+ pageScreen: stores.JSONSchemaStore.pageScreen,
6763
+ options: stores.JSONEditorStore.options,
6764
+ getJSONDataByKeyRoute:
6765
+ stores.JSONEditorStore.getJSONDataByKeyRoute,
6766
+ getInitJsonDataByKeyRoute:
6767
+ stores.JSONEditorStore.getInitJsonDataByKeyRoute,
6768
+ updateFormValueData: stores.JSONEditorStore.updateFormValueData,
6769
+ };
6770
+ })(
6771
+ (0, mobx_react__WEBPACK_IMPORTED_MODULE_2__.observer)(
6772
+ InputImageSchema,
6773
+ ),
6774
+ );
6775
+
6776
+ /***/
6777
+ },
6778
+
6450
6779
  /***/ './src/renderers/JsonFormSchema/index.js':
6451
6780
  /*!***********************************************!*\
6452
6781
  !*** ./src/renderers/JsonFormSchema/index.js ***!
@@ -12055,12 +12384,23 @@
12055
12384
  }
12056
12385
  var curJsonData =
12057
12386
  this.state.rootJSONStore.JSONEditorStore.jsonData;
12387
+ var newJsonData = {};
12058
12388
  /** 根据jsonSchema生成对应的最新jsonData */
12059
- var newJsonData = (0,
12060
- _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_5__.schema2json)(
12061
- this.jsonSchema,
12062
- curJsonData,
12063
- );
12389
+ if (this.jsonSchema.reset) {
12390
+ // schema 变动不保留旧版 jsonData 数据
12391
+ newJsonData = (0,
12392
+ _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_5__.schema2json)(
12393
+ this.jsonSchema,
12394
+ {},
12395
+ );
12396
+ } else {
12397
+ // 默认保留旧版jsonData数据
12398
+ newJsonData = (0,
12399
+ _wibetter_json_utils__WEBPACK_IMPORTED_MODULE_5__.schema2json)(
12400
+ this.jsonSchema,
12401
+ curJsonData,
12402
+ );
12403
+ }
12064
12404
  /** 更新当前的jsonData */
12065
12405
  this.state.rootJSONStore.JSONEditorStore.jsonData =
12066
12406
  newJsonData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wibetter/json-editor",
3
- "version": "5.0.7",
3
+ "version": "5.0.8",
4
4
  "description": "JSON数据可视化/JSONEditor, 可视化界面编辑json数据",
5
5
  "keywords": [
6
6
  "json",
package/sdk/index.css CHANGED
@@ -2,7 +2,7 @@
2
2
  * @wibetter/json-editor v5.0.7
3
3
  * author: wibetter
4
4
  * build tool: AKFun
5
- * build time: Mon Dec 23 2024 18:08:06 GMT+0800 (中国标准时间)
5
+ * build time: Tue Dec 24 2024 14:44:56 GMT+0800 (中国标准时间)
6
6
  * build tool info: https://github.com/wibetter/akfun
7
7
  */
8
8
  /*!*********************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\