@logora/debate 0.4.98 → 0.4.99

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.
@@ -1,92 +1,97 @@
1
- import { jsx as t, jsxs as d, Fragment as I } from "react/jsx-runtime";
2
- import { useState as p, useEffect as N } from "react";
3
- import { buildShareUrl as y } from "../../tools/share_url/index.js";
4
- import C from "classnames";
1
+ import { jsx as t, jsxs as l, Fragment as N } from "react/jsx-runtime";
2
+ import { useState as _, useEffect as I } from "react";
3
+ import { buildShareUrl as U } from "../../tools/share_url/index.js";
4
+ import p from "classnames";
5
5
  import { useIntl as L } from "react-intl";
6
6
  import o from "./ProposalBox.module.scss.js";
7
7
  import { useConfig as B } from "../../data/config_provider/useConfig.js";
8
- import { useAuth as U } from "../../auth/use_auth/useAuth.js";
9
- import { useTranslatedContent as _ } from "../../translation/translated_content/useTranslatedContent.js";
8
+ import { useAuth as F } from "../../auth/use_auth/useAuth.js";
9
+ import { useTranslatedContent as C } from "../../translation/translated_content/useTranslatedContent.js";
10
10
  import { lexicalToHtml as H } from "../../input/text_editor/lexicalToHtml.js";
11
- import { HashScroll as D } from "../../tools/hash_scroll/HashScroll.js";
12
- import { ContentHeader as P } from "../../user_content/content_header/ContentHeader.js";
13
- import { ReadMore as R } from "../../text/read_more/ReadMore.js";
14
- import { TranslationButton as F } from "../../translation/translation_button/TranslationButton.js";
15
- import { SourceListItem as $ } from "../../source/source_list_item/SourceListItem.js";
16
- import { ContentFooter as j } from "../../user_content/content_footer/ContentFooter.js";
11
+ import { HashScroll as P } from "../../tools/hash_scroll/HashScroll.js";
12
+ import { ContentHeader as R } from "../../user_content/content_header/ContentHeader.js";
13
+ import { ReadMore as D } from "../../text/read_more/ReadMore.js";
14
+ import { TranslationButton as j } from "../../translation/translation_button/TranslationButton.js";
15
+ import { SourceListItem as k } from "../../source/source_list_item/SourceListItem.js";
16
+ import { ContentFooter as $ } from "../../user_content/content_footer/ContentFooter.js";
17
17
  import { UpDownVoteBox as A } from "../../vote/up_down_vote_box/UpDownVoteBox.js";
18
- const re = ({
18
+ const ae = ({
19
19
  proposal: e,
20
- disabled: c = !1,
21
- fixedContentHeight: m,
22
- fitContent: T = !1,
23
- enableEdition: v = !0,
24
- hideFooter: x = !1
20
+ disabled: m = !1,
21
+ fixedContentHeight: c,
22
+ fitContent: v = !1,
23
+ enableEdition: T = !0,
24
+ hideFooter: M = !1,
25
+ showModerationFeedback: x
25
26
  }) => {
26
- const [h, M] = p(null), [w, b] = p(!1), s = L(), a = B(), { currentUser: f } = U(), u = f?.moderation_status === "banned", g = `proposal_${e.id}`, i = _(
27
+ const [h, w] = _(null), [b, y] = _(!1), a = L(), n = B(), { currentUser: u } = F(), f = u?.moderation_status === "banned", g = `proposal_${e.id}`, i = C(
27
28
  e.title,
28
29
  e.language,
29
30
  "title",
30
31
  e.translation_entries
31
- ), n = _(
32
+ ), s = C(
32
33
  e.content,
33
34
  e.language,
34
35
  "content",
35
36
  e.translation_entries
36
37
  );
37
- N(() => {
38
+ I(() => {
38
39
  if (e.rich_content) {
39
40
  const r = JSON.parse(e.rich_content);
40
41
  if (r.hasOwnProperty("root")) {
41
- const l = H(r);
42
- M(l);
42
+ const d = H(r);
43
+ w(d);
43
44
  }
44
45
  }
45
46
  }, [e.rich_content]);
46
47
  const S = () => {
47
- i.toggleContent(), n.toggleContent();
48
+ i.toggleContent(), s.toggleContent();
48
49
  };
49
- return /* @__PURE__ */ t(D, { elementId: g, onScroll: () => b(!0), children: /* @__PURE__ */ d(
50
+ return /* @__PURE__ */ t(P, { elementId: g, onScroll: () => y(!0), children: /* @__PURE__ */ l(
50
51
  "div",
51
52
  {
52
- className: C(o.proposalBoxContainer, { [o.flash]: w }),
53
+ className: p(o.proposalBoxContainer, { [o.flash]: b }),
53
54
  id: g,
54
55
  children: [
55
56
  /* @__PURE__ */ t(
56
- P,
57
+ R,
57
58
  {
58
59
  author: e.author,
59
60
  tag: e.tag?.display_name,
60
61
  date: e.created_at,
61
- oneLine: !1
62
+ oneLine: !1,
63
+ showModerationFeedback: x ?? (e.status === "rejected" && n.moderation?.showFeedback === !0),
64
+ moderationReason: e.moderation_entry?.moderation_reason,
65
+ moderationNotes: e.moderation_entry?.moderator_notes,
66
+ moderationPolicyUrl: n.provider?.userGuideUrl
62
67
  }
63
68
  ),
64
- /* @__PURE__ */ d(
69
+ /* @__PURE__ */ l(
65
70
  "div",
66
71
  {
67
- className: C(o.proposalBoxContent, {
68
- [o.fixedHeight]: m,
69
- [o.withMinHeight]: !T && !m
72
+ className: p(o.proposalBoxContent, {
73
+ [o.fixedHeight]: c,
74
+ [o.withMinHeight]: !v && !c
70
75
  }),
71
76
  children: [
72
77
  /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
73
- R,
78
+ D,
74
79
  {
75
- content: /* @__PURE__ */ d(I, { children: [
76
- e.is_edited && /* @__PURE__ */ t("div", { className: o.edited, children: s.formatMessage({
80
+ content: /* @__PURE__ */ l(N, { children: [
81
+ e.is_edited && /* @__PURE__ */ t("div", { className: o.edited, children: a.formatMessage({
77
82
  id: "proposal.updated",
78
83
  defaultMessage: "Updated proposal"
79
84
  }) }),
80
85
  /* @__PURE__ */ t("div", { className: o.proposalTitle, children: i.translatedContent }),
81
- h && !n.isTranslated ? /* @__PURE__ */ t(
86
+ h && !s.isTranslated ? /* @__PURE__ */ t(
82
87
  "div",
83
88
  {
84
89
  className: o.proposalContent,
85
90
  dangerouslySetInnerHTML: { __html: h }
86
91
  }
87
- ) : /* @__PURE__ */ t("div", { className: o.proposalContent, children: n.translatedContent }),
88
- (n.isTranslated || i.isTranslated) && /* @__PURE__ */ t(
89
- F,
92
+ ) : /* @__PURE__ */ t("div", { className: o.proposalContent, children: s.translatedContent }),
93
+ (s.isTranslated || i.isTranslated) && /* @__PURE__ */ t(
94
+ j,
90
95
  {
91
96
  language: e.language,
92
97
  callback: () => S()
@@ -94,45 +99,45 @@ const re = ({
94
99
  )
95
100
  ] }),
96
101
  lineCount: 7,
97
- readMoreText: s.formatMessage({
102
+ readMoreText: a.formatMessage({
98
103
  id: "action.read_more",
99
104
  defaultMessage: "Read more"
100
105
  }),
101
- readLessText: s.formatMessage({
106
+ readLessText: a.formatMessage({
102
107
  id: "action.read_less",
103
108
  defaultMessage: "Read less"
104
109
  })
105
110
  }
106
111
  ) }),
107
- e.sources?.length > 0 && /* @__PURE__ */ t("div", { className: o.proposalSourcesList, children: e.sources.map((r, l) => /* @__PURE__ */ t(
108
- $,
112
+ e.sources?.length > 0 && /* @__PURE__ */ t("div", { className: o.proposalSourcesList, children: e.sources.map((r, d) => /* @__PURE__ */ t(
113
+ k,
109
114
  {
110
115
  publisher: r.publisher,
111
116
  url: r.source_url,
112
117
  title: r.title,
113
- index: l
118
+ index: d
114
119
  },
115
120
  r.id
116
121
  )) })
117
122
  ]
118
123
  }
119
124
  ),
120
- !x && /* @__PURE__ */ t(
121
- j,
125
+ !M && /* @__PURE__ */ t(
126
+ $,
122
127
  {
123
128
  resource: e,
124
- disabled: c || u,
129
+ disabled: m || f,
125
130
  reportType: "Proposal",
126
131
  deleteType: "proposals",
127
132
  deleteListId: "proposalsList",
128
- shareModalTitle: s.formatMessage({ id: "share.proposal" }),
129
- shareUrl: y(a, "p", e.id),
130
- shareTitle: s.formatMessage({ id: "share.proposal.title" }),
131
- shareText: s.formatMessage({ id: "share.proposal.text" }),
132
- shareCode: `<iframe src="https://cdn.logora.com/embed.html?shortname=${a.shortname}&id=${e.id}&resource=proposal" frameborder="0" width="100%" height="335px" scrolling="no"></iframe>`,
133
- showShareCode: a?.actions?.hideCodeShare !== !0,
133
+ shareModalTitle: a.formatMessage({ id: "share.proposal" }),
134
+ shareUrl: U(n, "p", e.id),
135
+ shareTitle: a.formatMessage({ id: "share.proposal.title" }),
136
+ shareText: a.formatMessage({ id: "share.proposal.text" }),
137
+ shareCode: `<iframe src="https://cdn.logora.com/embed.html?shortname=${n.shortname}&id=${e.id}&resource=proposal" frameborder="0" width="100%" height="335px" scrolling="no"></iframe>`,
138
+ showShareCode: n?.actions?.hideCodeShare !== !0,
134
139
  showActions: !e.author.consultation_id,
135
- enableEdition: v,
140
+ enableEdition: T,
136
141
  children: /* @__PURE__ */ t(
137
142
  A,
138
143
  {
@@ -140,8 +145,8 @@ const re = ({
140
145
  voteableId: e.id,
141
146
  totalUpvote: e.total_upvotes,
142
147
  totalDownvote: e.total_downvotes,
143
- disabled: c || f?.id === e?.author?.id || u,
144
- hideDownvotes: a?.actions?.hideDownvotes
148
+ disabled: m || u?.id === e?.author?.id || f,
149
+ hideDownvotes: n?.actions?.hideDownvotes
145
150
  }
146
151
  )
147
152
  }
@@ -151,5 +156,5 @@ const re = ({
151
156
  ) });
152
157
  };
153
158
  export {
154
- re as ProposalBox
159
+ ae as ProposalBox
155
160
  };
@@ -8,13 +8,13 @@ import { SuggestionBox as M } from "../../suggestion/suggestion_box/SuggestionBo
8
8
  import { ProposalBox as v } from "../../proposal/proposal_box/ProposalBox.js";
9
9
  import { Argument as w } from "../../argument/argument/Argument.js";
10
10
  const C = ({ report: e, flash: i }) => {
11
- const o = g(), [d, c] = p(!1);
11
+ const o = g(), [c, d] = p(!1);
12
12
  h(() => {
13
13
  if (i === e.id) {
14
14
  const r = document.getElementById(`reports_${e.id}`);
15
- r && r.scrollIntoView({ behavior: "smooth", block: "center" }), c(!0);
15
+ r && r.scrollIntoView({ behavior: "smooth", block: "center" }), d(!0);
16
16
  } else
17
- c(!1);
17
+ d(!1);
18
18
  }, [i, e.id]);
19
19
  const l = () => {
20
20
  const { reportable_type: r, reportable: a } = e;
@@ -34,7 +34,14 @@ const C = ({ report: e, flash: i }) => {
34
34
  );
35
35
  }
36
36
  case "Proposal":
37
- return /* @__PURE__ */ t(v, { proposal: a, hideFooter: !0 });
37
+ return /* @__PURE__ */ t(
38
+ v,
39
+ {
40
+ proposal: a,
41
+ hideFooter: !0,
42
+ showModerationFeedback: !1
43
+ }
44
+ );
38
45
  case "Group":
39
46
  return /* @__PURE__ */ t(M, { suggestion: a, hideFooter: !0 });
40
47
  default:
@@ -65,7 +72,7 @@ const C = ({ report: e, flash: i }) => {
65
72
  {
66
73
  id: `reports_${e.id}`,
67
74
  className: f(s.reportBox, {
68
- [s.reportHighlighted]: d
75
+ [s.reportHighlighted]: c
69
76
  }),
70
77
  children: e && /* @__PURE__ */ n("div", { className: s.reportItem, children: [
71
78
  /* @__PURE__ */ n("div", { className: s.reportHeader, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.98",
3
+ "version": "0.4.99",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",