frst-components 0.22.88 → 0.22.90

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
@@ -3322,8 +3322,7 @@ function Loading(props) {
3322
3322
 
3323
3323
  const HypothesisComponent = ({ description, type, id, title, votes = [], onVote, canVote = false, canViewVote = false, userLoggedId, deleteVote, canViewListVotes, votesSingularText, votesPluralText, voteText, deleteVoteText, handleViewProfile, avatar, showAvatar, authorId, hasVoteGoal, loading }) => {
3324
3324
  const [isHover, seIsHover] = React.useState(false);
3325
- const [hasVoteHypothesis, setHasVoteHypothesis] = React.useState(votes?.some((vote) => vote?.user_uuid === userLoggedId));
3326
- const [hypothesisVotes, setHypothesisVotes] = React.useState(votes);
3325
+ const [hasVoteHypothesis, setHasVoteHypothesis] = React.useState(false);
3327
3326
  const [showVotesList, setShowVotesList] = React.useState(false);
3328
3327
  const ContainerRef = React.useRef(null);
3329
3328
  const [heightContainer, seHeightContainer] = React.useState(0);
@@ -3338,6 +3337,9 @@ const HypothesisComponent = ({ description, type, id, title, votes = [], onVote,
3338
3337
  setShowVotesList(false);
3339
3338
  }
3340
3339
  };
3340
+ React.useEffect(() => {
3341
+ setHasVoteHypothesis(votes?.some((vote) => vote?.user_uuid === userLoggedId));
3342
+ }, [votes]);
3341
3343
  React.useEffect(() => {
3342
3344
  document.addEventListener('mousedown', handleClickOutsideVote);
3343
3345
  return () => {
@@ -3354,11 +3356,6 @@ const HypothesisComponent = ({ description, type, id, title, votes = [], onVote,
3354
3356
  const handleVote = async (hyphoteseId) => {
3355
3357
  const vote = await onVote(hyphoteseId);
3356
3358
  if (vote?.status === 201) {
3357
- let updateVotes = hypothesisVotes;
3358
- if (!updateVotes?.some((vot) => vot?.id === vote?.data?.id)) {
3359
- updateVotes.push(vote.data);
3360
- setHypothesisVotes(updateVotes);
3361
- }
3362
3359
  setHasVoteHypothesis(true);
3363
3360
  }
3364
3361
  if (vote?.status !== 201)
@@ -3367,26 +3364,21 @@ const HypothesisComponent = ({ description, type, id, title, votes = [], onVote,
3367
3364
  const handleDeleteVote = async (voteId) => {
3368
3365
  const vote = await deleteVote(voteId);
3369
3366
  if (vote?.status === 204) {
3370
- let updateVotes = hypothesisVotes;
3371
- if (updateVotes.some((vot) => vot?.id === voteId)) {
3372
- const newArrayVotes = updateVotes.filter((vot) => vot.id !== voteId);
3373
- setHypothesisVotes(newArrayVotes);
3374
- }
3375
3367
  setHasVoteHypothesis(false);
3376
3368
  }
3377
3369
  };
3378
- 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 })] }), loading && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, style: { cursor: 'default' }, children: jsxRuntime.jsx(Loading, {}) }) })), !loading && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!canVote && canViewVote && 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) => {
3370
+ 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 })] }), loading && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, style: { cursor: 'default' }, children: jsxRuntime.jsx(Loading, {}) }) })), !loading && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!canVote && canViewVote && votes?.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: [votes?.slice(0, 2)?.map((vote, index) => {
3379
3371
  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));
3380
- }), hypothesisVotes?.length > 2 && (jsxRuntime.jsx(ImageContent$1, { style: { background: '#444444' }, children: jsxRuntime.jsxs("p", { style: {
3381
- fontSize: hypothesisVotes?.length > 9 ? 10 : hypothesisVotes?.length > 99 ? 8 : 14
3382
- }, children: ["+", hypothesisVotes?.length - 2] }) }))] }), hypothesisVotes?.length, " ", hypothesisVotes?.length > 1 ? votesPluralText : votesSingularText] }) }) }), jsxRuntime.jsx(VoteList, { hypothesisVotes: votes, showVotes: showVotesList, viewProfile: handleViewProfile })] })), canVote && hasVoteGoal && hypothesisVotes?.length > 0 && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, onMouseEnter: () => seIsHover(true), onMouseLeave: () => seIsHover(false), style: { cursor: hasVoteHypothesis ? 'pointer' : 'default' }, children: hasVoteHypothesis ? (isHover ? (jsxRuntime.jsxs("div", { style: {
3372
+ }), votes?.length > 2 && (jsxRuntime.jsx(ImageContent$1, { style: { background: '#444444' }, children: jsxRuntime.jsxs("p", { style: {
3373
+ fontSize: votes?.length > 9 ? 10 : votes?.length > 99 ? 8 : 14
3374
+ }, children: ["+", votes?.length - 2] }) }))] }), votes?.length, " ", votes?.length > 1 ? votesPluralText : votesSingularText] }) }) }), jsxRuntime.jsx(VoteList, { hypothesisVotes: votes, showVotes: showVotesList, viewProfile: handleViewProfile })] })), canVote && hasVoteGoal && votes?.length > 0 && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, onMouseEnter: () => seIsHover(true), onMouseLeave: () => seIsHover(false), style: { cursor: hasVoteHypothesis ? 'pointer' : 'default' }, children: hasVoteHypothesis ? (isHover ? (jsxRuntime.jsxs("div", { style: {
3383
3375
  display: 'flex',
3384
3376
  alignItems: 'center',
3385
3377
  gap: '4px',
3386
3378
  justifyContent: 'center'
3387
- }, 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) => {
3379
+ }, onClick: () => handleDeleteVote(votes?.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: [votes?.slice(0, 2)?.map((vote, index) => {
3388
3380
  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));
3389
- }), 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.jsx(ViewVotes, { hypothesisVotes: hypothesisVotes, votesPluralText: votesPluralText, votesSingularText: votesSingularText })) }) })), canVote && !hasVoteGoal && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, onMouseEnter: () => seIsHover(true), onMouseLeave: () => seIsHover(false), children: jsxRuntime.jsxs("div", { style: {
3381
+ }), votes.length > 2 && (jsxRuntime.jsx(ImageContent$1, { style: { background: '#444444' }, children: jsxRuntime.jsxs("p", { children: ["+", votes?.length - 2] }) }))] }), jsxRuntime.jsxs("p", { children: [votes?.length, " ", votes?.length > 1 ? votesPluralText : votesSingularText] })] }))) : (jsxRuntime.jsx(ViewVotes, { hypothesisVotes: votes, votesPluralText: votesPluralText, votesSingularText: votesSingularText })) }) })), canVote && !hasVoteGoal && (jsxRuntime.jsx(SplitContainer, { children: jsxRuntime.jsx(VoteButtonContainer, { type: type, modeDelete: isHover, height: heightContainer, onMouseEnter: () => seIsHover(true), onMouseLeave: () => seIsHover(false), children: jsxRuntime.jsxs("div", { style: {
3390
3382
  display: 'flex',
3391
3383
  alignItems: 'center',
3392
3384
  justifyContent: 'center',
@@ -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;AAK9B,eAAO,MAAM,mBAAmB;iBAuBjB,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;cACP,OAAO;iBA4NlB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/hypothesisComponent/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAK9B,eAAO,MAAM,mBAAmB;iBAuBjB,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;cACP,OAAO;iBAmNlB,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.88",
4
+ "version": "0.22.90",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",