@mirai/ui 1.0.113 → 1.0.114-alpha
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 +2 -0
- package/build/components/Action/Action.js +13 -5
- package/build/components/Action/Action.js.map +1 -1
- package/build/components/Action/Action.module.css +11 -2
- package/build/components/Action/Action.stories.js +8 -2
- package/build/components/Action/Action.stories.js.map +1 -1
- package/build/components/Action/__tests__/__snapshots__/Action.test.js.snap +23 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -325,10 +325,12 @@ A hyperlink component that receives the following props:
|
|
|
325
325
|
|
|
326
326
|
- `children:node|string`
|
|
327
327
|
- `disabled:boolean` applying 'disabled' attribute
|
|
328
|
+
- `href:string` applying 'href' attribute & force `a` tag
|
|
328
329
|
- `inline:boolean` modifying the button padding size
|
|
329
330
|
- `large:boolean` modifying the button size
|
|
330
331
|
- `small:boolean` modifying the button size
|
|
331
332
|
- `tag:string` html tag of resulting element ('button' by default)
|
|
333
|
+
- `target:boolean` applying 'target' attribute (in combination with `href:string`)
|
|
332
334
|
- `underline:boolean` use an underline text decoration
|
|
333
335
|
- `wide:bool` modifying the button to full-width
|
|
334
336
|
- `onEnter:function` executed when the user hovers over
|
|
@@ -10,7 +10,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _helpers = require("../../helpers");
|
|
11
11
|
var _primitives = require("../../primitives");
|
|
12
12
|
var _ActionModule = _interopRequireDefault(require("./Action.module.css"));
|
|
13
|
-
var _excluded = ["children", "disabled", "inline", "large", "small", "tag", "underline", "wide", "onPress"];
|
|
13
|
+
var _excluded = ["children", "disabled", "href", "inline", "large", "small", "tag", "target", "underline", "wide", "onPress"];
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -22,20 +22,26 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
22
22
|
var Action = function Action(_ref) {
|
|
23
23
|
var children = _ref.children,
|
|
24
24
|
disabled = _ref.disabled,
|
|
25
|
+
href = _ref.href,
|
|
25
26
|
inline = _ref.inline,
|
|
26
27
|
large = _ref.large,
|
|
27
28
|
small = _ref.small,
|
|
28
29
|
_ref$tag = _ref.tag,
|
|
29
30
|
tag = _ref$tag === void 0 ? 'button' : _ref$tag,
|
|
31
|
+
target = _ref.target,
|
|
30
32
|
underline = _ref.underline,
|
|
31
33
|
wide = _ref.wide,
|
|
32
|
-
|
|
34
|
+
_onPress = _ref.onPress,
|
|
33
35
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
34
36
|
return /*#__PURE__*/_react.default.createElement(_primitives.Pressable, _objectSpread(_objectSpread({}, others), {}, {
|
|
35
37
|
disabled: disabled,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
href: href,
|
|
39
|
+
tag: href ? 'a' : tag,
|
|
40
|
+
className: (0, _helpers.styles)(_ActionModule.default.action, disabled && _ActionModule.default.disabled, inline && _ActionModule.default.inline, large && _ActionModule.default.large, small && _ActionModule.default.small, underline && _ActionModule.default.underline, wide && _ActionModule.default.wide, others.className),
|
|
41
|
+
onPress: function onPress(event) {
|
|
42
|
+
_onPress && _onPress(event);
|
|
43
|
+
if (href && target) window.open(href, target);else if (href) window.location = href;
|
|
44
|
+
}
|
|
39
45
|
}), children);
|
|
40
46
|
};
|
|
41
47
|
exports.Action = Action;
|
|
@@ -43,10 +49,12 @@ Action.displayName = 'Component:Action';
|
|
|
43
49
|
Action.propTypes = {
|
|
44
50
|
children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
45
51
|
disabled: _propTypes.default.bool,
|
|
52
|
+
href: _propTypes.default.string,
|
|
46
53
|
inline: _propTypes.default.bool,
|
|
47
54
|
large: _propTypes.default.bool,
|
|
48
55
|
small: _propTypes.default.bool,
|
|
49
56
|
tag: _propTypes.default.string,
|
|
57
|
+
target: _propTypes.default.string,
|
|
50
58
|
underline: _propTypes.default.bool,
|
|
51
59
|
wide: _propTypes.default.bool,
|
|
52
60
|
onEnter: _propTypes.default.func,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.js","names":["Action","children","disabled","inline","large","small","tag","underline","wide","onPress","others","React","createElement","Pressable","className","styles","style","action","displayName","propTypes","PropTypes","oneOfType","string","node","bool","onEnter","func","onLeave"],"sources":["../../../src/components/Action/Action.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Pressable } from '../../primitives';\nimport style from './Action.module.css';\n\nconst Action = ({
|
|
1
|
+
{"version":3,"file":"Action.js","names":["Action","children","disabled","href","inline","large","small","tag","target","underline","wide","onPress","others","React","createElement","Pressable","className","styles","style","action","event","window","open","location","displayName","propTypes","PropTypes","oneOfType","string","node","bool","onEnter","func","onLeave"],"sources":["../../../src/components/Action/Action.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { styles } from '../../helpers';\nimport { Pressable } from '../../primitives';\nimport style from './Action.module.css';\n\nconst Action = ({\n children,\n disabled,\n href,\n inline,\n large,\n small,\n tag = 'button',\n target,\n underline,\n wide,\n onPress,\n ...others\n}) =>\n React.createElement(\n Pressable,\n {\n ...others,\n disabled,\n href,\n tag: href ? 'a' : tag,\n className: styles(\n style.action,\n disabled && style.disabled,\n inline && style.inline,\n large && style.large,\n small && style.small,\n underline && style.underline,\n wide && style.wide,\n others.className,\n ),\n onPress: (event) => {\n onPress && onPress(event);\n if (href && target) window.open(href, target);\n else if (href) window.location = href;\n },\n },\n children,\n );\n\nAction.displayName = 'Component:Action';\n\nAction.propTypes = {\n children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n disabled: PropTypes.bool,\n href: PropTypes.string,\n inline: PropTypes.bool,\n large: PropTypes.bool,\n small: PropTypes.bool,\n tag: PropTypes.string,\n target: PropTypes.string,\n underline: PropTypes.bool,\n wide: PropTypes.bool,\n onEnter: PropTypes.func,\n onLeave: PropTypes.func,\n onPress: PropTypes.func,\n};\n\nexport { Action };\n"],"mappings":";;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAExC,IAAMA,MAAM,GAAG,SAATA,MAAM;EAAA,IACVC,QAAQ,QAARA,QAAQ;IACRC,QAAQ,QAARA,QAAQ;IACRC,IAAI,QAAJA,IAAI;IACJC,MAAM,QAANA,MAAM;IACNC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IAAA,gBACLC,GAAG;IAAHA,GAAG,yBAAG,QAAQ;IACdC,MAAM,QAANA,MAAM;IACNC,SAAS,QAATA,SAAS;IACTC,IAAI,QAAJA,IAAI;IACJC,QAAO,QAAPA,OAAO;IACJC,MAAM;EAAA,oBAETC,cAAK,CAACC,aAAa,CACjBC,qBAAS,kCAEJH,MAAM;IACTV,QAAQ,EAARA,QAAQ;IACRC,IAAI,EAAJA,IAAI;IACJI,GAAG,EAAEJ,IAAI,GAAG,GAAG,GAAGI,GAAG;IACrBS,SAAS,EAAE,IAAAC,eAAM,EACfC,qBAAK,CAACC,MAAM,EACZjB,QAAQ,IAAIgB,qBAAK,CAAChB,QAAQ,E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,16 @@
|
|
|
10
10
|
width: fit-content;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.action:disabled {
|
|
13
|
+
.action:not(.disabled):hover {
|
|
14
|
+
color: var(--mirai-ui-content);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.action.disabled,
|
|
18
|
+
.action.disabled * {
|
|
14
19
|
color: var(--mirai-ui-action-color-disabled);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
.action:not(
|
|
22
|
+
.action:not(.disabled):active {
|
|
18
23
|
color: var(--mirai-ui-action-color-active);
|
|
19
24
|
}
|
|
20
25
|
|
|
@@ -46,3 +51,7 @@
|
|
|
46
51
|
.wide {
|
|
47
52
|
width: 100%;
|
|
48
53
|
}
|
|
54
|
+
|
|
55
|
+
.action * {
|
|
56
|
+
margin-right: calc(var(--mirai-ui-space-XS) / 2);
|
|
57
|
+
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.Story = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Action = require("./Action");
|
|
9
|
+
var _Icon = require("../../primitives/Icon");
|
|
9
10
|
var _Story$args;
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
@@ -22,15 +23,20 @@ var Story = function Story(props) {
|
|
|
22
23
|
exports.Story = Story;
|
|
23
24
|
Story.storyName = 'Action';
|
|
24
25
|
Story.args = (_Story$args = {
|
|
25
|
-
children:
|
|
26
|
+
children: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Icon.Icon, {
|
|
27
|
+
value: _Icon.ICON.INFO
|
|
28
|
+
}), "children"),
|
|
26
29
|
disabled: false,
|
|
30
|
+
href: '',
|
|
31
|
+
icon: '',
|
|
27
32
|
inline: false,
|
|
28
33
|
large: false,
|
|
29
34
|
small: false,
|
|
30
35
|
tag: 'button',
|
|
36
|
+
target: '',
|
|
31
37
|
underline: false,
|
|
32
38
|
wide: false
|
|
33
|
-
}, _defineProperty(_Story$args, 'data-testid', 'test-story'), _defineProperty(_Story$args, "
|
|
39
|
+
}, _defineProperty(_Story$args, 'data-testid', 'test-story'), _defineProperty(_Story$args, "style", {}), _Story$args);
|
|
34
40
|
Story.argTypes = {
|
|
35
41
|
onEnter: {
|
|
36
42
|
action: 'onEnter'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.stories.js","names":["title","Story","props","storyName","args","children","disabled","inline","large","small","tag","
|
|
1
|
+
{"version":3,"file":"Action.stories.js","names":["title","Story","props","storyName","args","children","ICON","INFO","disabled","href","icon","inline","large","small","tag","target","underline","wide","argTypes","onEnter","action","onLeave","onPress"],"sources":["../../../src/components/Action/Action.stories.jsx"],"sourcesContent":["import React from 'react';\n\nimport { Action } from './Action';\nimport { Icon, ICON } from '../../primitives/Icon';\n\nexport default { title: 'Components' };\n\nexport const Story = (props) => <Action {...props} />;\n\nStory.storyName = 'Action';\n\nStory.args = {\n children: (\n <>\n <Icon value={ICON.INFO} />\n children\n </>\n ),\n disabled: false,\n href: '',\n icon: '',\n inline: false,\n large: false,\n small: false,\n tag: 'button',\n target: '',\n underline: false,\n wide: false,\n // inherited properties\n ['data-testid']: 'test-story',\n style: {},\n};\n\nStory.argTypes = {\n onEnter: { action: 'onEnter' },\n onLeave: { action: 'onLeave' },\n onPress: { action: 'onPress' },\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AAAmD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAEpC;EAAEA,KAAK,EAAE;AAAa,CAAC;AAAA;AAE/B,IAAMC,KAAK,GAAG,SAARA,KAAK,CAAIC,KAAK;EAAA,oBAAK,6BAAC,cAAM,EAAKA,KAAK,CAAI;AAAA;AAAC;AAEtDD,KAAK,CAACE,SAAS,GAAG,QAAQ;AAE1BF,KAAK,CAACG,IAAI;EACRC,QAAQ,eACN,yEACE,6BAAC,UAAI;IAAC,KAAK,EAAEC,UAAI,CAACC;EAAK,EAAG,aAG7B;EACDC,QAAQ,EAAE,KAAK;EACfC,IAAI,EAAE,EAAE;EACRC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,KAAK;EACbC,KAAK,EAAE,KAAK;EACZC,KAAK,EAAE,KAAK;EACZC,GAAG,EAAE,QAAQ;EACbC,MAAM,EAAE,EAAE;EACVC,SAAS,EAAE,KAAK;EAChBC,IAAI,EAAE;AAAK,gCAEV,aAAa,EAAG,YAAY,yCACtB,CAAC,CAAC,eACV;AAEDhB,KAAK,CAACiB,QAAQ,GAAG;EACfC,OAAO,EAAE;IAAEC,MAAM,EAAE;EAAU,CAAC;EAC9BC,OAAO,EAAE;IAAED,MAAM,EAAE;EAAU,CAAC;EAC9BE,OAAO,EAAE;IAAEF,MAAM,EAAE;EAAU;AAC/B,CAAC"}
|
|
@@ -13,7 +13,7 @@ exports[`component:<Action> inherit:className 1`] = `
|
|
|
13
13
|
exports[`component:<Action> prop:disabled 1`] = `
|
|
14
14
|
<DocumentFragment>
|
|
15
15
|
<button
|
|
16
|
-
class="pressable disabled action"
|
|
16
|
+
class="pressable disabled action disabled"
|
|
17
17
|
disabled=""
|
|
18
18
|
>
|
|
19
19
|
children
|
|
@@ -21,6 +21,28 @@ exports[`component:<Action> prop:disabled 1`] = `
|
|
|
21
21
|
</DocumentFragment>
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
|
+
exports[`component:<Action> prop:href + prop:target 1`] = `
|
|
25
|
+
<DocumentFragment>
|
|
26
|
+
<a
|
|
27
|
+
class="pressable action"
|
|
28
|
+
href="soyjavi.com"
|
|
29
|
+
>
|
|
30
|
+
children
|
|
31
|
+
</a>
|
|
32
|
+
</DocumentFragment>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`component:<Action> prop:href 1`] = `
|
|
36
|
+
<DocumentFragment>
|
|
37
|
+
<a
|
|
38
|
+
class="pressable action"
|
|
39
|
+
href="soyjavi.com"
|
|
40
|
+
>
|
|
41
|
+
children
|
|
42
|
+
</a>
|
|
43
|
+
</DocumentFragment>
|
|
44
|
+
`;
|
|
45
|
+
|
|
24
46
|
exports[`component:<Action> prop:inline & prop:large 1`] = `
|
|
25
47
|
<DocumentFragment>
|
|
26
48
|
<button
|