@cloudbase/weda-ui 3.7.2 → 3.7.3

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.
@@ -138,6 +138,10 @@ declare const config: {
138
138
  readonly name: "format";
139
139
  readonly label: "js格式化";
140
140
  readonly description: "目前仅支持js格式化组件值";
141
+ readonly params: import("@sinclair/typebox").TObject<{
142
+ isCustomVal: import("@sinclair/typebox").TBoolean;
143
+ value: import("@sinclair/typebox").TString;
144
+ }>;
141
145
  }];
142
146
  readonly events: readonly [{
143
147
  name: string;
@@ -146,6 +150,10 @@ declare const config: {
146
150
  value: import("@sinclair/typebox").TString;
147
151
  }>;
148
152
  description: string;
153
+ }, {
154
+ readonly name: "ready";
155
+ readonly title: "代码编辑器ready";
156
+ readonly description: "当前代码编辑器已完成实例初始化";
149
157
  }];
150
158
  readonly meta: {
151
159
  readonly description: "用于代码编辑。";
@@ -64,9 +64,26 @@ const config = defineConfig({
64
64
  name: 'format',
65
65
  label: 'js格式化',
66
66
  description: '目前仅支持js格式化组件值',
67
+ params: Type.Object({
68
+ isCustomVal: Type.Boolean({
69
+ title: '自定义入参',
70
+ default: false,
71
+ description: '是否使用传入的格式化内容进行格式化。默认格式化当前组件值,开启则使用传入的格式化内容进行格式化,方法执行后返回格式化结果。',
72
+ }),
73
+ value: Type.String({
74
+ title: '格式化内容',
75
+ }),
76
+ }),
77
+ },
78
+ ],
79
+ events: [
80
+ FORM_ITEM_EVENTS.change,
81
+ {
82
+ name: 'ready',
83
+ title: '代码编辑器ready',
84
+ description: '当前代码编辑器已完成实例初始化',
67
85
  },
68
86
  ],
69
- events: [FORM_ITEM_EVENTS.change],
70
87
  meta: {
71
88
  description: '用于代码编辑。',
72
89
  figureIcon: '../figureIcons/WdTextarea.svg',
@@ -108,6 +108,10 @@ export declare const components: {
108
108
  readonly name: "format";
109
109
  readonly label: "js格式化";
110
110
  readonly description: "目前仅支持js格式化组件值";
111
+ readonly params: import("@sinclair/typebox").TObject<{
112
+ isCustomVal: import("@sinclair/typebox").TBoolean;
113
+ value: import("@sinclair/typebox").TString;
114
+ }>;
111
115
  }];
112
116
  readonly events: readonly [{
113
117
  name: string;
@@ -116,6 +120,10 @@ export declare const components: {
116
120
  value: import("@sinclair/typebox").TString;
117
121
  }>;
118
122
  description: string;
123
+ }, {
124
+ readonly name: "ready";
125
+ readonly title: "代码编辑器ready";
126
+ readonly description: "当前代码编辑器已完成实例初始化";
119
127
  }];
120
128
  readonly meta: {
121
129
  readonly description: "用于代码编辑。";
@@ -20172,6 +20180,10 @@ declare const _default: {
20172
20180
  readonly name: "format";
20173
20181
  readonly label: "js格式化";
20174
20182
  readonly description: "目前仅支持js格式化组件值";
20183
+ readonly params: import("@sinclair/typebox").TObject<{
20184
+ isCustomVal: import("@sinclair/typebox").TBoolean;
20185
+ value: import("@sinclair/typebox").TString;
20186
+ }>;
20175
20187
  }];
20176
20188
  readonly events: readonly [{
20177
20189
  name: string;
@@ -20180,6 +20192,10 @@ declare const _default: {
20180
20192
  value: import("@sinclair/typebox").TString;
20181
20193
  }>;
20182
20194
  description: string;
20195
+ }, {
20196
+ readonly name: "ready";
20197
+ readonly title: "代码编辑器ready";
20198
+ readonly description: "当前代码编辑器已完成实例初始化";
20183
20199
  }];
20184
20200
  readonly meta: {
20185
20201
  readonly description: "用于代码编辑。";
@@ -98,6 +98,7 @@ export default React.forwardRef(function ListView(props, ref) {
98
98
  (_a = observeRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
99
99
  clearContext();
100
100
  };
101
+ // eslint-disable-next-line react-hooks/exhaustive-deps
101
102
  }, []);
102
103
  // 监听更改数据源时,清空当前列表
103
104
  useEffect(() => {
@@ -240,7 +241,9 @@ export default React.forwardRef(function ListView(props, ref) {
240
241
  clearTimeout(delayRef.current.statusTimer);
241
242
  delayRef.current.statusTimer = null;
242
243
  }
243
- delayRef.current.statusTimer = window.setTimeout(statusCb, pagination === 'bottomLoad' ? 3000 : 150);
244
+ delayRef.current.statusTimer = window.setTimeout(statusCb, pagination === 'bottomLoad' && dataSourceType === 'expression'
245
+ ? 3000
246
+ : 150);
244
247
  }
245
248
  else {
246
249
  statusCb();
@@ -39,7 +39,7 @@ export const MenuLogo = React.memo(function MenuLogo({ navigationStyle, classNam
39
39
  });
40
40
  // icon回显
41
41
  export const IconShow = ({ onIcon, menuColor, menuFontSize }) => {
42
- return (_jsx(_Fragment, { children: (onIcon === null || onIcon === void 0 ? void 0 : onIcon.includes('td:')) ? (_jsx(IconFont, { name: onIcon === null || onIcon === void 0 ? void 0 : onIcon.split(':')[1], className: `${CLASS_PREFIX}__fonticon`, style: { color: menuColor, fontSize: menuFontSize } })) : (_jsx("div", { className: `${CLASS_PREFIX}__fonticon lcap-icon lcap-icon-${onIcon}`, style: { color: menuColor, fontSize: menuFontSize } })) }));
42
+ return (_jsx(_Fragment, { children: (onIcon === null || onIcon === void 0 ? void 0 : onIcon.includes('td:')) ? (_jsx(IconFont, { name: onIcon === null || onIcon === void 0 ? void 0 : onIcon.split(':')[1], className: `${CLASS_PREFIX}__fonticon wd-icon`, style: { color: menuColor, fontSize: menuFontSize } })) : (_jsx("div", { className: `${CLASS_PREFIX}__fonticon lcap-icon lcap-icon-${onIcon}`, style: { color: menuColor, fontSize: menuFontSize } })) }));
43
43
  };
44
44
  // 菜单图标
45
45
  export const renderMenuIcon = (iconUrl, iconPath, navigationStyle) => {
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
2
+ import { useEffect, useRef, useState } from 'react';
3
3
  import classNames from '../../utils/classnames';
4
4
  import { getTempFileURL } from '../../utils/tcb';
5
5
  import { LOAD_ERR_IMG_BASE64, getWhitelist } from '../../utils/constant';
6
+ import { getOnClick } from '../wd-unified-link/utils';
6
7
  import destr from 'destr';
7
8
  import './style';
8
9
  import xss from 'xss';
@@ -48,5 +49,16 @@ export default function RichTextView({ value = '', className, style, id, }) {
48
49
  setDisplayValue(tempValue);
49
50
  }
50
51
  }, [value]);
51
- return (displayValue && (_jsx("div", { className: cls, style: style, id: id, children: _jsx("div", { dangerouslySetInnerHTML: { __html: displayValue } }) })));
52
+ const richTextRef = useRef(null);
53
+ useEffect(() => {
54
+ if (richTextRef.current) {
55
+ richTextRef.current.querySelectorAll('a').forEach((a) => {
56
+ a.addEventListener('click', (e) => {
57
+ const url = a.href;
58
+ getOnClick({ url })(e);
59
+ });
60
+ });
61
+ }
62
+ }, [displayValue]);
63
+ return (displayValue && (_jsx("div", { ref: richTextRef, className: cls, style: style, id: id, children: _jsx("div", { dangerouslySetInnerHTML: { __html: displayValue } }) })));
52
64
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
3
3
  import CodeMirror from '@uiw/react-codemirror';
4
4
  import classNames from '../../utils/classnames';
5
5
  import { useConfig } from '../../utils/config-context';
@@ -50,16 +50,28 @@ export const WdCodeEditor = React.forwardRef(function WdCodeEditor(props, ref) {
50
50
  useSetWidgetApi(() => ({
51
51
  ...innerHandle,
52
52
  value,
53
- format: async () => {
53
+ format: async (params) => {
54
54
  try {
55
- const result = await format(value);
55
+ let _value = value;
56
+ if (params.isCustomVal) {
57
+ _value = params === null || params === void 0 ? void 0 : params.value;
58
+ }
59
+ const result = await format(_value);
56
60
  onChangeForm(result);
61
+ return result;
57
62
  }
58
63
  catch (error) {
59
64
  console.error(error);
60
65
  }
61
66
  },
62
67
  }), [innerHandle, onChangeForm, value], ref);
68
+ useEffect(() => {
69
+ if (events === null || events === void 0 ? void 0 : events.ready) {
70
+ // eslint-disable-next-line rulesdir/no-trigger-event-in-effect
71
+ events === null || events === void 0 ? void 0 : events.ready();
72
+ }
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, []);
63
75
  const themeExtension = themeData[theme];
64
76
  const languageExtension = loadLanguage(language);
65
77
  return (visible && (_jsx(WdFormItem, { ...props, validateErrorMsg: validateErrorMsg, validateState: validateState, readOnly: false, disabled: disabled, readValue: value, classRoot: classRoot, inputId: inputId, layout: props.layout, children: _jsx("div", { className: cls, ref: wrapRef, onFocus: () => wrapRef.current.classList.add('is-focused'), onBlur: () => wrapRef.current.classList.remove('is-focused'), "data-color-mode": theme, children: _jsxs("div", { className: `${root}__content`, "data-testid": "wd-code-editor", children: [_jsx(CodeMirror, { value: value, height: height, extensions: [languageExtension], onChange: onChange, placeholder: placeholder, editable: !readOnly && !disabled, autoFocus: focus, theme: themeExtension }), _jsx("textarea", { id: inputId, ref: textareaRef, placeholder: placeholder, name: name, value: value, autoFocus: focus, disabled: disabled, readOnly: readOnly, onChange: onChange, spellCheck: false, ...startWithOnProps })] }) }) })));
@@ -2,12 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { ConfigProvider } from 'tea-component';
4
4
  import { useConfig } from '../../utils/config-context';
5
- import { usePlatform, alertErrorMessage } from '../../utils/platform';
5
+ import { usePlatform } from '../../utils/platform';
6
6
  import classNames from '../../utils/classnames';
7
7
  import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
8
+ import { getOnClick } from './utils';
8
9
  import '../style';
9
10
  export const WdUnifiedLink = forwardRef(function WdUnifiedLink(props, ref) {
10
- const { className, id, style, children, url, options, events } = props;
11
+ const { className, id, style, children, url, options } = props;
11
12
  const platform = usePlatform();
12
13
  // 样式
13
14
  const { classPrefix } = useConfig();
@@ -19,73 +20,13 @@ export const WdUnifiedLink = forwardRef(function WdUnifiedLink(props, ref) {
19
20
  [compClassName]: true,
20
21
  [platformCss]: true,
21
22
  };
22
- const isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i);
23
23
  // Widget API,挂载组件只读属性和组件方法
24
24
  useSetWidgetApi(() => ({
25
25
  url,
26
26
  options,
27
27
  }), [url, options], ref);
28
28
  // 方法
29
- const onClick = async (e) => {
30
- var _a, _b, _c, _d, _e;
31
- events.tap && events.tap({}, { originEvent: e });
32
- // a 标签直接跳转
33
- if (/https?:\/\//.test(url)) {
34
- return;
35
- }
36
- if (!e.defaultPrevented) {
37
- e.preventDefault();
38
- const URL_REG = /^(weda-page|plugin|miniprogram):\/\/([0-9.\-A-Za-z]+)(?:\/([^?#]*))?(?:\?([^#]*))?$/;
39
- const matched = url.match(URL_REG);
40
- if (matched) {
41
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
- const [_, protocol, ...restOpts] = matched;
43
- switch (protocol) {
44
- case 'plugin':
45
- alertErrorMessage({
46
- message: '仅支持在小程序端打开插件页面',
47
- });
48
- break;
49
- case 'weda-page': {
50
- const [packageName, pageId, query] = restOpts;
51
- let params = {};
52
- if (query) {
53
- params = query.split('&').reduce((acc, param) => {
54
- const [key, value] = param.split('=');
55
- acc[key] = value;
56
- return acc;
57
- }, {});
58
- }
59
- // 页面参数,如果存在变量绑定,以绑定值为准
60
- if ((_a = props === null || props === void 0 ? void 0 : props.params) === null || _a === void 0 ? void 0 : _a[pageId]) {
61
- params = { ...params, ...(_b = props === null || props === void 0 ? void 0 : props.params) === null || _b === void 0 ? void 0 : _b[pageId] };
62
- }
63
- (_c = window === null || window === void 0 ? void 0 : window.app) === null || _c === void 0 ? void 0 : _c.navigateTo({
64
- pageId,
65
- packageName: packageName === 'main' ? '' : packageName,
66
- mode: (options === null || options === void 0 ? void 0 : options.target) === '_blank' ? 'web' : 'weDa',
67
- params,
68
- });
69
- break;
70
- }
71
- case 'miniprogram':
72
- // 打开其他小程序
73
- if (!isMobile) {
74
- alertErrorMessage({
75
- message: '仅支持在移动端打开小程序页面',
76
- });
77
- }
78
- else {
79
- (_d = window === null || window === void 0 ? void 0 : window.app) === null || _d === void 0 ? void 0 : _d.navigateTo({ url, options });
80
- }
81
- break;
82
- default:
83
- (_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.navigateTo({ url, options });
84
- break;
85
- }
86
- }
87
- }
88
- };
29
+ const onClick = getOnClick(props);
89
30
  return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx("a", { href: /https?:\/\//.test(url) ? url : 'javascript:void(0);', rel: "noopener noreferrer", className: classNames(classes, className), id: id, style: style, onClick: onClick, "data-testid": "wd-unified-link", ...options, children: children }) }));
90
31
  });
91
32
  export default WdUnifiedLink;
@@ -0,0 +1 @@
1
+ export declare const getOnClick: (props: any) => (e: any) => Promise<void>;
@@ -0,0 +1,66 @@
1
+ import { alertErrorMessage } from '../../utils/platform';
2
+ // ! reference in src/web/components/richTextView/index.tsx
3
+ export const getOnClick = (props) => {
4
+ const { url, options, events } = props;
5
+ const isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i);
6
+ return async (e) => {
7
+ var _a, _b, _c, _d, _e;
8
+ (events === null || events === void 0 ? void 0 : events.tap) && events.tap({}, { originEvent: e });
9
+ // a 标签直接跳转
10
+ if (/https?:\/\//.test(url)) {
11
+ return;
12
+ }
13
+ if (!e.defaultPrevented) {
14
+ e.preventDefault();
15
+ const URL_REG = /^(weda-page|plugin|miniprogram):\/\/([0-9.\-A-Za-z]+)(?:\/([^?#]*))?(?:\?([^#]*))?$/;
16
+ const matched = url.match(URL_REG);
17
+ if (matched) {
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ const [_, protocol, ...restOpts] = matched;
20
+ switch (protocol) {
21
+ case 'plugin':
22
+ alertErrorMessage({
23
+ message: '仅支持在小程序端打开插件页面',
24
+ });
25
+ break;
26
+ case 'weda-page': {
27
+ const [packageName, pageId, query] = restOpts;
28
+ let params = {};
29
+ if (query) {
30
+ params = query.split('&').reduce((acc, param) => {
31
+ const [key, value] = param.split('=');
32
+ acc[key] = value;
33
+ return acc;
34
+ }, {});
35
+ }
36
+ // 页面参数,如果存在变量绑定,以绑定值为准
37
+ if ((_a = props === null || props === void 0 ? void 0 : props.params) === null || _a === void 0 ? void 0 : _a[pageId]) {
38
+ params = { ...params, ...(_b = props === null || props === void 0 ? void 0 : props.params) === null || _b === void 0 ? void 0 : _b[pageId] };
39
+ }
40
+ (_c = window === null || window === void 0 ? void 0 : window.app) === null || _c === void 0 ? void 0 : _c.navigateTo({
41
+ pageId,
42
+ packageName: packageName === 'main' ? '' : packageName,
43
+ mode: (options === null || options === void 0 ? void 0 : options.target) === '_blank' ? 'web' : 'weDa',
44
+ params,
45
+ });
46
+ break;
47
+ }
48
+ case 'miniprogram':
49
+ // 打开其他小程序
50
+ if (!isMobile) {
51
+ alertErrorMessage({
52
+ message: '仅支持在移动端打开小程序页面',
53
+ });
54
+ }
55
+ else {
56
+ (_d = window === null || window === void 0 ? void 0 : window.app) === null || _d === void 0 ? void 0 : _d.navigateTo({ url, options });
57
+ }
58
+ break;
59
+ default:
60
+ (_e = window === null || window === void 0 ? void 0 : window.app) === null || _e === void 0 ? void 0 : _e.navigateTo({ url, options });
61
+ break;
62
+ }
63
+ }
64
+ }
65
+ };
66
+ };
@@ -226,7 +226,11 @@ export const getWhitelist = () => {
226
226
  onTagAttr: function (tag, name, value) {
227
227
  if (((tag === 'img' && name === 'src') ||
228
228
  (tag === 'a' && name === 'href')) &&
229
- /^((http)|(https)|(cloud)|(mailto)|(ftp)|(tel)):/.test(value)) {
229
+ // Prettier -> 单行过长 分行处理
230
+ [
231
+ /^((http)|(https)|(cloud)|(mailto)|(ftp)|(tel)):/,
232
+ /^((weda-page)|(miniprogram)|(plugin)):/,
233
+ ].some((reg) => reg.test(value))) {
230
234
  return `${name}="${value}"`;
231
235
  }
232
236
  if (name === 'style') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.7.2",
3
+ "version": "3.7.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",