@os-design/core 1.0.229 → 1.0.230
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 +89 -0
- package/dist/cjs/ButtonLink/index.js.map +1 -0
- package/dist/cjs/Link/index.js +3 -14
- package/dist/cjs/Link/index.js.map +1 -1
- package/dist/cjs/LinkButton/index.js +17 -58
- 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 +73 -0
- package/dist/esm/ButtonLink/index.js.map +1 -0
- package/dist/esm/Link/index.js +2 -13
- package/dist/esm/Link/index.js.map +1 -1
- package/dist/esm/LinkButton/index.js +25 -59
- 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 +2 -0
- package/dist/types/Link/index.d.ts.map +1 -1
- package/dist/types/LinkButton/index.d.ts +6 -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 +96 -0
- package/src/Link/index.tsx +2 -11
- package/src/LinkButton/index.tsx +38 -81
- package/src/Select/index.tsx +2 -2
- package/src/index.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["css","styled","m","resetButtonStyles","sizeStyles","transitionStyles","clr","omitEmotionProps","React","forwardRef","ButtonContent","useButtonColors","hoverStyles","p","disabled","colors","bgHover","primaryStyles","btnType","text","bg","ghostStyles","outlineStyles","wideDefaultStyles","wide","max","xxs","wideAlwaysStyles","disabledStyles","StyledButton","theme","borderRadius","buttonHeight","buttonPaddingHorizontal","Button","type","danger","left","right","loading","size","children","onMouseDown","rest","ref","buttonColors","loadingColors","createElement","_extends","e","preventDefault","displayName"],"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,
|
|
1
|
+
{"version":3,"file":"index.js","names":["css","styled","m","resetButtonStyles","sizeStyles","transitionStyles","clr","omitEmotionProps","React","forwardRef","ButtonContent","useButtonColors","hoverStyles","p","disabled","colors","bgHover","primaryStyles","btnType","text","bg","ghostStyles","outlineStyles","wideDefaultStyles","wide","max","xxs","wideAlwaysStyles","disabledStyles","StyledButton","theme","borderRadius","buttonHeight","buttonPaddingHorizontal","Button","type","danger","left","right","loading","size","children","onMouseDown","rest","ref","buttonColors","loadingColors","createElement","_extends","e","preventDefault","displayName"],"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,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,CAAC,QAAQ,kBAAkB;AACpC,SACEC,iBAAiB,EACjBC,UAAU,EACVC,gBAAgB,QAEX,mBAAmB;AAC1B,SAASC,GAAG,QAAQ,oBAAoB;AACxC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,eAAe,MAAwB,yBAAyB;;AAOvE;;AAmDA,MAAMC,WAAW,GAAIC,CAAC,IACpB,CAACA,CAAC,CAACC,QAAQ,IACXd,GAAI;AACN;AACA;AACA;AACA,4BAA4BM,GAAG,CAACO,CAAC,CAACE,MAAM,CAACC,OAAO,CAAE;AAClD;AACA;AACA,GAAG;AAEH,MAAMC,aAAa,GAAIJ,CAAC,IACtBA,CAAC,CAACK,OAAO,KAAK,SAAS,IACvBlB,GAAI;AACN,aAAaM,GAAG,CAACO,CAAC,CAACE,MAAM,CAACI,IAAI,CAAE;AAChC,wBAAwBb,GAAG,CAACO,CAAC,CAACE,MAAM,CAACK,EAAE,CAAE;AACzC,MAAMR,WAAW,CAACC,CAAC,CAAE;AACrB,GAAG;AAEH,MAAMQ,WAAW,GAAIR,CAAC,IACpBA,CAAC,CAACK,OAAO,KAAK,OAAO,IACrBlB,GAAI;AACN,aAAaM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","names":["useTheme","useMemo","useButtonColors","type","danger","disabled","theme","prefix","buttonColors","text","bg","bgHover","buttonDisabledPrimaryColorText","buttonDisabledPrimaryColorBg","buttonDisabledGhostColorText","loadingColors"],"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":["useTheme","useMemo","useButtonColors","type","danger","disabled","theme","prefix","buttonColors","text","bg","bgHover","buttonDisabledPrimaryColorText","buttonDisabledPrimaryColorBg","buttonDisabledGhostColorText","loadingColors"],"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,SAAgBA,QAAQ,QAAQ,oBAAoB;AACpD,SAASC,OAAO,QAAQ,OAAO;AAwB/B;AACA,MAAMC,eAAe,GAAGA,CAAC;EACvBC,IAAI;EACJC,MAAM;EACNC;AACK,CAAC,KAAyB;EAC/B,MAAM;IAAEC;EAAM,CAAC,GAAGN,QAAQ,CAAC,CAAC;EAE5B,MAAMO,MAAM,GAAGN,OAAO,CAAS,MAAM;IACnC,IAAIG,MAAM,EAAE,OAAO,QAAQ;IAC3B,OAAO,EAAE;EACX,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMI,YAAY,GAAGP,OAAO,CAAe,MAAM;IAC/C,IAAIE,IAAI,KAAK,SAAS,EAAE;MACtB,OAAO,CAACE,QAAQ,GACZ;QACEI,IAAI,EAAEH,KAAK,CAAE,SAAQC,MAAO,kBAAiB,CAAC;QAC9CG,EAAE,EAAEJ,KAAK,CAAE,SAAQC,MAAO,gBAAe,CAAC;QAC1CI,OAAO,EAAEL,KAAK,CAAE,SAAQC,MAAO,qBAAoB;MACrD,CAAC,GACD;QACEE,IAAI,EAAEH,KAAK,CAACM,8BAA8B;QAC1CF,EAAE,EAAEJ,KAAK,CAACO;MACZ,CAAC;IACP;IACA,OAAO,CAACR,QAAQ,GACZ;MACEI,IAAI,EAAEH,KAAK,CAAE,SAAQC,MAAO,gBAAe,CAAC;MAC5CI,OAAO,EAAEL,KAAK,CAAE,SAAQC,MAAO,mBAAkB;IACnD,CAAC,GACD;MACEE,IAAI,EAAEH,KAAK,CAACQ;IACd,CAAC;EACP,CAAC,EAAE,CAACX,IAAI,EAAEE,QAAQ,EAAEC,KAAK,EAAEC,MAAM,CAAC,CAAC;EAEnC,MAAMQ,aAAa,GAAGd,OAAO,CAAgB,MAAM;IACjD,IAAII,QAAQ,EAAE;MACZ,OAAO;QACLI,IAAI,EAAEH,KAAK,CAACM,8BAA8B;QAC1CF,EAAE,EAAEJ,KAAK,CAACO;MACZ,CAAC;IACH;IACA,IAAIV,IAAI,KAAK,SAAS,EAAE;MACtB,OAAO;QACLM,IAAI,EAAEH,KAAK,CAAE,SAAQC,MAAO,yBAAwB,CAAC;QACrDG,EAAE,EAAEJ,KAAK,CAAE,SAAQC,MAAO,uBAAsB;MAClD,CAAC;IACH;IACA,OAAO;MACLE,IAAI,EAAEH,KAAK,CAAE,SAAQC,MAAO,uBAAsB,CAAC;MACnDG,EAAE,EAAEJ,KAAK,CAAE,SAAQC,MAAO,qBAAoB;IAChD,CAAC;EACH,CAAC,EAAE,CAACF,QAAQ,EAAEF,IAAI,EAAEG,KAAK,EAAEC,MAAM,CAAC,CAAC;EAEnC,OAAO;IAAEC,YAAY;IAAEO;EAAc,CAAC;AACxC,CAAC;AAED,eAAeb,eAAe"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import { omitEmotionProps } from '@os-design/utils';
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
|
+
import { StyledButton } from '../Button';
|
|
7
|
+
import ButtonContent from '../Button/ButtonContent';
|
|
8
|
+
import useButtonColors from '../Button/utils/useButtonColors';
|
|
9
|
+
const disabledStyles = p => p.disabled && css`
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
`;
|
|
12
|
+
const StyledButtonLink = styled(StyledButton.withComponent('a'), omitEmotionProps('as', 'disabled'))`
|
|
13
|
+
text-decoration: none;
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
${disabledStyles};
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The button that is rendered as a link.
|
|
20
|
+
*/
|
|
21
|
+
const ButtonLink = /*#__PURE__*/forwardRef(({
|
|
22
|
+
type = 'primary',
|
|
23
|
+
danger = false,
|
|
24
|
+
left,
|
|
25
|
+
right,
|
|
26
|
+
wide = 'default',
|
|
27
|
+
loading = false,
|
|
28
|
+
disabled = false,
|
|
29
|
+
size,
|
|
30
|
+
as,
|
|
31
|
+
onMouseDown = () => {},
|
|
32
|
+
onKeyDown = () => {},
|
|
33
|
+
children,
|
|
34
|
+
...rest
|
|
35
|
+
}, ref) => {
|
|
36
|
+
const {
|
|
37
|
+
buttonColors,
|
|
38
|
+
loadingColors
|
|
39
|
+
} = useButtonColors({
|
|
40
|
+
type,
|
|
41
|
+
danger,
|
|
42
|
+
disabled
|
|
43
|
+
});
|
|
44
|
+
return /*#__PURE__*/React.createElement(StyledButtonLink, _extends({
|
|
45
|
+
btnType: type,
|
|
46
|
+
colors: buttonColors,
|
|
47
|
+
wide: wide,
|
|
48
|
+
loading: loading,
|
|
49
|
+
disabled: disabled || loading,
|
|
50
|
+
size: size,
|
|
51
|
+
as: as,
|
|
52
|
+
onMouseDown: e => {
|
|
53
|
+
onMouseDown(e);
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
},
|
|
56
|
+
onKeyDown: e => {
|
|
57
|
+
onKeyDown(e);
|
|
58
|
+
if (disabled || loading) e.preventDefault();
|
|
59
|
+
},
|
|
60
|
+
"aria-disabled": disabled || loading,
|
|
61
|
+
"aria-busy": loading
|
|
62
|
+
}, rest, {
|
|
63
|
+
ref: ref
|
|
64
|
+
}), /*#__PURE__*/React.createElement(ButtonContent, {
|
|
65
|
+
left: left,
|
|
66
|
+
right: right,
|
|
67
|
+
loading: loading,
|
|
68
|
+
loadingColors: loadingColors
|
|
69
|
+
}, children));
|
|
70
|
+
});
|
|
71
|
+
ButtonLink.displayName = 'ButtonLink';
|
|
72
|
+
export default ButtonLink;
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 return (\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);\n\nButtonLink.displayName = 'ButtonLink';\n\nexport default ButtonLink;\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAAsBC,YAAY,QAAQ,WAAW;AACrD,OAAOC,aAAa,MAAM,yBAAyB;AACnD,OAAOC,eAAe,MAAM,iCAAiC;AAS7D,MAAMC,cAAc,GAAIC,CAAC,IACvBA,CAAC,CAACC,QAAQ,IACVV,GAAI;AACN;AACA,GAAG;AAEH,MAAMW,gBAAgB,GAAGV,MAAM,CAC7BI,YAAY,CAACO,aAAa,CAAC,GAAG,CAAC,EAC/BV,gBAAgB,CAAC,IAAI,EAAE,UAAU,CACnC,CAAE;AACF;AACA;AACA,IAAIM,cAAe;AACnB,CAAC;;AAED;AACA;AACA;AAC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GAE5BJ,QACY,CACC,CAAC;AAEvB,CACF,CAAC;AAEDX,UAAU,CAACsB,WAAW,GAAG,YAAY;AAErC,eAAetB,UAAU"}
|
package/dist/esm/Link/index.js
CHANGED
|
@@ -5,9 +5,6 @@ import { resetFocusStyles, sizeStyles, transitionStyles } from '@os-design/style
|
|
|
5
5
|
import { clr } from '@os-design/theming';
|
|
6
6
|
import { omitEmotionProps } from '@os-design/utils';
|
|
7
7
|
import React, { forwardRef } from 'react';
|
|
8
|
-
/**
|
|
9
|
-
* Sets base underline styles.
|
|
10
|
-
*/
|
|
11
8
|
const underlineBaseStyles = p => css`
|
|
12
9
|
position: relative;
|
|
13
10
|
display: inline-block;
|
|
@@ -22,11 +19,7 @@ const underlineBaseStyles = p => css`
|
|
|
22
19
|
background-color: ${clr(p.theme.linkColor)};
|
|
23
20
|
}
|
|
24
21
|
`;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Sets underline styles on hover.
|
|
28
|
-
*/
|
|
29
|
-
const underlineHoverStyles = p => p.underline === 'hover' && css`
|
|
22
|
+
export const underlineHoverStyles = p => p.underline === 'hover' && css`
|
|
30
23
|
@media (hover: hover) {
|
|
31
24
|
${underlineBaseStyles(p)};
|
|
32
25
|
|
|
@@ -43,11 +36,7 @@ const underlineHoverStyles = p => p.underline === 'hover' && css`
|
|
|
43
36
|
}
|
|
44
37
|
}
|
|
45
38
|
`;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Sets underline styles always.
|
|
49
|
-
*/
|
|
50
|
-
const underlineAlwaysStyles = p => p.underline === 'always' && css`
|
|
39
|
+
export const underlineAlwaysStyles = p => p.underline === 'always' && css`
|
|
51
40
|
${underlineBaseStyles(p)};
|
|
52
41
|
|
|
53
42
|
&::after {
|
|
@@ -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\
|
|
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 ({ underline = 'hover', as, onMouseDown = () => {}, ...rest }, ref) => (\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\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;AAsBzC,MAAMC,mBAAmB,GAAIC,CAAC,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K;IAClBL,WAAW,CAACK,CAAC,CAAC;IACdA,CAAC,CAACC,cAAc,CAAC,CAAC;EACpB;AAAE,GACEL,IAAI;EACRC,GAAG,EAAEA;AAAI,EACV,CAEL,CAAC;AAEDJ,IAAI,CAACS,WAAW,GAAG,MAAM;AAEzB,eAAeT,IAAI"}
|
|
@@ -1,73 +1,39 @@
|
|
|
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';
|
|
3
2
|
import styled from '@emotion/styled';
|
|
3
|
+
import { resetButtonStyles, sizeStyles } from '@os-design/styles';
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
${
|
|
7
|
+
import { underlineAlwaysStyles, underlineHoverStyles } from '../Link';
|
|
8
|
+
const StyledButton = styled('button', omitEmotionProps('size', 'underline'))`
|
|
9
|
+
${resetButtonStyles};
|
|
10
|
+
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
text-align: left;
|
|
13
|
+
line-height: 1.2;
|
|
14
|
+
color: ${p => clr(p.theme.linkColor)};
|
|
15
|
+
|
|
16
|
+
${underlineHoverStyles};
|
|
17
|
+
${underlineAlwaysStyles};
|
|
18
|
+
${sizeStyles};
|
|
16
19
|
`;
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
|
-
* The
|
|
22
|
+
* The link component that is rendered as a button.
|
|
20
23
|
*/
|
|
21
24
|
const LinkButton = /*#__PURE__*/forwardRef(({
|
|
22
|
-
|
|
23
|
-
danger = false,
|
|
24
|
-
left,
|
|
25
|
-
right,
|
|
26
|
-
wide = 'default',
|
|
27
|
-
loading = false,
|
|
28
|
-
disabled = false,
|
|
29
|
-
size,
|
|
30
|
-
as,
|
|
25
|
+
underline = 'hover',
|
|
31
26
|
onMouseDown = () => {},
|
|
32
|
-
onKeyDown = () => {},
|
|
33
|
-
children,
|
|
34
27
|
...rest
|
|
35
|
-
}, ref) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return /*#__PURE__*/React.createElement(StyledLinkButton, _extends({
|
|
45
|
-
btnType: type,
|
|
46
|
-
colors: buttonColors,
|
|
47
|
-
wide: wide,
|
|
48
|
-
loading: loading,
|
|
49
|
-
disabled: disabled || loading,
|
|
50
|
-
size: size,
|
|
51
|
-
as: as,
|
|
52
|
-
onMouseDown: e => {
|
|
53
|
-
onMouseDown(e);
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
},
|
|
56
|
-
onKeyDown: e => {
|
|
57
|
-
onKeyDown(e);
|
|
58
|
-
if (disabled || loading) e.preventDefault();
|
|
59
|
-
},
|
|
60
|
-
"aria-disabled": disabled || loading,
|
|
61
|
-
"aria-busy": loading
|
|
62
|
-
}, rest, {
|
|
63
|
-
ref: ref
|
|
64
|
-
}), /*#__PURE__*/React.createElement(ButtonContent, {
|
|
65
|
-
left: left,
|
|
66
|
-
right: right,
|
|
67
|
-
loading: loading,
|
|
68
|
-
loadingColors: loadingColors
|
|
69
|
-
}, children));
|
|
70
|
-
});
|
|
28
|
+
}, ref) => /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
29
|
+
underline: underline,
|
|
30
|
+
onMouseDown: e => {
|
|
31
|
+
onMouseDown(e);
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
}
|
|
34
|
+
}, rest, {
|
|
35
|
+
ref: ref
|
|
36
|
+
})));
|
|
71
37
|
LinkButton.displayName = 'LinkButton';
|
|
72
38
|
export default LinkButton;
|
|
73
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["styled","resetButtonStyles","sizeStyles","clr","omitEmotionProps","React","forwardRef","underlineAlwaysStyles","underlineHoverStyles","StyledButton","p","theme","linkColor","LinkButton","underline","onMouseDown","rest","ref","createElement","_extends","e","preventDefault","displayName"],"sources":["../../../src/LinkButton/index.tsx"],"sourcesContent":["import 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 { underlineAlwaysStyles, underlineHoverStyles } 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\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 ${sizeStyles};\n`;\n\n/**\n * The link component that is rendered as a button.\n */\nconst LinkButton = forwardRef<HTMLButtonElement, LinkButtonProps>(\n ({ underline = 'hover', onMouseDown = () => {}, ...rest }, ref) => (\n <StyledButton\n underline={underline}\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n {...rest}\n ref={ref}\n />\n )\n);\n\nLinkButton.displayName = 'LinkButton';\n\nexport default LinkButton;\n"],"mappings":";AAAA,OAAOA,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,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,SAAS;AAYrE,MAAMC,YAAY,GAAGT,MAAM,CACzB,QAAQ,EACRI,gBAAgB,CAAC,MAAM,EAAE,WAAW,CACtC,CAAmB;AACnB,IAAIH,iBAAkB;AACtB;AACA;AACA;AACA;AACA,WAAYS,CAAC,IAAKP,GAAG,CAACO,CAAC,CAACC,KAAK,CAACC,SAAS,CAAE;AACzC;AACA,IAAIJ,oBAAqB;AACzB,IAAID,qBAAsB;AAC1B,IAAIL,UAAW;AACf,CAAC;;AAED;AACA;AACA;AACA,MAAMW,UAAU,gBAAGP,UAAU,CAC3B,CAAC;EAAEQ,SAAS,GAAG,OAAO;EAAEC,WAAW,GAAGA,CAAA,KAAM,CAAC,CAAC;EAAE,GAAGC;AAAK,CAAC,EAAEC,GAAG,kBAC5DZ,KAAA,CAAAa,aAAA,CAACT,YAAY,EAAAU,QAAA;EACXL,SAAS,EAAEA,SAAU;EACrBC,WAAW,EAAGK,CAAC,IAAK;IAClBL,WAAW,CAACK,CAAC,CAAC;IACdA,CAAC,CAACC,cAAc,CAAC,CAAC;EACpB;AAAE,GACEL,IAAI;EACRC,GAAG,EAAEA;AAAI,EACV,CAEL,CAAC;AAEDJ,UAAU,CAACS,WAAW,GAAG,YAAY;AAErC,eAAeT,UAAU"}
|
package/dist/esm/Select/index.js
CHANGED
|
@@ -97,7 +97,7 @@ export const Placeholder = styled.span`
|
|
|
97
97
|
color: ${p => clr(p.theme.inputColorPlaceholder)};
|
|
98
98
|
${ellipsisStyles};
|
|
99
99
|
`;
|
|
100
|
-
const
|
|
100
|
+
const titleUnborderedStyles = p => p.unbordered && css`
|
|
101
101
|
font-weight: 500;
|
|
102
102
|
${!p.disabled && `color: ${clr(p.theme.colorPrimary)};`}
|
|
103
103
|
`;
|
|
@@ -106,7 +106,7 @@ const titleDisabledStyles = p => p.disabled && css`
|
|
|
106
106
|
`;
|
|
107
107
|
export const Title = styled('span', omitEmotionProps('disabled', 'unbordered'))`
|
|
108
108
|
color: ${p => clr(p.theme.colorText)};
|
|
109
|
-
${
|
|
109
|
+
${titleUnborderedStyles};
|
|
110
110
|
${titleDisabledStyles};
|
|
111
111
|
${ellipsisStyles};
|
|
112
112
|
`;
|