@os-design/core 1.0.230 → 1.0.231
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/dist/cjs/ButtonLink/index.js +6 -1
- package/dist/cjs/ButtonLink/index.js.map +1 -1
- package/dist/cjs/Link/index.js +18 -5
- package/dist/cjs/Link/index.js.map +1 -1
- package/dist/cjs/LinkButton/index.js +20 -7
- package/dist/cjs/LinkButton/index.js.map +1 -1
- package/dist/esm/ButtonLink/index.js +6 -1
- package/dist/esm/ButtonLink/index.js.map +1 -1
- package/dist/esm/Link/index.js +34 -10
- package/dist/esm/Link/index.js.map +1 -1
- package/dist/esm/LinkButton/index.js +25 -9
- package/dist/esm/LinkButton/index.js.map +1 -1
- package/dist/types/ButtonLink/index.d.ts.map +1 -1
- package/dist/types/Link/index.d.ts +5 -0
- package/dist/types/Link/index.d.ts.map +1 -1
- package/dist/types/LinkButton/index.d.ts +1 -0
- package/dist/types/LinkButton/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/ButtonLink/index.tsx +8 -2
- package/src/Link/index.tsx +55 -13
- package/src/LinkButton/index.tsx +43 -12
|
@@ -12,6 +12,7 @@ var _react2 = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _Button = require("../Button");
|
|
13
13
|
var _ButtonContent = _interopRequireDefault(require("../Button/ButtonContent"));
|
|
14
14
|
var _useButtonColors2 = _interopRequireDefault(require("../Button/utils/useButtonColors"));
|
|
15
|
+
var _Link = require("../Link");
|
|
15
16
|
var _excluded = ["type", "danger", "left", "right", "wide", "loading", "disabled", "size", "as", "onMouseDown", "onKeyDown", "children"];
|
|
16
17
|
var _templateObject, _templateObject2;
|
|
17
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
@@ -57,7 +58,7 @@ var ButtonLink = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
|
57
58
|
}),
|
|
58
59
|
buttonColors = _useButtonColors.buttonColors,
|
|
59
60
|
loadingColors = _useButtonColors.loadingColors;
|
|
60
|
-
|
|
61
|
+
var link = /*#__PURE__*/_react2["default"].createElement(StyledButtonLink, _extends({
|
|
61
62
|
btnType: type,
|
|
62
63
|
colors: buttonColors,
|
|
63
64
|
wide: wide,
|
|
@@ -83,6 +84,10 @@ var ButtonLink = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
|
83
84
|
loading: loading,
|
|
84
85
|
loadingColors: loadingColors
|
|
85
86
|
}, children));
|
|
87
|
+
if (disabled || loading) {
|
|
88
|
+
return /*#__PURE__*/_react2["default"].createElement(_Link.DisabledWrapper, null, link);
|
|
89
|
+
}
|
|
90
|
+
return link;
|
|
86
91
|
});
|
|
87
92
|
ButtonLink.displayName = 'ButtonLink';
|
|
88
93
|
var _default = exports["default"] = ButtonLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_utils","_react2","_interopRequireWildcard","_Button","_ButtonContent","_useButtonColors2","_excluded","_templateObject","_templateObject2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","_taggedTemplateLiteral","strings","raw","slice","freeze","defineProperties","value","disabledStyles","p","disabled","css","StyledButtonLink","styled","StyledButton","withComponent","omitEmotionProps","ButtonLink","forwardRef","_ref","ref","_ref$type","type","_ref$danger","danger","left","right","_ref$wide","wide","_ref$loading","loading","_ref$disabled","size","as","_ref$onMouseDown","onMouseDown","_ref$onKeyDown","onKeyDown","children","rest","_useButtonColors","useButtonColors","buttonColors","loadingColors","createElement","btnType","colors","preventDefault","displayName","_default","exports"],"sources":["../../../src/ButtonLink/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\nimport { ButtonProps, StyledButton } from '../Button';\nimport ButtonContent from '../Button/ButtonContent';\nimport useButtonColors from '../Button/utils/useButtonColors';\nimport { LinkProps, ReactRouterLinkProps } from '../Link';\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'type' | 'ref'>;\nexport type ButtonLinkProps = JsxAProps &\n ReactRouterLinkProps &\n Pick<LinkProps, 'as'> &\n ButtonProps;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n pointer-events: none;\n `;\n\nconst StyledButtonLink = styled(\n StyledButton.withComponent('a'),\n omitEmotionProps('as', 'disabled')\n)`\n text-decoration: none;\n display: inline-flex;\n ${disabledStyles};\n`;\n\n/**\n * The button that is rendered as a link.\n */\nconst ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(\n (\n {\n type = 'primary',\n danger = false,\n left,\n right,\n wide = 'default',\n loading = false,\n disabled = false,\n size,\n as,\n onMouseDown = () => {},\n onKeyDown = () => {},\n children,\n ...rest\n },\n ref\n ) => {\n const { buttonColors, loadingColors } = useButtonColors({\n type,\n danger,\n disabled,\n });\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_utils","_react2","_interopRequireWildcard","_Button","_ButtonContent","_useButtonColors2","_Link","_excluded","_templateObject","_templateObject2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","_taggedTemplateLiteral","strings","raw","slice","freeze","defineProperties","value","disabledStyles","p","disabled","css","StyledButtonLink","styled","StyledButton","withComponent","omitEmotionProps","ButtonLink","forwardRef","_ref","ref","_ref$type","type","_ref$danger","danger","left","right","_ref$wide","wide","_ref$loading","loading","_ref$disabled","size","as","_ref$onMouseDown","onMouseDown","_ref$onKeyDown","onKeyDown","children","rest","_useButtonColors","useButtonColors","buttonColors","loadingColors","link","createElement","btnType","colors","preventDefault","DisabledWrapper","displayName","_default","exports"],"sources":["../../../src/ButtonLink/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\nimport { ButtonProps, StyledButton } from '../Button';\nimport ButtonContent from '../Button/ButtonContent';\nimport useButtonColors from '../Button/utils/useButtonColors';\nimport { DisabledWrapper, LinkProps, ReactRouterLinkProps } from '../Link';\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'type' | 'ref'>;\nexport type ButtonLinkProps = JsxAProps &\n ReactRouterLinkProps &\n Pick<LinkProps, 'as'> &\n ButtonProps;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n pointer-events: none;\n `;\n\nconst StyledButtonLink = styled(\n StyledButton.withComponent('a'),\n omitEmotionProps('as', 'disabled')\n)`\n text-decoration: none;\n display: inline-flex;\n ${disabledStyles};\n`;\n\n/**\n * The button that is rendered as a link.\n */\nconst ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(\n (\n {\n type = 'primary',\n danger = false,\n left,\n right,\n wide = 'default',\n loading = false,\n disabled = false,\n size,\n as,\n onMouseDown = () => {},\n onKeyDown = () => {},\n children,\n ...rest\n },\n ref\n ) => {\n const { buttonColors, loadingColors } = useButtonColors({\n type,\n danger,\n disabled,\n });\n\n const link = (\n <StyledButtonLink\n btnType={type}\n colors={buttonColors}\n wide={wide}\n loading={loading}\n disabled={disabled || loading}\n size={size}\n as={as}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n onKeyDown={(e) => {\n onKeyDown(e);\n if (disabled || loading) e.preventDefault();\n }}\n aria-disabled={disabled || loading}\n aria-busy={loading}\n {...rest}\n ref={ref}\n >\n <ButtonContent\n left={left}\n right={right}\n loading={loading}\n loadingColors={loadingColors}\n >\n {children}\n </ButtonContent>\n </StyledButtonLink>\n );\n\n if (disabled || loading) {\n return <DisabledWrapper>{link}</DisabledWrapper>;\n }\n\n return link;\n }\n);\n\nButtonLink.displayName = 'ButtonLink';\n\nexport default ButtonLink;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,uBAAA,CAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,iBAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAA2E,IAAAU,SAAA;AAAA,IAAAC,eAAA,EAAAC,gBAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OAAA,CAAAL,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA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AG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEvBnC,UAAU"}
|
package/dist/cjs/Link/index.js
CHANGED
|
@@ -4,15 +4,15 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.underlineHoverStyles = exports.underlineAlwaysStyles = exports["default"] = void 0;
|
|
7
|
+
exports.underlineHoverStyles = exports.underlineAlwaysStyles = exports["default"] = exports.DisabledWrapper = void 0;
|
|
8
8
|
var _react = require("@emotion/react");
|
|
9
9
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
10
|
var _styles = require("@os-design/styles");
|
|
11
11
|
var _theming = require("@os-design/theming");
|
|
12
12
|
var _utils = require("@os-design/utils");
|
|
13
13
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _excluded = ["underline", "as", "onMouseDown"];
|
|
15
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
14
|
+
var _excluded = ["underline", "disabled", "as", "onMouseDown"];
|
|
15
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -29,9 +29,13 @@ var underlineHoverStyles = exports.underlineHoverStyles = function underlineHove
|
|
|
29
29
|
var underlineAlwaysStyles = exports.underlineAlwaysStyles = function underlineAlwaysStyles(p) {
|
|
30
30
|
return p.underline === 'always' && (0, _react.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", ";\n\n &::after {\n width: 100%;\n opacity: 1;\n }\n "])), underlineBaseStyles(p));
|
|
31
31
|
};
|
|
32
|
-
var
|
|
32
|
+
var disabledStyles = function disabledStyles(p) {
|
|
33
|
+
return p.disabled && (0, _react.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n &,\n &:active,\n &:focus {\n color: ", ";\n }\n "])), (0, _theming.clr)(p.theme.inputColorPlaceholder));
|
|
34
|
+
};
|
|
35
|
+
var DisabledWrapper = exports.DisabledWrapper = _styled["default"].div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: inline-block;\n cursor: not-allowed;\n"])));
|
|
36
|
+
var StyledLink = (0, _styled["default"])('a', (0, _utils.omitEmotionProps)('size', 'underline', 'disabled', 'as'))(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ", ";\n\n cursor: pointer;\n text-decoration: none;\n line-height: 1.2;\n\n &,\n &:active,\n &:focus {\n color: ", ";\n }\n\n ", ";\n ", ";\n ", ";\n ", ";\n"])), _styles.resetFocusStyles, function (p) {
|
|
33
37
|
return (0, _theming.clr)(p.theme.linkColor);
|
|
34
|
-
}, underlineHoverStyles, underlineAlwaysStyles, _styles.sizeStyles);
|
|
38
|
+
}, underlineHoverStyles, underlineAlwaysStyles, disabledStyles, _styles.sizeStyles);
|
|
35
39
|
|
|
36
40
|
/**
|
|
37
41
|
* The link component to navigate between pages.
|
|
@@ -39,10 +43,19 @@ var StyledLink = (0, _styled["default"])('a', (0, _utils.omitEmotionProps)('size
|
|
|
39
43
|
var Link = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
40
44
|
var _ref$underline = _ref.underline,
|
|
41
45
|
underline = _ref$underline === void 0 ? 'hover' : _ref$underline,
|
|
46
|
+
_ref$disabled = _ref.disabled,
|
|
47
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
42
48
|
as = _ref.as,
|
|
43
49
|
_ref$onMouseDown = _ref.onMouseDown,
|
|
44
50
|
_onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
|
|
45
51
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
52
|
+
if (disabled) {
|
|
53
|
+
return /*#__PURE__*/_react2["default"].createElement(DisabledWrapper, null, /*#__PURE__*/_react2["default"].createElement(StyledLink, _extends({
|
|
54
|
+
disabled: true
|
|
55
|
+
}, rest, {
|
|
56
|
+
ref: ref
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
46
59
|
return /*#__PURE__*/_react2["default"].createElement(StyledLink, _extends({
|
|
47
60
|
underline: underline,
|
|
48
61
|
as: as,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_styles","_theming","_utils","_react2","_interopRequireWildcard","_excluded","_templateObject","_templateObject2","_templateObject3","_templateObject4","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","_taggedTemplateLiteral","strings","raw","slice","freeze","defineProperties","value","underlineBaseStyles","p","css","clr","theme","linkColor","underlineHoverStyles","exports","underline","transitionStyles","underlineAlwaysStyles","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_styles","_theming","_utils","_react2","_interopRequireWildcard","_excluded","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","_taggedTemplateLiteral","strings","raw","slice","freeze","defineProperties","value","underlineBaseStyles","p","css","clr","theme","linkColor","underlineHoverStyles","exports","underline","transitionStyles","underlineAlwaysStyles","disabledStyles","disabled","inputColorPlaceholder","DisabledWrapper","styled","div","StyledLink","omitEmotionProps","resetFocusStyles","sizeStyles","Link","forwardRef","_ref","ref","_ref$underline","_ref$disabled","as","_ref$onMouseDown","onMouseDown","rest","createElement","preventDefault","displayName","_default"],"sources":["../../../src/Link/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\n\nexport interface ReactRouterLinkProps {\n to?: string;\n replace?: boolean;\n}\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'ref'>;\nexport interface LinkProps extends JsxAProps, ReactRouterLinkProps, WithSize {\n /**\n * Type of the underline styles.\n * @default hover\n */\n underline?: 'hover' | 'always' | 'never';\n /**\n * Whether the link is disabled.\n * @default false\n */\n disabled?: boolean;\n /**\n * The custom link component.\n * For example, the Link from react-router-dom.\n * @default undefined\n */\n as?: React.ElementType;\n}\n\nconst underlineBaseStyles = (p) => css`\n position: relative;\n display: inline-block;\n padding-bottom: 0.1em;\n\n &::after {\n position: absolute;\n bottom: 0;\n left: 0;\n content: '';\n height: 0.125em;\n background-color: ${clr(p.theme.linkColor)};\n }\n`;\n\nexport const underlineHoverStyles = (p) =>\n p.underline === 'hover' &&\n css`\n @media (hover: hover) {\n ${underlineBaseStyles(p)};\n\n &::after {\n width: 0;\n opacity: 0;\n ${transitionStyles('width', 'opacity')(p)};\n }\n\n &:hover::after,\n &:focus::after {\n width: 100%;\n opacity: 1;\n }\n }\n `;\n\nexport const underlineAlwaysStyles = (p) =>\n p.underline === 'always' &&\n css`\n ${underlineBaseStyles(p)};\n\n &::after {\n width: 100%;\n opacity: 1;\n }\n `;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n pointer-events: none;\n\n &,\n &:active,\n &:focus {\n color: ${clr(p.theme.inputColorPlaceholder)};\n }\n `;\n\nexport const DisabledWrapper = styled.div`\n display: inline-block;\n cursor: not-allowed;\n`;\n\nconst StyledLink = styled(\n 'a',\n omitEmotionProps('size', 'underline', 'disabled', 'as')\n)<LinkProps>`\n ${resetFocusStyles};\n\n cursor: pointer;\n text-decoration: none;\n line-height: 1.2;\n\n &,\n &:active,\n &:focus {\n color: ${(p) => clr(p.theme.linkColor)};\n }\n\n ${underlineHoverStyles};\n ${underlineAlwaysStyles};\n ${disabledStyles};\n ${sizeStyles};\n`;\n\n/**\n * The link component to navigate between pages.\n */\nconst Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n {\n underline = 'hover',\n disabled = false,\n as,\n onMouseDown = () => {},\n ...rest\n },\n ref\n ) => {\n if (disabled) {\n return (\n <DisabledWrapper>\n <StyledLink disabled {...rest} ref={ref} />\n </DisabledWrapper>\n );\n }\n\n return (\n <StyledLink\n underline={underline}\n as={as}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n {...rest}\n ref={ref}\n />\n );\n }\n);\n\nLink.displayName = 'Link';\n\nexport default Link;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF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AAAuC,IAAA,EAAA7E,SAAA;EAIT,IAAIkE,QAAQ,EAAE;IACZ,oBACEpE,OAAA,YAAAuF,aAAA,CAACjB,eAAe,qBACdtE,OAAA,YAAAuF,aAAA,CAACd,UAAU,EAAA1C,QAAA;MAACqC,QAAQ;IAAA,GAAKkB,IAAI;MAAEN,GAAG,EAAEA;IAAI,EAAE,CAC3B,CAAC;EAEtB;EAEA,oBACEhF,OAAA,YAAAuF,aAAA,CAACd,UAAU,EAAA1C,QAAA;IACTiC,SAAS,EAAEA,SAAU;IACrBmB,EAAE,EAAEA,EAAG;IACPE,WAAW,EAAE,SAAAA,YAAC3E,CAAC,EAAK;MAClB2E,YAAW,CAAC3E,CAAC,CAAC;MACdA,CAAC,CAAC8E,cAAc,CAAC,CAAC;IACpB;EAAE,GACEF,IAAI;IACRN,GAAG,EAAEA;EAAI,EACV,CAAC;AAEN,CACF,CAAC;AAEDH,IAAI,CAACY,WAAW,GAAG,MAAM;AAAC,IAAAC,QAAA,GAAA3B,OAAA,cAEXc,IAAI"}
|
|
@@ -5,14 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
+
var _react = require("@emotion/react");
|
|
8
9
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
10
|
var _styles = require("@os-design/styles");
|
|
10
11
|
var _theming = require("@os-design/theming");
|
|
11
12
|
var _utils = require("@os-design/utils");
|
|
12
|
-
var
|
|
13
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
13
14
|
var _Link = require("../Link");
|
|
14
|
-
var _excluded = ["underline", "onMouseDown"];
|
|
15
|
-
var _templateObject;
|
|
15
|
+
var _excluded = ["underline", "disabled", "onMouseDown"];
|
|
16
|
+
var _templateObject, _templateObject2;
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -20,20 +21,32 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
20
21
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
22
|
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; }
|
|
22
23
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
23
|
-
var
|
|
24
|
+
var disabledStyles = function disabledStyles(p) {
|
|
25
|
+
return p.disabled && (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: inherit;\n color: ", ";\n "])), (0, _theming.clr)(p.theme.inputColorPlaceholder));
|
|
26
|
+
};
|
|
27
|
+
var StyledButton = (0, _styled["default"])('button', (0, _utils.omitEmotionProps)('size', 'underline'))(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n\n cursor: pointer;\n text-align: left;\n line-height: 1.2;\n color: ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n"])), _styles.resetButtonStyles, function (p) {
|
|
24
28
|
return (0, _theming.clr)(p.theme.linkColor);
|
|
25
|
-
}, _Link.underlineHoverStyles, _Link.underlineAlwaysStyles, _styles.sizeStyles);
|
|
29
|
+
}, _Link.underlineHoverStyles, _Link.underlineAlwaysStyles, disabledStyles, _styles.sizeStyles);
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* The link component that is rendered as a button.
|
|
29
33
|
*/
|
|
30
|
-
var LinkButton = /*#__PURE__*/(0,
|
|
34
|
+
var LinkButton = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
31
35
|
var _ref$underline = _ref.underline,
|
|
32
36
|
underline = _ref$underline === void 0 ? 'hover' : _ref$underline,
|
|
37
|
+
_ref$disabled = _ref.disabled,
|
|
38
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
33
39
|
_ref$onMouseDown = _ref.onMouseDown,
|
|
34
40
|
_onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
|
|
35
41
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
-
|
|
42
|
+
if (disabled) {
|
|
43
|
+
return /*#__PURE__*/_react2["default"].createElement(_Link.DisabledWrapper, null, /*#__PURE__*/_react2["default"].createElement(StyledButton, _extends({
|
|
44
|
+
disabled: true
|
|
45
|
+
}, rest, {
|
|
46
|
+
ref: ref
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/_react2["default"].createElement(StyledButton, _extends({
|
|
37
50
|
underline: underline,
|
|
38
51
|
onMouseDown: function onMouseDown(e) {
|
|
39
52
|
_onMouseDown(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_styles","_theming","_utils","_react2","_interopRequireWildcard","_Link","_excluded","_templateObject","_templateObject2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","_extends","assign","bind","target","arguments","length","source","key","apply","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","_taggedTemplateLiteral","strings","raw","slice","freeze","defineProperties","value","disabledStyles","p","disabled","css","clr","theme","inputColorPlaceholder","StyledButton","styled","omitEmotionProps","resetButtonStyles","linkColor","underlineHoverStyles","underlineAlwaysStyles","sizeStyles","LinkButton","forwardRef","_ref","ref","_ref$underline","underline","_ref$disabled","_ref$onMouseDown","onMouseDown","rest","createElement","DisabledWrapper","preventDefault","displayName","_default","exports"],"sources":["../../../src/LinkButton/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { resetButtonStyles, sizeStyles, WithSize } from '@os-design/styles';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\nimport {\n DisabledWrapper,\n underlineAlwaysStyles,\n underlineHoverStyles,\n} from '../Link';\n\ntype JsxButtonProps = Omit<JSX.IntrinsicElements['button'], 'ref'>;\n\nexport interface LinkButtonProps extends JsxButtonProps, WithSize {\n /**\n * Type of the underline styles.\n * @default hover\n */\n underline?: 'hover' | 'always' | 'never';\n /**\n * Whether the link is disabled.\n * @default false\n */\n disabled?: boolean;\n}\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n cursor: inherit;\n color: ${clr(p.theme.inputColorPlaceholder)};\n `;\n\nconst StyledButton = styled(\n 'button',\n omitEmotionProps('size', 'underline')\n)<LinkButtonProps>`\n ${resetButtonStyles};\n\n cursor: pointer;\n text-align: left;\n line-height: 1.2;\n color: ${(p) => clr(p.theme.linkColor)};\n\n ${underlineHoverStyles};\n ${underlineAlwaysStyles};\n ${disabledStyles};\n ${sizeStyles};\n`;\n\n/**\n * The link component that is rendered as a button.\n */\nconst LinkButton = forwardRef<HTMLButtonElement, LinkButtonProps>(\n (\n { underline = 'hover', disabled = false, onMouseDown = () => {}, ...rest },\n ref\n ) => {\n if (disabled) {\n return (\n <DisabledWrapper>\n <StyledButton disabled {...rest} ref={ref} />\n </DisabledWrapper>\n );\n }\n\n return (\n <StyledButton\n underline={underline}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n {...rest}\n ref={ref}\n />\n );\n }\n);\n\nLinkButton.displayName = 'LinkButton';\n\nexport default LinkButton;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAC,uBAAA,CAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAIiB,IAAAS,SAAA;AAAA,IAAAC,eAAA,EAAAC,gBAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OAAA,CAAAL,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAA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IACX6C,SAAS,EAAEA,SAAU;IACrBG,WAAW,EAAE,SAAAA,YAACrE,CAAC,EAAK;MAClBqE,YAAW,CAACrE,CAAC,CAAC;MACdA,CAAC,CAACyE,cAAc,CAAC,CAAC;IACpB;EAAE,GACEH,IAAI;IACRN,GAAG,EAAEA;EAAI,EACV,CAAC;AAEN,CACF,CAAC;AAEDH,UAAU,CAACa,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEvBf,UAAU"}
|
|
@@ -6,6 +6,7 @@ import React, { forwardRef } from 'react';
|
|
|
6
6
|
import { StyledButton } from '../Button';
|
|
7
7
|
import ButtonContent from '../Button/ButtonContent';
|
|
8
8
|
import useButtonColors from '../Button/utils/useButtonColors';
|
|
9
|
+
import { DisabledWrapper } from '../Link';
|
|
9
10
|
const disabledStyles = p => p.disabled && css`
|
|
10
11
|
pointer-events: none;
|
|
11
12
|
`;
|
|
@@ -41,7 +42,7 @@ const ButtonLink = /*#__PURE__*/forwardRef(({
|
|
|
41
42
|
danger,
|
|
42
43
|
disabled
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
+
const link = /*#__PURE__*/React.createElement(StyledButtonLink, _extends({
|
|
45
46
|
btnType: type,
|
|
46
47
|
colors: buttonColors,
|
|
47
48
|
wide: wide,
|
|
@@ -67,6 +68,10 @@ const ButtonLink = /*#__PURE__*/forwardRef(({
|
|
|
67
68
|
loading: loading,
|
|
68
69
|
loadingColors: loadingColors
|
|
69
70
|
}, children));
|
|
71
|
+
if (disabled || loading) {
|
|
72
|
+
return /*#__PURE__*/React.createElement(DisabledWrapper, null, link);
|
|
73
|
+
}
|
|
74
|
+
return link;
|
|
70
75
|
});
|
|
71
76
|
ButtonLink.displayName = 'ButtonLink';
|
|
72
77
|
export default ButtonLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["css","styled","omitEmotionProps","React","forwardRef","StyledButton","ButtonContent","useButtonColors","disabledStyles","p","disabled","StyledButtonLink","withComponent","ButtonLink","type","danger","left","right","wide","loading","size","as","onMouseDown","onKeyDown","children","rest","ref","buttonColors","loadingColors","createElement","_extends","btnType","colors","e","preventDefault","displayName"],"sources":["../../../src/ButtonLink/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\nimport { ButtonProps, StyledButton } from '../Button';\nimport ButtonContent from '../Button/ButtonContent';\nimport useButtonColors from '../Button/utils/useButtonColors';\nimport { LinkProps, ReactRouterLinkProps } from '../Link';\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'type' | 'ref'>;\nexport type ButtonLinkProps = JsxAProps &\n ReactRouterLinkProps &\n Pick<LinkProps, 'as'> &\n ButtonProps;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n pointer-events: none;\n `;\n\nconst StyledButtonLink = styled(\n StyledButton.withComponent('a'),\n omitEmotionProps('as', 'disabled')\n)`\n text-decoration: none;\n display: inline-flex;\n ${disabledStyles};\n`;\n\n/**\n * The button that is rendered as a link.\n */\nconst ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(\n (\n {\n type = 'primary',\n danger = false,\n left,\n right,\n wide = 'default',\n loading = false,\n disabled = false,\n size,\n as,\n onMouseDown = () => {},\n onKeyDown = () => {},\n children,\n ...rest\n },\n ref\n ) => {\n const { buttonColors, loadingColors } = useButtonColors({\n type,\n danger,\n disabled,\n });\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["css","styled","omitEmotionProps","React","forwardRef","StyledButton","ButtonContent","useButtonColors","DisabledWrapper","disabledStyles","p","disabled","StyledButtonLink","withComponent","ButtonLink","type","danger","left","right","wide","loading","size","as","onMouseDown","onKeyDown","children","rest","ref","buttonColors","loadingColors","link","createElement","_extends","btnType","colors","e","preventDefault","displayName"],"sources":["../../../src/ButtonLink/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\nimport { ButtonProps, StyledButton } from '../Button';\nimport ButtonContent from '../Button/ButtonContent';\nimport useButtonColors from '../Button/utils/useButtonColors';\nimport { DisabledWrapper, LinkProps, ReactRouterLinkProps } from '../Link';\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'type' | 'ref'>;\nexport type ButtonLinkProps = JsxAProps &\n ReactRouterLinkProps &\n Pick<LinkProps, 'as'> &\n ButtonProps;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n pointer-events: none;\n `;\n\nconst StyledButtonLink = styled(\n StyledButton.withComponent('a'),\n omitEmotionProps('as', 'disabled')\n)`\n text-decoration: none;\n display: inline-flex;\n ${disabledStyles};\n`;\n\n/**\n * The button that is rendered as a link.\n */\nconst ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(\n (\n {\n type = 'primary',\n danger = false,\n left,\n right,\n wide = 'default',\n loading = false,\n disabled = false,\n size,\n as,\n onMouseDown = () => {},\n onKeyDown = () => {},\n children,\n ...rest\n },\n ref\n ) => {\n const { buttonColors, loadingColors } = useButtonColors({\n type,\n danger,\n disabled,\n });\n\n const link = (\n <StyledButtonLink\n btnType={type}\n colors={buttonColors}\n wide={wide}\n loading={loading}\n disabled={disabled || loading}\n size={size}\n as={as}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n onKeyDown={(e) => {\n onKeyDown(e);\n if (disabled || loading) e.preventDefault();\n }}\n aria-disabled={disabled || loading}\n aria-busy={loading}\n {...rest}\n ref={ref}\n >\n <ButtonContent\n left={left}\n right={right}\n loading={loading}\n loadingColors={loadingColors}\n >\n {children}\n </ButtonContent>\n </StyledButtonLink>\n );\n\n if (disabled || loading) {\n return <DisabledWrapper>{link}</DisabledWrapper>;\n }\n\n return link;\n }\n);\n\nButtonLink.displayName = 'ButtonLink';\n\nexport default ButtonLink;\n"],"mappings":";AAAA,SAASA,GAAG,QAA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OAAQ;IAC9BC,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEA,EAAG;IACPC,WAAW,EAAGY,CAAC,IAAK;MAClBZ,WAAW,CAACY,CAAC,CAAC;MACdA,CAAC,CAACC,cAAc,CAAC,CAAC;IACpB,CAAE;IACFZ,SAAS,EAAGW,CAAC,IAAK;MAChBX,SAAS,CAACW,CAAC,CAAC;MACZ,IAAIxB,QAAQ,IAAIS,OAAO,EAAEe,CAAC,CAACC,cAAc,CAAC,CAAC;IAC7C,CAAE;IACF,iBAAezB,QAAQ,IAAIS,OAAQ;IACnC,aAAWA;EAAQ,GACfM,IAAI;IACRC,GAAG,EAAEA;EAAI,iBAETxB,KAAA,CAAA4B,aAAA,CAACzB,aAAa;IACZW,IAAI,EAAEA,IAAK;IACXC,KAAK,EAAEA,KAAM;IACbE,OAAO,EAAEA,OAAQ;IACjBS,aAAa,EAAEA;EAAc,GAE5BJ,QACY,CACC,CACnB;EAED,IAAId,QAAQ,IAAIS,OAAO,EAAE;IACvB,oBAAOjB,KAAA,CAAA4B,aAAA,CAACvB,eAAe,QAAEsB,IAAsB,CAAC;EAClD;EAEA,OAAOA,IAAI;AACb,CACF,CAAC;AAEDhB,UAAU,CAACuB,WAAW,GAAG,YAAY;AAErC,eAAevB,UAAU"}
|
package/dist/esm/Link/index.js
CHANGED
|
@@ -44,7 +44,20 @@ export const underlineAlwaysStyles = p => p.underline === 'always' && css`
|
|
|
44
44
|
opacity: 1;
|
|
45
45
|
}
|
|
46
46
|
`;
|
|
47
|
-
const
|
|
47
|
+
const disabledStyles = p => p.disabled && css`
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
|
|
50
|
+
&,
|
|
51
|
+
&:active,
|
|
52
|
+
&:focus {
|
|
53
|
+
color: ${clr(p.theme.inputColorPlaceholder)};
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
export const DisabledWrapper = styled.div`
|
|
57
|
+
display: inline-block;
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
`;
|
|
60
|
+
const StyledLink = styled('a', omitEmotionProps('size', 'underline', 'disabled', 'as'))`
|
|
48
61
|
${resetFocusStyles};
|
|
49
62
|
|
|
50
63
|
cursor: pointer;
|
|
@@ -59,6 +72,7 @@ const StyledLink = styled('a', omitEmotionProps('size', 'underline', 'as'))`
|
|
|
59
72
|
|
|
60
73
|
${underlineHoverStyles};
|
|
61
74
|
${underlineAlwaysStyles};
|
|
75
|
+
${disabledStyles};
|
|
62
76
|
${sizeStyles};
|
|
63
77
|
`;
|
|
64
78
|
|
|
@@ -67,19 +81,29 @@ const StyledLink = styled('a', omitEmotionProps('size', 'underline', 'as'))`
|
|
|
67
81
|
*/
|
|
68
82
|
const Link = /*#__PURE__*/forwardRef(({
|
|
69
83
|
underline = 'hover',
|
|
84
|
+
disabled = false,
|
|
70
85
|
as,
|
|
71
86
|
onMouseDown = () => {},
|
|
72
87
|
...rest
|
|
73
|
-
}, ref) =>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
}, ref) => {
|
|
89
|
+
if (disabled) {
|
|
90
|
+
return /*#__PURE__*/React.createElement(DisabledWrapper, null, /*#__PURE__*/React.createElement(StyledLink, _extends({
|
|
91
|
+
disabled: true
|
|
92
|
+
}, rest, {
|
|
93
|
+
ref: ref
|
|
94
|
+
})));
|
|
79
95
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
return /*#__PURE__*/React.createElement(StyledLink, _extends({
|
|
97
|
+
underline: underline,
|
|
98
|
+
as: as,
|
|
99
|
+
onMouseDown: e => {
|
|
100
|
+
onMouseDown(e);
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
}
|
|
103
|
+
}, rest, {
|
|
104
|
+
ref: ref
|
|
105
|
+
}));
|
|
106
|
+
});
|
|
83
107
|
Link.displayName = 'Link';
|
|
84
108
|
export default Link;
|
|
85
109
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["css","styled","resetFocusStyles","sizeStyles","transitionStyles","clr","omitEmotionProps","React","forwardRef","underlineBaseStyles","p","theme","linkColor","underlineHoverStyles","underline","underlineAlwaysStyles","StyledLink","Link","as","onMouseDown","rest","ref","createElement","_extends","e","preventDefault","displayName"],"sources":["../../../src/Link/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\n\nexport interface ReactRouterLinkProps {\n to?: string;\n replace?: boolean;\n}\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'ref'>;\nexport interface LinkProps extends JsxAProps, ReactRouterLinkProps, WithSize {\n /**\n * Type of the underline styles.\n * @default hover\n */\n underline?: 'hover' | 'always' | 'never';\n /**\n * The custom link component.\n * For example, the Link from react-router-dom.\n * @default undefined\n */\n as?: React.ElementType;\n}\n\nconst underlineBaseStyles = (p) => css`\n position: relative;\n display: inline-block;\n padding-bottom: 0.1em;\n\n &::after {\n position: absolute;\n bottom: 0;\n left: 0;\n content: '';\n height: 0.125em;\n background-color: ${clr(p.theme.linkColor)};\n }\n`;\n\nexport const underlineHoverStyles = (p) =>\n p.underline === 'hover' &&\n css`\n @media (hover: hover) {\n ${underlineBaseStyles(p)};\n\n &::after {\n width: 0;\n opacity: 0;\n ${transitionStyles('width', 'opacity')(p)};\n }\n\n &:hover::after,\n &:focus::after {\n width: 100%;\n opacity: 1;\n }\n }\n `;\n\nexport const underlineAlwaysStyles = (p) =>\n p.underline === 'always' &&\n css`\n ${underlineBaseStyles(p)};\n\n &::after {\n width: 100%;\n opacity: 1;\n }\n `;\n\nconst StyledLink = styled(\n 'a',\n omitEmotionProps('size', 'underline', 'as')\n)<LinkProps>`\n ${resetFocusStyles};\n\n cursor: pointer;\n text-decoration: none;\n line-height: 1.2;\n\n &,\n &:active,\n &:focus {\n color: ${(p) => clr(p.theme.linkColor)};\n }\n\n ${underlineHoverStyles};\n ${underlineAlwaysStyles};\n ${sizeStyles};\n`;\n\n/**\n * The link component to navigate between pages.\n */\nconst Link = forwardRef<HTMLAnchorElement, LinkProps>(\n ({
|
|
1
|
+
{"version":3,"file":"index.js","names":["css","styled","resetFocusStyles","sizeStyles","transitionStyles","clr","omitEmotionProps","React","forwardRef","underlineBaseStyles","p","theme","linkColor","underlineHoverStyles","underline","underlineAlwaysStyles","disabledStyles","disabled","inputColorPlaceholder","DisabledWrapper","div","StyledLink","Link","as","onMouseDown","rest","ref","createElement","_extends","e","preventDefault","displayName"],"sources":["../../../src/Link/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport {\n resetFocusStyles,\n sizeStyles,\n transitionStyles,\n WithSize,\n} from '@os-design/styles';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\n\nexport interface ReactRouterLinkProps {\n to?: string;\n replace?: boolean;\n}\n\ntype JsxAProps = Omit<JSX.IntrinsicElements['a'], 'ref'>;\nexport interface LinkProps extends JsxAProps, ReactRouterLinkProps, WithSize {\n /**\n * Type of the underline styles.\n * @default hover\n */\n underline?: 'hover' | 'always' | 'never';\n /**\n * Whether the link is disabled.\n * @default false\n */\n disabled?: boolean;\n /**\n * The custom link component.\n * For example, the Link from react-router-dom.\n * @default undefined\n */\n as?: React.ElementType;\n}\n\nconst underlineBaseStyles = (p) => css`\n position: relative;\n display: inline-block;\n padding-bottom: 0.1em;\n\n &::after {\n position: absolute;\n bottom: 0;\n left: 0;\n content: '';\n height: 0.125em;\n background-color: ${clr(p.theme.linkColor)};\n }\n`;\n\nexport const underlineHoverStyles = (p) =>\n p.underline === 'hover' &&\n css`\n @media (hover: hover) {\n ${underlineBaseStyles(p)};\n\n &::after {\n width: 0;\n opacity: 0;\n ${transitionStyles('width', 'opacity')(p)};\n }\n\n &:hover::after,\n &:focus::after {\n width: 100%;\n opacity: 1;\n }\n }\n `;\n\nexport const underlineAlwaysStyles = (p) =>\n p.underline === 'always' &&\n css`\n ${underlineBaseStyles(p)};\n\n &::after {\n width: 100%;\n opacity: 1;\n }\n `;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n pointer-events: none;\n\n &,\n &:active,\n &:focus {\n color: ${clr(p.theme.inputColorPlaceholder)};\n }\n `;\n\nexport const DisabledWrapper = styled.div`\n display: inline-block;\n cursor: not-allowed;\n`;\n\nconst StyledLink = styled(\n 'a',\n omitEmotionProps('size', 'underline', 'disabled', 'as')\n)<LinkProps>`\n ${resetFocusStyles};\n\n cursor: pointer;\n text-decoration: none;\n line-height: 1.2;\n\n &,\n &:active,\n &:focus {\n color: ${(p) => clr(p.theme.linkColor)};\n }\n\n ${underlineHoverStyles};\n ${underlineAlwaysStyles};\n ${disabledStyles};\n ${sizeStyles};\n`;\n\n/**\n * The link component to navigate between pages.\n */\nconst Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n {\n underline = 'hover',\n disabled = false,\n as,\n onMouseDown = () => {},\n ...rest\n },\n ref\n ) => {\n if (disabled) {\n return (\n <DisabledWrapper>\n <StyledLink disabled {...rest} ref={ref} />\n </DisabledWrapper>\n );\n }\n\n return (\n <StyledLink\n underline={underline}\n as={as}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n {...rest}\n ref={ref}\n />\n );\n }\n);\n\nLink.displayName = 'Link';\n\nexport default Link;\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SACEC,gBAAgB,EAChBC,UAAU,EACVC,gBAAgB,QAEX,mBAAmB;AAC1B,SAASC,GAAG,QAAQ,oBAAoB;AACxC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;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C;;AAED;AACA;AACA;AACA,MAAMmB,IAAI,gBAAGd,UAAU,CACrB,CACE;EACEM,SAAS,GAAG,OAAO;EACnBG,QAAQ,GAAG,KAAK;EAChBM,EAAE;EACFC,WAAW,GAAGA,CAAA,KAAM,CAAC,CAAC;EACtB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,IAAIT,QAAQ,EAAE;IACZ,oBACEV,KAAA,CAAAoB,aAAA,CAACR,eAAe,qBACdZ,KAAA,CAAAoB,aAAA,CAACN,UAAU,EAAAO,QAAA;MAACX,QAAQ;IAAA,GAAKQ,IAAI;MAAEC,GAAG,EAAEA;IAAI,EAAE,CAC3B,CAAC;EAEtB;EAEA,oBACEnB,KAAA,CAAAoB,aAAA,CAACN,UAAU,EAAAO,QAAA;IACTd,SAAS,EAAEA,SAAU;IACrBS,EAAE,EAAEA,EAAG;IACPC,WAAW,EAAGK,CAAC,IAAK;MAClBL,WAAW,CAACK,CAAC,CAAC;MACdA,CAAC,CAACC,cAAc,CAAC,CAAC;IACpB;EAAE,GACEL,IAAI;IACRC,GAAG,EAAEA;EAAI,EACV,CAAC;AAEN,CACF,CAAC;AAEDJ,IAAI,CAACS,WAAW,GAAG,MAAM;AAEzB,eAAeT,IAAI"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import { css } from '@emotion/react';
|
|
2
3
|
import styled from '@emotion/styled';
|
|
3
4
|
import { resetButtonStyles, sizeStyles } from '@os-design/styles';
|
|
4
5
|
import { clr } from '@os-design/theming';
|
|
5
6
|
import { omitEmotionProps } from '@os-design/utils';
|
|
6
7
|
import React, { forwardRef } from 'react';
|
|
7
|
-
import { underlineAlwaysStyles, underlineHoverStyles } from '../Link';
|
|
8
|
+
import { DisabledWrapper, underlineAlwaysStyles, underlineHoverStyles } from '../Link';
|
|
9
|
+
const disabledStyles = p => p.disabled && css`
|
|
10
|
+
cursor: inherit;
|
|
11
|
+
color: ${clr(p.theme.inputColorPlaceholder)};
|
|
12
|
+
`;
|
|
8
13
|
const StyledButton = styled('button', omitEmotionProps('size', 'underline'))`
|
|
9
14
|
${resetButtonStyles};
|
|
10
15
|
|
|
@@ -15,6 +20,7 @@ const StyledButton = styled('button', omitEmotionProps('size', 'underline'))`
|
|
|
15
20
|
|
|
16
21
|
${underlineHoverStyles};
|
|
17
22
|
${underlineAlwaysStyles};
|
|
23
|
+
${disabledStyles};
|
|
18
24
|
${sizeStyles};
|
|
19
25
|
`;
|
|
20
26
|
|
|
@@ -23,17 +29,27 @@ const StyledButton = styled('button', omitEmotionProps('size', 'underline'))`
|
|
|
23
29
|
*/
|
|
24
30
|
const LinkButton = /*#__PURE__*/forwardRef(({
|
|
25
31
|
underline = 'hover',
|
|
32
|
+
disabled = false,
|
|
26
33
|
onMouseDown = () => {},
|
|
27
34
|
...rest
|
|
28
|
-
}, ref) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
}, ref) => {
|
|
36
|
+
if (disabled) {
|
|
37
|
+
return /*#__PURE__*/React.createElement(DisabledWrapper, null, /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
38
|
+
disabled: true
|
|
39
|
+
}, rest, {
|
|
40
|
+
ref: ref
|
|
41
|
+
})));
|
|
33
42
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
return /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
44
|
+
underline: underline,
|
|
45
|
+
onMouseDown: e => {
|
|
46
|
+
onMouseDown(e);
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
}
|
|
49
|
+
}, rest, {
|
|
50
|
+
ref: ref
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
37
53
|
LinkButton.displayName = 'LinkButton';
|
|
38
54
|
export default LinkButton;
|
|
39
55
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["styled","resetButtonStyles","sizeStyles","clr","omitEmotionProps","React","forwardRef","underlineAlwaysStyles","underlineHoverStyles","
|
|
1
|
+
{"version":3,"file":"index.js","names":["css","styled","resetButtonStyles","sizeStyles","clr","omitEmotionProps","React","forwardRef","DisabledWrapper","underlineAlwaysStyles","underlineHoverStyles","disabledStyles","p","disabled","theme","inputColorPlaceholder","StyledButton","linkColor","LinkButton","underline","onMouseDown","rest","ref","createElement","_extends","e","preventDefault","displayName"],"sources":["../../../src/LinkButton/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { resetButtonStyles, sizeStyles, WithSize } from '@os-design/styles';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React, { forwardRef } from 'react';\nimport {\n DisabledWrapper,\n underlineAlwaysStyles,\n underlineHoverStyles,\n} from '../Link';\n\ntype JsxButtonProps = Omit<JSX.IntrinsicElements['button'], 'ref'>;\n\nexport interface LinkButtonProps extends JsxButtonProps, WithSize {\n /**\n * Type of the underline styles.\n * @default hover\n */\n underline?: 'hover' | 'always' | 'never';\n /**\n * Whether the link is disabled.\n * @default false\n */\n disabled?: boolean;\n}\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n cursor: inherit;\n color: ${clr(p.theme.inputColorPlaceholder)};\n `;\n\nconst StyledButton = styled(\n 'button',\n omitEmotionProps('size', 'underline')\n)<LinkButtonProps>`\n ${resetButtonStyles};\n\n cursor: pointer;\n text-align: left;\n line-height: 1.2;\n color: ${(p) => clr(p.theme.linkColor)};\n\n ${underlineHoverStyles};\n ${underlineAlwaysStyles};\n ${disabledStyles};\n ${sizeStyles};\n`;\n\n/**\n * The link component that is rendered as a button.\n */\nconst LinkButton = forwardRef<HTMLButtonElement, LinkButtonProps>(\n (\n { underline = 'hover', disabled = false, onMouseDown = () => {}, ...rest },\n ref\n ) => {\n if (disabled) {\n return (\n <DisabledWrapper>\n <StyledButton disabled {...rest} ref={ref} />\n </DisabledWrapper>\n );\n }\n\n return (\n <StyledButton\n underline={underline}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n {...rest}\n ref={ref}\n />\n );\n }\n);\n\nLinkButton.displayName = 'LinkButton';\n\nexport default LinkButton;\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,iBAAiB,EAAEC,UAAU,QAAkB,mBAAmB;AAC3E,SAASC,GAAG,QAAQ,oBAAoB;AACxC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SACEC,eAAe,EACfC,qBAAqB,EACrBC,oBAAoB,QACf,SAAS;AAiBhB,MAAMC,cAAc,GAAIC,CAAC,IACvBA,CAAC,CAACC,QAAQ,IACVb,GAAI;AACN;AACA,aAAaI,GAAG,CAACQ,CAAC,CAACE,KAAK,CAACC,qBAAqB,CAAE;AAChD,GAAG;AAEH,MAAMC,YAAY,GAAGf,MAAM,CACzB,QAAQ,EACRI,gBAAgB,CAAC,MAAM,EAAE,WAAW,CACtC,CAAmB;AACnB,IAAIH,iBAAkB;AACtB;AACA;AACA;AACA;AACA,WAAYU,CAAC,IAAKR,GAAG,CAACQ,CAAC,CAACE,KAAK,CAACG,SAAS,CAAE;AACzC;AACA,IAAIP,oBAAqB;AACzB,IAAID,qBAAsB;AAC1B,IAAIE,cAAe;AACnB,IAAIR,UAAW;AACf,CAAC;;AAED;AACA;AACA;AACA,MAAMe,UAAU,gBAAGX,UAAU,CAC3B,CACE;EAAEY,SAAS,GAAG,OAAO;EAAEN,QAAQ,GAAG,KAAK;EAAEO,WAAW,GAAGA,CAAA,KAAM,CAAC,CAAC;EAAE,GAAGC;AAAK,CAAC,EAC1EC,GAAG,KACA;EACH,IAAIT,QAAQ,EAAE;IACZ,oBACEP,KAAA,CAAAiB,aAAA,CAACf,eAAe,qBACdF,KAAA,CAAAiB,aAAA,CAACP,YAAY,EAAAQ,QAAA;MAACX,QAAQ;IAAA,GAAKQ,IAAI;MAAEC,GAAG,EAAEA;IAAI,EAAE,CAC7B,CAAC;EAEtB;EAEA,oBACEhB,KAAA,CAAAiB,aAAA,CAACP,YAAY,EAAAQ,QAAA;IACXL,SAAS,EAAEA,SAAU;IACrBC,WAAW,EAAGK,CAAC,IAAK;MAClBL,WAAW,CAACK,CAAC,CAAC;MACdA,CAAC,CAACC,cAAc,CAAC,CAAC;IACpB;EAAE,GACEL,IAAI;IACRC,GAAG,EAAEA;EAAI,EACV,CAAC;AAEN,CACF,CAAC;AAEDJ,UAAU,CAACS,WAAW,GAAG,YAAY;AAErC,eAAeT,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ButtonLink/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAgB,MAAM,WAAW,CAAC;AAGtD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ButtonLink/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAgB,MAAM,WAAW,CAAC;AAGtD,OAAO,EAAmB,SAAS,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE3E,KAAK,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,SAAS,GACrC,oBAAoB,GACpB,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GACrB,WAAW,CAAC;AAoBd,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iFAgEf,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
|
@@ -7,10 +7,15 @@ export interface ReactRouterLinkProps {
|
|
|
7
7
|
type JsxAProps = Omit<JSX.IntrinsicElements['a'], 'ref'>;
|
|
8
8
|
export interface LinkProps extends JsxAProps, ReactRouterLinkProps, WithSize {
|
|
9
9
|
underline?: 'hover' | 'always' | 'never';
|
|
10
|
+
disabled?: boolean;
|
|
10
11
|
as?: React.ElementType;
|
|
11
12
|
}
|
|
12
13
|
export declare const underlineHoverStyles: (p: any) => false | import("@emotion/utils").SerializedStyles;
|
|
13
14
|
export declare const underlineAlwaysStyles: (p: any) => false | import("@emotion/utils").SerializedStyles;
|
|
15
|
+
export declare const DisabledWrapper: import("@emotion/styled").StyledComponent<{
|
|
16
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
17
|
+
as?: React.ElementType<any> | undefined;
|
|
18
|
+
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
14
19
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
15
20
|
export default Link;
|
|
16
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Link/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,QAAQ,EACT,MAAM,mBAAm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SX.IntrinsicElements['button'], 'ref'>;
|
|
4
4
|
export interface LinkButtonProps extends JsxButtonProps, WithSize {
|
|
5
5
|
underline?: 'hover' | 'always' | 'never';
|
|
6
|
+
disabled?: boolean;
|
|
6
7
|
}
|
|
7
8
|
declare const LinkButton: React.ForwardRefExoticComponent<LinkButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
8
9
|
export default LinkButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/LinkButton/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/LinkButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiC,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG5E,OAAO,KAAqB,MAAM,OAAO,CAAC;AAO1C,KAAK,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;AAEnE,MAAM,WAAW,eAAgB,SAAQ,cAAc,EAAE,QAAQ;IAK/D,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAKzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA6BD,QAAA,MAAM,UAAU,2FAyBf,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.231",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"react": ">=18",
|
|
60
60
|
"react-dom": ">=18"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "62499aa4f865dbce0e0ccde63f92c0dbe893c19c"
|
|
63
63
|
}
|
package/src/ButtonLink/index.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import React, { forwardRef } from 'react';
|
|
|
5
5
|
import { ButtonProps, StyledButton } from '../Button';
|
|
6
6
|
import ButtonContent from '../Button/ButtonContent';
|
|
7
7
|
import useButtonColors from '../Button/utils/useButtonColors';
|
|
8
|
-
import { LinkProps, ReactRouterLinkProps } from '../Link';
|
|
8
|
+
import { DisabledWrapper, LinkProps, ReactRouterLinkProps } from '../Link';
|
|
9
9
|
|
|
10
10
|
type JsxAProps = Omit<JSX.IntrinsicElements['a'], 'type' | 'ref'>;
|
|
11
11
|
export type ButtonLinkProps = JsxAProps &
|
|
@@ -56,7 +56,7 @@ const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
|
|
56
56
|
disabled,
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
const link = (
|
|
60
60
|
<StyledButtonLink
|
|
61
61
|
btnType={type}
|
|
62
62
|
colors={buttonColors}
|
|
@@ -88,6 +88,12 @@ const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
|
|
88
88
|
</ButtonContent>
|
|
89
89
|
</StyledButtonLink>
|
|
90
90
|
);
|
|
91
|
+
|
|
92
|
+
if (disabled || loading) {
|
|
93
|
+
return <DisabledWrapper>{link}</DisabledWrapper>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return link;
|
|
91
97
|
}
|
|
92
98
|
);
|
|
93
99
|
|
package/src/Link/index.tsx
CHANGED
|
@@ -22,6 +22,11 @@ export interface LinkProps extends JsxAProps, ReactRouterLinkProps, WithSize {
|
|
|
22
22
|
* @default hover
|
|
23
23
|
*/
|
|
24
24
|
underline?: 'hover' | 'always' | 'never';
|
|
25
|
+
/**
|
|
26
|
+
* Whether the link is disabled.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
25
30
|
/**
|
|
26
31
|
* The custom link component.
|
|
27
32
|
* For example, the Link from react-router-dom.
|
|
@@ -76,9 +81,26 @@ export const underlineAlwaysStyles = (p) =>
|
|
|
76
81
|
}
|
|
77
82
|
`;
|
|
78
83
|
|
|
84
|
+
const disabledStyles = (p) =>
|
|
85
|
+
p.disabled &&
|
|
86
|
+
css`
|
|
87
|
+
pointer-events: none;
|
|
88
|
+
|
|
89
|
+
&,
|
|
90
|
+
&:active,
|
|
91
|
+
&:focus {
|
|
92
|
+
color: ${clr(p.theme.inputColorPlaceholder)};
|
|
93
|
+
}
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
export const DisabledWrapper = styled.div`
|
|
97
|
+
display: inline-block;
|
|
98
|
+
cursor: not-allowed;
|
|
99
|
+
`;
|
|
100
|
+
|
|
79
101
|
const StyledLink = styled(
|
|
80
102
|
'a',
|
|
81
|
-
omitEmotionProps('size', 'underline', 'as')
|
|
103
|
+
omitEmotionProps('size', 'underline', 'disabled', 'as')
|
|
82
104
|
)<LinkProps>`
|
|
83
105
|
${resetFocusStyles};
|
|
84
106
|
|
|
@@ -94,6 +116,7 @@ const StyledLink = styled(
|
|
|
94
116
|
|
|
95
117
|
${underlineHoverStyles};
|
|
96
118
|
${underlineAlwaysStyles};
|
|
119
|
+
${disabledStyles};
|
|
97
120
|
${sizeStyles};
|
|
98
121
|
`;
|
|
99
122
|
|
|
@@ -101,18 +124,37 @@ const StyledLink = styled(
|
|
|
101
124
|
* The link component to navigate between pages.
|
|
102
125
|
*/
|
|
103
126
|
const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
104
|
-
(
|
|
105
|
-
|
|
106
|
-
underline=
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
(
|
|
128
|
+
{
|
|
129
|
+
underline = 'hover',
|
|
130
|
+
disabled = false,
|
|
131
|
+
as,
|
|
132
|
+
onMouseDown = () => {},
|
|
133
|
+
...rest
|
|
134
|
+
},
|
|
135
|
+
ref
|
|
136
|
+
) => {
|
|
137
|
+
if (disabled) {
|
|
138
|
+
return (
|
|
139
|
+
<DisabledWrapper>
|
|
140
|
+
<StyledLink disabled {...rest} ref={ref} />
|
|
141
|
+
</DisabledWrapper>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<StyledLink
|
|
147
|
+
underline={underline}
|
|
148
|
+
as={as}
|
|
149
|
+
onMouseDown={(e) => {
|
|
150
|
+
onMouseDown(e);
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
}}
|
|
153
|
+
{...rest}
|
|
154
|
+
ref={ref}
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
116
158
|
);
|
|
117
159
|
|
|
118
160
|
Link.displayName = 'Link';
|
package/src/LinkButton/index.tsx
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
1
2
|
import styled from '@emotion/styled';
|
|
2
3
|
import { resetButtonStyles, sizeStyles, WithSize } from '@os-design/styles';
|
|
3
4
|
import { clr } from '@os-design/theming';
|
|
4
5
|
import { omitEmotionProps } from '@os-design/utils';
|
|
5
6
|
import React, { forwardRef } from 'react';
|
|
6
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
DisabledWrapper,
|
|
9
|
+
underlineAlwaysStyles,
|
|
10
|
+
underlineHoverStyles,
|
|
11
|
+
} from '../Link';
|
|
7
12
|
|
|
8
13
|
type JsxButtonProps = Omit<JSX.IntrinsicElements['button'], 'ref'>;
|
|
9
14
|
|
|
@@ -13,8 +18,20 @@ export interface LinkButtonProps extends JsxButtonProps, WithSize {
|
|
|
13
18
|
* @default hover
|
|
14
19
|
*/
|
|
15
20
|
underline?: 'hover' | 'always' | 'never';
|
|
21
|
+
/**
|
|
22
|
+
* Whether the link is disabled.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
16
26
|
}
|
|
17
27
|
|
|
28
|
+
const disabledStyles = (p) =>
|
|
29
|
+
p.disabled &&
|
|
30
|
+
css`
|
|
31
|
+
cursor: inherit;
|
|
32
|
+
color: ${clr(p.theme.inputColorPlaceholder)};
|
|
33
|
+
`;
|
|
34
|
+
|
|
18
35
|
const StyledButton = styled(
|
|
19
36
|
'button',
|
|
20
37
|
omitEmotionProps('size', 'underline')
|
|
@@ -28,6 +45,7 @@ const StyledButton = styled(
|
|
|
28
45
|
|
|
29
46
|
${underlineHoverStyles};
|
|
30
47
|
${underlineAlwaysStyles};
|
|
48
|
+
${disabledStyles};
|
|
31
49
|
${sizeStyles};
|
|
32
50
|
`;
|
|
33
51
|
|
|
@@ -35,17 +53,30 @@ const StyledButton = styled(
|
|
|
35
53
|
* The link component that is rendered as a button.
|
|
36
54
|
*/
|
|
37
55
|
const LinkButton = forwardRef<HTMLButtonElement, LinkButtonProps>(
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
(
|
|
57
|
+
{ underline = 'hover', disabled = false, onMouseDown = () => {}, ...rest },
|
|
58
|
+
ref
|
|
59
|
+
) => {
|
|
60
|
+
if (disabled) {
|
|
61
|
+
return (
|
|
62
|
+
<DisabledWrapper>
|
|
63
|
+
<StyledButton disabled {...rest} ref={ref} />
|
|
64
|
+
</DisabledWrapper>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<StyledButton
|
|
70
|
+
underline={underline}
|
|
71
|
+
onMouseDown={(e) => {
|
|
72
|
+
onMouseDown(e);
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
}}
|
|
75
|
+
{...rest}
|
|
76
|
+
ref={ref}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
49
80
|
);
|
|
50
81
|
|
|
51
82
|
LinkButton.displayName = 'LinkButton';
|