@laerdal/life-react-components 1.5.1-dev.21 → 1.5.1-dev.22.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.
@@ -33,7 +33,7 @@ var SegmentControlItemBackground = _styledComponents.default.div(_templateObject
33
33
 
34
34
  exports.SegmentControlItemBackground = SegmentControlItemBackground;
35
35
 
36
- var SegmentControlItemWrapper = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ", ";\n outline: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &:active {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: none;\n }\n }\n\n &.disabled {\n pointer-events: none;\n cursor: not-allowed;\n\n ", " {\n background-color: transparent;\n color: ", ";\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &.selected.disabled {\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n"])), _styles.Z_INDEXES.focus, SegmentControlItemContent, _styles.COLORS.primary_100, _styles.COLORS.primary_700, _styles.Z_INDEXES.hover, SegmentControlItemContent, _styles.COLORS.primary_100, _styles.COLORS.primary_700, _styles.Z_INDEXES.active, SegmentControlItemContent, _styles.COLORS.primary_200, _styles.COLORS.primary_800, SegmentControlItemContent, _styles.COLORS.neutral_300, SegmentControlItemContent, _styles.COLORS.primary_500, _styles.COLORS.white, SegmentControlItemContent, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300);
36
+ var SegmentControlItemWrapper = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ", ";\n outline: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &:active {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: none;\n }\n }\n\n &.disabled {\n cursor: not-allowed;\n\n ", " {\n background-color: transparent;\n color: ", ";\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &.selected.disabled {\n cursor: not-allowed;\n pointer-events: unset;\n \n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n"])), _styles.Z_INDEXES.focus, SegmentControlItemContent, _styles.COLORS.primary_100, _styles.COLORS.primary_700, _styles.Z_INDEXES.hover, SegmentControlItemContent, _styles.COLORS.primary_100, _styles.COLORS.primary_700, _styles.Z_INDEXES.active, SegmentControlItemContent, _styles.COLORS.primary_200, _styles.COLORS.primary_800, SegmentControlItemContent, _styles.COLORS.neutral_300, SegmentControlItemContent, _styles.COLORS.primary_500, _styles.COLORS.white, SegmentControlItemContent, _styles.COLORS.neutral_100, _styles.COLORS.neutral_300);
37
37
 
38
38
  exports.SegmentControlItemWrapper = SegmentControlItemWrapper;
39
39
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/SegmentControl/SegmentControl.tsx"],"names":["SegmentControlItemContent","styled","div","COLORS","neutral_600","SegmentControlItemBackground","neutral_20","SegmentControlItemWrapper","Z_INDEXES","focus","primary_100","primary_700","hover","active","primary_200","primary_800","neutral_300","primary_500","white","neutral_100","SegmentControlWrapper","ComponentTextStyle","Bold","SegmentControl","items","size","Size","Medium","onChange","selected","onKeyPress","e","item","key","document","activeElement","blur","disabled","onClick","map","a","i","undefined","defaultOnMouseDownHandler","content"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAGO,IAAMA,yBAAyB,GAAGC,0BAAOC,GAAV,2QAS3BC,eAAOC,WAToB,CAA/B;;;;AAYA,IAAMC,4BAA4B,GAAGJ,0BAAOC,GAAV,sNAKnBC,eAAOG,UALY,CAAlC;;;;AASA,IAAMC,yBAAyB,GAAGN,0BAAOC,GAAV,ykCAUvBM,kBAAUC,KAVa,EAahCT,yBAbgC,EAcZG,eAAOO,WAdK,EAevBP,eAAOQ,WAfgB,EAqBvBH,kBAAUI,KArBa,EAuBhCZ,yBAvBgC,EAwBZG,eAAOO,WAxBK,EAyBvBP,eAAOQ,WAzBgB,EA8BvBH,kBAAUK,MA9Ba,EAgChCb,yBAhCgC,EAiCZG,eAAOW,WAjCK,EAkCvBX,eAAOY,WAlCgB,EA2ChCf,yBA3CgC,EA6CvBG,eAAOa,WA7CgB,EAqDhChB,yBArDgC,EAsDZG,eAAOc,WAtDK,EAuDvBd,eAAOe,KAvDgB,EA4DhClB,yBA5DgC,EA6DZG,eAAOgB,WA7DK,EA8DvBhB,eAAOa,WA9DgB,CAA/B;;;;AAmEA,IAAMI,qBAAqB,GAAGnB,0BAAOC,GAAV,ynBAM9BK,yBAN8B,EAO5BF,4BAP4B,EAc9BE,yBAd8B,EAe5BF,4BAf4B,EAwB5BL,yBAxB4B,EAyB1B,+BAAkBqB,2BAAmBC,IAArC,EAA2C,IAA3C,CAzB0B,EA+B5BtB,yBA/B4B,EAgC1B,+BAAkBqB,2BAAmBC,IAArC,EAA2C,IAA3C,CAhC0B,CAA3B;;;;AAoDP,IAAMC,cAA4D,GAAG,SAA/DA,cAA+D,OAKO;AAAA,MAJJC,KAII,QAJJA,KAII;AAAA,uBAHJC,IAGI;AAAA,MAHJA,IAGI,0BAHGC,YAAKC,MAGR;AAAA,MAFJC,QAEI,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AAD,EAAIS,CAAJ,CAAjB;AAAA,SALhE;AAAA,+BAME,qBAAC,4BAAD;AAAA,iCACE,qBAAC,yBAAD;AAAA,sBACGA,CAAC,CAACI;AADL;AADF;AANF,SAAgCJ,CAAC,CAACP,GAAF,IAASQ,CAAzC,CADS;AAAA,KAAV;AADH,IADF;AAkBD,CApCD;;;AANEjB,EAAAA,K;AANAS,IAAAA,G;AACAI,IAAAA,Q;AACAO,IAAAA,O;;AAKAf,EAAAA,Q;AACAD,EAAAA,Q;;eA0CaL,c","sourcesContent":["import React from 'react';\nimport {Size} from '../types';\nimport styled from 'styled-components';\nimport {COLORS, ComponentMStyling, ComponentSStyling, ComponentTextStyle, Z_INDEXES} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\n\nexport const SegmentControlItemContent = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n border-radius: 8px;\n padding: 0 16px;\n\n background-color: transparent;\n color: ${COLORS.neutral_600};\n`\n\nexport const SegmentControlItemBackground = styled.div`\n flex: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: ${COLORS.neutral_20};\n padding: 4px 0px;\n`;\n\nexport const SegmentControlItemWrapper = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ${Z_INDEXES.focus};\n outline: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ${Z_INDEXES.hover};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n }\n }\n\n &:active {\n z-index: ${Z_INDEXES.active};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_200};\n color: ${COLORS.primary_800};\n box-shadow: none;\n }\n }\n\n &.disabled {\n pointer-events: none;\n cursor: not-allowed;\n\n ${SegmentControlItemContent} {\n background-color: transparent;\n color: ${COLORS.neutral_300};\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_500};\n color: ${COLORS.white};\n }\n }\n\n &.selected.disabled {\n ${SegmentControlItemContent} {\n background-color: ${COLORS.neutral_100};\n color: ${COLORS.neutral_300};\n }\n }\n`;\n\nexport const SegmentControlWrapper = styled.div`\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ${SegmentControlItemWrapper}:first-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-left-radius: 12px;\n border-top-left-radius: 12px;\n padding-left: 4px;\n }\n }\n\n ${SegmentControlItemWrapper}:last-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-right-radius: 12px;\n border-top-right-radius: 12px;\n padding-right: 4px;\n }\n }\n\n\n &.small {\n ${SegmentControlItemContent} {\n ${ComponentSStyling(ComponentTextStyle.Bold, null)}\n min-height: 32px;\n }\n }\n\n &.medium {\n ${SegmentControlItemContent} {\n ${ComponentMStyling(ComponentTextStyle.Bold, null)}\n min-height: 40px;\n }\n }\n`;\n\n\nexport interface SegmentControlItem {\n key: string\n disabled?: boolean;\n content: React.ReactNode | string;\n}\n\ninterface SegmentControlProps {\n items: SegmentControlItem[];\n selected: string;\n onChange: (value: string) => void;\n size?: Size.Small | Size.Medium;\n}\n\nconst SegmentControl: React.FunctionComponent<SegmentControlProps> = ({\n items,\n size = Size.Medium,\n onChange,\n selected\n }) => {\n const onKeyPress = (e: React.KeyboardEvent<HTMLDivElement>, item: SegmentControlItem) => {\n if (e.key === 'Enter' || e.key === ' ') {\n //@ts-ignore\n document?.activeElement?.blur();\n !item.disabled && onChange(item.key);\n }\n };\n\n const onClick = (e: React.MouseEvent, item: SegmentControlItem) => {\n !item.disabled && onChange(item.key);\n }\n\n return (\n <SegmentControlWrapper className={size}>\n {items.map((a, i) =>\n <SegmentControlItemWrapper key={a.key || i}\n className={(a.disabled ? 'disabled' : '') + (a.key === selected ? ' selected' : '')}\n tabIndex={a.disabled || a.key === selected ? -1 : 0}\n onClick={a.disabled ? undefined : (e) => onClick(e, a)}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={a.disabled ? undefined : (e) => onKeyPress(e, a)}>\n <SegmentControlItemBackground>\n <SegmentControlItemContent>\n {a.content}\n </SegmentControlItemContent>\n </SegmentControlItemBackground>\n </SegmentControlItemWrapper>)\n }\n </SegmentControlWrapper>\n );\n};\n\nexport default SegmentControl;\n"],"file":"SegmentControl.cjs"}
1
+ {"version":3,"sources":["../../src/SegmentControl/SegmentControl.tsx"],"names":["SegmentControlItemContent","styled","div","COLORS","neutral_600","SegmentControlItemBackground","neutral_20","SegmentControlItemWrapper","Z_INDEXES","focus","primary_100","primary_700","hover","active","primary_200","primary_800","neutral_300","primary_500","white","neutral_100","SegmentControlWrapper","ComponentTextStyle","Bold","SegmentControl","items","size","Size","Medium","onChange","selected","onKeyPress","e","item","key","document","activeElement","blur","disabled","onClick","map","a","i","undefined","defaultOnMouseDownHandler","content"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAGO,IAAMA,yBAAyB,GAAGC,0BAAOC,GAAV,2QAS3BC,eAAOC,WAToB,CAA/B;;;;AAYA,IAAMC,4BAA4B,GAAGJ,0BAAOC,GAAV,sNAKnBC,eAAOG,UALY,CAAlC;;;;AASA,IAAMC,yBAAyB,GAAGN,0BAAOC,GAAV,0mCAUvBM,kBAAUC,KAVa,EAahCT,yBAbgC,EAcZG,eAAOO,WAdK,EAevBP,eAAOQ,WAfgB,EAqBvBH,kBAAUI,KArBa,EAuBhCZ,yBAvBgC,EAwBZG,eAAOO,WAxBK,EAyBvBP,eAAOQ,WAzBgB,EA8BvBH,kBAAUK,MA9Ba,EAgChCb,yBAhCgC,EAiCZG,eAAOW,WAjCK,EAkCvBX,eAAOY,WAlCgB,EA0ChCf,yBA1CgC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N,CAAU,UAACC,CAAD,EAAIC,CAAJ;AAAA,0BACT,qBAAC,yBAAD;AAC2B,QAAA,SAAS,EAAE,CAACD,CAAC,CAACH,QAAF,GAAa,UAAb,GAA0B,EAA3B,KAAkCG,CAAC,CAACP,GAAF,KAAUJ,QAAV,GAAqB,WAArB,GAAmC,EAArE,CADtC;AAE2B,QAAA,QAAQ,EAAEW,CAAC,CAACH,QAAF,IAAcG,CAAC,CAACP,GAAF,KAAUJ,QAAxB,GAAmC,CAAC,CAApC,GAAwC,CAF7E;AAG2B,QAAA,OAAO,EAAEW,CAAC,CAACH,QAAF,GAAaK,SAAb,GAAyB,UAACX,CAAD;AAAA,iBAAOO,OAAO,CAACP,CAAD,EAAIS,CAAJ,CAAd;AAAA,SAH7D;AAI2B,QAAA,WAAW,EAAEG,iCAJxC;AAK2B,QAAA,UAAU,EAAEH,CAAC,CAACH,QAAF,GAAaK,SAAb,GAAyB,UAACX,CAAD;AAAA,iBAAOD,UAAU,CAACC,CAAD,EAAIS,CAAJ,CAAjB;AAAA,SALhE;AAAA,+BAME,qBAAC,4BAAD;AAAA,iCACE,qBAAC,yBAAD;AAAA,sBACGA,CAAC,CAACI;AADL;AADF;AANF,SAAgCJ,CAAC,CAACP,GAAF,IAASQ,CAAzC,CADS;AAAA,KAAV;AADH,IADF;AAkBD,CApCD;;;AANEjB,EAAAA,K;AANAS,IAAAA,G;AACAI,IAAAA,Q;AACAO,IAAAA,O;;AAKAf,EAAAA,Q;AACAD,EAAAA,Q;;eA0CaL,c","sourcesContent":["import React from 'react';\nimport {Size} from '../types';\nimport styled from 'styled-components';\nimport {COLORS, ComponentMStyling, ComponentSStyling, ComponentTextStyle, Z_INDEXES} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\n\nexport const SegmentControlItemContent = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n border-radius: 8px;\n padding: 0 16px;\n\n background-color: transparent;\n color: ${COLORS.neutral_600};\n`\n\nexport const SegmentControlItemBackground = styled.div`\n flex: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: ${COLORS.neutral_20};\n padding: 4px 0px;\n`;\n\nexport const SegmentControlItemWrapper = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ${Z_INDEXES.focus};\n outline: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ${Z_INDEXES.hover};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n }\n }\n\n &:active {\n z-index: ${Z_INDEXES.active};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_200};\n color: ${COLORS.primary_800};\n box-shadow: none;\n }\n }\n\n &.disabled {\n cursor: not-allowed;\n\n ${SegmentControlItemContent} {\n background-color: transparent;\n color: ${COLORS.neutral_300};\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_500};\n color: ${COLORS.white};\n }\n }\n\n &.selected.disabled {\n cursor: not-allowed;\n pointer-events: unset;\n \n ${SegmentControlItemContent} {\n background-color: ${COLORS.neutral_100};\n color: ${COLORS.neutral_300};\n }\n }\n`;\n\nexport const SegmentControlWrapper = styled.div`\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ${SegmentControlItemWrapper}:first-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-left-radius: 12px;\n border-top-left-radius: 12px;\n padding-left: 4px;\n }\n }\n\n ${SegmentControlItemWrapper}:last-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-right-radius: 12px;\n border-top-right-radius: 12px;\n padding-right: 4px;\n }\n }\n\n\n &.small {\n ${SegmentControlItemContent} {\n ${ComponentSStyling(ComponentTextStyle.Bold, null)}\n min-height: 32px;\n }\n }\n\n &.medium {\n ${SegmentControlItemContent} {\n ${ComponentMStyling(ComponentTextStyle.Bold, null)}\n min-height: 40px;\n }\n }\n`;\n\n\nexport interface SegmentControlItem {\n key: string\n disabled?: boolean;\n content: React.ReactNode | string;\n}\n\ninterface SegmentControlProps {\n items: SegmentControlItem[];\n selected: string;\n onChange: (value: string) => void;\n size?: Size.Small | Size.Medium;\n}\n\nconst SegmentControl: React.FunctionComponent<SegmentControlProps> = ({\n items,\n size = Size.Medium,\n onChange,\n selected\n }) => {\n const onKeyPress = (e: React.KeyboardEvent<HTMLDivElement>, item: SegmentControlItem) => {\n if (e.key === 'Enter' || e.key === ' ') {\n //@ts-ignore\n document?.activeElement?.blur();\n !item.disabled && onChange(item.key);\n }\n };\n\n const onClick = (e: React.MouseEvent, item: SegmentControlItem) => {\n !item.disabled && onChange(item.key);\n }\n\n return (\n <SegmentControlWrapper className={size}>\n {items.map((a, i) =>\n <SegmentControlItemWrapper key={a.key || i}\n className={(a.disabled ? 'disabled' : '') + (a.key === selected ? ' selected' : '')}\n tabIndex={a.disabled || a.key === selected ? -1 : 0}\n onClick={a.disabled ? undefined : (e) => onClick(e, a)}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={a.disabled ? undefined : (e) => onKeyPress(e, a)}>\n <SegmentControlItemBackground>\n <SegmentControlItemContent>\n {a.content}\n </SegmentControlItemContent>\n </SegmentControlItemBackground>\n </SegmentControlItemWrapper>)\n }\n </SegmentControlWrapper>\n );\n};\n\nexport default SegmentControl;\n"],"file":"SegmentControl.cjs"}
@@ -11,7 +11,7 @@ import { defaultOnMouseDownHandler } from '../common';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  export var SegmentControlItemContent = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n border-radius: 8px;\n padding: 0 16px;\n\n background-color: transparent;\n color: ", ";\n"])), COLORS.neutral_600);
13
13
  export var SegmentControlItemBackground = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: ", ";\n padding: 4px 0px;\n"])), COLORS.neutral_20);
14
- export var SegmentControlItemWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ", ";\n outline: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &:active {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: none;\n }\n }\n\n &.disabled {\n pointer-events: none;\n cursor: not-allowed;\n\n ", " {\n background-color: transparent;\n color: ", ";\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &.selected.disabled {\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n"])), Z_INDEXES.focus, SegmentControlItemContent, COLORS.primary_100, COLORS.primary_700, Z_INDEXES.hover, SegmentControlItemContent, COLORS.primary_100, COLORS.primary_700, Z_INDEXES.active, SegmentControlItemContent, COLORS.primary_200, COLORS.primary_800, SegmentControlItemContent, COLORS.neutral_300, SegmentControlItemContent, COLORS.primary_500, COLORS.white, SegmentControlItemContent, COLORS.neutral_100, COLORS.neutral_300);
14
+ export var SegmentControlItemWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ", ";\n outline: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &:active {\n z-index: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n box-shadow: none;\n }\n }\n\n &.disabled {\n cursor: not-allowed;\n\n ", " {\n background-color: transparent;\n color: ", ";\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n\n &.selected.disabled {\n cursor: not-allowed;\n pointer-events: unset;\n \n ", " {\n background-color: ", ";\n color: ", ";\n }\n }\n"])), Z_INDEXES.focus, SegmentControlItemContent, COLORS.primary_100, COLORS.primary_700, Z_INDEXES.hover, SegmentControlItemContent, COLORS.primary_100, COLORS.primary_700, Z_INDEXES.active, SegmentControlItemContent, COLORS.primary_200, COLORS.primary_800, SegmentControlItemContent, COLORS.neutral_300, SegmentControlItemContent, COLORS.primary_500, COLORS.white, SegmentControlItemContent, COLORS.neutral_100, COLORS.neutral_300);
15
15
  export var SegmentControlWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ", ":first-of-type {\n ", " {\n border-bottom-left-radius: 12px;\n border-top-left-radius: 12px;\n padding-left: 4px;\n }\n }\n\n ", ":last-of-type {\n ", " {\n border-bottom-right-radius: 12px;\n border-top-right-radius: 12px;\n padding-right: 4px;\n }\n }\n\n\n &.small {\n ", " {\n ", "\n min-height: 32px;\n }\n }\n\n &.medium {\n ", " {\n ", "\n min-height: 40px;\n }\n }\n"])), SegmentControlItemWrapper, SegmentControlItemBackground, SegmentControlItemWrapper, SegmentControlItemBackground, SegmentControlItemContent, ComponentSStyling(ComponentTextStyle.Bold, null), SegmentControlItemContent, ComponentMStyling(ComponentTextStyle.Bold, null));
16
16
 
17
17
  var SegmentControl = function SegmentControl(_ref) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/SegmentControl/SegmentControl.tsx"],"names":["React","Size","styled","COLORS","ComponentMStyling","ComponentSStyling","ComponentTextStyle","Z_INDEXES","defaultOnMouseDownHandler","SegmentControlItemContent","div","neutral_600","SegmentControlItemBackground","neutral_20","SegmentControlItemWrapper","focus","primary_100","primary_700","hover","active","primary_200","primary_800","neutral_300","primary_500","white","neutral_100","SegmentControlWrapper","Bold","SegmentControl","items","size","Medium","onChange","selected","onKeyPress","e","item","key","document","activeElement","blur","disabled","onClick","map","a","i","undefined","content"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAQC,IAAR,QAAmB,UAAnB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,SAAQC,MAAR,EAAgBC,iBAAhB,EAAmCC,iBAAnC,EAAsDC,kBAAtD,EAA0EC,SAA1E,QAA0F,WAA1F;AACA,SAAQC,yBAAR,QAAwC,WAAxC;;AAGA,OAAO,IAAMC,yBAAyB,GAAGP,MAAM,CAACQ,GAAV,6PAS3BP,MAAM,CAACQ,WAToB,CAA/B;AAYP,OAAO,IAAMC,4BAA4B,GAAGV,MAAM,CAACQ,GAAV,wMAKnBP,MAAM,CAACU,UALY,CAAlC;AASP,OAAO,IAAMC,yBAAyB,GAAGZ,MAAM,CAACQ,GAAV,2jCAUvBH,SAAS,CAACQ,KAVa,EAahCN,yBAbgC,EAcZN,MAAM,CAACa,WAdK,EAevBb,MAAM,CAACc,WAfgB,EAqBvBV,SAAS,CAACW,KArBa,EAuBhCT,yBAvBgC,EAwBZN,MAAM,CAACa,WAxBK,EAyBvBb,MAAM,CAACc,WAzBgB,EA8BvBV,SAAS,CAACY,MA9Ba,EAgChCV,yBAhCgC,EAiCZN,MAAM,CAACiB,WAjCK,EAkCvBjB,MAAM,CAACkB,WAlCgB,EA2ChCZ,yBA3CgC,EA6CvBN,MAAM,CAACmB,WA7CgB,EAqDhCb,yBArDgC,EAsDZ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AACc,GAAN,CAAU,UAACC,CAAD,EAAIC,CAAJ;AAAA,0BACT,KAAC,yBAAD;AAC2B,QAAA,SAAS,EAAE,CAACD,CAAC,CAACH,QAAF,GAAa,UAAb,GAA0B,EAA3B,KAAkCG,CAAC,CAACP,GAAF,KAAUJ,QAAV,GAAqB,WAArB,GAAmC,EAArE,CADtC;AAE2B,QAAA,QAAQ,EAAEW,CAAC,CAACH,QAAF,IAAcG,CAAC,CAACP,GAAF,KAAUJ,QAAxB,GAAmC,CAAC,CAApC,GAAwC,CAF7E;AAG2B,QAAA,OAAO,EAAEW,CAAC,CAACH,QAAF,GAAaK,SAAb,GAAyB,UAACX,CAAD;AAAA,iBAAOO,OAAO,CAACP,CAAD,EAAIS,CAAJ,CAAd;AAAA,SAH7D;AAI2B,QAAA,WAAW,EAAEpC,yBAJxC;AAK2B,QAAA,UAAU,EAAEoC,CAAC,CAACH,QAAF,GAAaK,SAAb,GAAyB,UAACX,CAAD;AAAA,iBAAOD,UAAU,CAACC,CAAD,EAAIS,CAAJ,CAAjB;AAAA,SALhE;AAAA,+BAME,KAAC,4BAAD;AAAA,iCACE,KAAC,yBAAD;AAAA,sBACGA,CAAC,CAACG;AADL;AADF;AANF,SAAgCH,CAAC,CAACP,GAAF,IAASQ,CAAzC,CADS;AAAA,KAAV;AADH,IADF;AAkBD,CApCD;;;AANEhB,EAAAA,K;AANAQ,IAAAA,G;AACAI,IAAAA,Q;AACAM,IAAAA,O;;AAKAd,EAAAA,Q;AACAD,EAAAA,Q;;AA0CF,eAAeJ,cAAf","sourcesContent":["import React from 'react';\nimport {Size} from '../types';\nimport styled from 'styled-components';\nimport {COLORS, ComponentMStyling, ComponentSStyling, ComponentTextStyle, Z_INDEXES} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\n\nexport const SegmentControlItemContent = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n border-radius: 8px;\n padding: 0 16px;\n\n background-color: transparent;\n color: ${COLORS.neutral_600};\n`\n\nexport const SegmentControlItemBackground = styled.div`\n flex: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: ${COLORS.neutral_20};\n padding: 4px 0px;\n`;\n\nexport const SegmentControlItemWrapper = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ${Z_INDEXES.focus};\n outline: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ${Z_INDEXES.hover};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n }\n }\n\n &:active {\n z-index: ${Z_INDEXES.active};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_200};\n color: ${COLORS.primary_800};\n box-shadow: none;\n }\n }\n\n &.disabled {\n pointer-events: none;\n cursor: not-allowed;\n\n ${SegmentControlItemContent} {\n background-color: transparent;\n color: ${COLORS.neutral_300};\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_500};\n color: ${COLORS.white};\n }\n }\n\n &.selected.disabled {\n ${SegmentControlItemContent} {\n background-color: ${COLORS.neutral_100};\n color: ${COLORS.neutral_300};\n }\n }\n`;\n\nexport const SegmentControlWrapper = styled.div`\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ${SegmentControlItemWrapper}:first-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-left-radius: 12px;\n border-top-left-radius: 12px;\n padding-left: 4px;\n }\n }\n\n ${SegmentControlItemWrapper}:last-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-right-radius: 12px;\n border-top-right-radius: 12px;\n padding-right: 4px;\n }\n }\n\n\n &.small {\n ${SegmentControlItemContent} {\n ${ComponentSStyling(ComponentTextStyle.Bold, null)}\n min-height: 32px;\n }\n }\n\n &.medium {\n ${SegmentControlItemContent} {\n ${ComponentMStyling(ComponentTextStyle.Bold, null)}\n min-height: 40px;\n }\n }\n`;\n\n\nexport interface SegmentControlItem {\n key: string\n disabled?: boolean;\n content: React.ReactNode | string;\n}\n\ninterface SegmentControlProps {\n items: SegmentControlItem[];\n selected: string;\n onChange: (value: string) => void;\n size?: Size.Small | Size.Medium;\n}\n\nconst SegmentControl: React.FunctionComponent<SegmentControlProps> = ({\n items,\n size = Size.Medium,\n onChange,\n selected\n }) => {\n const onKeyPress = (e: React.KeyboardEvent<HTMLDivElement>, item: SegmentControlItem) => {\n if (e.key === 'Enter' || e.key === ' ') {\n //@ts-ignore\n document?.activeElement?.blur();\n !item.disabled && onChange(item.key);\n }\n };\n\n const onClick = (e: React.MouseEvent, item: SegmentControlItem) => {\n !item.disabled && onChange(item.key);\n }\n\n return (\n <SegmentControlWrapper className={size}>\n {items.map((a, i) =>\n <SegmentControlItemWrapper key={a.key || i}\n className={(a.disabled ? 'disabled' : '') + (a.key === selected ? ' selected' : '')}\n tabIndex={a.disabled || a.key === selected ? -1 : 0}\n onClick={a.disabled ? undefined : (e) => onClick(e, a)}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={a.disabled ? undefined : (e) => onKeyPress(e, a)}>\n <SegmentControlItemBackground>\n <SegmentControlItemContent>\n {a.content}\n </SegmentControlItemContent>\n </SegmentControlItemBackground>\n </SegmentControlItemWrapper>)\n }\n </SegmentControlWrapper>\n );\n};\n\nexport default SegmentControl;\n"],"file":"SegmentControl.js"}
1
+ {"version":3,"sources":["../../src/SegmentControl/SegmentControl.tsx"],"names":["React","Size","styled","COLORS","ComponentMStyling","ComponentSStyling","ComponentTextStyle","Z_INDEXES","defaultOnMouseDownHandler","SegmentControlItemContent","div","neutral_600","SegmentControlItemBackground","neutral_20","SegmentControlItemWrapper","focus","primary_100","primary_700","hover","active","primary_200","primary_800","neutral_300","primary_500","white","neutral_100","SegmentControlWrapper","Bold","SegmentControl","items","size","Medium","onChange","selected","onKeyPress","e","item","key","document","activeElement","blur","disabled","onClick","map","a","i","undefined","content"],"mappings":";;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAQC,IAAR,QAAmB,UAAnB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,SAAQC,MAAR,EAAgBC,iBAAhB,EAAmCC,iBAAnC,EAAsDC,kBAAtD,EAA0EC,SAA1E,QAA0F,WAA1F;AACA,SAAQC,yBAAR,QAAwC,WAAxC;;AAGA,OAAO,IAAMC,yBAAyB,GAAGP,MAAM,CAACQ,GAAV,6PAS3BP,MAAM,CAACQ,WAToB,CAA/B;AAYP,OAAO,IAAMC,4BAA4B,GAAGV,MAAM,CAACQ,GAAV,wMAKnBP,MAAM,CAACU,UALY,CAAlC;AASP,OAAO,IAAMC,yBAAyB,GAAGZ,MAAM,CAACQ,GAAV,4lCAUvBH,SAAS,CAACQ,KAVa,EAahCN,yBAbgC,EAcZN,MAAM,CAACa,WAdK,EAevBb,MAAM,CAACc,WAfgB,EAqBvBV,SAAS,CAACW,KArBa,EAuBhCT,yBAvBgC,EAwBZN,MAAM,CAACa,WAxBK,EAyBvBb,MAAM,CAACc,WAzBgB,EA8BvBV,SAAS,CAACY,MA9Ba,EAgChCV,yBAhCgC,EAiCZN,MAAM,CAACiB,WAjCK,EAkCvBjB,MAAM,CAACkB,WAlCgB,EA0ChCZ,yBA1CgC,EA4CvBN,MAAM,CAACmB,WA5CgB,EAoDhCb,yBApDgC,EAqDZN,MAAM,CAACoB,WArDK,EAsDvBpB,MAAM,CAACqB,KAtDgB,EA8DhCf,yBA9DgC,EA+DZN,MAAM,CAACsB,WA/DK,EAgEvBtB,MAAM,CAACmB,WAhEgB,CAA/B;AAqEP,OAAO,IAAMI,qBAAqB,GAAGxB,MAAM,CAACQ,GAAV,2mBAM9BI,yBAN8B,EAO5BF,4BAP4B,EAc9BE,yBAd8B,EAe5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QAAF,IAAcG,CAAC,CAACP,GAAF,KAAUJ,QAAxB,GAAmC,CAAC,CAApC,GAAwC,CAF7E;AAG2B,QAAA,OAAO,EAAEW,CAAC,CAACH,QAAF,GAAaK,SAAb,GAAyB,UAACX,CAAD;AAAA,iBAAOO,OAAO,CAACP,CAAD,EAAIS,CAAJ,CAAd;AAAA,SAH7D;AAI2B,QAAA,WAAW,EAAEpC,yBAJxC;AAK2B,QAAA,UAAU,EAAEoC,CAAC,CAACH,QAAF,GAAaK,SAAb,GAAyB,UAACX,CAAD;AAAA,iBAAOD,UAAU,CAACC,CAAD,EAAIS,CAAJ,CAAjB;AAAA,SALhE;AAAA,+BAME,KAAC,4BAAD;AAAA,iCACE,KAAC,yBAAD;AAAA,sBACGA,CAAC,CAACG;AADL;AADF;AANF,SAAgCH,CAAC,CAACP,GAAF,IAASQ,CAAzC,CADS;AAAA,KAAV;AADH,IADF;AAkBD,CApCD;;;AANEhB,EAAAA,K;AANAQ,IAAAA,G;AACAI,IAAAA,Q;AACAM,IAAAA,O;;AAKAd,EAAAA,Q;AACAD,EAAAA,Q;;AA0CF,eAAeJ,cAAf","sourcesContent":["import React from 'react';\nimport {Size} from '../types';\nimport styled from 'styled-components';\nimport {COLORS, ComponentMStyling, ComponentSStyling, ComponentTextStyle, Z_INDEXES} from '../styles';\nimport {defaultOnMouseDownHandler} from '../common';\n\n\nexport const SegmentControlItemContent = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n border-radius: 8px;\n padding: 0 16px;\n\n background-color: transparent;\n color: ${COLORS.neutral_600};\n`\n\nexport const SegmentControlItemBackground = styled.div`\n flex: 1;\n display: flex;\n flex-direction: row;\n align-items: center;\n background-color: ${COLORS.neutral_20};\n padding: 4px 0px;\n`;\n\nexport const SegmentControlItemWrapper = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n flex: 1;\n cursor: pointer;\n min-height: 48px;\n\n &:focus {\n z-index: ${Z_INDEXES.focus};\n outline: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n box-shadow: 0px 4px 12px rgba(46, 127, 161, 0.25), 0px 0px 8px #2E7FA1;\n }\n }\n\n &:hover {\n z-index: ${Z_INDEXES.hover};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_100};\n color: ${COLORS.primary_700};\n }\n }\n\n &:active {\n z-index: ${Z_INDEXES.active};\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_200};\n color: ${COLORS.primary_800};\n box-shadow: none;\n }\n }\n\n &.disabled {\n cursor: not-allowed;\n\n ${SegmentControlItemContent} {\n background-color: transparent;\n color: ${COLORS.neutral_300};\n }\n }\n\n &.selected {\n cursor: default;\n pointer-events: none;\n\n ${SegmentControlItemContent} {\n background-color: ${COLORS.primary_500};\n color: ${COLORS.white};\n }\n }\n\n &.selected.disabled {\n cursor: not-allowed;\n pointer-events: unset;\n \n ${SegmentControlItemContent} {\n background-color: ${COLORS.neutral_100};\n color: ${COLORS.neutral_300};\n }\n }\n`;\n\nexport const SegmentControlWrapper = styled.div`\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n\n ${SegmentControlItemWrapper}:first-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-left-radius: 12px;\n border-top-left-radius: 12px;\n padding-left: 4px;\n }\n }\n\n ${SegmentControlItemWrapper}:last-of-type {\n ${SegmentControlItemBackground} {\n border-bottom-right-radius: 12px;\n border-top-right-radius: 12px;\n padding-right: 4px;\n }\n }\n\n\n &.small {\n ${SegmentControlItemContent} {\n ${ComponentSStyling(ComponentTextStyle.Bold, null)}\n min-height: 32px;\n }\n }\n\n &.medium {\n ${SegmentControlItemContent} {\n ${ComponentMStyling(ComponentTextStyle.Bold, null)}\n min-height: 40px;\n }\n }\n`;\n\n\nexport interface SegmentControlItem {\n key: string\n disabled?: boolean;\n content: React.ReactNode | string;\n}\n\ninterface SegmentControlProps {\n items: SegmentControlItem[];\n selected: string;\n onChange: (value: string) => void;\n size?: Size.Small | Size.Medium;\n}\n\nconst SegmentControl: React.FunctionComponent<SegmentControlProps> = ({\n items,\n size = Size.Medium,\n onChange,\n selected\n }) => {\n const onKeyPress = (e: React.KeyboardEvent<HTMLDivElement>, item: SegmentControlItem) => {\n if (e.key === 'Enter' || e.key === ' ') {\n //@ts-ignore\n document?.activeElement?.blur();\n !item.disabled && onChange(item.key);\n }\n };\n\n const onClick = (e: React.MouseEvent, item: SegmentControlItem) => {\n !item.disabled && onChange(item.key);\n }\n\n return (\n <SegmentControlWrapper className={size}>\n {items.map((a, i) =>\n <SegmentControlItemWrapper key={a.key || i}\n className={(a.disabled ? 'disabled' : '') + (a.key === selected ? ' selected' : '')}\n tabIndex={a.disabled || a.key === selected ? -1 : 0}\n onClick={a.disabled ? undefined : (e) => onClick(e, a)}\n onMouseDown={defaultOnMouseDownHandler}\n onKeyPress={a.disabled ? undefined : (e) => onKeyPress(e, a)}>\n <SegmentControlItemBackground>\n <SegmentControlItemContent>\n {a.content}\n </SegmentControlItemContent>\n </SegmentControlItemBackground>\n </SegmentControlItemWrapper>)\n }\n </SegmentControlWrapper>\n );\n};\n\nexport default SegmentControl;\n"],"file":"SegmentControl.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laerdal/life-react-components",
3
- "version": "1.5.1-dev.21",
3
+ "version": "1.5.1-dev.22.full",
4
4
  "private": false,
5
5
  "author": "Thomas Kalve <thomas.kalve@laerdal.com>",
6
6
  "contributors": [