@laerdal/life-react-components 1.8.0-dev.14 → 1.8.0-dev.15.full
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/Button/Iconbutton.cjs +6 -2
- package/dist/Button/Iconbutton.cjs.map +1 -1
- package/dist/Button/Iconbutton.d.ts +1 -0
- package/dist/Button/Iconbutton.js +6 -2
- package/dist/Button/Iconbutton.js.map +1 -1
- package/dist/InputFields/NumberField.cjs +16 -6
- package/dist/InputFields/NumberField.cjs.map +1 -1
- package/dist/InputFields/NumberField.js +17 -7
- package/dist/InputFields/NumberField.js.map +1 -1
- package/dist/ProfileButton/ProfileButton.cjs +96 -0
- package/dist/ProfileButton/ProfileButton.cjs.map +1 -0
- package/dist/ProfileButton/ProfileButton.d.ts +12 -0
- package/dist/ProfileButton/ProfileButton.js +71 -0
- package/dist/ProfileButton/ProfileButton.js.map +1 -0
- package/dist/ProfileButton/index.cjs +16 -0
- package/dist/ProfileButton/index.cjs.map +1 -0
- package/dist/ProfileButton/index.d.ts +1 -0
- package/dist/ProfileButton/index.js +2 -0
- package/dist/ProfileButton/index.js.map +1 -0
- package/dist/Table/Table.cjs +22 -22
- package/dist/Table/Table.cjs.map +1 -1
- package/dist/Table/Table.js +22 -22
- package/dist/Table/Table.js.map +1 -1
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -59,7 +59,7 @@ var StyledIconButton = _styledComponents.default.button(_templateObject2 || (_te
|
|
|
59
59
|
return props.invertFocus ? _styles.invertedFocusStyles : _styles.focusStyles;
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
var StyledPrimaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
62
|
+
var StyledPrimaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled), &.hover-state {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled), &.active-state {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
63
63
|
return props.useTransparentBackground ? 'transparent' : _styles.COLORS.primary_500;
|
|
64
64
|
}, function (props) {
|
|
65
65
|
return props.iconColor || _styles.COLORS.white;
|
|
@@ -67,7 +67,7 @@ var StyledPrimaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_
|
|
|
67
67
|
return props.iconColor || _styles.COLORS.white;
|
|
68
68
|
}, IconButtonContent, _styles.COLORS.primary_700, IconButtonContent, IconButtonContent, _styles.COLORS.white, IconButtonContent, _styles.COLORS.primary_800, IconButtonContent, IconButtonContent, _styles.COLORS.white, IconButtonContent, _styles.COLORS.neutral_200, _styles.COLORS.white, _styles.COLORS.white);
|
|
69
69
|
exports.StyledPrimaryIconButton = StyledPrimaryIconButton;
|
|
70
|
-
var StyledSecondaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n \n &:hover:not(:disabled) {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
70
|
+
var StyledSecondaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n \n &:hover:not(:disabled), &.hover-state {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled), &.active-state {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
71
71
|
return props.useTransparentBackground ? 'transparent' : _styles.COLORS.white;
|
|
72
72
|
}, function (props) {
|
|
73
73
|
return props.iconColor || _styles.COLORS.neutral_600;
|
|
@@ -80,6 +80,7 @@ exports.StyledSecondaryIconButton = StyledSecondaryIconButton;
|
|
|
80
80
|
|
|
81
81
|
var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
82
82
|
var id = _ref.id,
|
|
83
|
+
className = _ref.className,
|
|
83
84
|
variant = _ref.variant,
|
|
84
85
|
shape = _ref.shape,
|
|
85
86
|
action = _ref.action,
|
|
@@ -105,6 +106,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
105
106
|
case 'secondary':
|
|
106
107
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledSecondaryIconButton, {
|
|
107
108
|
id: id,
|
|
109
|
+
className: className,
|
|
108
110
|
type: type !== null && type !== void 0 ? type : 'button',
|
|
109
111
|
"data-testid": id,
|
|
110
112
|
ref: ref,
|
|
@@ -135,6 +137,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
135
137
|
default:
|
|
136
138
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledPrimaryIconButton, {
|
|
137
139
|
id: id,
|
|
140
|
+
className: className,
|
|
138
141
|
type: type !== null && type !== void 0 ? type : 'button',
|
|
139
142
|
"data-testid": id,
|
|
140
143
|
flatEdge: flatEdge,
|
|
@@ -166,6 +169,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
166
169
|
|
|
167
170
|
IconButton.propTypes = {
|
|
168
171
|
id: _propTypes.default.string,
|
|
172
|
+
className: _propTypes.default.string,
|
|
169
173
|
variant: _propTypes.default.oneOf(['primary', 'secondary']),
|
|
170
174
|
shape: _propTypes.default.oneOf(['square', 'circular']),
|
|
171
175
|
action: _propTypes.default.func.isRequired,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","IconButtonContent","styled","div","StyledIconButton","button","hideOnLowWidth","BREAKPOINTS","MEDIUM","unsetIconSize","invertFocus","invertedFocusStyles","focusStyles","StyledPrimaryIconButton","useTransparentBackground","COLORS","primary_500","iconColor","white","primary_700","primary_800","neutral_200","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","React","forwardRef","ref","id","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","focusBackgroundColor","type","hidden","style","event","stopPropagation","defaultOnMouseDownHandler"],"mappings":";;;;;;;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QAAA,QAAQ,EAAE6B,QAAQ,IAAI,CAbxB;AAcE,QAAA,YAAY,EAAEzC,YAAY,IAAIoC,KAAK,KAAK,UAA1B,GAAuC,EAAvC,GAA4C,CAd5D;AAeE,QAAA,WAAW,EAAEa,iCAff;AAgBE,QAAA,UAAU,EAAEP,UAhBd;AAiBE,QAAA,MAAM,EAAEG,MAjBV;AAkBE,QAAA,KAAK,EAAEC,KAlBT;AAmBE,QAAA,WAAW,EAAEjC,WAnBf;AAoBE,QAAA,oBAAoB,EAAE8B,oBApBxB;AAAA,+BAqBE,qBAAC,iBAAD;AAAA,oBAAoBJ;AAApB;AArBF,QADF;AA5BJ;AAsDD,CA9EkB,CAAnB;;;AAtBEL,EAAAA,E;AACAC,EAAAA,O,4BAAU,S,EAAY,W;AACtBC,EAAAA,K,4BAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACA5B,EAAAA,c;AAEA6B,EAAAA,c;AACAE,EAAAA,Q;AACAvB,EAAAA,wB;AACAG,EAAAA,S;AACAR,EAAAA,a;AACA6B,EAAAA,Q;AACAzC,EAAAA,Y;AACA0C,EAAAA,U;AACAC,EAAAA,oB;AAEAJ,EAAAA,Q;AACAM,EAAAA,M;AAEAhC,EAAAA,W;;eAmFaiB,U","sourcesContent":["import React from 'react';\nimport styled, {css, CSSProperties} from 'styled-components';\n\nimport {BREAKPOINTS, COLORS, focusStyles, invertedFocusStyles} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n invertFocus?: boolean;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n\n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nexport const IconButtonContent = styled.div``;\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n ${IconButtonContent} {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ${props => props.invertFocus ? invertedFocusStyles : focusStyles}\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:hover:not(:disabled) {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_700};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n ${IconButtonContent} {\n background: ${COLORS.primary_800};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n ${IconButtonContent} {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n \n &:hover:not(:disabled) {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_20};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n ${IconButtonContent} {\n background: ${COLORS.primary_100};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n`;\n\nexport interface IconButtonProps {\n id?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n style?: CSSProperties | undefined;\n invertFocus?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden,\n style,\n invertFocus\n}: IconButtonProps, ref) => {\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.cjs"}
|
|
1
|
+
{"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","IconButtonContent","styled","div","StyledIconButton","button","hideOnLowWidth","BREAKPOINTS","MEDIUM","unsetIconSize","invertFocus","invertedFocusStyles","focusStyles","StyledPrimaryIconButton","useTransparentBackground","COLORS","primary_500","iconColor","white","primary_700","primary_800","neutral_200","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","React","forwardRef","ref","id","className","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","focusBackgroundColor","type","hidden","style","event","stopPropagation","defaultOnMouseDownHandler"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAeA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;AAAA,SAA4BA,KAAK,CAACC,YAAN,aAAwBD,KAAK,CAACC,YAA9B,UAAiD,KAA7E;AAAA,CAAxB;;AAEA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACF,KAAD,EAA2B;AACtD,MAAMG,MAAM,GAAGJ,eAAe,CAACC,KAAD,CAA9B;;AACA,UAAOA,KAAK,CAACI,QAAb;AAEI,SAAK,MAAL;AACI,2BAAcD,MAAd,cAAwBA,MAAxB;;AAEJ,SAAK,OAAL;AACI,uBAAUA,MAAV,sBAA4BA,MAA5B;;AAEJ,SAAK,MAAL;AACA;AACI,uBAAUA,MAAV;AAVR;AAYD,CAdD;;AAgBO,IAAME,iBAAiB,GAAGC,0BAAOC,GAAV,mFAAvB;;;;AAEP,IAAMC,gBAAgB,GAAGF,0BAAOG,MAAV,koBAQT,UAACT,KAAD;AAAA,SAAYA,KAAK,CAACU,cAAN,GAAuB,MAAvB,GAAgC,OAA5C;AAAA,CARS,EASlBC,oBAAYC,MATM,EAaH,UAACZ,KAAD;AAAA,SAAYA,KAAK,CAACC,YAAN,aAAwBD,KAAK,CAACC,YAA9B,UAAiD,KAA7D;AAAA,CAbG,EAclBI,iBAdkB,EAiBDH,oBAjBC,EAsBN,UAACF,KAAD;AAAA,SAAYA,KAAK,CAACa,aAAN,GAAsB,OAAtB,GAAgC,MAA5C;AAAA,CAtBM,EAuBP,UAACb,KAAD;AAAA,SAAYA,KAAK,CAACa,aAAN,GAAs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E,QAAA,OAAO,EAAE,iBAACe,KAAD,EAAiD;AAACA,UAAAA,KAAK,CAACC,eAAN;AAAyBX,UAAAA,MAAM,CAACU,KAAD,CAAN;AAAe,SAPrG;AAQE,QAAA,QAAQ,EAAEP,QARZ;AASE,QAAA,cAAc,EAAEhC,cAAc,IAAI,KATpC;AAUE,QAAA,YAAY,EAAE8B,cAVhB;AAWE,QAAA,wBAAwB,EAAEtB,wBAX5B;AAYE,QAAA,SAAS,EAAEG,SAZb;AAaE,QAAA,aAAa,EAAER,aAbjB;AAcE,QAAA,QAAQ,EAAE8B,QAAQ,IAAI,CAdxB;AAeE,QAAA,YAAY,EAAE1C,YAAY,IAAIqC,KAAK,KAAK,UAA1B,GAAuC,EAAvC,GAA4C,CAf5D;AAgBE,QAAA,WAAW,EAAEa,iCAhBf;AAiBE,QAAA,UAAU,EAAEP,UAjBd;AAkBE,QAAA,MAAM,EAAEG,MAlBV;AAmBE,QAAA,KAAK,EAAEC,KAnBT;AAoBE,QAAA,WAAW,EAAElC,WApBf;AAqBE,QAAA,oBAAoB,EAAE+B,oBArBxB;AAAA,+BAsBE,qBAAC,iBAAD;AAAA,oBAAoBJ;AAApB;AAtBF,QADF;AA7BJ;AAwDD,CAjFkB,CAAnB;;;AAvBEN,EAAAA,E;AACAC,EAAAA,S;AACAC,EAAAA,O,4BAAU,S,EAAY,W;AACtBC,EAAAA,K,4BAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACA7B,EAAAA,c;AAEA8B,EAAAA,c;AACAE,EAAAA,Q;AACAxB,EAAAA,wB;AACAG,EAAAA,S;AACAR,EAAAA,a;AACA8B,EAAAA,Q;AACA1C,EAAAA,Y;AACA2C,EAAAA,U;AACAC,EAAAA,oB;AAEAJ,EAAAA,Q;AACAM,EAAAA,M;AAEAjC,EAAAA,W;;eAsFaiB,U","sourcesContent":["import React from 'react';\nimport styled, {css, CSSProperties} from 'styled-components';\n\nimport {BREAKPOINTS, COLORS, focusStyles, invertedFocusStyles} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n invertFocus?: boolean;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n\n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nexport const IconButtonContent = styled.div``;\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n ${IconButtonContent} {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ${props => props.invertFocus ? invertedFocusStyles : focusStyles}\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:hover:not(:disabled), &.hover-state {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_700};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled), &.active-state {\n ${IconButtonContent} {\n background: ${COLORS.primary_800};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n ${IconButtonContent} {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n \n &:hover:not(:disabled), &.hover-state {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_20};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled), &.active-state {\n ${IconButtonContent} {\n background: ${COLORS.primary_100};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n`;\n\nexport interface IconButtonProps {\n id?: string;\n className?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n style?: CSSProperties | undefined;\n invertFocus?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n className,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden,\n style,\n invertFocus\n}: IconButtonProps, ref) => {\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n className={className}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n className={className}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.cjs"}
|
|
@@ -17,6 +17,7 @@ export declare const StyledPrimaryIconButton: import("styled-components").Styled
|
|
|
17
17
|
export declare const StyledSecondaryIconButton: import("styled-components").StyledComponent<"button", any, HeaderItemProps, never>;
|
|
18
18
|
export interface IconButtonProps {
|
|
19
19
|
id?: string;
|
|
20
|
+
className?: string;
|
|
20
21
|
variant?: 'primary' | 'secondary';
|
|
21
22
|
shape?: 'square' | 'circular';
|
|
22
23
|
action: (event?: React.MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -41,14 +41,14 @@ var StyledIconButton = styled.button(_templateObject2 || (_templateObject2 = _ta
|
|
|
41
41
|
}, function (props) {
|
|
42
42
|
return props.invertFocus ? invertedFocusStyles : focusStyles;
|
|
43
43
|
});
|
|
44
|
-
export var StyledPrimaryIconButton = styled(StyledIconButton)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
44
|
+
export var StyledPrimaryIconButton = styled(StyledIconButton)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled), &.hover-state {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled), &.active-state {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
45
45
|
return props.useTransparentBackground ? 'transparent' : COLORS.primary_500;
|
|
46
46
|
}, function (props) {
|
|
47
47
|
return props.iconColor || COLORS.white;
|
|
48
48
|
}, function (props) {
|
|
49
49
|
return props.iconColor || COLORS.white;
|
|
50
50
|
}, IconButtonContent, COLORS.primary_700, IconButtonContent, IconButtonContent, COLORS.white, IconButtonContent, COLORS.primary_800, IconButtonContent, IconButtonContent, COLORS.white, IconButtonContent, COLORS.neutral_200, COLORS.white, COLORS.white);
|
|
51
|
-
export var StyledSecondaryIconButton = styled(StyledIconButton)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n \n &:hover:not(:disabled) {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
51
|
+
export var StyledSecondaryIconButton = styled(StyledIconButton)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", " {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n \n &:hover:not(:disabled), &.hover-state {\n ", " {\n background-color: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled), &.active-state {\n ", " {\n background: ", ";\n }\n ", " svg path,\n ", " svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n ", " {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), IconButtonContent, function (props) {
|
|
52
52
|
return props.useTransparentBackground ? 'transparent' : COLORS.white;
|
|
53
53
|
}, function (props) {
|
|
54
54
|
return props.iconColor || COLORS.neutral_600;
|
|
@@ -59,6 +59,7 @@ export var StyledSecondaryIconButton = styled(StyledIconButton)(_templateObject4
|
|
|
59
59
|
}, COLORS.neutral_300, COLORS.neutral_300);
|
|
60
60
|
var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
61
61
|
var id = _ref.id,
|
|
62
|
+
className = _ref.className,
|
|
62
63
|
variant = _ref.variant,
|
|
63
64
|
shape = _ref.shape,
|
|
64
65
|
action = _ref.action,
|
|
@@ -84,6 +85,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
84
85
|
case 'secondary':
|
|
85
86
|
return /*#__PURE__*/_jsx(StyledSecondaryIconButton, {
|
|
86
87
|
id: id,
|
|
88
|
+
className: className,
|
|
87
89
|
type: type !== null && type !== void 0 ? type : 'button',
|
|
88
90
|
"data-testid": id,
|
|
89
91
|
ref: ref,
|
|
@@ -114,6 +116,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
114
116
|
default:
|
|
115
117
|
return /*#__PURE__*/_jsx(StyledPrimaryIconButton, {
|
|
116
118
|
id: id,
|
|
119
|
+
className: className,
|
|
117
120
|
type: type !== null && type !== void 0 ? type : 'button',
|
|
118
121
|
"data-testid": id,
|
|
119
122
|
flatEdge: flatEdge,
|
|
@@ -144,6 +147,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
144
147
|
});
|
|
145
148
|
IconButton.propTypes = {
|
|
146
149
|
id: _pt.string,
|
|
150
|
+
className: _pt.string,
|
|
147
151
|
variant: _pt.oneOf(['primary', 'secondary']),
|
|
148
152
|
shape: _pt.oneOf(['square', 'circular']),
|
|
149
153
|
action: _pt.func.isRequired,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["React","styled","BREAKPOINTS","COLORS","focusStyles","invertedFocusStyles","defaultOnMouseDownHandler","getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","IconButtonContent","div","StyledIconButton","button","hideOnLowWidth","MEDIUM","unsetIconSize","invertFocus","StyledPrimaryIconButton","useTransparentBackground","primary_500","iconColor","white","primary_700","primary_800","neutral_200","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","forwardRef","ref","id","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","focusBackgroundColor","type","hidden","style","event","stopPropagation"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAyC,mBAAzC;AAEA,SAAQC,WAAR,EAAqBC,MAArB,EAA6BC,WAA7B,EAA0CC,mBAA1C,QAAoE,WAApE;AACA,SAAQC,yBAAR,QAAwC,WAAxC;;;AAeA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;AAAA,SAA4BA,KAAK,CAACC,YAAN,aAAwBD,KAAK,CAACC,YAA9B,UAAiD,KAA7E;AAAA,CAAxB;;AAEA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACF,KAAD,EAA2B;AACtD,MAAMG,MAAM,GAAGJ,eAAe,CAACC,KAAD,CAA9B;;AACA,UAAOA,KAAK,CAACI,QAAb;AAEI,SAAK,MAAL;AACI,2BAAcD,MAAd,cAAwBA,MAAxB;;AAEJ,SAAK,OAAL;AACI,uBAAUA,MAAV,sBAA4BA,MAA5B;;AAEJ,SAAK,MAAL;AACA;AACI,uBAAUA,MAAV;AAVR;AAYD,CAdD;;AAgBA,OAAO,IAAME,iBAAiB,GAAGZ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AD;AAAA,oBAAoBJ;AAApB;AArBF,QADF;AA5BJ;AAsDD,CA9EkB,CAAnB;;AAtBEL,EAAAA,E;AACAC,EAAAA,O,aAAU,S,EAAY,W;AACtBC,EAAAA,K,aAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACAvB,EAAAA,c;AAEAwB,EAAAA,c;AACAE,EAAAA,Q;AACArB,EAAAA,wB;AACAE,EAAAA,S;AACAL,EAAAA,a;AACAyB,EAAAA,Q;AACAnC,EAAAA,Y;AACAoC,EAAAA,U;AACAC,EAAAA,oB;AAEAJ,EAAAA,Q;AACAM,EAAAA,M;AAEA5B,EAAAA,W;;AAmFF,eAAec,UAAf","sourcesContent":["import React from 'react';\nimport styled, {css, CSSProperties} from 'styled-components';\n\nimport {BREAKPOINTS, COLORS, focusStyles, invertedFocusStyles} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n invertFocus?: boolean;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n\n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nexport const IconButtonContent = styled.div``;\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n ${IconButtonContent} {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ${props => props.invertFocus ? invertedFocusStyles : focusStyles}\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:hover:not(:disabled) {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_700};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n ${IconButtonContent} {\n background: ${COLORS.primary_800};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n ${IconButtonContent} {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n \n &:hover:not(:disabled) {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_20};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n ${IconButtonContent} {\n background: ${COLORS.primary_100};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n`;\n\nexport interface IconButtonProps {\n id?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n style?: CSSProperties | undefined;\n invertFocus?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden,\n style,\n invertFocus\n}: IconButtonProps, ref) => {\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["React","styled","BREAKPOINTS","COLORS","focusStyles","invertedFocusStyles","defaultOnMouseDownHandler","getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","IconButtonContent","div","StyledIconButton","button","hideOnLowWidth","MEDIUM","unsetIconSize","invertFocus","StyledPrimaryIconButton","useTransparentBackground","primary_500","iconColor","white","primary_700","primary_800","neutral_200","StyledSecondaryIconButton","neutral_600","primary_20","primary_100","neutral_300","IconButton","forwardRef","ref","id","className","variant","shape","action","isInMobileMenu","children","disabled","tabIndex","onKeyPress","focusBackgroundColor","type","hidden","style","event","stopPropagation"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAyC,mBAAzC;AAEA,SAAQC,WAAR,EAAqBC,MAArB,EAA6BC,WAA7B,EAA0CC,mBA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AAA,KAAK,CAACC,eAAN;AAAyBX,UAAAA,MAAM,CAACU,KAAD,CAAN;AAAe,SAPrG;AAQE,QAAA,QAAQ,EAAEP,QARZ;AASE,QAAA,cAAc,EAAE3B,cAAc,IAAI,KATpC;AAUE,QAAA,YAAY,EAAEyB,cAVhB;AAWE,QAAA,wBAAwB,EAAEpB,wBAX5B;AAYE,QAAA,SAAS,EAAEE,SAZb;AAaE,QAAA,aAAa,EAAEL,aAbjB;AAcE,QAAA,QAAQ,EAAE0B,QAAQ,IAAI,CAdxB;AAeE,QAAA,YAAY,EAAEpC,YAAY,IAAI+B,KAAK,KAAK,UAA1B,GAAuC,EAAvC,GAA4C,CAf5D;AAgBE,QAAA,WAAW,EAAElC,yBAhBf;AAiBE,QAAA,UAAU,EAAEwC,UAjBd;AAkBE,QAAA,MAAM,EAAEG,MAlBV;AAmBE,QAAA,KAAK,EAAEC,KAnBT;AAoBE,QAAA,WAAW,EAAE9B,WApBf;AAqBE,QAAA,oBAAoB,EAAE2B,oBArBxB;AAAA,+BAsBE,KAAC,iBAAD;AAAA,oBAAoBJ;AAApB;AAtBF,QADF;AA7BJ;AAwDD,CAjFkB,CAAnB;;AAvBEN,EAAAA,E;AACAC,EAAAA,S;AACAC,EAAAA,O,aAAU,S,EAAY,W;AACtBC,EAAAA,K,aAAQ,Q,EAAW,U;AACnBC,EAAAA,M;AACAxB,EAAAA,c;AAEAyB,EAAAA,c;AACAE,EAAAA,Q;AACAtB,EAAAA,wB;AACAE,EAAAA,S;AACAL,EAAAA,a;AACA0B,EAAAA,Q;AACApC,EAAAA,Y;AACAqC,EAAAA,U;AACAC,EAAAA,oB;AAEAJ,EAAAA,Q;AACAM,EAAAA,M;AAEA7B,EAAAA,W;;AAsFF,eAAec,UAAf","sourcesContent":["import React from 'react';\nimport styled, {css, CSSProperties} from 'styled-components';\n\nimport {BREAKPOINTS, COLORS, focusStyles, invertedFocusStyles} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\ninterface HeaderItemProps {\n hideOnLowWidth: boolean;\n inMobileMenu?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n borderRadius?: number;\n shape?: string;\n flatEdge?: string;\n focusBackgroundColor?: string;\n invertFocus?: boolean;\n}\n\nconst getBorderRadius = (props:HeaderItemProps) => (props.borderRadius ? `${props.borderRadius}px` : '4px');\n\nconst getBorderRadiusStyle = (props:HeaderItemProps) => {\n const radius = getBorderRadius(props);\n switch(props.flatEdge)\n {\n case 'left':\n return `0px ${radius} ${radius} 0px`;\n\n case 'right':\n return `${radius} 0px 0px ${radius}`;\n\n case 'none':\n default:\n return `${radius}`;\n }\n};\n\nexport const IconButtonContent = styled.div``;\n\nconst StyledIconButton = styled.button<HeaderItemProps>`\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ${(props) => (props.hideOnLowWidth ? 'none' : 'block')};\n ${BREAKPOINTS.MEDIUM} {\n display: block;\n }\n\n border-radius: ${(props) => (props.borderRadius ? `${props.borderRadius}px` : '4px')};\n ${IconButtonContent} {\n height: 36px;\n width: 36px;\n border-radius: ${getBorderRadiusStyle};\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n width: ${(props) => (props.unsetIconSize ? 'unset' : '24px')};\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ${props => props.invertFocus ? invertedFocusStyles : focusStyles}\n }\n`;\n\nexport const StyledPrimaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.primary_500)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.white};\n path {\n fill: ${(props) => props.iconColor || COLORS.white};\n }\n }\n }\n &:hover:not(:disabled), &.hover-state {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_700};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled), &.active-state {\n ${IconButtonContent} {\n background: ${COLORS.primary_800};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n ${IconButtonContent} {\n background-color: ${COLORS.neutral_200};\n }\n svg {\n path {\n fill: ${COLORS.white};\n }\n fill: ${COLORS.white};\n }\n }\n\n`;\n\nexport const StyledSecondaryIconButton = styled(StyledIconButton)`\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n\n svg {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n path {\n fill: ${(props) => props.iconColor || COLORS.neutral_600};\n }\n }\n }\n \n &:hover:not(:disabled), &.hover-state {\n ${IconButtonContent} {\n background-color: ${COLORS.primary_20};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled), &.active-state {\n ${IconButtonContent} {\n background: ${COLORS.primary_100};\n }\n ${IconButtonContent} svg path,\n ${IconButtonContent} svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n ${IconButtonContent} {\n background-color: ${(props) => (props.useTransparentBackground ? 'transparent' : COLORS.white)};\n }\n svg {\n path {\n fill: ${COLORS.neutral_300};\n }\n fill: ${COLORS.neutral_300};\n }\n }\n\n`;\n\nexport interface IconButtonProps {\n id?: string;\n className?: string;\n variant?: 'primary' | 'secondary';\n shape?: 'square' | 'circular';\n action: (event?: React.MouseEvent<HTMLButtonElement>) => void;\n hideOnLowWidth?: boolean;\n flatEdge?: 'right' | 'left' | 'none' | undefined;\n isInMobileMenu?: boolean;\n disabled?: boolean;\n useTransparentBackground?: boolean;\n iconColor?: string;\n unsetIconSize?: boolean;\n tabIndex?: number;\n borderRadius?: number;\n onKeyPress?: React.KeyboardEventHandler<HTMLButtonElement>;\n focusBackgroundColor?: string;\n type?: 'submit' | 'reset' | 'button' | undefined;\n children?: React.ReactNode;\n hidden?: boolean;\n style?: CSSProperties | undefined;\n invertFocus?: boolean;\n}\n\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(({\n id,\n className,\n variant,\n shape,\n action,\n hideOnLowWidth,\n isInMobileMenu,\n children,\n useTransparentBackground,\n disabled,\n iconColor,\n unsetIconSize,\n tabIndex,\n flatEdge,\n borderRadius,\n onKeyPress,\n focusBackgroundColor,\n type,\n hidden,\n style,\n invertFocus\n}: IconButtonProps, ref) => {\n\n // Let's render button\n switch (variant) {\n case 'secondary':\n return (\n <StyledSecondaryIconButton\n id={id}\n className={className}\n type={type ?? 'button'}\n data-testid={id}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledSecondaryIconButton>\n );\n case 'primary':\n default:\n return (\n <StyledPrimaryIconButton\n id={id}\n className={className}\n type={type ?? 'button'}\n data-testid={id}\n flatEdge={flatEdge}\n ref={ref}\n onClick={(event: React.MouseEvent<HTMLButtonElement>) => {event.stopPropagation(); action(event);}}\n disabled={disabled}\n hideOnLowWidth={hideOnLowWidth || false}\n inMobileMenu={isInMobileMenu}\n useTransparentBackground={useTransparentBackground}\n iconColor={iconColor}\n unsetIconSize={unsetIconSize}\n tabIndex={tabIndex || 0}\n borderRadius={borderRadius || shape === 'circular' ? 18 : 0}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={onKeyPress}\n hidden={hidden}\n style={style}\n invertFocus={invertFocus}\n focusBackgroundColor={focusBackgroundColor}>\n <IconButtonContent>{children}</IconButtonContent>\n </StyledPrimaryIconButton>\n );\n }\n});\n\nexport default IconButton;\n"],"file":"Iconbutton.js"}
|
|
@@ -39,7 +39,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
39
39
|
|
|
40
40
|
var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)([""])));
|
|
41
41
|
|
|
42
|
-
var LabelContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-bottom: 4px;\n color: ", ";\n display: flex;\n ", "\n"])), _styles.COLORS.neutral_500, (
|
|
42
|
+
var LabelContainer = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-bottom: 4px;\n color: ", ";\n display: flex;\n ", "\n"])), _styles.COLORS.neutral_500, function (props) {
|
|
43
|
+
return props.size === _types.Size.Small ? (0, _typography.ComponentXXSStyling)(_typography.ComponentTextStyle.Regular, null) : (0, _typography.ComponentXSStyling)(_typography.ComponentTextStyle.Regular, null);
|
|
44
|
+
});
|
|
43
45
|
|
|
44
46
|
var LabelText = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)([""])));
|
|
45
47
|
|
|
@@ -59,23 +61,25 @@ var PrefixContainer = _styledComponents.default.div(_templateObject6 || (_templa
|
|
|
59
61
|
return props.size === _types.Size.Small ? (0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Regular, null) : (0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Regular, null);
|
|
60
62
|
});
|
|
61
63
|
|
|
62
|
-
var OperatorWrapper = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n margin:", ";\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n
|
|
64
|
+
var OperatorWrapper = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n margin:", ";\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n margin: 16px 0;\n background: ", ";\n width: 1px;\n }\n"])), function (props) {
|
|
63
65
|
return props.size === _types.Size.Medium ? '4px 0' : '';
|
|
64
|
-
}, _styles.COLORS.neutral_200
|
|
66
|
+
}, _styles.COLORS.neutral_200);
|
|
65
67
|
|
|
66
|
-
var NumberInput = _styledComponents.default.input(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n width: 100
|
|
68
|
+
var NumberInput = _styledComponents.default.input(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n width: 100%; \n height: ", "; \n border: none;\n color: ", ";\n padding: 0; \n ", "\n\n &:hover, &:focus, &:active {\n outline: none;\n }\n"])), function (props) {
|
|
67
69
|
return props.fieldSize === _types.Size.Small ? '20px' : '24px';
|
|
68
70
|
}, _styles.COLORS.neutral_500, function (props) {
|
|
69
71
|
return props.fieldSize === _types.Size.Small ? (0, _typography.ComponentSStyling)(_typography.ComponentTextStyle.Italic, null) : (0, _typography.ComponentMStyling)(_typography.ComponentTextStyle.Italic, null);
|
|
70
72
|
});
|
|
71
73
|
|
|
72
|
-
var NoteLabel = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n ", " \n"])), _styles.COLORS.neutral_500, (
|
|
74
|
+
var NoteLabel = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n ", " \n"])), _styles.COLORS.neutral_500, function (props) {
|
|
75
|
+
return props.size === _types.Size.Small ? (0, _typography.ComponentXXSStyling)(_typography.ComponentTextStyle.Regular, null) : (0, _typography.ComponentXSStyling)(_typography.ComponentTextStyle.Regular, null);
|
|
76
|
+
});
|
|
73
77
|
|
|
74
78
|
var NoteIcon = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n svg {\n height: 16px;\n }\n"])));
|
|
75
79
|
|
|
76
80
|
var NoteContainer = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n margin-top: 5px;\n\n &.valid {\n ", " {\n color: ", ";\n }\n\n ", " {\n svg path {\n fill: ", ";\n }\n }\n }\n\n &.invalid {\n ", " {\n color: ", ";\n }\n\n ", " {\n svg path {\n fill: ", ";\n }\n }\n }\n"])), NoteLabel, _styles.COLORS.correct_500, NoteIcon, _styles.COLORS.correct_500, NoteLabel, _styles.COLORS.critical_500, NoteIcon, _styles.COLORS.critical_500);
|
|
77
81
|
|
|
78
|
-
var InputContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n min-width:
|
|
82
|
+
var InputContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n min-width: 160px;\n height: ", ";\n display: flex;\n border: 0;\n border-radius: 4px;\n box-shadow: inset 0px 0px 0px 1px ", ";\n\n &:hover:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &:focus-within:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &:active:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &.disabled {\n border: 1px solid ", ";\n cursor: not-allowed;\n \n ", "{\n color: ", ";\n }\n\n ", "{\n color: ", ";\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.readOnly {\n background: ", ";\n border: 1px solid ", ";\n cursor: not-allowed;\n\n ", "{\n background: ", ";\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.valid {\n border: 2px solid ", ";\n box-shadow: none;\n }\n\n &.invalid {\n border: 2px solid ", ";\n box-shadow: none;\n }\n"])), function (props) {
|
|
79
83
|
return props.size === _types.Size.Small ? '48px' : '56px';
|
|
80
84
|
}, _styles.COLORS.neutral_400, _styles.COLORS.primary_700, _styles.COLORS.primary_800, _styles.COLORS.primary_800, _styles.COLORS.neutral_100, PrefixContainer, _styles.COLORS.neutral_300, NumberInput, _styles.COLORS.neutral_300, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300, NumberInput, _styles.COLORS.neutral_100, _styles.COLORS.correct_400, _styles.COLORS.critical_400);
|
|
81
85
|
|
|
@@ -176,14 +180,17 @@ var NumberField = function NumberField(_ref) {
|
|
|
176
180
|
|
|
177
181
|
var isLocked = function isLocked(input, operator) {
|
|
178
182
|
var val = decimalPrecision ? parseFloat(input) : parseInt(input);
|
|
183
|
+
val = isNaN(val) && userInput === '' ? 0 : val;
|
|
179
184
|
var operatorState = false;
|
|
180
185
|
if (operator === 'add' && maxValue) operatorState = val < maxValue ? false : true;
|
|
181
186
|
if (operator === 'subtract' && minValue) operatorState = val > minValue ? false : true;
|
|
187
|
+
if (operator === 'subtract' && !minValue && !allowNegative) operatorState = val > 0 ? false : true;
|
|
182
188
|
return operatorState;
|
|
183
189
|
};
|
|
184
190
|
|
|
185
191
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
|
|
186
192
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(LabelContainer, {
|
|
193
|
+
size: size,
|
|
187
194
|
children: [required && /*#__PURE__*/(0, _jsxRuntime.jsx)(LabelIcon, {
|
|
188
195
|
size: size,
|
|
189
196
|
"data-testid": 'labelIcon',
|
|
@@ -219,6 +226,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
219
226
|
"data-testid": 'operators',
|
|
220
227
|
size: size,
|
|
221
228
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
229
|
+
tabIndex: -1,
|
|
222
230
|
variant: "secondary",
|
|
223
231
|
shape: "square",
|
|
224
232
|
action: function action() {
|
|
@@ -232,6 +240,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
232
240
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
233
241
|
className: "divider"
|
|
234
242
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
243
|
+
tabIndex: -1,
|
|
235
244
|
variant: "secondary",
|
|
236
245
|
shape: "square",
|
|
237
246
|
action: function action() {
|
|
@@ -249,6 +258,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
249
258
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(NoteIcon, {
|
|
250
259
|
children: noteIcon
|
|
251
260
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(NoteLabel, {
|
|
261
|
+
size: size,
|
|
252
262
|
children: note
|
|
253
263
|
})]
|
|
254
264
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/InputFields/NumberField.tsx"],"names":["Container","styled","div","LabelContainer","COLORS","neutral_500","ComponentTextStyle","Regular","LabelText","LabelIcon","props","size","Size","Small","InputWrapper","PrefixContainer","OperatorWrapper","Medium","neutral_200","NumberInput","input","fieldSize","Italic","NoteLabel","NoteIcon","NoteContainer","correct_500","critical_500","InputContainer","neutral_400","primary_700","primary_800","neutral_100","neutral_300","correct_400","critical_400","NumberField","label","note","noteIcon","required","prefix","interval","minValue","maxValue","allowNegative","decimalPrecision","disabled","readOnly","valid","defaultVal","React","useState","toString","userInput","setUserInput","fieldState","undefined","handleKeyPress","e","key","addInterval","subtractInterval","handleInput","preventDefault","simpleRegex","RegExp","decimalFormationRegEx","negativeDecimalFormationRegEx","allowNegativeRegex","decimalPrecisionRegex","negativeAndDecimalRegex","val","target","value","length","charAt","test","isInRange","replace","indexOf","lastIndexOf","includes","isDecimal","x","parseFloat","toFixed","parseInt","isNaN","Math","round","pow","isLocked","operator","operatorState","concat"],"mappings":";;;;;;;;;;;;;;;;;AAA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AXJ,EAgCKhB,IAAI,iBAAI,sBAAC,aAAD;AAAe,MAAA,SAAS,EAAE,YAAYyD,MAAZ,CAAmBvC,UAAU,cAAKA,UAAL,IAAkB,EAA/C,CAA1B;AAAA,8BACL,qBAAC,QAAD;AAAA,kBACKjB;AADL,QADK,eAIL,qBAAC,SAAD;AAAA,kBACKD;AADL,QAJK;AAAA,MAhCb;AAAA,IADJ;AA4CH,CAnLD;;;AAhBIG,EAAAA,M;AACAC,EAAAA,Q;AACAL,EAAAA,K;AACAC,EAAAA,I;AACAC,EAAAA,Q;AACAC,EAAAA,Q;AACAG,EAAAA,Q;AACAC,EAAAA,Q;AACAC,EAAAA,a;AACAC,EAAAA,gB;AACAC,EAAAA,Q;AACAC,EAAAA,Q;AACAC,EAAAA,K;AACAC,EAAAA,U;;eAwLWd,W","sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\nimport { IconButton } from '../Button';\nimport { SystemIcons } from '../icons';\nimport { COLORS } from '../styles';\nimport { ComponentMStyling, ComponentSStyling, ComponentTextStyle, ComponentXXSStyling } from '../styles/typography';\nimport { Size } from '../types';\n\nconst Container = styled.div``;\n\nconst LabelContainer = styled.div`\n margin-bottom: 4px;\n color: ${COLORS.neutral_500};\n display: flex;\n ${ComponentXXSStyling(ComponentTextStyle.Regular,null)}\n`;\n\nconst LabelText = styled.div``;\n\nconst LabelIcon = styled.div<{size: Size}>`\n margin-right: ${props => props.size === Size.Small?'6px':'8px'};\n svg {\n height: 9px;\n width: 9px;\n }\n`;\n\nconst InputWrapper = styled.div<{size: Size}>`\n margin: ${props => props.size === Size.Small?'14px 0 14px 16px':'16px 0 16px 16px'};\n display: flex;\n flex-grow: 1;\n`;\n\nconst PrefixContainer = styled.div<{size: Size}>`\n margin-right: 4px;\n width: ${props => props.size === Size.Small?'10px':'11px'};\n height: ${props => props.size === Size.Small?'20px':'24px'};\n color: ${COLORS.neutral_500};\n ${props=>props.size===Size.Small?ComponentSStyling(ComponentTextStyle.Regular,null):ComponentMStyling(ComponentTextStyle.Regular,null)}\n`;\n\nconst OperatorWrapper = styled.div<{size: Size}>`\n display: flex;\n margin:${props => props.size === Size.Medium?'4px 0':''};\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n border: 1px solid ${COLORS.neutral_200};\n margin: 16px 0;\n background: ${COLORS.neutral_200};\n }\n`;\n\nconst NumberInput = styled.input<{fieldSize: Size}>`\n width: 100%;\n height: ${props => props.fieldSize === Size.Small?'20px':'24px'};\n border: none;\n color: ${COLORS.neutral_500};\n ${props => props.fieldSize === Size.Small?ComponentSStyling(ComponentTextStyle.Italic, null):ComponentMStyling(ComponentTextStyle.Italic, null)}\n\n &:hover, &:focus, &:active {\n outline: none;\n }\n`;\n\nconst NoteLabel = styled.div`\n color: ${COLORS.neutral_500};\n ${ComponentXXSStyling(ComponentTextStyle.Regular,null)} \n`;\n\nconst NoteIcon = styled.div`\n svg {\n height: 16px;\n }\n`;\n\nconst NoteContainer = styled.div`\n display: flex;\n margin-top: 5px;\n\n &.valid {\n ${NoteLabel} {\n color: ${COLORS.correct_500};\n }\n\n ${NoteIcon} {\n svg path {\n fill: ${COLORS.correct_500};\n }\n }\n }\n\n &.invalid {\n ${NoteLabel} {\n color: ${COLORS.critical_500};\n }\n\n ${NoteIcon} {\n svg path {\n fill: ${COLORS.critical_500};\n }\n }\n }\n`;\n\nconst InputContainer = styled.div<{size: Size}>`\n min-width: 280px;\n height: ${props => props.size === Size.Small?'48px':'56px'};\n display: flex; \n border: 1px solid ${COLORS.neutral_400};\n border-radius: 4px;\n\n &:hover:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n border: 2px solid ${COLORS.primary_700};\n }\n\n &:focus-within:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n border: 2px solid ${COLORS.primary_800};\n }\n\n &:active:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n border: 2px solid ${COLORS.primary_800};\n }\n\n &.disabled {\n border: 1px solid ${COLORS.neutral_100};\n cursor: not-allowed;\n \n ${PrefixContainer}{\n color: ${COLORS.neutral_300};\n }\n\n ${NumberInput}{\n color: ${COLORS.neutral_300};\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.readOnly {\n background: ${COLORS.neutral_100};\n border: 1px solid ${COLORS.neutral_300};\n cursor: not-allowed;\n\n ${NumberInput}{\n background: ${COLORS.neutral_100};\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.valid {\n border: 2px solid ${COLORS.correct_400};\n }\n\n &.invalid {\n border: 2px solid ${COLORS.critical_400};\n }\n`;\n\ntype NumberFieldProps = {\n size: Size.Small | Size.Medium;\n prefix?: string;\n interval?: number;\n label: string;\n note?: string;\n noteIcon?: React.ReactNode;\n required?: boolean;\n minValue?: number;\n maxValue?: number;\n allowNegative?: boolean;\n decimalPrecision?: number;\n disabled?: boolean;\n readOnly?: boolean;\n valid?: boolean;\n defaultVal?: number;\n}\n\nconst NumberField: React.FunctionComponent<NumberFieldProps> = (\n {size=Size.Small, \n label,\n note, \n noteIcon, \n required, \n prefix,\n interval=1, \n minValue, \n maxValue, \n allowNegative, \n decimalPrecision, \n disabled=false, \n readOnly=false, \n valid,\n defaultVal}) => {\n const [userInput, setUserInput] = React.useState(defaultVal?defaultVal.toString():'');\n let fieldState = (valid!==undefined) ? (valid?'valid':'invalid') : undefined;\n\n const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n switch(e.key){\n case 'ArrowUp': addInterval();\n break;\n case 'ArrowDown': subtractInterval();\n break;\n default: break;\n }\n }\n\n const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n let simpleRegex = new RegExp(/^[0-9]\\d*$/);\n let decimalFormationRegEx = new RegExp(/^[0-9]\\d*\\.$/); \n let negativeDecimalFormationRegEx = new RegExp(/^[-][0-9]\\d*\\.$/);\n \n let allowNegativeRegex = new RegExp(/^[-][0-9]\\d*$/); \n let decimalPrecisionRegex = decimalPrecision ? new RegExp(`^[0-9]\\\\d*\\\\.[0-9]\\\\d{0,${decimalPrecision-1}}$`) : undefined;\n let negativeAndDecimalRegex = (decimalPrecision && allowNegative) ? new RegExp(`^[-][0-9]\\\\d*\\\\.[0-9]\\\\d{0,${decimalPrecision-1}}$`): undefined;\n \n let val = e.target.value; \n if(val!==''){\n if(allowNegative && decimalPrecision){\n if(val.length===1 && val.charAt(0)==='-')\n setUserInput(val);\n else{\n if((negativeAndDecimalRegex!.test(val) || decimalPrecisionRegex!.test(val)) && isInRange(val,true))\n setUserInput(val);\n\n else if((negativeDecimalFormationRegEx.test(val) || decimalFormationRegEx.test(val)) && isInRange(val.replace('.',''),true))\n setUserInput(val);\n \n else if((allowNegativeRegex.test(val) || simpleRegex.test(val)) && isInRange(val,true))\n setUserInput(val);\n }\n }\n\n else if(allowNegative){\n if(val.length===1 && val.charAt(0)==='-')\n setUserInput(val);\n else if((allowNegativeRegex.test(val) || simpleRegex.test(val)) && isInRange(val,false))\n setUserInput(val);\n }\n\n else if(decimalPrecision && (val.indexOf('.')===val.lastIndexOf('.')) && isInRange(val,true)){\n if(decimalPrecisionRegex!.test(val))\n setUserInput(val);\n else if(decimalFormationRegEx.test(val))\n setUserInput(val);\n else if(!val.includes('.') && simpleRegex.test(val))\n setUserInput(val);\n }\n\n else if(simpleRegex.test(val) && isInRange(val, false)){\n setUserInput(val);\n }\n }\n\n if(val==='')\n setUserInput('');\n }\n\n const isInRange = (value: string, isDecimal: boolean): boolean => {\n let x = isDecimal ? parseFloat(value).toFixed(decimalPrecision) : parseInt(value);\n if(minValue && minValue>x)\n return false;\n else if(maxValue && maxValue<x)\n return false;\n else\n return true;\n }\n\n const addInterval = () => {\n let val = decimalPrecision ? parseFloat(userInput) : parseInt(userInput);\n val = isNaN(val) && userInput === '' ? (minValue ?? 0) : val;\n if(!isNaN(val)){\n if(decimalPrecision)\n val = Math.round((val+interval)*Math.pow(10,decimalPrecision!))/Math.pow(10,decimalPrecision!);\n else\n val +=1;\n\n if(maxValue && maxValue>=val)\n setUserInput(val.toString());\n else if(!maxValue)\n setUserInput(val.toString());\n }\n }\n\n const subtractInterval = () => {\n let val = decimalPrecision ? parseFloat(userInput) : parseInt(userInput);\n val = isNaN(val) && userInput === '' ? (maxValue ?? 0) : val;\n if(!isNaN(val)){\n if(decimalPrecision)\n val = Math.round((val-interval)*Math.pow(10,decimalPrecision!))/Math.pow(10,decimalPrecision!);\n else\n val -=1;\n \n if(minValue && minValue<=val)\n allowNegative ? setUserInput(val.toString()) : (val>=0 ? setUserInput(val.toString()) : undefined);\n else if(!minValue)\n allowNegative ? setUserInput(val.toString()) : (val>=0 ? setUserInput(val.toString()) : undefined);\n }\n }\n\n const isLocked = (input: string, operator: string): boolean => {\n let val = decimalPrecision ? parseFloat(input) : parseInt(input);\n let operatorState = false;\n if(operator === 'add' && maxValue)\n operatorState = val < maxValue ? false : true;\n \n if(operator === 'subtract' && minValue)\n operatorState = val > minValue ? false : true;\n\n return operatorState;\n }\n\n return (\n <Container>\n <LabelContainer>\n {required && <LabelIcon size={size} data-testid={'labelIcon'}>\n <SystemIcons.Asterisk color={COLORS.critical_500}/>\n </LabelIcon>\n }\n <LabelText>\n {label}\n </LabelText>\n </LabelContainer>\n\n <InputContainer size={size} data-testid={'inputContainer'} tabIndex={-1} className={'numberField'.concat(disabled?' disabled':'')\n .concat(readOnly?' readOnly':'')\n .concat(fieldState?` ${fieldState}`:'')}>\n <InputWrapper size={size}>\n {prefix && <PrefixContainer size={size}>\n {prefix}\n </PrefixContainer>}\n <NumberInput fieldSize={size} placeholder='Enter number' value={userInput} tabIndex={(disabled || readOnly) ? -1 : 0} onChange={e=>handleInput(e)} onKeyDown={e=>handleKeyPress(e)}/>\n </InputWrapper>\n\n <OperatorWrapper data-testid={'operators'} size={size}>\n <IconButton variant='secondary' shape='square' action={()=>subtractInterval()} useTransparentBackground disabled={disabled || readOnly || isLocked(userInput,'subtract')}>\n <SystemIcons.Minus size='14px'/>\n </IconButton> \n <div className='divider'></div>\n <IconButton variant='secondary' shape='square' action={()=>addInterval()} useTransparentBackground disabled={disabled || readOnly || isLocked(userInput,'add')}>\n <SystemIcons.Plus size='14px'/>\n </IconButton>\n </OperatorWrapper>\n </InputContainer>\n\n {note && <NoteContainer className={'noteField'.concat(fieldState?` ${fieldState}`:'')}>\n <NoteIcon>\n {noteIcon}\n </NoteIcon>\n <NoteLabel>\n {note}\n </NoteLabel> \n </NoteContainer>\n }\n </Container>\n ); \n}\n\nexport default NumberField;\n"],"file":"NumberField.cjs"}
|
|
1
|
+
{"version":3,"sources":["../../src/InputFields/NumberField.tsx"],"names":["Container","styled","div","LabelContainer","COLORS","neutral_500","props","size","Size","Small","ComponentTextStyle","Regular","LabelText","LabelIcon","InputWrapper","PrefixContainer","OperatorWrapper","Medium","neutral_200","NumberInput","input","fieldSize","Italic","NoteLabel","NoteIcon","NoteContainer","correct_500","critical_500","InputContainer","neutral_400","primary_700","primary_800","neutral_100","neutral_300","correct_400","critical_400","NumberField","label","note","noteIcon","required","prefix","interval","minValue","maxValue","allowNegative","decimalPrecision","disabled","readOnly","valid","defaultVal","React","useState","toString","userInput","setUserInput","fieldState","undefined","handleKeyPress","e","key","addInterval","subtractInterval","handleInput","preventDefault","simpleRegex","RegExp","decimalFormationRegEx","negativeDecimalFormationRegEx","allowNegativeRegex","decimalPrecisionRegex","negativeAndDecimalRegex","val","target","value","length","charAt","test","isInRange","replace","indexOf","lastIndexOf","includes","isDecimal","x","parseFloat","toFixed","parseInt","isNaN","Math","round","pow","isLocked","operator","operatorState","concat"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,GAAGC,0BAAOC,GAAV,mFAAf;;AAEA,IAAMC,cAAc,GAAGF,0BAAOC,GAAV,iKAEPE,eAAOC,WAFA,EAId,UAAAC,KAAK;AAAA,SAAEA,KAAK,CAACC,IAAN,KAAaC,YAAKC,KAAlB,GAA0B,qCAAoBC,+BAAmBC,OAAvC,EAA+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AAA,OAAO,EAAC,WAAlC;AAA8C,UAAA,KAAK,EAAC,QAApD;AAA6D,UAAA,MAAM,EAAE;AAAA,mBAAIO,WAAW,EAAf;AAAA,WAArE;AAAwF,UAAA,wBAAwB,MAAhH;AAAiH,UAAA,QAAQ,EAAEd,QAAQ,IAAIC,QAAZ,IAAwB4C,QAAQ,CAACtC,SAAD,EAAW,KAAX,CAA3J;AAAA,iCACI,qBAAC,kBAAD,CAAa,IAAb;AAAkB,YAAA,IAAI,EAAC;AAAvB;AADJ,UALJ;AAAA,QAVJ;AAAA,MAXJ,EAgCKhB,IAAI,iBAAI,sBAAC,aAAD;AAAe,MAAA,SAAS,EAAE,YAAYyD,MAAZ,CAAmBvC,UAAU,cAAKA,UAAL,IAAkB,EAA/C,CAA1B;AAAA,8BACL,qBAAC,QAAD;AAAA,kBACKjB;AADL,QADK,eAIL,qBAAC,SAAD;AAAW,QAAA,IAAI,EAAEhC,IAAjB;AAAA,kBACK+B;AADL,QAJK;AAAA,MAhCb;AAAA,IADJ;AA4CH,CAvLD;;;AAhBIG,EAAAA,M;AACAC,EAAAA,Q;AACAL,EAAAA,K;AACAC,EAAAA,I;AACAC,EAAAA,Q;AACAC,EAAAA,Q;AACAG,EAAAA,Q;AACAC,EAAAA,Q;AACAC,EAAAA,a;AACAC,EAAAA,gB;AACAC,EAAAA,Q;AACAC,EAAAA,Q;AACAC,EAAAA,K;AACAC,EAAAA,U;;eA4LWd,W","sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\nimport { IconButton } from '../Button';\nimport { SystemIcons } from '../icons';\nimport { COLORS } from '../styles';\nimport { ComponentMStyling, ComponentSStyling, ComponentTextStyle, ComponentXXSStyling, ComponentXSStyling } from '../styles/typography';\nimport { Size } from '../types';\n\nconst Container = styled.div``;\n\nconst LabelContainer = styled.div<{size: Size}>`\n margin-bottom: 4px;\n color: ${COLORS.neutral_500};\n display: flex;\n ${props=>props.size===Size.Small ? ComponentXXSStyling(ComponentTextStyle.Regular,null) : ComponentXSStyling(ComponentTextStyle.Regular,null)}\n`;\n\nconst LabelText = styled.div``;\n\nconst LabelIcon = styled.div<{size: Size}>`\n margin-right: ${props => props.size === Size.Small?'6px':'8px'};\n svg {\n height: 9px;\n width: 9px;\n }\n`;\n\nconst InputWrapper = styled.div<{size: Size}>`\n margin: ${props => props.size === Size.Small?'14px 0 14px 16px':'16px 0 16px 16px'};\n display: flex;\n flex-grow: 1;\n`;\n\nconst PrefixContainer = styled.div<{size: Size}>`\n margin-right: 4px;\n width: ${props => props.size === Size.Small?'10px':'11px'};\n height: ${props => props.size === Size.Small?'20px':'24px'};\n color: ${COLORS.neutral_500};\n ${props=>props.size===Size.Small?ComponentSStyling(ComponentTextStyle.Regular,null):ComponentMStyling(ComponentTextStyle.Regular,null)}\n`;\n\nconst OperatorWrapper = styled.div<{size: Size}>`\n display: flex;\n margin:${props => props.size === Size.Medium?'4px 0':''};\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n margin: 16px 0;\n background: ${COLORS.neutral_200};\n width: 1px;\n }\n`;\n\nconst NumberInput = styled.input<{fieldSize: Size}>`\n width: 100%; \n height: ${props => props.fieldSize === Size.Small?'20px':'24px'}; \n border: none;\n color: ${COLORS.neutral_500};\n padding: 0; \n ${props => props.fieldSize === Size.Small?ComponentSStyling(ComponentTextStyle.Italic, null):ComponentMStyling(ComponentTextStyle.Italic, null)}\n\n &:hover, &:focus, &:active {\n outline: none;\n }\n`;\n\nconst NoteLabel = styled.div<{size: Size}>`\n color: ${COLORS.neutral_500};\n ${props=>props.size===Size.Small ? ComponentXXSStyling(ComponentTextStyle.Regular,null) : ComponentXSStyling(ComponentTextStyle.Regular,null)} \n`;\n\nconst NoteIcon = styled.div`\n svg {\n height: 16px;\n }\n`;\n\nconst NoteContainer = styled.div`\n display: flex;\n margin-top: 5px;\n\n &.valid {\n ${NoteLabel} {\n color: ${COLORS.correct_500};\n }\n\n ${NoteIcon} {\n svg path {\n fill: ${COLORS.correct_500};\n }\n }\n }\n\n &.invalid {\n ${NoteLabel} {\n color: ${COLORS.critical_500};\n }\n\n ${NoteIcon} {\n svg path {\n fill: ${COLORS.critical_500};\n }\n }\n }\n`;\n\nconst InputContainer = styled.div<{size: Size}>`\n min-width: 160px;\n height: ${props => props.size === Size.Small?'48px':'56px'};\n display: flex;\n border: 0;\n border-radius: 4px;\n box-shadow: inset 0px 0px 0px 1px ${COLORS.neutral_400};\n\n &:hover:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_700};\n }\n\n &:focus-within:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_800};\n }\n\n &:active:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ${COLORS.primary_800};\n }\n\n &.disabled {\n border: 1px solid ${COLORS.neutral_100};\n cursor: not-allowed;\n \n ${PrefixContainer}{\n color: ${COLORS.neutral_300};\n }\n\n ${NumberInput}{\n color: ${COLORS.neutral_300};\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.readOnly {\n background: ${COLORS.neutral_100};\n border: 1px solid ${COLORS.neutral_300};\n cursor: not-allowed;\n\n ${NumberInput}{\n background: ${COLORS.neutral_100};\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.valid {\n border: 2px solid ${COLORS.correct_400};\n box-shadow: none;\n }\n\n &.invalid {\n border: 2px solid ${COLORS.critical_400};\n box-shadow: none;\n }\n`;\n\ntype NumberFieldProps = {\n size: Size.Small | Size.Medium;\n prefix?: string;\n interval?: number;\n label: string;\n note?: string;\n noteIcon?: React.ReactNode;\n required?: boolean;\n minValue?: number;\n maxValue?: number;\n allowNegative?: boolean;\n decimalPrecision?: number;\n disabled?: boolean;\n readOnly?: boolean;\n valid?: boolean;\n defaultVal?: number;\n}\n\nconst NumberField: React.FunctionComponent<NumberFieldProps> = (\n {size=Size.Small, \n label,\n note, \n noteIcon, \n required, \n prefix,\n interval=1, \n minValue, \n maxValue, \n allowNegative, \n decimalPrecision, \n disabled=false, \n readOnly=false, \n valid,\n defaultVal}) => {\n const [userInput, setUserInput] = React.useState(defaultVal?defaultVal.toString():'');\n let fieldState = (valid!==undefined) ? (valid?'valid':'invalid') : undefined;\n\n const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n switch(e.key){\n case 'ArrowUp': addInterval();\n break;\n case 'ArrowDown': subtractInterval();\n break;\n default: break;\n }\n }\n\n const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n let simpleRegex = new RegExp(/^[0-9]\\d*$/);\n let decimalFormationRegEx = new RegExp(/^[0-9]\\d*\\.$/); \n let negativeDecimalFormationRegEx = new RegExp(/^[-][0-9]\\d*\\.$/);\n \n let allowNegativeRegex = new RegExp(/^[-][0-9]\\d*$/); \n let decimalPrecisionRegex = decimalPrecision ? new RegExp(`^[0-9]\\\\d*\\\\.[0-9]\\\\d{0,${decimalPrecision-1}}$`) : undefined;\n let negativeAndDecimalRegex = (decimalPrecision && allowNegative) ? new RegExp(`^[-][0-9]\\\\d*\\\\.[0-9]\\\\d{0,${decimalPrecision-1}}$`): undefined;\n \n let val = e.target.value; \n if(val!==''){\n if(allowNegative && decimalPrecision){\n if(val.length===1 && val.charAt(0)==='-')\n setUserInput(val);\n else{\n if((negativeAndDecimalRegex!.test(val) || decimalPrecisionRegex!.test(val)) && isInRange(val,true))\n setUserInput(val);\n\n else if((negativeDecimalFormationRegEx.test(val) || decimalFormationRegEx.test(val)) && isInRange(val.replace('.',''),true))\n setUserInput(val);\n \n else if((allowNegativeRegex.test(val) || simpleRegex.test(val)) && isInRange(val,true))\n setUserInput(val);\n }\n }\n\n else if(allowNegative){\n if(val.length===1 && val.charAt(0)==='-')\n setUserInput(val);\n else if((allowNegativeRegex.test(val) || simpleRegex.test(val)) && isInRange(val,false))\n setUserInput(val);\n }\n\n else if(decimalPrecision && (val.indexOf('.')===val.lastIndexOf('.')) && isInRange(val,true)){\n if(decimalPrecisionRegex!.test(val))\n setUserInput(val);\n else if(decimalFormationRegEx.test(val))\n setUserInput(val);\n else if(!val.includes('.') && simpleRegex.test(val))\n setUserInput(val);\n }\n\n else if(simpleRegex.test(val) && isInRange(val, false)){\n setUserInput(val);\n }\n }\n\n if(val==='')\n setUserInput('');\n }\n\n const isInRange = (value: string, isDecimal: boolean): boolean => {\n let x = isDecimal ? parseFloat(value).toFixed(decimalPrecision) : parseInt(value);\n if(minValue && minValue>x)\n return false;\n else if(maxValue && maxValue<x)\n return false;\n else\n return true;\n }\n\n const addInterval = () => {\n let val = decimalPrecision ? parseFloat(userInput) : parseInt(userInput);\n val = isNaN(val) && userInput === '' ? (minValue ?? 0) : val;\n if(!isNaN(val)){\n if(decimalPrecision)\n val = Math.round((val+interval)*Math.pow(10,decimalPrecision!))/Math.pow(10,decimalPrecision!);\n else\n val +=1;\n\n if(maxValue && maxValue>=val)\n setUserInput(val.toString());\n else if(!maxValue)\n setUserInput(val.toString());\n }\n }\n\n const subtractInterval = () => {\n let val = decimalPrecision ? parseFloat(userInput) : parseInt(userInput);\n val = isNaN(val) && userInput === '' ? (maxValue ?? 0) : val;\n if(!isNaN(val)){\n if(decimalPrecision)\n val = Math.round((val-interval)*Math.pow(10,decimalPrecision!))/Math.pow(10,decimalPrecision!);\n else\n val -=1;\n \n if(minValue && minValue<=val)\n allowNegative ? setUserInput(val.toString()) : (val>=0 ? setUserInput(val.toString()) : undefined);\n else if(!minValue)\n allowNegative ? setUserInput(val.toString()) : (val>=0 ? setUserInput(val.toString()) : undefined);\n }\n }\n\n const isLocked = (input: string, operator: string): boolean => {\n let val = decimalPrecision ? parseFloat(input) : parseInt(input);\n val = isNaN(val) && userInput === '' ? 0 : val;\n let operatorState = false;\n if(operator === 'add' && maxValue)\n operatorState = val < maxValue ? false : true;\n \n if(operator === 'subtract' && minValue)\n operatorState = val > minValue ? false : true;\n\n if(operator === 'subtract' && !minValue && !allowNegative)\n operatorState = val > 0 ? false : true;\n\n return operatorState;\n }\n\n return (\n <Container>\n <LabelContainer size={size}>\n {required && <LabelIcon size={size} data-testid={'labelIcon'}>\n <SystemIcons.Asterisk color={COLORS.critical_500}/>\n </LabelIcon>\n }\n <LabelText>\n {label}\n </LabelText>\n </LabelContainer>\n\n <InputContainer size={size} data-testid={'inputContainer'} tabIndex={-1} className={'numberField'.concat(disabled?' disabled':'')\n .concat(readOnly?' readOnly':'')\n .concat(fieldState?` ${fieldState}`:'')}>\n <InputWrapper size={size}>\n {prefix && <PrefixContainer size={size}>\n {prefix}\n </PrefixContainer>}\n <NumberInput fieldSize={size} placeholder='Enter number' value={userInput} tabIndex={(disabled || readOnly) ? -1 : 0} onChange={e=>handleInput(e)} onKeyDown={e=>handleKeyPress(e)}/>\n </InputWrapper>\n\n <OperatorWrapper data-testid={'operators'} size={size}>\n <IconButton tabIndex={-1} variant='secondary' shape='square' action={()=>subtractInterval()} useTransparentBackground disabled={disabled || readOnly || isLocked(userInput,'subtract')}>\n <SystemIcons.Minus size='14px'/>\n </IconButton> \n <div className='divider'></div>\n <IconButton tabIndex={-1} variant='secondary' shape='square' action={()=>addInterval()} useTransparentBackground disabled={disabled || readOnly || isLocked(userInput,'add')}>\n <SystemIcons.Plus size='14px'/>\n </IconButton>\n </OperatorWrapper>\n </InputContainer>\n\n {note && <NoteContainer className={'noteField'.concat(fieldState?` ${fieldState}`:'')}>\n <NoteIcon>\n {noteIcon}\n </NoteIcon>\n <NoteLabel size={size}>\n {note}\n </NoteLabel> \n </NoteContainer>\n }\n </Container>\n ); \n}\n\nexport default NumberField;\n"],"file":"NumberField.cjs"}
|
|
@@ -9,12 +9,14 @@ import styled from 'styled-components';
|
|
|
9
9
|
import { IconButton } from '../Button';
|
|
10
10
|
import { SystemIcons } from '../icons';
|
|
11
11
|
import { COLORS } from '../styles';
|
|
12
|
-
import { ComponentMStyling, ComponentSStyling, ComponentTextStyle, ComponentXXSStyling } from '../styles/typography';
|
|
12
|
+
import { ComponentMStyling, ComponentSStyling, ComponentTextStyle, ComponentXXSStyling, ComponentXSStyling } from '../styles/typography';
|
|
13
13
|
import { Size } from '../types';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
var Container = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
|
|
17
|
-
var LabelContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-bottom: 4px;\n color: ", ";\n display: flex;\n ", "\n"])), COLORS.neutral_500,
|
|
17
|
+
var LabelContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-bottom: 4px;\n color: ", ";\n display: flex;\n ", "\n"])), COLORS.neutral_500, function (props) {
|
|
18
|
+
return props.size === Size.Small ? ComponentXXSStyling(ComponentTextStyle.Regular, null) : ComponentXSStyling(ComponentTextStyle.Regular, null);
|
|
19
|
+
});
|
|
18
20
|
var LabelText = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
|
|
19
21
|
var LabelIcon = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n margin-right: ", ";\n svg {\n height: 9px;\n width: 9px;\n }\n"])), function (props) {
|
|
20
22
|
return props.size === Size.Small ? '6px' : '8px';
|
|
@@ -29,18 +31,20 @@ var PrefixContainer = styled.div(_templateObject6 || (_templateObject6 = _tagged
|
|
|
29
31
|
}, COLORS.neutral_500, function (props) {
|
|
30
32
|
return props.size === Size.Small ? ComponentSStyling(ComponentTextStyle.Regular, null) : ComponentMStyling(ComponentTextStyle.Regular, null);
|
|
31
33
|
});
|
|
32
|
-
var OperatorWrapper = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n margin:", ";\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n
|
|
34
|
+
var OperatorWrapper = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n margin:", ";\n svg {\n height: 14px;\n width: 14px;\n }\n .divider {\n margin: 16px 0;\n background: ", ";\n width: 1px;\n }\n"])), function (props) {
|
|
33
35
|
return props.size === Size.Medium ? '4px 0' : '';
|
|
34
|
-
}, COLORS.neutral_200
|
|
35
|
-
var NumberInput = styled.input(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 100
|
|
36
|
+
}, COLORS.neutral_200);
|
|
37
|
+
var NumberInput = styled.input(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 100%; \n height: ", "; \n border: none;\n color: ", ";\n padding: 0; \n ", "\n\n &:hover, &:focus, &:active {\n outline: none;\n }\n"])), function (props) {
|
|
36
38
|
return props.fieldSize === Size.Small ? '20px' : '24px';
|
|
37
39
|
}, COLORS.neutral_500, function (props) {
|
|
38
40
|
return props.fieldSize === Size.Small ? ComponentSStyling(ComponentTextStyle.Italic, null) : ComponentMStyling(ComponentTextStyle.Italic, null);
|
|
39
41
|
});
|
|
40
|
-
var NoteLabel = styled.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n color: ", ";\n ", " \n"])), COLORS.neutral_500,
|
|
42
|
+
var NoteLabel = styled.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n color: ", ";\n ", " \n"])), COLORS.neutral_500, function (props) {
|
|
43
|
+
return props.size === Size.Small ? ComponentXXSStyling(ComponentTextStyle.Regular, null) : ComponentXSStyling(ComponentTextStyle.Regular, null);
|
|
44
|
+
});
|
|
41
45
|
var NoteIcon = styled.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n svg {\n height: 16px;\n }\n"])));
|
|
42
46
|
var NoteContainer = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n margin-top: 5px;\n\n &.valid {\n ", " {\n color: ", ";\n }\n\n ", " {\n svg path {\n fill: ", ";\n }\n }\n }\n\n &.invalid {\n ", " {\n color: ", ";\n }\n\n ", " {\n svg path {\n fill: ", ";\n }\n }\n }\n"])), NoteLabel, COLORS.correct_500, NoteIcon, COLORS.correct_500, NoteLabel, COLORS.critical_500, NoteIcon, COLORS.critical_500);
|
|
43
|
-
var InputContainer = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n min-width:
|
|
47
|
+
var InputContainer = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n min-width: 160px;\n height: ", ";\n display: flex;\n border: 0;\n border-radius: 4px;\n box-shadow: inset 0px 0px 0px 1px ", ";\n\n &:hover:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &:focus-within:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &:active:not(.disabled):not(.readOnly):not(.valid):not(.invalid) {\n box-shadow: inset 0px 0px 0px 2px ", ";\n }\n\n &.disabled {\n border: 1px solid ", ";\n cursor: not-allowed;\n \n ", "{\n color: ", ";\n }\n\n ", "{\n color: ", ";\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.readOnly {\n background: ", ";\n border: 1px solid ", ";\n cursor: not-allowed;\n\n ", "{\n background: ", ";\n cursor: not-allowed;\n pointer-events: none;\n }\n }\n\n &.valid {\n border: 2px solid ", ";\n box-shadow: none;\n }\n\n &.invalid {\n border: 2px solid ", ";\n box-shadow: none;\n }\n"])), function (props) {
|
|
44
48
|
return props.size === Size.Small ? '48px' : '56px';
|
|
45
49
|
}, COLORS.neutral_400, COLORS.primary_700, COLORS.primary_800, COLORS.primary_800, COLORS.neutral_100, PrefixContainer, COLORS.neutral_300, NumberInput, COLORS.neutral_300, COLORS.neutral_100, COLORS.neutral_300, NumberInput, COLORS.neutral_100, COLORS.correct_400, COLORS.critical_400);
|
|
46
50
|
|
|
@@ -141,14 +145,17 @@ var NumberField = function NumberField(_ref) {
|
|
|
141
145
|
|
|
142
146
|
var isLocked = function isLocked(input, operator) {
|
|
143
147
|
var val = decimalPrecision ? parseFloat(input) : parseInt(input);
|
|
148
|
+
val = isNaN(val) && userInput === '' ? 0 : val;
|
|
144
149
|
var operatorState = false;
|
|
145
150
|
if (operator === 'add' && maxValue) operatorState = val < maxValue ? false : true;
|
|
146
151
|
if (operator === 'subtract' && minValue) operatorState = val > minValue ? false : true;
|
|
152
|
+
if (operator === 'subtract' && !minValue && !allowNegative) operatorState = val > 0 ? false : true;
|
|
147
153
|
return operatorState;
|
|
148
154
|
};
|
|
149
155
|
|
|
150
156
|
return /*#__PURE__*/_jsxs(Container, {
|
|
151
157
|
children: [/*#__PURE__*/_jsxs(LabelContainer, {
|
|
158
|
+
size: size,
|
|
152
159
|
children: [required && /*#__PURE__*/_jsx(LabelIcon, {
|
|
153
160
|
size: size,
|
|
154
161
|
"data-testid": 'labelIcon',
|
|
@@ -184,6 +191,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
184
191
|
"data-testid": 'operators',
|
|
185
192
|
size: size,
|
|
186
193
|
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
194
|
+
tabIndex: -1,
|
|
187
195
|
variant: "secondary",
|
|
188
196
|
shape: "square",
|
|
189
197
|
action: function action() {
|
|
@@ -197,6 +205,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
197
205
|
}), /*#__PURE__*/_jsx("div", {
|
|
198
206
|
className: "divider"
|
|
199
207
|
}), /*#__PURE__*/_jsx(IconButton, {
|
|
208
|
+
tabIndex: -1,
|
|
200
209
|
variant: "secondary",
|
|
201
210
|
shape: "square",
|
|
202
211
|
action: function action() {
|
|
@@ -214,6 +223,7 @@ var NumberField = function NumberField(_ref) {
|
|
|
214
223
|
children: [/*#__PURE__*/_jsx(NoteIcon, {
|
|
215
224
|
children: noteIcon
|
|
216
225
|
}), /*#__PURE__*/_jsx(NoteLabel, {
|
|
226
|
+
size: size,
|
|
217
227
|
children: note
|
|
218
228
|
})]
|
|
219
229
|
})]
|