@pega/cosmos-react-work 7.0.0-build.2.2 → 7.0.0-build.20.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.js +1 -2
- package/lib/components/AppAnnouncement/AppAnnouncement.js.map +1 -1
- package/lib/components/Article/Article.d.ts.map +1 -1
- package/lib/components/Article/Article.js +5 -5
- package/lib/components/Article/Article.js.map +1 -1
- package/lib/components/Article/ArticleMeta.d.ts.map +1 -1
- package/lib/components/Article/ArticleMeta.js +2 -2
- package/lib/components/Article/ArticleMeta.js.map +1 -1
- package/lib/components/ArticleList/AIArticleSummary.d.ts +4 -0
- package/lib/components/ArticleList/AIArticleSummary.d.ts.map +1 -0
- package/lib/components/ArticleList/AIArticleSummary.js +18 -0
- package/lib/components/ArticleList/AIArticleSummary.js.map +1 -0
- package/lib/components/ArticleList/ArticleBuddy.d.ts +1 -3
- package/lib/components/ArticleList/ArticleBuddy.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleBuddy.js +29 -52
- package/lib/components/ArticleList/ArticleBuddy.js.map +1 -1
- package/lib/components/ArticleList/ArticleBuddyList.d.ts +5 -0
- package/lib/components/ArticleList/ArticleBuddyList.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleBuddyList.js +22 -0
- package/lib/components/ArticleList/ArticleBuddyList.js.map +1 -0
- package/lib/components/ArticleList/ArticleBuddyResponse.d.ts +9 -0
- package/lib/components/ArticleList/ArticleBuddyResponse.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleBuddyResponse.js +56 -0
- package/lib/components/ArticleList/ArticleBuddyResponse.js.map +1 -0
- package/lib/components/ArticleList/ArticleFeedback.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleFeedback.js +2 -2
- package/lib/components/ArticleList/ArticleFeedback.js.map +1 -1
- package/lib/components/ArticleList/ArticleList.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleList.js +35 -8
- package/lib/components/ArticleList/ArticleList.js.map +1 -1
- package/lib/components/ArticleList/ArticleList.types.d.ts +38 -12
- package/lib/components/ArticleList/ArticleList.types.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleList.types.js.map +1 -1
- package/lib/components/ArticleList/ArticleListHeader.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleListHeader.js +2 -2
- package/lib/components/ArticleList/ArticleListHeader.js.map +1 -1
- package/lib/components/ArticleList/ArticleSummary.d.ts +0 -1
- package/lib/components/ArticleList/ArticleSummary.d.ts.map +1 -1
- package/lib/components/ArticleList/ArticleSummary.js +5 -49
- package/lib/components/ArticleList/ArticleSummary.js.map +1 -1
- package/lib/components/ArticleList/ArticleSummary.styles.d.ts +3 -0
- package/lib/components/ArticleList/ArticleSummary.styles.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleSummary.styles.js +48 -0
- package/lib/components/ArticleList/ArticleSummary.styles.js.map +1 -0
- package/lib/components/ArticleList/ArticleSummaryHeader.d.ts +7 -0
- package/lib/components/ArticleList/ArticleSummaryHeader.d.ts.map +1 -0
- package/lib/components/ArticleList/ArticleSummaryHeader.js +9 -0
- package/lib/components/ArticleList/ArticleSummaryHeader.js.map +1 -0
- package/lib/components/ArticleList/QuestionList.d.ts +13 -0
- package/lib/components/ArticleList/QuestionList.d.ts.map +1 -0
- package/lib/components/ArticleList/QuestionList.js +78 -0
- package/lib/components/ArticleList/QuestionList.js.map +1 -0
- package/lib/components/ArticleList/index.d.ts +2 -2
- package/lib/components/ArticleList/index.d.ts.map +1 -1
- package/lib/components/ArticleList/index.js.map +1 -1
- package/lib/components/Assignments/Assignments.styles.d.ts.map +1 -1
- package/lib/components/Assignments/Assignments.styles.js +14 -14
- package/lib/components/Assignments/Assignments.styles.js.map +1 -1
- package/lib/components/CasePreview/CasePreview.d.ts +7 -1
- package/lib/components/CasePreview/CasePreview.d.ts.map +1 -1
- package/lib/components/CasePreview/CasePreview.js +58 -14
- package/lib/components/CasePreview/CasePreview.js.map +1 -1
- package/lib/components/CaseView/CaseHeader/CaseHeader.d.ts.map +1 -1
- package/lib/components/CaseView/CaseHeader/CaseHeader.js +15 -13
- package/lib/components/CaseView/CaseHeader/CaseHeader.js.map +1 -1
- package/lib/components/CaseView/CaseView.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.js +43 -16
- package/lib/components/CaseView/CaseView.js.map +1 -1
- package/lib/components/CaseView/CaseView.styles.d.ts +7 -1
- package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.styles.js +85 -58
- package/lib/components/CaseView/CaseView.styles.js.map +1 -1
- package/lib/components/CaseView/CaseView.types.d.ts +10 -2
- 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 +1 -1
- package/lib/components/CaseView/UtilitiesSummary.d.ts.map +1 -1
- package/lib/components/CaseView/UtilitiesSummary.js +28 -12
- package/lib/components/CaseView/UtilitiesSummary.js.map +1 -1
- package/lib/components/CaseView/UtilitySummaryItemDialog.d.ts.map +1 -1
- package/lib/components/CaseView/UtilitySummaryItemDialog.js +0 -1
- package/lib/components/CaseView/UtilitySummaryItemDialog.js.map +1 -1
- package/lib/components/Details/Details.d.ts +22 -17
- package/lib/components/Details/Details.d.ts.map +1 -1
- package/lib/components/Details/Details.js +61 -49
- package/lib/components/Details/Details.js.map +1 -1
- package/lib/components/Details/Details.styles.d.ts +17 -27
- package/lib/components/Details/Details.styles.d.ts.map +1 -1
- package/lib/components/Details/Details.styles.js +174 -133
- package/lib/components/Details/Details.styles.js.map +1 -1
- package/lib/components/Details/DetailsList.d.ts +14 -0
- package/lib/components/Details/DetailsList.d.ts.map +1 -0
- package/lib/components/Details/DetailsList.js +31 -0
- package/lib/components/Details/DetailsList.js.map +1 -0
- package/lib/components/Details/index.d.ts +2 -1
- package/lib/components/Details/index.d.ts.map +1 -1
- package/lib/components/Details/index.js +2 -1
- package/lib/components/Details/index.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.d.ts +7 -0
- package/lib/components/GenAICoach/GenAICoach.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.js +151 -0
- package/lib/components/GenAICoach/GenAICoach.js.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts +29 -0
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.styles.js +211 -0
- package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts +2 -0
- package/lib/components/GenAICoach/GenAICoach.test-ids.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.test-ids.js +3 -0
- package/lib/components/GenAICoach/GenAICoach.test-ids.js.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.types.d.ts +53 -0
- package/lib/components/GenAICoach/GenAICoach.types.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.types.js +2 -0
- package/lib/components/GenAICoach/GenAICoach.types.js.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.utils.d.ts +9 -0
- package/lib/components/GenAICoach/GenAICoach.utils.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAICoach.utils.js +10 -0
- package/lib/components/GenAICoach/GenAICoach.utils.js.map +1 -0
- package/lib/components/GenAICoach/GenAIMessage.d.ts +5 -0
- package/lib/components/GenAICoach/GenAIMessage.d.ts.map +1 -0
- package/lib/components/GenAICoach/GenAIMessage.js +25 -0
- package/lib/components/GenAICoach/GenAIMessage.js.map +1 -0
- package/lib/components/GenAICoach/InitialSuggestedMessage.d.ts +5 -0
- package/lib/components/GenAICoach/InitialSuggestedMessage.d.ts.map +1 -0
- package/lib/components/GenAICoach/InitialSuggestedMessage.js +18 -0
- package/lib/components/GenAICoach/InitialSuggestedMessage.js.map +1 -0
- package/lib/components/GenAICoach/index.d.ts +6 -0
- package/lib/components/GenAICoach/index.d.ts.map +1 -0
- package/lib/components/GenAICoach/index.js +5 -0
- package/lib/components/GenAICoach/index.js.map +1 -0
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.d.ts.map +1 -1
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js +66 -77
- package/lib/components/IntelligentGuidance/IntelligentGuidance.styles.js.map +1 -1
- package/lib/components/SearchResults/Filter.js.map +1 -1
- package/lib/components/Stages/Stages.d.ts.map +1 -1
- package/lib/components/Stages/Stages.js +6 -5
- package/lib/components/Stages/Stages.js.map +1 -1
- package/lib/components/Stages/Stages.styles.d.ts +1 -0
- package/lib/components/Stages/Stages.styles.d.ts.map +1 -1
- package/lib/components/Stages/Stages.styles.js +7 -1
- package/lib/components/Stages/Stages.styles.js.map +1 -1
- package/lib/components/Tasks/Tasks.d.ts +5 -0
- package/lib/components/Tasks/Tasks.d.ts.map +1 -1
- package/lib/components/Tasks/Tasks.js +13 -5
- package/lib/components/Tasks/Tasks.js.map +1 -1
- package/lib/components/Timeline/Timeline.d.ts.map +1 -1
- package/lib/components/Timeline/Timeline.js +5 -9
- package/lib/components/Timeline/Timeline.js.map +1 -1
- package/lib/components/Timeline/Timeline.styles.d.ts +1 -0
- package/lib/components/Timeline/Timeline.styles.d.ts.map +1 -1
- package/lib/components/Timeline/Timeline.styles.js +9 -0
- package/lib/components/Timeline/Timeline.styles.js.map +1 -1
- package/lib/components/Timeline/Timeline.types.d.ts +1 -6
- 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 +2 -2
- package/lib/components/Timeline/TimelineItem.js.map +1 -1
- package/lib/components/Timeline/utils.d.ts +1 -4
- package/lib/components/Timeline/utils.d.ts.map +1 -1
- package/lib/components/Timeline/utils.js +0 -9
- package/lib/components/Timeline/utils.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { readableColor } from '
|
|
5
|
-
import { Button, StyledButton, Text, Icon, registerIcon, useI18n, tryCatch, defaultThemeProp, useDirection } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Button, StyledButton, Text, Icon, registerIcon, useI18n, tryCatch, defaultThemeProp, useDirection, readableColor } from '@pega/cosmos-react-core';
|
|
6
5
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
6
|
registerIcon(timesIcon);
|
|
8
7
|
const StyledDismissButton = styled.button `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppAnnouncement.js","sourceRoot":"","sources":["../../../src/components/AppAnnouncement/AppAnnouncement.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"AppAnnouncement.js","sourceRoot":"","sources":["../../../src/components/AppAnnouncement/AppAnnouncement.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAE1F,YAAY,CAAC,SAAS,CAAC,CAAC;AAo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OAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,aACzD,SAAS,IAAI,CACZ,KAAC,MAAM,IACL,EAAE,EAAE,mBAAmB,EACvB,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,SAAS,gBACN,CAAC,CAAC,4CAA4C,CAAC,YAE3D,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,EACD,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,OAAO,IAAI,CAAC,CAAC,sCAAsC,CAAC,GAAQ,EAChF,0BACG,WAAW,IAAI,sBAAI,WAAW,GAAK,EACnC,OAAO,IAAI,CACV,uBACG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;4BAC3B,oDAAoD;4BACpD,OAAO,uBAAiB,IAAI,IAAZ,KAAK,CAAa,CAAC;wBACrC,CAAC,CAAC,GACC,CACN,EACA,YAAY,IAAI,CACf,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAC,QAAQ,YAC5D,YAAY,GACN,CACV,IACG,IACgB,CACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n StyledButton,\n Text,\n Icon,\n registerIcon,\n useI18n,\n tryCatch,\n defaultThemeProp,\n useDirection,\n readableColor\n} from '@pega/cosmos-react-core';\nimport type { BaseProps, ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\n\nregisterIcon(timesIcon);\n\nexport interface AppAnnouncementProps extends BaseProps, NoChildrenProp {\n /** Heading text for the announcement. */\n heading?: string;\n /** Description text for the announcement. */\n description?: string;\n /** Announcement details to be displayed in form of bulleted list. */\n details?: string[];\n /** Url to open with What's new link. */\n whatsNewLink?: string;\n /** Content to populate the announcement button. */\n whatsNewText?: string;\n /** An image source for the decorative background. */\n image?: string;\n /** Callback when user dismisses the announcements. */\n onDismiss?: () => void;\n ref?: Ref<HTMLElement>;\n}\n\nconst StyledDismissButton = styled.button`\n font-size: 1.25rem;\n border: none;\n`;\n\nexport const StyledAppAnnouncement = styled.article<Pick<AppAnnouncementProps, 'image'>>(props => {\n const {\n theme: {\n base: {\n palette: { 'brand-primary': brandBackground },\n shadow,\n spacing\n },\n components: {\n card: { 'border-radius': borderRadius }\n }\n },\n image\n } = props;\n\n const { end } = useDirection();\n const color = tryCatch(() => readableColor(brandBackground));\n\n return css`\n padding: calc(2 * ${spacing});\n background: ${brandBackground};\n border-radius: ${borderRadius};\n color: ${color};\n position: relative;\n\n &::after {\n background: url('${image}') no-repeat;\n background-position: ${end} bottom;\n background-size: contain;\n background-origin: content-box;\n opacity: 0.2;\n content: '';\n display: block;\n position: absolute;\n width: 50%;\n height: 100%;\n inset-inline-end: 0;\n bottom: 0;\n padding: calc(2 * ${spacing});\n }\n\n h2 {\n position: relative;\n z-index: 2;\n margin-bottom: ${spacing};\n }\n\n ${StyledDismissButton} {\n position: absolute;\n top: 0.75rem;\n inset-inline-end: 0.75rem;\n color: inherit;\n z-index: 3;\n &:enabled:hover {\n background: #ffffff19;\n }\n &:enabled:focus {\n box-shadow: ${shadow.focus};\n }\n }\n\n > div {\n width: 75%;\n position: relative;\n z-index: 2;\n\n p,\n ul {\n padding-top: calc(2 * ${spacing});\n }\n\n ul {\n padding-inline-start: calc(2 * ${spacing});\n }\n\n ${StyledButton} {\n margin-top: calc(2 * ${spacing});\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${shadow.focus};\n }\n }\n }\n `;\n});\n\nStyledAppAnnouncement.defaultProps = defaultThemeProp;\n\nconst AppAnnouncement: FunctionComponent<AppAnnouncementProps & ForwardProps> = forwardRef(\n function AppAnnouncement(\n props: PropsWithoutRef<AppAnnouncementProps>,\n ref: AppAnnouncementProps['ref']\n ) {\n const t = useI18n();\n const {\n heading,\n description,\n details,\n whatsNewLink,\n whatsNewText = t('app_announcement_whats_new_button_label'),\n image,\n onDismiss,\n ...restProps\n } = props;\n\n return (\n <StyledAppAnnouncement {...restProps} ref={ref} image={image}>\n {onDismiss && (\n <Button\n as={StyledDismissButton}\n variant='simple'\n icon\n onClick={onDismiss}\n aria-label={t('app_announcement_dismiss_button_label_a11y')}\n >\n <Icon name='times' />\n </Button>\n )}\n <Text variant='h2'>{heading || t('app_announcement_details_list_header')}</Text>\n <div>\n {description && <p>{description}</p>}\n {details && (\n <ul>\n {details.map((item, index) => {\n // eslint-disable-next-line react/no-array-index-key\n return <li key={index}>{item}</li>;\n })}\n </ul>\n )}\n {whatsNewLink && (\n <Button variant='secondary' href={whatsNewLink} target='_blank'>\n {whatsNewText}\n </Button>\n )}\n </div>\n </StyledAppAnnouncement>\n );\n }\n);\n\nexport default AppAnnouncement;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Article.d.ts","sourceRoot":"","sources":["../../../src/components/Article/Article.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAetE,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAI/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,KAAK,gBAAgB,GAAG,CACtB,SAAS,EAAE,gBAAgB,CAA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O,CAAC,gBAAgB,CAAC,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AA8DpD,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,GAAG,YAAY,CAqI3D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -45,11 +45,11 @@ const StyledArticleContent = styled.div(props => {
|
|
|
45
45
|
});
|
|
46
46
|
const StyledBackNavButton = styled(Button)(({ theme: { base: { spacing } } }) => {
|
|
47
47
|
return css `
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: start;
|
|
50
|
+
gap: calc(0.5 * ${spacing});
|
|
51
|
+
margin-inline-end: calc(1.5 * ${spacing});
|
|
52
|
+
`;
|
|
53
53
|
});
|
|
54
54
|
StyledArticleContent.defaultProps = defaultThemeProp;
|
|
55
55
|
StyledArticleWrapper.defaultProps = defaultThemeProp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Article.js","sourceRoot":"","sources":["../../../src/components/Article/Article.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACb,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,cAAc,MAAM,oEAAoE,CAAC;AAGrG,OAAO,iBAAiB,EAAE,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE9F,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,aAAa,MAAM,iBAAiB,CAAC;A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AAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,YAAG,KAAK,GAAQ,GAC9C,EAEN,QAAQ,IAAI,CACX,KAAC,aAAa,IAEV,GAAG,QAAQ;wBACX,UAAU,EAAE,QAAQ,CAAC,EAAE;4BACrB,QAAQ,EAAE,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;wBAC5C,CAAC,GAEH,CACH,EAEA,IAAI,IAAI,CACP,KAAC,IAAI,IAAC,SAAS,QAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,YACjC,KAAC,WAAW,OAAK,IAAI,GAAI,GACpB,CACR,EACD,KAAC,oBAAoB,cAAE,OAAO,GAAwB,EAErD,MAAM,IAAI,CACT,KAAC,aAAa,OACR,UAAU,KACV,CAAC,cAAc;4BACjB,CAAC,CAAC;gCACE,QAAQ,EAAE;oCACR,GAAG,cAAc;oCACjB,UAAU,EAAE,QAAQ,CAAC,EAAE;wCACrB,cAAc,EAAE,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;oCAClD,CAAC;iCACF;6BACF;4BACH,CAAC,CAAC,SAAS,CAAC,GACd,CACH,IACA,CACJ,EACD,KAAC,QAAQ,IACP,OAAO,EAAE,CAAC,CAAC,OAAO,EAClB,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,EACrB,UAAU,EAAE,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC,CAAC,oBAAoB,CAAC,EAAE,GACjE,IACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { ReactNode, FunctionComponent, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n registerIcon,\n Flex,\n MenuButton,\n Text,\n defaultThemeProp,\n Button,\n Icon,\n Progress,\n useI18n,\n useDirection\n} from '@pega/cosmos-react-core';\nimport type {\n MenuItemProps,\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n OmitStrict\n} from '@pega/cosmos-react-core';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\n\nimport type { ArticleListHeaderProps } from '../ArticleList/ArticleList.types';\nimport ArticleListHeader, { StyledArticleListHeader } from '../ArticleList/ArticleListHeader';\n\nimport ArticleRating from './ArticleRating';\nimport type { ArticleRatingProps } from './ArticleRating';\nimport ArticleFooter from './ArticleFooter';\nimport type { ArticleFooterFeedback, ArticleFooterProps } from './ArticleFooter';\nimport ArticleMeta from './ArticleMeta';\nimport type { ArticleMetaProps } from './ArticleMeta';\n\nregisterIcon(caretRightIcon, caretLeftIcon);\n\ntype OnReactionWithId = (\n articleId: BaseArticleProps['articleId'],\n reaction: ArticleRatingProps['reaction']\n) => void;\n\nexport interface BaseArticleProps extends BaseProps, NoChildrenProp {\n articleId: string;\n /** Header to show icon , title and any actions on the container */\n header?: ArticleListHeaderProps;\n /** Control for navigating back */\n backNavigation?: {\n title: string;\n onClick: (e: MouseEvent<HTMLButtonElement>) => void;\n };\n /** Primary actions which needs to be displayed with an icon */\n primaryActions?: {\n /** Unique id for action, used in onClick callback */\n id: string;\n /** Label for this action, shown in tooltip and used for generating aria-label */\n label: string;\n /** Icon to be displayed in the button */\n icon: string;\n /** Callback triggered when a user clicks of presses enter on the action */\n onClick: (id: string, e: MouseEvent<HTMLButtonElement>) => void;\n }[];\n /** Secondary actions that needs to be pushed under more icon */\n secondaryActions?: {\n id: MenuItemProps['id'];\n text: MenuItemProps['primary'];\n onClick: MenuItemProps['onClick'];\n }[];\n /** Article title */\n title: string;\n /** Array of meta data */\n meta?: ArticleMetaProps;\n /** like and dislike status of the article */\n feedback?: OmitStrict<ArticleRatingProps, 'onReaction'> & {\n onReaction: OnReactionWithId;\n };\n /** Article content */\n content: ReactNode;\n /** Footer */\n footer?: OmitStrict<ArticleFooterProps, 'feedback'> & {\n feedback?: OmitStrict<ArticleFooterFeedback, 'onReaction'> & {\n onReaction: OnReactionWithId;\n };\n };\n /** Prop to check visibility of skeleton */\n loading: boolean;\n}\n\nexport type ArticleProps =\n | (BaseArticleProps & { loading?: false })\n | (Partial<BaseArticleProps> & { loading: true });\n\nconst StyledArticleWrapper = styled.div(props => {\n const { theme } = props;\n return css`\n background: ${theme.base.palette['primary-background']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n max-height: inherit;\n\n ${StyledArticleListHeader} {\n padding: 0 0 calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nconst StyledArticleHeader = styled.header`\n flex-shrink: 0;\n`;\n\nconst StyledArticleContent = styled.div(props => {\n const {\n theme,\n theme: {\n base: { spacing }\n }\n } = props;\n\n return css`\n flex-grow: 1;\n overflow-y: auto;\n padding: 0 calc(1.5 * ${spacing});\n margin: 0 calc(-1.5 * ${spacing});\n ul,\n ol {\n padding-left: calc(3 * ${spacing});\n }\n a {\n color: ${theme.components.link.color};\n }\n * {\n margin: revert;\n }\n `;\n});\n\nconst StyledBackNavButton = styled(Button)(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n display: flex;\n align-items: start;\n gap: calc(0.5 * ${spacing});\n margin-inline-end: calc(1.5 * ${spacing});\n `;\n }\n);\n\nStyledArticleContent.defaultProps = defaultThemeProp;\nStyledArticleWrapper.defaultProps = defaultThemeProp;\nStyledBackNavButton.defaultProps = defaultThemeProp;\n\nconst Article: FunctionComponent<ArticleProps & ForwardProps> = (props: ArticleProps) => {\n const {\n articleId,\n header,\n meta,\n title,\n backNavigation,\n content,\n primaryActions,\n secondaryActions,\n footer,\n loading,\n feedback,\n ...restProps\n } = props;\n\n const { feedback: footerFeedback, ...restFooter } = footer ?? {};\n const { rtl, ltr, end, start } = useDirection();\n\n const t = useI18n();\n const backButtonRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n if (!loading) {\n backButtonRef.current?.focus();\n }\n }, [loading]);\n\n return (\n <Flex\n {...restProps}\n container={{ direction: 'column', gap: 1, pad: [1.5, 2] }}\n as={StyledArticleWrapper}\n aria-busy={loading ? true : undefined}\n >\n {header && <ArticleListHeader {...header} />}\n {(backNavigation || primaryActions || secondaryActions) && (\n <Flex container={{ alignItems: 'start' }} item={{ grow: 1 }}>\n <Flex container={{ pad: [1, undefined, undefined] }} item={{ grow: 1 }}>\n <Button\n as={StyledBackNavButton}\n onClick={backNavigation?.onClick}\n variant='link'\n ref={backButtonRef}\n >\n {ltr && <Icon name={`caret-${start}`} />}\n {backNavigation?.title}\n {rtl && <Icon name={`caret-${end}`} />}\n </Button>\n </Flex>\n\n {!loading && (\n <>\n {primaryActions?.map(({ id, label, onClick, icon }) => {\n return (\n <Button\n key={id}\n onClick={(e: MouseEvent<HTMLButtonElement>) => onClick(id, e)}\n variant='simple'\n label={label}\n icon\n >\n <Icon name={icon} />\n </Button>\n );\n })}\n {secondaryActions && (\n <MenuButton\n variant='simple'\n text={t('actions')}\n icon='more'\n iconOnly\n menu={{\n items: secondaryActions.map(({ text, ...rest }) => ({\n ...rest,\n primary: text\n }))\n }}\n />\n )}\n </>\n )}\n </Flex>\n )}\n {!loading && (\n <>\n <Flex container as={StyledArticleHeader}>\n <Text variant={header ? 'h3' : 'h2'}>{title}</Text>\n </Flex>\n\n {feedback && (\n <ArticleRating\n {...{\n ...feedback,\n onReaction: reaction => {\n feedback?.onReaction(articleId, reaction);\n }\n }}\n />\n )}\n\n {meta && (\n <Flex container item={{ shrink: 0 }}>\n <ArticleMeta {...meta} />\n </Flex>\n )}\n <StyledArticleContent>{content}</StyledArticleContent>\n\n {footer && (\n <ArticleFooter\n {...restFooter}\n {...(footerFeedback\n ? {\n feedback: {\n ...footerFeedback,\n onReaction: reaction => {\n footerFeedback?.onReaction(articleId, reaction);\n }\n }\n }\n : undefined)}\n />\n )}\n </>\n )}\n <Progress\n visible={!!loading}\n placement='block'\n message={t('loading')}\n liveConfig={{ contextualLabel: title ?? t('article_label_a11y') }}\n />\n </Flex>\n );\n};\n\nexport default Article;\n"]}
|
|
1
|
+
{"version":3,"file":"Article.js","sourceRoot":"","sources":["../../../src/components/Article/Article.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,YAAY,EACb,MAAM,yBAAyB,CAAC;AAQjC,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,cAAc,MAAM,oEAAoE,CAAC;AAGrG,OAAO,iBAAiB,EAAE,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE9F,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC,YAAY,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AAyD5C,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IAC9C,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACxB,OAAO,GAAG,CAAA;kBACM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;gCAC1B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;;;MAGrD,uBAAuB;gCACG,KAAK,CAAC,IAAI,CAAC,OAAO;;GAE/C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAA;;CAExC,CAAC;AAEF,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IAC9C,MAAM,EACJ,KAAK,EACL,KAAK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wCACrB,cAAc,EAAE,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;oCAClD,CAAC;iCACF;6BACF;4BACH,CAAC,CAAC,SAAS,CAAC,GACd,CACH,IACA,CACJ,EACD,KAAC,QAAQ,IACP,OAAO,EAAE,CAAC,CAAC,OAAO,EAClB,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,EACrB,UAAU,EAAE,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC,CAAC,oBAAoB,CAAC,EAAE,GACjE,IACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { ReactNode, FunctionComponent, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n registerIcon,\n Flex,\n MenuButton,\n Text,\n defaultThemeProp,\n Button,\n Icon,\n Progress,\n useI18n,\n useDirection\n} from '@pega/cosmos-react-core';\nimport type {\n MenuItemProps,\n BaseProps,\n ForwardProps,\n NoChildrenProp,\n OmitStrict\n} from '@pega/cosmos-react-core';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\n\nimport type { ArticleListHeaderProps } from '../ArticleList/ArticleList.types';\nimport ArticleListHeader, { StyledArticleListHeader } from '../ArticleList/ArticleListHeader';\n\nimport ArticleRating from './ArticleRating';\nimport type { ArticleRatingProps } from './ArticleRating';\nimport ArticleFooter from './ArticleFooter';\nimport type { ArticleFooterFeedback, ArticleFooterProps } from './ArticleFooter';\nimport ArticleMeta from './ArticleMeta';\nimport type { ArticleMetaProps } from './ArticleMeta';\n\nregisterIcon(caretRightIcon, caretLeftIcon);\n\ntype OnReactionWithId = (\n articleId: BaseArticleProps['articleId'],\n reaction: ArticleRatingProps['reaction']\n) => void;\n\nexport interface BaseArticleProps extends BaseProps, NoChildrenProp {\n articleId: string;\n /** Header to show icon , title and any actions on the container */\n header?: ArticleListHeaderProps;\n /** Control for navigating back */\n backNavigation?: {\n title: string;\n onClick: (e: MouseEvent<HTMLButtonElement>) => void;\n };\n /** Primary actions which needs to be displayed with an icon */\n primaryActions?: {\n /** Unique id for action, used in onClick callback */\n id: string;\n /** Label for this action, shown in tooltip and used for generating aria-label */\n label: string;\n /** Icon to be displayed in the button */\n icon: string;\n /** Callback triggered when a user clicks of presses enter on the action */\n onClick: (id: string, e: MouseEvent<HTMLButtonElement>) => void;\n }[];\n /** Secondary actions that needs to be pushed under more icon */\n secondaryActions?: {\n id: MenuItemProps['id'];\n text: MenuItemProps['primary'];\n onClick: MenuItemProps['onClick'];\n }[];\n /** Article title */\n title: string;\n /** Array of meta data */\n meta?: ArticleMetaProps;\n /** like and dislike status of the article */\n feedback?: OmitStrict<ArticleRatingProps, 'onReaction'> & {\n onReaction: OnReactionWithId;\n };\n /** Article content */\n content: ReactNode;\n /** Footer */\n footer?: OmitStrict<ArticleFooterProps, 'feedback'> & {\n feedback?: OmitStrict<ArticleFooterFeedback, 'onReaction'> & {\n onReaction: OnReactionWithId;\n };\n };\n /** Prop to check visibility of skeleton */\n loading: boolean;\n}\n\nexport type ArticleProps =\n | (BaseArticleProps & { loading?: false })\n | (Partial<BaseArticleProps> & { loading: true });\n\nconst StyledArticleWrapper = styled.div(props => {\n const { theme } = props;\n return css`\n background: ${theme.base.palette['primary-background']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n max-height: inherit;\n\n ${StyledArticleListHeader} {\n padding: 0 0 calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nconst StyledArticleHeader = styled.header`\n flex-shrink: 0;\n`;\n\nconst StyledArticleContent = styled.div(props => {\n const {\n theme,\n theme: {\n base: { spacing }\n }\n } = props;\n\n return css`\n flex-grow: 1;\n overflow-y: auto;\n padding: 0 calc(1.5 * ${spacing});\n margin: 0 calc(-1.5 * ${spacing});\n ul,\n ol {\n padding-left: calc(3 * ${spacing});\n }\n a {\n color: ${theme.components.link.color};\n }\n * {\n margin: revert;\n }\n `;\n});\n\nconst StyledBackNavButton = styled(Button)(({\n theme: {\n base: { spacing }\n }\n}) => {\n return css`\n display: flex;\n align-items: start;\n gap: calc(0.5 * ${spacing});\n margin-inline-end: calc(1.5 * ${spacing});\n `;\n});\n\nStyledArticleContent.defaultProps = defaultThemeProp;\nStyledArticleWrapper.defaultProps = defaultThemeProp;\nStyledBackNavButton.defaultProps = defaultThemeProp;\n\nconst Article: FunctionComponent<ArticleProps & ForwardProps> = (props: ArticleProps) => {\n const {\n articleId,\n header,\n meta,\n title,\n backNavigation,\n content,\n primaryActions,\n secondaryActions,\n footer,\n loading,\n feedback,\n ...restProps\n } = props;\n\n const { feedback: footerFeedback, ...restFooter } = footer ?? {};\n const { rtl, ltr, end, start } = useDirection();\n\n const t = useI18n();\n const backButtonRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n if (!loading) {\n backButtonRef.current?.focus();\n }\n }, [loading]);\n\n return (\n <Flex\n {...restProps}\n container={{ direction: 'column', gap: 1, pad: [1.5, 2] }}\n as={StyledArticleWrapper}\n aria-busy={loading ? true : undefined}\n >\n {header && <ArticleListHeader {...header} />}\n {(backNavigation || primaryActions || secondaryActions) && (\n <Flex container={{ alignItems: 'start' }} item={{ grow: 1 }}>\n <Flex container={{ pad: [1, undefined, undefined] }} item={{ grow: 1 }}>\n <Button\n as={StyledBackNavButton}\n onClick={backNavigation?.onClick}\n variant='link'\n ref={backButtonRef}\n >\n {ltr && <Icon name={`caret-${start}`} />}\n {backNavigation?.title}\n {rtl && <Icon name={`caret-${end}`} />}\n </Button>\n </Flex>\n\n {!loading && (\n <>\n {primaryActions?.map(({ id, label, onClick, icon }) => {\n return (\n <Button\n key={id}\n onClick={(e: MouseEvent<HTMLButtonElement>) => onClick(id, e)}\n variant='simple'\n label={label}\n icon\n >\n <Icon name={icon} />\n </Button>\n );\n })}\n {secondaryActions && (\n <MenuButton\n variant='simple'\n text={t('actions')}\n icon='more'\n iconOnly\n menu={{\n items: secondaryActions.map(({ text, ...rest }) => ({\n ...rest,\n primary: text\n }))\n }}\n />\n )}\n </>\n )}\n </Flex>\n )}\n {!loading && (\n <>\n <Flex container as={StyledArticleHeader}>\n <Text variant={header ? 'h3' : 'h2'}>{title}</Text>\n </Flex>\n\n {feedback && (\n <ArticleRating\n {...{\n ...feedback,\n onReaction: reaction => {\n feedback?.onReaction(articleId, reaction);\n }\n }}\n />\n )}\n\n {meta && (\n <Flex container item={{ shrink: 0 }}>\n <ArticleMeta {...meta} />\n </Flex>\n )}\n <StyledArticleContent>{content}</StyledArticleContent>\n\n {footer && (\n <ArticleFooter\n {...restFooter}\n {...(footerFeedback\n ? {\n feedback: {\n ...footerFeedback,\n onReaction: reaction => {\n footerFeedback?.onReaction(articleId, reaction);\n }\n }\n }\n : undefined)}\n />\n )}\n </>\n )}\n <Progress\n visible={!!loading}\n placement='block'\n message={t('loading')}\n liveConfig={{ contextualLabel: title ?? t('article_label_a11y') }}\n />\n </Flex>\n );\n};\n\nexport default Article;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleMeta.d.ts","sourceRoot":"","sources":["../../../src/components/Article/ArticleMeta.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ArticleMeta.d.ts","sourceRoot":"","sources":["../../../src/components/Article/ArticleMeta.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAcpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAcpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -4,8 +4,8 @@ import styled, { css } from 'styled-components';
|
|
|
4
4
|
import { DateTimeDisplay, MetaList, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
5
5
|
const StyledMetaList = styled(MetaList)(({ theme: { base: { spacing } } }) => {
|
|
6
6
|
return css `
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
padding: calc(0.5 * ${spacing});
|
|
8
|
+
`;
|
|
9
9
|
});
|
|
10
10
|
StyledMetaList.defaultProps = defaultThemeProp;
|
|
11
11
|
const ArticleMeta = ({ category, publishedDate }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleMeta.js","sourceRoot":"","sources":["../../../src/components/Article/ArticleMeta.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGtF,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"ArticleMeta.js","sourceRoot":"","sources":["../../../src/components/Article/ArticleMeta.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGtF,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EACvC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;0BACc,OAAO;GAC9B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAO/C,MAAM,WAAW,GAAwC,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE;IACvF,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE;QAC7B,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACtB;QACD,IAAI,aAAa,EAAE;YACjB,KAAK,CAAC,IAAI,CAAC,KAAC,eAAe,IAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,GAAG,CAAC,CAAC;SACpF;QAED,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;IAE9B,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,SAAS,GAAI,CAAC;AAC9C,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { useMemo } from 'react';\nimport type { FunctionComponent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { DateTimeDisplay, MetaList, defaultThemeProp } from '@pega/cosmos-react-core';\nimport type { DateTimeDisplayProps } from '@pega/cosmos-react-core';\n\nconst StyledMetaList = styled(MetaList)(({\n theme: {\n base: { spacing }\n }\n}) => {\n return css`\n padding: calc(0.5 * ${spacing});\n `;\n});\n\nStyledMetaList.defaultProps = defaultThemeProp;\n\nexport interface ArticleMetaProps {\n category?: string;\n publishedDate?: DateTimeDisplayProps['value'];\n}\n\nconst ArticleMeta: FunctionComponent<ArticleMetaProps> = ({ category, publishedDate }) => {\n const metaItems = useMemo(() => {\n const items = [];\n if (category) {\n items.push(category);\n }\n if (publishedDate) {\n items.push(<DateTimeDisplay value={publishedDate} variant='date' format='long' />);\n }\n\n return items;\n }, [category, publishedDate]);\n\n return <StyledMetaList items={metaItems} />;\n};\n\nexport default ArticleMeta;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AIArticleSummaryProps } from './ArticleList.types';
|
|
2
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<AIArticleSummaryProps, "ref"> & import("react").RefAttributes<HTMLLIElement>>;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=AIArticleSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIArticleSummary.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/AIArticleSummary.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;;AAUjE,wBAiCG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { CardContent, Text, NumberDisplay, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
+
import { ArticleCard } from './ArticleSummary.styles';
|
|
6
|
+
import ArticleSummaryHeader from './ArticleSummaryHeader';
|
|
7
|
+
const StyledAiArticleCard = styled(ArticleCard) `
|
|
8
|
+
&:not(:last-child) {
|
|
9
|
+
border-block-end: none;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
export default forwardRef(function AIArticleSummary({ articleId, title, href, onTitleClick, actions, score, ...restProps }, ref) {
|
|
13
|
+
const t = useI18n();
|
|
14
|
+
return (_jsxs(StyledAiArticleCard, { ...restProps, as: 'li', ref: ref, children: [_jsx(ArticleSummaryHeader, { articleId: articleId, title: title, actions: actions, onTitleClick: onTitleClick, href: href }), score !== undefined && (_jsx(CardContent, { children: _jsx(Text, { variant: 'secondary', children: t('score', [
|
|
15
|
+
_jsx(NumberDisplay, { value: score, unit: 'percent', formattingOptions: { fractionDigits: 0 } })
|
|
16
|
+
]) }) }))] }));
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=AIArticleSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIArticleSummary.js","sourceRoot":"","sources":["../../../src/components/ArticleList/AIArticleSummary.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,WAAW,EACX,IAAI,EAEJ,aAAa,EACb,OAAO,EACR,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,MAAM,mBAAmB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;;;;CAI9C,CAAC;AAEF,eAAe,UAAU,CAGvB,SAAS,gBAAgB,CACzB,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EACtE,GAAG;IAEH,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,MAAC,mBAAmB,OAAK,SAAS,EAAE,EAAE,EAAC,IAAI,EAAC,GAAG,EAAE,GAAG,aAClD,KAAC,oBAAoB,IACnB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,GACV,EACD,KAAK,KAAK,SAAS,IAAI,CACtB,KAAC,WAAW,cACV,KAAC,IAAI,IAAC,OAAO,EAAC,WAAW,YACtB,CAAC,CAAC,OAAO,EAAE;wBACV,KAAC,aAAa,IACZ,KAAK,EAAE,KAAK,EACZ,IAAI,EAAC,SAAS,EACd,iBAAiB,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,GACxC;qBACH,CAAC,GACG,GACK,CACf,IACmB,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import type { PropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\nimport styled from 'styled-components';\n\nimport {\n CardContent,\n Text,\n type RefElement,\n NumberDisplay,\n useI18n\n} from '@pega/cosmos-react-core';\n\nimport type { AIArticleSummaryProps } from './ArticleList.types';\nimport { ArticleCard } from './ArticleSummary.styles';\nimport ArticleSummaryHeader from './ArticleSummaryHeader';\n\nconst StyledAiArticleCard = styled(ArticleCard)`\n &:not(:last-child) {\n border-block-end: none;\n }\n`;\n\nexport default forwardRef<\n RefElement<AIArticleSummaryProps>,\n PropsWithoutRef<AIArticleSummaryProps>\n>(function AIArticleSummary(\n { articleId, title, href, onTitleClick, actions, score, ...restProps },\n ref\n) {\n const t = useI18n();\n\n return (\n <StyledAiArticleCard {...restProps} as='li' ref={ref}>\n <ArticleSummaryHeader\n articleId={articleId}\n title={title}\n actions={actions}\n onTitleClick={onTitleClick}\n href={href}\n />\n {score !== undefined && (\n <CardContent>\n <Text variant='secondary'>\n {t('score', [\n <NumberDisplay\n value={score}\n unit='percent'\n formattingOptions={{ fractionDigits: 0 }}\n />\n ])}\n </Text>\n </CardContent>\n )}\n </StyledAiArticleCard>\n );\n});\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { FunctionComponent } from 'react';
|
|
2
2
|
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
import type { ArticleBuddyProps } from './ArticleList.types';
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const StyledDisclaimerText: import("styled-components").StyledComponent<FunctionComponent<import("@pega/cosmos-react-core").TextProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
-
export declare const StyledBuddyContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export declare const StyledQueryContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
7
5
|
declare const ArticleBuddy: FunctionComponent<ArticleBuddyProps & ForwardProps>;
|
|
8
6
|
export default ArticleBuddy;
|
|
9
7
|
//# sourceMappingURL=ArticleBuddy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleBuddy.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddy.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ArticleBuddy.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddy.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,OAAO,CAAC;AAc9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,eAAO,MAAM,oBAAoB,yGAWhC,CAAC;AAIF,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CA2ErE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,69 +1,46 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from 'react';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
export const
|
|
8
|
-
return css `
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
border-block-start: 0.0625rem solid ${palette['border-line']};
|
|
11
|
-
padding-block: ${spacing};
|
|
12
|
-
`;
|
|
13
|
-
});
|
|
14
|
-
StyledDisclaimerHeader.defaultProps = defaultThemeProp;
|
|
15
|
-
export const StyledDisclaimerText = styled(Text)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, spacing } } }) => {
|
|
16
|
-
const systemFontSize = calculateFontSize(fontSize, fontScale).xs;
|
|
17
|
-
return css `
|
|
18
|
-
font-style: italic;
|
|
19
|
-
font-size: ${systemFontSize};
|
|
20
|
-
margin-block-end: calc(2.5 * ${spacing});
|
|
21
|
-
`;
|
|
22
|
-
});
|
|
23
|
-
StyledDisclaimerText.defaultProps = defaultThemeProp;
|
|
24
|
-
export const StyledBuddyContainer = styled.div(({ theme: { base: { spacing } } }) => {
|
|
4
|
+
import { Flex, defaultThemeProp, useI18n, Button, useLiveLog, TextArea, AIButton, Progress, getFocusables } from '@pega/cosmos-react-core';
|
|
5
|
+
import ArticleBuddyList from './ArticleBuddyList';
|
|
6
|
+
import ArticleBuddyResponse from './ArticleBuddyResponse';
|
|
7
|
+
export const StyledQueryContainer = styled.div(({ theme: { base: { spacing, colors } } }) => {
|
|
25
8
|
return css `
|
|
26
9
|
padding: calc(2 * ${spacing});
|
|
27
|
-
|
|
28
|
-
max-height: inherit;
|
|
29
|
-
height: 100%;
|
|
10
|
+
background-color: ${colors.gray['extra-light']};
|
|
30
11
|
`;
|
|
31
12
|
});
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const ArticleBuddy = ({ query, onClear, onSubmit, title, content, actions, references, disclaimer, loading = false, error = false, feedback, ...restProps }) => {
|
|
13
|
+
StyledQueryContainer.defaultProps = defaultThemeProp;
|
|
14
|
+
const ArticleBuddy = ({ query, onClear, onSubmit, response, list, loading, ...restProps }) => {
|
|
35
15
|
const t = useI18n();
|
|
36
|
-
const
|
|
16
|
+
const buddyRef = useRef(null);
|
|
37
17
|
const { announcePolite } = useLiveLog();
|
|
38
18
|
useEffect(() => {
|
|
39
|
-
if (content) {
|
|
19
|
+
if (response?.content) {
|
|
40
20
|
announcePolite({
|
|
41
21
|
message: t('result_available'),
|
|
42
22
|
type: 'acknowledgement'
|
|
43
23
|
});
|
|
44
24
|
}
|
|
45
|
-
}, [content]);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}) }) }))] }, reference.id));
|
|
66
|
-
})] })), feedback && (_jsx(ArticleFeedback, { comment: feedback.comment, reaction: feedback.reaction, onReaction: feedback.onReaction, onSubmit: feedback.onSubmit }))] })), error && !content && !loading && (_jsx(Flex, { container: { justify: 'center', pad: 1, gap: 1 }, children: _jsx(ErrorState, { message: t('error_message') }) })), disclaimer && (_jsxs(Flex, { container: { direction: 'column' }, children: [_jsx(StyledDisclaimerHeader, { children: t('disclaimer') }), _jsx(StyledDisclaimerText, { children: disclaimer })] }))] }));
|
|
25
|
+
}, [response?.content]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const focusables = getFocusables(buddyRef);
|
|
28
|
+
if (focusables.length > 0) {
|
|
29
|
+
focusables[0].focus();
|
|
30
|
+
}
|
|
31
|
+
}, []);
|
|
32
|
+
return (_jsxs(Flex, { ...restProps, container: { direction: 'column' }, ref: buddyRef, children: [_jsxs(Flex, { as: StyledQueryContainer, container: { direction: 'column', gap: 1 }, children: [_jsx(TextArea, { ...query, autoResize: false, onKeyDown: (e) => {
|
|
33
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
if (query.value?.trim()) {
|
|
36
|
+
onSubmit();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} }), _jsxs(Flex, { container: { gap: 1, justify: 'end' }, children: [query.value && onClear && (_jsx(Button, { variant: 'link', onClick: () => {
|
|
40
|
+
onClear();
|
|
41
|
+
}, children: t('clear') })), _jsx(AIButton, { label: t('ask'), disabled: loading, "aria-label": t('ask_buddy'), onClick: () => {
|
|
42
|
+
onSubmit();
|
|
43
|
+
} })] })] }), _jsx(Progress, { visible: !!loading, placement: 'block', message: t('loading') }), !loading && (_jsxs(_Fragment, { children: [response && _jsx(ArticleBuddyResponse, { ...response }), list && _jsx(ArticleBuddyList, { ...list })] }))] }));
|
|
67
44
|
};
|
|
68
45
|
export default ArticleBuddy;
|
|
69
46
|
//# sourceMappingURL=ArticleBuddy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleBuddy.js","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddy.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAChD,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAC3B,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;4CAE8B,OAAO,CAAC,aAAa,CAAC;uBAC3C,OAAO;KACzB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,CAC9C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,WAAW,E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V,IACI,EACN,SAAS,CAAC,UAAU,IAAI,CACvB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,YACzD,KAAC,IAAI,cACF,YAAY,CAAC,SAAS,CAAC,UAAU,EAAE;oDAClC,MAAM;oDACN,OAAO,EAAE;wDACP,KAAK,EAAE,MAAM;wDACb,IAAI,EAAE,SAAS;wDACf,qBAAqB,EAAE,CAAC;qDACzB;iDACF,CAAC,GACG,GACF,CACR,KA/BkB,SAAS,CAAC,EAAE,CAgC1B,CACR,CAAC;4BACJ,CAAC,CAAC,IACG,CACR,EACA,QAAQ,IAAI,CACX,KAAC,eAAe,IACd,OAAO,EAAE,QAAQ,CAAC,OAAO,EACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,UAAU,EAAE,QAAQ,CAAC,UAAU,EAC/B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAC3B,CACH,IACA,CACJ,EACA,KAAK,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAChC,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YACpD,KAAC,UAAU,IAAC,OAAO,EAAE,CAAC,CAAC,eAAe,CAAC,GAAI,GACtC,CACR,EAEA,UAAU,IAAI,CACb,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,aACtC,KAAC,sBAAsB,cAAE,CAAC,CAAC,YAAY,CAAC,GAA0B,EAClE,KAAC,oBAAoB,cAAE,UAAU,GAAwB,IACpD,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport type { FunctionComponent, MouseEvent, KeyboardEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Text,\n Actions,\n Flex,\n defaultThemeProp,\n useI18n,\n Link,\n calculateFontSize,\n Progress,\n Button,\n useConfiguration,\n formatNumber,\n useLiveLog,\n TextArea,\n AIButton,\n ErrorState\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\n\nimport { isExternalLink, isInternalArticle } from './ArticleList.types';\nimport type { ArticleBuddyProps } from './ArticleList.types';\nimport ArticleFeedback from './ArticleFeedback';\n\nexport const StyledDisclaimerHeader = styled(Text)(\n ({\n theme: {\n base: { spacing, palette }\n }\n }) => {\n return css`\n font-weight: bold;\n border-block-start: 0.0625rem solid ${palette['border-line']};\n padding-block: ${spacing};\n `;\n }\n);\n\nStyledDisclaimerHeader.defaultProps = defaultThemeProp;\n\nexport const StyledDisclaimerText = styled(Text)(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n }) => {\n const systemFontSize = calculateFontSize(fontSize, fontScale).xs;\n return css`\n font-style: italic;\n font-size: ${systemFontSize};\n margin-block-end: calc(2.5 * ${spacing});\n `;\n }\n);\n\nStyledDisclaimerText.defaultProps = defaultThemeProp;\n\nexport const StyledBuddyContainer = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n padding: calc(2 * ${spacing});\n overflow-y: auto;\n max-height: inherit;\n height: 100%;\n `;\n }\n);\n\nStyledBuddyContainer.defaultProps = defaultThemeProp;\n\nconst StyledBuddyArticleHeader = styled.header``;\n\nconst ArticleBuddy: FunctionComponent<ArticleBuddyProps & ForwardProps> = ({\n query,\n onClear,\n onSubmit,\n title,\n content,\n actions,\n references,\n disclaimer,\n loading = false,\n error = false,\n feedback,\n ...restProps\n}) => {\n const t = useI18n();\n const { locale } = useConfiguration();\n const { announcePolite } = useLiveLog();\n\n useEffect(() => {\n if (content) {\n announcePolite({\n message: t('result_available'),\n type: 'acknowledgement'\n });\n }\n }, [content]);\n\n return (\n <Flex\n {...restProps}\n as={StyledBuddyContainer}\n container={{ direction: 'column', gap: 1 }}\n aria-busy={loading ? true : undefined}\n >\n <TextArea\n {...query}\n autoResize={false}\n onKeyDown={(e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n if (query.value?.trim()) {\n onSubmit();\n }\n }\n }}\n />\n <Flex container={{ gap: 1, justify: 'end' }}>\n {query.value && onClear && (\n <Button\n variant='link'\n onClick={() => {\n onClear();\n }}\n >\n {t('clear')}\n </Button>\n )}\n <AIButton\n label={t('ask')}\n disabled={loading}\n onClick={() => {\n onSubmit();\n }}\n />\n </Flex>\n\n {loading && <Progress visible={!!loading} placement='block' message={t('loading')} />}\n {!loading && title && content && (\n <>\n <article>\n <Flex container={{ alignItems: 'start' }} item={{ grow: 1 }}>\n <Flex\n container={{ pad: [1, undefined] }}\n item={{ grow: 1 }}\n as={StyledBuddyArticleHeader}\n >\n <Text variant='h3'>{title}</Text>\n </Flex>\n\n {actions && <Actions items={actions} />}\n </Flex>\n <Flex container item={{ grow: 1 }}>\n {content}\n </Flex>\n </article>\n {references && (\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h3'>{t('references')}</Text>\n {references?.map(reference => {\n return (\n <Flex container key={reference.id}>\n <Flex container={{ alignItems: 'start', gap: 1 }} item={{ grow: 1 }}>\n {isExternalLink(reference) && (\n <Link href={reference.href} target='_blank' key={reference.id}>\n {reference.name}\n </Link>\n )}\n {isInternalArticle(reference) && (\n <Button\n variant='link'\n onClick={(e: MouseEvent<HTMLButtonElement>) =>\n reference.onClick(reference.id, e)\n }\n >\n {reference.name}\n </Button>\n )}\n </Flex>\n {reference.confidence && (\n <Flex container={{ alignItems: 'start' }} item={{ grow: 0 }}>\n <Text>\n {formatNumber(reference.confidence, {\n locale,\n options: {\n style: 'unit',\n unit: 'percent',\n maximumFractionDigits: 0\n }\n })}\n </Text>\n </Flex>\n )}\n </Flex>\n );\n })}\n </Flex>\n )}\n {feedback && (\n <ArticleFeedback\n comment={feedback.comment}\n reaction={feedback.reaction}\n onReaction={feedback.onReaction}\n onSubmit={feedback.onSubmit}\n />\n )}\n </>\n )}\n {error && !content && !loading && (\n <Flex container={{ justify: 'center', pad: 1, gap: 1 }}>\n <ErrorState message={t('error_message')} />\n </Flex>\n )}\n\n {disclaimer && (\n <Flex container={{ direction: 'column' }}>\n <StyledDisclaimerHeader>{t('disclaimer')}</StyledDisclaimerHeader>\n <StyledDisclaimerText>{disclaimer}</StyledDisclaimerText>\n </Flex>\n )}\n </Flex>\n );\n};\n\nexport default ArticleBuddy;\n"]}
|
|
1
|
+
{"version":3,"file":"ArticleBuddy.js","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddy.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,aAAa,EACd,MAAM,yBAAyB,CAAC;AAIjC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAC5C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAC1B,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;0BACY,OAAO;0BACP,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;KAC/C,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,YAAY,GAAwD,CAAC,EACzE,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,GAAG,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S,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,aACxC,KAAK,CAAC,KAAK,IAAI,OAAO,IAAI,CACzB,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;oCACZ,OAAO,EAAE,CAAC;gCACZ,CAAC,YAEA,CAAC,CAAC,OAAO,CAAC,GACJ,CACV,EACD,KAAC,QAAQ,IACP,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EACf,QAAQ,EAAE,OAAO,gBACL,CAAC,CAAC,WAAW,CAAC,EAC1B,OAAO,EAAE,GAAG,EAAE;oCACZ,QAAQ,EAAE,CAAC;gCACb,CAAC,GACD,IACG,IACF,EACP,KAAC,QAAQ,IAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,GAAI,EACxE,CAAC,OAAO,IAAI,CACX,8BACG,QAAQ,IAAI,KAAC,oBAAoB,OAAK,QAAQ,GAAI,EAElD,IAAI,IAAI,KAAC,gBAAgB,OAAK,IAAI,GAAI,IACtC,CACJ,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { FunctionComponent, KeyboardEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n defaultThemeProp,\n useI18n,\n Button,\n useLiveLog,\n TextArea,\n AIButton,\n Progress,\n getFocusables\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\n\nimport type { ArticleBuddyProps } from './ArticleList.types';\nimport ArticleBuddyList from './ArticleBuddyList';\nimport ArticleBuddyResponse from './ArticleBuddyResponse';\n\nexport const StyledQueryContainer = styled.div(\n ({\n theme: {\n base: { spacing, colors }\n }\n }) => {\n return css`\n padding: calc(2 * ${spacing});\n background-color: ${colors.gray['extra-light']};\n `;\n }\n);\n\nStyledQueryContainer.defaultProps = defaultThemeProp;\n\nconst ArticleBuddy: FunctionComponent<ArticleBuddyProps & ForwardProps> = ({\n query,\n onClear,\n onSubmit,\n response,\n list,\n loading,\n ...restProps\n}) => {\n const t = useI18n();\n const buddyRef = useRef<HTMLDivElement>(null);\n const { announcePolite } = useLiveLog();\n\n useEffect(() => {\n if (response?.content) {\n announcePolite({\n message: t('result_available'),\n type: 'acknowledgement'\n });\n }\n }, [response?.content]);\n\n useEffect(() => {\n const focusables = getFocusables(buddyRef);\n if (focusables.length > 0) {\n focusables[0].focus();\n }\n }, []);\n\n return (\n <Flex {...restProps} container={{ direction: 'column' }} ref={buddyRef}>\n <Flex as={StyledQueryContainer} container={{ direction: 'column', gap: 1 }}>\n <TextArea\n {...query}\n autoResize={false}\n onKeyDown={(e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault();\n if (query.value?.trim()) {\n onSubmit();\n }\n }\n }}\n />\n <Flex container={{ gap: 1, justify: 'end' }}>\n {query.value && onClear && (\n <Button\n variant='link'\n onClick={() => {\n onClear();\n }}\n >\n {t('clear')}\n </Button>\n )}\n <AIButton\n label={t('ask')}\n disabled={loading}\n aria-label={t('ask_buddy')}\n onClick={() => {\n onSubmit();\n }}\n />\n </Flex>\n </Flex>\n <Progress visible={!!loading} placement='block' message={t('loading')} />\n {!loading && (\n <>\n {response && <ArticleBuddyResponse {...response} />}\n\n {list && <ArticleBuddyList {...list} />}\n </>\n )}\n </Flex>\n );\n};\n\nexport default ArticleBuddy;\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BuddyListProps } from './ArticleList.types';
|
|
2
|
+
export declare const StyledListContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
declare const _default: import("react").ForwardRefExoticComponent<Omit<BuddyListProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=ArticleBuddyList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArticleBuddyList.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddyList.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,eAAO,MAAM,mBAAmB,yGAQ9B,CAAC;;AAIH,wBAsDE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Flex, defaultThemeProp, useI18n, Button, EmptyState, StyledButton } from '@pega/cosmos-react-core';
|
|
5
|
+
import QuestionList from './QuestionList';
|
|
6
|
+
export const StyledListContainer = styled.div(() => {
|
|
7
|
+
return css `
|
|
8
|
+
overflow-y: auto;
|
|
9
|
+
max-height: inherit;
|
|
10
|
+
${StyledButton} {
|
|
11
|
+
margin: auto;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
});
|
|
15
|
+
StyledListContainer.defaultProps = defaultThemeProp;
|
|
16
|
+
export default forwardRef(function ArticleBuddyList({ autoAnswered, detected, pastQuestions, notRelevantQuestions, showMore = false, onShowMoreToggle, ...restProps }, ref) {
|
|
17
|
+
const t = useI18n();
|
|
18
|
+
return (_jsxs(Flex, { ...restProps, ref: ref, container: { direction: 'column', gap: 1, pad: [1, 2] }, as: StyledListContainer, children: [autoAnswered && autoAnswered.length > 0 && (_jsx(QuestionList, { list: autoAnswered, questionType: 'AUTO_ANSWERED' })), detected && detected.length > 0 && (_jsx(QuestionList, { list: detected, questionType: 'DETECTED' })), pastQuestions && pastQuestions.length > 0 && (_jsx(QuestionList, { list: pastQuestions, questionType: 'PAST_QUESTIONS' })), notRelevantQuestions && notRelevantQuestions.length > 0 && (_jsx(QuestionList, { list: notRelevantQuestions, questionType: 'NOT_RELEVANT' })), !autoAnswered && !detected && !notRelevantQuestions && !pastQuestions && _jsx(EmptyState, {}), onShowMoreToggle && (_jsx(Button, { variant: 'link', as: StyledButton, onClick: () => {
|
|
19
|
+
onShowMoreToggle();
|
|
20
|
+
}, children: t(showMore ? 'show_less' : 'show_more') }))] }));
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=ArticleBuddyList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArticleBuddyList.js","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddyList.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,MAAM,EACN,UAAU,EACV,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;IACjD,OAAO,GAAG,CAAA;;;MAGN,YAAY;;;GAGf,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mBAAmB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEpD,eAAe,UAAU,CACvB,SAAS,gBAAgB,CACvB,EACE,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,oBAAoB,EACpB,QAAQ,GAAG,KAAK,EAChB,gBAAgB,EAChB,GAAG,SAAS,EACb,EACD,GAAG;IAEH,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,OAAO,CACL,MAAC,IAAI,OACC,SAAS,EACb,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACvD,EAAE,EAAE,mBAAmB,aAEtB,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,CAC1C,KAAC,YAAY,IAAC,IAAI,EAAE,YAAY,EAAE,YAAY,EAAC,eAAe,GAAG,CAClE,EAEA,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAClC,KAAC,YAAY,IAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAC,UAAU,GAAG,CACzD,EAEA,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,CAC5C,KAAC,YAAY,IAAC,IAAI,EAAE,aAAa,EAAE,YAAY,EAAC,gBAAgB,GAAG,CACpE,EAEA,oBAAoB,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,IAAI,CAC1D,KAAC,YAAY,IAAC,IAAI,EAAE,oBAAoB,EAAE,YAAY,EAAC,cAAc,GAAG,CACzE,EAEA,CAAC,YAAY,IAAI,CAAC,QAAQ,IAAI,CAAC,oBAAoB,IAAI,CAAC,aAAa,IAAI,KAAC,UAAU,KAAG,EAEvF,gBAAgB,IAAI,CACnB,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,EAAE,EAAE,YAAY,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,gBAAgB,EAAE,CAAC;gBACrB,CAAC,YAEA,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,GACjC,CACV,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import type { PropsWithoutRef } from 'react';\nimport { forwardRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n defaultThemeProp,\n useI18n,\n Button,\n EmptyState,\n StyledButton,\n type RefElement\n} from '@pega/cosmos-react-core';\n\nimport type { BuddyListProps } from './ArticleList.types';\nimport QuestionList from './QuestionList';\n\nexport const StyledListContainer = styled.div(() => {\n return css`\n overflow-y: auto;\n max-height: inherit;\n ${StyledButton} {\n margin: auto;\n }\n `;\n});\n\nStyledListContainer.defaultProps = defaultThemeProp;\n\nexport default forwardRef<RefElement<BuddyListProps>, PropsWithoutRef<BuddyListProps>>(\n function ArticleBuddyList(\n {\n autoAnswered,\n detected,\n pastQuestions,\n notRelevantQuestions,\n showMore = false,\n onShowMoreToggle,\n ...restProps\n },\n ref\n ) {\n const t = useI18n();\n\n return (\n <Flex\n {...restProps}\n ref={ref}\n container={{ direction: 'column', gap: 1, pad: [1, 2] }}\n as={StyledListContainer}\n >\n {autoAnswered && autoAnswered.length > 0 && (\n <QuestionList list={autoAnswered} questionType='AUTO_ANSWERED' />\n )}\n\n {detected && detected.length > 0 && (\n <QuestionList list={detected} questionType='DETECTED' />\n )}\n\n {pastQuestions && pastQuestions.length > 0 && (\n <QuestionList list={pastQuestions} questionType='PAST_QUESTIONS' />\n )}\n\n {notRelevantQuestions && notRelevantQuestions.length > 0 && (\n <QuestionList list={notRelevantQuestions} questionType='NOT_RELEVANT' />\n )}\n\n {!autoAnswered && !detected && !notRelevantQuestions && !pastQuestions && <EmptyState />}\n\n {onShowMoreToggle && (\n <Button\n variant='link'\n as={StyledButton}\n onClick={() => {\n onShowMoreToggle();\n }}\n >\n {t(showMore ? 'show_less' : 'show_more')}\n </Button>\n )}\n </Flex>\n );\n }\n);\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { BuddyResponseProps } from './ArticleList.types';
|
|
4
|
+
export declare const StyledDisclaimerHeader: import("styled-components").StyledComponent<FunctionComponent<import("@pega/cosmos-react-core").TextProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
5
|
+
export declare const StyledDisclaimerText: import("styled-components").StyledComponent<FunctionComponent<import("@pega/cosmos-react-core").TextProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
+
export declare const StyledBackButton: import("styled-components").StyledComponent<FunctionComponent<import("@pega/cosmos-react-core").ButtonProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
+
declare const ArticleBuddyResponse: FunctionComponent<BuddyResponseProps & ForwardProps>;
|
|
8
|
+
export default ArticleBuddyResponse;
|
|
9
|
+
//# sourceMappingURL=ArticleBuddyResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArticleBuddyResponse.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddyResponse.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAmB3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAK9D,eAAO,MAAM,sBAAsB,iLAUjC,CAAC;AAIH,eAAO,MAAM,oBAAoB,iLAW/B,CAAC;AAMH,eAAO,MAAM,gBAAgB,mLAS3B,CAAC;AAIH,QAAA,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAkH9E,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { Text, Actions, Flex, defaultThemeProp, useI18n, Link, calculateFontSize, Button, useConfiguration, formatNumber, ErrorState, Icon, useDirection, registerIcon } from '@pega/cosmos-react-core';
|
|
5
|
+
import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
|
|
6
|
+
import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
|
|
7
|
+
import { isExternalLink, isInternalArticle } from './ArticleList.types';
|
|
8
|
+
import ArticleFeedback from './ArticleFeedback';
|
|
9
|
+
registerIcon(caretLeftIcon, caretRightIcon);
|
|
10
|
+
export const StyledDisclaimerHeader = styled(Text)(({ theme: { base: { spacing, palette } } }) => {
|
|
11
|
+
return css `
|
|
12
|
+
font-weight: bold;
|
|
13
|
+
border-block-start: 0.0625rem solid ${palette['border-line']};
|
|
14
|
+
padding-block: ${spacing};
|
|
15
|
+
`;
|
|
16
|
+
});
|
|
17
|
+
StyledDisclaimerHeader.defaultProps = defaultThemeProp;
|
|
18
|
+
export const StyledDisclaimerText = styled(Text)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, spacing } } }) => {
|
|
19
|
+
const systemFontSize = calculateFontSize(fontSize, fontScale).xs;
|
|
20
|
+
return css `
|
|
21
|
+
font-style: italic;
|
|
22
|
+
font-size: ${systemFontSize};
|
|
23
|
+
margin-block-end: calc(2.5 * ${spacing});
|
|
24
|
+
`;
|
|
25
|
+
});
|
|
26
|
+
StyledDisclaimerText.defaultProps = defaultThemeProp;
|
|
27
|
+
const StyledBuddyArticleHeader = styled.header ``;
|
|
28
|
+
export const StyledBackButton = styled(Button)(({ theme: { base: { spacing } } }) => {
|
|
29
|
+
return css `
|
|
30
|
+
align-self: flex-start;
|
|
31
|
+
margin-block: ${spacing};
|
|
32
|
+
`;
|
|
33
|
+
});
|
|
34
|
+
StyledBackButton.defaultProps = defaultThemeProp;
|
|
35
|
+
const ArticleBuddyResponse = ({ title, content, references, actions, feedback, error = false, disclaimer, onBackNavigation, ...restProps }) => {
|
|
36
|
+
const t = useI18n();
|
|
37
|
+
const { locale } = useConfiguration();
|
|
38
|
+
const backButtonRef = useRef(null);
|
|
39
|
+
const { rtl, ltr, end, start } = useDirection();
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (backButtonRef)
|
|
42
|
+
backButtonRef.current?.focus();
|
|
43
|
+
}, []);
|
|
44
|
+
return (_jsxs(Flex, { ...restProps, container: { direction: 'column', pad: [undefined, 2] }, children: [title && content && (_jsxs(_Fragment, { children: [onBackNavigation && (_jsxs(StyledBackButton, { onClick: onBackNavigation, variant: 'link', ref: backButtonRef, children: [ltr && _jsx(Icon, { name: `caret-${start}` }), t('back_to_ai_suggestions'), rtl && _jsx(Icon, { name: `caret-${end}` })] })), _jsxs("article", { children: [_jsxs(Flex, { container: { alignItems: 'start' }, item: { grow: 1 }, children: [_jsx(Flex, { container: { pad: [1, undefined] }, item: { grow: 1 }, as: StyledBuddyArticleHeader, children: _jsx(Text, { variant: 'h3', children: title }) }), actions && _jsx(Actions, { items: actions })] }), _jsx(Flex, { container: true, item: { grow: 1 }, children: content })] }), references && (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, children: [_jsx(Text, { variant: 'h3', children: t('references') }), references?.map(reference => {
|
|
45
|
+
return (_jsxs(Flex, { container: true, children: [_jsxs(Flex, { container: { alignItems: 'start', gap: 1 }, item: { grow: 1 }, children: [isExternalLink(reference) && (_jsx(Link, { href: reference.href, target: '_blank', children: reference.name }, reference.id)), isInternalArticle(reference) && (_jsx(Button, { variant: 'link', onClick: (e) => reference.onClick(reference.id, e), children: reference.name }))] }), reference.confidence && (_jsx(Flex, { container: { alignItems: 'start' }, item: { grow: 0 }, children: _jsx(Text, { children: formatNumber(reference.confidence, {
|
|
46
|
+
locale,
|
|
47
|
+
options: {
|
|
48
|
+
style: 'unit',
|
|
49
|
+
unit: 'percent',
|
|
50
|
+
maximumFractionDigits: 0
|
|
51
|
+
}
|
|
52
|
+
}) }) }))] }, reference.id));
|
|
53
|
+
})] })), feedback && (_jsx(ArticleFeedback, { comment: feedback.comment, reaction: feedback.reaction, onReaction: feedback.onReaction, onSubmit: feedback.onSubmit }))] })), error && !content && (_jsx(Flex, { container: { justify: 'center', pad: 1, gap: 1 }, children: _jsx(ErrorState, { message: t('error_message') }) })), disclaimer && (_jsxs(Flex, { container: { direction: 'column' }, children: [_jsx(StyledDisclaimerHeader, { children: t('disclaimer') }), _jsx(StyledDisclaimerText, { children: disclaimer })] }))] }));
|
|
54
|
+
};
|
|
55
|
+
export default ArticleBuddyResponse;
|
|
56
|
+
//# sourceMappingURL=ArticleBuddyResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArticleBuddyResponse.js","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleBuddyResponse.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,IAAI,EACJ,iBAAiB,EACjB,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,cAAc,MAAM,oEAAoE,CAAC;AAErG,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,YAAY,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAClD,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAC3B,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;0CAE8B,OAAO,CAAC,aAAa,CAAC;qBAC3C,OAAO;GACzB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAChD,KAAK,EAAE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CACpB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YACpD,KAAC,UAAU,IAAC,OAAO,EAAE,CAAC,CAAC,eAAe,CAAC,GAAI,GACtC,CACR,EAEA,UAAU,IAAI,CACb,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,aACtC,KAAC,sBAAsB,cAAE,CAAC,CAAC,YAAY,CAAC,GAA0B,EAClE,KAAC,oBAAoB,cAAE,UAAU,GAAwB,IACpD,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { FunctionComponent, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Text,\n Actions,\n Flex,\n defaultThemeProp,\n useI18n,\n Link,\n calculateFontSize,\n Button,\n useConfiguration,\n formatNumber,\n ErrorState,\n Icon,\n useDirection,\n registerIcon\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\n\nimport { isExternalLink, isInternalArticle } from './ArticleList.types';\nimport type { BuddyResponseProps } from './ArticleList.types';\nimport ArticleFeedback from './ArticleFeedback';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nexport const StyledDisclaimerHeader = styled(Text)(({\n theme: {\n base: { spacing, palette }\n }\n}) => {\n return css`\n font-weight: bold;\n border-block-start: 0.0625rem solid ${palette['border-line']};\n padding-block: ${spacing};\n `;\n});\n\nStyledDisclaimerHeader.defaultProps = defaultThemeProp;\n\nexport const StyledDisclaimerText = styled(Text)(({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n}) => {\n const systemFontSize = calculateFontSize(fontSize, fontScale).xs;\n return css`\n font-style: italic;\n font-size: ${systemFontSize};\n margin-block-end: calc(2.5 * ${spacing});\n `;\n});\n\nStyledDisclaimerText.defaultProps = defaultThemeProp;\n\nconst StyledBuddyArticleHeader = styled.header``;\n\nexport const StyledBackButton = styled(Button)(({\n theme: {\n base: { spacing }\n }\n}) => {\n return css`\n align-self: flex-start;\n margin-block: ${spacing};\n `;\n});\n\nStyledBackButton.defaultProps = defaultThemeProp;\n\nconst ArticleBuddyResponse: FunctionComponent<BuddyResponseProps & ForwardProps> = ({\n title,\n content,\n references,\n actions,\n feedback,\n error = false,\n disclaimer,\n onBackNavigation,\n ...restProps\n}) => {\n const t = useI18n();\n const { locale } = useConfiguration();\n const backButtonRef = useRef<HTMLButtonElement>(null);\n const { rtl, ltr, end, start } = useDirection();\n\n useEffect(() => {\n if (backButtonRef) backButtonRef.current?.focus();\n }, []);\n\n return (\n <Flex {...restProps} container={{ direction: 'column', pad: [undefined, 2] }}>\n {title && content && (\n <>\n {onBackNavigation && (\n <StyledBackButton onClick={onBackNavigation} variant='link' ref={backButtonRef}>\n {ltr && <Icon name={`caret-${start}`} />}\n {t('back_to_ai_suggestions')}\n {rtl && <Icon name={`caret-${end}`} />}\n </StyledBackButton>\n )}\n\n <article>\n <Flex container={{ alignItems: 'start' }} item={{ grow: 1 }}>\n <Flex\n container={{ pad: [1, undefined] }}\n item={{ grow: 1 }}\n as={StyledBuddyArticleHeader}\n >\n <Text variant='h3'>{title}</Text>\n </Flex>\n\n {actions && <Actions items={actions} />}\n </Flex>\n <Flex container item={{ grow: 1 }}>\n {content}\n </Flex>\n </article>\n {references && (\n <Flex container={{ direction: 'column', gap: 1 }}>\n <Text variant='h3'>{t('references')}</Text>\n {references?.map(reference => {\n return (\n <Flex container key={reference.id}>\n <Flex container={{ alignItems: 'start', gap: 1 }} item={{ grow: 1 }}>\n {isExternalLink(reference) && (\n <Link href={reference.href} target='_blank' key={reference.id}>\n {reference.name}\n </Link>\n )}\n {isInternalArticle(reference) && (\n <Button\n variant='link'\n onClick={(e: MouseEvent<HTMLButtonElement>) =>\n reference.onClick(reference.id, e)\n }\n >\n {reference.name}\n </Button>\n )}\n </Flex>\n {reference.confidence && (\n <Flex container={{ alignItems: 'start' }} item={{ grow: 0 }}>\n <Text>\n {formatNumber(reference.confidence, {\n locale,\n options: {\n style: 'unit',\n unit: 'percent',\n maximumFractionDigits: 0\n }\n })}\n </Text>\n </Flex>\n )}\n </Flex>\n );\n })}\n </Flex>\n )}\n {feedback && (\n <ArticleFeedback\n comment={feedback.comment}\n reaction={feedback.reaction}\n onReaction={feedback.onReaction}\n onSubmit={feedback.onSubmit}\n />\n )}\n </>\n )}\n {error && !content && (\n <Flex container={{ justify: 'center', pad: 1, gap: 1 }}>\n <ErrorState message={t('error_message')} />\n </Flex>\n )}\n\n {disclaimer && (\n <Flex container={{ direction: 'column' }}>\n <StyledDisclaimerHeader>{t('disclaimer')}</StyledDisclaimerHeader>\n <StyledDisclaimerText>{disclaimer}</StyledDisclaimerText>\n </Flex>\n )}\n </Flex>\n );\n};\n\nexport default ArticleBuddyResponse;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleFeedback.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleFeedback.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAY1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"ArticleFeedback.d.ts","sourceRoot":"","sources":["../../../src/components/ArticleList/ArticleFeedback.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAY1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,eAAO,MAAM,yBAAyB,iLAQpC,CAAC;AAGH,QAAA,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,GAAG,YAAY,CAoF3E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -4,8 +4,8 @@ import styled, { css } from 'styled-components';
|
|
|
4
4
|
import { Text, Flex, useI18n, Button, TextArea, defaultThemeProp, useLiveLog } from '@pega/cosmos-react-core';
|
|
5
5
|
export const StyledAcknowledgementText = styled(Text)(({ theme: { base: { spacing } } }) => {
|
|
6
6
|
return css `
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
padding-block: calc(2 * ${spacing});
|
|
8
|
+
`;
|
|
9
9
|
});
|
|
10
10
|
StyledAcknowledgementText.defaultProps = defaultThemeProp;
|
|
11
11
|
const ArticleFeedback = ({ comment, reaction, onReaction, onSubmit, ...restProps }) => {
|