@laerdal/life-react-components 1.7.0-dev.13.full → 1.7.0-dev.16

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.
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.StyledSecondaryIconButton = exports.StyledPrimaryIconButton = void 0;
8
+ exports.default = exports.StyledSecondaryIconButton = exports.StyledPrimaryIconButton = exports.IconButtonContent = void 0;
9
9
 
10
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
11
 
@@ -21,7 +21,7 @@ var _common = require("../common");
21
21
 
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
 
24
- var _templateObject, _templateObject2, _templateObject3;
24
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
25
25
 
26
26
  var getBorderRadius = function getBorderRadius(props) {
27
27
  return props.borderRadius ? "".concat(props.borderRadius, "px") : '4px';
@@ -43,11 +43,15 @@ var getBorderRadiusStyle = function getBorderRadiusStyle(props) {
43
43
  }
44
44
  };
45
45
 
46
- var StyledIconButton = _styledComponents.default.button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ", ";\n ", " {\n display: block;\n }\n\n border-radius: ", ";\n div {\n height: 36px;\n width: 36px;\n border-radius: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ", ";\n width: ", ";\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ", "\n }\n"])), function (props) {
46
+ var IconButtonContent = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)([""])));
47
+
48
+ exports.IconButtonContent = IconButtonContent;
49
+
50
+ var StyledIconButton = _styledComponents.default.button(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ", ";\n ", " {\n display: block;\n }\n\n border-radius: ", ";\n ", " {\n height: 36px;\n width: 36px;\n border-radius: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ", ";\n width: ", ";\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ", "\n }\n"])), function (props) {
47
51
  return props.hideOnLowWidth ? 'none' : 'block';
48
52
  }, _styles.BREAKPOINTS.MEDIUM, function (props) {
49
53
  return props.borderRadius ? "".concat(props.borderRadius, "px") : '4px';
50
- }, getBorderRadiusStyle, function (props) {
54
+ }, IconButtonContent, getBorderRadiusStyle, function (props) {
51
55
  return props.unsetIconSize ? 'unset' : '24px';
52
56
  }, function (props) {
53
57
  return props.unsetIconSize ? 'unset' : '24px';
@@ -55,21 +59,21 @@ var StyledIconButton = _styledComponents.default.button(_templateObject || (_tem
55
59
  return props.invertFocus ? _styles.invertedFocusStyles : _styles.focusStyles;
56
60
  });
57
61
 
58
- var StyledPrimaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), 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) {\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) {
59
63
  return props.useTransparentBackground ? 'transparent' : _styles.COLORS.primary_500;
60
64
  }, function (props) {
61
65
  return props.iconColor || _styles.COLORS.white;
62
66
  }, function (props) {
63
67
  return props.iconColor || _styles.COLORS.white;
64
- }, _styles.COLORS.primary_700, _styles.COLORS.white, _styles.COLORS.primary_800, _styles.COLORS.white, _styles.COLORS.neutral_200, _styles.COLORS.white, _styles.COLORS.white);
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);
65
69
  exports.StyledPrimaryIconButton = StyledPrimaryIconButton;
66
- var StyledSecondaryIconButton = (0, _styledComponents.default)(StyledIconButton)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n \n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), 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) {\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) {
67
71
  return props.useTransparentBackground ? 'transparent' : _styles.COLORS.white;
68
72
  }, function (props) {
69
73
  return props.iconColor || _styles.COLORS.neutral_600;
70
74
  }, function (props) {
71
75
  return props.iconColor || _styles.COLORS.neutral_600;
72
- }, _styles.COLORS.primary_20, _styles.COLORS.primary_700, _styles.COLORS.primary_100, _styles.COLORS.primary_800, function (props) {
76
+ }, IconButtonContent, _styles.COLORS.primary_20, IconButtonContent, IconButtonContent, _styles.COLORS.primary_700, IconButtonContent, _styles.COLORS.primary_100, IconButtonContent, IconButtonContent, _styles.COLORS.primary_800, IconButtonContent, function (props) {
73
77
  return props.useTransparentBackground ? 'transparent' : _styles.COLORS.white;
74
78
  }, _styles.COLORS.neutral_300, _styles.COLORS.neutral_300);
75
79
  exports.StyledSecondaryIconButton = StyledSecondaryIconButton;
@@ -122,7 +126,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
122
126
  style: style,
123
127
  invertFocus: invertFocus,
124
128
  focusBackgroundColor: focusBackgroundColor,
125
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
129
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconButtonContent, {
126
130
  children: children
127
131
  })
128
132
  });
@@ -153,7 +157,7 @@ var IconButton = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
153
157
  style: style,
154
158
  invertFocus: invertFocus,
155
159
  focusBackgroundColor: focusBackgroundColor,
156
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
160
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconButtonContent, {
157
161
  children: children
158
162
  })
159
163
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","StyledIconButton","styled","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":";;;;;;;;;;;;;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;;AAgBA,IAAME,gBAAgB,GAAGC,0BAAOC,MAAV,+nBAQT,UAACP,KAAD;AAAA,SAAYA,KAAK,CAACQ,cAAN,GAAuB,MAAvB,GAAgC,OAA5C;AAAA,CAR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AAOE,QAAA,QAAQ,EAAEP,QAPZ;AAQE,QAAA,cAAc,EAAE/B,cAAc,IAAI,KARpC;AASE,QAAA,YAAY,EAAE6B,cAThB;AAUE,QAAA,wBAAwB,EAAErB,wBAV5B;AAWE,QAAA,SAAS,EAAEG,SAXb;AAYE,QAAA,aAAa,EAAER,aAZjB;AAaE,QAAA,QAAQ,EAAE6B,QAAQ,IAAI,CAbxB;AAcE,QAAA,YAAY,EAAEvC,YAAY,IAAIkC,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;AAAA,oBAAMJ;AAAN;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;AACAvC,EAAAA,Y;AACAwC,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\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 div {\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 div {\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 div {\n background-color: ${COLORS.primary_700};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_800};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n div {\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 div {\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 div {\n background-color: ${COLORS.primary_20};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_100};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n div {\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 <div>{children}</div>\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 <div>{children}</div>\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","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,GAAsB,OAAtB,GAAgC,MAA5C;AAAA,CAvBO,EAmChB,UAAA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APZ;AAQE,QAAA,cAAc,EAAE/B,cAAc,IAAI,KARpC;AASE,QAAA,YAAY,EAAE6B,cAThB;AAUE,QAAA,wBAAwB,EAAErB,wBAV5B;AAWE,QAAA,SAAS,EAAEG,SAXb;AAYE,QAAA,aAAa,EAAER,aAZjB;AAaE,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"}
@@ -12,6 +12,7 @@ interface HeaderItemProps {
12
12
  focusBackgroundColor?: string;
13
13
  invertFocus?: boolean;
14
14
  }
15
+ export declare const IconButtonContent: import("styled-components").StyledComponent<"div", any, {}, never>;
15
16
  export declare const StyledPrimaryIconButton: import("styled-components").StyledComponent<"button", any, HeaderItemProps, never>;
16
17
  export declare const StyledSecondaryIconButton: import("styled-components").StyledComponent<"button", any, HeaderItemProps, never>;
17
18
  export interface IconButtonProps {
@@ -1,7 +1,7 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  import _pt from "prop-types";
3
3
 
4
- var _templateObject, _templateObject2, _templateObject3;
4
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
5
5
 
6
6
  import React from 'react';
7
7
  import styled from 'styled-components';
@@ -29,31 +29,32 @@ var getBorderRadiusStyle = function getBorderRadiusStyle(props) {
29
29
  }
30
30
  };
31
31
 
32
- var StyledIconButton = styled.button(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ", ";\n ", " {\n display: block;\n }\n\n border-radius: ", ";\n div {\n height: 36px;\n width: 36px;\n border-radius: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ", ";\n width: ", ";\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ", "\n }\n"])), function (props) {
32
+ export var IconButtonContent = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
33
+ var StyledIconButton = styled.button(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-width: 0;\n cursor: pointer;\n height: 48px;\n width: 48px;\n background: transparent;\n position: relative;\n\n display: ", ";\n ", " {\n display: block;\n }\n\n border-radius: ", ";\n ", " {\n height: 36px;\n width: 36px;\n border-radius: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n svg {\n height: ", ";\n width: ", ";\n padding: 0;\n }\n }\n &:only-child {\n margin: 0;\n }\n &:disabled {\n cursor: not-allowed;\n }\n\n &:focus {\n ", "\n }\n"])), function (props) {
33
34
  return props.hideOnLowWidth ? 'none' : 'block';
34
35
  }, BREAKPOINTS.MEDIUM, function (props) {
35
36
  return props.borderRadius ? "".concat(props.borderRadius, "px") : '4px';
36
- }, getBorderRadiusStyle, function (props) {
37
+ }, IconButtonContent, getBorderRadiusStyle, function (props) {
37
38
  return props.unsetIconSize ? 'unset' : '24px';
38
39
  }, function (props) {
39
40
  return props.unsetIconSize ? 'unset' : '24px';
40
41
  }, function (props) {
41
42
  return props.invertFocus ? invertedFocusStyles : focusStyles;
42
43
  });
43
- export var StyledPrimaryIconButton = styled(StyledIconButton)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), 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) {\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
45
  return props.useTransparentBackground ? 'transparent' : COLORS.primary_500;
45
46
  }, function (props) {
46
47
  return props.iconColor || COLORS.white;
47
48
  }, function (props) {
48
49
  return props.iconColor || COLORS.white;
49
- }, COLORS.primary_700, COLORS.white, COLORS.primary_800, COLORS.white, COLORS.neutral_200, COLORS.white, COLORS.white);
50
- export var StyledSecondaryIconButton = styled(StyledIconButton)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n div {\n background-color: ", ";\n\n svg {\n fill: ", ";\n path {\n fill: ", ";\n }\n }\n }\n \n &:hover:not(:disabled) {\n div {\n background-color: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n &:active:not(:disabled) {\n div {\n background: ", ";\n }\n div svg path,\n div svg {\n fill: ", ";\n }\n }\n\n &:disabled {\n div {\n background-color: ", ";\n }\n svg {\n path {\n fill: ", ";\n }\n fill: ", ";\n }\n }\n\n"])), function (props) {
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
52
  return props.useTransparentBackground ? 'transparent' : COLORS.white;
52
53
  }, function (props) {
53
54
  return props.iconColor || COLORS.neutral_600;
54
55
  }, function (props) {
55
56
  return props.iconColor || COLORS.neutral_600;
56
- }, COLORS.primary_20, COLORS.primary_700, COLORS.primary_100, COLORS.primary_800, function (props) {
57
+ }, IconButtonContent, COLORS.primary_20, IconButtonContent, IconButtonContent, COLORS.primary_700, IconButtonContent, COLORS.primary_100, IconButtonContent, IconButtonContent, COLORS.primary_800, IconButtonContent, function (props) {
57
58
  return props.useTransparentBackground ? 'transparent' : COLORS.white;
58
59
  }, COLORS.neutral_300, COLORS.neutral_300);
59
60
  var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
@@ -104,7 +105,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
104
105
  style: style,
105
106
  invertFocus: invertFocus,
106
107
  focusBackgroundColor: focusBackgroundColor,
107
- children: /*#__PURE__*/_jsx("div", {
108
+ children: /*#__PURE__*/_jsx(IconButtonContent, {
108
109
  children: children
109
110
  })
110
111
  });
@@ -135,7 +136,7 @@ var IconButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
135
136
  style: style,
136
137
  invertFocus: invertFocus,
137
138
  focusBackgroundColor: focusBackgroundColor,
138
- children: /*#__PURE__*/_jsx("div", {
139
+ children: /*#__PURE__*/_jsx(IconButtonContent, {
139
140
  children: children
140
141
  })
141
142
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Button/Iconbutton.tsx"],"names":["React","styled","BREAKPOINTS","COLORS","focusStyles","invertedFocusStyles","defaultOnMouseDownHandler","getBorderRadius","props","borderRadius","getBorderRadiusStyle","radius","flatEdge","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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,QAAA,WAAW,EAAE/B,yBAff;AAgBE,QAAA,UAAU,EAAEqC,UAhBd;AAiBE,QAAA,MAAM,EAAEG,MAjBV;AAkBE,QAAA,KAAK,EAAEC,KAlBT;AAmBE,QAAA,WAAW,EAAE7B,WAnBf;AAoBE,QAAA,oBAAoB,EAAE0B,oBApBxB;AAAA,+BAqBE;AAAA,oBAAMJ;AAAN;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;AACAjC,EAAAA,Y;AACAkC,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\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 div {\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 div {\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 div {\n background-color: ${COLORS.primary_700};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_800};\n }\n div svg path,\n div svg {\n fill: ${COLORS.white};\n }\n }\n &:disabled {\n div {\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 div {\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 div {\n background-color: ${COLORS.primary_20};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_700};\n }\n }\n &:active:not(:disabled) {\n div {\n background: ${COLORS.primary_100};\n }\n div svg path,\n div svg {\n fill: ${COLORS.primary_800};\n }\n }\n\n &:disabled {\n div {\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 <div>{children}</div>\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 <div>{children}</div>\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","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,yBAA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c,IAAI,KARpC;AASE,QAAA,YAAY,EAAEwB,cAThB;AAUE,QAAA,wBAAwB,EAAEnB,wBAV5B;AAWE,QAAA,SAAS,EAAEE,SAXb;AAYE,QAAA,aAAa,EAAEL,aAZjB;AAaE,QAAA,QAAQ,EAAEyB,QAAQ,IAAI,CAbxB;AAcE,QAAA,YAAY,EAAEnC,YAAY,IAAI8B,KAAK,KAAK,UAA1B,GAAuC,EAAvC,GAA4C,CAd5D;AAeE,QAAA,WAAW,EAAEjC,yBAff;AAgBE,QAAA,UAAU,EAAEuC,UAhBd;AAiBE,QAAA,MAAM,EAAEG,MAjBV;AAkBE,QAAA,KAAK,EAAEC,KAlBT;AAmBE,QAAA,WAAW,EAAE7B,WAnBf;AAoBE,QAAA,oBAAoB,EAAE0B,oBApBxB;AAAA,+BAqBE,KAAC,iBAAD;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"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = exports.ToggleButton = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ var _react = _interopRequireDefault(require("react"));
17
+
18
+ var _Button = require("../Button");
19
+
20
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
21
+
22
+ var _Iconbutton = require("../Button/Iconbutton");
23
+
24
+ var _styles = require("../styles");
25
+
26
+ var _jsxRuntime = require("react/jsx-runtime");
27
+
28
+ var _templateObject;
29
+
30
+ var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", " {\n transition: all 0.1s ease-in-out;\n }\n\n &.disabled,\n &.active:not(.state-change) {\n ", " {\n background: ", ";\n }\n }\n\n &.active:not(.state-change) {\n ", ":after {\n content: '';\n position: absolute;\n left: 12px;\n bottom: 1px;\n background-color: ", ";\n border-radius: 4px;\n height: 4px;\n width: 24px;\n }\n }\n\n &.disabled:not(.state-change) {\n ", ":after {\n background: ", ";\n }\n }\n"])), _Iconbutton.IconButtonContent, _Iconbutton.IconButtonContent, _styles.COLORS.white, _Iconbutton.IconButtonContent, _styles.COLORS.primary_500, _Iconbutton.IconButtonContent, _styles.COLORS.neutral_300);
31
+
32
+ var ToggleButton = function ToggleButton(props) {
33
+ var _props$activeState$co, _props$activeState, _props$activeState$ic, _props$activeState2;
34
+
35
+ var _React$useState = _react.default.useState(false),
36
+ _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
37
+ active = _React$useState2[0],
38
+ setActive = _React$useState2[1];
39
+
40
+ _react.default.useEffect(function () {
41
+ return setActive(props.active);
42
+ }, [props.active]);
43
+
44
+ var cls = "".concat(active ? 'active' : '', " ").concat(props.activeState ? 'state-change' : '', " ").concat(props.disabled ? 'disabled' : '');
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
46
+ className: cls,
47
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
48
+ variant: 'secondary',
49
+ useTransparentBackground: true,
50
+ shape: 'circular',
51
+ action: function action() {
52
+ setActive(!active);
53
+
54
+ if (props.onChange) {
55
+ props.onChange(!active);
56
+ }
57
+ },
58
+ iconColor: active ? (_props$activeState$co = (_props$activeState = props.activeState) === null || _props$activeState === void 0 ? void 0 : _props$activeState.color) !== null && _props$activeState$co !== void 0 ? _props$activeState$co : props.defaultState.color : props.defaultState.color,
59
+ disabled: props.disabled,
60
+ children: active ? (_props$activeState$ic = (_props$activeState2 = props.activeState) === null || _props$activeState2 === void 0 ? void 0 : _props$activeState2.icon) !== null && _props$activeState$ic !== void 0 ? _props$activeState$ic : props.defaultState.icon : props.defaultState.icon
61
+ })
62
+ });
63
+ };
64
+
65
+ exports.ToggleButton = ToggleButton;
66
+ ToggleButton.propTypes = {
67
+ active: _propTypes.default.bool.isRequired,
68
+ onChange: _propTypes.default.func,
69
+ disabled: _propTypes.default.bool,
70
+ defaultState: _propTypes.default.shape({
71
+ icon: _propTypes.default.node.isRequired,
72
+ color: _propTypes.default.string
73
+ }).isRequired,
74
+ activeState: _propTypes.default.shape({
75
+ icon: _propTypes.default.node.isRequired,
76
+ color: _propTypes.default.string
77
+ })
78
+ };
79
+ var _default = ToggleButton;
80
+ exports.default = _default;
81
+ //# sourceMappingURL=ToggleButton.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Toggles/ToggleButton.tsx"],"names":["Wrapper","styled","div","IconButtonContent","COLORS","white","primary_500","neutral_300","ToggleButton","props","React","useState","active","setActive","useEffect","cls","activeState","disabled","onChange","color","defaultState","icon"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;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AA,gBAWGL,MAAM,mDAAGH,KAAK,CAACO,WAAT,wDAAG,oBAAmBK,IAAtB,yEAA8BZ,KAAK,CAACW,YAAN,CAAmBC,IAAjD,GAAwDZ,KAAK,CAACW,YAAN,CAAmBC;AAXpF;AADF,IADF;AAiBD,CAzBM;;;;AARLT,EAAAA,M;AACAM,EAAAA,Q;AACAD,EAAAA,Q;AAEAG,EAAAA,Y;AATAC,IAAAA,I;AACAF,IAAAA,K;;AASAH,EAAAA,W;AAVAK,IAAAA,I;AACAF,IAAAA,K;;;eAuCaX,Y","sourcesContent":["import React from 'react';\nimport {IconButton} from '../Button';\nimport styled from 'styled-components';\nimport {IconButtonContent} from '../Button/Iconbutton';\nimport {COLORS} from '../styles';\n\nconst Wrapper = styled.div`\n ${IconButtonContent} {\n transition: all 0.1s ease-in-out;\n }\n\n &.disabled,\n &.active:not(.state-change) {\n ${IconButtonContent} {\n background: ${COLORS.white};\n }\n }\n\n &.active:not(.state-change) {\n ${IconButtonContent}:after {\n content: '';\n position: absolute;\n left: 12px;\n bottom: 1px;\n background-color: ${COLORS.primary_500};\n border-radius: 4px;\n height: 4px;\n width: 24px;\n }\n }\n\n &.disabled:not(.state-change) {\n ${IconButtonContent}:after {\n background: ${COLORS.neutral_300};\n }\n }\n`;\n\nexport interface ToggleButtonState {\n icon: React.ReactNode;\n color?: string;\n}\n\nexport interface ToggleButtonProps {\n active: boolean;\n onChange?: (value: boolean) => void;\n disabled?: boolean;\n\n defaultState: ToggleButtonState;\n activeState?: ToggleButtonState;\n}\n\nexport const ToggleButton: React.FunctionComponent<ToggleButtonProps> = (props) => {\n\n const [active, setActive] = React.useState(false);\n\n React.useEffect(() => setActive(props.active), [props.active]);\n\n const cls = `${active ? 'active' : ''} ${props.activeState ? 'state-change' : ''} ${props.disabled ? 'disabled' : ''}`;\n\n return (\n <Wrapper className={cls}>\n <IconButton variant={'secondary'}\n useTransparentBackground={true}\n shape={'circular'}\n action={() => {\n setActive(!active);\n if (props.onChange) {\n props.onChange(!active);\n }\n }}\n iconColor={active ? props.activeState?.color ?? props.defaultState.color : props.defaultState.color}\n disabled={props.disabled}>\n {active ? props.activeState?.icon ?? props.defaultState.icon : props.defaultState.icon}\n </IconButton>\n </Wrapper>\n )\n}\n\nexport default ToggleButton;\n"],"file":"ToggleButton.cjs"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface ToggleButtonState {
3
+ icon: React.ReactNode;
4
+ color?: string;
5
+ }
6
+ export interface ToggleButtonProps {
7
+ active: boolean;
8
+ onChange?: (value: boolean) => void;
9
+ disabled?: boolean;
10
+ defaultState: ToggleButtonState;
11
+ activeState?: ToggleButtonState;
12
+ }
13
+ export declare const ToggleButton: React.FunctionComponent<ToggleButtonProps>;
14
+ export default ToggleButton;
@@ -0,0 +1,59 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
3
+ import _pt from "prop-types";
4
+
5
+ var _templateObject;
6
+
7
+ import React from 'react';
8
+ import { IconButton } from '../Button';
9
+ import styled from 'styled-components';
10
+ import { IconButtonContent } from '../Button/Iconbutton';
11
+ import { COLORS } from '../styles';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", " {\n transition: all 0.1s ease-in-out;\n }\n\n &.disabled,\n &.active:not(.state-change) {\n ", " {\n background: ", ";\n }\n }\n\n &.active:not(.state-change) {\n ", ":after {\n content: '';\n position: absolute;\n left: 12px;\n bottom: 1px;\n background-color: ", ";\n border-radius: 4px;\n height: 4px;\n width: 24px;\n }\n }\n\n &.disabled:not(.state-change) {\n ", ":after {\n background: ", ";\n }\n }\n"])), IconButtonContent, IconButtonContent, COLORS.white, IconButtonContent, COLORS.primary_500, IconButtonContent, COLORS.neutral_300);
14
+ export var ToggleButton = function ToggleButton(props) {
15
+ var _props$activeState$co, _props$activeState, _props$activeState$ic, _props$activeState2;
16
+
17
+ var _React$useState = React.useState(false),
18
+ _React$useState2 = _slicedToArray(_React$useState, 2),
19
+ active = _React$useState2[0],
20
+ setActive = _React$useState2[1];
21
+
22
+ React.useEffect(function () {
23
+ return setActive(props.active);
24
+ }, [props.active]);
25
+ var cls = "".concat(active ? 'active' : '', " ").concat(props.activeState ? 'state-change' : '', " ").concat(props.disabled ? 'disabled' : '');
26
+ return /*#__PURE__*/_jsx(Wrapper, {
27
+ className: cls,
28
+ children: /*#__PURE__*/_jsx(IconButton, {
29
+ variant: 'secondary',
30
+ useTransparentBackground: true,
31
+ shape: 'circular',
32
+ action: function action() {
33
+ setActive(!active);
34
+
35
+ if (props.onChange) {
36
+ props.onChange(!active);
37
+ }
38
+ },
39
+ iconColor: active ? (_props$activeState$co = (_props$activeState = props.activeState) === null || _props$activeState === void 0 ? void 0 : _props$activeState.color) !== null && _props$activeState$co !== void 0 ? _props$activeState$co : props.defaultState.color : props.defaultState.color,
40
+ disabled: props.disabled,
41
+ children: active ? (_props$activeState$ic = (_props$activeState2 = props.activeState) === null || _props$activeState2 === void 0 ? void 0 : _props$activeState2.icon) !== null && _props$activeState$ic !== void 0 ? _props$activeState$ic : props.defaultState.icon : props.defaultState.icon
42
+ })
43
+ });
44
+ };
45
+ ToggleButton.propTypes = {
46
+ active: _pt.bool.isRequired,
47
+ onChange: _pt.func,
48
+ disabled: _pt.bool,
49
+ defaultState: _pt.shape({
50
+ icon: _pt.node.isRequired,
51
+ color: _pt.string
52
+ }).isRequired,
53
+ activeState: _pt.shape({
54
+ icon: _pt.node.isRequired,
55
+ color: _pt.string
56
+ })
57
+ };
58
+ export default ToggleButton;
59
+ //# sourceMappingURL=ToggleButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Toggles/ToggleButton.tsx"],"names":["React","IconButton","styled","IconButtonContent","COLORS","Wrapper","div","white","primary_500","neutral_300","ToggleButton","props","useState","active","setActive","useEffect","cls","activeState","disabled","onChange","color","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AAA,SAAS,EAAEA,MAAM,kDAAGF,KAAK,CAACM,WAAT,uDAAG,mBAAmBG,KAAtB,yEAA+BT,KAAK,CAACU,YAAN,CAAmBD,KAAlD,GAA0DT,KAAK,CAACU,YAAN,CAAmBD,KAT1G;AAUY,MAAA,QAAQ,EAAET,KAAK,CAACO,QAV5B;AAAA,gBAWGL,MAAM,mDAAGF,KAAK,CAACM,WAAT,wDAAG,oBAAmBK,IAAtB,yEAA8BX,KAAK,CAACU,YAAN,CAAmBC,IAAjD,GAAwDX,KAAK,CAACU,YAAN,CAAmBC;AAXpF;AADF,IADF;AAiBD,CAzBM;;AARLT,EAAAA,M;AACAM,EAAAA,Q;AACAD,EAAAA,Q;AAEAG,EAAAA,Y;AATAC,IAAAA,I;AACAF,IAAAA,K;;AASAH,EAAAA,W;AAVAK,IAAAA,I;AACAF,IAAAA,K;;;AAuCF,eAAeV,YAAf","sourcesContent":["import React from 'react';\nimport {IconButton} from '../Button';\nimport styled from 'styled-components';\nimport {IconButtonContent} from '../Button/Iconbutton';\nimport {COLORS} from '../styles';\n\nconst Wrapper = styled.div`\n ${IconButtonContent} {\n transition: all 0.1s ease-in-out;\n }\n\n &.disabled,\n &.active:not(.state-change) {\n ${IconButtonContent} {\n background: ${COLORS.white};\n }\n }\n\n &.active:not(.state-change) {\n ${IconButtonContent}:after {\n content: '';\n position: absolute;\n left: 12px;\n bottom: 1px;\n background-color: ${COLORS.primary_500};\n border-radius: 4px;\n height: 4px;\n width: 24px;\n }\n }\n\n &.disabled:not(.state-change) {\n ${IconButtonContent}:after {\n background: ${COLORS.neutral_300};\n }\n }\n`;\n\nexport interface ToggleButtonState {\n icon: React.ReactNode;\n color?: string;\n}\n\nexport interface ToggleButtonProps {\n active: boolean;\n onChange?: (value: boolean) => void;\n disabled?: boolean;\n\n defaultState: ToggleButtonState;\n activeState?: ToggleButtonState;\n}\n\nexport const ToggleButton: React.FunctionComponent<ToggleButtonProps> = (props) => {\n\n const [active, setActive] = React.useState(false);\n\n React.useEffect(() => setActive(props.active), [props.active]);\n\n const cls = `${active ? 'active' : ''} ${props.activeState ? 'state-change' : ''} ${props.disabled ? 'disabled' : ''}`;\n\n return (\n <Wrapper className={cls}>\n <IconButton variant={'secondary'}\n useTransparentBackground={true}\n shape={'circular'}\n action={() => {\n setActive(!active);\n if (props.onChange) {\n props.onChange(!active);\n }\n }}\n iconColor={active ? props.activeState?.color ?? props.defaultState.color : props.defaultState.color}\n disabled={props.disabled}>\n {active ? props.activeState?.icon ?? props.defaultState.icon : props.defaultState.icon}\n </IconButton>\n </Wrapper>\n )\n}\n\nexport default ToggleButton;\n"],"file":"ToggleButton.js"}
@@ -5,6 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ Object.defineProperty(exports, "ToggleButton", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _ToggleButton.default;
12
+ }
13
+ });
8
14
  Object.defineProperty(exports, "ToggleSwitch", {
9
15
  enumerable: true,
10
16
  get: function get() {
@@ -13,4 +19,6 @@ Object.defineProperty(exports, "ToggleSwitch", {
13
19
  });
14
20
 
15
21
  var _ToggleSwitch = _interopRequireDefault(require("./ToggleSwitch"));
22
+
23
+ var _ToggleButton = _interopRequireDefault(require("./ToggleButton"));
16
24
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Toggles/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["import ToggleSwitch from './ToggleSwitch';\n\nexport { ToggleSwitch };\n"],"file":"index.cjs"}
1
+ {"version":3,"sources":["../../src/Toggles/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["import ToggleSwitch from './ToggleSwitch';\nimport ToggleButton from './ToggleButton';\n\nexport {ToggleSwitch, ToggleButton};\n"],"file":"index.cjs"}
@@ -1,2 +1,3 @@
1
1
  import ToggleSwitch from './ToggleSwitch';
2
- export { ToggleSwitch };
2
+ import ToggleButton from './ToggleButton';
3
+ export { ToggleSwitch, ToggleButton };
@@ -1,3 +1,4 @@
1
1
  import ToggleSwitch from './ToggleSwitch';
2
- export { ToggleSwitch };
2
+ import ToggleButton from './ToggleButton';
3
+ export { ToggleSwitch, ToggleButton };
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Toggles/index.ts"],"names":["ToggleSwitch"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,gBAAzB;AAEA,SAASA,YAAT","sourcesContent":["import ToggleSwitch from './ToggleSwitch';\n\nexport { ToggleSwitch };\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/Toggles/index.ts"],"names":["ToggleSwitch","ToggleButton"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,gBAAzB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,SAAQD,YAAR,EAAsBC,YAAtB","sourcesContent":["import ToggleSwitch from './ToggleSwitch';\nimport ToggleButton from './ToggleButton';\n\nexport {ToggleSwitch, ToggleButton};\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laerdal/life-react-components",
3
- "version": "1.7.0-dev.13.full",
3
+ "version": "1.7.0-dev.16",
4
4
  "private": false,
5
5
  "author": "Thomas Kalve <thomas.kalve@laerdal.com>",
6
6
  "contributors": [