frst-components 0.22.8 → 0.22.9
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 +38 -8
- package/dist/src/components/input-comment/index.d.ts.map +1 -1
- package/dist/src/components/input-comment/mentionsStyle.d.ts.map +1 -1
- package/dist/src/components/input-comment/useInputHook.d.ts +0 -1
- package/dist/src/components/input-comment/useInputHook.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3564,6 +3564,7 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3564
3564
|
const clearDivContent = () => {
|
|
3565
3565
|
if (!divInputRef.current)
|
|
3566
3566
|
return;
|
|
3567
|
+
console.log('focus is', focus);
|
|
3567
3568
|
if ((divInputRef.current.childNodes.length === 0 && !focus)) {
|
|
3568
3569
|
// create a textnode with the placeholder
|
|
3569
3570
|
divInputRef.current.innerText = placeholder;
|
|
@@ -3627,22 +3628,51 @@ const useInputHook = ({ limit, placeholder, onSendMentions, onContentFormat, onC
|
|
|
3627
3628
|
React.useEffect(() => {
|
|
3628
3629
|
if (!divInputRef.current)
|
|
3629
3630
|
return;
|
|
3631
|
+
clearDivContent();
|
|
3632
|
+
}, [focus]);
|
|
3633
|
+
React.useEffect(() => {
|
|
3634
|
+
setStyleLimitExceeded(textLength > limit);
|
|
3635
|
+
}, [textLength]);
|
|
3636
|
+
React.useEffect(() => {
|
|
3637
|
+
if (!divInputRef.current)
|
|
3638
|
+
return;
|
|
3639
|
+
divInputRef.current.addEventListener('mousedown', () => {
|
|
3640
|
+
setFocus(true);
|
|
3641
|
+
});
|
|
3642
|
+
divInputRef.current.addEventListener('focus', () => {
|
|
3643
|
+
setFocus(true);
|
|
3644
|
+
});
|
|
3645
|
+
divInputRef.current.addEventListener('blur', () => {
|
|
3646
|
+
setFocus(false);
|
|
3647
|
+
});
|
|
3630
3648
|
//capture the cursor position on arrow up and down or left and right and check if it´s close to the @ key
|
|
3631
3649
|
divInputRef.current.addEventListener('keyup', (event) => {
|
|
3632
3650
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'Enter') {
|
|
3633
3651
|
setShowMention(false);
|
|
3634
3652
|
}
|
|
3635
3653
|
});
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3654
|
+
return () => {
|
|
3655
|
+
divInputRef.current?.removeEventListener('mousedown', () => {
|
|
3656
|
+
setFocus(true);
|
|
3657
|
+
});
|
|
3658
|
+
divInputRef.current?.removeEventListener('focus', () => {
|
|
3659
|
+
setFocus(true);
|
|
3660
|
+
});
|
|
3661
|
+
divInputRef.current?.removeEventListener('blur', () => {
|
|
3662
|
+
setFocus(false);
|
|
3663
|
+
});
|
|
3664
|
+
//capture the cursor position on arrow up and down or left and right and check if it´s close to the @ key
|
|
3665
|
+
divInputRef.current.removeEventListener('keyup', (event) => {
|
|
3666
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'ArrowLeft' || event.key === 'ArrowRight' || event.key === 'Enter') {
|
|
3667
|
+
setShowMention(false);
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
};
|
|
3671
|
+
}, []);
|
|
3641
3672
|
return {
|
|
3642
3673
|
handleInput,
|
|
3643
3674
|
clearDivContent,
|
|
3644
3675
|
focus,
|
|
3645
|
-
setFocus,
|
|
3646
3676
|
showMention,
|
|
3647
3677
|
setShowMention,
|
|
3648
3678
|
inputSearch,
|
|
@@ -3832,9 +3862,9 @@ const Mentions = (mention) => {
|
|
|
3832
3862
|
};
|
|
3833
3863
|
|
|
3834
3864
|
function InputComment$1({ placeholder, onChange, limit, users, showCharacterCounter, styles, onSendMentions, onContentFormat, onContentUnformat, disabled, className, value, replyMentionedUser, group_uuid, limitMessageExceeded }) {
|
|
3835
|
-
const { handleInput, isPlaceholder, focus,
|
|
3865
|
+
const { handleInput, isPlaceholder, focus, divInputRef, handleMentionUser, mentionTopPosition, setShowMention, showMention, textLength, styleLimitExceeded } = useInputHook({ limit, placeholder, onContentFormat, onContentUnformat, onSendMentions, onChange, value, replyMentionedUser });
|
|
3836
3866
|
const showMentions = showMention && ['b1005836-b0a6-4a50-8147-537ebdc64a75', '413c2f36-9195-4fef-86fe-572c49049007'].includes(group_uuid);
|
|
3837
|
-
return (jsxRuntime.jsx(styled.ThemeProvider, { theme: FRSTTheme, children: jsxRuntime.jsxs("div", { style: { minHeight: '48px', ...styles }, tabIndex: 0, children: [jsxRuntime.jsxs(InputWrapper$2, { focus: focus, tabIndex: 1, isPlaceholder: isPlaceholder, isInputLimit: styleLimitExceeded, children: [jsxRuntime.jsx(InputText$4, { tabIndex: 2, contentEditable: true, ref: divInputRef,
|
|
3867
|
+
return (jsxRuntime.jsx(styled.ThemeProvider, { theme: FRSTTheme, children: jsxRuntime.jsxs("div", { style: { minHeight: '48px', ...styles }, tabIndex: 0, children: [jsxRuntime.jsxs(InputWrapper$2, { focus: focus, tabIndex: 1, isPlaceholder: isPlaceholder, isInputLimit: styleLimitExceeded, children: [jsxRuntime.jsx(InputText$4, { tabIndex: 2, contentEditable: true, ref: divInputRef, onKeyUpCapture: (event) => {
|
|
3838
3868
|
handleInput(event);
|
|
3839
3869
|
}, "data-text": "enter", isPlaceholder: isPlaceholder, suppressContentEditableWarning: true, children: jsxRuntime.jsx("p", { children: jsxRuntime.jsx("br", {}) }) }), showMentions && users && users.length > 0 && jsxRuntime.jsx(Mentions, { users: users, top: mentionTopPosition, onSelect: (user) => {
|
|
3840
3870
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentionsStyle.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/mentionsStyle.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;UAAsB,OAAO;SAAO,MAAM;YAAU,MAAM;aAAW,MAAM;
|
|
1
|
+
{"version":3,"file":"mentionsStyle.d.ts","sourceRoot":"","sources":["../../../../src/components/input-comment/mentionsStyle.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;UAAsB,OAAO;SAAO,MAAM;YAAU,MAAM;aAAW,MAAM;SAkChG,CAAA;AAED,eAAO,MAAM,YAAY,sEAAiB,CAAA;AAE1C,eAAO,MAAM,WAAW,oEAKvB,CAAA;AAED,eAAO,MAAM,WAAW;aAAyB,OAAO;SAkBvD,CAAA;AAGD,eAAO,MAAM,aAAa,oEAIzB,CAAA;AAED,eAAO,MAAM,aAAa,oEAIzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,oEAQhC,CAAA;AAED,eAAO,MAAM,eAAe,qEAI3B,CAAA;AAED,eAAO,MAAM,wBAAwB,oEAOpC,CAAA;AAED,eAAO,MAAM,mBAAmB,qEAM/B,CAAA;AACD,eAAO,MAAM,MAAM,oEAQlB,CAAA;AACD,eAAO,MAAM,WAAW,qEAYvB,CAAA"}
|
|
@@ -14,7 +14,6 @@ export declare const useInputHook: ({ limit, placeholder, onSendMentions, onCont
|
|
|
14
14
|
handleInput: (event: React.KeyboardEvent) => void;
|
|
15
15
|
clearDivContent: () => void;
|
|
16
16
|
focus: boolean;
|
|
17
|
-
setFocus: React.Dispatch<React.SetStateAction<boolean>>;
|
|
18
17
|
showMention: boolean;
|
|
19
18
|
setShowMention: React.Dispatch<React.SetStateAction<boolean>>;
|
|
20
19
|
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;yBA2HxH,mBAAmB
|
|
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;;;;;;;;;8BA/Ed,IAAI;;;;CA6RxC,CAAA"}
|