@pega/cosmos-react-work 4.0.0-dev.14.1 → 4.0.0-dev.15.0

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.
Files changed (32) hide show
  1. package/lib/components/CasePreview/CasePreview.d.ts.map +1 -1
  2. package/lib/components/CasePreview/CasePreview.js +0 -5
  3. package/lib/components/CasePreview/CasePreview.js.map +1 -1
  4. package/lib/components/CaseView/CaseHeader/Summary.d.ts.map +1 -1
  5. package/lib/components/CaseView/CaseHeader/Summary.js +5 -9
  6. package/lib/components/CaseView/CaseHeader/Summary.js.map +1 -1
  7. package/lib/components/CaseView/CaseSummary.d.ts.map +1 -1
  8. package/lib/components/CaseView/CaseSummary.js +6 -1
  9. package/lib/components/CaseView/CaseSummary.js.map +1 -1
  10. package/lib/components/CaseView/CaseSummaryFields.d.ts.map +1 -1
  11. package/lib/components/CaseView/CaseSummaryFields.js +10 -3
  12. package/lib/components/CaseView/CaseSummaryFields.js.map +1 -1
  13. package/lib/components/CaseView/CaseView.d.ts.map +1 -1
  14. package/lib/components/CaseView/CaseView.js +41 -64
  15. package/lib/components/CaseView/CaseView.js.map +1 -1
  16. package/lib/components/CaseView/CaseView.styles.d.ts +4 -1
  17. package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
  18. package/lib/components/CaseView/CaseView.styles.js +40 -56
  19. package/lib/components/CaseView/CaseView.styles.js.map +1 -1
  20. package/lib/components/CaseView/CaseView.types.d.ts +1 -1
  21. package/lib/components/CaseView/CaseView.types.d.ts.map +1 -1
  22. package/lib/components/CaseView/CaseView.types.js.map +1 -1
  23. package/lib/components/Confirmation/Confirmation.d.ts.map +1 -1
  24. package/lib/components/Confirmation/Confirmation.js +2 -2
  25. package/lib/components/Confirmation/Confirmation.js.map +1 -1
  26. package/lib/components/Tasks/TaskList.d.ts +7 -1
  27. package/lib/components/Tasks/TaskList.d.ts.map +1 -1
  28. package/lib/components/Tasks/TaskList.js +37 -4
  29. package/lib/components/Tasks/TaskList.js.map +1 -1
  30. package/lib/components/Tasks/Tasks.js +1 -1
  31. package/lib/components/Tasks/Tasks.js.map +1 -1
  32. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"CasePreview.d.ts","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAKJ,MAAM,OAAO,CAAC;AAIf,OAAO,EAQL,YAAY,EAMZ,SAAS,EACT,UAAU,EACV,cAAc,EAEf,MAAM,yBAAyB,CAAC;AAGjC,OAAiB,EACf,aAAa,EAKd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAMlE,MAAM,WAAW,gBACf,SAAQ,IAAI,CACR,aAAa,EACX,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,aAAa,GACb,MAAM,GACN,UAAU,GACV,kBAAkB,GAClB,SAAS,GACT,iBAAiB,GACjB,QAAQ,GACR,eAAe,GACf,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,SAAS,GACT,WAAW,GACX,uBAAuB,CAC1B,EACD,cAAc,EACd,UAAU,EACV,SAAS;IACX,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC5C,iDAAiD;IACjD,IAAI,EAAE,OAAO,CAAC;IACd,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,yCAAyC;IACzC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,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C;CAC3B;AAkED,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAsGnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -47,11 +47,6 @@ const StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {
47
47
 
48
48
  ${StyledCaseViewContent} {
49
49
  overflow-y: auto;
50
- margin-bottom: calc(${theme.base['hit-area']['mouse-min']} + ${theme.base.spacing});
51
-
52
- @media (pointer: coarse) {
53
- margin-bottom: calc(${theme.base['hit-area']['finger-min']} + ${theme.base.spacing});
54
- }
55
50
 
56
51
  & > :last-child {
57
52
  padding-bottom: calc(2 * ${theme.base.spacing});
@@ -1 +1 @@
1
- {"version":3,"file":"CasePreview.js","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAIV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAEhB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,OAAO,EACP,eAAe,EAIf,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAE1F,OAAO,QAAQ,EAAE,EAEf,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,YAAY,CAAC,SAAS,CAAC,CAAC;AA6CxB,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,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,qBAAqB,EAAE,qBAAqB,EAC5C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,SACT,IACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useCallback,\n useEffect,\n useContext\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Drawer,\n Icon,\n registerIcon,\n Button,\n Flex,\n tryCatch,\n defaultThemeProp,\n ForwardProps,\n useBreakpoint,\n useElement,\n useDirection,\n useI18n,\n AppShellContext,\n BaseProps,\n TestIdProp,\n NoChildrenProp,\n useTestIds\n} from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport CaseView, {\n CaseViewProps,\n StyledCaseView,\n StyledCaseViewContent,\n StyledCaseDrawer,\n StyledSummaryRegion\n} from '../CaseView';\nimport { CaseViewContextValue } from '../CaseView/CaseView.types';\n\nimport { getCasePreviewTestIds } from './CasePreview.test-ids';\n\nregisterIcon(timesIcon);\n\nexport interface CasePreviewProps\n extends Pick<\n CaseViewProps,\n | 'caseId'\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 /** 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 ({\n theme: {\n base: {\n spacing,\n palette: { 'brand-primary': brandPrimary }\n }\n }\n }) => {\n const buttonColor = tryCatch(() => readableColor(brandPrimary));\n\n return css`\n background-color: ${brandPrimary};\n padding: ${spacing} calc(2 * ${spacing}) 0;\n\n button {\n color: ${buttonColor};\n }\n `;\n }\n);\n\nStyledPreviewActions.defaultProps = defaultThemeProp;\n\nconst StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {\n return css`\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\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 ${StyledSummaryRegion} {\n position: relative;\n top: 0;\n }\n }\n\n ${StyledCaseViewContent} {\n overflow-y: auto;\n margin-bottom: calc(${theme.base['hit-area']['mouse-min']} + ${theme.base.spacing});\n\n @media (pointer: coarse) {\n margin-bottom: calc(${theme.base['hit-area']['finger-min']} + ${theme.base.spacing});\n }\n\n & > :last-child {\n padding-bottom: calc(2 * ${theme.base.spacing});\n }\n }\n `;\n});\n\nStyledPreviewDrawer.defaultProps = defaultThemeProp;\n\nconst CasePreview: FunctionComponent<CasePreviewProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<CasePreviewProps>, ref: CasePreviewProps['ref']) => {\n const {\n testId,\n open: openProp,\n caseId,\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 ...restProps\n } = props;\n const testIds = useTestIds(testId, getCasePreviewTestIds);\n\n const t = useI18n();\n const { previewTriggerRef } = useContext(AppShellContext);\n const [closeButtonEl, setCloseButtonEl] = useElement<HTMLButtonElement>();\n const isSmallOrAbove = useBreakpoint('sm');\n const [open, setOpen] = useState(openProp);\n const direction = useDirection();\n\n const closePreview = useCallback(() => {\n setOpen(false);\n previewTriggerRef.current?.focus();\n }, []);\n\n useEffect(() => {\n setOpen(openProp);\n }, [openProp]);\n\n useEffect(() => {\n if (openProp && closeButtonEl) {\n closeButtonEl.focus();\n }\n }, [openProp, closeButtonEl]);\n\n return (\n <Drawer\n data-testid={testIds.root}\n {...restProps}\n as={StyledPreviewDrawer}\n role='complementary'\n forwardedAs={Flex}\n container={{ direction: 'column' }}\n ref={ref}\n open={open && isSmallOrAbove}\n position='fixed'\n placement={direction.end}\n aria-label={t('preview_of_noun', [heading])}\n shadow\n nullWhenClosed\n >\n <StyledPreviewActions>\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 <CaseView\n caseId={caseId}\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 </Drawer>\n );\n }\n);\n\nexport default CasePreview;\n"]}
1
+ {"version":3,"file":"Cas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OAAO,CAAC,KAAK,EAC1B,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,CAAC,CAAC,eAAe,CAAC,YAEzB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,GACY,EAEvB,KAAC,QAAQ,IACP,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,qBAAqB,EAAE,qBAAqB,EAC5C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,SACT,IACK,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n useState,\n useCallback,\n useEffect,\n useContext\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Drawer,\n Icon,\n registerIcon,\n Button,\n Flex,\n tryCatch,\n defaultThemeProp,\n ForwardProps,\n useBreakpoint,\n useElement,\n useDirection,\n useI18n,\n AppShellContext,\n BaseProps,\n TestIdProp,\n NoChildrenProp,\n useTestIds\n} from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nimport CaseView, {\n CaseViewProps,\n StyledCaseView,\n StyledCaseViewContent,\n StyledCaseDrawer,\n StyledSummaryRegion\n} from '../CaseView';\nimport { CaseViewContextValue } from '../CaseView/CaseView.types';\n\nimport { getCasePreviewTestIds } from './CasePreview.test-ids';\n\nregisterIcon(timesIcon);\n\nexport interface CasePreviewProps\n extends Pick<\n CaseViewProps,\n | 'caseId'\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 /** 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 ({\n theme: {\n base: {\n spacing,\n palette: { 'brand-primary': brandPrimary }\n }\n }\n }) => {\n const buttonColor = tryCatch(() => readableColor(brandPrimary));\n\n return css`\n background-color: ${brandPrimary};\n padding: ${spacing} calc(2 * ${spacing}) 0;\n\n button {\n color: ${buttonColor};\n }\n `;\n }\n);\n\nStyledPreviewActions.defaultProps = defaultThemeProp;\n\nconst StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {\n return css`\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\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 ${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});\n\nStyledPreviewDrawer.defaultProps = defaultThemeProp;\n\nconst CasePreview: FunctionComponent<CasePreviewProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<CasePreviewProps>, ref: CasePreviewProps['ref']) => {\n const {\n testId,\n open: openProp,\n caseId,\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 ...restProps\n } = props;\n const testIds = useTestIds(testId, getCasePreviewTestIds);\n\n const t = useI18n();\n const { previewTriggerRef } = useContext(AppShellContext);\n const [closeButtonEl, setCloseButtonEl] = useElement<HTMLButtonElement>();\n const isSmallOrAbove = useBreakpoint('sm');\n const [open, setOpen] = useState(openProp);\n const direction = useDirection();\n\n const closePreview = useCallback(() => {\n setOpen(false);\n previewTriggerRef.current?.focus();\n }, []);\n\n useEffect(() => {\n setOpen(openProp);\n }, [openProp]);\n\n useEffect(() => {\n if (openProp && closeButtonEl) {\n closeButtonEl.focus();\n }\n }, [openProp, closeButtonEl]);\n\n return (\n <Drawer\n data-testid={testIds.root}\n {...restProps}\n as={StyledPreviewDrawer}\n role='complementary'\n forwardedAs={Flex}\n container={{ direction: 'column' }}\n ref={ref}\n open={open && isSmallOrAbove}\n position='fixed'\n placement={direction.end}\n aria-label={t('preview_of_noun', [heading])}\n shadow\n nullWhenClosed\n >\n <StyledPreviewActions>\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 <CaseView\n caseId={caseId}\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 </Drawer>\n );\n }\n);\n\nexport default CasePreview;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Summary.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseView/CaseHeader/Summary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AA+C/D,QAAA,MAAM,OAAO;gBAAkC,UAAU,cAAc,CAAC;iBAkQvE,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Summary.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseView/CaseHeader/Summary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AA+C/D,QAAA,MAAM,OAAO;gBAAkC,UAAU,cAAc,CAAC;iBAiQvE,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -51,8 +51,8 @@ const Summary = ({ siblingRef }) => {
51
51
  let hasAvailableSpace = availableSpace;
52
52
  listChildren.forEach((item, index) => {
53
53
  const valueEl = item.lastChild;
54
- const truncatedSpace = valueEl.scrollWidth - valueEl.offsetWidth;
55
- const shouldTruncate = hasAvailableSpace - truncatedSpace < 0;
54
+ const truncatedSpace = Math.floor(valueEl.scrollWidth - valueEl.offsetWidth);
55
+ const shouldTruncate = truncatedSpace === 0 ? false : hasAvailableSpace - truncatedSpace <= 0;
56
56
  if (shouldTruncate) {
57
57
  if (!truncatedIndices?.includes(index)) {
58
58
  hasAvailableSpace += truncatedSpace;
@@ -76,7 +76,7 @@ const Summary = ({ siblingRef }) => {
76
76
  else if (hasAvailableSpace < 0) {
77
77
  const truncatedElMaxWidth = 20 * chToPxConversionFactor;
78
78
  const valueEl = item.lastChild;
79
- const spaceToTruncate = Math.max(valueEl.offsetWidth - truncatedElMaxWidth, 0);
79
+ const spaceToTruncate = Math.max(Math.floor(valueEl.offsetWidth - truncatedElMaxWidth), 0);
80
80
  if (spaceToTruncate) {
81
81
  indicesToTruncate.push(lastIndex - index);
82
82
  hasAvailableSpace += spaceToTruncate;
@@ -95,9 +95,7 @@ const Summary = ({ siblingRef }) => {
95
95
  side: 'trailing',
96
96
  ltr
97
97
  });
98
- hasAvailableSpace = ltr
99
- ? nextSiblingLeadingEdge - itemTrailingEdge
100
- : itemTrailingEdge - nextSiblingLeadingEdge;
98
+ hasAvailableSpace = Math.floor(ltr ? nextSiblingLeadingEdge - itemTrailingEdge : itemTrailingEdge - nextSiblingLeadingEdge);
101
99
  if (hasAvailableSpace < 0) {
102
100
  priorTrailingEdgeStack.current = [...priorTrailingEdgeStack.current, itemTrailingEdge];
103
101
  nextDisplayCount -= 1;
@@ -121,9 +119,7 @@ const Summary = ({ siblingRef }) => {
121
119
  const testEdge = lastSummaryItem
122
120
  ? getEdge({ el: lastSummaryItem, side: 'trailing', ltr })
123
121
  : getEdge({ el: containerEl, side: 'leading', ltr });
124
- let availableSpace = ltr
125
- ? nextSiblingLeadingEdge - testEdge
126
- : testEdge - nextSiblingLeadingEdge;
122
+ let availableSpace = Math.floor(ltr ? nextSiblingLeadingEdge - testEdge : testEdge - nextSiblingLeadingEdge);
127
123
  if (availableSpace === priorAvailableSpace.current)
128
124
  return;
129
125
  priorAvailableSpace.current = availableSpace;
@@ -1 +1 @@
1
- {"version":3,"file":"Summary.js","sourceRoot":"","sources":["../../../../src/components/CaseView/CaseHeader/Summary.tsx"],"names":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Ref, useState } from 'react';\n\nimport {\n Flex,\n getEdge,\n registerIcon,\n StyledStackedFieldValue,\n StyledLabel,\n StyledFieldName,\n useDirection,\n useChToPxConversionFactor\n} from '@pega/cosmos-react-core';\nimport * as pencilIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/pencil.icon';\nimport * as moreIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/more.icon';\n\nimport {\n StyledHeaderSummary,\n StyledHeaderSummaryValue,\n StyledHeaderSummaryBlock\n} from '../CaseView.styles';\nimport { useCaseViewContext } from '../CaseView.context';\nimport { SummaryField } from '../CaseView.types';\n\nregisterIcon(pencilIcon, moreIcon);\n\nconst Field = ({\n item,\n primary,\n truncate\n}: {\n item: SummaryField;\n primary: boolean;\n truncate: boolean;\n}) => {\n const { name, value, simpleValue } = item;\n const displayValue = simpleValue ?? value ?? <span>&ndash;&ndash;</span>;\n\n return (\n <StyledStackedFieldValue>\n <StyledLabel as={StyledFieldName}>{name}</StyledLabel>\n <StyledHeaderSummaryValue bold={primary} truncate={truncate}>\n {displayValue}\n </StyledHeaderSummaryValue>\n </StyledStackedFieldValue>\n );\n};\n\nconst Summary = ({ siblingRef }: { siblingRef: RefObject<HTMLDivElement> }) => {\n const { ltr } = useDirection();\n const { summaryFields } = useCaseViewContext();\n const chToPxConversionFactor = useChToPxConversionFactor();\n\n const containerRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDListElement>(null);\n\n const primaryItems = summaryFields?.primary ?? [];\n const secondaryItems = summaryFields?.secondary ?? [];\n const items = [...primaryItems, ...secondaryItems];\n\n const [displayCount, setDisplayCount] = useState(items.length);\n const [truncatedIndices, setTruncatedIndices] = useState<number[] | undefined>(\n items.map((_, i) => i)\n );\n\n const priorTrailingEdgeStack = useRef<number[]>([]);\n const priorAvailableSpace = useRef<number | null>(null);\n\n const evalItemAddition = ({\n nextSiblingLeadingEdge\n }: {\n nextSiblingLeadingEdge: number;\n }): {\n indicesToTruncate: number[];\n nextDisplayCount: number;\n } => {\n const indicesToTruncate: number[] = truncatedIndices ? [...truncatedIndices] : [];\n let nextDisplayCount = displayCount;\n\n const reversedTrailingEdgeStack = [...priorTrailingEdgeStack.current].reverse();\n for (let i = 0; i < reversedTrailingEdgeStack.length; i += 1) {\n const priorEdge = reversedTrailingEdgeStack[i];\n\n const shouldRender = ltr\n ? priorEdge < nextSiblingLeadingEdge\n : priorEdge > nextSiblingLeadingEdge;\n\n if (shouldRender) {\n priorTrailingEdgeStack.current.pop();\n\n if (!indicesToTruncate.includes(nextDisplayCount)) {\n indicesToTruncate.push(nextDisplayCount);\n }\n\n nextDisplayCount += 1;\n } else {\n break;\n }\n }\n\n return { indicesToTruncate, nextDisplayCount };\n };\n\n const evalTruncationReduction = ({\n listChildren,\n availableSpace\n }: {\n listChildren: Element[];\n availableSpace: number;\n }): {\n indicesToTruncate: number[];\n } => {\n const indicesToTruncate: number[] = [];\n let hasAvailableSpace = availableSpace;\n\n listChildren.forEach((item, index) => {\n const valueEl = item.lastChild as HTMLElement;\n const truncatedSpace = valueEl.scrollWidth - valueEl.offsetWidth;\n const shouldTruncate = hasAvailableSpace - truncatedSpace < 0;\n\n if (shouldTruncate) {\n if (!truncatedIndices?.includes(index)) {\n hasAvailableSpace += truncatedSpace;\n }\n\n indicesToTruncate.push(index);\n } else if (truncatedIndices?.includes(index)) {\n hasAvailableSpace -= truncatedSpace;\n }\n });\n\n return { indicesToTruncate };\n };\n\n const evalTruncationIncrease = ({\n listChildren,\n availableSpace\n }: {\n listChildren: Element[];\n availableSpace: number;\n }): {\n indicesToTruncate: number[];\n availableSpace: number;\n } => {\n const indicesToTruncate: number[] = [];\n const lastIndex = listChildren.length - 1;\n let hasAvailableSpace = availableSpace;\n\n [...listChildren].reverse().forEach((item, index) => {\n if (truncatedIndices?.includes(lastIndex - index)) {\n indicesToTruncate.push(lastIndex - index);\n } else if (hasAvailableSpace < 0) {\n const truncatedElMaxWidth = 20 * chToPxConversionFactor;\n const valueEl = item.lastChild as HTMLElement;\n const spaceToTruncate = Math.max(valueEl.offsetWidth - truncatedElMaxWidth, 0);\n\n if (spaceToTruncate) {\n indicesToTruncate.push(lastIndex - index);\n hasAvailableSpace += spaceToTruncate;\n }\n }\n });\n\n return { indicesToTruncate, availableSpace: hasAvailableSpace };\n };\n\n const evalItemRemoval = ({\n listChildren,\n availableSpace,\n nextSiblingLeadingEdge\n }: {\n listChildren: Element[];\n availableSpace: number;\n nextSiblingLeadingEdge: number;\n }): { displayCount: number } => {\n let nextDisplayCount = displayCount;\n let hasAvailableSpace = availableSpace;\n let lastChildIndex = listChildren.length - 1;\n\n do {\n const itemTrailingEdge = getEdge({\n el: listChildren[lastChildIndex],\n side: 'trailing',\n ltr\n });\n hasAvailableSpace = ltr\n ? nextSiblingLeadingEdge - itemTrailingEdge\n : itemTrailingEdge - nextSiblingLeadingEdge;\n\n if (hasAvailableSpace < 0) {\n priorTrailingEdgeStack.current = [...priorTrailingEdgeStack.current, itemTrailingEdge];\n\n nextDisplayCount -= 1;\n lastChildIndex -= 1;\n }\n } while (hasAvailableSpace < 0 && lastChildIndex > -1);\n\n return { displayCount: nextDisplayCount };\n };\n\n const evaluateSummaryDisplay = () => {\n const containerEl = containerRef.current;\n if (!containerEl) return;\n\n const listChildren = Array.from(listRef.current?.children ?? []);\n const lastSummaryItem = listChildren.length ? listChildren[listChildren.length - 1] : undefined;\n const nextSibling = siblingRef?.current ?? document.body;\n const nextSiblingLeadingEdge = getEdge({\n el: nextSibling,\n side: 'leading',\n ltr\n });\n const testEdge = lastSummaryItem\n ? getEdge({ el: lastSummaryItem, side: 'trailing', ltr })\n : getEdge({ el: containerEl, side: 'leading', ltr });\n\n let availableSpace = ltr\n ? nextSiblingLeadingEdge - testEdge\n : testEdge - nextSiblingLeadingEdge;\n if (availableSpace === priorAvailableSpace.current) return;\n\n priorAvailableSpace.current = availableSpace;\n\n let indicesToTruncate: number[] | undefined;\n let nextDisplayCount = displayCount;\n\n if (availableSpace >= 0) {\n if (displayCount !== items.length) {\n const additionsConfig = evalItemAddition({ nextSiblingLeadingEdge });\n\n indicesToTruncate = additionsConfig.indicesToTruncate;\n nextDisplayCount = additionsConfig.nextDisplayCount;\n } else if (truncatedIndices?.length) {\n const truncationConfig = evalTruncationReduction({\n listChildren,\n availableSpace\n });\n\n indicesToTruncate = truncationConfig.indicesToTruncate;\n }\n } else if (listChildren) {\n const truncationConfig = evalTruncationIncrease({\n listChildren,\n availableSpace\n });\n\n indicesToTruncate = truncationConfig.indicesToTruncate;\n availableSpace = truncationConfig.availableSpace;\n\n if (availableSpace < 0) {\n const removalConfig = evalItemRemoval({\n listChildren,\n availableSpace,\n nextSiblingLeadingEdge\n });\n\n nextDisplayCount = removalConfig.displayCount;\n }\n }\n\n setDisplayCount(nextDisplayCount);\n\n if (indicesToTruncate) {\n setTruncatedIndices(indicesToTruncate);\n }\n };\n\n // Initial display evaluation\n useEffect(() => {\n evaluateSummaryDisplay();\n }, []);\n\n // Overflow resize observer\n useEffect(() => {\n const resizeObserver = new ResizeObserver(evaluateSummaryDisplay);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current, { box: 'border-box' });\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [evaluateSummaryDisplay]);\n\n return (\n <Flex\n as={StyledHeaderSummaryBlock}\n item={{ grow: 1, shrink: 1 }}\n ref={containerRef}\n hasItems={displayCount > 0}\n >\n <Flex as={StyledHeaderSummary} container={{ gap: 4 }} ref={listRef}>\n {items.slice(0, displayCount).map((item, index) => {\n return (\n <Field\n item={item}\n primary={!!primaryItems?.length && index < primaryItems.length}\n truncate={!!truncatedIndices?.includes(index)}\n key={item.name}\n />\n );\n })}\n </Flex>\n </Flex>\n );\n};\n\nexport default Summary;\n"]}
1
+ {"version":3,"file":"Summary.js","sourceRoot":"","sources":["../../../../src/components/CaseView/CaseHeader/Summary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;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C,CAAC,GACG,GACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { RefObject, useEffect, useRef, useState } from 'react';\n\nimport {\n Flex,\n getEdge,\n registerIcon,\n StyledStackedFieldValue,\n StyledLabel,\n StyledFieldName,\n useDirection,\n useChToPxConversionFactor\n} from '@pega/cosmos-react-core';\nimport * as pencilIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/pencil.icon';\nimport * as moreIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/more.icon';\n\nimport {\n StyledHeaderSummary,\n StyledHeaderSummaryValue,\n StyledHeaderSummaryBlock\n} from '../CaseView.styles';\nimport { useCaseViewContext } from '../CaseView.context';\nimport { SummaryField } from '../CaseView.types';\n\nregisterIcon(pencilIcon, moreIcon);\n\nconst Field = ({\n item,\n primary,\n truncate\n}: {\n item: SummaryField;\n primary: boolean;\n truncate: boolean;\n}) => {\n const { name, value, simpleValue } = item;\n const displayValue = simpleValue ?? value ?? <span>&ndash;&ndash;</span>;\n\n return (\n <StyledStackedFieldValue>\n <StyledLabel as={StyledFieldName}>{name}</StyledLabel>\n <StyledHeaderSummaryValue bold={primary} truncate={truncate}>\n {displayValue}\n </StyledHeaderSummaryValue>\n </StyledStackedFieldValue>\n );\n};\n\nconst Summary = ({ siblingRef }: { siblingRef: RefObject<HTMLDivElement> }) => {\n const { ltr } = useDirection();\n const { summaryFields } = useCaseViewContext();\n const chToPxConversionFactor = useChToPxConversionFactor();\n\n const containerRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDListElement>(null);\n\n const primaryItems = summaryFields?.primary ?? [];\n const secondaryItems = summaryFields?.secondary ?? [];\n const items = [...primaryItems, ...secondaryItems];\n\n const [displayCount, setDisplayCount] = useState(items.length);\n const [truncatedIndices, setTruncatedIndices] = useState<number[] | undefined>(\n items.map((_, i) => i)\n );\n\n const priorTrailingEdgeStack = useRef<number[]>([]);\n const priorAvailableSpace = useRef<number | null>(null);\n\n const evalItemAddition = ({\n nextSiblingLeadingEdge\n }: {\n nextSiblingLeadingEdge: number;\n }): {\n indicesToTruncate: number[];\n nextDisplayCount: number;\n } => {\n const indicesToTruncate: number[] = truncatedIndices ? [...truncatedIndices] : [];\n let nextDisplayCount = displayCount;\n\n const reversedTrailingEdgeStack = [...priorTrailingEdgeStack.current].reverse();\n for (let i = 0; i < reversedTrailingEdgeStack.length; i += 1) {\n const priorEdge = reversedTrailingEdgeStack[i];\n\n const shouldRender = ltr\n ? priorEdge < nextSiblingLeadingEdge\n : priorEdge > nextSiblingLeadingEdge;\n\n if (shouldRender) {\n priorTrailingEdgeStack.current.pop();\n\n if (!indicesToTruncate.includes(nextDisplayCount)) {\n indicesToTruncate.push(nextDisplayCount);\n }\n\n nextDisplayCount += 1;\n } else {\n break;\n }\n }\n\n return { indicesToTruncate, nextDisplayCount };\n };\n\n const evalTruncationReduction = ({\n listChildren,\n availableSpace\n }: {\n listChildren: Element[];\n availableSpace: number;\n }): {\n indicesToTruncate: number[];\n } => {\n const indicesToTruncate: number[] = [];\n let hasAvailableSpace = availableSpace;\n\n listChildren.forEach((item, index) => {\n const valueEl = item.lastChild as HTMLElement;\n const truncatedSpace = Math.floor(valueEl.scrollWidth - valueEl.offsetWidth);\n const shouldTruncate = truncatedSpace === 0 ? false : hasAvailableSpace - truncatedSpace <= 0;\n\n if (shouldTruncate) {\n if (!truncatedIndices?.includes(index)) {\n hasAvailableSpace += truncatedSpace;\n }\n\n indicesToTruncate.push(index);\n } else if (truncatedIndices?.includes(index)) {\n hasAvailableSpace -= truncatedSpace;\n }\n });\n\n return { indicesToTruncate };\n };\n\n const evalTruncationIncrease = ({\n listChildren,\n availableSpace\n }: {\n listChildren: Element[];\n availableSpace: number;\n }): {\n indicesToTruncate: number[];\n availableSpace: number;\n } => {\n const indicesToTruncate: number[] = [];\n const lastIndex = listChildren.length - 1;\n let hasAvailableSpace = availableSpace;\n\n [...listChildren].reverse().forEach((item, index) => {\n if (truncatedIndices?.includes(lastIndex - index)) {\n indicesToTruncate.push(lastIndex - index);\n } else if (hasAvailableSpace < 0) {\n const truncatedElMaxWidth = 20 * chToPxConversionFactor;\n const valueEl = item.lastChild as HTMLElement;\n const spaceToTruncate = Math.max(Math.floor(valueEl.offsetWidth - truncatedElMaxWidth), 0);\n\n if (spaceToTruncate) {\n indicesToTruncate.push(lastIndex - index);\n hasAvailableSpace += spaceToTruncate;\n }\n }\n });\n\n return { indicesToTruncate, availableSpace: hasAvailableSpace };\n };\n\n const evalItemRemoval = ({\n listChildren,\n availableSpace,\n nextSiblingLeadingEdge\n }: {\n listChildren: Element[];\n availableSpace: number;\n nextSiblingLeadingEdge: number;\n }): { displayCount: number } => {\n let nextDisplayCount = displayCount;\n let hasAvailableSpace = availableSpace;\n let lastChildIndex = listChildren.length - 1;\n\n do {\n const itemTrailingEdge = getEdge({\n el: listChildren[lastChildIndex],\n side: 'trailing',\n ltr\n });\n hasAvailableSpace = Math.floor(\n ltr ? nextSiblingLeadingEdge - itemTrailingEdge : itemTrailingEdge - nextSiblingLeadingEdge\n );\n\n if (hasAvailableSpace < 0) {\n priorTrailingEdgeStack.current = [...priorTrailingEdgeStack.current, itemTrailingEdge];\n\n nextDisplayCount -= 1;\n lastChildIndex -= 1;\n }\n } while (hasAvailableSpace < 0 && lastChildIndex > -1);\n\n return { displayCount: nextDisplayCount };\n };\n\n const evaluateSummaryDisplay = () => {\n const containerEl = containerRef.current;\n if (!containerEl) return;\n\n const listChildren = Array.from(listRef.current?.children ?? []);\n const lastSummaryItem = listChildren.length ? listChildren[listChildren.length - 1] : undefined;\n const nextSibling = siblingRef?.current ?? document.body;\n const nextSiblingLeadingEdge = getEdge({\n el: nextSibling,\n side: 'leading',\n ltr\n });\n const testEdge = lastSummaryItem\n ? getEdge({ el: lastSummaryItem, side: 'trailing', ltr })\n : getEdge({ el: containerEl, side: 'leading', ltr });\n let availableSpace = Math.floor(\n ltr ? nextSiblingLeadingEdge - testEdge : testEdge - nextSiblingLeadingEdge\n );\n if (availableSpace === priorAvailableSpace.current) return;\n\n priorAvailableSpace.current = availableSpace;\n\n let indicesToTruncate: number[] | undefined;\n let nextDisplayCount = displayCount;\n\n if (availableSpace >= 0) {\n if (displayCount !== items.length) {\n const additionsConfig = evalItemAddition({ nextSiblingLeadingEdge });\n\n indicesToTruncate = additionsConfig.indicesToTruncate;\n nextDisplayCount = additionsConfig.nextDisplayCount;\n } else if (truncatedIndices?.length) {\n const truncationConfig = evalTruncationReduction({\n listChildren,\n availableSpace\n });\n\n indicesToTruncate = truncationConfig.indicesToTruncate;\n }\n } else if (listChildren) {\n const truncationConfig = evalTruncationIncrease({\n listChildren,\n availableSpace\n });\n\n indicesToTruncate = truncationConfig.indicesToTruncate;\n availableSpace = truncationConfig.availableSpace;\n\n if (availableSpace < 0) {\n const removalConfig = evalItemRemoval({\n listChildren,\n availableSpace,\n nextSiblingLeadingEdge\n });\n\n nextDisplayCount = removalConfig.displayCount;\n }\n }\n\n setDisplayCount(nextDisplayCount);\n\n if (indicesToTruncate) {\n setTruncatedIndices(indicesToTruncate);\n }\n };\n\n // Initial display evaluation\n useEffect(() => {\n evaluateSummaryDisplay();\n }, []);\n\n // Overflow resize observer\n useEffect(() => {\n const resizeObserver = new ResizeObserver(evaluateSummaryDisplay);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current, { box: 'border-box' });\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [evaluateSummaryDisplay]);\n\n return (\n <Flex\n as={StyledHeaderSummaryBlock}\n item={{ grow: 1, shrink: 1 }}\n ref={containerRef}\n hasItems={displayCount > 0}\n >\n <Flex as={StyledHeaderSummary} container={{ gap: 4 }} ref={listRef}>\n {items.slice(0, displayCount).map((item, index) => {\n return (\n <Field\n item={item}\n primary={!!primaryItems?.length && index < primaryItems.length}\n truncate={!!truncatedIndices?.includes(index)}\n key={item.name}\n />\n );\n })}\n </Flex>\n </Flex>\n );\n};\n\nexport default Summary;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CaseSummary.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAe3B,QAAA,MAAM,WAAW,EAAE,EAwBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"CaseSummary.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAgBpC,QAAA,MAAM,WAAW,EAAE,EA6BlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,12 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
2
3
  import { Flex, Tabs, registerIcon } from '@pega/cosmos-react-core';
3
4
  import * as arrowMicroLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-left.icon';
4
5
  import CaseHeader from './CaseHeader/CaseHeader';
5
6
  import { StyledCaseSummary, StyledCaseSummaryInfo, StyledCaseSummaryContainer } from './CaseView.styles';
6
7
  import { useCaseViewContext } from './CaseView.context';
8
+ import CaseSummaryFields from './CaseSummaryFields';
7
9
  registerIcon(arrowMicroLeftIcon);
8
10
  const CaseSummary = () => {
9
- const { testIds, summary, summaryExpanded, tabs, aboveMD, isPreview } = useCaseViewContext();
11
+ const { testIds, summaryFields, summaryExpanded, tabs, aboveMD, isPreview } = useCaseViewContext();
12
+ const summary = useMemo(() => {
13
+ return _jsx(CaseSummaryFields, { ...summaryFields, inSummaryPanel: true });
14
+ }, [summaryFields]);
10
15
  return (_jsxs(Flex, { as: StyledCaseSummary, container: { direction: 'column' }, item: { shrink: 0 }, children: [_jsx(CaseHeader, {}), aboveMD && !isPreview && summaryExpanded && (summary || tabs.items.length > 1) && (_jsxs(StyledCaseSummaryInfo, { children: [_jsx(StyledCaseSummaryContainer, { children: summary }), tabs.items.length > 1 && (_jsx(Tabs, { "data-testid": testIds.tabs, type: 'vertical', tabs: tabs.items, onTabClick: tabs.onClick, currentTabId: tabs.currentTabId }))] }))] }));
11
16
  };
12
17
  export default CaseSummary;
@@ -1 +1 @@
1
- {"version":3,"file":"CaseSummary.js","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummary.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,kBAAkB,MAAM,yEAAyE,CAAC;AAE9G,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAEjC,MAAM,WAAW,GAAO,GAAG,EAAE;IAC3B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAE7F,OAAO,CACL,MAAC,IAAI,IAAC,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAClF,KAAC,UAAU,KAAG,EAEb,OAAO,IAAI,CAAC,SAAS,IAAI,eAAe,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CACjF,MAAC,qBAAqB,eACpB,KAAC,0BAA0B,cAAE,OAAO,GAA8B,EAEjE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACxB,KAAC,IAAI,mBACU,OAAO,CAAC,IAAI,EACzB,IAAI,EAAC,UAAU,EACf,IAAI,EAAE,IAAI,CAAC,KAAK,EAChB,UAAU,EAAE,IAAI,CAAC,OAAO,EACxB,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACH,IACqB,CACzB,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC } from 'react';\n\nimport { Flex, Tabs, registerIcon } from '@pega/cosmos-react-core';\nimport * as arrowMicroLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-left.icon';\n\nimport CaseHeader from './CaseHeader/CaseHeader';\nimport {\n StyledCaseSummary,\n StyledCaseSummaryInfo,\n StyledCaseSummaryContainer\n} from './CaseView.styles';\nimport { useCaseViewContext } from './CaseView.context';\n\nregisterIcon(arrowMicroLeftIcon);\n\nconst CaseSummary: FC = () => {\n const { testIds, summary, summaryExpanded, tabs, aboveMD, isPreview } = useCaseViewContext();\n\n return (\n <Flex as={StyledCaseSummary} container={{ direction: 'column' }} item={{ shrink: 0 }}>\n <CaseHeader />\n\n {aboveMD && !isPreview && summaryExpanded && (summary || tabs.items.length > 1) && (\n <StyledCaseSummaryInfo>\n <StyledCaseSummaryContainer>{summary}</StyledCaseSummaryContainer>\n\n {tabs.items.length > 1 && (\n <Tabs\n data-testid={testIds.tabs}\n type='vertical'\n tabs={tabs.items}\n onTabClick={tabs.onClick}\n currentTabId={tabs.currentTabId}\n />\n )}\n </StyledCaseSummaryInfo>\n )}\n </Flex>\n );\n};\n\nexport default CaseSummary;\n"]}
1
+ {"version":3,"file":"CaseSummary.js","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,OAAO,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,kBAAkB,MAAM,yEAAyE,CAAC;AAE9G,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EACL,iBAAi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} from '@pega/cosmos-react-core';\nimport * as arrowMicroLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-left.icon';\n\nimport CaseHeader from './CaseHeader/CaseHeader';\nimport {\n StyledCaseSummary,\n StyledCaseSummaryInfo,\n StyledCaseSummaryContainer\n} from './CaseView.styles';\nimport { useCaseViewContext } from './CaseView.context';\nimport CaseSummaryFields from './CaseSummaryFields';\n\nregisterIcon(arrowMicroLeftIcon);\n\nconst CaseSummary: FC = () => {\n const { testIds, summaryFields, summaryExpanded, tabs, aboveMD, isPreview } =\n useCaseViewContext();\n\n const summary = useMemo(() => {\n return <CaseSummaryFields {...summaryFields} inSummaryPanel />;\n }, [summaryFields]);\n\n return (\n <Flex as={StyledCaseSummary} container={{ direction: 'column' }} item={{ shrink: 0 }}>\n <CaseHeader />\n\n {aboveMD && !isPreview && summaryExpanded && (summary || tabs.items.length > 1) && (\n <StyledCaseSummaryInfo>\n <StyledCaseSummaryContainer>{summary}</StyledCaseSummaryContainer>\n\n {tabs.items.length > 1 && (\n <Tabs\n data-testid={testIds.tabs}\n type='vertical'\n tabs={tabs.items}\n onTabClick={tabs.onClick}\n currentTabId={tabs.currentTabId}\n />\n )}\n </StyledCaseSummaryInfo>\n )}\n </Flex>\n );\n};\n\nexport default CaseSummary;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CaseSummaryFields.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummaryFields.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAmB,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAQ,YAAY,EAAW,MAAM,yBAAyB,CAAC;AAOtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,GAAG,YAAY,CA6BhE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"CaseSummaryFields.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummaryFields.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA2B,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAQ,YAAY,EAA0B,MAAM,yBAAyB,CAAC;AAOrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,GAAG,YAAY,CAsChE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,11 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Grid, useI18n } from '@pega/cosmos-react-core';
2
+ import { useRef } from 'react';
3
+ import { Grid, useI18n, useBreakpoint } from '@pega/cosmos-react-core';
3
4
  import { StyledCaseSummaryFields, StyledSummaryPrimaryList, StyledSummarySecondaryList } from './CaseView.styles';
4
5
  import { useCaseViewContext } from './CaseView.context';
5
- const CaseSummaryFields = ({ primary, secondary }) => {
6
+ const CaseSummaryFields = ({ primary, secondary, inSummaryPanel }) => {
6
7
  const t = useI18n();
7
8
  const { testIds } = useCaseViewContext();
8
- return (_jsxs(Grid, { "data-testid": testIds.summaryFields, as: StyledCaseSummaryFields, container: { rowGap: 2 }, children: [primary && (_jsx(StyledSummaryPrimaryList, { variant: 'stacked', fields: primary, "aria-label": t('primary_summary_fields') })), secondary && (_jsx(StyledSummarySecondaryList, { variant: 'inline', fields: secondary, "aria-label": t('summary_fields') }))] }));
9
+ const containerRef = useRef(null);
10
+ const isSMContentWidthOrAbove = useBreakpoint('sm', {
11
+ breakpointRef: containerRef,
12
+ themeProp: 'content-width'
13
+ });
14
+ const wrapped = !inSummaryPanel && !isSMContentWidthOrAbove;
15
+ return (_jsxs(Grid, { "data-testid": testIds.summaryFields, as: StyledCaseSummaryFields, container: { rowGap: 2 }, ref: containerRef, children: [primary && (_jsx(StyledSummaryPrimaryList, { variant: 'stacked', fields: primary, "aria-label": t('primary_summary_fields'), wrapped: wrapped })), secondary && (_jsx(StyledSummarySecondaryList, { variant: wrapped ? 'stacked' : 'inline', fields: secondary, "aria-label": t('summary_fields') }))] }));
9
16
  };
10
17
  export default CaseSummaryFields;
11
18
  //# sourceMappingURL=CaseSummaryFields.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CaseSummaryFields.js","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummaryFields.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAgB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,iBAAiB,GAA8C,CAAC,EACpE,OAAO,EACP,SAAS,EAC+B,EAAE,EAAE;IAC5C,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAEzC,OAAO,CACL,MAAC,IAAI,mBACU,OAAO,CAAC,aAAa,EAClC,EAAE,EAAE,uBAAuB,EAC3B,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,aAEvB,OAAO,IAAI,CACV,KAAC,wBAAwB,IACvB,OAAO,EAAC,SAAS,EACjB,MAAM,EAAE,OAAO,gBACH,CAAC,CAAC,wBAAwB,CAAC,GACvC,CACH,EACA,SAAS,IAAI,CACZ,KAAC,0BAA0B,IACzB,OAAO,EAAC,QAAQ,EAChB,MAAM,EAAE,SAAS,gBACL,CAAC,CAAC,gBAAgB,CAAC,GAC/B,CACH,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { FC, PropsWithoutRef } from 'react';\n\nimport { Grid, ForwardProps, useI18n } from '@pega/cosmos-react-core';\n\nimport {\n StyledCaseSummaryFields,\n StyledSummaryPrimaryList,\n StyledSummarySecondaryList\n} from './CaseView.styles';\nimport { CaseSummaryFieldsProps } from './CaseView.types';\nimport { useCaseViewContext } from './CaseView.context';\n\nconst CaseSummaryFields: FC<CaseSummaryFieldsProps & ForwardProps> = ({\n primary,\n secondary\n}: PropsWithoutRef<CaseSummaryFieldsProps>) => {\n const t = useI18n();\n const { testIds } = useCaseViewContext();\n\n return (\n <Grid\n data-testid={testIds.summaryFields}\n as={StyledCaseSummaryFields}\n container={{ rowGap: 2 }}\n >\n {primary && (\n <StyledSummaryPrimaryList\n variant='stacked'\n fields={primary}\n aria-label={t('primary_summary_fields')}\n />\n )}\n {secondary && (\n <StyledSummarySecondaryList\n variant='inline'\n fields={secondary}\n aria-label={t('summary_fields')}\n />\n )}\n </Grid>\n );\n};\n\nexport default CaseSummaryFields;\n"]}
1
+ {"version":3,"file":"CaseSummaryFields.js","sourceRoot":"","sources":["../../../src/components/CaseView/CaseSummaryFields.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAuB,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAgB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAErF,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,iBAAiB,GAA8C,CAAC,EACpE,OAAO,EACP,SAAS,EACT,cAAc,EAC0B,EAAE,EAAE;IAC5C,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,uBAAuB,GAAG,aAAa,CAAC,IAAI,EAAE;QAClD,aAAa,EAAE,YAAY;QAC3B,SAAS,EAAE,eAAe;KAC3B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,CAAC,cAAc,IAAI,CAAC,uBAAuB,CAAC;IAE5D,OAAO,CACL,MAAC,IAAI,mBACU,OAAO,CAAC,aAAa,EAClC,EAAE,EAAE,uBAAuB,EAC3B,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EACxB,GAAG,EAAE,YAAY,aAEhB,OAAO,IAAI,CACV,KAAC,wBAAwB,IACvB,OAAO,EAAC,SAAS,EACjB,MAAM,EAAE,OAAO,gBACH,CAAC,CAAC,wBAAwB,CAAC,EACvC,OAAO,EAAE,OAAO,GAChB,CACH,EACA,SAAS,IAAI,CACZ,KAAC,0BAA0B,IACzB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACvC,MAAM,EAAE,SAAS,gBACL,CAAC,CAAC,gBAAgB,CAAC,GAC/B,CACH,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { FC, PropsWithoutRef, useRef } from 'react';\n\nimport { Grid, ForwardProps, useI18n, useBreakpoint } from '@pega/cosmos-react-core';\n\nimport {\n StyledCaseSummaryFields,\n StyledSummaryPrimaryList,\n StyledSummarySecondaryList\n} from './CaseView.styles';\nimport { CaseSummaryFieldsProps } from './CaseView.types';\nimport { useCaseViewContext } from './CaseView.context';\n\nconst CaseSummaryFields: FC<CaseSummaryFieldsProps & ForwardProps> = ({\n primary,\n secondary,\n inSummaryPanel\n}: PropsWithoutRef<CaseSummaryFieldsProps>) => {\n const t = useI18n();\n const { testIds } = useCaseViewContext();\n const containerRef = useRef<HTMLDivElement>(null);\n const isSMContentWidthOrAbove = useBreakpoint('sm', {\n breakpointRef: containerRef,\n themeProp: 'content-width'\n });\n const wrapped = !inSummaryPanel && !isSMContentWidthOrAbove;\n\n return (\n <Grid\n data-testid={testIds.summaryFields}\n as={StyledCaseSummaryFields}\n container={{ rowGap: 2 }}\n ref={containerRef}\n >\n {primary && (\n <StyledSummaryPrimaryList\n variant='stacked'\n fields={primary}\n aria-label={t('primary_summary_fields')}\n wrapped={wrapped}\n />\n )}\n {secondary && (\n <StyledSummarySecondaryList\n variant={wrapped ? 'stacked' : 'inline'}\n fields={secondary}\n aria-label={t('summary_fields')}\n />\n )}\n </Grid>\n );\n};\n\nexport default CaseSummaryFields;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CaseView.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/CaseView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyD,MAAM,OAAO,CAAC;AAElF,OAAO,EAUL,YAAY,EAYb,MAAM,yBAAyB,CAAC;AAkBjC,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOvE,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CA8hB9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"CaseView.d.ts","sourceRoot":"","sources":["../../../src/components/CaseView/CaseView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyD,MAAM,OAAO,CAAC;AAElF,OAAO,EAUL,YAAY,EAWb,MAAM,yBAAyB,CAAC;AAmBjC,OAAO,EAAwB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOvE,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,GAAG,YAAY,CAihB9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -5,7 +5,7 @@ import * as moveRightSolidIcon from '@pega/cosmos-react-core/lib/components/Icon
5
5
  import * as moveLeftSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/move-left-solid.icon';
6
6
  import CaseSummary from './CaseSummary';
7
7
  import UtilitiesSummary from './UtilitiesSummary';
8
- import { StyledCaseDrawer, StyledCaseDrawerContent, StyledCaseView, StyledWorkArea, StyledPersistentUtility, StyledSummary, StyledSummaryTabContent, StyledUtilities, StyledUtilToggle } from './CaseView.styles';
8
+ import { StyledCaseDrawer, StyledCaseDrawerContent, StyledCaseView, StyledWorkArea, StyledPersistentUtility, StyledSummary, StyledSummaryTabContent, StyledUtilities, StyledUtilToggle, StyledUtilitiesHeader } from './CaseView.styles';
9
9
  import CaseViewContext from './CaseView.context';
10
10
  import CaseSummaryFields from './CaseSummaryFields';
11
11
  import { getCaseViewTestIds } from './CaseView.test-ids';
@@ -24,9 +24,6 @@ utilities, utilitiesSummaryItems, utilitiesExpanded: utilitiesExpandedProp = tru
24
24
  // Etc...
25
25
  persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
26
26
  const testIds = useTestIds(testId, getCaseViewTestIds);
27
- const summary = useMemo(() => {
28
- return _jsx(CaseSummaryFields, { ...summaryFields });
29
- }, [summaryFields]);
30
27
  // General util hooks
31
28
  const t = useI18n();
32
29
  const direction = useDirection();
@@ -93,67 +90,41 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
93
90
  }
94
91
  // Purposely not listing utilitiesExpanded as a dependency as it is not a trigger and will be captured when BPs change
95
92
  }, [mdOrAbove, lgOrAbove]);
96
- // Generate the tab items based on props and viewport conditions
97
- const tabItems = useMemo(() => {
93
+ // Prepare tabs
94
+ const [tabItems, tabContent] = useMemo(() => {
98
95
  const summaryTab = { id: summaryTabId, name: t('summary') };
99
- if (mdOrAbove) {
100
- return !summaryExpanded || (persistentUtility && !xlOrAbove)
101
- ? [summaryTab, ...tabItemsProp]
102
- : tabItemsProp;
103
- }
104
- const utilityTabs = [];
105
- if (utilities)
106
- utilityTabs.push({ id: utilitiesTabId, name: t('utilities') });
107
- if (persistentUtility) {
108
- utilityTabs.push({ id: persistentUtilityTabId, name: persistentUtility.title });
109
- }
110
- if (isPreview || !smOrAbove || !summaryExpanded) {
111
- return [summaryTab, ...tabItemsProp, ...utilityTabs];
112
- }
113
- return [...tabItemsProp, ...utilityTabs];
114
- }, [
115
- isPreview,
116
- smOrAbove,
117
- mdOrAbove,
118
- xlOrAbove,
119
- summaryTabId,
120
- utilitiesTabId,
121
- persistentUtilityTabId,
122
- utilities,
123
- persistentUtility,
124
- tabItemsProp,
125
- summaryExpanded
126
- ]);
127
- // Setup tab content
128
- const tabContent = useMemo(() => {
129
96
  const summaryTabContent = {
130
97
  id: summaryTabId,
131
- content: (_jsx(Card, { children: _jsx(StyledSummaryTabContent, { children: summary }) }))
98
+ content: (_jsx(Card, { children: _jsx(StyledSummaryTabContent, { children: _jsx(CaseSummaryFields, { ...summaryFields }) }) }))
132
99
  };
100
+ let items = tabItemsProp;
101
+ let content = tabContentProp;
133
102
  if (mdOrAbove) {
134
- return !summaryExpanded || (persistentUtility && !xlOrAbove)
135
- ? [summaryTabContent, ...tabContentProp]
136
- : tabContentProp;
103
+ if (!summaryExpanded || (persistentUtility && !xlOrAbove)) {
104
+ items = [summaryTab, ...tabItemsProp];
105
+ content = [summaryTabContent, ...tabContentProp];
106
+ }
107
+ return [items, content];
137
108
  }
138
- const utilityTabs = [];
109
+ const utilityTabsItems = [];
110
+ const utilityTabsContent = [];
139
111
  if (utilities) {
140
- utilityTabs.push({
112
+ utilityTabsItems.push({ id: utilitiesTabId, name: t('utilities') });
113
+ utilityTabsContent.push({
141
114
  id: utilitiesTabId,
142
115
  content: _jsx(Flex, { container: { direction: 'column', gap: 2 }, children: utilities })
143
116
  });
144
117
  }
145
118
  if (persistentUtility) {
146
- utilityTabs.push({ id: persistentUtilityTabId, content: persistentUtility?.content });
119
+ utilityTabsItems.push({ id: persistentUtilityTabId, name: persistentUtility.title });
120
+ utilityTabsContent.push({ id: persistentUtilityTabId, content: persistentUtility?.content });
147
121
  }
148
- if (isPreview || !smOrAbove || !summaryExpanded) {
149
- return [summaryTabContent, ...tabContentProp, ...utilityTabs];
150
- }
151
- return [...tabContentProp, ...utilityTabs];
122
+ items = [summaryTab, ...tabItemsProp, ...utilityTabsItems];
123
+ content = [summaryTabContent, ...tabContentProp, ...utilityTabsContent];
124
+ return [items, content];
152
125
  }, [
126
+ tabItemsProp,
153
127
  summaryTabId,
154
- summaryFields,
155
- isPreview,
156
- smOrAbove,
157
128
  mdOrAbove,
158
129
  summaryExpanded,
159
130
  persistentUtility,
@@ -228,11 +199,13 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
228
199
  useScrollStick(
229
200
  // isMediumOrAbove means side by side columns | | |
230
201
  mdOrAbove ? { ...scrollStickOptions.current, offset: stickOffset } : undefined);
202
+ // Preview set summary tab active
231
203
  useEffect(() => {
232
204
  if (isPreview) {
233
205
  onTabClick(summaryTabId);
234
206
  }
235
207
  }, []);
208
+ // Initial tab selection
236
209
  useEffect(() => {
237
210
  if (mdOrAbove &&
238
211
  summaryExpanded &&
@@ -245,8 +218,8 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
245
218
  onTabClick(initialTabId);
246
219
  }
247
220
  }, [mdOrAbove]);
221
+ // Initial / summary tab selection
248
222
  useEffect(() => {
249
- // Toggle summary tab selection
250
223
  if (!smOrAbove && currentTabId === initialTabId) {
251
224
  onTabClick(summaryTabId);
252
225
  }
@@ -254,11 +227,18 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
254
227
  onTabClick(initialTabId);
255
228
  }
256
229
  }, [smOrAbove]);
230
+ // Summary tab selection
257
231
  useEffect(() => {
258
232
  if (isPreview) {
259
233
  onTabClick(summaryTabId);
260
234
  }
261
235
  }, [isPreview]);
236
+ // Initial tab selection
237
+ useEffect(() => {
238
+ if (summaryExpanded && currentTabId === summaryTabId) {
239
+ onTabClick(initialTabId);
240
+ }
241
+ }, [summaryExpanded]);
262
242
  // Handles scrolling to tab content for newly clicked tab
263
243
  useEffect(() => {
264
244
  if (!tabContentEl)
@@ -294,7 +274,6 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
294
274
  actions,
295
275
  promotedActions,
296
276
  onEdit,
297
- summary,
298
277
  summaryFields,
299
278
  tabs: {
300
279
  items: tabItems,
@@ -313,7 +292,6 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
313
292
  aboveLG: lgOrAbove,
314
293
  aboveXL: xlOrAbove
315
294
  };
316
- // Here we go...
317
295
  return (_jsxs(_Fragment, { children: [_jsx(CaseViewContext.Provider, { value: ctxValue, children: _jsxs(Grid, { "data-testid": testIds.root, ...restProps, as: StyledCaseView, ref: caseViewRef, container: caseViewGridContainer, item: { area: 'case-view' }, children: [_jsx(Grid
318
296
  // Used for aria-controls on the toggle button
319
297
  , {
@@ -322,23 +300,22 @@ persistentUtility, intelligentGuidance, isPreview = false, ...restProps }) => {
322
300
  direction: 'column',
323
301
  alignContent: 'start',
324
302
  rowGap: 2
325
- }, as: StyledWorkArea, persistentUtility: Boolean(persistentUtility), children: [banners && _jsx("div", { "data-testid": testIds.banners, children: banners }), stages && _jsx("div", { "data-testid": testIds.stages, children: stages }), tasks && _jsx("div", { "data-testid": testIds.tasks, children: tasks }), (!mdOrAbove || (persistentUtility && !xlOrAbove) || !summaryExpanded) && (_jsx(Tabs, { "data-testid": testIds.tabs, tabs: tabItems, onTabClick: onTabClick, currentTabId: currentTabId })), _jsx("div", { ref: setTabContentEl, children: tabContent?.map(({ id, content }) => (_jsx(TabPanel, { "data-testid": currentTabId === id ? testIds.tabContent : undefined, currentTabId: currentTabId, tabId: id, children: content }, id))) })] }), persistentUtility && mdOrAbove && (_jsx(Grid, { as: StyledPersistentUtility, item: { area: 'persistentUtility' }, children: persistentUtility.content })), utilities && mdOrAbove && !lgOrAbove && utilitiesExpanded && (_jsx(Drawer, { as: StyledCaseDrawer, open: utilitiesExpanded, position: 'fixed', placement: direction.end, shadow: true, nullWhenClosed: true, hasPersistentUtility: !!persistentUtility, children: _jsxs(Flex, { as: StyledCaseDrawerContent, container: { direction: 'column', gap: 2 }, id: utilitiesDrawerId, children: [_jsx(Flex, { container: { justify: 'end' }, children: _jsx(Button, { "aria-expanded": utilitiesExpanded ? 'true' : 'false', "aria-controls": utilitiesDrawerId, variant: 'simple', icon: true, onClick: onToggleUtilities, as: StyledUtilToggle, label: t('collapse_utilities_panel'), children: _jsx(Icon, { name: `move-${direction.end}-solid` }) }) }), utilities] }) })), utilities && mdOrAbove && (_jsxs(Grid, { "data-testid": testIds.utilities, ref: (el) => {
303
+ }, as: StyledWorkArea, persistentUtility: Boolean(persistentUtility), children: [banners && _jsx("div", { "data-testid": testIds.banners, children: banners }), stages && _jsx("div", { "data-testid": testIds.stages, children: stages }), tasks && _jsx("div", { "data-testid": testIds.tasks, children: tasks }), (!mdOrAbove || (persistentUtility && !xlOrAbove) || !summaryExpanded) && (_jsx(Tabs, { "data-testid": testIds.tabs, tabs: tabItems, onTabClick: onTabClick, currentTabId: currentTabId })), _jsx("div", { ref: setTabContentEl, children: tabContent?.map(({ id, content }) => (_jsx(TabPanel, { "data-testid": currentTabId === id ? testIds.tabContent : undefined, currentTabId: currentTabId, tabId: id, children: content }, id))) })] }), persistentUtility && mdOrAbove && (_jsx(Grid, { as: StyledPersistentUtility, item: { area: 'persistentUtility' }, "data-app-region": true, children: persistentUtility.content })), utilities && mdOrAbove && !lgOrAbove && utilitiesExpanded && (_jsx(Drawer, { as: StyledCaseDrawer, open: utilitiesExpanded, position: 'fixed', placement: direction.end, shadow: true, nullWhenClosed: true, hasPersistentUtility: !!persistentUtility, children: _jsxs(Flex, { as: StyledCaseDrawerContent, container: { direction: 'column', gap: 2 }, id: utilitiesDrawerId, "data-app-region": true, children: [_jsxs(Flex, { container: { gap: 1, alignContent: 'center' }, children: [_jsx(StyledUtilitiesHeader, { variant: 'h2', children: t('utilities_label') }), _jsx(Button, { "aria-expanded": utilitiesExpanded ? 'true' : 'false', "aria-controls": utilitiesDrawerId, variant: 'simple', icon: true, onClick: onToggleUtilities, as: StyledUtilToggle, label: t('collapse_utilities_panel'), children: _jsx(Icon, { name: `move-${direction.end}-solid` }) })] }), utilities] }) })), utilities && mdOrAbove && (_jsxs(Grid, { "data-testid": testIds.utilities, ref: (el) => {
326
304
  if (el)
327
305
  scrollStickOptions.current?.elements.push(el);
328
306
  }, as: StyledUtilities, container: {
329
307
  cols: 'minmax(0, 1fr)',
330
- rowGap: 2,
331
- pad: [2, 0, 2]
308
+ rowGap: 2
332
309
  }, item: {
333
310
  area: 'utilities'
334
- }, children: [_jsx(Flex, { container: { justify: utilitiesExpanded ? 'end' : 'center' }, children: _jsx(Button, { "aria-expanded": utilitiesExpanded ? 'true' : 'false', "aria-controls": lgOrAbove ? utilitiesId : utilitiesDrawerId, variant: 'simple', icon: true, onClick: () => {
335
- if (!obeyUtilitiesExpandedProp && utilitiesExpandedProp) {
336
- setObeyUtilitiesExpandedProp(true);
337
- }
338
- else {
339
- onToggleUtilities?.();
340
- }
341
- }, as: StyledUtilToggle, label: t(utilitiesExpanded ? 'collapse_utilities_panel' : 'expand_utilities_panel'), children: _jsx(Icon, { name: `move-${utilitiesExpanded ? direction.end : direction.start}-solid` }) }) }), lgOrAbove && utilitiesExpanded && (_jsx(Flex, { container: { direction: 'column', gap: 2 }, id: utilitiesId, children: utilities })), (!utilitiesExpanded || (mdOrAbove && !lgOrAbove)) && (_jsx(UtilitiesSummary, { items: utilitiesSummaryItems, "aria-expanded": utilitiesExpanded ? 'true' : 'false', "aria-controls": lgOrAbove ? utilitiesId : utilitiesDrawerId }))] }))] }) }), intelligentGuidance] }));
311
+ }, "data-app-region": lgOrAbove || !utilitiesExpanded || undefined, "aria-label": t('utilities_label'), children: [_jsxs(Flex, { container: { gap: 1, justify: !utilitiesExpanded ? 'center' : undefined }, children: [utilitiesExpanded && (_jsx(StyledUtilitiesHeader, { variant: 'h2', children: t('utilities_label') })), _jsx(Button, { "aria-expanded": utilitiesExpanded ? 'true' : 'false', "aria-controls": lgOrAbove ? utilitiesId : utilitiesDrawerId, variant: 'simple', icon: true, onClick: () => {
312
+ if (!obeyUtilitiesExpandedProp && utilitiesExpandedProp) {
313
+ setObeyUtilitiesExpandedProp(true);
314
+ }
315
+ else {
316
+ onToggleUtilities?.();
317
+ }
318
+ }, as: StyledUtilToggle, label: t(utilitiesExpanded ? 'collapse_utilities_panel' : 'expand_utilities_panel'), children: _jsx(Icon, { name: `move-${utilitiesExpanded ? direction.end : direction.start}-solid` }) })] }), lgOrAbove && utilitiesExpanded && (_jsx(Flex, { container: { direction: 'column', gap: 2 }, id: utilitiesId, children: utilities })), (!utilitiesExpanded || (mdOrAbove && !lgOrAbove)) && (_jsx(UtilitiesSummary, { items: utilitiesSummaryItems, "aria-expanded": utilitiesExpanded ? 'true' : 'false', "aria-controls": lgOrAbove ? utilitiesId : utilitiesDrawerId }))] }))] }) }), intelligentGuidance] }));
342
319
  };
343
320
  export default CaseView;
344
321
  //# sourceMappingURL=CaseView.js.map