@pega/cosmos-react-core 7.0.0-build.26.8 → 7.0.0-build.26.9

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.
@@ -41,7 +41,7 @@ const getHorizontalUnselectedHoverStyle = ({ level, opacity, color }) => level &
41
41
  `;
42
42
  const getHorizontalStyles = ({ selected, level, theme }) => {
43
43
  const color = theme.components.button.color;
44
- const secondaryColor = theme.components.button['secondary-color'];
44
+ const secondaryColor = theme.base.palette['secondary-background'];
45
45
  const lightenedColor = tryCatch(() => transparentize(0.3, color)) ?? '';
46
46
  const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;
47
47
  const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);
@@ -1 +1 @@
1
- {"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/components/Tabs/Tab.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,OAAO,WAAW,MAAM,eAAe,C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,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,EAA6B,EAC7F,GAAoB;IAEpB,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,UAAU,EAAE,CAAC;IACvC,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACjD,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAE1C,OAAO,CACL,MAAC,SAAS,IACR,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,KACR,SAAS,aAEb,2BACG,CAAC,CAAC,MAAM,IAAI,CACX,8BACE,KAAC,eAAe,IAAC,IAAI,EAAC,YAAY,GAAG,EACrC,KAAC,OAAO,IAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,YACtD,CAAC,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,GAC1B,IACT,CACJ,EACD,+BAAoB,OAAO,YAAG,OAAO,GAAQ,IACxC,EACN,KAAK,IACI,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,GAAG,CAAC","sourcesContent":["import { forwardRef, useContext } from 'react';\nimport type { FC, ReactNode, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { StyledProps } from 'styled-components';\nimport { meetsContrastGuidelines, mix, transparentize } from 'polished';\n\nimport { readableHue } from '../../styles';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport { registerIcon } from '../Icon';\nimport { useConsolidatedRef, useElement, useI18n } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { StyledCount } from '../Badges/Count';\nimport type { ForwardProps } from '../../types';\nimport BareButton from '../Button/BareButton';\n\nimport TabsContext from './TabsContext';\nimport type { TabsContextValue } from './TabsContext';\nimport type { TabsProps } from './Tabs.types';\nimport { StyledErrorIcon } from './Tabs.styles';\n\nregisterIcon(warnSolidIcon);\n\nexport interface TabProps {\n /** Indicates if this Tab is active. */\n selected: boolean;\n /** The text to display as the name of the Tab. */\n content: string;\n /** A number to associate with the Tab. */\n count?: ReactNode;\n /** Determines the direction in which the Tab will render. */\n type: TabsProps['type'];\n /** Disables the tab if true */\n disabled?: boolean;\n /** An error to associate with the Tab. */\n errors?: number | boolean;\n /** Ref to the tab element. */\n ref?: Ref<HTMLButtonElement | HTMLAnchorElement>;\n}\n\nexport interface StyledTabProps {\n selected: TabProps['selected'];\n tabType: TabProps['type'];\n}\n\nconst activeStyle = (color: string) => css`\n ::after {\n display: block;\n background-color: ${color};\n }\n`;\n\nconst getHorizontalUnselectedHoverStyle = ({\n level,\n opacity,\n color\n}: { level?: TabsContextValue['level'] } & { color?: string; opacity: number }) =>\n level && level > 1\n ? css`\n ::before {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n border-radius: inherit;\n background-color: currentColor;\n opacity: ${opacity};\n }\n `\n : css`\n background-color: ${color};\n border-start-start-radius: calc(0.5rem * 0.5);\n border-start-end-radius: calc(0.5rem * 0.5);\n `;\n\nconst getHorizontalStyles = ({\n selected,\n level,\n theme\n}: Pick<StyledProps<StyledTabProps>, 'theme' | 'selected'> & {\n level?: TabsContextValue['level'];\n}) => {\n const color = theme.components.button.color;\n const secondaryColor = theme.components.button['secondary-color'];\n const lightenedColor = tryCatch(() => transparentize(0.3, color)) ?? '';\n const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;\n const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);\n const hoverBackgroundColor = tryCatch(() => mix(0.9, secondaryColor, usableColor));\n const activeBackgroundColor = tryCatch(() => mix(0.8, secondaryColor, usableColor));\n\n const { spacing } = theme.base;\n\n return css`\n align-items: center;\n display: flex;\n flex-direction: row;\n height: calc(4 * ${spacing});\n padding: 0 calc(1.5 * ${spacing});\n border: none;\n text-decoration: none;\n\n @media (pointer: coarse) {\n height: ${theme.base['hit-area']['finger-min']};\n }\n\n span:first-of-type {\n color: ${selected ? color : theme.base.palette['foreground-color']};\n display: inline-block;\n\n ::before {\n content: attr(data-content);\n display: block;\n font-weight: bold;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n }\n\n &:first-child {\n margin-left: 0;\n }\n\n ::after {\n background: ${selected ? color : lightenedColor};\n display: ${selected ? 'block' : 'none'};\n content: '';\n position: absolute;\n height: 0.125rem;\n bottom: 0;\n left: calc(1.5 * ${spacing});\n right: calc(1.5 * ${spacing});\n }\n\n ${!selected\n ? css`\n @media (hover: hover) {\n &:not(:disabled):hover {\n text-decoration: none;\n ${getHorizontalUnselectedHoverStyle({\n level,\n opacity: 0.1,\n color: hoverBackgroundColor\n })}\n }\n\n &:not(:disabled):active {\n text-decoration: none;\n ${getHorizontalUnselectedHoverStyle({\n level,\n opacity: 0.2,\n color: activeBackgroundColor\n })}\n }\n }\n `\n : css`\n ${level &&\n level > 1 &&\n css`\n background-color: ${theme.base.palette['primary-background']};\n `}\n `}\n\n &:focus,\n &:not([disabled]):focus {\n border-radius: calc(0.5rem * 0.5);\n box-shadow: ${theme.base.shadow['focus-inset']};\n text-decoration: none;\n ::after {\n display: none;\n }\n }\n\n @media (pointer: coarse) {\n min-block-size: ${theme.base['hit-area'].finger};\n }\n\n ${StyledCount} {\n margin-inline-start: calc(0.5 * ${spacing});\n }\n `;\n};\n\nconst getVerticalStyles = ({\n selected,\n theme\n}: Pick<StyledProps<StyledTabProps>, 'theme' | 'selected'>) => {\n const borderColor = theme.base.palette['border-line'];\n const primaryColor = theme.base.palette.interactive;\n const lightenedColor = tryCatch(() => transparentize(0.5, primaryColor)) ?? '';\n const { spacing } = theme.base;\n\n return css`\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-style: solid;\n color: ${theme.base.palette['foreground-color']};\n border-width: 0.0625rem 0;\n border-color: ${borderColor};\n height: calc(5.5 * ${spacing});\n margin-top: -0.0625rem;\n padding: 0 calc(2 * ${spacing});\n text-decoration: none;\n\n &:first-child {\n border-top: 0.0625rem solid ${borderColor};\n }\n\n ::after {\n content: '';\n position: absolute;\n display: ${selected ? 'block' : 'none'};\n top: 0;\n bottom: 0;\n right: 0;\n width: 0.25rem;\n background: ${primaryColor};\n }\n\n &:hover&:not(:disabled) {\n ${activeStyle(lightenedColor)}\n text-decoration: none;\n }\n\n &:focus,\n &:not([disabled]):focus {\n ${activeStyle(primaryColor)}\n box-shadow: inset 0 0 0 0.0625rem ${primaryColor};\n text-decoration: none;\n }\n `;\n};\n\nexport const StyledTab = styled(BareButton)<\n StyledTabProps & {\n level?: TabsContextValue['level'];\n }\n>(\n ({ theme, tabType, selected, level }) => css`\n position: relative;\n background: none;\n cursor: pointer;\n white-space: nowrap;\n\n ${selected &&\n css`\n font-weight: bold;\n `}\n\n & + & {\n margin-inline-start: 0;\n }\n\n &:focus {\n outline: none;\n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: ${theme.base['disabled-opacity']};\n }\n\n ${tabType === 'horizontal'\n ? getHorizontalStyles({ theme, selected, level })\n : getVerticalStyles({ theme, selected })}\n\n ${StyledErrorIcon} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n `\n);\n\nStyledTab.defaultProps = defaultThemeProp;\n\nconst Tab: FC<TabProps & ForwardProps> = forwardRef(function Tab(\n { selected, content, count, type, disabled, errors, ...restProps }: PropsWithoutRef<TabProps>,\n ref: TabProps['ref']\n) {\n const t = useI18n();\n const [tabEl, setTabEl] = useElement();\n const tabRef = useConsolidatedRef(ref, setTabEl);\n const { level } = useContext(TabsContext);\n\n return (\n <StyledTab\n ref={tabRef}\n selected={selected}\n tabType={type}\n disabled={disabled}\n level={level}\n {...restProps}\n >\n <span>\n {!!errors && (\n <>\n <StyledErrorIcon name='warn-solid' />\n <Tooltip target={tabEl} hideDelay='none' showDelay='none'>\n {t('tab_error_tooltip', [content])}\n </Tooltip>\n </>\n )}\n <span data-content={content}>{content}</span>\n </span>\n {count}\n </StyledTab>\n );\n});\n\nexport default Tab;\n"]}
1
+ {"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/components/Tabs/Tab.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAE9C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,YAAY,CAAC,aAAa,CAAC,CAAC;AAwB5B,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,CAAA;;;wBAGlB,KAAK;;CAE5B,CAAC;AAEF,MAAM,iCAAiC,GAAG,CAAC,EACzC,KAAK,EACL,OAAO,EACP,KAAK,EACuE,EAAE,EAAE,CAChF,KAAK,IAAI,KAAK,G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CAAC,WAAW,CAAC,CAAC;IAE1C,OAAO,CACL,MAAC,SAAS,IACR,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,KACR,SAAS,aAEb,2BACG,CAAC,CAAC,MAAM,IAAI,CACX,8BACE,KAAC,eAAe,IAAC,IAAI,EAAC,YAAY,GAAG,EACrC,KAAC,OAAO,IAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,YACtD,CAAC,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC,GAC1B,IACT,CACJ,EACD,+BAAoB,OAAO,YAAG,OAAO,GAAQ,IACxC,EACN,KAAK,IACI,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,GAAG,CAAC","sourcesContent":["import { forwardRef, useContext } from 'react';\nimport type { FC, ReactNode, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { StyledProps } from 'styled-components';\nimport { meetsContrastGuidelines, mix, transparentize } from 'polished';\n\nimport { readableHue } from '../../styles';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport { registerIcon } from '../Icon';\nimport { useConsolidatedRef, useElement, useI18n } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { StyledCount } from '../Badges/Count';\nimport type { ForwardProps } from '../../types';\nimport BareButton from '../Button/BareButton';\n\nimport TabsContext from './TabsContext';\nimport type { TabsContextValue } from './TabsContext';\nimport type { TabsProps } from './Tabs.types';\nimport { StyledErrorIcon } from './Tabs.styles';\n\nregisterIcon(warnSolidIcon);\n\nexport interface TabProps {\n /** Indicates if this Tab is active. */\n selected: boolean;\n /** The text to display as the name of the Tab. */\n content: string;\n /** A number to associate with the Tab. */\n count?: ReactNode;\n /** Determines the direction in which the Tab will render. */\n type: TabsProps['type'];\n /** Disables the tab if true */\n disabled?: boolean;\n /** An error to associate with the Tab. */\n errors?: number | boolean;\n /** Ref to the tab element. */\n ref?: Ref<HTMLButtonElement | HTMLAnchorElement>;\n}\n\nexport interface StyledTabProps {\n selected: TabProps['selected'];\n tabType: TabProps['type'];\n}\n\nconst activeStyle = (color: string) => css`\n ::after {\n display: block;\n background-color: ${color};\n }\n`;\n\nconst getHorizontalUnselectedHoverStyle = ({\n level,\n opacity,\n color\n}: { level?: TabsContextValue['level'] } & { color?: string; opacity: number }) =>\n level && level > 1\n ? css`\n ::before {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n border-radius: inherit;\n background-color: currentColor;\n opacity: ${opacity};\n }\n `\n : css`\n background-color: ${color};\n border-start-start-radius: calc(0.5rem * 0.5);\n border-start-end-radius: calc(0.5rem * 0.5);\n `;\n\nconst getHorizontalStyles = ({\n selected,\n level,\n theme\n}: Pick<StyledProps<StyledTabProps>, 'theme' | 'selected'> & {\n level?: TabsContextValue['level'];\n}) => {\n const color = theme.components.button.color;\n const secondaryColor = theme.base.palette['secondary-background'];\n const lightenedColor = tryCatch(() => transparentize(0.3, color)) ?? '';\n const backgroundUsable = meetsContrastGuidelines(color, secondaryColor).AA;\n const usableColor = backgroundUsable ? color : readableHue(color, secondaryColor);\n const hoverBackgroundColor = tryCatch(() => mix(0.9, secondaryColor, usableColor));\n const activeBackgroundColor = tryCatch(() => mix(0.8, secondaryColor, usableColor));\n\n const { spacing } = theme.base;\n\n return css`\n align-items: center;\n display: flex;\n flex-direction: row;\n height: calc(4 * ${spacing});\n padding: 0 calc(1.5 * ${spacing});\n border: none;\n text-decoration: none;\n\n @media (pointer: coarse) {\n height: ${theme.base['hit-area']['finger-min']};\n }\n\n span:first-of-type {\n color: ${selected ? color : theme.base.palette['foreground-color']};\n display: inline-block;\n\n ::before {\n content: attr(data-content);\n display: block;\n font-weight: bold;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n }\n }\n\n &:first-child {\n margin-left: 0;\n }\n\n ::after {\n background: ${selected ? color : lightenedColor};\n display: ${selected ? 'block' : 'none'};\n content: '';\n position: absolute;\n height: 0.125rem;\n bottom: 0;\n left: calc(1.5 * ${spacing});\n right: calc(1.5 * ${spacing});\n }\n\n ${!selected\n ? css`\n @media (hover: hover) {\n &:not(:disabled):hover {\n text-decoration: none;\n ${getHorizontalUnselectedHoverStyle({\n level,\n opacity: 0.1,\n color: hoverBackgroundColor\n })}\n }\n\n &:not(:disabled):active {\n text-decoration: none;\n ${getHorizontalUnselectedHoverStyle({\n level,\n opacity: 0.2,\n color: activeBackgroundColor\n })}\n }\n }\n `\n : css`\n ${level &&\n level > 1 &&\n css`\n background-color: ${theme.base.palette['primary-background']};\n `}\n `}\n\n &:focus,\n &:not([disabled]):focus {\n border-radius: calc(0.5rem * 0.5);\n box-shadow: ${theme.base.shadow['focus-inset']};\n text-decoration: none;\n ::after {\n display: none;\n }\n }\n\n @media (pointer: coarse) {\n min-block-size: ${theme.base['hit-area'].finger};\n }\n\n ${StyledCount} {\n margin-inline-start: calc(0.5 * ${spacing});\n }\n `;\n};\n\nconst getVerticalStyles = ({\n selected,\n theme\n}: Pick<StyledProps<StyledTabProps>, 'theme' | 'selected'>) => {\n const borderColor = theme.base.palette['border-line'];\n const primaryColor = theme.base.palette.interactive;\n const lightenedColor = tryCatch(() => transparentize(0.5, primaryColor)) ?? '';\n const { spacing } = theme.base;\n\n return css`\n display: flex;\n justify-content: space-between;\n align-items: center;\n border-style: solid;\n color: ${theme.base.palette['foreground-color']};\n border-width: 0.0625rem 0;\n border-color: ${borderColor};\n height: calc(5.5 * ${spacing});\n margin-top: -0.0625rem;\n padding: 0 calc(2 * ${spacing});\n text-decoration: none;\n\n &:first-child {\n border-top: 0.0625rem solid ${borderColor};\n }\n\n ::after {\n content: '';\n position: absolute;\n display: ${selected ? 'block' : 'none'};\n top: 0;\n bottom: 0;\n right: 0;\n width: 0.25rem;\n background: ${primaryColor};\n }\n\n &:hover&:not(:disabled) {\n ${activeStyle(lightenedColor)}\n text-decoration: none;\n }\n\n &:focus,\n &:not([disabled]):focus {\n ${activeStyle(primaryColor)}\n box-shadow: inset 0 0 0 0.0625rem ${primaryColor};\n text-decoration: none;\n }\n `;\n};\n\nexport const StyledTab = styled(BareButton)<\n StyledTabProps & {\n level?: TabsContextValue['level'];\n }\n>(\n ({ theme, tabType, selected, level }) => css`\n position: relative;\n background: none;\n cursor: pointer;\n white-space: nowrap;\n\n ${selected &&\n css`\n font-weight: bold;\n `}\n\n & + & {\n margin-inline-start: 0;\n }\n\n &:focus {\n outline: none;\n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: ${theme.base['disabled-opacity']};\n }\n\n ${tabType === 'horizontal'\n ? getHorizontalStyles({ theme, selected, level })\n : getVerticalStyles({ theme, selected })}\n\n ${StyledErrorIcon} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n `\n);\n\nStyledTab.defaultProps = defaultThemeProp;\n\nconst Tab: FC<TabProps & ForwardProps> = forwardRef(function Tab(\n { selected, content, count, type, disabled, errors, ...restProps }: PropsWithoutRef<TabProps>,\n ref: TabProps['ref']\n) {\n const t = useI18n();\n const [tabEl, setTabEl] = useElement();\n const tabRef = useConsolidatedRef(ref, setTabEl);\n const { level } = useContext(TabsContext);\n\n return (\n <StyledTab\n ref={tabRef}\n selected={selected}\n tabType={type}\n disabled={disabled}\n level={level}\n {...restProps}\n >\n <span>\n {!!errors && (\n <>\n <StyledErrorIcon name='warn-solid' />\n <Tooltip target={tabEl} hideDelay='none' showDelay='none'>\n {t('tab_error_tooltip', [content])}\n </Tooltip>\n </>\n )}\n <span data-content={content}>{content}</span>\n </span>\n {count}\n </StyledTab>\n );\n});\n\nexport default Tab;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/TabPanel.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,i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;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,kCAAkC;IAClC,UAAU,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,oCAAoC;IACpC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAMD,eAAO,MAAM,cAAc;aAEd,OAAO;WACT,MAAM;SAyBf,CAAC;AAgBH,QAAA,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CAyE5D,CAAC;AAIH,eAAe,QAAQ,CAAC"}
@@ -18,7 +18,7 @@ export const StyledTabPanel = styled(Flex)(({ current, tablistType, level, theme
18
18
 
19
19
  :focus {
20
20
  outline: none;
21
- box-shadow: ${theme.base.shadow['focus-inset']};
21
+ box-shadow: ${theme.base.shadow.focus};
22
22
  }
23
23
 
24
24
  ${!current &&
@@ -67,7 +67,9 @@ const TabPanel = forwardRef(function TabPanel({ tabId, currentTabId, title, tabl
67
67
  return (_jsx(TabsContext.Provider, { value: contextValue, children: _jsxs(StyledTabPanel, { ...restProps, container: {
68
68
  direction: 'column',
69
69
  rowGap: 1,
70
- ...(tablistType === 'horizontal' && { pad: level > 1 ? [1, 1.5, 1.5] : [1, 2, 2] })
70
+ ...(tablistType === 'horizontal' && {
71
+ pad: level > 1 ? [1, 1.5, undefined] : [1, undefined, undefined]
72
+ })
71
73
  }, item: { grow: 1 }, current: currentTabId && tabId ? currentTabId === tabId : true, role: 'tabpanel', "aria-labelledby": `${tabId}`, id: `${tabId}-panel`, ref: tabPanelRef, tabIndex: 0, tablistType: tablistType, level: level, children: [title && _jsx(Text, { variant: `h${Math.min(2 + level, 6)}`, children: title }), children, tablistRef?.current && showReturnButton && (_jsx(StyledButton, { variant: 'link', onClick: () => {
72
74
  getFocusables(tablistRef)[0]?.focus();
73
75
  }, children: t('return_to_tab_list') }))] }) }));
@@ -1 +1 @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esContent":["import { forwardRef, useState, useCallback, useMemo, useContext } from 'react';\nimport type { FunctionComponent, ReactNode, Ref, PropsWithoutRef, RefObject } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useConsolidatedRef, useI18n, useFocusWithin, useEvent } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport type { ForwardProps, HeadingTag } from '../../types';\nimport Button from '../Button';\nimport { getFocusables } from '../../utils';\nimport Flex from '../Flex';\nimport Text from '../Text';\n\nimport type { TabsProps } from './Tabs.types';\nimport TabsContext from './TabsContext';\n\ninterface TabPanelProps {\n /** The id of the Tab that the tab panel is related to. */\n tabId: string;\n /**\n * The current selected value of the tabs. Controls the visibility of the tab panel.\n * The tabsValue must match the tabId in order for the TabPanel to show itself.\n */\n currentTabId?: string;\n /** The title for the tab panel */\n title?: string;\n /** Content of the tab panel. */\n children: ReactNode;\n /** Ref to the tablist element. */\n tablistRef?: RefObject<HTMLElement>;\n /**\n * The tablist type indicates what direction the tabs are rendered in.\n * @default 'horizontal'\n */\n tablistType?: TabsProps['type'];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst defaultProps: Partial<TabPanelProps> = {\n tabId: ''\n};\n\nexport const StyledTabPanel = styled(Flex)<\n Pick<TabPanelProps, 'tablistType'> & {\n current: boolean;\n level: number;\n }\n>(({ current, tablistType, level, theme }) => {\n return css`\n min-width: 0;\n max-width: 100%;\n\n :focus {\n outline: none;\n box-shadow: ${theme.base.shadow['focus-inset']};\n }\n\n ${!current &&\n css`\n display: none;\n `}\n ${tablistType === 'horizontal' &&\n level > 1 &&\n css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-block-start: none;\n border-end-start-radius: calc(0.5rem * 0.5);\n border-end-end-radius: calc(0.5rem * 0.5);\n `}\n `;\n});\n\nStyledTabPanel.defaultProps = defaultThemeProp;\n\nconst StyledButton = styled(Button)(({ theme }) => {\n return css`\n padding-inline: calc(${theme.base.spacing});\n opacity: 0;\n &:focus {\n opacity: 1;\n }\n `;\n});\n\nStyledButton.defaultProps = defaultThemeProp;\n\nconst TabPanel: FunctionComponent<TabPanelProps & ForwardProps> = forwardRef(function TabPanel(\n {\n tabId,\n currentTabId,\n title,\n tablistRef,\n tablistType = 'horizontal',\n children,\n ...restProps\n }: PropsWithoutRef<TabPanelProps>,\n ref: TabPanelProps['ref']\n) {\n const t = useI18n();\n const tabPanelRef = useConsolidatedRef(ref);\n const [showReturnButton, setShowReturnButton] = useState(false);\n const { level } = useContext(TabsContext);\n\n const onFocusChange = useCallback(isFocused => {\n if (!isFocused) {\n setShowReturnButton(false);\n }\n }, []);\n\n useFocusWithin([tabPanelRef], onFocusChange);\n\n const contextValue = useMemo(\n () => ({ level: tablistType === 'horizontal' ? level + 1 : 1 }),\n [level, tablistType]\n );\n\n const onKeyUp = () => {\n if (tabPanelRef.current?.contains(document.activeElement)) {\n setShowReturnButton(true);\n }\n };\n useEvent('keyup', onKeyUp);\n\n return (\n <TabsContext.Provider value={contextValue}>\n <StyledTabPanel\n {...restProps}\n container={{\n direction: 'column',\n rowGap: 1,\n ...(tablistType === 'horizontal' && { pad: level > 1 ? [1, 1.5, 1.5] : [1, 2, 2] })\n }}\n item={{ grow: 1 }}\n current={currentTabId && tabId ? currentTabId === tabId : true}\n role='tabpanel'\n aria-labelledby={`${tabId}`}\n id={`${tabId}-panel`}\n ref={tabPanelRef}\n tabIndex={0}\n tablistType={tablistType}\n level={level}\n >\n {title && <Text variant={`h${Math.min(2 + level, 6)}` as HeadingTag}>{title}</Text>}\n {children}\n {tablistRef?.current && showReturnButton && (\n <StyledButton\n variant='link'\n onClick={() => {\n getFocusables(tablistRef)[0]?.focus();\n }}\n >\n {t('return_to_tab_list')}\n </StyledButton>\n )}\n </StyledTabPanel>\n </TabsContext.Provider>\n );\n});\n\nTabPanel.defaultProps = defaultProps;\n\nexport default TabPanel;\n"]}
1
+ {"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["../../../src/components/Tabs/TabPanel.t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AY,YACvC,MAAC,cAAc,OACT,SAAS,EACb,SAAS,EAAE;gBACT,SAAS,EAAE,QAAQ;gBACnB,MAAM,EAAE,CAAC;gBACT,GAAG,CAAC,WAAW,KAAK,YAAY,IAAI;oBAClC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC;iBACjE,CAAC;aACH,EACD,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EACjB,OAAO,EAAE,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,EAC9D,IAAI,EAAC,UAAU,qBACE,GAAG,KAAK,EAAE,EAC3B,EAAE,EAAE,GAAG,KAAK,QAAQ,EACpB,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,CAAC,EACX,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,aAEX,KAAK,IAAI,KAAC,IAAI,IAAC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,EAAgB,YAAG,KAAK,GAAQ,EAClF,QAAQ,EACR,UAAU,EAAE,OAAO,IAAI,gBAAgB,IAAI,CAC1C,KAAC,YAAY,IACX,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;wBACZ,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;oBACxC,CAAC,YAEA,CAAC,CAAC,oBAAoB,CAAC,GACX,CAChB,IACc,GACI,CACxB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;AAErC,eAAe,QAAQ,CAAC","sourcesContent":["import { forwardRef, useState, useCallback, useMemo, useContext } from 'react';\nimport type { FunctionComponent, ReactNode, Ref, PropsWithoutRef, RefObject } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useConsolidatedRef, useI18n, useFocusWithin, useEvent } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport type { ForwardProps, HeadingTag } from '../../types';\nimport Button from '../Button';\nimport { getFocusables } from '../../utils';\nimport Flex from '../Flex';\nimport Text from '../Text';\n\nimport type { TabsProps } from './Tabs.types';\nimport TabsContext from './TabsContext';\n\ninterface TabPanelProps {\n /** The id of the Tab that the tab panel is related to. */\n tabId: string;\n /**\n * The current selected value of the tabs. Controls the visibility of the tab panel.\n * The tabsValue must match the tabId in order for the TabPanel to show itself.\n */\n currentTabId?: string;\n /** The title for the tab panel */\n title?: string;\n /** Content of the tab panel. */\n children: ReactNode;\n /** Ref to the tablist element. */\n tablistRef?: RefObject<HTMLElement>;\n /**\n * The tablist type indicates what direction the tabs are rendered in.\n * @default 'horizontal'\n */\n tablistType?: TabsProps['type'];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst defaultProps: Partial<TabPanelProps> = {\n tabId: ''\n};\n\nexport const StyledTabPanel = styled(Flex)<\n Pick<TabPanelProps, 'tablistType'> & {\n current: boolean;\n level: number;\n }\n>(({ current, tablistType, level, theme }) => {\n return css`\n min-width: 0;\n max-width: 100%;\n\n :focus {\n outline: none;\n box-shadow: ${theme.base.shadow.focus};\n }\n\n ${!current &&\n css`\n display: none;\n `}\n ${tablistType === 'horizontal' &&\n level > 1 &&\n css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-block-start: none;\n border-end-start-radius: calc(0.5rem * 0.5);\n border-end-end-radius: calc(0.5rem * 0.5);\n `}\n `;\n});\n\nStyledTabPanel.defaultProps = defaultThemeProp;\n\nconst StyledButton = styled(Button)(({ theme }) => {\n return css`\n padding-inline: calc(${theme.base.spacing});\n opacity: 0;\n &:focus {\n opacity: 1;\n }\n `;\n});\n\nStyledButton.defaultProps = defaultThemeProp;\n\nconst TabPanel: FunctionComponent<TabPanelProps & ForwardProps> = forwardRef(function TabPanel(\n {\n tabId,\n currentTabId,\n title,\n tablistRef,\n tablistType = 'horizontal',\n children,\n ...restProps\n }: PropsWithoutRef<TabPanelProps>,\n ref: TabPanelProps['ref']\n) {\n const t = useI18n();\n const tabPanelRef = useConsolidatedRef(ref);\n const [showReturnButton, setShowReturnButton] = useState(false);\n const { level } = useContext(TabsContext);\n\n const onFocusChange = useCallback(isFocused => {\n if (!isFocused) {\n setShowReturnButton(false);\n }\n }, []);\n\n useFocusWithin([tabPanelRef], onFocusChange);\n\n const contextValue = useMemo(\n () => ({ level: tablistType === 'horizontal' ? level + 1 : 1 }),\n [level, tablistType]\n );\n\n const onKeyUp = () => {\n if (tabPanelRef.current?.contains(document.activeElement)) {\n setShowReturnButton(true);\n }\n };\n useEvent('keyup', onKeyUp);\n\n return (\n <TabsContext.Provider value={contextValue}>\n <StyledTabPanel\n {...restProps}\n container={{\n direction: 'column',\n rowGap: 1,\n ...(tablistType === 'horizontal' && {\n pad: level > 1 ? [1, 1.5, undefined] : [1, undefined, undefined]\n })\n }}\n item={{ grow: 1 }}\n current={currentTabId && tabId ? currentTabId === tabId : true}\n role='tabpanel'\n aria-labelledby={`${tabId}`}\n id={`${tabId}-panel`}\n ref={tabPanelRef}\n tabIndex={0}\n tablistType={tablistType}\n level={level}\n >\n {title && <Text variant={`h${Math.min(2 + level, 6)}` as HeadingTag}>{title}</Text>}\n {children}\n {tablistRef?.current && showReturnButton && (\n <StyledButton\n variant='link'\n onClick={() => {\n getFocusables(tablistRef)[0]?.focus();\n }}\n >\n {t('return_to_tab_list')}\n </StyledButton>\n )}\n </StyledTabPanel>\n </TabsContext.Provider>\n );\n});\n\nTabPanel.defaultProps = defaultProps;\n\nexport default TabPanel;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-core",
3
- "version": "7.0.0-build.26.8",
3
+ "version": "7.0.0-build.26.9",
4
4
  "description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
5
5
  "repository": {
6
6
  "type": "git",