@ray-js/code-sandbox 0.0.4 → 0.0.6

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.
@@ -26,7 +26,7 @@ const CodeSandbox = _ref => {
26
26
  react: ReactLib
27
27
  });
28
28
  const [title, setTitle] = React.useState(defaultTitle);
29
- const [content, setContent] = React.useState( /*#__PURE__*/React.createElement(context.__loading__, null));
29
+ const [content, setContent] = React.useState(/*#__PURE__*/React.createElement(context.__loading__, null));
30
30
  // @ts-ignore
31
31
  context.___setContent___ = setContent;
32
32
  // @ts-ignore
@@ -1,6 +1,6 @@
1
1
  import { Button, View } from '@ray-js/ray';
2
2
  import React from 'react';
3
- import Loading from '@ray-js/components-ty-loading';
3
+ import Loading from './ray-loading';
4
4
  import styles from './index.module.less';
5
5
  export const SandboxLoading = _ref => {
6
6
  let {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IProps } from './props';
3
+ declare const Loading: React.FC<IProps>;
4
+ export default Loading;
@@ -0,0 +1,32 @@
1
+ /* eslint-disable react/self-closing-comp */
2
+ /* eslint-disable react/no-unknown-property */
3
+ import React from 'react';
4
+ import styles from './index.module.less';
5
+ import { defaultProps } from './props';
6
+ import { View } from '@ray-js/ray';
7
+ function createSvgIcon(svg) {
8
+ return `data:image/svg+xml,${encodeURIComponent(`${svg}`)}`;
9
+ }
10
+ function CircularLoading(_ref) {
11
+ let {
12
+ color = '#1989FA'
13
+ } = _ref;
14
+ return createSvgIcon(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="32" height="32" viewBox="0 0 32 32"><defs><clipPath id="master_svg0_1695_29273"><rect x="0" y="0" width="32" height="32" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_1695_29273)"><g><path d="M14.73077392578125,8.807690000000001L14.73077392578125,6.26923C14.73077392578125,5.568254,15.29902692578125,5,16.00000392578125,5C16.70097392578125,5,17.26923392578125,5.568254,17.26923392578125,6.26923L17.26923392578125,8.807690000000001C17.26923392578125,9.50867,16.70097392578125,10.07693,16.00000392578125,10.07693C15.29902692578125,10.07693,14.73077392578125,9.50867,14.73077392578125,8.807690000000001Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(0.7071067690849304,0.7071067690849304,-0.7071067690849304,0.7071067690849304,11.880707750418878,-14.033822285849965)" style="opacity:0.05000000074505806;"><path d="M22.88067626953125,11.132061337890626L22.88067626953125,8.593601337890625C22.88067626953125,7.892624337890625,23.44892926953125,7.324371337890625,24.14990626953125,7.324371337890625C24.85088626953125,7.324371337890625,25.41913626953125,7.892624337890625,25.41913626953125,8.593601337890625L25.41913626953125,11.132061337890626C25.41913626953125,11.833041337890625,24.85088626953125,12.401291337890626,24.14990626953125,12.401291337890626C23.44892926953125,12.401291337890626,22.88067626953125,11.833041337890625,22.88067626953125,11.132061337890626Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(0,1,-1,0,41.73081970214844,-12.269180297851562)" style="opacity:0.10000000149011612;"><path d="M27,18.53850970214844L27,16.000049702148438C27,15.299072702148438,27.568253,14.730819702148438,28.26923,14.730819702148438C28.97021,14.730819702148438,29.53846,15.299072702148438,29.53846,16.000049702148438L29.53846,18.53850970214844C29.53846,19.23948970214844,28.97021,19.80773970214844,28.26923,19.80773970214844C27.568253,19.80773970214844,27,19.23948970214844,27,18.53850970214844Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(-0.7071067690849304,0.7071067690849304,-0.7071067690849304,-0.7071067690849304,58.30294381839121,21.611726407169044)" style="opacity:0.15000000596046448;"><path d="M24.675537109375,26.68848833984375L24.675537109375,24.15002833984375C24.675537109375,23.44905133984375,25.243790109375,22.88079833984375,25.944767109375,22.88079833984375C26.645747109375,22.88079833984375,27.213997109375,23.44905133984375,27.213997109375,24.15002833984375L27.213997109375,26.68848833984375C27.213997109375,27.389468339843752,26.645747109375,27.95771833984375,25.944767109375,27.95771833984375C25.243790109375,27.95771833984375,24.675537109375,27.389468339843752,24.675537109375,26.68848833984375Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(-1,0,0,-1,34.5384521484375,54)" style="opacity:0.30000001192092896;"><path d="M17.26922607421875,30.80769L17.26922607421875,28.26923C17.26922607421875,27.568254,17.83747907421875,27,18.53845607421875,27C19.23942607421875,27,19.80768607421875,27.568254,19.80768607421875,28.26923L19.80768607421875,30.80769C19.80768607421875,31.508670000000002,19.23942607421875,32.07693,18.53845607421875,32.07693C17.83747907421875,32.07693,17.26922607421875,31.508670000000002,17.26922607421875,30.80769Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(-0.7071068286895752,-0.7071067094802856,0.7071067094802856,-0.7071068286895752,-1.8805817391439632,48.572416538932885)" style="opacity:0.550000011920929;"><path d="M9.119384765625,28.483379697265626L9.119384765625,25.944919697265625C9.119384765625,25.243942697265624,9.687637765625,24.675689697265625,10.388614765625,24.675689697265625C11.089594765625,24.675689697265625,11.657844765625,25.243942697265624,11.657844765625,25.944919697265625L11.657844765625,28.483379697265626C11.657844765625,29.184359697265627,11.089594765625,29.752609697265626,10.388614765625,29.752609697265626C9.687637765625,29.752609697265626,9.119384765625,29.184359697265627,9.119384765625,28.483379697265626Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(0,-1,1,0,-12.269241333007812,22.269241333007812)" style="opacity:0.699999988079071;"><path d="M5,21.076931333007813L5,18.538471333007813C5,17.83749433300781,5.568253,17.269241333007812,6.26923,17.269241333007812C6.97021,17.269241333007812,7.538460000000001,17.83749433300781,7.538460000000001,18.538471333007813L7.538460000000001,21.076931333007813C7.538460000000001,21.777911333007815,6.97021,22.346161333007814,6.26923,22.346161333007814C5.568253,22.346161333007814,5,21.777911333007815,5,21.076931333007813Z" fill="#3678E3" fill-opacity="1"/></g><g transform="matrix(0.7071066498756409,-0.70710688829422,0.70710688829422,0.7071066498756409,-4.303046450104375,7.850115344526785)" style="opacity:0.8500000238418579;"><path d="M7.32440185546875,12.926983212890626L7.32440185546875,10.388523212890625C7.32440185546875,9.687546212890625,7.89265485546875,9.119293212890625,8.59363185546875,9.119293212890625C9.29461185546875,9.119293212890625,9.86286185546875,9.687546212890625,9.86286185546875,10.388523212890625L9.86286185546875,12.926983212890626C9.86286185546875,13.627963212890625,9.29461185546875,14.196213212890626,8.59363185546875,14.196213212890626C7.89265485546875,14.196213212890626,7.32440185546875,13.627963212890625,7.32440185546875,12.926983212890626Z" fill="#3678E3" fill-opacity="1"/></g></g></svg>`);
15
+ }
16
+ const Loading = props => {
17
+ const icon = CircularLoading({
18
+ color: '#1989FA'
19
+ });
20
+ return /*#__PURE__*/React.createElement(View, {
21
+ className: styles.loading,
22
+ style: {
23
+ backgroundImage: `url('${icon}')`,
24
+ backgroundSize: `${props.size} ${props.size}`,
25
+ width: props.size,
26
+ height: props.size
27
+ }
28
+ });
29
+ };
30
+ Loading.displayName = 'Loading';
31
+ Loading.defaultProps = defaultProps;
32
+ export default Loading;
@@ -0,0 +1,17 @@
1
+ @keyframes animation-rotate {
2
+ 0% {
3
+ transform: rotate(0deg);
4
+ }
5
+
6
+ 100% {
7
+ transform: rotate(360deg);
8
+ }
9
+ }
10
+
11
+ .loading {
12
+ animation-duration: 0.5s;
13
+ animation-delay: 0s;
14
+ animation-name: animation-rotate;
15
+ animation-timing-function: steps(8);
16
+ animation-iteration-count: infinite;
17
+ }
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ export interface IProps {
3
+ /**
4
+ * @description.zh 类名
5
+ * @description.en class name
6
+ */
7
+ className?: string;
8
+ /**
9
+ * @description.zh 样式
10
+ * @description.en Style
11
+ */
12
+ style?: React.CSSProperties;
13
+ /**
14
+ * @description.zh 颜色
15
+ * @description.en Color
16
+ * @default '#000000'
17
+ */
18
+ color?: string;
19
+ /**
20
+ * @description.zh 加载图标大小
21
+ * @description.en Size of loading icon
22
+ * @default '60rpx'
23
+ */
24
+ size?: string;
25
+ }
26
+ export declare const defaultProps: IProps;
@@ -0,0 +1,4 @@
1
+ export const defaultProps = {
2
+ size: '60rpx',
3
+ color: '#000000'
4
+ };
@@ -1,5 +1,6 @@
1
1
  import { DrawerProps } from 'antd';
2
2
  import React from 'react';
3
+ import { EditorAPI } from '@saber2pr/monaco';
3
4
  export interface CodeSandboxProps {
4
5
  code: string;
5
6
  title: string;
@@ -10,6 +11,7 @@ export interface CodeSandboxProps {
10
11
  langKey?: string;
11
12
  emptyText?: string;
12
13
  isZhLanguage?: boolean;
14
+ editorApi?: EditorAPI;
13
15
  }
14
16
  export declare const CodeSandbox: React.FC<CodeSandboxProps>;
15
17
  export declare const checkShowCodeSandbox: (code: string) => boolean;
@@ -25,8 +27,9 @@ export interface UseCodeSandboxDrawerOps {
25
27
  isZhLanguage?: boolean;
26
28
  code: string;
27
29
  langKey?: string;
30
+ editorApi?: EditorAPI;
28
31
  }
29
- export declare const useCodeSandboxDrawer: ({ getContainer, title, height, placement, isZhLanguage, pageName, txpCode, emptyText, langKey, baseUri, code, }: UseCodeSandboxDrawerOps) => {
32
+ export declare const useCodeSandboxDrawer: ({ getContainer, title, height, placement, isZhLanguage, pageName, txpCode, emptyText, langKey, baseUri, code, editorApi, }: UseCodeSandboxDrawerOps) => {
30
33
  modal: React.JSX.Element;
31
34
  show: boolean;
32
35
  setShow: React.Dispatch<React.SetStateAction<boolean>>;
@@ -41,4 +44,5 @@ export declare const CodeSandboxButton: React.FC<{
41
44
  baseUri: string;
42
45
  emptyText?: string;
43
46
  isZhLanguage?: boolean;
47
+ editorApi?: EditorAPI;
44
48
  }>;
@@ -19,11 +19,12 @@ export const CodeSandbox = _ref => {
19
19
  baseUri,
20
20
  langKey,
21
21
  emptyText,
22
- isZhLanguage
22
+ isZhLanguage,
23
+ editorApi
23
24
  } = _ref;
24
25
  const iframeRef = useRef();
25
26
  const [ts, setTs] = useState(Date.now());
26
- const apiRef = useRef();
27
+ const apiRef = useRef(editorApi);
27
28
  useEffect(() => {
28
29
  const handle = event => {
29
30
  var _event$data;
@@ -86,7 +87,8 @@ export const useCodeSandboxDrawer = _ref2 => {
86
87
  emptyText,
87
88
  langKey,
88
89
  baseUri,
89
- code
90
+ code,
91
+ editorApi
90
92
  } = _ref2;
91
93
  const [show, setShow] = useState(false);
92
94
  return {
@@ -107,6 +109,7 @@ export const useCodeSandboxDrawer = _ref2 => {
107
109
  setShow(false);
108
110
  }
109
111
  }, /*#__PURE__*/React.createElement(CodeSandbox, {
112
+ editorApi: editorApi,
110
113
  isZhLanguage: isZhLanguage,
111
114
  emptyText: emptyText,
112
115
  langKey: langKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/code-sandbox",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "小程序 CodeSandbox 容器",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
20
- "build": "patch-package && ray build --type=component",
20
+ "build": "export BROWSERSLIST='Last 3 versions' && patch-package && ray build --type=component",
21
21
  "watch": "ray start --type=component --output ./example/src/lib",
22
22
  "build:tuya": "ray build ./example",
23
23
  "build:wechat": "ray build ./example --target=wechat",
@@ -40,9 +40,8 @@
40
40
  "devDependencies": {
41
41
  "@commitlint/cli": "^7.2.1",
42
42
  "@commitlint/config-conventional": "^9.0.1",
43
- "@ray-js/cli": "^1.4.9",
44
- "@ray-js/components-ty-loading": "^0.1.1",
45
- "@ray-js/ray": "^1.4.9",
43
+ "@ray-js/cli": "^1.5.45",
44
+ "@ray-js/ray": "^1.5.45",
46
45
  "@saber2pr/monaco": "^0.0.90",
47
46
  "antd": "^5.20.2",
48
47
  "axios": "^1.7.4",
@@ -55,9 +54,6 @@
55
54
  "standard-version": "9.3.2",
56
55
  "styled-components": "^6.1.12"
57
56
  },
58
- "resolutions": {
59
- "@ray-js/builder-mp": "1.4.15"
60
- },
61
57
  "husky": {
62
58
  "hooks": {
63
59
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
@@ -74,4 +70,4 @@
74
70
  "git add"
75
71
  ]
76
72
  }
77
- }
73
+ }