@king-design/intact 3.1.0-beta.1 → 3.1.0-beta.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.
- package/components/colorpicker/styles.ts +4 -4
- package/components/copy/index.spec.ts +28 -0
- package/components/copy/index.ts +2 -0
- package/components/copy/useCopy.ts +9 -4
- package/components/dialog/base.ts +1 -1
- package/components/dialog/base.vdt +2 -2
- package/components/dialog/styles.ts +1 -0
- package/components/editable/index.vdt +7 -5
- package/components/layout/aside.ts +4 -2
- package/components/layout/body.ts +2 -0
- package/components/layout/index.md +1 -0
- package/components/layout/styles.ts +10 -2
- package/components/layout/useParse.ts +1 -1
- package/components/menu/demos/basic.md +1 -1
- package/components/menu/item.vdt +17 -2
- package/components/menu/menu.ts +4 -0
- package/components/menu/menu.vdt +1 -1
- package/components/menu/styles.ts +20 -16
- package/components/menu/useDropdown.ts +3 -6
- package/components/message/styles.ts +2 -2
- package/components/select/styles.ts +1 -1
- package/components/table/cell.vdt +1 -1
- package/components/table/column.vdt +1 -1
- package/components/table/row.vdt +2 -2
- package/components/table/styles.ts +2 -2
- package/components/table/table.vdt +1 -1
- package/components/table/useFixedColumns.ts +3 -2
- package/components/tooltip/styles.ts +1 -1
- package/components/tree/demos/draggable.md +63 -48
- package/components/tree/index.md +4 -3
- package/components/tree/index.spec.ts +39 -40
- package/components/tree/index.ts +8 -3
- package/components/tree/styles.ts +2 -0
- package/components/tree/useDraggable.ts +5 -5
- package/components/tree/useExpanded.ts +1 -1
- package/components/tree/useNodes.ts +1 -0
- package/components/treeSelect/index.md +7 -1
- package/components/treeSelect/index.ts +4 -0
- package/es/components/colorpicker/styles.js +2 -2
- package/es/components/copy/index.d.ts +1 -0
- package/es/components/copy/index.js +2 -1
- package/es/components/copy/index.spec.js +64 -1
- package/es/components/copy/useCopy.d.ts +1 -1
- package/es/components/copy/useCopy.js +11 -5
- package/es/components/dialog/base.js +1 -1
- package/es/components/dialog/base.vdt.js +3 -3
- package/es/components/dialog/styles.js +1 -1
- package/es/components/editable/index.vdt.js +8 -5
- package/es/components/layout/aside.d.ts +1 -0
- package/es/components/layout/aside.js +5 -3
- package/es/components/layout/body.js +2 -1
- package/es/components/layout/styles.d.ts +2 -1
- package/es/components/layout/styles.js +7 -2
- package/es/components/layout/useParse.js +1 -1
- package/es/components/menu/item.vdt.js +22 -2
- package/es/components/menu/menu.d.ts +1 -0
- package/es/components/menu/menu.js +2 -1
- package/es/components/menu/menu.vdt.js +1 -1
- package/es/components/menu/styles.d.ts +1 -0
- package/es/components/menu/styles.js +10 -2
- package/es/components/menu/useDropdown.js +3 -6
- package/es/components/message/styles.js +1 -1
- package/es/components/select/styles.js +1 -1
- package/es/components/table/cell.vdt.js +1 -1
- package/es/components/table/column.vdt.js +1 -1
- package/es/components/table/row.vdt.js +1 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/table/table.vdt.js +1 -1
- package/es/components/table/useFixedColumns.d.ts +1 -1
- package/es/components/table/useFixedColumns.js +2 -2
- package/es/components/tooltip/styles.js +1 -1
- package/es/components/tree/index.d.ts +5 -3
- package/es/components/tree/index.js +5 -0
- package/es/components/tree/index.spec.js +60 -39
- package/es/components/tree/styles.js +1 -1
- package/es/components/tree/useDraggable.js +12 -12
- package/es/components/tree/useExpanded.d.ts +1 -0
- package/es/components/tree/useExpanded.js +2 -1
- package/es/components/tree/useNodes.d.ts +1 -0
- package/es/components/treeSelect/index.d.ts +1 -0
- package/es/components/treeSelect/index.js +4 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/menu/demos/basic/react.js +2 -2
- package/es/site/data/components/tree/demos/draggable/index.d.ts +23 -17
- package/es/site/data/components/tree/demos/draggable/index.js +45 -35
- package/es/site/data/components/tree/demos/draggable/react.d.ts +23 -17
- package/es/site/data/components/tree/demos/draggable/react.js +54 -35
- package/index.ts +2 -2
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ order: 6
|
|
|
8
8
|
触发`denydrag`和`denydrop`事件来告知用户
|
|
9
9
|
|
|
10
10
|
```vdt
|
|
11
|
-
import {Tree, Input} from 'kpc';
|
|
11
|
+
import {Tree, Input, Icon} from 'kpc';
|
|
12
12
|
|
|
13
13
|
<Tree
|
|
14
14
|
draggable
|
|
@@ -19,11 +19,22 @@ import {Tree, Input} from 'kpc';
|
|
|
19
19
|
ev-denydrop={this.onDenyDrop}
|
|
20
20
|
v-model:data='data'
|
|
21
21
|
v-model:expandedKeys="expandedKeys"
|
|
22
|
-
|
|
22
|
+
>
|
|
23
|
+
<b:label args="[data, node]">
|
|
24
|
+
<Icon v-if={data.type === 'file'} class="k-icon-paper" />
|
|
25
|
+
<Icon v-else class="k-icon-folder" />
|
|
26
|
+
{data.label}
|
|
27
|
+
</b:label>
|
|
28
|
+
</Tree>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```styl
|
|
32
|
+
.k-tree-text .k-icon
|
|
33
|
+
margin-right 8px
|
|
23
34
|
```
|
|
24
35
|
|
|
25
36
|
```ts
|
|
26
|
-
import {Message, TreeDataItem, TreeNode, TreeDragEndData} from 'kpc';
|
|
37
|
+
import {Message, TreeDataItem, TreeNode, TreeDragEndData, TreeMode} from 'kpc';
|
|
27
38
|
|
|
28
39
|
interface Props {
|
|
29
40
|
data?: TreeDataItem<string>[]
|
|
@@ -37,58 +48,52 @@ export default class extends Component<Props> {
|
|
|
37
48
|
return {
|
|
38
49
|
data: [
|
|
39
50
|
{
|
|
40
|
-
label: '
|
|
41
|
-
key: '
|
|
51
|
+
label: '总览',
|
|
52
|
+
key: 'summarization',
|
|
53
|
+
type: 'file',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: '产品简介',
|
|
57
|
+
key: 'introduction',
|
|
58
|
+
type: 'file',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: '技术实现',
|
|
62
|
+
key: 'implemention',
|
|
63
|
+
type: 'file',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: '操作指南',
|
|
67
|
+
key: 'guide',
|
|
68
|
+
type: 'dir',
|
|
42
69
|
children: [
|
|
43
70
|
{
|
|
44
|
-
label: '
|
|
45
|
-
key: '
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
label: 'This node can not be dragged and dropped.',
|
|
49
|
-
key: '1-1-1'
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
71
|
+
label: '产品安装',
|
|
72
|
+
key: 'installation',
|
|
73
|
+
type: 'file',
|
|
74
|
+
},
|
|
53
75
|
]
|
|
54
76
|
},
|
|
55
77
|
{
|
|
56
|
-
label: '
|
|
57
|
-
key: '
|
|
78
|
+
label: '接入说明',
|
|
79
|
+
key: 'interaction',
|
|
80
|
+
type: 'dir',
|
|
58
81
|
children: [
|
|
59
82
|
{
|
|
60
|
-
label: '
|
|
61
|
-
key: '
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
label: 'Third floor-2.1.1',
|
|
65
|
-
key: '2-1-1'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
label: 'Third floor-2.1.2',
|
|
69
|
-
key: '2-1-2'
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
label: 'Second floor-2.2',
|
|
75
|
-
key: '2-2',
|
|
76
|
-
children: [
|
|
77
|
-
{
|
|
78
|
-
label: 'Third floor-2.2.1',
|
|
79
|
-
key: '2-2-1'
|
|
80
|
-
}
|
|
81
|
-
]
|
|
83
|
+
label: '使用',
|
|
84
|
+
key: 'usage',
|
|
85
|
+
type: 'file',
|
|
82
86
|
},
|
|
83
|
-
{
|
|
84
|
-
label: 'Second floor-2.3',
|
|
85
|
-
key: '2-3',
|
|
86
|
-
disabled: true
|
|
87
|
-
}
|
|
88
87
|
]
|
|
89
|
-
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: '禁用文件',
|
|
91
|
+
key: 'disabled',
|
|
92
|
+
type: 'file',
|
|
93
|
+
disabled: true,
|
|
94
|
+
},
|
|
90
95
|
],
|
|
91
|
-
expandedKeys: [
|
|
96
|
+
expandedKeys: [],
|
|
92
97
|
};
|
|
93
98
|
}
|
|
94
99
|
|
|
@@ -97,11 +102,21 @@ export default class extends Component<Props> {
|
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
allowDrag(node: TreeNode<string>) {
|
|
100
|
-
return node.key !== '
|
|
105
|
+
return node.key !== 'summarization';
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
allowDrop(node: TreeNode<string
|
|
104
|
-
|
|
108
|
+
allowDrop(node: TreeNode<string>, srcNode: TreeNode<string>, mode: TreeMode) {
|
|
109
|
+
// 能够将文件拖入文件夹,但是不能讲文件夹拖入文件夹
|
|
110
|
+
if (mode === TreeMode.Inner) {
|
|
111
|
+
// 文件拖入文件夹
|
|
112
|
+
return srcNode.data.type === 'file' && node.data.type === 'dir';
|
|
113
|
+
} else if (srcNode.data.type === 'dir' && node.parent) {
|
|
114
|
+
// 此时插入模式是,前面或者后面插入
|
|
115
|
+
// 如果拖动的是文件夹,但是目标节点存在父元素,代表目标节点也是文件夹,不能插入
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return true;
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
onDenyDrag(node: TreeNode<string>) {
|
package/components/tree/index.md
CHANGED
|
@@ -14,7 +14,7 @@ sidebar: doc
|
|
|
14
14
|
| uncorrelated | 是否让父子`checkbox`选中状态互不关联 | `boolean` | `false` |
|
|
15
15
|
| checkedKeys | 通过`key`指定勾选的数据节点 | `K[]` | `undefined` |
|
|
16
16
|
| expandedKeys | 通过`key`指定展开的数据节点 | `K[]` | `undefined` |
|
|
17
|
-
| defaultExpandAll | 是否默认展开所有节点 | `boolean` | `false` |
|
|
17
|
+
| defaultExpandAll | 是否默认展开所有节点 (该属性只在首次渲染时起作用,渲染后再更新数据`data`,没有效果) | `boolean` | `false` |
|
|
18
18
|
| selectable | 节点是否可选中,默认为`true`可选中 | `boolean` | `true` |
|
|
19
19
|
| selectedKeys | 通过`key`指定选中的数据节点 | `K[]` | `undefined` |
|
|
20
20
|
| multiple | `selectedKeys`是否支持多选 | `boolean` | `false` |
|
|
@@ -23,7 +23,7 @@ sidebar: doc
|
|
|
23
23
|
| showLine | 是否展示左侧对齐线 | `boolean` | `true` |
|
|
24
24
|
| draggable | 是否支持拖拽 | `boolean` | `false` |
|
|
25
25
|
| allowDrag | 指定哪些节点可拖拽 | `(node: TreeNode<K>) => boolean` | `undefined` |
|
|
26
|
-
| allowDrop | 指定哪些节点可以插入子节点 | `(node: TreeNode<K
|
|
26
|
+
| allowDrop | 指定哪些节点可以插入子节点 | `(node: TreeNode<K>, srcNode: TreeNode[K]) => boolean` | `undefined` |
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
import {Key, Children} from 'intact';
|
|
@@ -82,6 +82,7 @@ export class TreeNode<K extends Key> {
|
|
|
82
82
|
| expand | 展开节点 | `(key: K) => void`,`key` 要展开的节点的key | `undefined` |
|
|
83
83
|
| shrink | 收起节点 | `(key: K) => void`,`key` 要收起的节点的key | `undefined` |
|
|
84
84
|
| getNodes | 返回一级节点 | `() => TreeNode<K>[]` | `TreeNode<K>[]` 一级节点数组 |
|
|
85
|
+
| expandAll | 展开所有节点 | `() => void` | `undefined` |
|
|
85
86
|
|
|
86
87
|
# 事件
|
|
87
88
|
|
|
@@ -89,7 +90,7 @@ export class TreeNode<K extends Key> {
|
|
|
89
90
|
| --- | --- | --- |
|
|
90
91
|
| dragend | 拖拽完成触发 | `DragEndData<K>`,`{srcNode: '源节点', toNode: '目标节点', mode: '插入模式, Before: 插入节点前面, After: 插入节点后面, Inner: 插入节点内部'}` |
|
|
91
92
|
| denydrag | 拖拽不允许拖拽的节点触发 | `TreeNode<K>` |
|
|
92
|
-
| denydrop | 插入到不允许插入的节点时触发 | `TreeNode
|
|
93
|
+
| denydrop | 插入到不允许插入的节点时触发 | `(node: TreeNode[K], srcNode: TreeNode[K], mode: TreeMode)`,`node`: 当前要插入的目的节点, `srcNode`: 当前拖拽的节点,`mode`: 插入模式 |
|
|
93
94
|
|
|
94
95
|
```ts
|
|
95
96
|
import {Key} from 'intact';
|
|
@@ -181,57 +181,56 @@ describe('Tree', () => {
|
|
|
181
181
|
|
|
182
182
|
const [instance, element] = mount(DraggableDemo);
|
|
183
183
|
|
|
184
|
-
instance.set('expandedKeys', ['
|
|
184
|
+
instance.set('expandedKeys', ['guide']);
|
|
185
185
|
await wait(500);
|
|
186
186
|
|
|
187
|
+
let [notAllowed, file1, file2, dir1, file3, dir2, disabled]= element.querySelectorAll('.k-tree-label') as NodeListOf<HTMLElement>;
|
|
187
188
|
// can not drag disabled item
|
|
188
|
-
const disabled = element.querySelector('.k-disabled') as HTMLElement;
|
|
189
|
-
// dispatchEvent(disabled, 'mousedown');
|
|
190
189
|
dispatchEvent(disabled, 'dragstart');
|
|
191
190
|
expect(onDenyDrag.callCount).to.eql(1);
|
|
192
191
|
|
|
193
|
-
let nodes = element.querySelectorAll('.k-tree-label') as NodeListOf<HTMLElement>;
|
|
194
192
|
|
|
195
193
|
// can not drag not-allowed item
|
|
196
|
-
const notAllowed = nodes[2];
|
|
197
|
-
// dispatchEvent(notAllowed, 'mousedown');
|
|
198
194
|
dispatchEvent(notAllowed, 'dragstart');
|
|
199
195
|
expect(onDenyDrag.callCount).to.eql(2);
|
|
200
196
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
197
|
+
await dragInsert(dir1, dir1);
|
|
198
|
+
// drag to self will do nothing
|
|
199
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
200
|
+
expect(onDragEnd.callCount).to.eql(0);
|
|
201
|
+
|
|
202
|
+
await dragInsert(file1, notAllowed);
|
|
203
|
+
// drag to not-allowed item will do nothing
|
|
204
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
205
|
+
expect(onDragEnd.callCount).to.eql(0);
|
|
206
|
+
|
|
207
|
+
await dragInsert(file1, disabled);
|
|
208
|
+
// drag to disabled item will do nothing
|
|
209
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
210
|
+
expect(onDragEnd.callCount).to.eql(0);
|
|
211
|
+
|
|
212
|
+
await dragInsert(file2, file1, 'before');
|
|
213
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
214
|
+
expect(onDragEnd.callCount).to.eql(1);
|
|
215
|
+
expect(instance.get('data')).to.matchSnapshot();
|
|
216
|
+
|
|
217
|
+
await dragInsert(file2, file1, 'after');
|
|
218
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
219
|
+
expect(onDragEnd.callCount).to.eql(2);
|
|
220
|
+
expect(instance.get('data')).to.matchSnapshot();
|
|
221
|
+
|
|
222
|
+
await dragInsert(file1, dir1);
|
|
223
|
+
expect(onDragEnd.callCount).to.eql(3);
|
|
224
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
225
|
+
expect(instance.get('data')).to.matchSnapshot();
|
|
226
|
+
|
|
227
|
+
await dragInsert(dir2, dir1);
|
|
228
|
+
expect(onDragEnd.callCount).to.eql(3);
|
|
229
|
+
expect(onDenyDrag.callCount).to.eql(2);
|
|
230
|
+
|
|
231
|
+
await dragInsert(dir2, file3, 'before');
|
|
232
|
+
expect(onDragEnd.callCount).to.eql(3);
|
|
233
|
+
expect(onDenyDrag.callCount).to.eql(2);
|
|
235
234
|
});
|
|
236
235
|
});
|
|
237
236
|
|
package/components/tree/index.ts
CHANGED
|
@@ -14,9 +14,10 @@ import { useConfigContext } from '../config';
|
|
|
14
14
|
export type {
|
|
15
15
|
Node as TreeNode,
|
|
16
16
|
DataItem as TreeDataItem,
|
|
17
|
-
Mode as TreeMode,
|
|
18
17
|
};
|
|
19
18
|
|
|
19
|
+
export { Mode as TreeMode };
|
|
20
|
+
|
|
20
21
|
export interface TreeProps<K extends Key = Key> {
|
|
21
22
|
data?: DataItem<K>[]
|
|
22
23
|
filter?: Filter<K>
|
|
@@ -32,12 +33,12 @@ export interface TreeProps<K extends Key = Key> {
|
|
|
32
33
|
showLine?: boolean
|
|
33
34
|
draggable?: boolean
|
|
34
35
|
allowDrag?: (node: Node<K>) => boolean
|
|
35
|
-
allowDrop?: (node: Node<K
|
|
36
|
+
allowDrop?: (node: Node<K>, srcNode: Node<K>, mode: Mode) => boolean
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export interface TreeEvents<K extends Key> {
|
|
39
40
|
denydrag: [Node<K>]
|
|
40
|
-
denydrop: [Node<K
|
|
41
|
+
denydrop: [Node<K>, Node<K>, Mode]
|
|
41
42
|
dragend: [DragEndData<K>]
|
|
42
43
|
transitionEnd: []
|
|
43
44
|
}
|
|
@@ -125,6 +126,10 @@ export class Tree<K extends Key = Key> extends Component<TreeProps<K>, TreeEvent
|
|
|
125
126
|
return this.nodes.getNodes() as Node<K>[];
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
public expandAll() {
|
|
130
|
+
this.expanded.expandAll();
|
|
131
|
+
}
|
|
132
|
+
|
|
128
133
|
@bind
|
|
129
134
|
private onClick(node: Node<K>) {
|
|
130
135
|
if (node.data.disabled) return;
|
|
@@ -59,15 +59,15 @@ export function useDraggable() {
|
|
|
59
59
|
mode.set(newMode);
|
|
60
60
|
overKey.set(node.key);
|
|
61
61
|
|
|
62
|
-
// if the node does not allow drop, prevent the dragging
|
|
63
|
-
if (mode.value === Mode.Inner) {
|
|
62
|
+
// if the node does not allow drop, prevent the dragging node from inserting to it
|
|
63
|
+
// if (mode.value === Mode.Inner) {
|
|
64
64
|
const {allowDrop} = instance.get();
|
|
65
|
-
if (node.data.disabled || allowDrop && !allowDrop(node)) {
|
|
66
|
-
instance.trigger('denydrop', node);
|
|
65
|
+
if (node.data.disabled || allowDrop && !allowDrop(node, draggingNode!, newMode)) {
|
|
66
|
+
instance.trigger('denydrop', node, draggingNode!, newMode);
|
|
67
67
|
valid = false;
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
// }
|
|
71
71
|
|
|
72
72
|
valid = true;
|
|
73
73
|
}
|
|
@@ -29,7 +29,7 @@ sidebar: doc
|
|
|
29
29
|
| uncorrelated | 是否让父子`checkbox`选中状态互不关联 | `boolean` | `false` |
|
|
30
30
|
| load | 指定异步加载节点数据的函数,该函数通过`Promise`返回数组来添加子节点数据 | <code>(node: TreeNode<K>) => Proomise<void> | void</code> | `undefined` |
|
|
31
31
|
| showLine | 是否展示`Tree`的对齐线 | `boolean` | `true` |
|
|
32
|
-
| defaultExpandAll | 是否默认展开所有节点 | `boolean` | `
|
|
32
|
+
| defaultExpandAll | 是否默认展开所有节点 (该属性只在首次渲染时起作用,渲染后再更新数据`data`,没有效果) | `boolean` | `false` |
|
|
33
33
|
| checkbox | 是否展示复选框 | `boolean` | `false` |
|
|
34
34
|
| filter | 当支持筛选时,可以自定义筛选规则 | `(keywords: string, data: TreeDataItem<K>) => boolean` | `undefined` |
|
|
35
35
|
| show | 是否展示菜单项 | `boolean` | `false` |
|
|
@@ -74,6 +74,12 @@ type Collision = 'fit' | 'flip' | 'flipfit' | 'none'
|
|
|
74
74
|
import {Children} from 'intact';
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
# 方法
|
|
78
|
+
|
|
79
|
+
| 方法名 | 说明 | 参数 | 返回值 |
|
|
80
|
+
| --- | --- | --- | --- |
|
|
81
|
+
| expandAll | 展开所有节点 | `() => void` | `undefined` |
|
|
82
|
+
|
|
77
83
|
# 事件
|
|
78
84
|
|
|
79
85
|
| 事件名 | 说明 | 参数 |
|
|
@@ -123,11 +123,11 @@ export function makeStyles(k) {
|
|
|
123
123
|
}), "&.", k, "-disabled{.", k, "-colorpicker-color{background:", colorpicker.disabled.bgColor, ";border-color:", colorpicker.disabled.borderColor, ";cursor:", colorpicker.disabled.cursor, ";}}");
|
|
124
124
|
}
|
|
125
125
|
export function makePanelStyles(k) {
|
|
126
|
-
return /*#__PURE__*/css("padding:", colorpicker.panel.padding, ";width:", colorpicker.panel.width, ";.", k, "-colorpicker-saturation{height:", colorpicker.panel.saturationHeight, ";position:relative;overflow:hidden;user-select:none;}.", k, "-colorpicker-white,.", k, "-colorpicker-black{position:absolute;width:100%;height:100%;}.", k, "-colorpicker-white{background:linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));}.", k, "-colorpicker-black{background:linear-gradient(0, #000, rgba(0, 0, 0, 0));}.", k, "-colorpicker-pointer{position:absolute;}.", k, "-colorpicker-circle{width:", colorpicker.panel.circle.width, ";height:", colorpicker.panel.circle.width, ";box-shadow:", colorpicker.panel.circle.boxShadow, ";border-radius:50%;transform:translate(-50%, -50%);}.", k, "-colorpicker-controls{display:flex;margin-top:", colorpicker.panel.gutter, ";}.", k, "-colorpicker-sliders{flex:1;.", k, "-slider{margin-bottom:", colorpicker.panel.gutter, ";}.", k, "-slider-
|
|
126
|
+
return /*#__PURE__*/css("padding:", colorpicker.panel.padding, ";width:", colorpicker.panel.width, ";.", k, "-colorpicker-saturation{height:", colorpicker.panel.saturationHeight, ";position:relative;overflow:hidden;user-select:none;}.", k, "-colorpicker-white,.", k, "-colorpicker-black{position:absolute;width:100%;height:100%;}.", k, "-colorpicker-white{background:linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));}.", k, "-colorpicker-black{background:linear-gradient(0, #000, rgba(0, 0, 0, 0));}.", k, "-colorpicker-pointer{position:absolute;}.", k, "-colorpicker-circle{width:", colorpicker.panel.circle.width, ";height:", colorpicker.panel.circle.width, ";box-shadow:", colorpicker.panel.circle.boxShadow, ";border-radius:50%;transform:translate(-50%, -50%);}.", k, "-colorpicker-controls{display:flex;margin-top:", colorpicker.panel.gutter, ";}.", k, "-colorpicker-sliders{flex:1;.", k, "-slider{margin-bottom:", colorpicker.panel.gutter, ";}.", k, "-slider-track-wrapper,.", k, "-slider-track{height:", colorpicker.slider.height, ";}.", k, "-slider-track-wrapper{cursor:", colorpicker.slider.cursor, ";}.", k, "-slider-track{border-radius:", colorpicker.slider.borderRadius, ";margin:0 calc(", colorpicker.slider.thumb.width, " / 2 + 1px);background-color:transparent;}.", k, "-slider-bar{background:transparent;}.", k, "-slider-thumb{height:", colorpicker.slider.thumb.height, ";width:", colorpicker.slider.thumb.width, ";border:", colorpicker.slider.thumb.border, ";border-radius:", colorpicker.slider.thumb.borderRadius, ";box-shadow:", colorpicker.slider.thumb.boxShadow, ";&:focus,&:hover{transform:", colorpicker.slider.thumb.hover.transform, ";cursor:", colorpicker.slider.thumb.hover.cursor, ";background-color:", colorpicker.slider.thumb.hover.bgColor, ";}}}.", k, "-colorpicker-hue{.", k, "-slider-track-wrapper{background:linear-gradient(90deg, red 0, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red);}}.", k, "-colorpicker-alpha{background-size:contain;}.", k, "-colorpicker-alpha-bg{background-image:url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMElEQVQ4T2N89uzZfwY8QFJSEp80A+OoAcMiDP7//483HTx//hx/Ohg1gIFx6IcBALl+VXknOCvFAAAAAElFTkSuQmCC\");}.", k, "-colorpicker-color-wrapper{width:", colorpicker.color.width, ";height:", colorpicker.color.height, ";border-radius:", colorpicker.color.borderRadius, ";margin-left:", colorpicker.panel.gutter, ";overflow:hidden;}.", k, "-colorpicker-color{height:100%;box-shadow:", colorpicker.color.boxShadow, ";}.", k, "-colorpicker-input.", k, "-small{.", k, "-input-inner{height:", colorpicker.input.height, ";line-height:", colorpicker.input.height, ";padding:", colorpicker.input.padding, ";font-size:", colorpicker.panel.fontSize, ";}}.", k, "-colorpicker-text{text-align:center;font-size:", colorpicker.panel.fontSize, ";padding:", colorpicker.input.textPadding, ";}.", k, "-colorpicker-presets{border-top:", colorpicker.presets.delimiter, ";margin:0 -", colorpicker.panel.padding, ";overflow:hidden;}.", k, "-colorpicker-preset-color-wrapper{float:left;border-radius:", colorpicker.presets.borderRadius, ";cursor:pointer;overflow:hidden;margin:", colorpicker.panel.padding, " 0 0 ", colorpicker.panel.padding, ";}.", k, "-colorpicker-preset-color{width:", colorpicker.presets.width, ";height:", colorpicker.presets.height, ";box-shadow:", colorpicker.presets.boxShadow, ";}.", k, "-colorpicker-drag{cursor:ew-resize;user-select:none;}");
|
|
127
127
|
}
|
|
128
128
|
export function makeAlphaBgColor(_ref, k) {
|
|
129
129
|
var r = _ref.r,
|
|
130
130
|
g = _ref.g,
|
|
131
131
|
b = _ref.b;
|
|
132
|
-
return /*#__PURE__*/css(".", k, "-slider-
|
|
132
|
+
return /*#__PURE__*/css(".", k, "-slider-track-wrapper{background:linear-gradient(to right, rgba(", r, ", ", g, ", ", b, ", 0) 0%, rgb(", r, ", ", g, ", ", b, ") 100%);}");
|
|
133
133
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import BasicDemo from '~/components/copy/demos/basic';
|
|
4
|
-
import { mount, unmount } from '../../test/utils';
|
|
6
|
+
import { mount, unmount, wait } from '../../test/utils';
|
|
7
|
+
import { Tooltip } from '../tooltip';
|
|
8
|
+
import { Component } from 'intact';
|
|
9
|
+
import { Copy } from '.';
|
|
5
10
|
describe('Copy', function () {
|
|
6
11
|
afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
7
12
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -49,4 +54,62 @@ describe('Copy', function () {
|
|
|
49
54
|
}
|
|
50
55
|
}, _callee2, null, [[2, 9]]);
|
|
51
56
|
})));
|
|
57
|
+
it('wrap copy with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
58
|
+
var Demo, _mount2, instance, element, text;
|
|
59
|
+
|
|
60
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
61
|
+
while (1) {
|
|
62
|
+
switch (_context4.prev = _context4.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
65
|
+
_inheritsLoose(Demo, _Component);
|
|
66
|
+
|
|
67
|
+
function Demo() {
|
|
68
|
+
var _context3;
|
|
69
|
+
|
|
70
|
+
var _this;
|
|
71
|
+
|
|
72
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
73
|
+
args[_key] = arguments[_key];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context3 = [this]).call(_context3, args)) || this;
|
|
77
|
+
_this.Tooltip = Tooltip;
|
|
78
|
+
_this.Copy = Copy;
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return Demo;
|
|
83
|
+
}(Component);
|
|
84
|
+
|
|
85
|
+
Demo.template = "\n const { Tooltip, Copy } = this;\n <Tooltip content=\"test\">\n <Copy text=\"test\" />\n </Tooltip>\n ";
|
|
86
|
+
_mount2 = mount(Demo), instance = _mount2[0], element = _mount2[1];
|
|
87
|
+
element.click();
|
|
88
|
+
_context4.next = 6;
|
|
89
|
+
return wait();
|
|
90
|
+
|
|
91
|
+
case 6:
|
|
92
|
+
_context4.prev = 6;
|
|
93
|
+
_context4.next = 9;
|
|
94
|
+
return navigator.clipboard.readText();
|
|
95
|
+
|
|
96
|
+
case 9:
|
|
97
|
+
text = _context4.sent;
|
|
98
|
+
expect(text).to.eql('test');
|
|
99
|
+
_context4.next = 16;
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case 13:
|
|
103
|
+
_context4.prev = 13;
|
|
104
|
+
_context4.t0 = _context4["catch"](6);
|
|
105
|
+
// Read permisson denied
|
|
106
|
+
console.log(_context4.t0);
|
|
107
|
+
|
|
108
|
+
case 16:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context4.stop();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, _callee3, null, [[6, 13]]);
|
|
114
|
+
})));
|
|
52
115
|
});
|
|
@@ -8,7 +8,7 @@ export function useCopy() {
|
|
|
8
8
|
var success = useState(false);
|
|
9
9
|
var timer;
|
|
10
10
|
return {
|
|
11
|
-
startCopy: function startCopy() {
|
|
11
|
+
startCopy: function startCopy(e) {
|
|
12
12
|
var _instance$get = instance.get(),
|
|
13
13
|
text = _instance$get.text,
|
|
14
14
|
showMessage = _instance$get.showMessage;
|
|
@@ -30,6 +30,8 @@ export function useCopy() {
|
|
|
30
30
|
success.set(false);
|
|
31
31
|
instance.trigger('error');
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
instance.trigger('click', e);
|
|
33
35
|
},
|
|
34
36
|
success: success
|
|
35
37
|
};
|
|
@@ -57,15 +59,19 @@ function createFakeElement(value) {
|
|
|
57
59
|
|
|
58
60
|
function clipboardCopy(text) {
|
|
59
61
|
try {
|
|
60
|
-
navigator.clipboard
|
|
61
|
-
|
|
62
|
+
if (navigator.clipboard
|
|
63
|
+
/* && window.isSecureContext */
|
|
64
|
+
) {
|
|
65
|
+
navigator.clipboard.writeText(text);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
62
68
|
} catch (e) {
|
|
63
69
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
70
|
console.log(e);
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
72
|
}
|
|
73
|
+
|
|
74
|
+
return false;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
function commandCopy(text) {
|
|
@@ -142,7 +142,7 @@ export var BaseDialog = /*#__PURE__*/function (_Component) {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
_proto.onClickWrapper = function onClickWrapper(e) {
|
|
145
|
-
if (this.get('closable')) {
|
|
145
|
+
if (this.get('closable') && e.target === this.overlayRef.value) {
|
|
146
146
|
this.terminate();
|
|
147
147
|
}
|
|
148
148
|
};
|
|
@@ -123,15 +123,15 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
123
123
|
|
|
124
124
|
return _$cc(Portal, {
|
|
125
125
|
'container': container,
|
|
126
|
-
'children': _$ce(2, 'div',
|
|
126
|
+
'children': _$ce(2, 'div', overlay ? _$cc(Transition, {
|
|
127
127
|
'key': 'overlay',
|
|
128
128
|
'show': overlay ? value : false,
|
|
129
129
|
'appear': value,
|
|
130
130
|
'name': 'k-fade',
|
|
131
|
-
'children': _$ce(2, 'div',
|
|
131
|
+
'children': _$ce(2, 'div', dialog, 0, _$cn(k + "-dialog-overlay"), {
|
|
132
132
|
'ev-click': this.onClickWrapper
|
|
133
133
|
}, null, this.overlayRef)
|
|
134
|
-
}, 'overlay') :
|
|
134
|
+
}, 'overlay') : dialog, 0, _$cn((_$cn2 = {}, _$cn2[k + "-dialog-wrapper"] = true, _$cn2[k + "-open"] = value, _$cn2[makeWrapperStyles(k)] = true, _$cn2)))
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
;
|
|
@@ -92,7 +92,7 @@ export function makeDialogStyles(k) {
|
|
|
92
92
|
export function makeWrapperStyles(k) {
|
|
93
93
|
//.${k}-fade-leave-active will add position absolute to the styles
|
|
94
94
|
// so we must set fixed with important to .${k}-dialog-overlay
|
|
95
|
-
return /*#__PURE__*/css("position:absolute;z-index:", theme.maxZIndex, ";top:0;left:0;width:100%;.", k, "-dialog-overlay{position:fixed!important;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, .5);}");
|
|
95
|
+
return /*#__PURE__*/css("position:absolute;z-index:", theme.maxZIndex, ";top:0;left:0;width:100%;.", k, "-dialog-overlay{position:fixed!important;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, .5);overflow:auto;}");
|
|
96
96
|
}
|
|
97
97
|
export function makeAlertStyles(k) {
|
|
98
98
|
var _context2;
|
|
@@ -4,6 +4,7 @@ import { getRestProps } from '../utils';
|
|
|
4
4
|
import { Input } from '../input';
|
|
5
5
|
import { Icon } from '../icon';
|
|
6
6
|
import { makeStyles } from './styles';
|
|
7
|
+
import { Tooltip } from '../tooltip';
|
|
7
8
|
export default function ($props, $blocks, $__proto__) {
|
|
8
9
|
var _classNameObj;
|
|
9
10
|
|
|
@@ -25,11 +26,13 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
25
26
|
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-editable"] = true, _classNameObj[k + "-editing"] = editing, _classNameObj[k + "-disabled"] = disabled, _classNameObj[k + "-invalid"] = invalid, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
26
27
|
return _$cv('div', _extends({}, getRestProps(this), {
|
|
27
28
|
'className': _$cn(classNameObj)
|
|
28
|
-
}), [!disabled && !editing ? _$cc(
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
}), [!disabled && !editing ? _$cc(Tooltip, {
|
|
30
|
+
'content': tip,
|
|
31
|
+
'children': _$cc(Icon, {
|
|
32
|
+
'className': _$cn(k + "-icon-edit " + k + "-editable-icon"),
|
|
33
|
+
'ev-click': this.edit,
|
|
34
|
+
'hoverable': true
|
|
35
|
+
})
|
|
33
36
|
}) : undefined, _$ce(2, 'div', !editing ? children : _$cc(Input, {
|
|
34
37
|
'size': 'small',
|
|
35
38
|
'defaultValue': value,
|