@cloudbase/weda-ui 3.8.1 → 3.9.0
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/dist/configs/components/dataView.d.ts +14 -0
- package/dist/configs/components/dataView.js +104 -6
- package/dist/configs/components/listView.d.ts +29 -0
- package/dist/configs/components/listView.js +145 -24
- package/dist/configs/components/wd-input-number.d.ts +8 -0
- package/dist/configs/components/wd-input-number.js +9 -0
- package/dist/configs/components/wd-markdown.d.ts +95 -0
- package/dist/configs/components/wd-markdown.js +142 -0
- package/dist/configs/components/wd-menu-layout.d.ts +13 -10
- package/dist/configs/components/wd-menu-layout.js +12 -1
- package/dist/configs/components/wd-menu-nav-tab-layou.d.ts +27 -0
- package/dist/configs/components/wd-menu-nav-tab-layou.js +31 -0
- package/dist/configs/components/wd-table.d.ts +1 -1
- package/dist/configs/components/wd-table.js +1 -0
- package/dist/configs/index.d.ts +340 -10
- package/dist/configs/index.js +4 -0
- package/dist/configs/type-utils/type-form.js +1 -1
- package/dist/configs/utils/layout.d.ts +1 -1
- package/dist/configs/utils/layout.js +215 -6
- package/dist/style/index.scss +1 -1
- package/dist/web/components/dataView/index.js +5 -3
- package/dist/web/components/index.d.ts +2 -0
- package/dist/web/components/index.js +4 -0
- package/dist/web/components/listView/index.js +48 -13
- package/dist/web/components/listView/interface.d.ts +4 -0
- package/dist/web/components/listView/useQueryParams.d.ts +11 -0
- package/dist/web/components/listView/useQueryParams.js +23 -0
- package/dist/web/components/richTextView/index.js +4 -38
- package/dist/web/components/richTextView/useImgTransform.d.ts +1 -0
- package/dist/web/components/richTextView/useImgTransform.js +47 -0
- package/dist/web/components/wd-input-number/wd-input-number.js +16 -9
- package/dist/web/components/wd-markdown/github-markdown-light.css +1139 -0
- package/dist/web/components/wd-markdown/index.d.ts +4 -0
- package/dist/web/components/wd-markdown/index.js +3 -0
- package/dist/web/components/wd-markdown/style.d.ts +3 -0
- package/dist/web/components/wd-markdown/style.js +3 -0
- package/dist/web/components/wd-markdown/wd-markdown.d.ts +7 -0
- package/dist/web/components/wd-markdown/wd-markdown.js +88 -0
- package/dist/web/components/wd-menu-layout/components/H5Menu.js +3 -1
- package/dist/web/components/wd-menu-layout/components/NavTabMenu.d.ts +3 -0
- package/dist/web/components/wd-menu-layout/components/NavTabMenu.js +7 -0
- package/dist/web/components/wd-menu-layout/style.d.ts +1 -0
- package/dist/web/components/wd-menu-layout/style.js +1 -0
- package/dist/web/components/wd-menu-layout/wd-menu-layout.js +5 -2
- package/dist/web/components/wd-menu-nav-tab-layout/index.d.ts +6 -0
- package/dist/web/components/wd-menu-nav-tab-layout/index.js +5 -0
- package/dist/web/components/wd-table/components/FieldRender/index.js +5 -2
- package/dist/web/utils/getModelParams.d.ts +2 -0
- package/dist/web/utils/getModelParams.js +73 -4
- package/package.json +5 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CommonPropsType } from '../../types';
|
|
3
|
+
import type { DataType } from '../../../configs/components/wd-markdown';
|
|
4
|
+
import './style';
|
|
5
|
+
export interface MarkdownProps extends CommonPropsType, DataType {
|
|
6
|
+
}
|
|
7
|
+
export declare const WdMarkdown: React.ForwardRefExoticComponent<MarkdownProps & React.RefAttributes<any>>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
+
import { useEffect, useState, useCallback, forwardRef, useRef, } from 'react';
|
|
4
|
+
import MarkdownIt from 'markdown-it/dist/markdown-it.js';
|
|
5
|
+
import copy from 'markdown-it-code-copy';
|
|
6
|
+
import hljs from 'highlight.js';
|
|
7
|
+
import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
8
|
+
import { useConfig } from '../../utils/config-context';
|
|
9
|
+
import { usePlatform } from '../../utils/platform';
|
|
10
|
+
import classNames from '../../utils/classnames';
|
|
11
|
+
import useDebouncedCallback from '../../utils/hooks/use-debounced-callback';
|
|
12
|
+
import { useImgTransform } from '../richTextView/useImgTransform';
|
|
13
|
+
import { getOnClick } from '../wd-unified-link/utils';
|
|
14
|
+
import './style';
|
|
15
|
+
export const WdMarkdown = forwardRef(function WdMarkdown({ value = '', options, className, style, id }, ref) {
|
|
16
|
+
const platform = usePlatform();
|
|
17
|
+
const { classPrefix } = useConfig();
|
|
18
|
+
const cls = classNames({
|
|
19
|
+
[`${classPrefix}-markdown`]: true,
|
|
20
|
+
'markdown-body': true,
|
|
21
|
+
[`${classPrefix}-${platform}-table`]: true,
|
|
22
|
+
[className]: className,
|
|
23
|
+
});
|
|
24
|
+
// markdown-it实例
|
|
25
|
+
const [mdInstance, setMdInstance] = useState(null);
|
|
26
|
+
const destroy = useCallback(() => {
|
|
27
|
+
if (!mdInstance) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
setMdInstance(null);
|
|
31
|
+
}, [mdInstance]);
|
|
32
|
+
// 初始化markdown-it实例
|
|
33
|
+
const init = useDebouncedCallback(useCallback(async (options) => {
|
|
34
|
+
let md = mdInstance;
|
|
35
|
+
if (md) {
|
|
36
|
+
destroy();
|
|
37
|
+
}
|
|
38
|
+
md = new MarkdownIt({
|
|
39
|
+
// 默认开启高亮
|
|
40
|
+
highlight: function (str, lang) {
|
|
41
|
+
if (lang && hljs.getLanguage(lang)) {
|
|
42
|
+
try {
|
|
43
|
+
return hljs.highlight(lang, str).value;
|
|
44
|
+
}
|
|
45
|
+
catch (__) { }
|
|
46
|
+
}
|
|
47
|
+
return ''; // 使用额外的默认转义
|
|
48
|
+
},
|
|
49
|
+
...options,
|
|
50
|
+
});
|
|
51
|
+
md.use(copy);
|
|
52
|
+
setMdInstance(md);
|
|
53
|
+
}, [mdInstance, destroy]), 500, {
|
|
54
|
+
maxWait: 1000,
|
|
55
|
+
});
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
init(options);
|
|
58
|
+
}, [init, options]);
|
|
59
|
+
const [html, setHtml] = useState('');
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (mdInstance) {
|
|
62
|
+
setHtml(mdInstance === null || mdInstance === void 0 ? void 0 : mdInstance.render(value));
|
|
63
|
+
}
|
|
64
|
+
}, [mdInstance, value]);
|
|
65
|
+
const displayValue = useImgTransform(html);
|
|
66
|
+
const markdownRef = useRef(null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (markdownRef.current) {
|
|
69
|
+
markdownRef.current.querySelectorAll('a').forEach((a) => {
|
|
70
|
+
const url = a.href;
|
|
71
|
+
// 若非同域 默认新页面打开
|
|
72
|
+
if (/https?:\/\//.test(url) &&
|
|
73
|
+
!url.startsWith(window.location.origin)) {
|
|
74
|
+
a.target = a.target || '_blank';
|
|
75
|
+
}
|
|
76
|
+
a.addEventListener('click', (e) => {
|
|
77
|
+
getOnClick({ url })(e);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, [displayValue]);
|
|
82
|
+
useSetWidgetApi(() => {
|
|
83
|
+
return {
|
|
84
|
+
value,
|
|
85
|
+
};
|
|
86
|
+
}, [value], ref);
|
|
87
|
+
return (_jsx("div", { ref: markdownRef, className: cls, style: style, id: id, children: mdInstance && (_jsx("div", { dangerouslySetInnerHTML: { __html: displayValue } })) }));
|
|
88
|
+
});
|
|
@@ -14,5 +14,7 @@ export const H5Menu = forwardRef(function H5Menu(props, ref) {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
}, [setVisible]);
|
|
17
|
-
return (_jsxs(MenuLayoutContext.Provider, { value: provider, children: [_jsxs("div", { className: `${classPrefix}-menulayout__bar-wrap`, children: [_jsx("div", { className: `${classPrefix}-menulayout__bar-logo`, children: slotDiv(props.headSlot) }), _jsx("div", { className: `${classPrefix}-menulayout__bar-content`, children: slotDiv(props.headRightSlot, { justifyContent: 'flex-end' }) }), _jsx("div", { className: `${classPrefix}-menulayout__bar-extra`,
|
|
17
|
+
return (_jsxs(MenuLayoutContext.Provider, { value: provider, children: [_jsxs("div", { className: `${classPrefix}-menulayout__bar-wrap`, children: [_jsx("div", { className: `${classPrefix}-menulayout__bar-logo`, children: slotDiv(props.headSlot) }), _jsx("div", { className: `${classPrefix}-menulayout__bar-content`, children: slotDiv(props.headRightSlot, { justifyContent: 'flex-end' }) }), _jsx("div", { className: `${classPrefix}-menulayout__bar-extra`,
|
|
18
|
+
// 防止连续触发
|
|
19
|
+
style: props.outerClickClosable && visible ? { pointerEvents: 'none' } : {}, children: !visible ? (_jsx(WdIcon, { name: "td:view-list", size: "md", onClick: () => setVisible(true) })) : (_jsx(WdIcon, { name: "td:close", size: "md", onClick: () => setVisible(false) })) }), _jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsxs(Drawer, { style: { visibility: visible ? 'visible' : 'hidden' }, size: 'm', placement: 'right', disableAnimation: true, outerClickClosable: props.outerClickClosable, showMask: visible, visible: true, onClose: () => setVisible(false), className: `${classPrefix}-menulayout-h5__drawer ${classPrefix}-menulayout__menu`, children: [_jsx(WdMenuList, { ...props, className: "", id: "", style: {}, ref: ref }), _jsx("div", { className: `${classPrefix}-menulayout-h5__drawer-slot ${classPrefix}-menulayout-body__footer`, children: slotDiv(props.footerSlot) })] }) })] }), _jsx("div", { className: `${classPrefix}-menulayout-body`, children: _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot }) })] }));
|
|
18
20
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useConfig } from '../../../utils/config-context';
|
|
4
|
+
export const NavTabMenu = forwardRef(function TabMenu(props) {
|
|
5
|
+
const { classPrefix } = useConfig();
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: `${classPrefix}-menulayout-header`, children: props.headRightSlot }), _jsx("div", { className: `${classPrefix}-menulayout-body__content ${classPrefix}-menulayout__body`, children: props.contentSlot }), _jsx("div", { className: `${classPrefix}-menulayout-body__left-slot ${classPrefix}-menulayout-body__footer`, children: props.footerSlot })] }));
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../style';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../style';
|
|
@@ -5,6 +5,7 @@ import { PlantMenu } from './components/PlantMenu';
|
|
|
5
5
|
import { VerticalMenu } from './components/VerticalMenu';
|
|
6
6
|
import { TabMenu } from './components/TabMenu';
|
|
7
7
|
import { NavMenu } from './components/NavMenu';
|
|
8
|
+
import { NavTabMenu } from './components/NavTabMenu';
|
|
8
9
|
import { H5Menu } from './components/H5Menu';
|
|
9
10
|
import { useConfig } from '../../utils/config-context';
|
|
10
11
|
import classNames from '../../utils/classnames';
|
|
@@ -14,8 +15,10 @@ export const WdMenuLayout = forwardRef(function WdMenuLayout(props, ref) {
|
|
|
14
15
|
const { classPrefix } = useConfig();
|
|
15
16
|
const platform = usePlatform();
|
|
16
17
|
const _type = props.type || props.template;
|
|
17
|
-
const type = platform === 'h5' && !['tab', 'nav'].includes(_type)
|
|
18
|
+
const type = platform === 'h5' && !['tab', 'nav', 'navTab'].includes(_type)
|
|
19
|
+
? 'h5'
|
|
20
|
+
: _type;
|
|
18
21
|
return (
|
|
19
22
|
// 1024px 800px为方便测试 开发时去掉
|
|
20
|
-
_jsxs("div", { id: props.id, style: props.style, className: classNames(props.className, `${classPrefix}-menulayout`, `${classPrefix}-menulayout-root`, ['h5'].includes(type) ? `${classPrefix}-menulayout-h5-root` : '', `${classPrefix}-menulayout--${type}`), children: [['horizontal'].includes(type) && (_jsx(HorizontalMenu, { ...props, ref: ref })), ['vertical'].includes(type) && (_jsx(VerticalMenu, { ...props, ref: ref })), ['plant'].includes(type) && _jsx(PlantMenu, { ...props, ref: ref }), ['h5'].includes(type) && _jsx(H5Menu, { ...props, ref: ref }), ['tab'].includes(type) && _jsx(TabMenu, { ...props, ref: ref }), ['nav'].includes(type) && _jsx(NavMenu, { ...props, ref: ref })] }));
|
|
23
|
+
_jsxs("div", { id: props.id, style: props.style, className: classNames(props.className, `${classPrefix}-menulayout`, `${classPrefix}-menulayout-root`, ['h5'].includes(type) ? `${classPrefix}-menulayout-h5-root` : '', `${classPrefix}-menulayout--${type}`), children: [['horizontal'].includes(type) && (_jsx(HorizontalMenu, { ...props, ref: ref })), ['vertical'].includes(type) && (_jsx(VerticalMenu, { ...props, ref: ref })), ['plant'].includes(type) && _jsx(PlantMenu, { ...props, ref: ref }), ['h5'].includes(type) && _jsx(H5Menu, { ...props, ref: ref }), ['tab'].includes(type) && _jsx(TabMenu, { ...props, ref: ref }), ['nav'].includes(type) && _jsx(NavMenu, { ...props, ref: ref }), ['navTab'].includes(type) && (_jsx(NavTabMenu, { ...props, ref: ref }))] }));
|
|
21
24
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import classNames from '../../utils/classnames';
|
|
3
|
+
export default function WdMenuNavTabLayout({ children, className, style, id, }) {
|
|
4
|
+
return (_jsx("div", { role: "container", id: id, style: style, className: classNames({ 'weda-ui': true, [className]: className }), children: children }));
|
|
5
|
+
}
|
|
@@ -138,8 +138,8 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
138
138
|
}
|
|
139
139
|
return (_jsx(TextWrap, { ...textProps, children: fieldValue[relatedField] || fieldValue[primaryField] || '-' }));
|
|
140
140
|
}
|
|
141
|
-
else if (format === 'x-video') {
|
|
142
|
-
//
|
|
141
|
+
else if (format === 'x-video' || format === 'x-music') {
|
|
142
|
+
// 视频/音频
|
|
143
143
|
return _jsx(VideoPreview, { value: fieldValue });
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
@@ -165,6 +165,9 @@ export function getFieldRender(field = {}, extra = {}) {
|
|
|
165
165
|
if (format === 'x-location') {
|
|
166
166
|
return xLocationRender(fieldValue, modelType);
|
|
167
167
|
}
|
|
168
|
+
else if (format === 'x-json') {
|
|
169
|
+
return _jsx(TextWrap, { ...textProps, children: JSON.stringify(fieldValue) });
|
|
170
|
+
}
|
|
168
171
|
else if (modelType === 'detail') {
|
|
169
172
|
return objectRender({
|
|
170
173
|
value: fieldValue,
|
|
@@ -19,22 +19,91 @@ export const convertWhere = (props, supportManyRelated) => {
|
|
|
19
19
|
where = where === null || where === void 0 ? void 0 : where.filter((i) => !isEmptyObj(i));
|
|
20
20
|
return Array.isArray(where) ? where : [];
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* 拼接filter参数
|
|
24
|
+
*/
|
|
25
|
+
const getFilter = (wList) => {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
let where = [];
|
|
28
|
+
let filter = { where: {} };
|
|
29
|
+
if ((_a = wList === null || wList === void 0 ? void 0 : wList.where) === null || _a === void 0 ? void 0 : _a.$or) {
|
|
30
|
+
const wListWhere = ((_b = wList === null || wList === void 0 ? void 0 : wList.where) === null || _b === void 0 ? void 0 : _b.$or) || [];
|
|
31
|
+
if ((wList === null || wList === void 0 ? void 0 : wList.constructor) === Object) {
|
|
32
|
+
where = [...wListWhere];
|
|
33
|
+
filter = {
|
|
34
|
+
...wList,
|
|
35
|
+
where: {
|
|
36
|
+
$or: where,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const wListWhere = ((_c = wList === null || wList === void 0 ? void 0 : wList.where) === null || _c === void 0 ? void 0 : _c.$and) || [];
|
|
43
|
+
if ((wList === null || wList === void 0 ? void 0 : wList.constructor) === Object) {
|
|
44
|
+
where = [...wListWhere];
|
|
45
|
+
filter = {
|
|
46
|
+
...wList,
|
|
47
|
+
where: {
|
|
48
|
+
$and: where,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(wList)) {
|
|
54
|
+
where = [...wList];
|
|
55
|
+
filter = {
|
|
56
|
+
where: {
|
|
57
|
+
$and: where,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return getParseValue(filter);
|
|
62
|
+
};
|
|
63
|
+
const getSelectFields = (props) => {
|
|
64
|
+
let select = {};
|
|
65
|
+
// 支持自定义查询字段
|
|
66
|
+
if (props.selectFieldType === 'custom') {
|
|
67
|
+
const _selectFields = Array.isArray(props.selectFields)
|
|
68
|
+
? props.selectFields
|
|
69
|
+
: [];
|
|
70
|
+
_selectFields.forEach((name) => {
|
|
71
|
+
select[name] = true;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
select = { $master: true };
|
|
76
|
+
}
|
|
77
|
+
return select;
|
|
78
|
+
};
|
|
22
79
|
/**
|
|
23
80
|
* 获取tcb查询条件
|
|
24
81
|
*/
|
|
25
82
|
export const getModelParams = (props) => {
|
|
83
|
+
var _a;
|
|
26
84
|
const params = {};
|
|
27
85
|
try {
|
|
28
|
-
const where = convertWhere(props);
|
|
29
86
|
const { orderBy, orderType } = props || {};
|
|
30
87
|
if (orderBy && ['asc', 'desc'].includes(orderType)) {
|
|
31
88
|
params['orderBy'] = orderBy;
|
|
32
89
|
params['orderType'] = orderType;
|
|
33
90
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
91
|
+
if (props.supportManyRelated) {
|
|
92
|
+
// 支持多关联查询,需要将查询条件转换为filter
|
|
93
|
+
if (((_a = props === null || props === void 0 ? void 0 : props.queryCondition) === null || _a === void 0 ? void 0 : _a.constructor) === Object) {
|
|
94
|
+
params['filter'] = getFilter(props.queryCondition);
|
|
95
|
+
}
|
|
96
|
+
params.select = getSelectFields(props);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const where = convertWhere(props);
|
|
100
|
+
if (Array.isArray(where) && where.length > 0) {
|
|
101
|
+
params['where'] = where;
|
|
102
|
+
}
|
|
36
103
|
}
|
|
37
104
|
}
|
|
38
|
-
catch (e) {
|
|
105
|
+
catch (e) {
|
|
106
|
+
console.error('getModelParams error', e);
|
|
107
|
+
}
|
|
39
108
|
return params;
|
|
40
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -105,11 +105,14 @@
|
|
|
105
105
|
"echarts": "^5.3.0",
|
|
106
106
|
"echarts-for-react": "^3.0.2",
|
|
107
107
|
"eslint-plugin-compat": "^4.1.4",
|
|
108
|
+
"highlight.js": "^11.10.0",
|
|
108
109
|
"js-beautify": "^1.15.1",
|
|
109
110
|
"jsonexport": "3.2.0",
|
|
110
111
|
"lodash.get": "^4.4.2",
|
|
111
112
|
"lodash.isequal": "^4.5.0",
|
|
112
113
|
"lodash.set": "^4.3.2",
|
|
114
|
+
"markdown-it": "^14.1.0",
|
|
115
|
+
"markdown-it-code-copy": "^0.1.2",
|
|
113
116
|
"moment": "^2.29.4",
|
|
114
117
|
"object.fromentries": "^2.0.7",
|
|
115
118
|
"prop-types": "^15.7.2",
|
|
@@ -123,7 +126,7 @@
|
|
|
123
126
|
"spark-md5": "^3.0.2",
|
|
124
127
|
"swr": "^2.2.2",
|
|
125
128
|
"tdesign-icons-react": "0.0.8",
|
|
126
|
-
"tea-component": "
|
|
129
|
+
"tea-component": "~2.7.8",
|
|
127
130
|
"uuid": "8.3.2",
|
|
128
131
|
"video.js": "7.20.3",
|
|
129
132
|
"weui": "2.5.9",
|