@os-design/core 1.0.229 → 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/Button/ButtonContent.js +1 -1
- package/dist/cjs/Button/ButtonContent.js.map +1 -1
- package/dist/cjs/Button/index.js +2 -2
- package/dist/cjs/Button/index.js.map +1 -1
- package/dist/cjs/Button/utils/useButtonColors.js +1 -1
- package/dist/cjs/Button/utils/useButtonColors.js.map +1 -1
- package/dist/cjs/ButtonLink/index.js +94 -0
- package/dist/cjs/ButtonLink/index.js.map +1 -0
- package/dist/cjs/Link/index.js +20 -18
- package/dist/cjs/Link/index.js.map +1 -1
- package/dist/cjs/LinkButton/index.js +22 -50
- package/dist/cjs/LinkButton/index.js.map +1 -1
- package/dist/cjs/Select/index.js +2 -2
- package/dist/cjs/Select/index.js.map +1 -1
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Button/ButtonContent.js +1 -1
- package/dist/esm/Button/ButtonContent.js.map +1 -1
- package/dist/esm/Button/index.js +2 -2
- package/dist/esm/Button/index.js.map +1 -1
- package/dist/esm/Button/utils/useButtonColors.js +1 -1
- package/dist/esm/Button/utils/useButtonColors.js.map +1 -1
- package/dist/esm/ButtonLink/index.js +78 -0
- package/dist/esm/ButtonLink/index.js.map +1 -0
- package/dist/esm/Link/index.js +36 -23
- package/dist/esm/Link/index.js.map +1 -1
- package/dist/esm/LinkButton/index.js +29 -47
- package/dist/esm/LinkButton/index.js.map +1 -1
- package/dist/esm/Select/index.js +2 -2
- package/dist/esm/Select/index.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/ButtonLink/index.d.ts +286 -0
- package/dist/types/ButtonLink/index.d.ts.map +1 -0
- package/dist/types/Link/index.d.ts +7 -0
- package/dist/types/Link/index.d.ts.map +1 -1
- package/dist/types/LinkButton/index.d.ts +7 -283
- package/dist/types/LinkButton/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/Button/ButtonContent.tsx +1 -1
- package/src/Button/index.tsx +2 -2
- package/src/Button/utils/useButtonColors.ts +1 -1
- package/src/ButtonLink/index.tsx +102 -0
- package/src/Link/index.tsx +57 -24
- package/src/LinkButton/index.tsx +50 -62
- package/src/Select/index.tsx +2 -2
- package/src/index.ts +2 -0
|
@@ -32,7 +32,7 @@ var LoadingContainer = (0, _styled["default"])('div', (0, _utils.omitEmotionProp
|
|
|
32
32
|
return p.theme.transitionDelay;
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
// Used by Button,
|
|
35
|
+
// Used by Button, ButtonLink
|
|
36
36
|
var ButtonContent = function ButtonContent(_ref) {
|
|
37
37
|
var left = _ref.left,
|
|
38
38
|
right = _ref.right,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonContent.js","names":["_react","require","_styled","_interopRequireDefault","_icons","_theming","_utils","_react2","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","obj","__esModule","_taggedTemplateLiteral","strings","raw","slice","Object","freeze","defineProperties","value","LeftAddon","styled","div","p","theme","buttonAddonPaddingHorizontal","RightAddon","Content","span","buttonIconScaleFactor","LoadingIcon","Loading","loadingFadeIn","keyframes","LoadingContainer","omitEmotionProps","clr","colors","text","bg","transitionDelay","ButtonContent","_ref","left","right","_ref$loading","loading","loadingColors","children","createElement","Fragment","_default","exports"],"sources":["../../../src/Button/ButtonContent.tsx"],"sourcesContent":["import { keyframes } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { Loading } from '@os-design/icons';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React from 'react';\nimport { LoadingColors } from './utils/useButtonColors';\n\ninterface ButtonContentProps {\n left?: React.ReactNode;\n right?: React.ReactNode;\n loading?: boolean;\n loadingColors: LoadingColors;\n children?: React.ReactNode;\n}\n\nconst LeftAddon = styled.div`\n display: inherit;\n padding-right: ${(p) => p.theme.buttonAddonPaddingHorizontal}em;\n`;\n\nconst RightAddon = styled.div`\n display: inherit;\n padding-left: ${(p) => p.theme.buttonAddonPaddingHorizontal}em;\n`;\n\nconst Content = styled.span`\n display: inherit;\n\n & > svg {\n transform: scale(${(p) => p.theme.buttonIconScaleFactor});\n vertical-align: middle;\n }\n`;\n\nconst LoadingIcon = styled(Loading)`\n font-size: 1.2em;\n`;\n\nconst loadingFadeIn = keyframes`\n from { opacity: 0; }\n to { opacity: 1; }\n`;\n\ninterface LoadingContainerProps {\n colors: LoadingColors;\n}\nconst LoadingContainer = styled(\n 'div',\n omitEmotionProps('colors')\n)<LoadingContainerProps>`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: inherit;\n\n display: flex;\n justify-content: center;\n align-items: center;\n\n color: ${(p) => clr(p.colors.text)};\n background-color: ${(p) => clr(p.colors.bg)};\n animation: ${loadingFadeIn} ${(p) => p.theme.transitionDelay}ms;\n`;\n\n// Used by Button,
|
|
1
|
+
{"version":3,"file":"ButtonContent.js","names":["_react","require","_styled","_interopRequireDefault","_icons","_theming","_utils","_react2","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","obj","__esModule","_taggedTemplateLiteral","strings","raw","slice","Object","freeze","defineProperties","value","LeftAddon","styled","div","p","theme","buttonAddonPaddingHorizontal","RightAddon","Content","span","buttonIconScaleFactor","LoadingIcon","Loading","loadingFadeIn","keyframes","LoadingContainer","omitEmotionProps","clr","colors","text","bg","transitionDelay","ButtonContent","_ref","left","right","_ref$loading","loading","loadingColors","children","createElement","Fragment","_default","exports"],"sources":["../../../src/Button/ButtonContent.tsx"],"sourcesContent":["import { keyframes } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { Loading } from '@os-design/icons';\nimport { clr } from '@os-design/theming';\nimport { omitEmotionProps } from '@os-design/utils';\nimport React from 'react';\nimport { LoadingColors } from './utils/useButtonColors';\n\ninterface ButtonContentProps {\n left?: React.ReactNode;\n right?: React.ReactNode;\n loading?: boolean;\n loadingColors: LoadingColors;\n children?: React.ReactNode;\n}\n\nconst LeftAddon = styled.div`\n display: inherit;\n padding-right: ${(p) => p.theme.buttonAddonPaddingHorizontal}em;\n`;\n\nconst RightAddon = styled.div`\n display: inherit;\n padding-left: ${(p) => p.theme.buttonAddonPaddingHorizontal}em;\n`;\n\nconst Content = styled.span`\n display: inherit;\n\n & > svg {\n transform: scale(${(p) => p.theme.buttonIconScaleFactor});\n vertical-align: middle;\n }\n`;\n\nconst LoadingIcon = styled(Loading)`\n font-size: 1.2em;\n`;\n\nconst loadingFadeIn = keyframes`\n from { opacity: 0; }\n to { opacity: 1; }\n`;\n\ninterface LoadingContainerProps {\n colors: LoadingColors;\n}\nconst LoadingContainer = styled(\n 'div',\n omitEmotionProps('colors')\n)<LoadingContainerProps>`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n border-radius: inherit;\n\n display: flex;\n justify-content: center;\n align-items: center;\n\n color: ${(p) => clr(p.colors.text)};\n background-color: ${(p) => clr(p.colors.bg)};\n animation: ${loadingFadeIn} ${(p) => p.theme.transitionDelay}ms;\n`;\n\n// Used by Button, ButtonLink\nconst ButtonContent: React.FC<ButtonContentProps> = ({\n left,\n right,\n loading = false,\n loadingColors,\n children,\n}) => (\n <>\n {left && <LeftAddon>{left}</LeftAddon>}\n <Content>{children}</Content>\n {right && <RightAddon>{right}</RightAddon>}\n {loading && (\n <LoadingContainer colors={loadingColors}>\n <LoadingIcon />\n </LoadingContainer>\n )}\n </>\n);\n\nexport default ButtonContent;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAA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function
|
|
|
23
23
|
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; }
|
|
24
24
|
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; }
|
|
25
25
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
26
|
-
// Used by Button,
|
|
26
|
+
// Used by Button, ButtonLink
|
|
27
27
|
|
|
28
28
|
var hoverStyles = function hoverStyles(p) {
|
|
29
29
|
return !p.disabled && (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n @media (hover: hover) {\n &:hover,\n &:focus {\n background-color: ", ";\n }\n }\n "])), (0, _theming.clr)(p.colors.bgHover));
|
|
@@ -46,7 +46,7 @@ var wideAlwaysStyles = function wideAlwaysStyles(p) {
|
|
|
46
46
|
var disabledStyles = function disabledStyles(p) {
|
|
47
47
|
return p.disabled && (0, _react.css)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n cursor: not-allowed;\n "])));
|
|
48
48
|
};
|
|
49
|
-
var StyledButton = exports.StyledButton = (0, _styled["default"])('button', (0, _utils.omitEmotionProps)('btnType', 'colors', 'wide', 'loading', 'size'))(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n ", ";\n position: relative; // Because LoadingContainer has an absolute position\n cursor: pointer;\n user-select: none;\n box-sizing: border-box; // Important for
|
|
49
|
+
var StyledButton = exports.StyledButton = (0, _styled["default"])('button', (0, _utils.omitEmotionProps)('btnType', 'colors', 'wide', 'loading', 'size'))(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n ", ";\n position: relative; // Because LoadingContainer has an absolute position\n cursor: pointer;\n user-select: none;\n box-sizing: border-box; // Important for ButtonLink\n\n // Disable multiline\n white-space: nowrap;\n overflow: hidden;\n\n border-radius: ", "em;\n height: ", "em;\n padding: 0 ", "em;\n\n // Do not set inline-flex, otherwise the mobile safari cuts off\n // the bottom border of the button (tested in iPhone 6)\n display: flex;\n justify-content: center;\n align-items: center;\n\n font-weight: 500;\n line-height: 1;\n\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n\n ", ";\n\n ", ";\n ", ";\n"])), _styles.resetButtonStyles, function (p) {
|
|
50
50
|
return p.theme.borderRadius;
|
|
51
51
|
}, function (p) {
|
|
52
52
|
return p.theme.buttonHeight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_media","_styles","_theming","_utils","_react2","_interopRequireWildcard","_ButtonContent","_useButtonColors2","_excluded","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_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","hoverStyles","p","disabled","css","clr","colors","bgHover","primaryStyles","btnType","text","bg","ghostStyles","outlineStyles","wideDefaultStyles","wide","m","max","xxs","wideAlwaysStyles","disabledStyles","StyledButton","exports","styled","omitEmotionProps","resetButtonStyles","theme","borderRadius","buttonHeight","buttonPaddingHorizontal","sizeStyles","transitionStyles","Button","forwardRef","_ref","ref","_ref$type","type","_ref$danger","danger","left","right","_ref$wide","_ref$loading","loading","_ref$disabled","size","children","_ref$onMouseDown","onMouseDown","rest","_useButtonColors","useButtonColors","buttonColors","loadingColors","createElement","preventDefault","displayName","_default"],"sources":["../../../src/Button/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { m } from '@os-design/media';\nimport {\n resetButtonStyles,\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';\nimport ButtonContent from './ButtonContent';\nimport useButtonColors, { ButtonColors } from './utils/useButtonColors';\n\ntype JsxButtonProps = Omit<\n JSX.IntrinsicElements['button'],\n 'type' | 'color' | 'ref'\n>;\n\n// Used by Button, LinkButton\nexport interface BaseButtonProps extends WithSize {\n /**\n * Type of button styles.\n * @default primary\n */\n type?: 'primary' | 'outline' | 'ghost';\n /**\n * Sets the danger styles.\n * @default false\n */\n danger?: boolean;\n /**\n * The component located on the left side.\n * @default undefined\n */\n left?: React.ReactNode;\n /**\n * The component located on the right side.\n * @default undefined\n */\n right?: React.ReactNode;\n /**\n * Whether the button has full width.\n * Possible values:\n * `default` – the button has full width if the screen width is less than xs;\n * `always` – the button always has full width;\n * `never` – the button never has full width.\n * @default default\n */\n wide?: 'default' | 'always' | 'never';\n /**\n * Shows the loading status and disables the button.\n * @default false\n */\n loading?: boolean;\n /**\n * Whether the button is disabled.\n * @default false\n */\n disabled?: boolean;\n}\n\nexport type ButtonProps = JsxButtonProps & BaseButtonProps;\n\ninterface StyledButtonProps\n extends Pick<ButtonProps, 'wide' | 'loading' | 'disabled' | 'size'> {\n btnType: ButtonProps['type'];\n colors: ButtonColors;\n}\n\nconst hoverStyles = (p) =>\n !p.disabled &&\n css`\n @media (hover: hover) {\n &:hover,\n &:focus {\n background-color: ${clr(p.colors.bgHover)};\n }\n }\n `;\n\nconst primaryStyles = (p) =>\n p.btnType === 'primary' &&\n css`\n color: ${clr(p.colors.text)};\n background-color: ${clr(p.colors.bg)};\n ${hoverStyles(p)};\n `;\n\nconst ghostStyles = (p) =>\n p.btnType === 'ghost' &&\n css`\n color: ${clr(p.colors.text)};\n background-color: transparent;\n ${hoverStyles(p)};\n `;\n\nconst outlineStyles = (p) =>\n p.btnType === 'outline' &&\n css`\n color: ${clr(p.colors.text)};\n background-color: transparent;\n border: 1px solid currentColor;\n ${hoverStyles(p)};\n `;\n\nconst wideDefaultStyles = (p) =>\n p.wide === 'default' &&\n css`\n ${m.max.xxs} {\n width: 100%;\n }\n `;\n\nconst wideAlwaysStyles = (p) =>\n p.wide === 'always' &&\n css`\n width: 100%;\n `;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n cursor: not-allowed;\n `;\n\nexport const StyledButton = styled(\n 'button',\n omitEmotionProps('btnType', 'colors', 'wide', 'loading', 'size')\n)<StyledButtonProps>`\n ${resetButtonStyles};\n position: relative; // Because LoadingContainer has an absolute position\n cursor: pointer;\n user-select: none;\n box-sizing: border-box; // Important for LinkButton\n\n // Disable multiline\n white-space: nowrap;\n overflow: hidden;\n\n border-radius: ${(p) => p.theme.borderRadius}em;\n height: ${(p) => p.theme.buttonHeight}em;\n padding: 0 ${(p) => p.theme.buttonPaddingHorizontal}em;\n\n // Do not set inline-flex, otherwise the mobile safari cuts off\n // the bottom border of the button (tested in iPhone 6)\n display: flex;\n justify-content: center;\n align-items: center;\n\n font-weight: 500;\n line-height: 1;\n\n ${primaryStyles};\n ${outlineStyles};\n ${ghostStyles};\n\n ${wideDefaultStyles};\n ${wideAlwaysStyles};\n\n ${disabledStyles};\n\n ${sizeStyles};\n ${transitionStyles('background-color', 'color')};\n`;\n\n/**\n * Used to trigger the corresponding business logic.\n */\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n type = 'primary',\n danger = false,\n left,\n right,\n wide = 'default',\n loading = false,\n disabled = false,\n size,\n children,\n onMouseDown = () => {},\n ...rest\n },\n ref\n ) => {\n const { buttonColors, loadingColors } = useButtonColors({\n type,\n danger,\n disabled,\n });\n\n return (\n <StyledButton\n btnType={type}\n colors={buttonColors}\n wide={wide}\n loading={loading}\n disabled={disabled || loading}\n size={size}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\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 </StyledButton>\n );\n }\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAMA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAC,uBAAA,CAAAR,OAAA;AACA,IAAAS,cAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,iBAAA,GAAAR,sBAAA,CAAAF,OAAA;AAAwE,IAAAW,SAAA;AAAA,IAAAC,eAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,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,SAAAb,wBAAAa,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OA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E;IACF,aAAWZ;EAAQ,GACfM,IAAI;IACRf,GAAG,EAAEA;EAAI,iBAET9F,OAAA,YAAAkH,aAAA,CAAChH,cAAA,WAAa;IACZiG,IAAI,EAAEA,IAAK;IACXC,KAAK,EAAEA,KAAM;IACbG,OAAO,EAAEA,OAAQ;IACjBU,aAAa,EAAEA;EAAc,GAE5BP,QACY,CACH,CAAC;AAEnB,CACF,CAAC;AAEDf,MAAM,CAACyB,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAAApC,OAAA,cAEfU,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","_media","_styles","_theming","_utils","_react2","_interopRequireWildcard","_ButtonContent","_useButtonColors2","_excluded","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_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","hoverStyles","p","disabled","css","clr","colors","bgHover","primaryStyles","btnType","text","bg","ghostStyles","outlineStyles","wideDefaultStyles","wide","m","max","xxs","wideAlwaysStyles","disabledStyles","StyledButton","exports","styled","omitEmotionProps","resetButtonStyles","theme","borderRadius","buttonHeight","buttonPaddingHorizontal","sizeStyles","transitionStyles","Button","forwardRef","_ref","ref","_ref$type","type","_ref$danger","danger","left","right","_ref$wide","_ref$loading","loading","_ref$disabled","size","children","_ref$onMouseDown","onMouseDown","rest","_useButtonColors","useButtonColors","buttonColors","loadingColors","createElement","preventDefault","displayName","_default"],"sources":["../../../src/Button/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { m } from '@os-design/media';\nimport {\n resetButtonStyles,\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';\nimport ButtonContent from './ButtonContent';\nimport useButtonColors, { ButtonColors } from './utils/useButtonColors';\n\ntype JsxButtonProps = Omit<\n JSX.IntrinsicElements['button'],\n 'type' | 'color' | 'ref'\n>;\n\n// Used by Button, ButtonLink\nexport interface BaseButtonProps extends WithSize {\n /**\n * Type of button styles.\n * @default primary\n */\n type?: 'primary' | 'outline' | 'ghost';\n /**\n * Sets the danger styles.\n * @default false\n */\n danger?: boolean;\n /**\n * The component located on the left side.\n * @default undefined\n */\n left?: React.ReactNode;\n /**\n * The component located on the right side.\n * @default undefined\n */\n right?: React.ReactNode;\n /**\n * Whether the button has full width.\n * Possible values:\n * `default` – the button has full width if the screen width is less than xs;\n * `always` – the button always has full width;\n * `never` – the button never has full width.\n * @default default\n */\n wide?: 'default' | 'always' | 'never';\n /**\n * Shows the loading status and disables the button.\n * @default false\n */\n loading?: boolean;\n /**\n * Whether the button is disabled.\n * @default false\n */\n disabled?: boolean;\n}\n\nexport type ButtonProps = JsxButtonProps & BaseButtonProps;\n\ninterface StyledButtonProps\n extends Pick<ButtonProps, 'wide' | 'loading' | 'disabled' | 'size'> {\n btnType: ButtonProps['type'];\n colors: ButtonColors;\n}\n\nconst hoverStyles = (p) =>\n !p.disabled &&\n css`\n @media (hover: hover) {\n &:hover,\n &:focus {\n background-color: ${clr(p.colors.bgHover)};\n }\n }\n `;\n\nconst primaryStyles = (p) =>\n p.btnType === 'primary' &&\n css`\n color: ${clr(p.colors.text)};\n background-color: ${clr(p.colors.bg)};\n ${hoverStyles(p)};\n `;\n\nconst ghostStyles = (p) =>\n p.btnType === 'ghost' &&\n css`\n color: ${clr(p.colors.text)};\n background-color: transparent;\n ${hoverStyles(p)};\n `;\n\nconst outlineStyles = (p) =>\n p.btnType === 'outline' &&\n css`\n color: ${clr(p.colors.text)};\n background-color: transparent;\n border: 1px solid currentColor;\n ${hoverStyles(p)};\n `;\n\nconst wideDefaultStyles = (p) =>\n p.wide === 'default' &&\n css`\n ${m.max.xxs} {\n width: 100%;\n }\n `;\n\nconst wideAlwaysStyles = (p) =>\n p.wide === 'always' &&\n css`\n width: 100%;\n `;\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n cursor: not-allowed;\n `;\n\nexport const StyledButton = styled(\n 'button',\n omitEmotionProps('btnType', 'colors', 'wide', 'loading', 'size')\n)<StyledButtonProps>`\n ${resetButtonStyles};\n position: relative; // Because LoadingContainer has an absolute position\n cursor: pointer;\n user-select: none;\n box-sizing: border-box; // Important for ButtonLink\n\n // Disable multiline\n white-space: nowrap;\n overflow: hidden;\n\n border-radius: ${(p) => p.theme.borderRadius}em;\n height: ${(p) => p.theme.buttonHeight}em;\n padding: 0 ${(p) => p.theme.buttonPaddingHorizontal}em;\n\n // Do not set inline-flex, otherwise the mobile safari cuts off\n // the bottom border of the button (tested in iPhone 6)\n display: flex;\n justify-content: center;\n align-items: center;\n\n font-weight: 500;\n line-height: 1;\n\n ${primaryStyles};\n ${outlineStyles};\n ${ghostStyles};\n\n ${wideDefaultStyles};\n ${wideAlwaysStyles};\n\n ${disabledStyles};\n\n ${sizeStyles};\n ${transitionStyles('background-color', 'color')};\n`;\n\n/**\n * Used to trigger the corresponding business logic.\n */\nconst Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n type = 'primary',\n danger = false,\n left,\n right,\n wide = 'default',\n loading = false,\n disabled = false,\n size,\n children,\n onMouseDown = () => {},\n ...rest\n },\n ref\n ) => {\n const { buttonColors, loadingColors } = useButtonColors({\n type,\n danger,\n disabled,\n });\n\n return (\n <StyledButton\n btnType={type}\n colors={buttonColors}\n wide={wide}\n loading={loading}\n disabled={disabled || loading}\n size={size}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\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 </StyledButton>\n );\n }\n);\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAMA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAC,uBAAA,CAAAR,OAAA;AACA,IAAAS,cAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,iBAAA,GAAAR,sBAAA,CAAAF,OAAA;AAAwE,IAAAW,SAAA;AAAA,IAAAC,eAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,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,SAAAb,wBAAAa,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,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAA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C;AAEDf,MAAM,CAACyB,WAAW,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAAApC,OAAA,cAEfU,MAAM"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _theming = require("@os-design/theming");
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
// Used by Button,
|
|
9
|
+
// Used by Button, ButtonLink
|
|
10
10
|
var useButtonColors = function useButtonColors(_ref) {
|
|
11
11
|
var type = _ref.type,
|
|
12
12
|
danger = _ref.danger,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useButtonColors.js","names":["_theming","require","_react","useButtonColors","_ref","type","danger","disabled","_useTheme","useTheme","theme","prefix","useMemo","buttonColors","text","concat","bg","bgHover","buttonDisabledPrimaryColorText","buttonDisabledPrimaryColorBg","buttonDisabledGhostColorText","loadingColors","_default","exports"],"sources":["../../../../src/Button/utils/useButtonColors.ts"],"sourcesContent":["import { Color, useTheme } from '@os-design/theming';\nimport { useMemo } from 'react';\n\ninterface Props {\n type: 'primary' | 'outline' | 'ghost';\n danger: boolean;\n disabled: boolean;\n}\n\nexport interface ButtonColors {\n text: Color;\n bg?: Color;\n bgHover?: Color;\n}\n\nexport interface LoadingColors {\n text: Color;\n bg: Color;\n}\n\ninterface UseButtonColorsRes {\n buttonColors: ButtonColors;\n loadingColors: LoadingColors;\n}\n\n// Used by Button,
|
|
1
|
+
{"version":3,"file":"useButtonColors.js","names":["_theming","require","_react","useButtonColors","_ref","type","danger","disabled","_useTheme","useTheme","theme","prefix","useMemo","buttonColors","text","concat","bg","bgHover","buttonDisabledPrimaryColorText","buttonDisabledPrimaryColorBg","buttonDisabledGhostColorText","loadingColors","_default","exports"],"sources":["../../../../src/Button/utils/useButtonColors.ts"],"sourcesContent":["import { Color, useTheme } from '@os-design/theming';\nimport { useMemo } from 'react';\n\ninterface Props {\n type: 'primary' | 'outline' | 'ghost';\n danger: boolean;\n disabled: boolean;\n}\n\nexport interface ButtonColors {\n text: Color;\n bg?: Color;\n bgHover?: Color;\n}\n\nexport interface LoadingColors {\n text: Color;\n bg: Color;\n}\n\ninterface UseButtonColorsRes {\n buttonColors: ButtonColors;\n loadingColors: LoadingColors;\n}\n\n// Used by Button, ButtonLink\nconst useButtonColors = ({\n type,\n danger,\n disabled,\n}: Props): UseButtonColorsRes => {\n const { theme } = useTheme();\n\n const prefix = useMemo<string>(() => {\n if (danger) return 'Danger';\n return '';\n }, [danger]);\n\n const buttonColors = useMemo<ButtonColors>(() => {\n if (type === 'primary') {\n return !disabled\n ? {\n text: theme[`button${prefix}PrimaryColorText`],\n bg: theme[`button${prefix}PrimaryColorBg`],\n bgHover: theme[`button${prefix}PrimaryColorBgHover`],\n }\n : {\n text: theme.buttonDisabledPrimaryColorText,\n bg: theme.buttonDisabledPrimaryColorBg,\n };\n }\n return !disabled\n ? {\n text: theme[`button${prefix}GhostColorText`],\n bgHover: theme[`button${prefix}GhostColorBgHover`],\n }\n : {\n text: theme.buttonDisabledGhostColorText,\n };\n }, [type, disabled, theme, prefix]);\n\n const loadingColors = useMemo<LoadingColors>(() => {\n if (disabled) {\n return {\n text: theme.buttonDisabledPrimaryColorText,\n bg: theme.buttonDisabledPrimaryColorBg,\n };\n }\n if (type === 'primary') {\n return {\n text: theme[`button${prefix}PrimaryColorLoadingText`],\n bg: theme[`button${prefix}PrimaryColorLoadingBg`],\n };\n }\n return {\n text: theme[`button${prefix}GhostColorLoadingText`],\n bg: theme[`button${prefix}GhostColorLoadingBg`],\n };\n }, [disabled, type, theme, prefix]);\n\n return { buttonColors, loadingColors };\n};\n\nexport default useButtonColors;\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAwBA;AACA,IAAME,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAIY;EAAA,IAH/BC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC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AE;MACtB,OAAO;QACLS,IAAI,EAAEJ,KAAK,UAAAK,MAAA,CAAUJ,MAAM,6BAA0B;QACrDK,EAAE,EAAEN,KAAK,UAAAK,MAAA,CAAUJ,MAAM;MAC3B,CAAC;IACH;IACA,OAAO;MACLG,IAAI,EAAEJ,KAAK,UAAAK,MAAA,CAAUJ,MAAM,2BAAwB;MACnDK,EAAE,EAAEN,KAAK,UAAAK,MAAA,CAAUJ,MAAM;IAC3B,CAAC;EACH,CAAC,EAAE,CAACJ,QAAQ,EAAEF,IAAI,EAAEK,KAAK,EAAEC,MAAM,CAAC,CAAC;EAEnC,OAAO;IAAEE,YAAY,EAAZA,YAAY;IAAEQ,aAAa,EAAbA;EAAc,CAAC;AACxC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEapB,eAAe"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
|
+
var _utils = require("@os-design/utils");
|
|
11
|
+
var _react2 = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _Button = require("../Button");
|
|
13
|
+
var _ButtonContent = _interopRequireDefault(require("../Button/ButtonContent"));
|
|
14
|
+
var _useButtonColors2 = _interopRequireDefault(require("../Button/utils/useButtonColors"));
|
|
15
|
+
var _Link = require("../Link");
|
|
16
|
+
var _excluded = ["type", "danger", "left", "right", "wide", "loading", "disabled", "size", "as", "onMouseDown", "onKeyDown", "children"];
|
|
17
|
+
var _templateObject, _templateObject2;
|
|
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); }
|
|
19
|
+
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; }
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
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); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
25
|
+
var disabledStyles = function disabledStyles(p) {
|
|
26
|
+
return p.disabled && (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: none;\n "])));
|
|
27
|
+
};
|
|
28
|
+
var StyledButtonLink = (0, _styled["default"])(_Button.StyledButton.withComponent('a'), (0, _utils.omitEmotionProps)('as', 'disabled'))(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n text-decoration: none;\n display: inline-flex;\n ", ";\n"])), disabledStyles);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The button that is rendered as a link.
|
|
32
|
+
*/
|
|
33
|
+
var ButtonLink = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
34
|
+
var _ref$type = _ref.type,
|
|
35
|
+
type = _ref$type === void 0 ? 'primary' : _ref$type,
|
|
36
|
+
_ref$danger = _ref.danger,
|
|
37
|
+
danger = _ref$danger === void 0 ? false : _ref$danger,
|
|
38
|
+
left = _ref.left,
|
|
39
|
+
right = _ref.right,
|
|
40
|
+
_ref$wide = _ref.wide,
|
|
41
|
+
wide = _ref$wide === void 0 ? 'default' : _ref$wide,
|
|
42
|
+
_ref$loading = _ref.loading,
|
|
43
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
44
|
+
_ref$disabled = _ref.disabled,
|
|
45
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
46
|
+
size = _ref.size,
|
|
47
|
+
as = _ref.as,
|
|
48
|
+
_ref$onMouseDown = _ref.onMouseDown,
|
|
49
|
+
_onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
|
|
50
|
+
_ref$onKeyDown = _ref.onKeyDown,
|
|
51
|
+
_onKeyDown = _ref$onKeyDown === void 0 ? function () {} : _ref$onKeyDown,
|
|
52
|
+
children = _ref.children,
|
|
53
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
54
|
+
var _useButtonColors = (0, _useButtonColors2["default"])({
|
|
55
|
+
type: type,
|
|
56
|
+
danger: danger,
|
|
57
|
+
disabled: disabled
|
|
58
|
+
}),
|
|
59
|
+
buttonColors = _useButtonColors.buttonColors,
|
|
60
|
+
loadingColors = _useButtonColors.loadingColors;
|
|
61
|
+
var link = /*#__PURE__*/_react2["default"].createElement(StyledButtonLink, _extends({
|
|
62
|
+
btnType: type,
|
|
63
|
+
colors: buttonColors,
|
|
64
|
+
wide: wide,
|
|
65
|
+
loading: loading,
|
|
66
|
+
disabled: disabled || loading,
|
|
67
|
+
size: size,
|
|
68
|
+
as: as,
|
|
69
|
+
onMouseDown: function onMouseDown(e) {
|
|
70
|
+
_onMouseDown(e);
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
},
|
|
73
|
+
onKeyDown: function onKeyDown(e) {
|
|
74
|
+
_onKeyDown(e);
|
|
75
|
+
if (disabled || loading) e.preventDefault();
|
|
76
|
+
},
|
|
77
|
+
"aria-disabled": disabled || loading,
|
|
78
|
+
"aria-busy": loading
|
|
79
|
+
}, rest, {
|
|
80
|
+
ref: ref
|
|
81
|
+
}), /*#__PURE__*/_react2["default"].createElement(_ButtonContent["default"], {
|
|
82
|
+
left: left,
|
|
83
|
+
right: right,
|
|
84
|
+
loading: loading,
|
|
85
|
+
loadingColors: loadingColors
|
|
86
|
+
}, children));
|
|
87
|
+
if (disabled || loading) {
|
|
88
|
+
return /*#__PURE__*/_react2["default"].createElement(_Link.DisabledWrapper, null, link);
|
|
89
|
+
}
|
|
90
|
+
return link;
|
|
91
|
+
});
|
|
92
|
+
ButtonLink.displayName = 'ButtonLink';
|
|
93
|
+
var _default = exports["default"] = ButtonLink;
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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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AAO,EAAEA,OAAQ;IACjBa,aAAa,EAAEA;EAAc,GAE5BL,QACY,CACC,CACnB;EAED,IAAI5B,QAAQ,IAAIoB,OAAO,EAAE;IACvB,oBAAO9E,OAAA,YAAA6F,aAAA,CAACxF,KAAA,CAAA4F,eAAe,QAAEL,IAAsB,CAAC;EAClD;EAEA,OAAOA,IAAI;AACb,CACF,CAAC;AAED3B,UAAU,CAACiC,WAAW,GAAG,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["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 }; }
|
|
@@ -20,29 +20,22 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
20
20
|
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
21
|
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
22
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
23
|
-
/**
|
|
24
|
-
* Sets base underline styles.
|
|
25
|
-
*/
|
|
26
23
|
var underlineBaseStyles = function underlineBaseStyles(p) {
|
|
27
24
|
return (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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: ", ";\n }\n"])), (0, _theming.clr)(p.theme.linkColor));
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Sets underline styles on hover.
|
|
32
|
-
*/
|
|
33
|
-
var underlineHoverStyles = function underlineHoverStyles(p) {
|
|
26
|
+
var underlineHoverStyles = exports.underlineHoverStyles = function underlineHoverStyles(p) {
|
|
34
27
|
return p.underline === 'hover' && (0, _react.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n @media (hover: hover) {\n ", ";\n\n &::after {\n width: 0;\n opacity: 0;\n ", ";\n }\n\n &:hover::after,\n &:focus::after {\n width: 100%;\n opacity: 1;\n }\n }\n "])), underlineBaseStyles(p), (0, _styles.transitionStyles)('width', 'opacity')(p));
|
|
35
28
|
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Sets underline styles always.
|
|
39
|
-
*/
|
|
40
|
-
var underlineAlwaysStyles = function underlineAlwaysStyles(p) {
|
|
29
|
+
var underlineAlwaysStyles = exports.underlineAlwaysStyles = function underlineAlwaysStyles(p) {
|
|
41
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));
|
|
42
31
|
};
|
|
43
|
-
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) {
|
|
44
37
|
return (0, _theming.clr)(p.theme.linkColor);
|
|
45
|
-
}, underlineHoverStyles, underlineAlwaysStyles, _styles.sizeStyles);
|
|
38
|
+
}, underlineHoverStyles, underlineAlwaysStyles, disabledStyles, _styles.sizeStyles);
|
|
46
39
|
|
|
47
40
|
/**
|
|
48
41
|
* The link component to navigate between pages.
|
|
@@ -50,10 +43,19 @@ var StyledLink = (0, _styled["default"])('a', (0, _utils.omitEmotionProps)('size
|
|
|
50
43
|
var Link = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
51
44
|
var _ref$underline = _ref.underline,
|
|
52
45
|
underline = _ref$underline === void 0 ? 'hover' : _ref$underline,
|
|
46
|
+
_ref$disabled = _ref.disabled,
|
|
47
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
53
48
|
as = _ref.as,
|
|
54
49
|
_ref$onMouseDown = _ref.onMouseDown,
|
|
55
50
|
_onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
|
|
56
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
|
+
}
|
|
57
59
|
return /*#__PURE__*/_react2["default"].createElement(StyledLink, _extends({
|
|
58
60
|
underline: underline,
|
|
59
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","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,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAC,uBAAA,CAAAP,OAAA;AAA0C,IAAAQ,SAAA;AAAA,IAAAC,eAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,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,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAA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U,EACrB,UAAAC,IAAA,EAQEC,GAAG,EACA;EAAA,IAAAC,cAAA,GAAAF,IAAA,CAPDf,SAAS;IAATA,SAAS,GAAAiB,cAAA,cAAG,OAAO,GAAAA,cAAA;IAAAC,aAAA,GAAAH,IAAA,CACnBX,QAAQ;IAARA,QAAQ,GAAAc,aAAA,cAAG,KAAK,GAAAA,aAAA;IAChBC,EAAE,GAAAJ,IAAA,CAAFI,EAAE;IAAAC,gBAAA,GAAAL,IAAA,CACFM,WAAW;IAAXA,YAAW,GAAAD,gBAAA,cAAG,YAAM,CAAC,CAAC,GAAAA,gBAAA;IACnBE,IAAI,GAAA9C,wBAAA,CAAAuC,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"}
|
|
@@ -7,12 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _react = require("@emotion/react");
|
|
9
9
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
10
|
+
var _styles = require("@os-design/styles");
|
|
11
|
+
var _theming = require("@os-design/theming");
|
|
10
12
|
var _utils = require("@os-design/utils");
|
|
11
13
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var _useButtonColors2 = _interopRequireDefault(require("../Button/utils/useButtonColors"));
|
|
15
|
-
var _excluded = ["type", "danger", "left", "right", "wide", "loading", "disabled", "size", "as", "onMouseDown", "onKeyDown", "children"];
|
|
14
|
+
var _Link = require("../Link");
|
|
15
|
+
var _excluded = ["underline", "disabled", "onMouseDown"];
|
|
16
16
|
var _templateObject, _templateObject2;
|
|
17
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); }
|
|
18
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; }
|
|
@@ -22,67 +22,39 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
22
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; }
|
|
23
23
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
24
24
|
var disabledStyles = function disabledStyles(p) {
|
|
25
|
-
return p.disabled && (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
25
|
+
return p.disabled && (0, _react.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: inherit;\n color: ", ";\n "])), (0, _theming.clr)(p.theme.inputColorPlaceholder));
|
|
26
26
|
};
|
|
27
|
-
var
|
|
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) {
|
|
28
|
+
return (0, _theming.clr)(p.theme.linkColor);
|
|
29
|
+
}, _Link.underlineHoverStyles, _Link.underlineAlwaysStyles, disabledStyles, _styles.sizeStyles);
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
|
-
* The
|
|
32
|
+
* The link component that is rendered as a button.
|
|
31
33
|
*/
|
|
32
34
|
var LinkButton = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
|
|
33
|
-
var _ref$
|
|
34
|
-
|
|
35
|
-
_ref$danger = _ref.danger,
|
|
36
|
-
danger = _ref$danger === void 0 ? false : _ref$danger,
|
|
37
|
-
left = _ref.left,
|
|
38
|
-
right = _ref.right,
|
|
39
|
-
_ref$wide = _ref.wide,
|
|
40
|
-
wide = _ref$wide === void 0 ? 'default' : _ref$wide,
|
|
41
|
-
_ref$loading = _ref.loading,
|
|
42
|
-
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
35
|
+
var _ref$underline = _ref.underline,
|
|
36
|
+
underline = _ref$underline === void 0 ? 'hover' : _ref$underline,
|
|
43
37
|
_ref$disabled = _ref.disabled,
|
|
44
38
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
45
|
-
size = _ref.size,
|
|
46
|
-
as = _ref.as,
|
|
47
39
|
_ref$onMouseDown = _ref.onMouseDown,
|
|
48
40
|
_onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
|
|
49
|
-
_ref$onKeyDown = _ref.onKeyDown,
|
|
50
|
-
_onKeyDown = _ref$onKeyDown === void 0 ? function () {} : _ref$onKeyDown,
|
|
51
|
-
children = _ref.children,
|
|
52
41
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return /*#__PURE__*/_react2["default"].createElement(
|
|
61
|
-
|
|
62
|
-
colors: buttonColors,
|
|
63
|
-
wide: wide,
|
|
64
|
-
loading: loading,
|
|
65
|
-
disabled: disabled || loading,
|
|
66
|
-
size: size,
|
|
67
|
-
as: as,
|
|
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({
|
|
50
|
+
underline: underline,
|
|
68
51
|
onMouseDown: function onMouseDown(e) {
|
|
69
52
|
_onMouseDown(e);
|
|
70
53
|
e.preventDefault();
|
|
71
|
-
}
|
|
72
|
-
onKeyDown: function onKeyDown(e) {
|
|
73
|
-
_onKeyDown(e);
|
|
74
|
-
if (disabled || loading) e.preventDefault();
|
|
75
|
-
},
|
|
76
|
-
"aria-disabled": disabled || loading,
|
|
77
|
-
"aria-busy": loading
|
|
54
|
+
}
|
|
78
55
|
}, rest, {
|
|
79
56
|
ref: ref
|
|
80
|
-
})
|
|
81
|
-
left: left,
|
|
82
|
-
right: right,
|
|
83
|
-
loading: loading,
|
|
84
|
-
loadingColors: loadingColors
|
|
85
|
-
}, children));
|
|
57
|
+
}));
|
|
86
58
|
});
|
|
87
59
|
LinkButton.displayName = 'LinkButton';
|
|
88
60
|
var _default = exports["default"] = LinkButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_react","require","_styled","_interopRequireDefault","
|
|
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,C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