@pega/lists-react 8.8.0 → 9.0.0-build.10.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/A11y/RepeatingStructureA11y.d.ts +10 -5
- package/lib/Core/Components/A11y/RepeatingStructureA11y.d.ts.map +1 -1
- package/lib/Core/Components/A11y/RepeatingStructureA11y.js +27 -2
- package/lib/Core/Components/A11y/RepeatingStructureA11y.js.map +1 -1
- 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/ContextMenu/QuickFilter.js +6 -6
- package/lib/Core/Components/ContextMenu/QuickFilter.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.js +3 -2
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.js +3 -2
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/index.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/index.js +7 -6
- package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/index.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowActionMenu.d.ts +2 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowActionMenu.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowActionMenu.js +9 -21
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowActionMenu.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowDragDropHandle.d.ts +2 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowDragDropHandle.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowDragDropHandle.js +4 -3
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowDragDropHandle.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowError.d.ts +2 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowError.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowError.js +4 -3
- package/lib/Core/Components/DefaultComponents/CellRenderers/RowError.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/EmptyContainer.d.ts +3 -1
- package/lib/Core/Components/DefaultComponents/EmptyContainer.d.ts.map +1 -1
- package/lib/Core/Components/DefaultComponents/EmptyContainer.js +2 -4
- package/lib/Core/Components/DefaultComponents/EmptyContainer.js.map +1 -1
- package/lib/Core/Components/DefaultComponents/index.d.ts +3 -1
- package/lib/Core/Components/DefaultComponents/index.d.ts.map +1 -1
- package/lib/Core/Components/Filters/CommonFilter.d.ts.map +1 -1
- package/lib/Core/Components/Filters/CommonFilter.js +2 -2
- package/lib/Core/Components/Filters/CommonFilter.js.map +1 -1
- package/lib/Core/Components/Filters/FilterType.js +5 -5
- package/lib/Core/Components/Filters/FilterType.js.map +1 -1
- package/lib/Core/Components/Filters/SelectFilter.d.ts.map +1 -1
- package/lib/Core/Components/Filters/SelectFilter.js +2 -2
- package/lib/Core/Components/Filters/SelectFilter.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 +120 -5
- package/lib/Core/Components/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js +3 -3
- package/lib/Core/Components/Grouping/GroupingMenu.js.map +1 -1
- package/lib/Core/Components/HeaderCell.d.ts.map +1 -1
- package/lib/Core/Components/HeaderCell.js +5 -2
- package/lib/Core/Components/HeaderCell.js.map +1 -1
- package/lib/Core/Components/HeaderMenu/actions.d.ts.map +1 -1
- package/lib/Core/Components/HeaderMenu/actions.js +4 -3
- package/lib/Core/Components/HeaderMenu/actions.js.map +1 -1
- package/lib/Core/Components/HeaderMenu/index.d.ts.map +1 -1
- package/lib/Core/Components/HeaderMenu/index.js +2 -2
- package/lib/Core/Components/HeaderMenu/index.js.map +1 -1
- package/lib/Core/Components/RenderingEngine/RenderCell.d.ts +1 -1
- package/lib/Core/Components/RenderingEngine/RenderCell.d.ts.map +1 -1
- package/lib/Core/Components/RenderingEngine/RenderCell.js +4 -1
- package/lib/Core/Components/RenderingEngine/RenderCell.js.map +1 -1
- package/lib/Core/Components/Toolbar/AdvanceToolbar.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/AdvanceToolbar.js +4 -17
- package/lib/Core/Components/Toolbar/AdvanceToolbar.js.map +1 -1
- package/lib/Core/Components/Toolbar/AnnounceRowsCount.d.ts +1 -1
- package/lib/Core/Components/Toolbar/AnnounceRowsCount.js +1 -1
- package/lib/Core/Components/Toolbar/AnnounceRowsCount.js.map +1 -1
- package/lib/Core/Components/Toolbar/ColumnSelector.d.ts +20 -9
- package/lib/Core/Components/Toolbar/ColumnSelector.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/ColumnSelector.js +89 -65
- package/lib/Core/Components/Toolbar/ColumnSelector.js.map +1 -1
- package/lib/Core/Components/Toolbar/SimpleToolbar.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/SimpleToolbar.js +4 -2
- package/lib/Core/Components/Toolbar/SimpleToolbar.js.map +1 -1
- package/lib/Core/Components/Toolbar/Timeline/TimelineToolbar.d.ts +2 -3
- package/lib/Core/Components/Toolbar/Timeline/TimelineToolbar.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/Timeline/TimelineToolbar.js +92 -44
- package/lib/Core/Components/Toolbar/Timeline/TimelineToolbar.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js +3 -3
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.d.ts +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js +3 -2
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/utils.d.ts +2 -2
- package/lib/Core/Components/Toolbar/hooks/useGroup/utils.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/utils.js +3 -2
- package/lib/Core/Components/Toolbar/hooks/useGroup/utils.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useMore.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useMore.js +2 -2
- package/lib/Core/Components/Toolbar/hooks/useMore.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSearch.js +4 -4
- package/lib/Core/Components/Toolbar/hooks/useSearch.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/Toolbar/hooks/useWrapAction.d.ts +6 -0
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.d.ts.map +1 -0
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.js +17 -0
- package/lib/Core/Components/Toolbar/hooks/useWrapAction.js.map +1 -0
- package/lib/Core/Components/Toolbar/utils/utils.d.ts +1 -1
- package/lib/Core/Components/Toolbar/utils/utils.d.ts.map +1 -1
- package/lib/Core/Components/Toolbar/utils/utils.js +2 -1
- package/lib/Core/Components/Toolbar/utils/utils.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 +251 -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 +214 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js.map +1 -0
- package/lib/Core/Components/Virtualise/VirtualizeInfinite.js +8 -5
- package/lib/Core/Components/Virtualise/VirtualizeInfinite.js.map +1 -1
- package/lib/Core/Components/Virtualise/index.js +9 -16
- package/lib/Core/Components/Virtualise/index.js.map +1 -1
- 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/a11y/useAnnounce.d.ts +19 -0
- package/lib/Core/Hooks/a11y/useAnnounce.d.ts.map +1 -0
- package/lib/Core/Hooks/a11y/useAnnounce.js +49 -0
- package/lib/Core/Hooks/a11y/useAnnounce.js.map +1 -0
- 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/Hooks/useRepeat.d.ts.map +1 -1
- package/lib/Core/Hooks/useRepeat.js +7 -0
- package/lib/Core/Hooks/useRepeat.js.map +1 -1
- package/lib/Core/Localization/defaultTranslations.d.ts +7 -49
- package/lib/Core/Localization/defaultTranslations.d.ts.map +1 -1
- package/lib/Core/Localization/defaultTranslations.js +8 -50
- package/lib/Core/Localization/defaultTranslations.js.map +1 -1
- package/lib/Core/Test/JUnitMocks.d.ts +6 -617
- package/lib/Core/Test/JUnitMocks.d.ts.map +1 -1
- package/lib/Core/Test/JUnitMocks.js +5 -4
- package/lib/Core/Test/JUnitMocks.js.map +1 -1
- package/lib/Core/Utils/index.d.ts +11 -0
- package/lib/Core/Utils/index.d.ts.map +1 -1
- package/lib/Core/Utils/index.js +20 -8
- package/lib/Core/Utils/index.js.map +1 -1
- package/lib/Core/Views/Gallery/StyledGalleryContainer.d.ts.map +1 -1
- package/lib/Core/Views/Gallery/StyledGalleryContainer.js +1 -0
- package/lib/Core/Views/Gallery/StyledGalleryContainer.js.map +1 -1
- package/lib/Core/Views/Gallery/index.d.ts.map +1 -1
- package/lib/Core/Views/Gallery/index.js +7 -4
- package/lib/Core/Views/Gallery/index.js.map +1 -1
- package/lib/Core/Views/Map/index.d.ts.map +1 -1
- package/lib/Core/Views/Map/index.js +9 -3
- package/lib/Core/Views/Map/index.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 +7 -11
- 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 +27 -4
- 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/lib/Core/Views/Timeline/Timeline.d.ts +5 -0
- package/lib/Core/Views/Timeline/Timeline.d.ts.map +1 -0
- package/lib/Core/Views/Timeline/Timeline.js +28 -0
- package/lib/Core/Views/Timeline/Timeline.js.map +1 -0
- package/lib/Core/Views/Timeline/Timeline.styles.d.ts +24 -0
- package/lib/Core/Views/Timeline/Timeline.styles.d.ts.map +1 -0
- package/lib/Core/Views/Timeline/Timeline.styles.js +182 -0
- package/lib/Core/Views/Timeline/Timeline.styles.js.map +1 -0
- package/lib/Core/Views/Timeline/Timeline.types.d.ts +50 -0
- package/lib/Core/Views/Timeline/Timeline.types.d.ts.map +1 -0
- package/lib/Core/Views/Timeline/Timeline.types.js +2 -0
- package/lib/Core/Views/Timeline/Timeline.types.js.map +1 -0
- package/lib/Core/Views/Timeline/TimelineItem.d.ts +12 -0
- package/lib/Core/Views/Timeline/TimelineItem.d.ts.map +1 -0
- package/lib/Core/Views/Timeline/TimelineItem.js +43 -0
- package/lib/Core/Views/Timeline/TimelineItem.js.map +1 -0
- package/lib/Core/Views/Timeline/__tests__/Timeline.mocks.d.ts +4 -0
- package/lib/Core/Views/Timeline/__tests__/Timeline.mocks.d.ts.map +1 -0
- package/lib/Core/Views/Timeline/__tests__/Timeline.mocks.js +141 -0
- package/lib/Core/Views/Timeline/__tests__/Timeline.mocks.js.map +1 -0
- package/lib/Core/Views/Timeline/index.d.ts.map +1 -1
- package/lib/Core/Views/Timeline/index.js +12 -6
- package/lib/Core/Views/Timeline/index.js.map +1 -1
- package/lib/Core/Views/Timeline/utility.d.ts +1 -1
- package/lib/Core/Views/Timeline/utility.d.ts.map +1 -1
- package/lib/Core/Views/Timeline/utility.js.map +1 -1
- package/lib/Core/Views/Timeline/utils.d.ts +12 -0
- package/lib/Core/Views/Timeline/utils.d.ts.map +1 -0
- package/lib/Core/Views/Timeline/utils.js +66 -0
- package/lib/Core/Views/Timeline/utils.js.map +1 -0
- package/package.json +7 -8
- package/lib/Core/Components/EmptyContainer.d.ts +0 -5
- package/lib/Core/Components/EmptyContainer.d.ts.map +0 -1
- package/lib/Core/Components/EmptyContainer.js +0 -12
- package/lib/Core/Components/EmptyContainer.js.map +0 -1
- package/lib/Core/Hooks/useSelect.d.ts +0 -9
- package/lib/Core/Hooks/useSelect.d.ts.map +0 -1
- package/lib/Core/Hooks/useSelect.js +0 -24
- package/lib/Core/Hooks/useSelect.js.map +0 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Provides accessibility features for repeating structures, including focus boundary handling
|
|
3
|
+
* and announcing changes in the view's state for accessibility purposes.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} props.a11yRef - A reference object containing accessibility-related handlers.
|
|
6
|
+
* @param {Object} props.view - The view object containing the current state of the repeating structure.
|
|
7
|
+
*
|
|
8
|
+
* @returns {JSX.Element} The rendered structure with accessibility features.
|
|
9
|
+
*/
|
|
10
|
+
declare function RepeatingStructureA11y({ children, a11yRef, view }: Object): JSX.Element;
|
|
6
11
|
declare namespace RepeatingStructureA11y {
|
|
7
12
|
namespace propTypes {
|
|
8
13
|
let children: PropTypes.Requireable<object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeatingStructureA11y.d.ts","sourceRoot":"","sources":["../../../../Core/Components/A11y/RepeatingStructureA11y.jsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RepeatingStructureA11y.d.ts","sourceRoot":"","sources":["../../../../Core/Components/A11y/RepeatingStructureA11y.jsx"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,qEALW,MAAM,GAGJ,GAAG,CAAC,OAAO,CAgDvB;;;;;;;;;;;;;;;;;sBAtEqB,YAAY"}
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
-
import
|
|
5
|
+
import useAnnounce from '../../Hooks/a11y/useAnnounce';
|
|
6
|
+
import useTranslate from '../../Hooks/useTranslate';
|
|
6
7
|
const StyledInput = styled.input `
|
|
7
8
|
width: 0;
|
|
8
9
|
height: 0;
|
|
@@ -11,12 +12,36 @@ const StyledInput = styled.input `
|
|
|
11
12
|
outline: none;
|
|
12
13
|
opacity: 0;
|
|
13
14
|
`;
|
|
15
|
+
/**
|
|
16
|
+
* Provides accessibility features for repeating structures, including focus boundary handling
|
|
17
|
+
* and announcing changes in the view's state for accessibility purposes.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} props.a11yRef - A reference object containing accessibility-related handlers.
|
|
20
|
+
* @param {Object} props.view - The view object containing the current state of the repeating structure.
|
|
21
|
+
*
|
|
22
|
+
* @returns {JSX.Element} The rendered structure with accessibility features.
|
|
23
|
+
*/
|
|
14
24
|
export default function RepeatingStructureA11y({ children, a11yRef, view }) {
|
|
25
|
+
const [translate] = useTranslate();
|
|
15
26
|
const onFocusHandler = useCallback(e => {
|
|
16
27
|
a11yRef.current.boundaryElementsFocusHandler(e);
|
|
17
28
|
}, [a11yRef]);
|
|
18
29
|
const { state } = view;
|
|
19
|
-
|
|
30
|
+
// For show/hide columns, we only use the 'modified' message because there is always at least one column present.
|
|
31
|
+
// Any change—whether adding or removing a column is considered a modification for accessibility announcement.
|
|
32
|
+
useAnnounce(state.hiddenColumns, {
|
|
33
|
+
modified: translate('Show/Hide modified')
|
|
34
|
+
}, state.personalization?.active);
|
|
35
|
+
useAnnounce(state.freezeColumns, {
|
|
36
|
+
added: translate('Freeze applied'),
|
|
37
|
+
modified: translate('Freeze modified'),
|
|
38
|
+
removed: translate('Freeze removed')
|
|
39
|
+
}, state.personalization?.active);
|
|
40
|
+
useAnnounce(state.groups, {
|
|
41
|
+
added: translate('Group applied'),
|
|
42
|
+
modified: translate('Group modified'),
|
|
43
|
+
removed: translate('Group removed')
|
|
44
|
+
}, state.personalization?.active);
|
|
20
45
|
return (_jsxs(_Fragment, { children: [_jsx(StyledInput, { className: 'top', type: 'text', "aria-hidden": true, onFocus: onFocusHandler }), children, _jsx(StyledInput, { className: 'bottom', type: 'text', "aria-hidden": true, onFocus: onFocusHandler })] }));
|
|
21
46
|
}
|
|
22
47
|
RepeatingStructureA11y.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeatingStructureA11y.js","sourceRoot":"","sources":["../../../../Core/Components/A11y/RepeatingStructureA11y.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,
|
|
1
|
+
{"version":3,"file":"RepeatingStructureA11y.js","sourceRoot":"","sources":["../../../../Core/Components/A11y/RepeatingStructureA11y.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,WAAW,MAAM,8BAA8B,CAAC;AACvD,OAAO,YAAY,MAAM,0BAA0B,CAAC;AAEpD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;CAO/B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE;IACxE,MAAM,CAAC,SAAS,CAAC,GAAG,YAAY,EAAE,CAAC;IACnC,MAAM,cAAc,GAAG,WAAW,CACh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SAAS,CAAC,QAAQ,CAAC,CAAC,UAAU;IAC1D,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,UAAU;CACnD,CAAC;AAEF,sBAAsB,CAAC,YAAY,GAAG;IACpC,QAAQ,EAAE,EAAE;CACb,CAAC","sourcesContent":["import { useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from 'styled-components';\n\nimport useAnnounce from '../../Hooks/a11y/useAnnounce';\nimport useTranslate from '../../Hooks/useTranslate';\n\nconst StyledInput = styled.input`\n width: 0;\n height: 0;\n border-width: 0;\n position: absolute;\n outline: none;\n opacity: 0;\n`;\n\n/**\n * Provides accessibility features for repeating structures, including focus boundary handling\n * and announcing changes in the view's state for accessibility purposes.\n *\n * @param {Object} props.a11yRef - A reference object containing accessibility-related handlers.\n * @param {Object} props.view - The view object containing the current state of the repeating structure.\n *\n * @returns {JSX.Element} The rendered structure with accessibility features.\n */\nexport default function RepeatingStructureA11y({ children, a11yRef, view }) {\n const [translate] = useTranslate();\n const onFocusHandler = useCallback(\n e => {\n a11yRef.current.boundaryElementsFocusHandler(e);\n },\n [a11yRef]\n );\n const { state } = view;\n // For show/hide columns, we only use the 'modified' message because there is always at least one column present.\n // Any change—whether adding or removing a column is considered a modification for accessibility announcement.\n useAnnounce(\n state.hiddenColumns,\n {\n modified: translate('Show/Hide modified')\n },\n state.personalization?.active\n );\n\n useAnnounce(\n state.freezeColumns,\n {\n added: translate('Freeze applied'),\n modified: translate('Freeze modified'),\n removed: translate('Freeze removed')\n },\n state.personalization?.active\n );\n\n useAnnounce(\n state.groups,\n {\n added: translate('Group applied'),\n modified: translate('Group modified'),\n removed: translate('Group removed')\n },\n state.personalization?.active\n );\n\n return (\n <>\n <StyledInput className='top' type='text' aria-hidden onFocus={onFocusHandler} />\n {children}\n <StyledInput className='bottom' type='text' aria-hidden onFocus={onFocusHandler} />\n </>\n );\n}\n\nRepeatingStructureA11y.propTypes = {\n children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\n a11yRef: PropTypes.objectOf(PropTypes.objectOf).isRequired,\n view: PropTypes.objectOf(PropTypes.any).isRequired\n};\n\nRepeatingStructureA11y.defaultProps = {\n children: []\n};\n"]}
|
|
@@ -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,eA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AAE,EAAE,sBAAsB,EAC1B,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,iBACN,eAAe,CAAC,qBAAqB,YAEjD,gBAAgB,GACZ,EACP,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,GAAG,QAAQ,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":["../../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port 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,M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,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';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import get from 'lodash.get';
|
|
2
|
-
import { addFilter, getFilters, comparatorMap } from 'pega-repeating-structures-core';
|
|
2
|
+
import { addFilter, getFilters, comparatorMap, FieldType } from 'pega-repeating-structures-core';
|
|
3
3
|
import { TOOLBAR_FEATURES } from '../../constants';
|
|
4
4
|
const getBooleanComparator = inputValue => {
|
|
5
5
|
let comparator;
|
|
@@ -21,21 +21,21 @@ export const quickFilterEnabled = (columns, colId) => {
|
|
|
21
21
|
const column = columns.find(col => col.field.id.toString() === colId.toString());
|
|
22
22
|
return (column &&
|
|
23
23
|
column.parent.shouldDisplayFeature(TOOLBAR_FEATURES.FILTER, column) &&
|
|
24
|
-
!(column.field.type ===
|
|
24
|
+
!(column.field.type === FieldType.DATE || column.field.type === FieldType.DATE_TIME));
|
|
25
25
|
};
|
|
26
26
|
export const applyFilter = (columns, targetCell, rowContextData, filterExpression, actionColumnFiltering) => {
|
|
27
27
|
// preparing filter object to apply equals filter
|
|
28
28
|
const { colId } = targetCell.dataset;
|
|
29
29
|
const column = columns.find(col => col.field.id.toString() === colId.toString());
|
|
30
30
|
const inputValue = get(rowContextData, column.field.name);
|
|
31
|
-
const isPickList = column.field.type ===
|
|
31
|
+
const isPickList = column.field.type === FieldType.TEXT && column.field.filterPickList;
|
|
32
32
|
let comparator;
|
|
33
33
|
let input;
|
|
34
34
|
// decide the comparator based on filtered value or column type
|
|
35
35
|
if (inputValue === null || inputValue === undefined) {
|
|
36
36
|
comparator = comparatorMap.isNull;
|
|
37
37
|
}
|
|
38
|
-
else if (column.field.type ===
|
|
38
|
+
else if (column.field.type === FieldType.BOOLEAN) {
|
|
39
39
|
comparator = getBooleanComparator(inputValue);
|
|
40
40
|
}
|
|
41
41
|
else if (isPickList) {
|
|
@@ -45,10 +45,10 @@ export const applyFilter = (columns, targetCell, rowContextData, filterExpressio
|
|
|
45
45
|
comparator = comparatorMap.equals;
|
|
46
46
|
}
|
|
47
47
|
// decide input value for expression rhs
|
|
48
|
-
if (column.field.type ===
|
|
48
|
+
if (column.field.type === FieldType.NUMBER) {
|
|
49
49
|
input = inputValue && parseFloat(inputValue);
|
|
50
50
|
}
|
|
51
|
-
else if (column.field.type ===
|
|
51
|
+
else if (column.field.type === FieldType.BOOLEAN) {
|
|
52
52
|
input = null;
|
|
53
53
|
}
|
|
54
54
|
else if (isPickList) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickFilter.js","sourceRoot":"","sources":["../../../../Core/Components/ContextMenu/QuickFilter.js"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"QuickFilter.js","sourceRoot":"","sources":["../../../../Core/Components/ContextMenu/QuickFilter.js"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,oBAAoB,GAAG,UAAU,CAAC,EAAE;IACxC,IAAI,UAAU,CAAC;IACf,IAAI,UAAU,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QACpD,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;IACpC,CAAC;SAAM,IAAI,UAAU,EAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;QAC5D,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;IACnD,IA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AM,CAAC;QACN,qBAAqB,CAAC;YACpB,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import get from 'lodash.get';\n\nimport { addFilter, getFilters, comparatorMap, FieldType } from 'pega-repeating-structures-core';\n\nimport { TOOLBAR_FEATURES } from '../../constants';\n\nconst getBooleanComparator = inputValue => {\n let comparator;\n if (inputValue?.toString().toLowerCase() === 'true') {\n comparator = comparatorMap.isTrue;\n } else if (inputValue?.toString().toLowerCase() === 'false') {\n comparator = comparatorMap.isFalse;\n } else {\n comparator = comparatorMap.isNull;\n }\n return comparator;\n};\n\nexport const quickFilterEnabled = (columns, colId) => {\n if (!colId) {\n return false;\n }\n const column = columns.find(col => col.field.id.toString() === colId.toString());\n return (\n column &&\n column.parent.shouldDisplayFeature(TOOLBAR_FEATURES.FILTER, column) &&\n !(column.field.type === FieldType.DATE || column.field.type === FieldType.DATE_TIME)\n );\n};\n\nexport const applyFilter = (\n columns,\n targetCell,\n rowContextData,\n filterExpression,\n actionColumnFiltering\n) => {\n // preparing filter object to apply equals filter\n const { colId } = targetCell.dataset;\n const column = columns.find(col => col.field.id.toString() === colId.toString());\n const inputValue = get(rowContextData, column.field.name);\n const isPickList = column.field.type === FieldType.TEXT && column.field.filterPickList;\n let comparator;\n let input;\n\n // decide the comparator based on filtered value or column type\n if (inputValue === null || inputValue === undefined) {\n comparator = comparatorMap.isNull;\n } else if (column.field.type === FieldType.BOOLEAN) {\n comparator = getBooleanComparator(inputValue);\n } else if (isPickList) {\n comparator = comparatorMap.in;\n } else {\n comparator = comparatorMap.equals;\n }\n\n // decide input value for expression rhs\n if (column.field.type === FieldType.NUMBER) {\n input = inputValue && parseFloat(inputValue);\n } else if (column.field.type === FieldType.BOOLEAN) {\n input = null;\n } else if (isPickList) {\n input = inputValue && [inputValue];\n } else {\n input = inputValue;\n }\n\n const localFilterExpression = addFilter({\n comparator,\n input,\n filterExpression,\n column\n });\n actionColumnFiltering({\n filterExp: localFilterExpression\n });\n};\n\nexport const removeFilter = (\n filterExpression,\n targetCell,\n actionColumnFiltering,\n actionClearFiltering\n) => {\n const filters = getFilters({ filterExpression });\n if (filters.length > 1) {\n // removing equals filter applied on current column\n actionClearFiltering(targetCell.dataset.colId);\n } else {\n actionColumnFiltering({\n filterExp: null\n });\n }\n};\n"]}
|
package/lib/Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.jsx"],"names":[],"mappings":";AAUA,+EAoCC;;;;;;;;;sBA7CqB,YAAY"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { Input } from '@pega/cosmos-react-core';
|
|
5
|
+
import { FieldType } from 'pega-repeating-structures-core';
|
|
5
6
|
const styles = {
|
|
6
7
|
input: { width: '100%' }
|
|
7
8
|
};
|
|
@@ -9,7 +10,7 @@ function DateTime(props) {
|
|
|
9
10
|
const { getField, getValue } = props;
|
|
10
11
|
const { type } = getField();
|
|
11
12
|
const oldValue = getValue();
|
|
12
|
-
const [value, setValue] = useState(type ===
|
|
13
|
+
const [value, setValue] = useState(type === FieldType.DATE_TIME ? oldValue?.slice(0, -1) : oldValue);
|
|
13
14
|
const inputRef = useRef(null);
|
|
14
15
|
const onChange = event => setValue(event.target.value);
|
|
15
16
|
const onEscape = event => {
|
|
@@ -21,7 +22,7 @@ function DateTime(props) {
|
|
|
21
22
|
useEffect(() => {
|
|
22
23
|
inputRef.current?.focus();
|
|
23
24
|
}, [inputRef]);
|
|
24
|
-
return (_jsx(Input, { ...props, type: type ===
|
|
25
|
+
return (_jsx(Input, { ...props, type: type === FieldType.DATE_TIME ? 'datetime-local' : type, value: value, style: styles.input, ref: ref => {
|
|
25
26
|
inputRef.current = ref;
|
|
26
27
|
}, onChange: onChange, onBlur: onBlur, onKeyDown: onEscape }));
|
|
27
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/DateTime.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;CACzB,CAAC;AAEF,SAAS,QAAQ,CAAC,KAAK;IACrB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAChC,IAAI,KAAK,SAAS,CAAC,SAAS,CAAC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AAC,IAAI,CAAC,UAAU;IACnC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;CACpC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { useState, useRef, useEffect } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { Input } from '@pega/cosmos-react-core';\nimport { FieldType } from 'pega-repeating-structures-core';\n\nconst styles = {\n input: { width: '100%' }\n};\n\nfunction DateTime(props) {\n const { getField, getValue } = props;\n const { type } = getField();\n const oldValue = getValue();\n const [value, setValue] = useState(\n type === FieldType.DATE_TIME ? oldValue?.slice(0, -1) : oldValue\n );\n const inputRef = useRef(null);\n\n const onChange = event => setValue(event.target.value);\n\n const onEscape = event => {\n if (event.key === 'Escape') {\n props.onCancel();\n }\n };\n\n const onBlur = () => props.onSubmit({ oldValue, newValue: value });\n useEffect(() => {\n inputRef.current?.focus();\n }, [inputRef]);\n\n return (\n <Input\n {...props}\n type={type === FieldType.DATE_TIME ? 'datetime-local' : type}\n value={value}\n style={styles.input}\n ref={ref => {\n inputRef.current = ref;\n }}\n onChange={onChange}\n onBlur={onBlur}\n onKeyDown={onEscape}\n />\n );\n}\n\nDateTime.propTypes = {\n onCancel: PropTypes.func.isRequired,\n onSubmit: PropTypes.func.isRequired,\n getField: PropTypes.func.isRequired,\n getValue: PropTypes.func.isRequired\n};\n\nexport default DateTime;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.jsx"],"names":[],"mappings":";AASA,iFA+CC;;;;;;;;;;;;sBAvDqB,YAAY"}
|
|
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { RadioButton, RadioCheckGroup } from '@pega/cosmos-react-core';
|
|
6
|
+
import { FieldType } from 'pega-repeating-structures-core';
|
|
6
7
|
const StyledRadioGroup = styled.div ``;
|
|
7
8
|
function RadioGroup(props) {
|
|
8
9
|
const { getField, getValue, getFormatter, renderFactory, resolveCellComponent } = props;
|
|
@@ -13,11 +14,11 @@ function RadioGroup(props) {
|
|
|
13
14
|
? 'Empty'
|
|
14
15
|
: oldValue;
|
|
15
16
|
const [value, setValue] = useState(translatedValue);
|
|
16
|
-
const radioOptions = field.type ===
|
|
17
|
+
const radioOptions = field.type === FieldType.BOOLEAN ? [true, false, 'Empty'] : field.filterPickListOptions;
|
|
17
18
|
const onChange = event => {
|
|
18
19
|
setValue(event.target.id);
|
|
19
20
|
let newValue = event.target.id;
|
|
20
|
-
if (field.type ===
|
|
21
|
+
if (field.type === FieldType.BOOLEAN) {
|
|
21
22
|
if (event.target.id === 'Empty')
|
|
22
23
|
newValue = null;
|
|
23
24
|
else
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/Radio.jsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,M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AAC","sourcesContent":["import { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport styled from 'styled-components';\n\nimport { RadioButton, RadioCheckGroup } from '@pega/cosmos-react-core';\nimport { FieldType } from 'pega-repeating-structures-core';\n\nconst StyledRadioGroup = styled.div``;\n\nfunction RadioGroup(props) {\n const { getField, getValue, getFormatter, renderFactory, resolveCellComponent } = props;\n const field = getField();\n const { id } = field;\n const oldValue = getValue();\n const translatedValue =\n oldValue === 'null' || oldValue === '' || oldValue === null || typeof oldValue === 'undefined'\n ? 'Empty'\n : oldValue;\n const [value, setValue] = useState(translatedValue);\n const radioOptions =\n field.type === FieldType.BOOLEAN ? [true, false, 'Empty'] : field.filterPickListOptions;\n const onChange = event => {\n setValue(event.target.id);\n let newValue = event.target.id;\n if (field.type === FieldType.BOOLEAN) {\n if (event.target.id === 'Empty') newValue = null;\n else newValue = event.target.id === 'true';\n }\n props.onSubmit({ oldValue, newValue });\n };\n\n return (\n <StyledRadioGroup>\n <RadioCheckGroup name={id}>\n {radioOptions.map(item => {\n const checkedProp = {};\n if (item === value) checkedProp.defaultChecked = true;\n\n return (\n <RadioButton\n key={`${item}`}\n id={`${item}`}\n name={`${item}`}\n onClick={onChange}\n label={resolveCellComponent('cellRenderer', renderFactory, {\n ...props,\n getValue: () => item.toString(),\n getFormattedValue: () => getFormatter?.()?.(item) || item.toString()\n })}\n {...checkedProp}\n />\n );\n })}\n </RadioCheckGroup>\n </StyledRadioGroup>\n );\n}\n\nRadioGroup.propTypes = {\n onCancel: PropTypes.func.isRequired,\n onSubmit: PropTypes.func.isRequired,\n getField: PropTypes.func.isRequired,\n getValue: PropTypes.func.isRequired,\n getFormatter: PropTypes.func.isRequired,\n renderFactory: PropTypes.func.isRequired,\n resolveCellComponent: PropTypes.func.isRequired\n};\n\nexport default RadioGroup;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/index.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/index.jsx"],"names":[],"mappings":";AAcA,6EA8DC;;;;;;;;;;;;;sBA5EqB,YAAY"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Popover, useElement, useOuterEvent } from '@pega/cosmos-react-core';
|
|
5
|
+
import { FieldType } from 'pega-repeating-structures-core';
|
|
5
6
|
import TextInput from './TextInput';
|
|
6
7
|
import DateTime from './DateTime';
|
|
7
8
|
import Radio from './Radio';
|
|
@@ -13,7 +14,7 @@ function Editor(props) {
|
|
|
13
14
|
const { getField, onCancel, getElement, setEditContext, getFormatter, getValue, renderFactory, resolveCellComponent } = props;
|
|
14
15
|
setEditContext();
|
|
15
16
|
const { type, filterPickList, filterPickListOptions } = getField();
|
|
16
|
-
const showInPopOver = type ===
|
|
17
|
+
const showInPopOver = type === FieldType.BOOLEAN || (filterPickList && filterPickListOptions);
|
|
17
18
|
const [popperRef, setPopperRef] = useElement();
|
|
18
19
|
const [popperTarget, setPopperTarget] = useElement(getElement());
|
|
19
20
|
useOuterEvent('mousedown', [popperRef], () => {
|
|
@@ -23,15 +24,15 @@ function Editor(props) {
|
|
|
23
24
|
});
|
|
24
25
|
let Component = null;
|
|
25
26
|
switch (type) {
|
|
26
|
-
case
|
|
27
|
-
case
|
|
27
|
+
case FieldType.TEXT:
|
|
28
|
+
case FieldType.NUMBER:
|
|
28
29
|
Component = TextInput;
|
|
29
30
|
break;
|
|
30
|
-
case
|
|
31
|
-
case
|
|
31
|
+
case FieldType.DATE:
|
|
32
|
+
case FieldType.DATE_TIME:
|
|
32
33
|
Component = DateTime;
|
|
33
34
|
break;
|
|
34
|
-
case
|
|
35
|
+
case FieldType.BOOLEAN:
|
|
35
36
|
Component = Radio;
|
|
36
37
|
break;
|
|
37
38
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/index.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../Core/Components/DefaultComponents/CellRenderers/EditComponents/index.jsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG/B,CAAC;AACF,SAAS,MAAM,CAAC,KAAK;IACnB,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,oBAAoB,EACrB,GAAG,KAAK,CAAC;IACV,cAAc,EAAE,CAAC;IAEjB,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,qBAAqB,EAAE,GAAG,QAAQ,EAAE,CAAC;IACnE,MAAM,aAAa,GAAG,IAAI,KAAK,SAAS,CAAC,OAAO,IAAI,CAAC,cAAc,IAAI,qBAAqB,CAAC,CAAC;IAC9F,MAAM,CAAC,SAAS,EAAE,YAA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AK,KAAK,GAAI,GACV,GACR,CACX,IACA,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,SAAS,GAAG;IACjB,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACnC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACnC,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACrC,cAAc,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACzC,YAAY,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACvC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACnC,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;IACxC,oBAAoB,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU;CAChD,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import PropTypes from 'prop-types';\nimport styled from 'styled-components';\n\nimport { Popover, useElement, useOuterEvent } from '@pega/cosmos-react-core';\nimport { FieldType } from 'pega-repeating-structures-core';\n\nimport TextInput from './TextInput';\nimport DateTime from './DateTime';\nimport Radio from './Radio';\n\nconst StyledPopover = styled.div`\n padding: 1rem;\n min-width: 7rem;\n`;\nfunction Editor(props) {\n const {\n getField,\n onCancel,\n getElement,\n setEditContext,\n getFormatter,\n getValue,\n renderFactory,\n resolveCellComponent\n } = props;\n setEditContext();\n\n const { type, filterPickList, filterPickListOptions } = getField();\n const showInPopOver = type === FieldType.BOOLEAN || (filterPickList && filterPickListOptions);\n const [popperRef, setPopperRef] = useElement();\n const [popperTarget, setPopperTarget] = useElement(getElement());\n\n useOuterEvent('mousedown', [popperRef], () => {\n setPopperTarget(null);\n if (showInPopOver) onCancel();\n });\n let Component = null;\n switch (type) {\n case FieldType.TEXT:\n case FieldType.NUMBER:\n Component = TextInput;\n break;\n case FieldType.DATE:\n case FieldType.DATE_TIME:\n Component = DateTime;\n break;\n case FieldType.BOOLEAN:\n Component = Radio;\n break;\n\n default:\n Component = TextInput;\n break;\n }\n if (filterPickList && filterPickListOptions) {\n Component = Radio;\n }\n\n if (!showInPopOver) return <Component {...props} />;\n const value = getValue();\n return (\n <>\n {resolveCellComponent('cellRenderer', renderFactory, {\n ...props,\n getFormattedValue: () => getFormatter?.()?.(value) || value\n })}\n\n {showInPopOver && (\n <Popover ref={setPopperRef} className='editpopper' target={popperTarget}>\n <StyledPopover>\n <Component {...props} />\n </StyledPopover>\n </Popover>\n )}\n </>\n );\n}\n\nEditor.propTypes = {\n getField: PropTypes.func.isRequired,\n onCancel: PropTypes.func.isRequired,\n getElement: PropTypes.func.isRequired,\n setEditContext: PropTypes.func.isRequired,\n getFormatter: PropTypes.func.isRequired,\n getValue: PropTypes.func.isRequired,\n renderFactory: PropTypes.func.isRequired,\n resolveCellComponent: PropTypes.func.isRequired\n};\n\nexport default Editor;\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default RowActionMenu;
|
|
2
|
-
declare function RowActionMenu({ getRsMeta, getExecutionContext }: {
|
|
2
|
+
declare function RowActionMenu({ getRsMeta, getExecutionContext, getParentContext }: {
|
|
3
3
|
getRsMeta: any;
|
|
4
4
|
getExecutionContext: any;
|
|
5
|
+
getParentContext: any;
|
|
5
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
declare namespace RowActionMenu {
|
|
7
8
|
namespace propTypes {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowActionMenu.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/DefaultComponents/CellRenderers/RowActionMenu.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"RowActionMenu.d.ts","sourceRoot":"","sources":["../../../../../Core/Components/DefaultComponents/CellRenderers/RowActionMenu.jsx"],"names":[],"mappings":";AAkBA;;;;4CA0DC;;;;;;;sBA3EqB,YAAY"}
|