@pega/lists-react 9.0.0-build.6.8 → 9.0.0-build.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Core/Components/AggregateMenu.d.ts +1 -0
- package/lib/Core/Components/AggregateMenu.d.ts.map +1 -1
- package/lib/Core/Components/AggregateMenu.js +26 -16
- package/lib/Core/Components/AggregateMenu.js.map +1 -1
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.d.ts.map +1 -1
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.js +4 -2
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.js.map +1 -1
- package/lib/Core/Components/GroupRenderer.d.ts +16 -0
- package/lib/Core/Components/GroupRenderer.d.ts.map +1 -1
- package/lib/Core/Components/GroupRenderer.js +112 -4
- package/lib/Core/Components/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSort/Row.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSort/Row.js.map +1 -1
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts +97 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js +249 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.d.ts +22 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.js +38 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.d.ts +22 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.js +45 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.d.ts +49 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.js +55 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.d.ts +21 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.js +39 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.d.ts +38 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.js +62 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts +112 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js +213 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js.map +1 -0
- package/lib/Core/Components/Virtualise/utility.d.ts +1 -1
- package/lib/Core/Components/Virtualise/utility.d.ts.map +1 -1
- package/lib/Core/Components/Virtualise/utility.js +3 -2
- package/lib/Core/Components/Virtualise/utility.js.map +1 -1
- package/lib/Core/Hooks/useDragDrop.d.ts.map +1 -1
- package/lib/Core/Hooks/useDragDrop.js +2 -0
- package/lib/Core/Hooks/useDragDrop.js.map +1 -1
- package/lib/Core/Localization/defaultTranslations.d.ts +1 -0
- package/lib/Core/Localization/defaultTranslations.d.ts.map +1 -1
- package/lib/Core/Localization/defaultTranslations.js +2 -1
- package/lib/Core/Localization/defaultTranslations.js.map +1 -1
- package/lib/Core/Views/Table/Row.d.ts +3 -1
- package/lib/Core/Views/Table/Row.d.ts.map +1 -1
- package/lib/Core/Views/Table/Row.js +5 -3
- package/lib/Core/Views/Table/Row.js.map +1 -1
- package/lib/Core/Views/Table/StyledTableContainer.d.ts.map +1 -1
- package/lib/Core/Views/Table/StyledTableContainer.js +4 -0
- package/lib/Core/Views/Table/StyledTableContainer.js.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts +3 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.js +18 -2
- package/lib/Core/Views/Table/VirtualizeWrapper.js.map +1 -1
- package/lib/Core/Views/Table/index.d.ts.map +1 -1
- package/lib/Core/Views/Table/index.js +2 -2
- package/lib/Core/Views/Table/index.js.map +1 -1
- package/lib/Core/Views/Table/useCountChange.d.ts +10 -0
- package/lib/Core/Views/Table/useCountChange.d.ts.map +1 -0
- package/lib/Core/Views/Table/useCountChange.js +39 -0
- package/lib/Core/Views/Table/useCountChange.js.map +1 -0
- package/package.json +8 -8
|
@@ -19,5 +19,6 @@ declare namespace AggregateMenu {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
export default AggregateMenu;
|
|
22
|
+
export function getFormattedAggregationValue(rawAggregationValue: number | string, aggregationType: string, column: import("pega-repeating-structures-core").RsCoreTypes.Column): string | number;
|
|
22
23
|
import PropTypes from 'prop-types';
|
|
23
24
|
//# sourceMappingURL=AggregateMenu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AggregateMenu.d.ts","sourceRoot":"","sources":["../../../Core/Components/AggregateMenu.jsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AggregateMenu.d.ts","sourceRoot":"","sources":["../../../Core/Components/AggregateMenu.jsx"],"names":[],"mappings":"AAkEA;;;mDAwDC;;;;;;;;;;;;;;;;;;AA3EM,kEALI,MAAM,GAAC,MAAM,mBACb,MAAM,UACN,OAAO,gCAAgC,EAAE,WAAW,CAAC,MAAM,GACzD,MAAM,GAAC,MAAM,CAmBzB;sBA/DqB,YAAY"}
|
|
@@ -25,8 +25,32 @@ const StyledCell = styled.div `
|
|
|
25
25
|
const StyledAggregationValue = styled.div `
|
|
26
26
|
font-weight: ${props => props.theme.base['font-weight']['semi-bold']};
|
|
27
27
|
`;
|
|
28
|
+
/**
|
|
29
|
+
* Formats the aggregation value based on the aggregation type and column context.
|
|
30
|
+
*
|
|
31
|
+
* @param {number|string} rawAggregationValue - The raw aggregation value to format.
|
|
32
|
+
* @param {string} aggregationType - The type of aggregation (e.g., 'Avg').
|
|
33
|
+
* @param {import('pega-repeating-structures-core').RsCoreTypes.Column} column - The column object.
|
|
34
|
+
* @returns {string|number} The formatted aggregation value or the raw value if no formatter is available.
|
|
35
|
+
*/
|
|
36
|
+
export const getFormattedAggregationValue = (rawAggregationValue, aggregationType, column) => {
|
|
37
|
+
const formatter = column.getContext().getFormatter();
|
|
38
|
+
const fieldDef = column.getContext().getField();
|
|
39
|
+
const { fieldType } = fieldDef;
|
|
40
|
+
const { locale, timezone } = column.parent.meta;
|
|
41
|
+
if (!formatter)
|
|
42
|
+
return rawAggregationValue;
|
|
43
|
+
if (aggregationType === 'Avg' && fieldType === 'Integer') {
|
|
44
|
+
return formatNumber(Number(rawAggregationValue), {
|
|
45
|
+
locale,
|
|
46
|
+
useGrouping: true,
|
|
47
|
+
maximumFractionDigits: 2
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return formatter(rawAggregationValue, { locale, timezone, fieldDef });
|
|
51
|
+
};
|
|
28
52
|
export default function AggregateMenu({ column, context }) {
|
|
29
|
-
const { aggregateOptions
|
|
53
|
+
const { aggregateOptions } = column.parent.meta;
|
|
30
54
|
const { aggregationType } = column;
|
|
31
55
|
const uid = createUID();
|
|
32
56
|
const [translate] = useTranslate();
|
|
@@ -39,21 +63,7 @@ export default function AggregateMenu({ column, context }) {
|
|
|
39
63
|
if (!actions)
|
|
40
64
|
return null;
|
|
41
65
|
const rawAggregationValue = context.getValue();
|
|
42
|
-
const
|
|
43
|
-
const fieldDef = column.getContext().getField();
|
|
44
|
-
const { fieldType } = fieldDef;
|
|
45
|
-
const aggregationValue = (() => {
|
|
46
|
-
if (!formatter)
|
|
47
|
-
return rawAggregationValue;
|
|
48
|
-
if (aggregationType === 'Avg' && fieldType === 'Integer') {
|
|
49
|
-
return formatNumber(Number(rawAggregationValue), {
|
|
50
|
-
locale,
|
|
51
|
-
useGrouping: true,
|
|
52
|
-
maximumFractionDigits: 2
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return formatter(rawAggregationValue, { locale, timezone, fieldDef });
|
|
56
|
-
})();
|
|
66
|
+
const aggregationValue = getFormattedAggregationValue(rawAggregationValue, aggregationType, column);
|
|
57
67
|
const buttonText = translate('Aggregate options');
|
|
58
68
|
return (_jsxs(StyledCell, { children: [_jsx("span", { children: translate(aggregationType) }), _jsx(StyledMenuButton, { className: 'aggregate-button', menu: {
|
|
59
69
|
items: actions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AggregateMenu.js","sourceRoot":"","sources":["../../../Core/Components/AggregateMenu.jsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EACL,IAAI,EACJ,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAEjD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;WAChC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;;;CAK/D,CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;CAU5B,CAAC;AAEF,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAA;iBACxB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC;CACrE,CAAC;AAEF,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"AggregateMenu.js","sourceRoot":"","sources":["../../../Core/Components/AggregateMenu.jsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EACL,IAAI,EACJ,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAEjD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;WAChC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,C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Q,iCACnC,GAAG,SAAS,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,UAAU,EAAE,GACjD,IACV,CACd,CAAC;AACJ,CAAC;AAED,aAAa,CAAC,SAAS,GAAG;IACxB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;IACzC,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC;CAC3C,CAAC;AAEF,aAAa,CAAC,YAAY,GAAG;IAC3B,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;CACZ,CAAC","sourcesContent":["import styled from 'styled-components';\nimport PropTypes from 'prop-types';\n\nimport {\n Flex,\n MenuButton,\n VisuallyHiddenText,\n createUID,\n formatNumber\n} from '@pega/cosmos-react-core';\n\nimport useTranslate from '../Hooks/useTranslate';\n\nimport TestIdConstants from './TestIdConstants';\n\nconst StyledMenuButton = styled(MenuButton)`\n color: ${props => props.theme.base.palette['foreground-color']};\n svg {\n width: 1.5rem;\n height: 1.5rem;\n }\n`;\n\nconst StyledCell = styled.div`\n display: flex;\n text-align: right;\n justify-content: flex-end;\n align-items: center;\n margin-inline-end: var(--cell-padding);\n\n &:hover {\n background-clip: padding-box;\n }\n`;\n\nconst StyledAggregationValue = styled.div`\n font-weight: ${props => props.theme.base['font-weight']['semi-bold']};\n`;\n\n/**\n * Formats the aggregation value based on the aggregation type and column context.\n *\n * @param {number|string} rawAggregationValue - The raw aggregation value to format.\n * @param {string} aggregationType - The type of aggregation (e.g., 'Avg').\n * @param {import('pega-repeating-structures-core').RsCoreTypes.Column} column - The column object.\n * @returns {string|number} The formatted aggregation value or the raw value if no formatter is available.\n */\nexport const getFormattedAggregationValue = (rawAggregationValue, aggregationType, column) => {\n const formatter = column.getContext().getFormatter();\n const fieldDef = column.getContext().getField();\n const { fieldType } = fieldDef;\n const { locale, timezone } = column.parent.meta;\n\n if (!formatter) return rawAggregationValue;\n\n if (aggregationType === 'Avg' && fieldType === 'Integer') {\n return formatNumber(Number(rawAggregationValue), {\n locale,\n useGrouping: true,\n maximumFractionDigits: 2\n });\n }\n\n return formatter(rawAggregationValue, { locale, timezone, fieldDef });\n};\n\nexport default function AggregateMenu({ column, context }) {\n const { aggregateOptions } = column.parent.meta;\n const { aggregationType } = column;\n const uid = createUID();\n const [translate] = useTranslate();\n\n const actions = aggregateOptions[column.field.type]?.map(label => ({\n primary: translate(label),\n id: label,\n onClick: () => column.applyAggregation(label),\n selected: aggregationType === label\n }));\n if (!actions) return null;\n\n const rawAggregationValue = context.getValue();\n\n const aggregationValue = getFormattedAggregationValue(\n rawAggregationValue,\n aggregationType,\n column\n );\n\n const buttonText = translate('Aggregate options');\n\n return (\n <StyledCell>\n <span>{translate(aggregationType)}</span>\n <StyledMenuButton\n className='aggregate-button'\n menu={{\n items: actions,\n mode: 'single-select'\n }}\n popover={{\n portal: true\n }}\n icon='arrow-micro-down'\n iconOnly\n variant='simple'\n compact\n text={buttonText} // Text property to display tooltip on hover\n aria-labelledby={`${uid}_label`}\n />\n <Flex\n container\n as={StyledAggregationValue}\n item={{ shrink: 0 }}\n data-testid={TestIdConstants.aggregateDisplayValue}\n >\n {aggregationValue}\n </Flex>\n <VisuallyHiddenText id={`${uid}_label`} aria-hidden>\n {`${translate(aggregationType)} ${context.getValue()} ${buttonText}`}\n </VisuallyHiddenText>\n </StyledCell>\n );\n}\n\nAggregateMenu.propTypes = {\n column: PropTypes.objectOf(PropTypes.any),\n context: PropTypes.objectOf(PropTypes.any)\n};\n\nAggregateMenu.defaultProps = {\n column: {},\n context: {}\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Components/ContextMenu/ContextMenuContainer.jsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextMenuContainer.d.ts","sourceRoot":"","sources":["../../../../Core/Components/ContextMenu/ContextMenuContainer.jsx"],"names":[],"mappings":"AA4MA;;;mDA+GC;;;;;;;;;;;;sBA3TqB,YAAY"}
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useRef, useState, useMemo, useEffect, useCallback } from 'react';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
|
-
import {
|
|
5
|
+
import { mix } from 'polished';
|
|
6
|
+
import { Popover, Icon, useElement, useOuterEvent, tryCatch } from '@pega/cosmos-react-core';
|
|
6
7
|
import { getRowContextData, getScrollerElem, isFilterApplied } from 'pega-repeating-structures-core';
|
|
7
8
|
import { createClassName as cx } from '../../Utils';
|
|
8
9
|
import useTranslate from '../../Hooks/useTranslate';
|
|
@@ -13,6 +14,7 @@ const StyledPopover = styled.div `
|
|
|
13
14
|
width: 10rem;
|
|
14
15
|
`;
|
|
15
16
|
const StyledContent = styled.div(({ theme }) => {
|
|
17
|
+
const hoverColor = tryCatch(() => mix(0.95, theme.base.palette['primary-background'], theme.base.palette.interactive));
|
|
16
18
|
return css `
|
|
17
19
|
white-space: nowrap;
|
|
18
20
|
overflow: hidden;
|
|
@@ -24,7 +26,7 @@ const StyledContent = styled.div(({ theme }) => {
|
|
|
24
26
|
margin-top: 0.125rem;
|
|
25
27
|
margin-bottom: 0.125rem;
|
|
26
28
|
:hover {
|
|
27
|
-
background-color: ${
|
|
29
|
+
background-color: ${hoverColor};
|
|
28
30
|
box-shadow: ${theme.base.shadow['focus-inset']};
|
|
29
31
|
}
|
|
30
32
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuContainer.js","sourceRoot":"","sources":["../../../../Core/Components/ContextMenu/ContextMenuContainer.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM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,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,eAAe,CAAC,CAAC,CAAC;IAEzD,IAAI,CAAC,cAAc,CAAC,UAAU,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;QAC7D,IAAI,cAAc,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAC;YAC1C,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,OAAO,IAAC,MAAM,QAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,CAAC,UAAU,YAClE,KAAC,aAAa,cACX,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACrB,KAAC,QAAQ,IAEP,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,cAAc,CAAC,UAAU,EACjC,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,IAAI,EAAE,IAAI,IALL,IAAI,CAAC,EAAE,CAMZ,CACH,CAAC,GACY,GACR,CACX,CAAC;AACJ,CAAC;AAED,oBAAoB,CAAC,SAAS,GAAG;IAC/B,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;IAClD,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;CACvD,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport { useRef, useState, useMemo, useEffect, useCallback } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Popover, Icon, useElement, useOuterEvent } from '@pega/cosmos-react-core';\nimport {\n getRowContextData,\n getScrollerElem,\n isFilterApplied\n} from 'pega-repeating-structures-core';\n\nimport { createClassName as cx } from '../../Utils';\nimport useTranslate from '../../Hooks/useTranslate';\nimport useScrollAway from '../../Hooks/useScrollAway';\n\nimport { applyFilter, quickFilterEnabled, removeFilter } from './QuickFilter';\nimport copyText from './CopyPaste';\n\nconst StyledPopover = styled.div`\n width: 10rem;\n`;\n\nconst StyledContent = styled.div(({ theme }) => {\n return css`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n padding: 0.25rem;\n border-radius: 0.156rem;\n box-sizing: border-box;\n cursor: pointer;\n margin-top: 0.125rem;\n margin-bottom: 0.125rem;\n :hover {\n background-color: ${theme.base.colors.blue['extra-light']};\n box-shadow: ${theme.base.shadow['focus-inset']};\n }\n `;\n});\n\nconst StyledListItem = styled.div(({ theme }) => {\n return css`\n button {\n display: flex;\n align-items: center;\n /* stylelint-disable unit-allowed-list */\n padding: 4px 8px;\n }\n .label {\n padding-left: 14px;\n vertical-align: text-top;\n }\n .disabled {\n padding-left: 14px;\n vertical-align: text-top;\n opacity: ${theme.base['disabled-opacity']};\n }\n `;\n});\n\nconst StyledButton = styled.button`\n display: block;\n text-align: start;\n background: none;\n border: none;\n line-height: 1;\n outline: none;\n cursor: pointer;\n color: ${props => props.theme.base.palette['foreground-color']};\n border-radius: 0;\n`;\n\nconst getDefaultMenuItems = (\n column,\n rowContextData,\n targetCell,\n columns,\n filterExpression,\n actionColumnFiltering,\n actionClearFiltering,\n translate\n) => {\n const isFiltered = isFilterApplied(column, filterExpression);\n return [\n {\n id: 'quickFilter',\n icon: isFiltered ? 'times' : 'filter',\n label: isFiltered ? translate('Remove filter') : translate('Filter by this'),\n show: !!quickFilterEnabled(columns, column.field.id),\n disabled: false,\n onClick: () => {\n if (isFiltered) {\n return removeFilter(\n filterExpression,\n targetCell,\n actionColumnFiltering,\n actionClearFiltering\n );\n }\n return applyFilter(\n columns,\n targetCell,\n rowContextData,\n filterExpression,\n actionColumnFiltering\n );\n }\n },\n {\n id: 'copyText',\n icon: 'copy',\n label: translate('Copy text'),\n show: true,\n disabled: false,\n onClick: () => copyText(targetCell)\n },\n {\n id: 'pasteText',\n icon: 'documents',\n label: translate('Paste text'),\n show: true,\n disabled: true,\n onClick: () => {}\n }\n ];\n};\n\nconst getMenuItems = (\n targetCell,\n column,\n rowContextData,\n columns,\n filterExpression,\n actionColumnFiltering,\n actionClearFiltering,\n translate\n) => {\n const fieldContextOptions = column.field?.contextMenuOptions || [];\n return [\n ...getDefaultMenuItems(\n column,\n rowContextData,\n targetCell,\n columns,\n filterExpression,\n actionColumnFiltering,\n actionClearFiltering,\n translate\n ),\n ...fieldContextOptions\n ];\n};\n\nconst shouldOverrideContextMenu = (targetCell, columns) => {\n if (!targetCell) {\n return false;\n }\n const { colId } = targetCell.dataset;\n\n const { field } = columns.find(col => col.field.id.toString() === colId?.toString()) || {};\n return !(!field || field?.noContextMenu);\n};\n\nconst MenuItem = ({\n menu = {},\n target = {},\n column = {},\n rowContextData = {},\n onMenuItemClick = () => {}\n}) => {\n const { onClick = () => {}, icon, disabled = false, show = true, label } = menu;\n if (!show) {\n return null;\n }\n\n return (\n <StyledContent\n onClick={() => {\n onMenuItemClick();\n onClick(target, column, rowContextData);\n }}\n >\n <StyledListItem>\n <StyledButton>\n {icon && <Icon name={icon} />}\n <span className={cx('label', { disabled })}>{label}</span>\n </StyledButton>\n </StyledListItem>\n </StyledContent>\n );\n};\n\nMenuItem.propTypes = {\n menu: PropTypes.objectOf(PropTypes.any),\n target: PropTypes.objectOf(PropTypes.any),\n column: PropTypes.objectOf(PropTypes.any),\n rowContextData: PropTypes.objectOf(PropTypes.any),\n onMenuItemClick: PropTypes.func\n};\n\nexport default function ContextMenuContainer({ view, selector }) {\n const {\n columns,\n data,\n state: { paginationOptions, filterExpression } = {},\n domContainer,\n type: { applyFilter: applyViewFilter, clearFilter }\n } = view;\n const [translate] = useTranslate();\n const contextMenuRef = useRef({}).current;\n const [showMenu, setShowMenu] = useState(false);\n const [menuItems, setMenuItems] = useState([]);\n const [popperRef, setPopperRef] = useElement();\n const scrollerElem = useMemo(() => getScrollerElem(view), [view]);\n\n useOuterEvent('mousedown', [popperRef], () => {\n setShowMenu(false);\n });\n\n useScrollAway(popperRef, scrollerElem, () => {\n setShowMenu(false);\n });\n\n const onMenuItemClick = useCallback(event => {\n if (event && event.key !== 'Escape') {\n return;\n }\n setShowMenu(false);\n }, []);\n\n const contextMenuListener = useCallback(\n e => {\n const targetElement = selector ? e.target.closest(selector.query.toString()) : e.target;\n if (\n shouldOverrideContextMenu(targetElement, columns) &&\n // TODO: We will add \"Open link in new tab\" option in context menu once the custom context menu is made accessible.\n !e.target.closest('a')\n ) {\n e.stopPropagation();\n e.preventDefault();\n contextMenuRef.targetCell = targetElement;\n const { colId } = contextMenuRef.targetCell.dataset;\n contextMenuRef.column = columns.find(col => col.field.id.toString() === colId?.toString());\n contextMenuRef.rowContextData = getRowContextData(data, paginationOptions, targetElement);\n targetElement.classList.add('selection-border', 'disable-select');\n const options = getMenuItems(\n targetElement,\n contextMenuRef.column,\n contextMenuRef.rowContextData,\n columns,\n filterExpression,\n applyViewFilter,\n clearFilter,\n translate\n );\n setShowMenu(true);\n setMenuItems(options);\n }\n },\n\n [\n selector,\n columns,\n contextMenuRef.targetCell,\n contextMenuRef.column,\n contextMenuRef.rowContextData,\n data,\n paginationOptions,\n filterExpression,\n applyViewFilter,\n clearFilter,\n translate\n ]\n );\n\n useEffect(() => {\n if (domContainer) {\n domContainer.addEventListener('contextmenu', contextMenuListener);\n domContainer.addEventListener('keydown', onMenuItemClick);\n }\n return () => {\n if (domContainer) {\n domContainer.removeEventListener('contextmenu', contextMenuListener);\n domContainer.removeEventListener('keydown', onMenuItemClick);\n }\n };\n }, [domContainer, contextMenuListener, onMenuItemClick]);\n\n if (!contextMenuRef.targetCell || !showMenu || !domContainer) {\n if (contextMenuRef.targetCell && selector) {\n contextMenuRef.targetCell.classList.remove('selection-border', 'disable-select');\n }\n return null;\n }\n\n return (\n <Popover portal ref={setPopperRef} target={contextMenuRef.targetCell}>\n <StyledPopover>\n {menuItems.map(menu => (\n <MenuItem\n key={menu.id}\n onMenuItemClick={onMenuItemClick}\n target={contextMenuRef.targetCell}\n column={contextMenuRef.column}\n rowContextData={contextMenuRef.rowContextData}\n menu={menu}\n />\n ))}\n </StyledPopover>\n </Popover>\n );\n}\n\nContextMenuContainer.propTypes = {\n view: PropTypes.objectOf(PropTypes.any).isRequired,\n selector: PropTypes.objectOf(PropTypes.any).isRequired\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ContextMenuContainer.js","sourceRoot":"","sources":["../../../../Core/Components/ContextMenu/ContextMenuContainer.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,EAChB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,eAAe,IAAI,EAAE,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE/B,CAAC;AAEF,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC7C,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAA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AC,QAAQ,IAEP,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,cAAc,CAAC,UAAU,EACjC,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,IAAI,EAAE,IAAI,IALL,IAAI,CAAC,EAAE,CAMZ,CACH,CAAC,GACY,GACR,CACX,CAAC;AACJ,CAAC;AAED,oBAAoB,CAAC,SAAS,GAAG;IAC/B,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;IAClD,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;CACvD,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport { useRef, useState, useMemo, useEffect, useCallback } from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix } from 'polished';\n\nimport { Popover, Icon, useElement, useOuterEvent, tryCatch } from '@pega/cosmos-react-core';\nimport {\n getRowContextData,\n getScrollerElem,\n isFilterApplied\n} from 'pega-repeating-structures-core';\n\nimport { createClassName as cx } from '../../Utils';\nimport useTranslate from '../../Hooks/useTranslate';\nimport useScrollAway from '../../Hooks/useScrollAway';\n\nimport { applyFilter, quickFilterEnabled, removeFilter } from './QuickFilter';\nimport copyText from './CopyPaste';\n\nconst StyledPopover = styled.div`\n width: 10rem;\n`;\n\nconst StyledContent = styled.div(({ theme }) => {\n const hoverColor = tryCatch(() =>\n mix(0.95, theme.base.palette['primary-background'], theme.base.palette.interactive)\n );\n return css`\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n padding: 0.25rem;\n border-radius: 0.156rem;\n box-sizing: border-box;\n cursor: pointer;\n margin-top: 0.125rem;\n margin-bottom: 0.125rem;\n :hover {\n background-color: ${hoverColor};\n box-shadow: ${theme.base.shadow['focus-inset']};\n }\n `;\n});\n\nconst StyledListItem = styled.div(({ theme }) => {\n return css`\n button {\n display: flex;\n align-items: center;\n /* stylelint-disable unit-allowed-list */\n padding: 4px 8px;\n }\n .label {\n padding-left: 14px;\n vertical-align: text-top;\n }\n .disabled {\n padding-left: 14px;\n vertical-align: text-top;\n opacity: ${theme.base['disabled-opacity']};\n }\n `;\n});\n\nconst StyledButton = styled.button`\n display: block;\n text-align: start;\n background: none;\n border: none;\n line-height: 1;\n outline: none;\n cursor: pointer;\n color: ${props => props.theme.base.palette['foreground-color']};\n border-radius: 0;\n`;\n\nconst getDefaultMenuItems = (\n column,\n rowContextData,\n targetCell,\n columns,\n filterExpression,\n actionColumnFiltering,\n actionClearFiltering,\n translate\n) => {\n const isFiltered = isFilterApplied(column, filterExpression);\n return [\n {\n id: 'quickFilter',\n icon: isFiltered ? 'times' : 'filter',\n label: isFiltered ? translate('Remove filter') : translate('Filter by this'),\n show: !!quickFilterEnabled(columns, column.field.id),\n disabled: false,\n onClick: () => {\n if (isFiltered) {\n return removeFilter(\n filterExpression,\n targetCell,\n actionColumnFiltering,\n actionClearFiltering\n );\n }\n return applyFilter(\n columns,\n targetCell,\n rowContextData,\n filterExpression,\n actionColumnFiltering\n );\n }\n },\n {\n id: 'copyText',\n icon: 'copy',\n label: translate('Copy text'),\n show: true,\n disabled: false,\n onClick: () => copyText(targetCell)\n },\n {\n id: 'pasteText',\n icon: 'documents',\n label: translate('Paste text'),\n show: true,\n disabled: true,\n onClick: () => {}\n }\n ];\n};\n\nconst getMenuItems = (\n targetCell,\n column,\n rowContextData,\n columns,\n filterExpression,\n actionColumnFiltering,\n actionClearFiltering,\n translate\n) => {\n const fieldContextOptions = column.field?.contextMenuOptions || [];\n return [\n ...getDefaultMenuItems(\n column,\n rowContextData,\n targetCell,\n columns,\n filterExpression,\n actionColumnFiltering,\n actionClearFiltering,\n translate\n ),\n ...fieldContextOptions\n ];\n};\n\nconst shouldOverrideContextMenu = (targetCell, columns) => {\n if (!targetCell) {\n return false;\n }\n const { colId } = targetCell.dataset;\n\n const { field } = columns.find(col => col.field.id.toString() === colId?.toString()) || {};\n return !(!field || field?.noContextMenu);\n};\n\nconst MenuItem = ({\n menu = {},\n target = {},\n column = {},\n rowContextData = {},\n onMenuItemClick = () => {}\n}) => {\n const { onClick = () => {}, icon, disabled = false, show = true, label } = menu;\n if (!show) {\n return null;\n }\n\n return (\n <StyledContent\n onClick={() => {\n onMenuItemClick();\n onClick(target, column, rowContextData);\n }}\n >\n <StyledListItem>\n <StyledButton>\n {icon && <Icon name={icon} />}\n <span className={cx('label', { disabled })}>{label}</span>\n </StyledButton>\n </StyledListItem>\n </StyledContent>\n );\n};\n\nMenuItem.propTypes = {\n menu: PropTypes.objectOf(PropTypes.any),\n target: PropTypes.objectOf(PropTypes.any),\n column: PropTypes.objectOf(PropTypes.any),\n rowContextData: PropTypes.objectOf(PropTypes.any),\n onMenuItemClick: PropTypes.func\n};\n\nexport default function ContextMenuContainer({ view, selector }) {\n const {\n columns,\n data,\n state: { paginationOptions, filterExpression } = {},\n domContainer,\n type: { applyFilter: applyViewFilter, clearFilter }\n } = view;\n const [translate] = useTranslate();\n const contextMenuRef = useRef({}).current;\n const [showMenu, setShowMenu] = useState(false);\n const [menuItems, setMenuItems] = useState([]);\n const [popperRef, setPopperRef] = useElement();\n const scrollerElem = useMemo(() => getScrollerElem(view), [view]);\n\n useOuterEvent('mousedown', [popperRef], () => {\n setShowMenu(false);\n });\n\n useScrollAway(popperRef, scrollerElem, () => {\n setShowMenu(false);\n });\n\n const onMenuItemClick = useCallback(event => {\n if (event && event.key !== 'Escape') {\n return;\n }\n setShowMenu(false);\n }, []);\n\n const contextMenuListener = useCallback(\n e => {\n const targetElement = selector ? e.target.closest(selector.query.toString()) : e.target;\n if (\n shouldOverrideContextMenu(targetElement, columns) &&\n // TODO: We will add \"Open link in new tab\" option in context menu once the custom context menu is made accessible.\n !e.target.closest('a')\n ) {\n e.stopPropagation();\n e.preventDefault();\n contextMenuRef.targetCell = targetElement;\n const { colId } = contextMenuRef.targetCell.dataset;\n contextMenuRef.column = columns.find(col => col.field.id.toString() === colId?.toString());\n contextMenuRef.rowContextData = getRowContextData(data, paginationOptions, targetElement);\n targetElement.classList.add('selection-border', 'disable-select');\n const options = getMenuItems(\n targetElement,\n contextMenuRef.column,\n contextMenuRef.rowContextData,\n columns,\n filterExpression,\n applyViewFilter,\n clearFilter,\n translate\n );\n setShowMenu(true);\n setMenuItems(options);\n }\n },\n\n [\n selector,\n columns,\n contextMenuRef.targetCell,\n contextMenuRef.column,\n contextMenuRef.rowContextData,\n data,\n paginationOptions,\n filterExpression,\n applyViewFilter,\n clearFilter,\n translate\n ]\n );\n\n useEffect(() => {\n if (domContainer) {\n domContainer.addEventListener('contextmenu', contextMenuListener);\n domContainer.addEventListener('keydown', onMenuItemClick);\n }\n return () => {\n if (domContainer) {\n domContainer.removeEventListener('contextmenu', contextMenuListener);\n domContainer.removeEventListener('keydown', onMenuItemClick);\n }\n };\n }, [domContainer, contextMenuListener, onMenuItemClick]);\n\n if (!contextMenuRef.targetCell || !showMenu || !domContainer) {\n if (contextMenuRef.targetCell && selector) {\n contextMenuRef.targetCell.classList.remove('selection-border', 'disable-select');\n }\n return null;\n }\n\n return (\n <Popover portal ref={setPopperRef} target={contextMenuRef.targetCell}>\n <StyledPopover>\n {menuItems.map(menu => (\n <MenuItem\n key={menu.id}\n onMenuItemClick={onMenuItemClick}\n target={contextMenuRef.targetCell}\n column={contextMenuRef.column}\n rowContextData={contextMenuRef.rowContextData}\n menu={menu}\n />\n ))}\n </StyledPopover>\n </Popover>\n );\n}\n\nContextMenuContainer.propTypes = {\n view: PropTypes.objectOf(PropTypes.any).isRequired,\n selector: PropTypes.objectOf(PropTypes.any).isRequired\n};\n"]}
|
|
@@ -11,5 +11,21 @@ declare namespace GroupHeader {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export default GroupHeader;
|
|
14
|
+
/**
|
|
15
|
+
* Formats additional field data based on its type and properties.
|
|
16
|
+
*/
|
|
17
|
+
export type AdditionalFieldData = NonNullable<Awaited<ReturnType<NonNullable<import("pega-repeating-structures-core").RsCoreTypes.ApiContext["fetchGroupedInfo"]>>>[number]["additionalFieldsData"]>[number];
|
|
18
|
+
/**
|
|
19
|
+
* Formats additional field data based on its type and properties.
|
|
20
|
+
*/
|
|
21
|
+
export type Column = import("pega-repeating-structures-core").RsCoreTypes.Column;
|
|
22
|
+
/**
|
|
23
|
+
* Formats additional field data based on its type and properties.
|
|
24
|
+
*/
|
|
25
|
+
export type Meta = import("pega-repeating-structures-core").RsCoreTypes.Meta;
|
|
26
|
+
/**
|
|
27
|
+
* Formats additional field data based on its type and properties.
|
|
28
|
+
*/
|
|
29
|
+
export type GroupGenerator = import("pega-repeating-structures-core").RsCoreTypes.GroupGenerator;
|
|
14
30
|
import PropTypes from 'prop-types';
|
|
15
31
|
//# sourceMappingURL=GroupRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupRenderer.d.ts","sourceRoot":"","sources":["../../../Core/Components/GroupRenderer.jsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupRenderer.d.ts","sourceRoot":"","sources":["../../../Core/Components/GroupRenderer.jsx"],"names":[],"mappings":"AAwXA;;;mDAqIC;;;;;;;;;;;;;kCA7UY,WAAW,CACnB,OAAO,CACL,UAAU,CACR,WAAW,CACnB,OAAiB,gCAAgC,EAAE,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,CACpF,CACF,CACF,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAClC,CAAC,MAAM,CAAC;;;;qBAEC,OAAO,gCAAgC,EAAE,WAAW,CAAC,MAAM;;;;mBAC3D,OAAO,gCAAgC,EAAE,WAAW,CAAC,IAAI;;;;6BACzD,OAAO,gCAAgC,EAAE,WAAW,CAAC,cAAc;sBA5L1D,YAAY"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
-
import { Icon } from '@pega/cosmos-react-core';
|
|
5
|
+
import { Flex, Icon, Tooltip, useElement, Text, MetaList } from '@pega/cosmos-react-core';
|
|
6
6
|
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
7
7
|
import { getGroupFromKey } from 'pega-ui-list-data-apis';
|
|
8
|
+
import { dateFunctionLabels, FieldType } from 'pega-repeating-structures-core';
|
|
9
|
+
import { StyledMetaListItem } from '@pega/cosmos-react-core/lib/components/MetaList/MetaList';
|
|
8
10
|
import { createClassName as cx } from '../Utils';
|
|
9
11
|
import useTranslate from '../Hooks/useTranslate';
|
|
10
12
|
import { customFunctions, intervalGroupingBoundaries } from '../constants';
|
|
@@ -12,6 +14,7 @@ import AggregatorCell from './AggregatorCell';
|
|
|
12
14
|
import RenderingEngine from './RenderingEngine/RenderCell';
|
|
13
15
|
import DateValueDisplay from './DateValueDisplay';
|
|
14
16
|
import TestIdConstants from './TestIdConstants';
|
|
17
|
+
import { getFormattedAggregationValue } from './AggregateMenu';
|
|
15
18
|
const groupheaderleftdisplacement = headerLevel => `${(headerLevel.level + 1) * 0.5}rem`;
|
|
16
19
|
/**
|
|
17
20
|
* TODO: remove currentColor style after cosmos fixes the issue
|
|
@@ -108,6 +111,7 @@ const StyledGroupHeader = styled.div `
|
|
|
108
111
|
|
|
109
112
|
> .group-wrapper {
|
|
110
113
|
margin-inline-start: ${({ groupHeader, theme }) => groupHeader.count === 0 ? `calc(${theme.base.spacing} * 2.25)` : 'unset'};
|
|
114
|
+
align-items: baseline;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
.cell-content {
|
|
@@ -139,6 +143,107 @@ const StyledGroupHeader = styled.div `
|
|
|
139
143
|
background-color: var(--group-bg-color);
|
|
140
144
|
}
|
|
141
145
|
`;
|
|
146
|
+
const StyledText = styled(Text) `
|
|
147
|
+
display: inline-flex;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
text-overflow: ellipsis;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
`;
|
|
152
|
+
const StyledMetaList = styled(MetaList) `
|
|
153
|
+
margin-inline-start: 0;
|
|
154
|
+
`;
|
|
155
|
+
const GroupAdditionalInfoSeparator = styled(StyledMetaListItem) `
|
|
156
|
+
margin-inline-start: 0.3rem;
|
|
157
|
+
`;
|
|
158
|
+
/**
|
|
159
|
+
* For
|
|
160
|
+
* @param {*} additionalFieldData
|
|
161
|
+
* @param {*} additionalField
|
|
162
|
+
* @param {*} param2
|
|
163
|
+
* @returns
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* Formats additional field data based on its type and properties.
|
|
167
|
+
*
|
|
168
|
+
* @typedef {NonNullable<
|
|
169
|
+
* Awaited<
|
|
170
|
+
* ReturnType<
|
|
171
|
+
* NonNullable<
|
|
172
|
+
* import('pega-repeating-structures-core').RsCoreTypes.ApiContext['fetchGroupedInfo']
|
|
173
|
+
* >
|
|
174
|
+
* >
|
|
175
|
+
* >[number]['additionalFieldsData']
|
|
176
|
+
* >[number]} AdditionalFieldData
|
|
177
|
+
*
|
|
178
|
+
* @typedef {import('pega-repeating-structures-core').RsCoreTypes.Column} Column
|
|
179
|
+
* @typedef {import('pega-repeating-structures-core').RsCoreTypes.Meta} Meta
|
|
180
|
+
* @typedef {import('pega-repeating-structures-core').RsCoreTypes.GroupGenerator} GroupGenerator
|
|
181
|
+
*
|
|
182
|
+
* @param {AdditionalFieldData} additionalFieldData - The data for the additional field.
|
|
183
|
+
* @param {import('pega-repeating-structures-core').RsCoreTypes.GroupAdditionalField} additionalField - The configuration for the additional field.
|
|
184
|
+
* @param {{column: Column, meta: Meta, groupHeader: GroupGenerator}} config - Additional config for formatting.
|
|
185
|
+
* @param {Column} config.column - The column configuration.
|
|
186
|
+
* @param {Meta} config.meta - RS Meta.
|
|
187
|
+
* @param {GroupGenerator} config.groupHeader - The group header data.
|
|
188
|
+
*
|
|
189
|
+
* @returns {{label: string, renderer: ReactNode | string}} An object containing the formatted label and renderer.
|
|
190
|
+
* @returns {string} returns.label - The formatted label for the additional field.
|
|
191
|
+
* @returns {ReactNode | string} returns.renderer - The React component or value to render.
|
|
192
|
+
*/
|
|
193
|
+
const getFormattedAdditionalFieldData = (additionalFieldData, additionalField, { column, meta, groupHeader, translate }) => {
|
|
194
|
+
const { value, count = 0 } = additionalFieldData || {};
|
|
195
|
+
const { aggregation, dateFunction } = additionalField || {};
|
|
196
|
+
const { locale, timezone } = meta;
|
|
197
|
+
const { label, field: { type } } = column;
|
|
198
|
+
// Additional field as aggregation
|
|
199
|
+
if (aggregation && type === FieldType.NUMBER) {
|
|
200
|
+
return {
|
|
201
|
+
label: `${label}(${translate(aggregation)})`,
|
|
202
|
+
renderer: getFormattedAggregationValue(value, aggregation, column)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// Additional field as Date part
|
|
206
|
+
if (dateFunction && [FieldType.DATE, FieldType.DATE_TIME, FieldType.DATE_ONLY].includes(type)) {
|
|
207
|
+
return {
|
|
208
|
+
label: `${label}(${translate(dateFunctionLabels[dateFunction])})`,
|
|
209
|
+
renderer: (_jsx(DateValueDisplay, { value: value, dateFunction: dateFunction, locale: locale, timezone: timezone }))
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// Additional field as normal field but with multiple values.
|
|
213
|
+
if (count > 1) {
|
|
214
|
+
const { getFormatterByKey } = column.parent;
|
|
215
|
+
const integerFormatter = getFormatterByKey('Integer');
|
|
216
|
+
return {
|
|
217
|
+
label: `${label}(${translate('Count')})`,
|
|
218
|
+
renderer: integerFormatter ? integerFormatter(count, { locale }) : count
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// Additional field as normal field.
|
|
222
|
+
column.setExecutionContext(null);
|
|
223
|
+
return {
|
|
224
|
+
label,
|
|
225
|
+
renderer: (_jsx(RenderingEngine, { ...column.getRenderingEngineProps(),
|
|
226
|
+
context: {
|
|
227
|
+
...column.getContext(),
|
|
228
|
+
name: 'GroupAdditionalField',
|
|
229
|
+
getValue: () => value,
|
|
230
|
+
getExecutionContext: () => {
|
|
231
|
+
return { getValue: () => groupHeader.data, name: 'groupHeader' };
|
|
232
|
+
}
|
|
233
|
+
} }))
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
const GroupAdditionalInfo = ({ additionalFieldData, columns, groupHeader, additionalField }) => {
|
|
237
|
+
const [infoRef, setInfoRef] = useElement(null);
|
|
238
|
+
const [translate] = useTranslate();
|
|
239
|
+
const { id } = additionalFieldData;
|
|
240
|
+
const column = columns.find(c => c.field.id === id);
|
|
241
|
+
if (!column)
|
|
242
|
+
return null;
|
|
243
|
+
const { meta } = column.parent;
|
|
244
|
+
const { label, renderer } = getFormattedAdditionalFieldData(additionalFieldData, additionalField, { column, meta, groupHeader, translate });
|
|
245
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Flex, { container: { gap: 0.5 }, ref: setInfoRef, children: [_jsxs(StyledText, { variant: 'secondary', "data-testid": 'additional-field-label', children: [label, ":"] }), _jsx(StyledText, { variant: 'secondary', "data-testid": 'additional-field-renderer', children: renderer })] }), _jsxs(Tooltip, { smart: true, target: infoRef, showDelay: 'short', hideDelay: 'none', children: [_jsx(Text, { children: `${label}: ` }), _jsx(Text, { children: renderer })] })] }));
|
|
246
|
+
};
|
|
142
247
|
/**
|
|
143
248
|
* Returns label for interval grouping based on interval and boundaries
|
|
144
249
|
Response data depends on boundary settings.
|
|
@@ -204,7 +309,7 @@ export default function GroupHeader({ groupHeader, columns }) {
|
|
|
204
309
|
return null;
|
|
205
310
|
const view = columns[0].parent;
|
|
206
311
|
// If grouping by a regular column (i.e. without a dateFunction), determine props for the renderer
|
|
207
|
-
const { columnId, dateFunction, customFunction } = getGroupFromKey(groupHeader.groupBy, view.state.groups) ?? {};
|
|
312
|
+
const { columnId, dateFunction, customFunction, additionalFields = [] } = getGroupFromKey(groupHeader.groupBy, view.state.groups) ?? {};
|
|
208
313
|
// if state.groups is not yet prepared/updated, then getGroupFromKey will return undefined
|
|
209
314
|
if (!columnId) {
|
|
210
315
|
return null;
|
|
@@ -216,6 +321,7 @@ export default function GroupHeader({ groupHeader, columns }) {
|
|
|
216
321
|
? formatter(groupHeader.count, { locale })
|
|
217
322
|
: groupHeader.count;
|
|
218
323
|
const isAggregationApplied = columns.filter(c => !c.hidden).some(c => c.aggregated);
|
|
324
|
+
// FIXME: Import rather than COPY, i would rather
|
|
219
325
|
return (_jsxs(StyledGroupHeader, { groupHeader: groupHeader, className: cx('row group-header-row sticky-group-header'), "data-test-id": 'groupHeader', "data-testid": TestIdConstants.groupHeader, isAggregationApplied: isAggregationApplied, role: 'row', onFocus: e => {
|
|
220
326
|
if (buttonRef.current && !e.currentTarget.contains(e.relatedTarget)) {
|
|
221
327
|
e.preventDefault();
|
|
@@ -224,7 +330,9 @@ export default function GroupHeader({ groupHeader, columns }) {
|
|
|
224
330
|
}, children: [_jsx("div", { className: 'stickyGroupHeader', children: _jsxs(BareButton, { ref: buttonRef, "aria-label": `${column.field.hideGroupColumnNameLabel ? '' : groupHeader.label} ${groupHeader.name}, ${groupCountFormatted} items`, "aria-expanded": !!groupHeader.isExpanded, style: {
|
|
225
331
|
paddingRight: 'var(--group-left)'
|
|
226
332
|
}, onClick: () => groupHeader.count > 0 && view.type.toggleGroupExpansion({ groupHeader }), tabIndex: -1, icon: true, children: [groupHeader.count > 0 &&
|
|
227
|
-
(groupHeader.isExpanded ? _jsx(Icon, { name: 'caret-down' }) : _jsx(Icon, { name: 'caret-right' })), _jsxs("div", { className: 'group-wrapper', children: [_jsx("div", { className: 'group-label' }), !column.field.hideGroupColumnNameLabel && (_jsxs("span", { className: 'group-header-groupby', "data-test-id": groupHeader.groupBy, "data-testid": `${TestIdConstants.groupHeaderGroupBy}-${groupHeader.groupBy}`, children: [groupHeader.label, ":"] })), _jsx("div", { className: 'group-label' }), _jsxs("span", { className: 'group-context-count', style: { display: 'inline-flex' }, "data-test-id": 'groupHeader', "data-testid": TestIdConstants.groupHeaderCount, children: [_jsx(GroupName, { view: view, column: column, groupHeader: groupHeader, dateFunction: dateFunction, customFunction: customFunction }), _jsx("span", { className: 'group-count', children: ` (${groupCountFormatted})` })] })
|
|
333
|
+
(groupHeader.isExpanded ? _jsx(Icon, { name: 'caret-down' }) : _jsx(Icon, { name: 'caret-right' })), _jsxs("div", { className: 'group-wrapper', children: [_jsx("div", { className: 'group-label' }), !column.field.hideGroupColumnNameLabel && (_jsxs("span", { className: 'group-header-groupby', "data-test-id": groupHeader.groupBy, "data-testid": `${TestIdConstants.groupHeaderGroupBy}-${groupHeader.groupBy}`, children: [groupHeader.label, ":"] })), _jsx("div", { className: 'group-label' }), _jsxs("span", { className: 'group-context-count', style: { display: 'inline-flex' }, "data-test-id": 'groupHeader', "data-testid": TestIdConstants.groupHeaderCount, children: [_jsx(GroupName, { view: view, column: column, groupHeader: groupHeader, dateFunction: dateFunction, customFunction: customFunction }), _jsx("span", { className: 'group-count', children: ` (${groupCountFormatted})` })] }), !!(groupHeader.additionalFieldsData?.length && additionalFields.length) && (_jsxs(_Fragment, { children: [_jsx(Text, { "aria-hidden": true, variant: 'secondary', as: GroupAdditionalInfoSeparator, children: "\u2022" }), _jsx(StyledMetaList, { wrapItems: false, items: [
|
|
334
|
+
...groupHeader.additionalFieldsData.map(additionalFieldsData => (_jsx(GroupAdditionalInfo, { additionalFieldData: additionalFieldsData, additionalField: additionalFields.find(additionalField => additionalField.id === additionalFieldsData.id), columns: columns, groupHeader: groupHeader })))
|
|
335
|
+
] })] }))] })] }) }), _jsx("div", { className: 'group-header-aggregation-row', children: columns.map(c => {
|
|
228
336
|
const cxt = {
|
|
229
337
|
getValue: () => groupHeader?.aggregation?.[c.field.name]?.[c.aggregationType?.toLowerCase()]
|
|
230
338
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"G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AAC,CAAC,EAAE;oBACf,MAAM,GAAG,GAAG;wBACV,QAAQ,EAAE,GAAG,EAAE,CACb,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,WAAW,EAAE,CAAC;qBAC/E,CAAC;oBACF,OAAO,CACL,KAAC,cAAc,IAEb,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE;4BACpB,YAAY,EAAE,MAAM,CAAC,MAAM;yBAC5B,CAAC,IALG,CAAC,CAAC,KAAK,CAAC,EAAE,CAMf,CACH,CAAC;gBACJ,CAAC,CAAC,GACE,IACY,CACrB,CAAC;AACJ,CAAC;AAED,WAAW,CAAC,SAAS,GAAG;IACtB,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;IACpD,WAAW,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;CAC1D,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport { useRef } from 'react';\nimport styled from 'styled-components';\n\nimport { Icon } from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport { getGroupFromKey } from 'pega-ui-list-data-apis';\n\nimport { createClassName as cx } from '../Utils';\nimport useTranslate from '../Hooks/useTranslate';\nimport { customFunctions, intervalGroupingBoundaries } from '../constants';\n\nimport AggregatorCell from './AggregatorCell';\nimport RenderingEngine from './RenderingEngine/RenderCell';\nimport DateValueDisplay from './DateValueDisplay';\nimport TestIdConstants from './TestIdConstants';\n\nconst groupheaderleftdisplacement = headerLevel => `${(headerLevel.level + 1) * 0.5}rem`;\n/**\n * TODO: remove currentColor style after cosmos fixes the issue\n * Cosmos yet to handle dark theme on BareButton\n */\n\nconst StyledGroupHeader = styled.div`\n --group-left: ${props => groupheaderleftdisplacement(props.groupHeader)};\n --group-bg-color: ${props => props.theme.base.palette['secondary-background']};\n background-color: var(--group-bg-color);\n &:has(button[aria-expanded='true']) {\n filter: ${props => props.theme.base.shadow['low-filter']};\n }\n\n &.row.sticky-group-header {\n position: sticky;\n display: block;\n top: calc(\n ${props =>\n props.groupHeader.isLeafNode && props.groupHeader.level !== 0\n ? 'calc(var(--row-height) + var(--group-header-height))'\n : 'var(--row-height)'}\n );\n\n /* z-index starting from 8 because freeze-line has z-index 7 */\n z-index: ${props => `${8 + props.groupHeader.index}`};\n > .cell-action,\n .cell-fixed {\n background-color: var(--group-bg-color);\n }\n }\n\n .group-label {\n width: 0.437rem;\n display: inline-block;\n flex-shrink: 0;\n }\n\n .group-header-groupby {\n font-weight: ${props => props.theme.base['font-weight'].normal};\n }\n\n .group-context-count .group-count {\n font-weight: ${props => props.theme.base['font-weight'].bold};\n white-space: pre;\n }\n\n &.row.group-header-row {\n height: auto;\n border-bottom: ${props => (!props.isAggregationApplied ? 'var(--border-style)' : 'none')};\n\n .group-header-aggregation-row {\n display: flex;\n\n /* Using height 0 so that the aggregations aren't visible when not applied but the cells can take the width and stretch the group header to the full width */\n height: ${props => (props.isAggregationApplied ? 'var(--group-header-height)' : 0)};\n\n &::before {\n content: '';\n position: sticky;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 0.25rem;\n height: 100%;\n background-color: ${props => props.groupHeader.colorIndicator};\n z-index: 12;\n }\n }\n }\n\n &.group-header-row .stickyGroupHeader {\n position: sticky;\n left: 0;\n width: 0;\n z-index: 10;\n height: var(--group-header-height);\n\n > button {\n color: currentColor;\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n width: max-content;\n max-width: var(--container-width);\n display: flex;\n align-items: center;\n background-color: var(--group-bg-color);\n padding-left: var(--group-left);\n margin-inline-start: 0.25rem;\n z-index: 30;\n cursor: pointer;\n white-space: nowrap;\n text-align: inherit;\n font-stretch: inherit;\n\n > .group-wrapper {\n margin-inline-start: ${({ groupHeader, theme }) =>\n groupHeader.count === 0 ? `calc(${theme.base.spacing} * 2.25)` : 'unset'};\n }\n\n .cell-content {\n max-height: var(--group-header-height);\n padding: 0;\n }\n }\n button:focus {\n box-shadow: ${({ theme }) => theme.base.shadow['focus-inset']};\n }\n\n &::before {\n content: '';\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 0.25rem;\n height: 100%;\n background-color: ${props => props.groupHeader.colorIndicator};\n z-index: 12;\n }\n }\n .group-header.cell {\n left: 0;\n padding-left: var(--group-left);\n }\n\n div.group-header.cell-fixed {\n background-color: var(--group-bg-color);\n }\n`;\n\n/**\n * Returns label for interval grouping based on interval and boundaries\n Response data depends on boundary settings.\n Ex: For sample data of profit\n profit --> cases(count)\n {'0': 10, 1': 100, '2':30, '10': 35, '15':45, '20':2}\n For Interval 10\n If the boundary is 'include-lower-only',\n and value is 10 then label -> 10 to 20\n\n If boundary is 'include-upper-only',\n and value is 10 then label -> 0 to 10\n * */\nfunction buildIntervalGroupingLabel(value, customFunction, translate) {\n const { interval, boundaries } = customFunction;\n // To restrict the decimals in labels\n const intervalDecimalLength = (interval.toString().split('.')[1] || '').length;\n value = Number(value);\n // In case of 'include-lower-only'\n let lowerValue = value.toFixed(intervalDecimalLength);\n let upperValue = (value + interval).toFixed(intervalDecimalLength);\n // In case of boundary 'include-upper-only'\n if (boundaries === intervalGroupingBoundaries.includeUpperOnly) {\n lowerValue = (value - interval).toFixed(intervalDecimalLength);\n upperValue = value.toFixed(intervalDecimalLength);\n }\n return `${lowerValue} ${translate('to')} ${upperValue}`;\n}\n\nfunction GroupName({ view, column, groupHeader, dateFunction, customFunction }) {\n const [translate] = useTranslate();\n const { locale, timezone } = view.meta;\n const isRangeGrouping = customFunction?.type === customFunctions.RANGE_GROUPING;\n const isIntervalGrouping = customFunction?.type === customFunctions.INTERVAL_GROUPING;\n\n if (dateFunction) {\n return (\n <DateValueDisplay\n value={groupHeader.name}\n dateFunction={dateFunction}\n locale={locale}\n timezone={timezone}\n />\n );\n }\n\n if (isRangeGrouping) {\n /** If custom range grouping applied on number field , we need to show group name as text instead of number */\n return groupHeader.name;\n }\n\n if (isIntervalGrouping) {\n /** If custom range grouping applied on number , we need to show group name based on value and custom function details like interval and boundaries */\n return buildIntervalGroupingLabel(groupHeader.name, customFunction, translate);\n }\n\n column.setExecutionContext(null); // If null is not set then it will execute on the previous row context and facing issues when cell is edited. Based on column.editMode and current context renderer varies (it can be cellEditRenderer)\n\n const columnRendererProps = {\n ...column.getRenderingEngineProps(),\n context: {\n getValue: () => groupHeader.name,\n getExecutionContext: () => {\n return { getValue: () => groupHeader.data, name: 'groupHeader' };\n }\n }\n };\n\n return <RenderingEngine {...columnRendererProps} />;\n}\n\n// NOTE: While making any changes in GroupRenderer.jsx, also make similar changes in HierarchicalGroupRenderer.jsx file if applicable\n\nexport default function GroupHeader({ groupHeader, columns }) {\n const buttonRef = useRef();\n\n // TODO: This we are adding temporary to show freeze border until we make group header rendering change\n // when we will pick up aggregation.\n if (!groupHeader.isVisible) return null;\n\n const view = columns[0].parent;\n // If grouping by a regular column (i.e. without a dateFunction), determine props for the renderer\n const { columnId, dateFunction, customFunction } =\n getGroupFromKey(groupHeader.groupBy, view.state.groups) ?? {};\n // if state.groups is not yet prepared/updated, then getGroupFromKey will return undefined\n if (!columnId) {\n return null;\n }\n\n const column = columns.find(c => c.field.id === columnId);\n const formatter = view.getFormatterByKey('Integer');\n const { locale } = view.meta;\n const groupCountFormatted = formatter\n ? formatter(groupHeader.count, { locale })\n : groupHeader.count;\n const isAggregationApplied = columns.filter(c => !c.hidden).some(c => c.aggregated);\n\n return (\n <StyledGroupHeader\n groupHeader={groupHeader}\n className={cx('row group-header-row sticky-group-header')}\n data-test-id='groupHeader'\n data-testid={TestIdConstants.groupHeader}\n isAggregationApplied={isAggregationApplied}\n role='row'\n onFocus={e => {\n if (buttonRef.current && !e.currentTarget.contains(e.relatedTarget)) {\n e.preventDefault();\n buttonRef.current.focus();\n }\n }}\n >\n <div className='stickyGroupHeader'>\n <BareButton\n ref={buttonRef}\n aria-label={`${\n column.field.hideGroupColumnNameLabel ? '' : groupHeader.label\n } ${groupHeader.name}, ${groupCountFormatted} items`}\n aria-expanded={!!groupHeader.isExpanded}\n style={{\n paddingRight: 'var(--group-left)'\n }}\n onClick={() => groupHeader.count > 0 && view.type.toggleGroupExpansion({ groupHeader })}\n tabIndex={-1}\n icon\n >\n {groupHeader.count > 0 &&\n (groupHeader.isExpanded ? <Icon name='caret-down' /> : <Icon name='caret-right' />)}\n <div className='group-wrapper'>\n <div className='group-label' />\n {!column.field.hideGroupColumnNameLabel && (\n <span\n className='group-header-groupby'\n data-test-id={groupHeader.groupBy}\n data-testid={`${TestIdConstants.groupHeaderGroupBy}-${groupHeader.groupBy}`}\n >\n {groupHeader.label}:\n </span>\n )}\n <div className='group-label' />\n <span\n className='group-context-count'\n style={{ display: 'inline-flex' }}\n data-test-id='groupHeader'\n data-testid={TestIdConstants.groupHeaderCount}\n >\n <GroupName\n view={view}\n column={column}\n groupHeader={groupHeader}\n dateFunction={dateFunction}\n customFunction={customFunction}\n />\n {/* adding whitespace pre to preserve the space at the begining of count text */}\n <span className='group-count'>{` (${groupCountFormatted})`}</span>\n </span>\n </div>\n </BareButton>\n </div>\n <div className='group-header-aggregation-row'>\n {columns.map(c => {\n const cxt = {\n getValue: () =>\n groupHeader?.aggregation?.[c.field.name]?.[c.aggregationType?.toLowerCase()]\n };\n return (\n <AggregatorCell\n key={c.field.id}\n column={c}\n context={cxt}\n className={cx('cell', {\n 'cell-fixed': column.frozen\n })}\n />\n );\n })}\n </div>\n </StyledGroupHeader>\n );\n}\n\nGroupHeader.propTypes = {\n columns: PropTypes.arrayOf(PropTypes.any).isRequired,\n groupHeader: PropTypes.objectOf(PropTypes.any).isRequired\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GroupRenderer.js","sourceRoot":"","sources":["../../../Core/Components/GroupRenderer.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAA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from 'styled-components';\n\nimport { Flex, Icon, Tooltip, useElement, Text, MetaList } from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport { getGroupFromKey } from 'pega-ui-list-data-apis';\nimport { dateFunctionLabels, FieldType } from 'pega-repeating-structures-core';\nimport { StyledMetaListItem } from '@pega/cosmos-react-core/lib/components/MetaList/MetaList';\n\nimport { createClassName as cx } from '../Utils';\nimport useTranslate from '../Hooks/useTranslate';\nimport { customFunctions, intervalGroupingBoundaries } from '../constants';\n\nimport AggregatorCell from './AggregatorCell';\nimport RenderingEngine from './RenderingEngine/RenderCell';\nimport DateValueDisplay from './DateValueDisplay';\nimport TestIdConstants from './TestIdConstants';\nimport { getFormattedAggregationValue } from './AggregateMenu';\n\nconst groupheaderleftdisplacement = headerLevel => `${(headerLevel.level + 1) * 0.5}rem`;\n/**\n * TODO: remove currentColor style after cosmos fixes the issue\n * Cosmos yet to handle dark theme on BareButton\n */\n\nconst StyledGroupHeader = styled.div`\n --group-left: ${props => groupheaderleftdisplacement(props.groupHeader)};\n --group-bg-color: ${props => props.theme.base.palette['secondary-background']};\n background-color: var(--group-bg-color);\n &:has(button[aria-expanded='true']) {\n filter: ${props => props.theme.base.shadow['low-filter']};\n }\n\n &.row.sticky-group-header {\n position: sticky;\n display: block;\n top: calc(\n ${props =>\n props.groupHeader.isLeafNode && props.groupHeader.level !== 0\n ? 'calc(var(--row-height) + var(--group-header-height))'\n : 'var(--row-height)'}\n );\n\n /* z-index starting from 8 because freeze-line has z-index 7 */\n z-index: ${props => `${8 + props.groupHeader.index}`};\n > .cell-action,\n .cell-fixed {\n background-color: var(--group-bg-color);\n }\n }\n\n .group-label {\n width: 0.437rem;\n display: inline-block;\n flex-shrink: 0;\n }\n\n .group-header-groupby {\n font-weight: ${props => props.theme.base['font-weight'].normal};\n }\n\n .group-context-count .group-count {\n font-weight: ${props => props.theme.base['font-weight'].bold};\n white-space: pre;\n }\n\n &.row.group-header-row {\n height: auto;\n border-bottom: ${props => (!props.isAggregationApplied ? 'var(--border-style)' : 'none')};\n\n .group-header-aggregation-row {\n display: flex;\n\n /* Using height 0 so that the aggregations aren't visible when not applied but the cells can take the width and stretch the group header to the full width */\n height: ${props => (props.isAggregationApplied ? 'var(--group-header-height)' : 0)};\n\n &::before {\n content: '';\n position: sticky;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 0.25rem;\n height: 100%;\n background-color: ${props => props.groupHeader.colorIndicator};\n z-index: 12;\n }\n }\n }\n\n &.group-header-row .stickyGroupHeader {\n position: sticky;\n left: 0;\n width: 0;\n z-index: 10;\n height: var(--group-header-height);\n\n > button {\n color: currentColor;\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n width: max-content;\n max-width: var(--container-width);\n display: flex;\n align-items: center;\n background-color: var(--group-bg-color);\n padding-left: var(--group-left);\n margin-inline-start: 0.25rem;\n z-index: 30;\n cursor: pointer;\n white-space: nowrap;\n text-align: inherit;\n font-stretch: inherit;\n\n > .group-wrapper {\n margin-inline-start: ${({ groupHeader, theme }) =>\n groupHeader.count === 0 ? `calc(${theme.base.spacing} * 2.25)` : 'unset'};\n align-items: baseline;\n }\n\n .cell-content {\n max-height: var(--group-header-height);\n padding: 0;\n }\n }\n button:focus {\n box-shadow: ${({ theme }) => theme.base.shadow['focus-inset']};\n }\n\n &::before {\n content: '';\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n width: 0.25rem;\n height: 100%;\n background-color: ${props => props.groupHeader.colorIndicator};\n z-index: 12;\n }\n }\n .group-header.cell {\n left: 0;\n padding-left: var(--group-left);\n }\n\n div.group-header.cell-fixed {\n background-color: var(--group-bg-color);\n }\n`;\n\nconst StyledText = styled(Text)`\n display: inline-flex;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n`;\n\nconst StyledMetaList = styled(MetaList)`\n margin-inline-start: 0;\n`;\nconst GroupAdditionalInfoSeparator = styled(StyledMetaListItem)`\n margin-inline-start: 0.3rem;\n`;\n\n/**\n * For\n * @param {*} additionalFieldData\n * @param {*} additionalField\n * @param {*} param2\n * @returns\n */\n/**\n * Formats additional field data based on its type and properties.\n *\n * @typedef {NonNullable<\n * Awaited<\n * ReturnType<\n * NonNullable<\n * import('pega-repeating-structures-core').RsCoreTypes.ApiContext['fetchGroupedInfo']\n * >\n * >\n * >[number]['additionalFieldsData']\n * >[number]} AdditionalFieldData\n *\n * @typedef {import('pega-repeating-structures-core').RsCoreTypes.Column} Column\n * @typedef {import('pega-repeating-structures-core').RsCoreTypes.Meta} Meta\n * @typedef {import('pega-repeating-structures-core').RsCoreTypes.GroupGenerator} GroupGenerator\n *\n * @param {AdditionalFieldData} additionalFieldData - The data for the additional field.\n * @param {import('pega-repeating-structures-core').RsCoreTypes.GroupAdditionalField} additionalField - The configuration for the additional field.\n * @param {{column: Column, meta: Meta, groupHeader: GroupGenerator}} config - Additional config for formatting.\n * @param {Column} config.column - The column configuration.\n * @param {Meta} config.meta - RS Meta.\n * @param {GroupGenerator} config.groupHeader - The group header data.\n *\n * @returns {{label: string, renderer: ReactNode | string}} An object containing the formatted label and renderer.\n * @returns {string} returns.label - The formatted label for the additional field.\n * @returns {ReactNode | string} returns.renderer - The React component or value to render.\n */\nconst getFormattedAdditionalFieldData = (\n additionalFieldData,\n additionalField,\n { column, meta, groupHeader, translate }\n) => {\n const { value, count = 0 } = additionalFieldData || {};\n const { aggregation, dateFunction } = additionalField || {};\n const { locale, timezone } = meta;\n const {\n label,\n field: { type }\n } = column;\n\n // Additional field as aggregation\n if (aggregation && type === FieldType.NUMBER) {\n return {\n label: `${label}(${translate(aggregation)})`,\n renderer: getFormattedAggregationValue(value, aggregation, column)\n };\n }\n\n // Additional field as Date part\n if (dateFunction && [FieldType.DATE, FieldType.DATE_TIME, FieldType.DATE_ONLY].includes(type)) {\n return {\n label: `${label}(${translate(dateFunctionLabels[dateFunction])})`,\n renderer: (\n <DateValueDisplay\n value={value}\n dateFunction={dateFunction}\n locale={locale}\n timezone={timezone}\n />\n )\n };\n }\n\n // Additional field as normal field but with multiple values.\n if (count > 1) {\n const { getFormatterByKey } = column.parent;\n const integerFormatter = getFormatterByKey('Integer');\n return {\n label: `${label}(${translate('Count')})`,\n renderer: integerFormatter ? integerFormatter(count, { locale }) : count\n };\n }\n\n // Additional field as normal field.\n column.setExecutionContext(null);\n return {\n label,\n renderer: (\n <RenderingEngine\n {...{\n ...column.getRenderingEngineProps(),\n context: {\n ...column.getContext(),\n name: 'GroupAdditionalField',\n getValue: () => value,\n getExecutionContext: () => {\n return { getValue: () => groupHeader.data, name: 'groupHeader' };\n }\n }\n }}\n />\n )\n };\n};\n\nconst GroupAdditionalInfo = ({ additionalFieldData, columns, groupHeader, additionalField }) => {\n const [infoRef, setInfoRef] = useElement(null);\n const [translate] = useTranslate();\n const { id } = additionalFieldData;\n const column = columns.find(c => c.field.id === id);\n\n if (!column) return null;\n\n const { meta } = column.parent;\n\n const { label, renderer } = getFormattedAdditionalFieldData(\n additionalFieldData,\n additionalField,\n { column, meta, groupHeader, translate }\n );\n\n return (\n <>\n <Flex container={{ gap: 0.5 }} ref={setInfoRef}>\n <StyledText variant='secondary' data-testid='additional-field-label'>\n {label}:\n </StyledText>\n <StyledText variant='secondary' data-testid='additional-field-renderer'>\n {renderer}\n </StyledText>\n </Flex>\n <Tooltip smart target={infoRef} showDelay='short' hideDelay='none'>\n <Text>{`${label}: `}</Text>\n <Text>{renderer}</Text>\n </Tooltip>\n </>\n );\n};\n\n/**\n * Returns label for interval grouping based on interval and boundaries\n Response data depends on boundary settings.\n Ex: For sample data of profit\n profit --> cases(count)\n {'0': 10, 1': 100, '2':30, '10': 35, '15':45, '20':2}\n For Interval 10\n If the boundary is 'include-lower-only',\n and value is 10 then label -> 10 to 20\n\n If boundary is 'include-upper-only',\n and value is 10 then label -> 0 to 10\n * */\nfunction buildIntervalGroupingLabel(value, customFunction, translate) {\n const { interval, boundaries } = customFunction;\n // To restrict the decimals in labels\n const intervalDecimalLength = (interval.toString().split('.')[1] || '').length;\n value = Number(value);\n // In case of 'include-lower-only'\n let lowerValue = value.toFixed(intervalDecimalLength);\n let upperValue = (value + interval).toFixed(intervalDecimalLength);\n // In case of boundary 'include-upper-only'\n if (boundaries === intervalGroupingBoundaries.includeUpperOnly) {\n lowerValue = (value - interval).toFixed(intervalDecimalLength);\n upperValue = value.toFixed(intervalDecimalLength);\n }\n return `${lowerValue} ${translate('to')} ${upperValue}`;\n}\n\nfunction GroupName({ view, column, groupHeader, dateFunction, customFunction }) {\n const [translate] = useTranslate();\n const { locale, timezone } = view.meta;\n const isRangeGrouping = customFunction?.type === customFunctions.RANGE_GROUPING;\n const isIntervalGrouping = customFunction?.type === customFunctions.INTERVAL_GROUPING;\n\n if (dateFunction) {\n return (\n <DateValueDisplay\n value={groupHeader.name}\n dateFunction={dateFunction}\n locale={locale}\n timezone={timezone}\n />\n );\n }\n\n if (isRangeGrouping) {\n /** If custom range grouping applied on number field , we need to show group name as text instead of number */\n return groupHeader.name;\n }\n\n if (isIntervalGrouping) {\n /** If custom range grouping applied on number , we need to show group name based on value and custom function details like interval and boundaries */\n return buildIntervalGroupingLabel(groupHeader.name, customFunction, translate);\n }\n\n column.setExecutionContext(null); // If null is not set then it will execute on the previous row context and facing issues when cell is edited. Based on column.editMode and current context renderer varies (it can be cellEditRenderer)\n\n const columnRendererProps = {\n ...column.getRenderingEngineProps(),\n context: {\n getValue: () => groupHeader.name,\n getExecutionContext: () => {\n return { getValue: () => groupHeader.data, name: 'groupHeader' };\n }\n }\n };\n\n return <RenderingEngine {...columnRendererProps} />;\n}\n\n// NOTE: While making any changes in GroupRenderer.jsx, also make similar changes in HierarchicalGroupRenderer.jsx file if applicable\n\nexport default function GroupHeader({ groupHeader, columns }) {\n const buttonRef = useRef();\n\n // TODO: This we are adding temporary to show freeze border until we make group header rendering change\n // when we will pick up aggregation.\n if (!groupHeader.isVisible) return null;\n\n const view = columns[0].parent;\n // If grouping by a regular column (i.e. without a dateFunction), determine props for the renderer\n const {\n columnId,\n dateFunction,\n customFunction,\n additionalFields = []\n } = getGroupFromKey(groupHeader.groupBy, view.state.groups) ?? {};\n // if state.groups is not yet prepared/updated, then getGroupFromKey will return undefined\n if (!columnId) {\n return null;\n }\n\n const column = columns.find(c => c.field.id === columnId);\n const formatter = view.getFormatterByKey('Integer');\n const { locale } = view.meta;\n const groupCountFormatted = formatter\n ? formatter(groupHeader.count, { locale })\n : groupHeader.count;\n const isAggregationApplied = columns.filter(c => !c.hidden).some(c => c.aggregated);\n\n // FIXME: Import rather than COPY, i would rather\n return (\n <StyledGroupHeader\n groupHeader={groupHeader}\n className={cx('row group-header-row sticky-group-header')}\n data-test-id='groupHeader'\n data-testid={TestIdConstants.groupHeader}\n isAggregationApplied={isAggregationApplied}\n role='row'\n onFocus={e => {\n if (buttonRef.current && !e.currentTarget.contains(e.relatedTarget)) {\n e.preventDefault();\n buttonRef.current.focus();\n }\n }}\n >\n <div className='stickyGroupHeader'>\n <BareButton\n ref={buttonRef}\n aria-label={`${\n column.field.hideGroupColumnNameLabel ? '' : groupHeader.label\n } ${groupHeader.name}, ${groupCountFormatted} items`}\n aria-expanded={!!groupHeader.isExpanded}\n style={{\n paddingRight: 'var(--group-left)'\n }}\n onClick={() => groupHeader.count > 0 && view.type.toggleGroupExpansion({ groupHeader })}\n tabIndex={-1}\n icon\n >\n {groupHeader.count > 0 &&\n (groupHeader.isExpanded ? <Icon name='caret-down' /> : <Icon name='caret-right' />)}\n <div className='group-wrapper'>\n <div className='group-label' />\n {!column.field.hideGroupColumnNameLabel && (\n <span\n className='group-header-groupby'\n data-test-id={groupHeader.groupBy}\n data-testid={`${TestIdConstants.groupHeaderGroupBy}-${groupHeader.groupBy}`}\n >\n {groupHeader.label}:\n </span>\n )}\n <div className='group-label' />\n <span\n className='group-context-count'\n style={{ display: 'inline-flex' }}\n data-test-id='groupHeader'\n data-testid={TestIdConstants.groupHeaderCount}\n >\n <GroupName\n view={view}\n column={column}\n groupHeader={groupHeader}\n dateFunction={dateFunction}\n customFunction={customFunction}\n />\n {/* adding whitespace pre to preserve the space at the begining of count text */}\n <span className='group-count'>{` (${groupCountFormatted})`}</span>\n </span>\n {!!(groupHeader.additionalFieldsData?.length && additionalFields.length) && (\n <>\n <Text aria-hidden variant='secondary' as={GroupAdditionalInfoSeparator}>\n •\n </Text>\n <StyledMetaList\n wrapItems={false}\n items={[\n ...groupHeader.additionalFieldsData.map(additionalFieldsData => (\n <GroupAdditionalInfo\n additionalFieldData={additionalFieldsData}\n additionalField={additionalFields.find(\n additionalField => additionalField.id === additionalFieldsData.id\n )}\n columns={columns}\n groupHeader={groupHeader}\n />\n ))\n ]}\n />\n </>\n )}\n </div>\n </BareButton>\n </div>\n <div className='group-header-aggregation-row'>\n {columns.map(c => {\n const cxt = {\n getValue: () =>\n groupHeader?.aggregation?.[c.field.name]?.[c.aggregationType?.toLowerCase()]\n };\n return (\n <AggregatorCell\n key={c.field.id}\n column={c}\n context={cxt}\n className={cx('cell', {\n 'cell-fixed': column.frozen\n })}\n />\n );\n })}\n </div>\n </StyledGroupHeader>\n );\n}\n\nGroupHeader.propTypes = {\n columns: PropTypes.arrayOf(PropTypes.any).isRequired,\n groupHeader: PropTypes.objectOf(PropTypes.any).isRequired\n};\n"]}
|
|
@@ -57,7 +57,7 @@ export default function GroupingMenu({ column, finishPopOver }) {
|
|
|
57
57
|
applyGrouping([...groups, newGroup]);
|
|
58
58
|
finishPopOver();
|
|
59
59
|
};
|
|
60
|
-
return (_jsxs(StyledGroupingMenu, { children: [_jsx(Select, { label: 'Date function', labelHidden: true, "data-test-id": 'GroupingDateFuncSelector', value: selectedDateFunction || 'NONE', onChange: e => setSelectedDateFunction(e.target.value), children: allOptions.map(o => (_jsx(Option, { value: o.key, children: o.label }, o.key))) }), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: finishPopOver, children: translate('Cancel') }), _jsx(Button, { variant: 'primary', onClick: onSubmit, children: translate('Submit') })] })] }));
|
|
60
|
+
return (_jsxs(StyledGroupingMenu, { children: [_jsx(Select, { label: 'Date function', labelHidden: true, "data-test-id": 'GroupingDateFuncSelector', value: selectedDateFunction || 'NONE', onChange: e => setSelectedDateFunction(e.target.value), children: allOptions.map(o => (_jsx(Option, { value: o.key, children: translate(o.label) }, o.key))) }), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: finishPopOver, children: translate('Cancel') }), _jsx(Button, { variant: 'primary', onClick: onSubmit, children: translate('Submit') })] })] }));
|
|
61
61
|
}
|
|
62
62
|
GroupingMenu.propTypes = {
|
|
63
63
|
column: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMenu.js","sourceRoot":"","sources":["../../../../Core/Components/Grouping/GroupingMenu.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE/E,OAAO,YAAY,MAAM,0BAA0B,CAAC;AAEpD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;CAKjC,CAAC;AAEF,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;aAC1B,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO;;;;eAI1C,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;oBACxC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE;;;CAG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C,MAAM,IAAC,OAAO,EAAE,aAAa,YAAG,SAAS,CAAC,QAAQ,CAAC,GAAU,EAC9D,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,QAAQ,YACxC,SAAS,CAAC,QAAQ,CAAC,GACb,IACI,IACI,CACtB,CAAC;AACJ,CAAC;AAED,YAAY,CAAC,SAAS,GAAG;IACvB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;IACpD,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;CACzC,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport { useMemo, useState } from 'react';\nimport styled from 'styled-components';\n\nimport { Button, Flex, Option, Select } from '@pega/cosmos-react-core';\nimport { dateFunctionLabels, FieldType } from 'pega-repeating-structures-core';\n\nimport useTranslate from '../../Hooks/useTranslate';\n\nconst StyledFooter = styled.footer`\n margin-top: 0.625rem;\n display: flex;\n justify-content: space-between;\n align-items: baseline;\n`;\n\nconst StyledGroupingMenu = styled(Flex)`\n z-index: ${props => props.theme.base['z-index'].popover};\n max-height: 35.156rem;\n padding: 0.625rem;\n overflow: auto;\n max-width: ${props => props.theme.base['content-width'].lg};\n min-width: calc(${props => props.theme.base['content-width'].lg} * 0.3125);\n display: flex;\n flex-direction: column;\n`;\nexport default function GroupingMenu({ column, finishPopOver }) {\n const [translate] = useTranslate();\n const [selectedDateFunction, setSelectedDateFunction] = useState(undefined);\n const view = column.parent;\n const {\n meta: { dateFunctions },\n state: { groups = [] },\n type: { applyGrouping }\n } = view;\n\n const fieldType = column.field.type;\n const allOptions = useMemo(() => {\n // If date functions are disabled or not applicable to the current field type\n if (!dateFunctions || ![FieldType.DATE, FieldType.DATE_TIME].includes(fieldType)) {\n return [];\n }\n\n return [\n // Date functions applicable for the given field type\n ...dateFunctions[fieldType === FieldType.DATE ? 'DATE_ONLY' : 'DATE_TIME'].map(f => ({\n key: f,\n dateFunction: f,\n label: translate(dateFunctionLabels[f])\n })),\n\n // Option for grouping directly by the field values\n // The key 'NONE' is needed to work with the Select component\n { key: 'NONE', dateFunction: undefined, label: 'Default' }\n ];\n }, [dateFunctions, fieldType, translate]);\n\n if (allOptions.length === 0) {\n return null;\n }\n\n const onSubmit = () => {\n const newGroup = {\n columnId: column.field.id,\n dateFunction: selectedDateFunction,\n level: groups.length,\n order: 'asc'\n };\n applyGrouping([...groups, newGroup]);\n finishPopOver();\n };\n\n return (\n <StyledGroupingMenu>\n <Select\n label='Date function'\n labelHidden\n data-test-id='GroupingDateFuncSelector'\n value={selectedDateFunction || 'NONE'} // Can't set up `undefined` as value\n onChange={e => setSelectedDateFunction(e.target.value)}\n >\n {allOptions.map(o => (\n <Option key={o.key} value={o.key}>\n {translate(o.label)}\n </Option>\n ))}\n </Select>\n <StyledFooter>\n <Button onClick={finishPopOver}>{translate('Cancel')}</Button>\n <Button variant='primary' onClick={onSubmit}>\n {translate('Submit')}\n </Button>\n </StyledFooter>\n </StyledGroupingMenu>\n );\n}\n\nGroupingMenu.propTypes = {\n column: PropTypes.objectOf(PropTypes.any).isRequired,\n finishPopOver: PropTypes.func.isRequired\n};\n"]}
|
|
@@ -44,7 +44,7 @@ const DateFunctionSelector = props => {
|
|
|
44
44
|
// If we instead appended `group.dateFunction` to `available`, the order or options will change on further selections.
|
|
45
45
|
const { available } = groupingOptions.dateFuncs[group.columnId];
|
|
46
46
|
const optionsToUse = allOptions.filter(o => available.includes(o.dateFunction) || o.dateFunction === group.dateFunction);
|
|
47
|
-
return (_jsx(StyledDateFuncWrapper, { children: _jsx(Select, { label: 'Date function', labelHidden: true, "data-testid": 'GroupingDateFuncSelector', value: group.dateFunction || 'NONE', onChange: e => onChange(e.target.value === 'NONE' ? undefined : e.target.value), children: optionsToUse.map(o => (_jsx(Option, { value: o.key, children: o.label }, o.key))) }) }));
|
|
47
|
+
return (_jsx(StyledDateFuncWrapper, { children: _jsx(Select, { label: 'Date function', labelHidden: true, "data-testid": 'GroupingDateFuncSelector', value: group.dateFunction || 'NONE', onChange: e => onChange(e.target.value === 'NONE' ? undefined : e.target.value), children: optionsToUse.map(o => (_jsx(Option, { value: o.key, children: translate(o.label) }, o.key))) }) }));
|
|
48
48
|
};
|
|
49
49
|
DateFunctionSelector.propTypes = {
|
|
50
50
|
group: PropTypes.objectOf(PropTypes.any).isRequired,
|