@cqsjjb/jjb-react-admin-component 3.1.3 → 3.2.0-beta.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.
@@ -0,0 +1,100 @@
1
+ @com-prefix-cls: if(isdefined(@ant-prefix), @ant-prefix, ant);
2
+
3
+ .@{com-prefix-cls}_image-file-uploader_ {
4
+ position: relative;
5
+ transition: border-color .3s;
6
+ text-align: center;
7
+ overflow: hidden;
8
+ border-radius: var(--gbs-var-border-radius);
9
+ background-color: var(--gbs-var-algorithm);
10
+
11
+ &.@{com-prefix-cls}_image-file-uploader-default_ {
12
+ border-color: #d9d9d9;
13
+ }
14
+
15
+ &.@{com-prefix-cls}_image-file-uploader-dark_ {
16
+ border-color: #424242;
17
+ }
18
+
19
+ &:hover {
20
+ border-color: var(--gbs-var-color-primary);
21
+ }
22
+
23
+ .@{com-prefix-cls}_image-file-uploader-preview_ {
24
+ position: absolute;
25
+ width: 100%;
26
+ height: 100%;
27
+ top: 0;
28
+ left: 0;
29
+ overflow: hidden;
30
+ box-sizing: border-box;
31
+
32
+ .@{com-prefix-cls}-image {
33
+ width: 100%;
34
+ height: 100%;
35
+ display: flex;
36
+ border: none;
37
+ position: relative;
38
+ z-index: 9;
39
+ flex-direction: column;
40
+ align-items: center;
41
+ justify-content: center;
42
+ }
43
+
44
+ .@{com-prefix-cls}_image-file-uploader-preview-control_ {
45
+ position: absolute;
46
+ z-index: 10;
47
+ width: 100%;
48
+ height: 100%;
49
+ top: 0;
50
+ left: 0;
51
+ opacity: 0;
52
+ transition: opacity .123s linear;
53
+ background-color: rgba(0, 0, 0, .5);
54
+ display: flex;
55
+ align-items: center;
56
+ gap: 12px;
57
+ color: white;
58
+ justify-content: center;
59
+ font-size: 16px;
60
+ }
61
+
62
+ &:hover {
63
+ .@{com-prefix-cls}_image-file-uploader-preview-control_ {
64
+ opacity: 1;
65
+ }
66
+ }
67
+ }
68
+
69
+ .@{com-prefix-cls}_image-file-uploader-select_ {
70
+ position: absolute;
71
+ width: 100%;
72
+ height: 100%;
73
+ top: 0;
74
+ left: 0;
75
+ display: flex;
76
+ align-items: center;
77
+ flex-direction: column;
78
+ justify-content: center;
79
+ cursor: pointer;
80
+ user-select: none;
81
+
82
+ .@{com-prefix-cls}_image-file-uploader-select-tip_ {
83
+ margin-top: 8px;
84
+ white-space: nowrap;
85
+ text-overflow: ellipsis;
86
+ overflow: hidden;
87
+ padding: 0 10px;
88
+ }
89
+ }
90
+ }
91
+
92
+ .@{com-prefix-cls}-form-item-has-error {
93
+ .@{com-prefix-cls}_image-file-uploader_ {
94
+ border-color: #ff4d4f !important;
95
+
96
+ .@{com-prefix-cls}_image-file-uploader-select_ {
97
+ color: #ff4d4f !important;
98
+ }
99
+ }
100
+ }
@@ -1,13 +1,16 @@
1
- // @ts-ignore
2
1
  import * as React from 'react';
3
- import { ComponentProps } from '../types';
4
2
 
5
- interface MediaQueryProps extends ComponentProps {
3
+ export interface MediaQueryProps {
4
+ /** 子节点,可以是单个React元素或数组 */
5
+ children: React.ReactNode | React.ReactNode[];
6
+ /** 是否禁用媒体查询监听 */
6
7
  disabled?: boolean;
7
8
  }
8
9
 
9
- interface MediaQueryFc extends React.FC<MediaQueryProps> {
10
- }
10
+ /**
11
+ * MediaQuery 组件
12
+ * 会根据窗口宽度匹配 MEDIA_QUERY_LIST,并将匹配结果通过 `data-media-query` 传给子元素
13
+ */
14
+ declare const MediaQuery: React.FC<MediaQueryProps>;
11
15
 
12
- declare const MediaQuery: MediaQueryFc;
13
16
  export default MediaQuery;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState, useMemo } from 'react';
2
2
  const MEDIA_QUERY_LIST = {
3
3
  MAX_WIDTH_479: '(max-width: 479px)',
4
4
  MIN_WIDTH_480_AND_MAX_WIDTH_599: '(min-width: 480px) and (max-width: 599px)',
@@ -7,85 +7,36 @@ const MEDIA_QUERY_LIST = {
7
7
  MIN_WIDTH_1200_AND_MAX_WIDTH_1439: '(min-width: 1200px) and (max-width: 1439px)',
8
8
  MIN_WIDTH_1440: '(min-width: 1440px)'
9
9
  };
10
- export default class MediaQuery extends React.Component {
11
- state = {
12
- media: undefined
13
- };
14
- componentDidMount() {
15
- const {
16
- disabled
17
- } = this.props;
18
- if (disabled) {
19
- return;
20
- }
10
+ export default function MediaQuery({
11
+ children,
12
+ disabled
13
+ }) {
14
+ const [media, setMedia] = useState(undefined);
15
+ const mediaQueries = useMemo(() => {
16
+ if (disabled) return {};
17
+ return Object.fromEntries(Object.entries(MEDIA_QUERY_LIST).map(([key, query]) => [key, window.matchMedia(query)]));
18
+ }, [disabled]);
19
+ useEffect(() => {
20
+ if (disabled) return;
21
+ const handleChange = () => {
22
+ for (const [key, mql] of Object.entries(mediaQueries)) {
23
+ if (mql.matches) {
24
+ setMedia(key);
25
+ return;
26
+ }
27
+ }
28
+ setMedia(undefined);
29
+ };
30
+ Object.values(mediaQueries).forEach(mql => mql.addEventListener('change', handleChange));
21
31
 
22
- // 超小
23
- this.ultraSmall = window.matchMedia(MEDIA_QUERY_LIST.MAX_WIDTH_479);
24
- // 正常小
25
- this.normalSmall = window.matchMedia(MEDIA_QUERY_LIST.MIN_WIDTH_480_AND_MAX_WIDTH_599);
26
- // 中等
27
- this.normalMiddle = window.matchMedia(MEDIA_QUERY_LIST.MIN_WIDTH_600_AND_MAX_WIDTH_899);
28
- // 正常大
29
- this.normalLarge = window.matchMedia(MEDIA_QUERY_LIST.MIN_WIDTH_900_AND_MAX_WIDTH_1199);
30
- // 超大
31
- this.superLarge = window.matchMedia(MEDIA_QUERY_LIST.MIN_WIDTH_1200_AND_MAX_WIDTH_1439);
32
- // 超宽
33
- this.normalHuge = window.matchMedia(MEDIA_QUERY_LIST.MIN_WIDTH_1440);
34
- this.handleMediaQueryChange();
35
- this.ultraSmall.addEventListener('change', this.handleMediaQueryChange.bind(this));
36
- this.normalSmall.addEventListener('change', this.handleMediaQueryChange.bind(this));
37
- this.normalMiddle.addEventListener('change', this.handleMediaQueryChange.bind(this));
38
- this.normalLarge.addEventListener('change', this.handleMediaQueryChange.bind(this));
39
- this.superLarge.addEventListener('change', this.handleMediaQueryChange.bind(this));
40
- this.normalHuge.addEventListener('change', this.handleMediaQueryChange.bind(this));
41
- }
42
- componentWillUnmount() {
43
- this.ultraSmall.removeEventListener('change', this.handleMediaQueryChange.bind(this));
44
- this.normalSmall.removeEventListener('change', this.handleMediaQueryChange.bind(this));
45
- this.normalMiddle.removeEventListener('change', this.handleMediaQueryChange.bind(this));
46
- this.normalLarge.removeEventListener('change', this.handleMediaQueryChange.bind(this));
47
- this.superLarge.removeEventListener('change', this.handleMediaQueryChange.bind(this));
48
- this.normalHuge.removeEventListener('change', this.handleMediaQueryChange.bind(this));
49
- }
50
- handleMediaQueryChange() {
51
- const {
52
- disabled
53
- } = this.props;
54
- if (disabled) {
55
- return;
56
- }
57
- let media;
58
- if (this.ultraSmall.matches) {
59
- media = this.ultraSmall.media;
60
- } else if (this.normalSmall.matches) {
61
- media = this.normalSmall.media;
62
- } else if (this.normalMiddle.matches) {
63
- media = this.normalMiddle.media;
64
- } else if (this.normalLarge.matches) {
65
- media = this.normalLarge.media;
66
- } else if (this.superLarge.matches) {
67
- media = this.superLarge.media;
68
- } else if (this.normalHuge.matches) {
69
- media = this.normalHuge.media;
70
- }
71
- this.setState({
72
- media: Object.keys(MEDIA_QUERY_LIST).find(key => media === MEDIA_QUERY_LIST[key])
73
- });
74
- }
75
- get children() {
76
- return this.props.children;
77
- }
78
- render() {
79
- const {
80
- media
81
- } = this.state;
82
- const {
83
- children
84
- } = this.props;
85
- return /*#__PURE__*/React.createElement(React.Fragment, null, (Array.isArray(children) ? children : [].concat(children)).map((item, key) => ( /*#__PURE__*/React.createElement(item.type, {
86
- key,
87
- ...item.props,
88
- ['data-media-query']: media
89
- }))));
90
- }
32
+ // 初始化
33
+ handleChange();
34
+ return () => {
35
+ Object.values(mediaQueries).forEach(mql => mql.removeEventListener('change', handleChange));
36
+ };
37
+ }, [mediaQueries, disabled]);
38
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (Array.isArray(children) ? children : [children]).map((item, index) => /*#__PURE__*/React.isValidElement(item) ? /*#__PURE__*/React.cloneElement(item, {
39
+ key: index,
40
+ 'data-media-query': media
41
+ }) : item));
91
42
  }
@@ -0,0 +1,44 @@
1
+ // PageLayout.d.ts
2
+ import { CSSProperties, ReactNode, FC } from 'react';
3
+ import { History } from 'history';
4
+
5
+ export interface PageLayoutProps {
6
+ // 页面名称
7
+ title?: string;
8
+ // 右侧多余部分扩展(自定义)
9
+ extra?: ReactNode;
10
+ // 自定义头部
11
+ header?: ReactNode;
12
+ // 自定义底部
13
+ footer?: ReactNode;
14
+ // 路由历史对象
15
+ history?: History;
16
+ // 去除所有样式 默认-false
17
+ noStyle?: boolean;
18
+ // 取消边框 默认-false
19
+ noBorder?: boolean;
20
+ // form 表单行 默认-空
21
+ formLine?: ReactNode;
22
+ // form 表单行样式 默认-空
23
+ formLineStyle?: CSSProperties;
24
+ // 是否显示左箭头按钮 默认-false
25
+ previous?: boolean;
26
+ // 背景透明 默认-false
27
+ transparent?: boolean;
28
+ // 内容样式 默认-空
29
+ contentStyle?: CSSProperties;
30
+ // 底部样式 默认-空
31
+ footerStyle?: CSSProperties;
32
+ // 头部样式 默认-空
33
+ pageHeaderStyle?: CSSProperties;
34
+ // 自定义返回事件 默认-空
35
+ onBack?: () => void;
36
+ // 容器样式 默认-空
37
+ style?: CSSProperties;
38
+ // data-node-id 属性 默认-空
39
+ 'data-node-id'?: string;
40
+ }
41
+
42
+ declare const PageLayout: FC<PageLayoutProps>;
43
+
44
+ export default PageLayout;
@@ -0,0 +1,85 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { memo, useCallback } from 'react';
3
+ import { PageHeader } from '@ant-design/pro-layout';
4
+ import './index.less';
5
+ import { getPrefixCls } from '../tools/index.js';
6
+ const prefixCls = getPrefixCls();
7
+ const PageLayout = /*#__PURE__*/memo(props => {
8
+ const {
9
+ title,
10
+ extra,
11
+ style = {},
12
+ header,
13
+ footer,
14
+ history = {},
15
+ noStyle,
16
+ formLine,
17
+ formLineStyle,
18
+ noBorder = false,
19
+ previous = false,
20
+ children,
21
+ transparent,
22
+ contentStyle,
23
+ footerStyle,
24
+ pageHeaderStyle,
25
+ onBack,
26
+ 'data-node-id': dataNodeId
27
+ } = props;
28
+ const containerClass = [`${prefixCls}-layout-container`, transparent && `${prefixCls}-layout-container-transparent`, noStyle && `${prefixCls}-layout-container-no-style`].filter(Boolean).join(' ');
29
+ const backHandler = useCallback(() => {
30
+ if (onBack) {
31
+ onBack();
32
+ } else if (previous) {
33
+ history.go(-1);
34
+ }
35
+ }, [onBack, previous, history]);
36
+ return /*#__PURE__*/React.createElement("div", {
37
+ style: noBorder ? {
38
+ border: 'none',
39
+ ...style
40
+ } : style,
41
+ className: containerClass,
42
+ "data-node-id": dataNodeId
43
+ }, !header ? /*#__PURE__*/React.createElement(PageHeader, {
44
+ title: title,
45
+ extra: extra,
46
+ style: pageHeaderStyle,
47
+ onBack: previous || onBack ? backHandler : undefined
48
+ }) : header, formLine && /*#__PURE__*/React.createElement("div", {
49
+ className: `${prefixCls}-layout-container-tools`,
50
+ style: formLineStyle
51
+ }, formLine), /*#__PURE__*/React.createElement("div", {
52
+ style: contentStyle,
53
+ className: `${prefixCls}-layout-container-content`
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: `${prefixCls}-layout-container-content-abs`
56
+ }, children)), footer && /*#__PURE__*/React.createElement("div", {
57
+ className: `${prefixCls}-lay-container-bottom`,
58
+ style: footerStyle
59
+ }, footer));
60
+ });
61
+ PageLayout.propTypes = {
62
+ style: PropTypes.object,
63
+ title: PropTypes.string,
64
+ extra: PropTypes.node,
65
+ header: PropTypes.node,
66
+ footer: PropTypes.any,
67
+ history: PropTypes.object,
68
+ noStyle: PropTypes.bool,
69
+ noBorder: PropTypes.bool,
70
+ formLine: PropTypes.node,
71
+ previous: PropTypes.bool,
72
+ transparent: PropTypes.bool,
73
+ formLineStyle: PropTypes.object,
74
+ contentStyle: PropTypes.object,
75
+ footerStyle: PropTypes.object,
76
+ pageHeaderStyle: PropTypes.object,
77
+ onBack: PropTypes.func
78
+ };
79
+ PageLayout.defaultProps = {
80
+ style: {},
81
+ history: {},
82
+ noBorder: false,
83
+ previous: false
84
+ };
85
+ export default PageLayout;
@@ -0,0 +1,47 @@
1
+ @com-prefix-cls: if(isdefined(@ant-prefix), @ant-prefix, ant);
2
+
3
+ .@{com-prefix-cls}-layout-container {
4
+ display: flex;
5
+ flex-direction: column;
6
+ height: 100%;
7
+ overflow: hidden;
8
+ border-radius: 4px;
9
+ border: 1px solid #f0f0f0;
10
+ background-color: #fff;
11
+
12
+ &.@{com-prefix-cls}-layout-container-transparent {
13
+ background-color: transparent;
14
+ }
15
+
16
+ &.@{com-prefix-cls}-layout-container-no-style {
17
+ .@{com-prefix-cls}-layout-container-content {
18
+ padding: 0;
19
+ }
20
+ }
21
+
22
+ .@{com-prefix-cls}-layout-container-tools {
23
+ margin-top: 0;
24
+ margin-bottom: 0;
25
+ padding: 0 20px 16px 20px;
26
+ }
27
+
28
+ .@{com-prefix-cls}-layout-container-content {
29
+ flex: 1;
30
+ margin: 0 20px 20px 20px;
31
+ position: relative;
32
+ &-abs {
33
+ top: 0;
34
+ left: 0;
35
+ width: 100%;
36
+ height: 100%;
37
+ position: absolute;
38
+ overflow-y: auto;
39
+ overflow-x: hidden;
40
+ }
41
+ }
42
+
43
+ .@{com-prefix-cls}-lay-container-bottom {
44
+ padding: 20px;
45
+ border-top: 1px #f0f0f0 solid;
46
+ }
47
+ }
@@ -1,57 +1,34 @@
1
- // @ts-ignore
2
- import * as React from 'react';
3
- import { ComponentProps } from '../types';
1
+ import React from 'react';
2
+ import { FormInstance } from 'antd';
3
+ import { CSSProperties, ReactNode } from 'react';
4
4
 
5
- interface SearchFormProps extends ComponentProps {
6
- /**
7
- * @description form实例
8
- */
9
- form?: any,
10
- /**
11
- * @description 样式
12
- */
13
- style?: React.CSSProperties,
14
- /**
15
- * @description 是否显示展开按钮
16
- */
5
+ export interface SearchFormProps {
6
+ // 可选外部传入 form 实例
7
+ form?: React.RefObject<FormInstance>;
8
+ // 样式 默认-空
9
+ style?: CSSProperties;
10
+ // 是否展开,受控模式 默认-false
17
11
  expand?: boolean;
18
- /**
19
- * @description 每行列数,默认3
20
- */
21
- colSize?: boolean;
22
- /**
23
- * @description 表单内容列表 [<Form.Item>...</Form.Item>,...]
24
- */
25
- formLine: Array<React.ReactNode>;
26
- /**
27
- * @description 加载中
28
- */
12
+ // 内部默认展开状态,仅在 expand 未传入时生效 默认-false
13
+ defaultExpand?: boolean;
14
+ // 列数 默认-3
15
+ colSize?: number;
16
+ // 查询 loading 状态 默认-false
29
17
  loading?: boolean;
30
- /**
31
- * @description 表单默认值,只有初始化以及重置时生效
32
- */
33
- initialValues?:object
34
- /**
35
- * @description 组件挂载完成 通过事件返回form实例
36
- */
37
- onRef?: (ref: React.Ref<any>) => void;
38
- /**
39
- * @description 搜索 按钮触发,返回表单字段
40
- */
41
- onFinish?: (values: { [ p: string ]: any }) => void;
42
- /**
43
- * @description 重置 按钮触发
44
- */
45
- onReset?: (values: { [ p: string ]: any }) => void;
46
- /**
47
- * @description 展开/收起事件
48
- * @param open 展开/收起状态
49
- */
18
+ // 表单行节点数组 默认-[]
19
+ formLine: ReactNode[];
20
+ // 表单初始值
21
+ initialValues?: Record<string, any>;
22
+ /** 获取 form 实例回调 @deprecated */
23
+ onRef?: (form: React.RefObject<FormInstance>) => void;
24
+ // 重置回调
25
+ onReset?: (values: Record<string, any>) => void;
26
+ // 提交回调
27
+ onFinish?: (values: Record<string, any>) => void;
28
+ // 展开/收起状态变化回调
50
29
  onExpand?: (open: boolean) => void;
51
30
  }
52
31
 
53
- interface SearchFormFc extends React.FC<SearchFormProps> {
54
- }
32
+ declare const SearchForm: React.FC<SearchFormProps>;
55
33
 
56
- declare const SearchForm: SearchFormFc;
57
34
  export default SearchForm;