@jswork/antd-components 1.0.89 → 1.0.91
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/main.cjs.js +1 -20
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.d.mts +58 -4
- package/dist/main.d.ts +58 -4
- package/dist/main.esm.js +1 -20
- package/dist/main.esm.js.map +1 -1
- package/package.json +6 -7
- package/src/lib/breadcrumb.tsx +2 -2
- package/src/lib/checkbox-group.tsx +1 -1
- package/src/lib/radio-group.tsx +1 -1
- package/src/lib/select.tsx +5 -6
- package/src/lib/transfer.tsx +1 -1
- package/src/lib/tree-select.tsx +2 -2
- package/src/lib/tree.tsx +4 -4
- package/src/main.ts +27 -0
- package/src/tpls/breadcrumb/index.tsx +8 -0
- package/src/tpls/kv/index.tsx +74 -0
- package/src/tpls/raw/index.tsx +47 -0
- package/src/tpls/transfer/index.tsx +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jswork/antd-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.91",
|
|
4
4
|
"main": "dist/main.cjs.js",
|
|
5
5
|
"module": "dist/main.esm.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"release": "release-it --ci"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@jswork/harmony-events": "^1.2.
|
|
21
|
-
"@jswork/next": "^1.2.
|
|
20
|
+
"@jswork/harmony-events": "^1.2.2",
|
|
21
|
+
"@jswork/next": "^1.2.6",
|
|
22
22
|
"@swc/core": "^1.3.93",
|
|
23
23
|
"@types/react": "^18.2.28",
|
|
24
24
|
"@types/react-dom": "^18.2.13",
|
|
@@ -39,14 +39,13 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@jswork/antd-form-builder": "^1.1.27",
|
|
42
|
-
"@jswork/antd-tpls": "^1.0.16",
|
|
43
42
|
"@jswork/loadkit": "^1.0.6",
|
|
44
|
-
"@jswork/next-dom-event": "^1.0.
|
|
43
|
+
"@jswork/next-dom-event": "^1.0.8",
|
|
45
44
|
"@jswork/next-gpid": "^1.0.4",
|
|
46
45
|
"@jswork/next-tree-walk": "^1.0.7",
|
|
47
46
|
"@jswork/noop": "^1.0.0",
|
|
48
|
-
"@jswork/react-codeflask": "^1.
|
|
49
|
-
"@jswork/react-list": "^1.2.
|
|
47
|
+
"@jswork/react-codeflask": "^1.1.2",
|
|
48
|
+
"@jswork/react-list": "^1.2.10",
|
|
50
49
|
"@jswork/weibo2res": "^1.0.4",
|
|
51
50
|
"fast-deep-equal": "^3.1.3",
|
|
52
51
|
"nanoid": "^4.0.2",
|
package/src/lib/breadcrumb.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import noop from '@jswork/noop';
|
|
3
3
|
import { Breadcrumb, BreadcrumbProps } from 'antd';
|
|
4
4
|
import ReactList, { TemplateArgs } from '@jswork/react-list';
|
|
5
|
-
import { breadcrumbDefault } from '
|
|
5
|
+
import { breadcrumbDefault } from '../tpls/breadcrumb';
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
|
|
8
8
|
// hack for react-list
|
|
@@ -26,7 +26,7 @@ export class AcBreadcrumb extends React.Component<Props> {
|
|
|
26
26
|
static displayName = CLASS_NAME;
|
|
27
27
|
static defaultProps = {
|
|
28
28
|
onChange: noop,
|
|
29
|
-
template: breadcrumbDefault
|
|
29
|
+
template: breadcrumbDefault,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
render() {
|
|
@@ -3,7 +3,7 @@ import ReactList from '@jswork/react-list';
|
|
|
3
3
|
import noop from '@jswork/noop';
|
|
4
4
|
import { Checkbox } from 'antd';
|
|
5
5
|
import cx from 'classnames';
|
|
6
|
-
import { checkboxKv } from '
|
|
6
|
+
import { checkboxKv } from '../tpls/kv';
|
|
7
7
|
import { CheckboxGroupProps } from 'antd/es/checkbox';
|
|
8
8
|
|
|
9
9
|
const CLASS_NAME = 'ac-checkbox-group';
|
package/src/lib/radio-group.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import ReactList from '@jswork/react-list';
|
|
|
3
3
|
import noop from '@jswork/noop';
|
|
4
4
|
import { Radio } from 'antd';
|
|
5
5
|
import cx from 'classnames';
|
|
6
|
-
import { radioKv } from '
|
|
6
|
+
import { radioKv } from '../tpls/kv';
|
|
7
7
|
|
|
8
8
|
const CLASS_NAME = 'ac-radio-group';
|
|
9
9
|
type StdEventTarget = { target: { value: any } };
|
package/src/lib/select.tsx
CHANGED
|
@@ -3,12 +3,12 @@ import ReactList from '@jswork/react-list';
|
|
|
3
3
|
import noop from '@jswork/noop';
|
|
4
4
|
import { Select, SelectProps } from 'antd';
|
|
5
5
|
import cx from 'classnames';
|
|
6
|
-
import { selectKv, kv as KvTmpl } from '
|
|
6
|
+
import { selectKv, kv as KvTmpl } from '../tpls/kv';
|
|
7
7
|
|
|
8
8
|
const CLASS_NAME = 'ac-select';
|
|
9
9
|
const DEFAULT_KV = {
|
|
10
10
|
label: 'label',
|
|
11
|
-
value: 'value'
|
|
11
|
+
value: 'value',
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
type StdEventTarget = { target: { value: any } };
|
|
@@ -33,11 +33,11 @@ export class AcSelect extends React.Component<Props> {
|
|
|
33
33
|
kv: DEFAULT_KV,
|
|
34
34
|
template: selectKv,
|
|
35
35
|
onChange: noop,
|
|
36
|
-
onSearch: noop
|
|
36
|
+
onSearch: noop,
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
state = {
|
|
40
|
-
value: this.props.value
|
|
40
|
+
value: this.props.value,
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
shouldComponentUpdate(nextProps: Readonly<Props>): boolean {
|
|
@@ -64,7 +64,7 @@ export class AcSelect extends React.Component<Props> {
|
|
|
64
64
|
if (kv === DEFAULT_KV) return template!(args);
|
|
65
65
|
return KvTmpl(args, {
|
|
66
66
|
component: Select.Option,
|
|
67
|
-
...kv
|
|
67
|
+
...kv,
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -73,7 +73,6 @@ export class AcSelect extends React.Component<Props> {
|
|
|
73
73
|
const { value: _value } = this.state;
|
|
74
74
|
return (
|
|
75
75
|
<ReactList
|
|
76
|
-
allowEmpty
|
|
77
76
|
as={Select}
|
|
78
77
|
onChange={this.handleChange}
|
|
79
78
|
className={cx(CLASS_NAME, className)}
|
package/src/lib/transfer.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import noop from '@jswork/noop';
|
|
3
3
|
import { Transfer, TransferProps } from 'antd';
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import { transferLabel } from '
|
|
5
|
+
import { transferLabel } from '../tpls/transfer';
|
|
6
6
|
|
|
7
7
|
const CLASS_NAME = 'ac-transfer';
|
|
8
8
|
type StdEventTarget = { target: { value: any } };
|
package/src/lib/tree-select.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import cx from 'classnames';
|
|
|
3
3
|
import noop from '@jswork/noop';
|
|
4
4
|
import { TreeSelect, TreeSelectProps } from 'antd';
|
|
5
5
|
import '@jswork/next-tree-walk';
|
|
6
|
-
import { treeSelectKv } from '
|
|
6
|
+
import { treeSelectKv } from '../tpls/kv';
|
|
7
7
|
|
|
8
8
|
const CLASS_NAME = 'ac-tree-select';
|
|
9
9
|
type StdEventTarget = { target: { value: any } };
|
|
@@ -26,7 +26,7 @@ export class AcTreeSelect extends React.Component<Props> {
|
|
|
26
26
|
items: [],
|
|
27
27
|
template: treeSelectKv,
|
|
28
28
|
itemsKey: 'children',
|
|
29
|
-
onChange: noop
|
|
29
|
+
onChange: noop,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
get childView() {
|
package/src/lib/tree.tsx
CHANGED
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { Tree, TreeProps } from 'antd';
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import '@jswork/next-tree-walk';
|
|
5
|
-
import { treeKv, kv as KvTmpl } from '
|
|
5
|
+
import { treeKv, kv as KvTmpl } from '../tpls/kv';
|
|
6
6
|
|
|
7
7
|
const CLASS_NAME = 'ac-tree';
|
|
8
8
|
const DEFAULT_KV = {
|
|
9
9
|
label: 'label',
|
|
10
|
-
value: 'value'
|
|
10
|
+
value: 'value',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
type Props = {
|
|
@@ -27,7 +27,7 @@ export class AcTree extends React.Component<Props> {
|
|
|
27
27
|
items: [],
|
|
28
28
|
kv: DEFAULT_KV,
|
|
29
29
|
template: treeKv,
|
|
30
|
-
itemsKey: 'children'
|
|
30
|
+
itemsKey: 'children',
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
get childView() {
|
|
@@ -40,7 +40,7 @@ export class AcTree extends React.Component<Props> {
|
|
|
40
40
|
if (kv === DEFAULT_KV) return template!(args);
|
|
41
41
|
return KvTmpl(args, {
|
|
42
42
|
component: Tree.TreeNode,
|
|
43
|
-
...kv
|
|
43
|
+
...kv,
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
|
package/src/main.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { breadcrumbDefault } from './tpls/breadcrumb';
|
|
2
|
+
import { kv, checkboxKv, radioKv, treeKv, selectKv, treeSelectKv } from './tpls/kv';
|
|
3
|
+
import { raw, checkboxRaw, radioRaw, selectRaw } from './tpls/raw';
|
|
4
|
+
import { transferLabel } from './tpls/transfer';
|
|
5
|
+
|
|
6
|
+
|
|
1
7
|
export * from './lib/alert';
|
|
2
8
|
export * from './lib/breadcrumb';
|
|
3
9
|
export * from './lib/checkable-dropdown';
|
|
@@ -32,3 +38,24 @@ export * from './lib/upload-dragger';
|
|
|
32
38
|
export * from './lib/upload-picture';
|
|
33
39
|
export * from './lib/upload-picture-card';
|
|
34
40
|
export * from './lib/upload';
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// export all templates
|
|
44
|
+
export {
|
|
45
|
+
// breadcrumb
|
|
46
|
+
breadcrumbDefault,
|
|
47
|
+
// kv
|
|
48
|
+
kv,
|
|
49
|
+
checkboxKv,
|
|
50
|
+
radioKv,
|
|
51
|
+
treeKv,
|
|
52
|
+
selectKv,
|
|
53
|
+
treeSelectKv,
|
|
54
|
+
// raw
|
|
55
|
+
raw,
|
|
56
|
+
checkboxRaw,
|
|
57
|
+
radioRaw,
|
|
58
|
+
selectRaw,
|
|
59
|
+
// transfer
|
|
60
|
+
transferLabel,
|
|
61
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Breadcrumb } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
export const breadcrumbDefault = ({ item, index, items }) => {
|
|
5
|
+
const last = items?.length - 1 === index;
|
|
6
|
+
const child = last ? <span>{item.label}</span> : <a href={item.value}>{item.label}</a>;
|
|
7
|
+
return <Breadcrumb.Item key={index}>{child}</Breadcrumb.Item>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Checkbox, Select, Radio, Tree, TreeSelect } from 'antd';
|
|
3
|
+
|
|
4
|
+
interface Options {
|
|
5
|
+
component: React.ComponentType<any>;
|
|
6
|
+
value?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const defaults = {
|
|
13
|
+
value: 'value',
|
|
14
|
+
label: 'label',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* KV component template, for key-value pair.
|
|
19
|
+
* @param item
|
|
20
|
+
* @param index
|
|
21
|
+
* @param options
|
|
22
|
+
*/
|
|
23
|
+
export const kv = ({ item, index }, options: Options) => {
|
|
24
|
+
const opts = { ...defaults, ...options };
|
|
25
|
+
const { component: Component, value, label, ...otherProps } = opts;
|
|
26
|
+
const val = item[value];
|
|
27
|
+
const children = item[label];
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Component key={index} value={val} {...otherProps}>
|
|
31
|
+
{children}
|
|
32
|
+
</Component>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// checkboxKv
|
|
37
|
+
export const checkboxKv = (args) => {
|
|
38
|
+
return kv(args, {
|
|
39
|
+
component: Checkbox,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// selectKv
|
|
44
|
+
export const selectKv = (args) => {
|
|
45
|
+
return kv(args, {
|
|
46
|
+
component: Select.Option,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// radioKv
|
|
51
|
+
export const radioKv = (args, opts) => {
|
|
52
|
+
const { isButton, ...otherProps } = opts || {};
|
|
53
|
+
const RadioComponent = isButton ? Radio.Button : Radio;
|
|
54
|
+
const radioProps = isButton ? otherProps : {};
|
|
55
|
+
|
|
56
|
+
return kv(args, {
|
|
57
|
+
component: RadioComponent,
|
|
58
|
+
...radioProps,
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const treeKv = ({ item }, cb) => {
|
|
63
|
+
const { value, label, ...itemProps } = item;
|
|
64
|
+
return (
|
|
65
|
+
<Tree.TreeNode key={value} title={label} {...itemProps}>
|
|
66
|
+
{cb()}
|
|
67
|
+
</Tree.TreeNode>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const treeSelectKv = ({ item }, cb) => {
|
|
72
|
+
const { value, label } = item;
|
|
73
|
+
return <TreeSelect.TreeNode key={value} value={value} title={label} children={cb()} />;
|
|
74
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Checkbox, Radio, Select } from 'antd';
|
|
3
|
+
|
|
4
|
+
interface Options {
|
|
5
|
+
component: React.ComponentType<any>;
|
|
6
|
+
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Raw component template, for array of items.
|
|
12
|
+
* @param item
|
|
13
|
+
* @param index
|
|
14
|
+
* @param options
|
|
15
|
+
*/
|
|
16
|
+
export const raw = ({ item, index }, options: Options) => {
|
|
17
|
+
const { component: Component, ...otherProps } = options;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Component key={index} value={item} {...otherProps}>
|
|
21
|
+
{item}
|
|
22
|
+
</Component>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const checkboxRaw = (args) => {
|
|
27
|
+
return raw(args, {
|
|
28
|
+
component: Checkbox,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const selectRaw = (args) => {
|
|
33
|
+
return raw(args, {
|
|
34
|
+
component: Select.Option,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const radioRaw = (args, opts) => {
|
|
39
|
+
const { isButton, ...otherProps } = opts || {};
|
|
40
|
+
const RadioComponent = isButton ? Radio.Button : Radio;
|
|
41
|
+
const radioProps = isButton ? otherProps : {};
|
|
42
|
+
|
|
43
|
+
return raw(args, {
|
|
44
|
+
component: RadioComponent,
|
|
45
|
+
...radioProps,
|
|
46
|
+
});
|
|
47
|
+
};
|