@mirai/ui 1.0.46 → 1.0.47
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/build/components/Button/Button.js +11 -5
- package/build/components/Button/Button.js.map +1 -1
- package/build/components/Button/Button.module.css +44 -8
- package/build/components/Button/__tests__/__snapshots__/Button.test.js.snap +28 -0
- package/build/components/InputNumber/__tests__/__snapshots__/InputNumber.test.js.snap +9 -9
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ var _primitives = require("../../primitives");
|
|
|
15
15
|
|
|
16
16
|
var _ButtonModule = _interopRequireDefault(require("./Button.module.css"));
|
|
17
17
|
|
|
18
|
-
var _excluded = ["children", "disabled", "large", "outlined", "rounded", "small", "squared", "tag"];
|
|
18
|
+
var _excluded = ["busy", "children", "disabled", "large", "outlined", "rounded", "small", "squared", "tag", "onPress"];
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
@@ -30,7 +30,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
30
30
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
31
|
|
|
32
32
|
var Button = function Button(_ref) {
|
|
33
|
-
var
|
|
33
|
+
var busy = _ref.busy,
|
|
34
|
+
children = _ref.children,
|
|
34
35
|
disabled = _ref.disabled,
|
|
35
36
|
large = _ref.large,
|
|
36
37
|
outlined = _ref.outlined,
|
|
@@ -40,18 +41,23 @@ var Button = function Button(_ref) {
|
|
|
40
41
|
squared = _ref$squared === void 0 ? false : _ref$squared,
|
|
41
42
|
_ref$tag = _ref.tag,
|
|
42
43
|
tag = _ref$tag === void 0 ? 'button' : _ref$tag,
|
|
44
|
+
onPress = _ref.onPress,
|
|
43
45
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
44
46
|
|
|
45
47
|
return /*#__PURE__*/_react.default.createElement(_primitives.Pressable, _objectSpread(_objectSpread({}, others), {}, {
|
|
46
|
-
disabled: disabled,
|
|
48
|
+
disabled: disabled || busy,
|
|
47
49
|
tag: tag,
|
|
48
|
-
className: (0, _helpers.styles)(_ButtonModule.default.button, large && _ButtonModule.default.large, small && _ButtonModule.default.small, rounded && _ButtonModule.default.rounded, squared && _ButtonModule.default.squared, outlined &&
|
|
49
|
-
|
|
50
|
+
className: (0, _helpers.styles)(_ButtonModule.default.button, busy && _ButtonModule.default.busy, large && _ButtonModule.default.large, small && _ButtonModule.default.small, rounded && _ButtonModule.default.rounded, squared && _ButtonModule.default.squared, outlined && _ButtonModule.default.outlined, outlined && (disabled || busy) && _ButtonModule.default.disabled, others.className),
|
|
51
|
+
onPress: !disabled && !busy ? onPress : undefined
|
|
52
|
+
}), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, busy !== undefined && /*#__PURE__*/_react.default.createElement(_primitives.View, {
|
|
53
|
+
className: (0, _helpers.styles)(_ButtonModule.default.busyProgress, busy && _ButtonModule.default.active)
|
|
54
|
+
}), children));
|
|
50
55
|
};
|
|
51
56
|
|
|
52
57
|
exports.Button = Button;
|
|
53
58
|
Button.displayName = 'Component:Button';
|
|
54
59
|
Button.propTypes = {
|
|
60
|
+
busy: _propTypes.default.bool,
|
|
55
61
|
children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
56
62
|
disabled: _propTypes.default.bool,
|
|
57
63
|
large: _propTypes.default.bool,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["Button","children","disabled","large","outlined","rounded","small","squared","tag","others","React","createElement","Pressable","className","style","button","displayName","propTypes","PropTypes","oneOfType","string","node","
|
|
1
|
+
{"version":3,"file":"Button.js","names":["Button","busy","children","disabled","large","outlined","rounded","small","squared","tag","onPress","others","React","createElement","Pressable","className","style","button","undefined","busyProgress","active","displayName","propTypes","PropTypes","bool","oneOfType","string","node","onEnter","func","onLeave"],"sources":["../../../src/components/Button/Button.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Pressable, View } from '../../primitives';\nimport style from './Button.module.css';\n\nconst Button = ({\n busy,\n children,\n disabled,\n large,\n outlined,\n rounded,\n small,\n squared = false,\n tag = 'button',\n onPress,\n ...others\n}) =>\n React.createElement(\n Pressable,\n {\n ...others,\n disabled: disabled || busy,\n tag,\n className: styles(\n style.button,\n busy && style.busy,\n large && style.large,\n small && style.small,\n rounded && style.rounded,\n squared && style.squared,\n outlined && style.outlined,\n outlined && (disabled || busy) && style.disabled,\n others.className,\n ),\n onPress: !disabled && !busy ? onPress : undefined,\n },\n <>\n {busy !== undefined && <View className={styles(style.busyProgress, busy && style.active)} />}\n {children}\n </>,\n );\n\nButton.displayName = 'Component:Button';\n\nButton.propTypes = {\n busy: PropTypes.bool,\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n large: PropTypes.bool,\n outlined: PropTypes.bool,\n rounded: PropTypes.bool,\n small: PropTypes.bool,\n squared: PropTypes.bool,\n tag: PropTypes.string,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Button };\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;EAAA,IACbC,IADa,QACbA,IADa;EAAA,IAEbC,QAFa,QAEbA,QAFa;EAAA,IAGbC,QAHa,QAGbA,QAHa;EAAA,IAIbC,KAJa,QAIbA,KAJa;EAAA,IAKbC,QALa,QAKbA,QALa;EAAA,IAMbC,OANa,QAMbA,OANa;EAAA,IAObC,KAPa,QAObA,KAPa;EAAA,wBAQbC,OARa;EAAA,IAQbA,OARa,6BAQH,KARG;EAAA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EAAEgB,mBAAUC,IAPA;EAQjBhB,OAAO,EAAEe,mBAAUC,IARF;EASjBf,GAAG,EAAEc,mBAAUG,MATE;EAUjBE,OAAO,EAAEL,mBAAUM,IAVF;EAWjBC,OAAO,EAAEP,mBAAUM,IAXF;EAYjBnB,OAAO,EAAEa,mBAAUM;AAZF,CAAnB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--mirai-ui-button-background: var(--mirai-ui-accent);
|
|
3
|
+
--mirai-ui-button-busy-width: 0%;
|
|
4
|
+
--mirai-ui-button-busy-motion: calc(var(--mirai-ui-motion-expand) * 10);
|
|
3
5
|
--mirai-ui-button-color: var(--mirai-ui-base);
|
|
4
6
|
--mirai-ui-button-color-active: rgba(255, 255, 255, 0.2);
|
|
5
7
|
--mirai-ui-button-color-focus: var(--mirai-ui-content);
|
|
@@ -25,21 +27,45 @@
|
|
|
25
27
|
font-weight: var(--mirai-ui-button-font-weight);
|
|
26
28
|
justify-content: center;
|
|
27
29
|
padding: var(--mirai-ui-button-padding-y) var(--mirai-ui-button-padding-x);
|
|
30
|
+
position: relative;
|
|
28
31
|
transition: background-color var(--mirai-ui-motion-expand) var(--mirai-ui-motion-easing),
|
|
29
32
|
box-shadow var(--mirai-ui-motion-expand) var(--mirai-ui-motion-easing),
|
|
30
33
|
color var(--mirai-ui-motion-expand) var(--mirai-ui-motion-easing);
|
|
31
34
|
width: fit-content;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
.button:disabled {
|
|
37
|
+
.button:disabled:not(.busy) {
|
|
35
38
|
background-color: var(--mirai-ui-button-disabled-background);
|
|
36
39
|
color: var(--mirai-ui-button-disabled-color);
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
@keyframes mirai-button-busy {
|
|
43
|
+
from {
|
|
44
|
+
width: var(--mirai-ui-button-busy-width);
|
|
45
|
+
}
|
|
46
|
+
to {
|
|
47
|
+
width: 100%;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.outlined .busyProgress {
|
|
52
|
+
background-color: var(--mirai-ui-button-background);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.busyProgress {
|
|
56
|
+
background-color: var(--mirai-ui-button-color);
|
|
57
|
+
opacity: 0.2;
|
|
58
|
+
height: 100%;
|
|
59
|
+
left: 0;
|
|
60
|
+
position: absolute;
|
|
61
|
+
width: 0%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.busyProgress.active {
|
|
65
|
+
animation-duration: var(--mirai-ui-button-busy-motion);
|
|
66
|
+
animation-iteration-count: infinite;
|
|
67
|
+
animation-name: mirai-button-busy;
|
|
68
|
+
animation-timing-function: var(--mirai-ui-motion-easing);
|
|
43
69
|
}
|
|
44
70
|
|
|
45
71
|
.button:not(:disabled):active {
|
|
@@ -52,15 +78,25 @@
|
|
|
52
78
|
calc(var(--mirai-ui-button-padding-x) + calc(var(--mirai-ui-button-padding-y) / 2));
|
|
53
79
|
}
|
|
54
80
|
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
.outlined {
|
|
82
|
+
background-color: var(--mirai-ui-button-outlined-background);
|
|
83
|
+
border: solid 1px var(--mirai-ui-button-background);
|
|
84
|
+
color: var(--mirai-ui-button-background);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.outlined.disabled:not(.busy) {
|
|
88
|
+
border-color: var(--mirai-ui-button-disabled-background);
|
|
58
89
|
}
|
|
59
90
|
|
|
60
91
|
.rounded {
|
|
61
92
|
border-radius: 50%;
|
|
62
93
|
}
|
|
63
94
|
|
|
95
|
+
.small:not(.squared) {
|
|
96
|
+
font-size: var(--mirai-ui-font-size-small);
|
|
97
|
+
padding: var(--mirai-ui-button-padding-y) calc(var(--mirai-ui-button-padding-x) / 2);
|
|
98
|
+
}
|
|
99
|
+
|
|
64
100
|
.squared {
|
|
65
101
|
height: var(--mirai-ui-button-squared);
|
|
66
102
|
padding: 0;
|
|
@@ -10,6 +10,20 @@ exports[`component:<Button> inherit:className 1`] = `
|
|
|
10
10
|
</DocumentFragment>
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
+
exports[`component:<Button> prop:busy 1`] = `
|
|
14
|
+
<DocumentFragment>
|
|
15
|
+
<button
|
|
16
|
+
class="pressable button busy"
|
|
17
|
+
disabled=""
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
class="view busyProgress active"
|
|
21
|
+
/>
|
|
22
|
+
children
|
|
23
|
+
</button>
|
|
24
|
+
</DocumentFragment>
|
|
25
|
+
`;
|
|
26
|
+
|
|
13
27
|
exports[`component:<Button> prop:disabled 1`] = `
|
|
14
28
|
<DocumentFragment>
|
|
15
29
|
<button
|
|
@@ -31,6 +45,20 @@ exports[`component:<Button> prop:large 1`] = `
|
|
|
31
45
|
</DocumentFragment>
|
|
32
46
|
`;
|
|
33
47
|
|
|
48
|
+
exports[`component:<Button> prop:outlined && prop:busy 1`] = `
|
|
49
|
+
<DocumentFragment>
|
|
50
|
+
<button
|
|
51
|
+
class="pressable button busy outlined disabled"
|
|
52
|
+
disabled=""
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
class="view busyProgress active"
|
|
56
|
+
/>
|
|
57
|
+
children
|
|
58
|
+
</button>
|
|
59
|
+
</DocumentFragment>
|
|
60
|
+
`;
|
|
61
|
+
|
|
34
62
|
exports[`component:<Button> prop:outlined 1`] = `
|
|
35
63
|
<DocumentFragment>
|
|
36
64
|
<button
|
|
@@ -9,7 +9,7 @@ exports[`component:<InputNumber> inherit:className 1`] = `
|
|
|
9
9
|
class="view texts"
|
|
10
10
|
/>
|
|
11
11
|
<button
|
|
12
|
-
class="pressable button rounded squared"
|
|
12
|
+
class="pressable button rounded squared outlined disabled"
|
|
13
13
|
disabled=""
|
|
14
14
|
>
|
|
15
15
|
<span
|
|
@@ -85,7 +85,7 @@ exports[`component:<InputNumber> prop:disabled 1`] = `
|
|
|
85
85
|
class="view texts"
|
|
86
86
|
/>
|
|
87
87
|
<button
|
|
88
|
-
class="pressable button rounded squared"
|
|
88
|
+
class="pressable button rounded squared outlined disabled"
|
|
89
89
|
disabled=""
|
|
90
90
|
>
|
|
91
91
|
<span
|
|
@@ -117,7 +117,7 @@ exports[`component:<InputNumber> prop:disabled 1`] = `
|
|
|
117
117
|
0
|
|
118
118
|
</span>
|
|
119
119
|
<button
|
|
120
|
-
class="pressable button rounded squared"
|
|
120
|
+
class="pressable button rounded squared outlined disabled"
|
|
121
121
|
disabled=""
|
|
122
122
|
>
|
|
123
123
|
<span
|
|
@@ -168,7 +168,7 @@ exports[`component:<InputNumber> prop:hint 1`] = `
|
|
|
168
168
|
</span>
|
|
169
169
|
</div>
|
|
170
170
|
<button
|
|
171
|
-
class="pressable button rounded squared"
|
|
171
|
+
class="pressable button rounded squared outlined disabled"
|
|
172
172
|
disabled=""
|
|
173
173
|
>
|
|
174
174
|
<span
|
|
@@ -250,7 +250,7 @@ exports[`component:<InputNumber> prop:label 1`] = `
|
|
|
250
250
|
</span>
|
|
251
251
|
</div>
|
|
252
252
|
<button
|
|
253
|
-
class="pressable button rounded squared"
|
|
253
|
+
class="pressable button rounded squared outlined disabled"
|
|
254
254
|
disabled=""
|
|
255
255
|
>
|
|
256
256
|
<span
|
|
@@ -357,7 +357,7 @@ exports[`component:<InputNumber> prop:max 1`] = `
|
|
|
357
357
|
10
|
|
358
358
|
</span>
|
|
359
359
|
<button
|
|
360
|
-
class="pressable button rounded squared"
|
|
360
|
+
class="pressable button rounded squared outlined disabled"
|
|
361
361
|
disabled=""
|
|
362
362
|
>
|
|
363
363
|
<span
|
|
@@ -402,7 +402,7 @@ exports[`component:<InputNumber> prop:min 1`] = `
|
|
|
402
402
|
class="view texts"
|
|
403
403
|
/>
|
|
404
404
|
<button
|
|
405
|
-
class="pressable button rounded squared"
|
|
405
|
+
class="pressable button rounded squared outlined disabled"
|
|
406
406
|
disabled=""
|
|
407
407
|
>
|
|
408
408
|
<span
|
|
@@ -628,7 +628,7 @@ exports[`component:<InputNumber> renders 1`] = `
|
|
|
628
628
|
class="view texts"
|
|
629
629
|
/>
|
|
630
630
|
<button
|
|
631
|
-
class="pressable button rounded squared"
|
|
631
|
+
class="pressable button rounded squared outlined disabled"
|
|
632
632
|
disabled=""
|
|
633
633
|
>
|
|
634
634
|
<span
|
|
@@ -705,7 +705,7 @@ exports[`component:<InputNumber> testID 1`] = `
|
|
|
705
705
|
class="view texts"
|
|
706
706
|
/>
|
|
707
707
|
<button
|
|
708
|
-
class="pressable button rounded squared"
|
|
708
|
+
class="pressable button rounded squared outlined disabled"
|
|
709
709
|
disabled=""
|
|
710
710
|
>
|
|
711
711
|
<span
|