vaishu-react-comp 1.1.7 → 1.1.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/lib/components/ScriptCommentModal/ScriptCommentModal.js +18 -20
- package/lib/components/ScriptCommentModal/ScriptCommentModal.js.map +1 -1
- package/lib/components/ScriptCommentModal/components/FooterText.js +39 -1
- package/lib/components/ScriptCommentModal/components/FooterText.js.map +1 -1
- package/lib/components/ScriptCommentModal/type.d.ts +10 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
|
@@ -4,26 +4,34 @@ import MiniModal from '../MiniModal';
|
|
|
4
4
|
import CommentsTitle from './components/CommentsTitle';
|
|
5
5
|
import CommentDescription from './components/CommentDiscription';
|
|
6
6
|
import './ScriptCommentModal.scss';
|
|
7
|
-
const ScriptCommentModal = ({ anchorRef, isOpen, onClose, targetRef, }) => {
|
|
8
|
-
const [comment, setComment] = useState(
|
|
9
|
-
const [isEditMode, setIsEditMode] = useState(
|
|
7
|
+
const ScriptCommentModal = ({ anchorRef, isOpen, onClose, targetRef, comment: initialComment = '', modifiedBy, modifiedOn, loading = false, onSave, onDelete, }) => {
|
|
8
|
+
const [comment, setComment] = useState(initialComment);
|
|
9
|
+
const [isEditMode, setIsEditMode] = useState(!initialComment);
|
|
10
10
|
const popUpRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setComment(initialComment);
|
|
13
|
+
setIsEditMode(!initialComment);
|
|
14
|
+
}, [initialComment]);
|
|
11
15
|
const handleSave = () => {
|
|
12
|
-
|
|
16
|
+
if (!comment.trim())
|
|
17
|
+
return;
|
|
18
|
+
onSave?.(comment);
|
|
13
19
|
setIsEditMode(false);
|
|
14
20
|
};
|
|
15
21
|
const handleUpdate = () => {
|
|
16
|
-
|
|
22
|
+
if (!comment.trim())
|
|
23
|
+
return;
|
|
24
|
+
onSave?.(comment);
|
|
17
25
|
setIsEditMode(false);
|
|
18
26
|
};
|
|
19
27
|
const handleCancel = () => {
|
|
20
28
|
setIsEditMode(false);
|
|
29
|
+
setComment(initialComment);
|
|
21
30
|
onClose();
|
|
22
31
|
};
|
|
23
32
|
const handleDelete = () => {
|
|
24
|
-
|
|
33
|
+
onDelete?.();
|
|
25
34
|
};
|
|
26
|
-
console.log('hiii');
|
|
27
35
|
useEffect(() => {
|
|
28
36
|
if (!targetRef)
|
|
29
37
|
return;
|
|
@@ -32,27 +40,17 @@ const ScriptCommentModal = ({ anchorRef, isOpen, onClose, targetRef, }) => {
|
|
|
32
40
|
: targetRef.current;
|
|
33
41
|
if (!targetElement)
|
|
34
42
|
return;
|
|
35
|
-
// Keep all step action icons visible
|
|
36
43
|
targetElement.classList.add('menu-hover-active');
|
|
37
44
|
return () => {
|
|
38
45
|
targetElement.classList.remove('menu-hover-active');
|
|
39
46
|
};
|
|
40
47
|
}, [targetRef]);
|
|
41
|
-
return (_jsx(MiniModal, { anchorRef: anchorRef, ignoreRefs: [popUpRef, anchorRef],
|
|
42
|
-
// firstAnchorRef={anchorRef}
|
|
43
|
-
outSideClick: onClose, isIconModel: isOpen, modalProperties: {
|
|
48
|
+
return (_jsx(MiniModal, { anchorRef: anchorRef, ignoreRefs: [popUpRef, anchorRef], isIconModel: isOpen, modalProperties: {
|
|
44
49
|
width: 350,
|
|
45
50
|
borderRadius: 8,
|
|
46
51
|
zIndex: 2000,
|
|
47
52
|
padding: 4,
|
|
48
|
-
},
|
|
49
|
-
// wrapperProperties={{
|
|
50
|
-
// zIndex: 1500,
|
|
51
|
-
// width: 34,
|
|
52
|
-
// }}
|
|
53
|
-
// isWrapped
|
|
54
|
-
// anchorRefLeftNum={165}
|
|
55
|
-
modalPosition: "bottom", isPopOver: true, arrowZIndex: 2001, arrowProperties: {
|
|
53
|
+
}, modalPosition: "bottom", isPopOver: true, arrowZIndex: 2001, arrowProperties: {
|
|
56
54
|
left: 36,
|
|
57
55
|
size: 8,
|
|
58
56
|
top: -12,
|
|
@@ -60,7 +58,7 @@ const ScriptCommentModal = ({ anchorRef, isOpen, onClose, targetRef, }) => {
|
|
|
60
58
|
isOverlay: true,
|
|
61
59
|
backgroundColorOverlay: 'rgba(0, 0, 0, 0.2)',
|
|
62
60
|
zIndexOverlay: 1999,
|
|
63
|
-
}, childContent: _jsxs("div", { ref: popUpRef, className: "ff-main-container", children: [_jsx(CommentsTitle, { ref: popUpRef, isEditMode: isEditMode, onEdit: () => setIsEditMode(true), onDelete: handleDelete, onClose: onClose }), _jsx(CommentDescription, { comment: comment, setComment: setComment, isEditMode: isEditMode, onCancel: handleCancel, onSave: isEditMode ? handleUpdate : handleSave })] }) }));
|
|
61
|
+
}, childContent: _jsxs("div", { ref: popUpRef, className: "ff-main-container", children: [_jsx(CommentsTitle, { ref: popUpRef, isEditMode: isEditMode, onEdit: () => setIsEditMode(true), onDelete: handleDelete, onClose: onClose, modifiedBy: modifiedBy, modifiedOn: modifiedOn }), _jsx(CommentDescription, { comment: comment, setComment: setComment, isEditMode: isEditMode, loading: loading, onCancel: handleCancel, onSave: isEditMode ? handleUpdate : handleSave })] }) }));
|
|
64
62
|
};
|
|
65
63
|
export default ScriptCommentModal;
|
|
66
64
|
//# sourceMappingURL=ScriptCommentModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptCommentModal.js","sourceRoot":"","sources":["../../../src/components/ScriptCommentModal/ScriptCommentModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,kBAAkB,MAAM,iCAAiC,CAAC;AAEjE,OAAO,2BAA2B,CAAC;AAEnC,MAAM,kBAAkB,GAA0B,CAAC,EACjD,SAAS,EACT,MAAM,EACN,OAAO,EACP,SAAS,
|
|
1
|
+
{"version":3,"file":"ScriptCommentModal.js","sour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G,EAAE,QAAQ,EAAE,SAAS,EAAC,mBAAmB,aAC/C,KAAC,aAAa,IACZ,GAAG,EAAE,QAAQ,EACb,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EACjC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB,EAEF,KAAC,kBAAkB,IACjB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,GAC9C,IACE,GAER,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Typography from '../../Typography';
|
|
3
3
|
const FooterText = ({ modifiedBy, modifiedOn }) => {
|
|
4
|
-
|
|
4
|
+
const getRelativeTime = (dateString) => {
|
|
5
|
+
if (!dateString)
|
|
6
|
+
return '';
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const date = new Date(dateString);
|
|
9
|
+
const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
10
|
+
// Future date or invalid date
|
|
11
|
+
if (isNaN(diffInSeconds) || diffInSeconds < 0) {
|
|
12
|
+
return 'Just now';
|
|
13
|
+
}
|
|
14
|
+
// Less than 1 minute
|
|
15
|
+
if (diffInSeconds < 60) {
|
|
16
|
+
return 'Just now';
|
|
17
|
+
}
|
|
18
|
+
const diffInMinutes = Math.floor(diffInSeconds / 60);
|
|
19
|
+
// Minutes
|
|
20
|
+
if (diffInMinutes < 60) {
|
|
21
|
+
return `${diffInMinutes} ${diffInMinutes === 1 ? 'Min' : 'Mins'} Ago`;
|
|
22
|
+
}
|
|
23
|
+
const diffInHours = Math.floor(diffInMinutes / 60);
|
|
24
|
+
// Hours
|
|
25
|
+
if (diffInHours < 24) {
|
|
26
|
+
return `${diffInHours} ${diffInHours === 1 ? 'Hour' : 'Hours'} Ago`;
|
|
27
|
+
}
|
|
28
|
+
const diffInDays = Math.floor(diffInHours / 24);
|
|
29
|
+
// Days
|
|
30
|
+
if (diffInDays < 30) {
|
|
31
|
+
return `${diffInDays} ${diffInDays === 1 ? 'Day' : 'Days'} Ago`;
|
|
32
|
+
}
|
|
33
|
+
const diffInMonths = Math.floor(diffInDays / 30);
|
|
34
|
+
// Months
|
|
35
|
+
if (diffInMonths < 12) {
|
|
36
|
+
return `${diffInMonths} ${diffInMonths === 1 ? 'Month' : 'Months'} Ago`;
|
|
37
|
+
}
|
|
38
|
+
const diffInYears = Math.floor(diffInDays / 365);
|
|
39
|
+
// Years
|
|
40
|
+
return `${diffInYears} ${diffInYears === 1 ? 'Year' : 'Years'} Ago`;
|
|
41
|
+
};
|
|
42
|
+
return (_jsxs("div", { className: "ff-button-actions-container", children: [_jsx(Typography, { children: modifiedBy }), _jsx(Typography, { children: getRelativeTime(modifiedOn) })] }));
|
|
5
43
|
};
|
|
6
44
|
export default FooterText;
|
|
7
45
|
//# sourceMappingURL=FooterText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FooterText.js","sourceRoot":"","sources":["../../../../src/components/ScriptCommentModal/components/FooterText.tsx"],"names":[],"mappings":";AAEA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAM1C,MAAM,UAAU,GAAwB,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE;IACrE,OAAO,CACL,eAAK,SAAS,EAAC,6BAA6B,aAC1C,KAAC,UAAU,cAAE,UAAU,GAAc,EAErC,KAAC,UAAU,cAAE,
|
|
1
|
+
{"version":3,"file":"FooterText.js","sourceRoot":"","sources":["../../../../src/components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UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC;QAEhD,OAAO;QACP,IAAI,UAAU,GAAG,EAAE,EAAE,CAAC;YACpB,OAAO,GAAG,UAAU,IAAI,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC;QAClE,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC;QAEjD,SAAS;QACT,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;YACtB,OAAO,GAAG,YAAY,IAAI,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC;QAC1E,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC;QAEjD,QAAQ;QACR,OAAO,GAAG,WAAW,IAAI,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC;IACtE,CAAC,CAAC;IACF,OAAO,CACL,eAAK,SAAS,EAAC,6BAA6B,aAC1C,KAAC,UAAU,cAAE,UAAU,GAAc,EAErC,KAAC,UAAU,cAAE,eAAe,CAAC,UAA6B,CAAC,GAAc,IACrE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -4,12 +4,21 @@ export interface ScriptCommentprop {
|
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
targetRef?: RefObject<HTMLElement>;
|
|
7
|
+
comment?: string;
|
|
8
|
+
modifiedBy?: string;
|
|
9
|
+
modifiedOn?: string;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
onSave?: (comment: string) => void;
|
|
12
|
+
onDelete?: () => void;
|
|
7
13
|
}
|
|
8
14
|
export interface CommentsTitleProps {
|
|
15
|
+
modifiedBy?: string;
|
|
16
|
+
modifiedOn?: string;
|
|
9
17
|
isEditMode: boolean;
|
|
10
18
|
onEdit: () => void;
|
|
11
19
|
onDelete: () => void;
|
|
12
20
|
onClose: () => void;
|
|
21
|
+
loading?: boolean;
|
|
13
22
|
}
|
|
14
23
|
export interface CommentDescriptionProps {
|
|
15
24
|
comment: string;
|
|
@@ -18,6 +27,7 @@ export interface CommentDescriptionProps {
|
|
|
18
27
|
onCancel: () => void;
|
|
19
28
|
onSave: () => void;
|
|
20
29
|
isEditMode: boolean;
|
|
30
|
+
loading?: boolean;
|
|
21
31
|
}
|
|
22
32
|
export interface CommentCountProps {
|
|
23
33
|
commentLength: number;
|
package/lib/index.d.ts
CHANGED
|
@@ -4353,6 +4353,12 @@ interface ScriptCommentprop {
|
|
|
4353
4353
|
isOpen: boolean;
|
|
4354
4354
|
onClose: () => void;
|
|
4355
4355
|
targetRef?: RefObject<HTMLElement>;
|
|
4356
|
+
comment?: string;
|
|
4357
|
+
modifiedBy?: string;
|
|
4358
|
+
modifiedOn?: string;
|
|
4359
|
+
loading?: boolean;
|
|
4360
|
+
onSave?: (comment: string) => void;
|
|
4361
|
+
onDelete?: () => void;
|
|
4356
4362
|
}
|
|
4357
4363
|
|
|
4358
4364
|
declare const ScriptCommentModal: FC<ScriptCommentprop>;
|