@pega/cosmos-react-work 10.0.0-build.1.9 → 10.0.0-build.2.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/CaseView/CaseView.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.js +5 -11
- package/lib/components/CaseView/CaseView.js.map +1 -1
- package/lib/components/CaseView/CaseView.styles.d.ts.map +1 -1
- package/lib/components/CaseView/CaseView.styles.js +7 -20
- package/lib/components/CaseView/CaseView.styles.js.map +1 -1
- package/lib/components/Details/Details.styles.js +5 -5
- package/lib/components/Details/Details.styles.js.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.d.ts.map +1 -1
- package/lib/components/GenAICoach/GenAICoach.styles.js +3 -4
- package/lib/components/GenAICoach/GenAICoach.styles.js.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.d.ts +2 -2
- package/lib/components/InteractionNotification/InteractionNotification.d.ts.map +1 -1
- package/lib/components/InteractionNotification/InteractionNotification.js +6 -4
- package/lib/components/InteractionNotification/InteractionNotification.js.map +1 -1
- package/lib/components/SearchResults/SearchResults.d.ts.map +1 -1
- package/lib/components/SearchResults/SearchResults.js +4 -2
- package/lib/components/SearchResults/SearchResults.js.map +1 -1
- package/lib/components/SearchResults/SearchResults.styles.js +3 -3
- package/lib/components/SearchResults/SearchResults.styles.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.js +5 -8
- package/lib/components/Shortcuts/Shortcuts.js.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.styles.d.ts +4 -7
- package/lib/components/Shortcuts/Shortcuts.styles.d.ts.map +1 -1
- package/lib/components/Shortcuts/Shortcuts.styles.js +29 -32
- package/lib/components/Shortcuts/Shortcuts.styles.js.map +1 -1
- package/lib/components/Stages/Stages.d.ts +4 -2
- package/lib/components/Stages/Stages.d.ts.map +1 -1
- package/lib/components/Stages/Stages.js +99 -88
- package/lib/components/Stages/Stages.js.map +1 -1
- package/lib/components/Stages/Stages.styles.d.ts +14 -0
- package/lib/components/Stages/Stages.styles.d.ts.map +1 -1
- package/lib/components/Stages/Stages.styles.js +179 -39
- package/lib/components/Stages/Stages.styles.js.map +1 -1
- package/lib/components/Stages/Stages.test-ids.d.ts +2 -0
- package/lib/components/Stages/Stages.test-ids.d.ts.map +1 -0
- package/lib/components/Stages/Stages.test-ids.js +3 -0
- package/lib/components/Stages/Stages.test-ids.js.map +1 -0
- package/lib/components/Stages/Stages.types.d.ts +3 -3
- package/lib/components/Stages/Stages.types.d.ts.map +1 -1
- package/lib/components/Stages/Stages.types.js.map +1 -1
- package/lib/components/Stages/index.d.ts +1 -0
- package/lib/components/Stages/index.d.ts.map +1 -1
- package/lib/components/Stages/index.js +1 -0
- 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 +2 -2
- package/lib/components/Stakeholders/Stakeholders.js.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.types.d.ts +1 -1
- package/lib/components/Stakeholders/Stakeholders.types.d.ts.map +1 -1
- package/lib/components/Stakeholders/Stakeholders.types.js.map +1 -1
- package/lib/components/Tasks/TaskCard.d.ts +8 -0
- package/lib/components/Tasks/TaskCard.d.ts.map +1 -0
- package/lib/components/Tasks/TaskCard.js +39 -0
- package/lib/components/Tasks/TaskCard.js.map +1 -0
- package/lib/components/Tasks/TaskCards.d.ts +9 -0
- package/lib/components/Tasks/TaskCards.d.ts.map +1 -0
- package/lib/components/Tasks/TaskCards.js +39 -0
- package/lib/components/Tasks/TaskCards.js.map +1 -0
- package/lib/components/Tasks/TaskList.d.ts +11 -1
- package/lib/components/Tasks/TaskList.d.ts.map +1 -1
- package/lib/components/Tasks/TaskList.js +8 -5
- package/lib/components/Tasks/TaskList.js.map +1 -1
- package/lib/components/Tasks/Tasks.d.ts +40 -5
- package/lib/components/Tasks/Tasks.d.ts.map +1 -1
- package/lib/components/Tasks/Tasks.js +5 -1
- package/lib/components/Tasks/Tasks.js.map +1 -1
- package/lib/components/Tasks/Tasks.test-ids.d.ts +1 -1
- package/lib/components/Tasks/Tasks.test-ids.d.ts.map +1 -1
- package/lib/components/Tasks/Tasks.test-ids.js +1 -1
- package/lib/components/Tasks/Tasks.test-ids.js.map +1 -1
- package/lib/components/Tasks/index.d.ts +1 -1
- package/lib/components/Tasks/index.d.ts.map +1 -1
- package/lib/components/Tasks/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
import type { AvatarProps, ForwardProps, ListToolbarProps, NoChildrenProp, SearchInputProps, TestIdProp } from '@pega/cosmos-react-core';
|
|
3
3
|
import type { ViewSelectorProps } from '@pega/cosmos-react-core/lib/components/ListToolbar/ListToolbar.types';
|
|
4
4
|
import type { TaskItemProps } from './TaskList';
|
|
5
|
-
export interface
|
|
6
|
-
/**
|
|
5
|
+
export interface TaskGroupProps {
|
|
6
|
+
/** Unique key for this group, typically the case type class name. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Display name for the card header (localized case type label). */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Optional visual element rendered before the heading (e.g. a case-type icon). */
|
|
11
|
+
visual?: ReactNode;
|
|
12
|
+
/** Assignments belonging to this group. */
|
|
7
13
|
items: TaskItemProps[];
|
|
14
|
+
/** Total count on the server (may exceed items.length before Show More). */
|
|
15
|
+
count?: number;
|
|
16
|
+
/** Marks this group as the Approvals card. Controls visual treatment. */
|
|
17
|
+
isApprovals?: boolean;
|
|
18
|
+
/** Callback when Show More is clicked for this group (e.g. to trigger a fetch). */
|
|
19
|
+
onShowMore?: () => void;
|
|
20
|
+
/** Flag while this group is loading more items. */
|
|
21
|
+
loadingMore?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface TasksBaseProps extends NoChildrenProp, TestIdProp {
|
|
8
24
|
/** Heading text to render at the top of the list. */
|
|
9
25
|
name: ListToolbarProps['name'];
|
|
10
26
|
/** A visual to accompany the header text. */
|
|
@@ -32,14 +48,33 @@ export interface TasksProps extends NoChildrenProp, TestIdProp {
|
|
|
32
48
|
*/
|
|
33
49
|
onItemLimitChange?: (limit: number) => void;
|
|
34
50
|
}
|
|
51
|
+
type TasksVariantProps = {
|
|
52
|
+
/**
|
|
53
|
+
* Rendering variant.
|
|
54
|
+
* @default 'list'
|
|
55
|
+
*/
|
|
56
|
+
variant?: 'list';
|
|
57
|
+
/** An array of TaskItemProps to generate the list. */
|
|
58
|
+
items?: TaskItemProps[];
|
|
59
|
+
/** Not applicable for the list variant. */
|
|
60
|
+
groups?: never;
|
|
61
|
+
} | {
|
|
62
|
+
/** Rendering variant. */
|
|
63
|
+
variant: 'cards';
|
|
64
|
+
/** Not applicable for the cards variant. */
|
|
65
|
+
items?: never;
|
|
66
|
+
/** Groups to render as cards. */
|
|
67
|
+
groups: TaskGroupProps[];
|
|
68
|
+
};
|
|
69
|
+
export type TasksProps = TasksBaseProps & TasksVariantProps;
|
|
35
70
|
export declare const StyledTasks: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("@pega/cosmos-react-core").CardProps, "ref"> & import("react").RefAttributes<HTMLElement> & ForwardProps, "ref"> & {
|
|
36
71
|
ref?: ((instance: HTMLElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLElement> | null | undefined;
|
|
37
72
|
}, {
|
|
38
73
|
openItem?: boolean;
|
|
39
74
|
fitToParent?: boolean;
|
|
40
75
|
}>> & string & Omit<import("@pega/cosmos-react-core").ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").CardProps>, keyof import("react").Component<any, {}, any>>;
|
|
41
|
-
declare const _default:
|
|
42
|
-
getTestIds: (testIdProp?: TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["show-more-less"]>;
|
|
76
|
+
declare const _default: ((props: TasksProps & ForwardProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
77
|
+
getTestIds: (testIdProp?: TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["show-more-less", "card-grid"]>;
|
|
43
78
|
};
|
|
44
79
|
export default _default;
|
|
45
80
|
//# sourceMappingURL=Tasks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tasks.d.ts","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Tasks.d.ts","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAqBnD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sEAAsE,CAAC;AAG9G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,2CAA2C;IAC3C,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,mDA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B,OAAO;kLAiBjF,CAAC;iCAYmB,UAAU,GAAG,YAAY;;;AA8H/C,wBAAmD"}
|
|
@@ -6,6 +6,7 @@ import { useMonitoredSize } from '@pega/cosmos-react-core/lib/components/PageTem
|
|
|
6
6
|
import { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';
|
|
7
7
|
import TaskList, { TaskItem } from './TaskList';
|
|
8
8
|
import { getTasksTestIds } from './Tasks.test-ids';
|
|
9
|
+
import TaskCards from './TaskCards';
|
|
9
10
|
export const StyledTasks = styled(Card)(({ theme, openItem, fitToParent }) => {
|
|
10
11
|
return openItem
|
|
11
12
|
? css `
|
|
@@ -29,7 +30,7 @@ const StyledCardContent = styled(CardContent) `
|
|
|
29
30
|
`;
|
|
30
31
|
StyledTasks.defaultProps = defaultThemeProp;
|
|
31
32
|
const Tasks = (props) => {
|
|
32
|
-
const { testId, items = [], name, avatar, viewSelector, count = items.length, search, loadingMore = false, fitToParent = false, onExpandToggle, onItemLimitChange, ...restProps } = props;
|
|
33
|
+
const { testId, items = [], name, avatar, viewSelector, count = items.length, search, loadingMore = false, fitToParent = false, onExpandToggle, onItemLimitChange, variant, groups, ...restProps } = props;
|
|
33
34
|
const testIds = useTestIds(testId, getTasksTestIds);
|
|
34
35
|
const openItem = items.find(item => item.content);
|
|
35
36
|
const t = useI18n();
|
|
@@ -68,6 +69,9 @@ const Tasks = (props) => {
|
|
|
68
69
|
const newLimit = Math.max(1, Math.floor(availableHeight / itemHeight));
|
|
69
70
|
onItemLimitChange(newLimit);
|
|
70
71
|
}, [fitToParent, items, onItemLimitChange, openItem, containerSize]);
|
|
72
|
+
if (variant === 'cards' && groups !== undefined) {
|
|
73
|
+
return _jsx(TaskCards, { groups: groups, name: name, testId: testId ?? undefined, ...restProps });
|
|
74
|
+
}
|
|
71
75
|
return (_jsxs(StyledTasks, { "data-testid": testIds.root, ...restProps, openItem: !!openItem, fitToParent: fitToParent, "data-app-region": true, "data-focusable-form-container": '', ref: setContainerEl, children: [!openItem && (_jsxs(CardHeader, { container: { justify: 'start', alignItems: 'center', gap: 1 }, children: [avatar && _jsx(Avatar, { ...avatar }), _jsx(ListToolbar, { name: name, headingTag: 'h2', viewSelector: viewSelector, count: { total: count }, search: search, item: { grow: 1 } })] })), fitToParent ? (_jsx(StyledCardContent, { children: items.length > 0 ? TaskItems : _jsx(EmptyState, {}) })) : (_jsx(CardContent, { children: items.length > 0 ? TaskItems : _jsx(EmptyState, {}) })), _jsx(Progress, { placement: 'block', ref: progressRef, visible: loadingMore, focusOnVisible: true }), hasFooter && !loadingMore && (_jsx(CardFooter, { justify: 'center', children: _jsx(Button, { "data-testid": testIds.showMoreLess, variant: 'link', "aria-label": t(!!count && count > items.length ? 'show_more' : 'show_less', ['tasks']), onClick: (e) => {
|
|
72
76
|
onExpandToggle?.();
|
|
73
77
|
if (!!count && count <= items.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tasks.js","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,MAAM,EACN,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uEAAuE,CAAC;AASzG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAG1F,OAAO,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;A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C,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC,EACD,GAAG,EAAE,eAAe,YAEnB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,GACxD,GACE,CACd,IACW,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';\nimport type { FC, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Card,\n CardHeader,\n CardContent,\n CardFooter,\n Button,\n useI18n,\n defaultThemeProp,\n ListToolbar,\n EmptyState,\n useTestIds,\n Avatar,\n withTestIds,\n Progress,\n getActiveElement,\n useElement\n} from '@pega/cosmos-react-core';\nimport { useMonitoredSize } from '@pega/cosmos-react-core/lib/components/PageTemplates/GridLayout/utils';\nimport type {\n AvatarProps,\n ForwardProps,\n ListToolbarProps,\n NoChildrenProp,\n SearchInputProps,\n TestIdProp\n} from '@pega/cosmos-react-core';\nimport { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';\nimport type { ViewSelectorProps } from '@pega/cosmos-react-core/lib/components/ListToolbar/ListToolbar.types';\n\nimport TaskList, { TaskItem } from './TaskList';\nimport type { TaskItemProps } from './TaskList';\nimport { getTasksTestIds } from './Tasks.test-ids';\n\nexport interface TasksProps extends NoChildrenProp, TestIdProp {\n /** An array of TaskItemProps to generate the list. */\n items: TaskItemProps[];\n /** Heading text to render at the top of the list. */\n name: ListToolbarProps['name'];\n /** A visual to accompany the header text. */\n avatar?: Pick<AvatarProps, 'name' | 'icon' | 'imageSrc' | 'status'>;\n /** Definition of view selection. */\n viewSelector?: Pick<ViewSelectorProps, 'views' | 'onViewSelect' | 'filterInputProps'>;\n /** Integer representing the total count of tasks. */\n count?: number;\n /** Opt-in search configuration. */\n search?: Pick<SearchInputProps, 'value' | 'onSearchChange'>;\n /** Callback for when to show more/less button is clicked. Lists greater than 3 items will display the show toggle button in its footer if passed. */\n onExpandToggle?: () => void;\n /**\n * Flag indicating more items are being fetched\n * @default false\n */\n loadingMore?: boolean;\n /**\n * Whether to fit Tasks widget in the parent element.\n */\n fitToParent?: boolean;\n /**\n * Callback invoked with the calculated item limit based on available height.\n * Only fires when fitToParent is true.\n */\n onItemLimitChange?: (limit: number) => void;\n}\n\nexport const StyledTasks = styled(Card)<{ openItem?: boolean; fitToParent?: boolean }>(({\n theme,\n openItem,\n fitToParent\n}) => {\n return openItem\n ? css`\n box-shadow: ${theme.base.shadow.low};\n min-block-size: ${fitToParent ? '100%' : 'auto'};\n `\n : css`\n min-block-size: ${fitToParent ? '100%' : 'auto'};\n\n ${StyledCardHeader}:not(& & > ${StyledCardHeader}) {\n padding-block-end: calc(${theme.base.spacing} / 2);\n }\n `;\n});\n\nconst StyledCardContent = styled(CardContent)`\n overflow: auto;\n flex-grow: 1;\n flex-basis: 0;\n min-block-size: 0;\n min-inline-size: 0;\n`;\n\nStyledTasks.defaultProps = defaultThemeProp;\n\nconst Tasks: FC<ForwardProps & TasksProps> = (props: TasksProps) => {\n const {\n testId,\n items = [],\n name,\n avatar,\n viewSelector,\n count = items.length,\n search,\n loadingMore = false,\n fitToParent = false,\n onExpandToggle,\n onItemLimitChange,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getTasksTestIds);\n const openItem = items.find(item => item.content);\n const t = useI18n();\n const toggleButtonRef = useRef<HTMLButtonElement>(null);\n const progressRef = useRef<HTMLDivElement>(null);\n const [containerEl, setContainerEl] = useElement<HTMLDivElement>();\n const containerSize = useMonitoredSize(containerEl, 0);\n\n const hasFooter = !!(!openItem && onExpandToggle && count > 0);\n\n const TaskItems = useMemo(() => {\n return openItem ? (\n <TaskItem {...openItem} headingTag='h2' />\n ) : (\n <TaskList items={items} hasFooter={hasFooter} testId={testIds.root} />\n );\n }, [items, openItem]);\n\n useEffect(() => {\n if (!loadingMore && getActiveElement() === progressRef.current && toggleButtonRef.current) {\n toggleButtonRef?.current.focus();\n }\n }, [loadingMore]);\n\n // Measure available height and calculate item limit when fitToParent is enabled\n useLayoutEffect(() => {\n if (!fitToParent || !containerEl || !onItemLimitChange || openItem) return;\n\n const container = containerEl;\n const containerHeight = container.getBoundingClientRect().height;\n if (containerHeight === 0) return;\n\n const header = container.querySelector('header');\n const footer = container.querySelector('footer');\n const headerHeight = header ? header.getBoundingClientRect().height : 0;\n const footerHeight = footer ? footer.getBoundingClientRect().height : 0;\n\n const listItems = container.querySelectorAll('ul > li');\n if (listItems.length === 0) return;\n\n const itemHeight = listItems[0].getBoundingClientRect().height;\n if (itemHeight === 0) return;\n\n const availableHeight = containerHeight - headerHeight - footerHeight;\n const newLimit = Math.max(1, Math.floor(availableHeight / itemHeight));\n\n onItemLimitChange(newLimit);\n }, [fitToParent, items, onItemLimitChange, openItem, containerSize]);\n\n return (\n <StyledTasks\n data-testid={testIds.root}\n {...restProps}\n openItem={!!openItem}\n fitToParent={fitToParent}\n data-app-region\n data-focusable-form-container=''\n ref={setContainerEl}\n >\n {!openItem && (\n <CardHeader container={{ justify: 'start', alignItems: 'center', gap: 1 }}>\n {avatar && <Avatar {...avatar} />}\n <ListToolbar\n name={name}\n headingTag='h2'\n viewSelector={viewSelector}\n count={{ total: count }}\n search={search}\n item={{ grow: 1 }}\n />\n </CardHeader>\n )}\n\n {fitToParent ? (\n <StyledCardContent>{items.length > 0 ? TaskItems : <EmptyState />}</StyledCardContent>\n ) : (\n <CardContent>{items.length > 0 ? TaskItems : <EmptyState />}</CardContent>\n )}\n\n <Progress placement='block' ref={progressRef} visible={loadingMore} focusOnVisible />\n {hasFooter && !loadingMore && (\n <CardFooter justify='center'>\n <Button\n data-testid={testIds.showMoreLess}\n variant='link'\n aria-label={t(!!count && count > items.length ? 'show_more' : 'show_less', ['tasks'])}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n onExpandToggle?.();\n if (!!count && count <= items.length) {\n const { currentTarget } = e;\n requestAnimationFrame(() => {\n if (currentTarget.getBoundingClientRect().top < 0) currentTarget.scrollIntoView();\n });\n }\n }}\n ref={toggleButtonRef}\n >\n {t(!!count && count > items.length ? 'show_more' : 'show_less')}\n </Button>\n </CardFooter>\n )}\n </StyledTasks>\n );\n};\n\nexport default withTestIds(Tasks, getTasksTestIds);\n"]}
|
|
1
|
+
{"version":3,"file":"Tasks.js","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,UAAU,EACV,MAAM,EACN,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uEAAuE,CAAC;AASzG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAG1F,OAAO,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,SAAS,MAAM,aAAa,CAAC;AAyEpC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAgD,CAAC,EACtF,KAAK,EACL,QAAQ,EACR,WAAW,EACZ,EAAE,EAAE;IACH,OAAO,QAAQ;QACb,CAAC,CAAC,GAAG,CAAA;sBACa,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG;0BACjB,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,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G,EAAE,eAAe,YAEnB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,GACxD,GACE,CACd,IACW,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';\nimport type { MouseEvent, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Card,\n CardHeader,\n CardContent,\n CardFooter,\n Button,\n useI18n,\n defaultThemeProp,\n ListToolbar,\n EmptyState,\n useTestIds,\n Avatar,\n withTestIds,\n Progress,\n getActiveElement,\n useElement\n} from '@pega/cosmos-react-core';\nimport { useMonitoredSize } from '@pega/cosmos-react-core/lib/components/PageTemplates/GridLayout/utils';\nimport type {\n AvatarProps,\n ForwardProps,\n ListToolbarProps,\n NoChildrenProp,\n SearchInputProps,\n TestIdProp\n} from '@pega/cosmos-react-core';\nimport { StyledCardHeader } from '@pega/cosmos-react-core/lib/components/Card/CardHeader';\nimport type { ViewSelectorProps } from '@pega/cosmos-react-core/lib/components/ListToolbar/ListToolbar.types';\n\nimport TaskList, { TaskItem } from './TaskList';\nimport type { TaskItemProps } from './TaskList';\nimport { getTasksTestIds } from './Tasks.test-ids';\nimport TaskCards from './TaskCards';\n\nexport interface TaskGroupProps {\n /** Unique key for this group, typically the case type class name. */\n id: string;\n /** Display name for the card header (localized case type label). */\n name: string;\n /** Optional visual element rendered before the heading (e.g. a case-type icon). */\n visual?: ReactNode;\n /** Assignments belonging to this group. */\n items: TaskItemProps[];\n /** Total count on the server (may exceed items.length before Show More). */\n count?: number;\n /** Marks this group as the Approvals card. Controls visual treatment. */\n isApprovals?: boolean;\n /** Callback when Show More is clicked for this group (e.g. to trigger a fetch). */\n onShowMore?: () => void;\n /** Flag while this group is loading more items. */\n loadingMore?: boolean;\n}\n\ninterface TasksBaseProps extends NoChildrenProp, TestIdProp {\n /** Heading text to render at the top of the list. */\n name: ListToolbarProps['name'];\n /** A visual to accompany the header text. */\n avatar?: Pick<AvatarProps, 'name' | 'icon' | 'imageSrc' | 'status'>;\n /** Definition of view selection. */\n viewSelector?: Pick<ViewSelectorProps, 'views' | 'onViewSelect' | 'filterInputProps'>;\n /** Integer representing the total count of tasks. */\n count?: number;\n /** Opt-in search configuration. */\n search?: Pick<SearchInputProps, 'value' | 'onSearchChange'>;\n /** Callback for when to show more/less button is clicked. Lists greater than 3 items will display the show toggle button in its footer if passed. */\n onExpandToggle?: () => void;\n /**\n * Flag indicating more items are being fetched\n * @default false\n */\n loadingMore?: boolean;\n /**\n * Whether to fit Tasks widget in the parent element.\n */\n fitToParent?: boolean;\n /**\n * Callback invoked with the calculated item limit based on available height.\n * Only fires when fitToParent is true.\n */\n onItemLimitChange?: (limit: number) => void;\n}\n\ntype TasksVariantProps =\n | {\n /**\n * Rendering variant.\n * @default 'list'\n */\n variant?: 'list';\n /** An array of TaskItemProps to generate the list. */\n items?: TaskItemProps[];\n /** Not applicable for the list variant. */\n groups?: never;\n }\n | {\n /** Rendering variant. */\n variant: 'cards';\n /** Not applicable for the cards variant. */\n items?: never;\n /** Groups to render as cards. */\n groups: TaskGroupProps[];\n };\n\nexport type TasksProps = TasksBaseProps & TasksVariantProps;\n\nexport const StyledTasks = styled(Card)<{ openItem?: boolean; fitToParent?: boolean }>(({\n theme,\n openItem,\n fitToParent\n}) => {\n return openItem\n ? css`\n box-shadow: ${theme.base.shadow.low};\n min-block-size: ${fitToParent ? '100%' : 'auto'};\n `\n : css`\n min-block-size: ${fitToParent ? '100%' : 'auto'};\n\n ${StyledCardHeader}:not(& & > ${StyledCardHeader}) {\n padding-block-end: calc(${theme.base.spacing} / 2);\n }\n `;\n});\n\nconst StyledCardContent = styled(CardContent)`\n overflow: auto;\n flex-grow: 1;\n flex-basis: 0;\n min-block-size: 0;\n min-inline-size: 0;\n`;\n\nStyledTasks.defaultProps = defaultThemeProp;\n\nconst Tasks = (props: TasksProps & ForwardProps) => {\n const {\n testId,\n items = [],\n name,\n avatar,\n viewSelector,\n count = items.length,\n search,\n loadingMore = false,\n fitToParent = false,\n onExpandToggle,\n onItemLimitChange,\n variant,\n groups,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getTasksTestIds);\n const openItem = items.find(item => item.content);\n const t = useI18n();\n const toggleButtonRef = useRef<HTMLButtonElement>(null);\n const progressRef = useRef<HTMLDivElement>(null);\n const [containerEl, setContainerEl] = useElement<HTMLDivElement>();\n const containerSize = useMonitoredSize(containerEl, 0);\n\n const hasFooter = !!(!openItem && onExpandToggle && count > 0);\n\n const TaskItems = useMemo(() => {\n return openItem ? (\n <TaskItem {...openItem} headingTag='h2' />\n ) : (\n <TaskList items={items} hasFooter={hasFooter} testId={testIds.root} />\n );\n }, [items, openItem]);\n\n useEffect(() => {\n if (!loadingMore && getActiveElement() === progressRef.current && toggleButtonRef.current) {\n toggleButtonRef?.current.focus();\n }\n }, [loadingMore]);\n\n // Measure available height and calculate item limit when fitToParent is enabled\n useLayoutEffect(() => {\n if (!fitToParent || !containerEl || !onItemLimitChange || openItem) return;\n\n const container = containerEl;\n const containerHeight = container.getBoundingClientRect().height;\n if (containerHeight === 0) return;\n\n const header = container.querySelector('header');\n const footer = container.querySelector('footer');\n const headerHeight = header ? header.getBoundingClientRect().height : 0;\n const footerHeight = footer ? footer.getBoundingClientRect().height : 0;\n\n const listItems = container.querySelectorAll('ul > li');\n if (listItems.length === 0) return;\n\n const itemHeight = listItems[0].getBoundingClientRect().height;\n if (itemHeight === 0) return;\n\n const availableHeight = containerHeight - headerHeight - footerHeight;\n const newLimit = Math.max(1, Math.floor(availableHeight / itemHeight));\n\n onItemLimitChange(newLimit);\n }, [fitToParent, items, onItemLimitChange, openItem, containerSize]);\n\n if (variant === 'cards' && groups !== undefined) {\n return <TaskCards groups={groups} name={name} testId={testId ?? undefined} {...restProps} />;\n }\n\n return (\n <StyledTasks\n data-testid={testIds.root}\n {...restProps}\n openItem={!!openItem}\n fitToParent={fitToParent}\n data-app-region\n data-focusable-form-container=''\n ref={setContainerEl}\n >\n {!openItem && (\n <CardHeader container={{ justify: 'start', alignItems: 'center', gap: 1 }}>\n {avatar && <Avatar {...avatar} />}\n <ListToolbar\n name={name}\n headingTag='h2'\n viewSelector={viewSelector}\n count={{ total: count }}\n search={search}\n item={{ grow: 1 }}\n />\n </CardHeader>\n )}\n\n {fitToParent ? (\n <StyledCardContent>{items.length > 0 ? TaskItems : <EmptyState />}</StyledCardContent>\n ) : (\n <CardContent>{items.length > 0 ? TaskItems : <EmptyState />}</CardContent>\n )}\n\n <Progress placement='block' ref={progressRef} visible={loadingMore} focusOnVisible />\n {hasFooter && !loadingMore && (\n <CardFooter justify='center'>\n <Button\n data-testid={testIds.showMoreLess}\n variant='link'\n aria-label={t(!!count && count > items.length ? 'show_more' : 'show_less', ['tasks'])}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n onExpandToggle?.();\n if (!!count && count <= items.length) {\n const { currentTarget } = e;\n requestAnimationFrame(() => {\n if (currentTarget.getBoundingClientRect().top < 0) currentTarget.scrollIntoView();\n });\n }\n }}\n ref={toggleButtonRef}\n >\n {t(!!count && count > items.length ? 'show_more' : 'show_less')}\n </Button>\n </CardFooter>\n )}\n </StyledTasks>\n );\n};\n\nexport default withTestIds(Tasks, getTasksTestIds);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const getTasksTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["show-more-less"]>;
|
|
1
|
+
export declare const getTasksTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["show-more-less", "card-grid"]>;
|
|
2
2
|
export declare const getTaskListTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly []>;
|
|
3
3
|
export declare const getTaskItemTestIds: (testIdProp?: import("@pega/cosmos-react-core").TestIdProp["testId"]) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["open-task"]>;
|
|
4
4
|
//# sourceMappingURL=Tasks.test-ids.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tasks.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"Tasks.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,oKAAmE,CAAC;AAEhG,eAAO,MAAM,kBAAkB,uIAA0C,CAAC;AAE1E,eAAO,MAAM,kBAAkB,kJAAqD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createTestIds } from '@pega/cosmos-react-core';
|
|
2
|
-
export const getTasksTestIds = createTestIds('tasks', ['show-more-less']);
|
|
2
|
+
export const getTasksTestIds = createTestIds('tasks', ['show-more-less', 'card-grid']);
|
|
3
3
|
export const getTaskListTestIds = createTestIds('task-list', []);
|
|
4
4
|
export const getTaskItemTestIds = createTestIds('task-item', ['open-task']);
|
|
5
5
|
//# sourceMappingURL=Tasks.test-ids.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tasks.test-ids.js","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Tasks.test-ids.js","sourceRoot":"","sources":["../../../src/components/Tasks/Tasks.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAU,CAAC,CAAC;AAEhG,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,WAAW,EAAE,EAAW,CAAC,CAAC;AAE1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC,WAAW,CAAU,CAAC,CAAC","sourcesContent":["import { createTestIds } from '@pega/cosmos-react-core';\n\nexport const getTasksTestIds = createTestIds('tasks', ['show-more-less', 'card-grid'] as const);\n\nexport const getTaskListTestIds = createTestIds('task-list', [] as const);\n\nexport const getTaskItemTestIds = createTestIds('task-item', ['open-task'] as const);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default } from './Tasks';
|
|
2
|
-
export type { TasksProps } from './Tasks';
|
|
2
|
+
export type { TasksProps, TaskGroupProps } from './Tasks';
|
|
3
3
|
export { default as TaskList } from './TaskList';
|
|
4
4
|
export type { TaskListProps, TaskItemProps } from './TaskList';
|
|
5
5
|
export { listToolbarHelpers as tasksHelpers } from '@pega/cosmos-react-core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { default } from './Tasks';\nexport type { TasksProps } from './Tasks';\nexport { default as TaskList } from './TaskList';\nexport type { TaskListProps, TaskItemProps } from './TaskList';\nexport { listToolbarHelpers as tasksHelpers } from '@pega/cosmos-react-core';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["export { default } from './Tasks';\nexport type { TasksProps, TaskGroupProps } from './Tasks';\nexport { default as TaskList } from './TaskList';\nexport type { TaskListProps, TaskItemProps } from './TaskList';\nexport { listToolbarHelpers as tasksHelpers } from '@pega/cosmos-react-core';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-work",
|
|
3
|
-
"version": "10.0.0-build.1
|
|
3
|
+
"version": "10.0.0-build.2.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"author": "Pegasystems",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"build": "tsc -b tsconfig.build.json"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pega/cosmos-react-core": "10.0.0-build.1
|
|
18
|
-
"@pega/cosmos-react-rte": "10.0.0-build.1
|
|
17
|
+
"@pega/cosmos-react-core": "10.0.0-build.2.1",
|
|
18
|
+
"@pega/cosmos-react-rte": "10.0.0-build.2.1",
|
|
19
19
|
"@types/react": "^17.0.62 || ^18.3.3",
|
|
20
20
|
"@types/react-dom": "^17.0.20 || ^18.3.0",
|
|
21
21
|
"polished": "^4.1.0",
|