assui 2.1.52 → 2.1.54

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/es/index.d.ts CHANGED
@@ -48,6 +48,7 @@ export type { LabelTextAreaProps } from './label-text-area';
48
48
  export { default as LabelTextArea } from './label-text-area';
49
49
  export type { AreaTextProps } from './area-text';
50
50
  export { default as AreaText } from './area-text';
51
+ export type { JSONEditorProps } from './json-editor';
51
52
  export { default as JsonEditor } from './json-editor';
52
53
  export type { LabelRangePickerProps } from './label-range-picker';
53
54
  export { default as LabelRangePicker } from './label-range-picker';
@@ -1,2 +1,10 @@
1
- declare const Jsoneditor: () => JSX.Element;
2
- export default Jsoneditor;
1
+ import type { JSONEditorOptions } from 'jsoneditor';
2
+ import React from 'react';
3
+ export declare type JSONEditorProps = {
4
+ className?: string;
5
+ options?: JSONEditorOptions;
6
+ onChange?: (value: string) => void;
7
+ value?: string;
8
+ };
9
+ declare const ForwardRefJsonEditor: React.ForwardRefExoticComponent<JSONEditorProps & React.RefAttributes<unknown>>;
10
+ export default ForwardRefJsonEditor;
@@ -1,17 +1,103 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __read = this && this.__read || function (o, n) {
18
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19
+ if (!m) return o;
20
+ var i = m.call(o),
21
+ r,
22
+ ar = [],
23
+ e;
24
+
25
+ try {
26
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
27
+ ar.push(r.value);
28
+ }
29
+ } catch (error) {
30
+ e = {
31
+ error: error
32
+ };
33
+ } finally {
34
+ try {
35
+ if (r && !r.done && (m = i["return"])) m.call(i);
36
+ } finally {
37
+ if (e) throw e.error;
38
+ }
39
+ }
40
+
41
+ return ar;
42
+ };
43
+
1
44
  import JSONEditor from 'jsoneditor';
2
- import React, { useEffect } from 'react';
45
+ import React, { useEffect, useImperativeHandle } from 'react';
46
+ import useControllableValue from "ahooks/es/useControllableValue";
47
+ import useMount from "ahooks/es/useMount";
48
+ import isEqual from 'lodash/isEqual';
49
+ import useUnmount from "ahooks/es/useUnmount";
50
+ import classNames from 'classnames';
51
+
52
+ var JsonEditor = function JsonEditor(props, ref) {
53
+ var options = props.options,
54
+ className = props.className;
55
+
56
+ var _a = __read(useControllableValue(props), 2),
57
+ value = _a[0],
58
+ setValue = _a[1];
3
59
 
4
- var Jsoneditor = function Jsoneditor() {
5
60
  var containerRef = React.useRef();
61
+ var editorInstanceRef = React.useRef();
62
+ useMount(function () {
63
+ editorInstanceRef.current = new JSONEditor(containerRef.current, __assign(__assign({
64
+ mode: 'code',
65
+ indentation: 2
66
+ }, options), {
67
+ onChangeText: function onChangeText() {
68
+ var _a;
69
+
70
+ try {
71
+ var currentJson = (_a = editorInstanceRef.current) === null || _a === void 0 ? void 0 : _a.get();
72
+ setValue(currentJson);
73
+ } catch (error) {
74
+ console.log('error', error);
75
+ }
76
+ }
77
+ }));
78
+ });
79
+ useImperativeHandle(ref, function () {
80
+ return containerRef.current;
81
+ });
6
82
  useEffect(function () {
7
- var options = {};
8
- var editor = new JSONEditor(containerRef.current, options);
9
- }, []);
83
+ var _a, _b;
84
+
85
+ if (value && !isEqual(value, (_a = editorInstanceRef.current) === null || _a === void 0 ? void 0 : _a.get())) {
86
+ (_b = editorInstanceRef.current) === null || _b === void 0 ? void 0 : _b.update(value);
87
+ }
88
+ }, [value]);
89
+ useUnmount(function () {
90
+ var _a;
91
+
92
+ (_a = editorInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
93
+ });
10
94
  return /*#__PURE__*/React.createElement("div", {
11
95
  ref: function ref(el) {
12
96
  return containerRef.current = el;
13
- }
97
+ },
98
+ className: classNames('a-jason-editor', className)
14
99
  });
15
100
  };
16
101
 
17
- export default Jsoneditor;
102
+ var ForwardRefJsonEditor = /*#__PURE__*/React.forwardRef(JsonEditor);
103
+ export default ForwardRefJsonEditor;
@@ -0,0 +1,3 @@
1
+ .a-jason-editor .jsoneditor-menu {
2
+ display: none;
3
+ }
@@ -1 +1,2 @@
1
1
  import 'jsoneditor/dist/jsoneditor.min.css';
2
+ import './index.less';
@@ -1 +1,2 @@
1
- import 'jsoneditor/dist/jsoneditor.min.css';
1
+ import 'jsoneditor/dist/jsoneditor.min.css';
2
+ import './index.less';
@@ -0,0 +1,5 @@
1
+ .a-jason-editor {
2
+ .jsoneditor-menu {
3
+ display: none;
4
+ }
5
+ }
@@ -14,6 +14,7 @@ export interface LabelCustomizeRangePickerProps extends Omit<LabelRangePickerPro
14
14
  label?: React.ReactNode;
15
15
  /** 最大时间范围 */
16
16
  maxScope?: number;
17
+ showShortcutPanel?: boolean;
17
18
  }
18
19
  declare const LabelCustomizeRangePicker: (props: LabelCustomizeRangePickerProps) => JSX.Element;
19
20
  export default LabelCustomizeRangePicker;
@@ -77,23 +77,25 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
77
77
  showTime = props.showTime,
78
78
  maxScope = props.maxScope,
79
79
  onOpenChange = props.onOpenChange,
80
- restProps = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label", "showTime", "maxScope", "onOpenChange"]);
80
+ _b = props.showShortcutPanel,
81
+ showShortcutPanel = _b === void 0 ? true : _b,
82
+ restProps = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label", "showTime", "maxScope", "onOpenChange", "showShortcutPanel"]);
81
83
 
82
- var _b = __read(useControllableValue(props), 2),
83
- date = _b[0],
84
- setDate = _b[1];
84
+ var _c = __read(useControllableValue(props), 2),
85
+ date = _c[0],
86
+ setDate = _c[1];
85
87
 
86
- var _c = __read(useState(false), 2),
87
- isVisiblePanel = _c[0],
88
- setIsVisiblePanel = _c[1];
88
+ var _d = __read(useState(false), 2),
89
+ isVisiblePanel = _d[0],
90
+ setIsVisiblePanel = _d[1];
89
91
 
90
- var _d = __read(useState(), 2),
91
- radioKey = _d[0],
92
- setRadioKey = _d[1];
92
+ var _e = __read(useState(), 2),
93
+ radioKey = _e[0],
94
+ setRadioKey = _e[1];
93
95
 
94
- var _e = __read(useState(false), 2),
95
- open = _e[0],
96
- setOpen = _e[1];
96
+ var _f = __read(useState(false), 2),
97
+ open = _f[0],
98
+ setOpen = _f[1];
97
99
 
98
100
  var messages = useContext(LocaleContext);
99
101
  var dataSource = radioList !== null && radioList !== void 0 ? radioList : getDefaultRadioList(messages);
@@ -132,8 +134,18 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
132
134
  }
133
135
  }, [date]);
134
136
  useEffect(function () {
137
+ var _a = __read(date || [], 2),
138
+ startTime = _a[0],
139
+ endTime = _a[1];
140
+
135
141
  if (maxScope) {
136
- setDate(formatMaxScope(date, maxScope));
142
+ var _b = __read(formatMaxScope(date, maxScope), 2),
143
+ newStartDate = _b[0],
144
+ newEndDate = _b[1];
145
+
146
+ if (!(newStartDate === null || newStartDate === void 0 ? void 0 : newStartDate.isSame(startTime)) || !(newEndDate === null || newEndDate === void 0 ? void 0 : newEndDate.isSame(endTime))) {
147
+ setDate(formatMaxScope(date, maxScope));
148
+ }
137
149
  }
138
150
  }, [maxScope]);
139
151
 
@@ -247,7 +259,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
247
259
  onChange: onDateChange,
248
260
  open: open,
249
261
  onOpenChange: handleOpenChange,
250
- panelRender: panelRender,
262
+ panelRender: showShortcutPanel ? panelRender : undefined,
251
263
  allowClear: false
252
264
  };
253
265
  return rangePickerType === 'label' ? /*#__PURE__*/React.createElement(LabelRangePicker, __assign({
package/lib/index.d.ts CHANGED
@@ -48,6 +48,7 @@ export type { LabelTextAreaProps } from './label-text-area';
48
48
  export { default as LabelTextArea } from './label-text-area';
49
49
  export type { AreaTextProps } from './area-text';
50
50
  export { default as AreaText } from './area-text';
51
+ export type { JSONEditorProps } from './json-editor';
51
52
  export { default as JsonEditor } from './json-editor';
52
53
  export type { LabelRangePickerProps } from './label-range-picker';
53
54
  export { default as LabelRangePicker } from './label-range-picker';
@@ -1,2 +1,10 @@
1
- declare const Jsoneditor: () => JSX.Element;
2
- export default Jsoneditor;
1
+ import type { JSONEditorOptions } from 'jsoneditor';
2
+ import React from 'react';
3
+ export declare type JSONEditorProps = {
4
+ className?: string;
5
+ options?: JSONEditorOptions;
6
+ onChange?: (value: string) => void;
7
+ value?: string;
8
+ };
9
+ declare const ForwardRefJsonEditor: React.ForwardRefExoticComponent<JSONEditorProps & React.RefAttributes<unknown>>;
10
+ export default ForwardRefJsonEditor;
@@ -1,5 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
3
19
  var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
4
20
  if (k2 === undefined) k2 = k;
5
21
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -40,6 +56,33 @@ var __importStar = this && this.__importStar || function (mod) {
40
56
  return result;
41
57
  };
42
58
 
59
+ var __read = this && this.__read || function (o, n) {
60
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
61
+ if (!m) return o;
62
+ var i = m.call(o),
63
+ r,
64
+ ar = [],
65
+ e;
66
+
67
+ try {
68
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
69
+ ar.push(r.value);
70
+ }
71
+ } catch (error) {
72
+ e = {
73
+ error: error
74
+ };
75
+ } finally {
76
+ try {
77
+ if (r && !r.done && (m = i["return"])) m.call(i);
78
+ } finally {
79
+ if (e) throw e.error;
80
+ }
81
+ }
82
+
83
+ return ar;
84
+ };
85
+
43
86
  var __importDefault = this && this.__importDefault || function (mod) {
44
87
  return mod && mod.__esModule ? mod : {
45
88
  "default": mod
@@ -54,17 +97,65 @@ var jsoneditor_1 = __importDefault(require("jsoneditor"));
54
97
 
55
98
  var react_1 = __importStar(require("react"));
56
99
 
57
- var Jsoneditor = function Jsoneditor() {
100
+ var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
101
+
102
+ var useMount_1 = __importDefault(require("ahooks/lib/useMount"));
103
+
104
+ var isEqual_1 = __importDefault(require("lodash/isEqual"));
105
+
106
+ var useUnmount_1 = __importDefault(require("ahooks/lib/useUnmount"));
107
+
108
+ var classnames_1 = __importDefault(require("classnames"));
109
+
110
+ var JsonEditor = function JsonEditor(props, ref) {
111
+ var options = props.options,
112
+ className = props.className;
113
+
114
+ var _a = __read((0, useControllableValue_1["default"])(props), 2),
115
+ value = _a[0],
116
+ setValue = _a[1];
117
+
58
118
  var containerRef = react_1["default"].useRef();
119
+ var editorInstanceRef = react_1["default"].useRef();
120
+ (0, useMount_1["default"])(function () {
121
+ editorInstanceRef.current = new jsoneditor_1["default"](containerRef.current, __assign(__assign({
122
+ mode: 'code',
123
+ indentation: 2
124
+ }, options), {
125
+ onChangeText: function onChangeText() {
126
+ var _a;
127
+
128
+ try {
129
+ var currentJson = (_a = editorInstanceRef.current) === null || _a === void 0 ? void 0 : _a.get();
130
+ setValue(currentJson);
131
+ } catch (error) {
132
+ console.log('error', error);
133
+ }
134
+ }
135
+ }));
136
+ });
137
+ (0, react_1.useImperativeHandle)(ref, function () {
138
+ return containerRef.current;
139
+ });
59
140
  (0, react_1.useEffect)(function () {
60
- var options = {};
61
- var editor = new jsoneditor_1["default"](containerRef.current, options);
62
- }, []);
141
+ var _a, _b;
142
+
143
+ if (value && !(0, isEqual_1["default"])(value, (_a = editorInstanceRef.current) === null || _a === void 0 ? void 0 : _a.get())) {
144
+ (_b = editorInstanceRef.current) === null || _b === void 0 ? void 0 : _b.update(value);
145
+ }
146
+ }, [value]);
147
+ (0, useUnmount_1["default"])(function () {
148
+ var _a;
149
+
150
+ (_a = editorInstanceRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
151
+ });
63
152
  return react_1["default"].createElement("div", {
64
153
  ref: function ref(el) {
65
154
  return containerRef.current = el;
66
- }
155
+ },
156
+ className: (0, classnames_1["default"])('a-jason-editor', className)
67
157
  });
68
158
  };
69
159
 
70
- exports["default"] = Jsoneditor;
160
+ var ForwardRefJsonEditor = react_1["default"].forwardRef(JsonEditor);
161
+ exports["default"] = ForwardRefJsonEditor;
@@ -0,0 +1,3 @@
1
+ .a-jason-editor .jsoneditor-menu {
2
+ display: none;
3
+ }
@@ -1 +1,2 @@
1
1
  import 'jsoneditor/dist/jsoneditor.min.css';
2
+ import './index.less';
@@ -4,4 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- require("jsoneditor/dist/jsoneditor.min.css");
7
+ require("jsoneditor/dist/jsoneditor.min.css");
8
+
9
+ require("./index.less");
@@ -0,0 +1,5 @@
1
+ .a-jason-editor {
2
+ .jsoneditor-menu {
3
+ display: none;
4
+ }
5
+ }
@@ -14,6 +14,7 @@ export interface LabelCustomizeRangePickerProps extends Omit<LabelRangePickerPro
14
14
  label?: React.ReactNode;
15
15
  /** 最大时间范围 */
16
16
  maxScope?: number;
17
+ showShortcutPanel?: boolean;
17
18
  }
18
19
  declare const LabelCustomizeRangePicker: (props: LabelCustomizeRangePickerProps) => JSX.Element;
19
20
  export default LabelCustomizeRangePicker;
@@ -141,23 +141,25 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
141
141
  showTime = props.showTime,
142
142
  maxScope = props.maxScope,
143
143
  onOpenChange = props.onOpenChange,
144
- restProps = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label", "showTime", "maxScope", "onOpenChange"]);
144
+ _b = props.showShortcutPanel,
145
+ showShortcutPanel = _b === void 0 ? true : _b,
146
+ restProps = __rest(props, ["customizeTimeList", "radioList", "rangePickerType", "label", "showTime", "maxScope", "onOpenChange", "showShortcutPanel"]);
145
147
 
146
- var _b = __read((0, useControllableValue_1["default"])(props), 2),
147
- date = _b[0],
148
- setDate = _b[1];
148
+ var _c = __read((0, useControllableValue_1["default"])(props), 2),
149
+ date = _c[0],
150
+ setDate = _c[1];
149
151
 
150
- var _c = __read((0, react_1.useState)(false), 2),
151
- isVisiblePanel = _c[0],
152
- setIsVisiblePanel = _c[1];
152
+ var _d = __read((0, react_1.useState)(false), 2),
153
+ isVisiblePanel = _d[0],
154
+ setIsVisiblePanel = _d[1];
153
155
 
154
- var _d = __read((0, react_1.useState)(), 2),
155
- radioKey = _d[0],
156
- setRadioKey = _d[1];
156
+ var _e = __read((0, react_1.useState)(), 2),
157
+ radioKey = _e[0],
158
+ setRadioKey = _e[1];
157
159
 
158
- var _e = __read((0, react_1.useState)(false), 2),
159
- open = _e[0],
160
- setOpen = _e[1];
160
+ var _f = __read((0, react_1.useState)(false), 2),
161
+ open = _f[0],
162
+ setOpen = _f[1];
161
163
 
162
164
  var messages = (0, react_1.useContext)(context_1["default"]);
163
165
  var dataSource = radioList !== null && radioList !== void 0 ? radioList : (0, defaultRadioList_1["default"])(messages);
@@ -196,8 +198,18 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
196
198
  }
197
199
  }, [date]);
198
200
  (0, react_1.useEffect)(function () {
201
+ var _a = __read(date || [], 2),
202
+ startTime = _a[0],
203
+ endTime = _a[1];
204
+
199
205
  if (maxScope) {
200
- setDate((0, utils_1.formatMaxScope)(date, maxScope));
206
+ var _b = __read((0, utils_1.formatMaxScope)(date, maxScope), 2),
207
+ newStartDate = _b[0],
208
+ newEndDate = _b[1];
209
+
210
+ if (!(newStartDate === null || newStartDate === void 0 ? void 0 : newStartDate.isSame(startTime)) || !(newEndDate === null || newEndDate === void 0 ? void 0 : newEndDate.isSame(endTime))) {
211
+ setDate((0, utils_1.formatMaxScope)(date, maxScope));
212
+ }
201
213
  }
202
214
  }, [maxScope]);
203
215
 
@@ -311,7 +323,7 @@ var LabelCustomizeRangePicker = function LabelCustomizeRangePicker(props) {
311
323
  onChange: onDateChange,
312
324
  open: open,
313
325
  onOpenChange: handleOpenChange,
314
- panelRender: panelRender,
326
+ panelRender: showShortcutPanel ? panelRender : undefined,
315
327
  allowClear: false
316
328
  };
317
329
  return rangePickerType === 'label' ? react_1["default"].createElement(label_range_picker_1["default"], __assign({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assui",
3
- "version": "2.1.52",
3
+ "version": "2.1.54",
4
4
  "description": "react ui library",
5
5
  "author": "jason <usochen@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -40,6 +40,8 @@
40
40
  "bignumber.js": "^9.0.1",
41
41
  "copy-to-clipboard": "^3.3.1",
42
42
  "echarts": "^5.1.2",
43
+ "jsoneditor": "^9.9.0",
44
+ "jsoneditor-react": "^3.1.2",
43
45
  "qrcode": "^1.4.4",
44
46
  "rc-motion": "^2.4.4",
45
47
  "rc-util": "^5.13.2",
@@ -60,6 +62,7 @@
60
62
  "devDependencies": {
61
63
  "@types/enzyme": "^3.10.5",
62
64
  "@types/insert-css": "^2.0.1",
65
+ "@types/jsoneditor": "^9.5.1",
63
66
  "@types/qrcode": "^1.4.1",
64
67
  "@types/react-highlight-words": "^0.16.3",
65
68
  "@types/react-transition-group": "^4.4.2",
@@ -73,5 +76,5 @@
73
76
  "node": ">=10.0.0"
74
77
  },
75
78
  "license": "MIT",
76
- "gitHead": "f131b5a8ff5cd8f82b12a2b84431fc02d5435d69"
79
+ "gitHead": "17d94d75438b08256e76b9839610f2f26a474bf1"
77
80
  }