plain-design 1.0.0-beta.145 → 1.0.0-beta.146
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {computed, designComponent, getComponentCls, iHTMLElement, iMouseEvent, PropType, useClasses, useStyles} from "@peryl/react-compose";
|
|
1
|
+
import {computed, designComponent, getComponentCls, iHTMLElement, iMouseEvent, PropType, useClasses, useRefs, useStyles} from "@peryl/react-compose";
|
|
2
2
|
import {ThemeSize, ThemeStatus, useStyle} from "../../uses/useStyle";
|
|
3
3
|
import {iTagColor, TagColor} from "./tag.utils";
|
|
4
4
|
import Icon from "../Icon";
|
|
@@ -24,6 +24,8 @@ export const Tag = designComponent({
|
|
|
24
24
|
},
|
|
25
25
|
setup({ props, event: { emit }, slots }) {
|
|
26
26
|
|
|
27
|
+
const { refs, onRef } = useRefs({ closeWrapper: {} as typeof HTMLSpanElement });
|
|
28
|
+
|
|
27
29
|
const status = Object.keys(ThemeStatus);
|
|
28
30
|
|
|
29
31
|
const colors = computed((): iTagColor => {
|
|
@@ -60,7 +62,10 @@ export const Tag = designComponent({
|
|
|
60
62
|
|
|
61
63
|
const handler = {
|
|
62
64
|
onClick: (e: iMouseEvent) => {
|
|
63
|
-
if (
|
|
65
|
+
if (refs.closeWrapper == e.target || (!!refs.closeWrapper && refs.closeWrapper.contains(e.target as HTMLElement))) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
emit.onClick(e);
|
|
64
69
|
},
|
|
65
70
|
onClose: (e: iMouseEvent) => emit.onClose(e),
|
|
66
71
|
};
|
|
@@ -70,7 +75,7 @@ export const Tag = designComponent({
|
|
|
70
75
|
{!!props.icon && <Icon icon={props.icon}/>}
|
|
71
76
|
{!!props.loading && <Loading type="beta"/>}
|
|
72
77
|
<span>{slots.default(props.label as any)}</span>
|
|
73
|
-
{!!props.closeable && <Icon icon="pi-close" onClick={handler.onClose}
|
|
78
|
+
{!!props.closeable && <span ref={onRef.closeWrapper} className="tag-close-wrapper"><Icon icon="pi-close" onClick={handler.onClose}/></span>}
|
|
74
79
|
</span>
|
|
75
80
|
);
|
|
76
81
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
padding: 0 4px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.#{componentName(loading)}, .#{componentName(icon)} {
|
|
17
|
+
& > .#{componentName(loading)}, & > .#{componentName(icon)}, & > .tag-close-wrapper {
|
|
18
18
|
&:last-child {
|
|
19
19
|
cursor: pointer;
|
|
20
20
|
margin-left: 4px;
|
|
@@ -24,4 +24,13 @@
|
|
|
24
24
|
margin-right: 4px !important;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
.tag-close-wrapper {
|
|
29
|
+
vertical-align: middle;
|
|
30
|
+
height: 1em;
|
|
31
|
+
width: 1em;
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
27
36
|
}
|