@pega/cosmos-react-build 3.0.0-dev.4.2 → 3.0.0-dev.5.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.
Files changed (99) hide show
  1. package/lib/components/AppHeader/AppHeader.js +4 -4
  2. package/lib/components/AppHeader/AppHeader.js.map +1 -1
  3. package/lib/components/AppHeader/BranchButton.js +1 -1
  4. package/lib/components/AppHeader/BranchButton.js.map +1 -1
  5. package/lib/components/AppShell/AppShell.js +9 -9
  6. package/lib/components/AppShell/AppShell.js.map +1 -1
  7. package/lib/components/DynamicContentEditor/DynamicContentEditor.js +3 -3
  8. package/lib/components/DynamicContentEditor/DynamicContentEditor.js.map +1 -1
  9. package/lib/components/FlowModeller/AddNode.js +1 -1
  10. package/lib/components/FlowModeller/AddNode.js.map +1 -1
  11. package/lib/components/FlowModeller/Connector.js +1 -1
  12. package/lib/components/FlowModeller/Connector.js.map +1 -1
  13. package/lib/components/FlowModeller/DeletePopover.js +2 -2
  14. package/lib/components/FlowModeller/DeletePopover.js.map +1 -1
  15. package/lib/components/FlowModeller/FlowModeller.d.ts.map +1 -1
  16. package/lib/components/FlowModeller/FlowModeller.js +2 -2
  17. package/lib/components/FlowModeller/FlowModeller.js.map +1 -1
  18. package/lib/components/FlowModeller/Node/Node.types.d.ts +0 -3
  19. package/lib/components/FlowModeller/Node/Node.types.d.ts.map +1 -1
  20. package/lib/components/FlowModeller/Node/Node.types.js +2 -3
  21. package/lib/components/FlowModeller/Node/Node.types.js.map +1 -1
  22. package/lib/components/FlowModeller/Node/NodeTemplates.d.ts +1 -1
  23. package/lib/components/FlowModeller/Node/NodeTemplates.d.ts.map +1 -1
  24. package/lib/components/FlowModeller/Node/NodeTemplates.js +12 -11
  25. package/lib/components/FlowModeller/Node/NodeTemplates.js.map +1 -1
  26. package/lib/components/FlowModeller/Node.js +3 -3
  27. package/lib/components/FlowModeller/Node.js.map +1 -1
  28. package/lib/components/FlowModeller/Renderer/Connectors.js +2 -2
  29. package/lib/components/FlowModeller/Renderer/Connectors.js.map +1 -1
  30. package/lib/components/FlowModeller/Renderer/Nodes.js +2 -2
  31. package/lib/components/FlowModeller/Renderer/Nodes.js.map +1 -1
  32. package/lib/components/FlowModeller/Renderer/Renderer.js +1 -1
  33. package/lib/components/FlowModeller/Renderer/Renderer.js.map +1 -1
  34. package/lib/components/ItemLibrary/ItemLibrary.d.ts +8 -6
  35. package/lib/components/ItemLibrary/ItemLibrary.d.ts.map +1 -1
  36. package/lib/components/ItemLibrary/ItemLibrary.js +6 -5
  37. package/lib/components/ItemLibrary/ItemLibrary.js.map +1 -1
  38. package/lib/components/LifeCycle/Category.d.ts.map +1 -1
  39. package/lib/components/LifeCycle/Category.js +6 -3
  40. package/lib/components/LifeCycle/Category.js.map +1 -1
  41. package/lib/components/LifeCycle/LifeCycle.d.ts.map +1 -1
  42. package/lib/components/LifeCycle/LifeCycle.js +2 -3
  43. package/lib/components/LifeCycle/LifeCycle.js.map +1 -1
  44. package/lib/components/LifeCycle/LifeCycle.types.d.ts +2 -4
  45. package/lib/components/LifeCycle/LifeCycle.types.d.ts.map +1 -1
  46. package/lib/components/LifeCycle/LifeCycle.types.js.map +1 -1
  47. package/lib/components/LifeCycle/LifeCycleList.js +1 -1
  48. package/lib/components/LifeCycle/LifeCycleList.js.map +1 -1
  49. package/lib/components/LifeCycle/Stage.d.ts.map +1 -1
  50. package/lib/components/LifeCycle/Stage.js +8 -17
  51. package/lib/components/LifeCycle/Stage.js.map +1 -1
  52. package/lib/components/LifeCycle/Step.d.ts +3 -2
  53. package/lib/components/LifeCycle/Step.d.ts.map +1 -1
  54. package/lib/components/LifeCycle/Step.js +8 -30
  55. package/lib/components/LifeCycle/Step.js.map +1 -1
  56. package/lib/components/LifeCycle/Task.d.ts +4 -1
  57. package/lib/components/LifeCycle/Task.d.ts.map +1 -1
  58. package/lib/components/LifeCycle/Task.js +17 -10
  59. package/lib/components/LifeCycle/Task.js.map +1 -1
  60. package/lib/components/LifeCycle/index.d.ts +1 -2
  61. package/lib/components/LifeCycle/index.d.ts.map +1 -1
  62. package/lib/components/LifeCycle/index.js.map +1 -1
  63. package/lib/components/ObjectSelect/ObjectConfig.js +3 -3
  64. package/lib/components/ObjectSelect/ObjectConfig.js.map +1 -1
  65. package/lib/components/ObjectSelect/ObjectPicker.js +1 -1
  66. package/lib/components/ObjectSelect/ObjectPicker.js.map +1 -1
  67. package/lib/components/ObjectSelect/ObjectSelect.js +1 -1
  68. package/lib/components/ObjectSelect/ObjectSelect.js.map +1 -1
  69. package/lib/components/ObjectSelect/ObjectSummary.js +1 -1
  70. package/lib/components/ObjectSelect/ObjectSummary.js.map +1 -1
  71. package/lib/components/PageTemplates/GalleryPage.js +4 -4
  72. package/lib/components/PageTemplates/GalleryPage.js.map +1 -1
  73. package/lib/components/PageTemplates/PageTemplates.js +7 -7
  74. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  75. package/lib/components/SummaryCard/SummaryCard.js +1 -1
  76. package/lib/components/SummaryCard/SummaryCard.js.map +1 -1
  77. package/lib/components/Visual/Visual.js +1 -1
  78. package/lib/components/Visual/Visual.js.map +1 -1
  79. package/lib/components/Workbench/ConfigurationPanel.js +1 -1
  80. package/lib/components/Workbench/ConfigurationPanel.js.map +1 -1
  81. package/lib/components/Workbench/Toolbar.js +2 -2
  82. package/lib/components/Workbench/Toolbar.js.map +1 -1
  83. package/lib/components/Workbench/UtilityPanel.js +1 -1
  84. package/lib/components/Workbench/UtilityPanel.js.map +1 -1
  85. package/lib/components/Workbench/Workbench.js +1 -1
  86. package/lib/components/Workbench/Workbench.js.map +1 -1
  87. package/lib/index.d.ts +1 -0
  88. package/lib/index.d.ts.map +1 -1
  89. package/lib/index.js +1 -0
  90. package/lib/index.js.map +1 -1
  91. package/lib/utils/index.d.ts +2 -0
  92. package/lib/utils/index.d.ts.map +1 -0
  93. package/lib/utils/index.js +2 -0
  94. package/lib/utils/index.js.map +1 -0
  95. package/lib/utils/utils.d.ts +14 -0
  96. package/lib/utils/utils.d.ts.map +1 -0
  97. package/lib/utils/utils.js +13 -0
  98. package/lib/utils/utils.js.map +1 -0
  99. package/package.json +4 -4
@@ -3,36 +3,9 @@ import { useState } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { readableColor } from 'polished';
5
5
  import { Flex, defaultThemeProp, Icon, Tooltip, useElement, Status, Actions, useI18n, Avatar, StyledTooltip } from '@pega/cosmos-react-core';
6
+ import { colorMap } from '../../utils';
6
7
  export const StyledStepType = styled.div(({ theme, color, img }) => {
7
- let bgColor = '';
8
- switch (color) {
9
- case 'magenta':
10
- bgColor = '#AC1361';
11
- break;
12
- case 'studio':
13
- bgColor = '#684AAE';
14
- break;
15
- case 'congressBlue':
16
- bgColor = '#0076d1';
17
- break;
18
- case 'Japaneselaurel':
19
- bgColor = '#27813E';
20
- break;
21
- case 'violet':
22
- bgColor = '#8C479F';
23
- break;
24
- case 'yellow':
25
- bgColor = '#f7a801';
26
- break;
27
- case 'darkyellow':
28
- bgColor = '#f7951c';
29
- break;
30
- case 'orange':
31
- bgColor = '#f46c22';
32
- break;
33
- default:
34
- bgColor = '#27813E';
35
- }
8
+ const bgColor = colorMap[color];
36
9
  const contrastColor = readableColor(bgColor);
37
10
  return img
38
11
  ? css `
@@ -48,6 +21,7 @@ export const StyledStepType = styled.div(({ theme, color, img }) => {
48
21
  border-radius: calc(0.25 * ${theme.base['border-radius']});
49
22
  `;
50
23
  });
24
+ StyledStepType.defaultProps = defaultThemeProp;
51
25
  export const StyledStepBadge = styled.div(({ theme }) => {
52
26
  return css `
53
27
  padding: 0 calc(0.5 * ${theme.base.spacing});
@@ -61,6 +35,7 @@ export const StyledStepBadge = styled.div(({ theme }) => {
61
35
  }
62
36
  `;
63
37
  });
38
+ StyledStepBadge.defaultProps = defaultThemeProp;
64
39
  const StyledStepValue = styled.div(({ theme, error }) => {
65
40
  return css `
66
41
  border-radius: calc(0.5 * ${theme.base['border-radius']});
@@ -70,6 +45,7 @@ const StyledStepValue = styled.div(({ theme, error }) => {
70
45
  `}
71
46
  `;
72
47
  });
48
+ StyledStepValue.defaultProps = defaultThemeProp;
73
49
  export const StyledStepValueInput = styled.input(({ error, theme }) => {
74
50
  return css `
75
51
  height: ${theme.components.input.height};
@@ -105,6 +81,7 @@ export const StyledStepValueInput = styled.input(({ error, theme }) => {
105
81
  `}
106
82
  `;
107
83
  });
84
+ StyledStepValueInput.defaultProps = defaultThemeProp;
108
85
  export const StyledStepStatus = styled.div(({ theme, badge, error }) => {
109
86
  return css `
110
87
  border: none;
@@ -126,6 +103,7 @@ export const StyledStepStatus = styled.div(({ theme, badge, error }) => {
126
103
  `}
127
104
  `;
128
105
  });
106
+ StyledStepStatus.defaultProps = defaultThemeProp;
129
107
  export const StyledStep = styled.div(({ theme, error }) => {
130
108
  return css `
131
109
  background: ${theme.base.palette['secondary-background']};
@@ -245,7 +223,7 @@ const Step = ({ value, id, visual, actions, badge, error, onChange, categoryItem
245
223
  };
246
224
  onBlur?.(actionParam, e);
247
225
  };
248
- return (_jsxs(Flex, { as: StyledStep, container: { inline: true }, error: error, children: [_jsxs(Flex, { as: StyledStepType, color: visual.color, ref: setIconEl, img: visual.imgurl, children: [visual.imgurl.length > 0 && (_jsx(Avatar, { name: visual.title || '', imageSrc: visual?.imgurl, shape: 'squircle', size: 'm' }, void 0)), !visual.imgurl && _jsx(Icon, { name: visual.icon }, void 0)] }, void 0), _jsx(Tooltip, { target: iconEl, children: visual.title }, void 0), _jsxs(Flex, { as: StyledStepValue, item: { grow: 2 }, error: error, container: { inline: true, alignItems: 'center' }, children: [_jsx(StyledStepValueInput, { value: stepValue, type: 'text', ref: setInputEl, error: error, onChange: onInputChange, "aria-label": stepValue, id: item.id, ...restProps, onFocus: onInputFocus, onBlur: onInputBlur }, void 0), badge?.type && (_jsx(Flex, { as: StyledStepBadge, container: { inline: true, alignItems: 'center' }, children: _jsx(Status, { variant: badge?.type || 'success', children: badge?.label }, void 0) }, void 0))] }, void 0), _jsx(Tooltip, { target: inputEl, hideDelay: 'none', children: error || tooltipValue || 'test' }, void 0), _jsx(Flex, { as: StyledStepStatus, ref: setActionEl, badge: badge?.type, error: error, children: actionsClone && _jsx(Actions, { items: actionsClone, menuAt: 2, iconOnly: true }, void 0) }, void 0), _jsx(Tooltip, { target: actionEl, "aria-hidden": 'true', children: actions && actions?.length > 1 ? actionsLabel : singleActionLabel }, void 0)] }, void 0));
226
+ return (_jsxs(Flex, { as: StyledStep, container: { inline: true }, error: error, children: [_jsxs(Flex, { as: StyledStepType, color: visual.color, ref: setIconEl, img: visual.imgurl, children: [visual.imgurl.length > 0 && (_jsx(Avatar, { name: visual.title || '', imageSrc: visual?.imgurl, shape: 'squircle', size: 'm' })), !visual.imgurl && _jsx(Icon, { name: visual.icon })] }), _jsx(Tooltip, { target: iconEl, children: visual.title }), _jsxs(Flex, { as: StyledStepValue, item: { grow: 2 }, error: error, container: { inline: true, alignItems: 'center' }, children: [_jsx(StyledStepValueInput, { value: stepValue, type: 'text', ref: setInputEl, error: error, onChange: onInputChange, "aria-label": stepValue, id: item.id, ...restProps, onFocus: onInputFocus, onBlur: onInputBlur }), badge?.type && (_jsx(Flex, { as: StyledStepBadge, container: { inline: true, alignItems: 'center' }, children: _jsx(Status, { variant: badge?.type || 'success', children: badge?.label }) }))] }), _jsx(Tooltip, { target: inputEl, hideDelay: 'none', children: error || tooltipValue || 'test' }), _jsx(Flex, { as: StyledStepStatus, ref: setActionEl, badge: badge?.type, error: error, children: actionsClone && _jsx(Actions, { items: actionsClone, menuAt: 2, iconOnly: true }) }), _jsx(Tooltip, { target: actionEl, "aria-hidden": 'true', children: actions && actions?.length > 1 ? actionsLabel : singleActionLabel })] }));
249
227
  };
250
228
  export default Step;
251
229
  //# sourceMappingURL=Step.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Step.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/Step.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EAMT,MAAM,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CAAC,EAAE,KACP,SAAS,EACb,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,WACnB,EACD,KAAK,EAAE,IAAI,IAAI,CACd,KAAC,IAAI,IAAC,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAC1E,KAAC,MAAM,IAAC,OAAO,EAAE,KAAK,EAAE,IAAI,IAAI,SAAS,YAAG,KAAK,EAAE,KAAK,WAAU,WAC7D,CACR,YACI,EACP,KAAC,OAAO,IAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,YACvC,KAAK,IAAI,YAAY,IAAI,MAAM,WACxB,EACV,KAAC,IAAI,IAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,YAC3E,YAAY,IAAI,KAAC,OAAO,IAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,iBAAG,WAChE,EACP,KAAC,OAAO,IAAC,MAAM,EAAE,QAAQ,iBAAc,MAAM,YAC1C,OAAO,IAAI,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,WAC1D,YACL,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n useState,\n FunctionComponent,\n PropsWithoutRef,\n ChangeEvent,\n FocusEvent,\n MouseEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Flex,\n defaultThemeProp,\n BaseProps,\n ForwardProps,\n Icon,\n Tooltip,\n useElement,\n Status,\n FormControlProps,\n Actions,\n useI18n,\n Avatar,\n StyledTooltip,\n Action\n} from '@pega/cosmos-react-core';\n\nimport {\n TaskItemProps,\n StepItemProps,\n StageItemProps,\n CategoryItemProps,\n LifeCycleAction,\n LifeCycleActionParam\n} from './LifeCycle.types';\n\nexport interface StepProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** Input Change */\n onChange?: (param: LifeCycleActionParam, e: ChangeEvent<HTMLInputElement>) => void;\n /** callback for Focus of input */\n onFocus?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n /** callback for Blur of input */\n onBlur?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n}\n\ninterface StepComponentProps extends BaseProps, StepProps {\n /** Pass text for the step. */\n value?: string;\n /** step data id */\n id?: string;\n /** Determines the visual for icon, color and label to render.\n * This color is passed as a variant and accessible colors are used to display.\n * Icon and label are passed as normal string */\n visual: {\n imgurl: string;\n color:\n | 'magenta'\n | 'studio'\n | 'congressBlue'\n | 'Japaneselaurel'\n | 'violet'\n | 'yellow'\n | 'orange'\n | 'darkyellow';\n icon: string;\n title: string;\n };\n /* Determines the variant and label for the badges */\n badge?: StepItemProps['status'];\n /* The status is used to show the input error status and the info on tooltip in case of error */\n error?: string;\n /* Data of the steps which can be used to send the full info back */\n item: StepItemProps;\n stageItem: StageItemProps;\n taskItem: TaskItemProps;\n categoryItem: CategoryItemProps;\n}\n\nexport const StyledStepType = styled.div<{ color: string; ref: HTMLDivElement; img: string }>(\n ({ theme, color, img }) => {\n let bgColor = '';\n switch (color) {\n case 'magenta':\n bgColor = '#AC1361';\n break;\n case 'studio':\n bgColor = '#684AAE';\n break;\n case 'congressBlue':\n bgColor = '#0076d1';\n break;\n case 'Japaneselaurel':\n bgColor = '#27813E';\n break;\n case 'violet':\n bgColor = '#8C479F';\n break;\n case 'yellow':\n bgColor = '#f7a801';\n break;\n case 'darkyellow':\n bgColor = '#f7951c';\n break;\n case 'orange':\n bgColor = '#f46c22';\n break;\n\n default:\n bgColor = '#27813E';\n }\n\n const contrastColor = readableColor(bgColor);\n return img\n ? css`\n height: 2rem;\n padding-inline-end: calc(0.25 * ${theme.base.spacing});\n `\n : css`\n background: ${bgColor};\n margin: calc(0.5 * ${theme.base.spacing});\n padding: 0 calc(0.5 * ${theme.base.spacing});\n color: ${contrastColor};\n text-align: center;\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n `;\n }\n);\n\nexport const StyledStepBadge = styled.div(({ theme }) => {\n return css`\n padding: 0 calc(0.5 * ${theme.base.spacing});\n justify-content: flex-end;\n width: auto;\n max-width: calc(50% - ${theme.base.spacing});\n > span {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n `;\n});\n\nconst StyledStepValue = styled.div<{ error: string }>(({ theme, error }) => {\n return css`\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n ${error &&\n css`\n background: ${theme.base.colors.red['extra-light']};\n `}\n `;\n});\n\nexport const StyledStepValueInput = styled.input<{ error: string | undefined }>(\n ({ error, theme }) => {\n return css`\n height: ${theme.components.input.height};\n padding: 0 calc(0.5 * ${theme.base.spacing});\n border: none;\n border-inline-start: 0.0625rem solid transparent;\n border-inline-end: 0.0625rem solid transparent;\n text-overflow: ellipsis;\n min-width: 40%;\n outline: none;\n &:hover {\n cursor: pointer;\n }\n &:disabled {\n cursor: not-allowed;\n }\n ${error\n ? css`\n background: ${theme.base.colors.red['extra-light']};\n &:focus:enabled {\n border-color: ${theme.base.colors.red.medium};\n }\n `\n : css`\n background: ${theme.base.palette['secondary-background']};\n &&:hover {\n background: ${theme.base.palette['app-background']};\n }\n &&:focus:enabled {\n background: ${theme.base.palette['primary-background']};\n border-color: ${theme.base.colors.blue.medium};\n }\n `}\n `;\n }\n);\n\nexport const StyledStepStatus = styled.div<{\n badge: string;\n error: string;\n}>(({ theme, badge, error }) => {\n return css`\n border: none;\n ${badge &&\n css`\n display: none;\n `}\n visibility: hidden;\n &:hover {\n cursor: pointer;\n }\n &:focus:not([disabled]) {\n outline: 0.0625rem solid ${theme.base.colors.blue.medium};\n }\n ${error &&\n !badge &&\n css`\n visibility: visible;\n `}\n `;\n});\n\nexport const StyledStep = styled.div<{ error: string }>(({ theme, error }) => {\n return css`\n background: ${theme.base.palette['secondary-background']};\n border: 0.0625rem solid transparent;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n margin: 0 0 calc(0.5 * ${theme.base.spacing});\n width: 100%;\n ${error &&\n css`\n border-color: ${theme.base.colors.red.medium};\n box-shadow: none;\n `}\n &:hover {\n cursor: pointer;\n ${StyledStepBadge} {\n ${css`\n display: none;\n `}\n }\n ${StyledStepStatus} {\n ${css`\n visibility: visible;\n display: inline-block;\n `}\n }\n }\n &:focus-within {\n ${!error &&\n css`\n border-color: ${theme.base.colors.blue.medium};\n box-shadow: ${theme.components['form-control'][':focus']['box-shadow']};\n `}\n ${StyledStepBadge} {\n ${css`\n display: none;\n `}\n }\n ${StyledStepStatus} {\n ${css`\n display: inline-block;\n visibility: visible;\n `}\n }\n ${StyledTooltip} {\n ${css`\n visibility: hidden;\n `}\n }\n }\n `;\n});\n\nStyledStep.defaultProps = defaultThemeProp;\n\nconst Step: FunctionComponent<StepComponentProps & ForwardProps> = ({\n value,\n id,\n visual,\n actions,\n badge,\n error,\n onChange,\n categoryItem,\n item,\n stageItem,\n taskItem,\n onFocus,\n onBlur,\n ...restProps\n}: PropsWithoutRef<StepComponentProps>) => {\n const t = useI18n();\n const [stepValue, setStepValue] = useState(value);\n const [iconEl, setIconEl] = useElement();\n const [actionEl, setActionEl] = useElement();\n const [inputEl, setInputEl] = useElement();\n const actionsLabel = t('actions');\n const singleActionLabel = (actions?.[0]?.text as string) ?? '';\n const tooltipValue = stepValue || error;\n\n /* Need to check the value with statusProps */\n\n const onActionItemClick = (\n actionId: string,\n e: MouseEvent<HTMLInputElement | HTMLAnchorElement | HTMLButtonElement>\n ) => {\n const param: LifeCycleActionParam = {\n task: taskItem,\n stage: stageItem,\n step: item,\n category: categoryItem\n };\n actions?.forEach(actionItem => {\n if (actionItem.id === actionId) {\n actionItem.onClick(param, e);\n }\n });\n };\n /* Deep copy of actions is required to provide consistent callback objects on actions */\n const actionsClone: Action[] = [];\n\n if (actions) {\n actions.forEach(actionItem => {\n const actionCloneItem = {} as Action;\n Object.keys(actionItem).forEach((key: string) => {\n actionCloneItem[key] = actionItem[key];\n });\n actionCloneItem.onClick = onActionItemClick;\n actionsClone.push(actionCloneItem);\n return actionItem;\n });\n }\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n setStepValue(e.target.value);\n const actionParam: LifeCycleActionParam = {\n value: e.target.value,\n step: item,\n task: taskItem,\n category: categoryItem,\n stage: stageItem\n };\n onChange?.(actionParam, e);\n };\n\n const onInputFocus = (e: FocusEvent<HTMLInputElement>) => {\n const actionParam: LifeCycleActionParam = {\n value: e.target.value,\n step: item,\n task: taskItem,\n category: categoryItem,\n stage: stageItem\n };\n onFocus?.(actionParam, e);\n };\n\n const onInputBlur = (e: FocusEvent<HTMLInputElement>) => {\n const actionParam: LifeCycleActionParam = {\n value: e.target.value,\n step: item,\n task: taskItem,\n category: categoryItem,\n stage: stageItem\n };\n onBlur?.(actionParam, e);\n };\n\n return (\n <Flex as={StyledStep} container={{ inline: true }} error={error}>\n <Flex as={StyledStepType} color={visual.color} ref={setIconEl} img={visual.imgurl}>\n {visual.imgurl.length > 0 && (\n <Avatar name={visual.title || ''} imageSrc={visual?.imgurl} shape='squircle' size='m' />\n )}\n {!visual.imgurl && <Icon name={visual.icon} />}\n </Flex>\n\n <Tooltip target={iconEl}>{visual.title}</Tooltip>\n\n <Flex\n as={StyledStepValue}\n item={{ grow: 2 }}\n error={error}\n container={{ inline: true, alignItems: 'center' }}\n >\n <StyledStepValueInput\n value={stepValue}\n type='text'\n ref={setInputEl}\n error={error}\n onChange={onInputChange}\n aria-label={stepValue}\n id={item.id}\n {...restProps}\n onFocus={onInputFocus}\n onBlur={onInputBlur}\n />\n {badge?.type && (\n <Flex as={StyledStepBadge} container={{ inline: true, alignItems: 'center' }}>\n <Status variant={badge?.type || 'success'}>{badge?.label}</Status>\n </Flex>\n )}\n </Flex>\n <Tooltip target={inputEl} hideDelay='none'>\n {error || tooltipValue || 'test'}\n </Tooltip>\n <Flex as={StyledStepStatus} ref={setActionEl} badge={badge?.type} error={error}>\n {actionsClone && <Actions items={actionsClone} menuAt={2} iconOnly />}\n </Flex>\n <Tooltip target={actionEl} aria-hidden='true'>\n {actions && actions?.length > 1 ? actionsLabel : singleActionLabel}\n </Tooltip>\n </Flex>\n );\n};\n\nexport default Step;\n"]}
1
+ {"version":3,"file":"Step.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/Step.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EAMT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,IAAI,EACJ,gBAAgB,EAGhB,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,EAEN,OAAO,EACP,OAAO,EACP,MAAM,EACN,aAAa,EAEd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAa,MAAM,aAAa,CAAC;AA+ClD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CACtC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;IACxB,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhC,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC7C,OAAO,GAAG;QACR,CAAC,CAAC,GAAG,CAAA;;4CAEiC,KAAK,CAAC,IAAI,CAAC,OAAO;SACrD;QACH,CAAC,CAAC,GAAG,CAAA;wBACa,OAAO;+BACA,KAAK,CAAC,IAAI,CAAC,OAAO;kCACf,KAAK,CAAC,IAAI,CAAC,OAAO;mBACjC,aAAa;;uCAEO,KAAK,CAAC,IAAI,CAAC,eAAe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E,aAEjD,KAAC,oBAAoB,IACnB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,MAAM,EACX,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,gBACX,SAAS,EACrB,EAAE,EAAE,IAAI,CAAC,EAAE,KACP,SAAS,EACb,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,GACnB,EACD,KAAK,EAAE,IAAI,IAAI,CACd,KAAC,IAAI,IAAC,EAAE,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAC1E,KAAC,MAAM,IAAC,OAAO,EAAE,KAAK,EAAE,IAAI,IAAI,SAAS,YAAG,KAAK,EAAE,KAAK,GAAU,GAC7D,CACR,IACI,EACP,KAAC,OAAO,IAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,YACvC,KAAK,IAAI,YAAY,IAAI,MAAM,GACxB,EACV,KAAC,IAAI,IAAC,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,YAC3E,YAAY,IAAI,KAAC,OAAO,IAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,SAAG,GAChE,EACP,KAAC,OAAO,IAAC,MAAM,EAAE,QAAQ,iBAAc,MAAM,YAC1C,OAAO,IAAI,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,GAC1D,IACL,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n useState,\n FunctionComponent,\n PropsWithoutRef,\n ChangeEvent,\n FocusEvent,\n MouseEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor } from 'polished';\n\nimport {\n Flex,\n defaultThemeProp,\n BaseProps,\n ForwardProps,\n Icon,\n Tooltip,\n useElement,\n Status,\n FormControlProps,\n Actions,\n useI18n,\n Avatar,\n StyledTooltip,\n Action\n} from '@pega/cosmos-react-core';\n\nimport { colorMap, ColorName } from '../../utils';\n\nimport {\n TaskItemProps,\n StepItemProps,\n StageItemProps,\n CategoryItemProps,\n LifeCycleAction,\n LifeCycleActionParam\n} from './LifeCycle.types';\n\nexport interface StepProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** Input Change */\n onChange?: (param: LifeCycleActionParam, e: ChangeEvent<HTMLInputElement>) => void;\n /** callback for Focus of input */\n onFocus?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n /** callback for Blur of input */\n onBlur?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n}\n\ninterface StepComponentProps extends BaseProps, StepProps {\n /** Pass text for the step. */\n value?: string;\n /** step data id */\n id?: string;\n /** Determines the visual for icon, color and label to render.\n * This color is passed as a variant and accessible colors are used to display.\n * Icon and label are passed as normal string */\n visual: {\n imgurl: string;\n color: ColorName;\n icon: string;\n title: string;\n };\n /* Determines the variant and label for the badges */\n badge?: StepItemProps['status'];\n /* The status is used to show the input error status and the info on tooltip in case of error */\n error?: string;\n /* Data of the steps which can be used to send the full info back */\n item: StepItemProps;\n stageItem: StageItemProps;\n taskItem: TaskItemProps;\n categoryItem: CategoryItemProps;\n}\n\nexport const StyledStepType = styled.div<{ color: ColorName; ref: HTMLDivElement; img: string }>(\n ({ theme, color, img }) => {\n const bgColor = colorMap[color];\n\n const contrastColor = readableColor(bgColor);\n return img\n ? css`\n height: 2rem;\n padding-inline-end: calc(0.25 * ${theme.base.spacing});\n `\n : css`\n background: ${bgColor};\n margin: calc(0.5 * ${theme.base.spacing});\n padding: 0 calc(0.5 * ${theme.base.spacing});\n color: ${contrastColor};\n text-align: center;\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n `;\n }\n);\n\nStyledStepType.defaultProps = defaultThemeProp;\n\nexport const StyledStepBadge = styled.div(({ theme }) => {\n return css`\n padding: 0 calc(0.5 * ${theme.base.spacing});\n justify-content: flex-end;\n width: auto;\n max-width: calc(50% - ${theme.base.spacing});\n > span {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n `;\n});\n\nStyledStepBadge.defaultProps = defaultThemeProp;\n\nconst StyledStepValue = styled.div<{ error: string }>(({ theme, error }) => {\n return css`\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n ${error &&\n css`\n background: ${theme.base.colors.red['extra-light']};\n `}\n `;\n});\n\nStyledStepValue.defaultProps = defaultThemeProp;\n\nexport const StyledStepValueInput = styled.input<{ error: string | undefined }>(\n ({ error, theme }) => {\n return css`\n height: ${theme.components.input.height};\n padding: 0 calc(0.5 * ${theme.base.spacing});\n border: none;\n border-inline-start: 0.0625rem solid transparent;\n border-inline-end: 0.0625rem solid transparent;\n text-overflow: ellipsis;\n min-width: 40%;\n outline: none;\n &:hover {\n cursor: pointer;\n }\n &:disabled {\n cursor: not-allowed;\n }\n ${error\n ? css`\n background: ${theme.base.colors.red['extra-light']};\n &:focus:enabled {\n border-color: ${theme.base.colors.red.medium};\n }\n `\n : css`\n background: ${theme.base.palette['secondary-background']};\n &&:hover {\n background: ${theme.base.palette['app-background']};\n }\n &&:focus:enabled {\n background: ${theme.base.palette['primary-background']};\n border-color: ${theme.base.colors.blue.medium};\n }\n `}\n `;\n }\n);\n\nStyledStepValueInput.defaultProps = defaultThemeProp;\n\nexport const StyledStepStatus = styled.div<{\n badge: string;\n error: string;\n}>(({ theme, badge, error }) => {\n return css`\n border: none;\n ${badge &&\n css`\n display: none;\n `}\n visibility: hidden;\n &:hover {\n cursor: pointer;\n }\n &:focus:not([disabled]) {\n outline: 0.0625rem solid ${theme.base.colors.blue.medium};\n }\n ${error &&\n !badge &&\n css`\n visibility: visible;\n `}\n `;\n});\n\nStyledStepStatus.defaultProps = defaultThemeProp;\n\nexport const StyledStep = styled.div<{ error: string }>(({ theme, error }) => {\n return css`\n background: ${theme.base.palette['secondary-background']};\n border: 0.0625rem solid transparent;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n margin: 0 0 calc(0.5 * ${theme.base.spacing});\n width: 100%;\n ${error &&\n css`\n border-color: ${theme.base.colors.red.medium};\n box-shadow: none;\n `}\n &:hover {\n cursor: pointer;\n ${StyledStepBadge} {\n ${css`\n display: none;\n `}\n }\n ${StyledStepStatus} {\n ${css`\n visibility: visible;\n display: inline-block;\n `}\n }\n }\n &:focus-within {\n ${!error &&\n css`\n border-color: ${theme.base.colors.blue.medium};\n box-shadow: ${theme.components['form-control'][':focus']['box-shadow']};\n `}\n ${StyledStepBadge} {\n ${css`\n display: none;\n `}\n }\n ${StyledStepStatus} {\n ${css`\n display: inline-block;\n visibility: visible;\n `}\n }\n ${StyledTooltip} {\n ${css`\n visibility: hidden;\n `}\n }\n }\n `;\n});\n\nStyledStep.defaultProps = defaultThemeProp;\n\nconst Step: FunctionComponent<StepComponentProps & ForwardProps> = ({\n value,\n id,\n visual,\n actions,\n badge,\n error,\n onChange,\n categoryItem,\n item,\n stageItem,\n taskItem,\n onFocus,\n onBlur,\n ...restProps\n}: PropsWithoutRef<StepComponentProps>) => {\n const t = useI18n();\n const [stepValue, setStepValue] = useState(value);\n const [iconEl, setIconEl] = useElement();\n const [actionEl, setActionEl] = useElement();\n const [inputEl, setInputEl] = useElement();\n const actionsLabel = t('actions');\n const singleActionLabel = (actions?.[0]?.text as string) ?? '';\n const tooltipValue = stepValue || error;\n\n /* Need to check the value with statusProps */\n\n const onActionItemClick = (\n actionId: string,\n e: MouseEvent<HTMLInputElement | HTMLAnchorElement | HTMLButtonElement>\n ) => {\n const param: LifeCycleActionParam = {\n task: taskItem,\n stage: stageItem,\n step: item,\n category: categoryItem\n };\n actions?.forEach(actionItem => {\n if (actionItem.id === actionId) {\n actionItem.onClick(param, e);\n }\n });\n };\n /* Deep copy of actions is required to provide consistent callback objects on actions */\n const actionsClone: Action[] = [];\n\n if (actions) {\n actions.forEach(actionItem => {\n const actionCloneItem = {} as Action;\n Object.keys(actionItem).forEach((key: string) => {\n actionCloneItem[key] = actionItem[key];\n });\n actionCloneItem.onClick = onActionItemClick;\n actionsClone.push(actionCloneItem);\n return actionItem;\n });\n }\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n setStepValue(e.target.value);\n const actionParam: LifeCycleActionParam = {\n value: e.target.value,\n step: item,\n task: taskItem,\n category: categoryItem,\n stage: stageItem\n };\n onChange?.(actionParam, e);\n };\n\n const onInputFocus = (e: FocusEvent<HTMLInputElement>) => {\n const actionParam: LifeCycleActionParam = {\n value: e.target.value,\n step: item,\n task: taskItem,\n category: categoryItem,\n stage: stageItem\n };\n onFocus?.(actionParam, e);\n };\n\n const onInputBlur = (e: FocusEvent<HTMLInputElement>) => {\n const actionParam: LifeCycleActionParam = {\n value: e.target.value,\n step: item,\n task: taskItem,\n category: categoryItem,\n stage: stageItem\n };\n onBlur?.(actionParam, e);\n };\n\n return (\n <Flex as={StyledStep} container={{ inline: true }} error={error}>\n <Flex as={StyledStepType} color={visual.color} ref={setIconEl} img={visual.imgurl}>\n {visual.imgurl.length > 0 && (\n <Avatar name={visual.title || ''} imageSrc={visual?.imgurl} shape='squircle' size='m' />\n )}\n {!visual.imgurl && <Icon name={visual.icon} />}\n </Flex>\n\n <Tooltip target={iconEl}>{visual.title}</Tooltip>\n\n <Flex\n as={StyledStepValue}\n item={{ grow: 2 }}\n error={error}\n container={{ inline: true, alignItems: 'center' }}\n >\n <StyledStepValueInput\n value={stepValue}\n type='text'\n ref={setInputEl}\n error={error}\n onChange={onInputChange}\n aria-label={stepValue}\n id={item.id}\n {...restProps}\n onFocus={onInputFocus}\n onBlur={onInputBlur}\n />\n {badge?.type && (\n <Flex as={StyledStepBadge} container={{ inline: true, alignItems: 'center' }}>\n <Status variant={badge?.type || 'success'}>{badge?.label}</Status>\n </Flex>\n )}\n </Flex>\n <Tooltip target={inputEl} hideDelay='none'>\n {error || tooltipValue || 'test'}\n </Tooltip>\n <Flex as={StyledStepStatus} ref={setActionEl} badge={badge?.type} error={error}>\n {actionsClone && <Actions items={actionsClone} menuAt={2} iconOnly />}\n </Flex>\n <Tooltip target={actionEl} aria-hidden='true'>\n {actions && actions?.length > 1 ? actionsLabel : singleActionLabel}\n </Tooltip>\n </Flex>\n );\n};\n\nexport default Step;\n"]}
@@ -1,5 +1,6 @@
1
1
  import { FunctionComponent, ChangeEvent, FocusEvent } from 'react';
2
2
  import { BaseProps, ForwardProps, FormControlProps } from '@pega/cosmos-react-core';
3
+ import { LibraryItem } from '../ItemLibrary';
3
4
  import { StepProps } from './Step';
4
5
  import { TaskItemProps, StageItemProps, CategoryItemProps, LifeCycleAction, LifeCycleActionParam } from './LifeCycle.types';
5
6
  export interface TaskProps extends Omit<FormControlProps, 'status' | 'id'> {
@@ -13,12 +14,14 @@ export interface TaskProps extends Omit<FormControlProps, 'status' | 'id'> {
13
14
  showOnce: boolean;
14
15
  onAddTask?: LifeCycleAction['onClick'];
15
16
  };
16
- onAddStep?: LifeCycleAction['onClick'];
17
+ onAddStep?: (param: LifeCycleActionParam, selectedItem: LibraryItem) => void;
17
18
  onChange?: (param: LifeCycleActionParam, e: ChangeEvent<HTMLInputElement>) => void;
18
19
  /** callback for Focus of input */
19
20
  onFocus?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;
20
21
  /** callback for Blur of input */
21
22
  onBlur?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;
23
+ /** Types of Nodes */
24
+ nodeLibrary: LibraryItem[];
22
25
  }
23
26
  interface TaskComponentProps extends BaseProps, TaskProps {
24
27
  /** Pass text for the task. */
@@ -1 +1 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,WAA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B,4GAK3B,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAI5B,CAAC;AAEH,eAAO,MAAM,WAAW;WAAyB,MAAM,GAAG,SAAS;SA+BjE,CAAC;AAIH,eAAO,MAAM,iBAAiB;SACvB,cAAc;WACZ,MAAM;SAoBb,CAAC;AAEH,eAAO,MAAM,UAAU,6GAoBrB,CAAC;AAIH,eAAO,MAAM,kBAAkB,yGAQ9B,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAsM9D,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
2
+ import { useState, useCallback } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { Flex, defaultThemeProp, Button, Icon, Tooltip, useElement, Actions, useI18n, Avatar, StyledTooltip } from '@pega/cosmos-react-core';
4
+ import { Flex, defaultThemeProp, Button, Icon, Tooltip, useElement, Actions, useI18n, Avatar, StyledTooltip, useOuterEvent, useEscape } from '@pega/cosmos-react-core';
5
+ import { ItemLibrary } from '../ItemLibrary';
5
6
  import Step from './Step';
6
7
  export const StyledTaskList = styled.li(({ theme }) => {
7
8
  return css `
@@ -12,6 +13,7 @@ export const StyledTaskList = styled.li(({ theme }) => {
12
13
  }
13
14
  `;
14
15
  });
16
+ StyledTaskList.defaultProps = defaultThemeProp;
15
17
  export const StyledCardHeader = styled.header(({ theme }) => {
16
18
  return css `
17
19
  padding: 0;
@@ -24,7 +26,6 @@ export const StyledCardContent = styled.div(() => {
24
26
  padding: 0;
25
27
  `;
26
28
  });
27
- StyledCardContent.defaultProps = defaultThemeProp;
28
29
  export const StyledInput = styled.input(({ error, theme }) => {
29
30
  return css `
30
31
  height: ${theme.components.input.height};
@@ -78,7 +79,6 @@ export const StyledTaskActions = styled.div(({ error }) => {
78
79
  }
79
80
  `;
80
81
  });
81
- StyledTaskActions.defaultProps = defaultThemeProp;
82
82
  export const StyledTask = styled.article(({ theme }) => {
83
83
  return css `
84
84
  background: ${theme.base.palette['primary-background']};
@@ -110,9 +110,11 @@ export const StyledInputWrapper = styled.div `
110
110
  }
111
111
  }
112
112
  `;
113
- const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem, error, onAddStep, onChange, onFocus, onBlur, categoryItem, id, step: stepProp, ...restProps }) => {
113
+ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem, error, onAddStep, onChange, onFocus, onBlur, categoryItem, id, step: stepProp, nodeLibrary, ...restProps }) => {
114
114
  const t = useI18n();
115
115
  const [taskValue, setTaskValue] = useState(value);
116
+ const [showLibrary, setLibrary] = useState(false);
117
+ const [popoverEl, setPopoverEl] = useElement(null);
116
118
  const [actionEl, setActionEl] = useElement();
117
119
  const [inputEl, setInputEl] = useElement();
118
120
  const [addEl, setAddEl] = useElement();
@@ -171,15 +173,20 @@ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem,
171
173
  };
172
174
  onBlur?.(param, e);
173
175
  };
174
- const onAddStepClick = (e) => {
176
+ const onLibraryItemSelect = useCallback((libItem) => {
175
177
  const param = {
176
178
  task: item,
177
179
  stage: stageItem,
178
180
  category: categoryItem
179
181
  };
180
- onAddStep?.(param, e);
181
- };
182
- return (_jsx(Flex, { as: StyledTaskList, ...restProps, children: _jsxs(Flex, { as: StyledTask, container: { direction: 'column' }, role: 'region', children: [_jsxs(Flex, { as: StyledCardHeader, container: { itemGap: 0.4 }, children: [visual?.imgurl.length > 0 && _jsx(Avatar, { name: taskValue || '', imageSrc: visual?.imgurl }, void 0), _jsxs(Flex, { item: { grow: 1 }, as: StyledInputWrapper, container: { inline: true, alignItems: 'center' }, children: [_jsx(StyledInput, { value: taskValue, type: 'text', onChange: onInputChange, ref: setInputEl, error: error, id: item.id, "aria-labelledby": categoryItem.categoryId, onFocus: onInputFocus, onBlur: onInputBlur }, void 0), taskValue && (_jsx(Tooltip, { target: inputEl, hideDelay: 'none', children: error || taskValue }, void 0))] }, void 0), _jsxs(Flex, { as: StyledTaskActions, ref: setActionEl, error: error, children: [actionsClone && _jsx(Actions, { items: actionsClone, menuAt: 2, iconOnly: true }, void 0), _jsx(Tooltip, { target: actionEl, "aria-hidden": 'true', children: actions && actions?.length > 1 ? actionsLabel : singleActionLabel }, void 0)] }, void 0)] }, void 0), _jsxs(Flex, { as: StyledCardContent, children: [item?.steps.map((steps) => {
182
+ onAddStep?.(param, libItem);
183
+ setLibrary(false);
184
+ }, [onAddStep]);
185
+ useEscape(() => {
186
+ setLibrary(false);
187
+ });
188
+ useOuterEvent('mousedown', [addEl, popoverEl], () => setLibrary(false));
189
+ return (_jsx(Flex, { as: StyledTaskList, ...restProps, children: _jsxs(Flex, { as: StyledTask, container: { direction: 'column' }, role: 'region', children: [_jsxs(Flex, { as: StyledCardHeader, container: { itemGap: 0.4 }, children: [visual?.imgurl.length > 0 && _jsx(Avatar, { name: taskValue || '', imageSrc: visual?.imgurl }), _jsxs(Flex, { item: { grow: 1 }, as: StyledInputWrapper, container: { inline: true, alignItems: 'center' }, children: [_jsx(StyledInput, { value: taskValue, type: 'text', onChange: onInputChange, ref: setInputEl, error: error, id: item.id, "aria-labelledby": categoryItem.categoryId, onFocus: onInputFocus, onBlur: onInputBlur }), taskValue && (_jsx(Tooltip, { target: inputEl, hideDelay: 'none', children: error || taskValue }))] }), _jsxs(Flex, { as: StyledTaskActions, ref: setActionEl, error: error, children: [actionsClone && _jsx(Actions, { items: actionsClone, menuAt: 2, iconOnly: true }), _jsx(Tooltip, { target: actionEl, "aria-hidden": 'true', children: actions && actions?.length > 1 ? actionsLabel : singleActionLabel })] })] }), _jsxs(Flex, { as: StyledCardContent, children: [item?.steps.map((steps) => {
183
190
  const badgeStatus = steps?.status?.type ? steps.status.type : '';
184
191
  const badgeLabel = steps?.status?.label ? steps.status.label : '';
185
192
  return (_jsx(Step, { id: steps.id, value: steps.label, visual: {
@@ -191,7 +198,7 @@ const Task = ({ value, visual, actions, item, addStepTitle, addTask, stageItem,
191
198
  type: badgeStatus,
192
199
  label: badgeLabel
193
200
  }, error: steps.error, categoryItem: categoryItem, ...stepProp }, steps.id));
194
- }), _jsxs(Flex, { children: [_jsx(Button, { variant: 'simple', label: addStepTitle, onClick: onAddStepClick, ref: setAddEl, icon: true, "aria-label": `${t('add')} ${addStepTitle}`, children: _jsx(Icon, { name: 'plus' }, void 0) }, void 0), _jsx(Tooltip, { target: addEl, "aria-hidden": 'true', children: `${t('add')} ${addStepTitle}` }, void 0)] }, void 0)] }, void 0)] }, void 0) }, void 0));
201
+ }), _jsxs(Flex, { children: [_jsx(Button, { variant: 'simple', label: addStepTitle, onClick: () => setLibrary(!showLibrary), ref: setAddEl, icon: true, "aria-label": `${t('add')} ${addStepTitle}`, children: _jsx(Icon, { name: 'plus' }) }), _jsx(Tooltip, { target: addEl, "aria-hidden": 'true', children: `${t('add')} ${addStepTitle}` }), _jsx(ItemLibrary, { items: nodeLibrary, show: showLibrary, target: addEl, onClick: onLibraryItemSelect, ref: setPopoverEl, placeholder: t('search_nodes') })] })] })] }) }));
195
202
  };
196
203
  export default Task;
197
204
  //# sourceMappingURL=Task.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Task.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EAMT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,gBAAgB,EAGhB,MAAM,EACN,IAAI,EAEJ,OAAO,EACP,UAAU,EACV,OAAO,EAEP,OAAO,EACP,MAAM,EACN,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,IAAmB,MAAM,QAAQ,CAAC;AAiDzC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;I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AM,WAAG,WACb,EACT,KAAC,OAAO,IAAC,MAAM,EAAE,KAAK,iBAAc,MAAM,YACvC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,EAAE,WACtB,YACL,YACF,YACF,WACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n useState,\n FunctionComponent,\n PropsWithChildren,\n ChangeEvent,\n FocusEvent,\n MouseEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n defaultThemeProp,\n BaseProps,\n ForwardProps,\n Button,\n Icon,\n Action,\n Tooltip,\n useElement,\n Actions,\n FormControlProps,\n useI18n,\n Avatar,\n StyledTooltip\n} from '@pega/cosmos-react-core';\n\nimport Step, { StepProps } from './Step';\nimport {\n TaskItemProps,\n StageItemProps,\n StepItemProps,\n CategoryItemProps,\n LifeCycleAction,\n LifeCycleActionParam\n} from './LifeCycle.types';\n\nexport interface TaskProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** Tooltip for adding items to the task component */\n addStepTitle: string;\n /** Region for adding the task component */\n addTask: {\n title: string;\n showOnce: boolean;\n onAddTask?: LifeCycleAction['onClick'];\n };\n onAddStep?: LifeCycleAction['onClick'];\n onChange?: (param: LifeCycleActionParam, e: ChangeEvent<HTMLInputElement>) => void;\n /** callback for Focus of input */\n onFocus?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n /** callback for Blur of input */\n onBlur?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n}\n\ninterface TaskComponentProps extends BaseProps, TaskProps {\n /** Pass text for the task. */\n value?: string;\n /** support for an Avatar, Icon, or other supporting visual. */\n visual: {\n imgurl: string;\n };\n /** Pass task data */\n item: TaskItemProps;\n /* The status is used to show the input error status and the info on tooltip in case of error */\n error?: string;\n /** Step Props */\n step?: StepProps;\n /** Stage data to pass it as callback */\n stageItem: StageItemProps;\n /** Category data to pass it as callback */\n categoryItem: CategoryItemProps;\n id: string;\n}\n\nexport const StyledTaskList = styled.li(({ theme }) => {\n return css`\n list-style-type: none;\n margin-block-end: ${theme.base.spacing};\n &:last-child > article {\n margin-block-end: 0;\n }\n `;\n});\n\nexport const StyledCardHeader = styled.header(({ theme }) => {\n return css`\n padding: 0;\n margin: 0 0 calc(0.5 * ${theme.base.spacing});\n `;\n});\nStyledCardHeader.defaultProps = defaultThemeProp;\n\nexport const StyledCardContent = styled.div(() => {\n return css`\n padding: 0;\n `;\n});\nStyledCardContent.defaultProps = defaultThemeProp;\n\nexport const StyledInput = styled.input<{ error: string | undefined }>(({ error, theme }) => {\n return css`\n height: ${theme.components.input.height};\n padding: 0 calc(0.5 * ${theme.base.spacing});\n text-overflow: ellipsis;\n border: 0.0625rem solid transparent;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n width: 100%;\n outline: none;\n &:hover {\n cursor: pointer;\n }\n &:disabled {\n cursor: not-allowed;\n }\n ${error\n ? css`\n background: ${theme.base.colors.red['extra-light']};\n border: 0.0625rem solid ${theme.base.colors.red.medium};\n `\n : css`\n background: ${theme.base.palette['primary-background']};\n &&:hover {\n background: ${theme.base.palette['secondary-background']};\n }\n &&:focus:enabled {\n border: 0.0625rem solid ${theme.base.colors.blue.medium};\n background: ${theme.base.palette['primary-background']};\n }\n `}\n `;\n});\nStyledInput.defaultProps = defaultThemeProp;\n\nexport const StyledTaskActions = styled.div<{\n ref: HTMLDivElement;\n error: string;\n}>(({ error }) => {\n return css`\n border: none;\n visibility: hidden;\n &:hover {\n cursor: pointer;\n }\n ${error &&\n css`\n visibility: visible;\n `}\n &:focus-within {\n ${StyledTooltip} {\n ${css`\n display: none;\n `}\n }\n }\n `;\n});\nStyledTaskActions.defaultProps = defaultThemeProp;\n\nexport const StyledTask = styled.article(({ theme }) => {\n return css`\n background: ${theme.base.palette['primary-background']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n padding: ${theme.base.spacing};\n &:focus-within,\n &:hover {\n ${StyledTaskActions} {\n ${css`\n visibility: visible;\n `}\n }\n }\n &:focus-within {\n box-shadow: 0 0 0.2rem 0.0625rem ${theme.base.colors.blue.medium};\n }\n &:hover {\n cursor: pointer;\n }\n `;\n});\nStyledTask.defaultProps = defaultThemeProp;\n\nexport const StyledInputWrapper = styled.div`\n &:focus-within {\n ${StyledTooltip} {\n ${css`\n display: none;\n `}\n }\n }\n`;\n\nconst Task: FunctionComponent<TaskComponentProps & ForwardProps> = ({\n value,\n visual,\n actions,\n item,\n addStepTitle,\n addTask,\n stageItem,\n error,\n onAddStep,\n onChange,\n onFocus,\n onBlur,\n categoryItem,\n id,\n step: stepProp,\n ...restProps\n}: PropsWithChildren<TaskComponentProps>) => {\n const t = useI18n();\n const [taskValue, setTaskValue] = useState(value);\n const [actionEl, setActionEl] = useElement();\n const [inputEl, setInputEl] = useElement();\n const [addEl, setAddEl] = useElement();\n const actionsLabel = t('actions');\n const singleActionLabel = (actions?.[0]?.text as string) || '';\n\n const onActionItemClick = (\n actionId: string,\n e: MouseEvent<HTMLInputElement | HTMLAnchorElement | HTMLButtonElement>\n ) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n actions?.forEach(actionItem => {\n if (actionItem.id === actionId) {\n actionItem.onClick(param, e);\n }\n });\n };\n /* Deep copy of actions is required to provide consistent callback objects on actions */\n const actionsClone: Action[] = [];\n\n if (actions) {\n actions.forEach(actionItem => {\n const actionCloneItem = {} as Action;\n Object.keys(actionItem).forEach((key: string) => {\n actionCloneItem[key] = actionItem[key];\n });\n actionCloneItem.onClick = onActionItemClick;\n actionsClone.push(actionCloneItem);\n return actionItem;\n });\n }\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n setTaskValue(e.target.value);\n const param: LifeCycleActionParam = {\n value: e.target.value,\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onChange?.(param, e);\n };\n\n const onInputFocus = (e: FocusEvent<HTMLInputElement>) => {\n const param: LifeCycleActionParam = {\n value: taskValue,\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onFocus?.(param, e);\n };\n\n const onInputBlur = (e: FocusEvent<HTMLInputElement>) => {\n const param: LifeCycleActionParam = {\n value: taskValue,\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onBlur?.(param, e);\n };\n\n const onAddStepClick = (e: MouseEvent<HTMLButtonElement>) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onAddStep?.(param, e);\n };\n\n return (\n <Flex as={StyledTaskList} {...restProps}>\n <Flex as={StyledTask} container={{ direction: 'column' }} role='region'>\n <Flex as={StyledCardHeader} container={{ itemGap: 0.4 }}>\n {visual?.imgurl.length > 0 && <Avatar name={taskValue || ''} imageSrc={visual?.imgurl} />}\n <Flex\n item={{ grow: 1 }}\n as={StyledInputWrapper}\n container={{ inline: true, alignItems: 'center' }}\n >\n <StyledInput\n value={taskValue}\n type='text'\n onChange={onInputChange}\n ref={setInputEl}\n error={error}\n id={item.id}\n aria-labelledby={categoryItem.categoryId}\n onFocus={onInputFocus}\n onBlur={onInputBlur}\n />\n {taskValue && (\n <Tooltip target={inputEl} hideDelay='none'>\n {error || taskValue}\n </Tooltip>\n )}\n </Flex>\n <Flex as={StyledTaskActions} ref={setActionEl} error={error}>\n {actionsClone && <Actions items={actionsClone} menuAt={2} iconOnly />}\n <Tooltip target={actionEl} aria-hidden='true'>\n {actions && actions?.length > 1 ? actionsLabel : singleActionLabel}\n </Tooltip>\n </Flex>\n </Flex>\n <Flex as={StyledCardContent}>\n {item?.steps.map((steps: StepItemProps) => {\n const badgeStatus = steps?.status?.type ? steps.status.type : '';\n const badgeLabel = steps?.status?.label ? steps.status.label : '';\n return (\n <Step\n key={steps.id}\n id={steps.id}\n value={steps.label}\n visual={{\n imgurl: steps.visual.imgurl,\n color: steps.visual.color,\n icon: steps.visual.icon,\n title: steps.visual.label\n }}\n item={steps}\n taskItem={item}\n stageItem={stageItem}\n badge={{\n type: badgeStatus,\n label: badgeLabel\n }}\n error={steps.error}\n categoryItem={categoryItem}\n {...stepProp}\n />\n );\n })}\n <Flex>\n <Button\n variant='simple'\n label={addStepTitle}\n onClick={onAddStepClick}\n ref={setAddEl}\n icon\n aria-label={`${t('add')} ${addStepTitle}`}\n >\n <Icon name='plus' />\n </Button>\n <Tooltip target={addEl} aria-hidden='true'>\n {`${t('add')} ${addStepTitle}`}\n </Tooltip>\n </Flex>\n </Flex>\n </Flex>\n </Flex>\n );\n};\n\nexport default Task;\n"]}
1
+ {"version":3,"file":"Task.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/Task.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,QAAQ,EAMR,WAAW,EACZ,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,gBAAgB,EAGhB,MAAM,EACN,IAAI,EAEJ,OAAO,EACP,UAAU,EACV,OAAO,EAEP,OAAO,EACP,MAAM,EACN,aAAa,EACb,aAAa,EACb,SAAS,EACV,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,IAAmB,MAAM,QAAQ,CAAC;AAmDzC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,OAAO,GAAG,CAAA;;wBAEY,KAAK,CAAC,IAAI,CAAC,OAAO;;;;GAIvC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1D,OAAO,GAAG,CAAA;;6BAEiB,KAAK,CAAC,IAAI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U,CAAC,CAAC,WAAW,CAAC,EACvC,GAAG,EAAE,QAAQ,EACb,IAAI,sBACQ,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,EAAE,YAEzC,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,EACT,KAAC,OAAO,IAAC,MAAM,EAAE,KAAK,iBAAc,MAAM,YACvC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,EAAE,GACtB,EACV,KAAC,WAAW,IACV,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,KAAoB,EAC5B,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,YAAY,EACjB,WAAW,EAAE,CAAC,CAAC,cAAc,CAAC,GAC9B,IACG,IACF,IACF,GACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n useState,\n FunctionComponent,\n PropsWithChildren,\n ChangeEvent,\n FocusEvent,\n MouseEvent,\n useCallback\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n defaultThemeProp,\n BaseProps,\n ForwardProps,\n Button,\n Icon,\n Action,\n Tooltip,\n useElement,\n Actions,\n FormControlProps,\n useI18n,\n Avatar,\n StyledTooltip,\n useOuterEvent,\n useEscape\n} from '@pega/cosmos-react-core';\n\nimport { LibraryItem, ItemLibrary } from '../ItemLibrary';\n\nimport Step, { StepProps } from './Step';\nimport {\n TaskItemProps,\n StageItemProps,\n StepItemProps,\n CategoryItemProps,\n LifeCycleAction,\n LifeCycleActionParam\n} from './LifeCycle.types';\n\nexport interface TaskProps extends Omit<FormControlProps, 'status' | 'id'> {\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: LifeCycleAction[];\n /** Tooltip for adding items to the task component */\n addStepTitle: string;\n /** Region for adding the task component */\n addTask: {\n title: string;\n showOnce: boolean;\n onAddTask?: LifeCycleAction['onClick'];\n };\n onAddStep?: (param: LifeCycleActionParam, selectedItem: LibraryItem) => void;\n onChange?: (param: LifeCycleActionParam, e: ChangeEvent<HTMLInputElement>) => void;\n /** callback for Focus of input */\n onFocus?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n /** callback for Blur of input */\n onBlur?: (param: LifeCycleActionParam, e: FocusEvent<HTMLInputElement>) => void;\n /** Types of Nodes */\n nodeLibrary: LibraryItem[];\n}\n\ninterface TaskComponentProps extends BaseProps, TaskProps {\n /** Pass text for the task. */\n value?: string;\n /** support for an Avatar, Icon, or other supporting visual. */\n visual: {\n imgurl: string;\n };\n /** Pass task data */\n item: TaskItemProps;\n /* The status is used to show the input error status and the info on tooltip in case of error */\n error?: string;\n /** Step Props */\n step?: StepProps;\n /** Stage data to pass it as callback */\n stageItem: StageItemProps;\n /** Category data to pass it as callback */\n categoryItem: CategoryItemProps;\n id: string;\n}\n\nexport const StyledTaskList = styled.li(({ theme }) => {\n return css`\n list-style-type: none;\n margin-block-end: ${theme.base.spacing};\n &:last-child > article {\n margin-block-end: 0;\n }\n `;\n});\n\nStyledTaskList.defaultProps = defaultThemeProp;\n\nexport const StyledCardHeader = styled.header(({ theme }) => {\n return css`\n padding: 0;\n margin: 0 0 calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledCardHeader.defaultProps = defaultThemeProp;\n\nexport const StyledCardContent = styled.div(() => {\n return css`\n padding: 0;\n `;\n});\n\nexport const StyledInput = styled.input<{ error: string | undefined }>(({ error, theme }) => {\n return css`\n height: ${theme.components.input.height};\n padding: 0 calc(0.5 * ${theme.base.spacing});\n text-overflow: ellipsis;\n border: 0.0625rem solid transparent;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n width: 100%;\n outline: none;\n &:hover {\n cursor: pointer;\n }\n &:disabled {\n cursor: not-allowed;\n }\n ${error\n ? css`\n background: ${theme.base.colors.red['extra-light']};\n border: 0.0625rem solid ${theme.base.colors.red.medium};\n `\n : css`\n background: ${theme.base.palette['primary-background']};\n &&:hover {\n background: ${theme.base.palette['secondary-background']};\n }\n &&:focus:enabled {\n border: 0.0625rem solid ${theme.base.colors.blue.medium};\n background: ${theme.base.palette['primary-background']};\n }\n `}\n `;\n});\n\nStyledInput.defaultProps = defaultThemeProp;\n\nexport const StyledTaskActions = styled.div<{\n ref: HTMLDivElement;\n error: string;\n}>(({ error }) => {\n return css`\n border: none;\n visibility: hidden;\n &:hover {\n cursor: pointer;\n }\n ${error &&\n css`\n visibility: visible;\n `}\n &:focus-within {\n ${StyledTooltip} {\n ${css`\n display: none;\n `}\n }\n }\n `;\n});\n\nexport const StyledTask = styled.article(({ theme }) => {\n return css`\n background: ${theme.base.palette['primary-background']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n padding: ${theme.base.spacing};\n &:focus-within,\n &:hover {\n ${StyledTaskActions} {\n ${css`\n visibility: visible;\n `}\n }\n }\n &:focus-within {\n box-shadow: 0 0 0.2rem 0.0625rem ${theme.base.colors.blue.medium};\n }\n &:hover {\n cursor: pointer;\n }\n `;\n});\n\nStyledTask.defaultProps = defaultThemeProp;\n\nexport const StyledInputWrapper = styled.div`\n &:focus-within {\n ${StyledTooltip} {\n ${css`\n display: none;\n `}\n }\n }\n`;\n\nconst Task: FunctionComponent<TaskComponentProps & ForwardProps> = ({\n value,\n visual,\n actions,\n item,\n addStepTitle,\n addTask,\n stageItem,\n error,\n onAddStep,\n onChange,\n onFocus,\n onBlur,\n categoryItem,\n id,\n step: stepProp,\n nodeLibrary,\n ...restProps\n}: PropsWithChildren<TaskComponentProps>) => {\n const t = useI18n();\n const [taskValue, setTaskValue] = useState(value);\n const [showLibrary, setLibrary] = useState(false);\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>(null);\n const [actionEl, setActionEl] = useElement();\n const [inputEl, setInputEl] = useElement();\n const [addEl, setAddEl] = useElement();\n const actionsLabel = t('actions');\n const singleActionLabel = (actions?.[0]?.text as string) || '';\n\n const onActionItemClick = (\n actionId: string,\n e: MouseEvent<HTMLInputElement | HTMLAnchorElement | HTMLButtonElement>\n ) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n actions?.forEach(actionItem => {\n if (actionItem.id === actionId) {\n actionItem.onClick(param, e);\n }\n });\n };\n /* Deep copy of actions is required to provide consistent callback objects on actions */\n const actionsClone: Action[] = [];\n\n if (actions) {\n actions.forEach(actionItem => {\n const actionCloneItem = {} as Action;\n Object.keys(actionItem).forEach((key: string) => {\n actionCloneItem[key] = actionItem[key];\n });\n actionCloneItem.onClick = onActionItemClick;\n actionsClone.push(actionCloneItem);\n return actionItem;\n });\n }\n\n const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {\n setTaskValue(e.target.value);\n const param: LifeCycleActionParam = {\n value: e.target.value,\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onChange?.(param, e);\n };\n\n const onInputFocus = (e: FocusEvent<HTMLInputElement>) => {\n const param: LifeCycleActionParam = {\n value: taskValue,\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onFocus?.(param, e);\n };\n\n const onInputBlur = (e: FocusEvent<HTMLInputElement>) => {\n const param: LifeCycleActionParam = {\n value: taskValue,\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onBlur?.(param, e);\n };\n\n const onLibraryItemSelect = useCallback(\n (libItem: LibraryItem) => {\n const param: LifeCycleActionParam = {\n task: item,\n stage: stageItem,\n category: categoryItem\n };\n onAddStep?.(param, libItem);\n setLibrary(false);\n },\n [onAddStep]\n );\n\n useEscape(() => {\n setLibrary(false);\n });\n\n useOuterEvent('mousedown', [addEl, popoverEl], () => setLibrary(false));\n\n return (\n <Flex as={StyledTaskList} {...restProps}>\n <Flex as={StyledTask} container={{ direction: 'column' }} role='region'>\n <Flex as={StyledCardHeader} container={{ itemGap: 0.4 }}>\n {visual?.imgurl.length > 0 && <Avatar name={taskValue || ''} imageSrc={visual?.imgurl} />}\n <Flex\n item={{ grow: 1 }}\n as={StyledInputWrapper}\n container={{ inline: true, alignItems: 'center' }}\n >\n <StyledInput\n value={taskValue}\n type='text'\n onChange={onInputChange}\n ref={setInputEl}\n error={error}\n id={item.id}\n aria-labelledby={categoryItem.categoryId}\n onFocus={onInputFocus}\n onBlur={onInputBlur}\n />\n {taskValue && (\n <Tooltip target={inputEl} hideDelay='none'>\n {error || taskValue}\n </Tooltip>\n )}\n </Flex>\n <Flex as={StyledTaskActions} ref={setActionEl} error={error}>\n {actionsClone && <Actions items={actionsClone} menuAt={2} iconOnly />}\n <Tooltip target={actionEl} aria-hidden='true'>\n {actions && actions?.length > 1 ? actionsLabel : singleActionLabel}\n </Tooltip>\n </Flex>\n </Flex>\n <Flex as={StyledCardContent}>\n {item?.steps.map((steps: StepItemProps) => {\n const badgeStatus = steps?.status?.type ? steps.status.type : '';\n const badgeLabel = steps?.status?.label ? steps.status.label : '';\n return (\n <Step\n key={steps.id}\n id={steps.id}\n value={steps.label}\n visual={{\n imgurl: steps.visual.imgurl,\n color: steps.visual.color,\n icon: steps.visual.icon,\n title: steps.visual.label\n }}\n item={steps}\n taskItem={item}\n stageItem={stageItem}\n badge={{\n type: badgeStatus,\n label: badgeLabel\n }}\n error={steps.error}\n categoryItem={categoryItem}\n {...stepProp}\n />\n );\n })}\n <Flex>\n <Button\n variant='simple'\n label={addStepTitle}\n onClick={() => setLibrary(!showLibrary)}\n ref={setAddEl}\n icon\n aria-label={`${t('add')} ${addStepTitle}`}\n >\n <Icon name='plus' />\n </Button>\n <Tooltip target={addEl} aria-hidden='true'>\n {`${t('add')} ${addStepTitle}`}\n </Tooltip>\n <ItemLibrary\n items={nodeLibrary}\n show={showLibrary}\n target={addEl as HTMLElement}\n onClick={onLibraryItemSelect}\n ref={setPopoverEl}\n placeholder={t('search_nodes')}\n />\n </Flex>\n </Flex>\n </Flex>\n </Flex>\n );\n};\n\nexport default Task;\n"]}
@@ -1,4 +1,3 @@
1
- export { default } from './LifeCycle';
2
- export { LifeCycleProps } from './LifeCycle';
1
+ export { default, LifeCycleProps } from './LifeCycle';
3
2
  export { StepItemProps, TaskItemProps, StageItemProps, CategoryItemProps, CategoriesItemProps, LifeCycleActionParam, LifeCycleAction } from './LifeCycle.types';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LifeCycle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { default } from './LifeCycle';\nexport { LifeCycleProps } from './LifeCycle';\nexport {\n StepItemProps,\n TaskItemProps,\n StageItemProps,\n CategoryItemProps,\n CategoriesItemProps,\n LifeCycleActionParam,\n LifeCycleAction\n} from './LifeCycle.types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/LifeCycle/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,MAAM,aAAa,CAAC","sourcesContent":["export { default, LifeCycleProps } from './LifeCycle';\n\nexport {\n StepItemProps,\n TaskItemProps,\n StageItemProps,\n CategoryItemProps,\n CategoriesItemProps,\n LifeCycleActionParam,\n LifeCycleAction\n} from './LifeCycle.types';\n"]}
@@ -2,13 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, Flex, Icon, Text, useI18n } from '@pega/cosmos-react-core';
3
3
  const ObjectConfig = ({ heading, content, primaryAction, secondaryAction, disabled, dismissPopover }) => {
4
4
  const t = useI18n();
5
- return (_jsxs(Flex, { container: { direction: 'column', pad: 2, gap: 2 }, children: [_jsxs(Flex, { container: { justify: 'between', alignItems: 'center' }, children: [_jsx(Text, { variant: 'h3', children: heading }, void 0), _jsx(Button, { icon: true, variant: 'simple', label: t('close'), onClick: () => dismissPopover(), children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)] }, void 0), content, _jsxs(Flex, { container: { justify: 'between' }, children: [_jsx(Button, { variant: 'secondary', disabled: disabled, onClick: (e) => {
5
+ return (_jsxs(Flex, { container: { direction: 'column', pad: 2, gap: 2 }, children: [_jsxs(Flex, { container: { justify: 'between', alignItems: 'center' }, children: [_jsx(Text, { variant: 'h3', children: heading }), _jsx(Button, { icon: true, variant: 'simple', label: t('close'), onClick: () => dismissPopover(), children: _jsx(Icon, { name: 'times' }) })] }), content, _jsxs(Flex, { container: { justify: 'between' }, children: [_jsx(Button, { variant: 'secondary', disabled: disabled, onClick: (e) => {
6
6
  secondaryAction.onClick?.(secondaryAction.id, e);
7
7
  dismissPopover(secondaryAction.id);
8
- }, children: secondaryAction.text }, void 0), _jsx(Button, { variant: 'primary', disabled: disabled, onClick: (e) => {
8
+ }, children: secondaryAction.text }), _jsx(Button, { variant: 'primary', disabled: disabled, onClick: (e) => {
9
9
  primaryAction.onClick?.(primaryAction.id, e);
10
10
  dismissPopover(primaryAction.id);
11
- }, children: primaryAction.text }, void 0)] }, void 0)] }, void 0));
11
+ }, children: primaryAction.text })] })] }));
12
12
  };
13
13
  export default ObjectConfig;
14
14
  //# sourceMappingURL=ObjectConfig.js.map
@@ -1 +1 @@
1
- {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S,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC5C,aAAa,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;4BAC7C,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;wBACnC,CAAC,YAEA,aAAa,CAAC,IAAI,WACZ,YACJ,YACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { ReactNode, FC, Ref, MouseEvent } from 'react';\n\nimport { ForwardProps, Button, Flex, Icon, Action, Text, useI18n } from '@pega/cosmos-react-core';\n\nexport interface ObjectConfigProps {\n label: string;\n heading: string;\n primaryAction: Action;\n secondaryAction: Action;\n content?: ReactNode;\n onBeforeOpen?: () => void;\n onAfterClose?: (id?: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectConfig: FC<\n ObjectConfigProps & ForwardProps & { disabled?: boolean; dismissPopover: (id?: string) => void }\n> = ({ heading, content, primaryAction, secondaryAction, disabled, dismissPopover }) => {\n const t = useI18n();\n\n return (\n <Flex container={{ direction: 'column', pad: 2, gap: 2 }}>\n <Flex container={{ justify: 'between', alignItems: 'center' }}>\n <Text variant='h3'>{heading}</Text>\n <Button icon variant='simple' label={t('close')} onClick={() => dismissPopover()}>\n <Icon name='times' />\n </Button>\n </Flex>\n {content}\n <Flex container={{ justify: 'between' }}>\n <Button\n variant='secondary'\n disabled={disabled}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n secondaryAction.onClick?.(secondaryAction.id, e);\n dismissPopover(secondaryAction.id);\n }}\n >\n {secondaryAction.text}\n </Button>\n <Button\n variant='primary'\n disabled={disabled}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n primaryAction.onClick?.(primaryAction.id, e);\n dismissPopover(primaryAction.id);\n }}\n >\n {primaryAction.text}\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default ObjectConfig;\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O,EAAC,SAAS,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,CAAgC,EAAE,EAAE;4BAC5C,aAAa,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;4BAC7C,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;wBACnC,CAAC,YAEA,aAAa,CAAC,IAAI,GACZ,IACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { ReactNode, FC, Ref, MouseEvent } from 'react';\n\nimport { ForwardProps, Button, Flex, Icon, Action, Text, useI18n } from '@pega/cosmos-react-core';\n\nexport interface ObjectConfigProps {\n label: string;\n heading: string;\n primaryAction: Action;\n secondaryAction: Action;\n content?: ReactNode;\n onBeforeOpen?: () => void;\n onAfterClose?: (id?: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectConfig: FC<\n ObjectConfigProps & ForwardProps & { disabled?: boolean; dismissPopover: (id?: string) => void }\n> = ({ heading, content, primaryAction, secondaryAction, disabled, dismissPopover }) => {\n const t = useI18n();\n\n return (\n <Flex container={{ direction: 'column', pad: 2, gap: 2 }}>\n <Flex container={{ justify: 'between', alignItems: 'center' }}>\n <Text variant='h3'>{heading}</Text>\n <Button icon variant='simple' label={t('close')} onClick={() => dismissPopover()}>\n <Icon name='times' />\n </Button>\n </Flex>\n {content}\n <Flex container={{ justify: 'between' }}>\n <Button\n variant='secondary'\n disabled={disabled}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n secondaryAction.onClick?.(secondaryAction.id, e);\n dismissPopover(secondaryAction.id);\n }}\n >\n {secondaryAction.text}\n </Button>\n <Button\n variant='primary'\n disabled={disabled}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n primaryAction.onClick?.(primaryAction.id, e);\n dismissPopover(primaryAction.id);\n }}\n >\n {primaryAction.text}\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default ObjectConfig;\n"]}
@@ -19,7 +19,7 @@ const ObjectPicker = forwardRef(({ items, onSelect, ...restProps }, ref) => {
19
19
  items: itemsToRender,
20
20
  onItemClick: onSelect,
21
21
  accent: filterRegex
22
- } }, void 0));
22
+ } }));
23
23
  });
24
24
  export default ObjectPicker;
25
25
  //# sourceMappingURL=ObjectPicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAM,QAAQ,EAAE,OAAO,EAAoB,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,QAAQ,EACR,WAAW,EAIX,mBAAmB,EAGpB,MAAM,yBAAyB,CAAC;AAuBjC,MAAM,YAAY,GAAyC,UAAU,CACnE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,GAA6B,EAAE,EAAE;IACnE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE/E,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,MAAM,QAAQ,GAAG,WAAW;YAC1B,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAiB,EAAE,EAAE;gBAC/D,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC,CAAC;YACJ,CAAC,CAAC,KAAK,CAAC;QAEV,OAAO,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5C,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;SACnD,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,KAAC,QAAQ,OACH,SAAS,EACb,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,eAAe,EACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC9E,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,EAChC,IAAI,EAAE;YACJ,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,QAAQ;YACrB,MAAM,EAAE,WAAW;SACpB,WACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, FC, useState, useMemo, ChangeEvent, Ref } from 'react';\n\nimport {\n BaseProps,\n ComboBox,\n menuHelpers,\n ForwardProps,\n MenuProps,\n MenuItemProps,\n createStringMatcher,\n ComboBoxProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\ninterface ObjectPickerProps\n extends BaseProps,\n NoChildrenProp,\n Pick<\n ComboBoxProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'name'\n | 'status'\n | 'info'\n | 'placeholder'\n > {\n items: MenuProps['items'];\n onSelect: (id: MenuItemProps['id']) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectPicker: FC<ObjectPickerProps & ForwardProps> = forwardRef(\n ({ items, onSelect, ...restProps }, ref: ObjectPickerProps['ref']) => {\n const [filterValue, setFilterValue] = useState('');\n const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return filterRegex?.test(primary);\n })\n : items;\n\n return menuHelpers.mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }, [filterValue, items]);\n\n return (\n <ComboBox\n {...restProps}\n ref={ref}\n mode='single-select'\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setFilterValue(e.target.value)}\n onBlur={() => setFilterValue('')}\n menu={{\n items: itemsToRender,\n onItemClick: onSelect,\n accent: filterRegex\n }}\n />\n );\n }\n);\n\nexport default ObjectPicker;\n"]}
1
+ {"version":3,"file":"ObjectPicker.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAM,QAAQ,EAAE,OAAO,EAAoB,MAAM,OAAO,CAAC;AAE5E,OAAO,EAEL,QAAQ,EACR,WAAW,EAIX,mBAAmB,EAGpB,MAAM,yBAAyB,CAAC;AAuBjC,MAAM,YAAY,GAAyC,UAAU,CACnE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,GAA6B,EAAE,EAAE;IACnE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE/E,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,MAAM,QAAQ,GAAG,WAAW;YAC1B,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAiB,EAAE,EAAE;gBAC/D,OAAO,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC,CAAC;YACJ,CAAC,CAAC,KAAK,CAAC;QAEV,OAAO,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5C,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ;SACnD,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,KAAC,QAAQ,OACH,SAAS,EACb,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,eAAe,EACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC9E,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,EAChC,IAAI,EAAE;YACJ,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,QAAQ;YACrB,MAAM,EAAE,WAAW;SACpB,GACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, FC, useState, useMemo, ChangeEvent, Ref } from 'react';\n\nimport {\n BaseProps,\n ComboBox,\n menuHelpers,\n ForwardProps,\n MenuProps,\n MenuItemProps,\n createStringMatcher,\n ComboBoxProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\ninterface ObjectPickerProps\n extends BaseProps,\n NoChildrenProp,\n Pick<\n ComboBoxProps,\n | 'id'\n | 'label'\n | 'labelHidden'\n | 'required'\n | 'disabled'\n | 'readOnly'\n | 'name'\n | 'status'\n | 'info'\n | 'placeholder'\n > {\n items: MenuProps['items'];\n onSelect: (id: MenuItemProps['id']) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectPicker: FC<ObjectPickerProps & ForwardProps> = forwardRef(\n ({ items, onSelect, ...restProps }, ref: ObjectPickerProps['ref']) => {\n const [filterValue, setFilterValue] = useState('');\n const filterRegex = filterValue ? createStringMatcher(filterValue) : undefined;\n\n const itemsToRender = useMemo(() => {\n const newItems = filterValue\n ? menuHelpers.flatten(items).filter(({ primary }: MenuItemProps) => {\n return filterRegex?.test(primary);\n })\n : items;\n\n return menuHelpers.mapTree(newItems, item => ({\n ...item,\n selected: item.items ? undefined : !!item.selected\n }));\n }, [filterValue, items]);\n\n return (\n <ComboBox\n {...restProps}\n ref={ref}\n mode='single-select'\n value={filterValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => setFilterValue(e.target.value)}\n onBlur={() => setFilterValue('')}\n menu={{\n items: itemsToRender,\n onItemClick: onSelect,\n accent: filterRegex\n }}\n />\n );\n }\n);\n\nexport default ObjectPicker;\n"]}
@@ -14,7 +14,7 @@ const ObjectSelect = forwardRef(({ items, value, configuration, disabled, onChan
14
14
  : objectPickerRef.current?.querySelector('input');
15
15
  element?.focus();
16
16
  }, [value, disabled]);
17
- return (_jsx("div", { ref: ref, children: value ? (_jsx(ObjectSummary, { ...restProps, value: value, disabled: disabled, onDelete: () => onChange(''), ref: objectSummaryRef, configuration: configuration, onPreview: e => onPreview?.(value.id, e) }, void 0)) : (_jsx(ObjectPicker, { ...restProps, disabled: disabled, ref: objectPickerRef, items: items, onSelect: onChange }, void 0)) }, void 0));
17
+ return (_jsx("div", { ref: ref, children: value ? (_jsx(ObjectSummary, { ...restProps, value: value, disabled: disabled, onDelete: () => onChange(''), ref: objectSummaryRef, configuration: configuration, onPreview: e => onPreview?.(value.id, e) })) : (_jsx(ObjectPicker, { ...restProps, disabled: disabled, ref: objectPickerRef, items: items, onSelect: onChange })) }));
18
18
  });
19
19
  export default ObjectSelect;
20
20
  //# sourceMappingURL=ObjectSelect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAGL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AAQ,EAAE,QAAQ,WAClB,CACH,WACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, useRef } from 'react';\n\nimport {\n BaseProps,\n ForwardProps,\n useAfterInitialEffect,\n FormControlProps,\n MenuItemProps,\n NoChildrenProp,\n MenuProps\n} from '@pega/cosmos-react-core';\n\nimport ObjectPicker from './ObjectPicker';\nimport ObjectSummary, { ObjectSummaryProps } from './ObjectSummary';\n\nexport interface ObjectSelectProps\n extends BaseProps,\n NoChildrenProp,\n Omit<FormControlProps, 'value'> {\n /** An array of MenuItemProps to be shown in the ObjectPicker menu. */\n items: MenuProps['items'];\n /** The value for the ObjectSummary */\n value?: ObjectSummaryProps['value'];\n /** Props for configuration popover */\n configuration?: ObjectSummaryProps['configuration'];\n /** Callback fired when a new item is selected and on clearing the selected item. */\n onChange: (id: MenuItemProps['id']) => void;\n /** Callback fired when the preview in the ObjectSummary link is clicked. */\n onPreview?: (id: MenuItemProps['id'], e: { href: string }) => void;\n /** Ref placed on the element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectSelect: FunctionComponent<ObjectSelectProps & ForwardProps> = forwardRef(\n (\n { items, value, configuration, disabled, onChange, onPreview, ...restProps },\n ref: ObjectSelectProps['ref']\n ) => {\n const objectPickerRef = useRef<HTMLDivElement>(null);\n const objectSummaryRef = useRef<HTMLDivElement>(null);\n\n useAfterInitialEffect(() => {\n if (disabled) return;\n const element = value\n ? objectSummaryRef.current?.querySelector('a')\n : objectPickerRef.current?.querySelector('input');\n element?.focus();\n }, [value, disabled]);\n\n return (\n <div ref={ref}>\n {value ? (\n <ObjectSummary\n {...restProps}\n value={value}\n disabled={disabled}\n onDelete={() => onChange('')}\n ref={objectSummaryRef}\n configuration={configuration}\n onPreview={e => onPreview?.(value.id, e)}\n />\n ) : (\n <ObjectPicker\n {...restProps}\n disabled={disabled}\n ref={objectPickerRef}\n items={items}\n onSelect={onChange}\n />\n )}\n </div>\n );\n }\n);\n\nexport default ObjectSelect;\n"]}
1
+ {"version":3,"file":"ObjectSelect.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,EAGL,qBAAqB,EAKtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AAoBpE,MAAM,YAAY,GAAwD,UAAU,CAClF,CACE,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAC5E,GAA6B,EAC7B,EAAE;IACF,MAAM,eAAe,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACrD,MAAM,gBAAgB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEtD,qBAAqB,CAAC,GAAG,EAAE;QACzB,IAAI,QAAQ;YAAE,OAAO;QACrB,MAAM,OAAO,GAAG,KAAK;YACnB,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC;YAC9C,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtB,OAAO,CACL,cAAK,GAAG,EAAE,GAAG,YACV,KAAK,CAAC,CAAC,CAAC,CACP,KAAC,aAAa,OACR,SAAS,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAC5B,GAAG,EAAE,gBAAgB,EACrB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GACxC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,OACP,SAAS,EACb,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAClB,CACH,GACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, useRef } from 'react';\n\nimport {\n BaseProps,\n ForwardProps,\n useAfterInitialEffect,\n FormControlProps,\n MenuItemProps,\n NoChildrenProp,\n MenuProps\n} from '@pega/cosmos-react-core';\n\nimport ObjectPicker from './ObjectPicker';\nimport ObjectSummary, { ObjectSummaryProps } from './ObjectSummary';\n\nexport interface ObjectSelectProps\n extends BaseProps,\n NoChildrenProp,\n Omit<FormControlProps, 'value'> {\n /** An array of MenuItemProps to be shown in the ObjectPicker menu. */\n items: MenuProps['items'];\n /** The value for the ObjectSummary */\n value?: ObjectSummaryProps['value'];\n /** Props for configuration popover */\n configuration?: ObjectSummaryProps['configuration'];\n /** Callback fired when a new item is selected and on clearing the selected item. */\n onChange: (id: MenuItemProps['id']) => void;\n /** Callback fired when the preview in the ObjectSummary link is clicked. */\n onPreview?: (id: MenuItemProps['id'], e: { href: string }) => void;\n /** Ref placed on the element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nconst ObjectSelect: FunctionComponent<ObjectSelectProps & ForwardProps> = forwardRef(\n (\n { items, value, configuration, disabled, onChange, onPreview, ...restProps },\n ref: ObjectSelectProps['ref']\n ) => {\n const objectPickerRef = useRef<HTMLDivElement>(null);\n const objectSummaryRef = useRef<HTMLDivElement>(null);\n\n useAfterInitialEffect(() => {\n if (disabled) return;\n const element = value\n ? objectSummaryRef.current?.querySelector('a')\n : objectPickerRef.current?.querySelector('input');\n element?.focus();\n }, [value, disabled]);\n\n return (\n <div ref={ref}>\n {value ? (\n <ObjectSummary\n {...restProps}\n value={value}\n disabled={disabled}\n onDelete={() => onChange('')}\n ref={objectSummaryRef}\n configuration={configuration}\n onPreview={e => onPreview?.(value.id, e)}\n />\n ) : (\n <ObjectPicker\n {...restProps}\n disabled={disabled}\n ref={objectPickerRef}\n items={items}\n onSelect={onChange}\n />\n )}\n </div>\n );\n }\n);\n\nexport default ObjectSelect;\n"]}
@@ -65,7 +65,7 @@ const ObjectSummary = forwardRef(({ value, configuration, label, disabled, statu
65
65
  else
66
66
  buttonEl?.focus();
67
67
  }, [open, popoverEl]);
68
- return (_jsx(FormField, { ...restProps, ref: ref, label: label, status: status, children: _jsx(SummaryItem, { as: StyledObjectSummary, status: status, meta: value.meta, primary: _jsx(Link, { href: value.href, "aria-label": `${label} ${value.primary}`, previewable: true, target: '_blank', onPreview: onPreview, children: value.primary }, void 0), secondary: value.meta && _jsx(StyledMetaText, { variant: 'secondary', children: value.meta }, void 0), actions: _jsxs(_Fragment, { children: [configuration && (_jsx(Button, { ref: setButtonEl, label: configuration?.label, icon: true, variant: 'simple', onClick: openPopover, children: _jsx(Icon, { name: 'gear' }, void 0) }, void 0)), !readOnly && (_jsx(Button, { disabled: disabled, label: t('clear_object_summary', [String(label)]), icon: true, variant: 'simple', onClick: onDelete, children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)), _jsx(Popover, { ref: popoverRef, placement: rtl ? 'bottom-end' : 'bottom-start', hideOnTargetHidden: true, show: open, target: buttonEl, children: configuration && open && (_jsx(ObjectConfig, { ...configuration, disabled: disabled, dismissPopover: dismissPopover }, void 0)) }, void 0)] }, void 0) }, void 0) }, void 0));
68
+ return (_jsx(FormField, { ...restProps, ref: ref, label: label, status: status, children: _jsx(SummaryItem, { as: StyledObjectSummary, status: status, meta: value.meta, primary: _jsx(Link, { href: value.href, "aria-label": `${label} ${value.primary}`, previewable: true, target: '_blank', onPreview: onPreview, children: value.primary }), secondary: value.meta && _jsx(StyledMetaText, { variant: 'secondary', children: value.meta }), actions: _jsxs(_Fragment, { children: [configuration && (_jsx(Button, { ref: setButtonEl, label: configuration?.label, icon: true, variant: 'simple', onClick: openPopover, children: _jsx(Icon, { name: 'gear' }) })), !readOnly && (_jsx(Button, { disabled: disabled, label: t('clear_object_summary', [String(label)]), icon: true, variant: 'simple', onClick: onDelete, children: _jsx(Icon, { name: 'times' }) })), _jsx(Popover, { ref: popoverRef, placement: rtl ? 'bottom-end' : 'bottom-start', hideOnTargetHidden: true, show: open, target: buttonEl, children: configuration && open && (_jsx(ObjectConfig, { ...configuration, disabled: disabled, dismissPopover: dismissPopover })) })] }) }) }));
69
69
  });
70
70
  export default ObjectSummary;
71
71
  //# sourceMappingURL=ObjectSummary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectSummary.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSummary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAwB,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAEL,WAAW,EACX,IAAI,EACJ,MAAM,EACN,IAAI,EAEJ,iBAAiB,EACjB,SAAS,EAGT,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,8DAA8D,CAAC;AACtF,OAAO,KAAK,IAAI,MAAM,6DAA6D,CAAC;AAEpF,OAAO,YAAmC,MAAM,gBAAgB,CAAC;AAEjE,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAiB1B,MAAM,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAkB;aAC1D,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CA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ACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, forwardRef, Ref, PropsWithoutRef, useCallback, useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\nimport {\n BaseProps,\n SummaryItem,\n Link,\n Button,\n Icon,\n ForwardProps,\n StyledFormControl,\n FormField,\n FormControlProps,\n MenuItemProps,\n useI18n,\n registerIcon,\n Text,\n Popover,\n getFocusables,\n useAfterInitialEffect,\n useConsolidatedRef,\n useDirection,\n useElement\n} from '@pega/cosmos-react-core';\nimport * as times from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as gear from '@pega/cosmos-react-core/lib/components/Icon/icons/gear.icon';\n\nimport ObjectConfig, { ObjectConfigProps } from './ObjectConfig';\n\nregisterIcon(times, gear);\n\ninterface ObjectSummaryValueProps {\n id: MenuItemProps['id'];\n primary: MenuItemProps['primary'];\n href: string;\n meta?: string;\n}\n\nexport interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {\n value: ObjectSummaryValueProps;\n configuration?: ObjectConfigProps;\n onDelete: () => void;\n onPreview?: (e: { href: string }) => void;\n ref: Ref<HTMLDivElement>;\n}\n\nconst StyledObjectSummary = styled(StyledFormControl)<{ meta: string }>`\n padding: ${({ meta }) => (meta ? '0.5rem' : '0 0.5rem')};\n`;\n\nconst StyledMetaText = styled(Text)`\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n overflow: hidden;\n`;\n\nconst ObjectSummary: FC<PropsWithoutRef<ObjectSummaryProps> & ForwardProps> = forwardRef(\n (\n { value, configuration, label, disabled, status, readOnly, onDelete, onPreview, ...restProps },\n ref: ObjectSummaryProps['ref']\n ) => {\n const [open, setOpen] = useState(false);\n const [buttonEl, setButtonEl] = useElement<HTMLButtonElement>();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const popoverRef = useConsolidatedRef<HTMLDivElement>(configuration?.ref, setPopoverEl);\n const t = useI18n();\n const { rtl } = useDirection();\n\n const openPopover = () => {\n configuration?.onBeforeOpen?.();\n setOpen(true);\n };\n\n const dismissPopover = (id?: string) => {\n setOpen(false);\n configuration?.onAfterClose?.(id);\n };\n\n const onKeydown = useCallback(\n (e: KeyboardEvent) => {\n const { key } = e;\n if (key === 'Escape') {\n setOpen(false);\n } else if (key === 'Tab' && popoverEl) {\n const focusableContent = getFocusables(popoverRef);\n\n if (!focusableContent) return;\n\n const firstFocusableElement = focusableContent[0];\n const lastFocusableElement = focusableContent[focusableContent.length - 1];\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n }\n },\n [popoverEl]\n );\n\n useEffect(() => {\n popoverEl?.addEventListener('keydown', onKeydown);\n return () => {\n popoverEl?.removeEventListener('keydown', onKeydown);\n };\n }, [popoverEl]);\n\n useAfterInitialEffect(() => {\n if (open) popoverEl?.querySelector('button')?.focus();\n else buttonEl?.focus();\n }, [open, popoverEl]);\n\n return (\n <FormField {...restProps} ref={ref} label={label} status={status}>\n <SummaryItem\n as={StyledObjectSummary}\n status={status}\n meta={value.meta}\n primary={\n <Link\n href={value.href}\n aria-label={`${label} ${value.primary}`}\n previewable\n target='_blank'\n onPreview={onPreview}\n >\n {value.primary}\n </Link>\n }\n secondary={\n value.meta && <StyledMetaText variant='secondary'>{value.meta}</StyledMetaText>\n }\n actions={\n <>\n {configuration && (\n <Button\n ref={setButtonEl}\n label={configuration?.label}\n icon\n variant='simple'\n onClick={openPopover}\n >\n <Icon name='gear' />\n </Button>\n )}\n {!readOnly && (\n <Button\n disabled={disabled}\n label={t('clear_object_summary', [String(label)])}\n icon\n variant='simple'\n onClick={onDelete}\n >\n <Icon name='times' />\n </Button>\n )}\n <Popover\n ref={popoverRef}\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n show={open}\n target={buttonEl}\n >\n {configuration && open && (\n <ObjectConfig\n {...configuration}\n disabled={disabled}\n dismissPopover={dismissPopover}\n />\n )}\n </Popover>\n </>\n }\n />\n </FormField>\n );\n }\n);\n\nexport default ObjectSummary;\n"]}
1
+ {"version":3,"file":"ObjectSummary.js","sourceRoot":"","sources":["../../../src/components/ObjectSelect/ObjectSummary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAwB,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAEL,WAAW,EACX,IAAI,EACJ,MAAM,EACN,IAAI,EAEJ,iBAAiB,EACjB,SAAS,EAGT,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,8DAA8D,CAAC;AACtF,OAAO,KAAK,IAAI,MAAM,6DAA6D,CAAC;AAEpF,OAAO,YAAmC,MAAM,gBAAgB,CAAC;AAEjE,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAiB1B,MAAM,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAkB;aAC1D,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC;CACxD,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;CAKlC,CAAC;AAEF,MAAM,aAAa,GAA2D,UAAU,CACtF,CACE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,EAC9F,GAA8B,EAC9B,EAAE;IACF,MAAM,CAAC,IAAI,EAAE,OAAO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K,CAAC,IAAI,GAAkB,EAEjF,OAAO,EACL,8BACG,aAAa,IAAI,CAChB,KAAC,MAAM,IACL,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EAAE,KAAK,EAC3B,IAAI,QACJ,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,WAAW,YAEpB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,CACV,EACA,CAAC,QAAQ,IAAI,CACZ,KAAC,MAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,CAAC,CAAC,sBAAsB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EACjD,IAAI,QACJ,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,QAAQ,YAEjB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,CACV,EACD,KAAC,OAAO,IACN,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,EAC9C,kBAAkB,QAClB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,QAAQ,YAEf,aAAa,IAAI,IAAI,IAAI,CACxB,KAAC,YAAY,OACP,aAAa,EACjB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,GAC9B,CACH,GACO,IACT,GAEL,GACQ,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, forwardRef, Ref, PropsWithoutRef, useCallback, useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\nimport {\n BaseProps,\n SummaryItem,\n Link,\n Button,\n Icon,\n ForwardProps,\n StyledFormControl,\n FormField,\n FormControlProps,\n MenuItemProps,\n useI18n,\n registerIcon,\n Text,\n Popover,\n getFocusables,\n useAfterInitialEffect,\n useConsolidatedRef,\n useDirection,\n useElement\n} from '@pega/cosmos-react-core';\nimport * as times from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as gear from '@pega/cosmos-react-core/lib/components/Icon/icons/gear.icon';\n\nimport ObjectConfig, { ObjectConfigProps } from './ObjectConfig';\n\nregisterIcon(times, gear);\n\ninterface ObjectSummaryValueProps {\n id: MenuItemProps['id'];\n primary: MenuItemProps['primary'];\n href: string;\n meta?: string;\n}\n\nexport interface ObjectSummaryProps extends BaseProps, Omit<FormControlProps, 'value'> {\n value: ObjectSummaryValueProps;\n configuration?: ObjectConfigProps;\n onDelete: () => void;\n onPreview?: (e: { href: string }) => void;\n ref: Ref<HTMLDivElement>;\n}\n\nconst StyledObjectSummary = styled(StyledFormControl)<{ meta: string }>`\n padding: ${({ meta }) => (meta ? '0.5rem' : '0 0.5rem')};\n`;\n\nconst StyledMetaText = styled(Text)`\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n overflow: hidden;\n`;\n\nconst ObjectSummary: FC<PropsWithoutRef<ObjectSummaryProps> & ForwardProps> = forwardRef(\n (\n { value, configuration, label, disabled, status, readOnly, onDelete, onPreview, ...restProps },\n ref: ObjectSummaryProps['ref']\n ) => {\n const [open, setOpen] = useState(false);\n const [buttonEl, setButtonEl] = useElement<HTMLButtonElement>();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const popoverRef = useConsolidatedRef<HTMLDivElement>(configuration?.ref, setPopoverEl);\n const t = useI18n();\n const { rtl } = useDirection();\n\n const openPopover = () => {\n configuration?.onBeforeOpen?.();\n setOpen(true);\n };\n\n const dismissPopover = (id?: string) => {\n setOpen(false);\n configuration?.onAfterClose?.(id);\n };\n\n const onKeydown = useCallback(\n (e: KeyboardEvent) => {\n const { key } = e;\n if (key === 'Escape') {\n setOpen(false);\n } else if (key === 'Tab' && popoverEl) {\n const focusableContent = getFocusables(popoverRef);\n\n if (!focusableContent) return;\n\n const firstFocusableElement = focusableContent[0];\n const lastFocusableElement = focusableContent[focusableContent.length - 1];\n\n if (e.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n lastFocusableElement.focus();\n e.preventDefault();\n }\n } else if (document.activeElement === lastFocusableElement) {\n firstFocusableElement.focus();\n e.preventDefault();\n }\n }\n },\n [popoverEl]\n );\n\n useEffect(() => {\n popoverEl?.addEventListener('keydown', onKeydown);\n return () => {\n popoverEl?.removeEventListener('keydown', onKeydown);\n };\n }, [popoverEl]);\n\n useAfterInitialEffect(() => {\n if (open) popoverEl?.querySelector('button')?.focus();\n else buttonEl?.focus();\n }, [open, popoverEl]);\n\n return (\n <FormField {...restProps} ref={ref} label={label} status={status}>\n <SummaryItem\n as={StyledObjectSummary}\n status={status}\n meta={value.meta}\n primary={\n <Link\n href={value.href}\n aria-label={`${label} ${value.primary}`}\n previewable\n target='_blank'\n onPreview={onPreview}\n >\n {value.primary}\n </Link>\n }\n secondary={\n value.meta && <StyledMetaText variant='secondary'>{value.meta}</StyledMetaText>\n }\n actions={\n <>\n {configuration && (\n <Button\n ref={setButtonEl}\n label={configuration?.label}\n icon\n variant='simple'\n onClick={openPopover}\n >\n <Icon name='gear' />\n </Button>\n )}\n {!readOnly && (\n <Button\n disabled={disabled}\n label={t('clear_object_summary', [String(label)])}\n icon\n variant='simple'\n onClick={onDelete}\n >\n <Icon name='times' />\n </Button>\n )}\n <Popover\n ref={popoverRef}\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n show={open}\n target={buttonEl}\n >\n {configuration && open && (\n <ObjectConfig\n {...configuration}\n disabled={disabled}\n dismissPopover={dismissPopover}\n />\n )}\n </Popover>\n </>\n }\n />\n </FormField>\n );\n }\n);\n\nexport default ObjectSummary;\n"]}