@pega/cosmos-react-work 9.0.0-build.9.11 → 9.0.0-build.9.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AppAnnouncement.d.ts","sourceRoot":"","sources":["../../../src/components/AppAnnouncement/AppAnnouncement.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAclD,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,cAAc,EACf,MAAM,yBAAyB,CAAC;AAKjC,MAAM,WAAW,oBAAqB,SAAQ,SAAS,EAAE,cAAc;IACrE,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAOD,eAAO,MAAM,qBAAqB,8JA4FhC,CAAC;AAIH,QAAA,MAAM,eAAe,EAAE,+BAA+B,CAAC,oBAAoB,CAkD1E,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"AppAnnouncement.d.ts","sourceRoot":"","sources":["../../../src/components/AppAnnouncement/AppAnnouncement.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAelD,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,cAAc,EACf,MAAM,yBAAyB,CAAC;AAKjC,MAAM,WAAW,oBAAqB,SAAQ,SAAS,EAAE,cAAc;IACrE,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxB;AAOD,eAAO,MAAM,qBAAqB,8JA4FhC,CAAC;AAIH,QAAA,MAAM,eAAe,EAAE,+BAA+B,CAAC,oBAAoB,CAsD1E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { Button, StyledButton, Text, Icon, registerIcon, useI18n, defaultThemeProp, useDirection, calculateForegroundColor } from '@pega/cosmos-react-core';
4
+ import { Button, StyledButton, Text, Icon, registerIcon, useI18n, defaultThemeProp, useDirection, calculateForegroundColor, HTML } from '@pega/cosmos-react-core';
5
5
  import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
6
6
  registerIcon(timesIcon);
7
7
  const StyledDismissButton = styled.button `
@@ -92,9 +92,10 @@ StyledAppAnnouncement.defaultProps = defaultThemeProp;
92
92
  const AppAnnouncement = forwardRef(function AppAnnouncement(props, ref) {
93
93
  const t = useI18n();
94
94
  const { heading, description, details, whatsNewLink, whatsNewText = t('app_announcement_whats_new_button_label'), image, onDismiss, ...restProps } = props;
95
- return (_jsxs(StyledAppAnnouncement, { ...restProps, ref: ref, image: image, children: [onDismiss && (_jsx(Button, { as: StyledDismissButton, variant: 'simple', icon: true, onClick: onDismiss, "aria-label": t('app_announcement_dismiss_button_label_a11y'), children: _jsx(Icon, { name: 'times' }) })), _jsx(Text, { variant: 'h2', children: heading || t('app_announcement_details_list_header') }), _jsxs("div", { children: [description && _jsx("p", { children: description }), details && (_jsx("ul", { children: details.map((item, index) => {
95
+ return (_jsxs(StyledAppAnnouncement, { ...restProps, ref: ref, image: image, children: [onDismiss && (_jsx(Button, { as: StyledDismissButton, variant: 'simple', icon: true, onClick: onDismiss, "aria-label": t('app_announcement_dismiss_button_label_a11y'), children: _jsx(Icon, { name: 'times' }) })), _jsx(Text, { variant: 'h2', children: heading || t('app_announcement_details_list_header') }), _jsxs("div", { children: [description && _jsx(HTML, { as: 'p', content: description }), details && (_jsx("ul", { children: details.map((item, index) => {
96
+ return (
96
97
  // eslint-disable-next-line react/no-array-index-key
97
- return _jsx("li", { children: item }, index);
98
+ _jsx("li", { children: _jsx(HTML, { content: item }) }, index));
98
99
  }) })), whatsNewLink && (_jsx(Button, { variant: 'secondary', href: whatsNewLink, target: '_blank', children: whatsNewText }))] })] }));
99
100
  });
100
101
  export default AppAnnouncement;
@@ -1 +1 @@
1
- {"version":3,"file":"AppAnnouncement.js","sourceRoot":"","sources":["../../../src/components/AppAnnouncement/AppAnnouncement.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAMjC,OAAO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C,CAAC,yCAAyC,CAAC,EAC3D,KAAK,EACL,SAAS,EACT,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,OAAO,CACL,MAAC,qBAAqB,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,aACzD,SAAS,IAAI,CACZ,KAAC,MAAM,IACL,EAAE,EAAE,mBAAmB,EACvB,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,SAAS,gBACN,CAAC,CAAC,4CAA4C,CAAC,YAE3D,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,EACD,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,IAAI,CAAC,CAAC,sCAAsC,CAAC,GAAQ,EAChF,0BACG,WAAW,IAAI,sBAAI,WAAW,GAAK,EACnC,OAAO,IAAI,CACV,uBACG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;4BAC3B,oDAAoD;4BACpD,OAAO,uBAAiB,IAAI,IAAZ,KAAK,CAAa,CAAC;wBACrC,CAAC,CAAC,GACC,CACN,EACA,YAAY,IAAI,CACf,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAC,QAAQ,YAC5D,YAAY,GACN,CACV,IACG,IACgB,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n StyledButton,\n Text,\n Icon,\n registerIcon,\n useI18n,\n defaultThemeProp,\n useDirection,\n calculateForegroundColor\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nregisterIcon(timesIcon);\n\nexport interface AppAnnouncementProps extends BaseProps, NoChildrenProp {\n /** Heading text for the announcement. */\n heading?: string;\n /** Description text for the announcement. */\n description?: string;\n /** Announcement details to be displayed in form of bulleted list. */\n details?: string[];\n /** Url to open with What's new link. */\n whatsNewLink?: string;\n /** Content to populate the announcement button. */\n whatsNewText?: string;\n /** An image source for the decorative background. */\n image?: string;\n /**\n * Whether to fit AppAnnouncement widget in the parent element.\n */\n fitToParent?: boolean;\n /** Callback when user dismisses the announcements. */\n onDismiss?: () => void;\n ref?: Ref<HTMLElement>;\n}\n\nconst StyledDismissButton = styled.button`\n font-size: 1.25rem;\n border: none;\n`;\n\nexport const StyledAppAnnouncement = styled.article<\n Pick<AppAnnouncementProps, 'image' | 'fitToParent'>\n>(props => {\n const {\n theme: {\n base: { shadow, spacing },\n components: {\n card: { 'border-radius': borderRadius },\n announcement: { background, 'foreground-color': foregroundColor }\n }\n },\n image\n } = props;\n\n const { end } = useDirection();\n const color = calculateForegroundColor(background, foregroundColor);\n\n return css`\n padding: calc(2 * ${spacing});\n background: ${background};\n border-radius: ${borderRadius};\n color: ${color};\n position: relative;\n\n ${props.fitToParent && 'block-size: 100%;'};\n\n &::after {\n background: url('${image}') no-repeat;\n background-position: ${end} bottom;\n background-size: contain;\n background-origin: content-box;\n opacity: 0.2;\n content: '';\n display: block;\n position: absolute;\n width: 50%;\n height: 100%;\n inset-inline-end: 0;\n bottom: 0;\n padding: calc(2 * ${spacing});\n }\n\n h2 {\n position: relative;\n z-index: 2;\n }\n\n ${StyledDismissButton} {\n position: absolute;\n top: 0.75rem;\n inset-inline-end: 0.75rem;\n color: inherit;\n z-index: 3;\n &:enabled:hover {\n background: #ffffff19;\n }\n &:enabled:focus {\n box-shadow: ${shadow.focus};\n }\n }\n\n > div {\n position: relative;\n z-index: 2;\n\n p,\n ul {\n padding-top: calc(2 * ${spacing});\n line-height: 1.4;\n }\n\n ul {\n padding-inline-start: calc(2 * ${spacing});\n }\n\n li {\n &:not(:last-child) {\n margin-block-end: ${spacing};\n }\n }\n\n ${StyledButton} {\n margin-top: calc(2 * ${spacing});\n white-space: normal;\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${shadow.focus};\n }\n }\n }\n `;\n});\n\nStyledAppAnnouncement.defaultProps = defaultThemeProp;\n\nconst AppAnnouncement: ForwardRefForwardPropsComponent<AppAnnouncementProps> = forwardRef(\n function AppAnnouncement(\n props: PropsWithoutRef<AppAnnouncementProps>,\n ref: AppAnnouncementProps['ref']\n ) {\n const t = useI18n();\n const {\n heading,\n description,\n details,\n whatsNewLink,\n whatsNewText = t('app_announcement_whats_new_button_label'),\n image,\n onDismiss,\n ...restProps\n } = props;\n\n return (\n <StyledAppAnnouncement {...restProps} ref={ref} image={image}>\n {onDismiss && (\n <Button\n as={StyledDismissButton}\n variant='simple'\n icon\n onClick={onDismiss}\n aria-label={t('app_announcement_dismiss_button_label_a11y')}\n >\n <Icon name='times' />\n </Button>\n )}\n <Text variant='h2'>{heading || t('app_announcement_details_list_header')}</Text>\n <div>\n {description && <p>{description}</p>}\n {details && (\n <ul>\n {details.map((item, index) => {\n // eslint-disable-next-line react/no-array-index-key\n return <li key={index}>{item}</li>;\n })}\n </ul>\n )}\n {whatsNewLink && (\n <Button variant='secondary' href={whatsNewLink} target='_blank'>\n {whatsNewText}\n </Button>\n )}\n </div>\n </StyledAppAnnouncement>\n );\n }\n);\n\nexport default AppAnnouncement;\n"]}
1
+ {"version":3,"file":"AppAnnouncement.js","sourceRoot":"","sources":["../../../src/components/AppAnnouncement/AppAnnouncement.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,wBAAw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P,WAAW,EACX,OAAO,EACP,YAAY,EACZ,YAAY,GAAG,CAAC,CAAC,yCAAyC,CAAC,EAC3D,KAAK,EACL,SAAS,EACT,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,OAAO,CACL,MAAC,qBAAqB,OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,aACzD,SAAS,IAAI,CACZ,KAAC,MAAM,IACL,EAAE,EAAE,mBAAmB,EACvB,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,SAAS,gBACN,CAAC,CAAC,4CAA4C,CAAC,YAE3D,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,EACD,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,IAAI,CAAC,CAAC,sCAAsC,CAAC,GAAQ,EAChF,0BACG,WAAW,IAAI,KAAC,IAAI,IAAC,EAAE,EAAC,GAAG,EAAC,OAAO,EAAE,WAAW,GAAI,EACpD,OAAO,IAAI,CACV,uBACG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;4BAC3B,OAAO;4BACL,oDAAoD;4BACpD,uBACE,KAAC,IAAI,IAAC,OAAO,EAAE,IAAI,GAAI,IADhB,KAAK,CAET,CACN,CAAC;wBACJ,CAAC,CAAC,GACC,CACN,EACA,YAAY,IAAI,CACf,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAC,QAAQ,YAC5D,YAAY,GACN,CACV,IACG,IACgB,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n StyledButton,\n Text,\n Icon,\n registerIcon,\n useI18n,\n defaultThemeProp,\n useDirection,\n calculateForegroundColor,\n HTML\n} from '@pega/cosmos-react-core';\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nregisterIcon(timesIcon);\n\nexport interface AppAnnouncementProps extends BaseProps, NoChildrenProp {\n /** Heading text for the announcement. */\n heading?: string;\n /** Description text for the announcement. */\n description?: string;\n /** Announcement details to be displayed in form of bulleted list. */\n details?: string[];\n /** Url to open with What's new link. */\n whatsNewLink?: string;\n /** Content to populate the announcement button. */\n whatsNewText?: string;\n /** An image source for the decorative background. */\n image?: string;\n /**\n * Whether to fit AppAnnouncement widget in the parent element.\n */\n fitToParent?: boolean;\n /** Callback when user dismisses the announcements. */\n onDismiss?: () => void;\n ref?: Ref<HTMLElement>;\n}\n\nconst StyledDismissButton = styled.button`\n font-size: 1.25rem;\n border: none;\n`;\n\nexport const StyledAppAnnouncement = styled.article<\n Pick<AppAnnouncementProps, 'image' | 'fitToParent'>\n>(props => {\n const {\n theme: {\n base: { shadow, spacing },\n components: {\n card: { 'border-radius': borderRadius },\n announcement: { background, 'foreground-color': foregroundColor }\n }\n },\n image\n } = props;\n\n const { end } = useDirection();\n const color = calculateForegroundColor(background, foregroundColor);\n\n return css`\n padding: calc(2 * ${spacing});\n background: ${background};\n border-radius: ${borderRadius};\n color: ${color};\n position: relative;\n\n ${props.fitToParent && 'block-size: 100%;'};\n\n &::after {\n background: url('${image}') no-repeat;\n background-position: ${end} bottom;\n background-size: contain;\n background-origin: content-box;\n opacity: 0.2;\n content: '';\n display: block;\n position: absolute;\n width: 50%;\n height: 100%;\n inset-inline-end: 0;\n bottom: 0;\n padding: calc(2 * ${spacing});\n }\n\n h2 {\n position: relative;\n z-index: 2;\n }\n\n ${StyledDismissButton} {\n position: absolute;\n top: 0.75rem;\n inset-inline-end: 0.75rem;\n color: inherit;\n z-index: 3;\n &:enabled:hover {\n background: #ffffff19;\n }\n &:enabled:focus {\n box-shadow: ${shadow.focus};\n }\n }\n\n > div {\n position: relative;\n z-index: 2;\n\n p,\n ul {\n padding-top: calc(2 * ${spacing});\n line-height: 1.4;\n }\n\n ul {\n padding-inline-start: calc(2 * ${spacing});\n }\n\n li {\n &:not(:last-child) {\n margin-block-end: ${spacing};\n }\n }\n\n ${StyledButton} {\n margin-top: calc(2 * ${spacing});\n white-space: normal;\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${shadow.focus};\n }\n }\n }\n `;\n});\n\nStyledAppAnnouncement.defaultProps = defaultThemeProp;\n\nconst AppAnnouncement: ForwardRefForwardPropsComponent<AppAnnouncementProps> = forwardRef(\n function AppAnnouncement(\n props: PropsWithoutRef<AppAnnouncementProps>,\n ref: AppAnnouncementProps['ref']\n ) {\n const t = useI18n();\n const {\n heading,\n description,\n details,\n whatsNewLink,\n whatsNewText = t('app_announcement_whats_new_button_label'),\n image,\n onDismiss,\n ...restProps\n } = props;\n\n return (\n <StyledAppAnnouncement {...restProps} ref={ref} image={image}>\n {onDismiss && (\n <Button\n as={StyledDismissButton}\n variant='simple'\n icon\n onClick={onDismiss}\n aria-label={t('app_announcement_dismiss_button_label_a11y')}\n >\n <Icon name='times' />\n </Button>\n )}\n <Text variant='h2'>{heading || t('app_announcement_details_list_header')}</Text>\n <div>\n {description && <HTML as='p' content={description} />}\n {details && (\n <ul>\n {details.map((item, index) => {\n return (\n // eslint-disable-next-line react/no-array-index-key\n <li key={index}>\n <HTML content={item} />\n </li>\n );\n })}\n </ul>\n )}\n {whatsNewLink && (\n <Button variant='secondary' href={whatsNewLink} target='_blank'>\n {whatsNewText}\n </Button>\n )}\n </div>\n </StyledAppAnnouncement>\n );\n }\n);\n\nexport default AppAnnouncement;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CasePreview.d.ts","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;A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1B,yCAAyC;IACzC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;;;;AAmPD,wBAA+D"}
@@ -1,53 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useState, useCallback, useEffect, useContext } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { Drawer, Icon, registerIcon, Button, Flex, defaultThemeProp, useBreakpoint, useElement, useDirection, useI18n, AppShellContext, useTestIds, withTestIds, Progress, ErrorState, getFocusables, useConsolidatedRef, StyledButton, calculateForegroundColor, useFocusTrap, readableHue } from '@pega/cosmos-react-core';
4
+ import { Drawer, Icon, registerIcon, Flex, defaultThemeProp, useBreakpoint, useElement, useDirection, useI18n, AppShellContext, useTestIds, withTestIds, Progress, ErrorState, getFocusables, useConsolidatedRef, useFocusTrap, readableHue, StyledIcon } from '@pega/cosmos-react-core';
5
5
  import { resizeDrawerDefaultWidth } from '@pega/cosmos-react-core/lib/styles/constants';
6
6
  import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
7
+ import { StyledResizeHandle } from '@pega/cosmos-react-core/lib/components/Drawer/ResizeHandle';
7
8
  import CaseView, { StyledCaseView, StyledCaseViewContent, StyledCaseDrawer, StyledSummaryRegion } from '../CaseView';
8
9
  import { StyledGenAICoachContainer } from '../GenAICoach/GenAICoach.styles';
9
- import { StyledCaseHeader } from '../CaseView/CaseView.styles';
10
+ import { StyledExpandCollapseButton } from '../CaseView/CaseView.styles';
10
11
  import { getCasePreviewTestIds } from './CasePreview.test-ids';
11
12
  registerIcon(timesIcon);
12
- const StyledPreviewHeader = styled.div(({ theme }) => {
13
- return css `
14
- z-index: ${theme.base['z-index'].drawer};
15
- background-color: ${theme.base.palette['primary-background']};
16
- `;
17
- });
18
- StyledPreviewHeader.defaultProps = defaultThemeProp;
19
- const StyledPreviewActions = styled.div(({ theme: { base: { spacing, 'z-index': { backdrop, popover } }, components: { 'case-view': { header: { background, 'foreground-color': color } } } }, fixedHeaderHeight, progressActive }) => {
20
- const foregroundColor = calculateForegroundColor(background, color);
21
- return css `
22
- color: ${foregroundColor};
23
- padding: ${spacing} calc(2 * ${spacing}) calc(0.25 * ${spacing});
24
-
25
- ${fixedHeaderHeight
26
- ? css `
27
- background: ${background};
28
- `
29
- : css `
30
- position: absolute;
31
- z-index: ${popover + 1};
32
- `}
33
-
34
- ${StyledButton} {
35
- color: ${foregroundColor};
36
-
37
- ${progressActive &&
38
- css `
39
- z-index: ${backdrop + 1};
40
- color: ${foregroundColor};
41
- `}
42
- }
43
-
44
- ${fixedHeaderHeight &&
45
- css `
46
- min-height: 6.625rem;
47
- `}
48
- `;
49
- });
50
- StyledPreviewActions.defaultProps = defaultThemeProp;
51
13
  const StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {
52
14
  return css `
53
15
  background-color: ${theme.base.palette['app-background']};
@@ -58,25 +20,18 @@ const StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {
58
20
  transition-duration: max(${theme.base.animation.speed}, 0.0001s);
59
21
  transition-timing-function: ${theme.base.animation.timing.ease};
60
22
 
23
+ ${StyledResizeHandle} {
24
+ z-index: calc(${theme.base['z-index'].max - 1});
25
+ }
26
+
61
27
  ${StyledCaseView} {
62
28
  height: calc(100vh - ${theme.base.spacing} - ${theme.base['hit-area']['mouse-min']});
29
+ z-index: 1;
63
30
 
64
31
  @media (pointer: coarse) {
65
32
  height: calc(100vh - ${theme.base.spacing} - ${theme.base['hit-area']['finger-min']});
66
33
  }
67
34
 
68
- ${StyledCaseHeader} {
69
- padding-block-start: calc(
70
- (2.25 * ${theme.base.spacing}) + ${theme.base['hit-area']['mouse-min']}
71
- );
72
-
73
- @media (pointer: coarse) {
74
- padding-block-start: calc(
75
- (2.25 * ${theme.base.spacing}) + ${theme.base['hit-area']['finger-min']}
76
- );
77
- }
78
- }
79
-
80
35
  ${StyledSummaryRegion} {
81
36
  position: relative;
82
37
  top: 0;
@@ -107,6 +62,31 @@ const StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {
107
62
  `;
108
63
  });
109
64
  StyledPreviewDrawer.defaultProps = defaultThemeProp;
65
+ const StyledCloseButton = styled(StyledExpandCollapseButton)(({ theme }) => {
66
+ return css `
67
+ --half-btn-compact-difference: calc(
68
+ (${theme.base['hit-area'].mouse} - ${theme.base['hit-area'].compact}) / 2
69
+ );
70
+ @media (pointer: coarse) {
71
+ --half-btn-compact-difference: calc(
72
+ (${theme.base['hit-area'].finger} - ${theme.base['hit-area'].compact}) / 2
73
+ );
74
+ }
75
+ position: absolute;
76
+
77
+ /* Places above CaseHeader and resize handle */
78
+ z-index: ${theme.base['z-index'].max};
79
+ box-shadow: ${theme.base.shadow.low};
80
+ inset-inline-start: calc(-${theme.base['hit-area'].compact} / 2);
81
+ inset-block-start: calc(2 * ${theme.base.spacing} + var(--half-btn-compact-difference));
82
+
83
+ & > ${StyledIcon} {
84
+ inline-size: 1em;
85
+ block-size: 1em;
86
+ }
87
+ `;
88
+ });
89
+ StyledCloseButton.defaultProps = defaultThemeProp;
110
90
  const CasePreview = forwardRef(function CasePreview(props, ref) {
111
91
  const { testId, open: openProp, progress, error, onErrorRetry, caseId, caseType, heading, subheading, caseLink, parentCases, icon, followed, onFollowedChange, summaryFields, tabs, stages, tasks, tabContent, utilities, utilitiesSummaryItems, actions, banners, onEdit, onBeforeOpen, onAfterOpen, onBeforeClose, ...restProps } = props;
112
92
  const testIds = useTestIds(testId, getCasePreviewTestIds);
@@ -116,7 +96,6 @@ const CasePreview = forwardRef(function CasePreview(props, ref) {
116
96
  const [closeButtonEl, setCloseButtonEl] = useElement();
117
97
  const isSmallOrAbove = useBreakpoint('sm');
118
98
  const [open, setOpen] = useState(openProp);
119
- const [progressActive, setProgressActive] = useState(false);
120
99
  const [progressVisible, setProgressVisible] = useState(false);
121
100
  const direction = useDirection();
122
101
  const closePreview = useCallback(() => {
@@ -154,10 +133,9 @@ const CasePreview = forwardRef(function CasePreview(props, ref) {
154
133
  }, onBeforeClose: () => {
155
134
  setPreviewActive(false);
156
135
  onBeforeClose?.();
157
- }, as: StyledPreviewDrawer, role: 'complementary', forwardedAs: Flex, container: { direction: 'column' }, ref: previewRef, open: open && isSmallOrAbove, position: 'fixed', placement: direction.end, "aria-label": t('preview_of_noun', [heading]), size: resizeDrawerDefaultWidth, resizeable: true, shadow: true, nullWhenClosed: true, children: [_jsx(StyledPreviewActions, { fixedHeaderHeight: !!error || !!progress, progressActive: progressActive, children: _jsx(Button, { "data-testid": testIds.close, variant: 'simple', icon: true, onClick: closePreview, ref: setCloseButtonEl, label: t('close_preview'), children: _jsx(Icon, { name: 'times' }) }) }), _jsx(Progress, { placement: 'local', visible: !!progress, focusOnVisible: true, delay: true, onTransitionStartIn: () => {
158
- setProgressActive(true);
136
+ }, as: StyledPreviewDrawer, role: 'complementary', forwardedAs: Flex, container: { direction: 'column' }, ref: previewRef, open: open && isSmallOrAbove, position: 'fixed', placement: direction.end, "aria-label": t('preview_of_noun', [heading]), size: resizeDrawerDefaultWidth, resizeable: true, shadow: true, nullWhenClosed: true, children: [_jsx(StyledCloseButton, { "data-testid": testIds.close, icon: true, compact: true, onClick: closePreview, ref: setCloseButtonEl, label: t('close_preview'), children: _jsx(Icon, { name: 'times' }) }), _jsx(Progress, { placement: 'local', visible: !!progress, focusOnVisible: true, delay: true, onTransitionStartIn: () => {
159
137
  setProgressVisible(true);
160
- }, onTransitionStartOut: () => setProgressActive(false), onTransitionEndOut: () => setProgressVisible(false) }), !progress && content] }));
138
+ }, onTransitionEndOut: () => setProgressVisible(false) }), !progress && content] }));
161
139
  });
162
140
  export default withTestIds(CasePreview, getCasePreviewTestIds);
163
141
  //# sourceMappingURL=CasePreview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CasePreview.js","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,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C;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback, useEffect, useContext } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Drawer,\n Icon,\n registerIcon,\n Button,\n Flex,\n defaultThemeProp,\n useBreakpoint,\n useElement,\n useDirection,\n useI18n,\n AppShellContext,\n useTestIds,\n withTestIds,\n Progress,\n ErrorState,\n getFocusables,\n useConsolidatedRef,\n StyledButton,\n calculateForegroundColor,\n useFocusTrap,\n readableHue\n} from '@pega/cosmos-react-core';\nimport type {\n ForwardRefForwardPropsComponent,\n BaseProps,\n TestIdProp,\n NoChildrenProp,\n ErrorStateProps\n} from '@pega/cosmos-react-core';\nimport { resizeDrawerDefaultWidth } from '@pega/cosmos-react-core/lib/styles/constants';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport CaseView, {\n StyledCaseView,\n StyledCaseViewContent,\n StyledCaseDrawer,\n StyledSummaryRegion\n} from '../CaseView';\nimport type { CaseViewProps } from '../CaseView';\nimport type { CaseViewContextValue } from '../CaseView/CaseView.types';\nimport { StyledGenAICoachContainer } from '../GenAICoach/GenAICoach.styles';\nimport { StyledCaseHeader } from '../CaseView/CaseView.styles';\n\nimport { getCasePreviewTestIds } from './CasePreview.test-ids';\n\nregisterIcon(timesIcon);\n\nexport interface CasePreviewProps\n extends Pick<\n CaseViewProps,\n | 'caseId'\n | 'caseType'\n | 'heading'\n | 'subheading'\n | 'parentCases'\n | 'icon'\n | 'followed'\n | 'onFollowedChange'\n | 'actions'\n | 'promotedActions'\n | 'onEdit'\n | 'summaryFields'\n | 'tabs'\n | 'tabContent'\n | 'stages'\n | 'tasks'\n | 'banners'\n | 'utilities'\n | 'utilitiesSummaryItems'\n >,\n NoChildrenProp,\n TestIdProp,\n BaseProps {\n /** A set of props including an href that will be forwarded to the case preview's heading and subheading. */\n caseLink?: CaseViewContextValue['caseLink'];\n /** If true, the Case Preview will be visible. */\n open: boolean;\n /** If true, the Case Preview will render in a progress state. */\n progress?: boolean;\n /** If true, the Case Preview will render in an error state. */\n error?: boolean;\n /** Callback fired when \"Try again\" button is clicked in an error state. */\n onErrorRetry?: ErrorStateProps['onRetry'];\n /** Callback fired before Case Preview opens. */\n onBeforeOpen?: () => void;\n /** Callback fired after Case Preview opens. */\n onAfterOpen?: () => void;\n /** Callback fired before Case Preview closes. */\n onBeforeClose?: () => void;\n /** Callback fired after Case Preview closes. */\n onAfterClose?: () => void;\n /** Callback fired when a click action occurs outside of the Case Preview. */\n onOuterClick?: () => void;\n /** Reference to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledPreviewHeader = styled.div(({ theme }) => {\n return css`\n z-index: ${theme.base['z-index'].drawer};\n background-color: ${theme.base.palette['primary-background']};\n `;\n});\n\nStyledPreviewHeader.defaultProps = defaultThemeProp;\n\nconst StyledPreviewActions = styled.div<{\n fixedHeaderHeight?: boolean;\n progressActive?: boolean;\n}>(\n ({\n theme: {\n base: {\n spacing,\n 'z-index': { backdrop, popover }\n },\n components: {\n 'case-view': {\n header: { background, 'foreground-color': color }\n }\n }\n },\n fixedHeaderHeight,\n progressActive\n }) => {\n const foregroundColor = calculateForegroundColor(background, color);\n\n return css`\n color: ${foregroundColor};\n padding: ${spacing} calc(2 * ${spacing}) calc(0.25 * ${spacing});\n\n ${fixedHeaderHeight\n ? css`\n background: ${background};\n `\n : css`\n position: absolute;\n z-index: ${popover + 1};\n `}\n\n ${StyledButton} {\n color: ${foregroundColor};\n\n ${progressActive &&\n css`\n z-index: ${backdrop + 1};\n color: ${foregroundColor};\n `}\n }\n\n ${fixedHeaderHeight &&\n css`\n min-height: 6.625rem;\n `}\n `;\n }\n);\n\nStyledPreviewActions.defaultProps = defaultThemeProp;\n\nconst StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['app-background']};\n height: calc(100vh - var(--appshell-offset, 0rem));\n top: var(--appshell-offset, 0);\n z-index: calc(${theme.base['z-index'].drawer} + 500);\n transition-property: transform, box-shadow, opacity, border-inline-start;\n transition-duration: max(${theme.base.animation.speed}, 0.0001s);\n transition-timing-function: ${theme.base.animation.timing.ease};\n\n ${StyledCaseView} {\n height: calc(100vh - ${theme.base.spacing} - ${theme.base['hit-area']['mouse-min']});\n\n @media (pointer: coarse) {\n height: calc(100vh - ${theme.base.spacing} - ${theme.base['hit-area']['finger-min']});\n }\n\n ${StyledCaseHeader} {\n padding-block-start: calc(\n (2.25 * ${theme.base.spacing}) + ${theme.base['hit-area']['mouse-min']}\n );\n\n @media (pointer: coarse) {\n padding-block-start: calc(\n (2.25 * ${theme.base.spacing}) + ${theme.base['hit-area']['finger-min']}\n );\n }\n }\n\n ${StyledSummaryRegion} {\n position: relative;\n top: 0;\n }\n }\n\n ${StyledCaseViewContent} {\n overflow-y: auto;\n\n & > :last-child {\n padding-bottom: calc(2 * ${theme.base.spacing});\n }\n }\n\n ${StyledGenAICoachContainer} {\n width: unset;\n min-width: unset;\n }\n\n @media (min-width: ${theme.base.breakpoints.xl}) {\n box-shadow: none;\n border-inline-start: 0.0625rem solid\n ${readableHue(theme.base.palette['border-line'], theme.base.palette['app-background'], {\n mode: 'both',\n level: 'AANonText'\n })};\n }\n `;\n});\n\nStyledPreviewDrawer.defaultProps = defaultThemeProp;\n\nconst CasePreview: ForwardRefForwardPropsComponent<CasePreviewProps> = forwardRef(\n function CasePreview(props: PropsWithoutRef<CasePreviewProps>, ref: CasePreviewProps['ref']) {\n const {\n testId,\n open: openProp,\n progress,\n error,\n onErrorRetry,\n caseId,\n caseType,\n heading,\n subheading,\n caseLink,\n parentCases,\n icon,\n followed,\n onFollowedChange,\n summaryFields,\n tabs,\n stages,\n tasks,\n tabContent,\n utilities,\n utilitiesSummaryItems,\n actions,\n banners,\n onEdit,\n onBeforeOpen,\n onAfterOpen,\n onBeforeClose,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getCasePreviewTestIds);\n\n const t = useI18n();\n const previewRef = useConsolidatedRef(ref);\n\n const { previewTriggerRef, setPreviewActive } = useContext(AppShellContext);\n const [closeButtonEl, setCloseButtonEl] = useElement<HTMLButtonElement>();\n const isSmallOrAbove = useBreakpoint('sm');\n const [open, setOpen] = useState(openProp);\n const [progressActive, setProgressActive] = useState(false);\n const [progressVisible, setProgressVisible] = useState(false);\n const direction = useDirection();\n\n const closePreview = useCallback(() => {\n setOpen(false);\n previewTriggerRef.current?.focus();\n }, []);\n\n const setFocus = () => {\n if (progressVisible) return;\n\n const focusables = getFocusables(previewRef).filter(el => el !== closeButtonEl);\n const focusable = focusables[0] ?? closeButtonEl;\n focusable?.focus();\n };\n\n useEffect(() => {\n setOpen(openProp);\n }, [openProp]);\n\n useEffect(() => {\n if (!progressVisible) {\n setFocus();\n }\n }, [progressVisible]);\n\n useEffect(() => {\n return () => {\n setPreviewActive(false);\n };\n }, []);\n\n useFocusTrap(previewRef, true, [], false);\n\n const content = error ? (\n <ErrorState message={t('preview_error')} onRetry={onErrorRetry} />\n ) : (\n <CaseView\n caseId={caseId}\n caseType={caseType}\n parentCases={parentCases}\n heading={heading}\n subheading={subheading}\n caseLink={caseLink}\n icon={icon}\n followed={followed}\n onFollowedChange={onFollowedChange}\n summaryFields={summaryFields}\n tabs={tabs}\n stages={stages}\n tasks={tasks}\n tabContent={tabContent}\n utilities={utilities}\n utilitiesSummaryItems={utilitiesSummaryItems}\n actions={actions}\n banners={banners}\n onEdit={onEdit}\n isPreview\n />\n );\n\n return (\n <Drawer\n data-testid={testIds.root}\n {...restProps}\n onBeforeOpen={() => {\n setPreviewActive(true);\n onBeforeOpen?.();\n }}\n onAfterOpen={() => {\n setFocus();\n onAfterOpen?.();\n }}\n onBeforeClose={() => {\n setPreviewActive(false);\n onBeforeClose?.();\n }}\n as={StyledPreviewDrawer}\n role='complementary'\n forwardedAs={Flex}\n container={{ direction: 'column' }}\n ref={previewRef}\n open={open && isSmallOrAbove}\n position='fixed'\n placement={direction.end}\n aria-label={t('preview_of_noun', [heading])}\n size={resizeDrawerDefaultWidth}\n resizeable\n shadow\n nullWhenClosed\n >\n <StyledPreviewActions\n fixedHeaderHeight={!!error || !!progress}\n progressActive={progressActive}\n >\n <Button\n data-testid={testIds.close}\n variant='simple'\n icon\n onClick={closePreview}\n ref={setCloseButtonEl}\n label={t('close_preview')}\n >\n <Icon name='times' />\n </Button>\n </StyledPreviewActions>\n\n <Progress\n placement='local'\n visible={!!progress}\n focusOnVisible\n delay\n onTransitionStartIn={() => {\n setProgressActive(true);\n setProgressVisible(true);\n }}\n onTransitionStartOut={() => setProgressActive(false)}\n onTransitionEndOut={() => setProgressVisible(false)}\n />\n\n {!progress && content}\n </Drawer>\n );\n }\n);\n\nexport default withTestIds(CasePreview, getCasePreviewTestIds);\n"]}
1
+ {"version":3,"file":"CasePreview.js","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,OAAO,EACP,eAAe,EACf,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,UAAU,EACX,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAEhG,OAAO,QAAQ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AAW,EAAE,EAAE,CAAC;QAClB,CAAC,EACD,aAAa,EAAE,GAAG,EAAE;YAClB,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACxB,aAAa,EAAE,EAAE,CAAC;QACpB,CAAC,EACD,EAAE,EAAE,mBAAmB,EACvB,IAAI,EAAC,eAAe,EACpB,WAAW,EAAE,IAAI,EACjB,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,IAAI,IAAI,cAAc,EAC5B,QAAQ,EAAC,OAAO,EAChB,SAAS,EAAE,SAAS,CAAC,GAAG,gBACZ,CAAC,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC,EAC3C,IAAI,EAAE,wBAAwB,EAC9B,UAAU,QACV,MAAM,QACN,cAAc,mBAEd,KAAC,iBAAiB,mBACH,OAAO,CAAC,KAAK,EAC1B,IAAI,QACJ,OAAO,QACP,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,CAAC,CAAC,eAAe,CAAC,YAEzB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACH,EAEpB,KAAC,QAAQ,IACP,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,CAAC,CAAC,QAAQ,EACnB,cAAc,QACd,KAAK,QACL,mBAAmB,EAAE,GAAG,EAAE;oBACxB,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBAC3B,CAAC,EACD,kBAAkB,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,GACnD,EAED,CAAC,QAAQ,IAAI,OAAO,IACd,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback, useEffect, useContext } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Drawer,\n Icon,\n registerIcon,\n Flex,\n defaultThemeProp,\n useBreakpoint,\n useElement,\n useDirection,\n useI18n,\n AppShellContext,\n useTestIds,\n withTestIds,\n Progress,\n ErrorState,\n getFocusables,\n useConsolidatedRef,\n useFocusTrap,\n readableHue,\n StyledIcon\n} from '@pega/cosmos-react-core';\nimport type {\n ForwardRefForwardPropsComponent,\n BaseProps,\n TestIdProp,\n NoChildrenProp,\n ErrorStateProps\n} from '@pega/cosmos-react-core';\nimport { resizeDrawerDefaultWidth } from '@pega/cosmos-react-core/lib/styles/constants';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport { StyledResizeHandle } from '@pega/cosmos-react-core/lib/components/Drawer/ResizeHandle';\n\nimport CaseView, {\n StyledCaseView,\n StyledCaseViewContent,\n StyledCaseDrawer,\n StyledSummaryRegion\n} from '../CaseView';\nimport type { CaseViewProps } from '../CaseView';\nimport type { CaseViewContextValue } from '../CaseView/CaseView.types';\nimport { StyledGenAICoachContainer } from '../GenAICoach/GenAICoach.styles';\nimport { StyledExpandCollapseButton } from '../CaseView/CaseView.styles';\n\nimport { getCasePreviewTestIds } from './CasePreview.test-ids';\n\nregisterIcon(timesIcon);\n\nexport interface CasePreviewProps\n extends Pick<\n CaseViewProps,\n | 'caseId'\n | 'caseType'\n | 'heading'\n | 'subheading'\n | 'parentCases'\n | 'icon'\n | 'followed'\n | 'onFollowedChange'\n | 'actions'\n | 'promotedActions'\n | 'onEdit'\n | 'summaryFields'\n | 'tabs'\n | 'tabContent'\n | 'stages'\n | 'tasks'\n | 'banners'\n | 'utilities'\n | 'utilitiesSummaryItems'\n >,\n NoChildrenProp,\n TestIdProp,\n BaseProps {\n /** A set of props including an href that will be forwarded to the case preview's heading and subheading. */\n caseLink?: CaseViewContextValue['caseLink'];\n /** If true, the Case Preview will be visible. */\n open: boolean;\n /** If true, the Case Preview will render in a progress state. */\n progress?: boolean;\n /** If true, the Case Preview will render in an error state. */\n error?: boolean;\n /** Callback fired when \"Try again\" button is clicked in an error state. */\n onErrorRetry?: ErrorStateProps['onRetry'];\n /** Callback fired before Case Preview opens. */\n onBeforeOpen?: () => void;\n /** Callback fired after Case Preview opens. */\n onAfterOpen?: () => void;\n /** Callback fired before Case Preview closes. */\n onBeforeClose?: () => void;\n /** Callback fired after Case Preview closes. */\n onAfterClose?: () => void;\n /** Callback fired when a click action occurs outside of the Case Preview. */\n onOuterClick?: () => void;\n /** Reference to the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['app-background']};\n height: calc(100vh - var(--appshell-offset, 0rem));\n top: var(--appshell-offset, 0);\n z-index: calc(${theme.base['z-index'].drawer} + 500);\n transition-property: transform, box-shadow, opacity, border-inline-start;\n transition-duration: max(${theme.base.animation.speed}, 0.0001s);\n transition-timing-function: ${theme.base.animation.timing.ease};\n\n ${StyledResizeHandle} {\n z-index: calc(${theme.base['z-index'].max - 1});\n }\n\n ${StyledCaseView} {\n height: calc(100vh - ${theme.base.spacing} - ${theme.base['hit-area']['mouse-min']});\n z-index: 1;\n\n @media (pointer: coarse) {\n height: calc(100vh - ${theme.base.spacing} - ${theme.base['hit-area']['finger-min']});\n }\n\n ${StyledSummaryRegion} {\n position: relative;\n top: 0;\n }\n }\n\n ${StyledCaseViewContent} {\n overflow-y: auto;\n\n & > :last-child {\n padding-bottom: calc(2 * ${theme.base.spacing});\n }\n }\n\n ${StyledGenAICoachContainer} {\n width: unset;\n min-width: unset;\n }\n\n @media (min-width: ${theme.base.breakpoints.xl}) {\n box-shadow: none;\n border-inline-start: 0.0625rem solid\n ${readableHue(theme.base.palette['border-line'], theme.base.palette['app-background'], {\n mode: 'both',\n level: 'AANonText'\n })};\n }\n `;\n});\n\nStyledPreviewDrawer.defaultProps = defaultThemeProp;\n\nconst StyledCloseButton = styled(StyledExpandCollapseButton)(({ theme }) => {\n return css`\n --half-btn-compact-difference: calc(\n (${theme.base['hit-area'].mouse} - ${theme.base['hit-area'].compact}) / 2\n );\n @media (pointer: coarse) {\n --half-btn-compact-difference: calc(\n (${theme.base['hit-area'].finger} - ${theme.base['hit-area'].compact}) / 2\n );\n }\n position: absolute;\n\n /* Places above CaseHeader and resize handle */\n z-index: ${theme.base['z-index'].max};\n box-shadow: ${theme.base.shadow.low};\n inset-inline-start: calc(-${theme.base['hit-area'].compact} / 2);\n inset-block-start: calc(2 * ${theme.base.spacing} + var(--half-btn-compact-difference));\n\n & > ${StyledIcon} {\n inline-size: 1em;\n block-size: 1em;\n }\n `;\n});\n\nStyledCloseButton.defaultProps = defaultThemeProp;\n\nconst CasePreview: ForwardRefForwardPropsComponent<CasePreviewProps> = forwardRef(\n function CasePreview(props: PropsWithoutRef<CasePreviewProps>, ref: CasePreviewProps['ref']) {\n const {\n testId,\n open: openProp,\n progress,\n error,\n onErrorRetry,\n caseId,\n caseType,\n heading,\n subheading,\n caseLink,\n parentCases,\n icon,\n followed,\n onFollowedChange,\n summaryFields,\n tabs,\n stages,\n tasks,\n tabContent,\n utilities,\n utilitiesSummaryItems,\n actions,\n banners,\n onEdit,\n onBeforeOpen,\n onAfterOpen,\n onBeforeClose,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getCasePreviewTestIds);\n\n const t = useI18n();\n const previewRef = useConsolidatedRef(ref);\n\n const { previewTriggerRef, setPreviewActive } = useContext(AppShellContext);\n const [closeButtonEl, setCloseButtonEl] = useElement<HTMLButtonElement>();\n const isSmallOrAbove = useBreakpoint('sm');\n const [open, setOpen] = useState(openProp);\n const [progressVisible, setProgressVisible] = useState(false);\n const direction = useDirection();\n\n const closePreview = useCallback(() => {\n setOpen(false);\n previewTriggerRef.current?.focus();\n }, []);\n\n const setFocus = () => {\n if (progressVisible) return;\n\n const focusables = getFocusables(previewRef).filter(el => el !== closeButtonEl);\n const focusable = focusables[0] ?? closeButtonEl;\n focusable?.focus();\n };\n\n useEffect(() => {\n setOpen(openProp);\n }, [openProp]);\n\n useEffect(() => {\n if (!progressVisible) {\n setFocus();\n }\n }, [progressVisible]);\n\n useEffect(() => {\n return () => {\n setPreviewActive(false);\n };\n }, []);\n\n useFocusTrap(previewRef, true, [], false);\n\n const content = error ? (\n <ErrorState message={t('preview_error')} onRetry={onErrorRetry} />\n ) : (\n <CaseView\n caseId={caseId}\n caseType={caseType}\n parentCases={parentCases}\n heading={heading}\n subheading={subheading}\n caseLink={caseLink}\n icon={icon}\n followed={followed}\n onFollowedChange={onFollowedChange}\n summaryFields={summaryFields}\n tabs={tabs}\n stages={stages}\n tasks={tasks}\n tabContent={tabContent}\n utilities={utilities}\n utilitiesSummaryItems={utilitiesSummaryItems}\n actions={actions}\n banners={banners}\n onEdit={onEdit}\n isPreview\n />\n );\n\n return (\n <Drawer\n data-testid={testIds.root}\n {...restProps}\n onBeforeOpen={() => {\n setPreviewActive(true);\n onBeforeOpen?.();\n }}\n onAfterOpen={() => {\n setFocus();\n onAfterOpen?.();\n }}\n onBeforeClose={() => {\n setPreviewActive(false);\n onBeforeClose?.();\n }}\n as={StyledPreviewDrawer}\n role='complementary'\n forwardedAs={Flex}\n container={{ direction: 'column' }}\n ref={previewRef}\n open={open && isSmallOrAbove}\n position='fixed'\n placement={direction.end}\n aria-label={t('preview_of_noun', [heading])}\n size={resizeDrawerDefaultWidth}\n resizeable\n shadow\n nullWhenClosed\n >\n <StyledCloseButton\n data-testid={testIds.close}\n icon\n compact\n onClick={closePreview}\n ref={setCloseButtonEl}\n label={t('close_preview')}\n >\n <Icon name='times' />\n </StyledCloseButton>\n\n <Progress\n placement='local'\n visible={!!progress}\n focusOnVisible\n delay\n onTransitionStartIn={() => {\n setProgressVisible(true);\n }}\n onTransitionEndOut={() => setProgressVisible(false)}\n />\n\n {!progress && content}\n </Drawer>\n );\n }\n);\n\nexport default withTestIds(CasePreview, getCasePreviewTestIds);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UtilitiesSummary.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/UtilitiesSummary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAoB3D,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,kBAAkB,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,wGAsBjC,CAAC;AAoHH,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAoE9D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"UtilitiesSummary.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/UtilitiesSummary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAqB3D,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,kBAAkB,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;IAC/C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,wGAsBjC,CAAC;AAsHH,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAoE9D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useMemo, useState } from 'react';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { mix } from 'polished';
6
- import { Button, Card, Count, Flex, Icon, Tooltip, Alert, useI18n, VisuallyHiddenText, useElement, tryCatch, defaultThemeProp, usePrevious } from '@pega/cosmos-react-core';
6
+ import { Button, Card, Count, Flex, Icon, Tooltip, Alert, useI18n, VisuallyHiddenText, useElement, tryCatch, defaultThemeProp, usePrevious, useDirection } from '@pega/cosmos-react-core';
7
7
  export const StyledUtilitiesSummary = styled.ul(({ theme }) => {
8
8
  const { base: { 'border-radius': borderRadius } } = theme;
9
9
  return css `
@@ -84,6 +84,7 @@ const getUpdatedItems = (previousItems, currentItems) => {
84
84
  };
85
85
  const UtilitySummary = ({ name, iconName, count, onClick, showNotification }) => {
86
86
  const t = useI18n();
87
+ const { start } = useDirection();
87
88
  const [utilSummaryTooltip, setUtilSummaryTooltip] = useElement();
88
89
  return (
89
90
  // Default role is removed by "list-style: none" on StyledUtilitiesSummary.
@@ -92,7 +93,7 @@ const UtilitySummary = ({ name, iconName, count, onClick, showNotification }) =>
92
93
  direction: 'column',
93
94
  alignItems: 'center',
94
95
  gap: 0.5
95
- }, onClick: onClick, ref: setUtilSummaryTooltip, as: StyledUtilitySummaryButton, children: [_jsx(Icon, { name: iconName }), count !== undefined && _jsx(Count, { "aria-hidden": true, children: count }), _jsx(VisuallyHiddenText, { children: `${count ?? ''} ${name}` }), showNotification && (_jsx(StyledNotification, { variant: 'urgent', "aria-label": t('update_available') }))] }), _jsx(Tooltip, { target: utilSummaryTooltip, showDelay: 'none', hideDelay: 'none', children: name })] }));
96
+ }, onClick: onClick, ref: setUtilSummaryTooltip, as: StyledUtilitySummaryButton, children: [_jsx(Icon, { name: iconName }), count !== undefined && _jsx(Count, { "aria-hidden": true, children: count }), _jsx(VisuallyHiddenText, { children: `${count ?? ''} ${name}` }), showNotification && (_jsx(StyledNotification, { variant: 'urgent', "aria-label": t('update_available') }))] }), _jsx(Tooltip, { target: utilSummaryTooltip, showDelay: 'none', hideDelay: 'none', placement: start, children: name })] }));
96
97
  };
97
98
  const UtilitiesSummary = ({ items = [], isExpanded = false }) => {
98
99
  const t = useI18n();
@@ -1 +1 @@
1
- {"version":3,"file":"UtilitiesSummary.js","sourceRoot":"","sources":["../../../src/components/CaseView/UtilitiesSummary.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,Q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I,EAAC,MAAM,YAEV,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChB,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtE,OAAO,CACL,eAAC,cAAc,OACT,IAAI,EACR,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,gBAAgB,EAAE,cAAc,EAChC,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;oBAC5C,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;oBAClB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACvB,CAAC,GACD,CACH,CAAC;QACJ,CAAC,CAAC,GACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { useEffect, useMemo, useState } from 'react';\nimport type { FunctionComponent, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport {\n Button,\n Card,\n Count,\n Flex,\n Icon,\n Tooltip,\n Alert,\n useI18n,\n VisuallyHiddenText,\n useElement,\n tryCatch,\n defaultThemeProp,\n usePrevious\n} from '@pega/cosmos-react-core';\n\nimport type { CaseViewProps, UtilitySummaryItem } from './CaseView.types';\n\nexport interface UtilitiesSummaryProps {\n items?: CaseViewProps['utilitiesSummaryItems'];\n isExpanded?: boolean;\n}\n\nexport const StyledUtilitiesSummary = styled.ul(({ theme }) => {\n const {\n base: { 'border-radius': borderRadius }\n } = theme;\n return css`\n width: 2.75rem;\n list-style: none;\n\n > li {\n display: contents;\n\n &:first-child {\n border-start-start-radius: var(--border-radius, ${borderRadius});\n border-start-end-radius: var(--border-radius, ${borderRadius});\n }\n\n &:last-child {\n border-end-start-radius: var(--border-radius, ${borderRadius});\n border-end-end-radius: var(--border-radius, ${borderRadius});\n }\n }\n `;\n});\n\nStyledUtilitiesSummary.defaultProps = defaultThemeProp;\n\nconst StyledUtilitySummaryButton = styled(Button)(({\n theme: {\n base: { palette, spacing }\n }\n}) => {\n const hoverBackground = tryCatch(() =>\n mix(0.9, palette['primary-background'], palette['foreground-color'])\n );\n return css`\n padding-block: ${spacing};\n padding-inline: 0;\n width: 100%;\n color: currentColor;\n border-radius: unset;\n border: none;\n background: ${palette['primary-background']};\n\n & + & {\n margin: 0;\n }\n\n &:hover {\n background: ${hoverBackground};\n color: currentColor;\n }\n\n &:focus {\n z-index: 1;\n }\n\n &:first-child {\n border-start-start-radius: inherit;\n border-start-end-radius: inherit;\n }\n\n &:last-child {\n border-end-start-radius: inherit;\n border-end-end-radius: inherit;\n }\n `;\n});\n\nStyledUtilitySummaryButton.defaultProps = defaultThemeProp;\n\nconst StyledNotification = styled(Alert)(({ theme }) => {\n return css`\n position: absolute;\n inset-block-start: calc(0.5 * ${theme.base.spacing});\n inset-inline-start: calc(3.5 * ${theme.base.spacing});\n `;\n});\nStyledNotification.defaultProps = defaultThemeProp;\n\nconst getUpdatedItems = (\n previousItems: UtilitySummaryItem[],\n currentItems: UtilitySummaryItem[]\n): UtilitySummaryItem[] => {\n const updatedItems: UtilitySummaryItem[] = [];\n\n for (const item of currentItems) {\n const prevItem = previousItems.find(({ id }) => item.id === id);\n\n if (\n prevItem?.count !== undefined &&\n prevItem.count !== item.count &&\n !(prevItem.count === 0 && item.count === 0)\n ) {\n updatedItems.push(item);\n }\n }\n\n return updatedItems;\n};\n\nconst UtilitySummary: FunctionComponent<UtilitySummaryItem> = ({\n name,\n iconName,\n count,\n onClick,\n showNotification\n}) => {\n const t = useI18n();\n const [utilSummaryTooltip, setUtilSummaryTooltip] = useElement<HTMLElement>();\n return (\n // Default role is removed by \"list-style: none\" on StyledUtilitiesSummary.\n // eslint-disable-next-line jsx-a11y/no-redundant-roles\n <li role='listitem'>\n <Flex\n container={{\n direction: 'column',\n alignItems: 'center',\n gap: 0.5\n }}\n onClick={onClick}\n ref={setUtilSummaryTooltip}\n as={StyledUtilitySummaryButton}\n >\n <Icon name={iconName} />\n {count !== undefined && <Count aria-hidden>{count}</Count>}\n <VisuallyHiddenText>{`${count ?? ''} ${name}`}</VisuallyHiddenText>\n {showNotification && (\n <StyledNotification variant='urgent' aria-label={t('update_available')} />\n )}\n </Flex>\n\n <Tooltip target={utilSummaryTooltip} showDelay='none' hideDelay='none'>\n {name}\n </Tooltip>\n </li>\n );\n};\n\nconst UtilitiesSummary: FunctionComponent<UtilitiesSummaryProps> = ({\n items = [],\n isExpanded = false\n}) => {\n const t = useI18n();\n const previousData = usePrevious(items);\n const updatedItems = useMemo(() => {\n return isExpanded ? [] : getUpdatedItems(previousData ?? [], items);\n }, [items, isExpanded, previousData]);\n const [notification, setNotification] = useState<Set<string>>(new Set());\n\n useEffect(() => {\n if (isExpanded && notification.size > 0) {\n setNotification(new Set());\n }\n }, [isExpanded, notification]);\n\n useEffect(() => {\n if (!updatedItems.length) return;\n\n setNotification(prev => {\n const newSet = new Set(prev);\n let hasChanged = false;\n\n updatedItems.forEach(item => {\n if ((item.count ?? 0) > 0 && !newSet.has(item.id)) {\n newSet.add(item.id);\n hasChanged = true;\n }\n });\n\n return hasChanged ? newSet : prev;\n });\n }, [updatedItems]);\n\n const handleClick = (id: string) => {\n setNotification(prev => {\n const newSet = new Set(prev);\n if (newSet.has(id)) {\n newSet.delete(id);\n }\n return newSet;\n });\n };\n\n return (\n <Card\n container={{ direction: 'column', alignItems: 'center' }}\n as={StyledUtilitiesSummary}\n aria-label={t('utilities_summary')}\n role='list'\n >\n {items.map(item => {\n const isCountUpdated = isExpanded ? false : notification.has(item.id);\n return (\n <UtilitySummary\n {...item}\n key={item.iconName}\n showNotification={isCountUpdated}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n item.onClick?.(e);\n handleClick(item.id);\n }}\n />\n );\n })}\n </Card>\n );\n};\n\nexport default UtilitiesSummary;\n"]}
1
+ {"version":3,"file":"UtilitiesSummary.js","sourceRoot":"","sources":["../../../src/components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IAEF,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EACxD,EAAE,EAAE,sBAAsB,gBACd,CAAC,CAAC,mBAAmB,CAAC,EAClC,IAAI,EAAC,MAAM,YAEV,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAChB,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtE,OAAO,CACL,eAAC,cAAc,OACT,IAAI,EACR,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,gBAAgB,EAAE,cAAc,EAChC,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;oBAC5C,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;oBAClB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACvB,CAAC,GACD,CACH,CAAC;QACJ,CAAC,CAAC,GACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { useEffect, useMemo, useState } from 'react';\nimport type { FunctionComponent, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport {\n Button,\n Card,\n Count,\n Flex,\n Icon,\n Tooltip,\n Alert,\n useI18n,\n VisuallyHiddenText,\n useElement,\n tryCatch,\n defaultThemeProp,\n usePrevious,\n useDirection\n} from '@pega/cosmos-react-core';\n\nimport type { CaseViewProps, UtilitySummaryItem } from './CaseView.types';\n\nexport interface UtilitiesSummaryProps {\n items?: CaseViewProps['utilitiesSummaryItems'];\n isExpanded?: boolean;\n}\n\nexport const StyledUtilitiesSummary = styled.ul(({ theme }) => {\n const {\n base: { 'border-radius': borderRadius }\n } = theme;\n return css`\n width: 2.75rem;\n list-style: none;\n\n > li {\n display: contents;\n\n &:first-child {\n border-start-start-radius: var(--border-radius, ${borderRadius});\n border-start-end-radius: var(--border-radius, ${borderRadius});\n }\n\n &:last-child {\n border-end-start-radius: var(--border-radius, ${borderRadius});\n border-end-end-radius: var(--border-radius, ${borderRadius});\n }\n }\n `;\n});\n\nStyledUtilitiesSummary.defaultProps = defaultThemeProp;\n\nconst StyledUtilitySummaryButton = styled(Button)(({\n theme: {\n base: { palette, spacing }\n }\n}) => {\n const hoverBackground = tryCatch(() =>\n mix(0.9, palette['primary-background'], palette['foreground-color'])\n );\n return css`\n padding-block: ${spacing};\n padding-inline: 0;\n width: 100%;\n color: currentColor;\n border-radius: unset;\n border: none;\n background: ${palette['primary-background']};\n\n & + & {\n margin: 0;\n }\n\n &:hover {\n background: ${hoverBackground};\n color: currentColor;\n }\n\n &:focus {\n z-index: 1;\n }\n\n &:first-child {\n border-start-start-radius: inherit;\n border-start-end-radius: inherit;\n }\n\n &:last-child {\n border-end-start-radius: inherit;\n border-end-end-radius: inherit;\n }\n `;\n});\n\nStyledUtilitySummaryButton.defaultProps = defaultThemeProp;\n\nconst StyledNotification = styled(Alert)(({ theme }) => {\n return css`\n position: absolute;\n inset-block-start: calc(0.5 * ${theme.base.spacing});\n inset-inline-start: calc(3.5 * ${theme.base.spacing});\n `;\n});\nStyledNotification.defaultProps = defaultThemeProp;\n\nconst getUpdatedItems = (\n previousItems: UtilitySummaryItem[],\n currentItems: UtilitySummaryItem[]\n): UtilitySummaryItem[] => {\n const updatedItems: UtilitySummaryItem[] = [];\n\n for (const item of currentItems) {\n const prevItem = previousItems.find(({ id }) => item.id === id);\n\n if (\n prevItem?.count !== undefined &&\n prevItem.count !== item.count &&\n !(prevItem.count === 0 && item.count === 0)\n ) {\n updatedItems.push(item);\n }\n }\n\n return updatedItems;\n};\n\nconst UtilitySummary: FunctionComponent<UtilitySummaryItem> = ({\n name,\n iconName,\n count,\n onClick,\n showNotification\n}) => {\n const t = useI18n();\n const { start } = useDirection();\n const [utilSummaryTooltip, setUtilSummaryTooltip] = useElement<HTMLElement>();\n\n return (\n // Default role is removed by \"list-style: none\" on StyledUtilitiesSummary.\n // eslint-disable-next-line jsx-a11y/no-redundant-roles\n <li role='listitem'>\n <Flex\n container={{\n direction: 'column',\n alignItems: 'center',\n gap: 0.5\n }}\n onClick={onClick}\n ref={setUtilSummaryTooltip}\n as={StyledUtilitySummaryButton}\n >\n <Icon name={iconName} />\n {count !== undefined && <Count aria-hidden>{count}</Count>}\n <VisuallyHiddenText>{`${count ?? ''} ${name}`}</VisuallyHiddenText>\n {showNotification && (\n <StyledNotification variant='urgent' aria-label={t('update_available')} />\n )}\n </Flex>\n\n <Tooltip target={utilSummaryTooltip} showDelay='none' hideDelay='none' placement={start}>\n {name}\n </Tooltip>\n </li>\n );\n};\n\nconst UtilitiesSummary: FunctionComponent<UtilitiesSummaryProps> = ({\n items = [],\n isExpanded = false\n}) => {\n const t = useI18n();\n const previousData = usePrevious(items);\n const updatedItems = useMemo(() => {\n return isExpanded ? [] : getUpdatedItems(previousData ?? [], items);\n }, [items, isExpanded, previousData]);\n const [notification, setNotification] = useState<Set<string>>(new Set());\n\n useEffect(() => {\n if (isExpanded && notification.size > 0) {\n setNotification(new Set());\n }\n }, [isExpanded, notification]);\n\n useEffect(() => {\n if (!updatedItems.length) return;\n\n setNotification(prev => {\n const newSet = new Set(prev);\n let hasChanged = false;\n\n updatedItems.forEach(item => {\n if ((item.count ?? 0) > 0 && !newSet.has(item.id)) {\n newSet.add(item.id);\n hasChanged = true;\n }\n });\n\n return hasChanged ? newSet : prev;\n });\n }, [updatedItems]);\n\n const handleClick = (id: string) => {\n setNotification(prev => {\n const newSet = new Set(prev);\n if (newSet.has(id)) {\n newSet.delete(id);\n }\n return newSet;\n });\n };\n\n return (\n <Card\n container={{ direction: 'column', alignItems: 'center' }}\n as={StyledUtilitiesSummary}\n aria-label={t('utilities_summary')}\n role='list'\n >\n {items.map(item => {\n const isCountUpdated = isExpanded ? false : notification.has(item.id);\n return (\n <UtilitySummary\n {...item}\n key={item.iconName}\n showNotification={isCountUpdated}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n item.onClick?.(e);\n handleClick(item.id);\n }}\n />\n );\n })}\n </Card>\n );\n};\n\nexport default UtilitiesSummary;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-work",
3
- "version": "9.0.0-build.9.11",
3
+ "version": "9.0.0-build.9.12",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "Pegasystems",
6
6
  "sideEffects": false,
@@ -14,8 +14,8 @@
14
14
  "build": "tsc -b tsconfig.build.json"
15
15
  },
16
16
  "dependencies": {
17
- "@pega/cosmos-react-core": "9.0.0-build.9.11",
18
- "@pega/cosmos-react-rte": "9.0.0-build.9.11",
17
+ "@pega/cosmos-react-core": "9.0.0-build.9.12",
18
+ "@pega/cosmos-react-rte": "9.0.0-build.9.12",
19
19
  "@types/react": "^17.0.62 || ^18.3.3",
20
20
  "@types/react-dom": "^17.0.20 || ^18.3.0",
21
21
  "@types/styled-components": "^5.1.26",