@dartech/arsenal-ui 1.3.64 → 1.3.65

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/index.js CHANGED
@@ -129,7 +129,8 @@ var RoundingMode;
129
129
  */
130
130
  const Loader = ({
131
131
  transparent,
132
- position
132
+ position,
133
+ bgcolor
133
134
  }) => {
134
135
  return jsx(Box, Object.assign({
135
136
  position: position !== null && position !== void 0 ? position : 'absolute',
@@ -140,7 +141,7 @@ const Loader = ({
140
141
  display: "flex",
141
142
  alignItems: "center",
142
143
  justifyContent: "center",
143
- bgcolor: transparent ? 'none' : 'rgba(255, 255, 255, .3)',
144
+ bgcolor: bgcolor || (transparent ? 'none' : 'rgba(255, 255, 255, .3)'),
144
145
  zIndex: 10
145
146
  }, {
146
147
  children: jsx(CircularProgress, {})
@@ -1209,27 +1210,62 @@ const deepParseJson = value => {
1209
1210
  // return obj;
1210
1211
  // };
1211
1212
 
1212
- const JsonView = ({
1213
+ const JsonView = /*#__PURE__*/forwardRef(({
1213
1214
  value,
1214
1215
  height: _height = '200px',
1215
1216
  fontSize: _fontSize = 16
1216
- }) => {
1217
- return jsx(CodeMirror, {
1218
- readOnly: true,
1219
- width: "100%",
1220
- value: typeof value === 'string' ? value : JSON.stringify(value, null, 2),
1221
- height: _height,
1222
- basicSetup: {
1223
- autocompletion: true,
1224
- history: true
1225
- },
1226
- extensions: [langs.json()],
1227
- style: {
1228
- fontSize: _fontSize,
1229
- width: '100%'
1217
+ }, ref) => {
1218
+ const [loading, setLoading] = useState(true);
1219
+ const onCreateEditor = useCallback(view => {
1220
+ const onScroll = e => {
1221
+ if (e.target.scrollTop === 0) {
1222
+ setLoading(false);
1223
+ view.scrollDOM.removeEventListener('scroll', onScroll);
1224
+ }
1225
+ };
1226
+ if (view.scrollDOM.scrollHeight > 38300) {
1227
+ setLoading(true);
1228
+ view.scrollDOM.addEventListener('scroll', onScroll);
1229
+ view.scrollDOM.scrollTo(0, view.scrollDOM.scrollHeight - 300);
1230
+ setTimeout(() => {
1231
+ view.scrollDOM.scrollTo({
1232
+ top: view.scrollDOM.scrollHeight,
1233
+ behavior: 'smooth'
1234
+ });
1235
+ }, 300);
1236
+ setTimeout(() => {
1237
+ view.scrollDOM.scrollTo(0, 0);
1238
+ }, 500);
1239
+ } else {
1240
+ setLoading(false);
1230
1241
  }
1231
- });
1232
- };
1242
+ }, []);
1243
+ return jsxs(Box, Object.assign({
1244
+ position: "relative"
1245
+ }, {
1246
+ children: [loading && jsx(Loader, {
1247
+ bgcolor: "#fff"
1248
+ }), jsx(CodeMirror, {
1249
+ ref: ref,
1250
+ readOnly: true,
1251
+ width: "100%",
1252
+ value: typeof value === 'string' ? value : JSON.stringify(value, null, 2),
1253
+ height: _height,
1254
+ basicSetup: {
1255
+ autocompletion: true,
1256
+ history: true,
1257
+ foldGutter: true
1258
+ // bracketMatching: true
1259
+ },
1260
+ onCreateEditor: onCreateEditor,
1261
+ extensions: [langs.json()],
1262
+ style: {
1263
+ fontSize: _fontSize,
1264
+ width: '100%'
1265
+ }
1266
+ })]
1267
+ }));
1268
+ });
1233
1269
 
1234
1270
  const JsonModalView = ({
1235
1271
  open,
@@ -1237,6 +1273,13 @@ const JsonModalView = ({
1237
1273
  value,
1238
1274
  jsonViewProps
1239
1275
  }) => {
1276
+ const editorRef = useRef();
1277
+ // useEffect(() => {
1278
+ // if (editorRef.current) {
1279
+ // console.log(editorRef.current);
1280
+ // editorRef.current.editor.scrollTop = 1000;
1281
+ // }
1282
+ // }, [open, editorRef]);
1240
1283
  return jsxs(Dialog, Object.assign({
1241
1284
  disableEscapeKeyDown: true,
1242
1285
  open: open,
@@ -1251,7 +1294,9 @@ const JsonModalView = ({
1251
1294
  children: [jsx(DialogContent, {
1252
1295
  children: jsx(JsonView, Object.assign({
1253
1296
  value: value
1254
- }, jsonViewProps))
1297
+ }, jsonViewProps, {
1298
+ ref: editorRef
1299
+ }))
1255
1300
  }), jsxs(DialogActions, {
1256
1301
  children: [jsx(CopyButton, {
1257
1302
  copyText: value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.3.64",
3
+ "version": "1.3.65",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
+ import { ReactCodeMirrorRef } from '@uiw/react-codemirror';
2
3
  type Props = {
3
4
  value: unknown;
4
5
  height?: string;
5
6
  fontSize?: number;
6
7
  };
7
- export declare const JsonView: ({ value, height, fontSize }: Props) => JSX.Element;
8
+ export declare const JsonView: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<ReactCodeMirrorRef>>;
8
9
  export {};
@@ -12,10 +12,11 @@ export interface LoaderProps {
12
12
  * CSS `position` property. Default: `absolute`
13
13
  */
14
14
  position?: 'absolute' | 'relative' | 'fixed';
15
+ bgcolor?: string;
15
16
  }
16
17
  /**
17
18
  * Loader screen component. Used in the data loading process
18
19
  * @category Common UI components
19
20
  */
20
- export declare const Loader: ({ transparent, position }: LoaderProps) => JSX.Element;
21
+ export declare const Loader: ({ transparent, position, bgcolor }: LoaderProps) => JSX.Element;
21
22
  export default Loader;