frst-components 0.22.22 → 0.22.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3422,7 +3422,6 @@ const LimitCharsExceededMessage = styled__default["default"].span `
3422
3422
  // transform: scale(0.845);
3423
3423
 
3424
3424
  const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onContentUnformat, onChange, value, replyMentionedUser }) => {
3425
- const [focus, setFocus] = React.useState(false);
3426
3425
  const [showMention, setShowMention] = React.useState(false);
3427
3426
  const [inputSearch, setInputSearch] = React.useState('');
3428
3427
  const divInputRef = React.useRef(null);
@@ -3591,15 +3590,23 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
3591
3590
  //if divInputRef is not focused
3592
3591
  const isFocused = divInputRef.current === document.activeElement;
3593
3592
  if (divInputRef.current && !isFocused) {
3593
+ if (divInputRef.current.childNodes.length <= 0)
3594
+ return true;
3594
3595
  divInputRef.current.childNodes.forEach((child) => {
3595
3596
  if (child.textContent.length <= 0) {
3596
3597
  isEmpty = true;
3597
3598
  }
3599
+ else {
3600
+ isEmpty = false;
3601
+ return false;
3602
+ }
3598
3603
  });
3599
3604
  }
3600
3605
  return isEmpty;
3601
3606
  };
3602
3607
  const handlePlaceholderInputText = (isPlaceHolderFocus = false) => {
3608
+ if (document.activeElement?.id === 'input-comment-component')
3609
+ return;
3603
3610
  // if divInputRef has any element hide the placeholder
3604
3611
  if (isPlaceHolderFocus) {
3605
3612
  divPlaceholder.current?.style.setProperty('display', 'none');
@@ -3722,7 +3729,10 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
3722
3729
  React.useEffect(() => {
3723
3730
  if (replyMentionedUser)
3724
3731
  return;
3725
- if (!value || value.length <= 0 && document.activeElement !== divInputRef.current) {
3732
+ // check if the cursor is inside the divInputRef
3733
+ const isFocused = divInputRef.current === document.activeElement;
3734
+ // if the cursor is not inside the divInputRef show the placeholder
3735
+ if ((!value || value.length <= 0) && document.activeElement?.id !== 'input-comment-component' && !isFocused) {
3726
3736
  divPlaceholder.current?.style.setProperty('display', 'block');
3727
3737
  divInputRef.current.style.setProperty('display', 'none');
3728
3738
  divInputRef.current.innerHTML = '<p><br /></p>';
@@ -3733,7 +3743,6 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
3733
3743
  return {
3734
3744
  handleInput,
3735
3745
  handlePlaceholderInputText,
3736
- focus,
3737
3746
  showMention,
3738
3747
  setShowMention,
3739
3748
  inputSearch,
@@ -3925,7 +3934,7 @@ const Mentions = (mention) => {
3925
3934
 
3926
3935
  function InputComment$1({ placeholder, onChange, limit, users, showCharacterCounter, styles, onSendMentions, onContentFormat, onContentUnformat, disabled, className, value, replyMentionedUser, group_uuid, limitMessageExceeded }) {
3927
3936
  const { divPlaceholder, handleInput, isPlaceholder, divInputRef, handleMentionUser, mentionTopPosition, setShowMention, showMention, textLength, styleLimitExceeded } = useInputHook({ limit, placeholder, onContentFormat, onContentUnformat, onSendMentions, onChange, value, replyMentionedUser });
3928
- return (jsxRuntime.jsx(styled.ThemeProvider, { theme: FRSTTheme, children: jsxRuntime.jsxs("div", { style: { minHeight: '48px', ...styles }, tabIndex: 0, children: [jsxRuntime.jsxs(InputWrapper$2, { tabIndex: 1, isPlaceholder: isPlaceholder, isInputLimit: styleLimitExceeded, children: [jsxRuntime.jsx(InputText$4, { tabIndex: 2, contentEditable: true, ref: divInputRef, onKeyUpCapture: (event) => {
3937
+ return (jsxRuntime.jsx(styled.ThemeProvider, { theme: FRSTTheme, children: jsxRuntime.jsxs("div", { style: { minHeight: '48px', ...styles }, tabIndex: 0, children: [jsxRuntime.jsxs(InputWrapper$2, { tabIndex: 1, isPlaceholder: isPlaceholder, isInputLimit: styleLimitExceeded, children: [jsxRuntime.jsx(InputText$4, { id: "input-comment-component", tabIndex: 2, contentEditable: true, ref: divInputRef, onKeyUpCapture: (event) => {
3929
3938
  handleInput(event);
3930
3939
  }, "data-text": "enter", suppressContentEditableWarning: true, children: jsxRuntime.jsx("p", { children: jsxRuntime.jsx("br", {}) }) }), jsxRuntime.jsx(InputPlaceholder, { style: { display: 'none' }, contentEditable: true, ref: divPlaceholder, children: placeholder }), showMention && users && users.length > 0 && jsxRuntime.jsx(Mentions, { users: users, top: mentionTopPosition, onSelect: (user) => {
3931
3940
  setShowMention(false);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/index.tsx"],"names":[],"mappings":";AACA,OAAO,yBAAyB,CAAA;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAOvC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,oBAAoB,EAAE,EAAE,aAAa,eAwD9P"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/index.tsx"],"names":[],"mappings":";AACA,OAAO,yBAAyB,CAAA;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAOvC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,oBAAoB,EAAE,EAAE,aAAa,eAyD9P"}
@@ -13,7 +13,6 @@ interface IInputHook {
13
13
  export declare const useInputHook: ({ limit, placeholder, onSendMentions, onContentFormat, onContentUnformat, onChange, value, replyMentionedUser }: IInputHook) => {
14
14
  handleInput: (event: React.KeyboardEvent) => void;
15
15
  handlePlaceholderInputText: (isPlaceHolderFocus?: boolean) => void;
16
- focus: boolean;
17
16
  showMention: boolean;
18
17
  setShowMention: React.Dispatch<React.SetStateAction<boolean>>;
19
18
  inputSearch: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useInputHook.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/useInputHook.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC5C,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAC5B;AAED,eAAO,MAAM,YAAY,oHAAqH,UAAU;yBA4HxH,mBAAmB;sDA+EQ,OAAO;;;;;;;;8BA9J7B,IAAI;;;;;CA4UxC,CAAA"}
1
+ {"version":3,"file":"useInputHook.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/useInputHook.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC5C,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,IAAI,CAAA;CAC5B;AAED,eAAO,MAAM,YAAY,oHAAqH,UAAU;yBA2HxH,mBAAmB;sDAkFQ,OAAO;;;;;;;8BAjK7B,IAAI;;;;;CAqVxC,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "frst-components",
3
3
  "homepage": "http://FRST-Falconi.github.io/storybook.frstfalconi.com",
4
- "version": "0.22.22",
4
+ "version": "0.22.24",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",