@pega/cosmos-react-work 4.0.0-dev.9.1 → 4.0.0-rc.1
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.
- package/lib/components/AppAnnouncement/AppAnnouncement.d.ts +7 -21
- package/lib/components/AppAnnouncement/AppAnnouncement.d.ts.map +1 -1
- package/lib/components/AppAnnouncement/AppAnnouncement.js +3 -2
- package/lib/components/AppAnnouncement/AppAnnouncement.js.map +1 -1
- package/lib/components/AppAnnouncement/index.d.ts +1 -1
- package/lib/components/AppAnnouncement/index.d.ts.map +1 -1
- package/lib/components/AppAnnouncement/index.js.map +1 -1
- package/lib/components/Article/Article.d.ts +49 -0
- package/lib/components/Article/Article.d.ts.map +1 -0
- package/lib/components/Article/Article.js +73 -0
- package/lib/components/Article/Article.js.map +1 -0
- package/lib/components/Article/ArticleFooter.d.ts +40 -0
- package/lib/components/Article/ArticleFooter.d.ts.map +1 -0
- package/lib/components/Article/ArticleFooter.js +54 -0
- package/lib/components/Article/ArticleFooter.js.map +1 -0
- package/lib/components/Article/ArticleMeta.d.ts +13 -0
- package/lib/components/Article/ArticleMeta.d.ts.map +1 -0
- package/lib/components/Article/ArticleMeta.js +24 -0
- package/lib/components/Article/ArticleMeta.js.map +1 -0
- package/lib/components/Article/index.d.ts +5 -0
- package/lib/components/Article/index.d.ts.map +1 -0
- package/lib/components/Article/index.js +3 -0
- package/lib/components/Article/index.js.map +1 -0
- package/lib/components/ArticleList/ArticleList.d.ts +6 -0
- package/lib/components/ArticleList/ArticleList.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleList.js +137 -0
- package/lib/components/ArticleList/ArticleList.js.map +1 -0
- package/lib/components/ArticleList/ArticleList.types.d.ts +87 -0
- package/lib/components/ArticleList/ArticleList.types.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleList.types.js +2 -0
- package/lib/components/ArticleList/ArticleList.types.js.map +1 -0
- package/lib/components/ArticleList/ArticleListFilter.d.ts +6 -0
- package/lib/components/ArticleList/ArticleListFilter.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleListFilter.js +61 -0
- package/lib/components/ArticleList/ArticleListFilter.js.map +1 -0
- package/lib/components/ArticleList/ArticleListHeader.d.ts +5 -0
- package/lib/components/ArticleList/ArticleListHeader.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleListHeader.js +20 -0
- package/lib/components/ArticleList/ArticleListHeader.js.map +1 -0
- package/lib/components/ArticleList/ArticleSummary.d.ts +7 -0
- package/lib/components/ArticleList/ArticleSummary.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleSummary.js +56 -0
- package/lib/components/ArticleList/ArticleSummary.js.map +1 -0
- package/lib/components/ArticleList/index.d.ts +6 -0
- package/lib/components/ArticleList/index.d.ts.map +1 -0
- package/lib/components/ArticleList/index.js +4 -0
- package/lib/components/ArticleList/index.js.map +1 -0
- package/lib/components/Assignments/Assignments.d.ts +21 -0
- package/lib/components/Assignments/Assignments.d.ts.map +1 -0
- package/lib/components/Assignments/Assignments.js +20 -0
- package/lib/components/Assignments/Assignments.js.map +1 -0
- package/lib/components/Assignments/Assignments.styles.d.ts +8 -0
- package/lib/components/Assignments/Assignments.styles.d.ts.map +1 -0
- package/lib/components/Assignments/Assignments.styles.js +41 -0
- package/lib/components/Assignments/Assignments.styles.js.map +1 -0
- package/lib/components/Assignments/index.d.ts +2 -0
- package/lib/components/Assignments/index.d.ts.map +1 -0
- package/lib/components/Assignments/index.js +2 -0
- package/lib/components/Assignments/index.js.map +1 -0
- package/lib/components/CasePreview/CasePreview.d.ts +9 -4
- package/lib/components/CasePreview/CasePreview.d.ts.map +1 -1
- package/lib/components/CasePreview/CasePreview.js +7 -10
- package/lib/components/CasePreview/CasePreview.js.map +1 -1
- package/lib/components/CasePreview/CasePreview.test-ids.d.ts +2 -0
- package/lib/components/CasePreview/CasePreview.test-ids.d.ts.map +1 -0
- package/lib/components/CasePreview/CasePreview.test-ids.js +3 -0
- package/lib/components/CasePreview/CasePreview.test-ids.js.map +1 -0
- package/lib/components/CasePreview/index.d.ts +1 -1
- package/lib/components/CasePreview/index.d.ts.map +1 -1
- package/lib/components/CasePreview/index.js.map +1 -1
- package/lib/components/CaseView/CaseHeader/CaseHeader.d.ts.map +1 -0
- package/lib/components/CaseView/CaseHeader/CaseHeader.js +119 -0
- package/lib/components/CaseView/CaseHeader/CaseHeader.js.map +1 -0
- package/lib/components/CaseView/CaseHeader/Summary.d.ts +6 -0
- package/lib/components/CaseView/CaseHeader/Summary.d.ts.map +1 -0
- package/lib/components/CaseView/CaseHeader/Summary.js +182 -0
- package/lib/components/CaseView/CaseHeader/Summary.js.map +1 -0
- package/lib/components/CaseView/CaseSummary.d.ts.map +1 -1
- package/lib/components/CaseView/CaseSummary.js +9 -4
- package/lib/components/CaseView/CaseSummary.js.map +1 -1
- package/lib/components/CaseView/CaseSummaryFields.d.ts.map +1 -1
- package/lib/components/CaseView/CaseSummaryFields.js +12 -3
- package/lib/components/CaseView/CaseSummaryFields.js.map +1 -1
- package/lib/components/CaseView/CaseView.d.ts +4 -2
- package/lib/components/CaseView/CaseView.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.js +174 -67
- package/lib/components/CaseView/CaseView.js.map +1 -1
- package/lib/components/CaseView/CaseView.styles.d.ts +45 -22
- package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.styles.js +298 -79
- package/lib/components/CaseView/CaseView.styles.js.map +1 -1
- package/lib/components/CaseView/CaseView.test-ids.d.ts +2 -0
- package/lib/components/CaseView/CaseView.test-ids.d.ts.map +1 -0
- package/lib/components/CaseView/CaseView.test-ids.js +17 -0
- package/lib/components/CaseView/CaseView.test-ids.js.map +1 -0
- package/lib/components/CaseView/CaseView.types.d.ts +23 -24
- package/lib/components/CaseView/CaseView.types.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.types.js.map +1 -1
- package/lib/components/CaseView/UtilitiesSummary.d.ts +0 -1
- package/lib/components/CaseView/UtilitiesSummary.d.ts.map +1 -1
- package/lib/components/CaseView/UtilitiesSummary.js +4 -8
- package/lib/components/CaseView/UtilitiesSummary.js.map +1 -1
- package/lib/components/CaseView/index.d.ts +1 -6
- package/lib/components/CaseView/index.d.ts.map +1 -1
- package/lib/components/CaseView/index.js +0 -4
- package/lib/components/CaseView/index.js.map +1 -1
- package/lib/components/ConfigurableLayout/ConfigurableLayout.d.ts.map +1 -1
- package/lib/components/ConfigurableLayout/ConfigurableLayout.js +1 -1
- package/lib/components/ConfigurableLayout/ConfigurableLayout.js.map +1 -1
- package/lib/components/ConfigurableLayout/ConfigurableLayout.types.d.ts +1 -3
- package/lib/components/ConfigurableLayout/ConfigurableLayout.types.d.ts.map +1 -1
- package/lib/components/ConfigurableLayout/ConfigurableLayout.types.js.map +1 -1
- package/lib/components/ConfigurableLayout/index.d.ts +1 -1
- package/lib/components/ConfigurableLayout/index.d.ts.map +1 -1
- package/lib/components/ConfigurableLayout/index.js.map +1 -1
- package/lib/components/Confirmation/Confirmation.d.ts +1 -1
- package/lib/components/Confirmation/Confirmation.d.ts.map +1 -1
- package/lib/components/Confirmation/Confirmation.js +20 -5
- package/lib/components/Confirmation/Confirmation.js.map +1 -1
- package/lib/components/Confirmation/index.d.ts +1 -1
- package/lib/components/Confirmation/index.d.ts.map +1 -1
- package/lib/components/Confirmation/index.js.map +1 -1
- package/lib/components/Details/Details.d.ts +8 -4
- package/lib/components/Details/Details.d.ts.map +1 -1
- package/lib/components/Details/Details.js +33 -21
- package/lib/components/Details/Details.js.map +1 -1
- package/lib/components/Details/Details.styles.d.ts +7 -4
- package/lib/components/Details/Details.styles.d.ts.map +1 -1
- package/lib/components/Details/Details.styles.js +46 -101
- package/lib/components/Details/Details.styles.js.map +1 -1
- package/lib/components/Details/Details.test-ids.d.ts +2 -0
- package/lib/components/Details/Details.test-ids.d.ts.map +1 -0
- package/lib/components/Details/Details.test-ids.js +9 -0
- package/lib/components/Details/Details.test-ids.js.map +1 -0
- package/lib/components/Glimpse/Glimpse.d.ts +10 -10
- package/lib/components/Glimpse/Glimpse.d.ts.map +1 -1
- package/lib/components/Glimpse/Glimpse.js +7 -17
- package/lib/components/Glimpse/Glimpse.js.map +1 -1
- package/lib/components/Glimpse/index.d.ts +1 -1
- package/lib/components/Glimpse/index.d.ts.map +1 -1
- package/lib/components/Glimpse/index.js +0 -1
- package/lib/components/Glimpse/index.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.js +38 -27
- package/lib/components/IntelligentGuidance/IntelligentGuidance.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts +3 -2
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +137 -81
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.types.d.ts +9 -9
- package/lib/components/IntelligentGuidance/IntelligentGuidance.types.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.types.js.map +1 -1
- package/lib/components/IntelligentGuidance/index.d.ts +1 -1
- package/lib/components/IntelligentGuidance/index.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/index.js.map +1 -1
- package/lib/components/Predictions/Predictions.d.ts +6 -0
- package/lib/components/Predictions/Predictions.d.ts.map +1 -0
- package/lib/components/Predictions/Predictions.js +68 -0
- package/lib/components/Predictions/Predictions.js.map +1 -0
- package/lib/components/Predictions/Predictions.types.d.ts +23 -0
- package/lib/components/Predictions/Predictions.types.d.ts.map +1 -0
- package/lib/components/Predictions/Predictions.types.js +2 -0
- package/lib/components/Predictions/Predictions.types.js.map +1 -0
- package/lib/components/Predictions/index.d.ts +3 -0
- package/lib/components/Predictions/index.d.ts.map +1 -0
- package/lib/components/Predictions/index.js +2 -0
- package/lib/components/Predictions/index.js.map +1 -0
- package/lib/components/SearchResults/SearchResults.js +1 -1
- package/lib/components/SearchResults/SearchResults.js.map +1 -1
- package/lib/components/SearchResults/SearchResults.types.d.ts +5 -5
- package/lib/components/SearchResults/SearchResults.types.d.ts.map +1 -1
- package/lib/components/SearchResults/SearchResults.types.js.map +1 -1
- package/lib/components/SearchResults/index.d.ts +1 -1
- package/lib/components/SearchResults/index.d.ts.map +1 -1
- package/lib/components/SearchResults/index.js.map +1 -1
- package/lib/components/Stages/Stages.d.ts.map +1 -1
- package/lib/components/Stages/Stages.js +8 -8
- package/lib/components/Stages/Stages.js.map +1 -1
- package/lib/components/Stages/Stages.styles.d.ts.map +1 -1
- package/lib/components/Stages/Stages.styles.js +0 -2
- package/lib/components/Stages/Stages.styles.js.map +1 -1
- package/lib/components/Stages/index.d.ts +1 -1
- package/lib/components/Stages/index.d.ts.map +1 -1
- package/lib/components/Stages/index.js.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.d.ts.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.js +3 -3
- package/lib/components/Stakeholders/Stakeholders.js.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.types.d.ts +5 -13
- package/lib/components/Stakeholders/Stakeholders.types.d.ts.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.types.js.map +1 -1
- package/lib/components/Stakeholders/index.d.ts +1 -1
- package/lib/components/Stakeholders/index.d.ts.map +1 -1
- package/lib/components/Stakeholders/index.js.map +1 -1
- package/lib/components/Tags/Tags.d.ts +1 -1
- package/lib/components/Tags/Tags.d.ts.map +1 -1
- package/lib/components/Tags/Tags.js +5 -21
- package/lib/components/Tags/Tags.js.map +1 -1
- package/lib/components/Tags/index.d.ts +2 -1
- package/lib/components/Tags/index.d.ts.map +1 -1
- package/lib/components/Tags/index.js.map +1 -1
- package/lib/components/Tasks/TaskList.d.ts +18 -7
- package/lib/components/Tasks/TaskList.d.ts.map +1 -1
- package/lib/components/Tasks/TaskList.js +48 -10
- package/lib/components/Tasks/TaskList.js.map +1 -1
- package/lib/components/Tasks/Tasks.d.ts +21 -15
- package/lib/components/Tasks/Tasks.d.ts.map +1 -1
- package/lib/components/Tasks/Tasks.js +9 -9
- package/lib/components/Tasks/Tasks.js.map +1 -1
- package/lib/components/Tasks/Tasks.test-ids.d.ts +4 -0
- package/lib/components/Tasks/Tasks.test-ids.d.ts.map +1 -0
- package/lib/components/Tasks/Tasks.test-ids.js +5 -0
- package/lib/components/Tasks/Tasks.test-ids.js.map +1 -0
- package/lib/components/Tasks/index.d.ts +3 -5
- package/lib/components/Tasks/index.d.ts.map +1 -1
- package/lib/components/Tasks/index.js +1 -0
- package/lib/components/Tasks/index.js.map +1 -1
- package/lib/components/Timeline/Timeline.d.ts.map +1 -1
- package/lib/components/Timeline/Timeline.js +15 -13
- package/lib/components/Timeline/Timeline.js.map +1 -1
- package/lib/components/Timeline/Timeline.styles.d.ts +4 -5
- package/lib/components/Timeline/Timeline.styles.d.ts.map +1 -1
- package/lib/components/Timeline/Timeline.styles.js +28 -53
- package/lib/components/Timeline/Timeline.styles.js.map +1 -1
- package/lib/components/Timeline/Timeline.types.d.ts +8 -8
- package/lib/components/Timeline/Timeline.types.d.ts.map +1 -1
- package/lib/components/Timeline/Timeline.types.js.map +1 -1
- package/lib/components/Timeline/TimelineItem.d.ts.map +1 -1
- package/lib/components/Timeline/TimelineItem.js +19 -7
- package/lib/components/Timeline/TimelineItem.js.map +1 -1
- package/lib/components/Timeline/TimelineToolbar.js +1 -1
- package/lib/components/Timeline/TimelineToolbar.js.map +1 -1
- package/lib/components/Timeline/index.d.ts +1 -1
- package/lib/components/Timeline/index.d.ts.map +1 -1
- package/lib/components/Timeline/index.js.map +1 -1
- package/lib/components/Timeline/utils.d.ts +1 -0
- package/lib/components/Timeline/utils.d.ts.map +1 -1
- package/lib/components/Timeline/utils.js +12 -0
- package/lib/components/Timeline/utils.js.map +1 -1
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/package.json +14 -14
- package/lib/components/CaseView/CaseHeader.d.ts.map +0 -1
- package/lib/components/CaseView/CaseHeader.js +0 -49
- package/lib/components/CaseView/CaseHeader.js.map +0 -1
- package/lib/components/CaseView/MobileCaseView.d.ts +0 -13
- package/lib/components/CaseView/MobileCaseView.d.ts.map +0 -1
- package/lib/components/CaseView/MobileCaseView.js +0 -25
- package/lib/components/CaseView/MobileCaseView.js.map +0 -1
- /package/lib/components/CaseView/{CaseHeader.d.ts → CaseHeader/CaseHeader.d.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { Button, Card, CardContent, defaultThemeProp, StyledCard, StyledIcon, useDirection } from '@pega/cosmos-react-core';
|
|
3
|
+
export const StyledExpandButton = styled(Button)(({ theme: { base: { animation } } }) => {
|
|
4
|
+
const { rtl } = useDirection();
|
|
5
|
+
return css `
|
|
6
|
+
${StyledIcon} {
|
|
7
|
+
transition: transform ${animation.speed} ${animation.timing.ease};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&[aria-expanded='true'] ${StyledIcon} {
|
|
11
|
+
transform: rotate(90deg);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&[aria-expanded='false'] ${StyledIcon} {
|
|
15
|
+
transform: rotate(${rtl ? 180 : 0}deg);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:hover,
|
|
19
|
+
&:active {
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
});
|
|
24
|
+
StyledExpandButton.defaultProps = defaultThemeProp;
|
|
25
|
+
export const StyledAssignments = styled(Card)(({ theme, openItem }) => {
|
|
26
|
+
return openItem
|
|
27
|
+
? css `
|
|
28
|
+
box-shadow: ${theme.base.shadow.low};
|
|
29
|
+
`
|
|
30
|
+
: null;
|
|
31
|
+
});
|
|
32
|
+
StyledAssignments.defaultProps = defaultThemeProp;
|
|
33
|
+
export const StyledCardContent = styled(CardContent)(({ theme, openItem }) => {
|
|
34
|
+
return css `
|
|
35
|
+
&:not(${StyledCard} ${StyledCard} > &) {
|
|
36
|
+
padding: ${openItem ? theme.base.spacing : '0'} calc(2 * ${theme.base.spacing});
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
});
|
|
40
|
+
StyledCardContent.defaultProps = defaultThemeProp;
|
|
41
|
+
//# sourceMappingURL=Assignments.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assignments.styles.js","sourceRoot":"","sources":["../../../src/components/Assignments/Assignments.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,CAC9C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,SAAS,EAAE,EACpB,EACF,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAC/B,OAAO,GAAG,CAAA;QACN,UAAU;gCACc,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI;;;gCAGxC,UAAU;;;;iCAIT,UAAU;4BACf,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;;;;;;KAOpC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAkB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAyB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC5F,OAAO,QAAQ;QACb,CAAC,CAAC,GAAG,CAAA;sBACa,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;OACpC;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC,CAClD,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtB,OAAO,GAAG,CAAA;cACA,UAAU,IAAI,UAAU;mBACnB,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,KAAK,CAAC,IAAI,CAAC,OAAO;;KAEhF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport {\n Button,\n Card,\n CardContent,\n defaultThemeProp,\n StyledCard,\n StyledIcon,\n useDirection\n} from '@pega/cosmos-react-core';\n\nexport const StyledExpandButton = styled(Button)(\n ({\n theme: {\n base: { animation }\n }\n }) => {\n const { rtl } = useDirection();\n return css`\n ${StyledIcon} {\n transition: transform ${animation.speed} ${animation.timing.ease};\n }\n\n &[aria-expanded='true'] ${StyledIcon} {\n transform: rotate(90deg);\n }\n\n &[aria-expanded='false'] ${StyledIcon} {\n transform: rotate(${rtl ? 180 : 0}deg);\n }\n\n &:hover,\n &:active {\n text-decoration: none;\n }\n `;\n }\n);\n\nStyledExpandButton.defaultProps = defaultThemeProp;\n\nexport const StyledAssignments = styled(Card)<{ openItem?: boolean }>(({ theme, openItem }) => {\n return openItem\n ? css`\n box-shadow: ${theme.base.shadow.low};\n `\n : null;\n});\n\nStyledAssignments.defaultProps = defaultThemeProp;\n\nexport const StyledCardContent = styled(CardContent)<{ openItem?: boolean }>(\n ({ theme, openItem }) => {\n return css`\n &:not(${StyledCard} ${StyledCard} > &) {\n padding: ${openItem ? theme.base.spacing : '0'} calc(2 * ${theme.base.spacing});\n }\n `;\n }\n);\n\nStyledCardContent.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Assignments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Assignments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyB,MAAM,eAAe,CAAC","sourcesContent":["export { default, type AssignmentsProps } from './Assignments';\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FunctionComponent, Ref } from 'react';
|
|
2
|
-
import { ForwardProps, BaseProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
2
|
+
import { ForwardProps, BaseProps, TestIdProp, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
3
|
import { CaseViewProps } from '../CaseView';
|
|
4
|
-
|
|
4
|
+
import { CaseViewContextValue } from '../CaseView/CaseView.types';
|
|
5
|
+
export interface CasePreviewProps extends Pick<CaseViewProps, 'caseId' | 'heading' | 'subheading' | 'parentCases' | 'icon' | 'followed' | 'onFollowedChange' | 'actions' | 'promotedActions' | 'onEdit' | 'summaryFields' | 'tabs' | 'tabContent' | 'stages' | 'tasks' | 'banners' | 'utilities' | 'utilitiesSummaryItems'>, NoChildrenProp, TestIdProp, BaseProps {
|
|
6
|
+
/** A set of props including an href that will be forwarded to the case preview's heading and subheading. */
|
|
7
|
+
caseLink?: CaseViewContextValue['caseLink'];
|
|
5
8
|
/** If true, the Case Preview will be visible. */
|
|
6
9
|
open: boolean;
|
|
7
10
|
/** Callback fired before Case Preview opens. */
|
|
@@ -17,6 +20,8 @@ export interface CasePreviewProps extends Pick<CaseViewProps, 'caseId' | 'headin
|
|
|
17
20
|
/** Reference to the wrapping element. */
|
|
18
21
|
ref?: Ref<HTMLDivElement>;
|
|
19
22
|
}
|
|
20
|
-
declare const
|
|
21
|
-
|
|
23
|
+
declare const _default: FunctionComponent<CasePreviewProps & ForwardProps> & {
|
|
24
|
+
getTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["close"]>;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
|
22
27
|
//# sourceMappingURL=CasePreview.d.ts.map
|
|
@@ -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,cAAc,
|
|
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,EAGf,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,CAAC;CAC3B;;;;AA0KD,wBAA+D"}
|
|
@@ -2,9 +2,10 @@ 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
4
|
import { readableColor } from 'polished';
|
|
5
|
-
import { Drawer, Icon, registerIcon, Button, Flex, tryCatch, defaultThemeProp, useBreakpoint, useElement, useDirection, useI18n, AppShellContext } from '@pega/cosmos-react-core';
|
|
5
|
+
import { Drawer, Icon, registerIcon, Button, Flex, tryCatch, defaultThemeProp, useBreakpoint, useElement, useDirection, useI18n, AppShellContext, useTestIds, withTestIds } from '@pega/cosmos-react-core';
|
|
6
6
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
7
|
import CaseView, { StyledCaseView, StyledCaseViewContent, StyledCaseDrawer, StyledSummaryRegion } from '../CaseView';
|
|
8
|
+
import { getCasePreviewTestIds } from './CasePreview.test-ids';
|
|
8
9
|
registerIcon(timesIcon);
|
|
9
10
|
const StyledPreviewHeader = styled.div(({ theme }) => {
|
|
10
11
|
return css `
|
|
@@ -46,11 +47,6 @@ const StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {
|
|
|
46
47
|
|
|
47
48
|
${StyledCaseViewContent} {
|
|
48
49
|
overflow-y: auto;
|
|
49
|
-
margin-bottom: calc(${theme.base['hit-area']['mouse-min']} + ${theme.base.spacing});
|
|
50
|
-
|
|
51
|
-
@media (pointer: coarse) {
|
|
52
|
-
margin-bottom: calc(${theme.base['hit-area']['finger-min']} + ${theme.base.spacing});
|
|
53
|
-
}
|
|
54
50
|
|
|
55
51
|
& > :last-child {
|
|
56
52
|
padding-bottom: calc(2 * ${theme.base.spacing});
|
|
@@ -59,8 +55,9 @@ const StyledPreviewDrawer = styled(StyledCaseDrawer)(({ theme }) => {
|
|
|
59
55
|
`;
|
|
60
56
|
});
|
|
61
57
|
StyledPreviewDrawer.defaultProps = defaultThemeProp;
|
|
62
|
-
const CasePreview = forwardRef((props, ref)
|
|
63
|
-
const { open: openProp, caseId, heading, subheading, caseLink, parentCases, icon, followed, onFollowedChange, summaryFields, tabs, stages, tasks, tabContent, utilities, utilitiesSummaryItems, actions, banners, onEdit, ...restProps } = props;
|
|
58
|
+
const CasePreview = forwardRef(function CasePreview(props, ref) {
|
|
59
|
+
const { testId, open: openProp, caseId, heading, subheading, caseLink, parentCases, icon, followed, onFollowedChange, summaryFields, tabs, stages, tasks, tabContent, utilities, utilitiesSummaryItems, actions, banners, onEdit, ...restProps } = props;
|
|
60
|
+
const testIds = useTestIds(testId, getCasePreviewTestIds);
|
|
64
61
|
const t = useI18n();
|
|
65
62
|
const { previewTriggerRef } = useContext(AppShellContext);
|
|
66
63
|
const [closeButtonEl, setCloseButtonEl] = useElement();
|
|
@@ -79,7 +76,7 @@ const CasePreview = forwardRef((props, ref) => {
|
|
|
79
76
|
closeButtonEl.focus();
|
|
80
77
|
}
|
|
81
78
|
}, [openProp, closeButtonEl]);
|
|
82
|
-
return (_jsxs(Drawer, { ...restProps, as: StyledPreviewDrawer, role: 'complementary', forwardedAs: Flex, container: { direction: 'column' }, ref: ref, open: open && isSmallOrAbove, position: 'fixed', placement: direction.end, "aria-label": t('preview_of_noun', [heading]), shadow: true, nullWhenClosed: true, children: [_jsx(StyledPreviewActions, { children: _jsx(Button, { variant: 'simple', icon: true, onClick: closePreview, ref: setCloseButtonEl, label: t('close_preview'), children: _jsx(Icon, { name: 'times' }) }) }), _jsx(CaseView, { caseId: caseId, parentCases: parentCases, heading: heading, subheading: subheading, caseLink: caseLink, icon: icon, followed: followed, onFollowedChange: onFollowedChange, summaryFields: summaryFields, tabs: tabs, stages: stages, tasks: tasks, tabContent: tabContent, utilities: utilities, utilitiesSummaryItems: utilitiesSummaryItems, actions: actions, banners: banners, onEdit: onEdit, isPreview: true })] }));
|
|
79
|
+
return (_jsxs(Drawer, { "data-testid": testIds.root, ...restProps, as: StyledPreviewDrawer, role: 'complementary', forwardedAs: Flex, container: { direction: 'column' }, ref: ref, open: open && isSmallOrAbove, position: 'fixed', placement: direction.end, "aria-label": t('preview_of_noun', [heading]), shadow: true, nullWhenClosed: true, children: [_jsx(StyledPreviewActions, { 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(CaseView, { caseId: caseId, parentCases: parentCases, heading: heading, subheading: subheading, caseLink: caseLink, icon: icon, followed: followed, onFollowedChange: onFollowedChange, summaryFields: summaryFields, tabs: tabs, stages: stages, tasks: tasks, tabContent: tabContent, utilities: utilities, utilitiesSummaryItems: utilitiesSummaryItems, actions: actions, banners: banners, onEdit: onEdit, isPreview: true })] }));
|
|
83
80
|
});
|
|
84
|
-
export default CasePreview;
|
|
81
|
+
export default withTestIds(CasePreview, getCasePreviewTestIds);
|
|
85
82
|
//# sourceMappingURL=CasePreview.js.map
|
|
@@ -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,EAC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AAK,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 NoChildrenProp\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';\n\nregisterIcon(timesIcon);\n\nexport interface CasePreviewProps\n extends Pick<\n CaseViewProps,\n | 'caseId'\n | 'heading'\n | 'subheading'\n | 'caseLink'\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 BaseProps {\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 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 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 {...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 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":"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,EACV,WAAW,EACZ,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,EAAE,EAAE;IACnD,OAAO,GAAG,CAAA;eACG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM;wBACnB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;GAC7D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mBAAmB,CAAC,YAAY,G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,GAAG,EAAE,GAAG,EACR,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,MAAM,QACN,cAAc,mBAEd,KAAC,oBAAoB,cACnB,KAAC,MAAM,mBACQ,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,WAAW,EAAE,qBAAqB,CAAC,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 withTestIds\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 function CasePreview(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 withTestIds(CasePreview, getCasePreviewTestIds);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CasePreview.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,0GAAoD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CasePreview.test-ids.js","sourceRoot":"","sources":["../../../src/components/CasePreview/CasePreview.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,EAAE,CAAC,OAAO,CAAU,CAAC,CAAC","sourcesContent":["import { createTestIds } from '@pega/cosmos-react-core';\n\nexport const getCasePreviewTestIds = createTestIds('case-preview', ['close'] as const);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CasePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CasePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CasePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { default } from './CasePreview';\nexport { CasePreviewProps } from './CasePreview';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CasePreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC","sourcesContent":["export { default } from './CasePreview';\nexport type { CasePreviewProps } from './CasePreview';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaseHeader.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseView/CaseHeader/CaseHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA4D,MAAM,OAAO,CAAC;AAoCrF,QAAA,MAAM,UAAU,EAAE,EAgRjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Breadcrumbs, Flex, getEdge, Icon, registerIcon, Text, Link, Button, MenuButton, throttle, useDirection, useI18n, useAfterInitialEffect } from '@pega/cosmos-react-core';
|
|
4
|
+
import * as pencilIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/pencil.icon';
|
|
5
|
+
import * as moreIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/more.icon';
|
|
6
|
+
import { StyledCaseHeader, StyledCaseIconWrap, StyledCaseHeaderText, StyledExpandCollapseSummaryButton, StyledSubheading, StyledHeaderActions, StyledCaseHeaderPromotedAction } from '../CaseView.styles';
|
|
7
|
+
import { useCaseViewContext } from '../CaseView.context';
|
|
8
|
+
import Summary from './Summary';
|
|
9
|
+
registerIcon(pencilIcon, moreIcon);
|
|
10
|
+
const CaseHeader = () => {
|
|
11
|
+
const t = useI18n();
|
|
12
|
+
const { ltr } = useDirection();
|
|
13
|
+
const { testIds, caseId, icon, heading, subheading, actions, caseLink, parentCases, onEdit, followed, onFollowedChange, promotedActions, summaryExpanded, summaryFields, onToggleSummary, isPreview, aboveSM, aboveMD, persistentUtility } = useCaseViewContext();
|
|
14
|
+
const [wrapPromotedActions, setWrapPromotedActions] = useState(false);
|
|
15
|
+
const [summaryResetID, setSummaryResetID] = useState(Math.random());
|
|
16
|
+
const wrapActionsBreakpoint = useRef(null);
|
|
17
|
+
const contentsEl = useRef(null);
|
|
18
|
+
const headerGroupEl = useRef(null);
|
|
19
|
+
const actionsContainerEl = useRef(null);
|
|
20
|
+
const caseActions = actions
|
|
21
|
+
? actions.map(action => {
|
|
22
|
+
return {
|
|
23
|
+
...action,
|
|
24
|
+
primary: action.text,
|
|
25
|
+
visual: action.icon ? _jsx(Icon, { name: action.icon }) : null
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
: undefined;
|
|
29
|
+
const toggleButtonRef = useRef(null);
|
|
30
|
+
// FIXME: This is a hack to get the Tooltip to reset its position when the summary changes layout.
|
|
31
|
+
useAfterInitialEffect(() => {
|
|
32
|
+
if (toggleButtonRef.current && toggleButtonRef.current === document.activeElement) {
|
|
33
|
+
toggleButtonRef.current.blur();
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
toggleButtonRef.current?.focus();
|
|
36
|
+
}, 0);
|
|
37
|
+
}
|
|
38
|
+
}, [summaryExpanded]);
|
|
39
|
+
const showExpandCollapse = !isPreview && aboveMD;
|
|
40
|
+
const collapsedMainHeader = (!isPreview && !aboveMD && aboveSM) || (showExpandCollapse && !summaryExpanded);
|
|
41
|
+
// Actions wrapping
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
if (!wrapPromotedActions &&
|
|
44
|
+
contentsEl.current &&
|
|
45
|
+
headerGroupEl.current &&
|
|
46
|
+
actionsContainerEl.current) {
|
|
47
|
+
const contentStart = getEdge({
|
|
48
|
+
el: contentsEl.current,
|
|
49
|
+
side: 'leading',
|
|
50
|
+
ltr
|
|
51
|
+
});
|
|
52
|
+
const headerGroupEnd = getEdge({
|
|
53
|
+
el: headerGroupEl.current,
|
|
54
|
+
side: 'trailing',
|
|
55
|
+
ltr
|
|
56
|
+
});
|
|
57
|
+
const actionsContainerWidth = actionsContainerEl.current.getBoundingClientRect().width;
|
|
58
|
+
wrapActionsBreakpoint.current =
|
|
59
|
+
Math.ceil(headerGroupEnd) - Math.ceil(contentStart) + Math.ceil(actionsContainerWidth);
|
|
60
|
+
}
|
|
61
|
+
const promotedActionsWrapHandler = () => {
|
|
62
|
+
if (wrapActionsBreakpoint.current && contentsEl.current) {
|
|
63
|
+
setWrapPromotedActions(Math.ceil(contentsEl.current.offsetWidth) < wrapActionsBreakpoint.current);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const resizeObserver = new ResizeObserver(throttle(promotedActionsWrapHandler, 30));
|
|
67
|
+
promotedActionsWrapHandler();
|
|
68
|
+
if (contentsEl.current) {
|
|
69
|
+
resizeObserver.observe(contentsEl.current, { box: 'border-box' });
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
resizeObserver.disconnect();
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
contentsEl,
|
|
76
|
+
headerGroupEl,
|
|
77
|
+
actionsContainerEl,
|
|
78
|
+
promotedActions,
|
|
79
|
+
heading,
|
|
80
|
+
subheading,
|
|
81
|
+
wrapPromotedActions
|
|
82
|
+
]);
|
|
83
|
+
// Reset summary
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
setSummaryResetID(Math.random());
|
|
86
|
+
}, [heading, summaryFields, promotedActions]);
|
|
87
|
+
return (_jsxs(Flex, { "data-testid": testIds.header, as: StyledCaseHeader, container: { direction: 'column', gap: 1.5 }, children: [_jsxs(Flex, { container: true, ref: contentsEl, children: [showExpandCollapse && onToggleSummary && !persistentUtility && (_jsx(StyledExpandCollapseSummaryButton, { ref: toggleButtonRef, onClick: onToggleSummary, label: t(summaryExpanded ? 'collapse' : 'expand'), "aria-label": t(summaryExpanded ? 'collapse_summary' : 'expand_summary'), icon: true, compact: true, children: _jsx(Icon, { name: 'arrow-micro-left' }) })), icon && (_jsx(Flex, { container: true, item: { shrink: 0 }, as: StyledCaseIconWrap, children: icon })), _jsxs(Flex, { as: StyledCaseHeaderText, container: {
|
|
88
|
+
direction: 'column',
|
|
89
|
+
pad: [0.5, 2, 0.5, 1.5],
|
|
90
|
+
alignItems: 'start'
|
|
91
|
+
}, item: aboveSM ? { shrink: wrapPromotedActions ? 1 : 0 } : { shrink: 1, grow: 1 }, ref: headerGroupEl, children: [_jsx(Text, { "data-testid": testIds.heading, variant: 'h1', children: caseLink ? _jsx(Link, { ...caseLink, children: heading }) : heading }), subheading && (!parentCases || subheading !== caseId) && (_jsx(StyledSubheading, { "data-testid": testIds.subheading, children: subheading })), parentCases && (_jsx(Breadcrumbs, { forwardedAs: 'p', path: [
|
|
92
|
+
...parentCases,
|
|
93
|
+
{
|
|
94
|
+
...caseLink,
|
|
95
|
+
id: caseId,
|
|
96
|
+
primary: caseId,
|
|
97
|
+
href: caseLink?.href
|
|
98
|
+
}
|
|
99
|
+
], leafOnly: true }))] }), collapsedMainHeader && !wrapPromotedActions && (_jsx(Summary, { siblingRef: actionsContainerEl }, summaryResetID)), _jsxs(Flex, { as: StyledHeaderActions, item: { shrink: 0 }, container: { alignItems: 'start', pad: [0, 0, 0, 2] }, offsetEnd: !summaryExpanded, ref: actionsContainerEl, children: [collapsedMainHeader &&
|
|
100
|
+
!wrapPromotedActions &&
|
|
101
|
+
promotedActions &&
|
|
102
|
+
promotedActions.length > 0 ? (_jsx(_Fragment, { children: promotedActions.map(promotedAction => (_jsx(StyledCaseHeaderPromotedAction, { variant: 'secondary', onClick: (e) => promotedAction.onClick?.(promotedAction.id, e), children: promotedAction.text }, promotedAction.id))) })) : null, onEdit && (_jsx(Button, { "data-testid": testIds.edit, icon: true, variant: 'simple', onClick: onEdit, label: t('edit'), children: _jsx(Icon, { name: 'pencil' }) })), caseActions && (_jsx(MenuButton, { "data-testid": testIds.actions, icon: 'more', iconOnly: true, variant: 'simple', text: t('actions'), menu: {
|
|
103
|
+
items: followed !== undefined
|
|
104
|
+
? [
|
|
105
|
+
{
|
|
106
|
+
id: 'follow',
|
|
107
|
+
primary: followed ? t('unfollow') : t('follow'),
|
|
108
|
+
onClick: () => onFollowedChange?.(!followed)
|
|
109
|
+
},
|
|
110
|
+
...caseActions
|
|
111
|
+
]
|
|
112
|
+
: caseActions,
|
|
113
|
+
scrollAt: 20
|
|
114
|
+
} }))] })] }), (!collapsedMainHeader || wrapPromotedActions || !aboveSM) &&
|
|
115
|
+
promotedActions &&
|
|
116
|
+
promotedActions.length > 0 ? (_jsx(Flex, { "data-testid": testIds.promotedActions, container: { justify: 'start', wrap: 'wrap', gap: 1, pad: [0, 0, 0.5] }, children: promotedActions.map(({ id, text, onClick }) => (_jsx("div", { children: _jsx(StyledCaseHeaderPromotedAction, { variant: 'secondary', onClick: (e) => onClick?.(id, e), children: text }) }, text))) })) : null] }));
|
|
117
|
+
};
|
|
118
|
+
export default CaseHeader;
|
|
119
|
+
//# sourceMappingURL=CaseHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaseHeader.js","sourceRoot":"","sources":["../../../../src/components/CaseView/CaseHeader/CaseHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErF,OAAO,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,IAAI,EAEJ,MAAM,EACN,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,+DAA+D,CAAC;AAC5F,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AAExF,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,iCAAiC,EACjC,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAEnC,MAAM,UAAU,GAAO,GAAG,EAAE;IAC1B,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;IAE/B,MAAM,EACJ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,aAAa,EACb,eAAe,EACf,SAAS,EACT,OAAO,EACP,OAAO,EACP,iBAAiB,EAClB,GAAG,kBAAkB,EAAE,CAAC;IAEzB,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,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C,mBAAmB,IAAI,mBAAmB,IAAI,CAAC,OAAO,CAAC;gBAC1D,eAAe;gBACf,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC3B,KAAC,IAAI,mBACU,OAAO,CAAC,eAAe,EACpC,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,YAEtE,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAC9C,wBACE,KAAC,8BAA8B,IAC7B,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,YAE9D,IAAI,GAC0B,IANzB,IAAI,CAOR,CACP,CAAC,GACG,CACR,CAAC,CAAC,CAAC,IAAI,IACH,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FC, MouseEvent, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nimport {\n Breadcrumbs,\n Flex,\n getEdge,\n Icon,\n registerIcon,\n Text,\n Link,\n MenuItemProps,\n Button,\n MenuButton,\n throttle,\n useDirection,\n useI18n,\n useAfterInitialEffect\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 StyledCaseHeader,\n StyledCaseIconWrap,\n StyledCaseHeaderText,\n StyledExpandCollapseSummaryButton,\n StyledSubheading,\n StyledHeaderActions,\n StyledCaseHeaderPromotedAction\n} from '../CaseView.styles';\nimport { useCaseViewContext } from '../CaseView.context';\n\nimport Summary from './Summary';\n\nregisterIcon(pencilIcon, moreIcon);\n\nconst CaseHeader: FC = () => {\n const t = useI18n();\n const { ltr } = useDirection();\n\n const {\n testIds,\n caseId,\n icon,\n heading,\n subheading,\n actions,\n caseLink,\n parentCases,\n onEdit,\n followed,\n onFollowedChange,\n promotedActions,\n summaryExpanded,\n summaryFields,\n onToggleSummary,\n isPreview,\n aboveSM,\n aboveMD,\n persistentUtility\n } = useCaseViewContext();\n\n const [wrapPromotedActions, setWrapPromotedActions] = useState(false);\n const [summaryResetID, setSummaryResetID] = useState<number | undefined>(Math.random());\n\n const wrapActionsBreakpoint = useRef<number | null>(null);\n const contentsEl = useRef<HTMLDivElement>(null);\n const headerGroupEl = useRef<HTMLElement>(null);\n const actionsContainerEl = useRef<HTMLDivElement>(null);\n\n const caseActions: MenuItemProps[] | undefined = actions\n ? actions.map(action => {\n return {\n ...action,\n primary: action.text,\n visual: action.icon ? <Icon name={action.icon} /> : null\n };\n })\n : undefined;\n\n const toggleButtonRef = useRef<HTMLButtonElement>(null);\n\n // FIXME: This is a hack to get the Tooltip to reset its position when the summary changes layout.\n useAfterInitialEffect(() => {\n if (toggleButtonRef.current && toggleButtonRef.current === document.activeElement) {\n toggleButtonRef.current.blur();\n setTimeout(() => {\n toggleButtonRef.current?.focus();\n }, 0);\n }\n }, [summaryExpanded]);\n\n const showExpandCollapse = !isPreview && aboveMD;\n const collapsedMainHeader =\n (!isPreview && !aboveMD && aboveSM) || (showExpandCollapse && !summaryExpanded);\n\n // Actions wrapping\n useLayoutEffect(() => {\n if (\n !wrapPromotedActions &&\n contentsEl.current &&\n headerGroupEl.current &&\n actionsContainerEl.current\n ) {\n const contentStart = getEdge({\n el: contentsEl.current,\n side: 'leading',\n ltr\n });\n const headerGroupEnd = getEdge({\n el: headerGroupEl.current,\n side: 'trailing',\n ltr\n });\n const actionsContainerWidth = actionsContainerEl.current.getBoundingClientRect().width;\n\n wrapActionsBreakpoint.current =\n Math.ceil(headerGroupEnd) - Math.ceil(contentStart) + Math.ceil(actionsContainerWidth);\n }\n\n const promotedActionsWrapHandler = () => {\n if (wrapActionsBreakpoint.current && contentsEl.current) {\n setWrapPromotedActions(\n Math.ceil(contentsEl.current.offsetWidth) < wrapActionsBreakpoint.current\n );\n }\n };\n\n const resizeObserver = new ResizeObserver(throttle(promotedActionsWrapHandler, 30));\n\n promotedActionsWrapHandler();\n\n if (contentsEl.current) {\n resizeObserver.observe(contentsEl.current, { box: 'border-box' });\n }\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [\n contentsEl,\n headerGroupEl,\n actionsContainerEl,\n promotedActions,\n heading,\n subheading,\n wrapPromotedActions\n ]);\n\n // Reset summary\n useEffect(() => {\n setSummaryResetID(Math.random());\n }, [heading, summaryFields, promotedActions]);\n\n return (\n <Flex\n data-testid={testIds.header}\n as={StyledCaseHeader}\n container={{ direction: 'column', gap: 1.5 }}\n >\n <Flex container ref={contentsEl}>\n {showExpandCollapse && onToggleSummary && !persistentUtility && (\n <StyledExpandCollapseSummaryButton\n ref={toggleButtonRef}\n onClick={onToggleSummary}\n label={t(summaryExpanded ? 'collapse' : 'expand')}\n aria-label={t(summaryExpanded ? 'collapse_summary' : 'expand_summary')}\n icon\n compact\n >\n <Icon name='arrow-micro-left' />\n </StyledExpandCollapseSummaryButton>\n )}\n\n {icon && (\n <Flex container item={{ shrink: 0 }} as={StyledCaseIconWrap}>\n {icon}\n </Flex>\n )}\n\n {/* header group */}\n <Flex\n as={StyledCaseHeaderText}\n container={{\n direction: 'column',\n pad: [0.5, 2, 0.5, 1.5],\n alignItems: 'start'\n }}\n item={aboveSM ? { shrink: wrapPromotedActions ? 1 : 0 } : { shrink: 1, grow: 1 }}\n ref={headerGroupEl}\n >\n <Text data-testid={testIds.heading} variant='h1'>\n {caseLink ? <Link {...caseLink}>{heading}</Link> : heading}\n </Text>\n\n {subheading && (!parentCases || subheading !== caseId) && (\n <StyledSubheading data-testid={testIds.subheading}>{subheading}</StyledSubheading>\n )}\n\n {parentCases && (\n <Breadcrumbs\n forwardedAs='p'\n path={[\n ...parentCases,\n {\n ...caseLink,\n id: caseId,\n primary: caseId,\n href: caseLink?.href\n }\n ]}\n leafOnly\n />\n )}\n </Flex>\n\n {/* summary */}\n {collapsedMainHeader && !wrapPromotedActions && (\n <Summary siblingRef={actionsContainerEl} key={summaryResetID} />\n )}\n\n {/* inline actions */}\n <Flex\n as={StyledHeaderActions}\n item={{ shrink: 0 }}\n container={{ alignItems: 'start', pad: [0, 0, 0, 2] }}\n offsetEnd={!summaryExpanded}\n ref={actionsContainerEl}\n >\n {collapsedMainHeader &&\n !wrapPromotedActions &&\n promotedActions &&\n promotedActions.length > 0 ? (\n <>\n {promotedActions.map(promotedAction => (\n <StyledCaseHeaderPromotedAction\n variant='secondary'\n onClick={(e: MouseEvent<HTMLButtonElement>) =>\n promotedAction.onClick?.(promotedAction.id, e)\n }\n key={promotedAction.id}\n >\n {promotedAction.text}\n </StyledCaseHeaderPromotedAction>\n ))}\n </>\n ) : null}\n\n {onEdit && (\n <Button\n data-testid={testIds.edit}\n icon\n variant='simple'\n onClick={onEdit}\n label={t('edit')}\n >\n <Icon name='pencil' />\n </Button>\n )}\n\n {caseActions && (\n <MenuButton\n data-testid={testIds.actions}\n icon='more'\n iconOnly\n variant='simple'\n text={t('actions')}\n menu={{\n items:\n followed !== undefined\n ? [\n {\n id: 'follow',\n primary: followed ? t('unfollow') : t('follow'),\n onClick: () => onFollowedChange?.(!followed)\n },\n ...caseActions\n ]\n : caseActions,\n scrollAt: 20\n }}\n />\n )}\n </Flex>\n </Flex>\n\n {/* wrapped promoted actions */}\n {(!collapsedMainHeader || wrapPromotedActions || !aboveSM) &&\n promotedActions &&\n promotedActions.length > 0 ? (\n <Flex\n data-testid={testIds.promotedActions}\n container={{ justify: 'start', wrap: 'wrap', gap: 1, pad: [0, 0, 0.5] }}\n >\n {promotedActions.map(({ id, text, onClick }) => (\n <div key={text}>\n <StyledCaseHeaderPromotedAction\n variant='secondary'\n onClick={(e: MouseEvent<HTMLButtonElement>) => onClick?.(id, e)}\n >\n {text}\n </StyledCaseHeaderPromotedAction>\n </div>\n ))}\n </Flex>\n ) : null}\n </Flex>\n );\n};\n\nexport default CaseHeader;\n"]}
|
|
@@ -0,0 +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;AAgD/D,QAAA,MAAM,OAAO;gBAAkC,UAAU,cAAc,CAAC;iBAkQvE,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Flex, getEdge, registerIcon, StyledStackedFieldValue, StyledLabel, StyledFieldName, useDirection, useChToPxConversionFactor, NoValue } from '@pega/cosmos-react-core';
|
|
4
|
+
import * as pencilIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/pencil.icon';
|
|
5
|
+
import * as moreIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/more.icon';
|
|
6
|
+
import { StyledHeaderSummary, StyledHeaderSummaryValue, StyledHeaderSummaryBlock } from '../CaseView.styles';
|
|
7
|
+
import { useCaseViewContext } from '../CaseView.context';
|
|
8
|
+
registerIcon(pencilIcon, moreIcon);
|
|
9
|
+
const Field = ({ item, primary, truncate }) => {
|
|
10
|
+
const { name, value, simpleValue } = item;
|
|
11
|
+
const displayValue = simpleValue ?? value ?? _jsx(NoValue, {});
|
|
12
|
+
return (_jsxs(StyledStackedFieldValue, { children: [_jsx(StyledLabel, { as: StyledFieldName, children: name }), _jsx(StyledHeaderSummaryValue, { bold: primary, truncate: truncate, children: displayValue })] }));
|
|
13
|
+
};
|
|
14
|
+
const Summary = ({ siblingRef }) => {
|
|
15
|
+
const { ltr } = useDirection();
|
|
16
|
+
const { summaryFields } = useCaseViewContext();
|
|
17
|
+
const chToPxConversionFactor = useChToPxConversionFactor();
|
|
18
|
+
const containerRef = useRef(null);
|
|
19
|
+
const listRef = useRef(null);
|
|
20
|
+
const primaryItems = summaryFields?.primary ?? [];
|
|
21
|
+
const secondaryItems = summaryFields?.secondary ?? [];
|
|
22
|
+
const items = [...primaryItems, ...secondaryItems];
|
|
23
|
+
const [displayCount, setDisplayCount] = useState(items.length);
|
|
24
|
+
const [truncatedIndices, setTruncatedIndices] = useState(items.map((_, i) => i));
|
|
25
|
+
const priorTrailingEdgeStack = useRef([]);
|
|
26
|
+
const priorAvailableSpace = useRef(null);
|
|
27
|
+
const evalItemAddition = ({ nextSiblingLeadingEdge }) => {
|
|
28
|
+
const indicesToTruncate = truncatedIndices ? [...truncatedIndices] : [];
|
|
29
|
+
let nextDisplayCount = displayCount;
|
|
30
|
+
const reversedTrailingEdgeStack = [...priorTrailingEdgeStack.current].reverse();
|
|
31
|
+
for (let i = 0; i < reversedTrailingEdgeStack.length; i += 1) {
|
|
32
|
+
const priorEdge = reversedTrailingEdgeStack[i];
|
|
33
|
+
const shouldRender = ltr
|
|
34
|
+
? priorEdge < nextSiblingLeadingEdge
|
|
35
|
+
: priorEdge > nextSiblingLeadingEdge;
|
|
36
|
+
if (shouldRender) {
|
|
37
|
+
priorTrailingEdgeStack.current.pop();
|
|
38
|
+
if (!indicesToTruncate.includes(nextDisplayCount)) {
|
|
39
|
+
indicesToTruncate.push(nextDisplayCount);
|
|
40
|
+
}
|
|
41
|
+
nextDisplayCount += 1;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { indicesToTruncate, nextDisplayCount };
|
|
48
|
+
};
|
|
49
|
+
const evalTruncationReduction = ({ listChildren, availableSpace }) => {
|
|
50
|
+
const indicesToTruncate = [];
|
|
51
|
+
let hasAvailableSpace = availableSpace;
|
|
52
|
+
listChildren.forEach((item, index) => {
|
|
53
|
+
const valueEl = item.lastChild;
|
|
54
|
+
const truncatedSpace = Math.floor(valueEl.scrollWidth - valueEl.offsetWidth);
|
|
55
|
+
const shouldTruncate = truncatedSpace === 0 ? false : hasAvailableSpace - truncatedSpace <= 0;
|
|
56
|
+
if (shouldTruncate) {
|
|
57
|
+
if (!truncatedIndices?.includes(index)) {
|
|
58
|
+
hasAvailableSpace += truncatedSpace;
|
|
59
|
+
}
|
|
60
|
+
indicesToTruncate.push(index);
|
|
61
|
+
}
|
|
62
|
+
else if (truncatedIndices?.includes(index)) {
|
|
63
|
+
hasAvailableSpace -= truncatedSpace;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return { indicesToTruncate };
|
|
67
|
+
};
|
|
68
|
+
const evalTruncationIncrease = ({ listChildren, availableSpace }) => {
|
|
69
|
+
const indicesToTruncate = [];
|
|
70
|
+
const lastIndex = listChildren.length - 1;
|
|
71
|
+
let hasAvailableSpace = availableSpace;
|
|
72
|
+
[...listChildren].reverse().forEach((item, index) => {
|
|
73
|
+
if (truncatedIndices?.includes(lastIndex - index)) {
|
|
74
|
+
indicesToTruncate.push(lastIndex - index);
|
|
75
|
+
}
|
|
76
|
+
else if (hasAvailableSpace < 0) {
|
|
77
|
+
const truncatedElMaxWidth = 20 * chToPxConversionFactor;
|
|
78
|
+
const valueEl = item.lastChild;
|
|
79
|
+
const spaceToTruncate = Math.max(Math.floor(valueEl.offsetWidth - truncatedElMaxWidth), 0);
|
|
80
|
+
if (spaceToTruncate) {
|
|
81
|
+
indicesToTruncate.push(lastIndex - index);
|
|
82
|
+
hasAvailableSpace += spaceToTruncate;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return { indicesToTruncate, availableSpace: hasAvailableSpace };
|
|
87
|
+
};
|
|
88
|
+
const evalItemRemoval = ({ listChildren, availableSpace, nextSiblingLeadingEdge }) => {
|
|
89
|
+
let nextDisplayCount = displayCount;
|
|
90
|
+
let hasAvailableSpace = availableSpace;
|
|
91
|
+
let lastChildIndex = listChildren.length - 1;
|
|
92
|
+
do {
|
|
93
|
+
const itemTrailingEdge = getEdge({
|
|
94
|
+
el: listChildren[lastChildIndex],
|
|
95
|
+
side: 'trailing',
|
|
96
|
+
ltr
|
|
97
|
+
});
|
|
98
|
+
hasAvailableSpace = Math.floor(ltr ? nextSiblingLeadingEdge - itemTrailingEdge : itemTrailingEdge - nextSiblingLeadingEdge);
|
|
99
|
+
if (hasAvailableSpace < 0) {
|
|
100
|
+
priorTrailingEdgeStack.current = [...priorTrailingEdgeStack.current, itemTrailingEdge];
|
|
101
|
+
nextDisplayCount -= 1;
|
|
102
|
+
lastChildIndex -= 1;
|
|
103
|
+
}
|
|
104
|
+
} while (hasAvailableSpace < 0 && lastChildIndex > -1);
|
|
105
|
+
return { displayCount: nextDisplayCount };
|
|
106
|
+
};
|
|
107
|
+
const evaluateSummaryDisplay = () => {
|
|
108
|
+
const containerEl = containerRef.current;
|
|
109
|
+
if (!containerEl)
|
|
110
|
+
return;
|
|
111
|
+
const listChildren = Array.from(listRef.current?.children ?? []);
|
|
112
|
+
const lastSummaryItem = listChildren.length ? listChildren[listChildren.length - 1] : undefined;
|
|
113
|
+
const nextSibling = siblingRef?.current ?? document.body;
|
|
114
|
+
const nextSiblingLeadingEdge = getEdge({
|
|
115
|
+
el: nextSibling,
|
|
116
|
+
side: 'leading',
|
|
117
|
+
ltr
|
|
118
|
+
});
|
|
119
|
+
const testEdge = lastSummaryItem
|
|
120
|
+
? getEdge({ el: lastSummaryItem, side: 'trailing', ltr })
|
|
121
|
+
: getEdge({ el: containerEl, side: 'leading', ltr });
|
|
122
|
+
let availableSpace = Math.floor(ltr ? nextSiblingLeadingEdge - testEdge : testEdge - nextSiblingLeadingEdge);
|
|
123
|
+
if (availableSpace === priorAvailableSpace.current)
|
|
124
|
+
return;
|
|
125
|
+
priorAvailableSpace.current = availableSpace;
|
|
126
|
+
let indicesToTruncate;
|
|
127
|
+
let nextDisplayCount = displayCount;
|
|
128
|
+
if (availableSpace >= 0) {
|
|
129
|
+
if (displayCount !== items.length) {
|
|
130
|
+
const additionsConfig = evalItemAddition({ nextSiblingLeadingEdge });
|
|
131
|
+
indicesToTruncate = additionsConfig.indicesToTruncate;
|
|
132
|
+
nextDisplayCount = additionsConfig.nextDisplayCount;
|
|
133
|
+
}
|
|
134
|
+
else if (truncatedIndices?.length) {
|
|
135
|
+
const truncationConfig = evalTruncationReduction({
|
|
136
|
+
listChildren,
|
|
137
|
+
availableSpace
|
|
138
|
+
});
|
|
139
|
+
indicesToTruncate = truncationConfig.indicesToTruncate;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (listChildren) {
|
|
143
|
+
const truncationConfig = evalTruncationIncrease({
|
|
144
|
+
listChildren,
|
|
145
|
+
availableSpace
|
|
146
|
+
});
|
|
147
|
+
indicesToTruncate = truncationConfig.indicesToTruncate;
|
|
148
|
+
availableSpace = truncationConfig.availableSpace;
|
|
149
|
+
if (availableSpace < 0) {
|
|
150
|
+
const removalConfig = evalItemRemoval({
|
|
151
|
+
listChildren,
|
|
152
|
+
availableSpace,
|
|
153
|
+
nextSiblingLeadingEdge
|
|
154
|
+
});
|
|
155
|
+
nextDisplayCount = removalConfig.displayCount;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
setDisplayCount(nextDisplayCount);
|
|
159
|
+
if (indicesToTruncate) {
|
|
160
|
+
setTruncatedIndices(indicesToTruncate);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
// Initial display evaluation
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
evaluateSummaryDisplay();
|
|
166
|
+
}, []);
|
|
167
|
+
// Overflow resize observer
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
const resizeObserver = new ResizeObserver(evaluateSummaryDisplay);
|
|
170
|
+
if (containerRef.current) {
|
|
171
|
+
resizeObserver.observe(containerRef.current, { box: 'border-box' });
|
|
172
|
+
}
|
|
173
|
+
return () => {
|
|
174
|
+
resizeObserver.disconnect();
|
|
175
|
+
};
|
|
176
|
+
}, [evaluateSummaryDisplay]);
|
|
177
|
+
return (_jsx(Flex, { as: StyledHeaderSummaryBlock, item: { grow: 1, shrink: 1 }, container: { pad: [0.5, 0], alignItems: 'center' }, ref: containerRef, hasItems: displayCount > 0, children: _jsx(Flex, { as: StyledHeaderSummary, container: { gap: 4 }, ref: listRef, children: items.slice(0, displayCount).map((item, index) => {
|
|
178
|
+
return (_jsx(Field, { item: item, primary: !!primaryItems?.length && index < primaryItems.length, truncate: !!truncatedIndices?.includes(index) }, item.name));
|
|
179
|
+
}) }) }));
|
|
180
|
+
};
|
|
181
|
+
export default Summary;
|
|
182
|
+
//# sourceMappingURL=Summary.js.map
|