@mirai/ui 1.0.7 → 1.0.11
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/README.md +79 -17
- package/build/components/Button/Button.js.map +1 -1
- package/build/components/Button/Button.module.css +20 -13
- package/build/components/Button/index.js.map +1 -1
- package/build/components/Calendar/Calendar.Month.js.map +1 -1
- package/build/components/Calendar/Calendar.Week.js.map +1 -1
- package/build/components/Calendar/Calendar.Weekdays.js.map +1 -1
- package/build/components/Calendar/Calendar.constants.js.map +1 -1
- package/build/components/Calendar/Calendar.js.map +1 -1
- package/build/components/Calendar/helpers/getFirstDateOfMonth.js.map +1 -1
- package/build/components/Calendar/helpers/getFirstDateOfWeek.js.map +1 -1
- package/build/components/Calendar/helpers/getHeader.js.map +1 -1
- package/build/components/Calendar/helpers/getToday.js.map +1 -1
- package/build/components/Calendar/helpers/getWeekNumber.js.map +1 -1
- package/build/components/Calendar/helpers/getWeekdays.js.map +1 -1
- package/build/components/Calendar/helpers/index.js.map +1 -1
- package/build/components/Calendar/helpers/isJest.js.map +1 -1
- package/build/components/Calendar/index.js.map +1 -1
- package/build/components/Form/Form.js.map +1 -1
- package/build/components/Form/helpers/getChildrenErrors.js.map +1 -1
- package/build/components/Form/helpers/getChildrenValues.js.map +1 -1
- package/build/components/Form/helpers/getField.js.map +1 -1
- package/build/components/Form/helpers/groupState.js.map +1 -1
- package/build/components/Form/helpers/index.js.map +1 -1
- package/build/components/Form/index.js.map +1 -1
- package/build/components/InputNumber/InputNumber.js +10 -8
- package/build/components/InputNumber/InputNumber.js.map +1 -1
- package/build/components/InputNumber/InputNumber.module.css +14 -2
- package/build/components/InputNumber/__tests__/__snapshots__/InputNumber.test.js.snap +78 -1
- package/build/components/InputNumber/index.js.map +1 -1
- package/build/components/InputOption/InputOption.constants.js.map +1 -1
- package/build/components/InputOption/InputOption.js +1 -1
- package/build/components/InputOption/InputOption.js.map +1 -1
- package/build/components/InputOption/InputOption.module.css +6 -1
- package/build/components/InputOption/index.js.map +1 -1
- package/build/components/InputSelect/InputSelect.js +4 -4
- package/build/components/InputSelect/InputSelect.js.map +1 -1
- package/build/components/InputSelect/__tests__/__snapshots__/InputSelect.test.js.snap +49 -49
- package/build/components/InputSelect/index.js.map +1 -1
- package/build/components/InputText/InputText.js +3 -3
- package/build/components/InputText/InputText.js.map +1 -1
- package/build/components/InputText/InputText.module.css +43 -25
- package/build/components/InputText/__tests__/__snapshots__/InputText.test.js.snap +1 -1
- package/build/components/InputText/index.js.map +1 -1
- package/build/components/Menu/Menu.Option.js +42 -0
- package/build/components/Menu/Menu.Option.js.map +1 -0
- package/build/components/Menu/Menu.js +52 -0
- package/build/components/Menu/Menu.js.map +1 -0
- package/build/components/Menu/Menu.module.css +50 -0
- package/build/components/Menu/__tests__/__snapshots__/Menu.test.jsx.snap +178 -0
- package/build/components/Menu/index.js +19 -0
- package/build/components/Menu/index.js.map +1 -0
- package/build/components/Modal/Modal.js.map +1 -1
- package/build/components/Modal/Modal.module.css +3 -2
- package/build/components/Modal/index.js.map +1 -1
- package/build/components/Table/Table.Row.js.map +1 -1
- package/build/components/Table/Table.js.map +1 -1
- package/build/components/Table/Table.module.css +27 -25
- package/build/components/Table/helpers/index.js.map +1 -1
- package/build/components/Table/helpers/select.js.map +1 -1
- package/build/components/Table/index.js.map +1 -1
- package/build/components/Tooltip/Tooltip.js +65 -0
- package/build/components/Tooltip/Tooltip.js.map +1 -0
- package/build/components/Tooltip/Tooltip.module.css +26 -0
- package/build/components/Tooltip/__tests__/__snapshots__/Tooltip.test.jsx.snap +117 -0
- package/build/components/Tooltip/index.js +19 -0
- package/build/components/Tooltip/index.js.map +1 -0
- package/build/components/index.js +26 -0
- package/build/components/index.js.map +1 -1
- package/build/helpers/getInputErrors.js.map +1 -1
- package/build/helpers/index.js.map +1 -1
- package/build/helpers/isValidDate.js.map +1 -1
- package/build/helpers/isValidEmail.js.map +1 -1
- package/build/helpers/isValidPhone.js.map +1 -1
- package/build/helpers/styles.js.map +1 -1
- package/build/hooks/helpers/getNavigator.js.map +1 -1
- package/build/hooks/helpers/getResolution.js.map +1 -1
- package/build/hooks/helpers/index.js.map +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/useDevice.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/primitives/Checkbox/Checkbox.js +5 -3
- package/build/primitives/Checkbox/Checkbox.js.map +1 -1
- package/build/primitives/Checkbox/Checkbox.module.css +6 -6
- package/build/primitives/Checkbox/index.js.map +1 -1
- package/build/primitives/Icon/Icon.constants.js +1 -0
- package/build/primitives/Icon/Icon.constants.js.map +1 -1
- package/build/primitives/Icon/Icon.js.map +1 -1
- package/build/primitives/Icon/index.js.map +1 -1
- package/build/primitives/Input/Input.js.map +1 -1
- package/build/primitives/Input/Input.module.css +13 -5
- package/build/primitives/Input/helpers/index.js.map +1 -1
- package/build/primitives/Input/helpers/parseValue.js.map +1 -1
- package/build/primitives/Input/index.js.map +1 -1
- package/build/primitives/Layer/Layer.js +32 -34
- package/build/primitives/Layer/Layer.js.map +1 -1
- package/build/primitives/Layer/Layer.module.css +1 -1
- package/build/primitives/Layer/LayerContent.js +1 -1
- package/build/primitives/Layer/LayerContent.js.map +1 -1
- package/build/primitives/Layer/__tests__/__snapshots__/Layer.test.js.snap +51 -17
- package/build/primitives/Layer/helpers/getElementLayout.js.map +1 -1
- package/build/primitives/Layer/helpers/getLayerPosition.js +2 -0
- package/build/primitives/Layer/helpers/getLayerPosition.js.map +1 -1
- package/build/primitives/Layer/helpers/index.js.map +1 -1
- package/build/primitives/Layer/index.js.map +1 -1
- package/build/primitives/Pressable/Pressable.constants.js.map +1 -1
- package/build/primitives/Pressable/Pressable.js.map +1 -1
- package/build/primitives/Pressable/index.js.map +1 -1
- package/build/primitives/Radio/Radio.js +5 -3
- package/build/primitives/Radio/Radio.js.map +1 -1
- package/build/primitives/Radio/Radio.module.css +10 -9
- package/build/primitives/Radio/__tests__/__snapshots__/Radio.test.js.snap +0 -1
- package/build/primitives/Radio/index.js.map +1 -1
- package/build/primitives/ScrollView/ScrollView.js.map +1 -1
- package/build/primitives/ScrollView/ScrollView.module.css +1 -1
- package/build/primitives/ScrollView/index.js.map +1 -1
- package/build/primitives/Select/Select.js +1 -1
- package/build/primitives/Select/Select.js.map +1 -1
- package/build/primitives/Select/Select.module.css +9 -7
- package/build/primitives/Select/__tests__/__snapshots__/Select.test.js.snap +25 -25
- package/build/primitives/Select/index.js.map +1 -1
- package/build/primitives/Switch/Switch.js +2 -4
- package/build/primitives/Switch/Switch.js.map +1 -1
- package/build/primitives/Switch/Switch.module.css +27 -19
- package/build/primitives/Switch/__tests__/__snapshots__/Switch.test.js.snap +0 -5
- package/build/primitives/Switch/index.js +1 -1
- package/build/primitives/Switch/index.js.map +1 -1
- package/build/primitives/Text/Text.js +2 -3
- package/build/primitives/Text/Text.js.map +1 -1
- package/build/primitives/Text/Text.module.css +1 -4
- package/build/primitives/Text/__tests__/__snapshots__/Text.test.js.snap +0 -10
- package/build/primitives/Text/index.js.map +1 -1
- package/build/primitives/View/View.js.map +1 -1
- package/build/primitives/View/index.js.map +1 -1
- package/build/primitives/index.js.map +1 -1
- package/build/theme/default.theme.css +17 -7
- package/build/theme/helpers/camelcase.js.map +1 -1
- package/build/theme/helpers/index.js.map +1 -1
- package/build/theme/index.js.map +1 -1
- package/build/theme/theme.js.map +1 -1
- package/package.json +12 -5
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--mirai-ui-menu-base: var(--mirai-ui-base);
|
|
3
|
+
--mirai-ui-menu-border-radius: var(--mirai-ui-border-radius);
|
|
4
|
+
--mirai-ui-menu-min-width: 200px;
|
|
5
|
+
--mirai-ui-menu-shadow: 0 1px calc(var(--mirai-ui-space-XS) / 2) var(--mirai-ui-lighten);
|
|
6
|
+
--mirai-ui-menu-option-padding: var(--mirai-ui-space-M);
|
|
7
|
+
--mirai-ui-menu-option-disabled: var(--mirai-ui-disabled);
|
|
8
|
+
--mirai-ui-menu-option-hover: var(--mirai-ui-accent-lighten);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.menu {
|
|
12
|
+
background-color: var(--mirai-ui-menu-base);
|
|
13
|
+
border-radius: var(--mirai-ui-menu-border-radius);
|
|
14
|
+
box-shadow: var(--mirai-ui-menu-shadow);
|
|
15
|
+
min-width: var(--mirai-ui-menu-min-width);
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.menu .option {
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
padding: var(--mirai-ui-menu-option-padding);
|
|
24
|
+
align-items: center;
|
|
25
|
+
flex: 1;
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.menu .option:hover:not(.disabled) {
|
|
30
|
+
background-color: var(--mirai-ui-menu-option-hover);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.menu .icon {
|
|
34
|
+
margin-right: var(--mirai-ui-menu-option-padding);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.menu .label {
|
|
38
|
+
flex: 1;
|
|
39
|
+
text-align: left;
|
|
40
|
+
padding-right: var(--mirai-ui-menu-option-padding);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.menu .divider {
|
|
44
|
+
box-shadow: inset 0 -1px var(--mirai-ui-menu-option-disabled);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.menu .disabled {
|
|
48
|
+
color: var(--mirai-ui-menu-option-disabled);
|
|
49
|
+
cursor: default;
|
|
50
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`component:<Menu> inherit:className 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<span />
|
|
6
|
+
</DocumentFragment>
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`component:<Menu> renders 1`] = `
|
|
10
|
+
<DocumentFragment>
|
|
11
|
+
<span />
|
|
12
|
+
</DocumentFragment>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`component:<Menu> testID 1`] = `
|
|
16
|
+
<DocumentFragment>
|
|
17
|
+
<span
|
|
18
|
+
data-testid="mirai"
|
|
19
|
+
/>
|
|
20
|
+
</DocumentFragment>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
exports[`component:<Menu> w/ Template 1`] = `
|
|
24
|
+
<DocumentFragment>
|
|
25
|
+
<span>
|
|
26
|
+
<button
|
|
27
|
+
class="pressable button"
|
|
28
|
+
>
|
|
29
|
+
Action
|
|
30
|
+
</button>
|
|
31
|
+
</span>
|
|
32
|
+
</DocumentFragment>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`component:<Menu> w/ children 1`] = `
|
|
36
|
+
<DocumentFragment>
|
|
37
|
+
<span>
|
|
38
|
+
<button
|
|
39
|
+
class="pressable button"
|
|
40
|
+
>
|
|
41
|
+
Action
|
|
42
|
+
</button>
|
|
43
|
+
</span>
|
|
44
|
+
</DocumentFragment>
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`component:<Menu> w/ options & visible 1`] = `
|
|
48
|
+
<DocumentFragment>
|
|
49
|
+
<span>
|
|
50
|
+
<button
|
|
51
|
+
class="pressable button"
|
|
52
|
+
>
|
|
53
|
+
Action
|
|
54
|
+
</button>
|
|
55
|
+
</span>
|
|
56
|
+
<span
|
|
57
|
+
class="layer menu visible"
|
|
58
|
+
style="left: 0px; top: 0px;"
|
|
59
|
+
>
|
|
60
|
+
<div
|
|
61
|
+
class="pressable option"
|
|
62
|
+
value="one"
|
|
63
|
+
>
|
|
64
|
+
<span
|
|
65
|
+
class="icon icon"
|
|
66
|
+
>
|
|
67
|
+
<svg
|
|
68
|
+
fill="none"
|
|
69
|
+
height="1em"
|
|
70
|
+
stroke="currentColor"
|
|
71
|
+
stroke-linecap="round"
|
|
72
|
+
stroke-linejoin="round"
|
|
73
|
+
stroke-width="2"
|
|
74
|
+
viewBox="0 0 24 24"
|
|
75
|
+
width="1em"
|
|
76
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
77
|
+
>
|
|
78
|
+
<line
|
|
79
|
+
x1="12"
|
|
80
|
+
x2="12"
|
|
81
|
+
y1="5"
|
|
82
|
+
y2="19"
|
|
83
|
+
/>
|
|
84
|
+
<line
|
|
85
|
+
x1="5"
|
|
86
|
+
x2="19"
|
|
87
|
+
y1="12"
|
|
88
|
+
y2="12"
|
|
89
|
+
/>
|
|
90
|
+
</svg>
|
|
91
|
+
</span>
|
|
92
|
+
<span
|
|
93
|
+
class="text paragraph label"
|
|
94
|
+
>
|
|
95
|
+
Item 1
|
|
96
|
+
</span>
|
|
97
|
+
</div>
|
|
98
|
+
<div
|
|
99
|
+
class="pressable option disabled"
|
|
100
|
+
value="two"
|
|
101
|
+
>
|
|
102
|
+
<span
|
|
103
|
+
class="icon icon disabled"
|
|
104
|
+
>
|
|
105
|
+
<svg
|
|
106
|
+
fill="none"
|
|
107
|
+
height="1em"
|
|
108
|
+
stroke="currentColor"
|
|
109
|
+
stroke-linecap="round"
|
|
110
|
+
stroke-linejoin="round"
|
|
111
|
+
stroke-width="2"
|
|
112
|
+
viewBox="0 0 24 24"
|
|
113
|
+
width="1em"
|
|
114
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
115
|
+
>
|
|
116
|
+
<line
|
|
117
|
+
x1="12"
|
|
118
|
+
x2="12"
|
|
119
|
+
y1="5"
|
|
120
|
+
y2="19"
|
|
121
|
+
/>
|
|
122
|
+
<line
|
|
123
|
+
x1="5"
|
|
124
|
+
x2="19"
|
|
125
|
+
y1="12"
|
|
126
|
+
y2="12"
|
|
127
|
+
/>
|
|
128
|
+
</svg>
|
|
129
|
+
</span>
|
|
130
|
+
<span
|
|
131
|
+
class="text paragraph label disabled"
|
|
132
|
+
>
|
|
133
|
+
Item 2
|
|
134
|
+
</span>
|
|
135
|
+
</div>
|
|
136
|
+
<div
|
|
137
|
+
class="pressable option divider"
|
|
138
|
+
value="three"
|
|
139
|
+
>
|
|
140
|
+
<span
|
|
141
|
+
class="icon icon"
|
|
142
|
+
/>
|
|
143
|
+
<span
|
|
144
|
+
class="text paragraph label"
|
|
145
|
+
>
|
|
146
|
+
Item 3
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
<div
|
|
150
|
+
class="pressable option"
|
|
151
|
+
value="four"
|
|
152
|
+
>
|
|
153
|
+
<span
|
|
154
|
+
class="text paragraph label"
|
|
155
|
+
>
|
|
156
|
+
Item 4
|
|
157
|
+
</span>
|
|
158
|
+
<button
|
|
159
|
+
class="pressable button small"
|
|
160
|
+
>
|
|
161
|
+
Add
|
|
162
|
+
</button>
|
|
163
|
+
</div>
|
|
164
|
+
</span>
|
|
165
|
+
</DocumentFragment>
|
|
166
|
+
`;
|
|
167
|
+
|
|
168
|
+
exports[`component:<Menu> w/ options 1`] = `
|
|
169
|
+
<DocumentFragment>
|
|
170
|
+
<span>
|
|
171
|
+
<button
|
|
172
|
+
class="pressable button"
|
|
173
|
+
>
|
|
174
|
+
Action
|
|
175
|
+
</button>
|
|
176
|
+
</span>
|
|
177
|
+
</DocumentFragment>
|
|
178
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _Menu = require("./Menu");
|
|
8
|
+
|
|
9
|
+
Object.keys(_Menu).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _Menu[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _Menu[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Menu/index.js"],"sourcesContent":["export * from './Menu';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Modal.js","names":["Modal","children","visible","onClose","others","isDesktop","style","overflow","modal","className","pressable","icon","displayName"],"sources":["../../../src/components/Modal/Modal.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { useDevice } from '../../hooks';\nimport { Icon, Pressable, View } from '../../primitives';\nimport style from './Modal.module.css';\n\nconst Modal = ({ children, visible, onClose, ...others }) => {\n const { isDesktop } = useDevice();\n\n return (\n <View row className={styles(style.overflow, visible && style.visible)}>\n <View {...others} fit className={styles(style.modal, visible && style.visible, others.className)}>\n <>\n {onClose && (\n <Pressable className={style.pressable} onPress={onClose}>\n <Icon name={isDesktop ? 'Close' : 'CloseArrow'} className={style.icon} />\n </Pressable>\n )}\n {children}\n </>\n </View>\n </View>\n );\n};\n\nModal.displayName = 'Component:Modal';\n\nModal.propTypes = {\n children: PropTypes.node,\n visible: PropTypes.bool,\n onClose: PropTypes.func,\n};\n\nexport { Modal };\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,OAA+C;EAAA,IAA5CC,QAA4C,QAA5CA,QAA4C;EAAA,IAAlCC,OAAkC,QAAlCA,OAAkC;EAAA,IAAzBC,OAAyB,QAAzBA,OAAyB;EAAA,IAAbC,MAAa;;EAC3D,iBAAsB,uBAAtB;EAAA,IAAQC,SAAR,cAAQA,SAAR;;EAEA,oBACE,6BAAC,gBAAD;IAAM,GAAG,MAAT;IAAU,SAAS,EAAE,qBAAOC,qBAAMC,QAAb,EAAuBL,OAAO,IAAII,qBAAMJ,OAAxC;EAArB,gBACE,6BAAC,gBAAD,oBAAUE,MAAV;IAAkB,GAAG,MAArB;IAAsB,SAAS,EAAE,qBAAOE,qBAAME,KAAb,EAAoBN,OAAO,IAAII,qBAAMJ,OAArC,EAA8CE,MAAM,CAACK,SAArD;EAAjC,iBACE,4DACGN,OAAO,iBACN,6BAAC,qBAAD;IAAW,SAAS,EAAEG,qBAAMI,SAA5B;IAAuC,OAAO,EAAEP;EAAhD,gBACE,6BAAC,gBAAD;IAAM,IAAI,EAAEE,SAAS,GAAG,OAAH,GAAa,YAAlC;IAAgD,SAAS,EAAEC,qBAAMK;EAAjE,EADF,CAFJ,EAMGV,QANH,CADF,CADF,CADF;AAcD,CAjBD;;;AAmBAD,KAAK,CAACY,WAAN,GAAoB,iBAApB"}
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
background-color: var(--mirai-ui-modal-background);
|
|
10
10
|
opacity: 0;
|
|
11
11
|
pointer-events: none;
|
|
12
|
-
transform: scale(
|
|
13
|
-
transition:
|
|
12
|
+
transform: scale(1.1);
|
|
13
|
+
transition: opacity var(--mirai-ui-motion-expand) var(--mirai-ui-motion-easing),
|
|
14
|
+
transform var(--mirai-ui-motion-expand) var(--mirai-ui-motion-easing);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
.modal.visible {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Modal/index.js"],"sourcesContent":["export * from './Modal';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Table.Row.js","names":["TableRow","dataSource","schema","selected","sort","onPress","onSelect","onSort","others","isHead","undefined","fields","Object","keys","tag","testId","style","className","React","createElement","select","checkbox","map","field","head","label","hideIcon","displayName"],"sources":["../../../src/components/Table/Table.Row.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Icon, View } from '../../primitives';\nimport { InputOption } from '../InputOption';\nimport style from './Table.module.css';\n\nconst TableRow = ({ dataSource, schema, selected, sort = {}, onPress, onSelect, onSort, ...others }) => {\n const isHead = dataSource === undefined;\n const fields = Object.keys(schema);\n const tag = isHead ? 'th' : 'td';\n const { ['data-testid']: testId } = others;\n\n return (\n <tr\n {...others}\n role=\"tr\"\n className={styles(selected && style.selected, onPress && style.onPress, others.className)}\n >\n {onSelect &&\n React.createElement(\n tag,\n { className: style.select },\n <View row>\n {!isHead && (\n <InputOption\n checked={selected}\n data-testid={testId ? `${testId}-checkbox` : undefined}\n name=\"checkbox\"\n className={style.checkbox}\n onChange={() => onSelect(dataSource)}\n />\n )}\n </View>,\n )}\n {fields.map((field) =>\n React.createElement(\n tag,\n {\n ['data-testid']: testId ? `${testId}-${field}` : undefined,\n key: field,\n onClick: !isHead && onPress ? () => onPress(dataSource) : undefined,\n },\n <View row tag=\"span\" className={isHead && style.head} onClick={isHead ? () => onSort(field) : undefined}>\n <>\n {isHead ? schema[field].label : dataSource[field]}\n {isHead && onSort && (\n <Icon name={sort[field] ? 'Down' : 'Up'} className={sort[field] === undefined && style.hideIcon} />\n )}\n </>\n </View>,\n ),\n )}\n </tr>\n );\n};\n\nTableRow.displayName = 'Table:Row';\n\nTableRow.propTypes = {\n dataSource: PropTypes.shape({}),\n schema: PropTypes.shape({}).isRequired,\n selected: PropTypes.bool,\n sort: PropTypes.shape({}),\n onPress: PropTypes.func,\n onSelect: PropTypes.func,\n onSort: PropTypes.func,\n};\n\nexport { TableRow };\n"],"mappings":";;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,QAAQ,GAAG,SAA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,KAAhB,IAA0Bb,SAHrD,8DAISa,KAJT,kEAKa,CAACd,MAAD,IAAWJ,OAAX,GAAqB;MAAA,OAAMA,OAAO,CAACJ,UAAD,CAAb;IAAA,CAArB,GAAiDS,SAL9D,uCAOE,6BAAC,gBAAD;MAAM,GAAG,MAAT;MAAU,GAAG,EAAC,MAAd;MAAqB,SAAS,EAAED,MAAM,IAAIO,qBAAMQ,IAAhD;MAAsD,OAAO,EAAEf,MAAM,GAAG;QAAA,OAAMF,MAAM,CAACgB,KAAD,CAAZ;MAAA,CAAH,GAAyBb;IAA9F,gBACE,4DACGD,MAAM,GAAGP,MAAM,CAACqB,KAAD,CAAN,CAAcE,KAAjB,GAAyBxB,UAAU,CAACsB,KAAD,CAD5C,EAEGd,MAAM,IAAIF,MAAV,iBACC,6BAAC,gBAAD;MAAM,IAAI,EAAEH,IAAI,CAACmB,KAAD,CAAJ,GAAc,MAAd,GAAuB,IAAnC;MAAyC,SAAS,EAAEnB,IAAI,CAACmB,KAAD,CAAJ,KAAgBb,SAAhB,IAA6BM,qBAAMU;IAAvF,EAHJ,CADF,CAPF,CADU;EAAA,CAAX,CArBH,CADF;AA0CD,CAhDD;;;AAkDA1B,QAAQ,CAAC2B,WAAT,GAAuB,WAAvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Table.js","names":["Table","dataSource","schema","search","onPress","onSelect","others","selected","setSelected","sort","setSort","handleSelect","row","exists","includes","next","filter","item","push","handleSort","field","undefined","testId","style","table","className","map","index"],"sources":["../../../src/components/Table/Table.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React, { useMemo, useState } from 'react';\n\nimport { styles } from '../../helpers';\nimport { select } from './helpers';\nimport style from './Table.module.css';\nimport { TableRow } from './Table.Row';\n\nexport const Table = ({ dataSource = [], schema, search, onPress, onSelect, ...others }) => {\n const [selected, setSelected] = useState([]);\n const [sort, setSort] = useState({});\n\n const handleSelect = (row) => {\n setSelected(() => {\n const exists = selected.includes(row);\n const next = selected.filter((item) => item !== row);\n if (!exists) next.push(row);\n\n onSelect(next);\n\n return next;\n });\n };\n\n const handleSort = (field) => {\n setSort(sort[field] === undefined ? { [field]: true } : sort[field] ? { [field]: false } : {});\n };\n\n const { ['data-testid']: testId } = others;\n\n return (\n <table {...others} className={styles(style.table, others.className)}>\n <thead>\n <TableRow schema={schema} sort={sort} onSelect={onSelect ? () => {} : undefined} onSort={handleSort} />\n </thead>\n <tbody>\n {useMemo(() => select(dataSource, { search, sort }), [dataSource, search, sort]).map((row, index) => (\n <TableRow\n data-testid={testId ? `${testId}-${index}` : undefined}\n dataSource={row}\n key={index}\n schema={schema}\n selected={selected.includes(row)}\n onPress={onPress}\n onSelect={onSelect ? handleSelect : undefined}\n />\n ))}\n </tbody>\n </table>\n );\n};\n\nTable.propTypes = {\n dataSource: PropTypes.arrayOf(PropTypes.shape({})),\n schema: PropTypes.shape({}).isRequired,\n search: PropTypes.string,\n onPress: PropTypes.func,\n onSelect: PropTypes.func,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,KAAK,GAAG,SAARA,KAAQ,OAAuE;EAAA,2BAApEC,UAAoE;EAAA,IAApEA,UAAoE,gCAAvD,EAAuD;EAAA,IAAnDC,MAAmD,QAAnDA,MAAmD;EAAA,IAA3CC,MAA2C,QAA3CA,MAA2C;EAAA,IAAnCC,OAAmC,QAAnCA,OAAmC;EAAA,IAA1BC,QAA0B,QAA1BA,QAA0B;EAAA,IAAbC,MAAa;;EAC1F,gBAAgC,qBAAS,EAAT,CAAhC;EAAA;EAAA,IAAOC,QAAP;EAAA,IAAiBC,WAAjB;;EACA,iBAAwB,qBAAS,EAAT,CAAxB;EAAA;EAAA,IAAOC,IAAP;EAAA,IAAaC,OAAb;;EAEA,IAAMC,YAAY,GAAG,SAAfA,YAAe,CAACC,GAAD,EAAS;IAC5BJ,WAAW,CAAC,YAAM;MAChB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MAEE,UAAU,EAAET,GAFd;MAGE,GAAG,EAAEe,KAHP;MAIE,MAAM,EAAEzB,MAJV;MAKE,QAAQ,EAAEK,QAAQ,CAACO,QAAT,CAAkBF,GAAlB,CALZ;MAME,OAAO,EAAER,OANX;MAOE,QAAQ,EAAEC,QAAQ,GAAGM,YAAH,GAAkBU;IAPtC,EADmF;EAAA,CAApF,CADH,CAJF,CADF;AAoBD,CA1CM"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--mirai-ui-table-base: var(--mirai-ui-base);
|
|
3
|
-
--mirai-ui-table-border-color: var(--mirai-ui-
|
|
3
|
+
--mirai-ui-table-border-color: var(--mirai-ui-content-300);
|
|
4
4
|
--mirai-ui-table-content: var(--mirai-ui-content);
|
|
5
|
-
--mirai-ui-table-
|
|
6
|
-
--mirai-ui-table-color
|
|
7
|
-
--mirai-ui-table-
|
|
5
|
+
--mirai-ui-table-hover-background: var(--mirai-ui-accent-300);
|
|
6
|
+
--mirai-ui-table-head-color: var(--mirai-ui-content-400);
|
|
7
|
+
--mirai-ui-table-padding-x: var(--mirai-ui-space-M);
|
|
8
|
+
--mirai-ui-table-padding-y: var(--mirai-ui-space-M);
|
|
9
|
+
--mirai-ui-table-selected-background: var(--mirai-ui-accent-200);
|
|
10
|
+
--mirai-ui-table-selected-color: var(--mirai-ui-accent);
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
.table {
|
|
@@ -18,29 +21,15 @@
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
.table thead tr {
|
|
21
|
-
color: var(--mirai-ui-table-
|
|
24
|
+
color: var(--mirai-ui-table-head-color);
|
|
22
25
|
font-family: var(--mirai-ui-font-bold);
|
|
23
26
|
font-size: var(--mirai-ui-font-size-small);
|
|
24
27
|
font-weight: var(--mirai-ui-font-bold-weight);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
.table thead tr th {
|
|
28
|
-
height: var(--mirai-ui-space-M);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.table thead tr th:hover {
|
|
32
|
-
color: var(--mirai-ui-table-content);
|
|
33
|
-
cursor: pointer;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
30
|
.table tbody tr.selected {
|
|
37
|
-
background-color: var(--mirai-ui-table-
|
|
38
|
-
color: var(--mirai-ui-table-color
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.table tbody tr:hover.onPress {
|
|
42
|
-
background-color: var(--mirai-ui-table-border-color);
|
|
43
|
-
cursor: pointer;
|
|
31
|
+
background-color: var(--mirai-ui-table-selected-background);
|
|
32
|
+
color: var(--mirai-ui-table-selected-color);
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
.table tr:not(:last-child) {
|
|
@@ -49,22 +38,23 @@
|
|
|
49
38
|
|
|
50
39
|
.table th,
|
|
51
40
|
.table td {
|
|
52
|
-
padding: var(--mirai-ui-
|
|
41
|
+
padding: var(--mirai-ui-table-padding-y) 0;
|
|
53
42
|
}
|
|
54
43
|
|
|
55
44
|
.table th:first-child,
|
|
56
45
|
.table td:first-child {
|
|
57
|
-
padding-left: var(--mirai-ui-
|
|
46
|
+
padding-left: var(--mirai-ui-table-padding-x);
|
|
58
47
|
}
|
|
59
48
|
|
|
60
49
|
.table th:last-child,
|
|
61
50
|
.table td:last-child {
|
|
62
|
-
padding-right: var(--mirai-ui-
|
|
51
|
+
padding-right: var(--mirai-ui-table-padding-x);
|
|
63
52
|
}
|
|
64
53
|
|
|
65
54
|
.table th.select,
|
|
66
55
|
.table td.select {
|
|
67
|
-
width:
|
|
56
|
+
width: var(--mirai-ui-checkbox-size);
|
|
57
|
+
padding-right: var(--mirai-ui-table-padding-x);
|
|
68
58
|
}
|
|
69
59
|
|
|
70
60
|
.table th .hideIcon {
|
|
@@ -74,3 +64,15 @@
|
|
|
74
64
|
.table .checkbox {
|
|
75
65
|
margin: 0;
|
|
76
66
|
}
|
|
67
|
+
|
|
68
|
+
@media only screen and (min-width: 600px) {
|
|
69
|
+
.table thead tr th:hover {
|
|
70
|
+
color: var(--mirai-ui-table-content);
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.table tbody tr:hover.onPress {
|
|
75
|
+
background-color: var(--mirai-ui-table-hover-background);
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/Table/helpers/index.js"],"sourcesContent":["export * from './select';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"select.js","names":["select","dataSource","search","sort","values","filter","row","JSON","stringify","includes","Object","keys","forEach","key","order","a","b"],"sources":["../../../../src/components/Table/helpers/select.js"],"sourcesContent":["export const select = (dataSource = [], { search, sort = {} } = {}) => {\n const values = dataSource.filter((row) => (search ? JSON.stringify(row).includes(search) : true));\n\n Object.keys(sort).forEach((key) => {\n const order = sort[key] ? 1 : -1;\n\n values.sort((a, b) => (a[key] >= b[key] ? 1 * order : -1 * order));\n });\n\n return values;\n};\n"],"mappings":";;;;;;;AAAO,IAAMA,MAAM,GAAG,SAATA,MAAS,GAAiD;EAAA,IAAhDC,UAAgD,uEAAnC,EAAmC;;EAAA,+EAAP,EAAO;EAAA,IAA7BC,MAA6B,QAA7BA,MAA6B;EAAA,qBAArBC,IAAqB;EAAA,IAArBA,IAAqB,0BAAd,EAAc;;EACrE,IAAMC,MAAM,GAAGH,UAAU,CAACI,MAAX,CAAkB,UAACC,GAAD;IAAA,OAAUJ,MAAM,GAAGK,IAAI,CAACC,SAAL,CAAeF,GAAf,EAAoBG,QAApB,CAA6BP,MAA7B,CAAH,GAA0C,IAA1D;EAAA,CAAlB,CAAf;EAEAQ,MAAM,CAACC,IAAP,CAAYR,IAAZ,EAAkBS,OAAlB,CAA0B,UAACC,GAAD,EAAS;IACjC,IAAMC,KAAK,GAAGX,IAAI,CAACU,GAAD,CAAJ,GAAY,CAAZ,GAAgB,CAAC,CAA/B;IAEAT,MAAM,CAACD,IAAP,CAAY,UAACY,CAAD,EAAIC,CAAJ;MAAA,OAAWD,CAAC,CAACF,GAAD,CAAD,IAAUG,CAAC,CAACH,GAAD,CAAX,GAAmB,IAAIC,KAAvB,GAA+B,CAAC,CAAD,GAAKA,KAA/C;IAAA,CAAZ;EACD,CAJD;EAMA,OAAOV,MAAP;AACD,CAVM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Table/index.js"],"sourcesContent":["export * from './Table';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.Tooltip = void 0;
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _helpers = require("../../helpers");
|
|
21
|
+
|
|
22
|
+
var _primitives = require("../../primitives");
|
|
23
|
+
|
|
24
|
+
var _TooltipModule = _interopRequireDefault(require("./Tooltip.module.css"));
|
|
25
|
+
|
|
26
|
+
var _excluded = ["children", "Template", "text"];
|
|
27
|
+
|
|
28
|
+
var Tooltip = function Tooltip(_ref) {
|
|
29
|
+
var children = _ref.children,
|
|
30
|
+
Template = _ref.Template,
|
|
31
|
+
text = _ref.text,
|
|
32
|
+
others = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
33
|
+
|
|
34
|
+
var _useState = (0, _react.useState)(others.visible || false),
|
|
35
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
36
|
+
visible = _useState2[0],
|
|
37
|
+
setVisible = _useState2[1];
|
|
38
|
+
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_primitives.Layer, Object.assign({}, others, {
|
|
40
|
+
centered: true,
|
|
41
|
+
visible: visible
|
|
42
|
+
}), _react.default.Children.map(children, function (child, index) {
|
|
43
|
+
return /*#__PURE__*/_react.default.cloneElement(child, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, child.props), {}, {
|
|
44
|
+
key: index,
|
|
45
|
+
'data-testid': others['data-testid'] ? "".concat(others['data-testid'], "-dispatcher") : undefined,
|
|
46
|
+
className: (0, _helpers.styles)(_TooltipModule.default.dispatcher, child.props.className),
|
|
47
|
+
onMouseEnter: function onMouseEnter() {
|
|
48
|
+
return setVisible(true);
|
|
49
|
+
},
|
|
50
|
+
onMouseLeave: function onMouseLeave() {
|
|
51
|
+
return setVisible(false);
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}), /*#__PURE__*/_react.default.createElement(_primitives.LayerContent, null, /*#__PURE__*/_react.default.createElement(_primitives.View, {
|
|
55
|
+
className: _TooltipModule.default.tooltip
|
|
56
|
+
}, Template ? /*#__PURE__*/_react.default.createElement(Template, null) : /*#__PURE__*/_react.default.createElement(_primitives.Text, {
|
|
57
|
+
bold: true,
|
|
58
|
+
small: true,
|
|
59
|
+
className: _TooltipModule.default.text
|
|
60
|
+
}, text))));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.Tooltip = Tooltip;
|
|
64
|
+
Tooltip.displayName = 'Component:Tooltip';
|
|
65
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["Tooltip","children","Template","text","others","visible","setVisible","React","Children","map","child","index","cloneElement","props","key","undefined","className","style","dispatcher","onMouseEnter","onMouseLeave","tooltip","displayName"],"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 = ({ children, Template, text, ...others }) => {\n const [visible, setVisible] = useState(others.visible || false);\n\n return (\n <Layer {...others} centered visible={visible}>\n {React.Children.map(children, (child, index) =>\n React.cloneElement(child, {\n ...child.props,\n key: index,\n 'data-testid': others['data-testid'] ? `${others['data-testid']}-dispatcher` : undefined,\n className: styles(style.dispatcher, child.props.className),\n onMouseEnter: () => setVisible(true),\n onMouseLeave: () => setVisible(false),\n }),\n )}\n\n <LayerContent>\n <View className={style.tooltip}>\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};\n\nTooltip.displayName = 'Component:Tooltip';\n\nTooltip.propTypes = {\n children: PropTypes.node,\n Template: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),\n text: PropTypes.string,\n visible: PropTypes.bool,\n};\n\nexport { Tooltip };\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,OAA6C;EAAA,IAA1CC,QAA0C,QAA1CA,QAA0C;EAAA,IAAhCC,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var(--mirai-ui-border-radius);
|
|
4
|
+
--mirai-ui-tooltip-color: var(--mirai-ui-base);
|
|
5
|
+
--mirai-ui-tooltip-space: var(--mirai-ui-space-XS);
|
|
6
|
+
--mirai-ui-tooltip-max-width: calc(var(--mirai-ui-space-XXL) * 4);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.dispatcher {
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.tooltip {
|
|
14
|
+
background-color: var(--mirai-ui-tooltip-background);
|
|
15
|
+
border-radius: var(--mirai-ui-tooltip-border-radius);
|
|
16
|
+
margin-bottom: calc(var(--mirai-ui-tooltip-space) / 2);
|
|
17
|
+
margin-top: calc(var(--mirai-ui-tooltip-space) / 2);
|
|
18
|
+
max-width: var(--mirai-ui-tooltip-max-width);
|
|
19
|
+
padding: var(--mirai-ui-tooltip-space);
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tooltip .text {
|
|
24
|
+
color: var(--mirai-ui-tooltip-color);
|
|
25
|
+
text-align: center;
|
|
26
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[` 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<span
|
|
6
|
+
data-testid="onEnter"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
class="pressable button dispatcher"
|
|
10
|
+
data-testid="onEnter-dispatcher"
|
|
11
|
+
>
|
|
12
|
+
Action
|
|
13
|
+
</button>
|
|
14
|
+
</span>
|
|
15
|
+
</DocumentFragment>
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
exports[` 2`] = `
|
|
19
|
+
<DocumentFragment>
|
|
20
|
+
<span
|
|
21
|
+
data-testid="onEnter"
|
|
22
|
+
>
|
|
23
|
+
<button
|
|
24
|
+
class="pressable button dispatcher"
|
|
25
|
+
data-testid="onEnter-dispatcher"
|
|
26
|
+
>
|
|
27
|
+
Action
|
|
28
|
+
</button>
|
|
29
|
+
</span>
|
|
30
|
+
</DocumentFragment>
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports[`component:<Tooltip> inherit:className 1`] = `
|
|
34
|
+
<DocumentFragment>
|
|
35
|
+
<span />
|
|
36
|
+
</DocumentFragment>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`component:<Tooltip> renders 1`] = `
|
|
40
|
+
<DocumentFragment>
|
|
41
|
+
<span />
|
|
42
|
+
</DocumentFragment>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`component:<Tooltip> simulate behavior: onEnter & onLeave w/ Template 1`] = `
|
|
46
|
+
<DocumentFragment>
|
|
47
|
+
<span
|
|
48
|
+
data-testid="onEnter"
|
|
49
|
+
>
|
|
50
|
+
<button
|
|
51
|
+
class="pressable button dispatcher"
|
|
52
|
+
data-testid="onEnter-dispatcher"
|
|
53
|
+
>
|
|
54
|
+
Action
|
|
55
|
+
</button>
|
|
56
|
+
</span>
|
|
57
|
+
</DocumentFragment>
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
exports[`component:<Tooltip> simulate behavior: onEnter & onLeave w/ Template 2`] = `
|
|
61
|
+
<DocumentFragment>
|
|
62
|
+
<span
|
|
63
|
+
data-testid="onEnter"
|
|
64
|
+
>
|
|
65
|
+
<button
|
|
66
|
+
class="pressable button dispatcher"
|
|
67
|
+
data-testid="onEnter-dispatcher"
|
|
68
|
+
>
|
|
69
|
+
Action
|
|
70
|
+
</button>
|
|
71
|
+
</span>
|
|
72
|
+
</DocumentFragment>
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
exports[`component:<Tooltip> testID 1`] = `
|
|
76
|
+
<DocumentFragment>
|
|
77
|
+
<span
|
|
78
|
+
data-testid="mirai"
|
|
79
|
+
/>
|
|
80
|
+
</DocumentFragment>
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
exports[`component:<Tooltip> w/ children + Template 1`] = `
|
|
84
|
+
<DocumentFragment>
|
|
85
|
+
<span>
|
|
86
|
+
<button
|
|
87
|
+
class="pressable button dispatcher"
|
|
88
|
+
>
|
|
89
|
+
Action
|
|
90
|
+
</button>
|
|
91
|
+
</span>
|
|
92
|
+
</DocumentFragment>
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
exports[`component:<Tooltip> w/ children + text 1`] = `
|
|
96
|
+
<DocumentFragment>
|
|
97
|
+
<span>
|
|
98
|
+
<button
|
|
99
|
+
class="pressable button dispatcher"
|
|
100
|
+
>
|
|
101
|
+
Action
|
|
102
|
+
</button>
|
|
103
|
+
</span>
|
|
104
|
+
</DocumentFragment>
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
exports[`component:<Tooltip> w/ children 1`] = `
|
|
108
|
+
<DocumentFragment>
|
|
109
|
+
<span>
|
|
110
|
+
<button
|
|
111
|
+
class="pressable button dispatcher"
|
|
112
|
+
>
|
|
113
|
+
Action
|
|
114
|
+
</button>
|
|
115
|
+
</span>
|
|
116
|
+
</DocumentFragment>
|
|
117
|
+
`;
|