frst-components 0.22.83 → 0.22.84
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 +61 -55
- package/dist/src/components/hypothesisComponent/hypothesisComponent.style.d.ts +2 -6
- package/dist/src/components/hypothesisComponent/hypothesisComponent.style.d.ts.map +1 -1
- package/dist/src/components/hypothesisComponent/index.d.ts +5 -1
- package/dist/src/components/hypothesisComponent/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3093,19 +3093,20 @@ font-family: PT Sans;
|
|
|
3093
3093
|
font-size:14px;
|
|
3094
3094
|
border-radius:8px;
|
|
3095
3095
|
padding: 0 0 0 16px;
|
|
3096
|
-
height: 100%;
|
|
3097
3096
|
min-height: 52px;
|
|
3098
3097
|
|
|
3099
|
-
${({ type }) =>
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3098
|
+
${({ type }) => {
|
|
3099
|
+
switch (type) {
|
|
3100
|
+
case 'prioritize':
|
|
3101
|
+
return styled.css `background: #FDAE15;`;
|
|
3102
|
+
case 'raised':
|
|
3103
|
+
return styled.css `background: #F8D784;`;
|
|
3104
|
+
case 'suggested':
|
|
3105
|
+
return styled.css `background: #CDDAEF;`;
|
|
3106
|
+
default:
|
|
3107
|
+
return '';
|
|
3108
|
+
}
|
|
3109
|
+
}}
|
|
3109
3110
|
`;
|
|
3110
3111
|
const Title$6 = styled__default["default"].span `
|
|
3111
3112
|
font-weight:700;
|
|
@@ -3127,15 +3128,7 @@ const SplitContainer = styled__default["default"].div `
|
|
|
3127
3128
|
display:flex;
|
|
3128
3129
|
justify-content: flex-start;
|
|
3129
3130
|
align-items:center;
|
|
3130
|
-
height:
|
|
3131
|
-
`;
|
|
3132
|
-
const VoteMainContainer = styled__default["default"].div `
|
|
3133
|
-
display: flex;
|
|
3134
|
-
align-items: center;
|
|
3135
|
-
justify-content: flex-start;
|
|
3136
|
-
cursor: pointer;
|
|
3137
|
-
height: ${({ height }) => height ? `${height}px` : '100%'};
|
|
3138
|
-
width: 100%;
|
|
3131
|
+
height: 100%;
|
|
3139
3132
|
`;
|
|
3140
3133
|
styled__default["default"].div `
|
|
3141
3134
|
display: flex;
|
|
@@ -3152,25 +3145,28 @@ const VoteButtonContainer = styled__default["default"].span `
|
|
|
3152
3145
|
justify-content: center;
|
|
3153
3146
|
width: 150px;
|
|
3154
3147
|
background: #F9CD5E;
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
${
|
|
3158
|
-
background: #DC9100;
|
|
3159
|
-
`}
|
|
3160
|
-
${({ type }) => type === 'raised' && styled.css `
|
|
3161
|
-
background: #F9CD5E;
|
|
3162
|
-
|
|
3163
|
-
`}
|
|
3164
|
-
${({ type }) => type === 'suggested' && styled.css `
|
|
3165
|
-
background: #A5C3F2;
|
|
3148
|
+
cursor: pointer;
|
|
3149
|
+
${({ height }) => height > 0 && styled.css `
|
|
3150
|
+
height: ${height}px;
|
|
3166
3151
|
`}
|
|
3167
3152
|
|
|
3153
|
+
${({ type }) => {
|
|
3154
|
+
switch (type) {
|
|
3155
|
+
case 'prioritize':
|
|
3156
|
+
return styled.css `background: #DC9100;`;
|
|
3157
|
+
case 'raised':
|
|
3158
|
+
return styled.css `background: #F9CD5E;`;
|
|
3159
|
+
case 'suggested':
|
|
3160
|
+
return styled.css `background: #A5C3F2;`;
|
|
3161
|
+
default:
|
|
3162
|
+
return '';
|
|
3163
|
+
}
|
|
3164
|
+
}}
|
|
3168
3165
|
${({ modeDelete }) => modeDelete && styled.css `
|
|
3169
3166
|
background: inherit;
|
|
3170
3167
|
`}
|
|
3171
3168
|
border-radius:0 8px 8px 0;
|
|
3172
3169
|
padding: 0 16px 0 16px;
|
|
3173
|
-
height: 100%;
|
|
3174
3170
|
min-height: 52px;
|
|
3175
3171
|
margin-left: 4px;
|
|
3176
3172
|
|
|
@@ -3251,11 +3247,13 @@ gap: 10px;
|
|
|
3251
3247
|
${({ lastVote }) => lastVote === false && "border-bottom: solid 1px #ccc;"}
|
|
3252
3248
|
`;
|
|
3253
3249
|
|
|
3254
|
-
const HypothesisComponent = ({ description, type, id, title, votes = [], onVote, canVote = false, canViewVote = false, userLoggedId, deleteVote, canViewListVotes, votesSingularText, votesPluralText, voteText, deleteVoteText, handleViewProfile }) => {
|
|
3250
|
+
const HypothesisComponent = ({ description, type, id, title, votes = [], onVote, canVote = false, canViewVote = false, userLoggedId, deleteVote, canViewListVotes, votesSingularText, votesPluralText, voteText, deleteVoteText, handleViewProfile, avatar, showAvatar, authorId, hasVoteGoal }) => {
|
|
3255
3251
|
const [isHover, seIsHover] = React.useState(false);
|
|
3256
|
-
const [
|
|
3252
|
+
const [hasVoteHypothesis, setHasVoteHypothesis] = React.useState(votes?.some((vote) => vote?.user_uuid === userLoggedId));
|
|
3257
3253
|
const [hypothesisVotes, setHypothesisVotes] = React.useState(votes);
|
|
3258
3254
|
const [showVotesList, setShowVotesList] = React.useState(false);
|
|
3255
|
+
const ContainerRef = React.useRef(null);
|
|
3256
|
+
const [heightContainer, seHeightContainer] = React.useState(0);
|
|
3259
3257
|
const toggleVotes = () => {
|
|
3260
3258
|
setShowVotesList(!showVotesList);
|
|
3261
3259
|
};
|
|
@@ -3273,6 +3271,13 @@ const HypothesisComponent = ({ description, type, id, title, votes = [], onVote,
|
|
|
3273
3271
|
document.removeEventListener('mousedown', handleClickOutsideVote);
|
|
3274
3272
|
};
|
|
3275
3273
|
}, [setShowVotesList]);
|
|
3274
|
+
React.useEffect(() => {
|
|
3275
|
+
const Container = ContainerRef?.current;
|
|
3276
|
+
if (ContainerRef) {
|
|
3277
|
+
const height = Container.clientHeight;
|
|
3278
|
+
seHeightContainer(height);
|
|
3279
|
+
}
|
|
3280
|
+
}, [ContainerRef]);
|
|
3276
3281
|
const handleVote = async (hyphoteseId) => {
|
|
3277
3282
|
const vote = await onVote(hyphoteseId);
|
|
3278
3283
|
if (vote?.status === 201) {
|
|
@@ -3281,10 +3286,10 @@ const HypothesisComponent = ({ description, type, id, title, votes = [], onVote,
|
|
|
3281
3286
|
updateVotes.push(vote.data);
|
|
3282
3287
|
setHypothesisVotes(updateVotes);
|
|
3283
3288
|
}
|
|
3284
|
-
|
|
3289
|
+
setHasVoteHypothesis(true);
|
|
3285
3290
|
}
|
|
3286
3291
|
if (vote?.status !== 201)
|
|
3287
|
-
|
|
3292
|
+
setHasVoteHypothesis(false);
|
|
3288
3293
|
};
|
|
3289
3294
|
const handleDeleteVote = async (voteId) => {
|
|
3290
3295
|
const vote = await deleteVote(voteId);
|
|
@@ -3294,27 +3299,28 @@ const HypothesisComponent = ({ description, type, id, title, votes = [], onVote,
|
|
|
3294
3299
|
const newArrayVotes = updateVotes.filter((vot) => vot.id !== voteId);
|
|
3295
3300
|
setHypothesisVotes(newArrayVotes);
|
|
3296
3301
|
}
|
|
3297
|
-
|
|
3302
|
+
setHasVoteHypothesis(false);
|
|
3298
3303
|
}
|
|
3299
3304
|
};
|
|
3300
|
-
return (jsxRuntime.jsx(MainContainer, { children: jsxRuntime.jsxs(Container$l, { type: type, id: id,
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3305
|
+
return (jsxRuntime.jsx(MainContainer, { children: jsxRuntime.jsxs(Container$l, { type: type, id: id, ref: ContainerRef, children: [jsxRuntime.jsxs(SplitContainer, { children: [showAvatar && (jsxRuntime.jsx(Avatar, { src: avatar, size: "24px", style: { marginRight: '8px', cursor: authorId ? 'pointer' : 'default' }, onClick: () => handleViewProfile(authorId) })), jsxRuntime.jsx(Title$6, { children: title }), jsxRuntime.jsx(Separator, { children: "|" }), jsxRuntime.jsx(Description$3, { children: description })] }), ((!canVote && canViewVote && hypothesisVotes?.length > 0) ||
|
|
3306
|
+
(canVote && hasVoteGoal && hypothesisVotes?.length > 0)) && (jsxRuntime.jsxs("div", { style: { position: 'relative', height: '100%' }, children: [jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { ref: viewVotesRef, height: heightContainer, style: { cursor: canViewListVotes ? 'pointer' : 'default' }, type: type, onClick: canViewListVotes ? toggleVotes : null, children: jsxRuntime.jsxs(VoteCount, { children: [jsxRuntime.jsxs(VoteContent, { children: [hypothesisVotes?.slice(0, 2)?.map((vote, index) => {
|
|
3307
|
+
return (jsxRuntime.jsx(ImageContent$1, { style: { zIndex: 14 - index }, children: jsxRuntime.jsx("img", { src: vote?.user?.avatar || 'https://cdn-images.frstfalconi.cloud/path582.svg' }) }, vote?.id));
|
|
3308
|
+
}), hypothesisVotes?.length > 2 && (jsxRuntime.jsx(ImageContent$1, { style: { background: '#444444' }, children: jsxRuntime.jsxs("p", { style: {
|
|
3309
|
+
fontSize: hypothesisVotes?.length > 9 ? 10 : hypothesisVotes?.length > 99 ? 8 : 14
|
|
3310
|
+
}, children: ["+", hypothesisVotes?.length - 2] }) }))] }), hypothesisVotes?.length, " ", hypothesisVotes?.length > 1 ? votesPluralText : votesSingularText] }) }) }), jsxRuntime.jsx(VoteList, { hypothesisVotes: votes, showVotes: showVotesList, viewProfile: handleViewProfile })] })), canVote && !hasVoteGoal && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, onMouseEnter: () => seIsHover(true), onMouseLeave: () => seIsHover(false), children: hasVoteHypothesis ? (isHover ? (jsxRuntime.jsxs("div", { style: {
|
|
3311
|
+
display: 'flex',
|
|
3312
|
+
alignItems: 'center',
|
|
3313
|
+
gap: '4px',
|
|
3314
|
+
justifyContent: 'center'
|
|
3315
|
+
}, onClick: () => handleDeleteVote(hypothesisVotes?.find((vote) => vote?.user_uuid === userLoggedId)?.id), children: [jsxRuntime.jsx(ExcludeVoteIcon, { width: "24", height: "24" }), jsxRuntime.jsx(VoteButton, { children: deleteVoteText })] })) : (jsxRuntime.jsxs(VoteCount, { children: [jsxRuntime.jsxs(VoteContent, { children: [hypothesisVotes?.slice(0, 2)?.map((vote, index) => {
|
|
3316
|
+
return (jsxRuntime.jsx(ImageContent$1, { style: { zIndex: 14 - index }, children: jsxRuntime.jsx("img", { src: vote?.user?.avatar || 'https://cdn-images.frstfalconi.cloud/path582.svg' }) }, vote?.id));
|
|
3317
|
+
}), hypothesisVotes.length > 2 && (jsxRuntime.jsx(ImageContent$1, { style: { background: '#444444' }, children: jsxRuntime.jsxs("p", { children: ["+", hypothesisVotes?.length - 2] }) }))] }), jsxRuntime.jsxs("p", { children: [hypothesisVotes?.length, " ", hypothesisVotes?.length > 1 ? votesPluralText : votesSingularText] })] }))) : (jsxRuntime.jsxs("div", { style: {
|
|
3318
|
+
display: 'flex',
|
|
3319
|
+
alignItems: 'center',
|
|
3320
|
+
justifyContent: 'center',
|
|
3321
|
+
paddingLeft: '4px',
|
|
3322
|
+
height: '100%'
|
|
3323
|
+
}, onClick: () => handleVote(id), children: [jsxRuntime.jsx(VoteIcon, { width: "24", height: "24", style: { marginLeft: '4px', marginRight: '4px' } }), jsxRuntime.jsx(VoteButton, { children: voteText })] })) }) }))] }) }));
|
|
3318
3324
|
};
|
|
3319
3325
|
const VoteList = ({ hypothesisVotes, showVotes, viewProfile }) => {
|
|
3320
3326
|
const sortedVotes = [...hypothesisVotes].sort((a, b) => a.user.name.localeCompare(b.user.name));
|
|
@@ -6,17 +6,13 @@ export declare const Title: import("styled-components").StyledComponent<"span",
|
|
|
6
6
|
export declare const Index: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
7
7
|
export declare const Separator: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
8
|
export declare const Description: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
9
|
-
export declare const SplitContainer: import("styled-components").StyledComponent<"div", any, {
|
|
10
|
-
height?: number;
|
|
11
|
-
}, never>;
|
|
12
|
-
export declare const VoteMainContainer: import("styled-components").StyledComponent<"div", any, {
|
|
13
|
-
height?: number;
|
|
14
|
-
}, never>;
|
|
9
|
+
export declare const SplitContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
15
10
|
export declare const VoteAvatarsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
11
|
export declare const VoteAvatar: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
12
|
export declare const VoteButtonContainer: import("styled-components").StyledComponent<"span", any, {
|
|
18
13
|
type?: string;
|
|
19
14
|
modeDelete?: boolean;
|
|
15
|
+
height?: number;
|
|
20
16
|
}, never>;
|
|
21
17
|
export declare const VoteCount: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
22
18
|
export declare const VoteButton: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hypothesisComponent.style.d.ts","sourceRoot":"","sources":["../../../../src/components/hypothesisComponent/hypothesisComponent.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,oEAMzB,CAAA;AACD,eAAO,MAAM,SAAS;UAAsB,MAAM;
|
|
1
|
+
{"version":3,"file":"hypothesisComponent.style.d.ts","sourceRoot":"","sources":["../../../../src/components/hypothesisComponent/hypothesisComponent.style.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,oEAMzB,CAAA;AACD,eAAO,MAAM,SAAS;UAAsB,MAAM;SAuBjD,CAAC;AAEF,eAAO,MAAM,KAAK,qEAGjB,CAAC;AAEF,eAAO,MAAM,KAAK,qEAEjB,CAAC;AAEF,eAAO,MAAM,SAAS,oEAGrB,CAAC;AAEF,eAAO,MAAM,WAAW,qEAIvB,CAAC;AACF,eAAO,MAAM,cAAc,oEAK1B,CAAA;AACD,eAAO,MAAM,oBAAoB,oEAKhC,CAAA;AAED,eAAO,MAAM,UAAU,oEAEtB,CAAA;AAED,eAAO,MAAM,mBAAmB;WAAwB,MAAM;iBAAe,OAAO;aAAW,MAAM;SA+BpG,CAAA;AACD,eAAO,MAAM,SAAS,qEAOrB,CAAA;AACD,eAAO,MAAM,UAAU,kEActB,CAAA;AACD,eAAO,MAAM,WAAW,oEASvB,CAAA;AACD,eAAO,MAAM,YAAY,oEAexB,CAAA;AAED,eAAO,MAAM,iBAAiB;gBAA4B,OAAO;SAiBhE,CAAA;AAED,eAAO,MAAM,YAAY;eAA2B,OAAO;SAO1D,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Vote } from './types';
|
|
3
|
-
export declare const HypothesisComponent: ({ description, type, id, title, votes, onVote, canVote, canViewVote, userLoggedId, deleteVote, canViewListVotes, votesSingularText, votesPluralText, voteText, deleteVoteText, handleViewProfile }: {
|
|
3
|
+
export declare const HypothesisComponent: ({ description, type, id, title, votes, onVote, canVote, canViewVote, userLoggedId, deleteVote, canViewListVotes, votesSingularText, votesPluralText, voteText, deleteVoteText, handleViewProfile, avatar, showAvatar, authorId, hasVoteGoal }: {
|
|
4
4
|
description: string;
|
|
5
5
|
type: string;
|
|
6
6
|
id: string;
|
|
@@ -13,9 +13,13 @@ export declare const HypothesisComponent: ({ description, type, id, title, votes
|
|
|
13
13
|
canVote?: boolean;
|
|
14
14
|
canViewListVotes?: boolean;
|
|
15
15
|
canViewVote?: boolean;
|
|
16
|
+
hasVoteGoal?: boolean;
|
|
16
17
|
votesSingularText?: string;
|
|
17
18
|
votesPluralText?: string;
|
|
18
19
|
voteText?: string;
|
|
19
20
|
deleteVoteText?: string;
|
|
21
|
+
avatar?: string;
|
|
22
|
+
showAvatar?: boolean;
|
|
23
|
+
authorId?: string;
|
|
20
24
|
}) => JSX.Element;
|
|
21
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/hypothesisComponent/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAI9B,eAAO,MAAM,mBAAmB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/hypothesisComponent/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAI9B,eAAO,MAAM,mBAAmB;iBAsBjB,MAAM;UACb,MAAM;QACR,MAAM;WACH,MAAM;WACN,IAAI,EAAE;kBACC,MAAM;2BACG,MAAM,KAAK,GAAG;0BACf,MAAM,KAAK,GAAG;iCACP,MAAM,KAAK,GAAG;cACjC,OAAO;uBACE,OAAO;kBACZ,OAAO;kBACP,OAAO;wBACD,MAAM;sBACR,MAAM;eACb,MAAM;qBACA,MAAM;aACd,MAAM;iBACF,OAAO;eACT,MAAM;iBA0LlB,CAAA"}
|