@pega/cosmos-react-social 4.0.0-dev.22.0 → 4.0.0-dev.22.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FeedEditRegion.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedEditRegion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAgB,YAAY,EAAgC,MAAM,yBAAyB,CAAC;AAInG,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAQnD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,GAAG,mBAAmB,CA6E1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FeedEditRegion.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedEditRegion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA2C,MAAM,OAAO,CAAC;AAGpE,OAAO,EAAgB,YAAY,EAAgC,MAAM,yBAAyB,CAAC;AAInG,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AASnD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,GAAG,mBAAmB,CAgF1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,16 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from 'react';
2
+ import { useContext, useEffect, useRef, useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { Button, Flex, Icon, useI18n, useOuterEvent } from '@pega/cosmos-react-core';
5
5
  import FeedRichText from './FeedRichText';
6
6
  import { minInputHeight, StyledActions } from './FeedInputRegion';
7
7
  import FeedButton from './FeedButton';
8
+ import { FeedContext } from './Feed.context';
8
9
  const StyledInputContainer = styled.div `
9
10
  width: 100%;
10
11
  `;
11
12
  const FeedEditRegion = (props) => {
12
13
  const { variant, id, content, setEditMode, onEditSubmit, emptyEditText, setEmptyEditText } = props;
13
14
  const t = useI18n();
15
+ const { setShowSearchResults } = useContext(FeedContext);
14
16
  const rteRef = useRef();
15
17
  const editTextAreaRef = useRef(null);
16
18
  const [contentModified, setContentModified] = useState(false);
@@ -19,6 +21,7 @@ const FeedEditRegion = (props) => {
19
21
  setEditMode(false);
20
22
  });
21
23
  const handleEdit = () => {
24
+ setShowSearchResults?.(false);
22
25
  if (!emptyEditText && contentModified) {
23
26
  onEditSubmit?.({
24
27
  id,
@@ -28,6 +31,7 @@ const FeedEditRegion = (props) => {
28
31
  }
29
32
  };
30
33
  const onKeyDown = (event) => {
34
+ setShowSearchResults?.(true);
31
35
  if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
32
36
  handleEdit();
33
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FeedEditRegion.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedEditRegion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAgB,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGnG,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAEtC,CAAC;AAEF,MAAM,cAAc,GAA2C,CAC7D,KAAyC,EACzC,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,GACxF,KAAK,CAAC;IAER,MAAM,CAAC,GA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e,YACxC,KAAC,YAAY,IACX,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,GAAG,EAAE;wBACb,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;wBAC/D,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,CAAC,CAAC;oBACjE,CAAC,EACD,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,GAAG,EAAE,MAAM,GACX,GACmB,EACvB,MAAC,IAAI,IAAC,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,aACnE,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EACjC,IAAI,QACJ,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAElB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,EAET,KAAC,MAAM,IACL,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,aAAa,IAAI,CAAC,eAAe,EAC3C,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,UAAU,EACnB,IAAI,QACJ,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAElB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,IACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\n\nimport { Button, Flex, ForwardProps, Icon, useI18n, useOuterEvent } from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport FeedRichText from './FeedRichText';\nimport { FeedEditRegionProps } from './Feed.types';\nimport { minInputHeight, StyledActions } from './FeedInputRegion';\nimport FeedButton from './FeedButton';\n\nconst StyledInputContainer = styled.div`\n width: 100%;\n`;\n\nconst FeedEditRegion: FC<ForwardProps & FeedEditRegionProps> = (\n props: ForwardProps & FeedEditRegionProps\n) => {\n const { variant, id, content, setEditMode, onEditSubmit, emptyEditText, setEmptyEditText } =\n props;\n\n const t = useI18n();\n const rteRef = useRef<RichTextEditorState>();\n const editTextAreaRef = useRef<HTMLDivElement>(null);\n\n const [contentModified, setContentModified] = useState(false);\n\n useOuterEvent('mousedown', [editTextAreaRef], () => {\n if (emptyEditText) setEditMode(false);\n });\n\n const handleEdit = () => {\n if (!emptyEditText && contentModified) {\n onEditSubmit?.({\n id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') handleEdit();\n };\n\n useEffect(() => {\n if (rteRef.current) {\n rteRef.current?.focus();\n }\n }, [rteRef]);\n\n const label = t(variant === 'post' ? 'feed_edit_post' : 'feed_edit_comment');\n\n return (\n <Flex container={{ gap: 1, alignItems: 'start' }}>\n <StyledInputContainer ref={editTextAreaRef}>\n <FeedRichText\n label={label}\n onChange={() => {\n setEmptyEditText(rteRef.current?.getPlainText().trim() === '');\n setContentModified(rteRef.current?.getPlainText() !== content);\n }}\n onKeyDown={onKeyDown}\n height={{ min: minInputHeight }}\n defaultValue={content}\n ref={rteRef}\n />\n </StyledInputContainer>\n <Flex as={StyledActions} container={{ direction: 'column', gap: 0.5 }}>\n <Button\n variant='simple'\n as={FeedButton}\n onClick={() => setEditMode(false)}\n icon\n label={t('cancel')}\n >\n <Icon name='times' />\n </Button>\n\n <Button\n as={FeedButton}\n disabled={emptyEditText || !contentModified}\n variant='simple'\n onClick={handleEdit}\n icon\n label={t('update')}\n >\n <Icon name='send' />\n </Button>\n </Flex>\n </Flex>\n );\n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AAE,SAAS,EACpB,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,GAAG,EAAE,MAAM,GACX,GACmB,EACvB,MAAC,IAAI,IAAC,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,aACnE,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EACjC,IAAI,QACJ,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAElB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,EAET,KAAC,MAAM,IACL,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,aAAa,IAAI,CAAC,eAAe,EAC3C,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,UAAU,EACnB,IAAI,QACJ,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAElB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,IACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FC, useContext, useEffect, useRef, useState } from 'react';\nimport styled from 'styled-components';\n\nimport { Button, Flex, ForwardProps, Icon, useI18n, useOuterEvent } from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport FeedRichText from './FeedRichText';\nimport { FeedEditRegionProps } from './Feed.types';\nimport { minInputHeight, StyledActions } from './FeedInputRegion';\nimport FeedButton from './FeedButton';\nimport { FeedContext } from './Feed.context';\n\nconst StyledInputContainer = styled.div`\n width: 100%;\n`;\n\nconst FeedEditRegion: FC<ForwardProps & FeedEditRegionProps> = (\n props: ForwardProps & FeedEditRegionProps\n) => {\n const { variant, id, content, setEditMode, onEditSubmit, emptyEditText, setEmptyEditText } =\n props;\n\n const t = useI18n();\n const { setShowSearchResults } = useContext(FeedContext);\n const rteRef = useRef<RichTextEditorState>();\n const editTextAreaRef = useRef<HTMLDivElement>(null);\n\n const [contentModified, setContentModified] = useState(false);\n\n useOuterEvent('mousedown', [editTextAreaRef], () => {\n if (emptyEditText) setEditMode(false);\n });\n\n const handleEdit = () => {\n setShowSearchResults?.(false);\n if (!emptyEditText && contentModified) {\n onEditSubmit?.({\n id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n setShowSearchResults?.(true);\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') handleEdit();\n };\n\n useEffect(() => {\n if (rteRef.current) {\n rteRef.current?.focus();\n }\n }, [rteRef]);\n\n const label = t(variant === 'post' ? 'feed_edit_post' : 'feed_edit_comment');\n\n return (\n <Flex container={{ gap: 1, alignItems: 'start' }}>\n <StyledInputContainer ref={editTextAreaRef}>\n <FeedRichText\n label={label}\n onChange={() => {\n setEmptyEditText(rteRef.current?.getPlainText().trim() === '');\n setContentModified(rteRef.current?.getPlainText() !== content);\n }}\n onKeyDown={onKeyDown}\n height={{ min: minInputHeight }}\n defaultValue={content}\n ref={rteRef}\n />\n </StyledInputContainer>\n <Flex as={StyledActions} container={{ direction: 'column', gap: 0.5 }}>\n <Button\n variant='simple'\n as={FeedButton}\n onClick={() => setEditMode(false)}\n icon\n label={t('cancel')}\n >\n <Icon name='times' />\n </Button>\n\n <Button\n as={FeedButton}\n disabled={emptyEditText || !contentModified}\n variant='simple'\n onClick={handleEdit}\n icon\n label={t('update')}\n >\n <Icon name='send' />\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default FeedEditRegion;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/cosmos-react-social",
3
- "version": "4.0.0-dev.22.0",
3
+ "version": "4.0.0-dev.22.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/pegasystems/cosmos-react.git",
@@ -23,9 +23,9 @@
23
23
  "build": "tsc -b"
24
24
  },
25
25
  "dependencies": {
26
- "@pega/cosmos-react-core": "4.0.0-dev.22.0",
27
- "@pega/cosmos-react-rte": "4.0.0-dev.22.0",
28
- "@pega/cosmos-react-work": "4.0.0-dev.22.0",
26
+ "@pega/cosmos-react-core": "4.0.0-dev.22.2",
27
+ "@pega/cosmos-react-rte": "4.0.0-dev.22.2",
28
+ "@pega/cosmos-react-work": "4.0.0-dev.22.2",
29
29
  "@types/parse5": "^6.0.0",
30
30
  "@types/react": "^16.14.24 || ^17.0.38",
31
31
  "@types/react-dom": "^16.9.14 || ^17.0.11",