@mirai/ui 1.0.92 → 1.0.93
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.
|
@@ -54,7 +54,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
54
54
|
right = position.right,
|
|
55
55
|
_position$top = position.top,
|
|
56
56
|
top = _position$top === void 0 ? propTop : _position$top;
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(_primitives.Layer, {
|
|
57
|
+
return text || Template ? /*#__PURE__*/_react.default.createElement(_primitives.Layer, {
|
|
58
58
|
centered: true,
|
|
59
59
|
forceRender: false,
|
|
60
60
|
visible: visible,
|
|
@@ -63,17 +63,15 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
63
63
|
onPosition: setPosition,
|
|
64
64
|
"data-testid": testId
|
|
65
65
|
}, _react.default.Children.map(children, function (child, index) {
|
|
66
|
-
return /*#__PURE__*/_react.default.cloneElement(child, _objectSpread(_objectSpread(
|
|
66
|
+
return /*#__PURE__*/_react.default.cloneElement(child, _objectSpread(_objectSpread({
|
|
67
67
|
key: index
|
|
68
|
-
},
|
|
69
|
-
onClick: function
|
|
68
|
+
}, child.props), {}, {
|
|
69
|
+
onClick: pressable ? function () {
|
|
70
70
|
return setVisible(!visible);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
onMouseEnter: function onMouseEnter() {
|
|
71
|
+
} : undefined,
|
|
72
|
+
onMouseEnter: !pressable ? function () {
|
|
74
73
|
return setVisible(true);
|
|
75
|
-
}
|
|
76
|
-
}), {}, {
|
|
74
|
+
} : undefined,
|
|
77
75
|
onMouseLeave: function onMouseLeave() {
|
|
78
76
|
return setVisible(false);
|
|
79
77
|
},
|
|
@@ -86,7 +84,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
86
84
|
bold: true,
|
|
87
85
|
small: true,
|
|
88
86
|
className: _TooltipModule.default.text
|
|
89
|
-
}, text))));
|
|
87
|
+
}, text)))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
90
88
|
};
|
|
91
89
|
exports.Tooltip = Tooltip;
|
|
92
90
|
Tooltip.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["Tooltip","children","pressable","Template","text","timestamp","propTop","top","visible","propVisible","others","useState","setVisible","position","setPosition","testId","rest","left","right","React","Children","map","child","index","cloneElement","
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["Tooltip","children","pressable","Template","text","timestamp","propTop","top","visible","propVisible","others","useState","setVisible","position","setPosition","testId","rest","left","right","React","Children","map","child","index","cloneElement","key","props","onClick","undefined","onMouseEnter","onMouseLeave","className","styles","style","dispatcher","tooltip","bottom","propTypes","PropTypes","node","isRequired","bool","oneOfType","func","string","number"],"sources":["../../../src/components/Tooltip/Tooltip.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { Layer, LayerContent, Text, View } from '../../primitives';\nimport style from './Tooltip.module.css';\n\nconst Tooltip = ({\n children,\n pressable = false,\n Template,\n text,\n timestamp,\n top: propTop,\n visible: propVisible = false,\n ...others\n}) => {\n const [visible, setVisible] = useState(propVisible);\n const [position, setPosition] = useState({});\n\n const { ['data-testid']: testId, ...rest } = others;\n\n const { left, right, top = propTop } = position;\n\n return text || Template ? (\n <Layer\n centered\n forceRender={false}\n visible={visible}\n timestamp={timestamp}\n top={top}\n onPosition={setPosition}\n data-testid={testId}\n >\n {React.Children.map(children, (child, index) =>\n React.cloneElement(child, {\n key: index,\n ...child.props,\n onClick: pressable ? () => setVisible(!visible) : undefined,\n onMouseEnter: !pressable ? () => setVisible(true) : undefined,\n onMouseLeave: () => setVisible(false),\n className: styles(style.dispatcher, child.props.className),\n 'data-testid': testId ? `${testId}-dispatcher` : undefined,\n }),\n )}\n\n <LayerContent>\n <View\n {...rest}\n className={styles(\n style.tooltip,\n left && style.left,\n right && style.right,\n top ? style.top : style.bottom,\n rest.className,\n )}\n >\n {Template ? (\n <Template />\n ) : (\n <Text bold small className={style.text}>\n {text}\n </Text>\n )}\n </View>\n </LayerContent>\n </Layer>\n ) : (\n <>{children}</>\n );\n};\n\nTooltip.propTypes = {\n children: PropTypes.node.isRequired,\n pressable: PropTypes.bool,\n Template: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n text: PropTypes.string,\n timestamp: PropTypes.number,\n top: PropTypes.bool,\n visible: PropTypes.bool,\n};\n\nexport { Tooltip };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAyC;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEzC,IAAMA,OAAO,GAAG,SAAVA,OAAO,OASP;EAAA,IARJC,QAAQ,QAARA,QAAQ;IAAA,sBACRC,SAAS;IAATA,SAAS,+BAAG,KAAK;IACjBC,QAAQ,QAARA,QAAQ;IACRC,IAAI,QAAJA,IAAI;IACJC,SAAS,QAATA,SAAS;IACJC,OAAO,QAAZC,GAAG;IAAA,oBACHC,OAAO;IAAEC,WAAW,6BAAG,KAAK;IACzBC,MAAM;EAET,gBAA8B,IAAAC,eAAQ,EAACF,WAAW,CAAC;IAAA;IAA5CD,OAAO;IAAEI,UAAU;EAC1B,iBAAgC,IAAAD,eAAQ,EAAC,CAAC,CAAC,CAAC;IAAA;IAArCE,QAAQ;IAAEC,WAAW;EAE5B,IAAyBC,MAAM,GAAcL,MAAM,CAA1C,aAAa;IAAcM,IAAI,4BAAKN,MAAM;EAEnD,IAAQO,IAAI,GAA2BJ,QAAQ,CAAvCI,IAAI;IAAEC,KAAK,GAAoBL,QAAQ,CAAjCK,KAAK;IAAA,gBAAoBL,QAAQ,CAA1BN,GAAG;IAAHA,GAAG,8BAAGD,OAAO;EAElC,OAAOF,IAAI,IAAID,QAAQ,gBACrB,6BAAC,iBAAK;IACJ,QAAQ;IACR,WAAW,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CACZ;AACH,CAAC;AAAC;AAEFD,OAAO,CAACqC,SAAS,GAAG;EAClBpC,QAAQ,EAAEqC,kBAAS,CAACC,IAAI,CAACC,UAAU;EACnCtC,SAAS,EAAEoC,kBAAS,CAACG,IAAI;EACzBtC,QAAQ,EAAEmC,kBAAS,CAACI,SAAS,CAAC,CAACJ,kBAAS,CAACC,IAAI,EAAED,kBAAS,CAACK,IAAI,CAAC,CAAC;EAC/DvC,IAAI,EAAEkC,kBAAS,CAACM,MAAM;EACtBvC,SAAS,EAAEiC,kBAAS,CAACO,MAAM;EAC3BtC,GAAG,EAAE+B,kBAAS,CAACG,IAAI;EACnBjC,OAAO,EAAE8B,kBAAS,CAACG;AACrB,CAAC"}
|
|
@@ -62,13 +62,11 @@ exports[` 4`] = `
|
|
|
62
62
|
|
|
63
63
|
exports[`component:<Tooltip> inherit:className 1`] = `
|
|
64
64
|
<DocumentFragment>
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
</button>
|
|
71
|
-
</span>
|
|
65
|
+
<button
|
|
66
|
+
class="pressable button"
|
|
67
|
+
>
|
|
68
|
+
Action
|
|
69
|
+
</button>
|
|
72
70
|
</DocumentFragment>
|
|
73
71
|
`;
|
|
74
72
|
|
|
@@ -124,37 +122,21 @@ exports[`component:<Tooltip> prop:text 1`] = `
|
|
|
124
122
|
|
|
125
123
|
exports[`component:<Tooltip> prop:top 1`] = `
|
|
126
124
|
<DocumentFragment>
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
class="pressable button dispatcher"
|
|
130
|
-
>
|
|
131
|
-
Action
|
|
132
|
-
</button>
|
|
133
|
-
</span>
|
|
134
|
-
<div
|
|
135
|
-
class="layer"
|
|
136
|
-
style="left: 0px; top: 0px;"
|
|
125
|
+
<button
|
|
126
|
+
class="pressable button"
|
|
137
127
|
>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
>
|
|
141
|
-
<span
|
|
142
|
-
class="text bold small text"
|
|
143
|
-
/>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
128
|
+
Action
|
|
129
|
+
</button>
|
|
146
130
|
</DocumentFragment>
|
|
147
131
|
`;
|
|
148
132
|
|
|
149
133
|
exports[`component:<Tooltip> renders 1`] = `
|
|
150
134
|
<DocumentFragment>
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
</button>
|
|
157
|
-
</span>
|
|
135
|
+
<button
|
|
136
|
+
class="pressable button"
|
|
137
|
+
>
|
|
138
|
+
Action
|
|
139
|
+
</button>
|
|
158
140
|
</DocumentFragment>
|
|
159
141
|
`;
|
|
160
142
|
|