proca 0.8.1 → 1.1.4

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.
Files changed (104) hide show
  1. package/README.md +1027 -28
  2. package/package.json +94 -101
  3. package/proca-cli +8 -0
  4. package/src/commands/action/count.mjs +61 -0
  5. package/src/commands/action/list.mjs +189 -0
  6. package/src/commands/action/replay.mjs +54 -0
  7. package/src/commands/campaign/add.mjs +101 -0
  8. package/src/commands/campaign/delete.mjs +61 -0
  9. package/src/commands/campaign/get.mjs +107 -0
  10. package/src/commands/campaign/list.mjs +156 -0
  11. package/src/commands/campaign/queries.graphql +19 -0
  12. package/src/commands/config/add.mjs +101 -0
  13. package/src/commands/config/get.mjs +33 -0
  14. package/src/commands/config/set.mjs +103 -0
  15. package/src/commands/config/user.mjs +76 -0
  16. package/src/commands/org/add.mjs +66 -0
  17. package/src/commands/org/crm.mjs +88 -0
  18. package/src/commands/org/delete.mjs +48 -0
  19. package/src/commands/org/get.mjs +97 -0
  20. package/src/commands/org/join.mjs +77 -0
  21. package/src/commands/supporter/count.mjs +96 -0
  22. package/src/commands/user/get.mjs +91 -0
  23. package/src/commands/user/leave.mjs +52 -0
  24. package/src/commands/user/list.mjs +71 -0
  25. package/src/commands/widget/add.mjs +101 -0
  26. package/src/commands/widget/get.mjs +59 -0
  27. package/src/commands/widget/list.mjs +116 -0
  28. package/src/config.mjs +36 -0
  29. package/src/generated/schema.json +10677 -0
  30. package/src/hooks/help.mjs +14 -0
  31. package/src/hooks/init.mjs +20 -0
  32. package/src/index.mjs +1 -0
  33. package/src/procaCommand.mjs +218 -0
  34. package/src/queries/campaign.mjs +21 -0
  35. package/src/queries/widget.mjs +12 -0
  36. package/src/urql.mjs +60 -0
  37. package/src/util/twitter.mjs +23 -0
  38. package/theme.json +29 -0
  39. package/LICENSE +0 -661
  40. package/dist/App.css +0 -22
  41. package/dist/App.js +0 -25
  42. package/dist/App.test.js +0 -8
  43. package/dist/Wizard.js +0 -32
  44. package/dist/components/Alert.js +0 -49
  45. package/dist/components/Clickify.js +0 -26
  46. package/dist/components/Consent.js +0 -120
  47. package/dist/components/Country.js +0 -94
  48. package/dist/components/Dialog.js +0 -84
  49. package/dist/components/Disabled.js +0 -3
  50. package/dist/components/Emoji.js +0 -12
  51. package/dist/components/FAB.js +0 -70
  52. package/dist/components/Html.js +0 -56
  53. package/dist/components/Loader.js +0 -14
  54. package/dist/components/Openletter.js +0 -443
  55. package/dist/components/Organisation.js +0 -181
  56. package/dist/components/Petition.js +0 -16
  57. package/dist/components/ProcaRoot.js +0 -23
  58. package/dist/components/ProcaStyle.js +0 -94
  59. package/dist/components/ProgressCounter.js +0 -64
  60. package/dist/components/Register.js +0 -345
  61. package/dist/components/Share.js +0 -177
  62. package/dist/components/TextField.js +0 -58
  63. package/dist/components/Twitter.js +0 -127
  64. package/dist/components/TwitterAction.js +0 -111
  65. package/dist/components/TwitterList.js +0 -25
  66. package/dist/components/TwitterText.js +0 -42
  67. package/dist/components/Widget.js +0 -266
  68. package/dist/components/bespoke/Download.js +0 -49
  69. package/dist/components/bespoke/Register-CH.js +0 -505
  70. package/dist/data/countries.json +0 -114
  71. package/dist/hooks/useConfig.js +0 -217
  72. package/dist/hooks/useCount.js +0 -95
  73. package/dist/hooks/useData.js +0 -59
  74. package/dist/hooks/useElementWidth.js +0 -46
  75. package/dist/hooks/useGeoLocation.js +0 -45
  76. package/dist/hooks/useLayout.js +0 -63
  77. package/dist/images/Twitter.js +0 -16
  78. package/dist/images/Twitter.svg +0 -1
  79. package/dist/index.css +0 -13
  80. package/dist/index.js +0 -114
  81. package/dist/lib/domparser.js +0 -12
  82. package/dist/lib/i18n.js +0 -40
  83. package/dist/lib/init.js +0 -7
  84. package/dist/lib/server.js +0 -331
  85. package/dist/lib/urlparser.js +0 -65
  86. package/dist/lib/uuid.js +0 -30
  87. package/dist/locales/README.md +0 -37
  88. package/dist/locales/common.json +0 -189
  89. package/dist/locales/de/common.json +0 -46
  90. package/dist/locales/de/index.js +0 -0
  91. package/dist/locales/en/common.json +0 -45
  92. package/dist/locales/fr/common.json +0 -51
  93. package/dist/locales/index.js +0 -27
  94. package/dist/locales/it/common.json +0 -46
  95. package/dist/logo.svg +0 -1
  96. package/dist/module.js +0 -14
  97. package/dist/slingshot.xcf +0 -0
  98. package/dist/tmp.config/0.json +0 -21
  99. package/dist/tmp.config/2.json +0 -11
  100. package/dist/tmp.config/20.json +0 -29
  101. package/dist/tmp.config/28.json +0 -14
  102. package/dist/tmp.config/32.json +0 -34
  103. package/dist/tmp.config/35.json +0 -14
  104. package/dist/tmp.config/null.json +0 -1
@@ -1,94 +0,0 @@
1
- import React from 'react';
2
- import { StylesProvider, createGenerateClassName, createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; //import CssBaseline from '@material-ui/core/ScopedCssBaseline';
3
- //import ScopedCssBaseline from '@material-ui/core/ScopedCssBaseline';
4
-
5
- import { useLayout } from "../hooks/useLayout";
6
- var generateClassName = createGenerateClassName({
7
- disableGlobal: false,
8
- productionPrefix: 'Proca',
9
- seed: 'proca'
10
- });
11
- /*
12
- const GlobalCss = withStyles({
13
- // @global is handled by jss-plugin-global.
14
- '@global': {
15
- // You should target [class*="MuiButton-root"] instead if you nest themes.
16
- '.proca-MuiInputBase-input': {
17
- background:'unset!important',
18
- border:'unset!important',
19
- },
20
- },
21
- })(() => null);
22
- */
23
- //<ScopedCssBaseline>
24
-
25
- export default function ProcaStyle(props) {
26
- var layout = useLayout();
27
- var theme = React.useMemo(function () {
28
- return createMuiTheme({
29
- palette: {
30
- primary: {
31
- main: layout.primaryColor
32
- },
33
- secondary: {
34
- main: layout.secondaryColor
35
- },
36
- type: layout.theme
37
- },
38
- typography: {
39
- fontFamily: 'unset!important',
40
- htmlFontSize: parseInt(window.getComputedStyle(document.getElementsByTagName('html')[0], null).getPropertyValue('font-size')) // get the actual font size
41
- // fontFamily: `-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif`,
42
- // fontSize: 14,
43
-
44
- },
45
- overrides: {
46
- MuiContainer: {
47
- root: {
48
- fontFamily: 'unset!important',
49
- paddingLeft: '0!important',
50
- paddingRight: '0!important',
51
- backgroundColor: layout.theme === 'dark' ? '#303030' : 'inherit'
52
- }
53
- },
54
- MuiIconButton: {
55
- root: {
56
- width: 'auto!important',
57
- minWidth: 'auto!important'
58
- }
59
- },
60
- MuiDialog: {
61
- root: {
62
- fontFamily: 'unset!important'
63
- }
64
- },
65
- MuiFilledInput: {
66
- multiline: {
67
- paddingTop: '23px!important',
68
- paddingBottom: '6px!important'
69
- },
70
- marginDense: {}
71
- },
72
- MuiInputBase: {
73
- input: {
74
- background: 'unset!important',
75
- border: 'unset!important' // this is where magic happens
76
- // '& *': { color: 'rgba(255, 255, 255, 0.7)' },
77
-
78
- }
79
- }
80
- }
81
- });
82
- }, [layout]); // palette.background.default
83
-
84
- for (var d in theme.zIndex) {
85
- // force the widget on the top
86
- theme.zIndex[d] += 100000;
87
- }
88
-
89
- return /*#__PURE__*/React.createElement(StylesProvider, {
90
- generateClassName: generateClassName
91
- }, /*#__PURE__*/React.createElement(ThemeProvider, {
92
- theme: theme
93
- }, props.children));
94
- }
@@ -1,64 +0,0 @@
1
- import React from "react";
2
- /*import Backdrop from '@material-ui/core/Backdrop';
3
- import CircularProgress from '@material-ui/core/CircularProgress';
4
-
5
- <Backdrop className={classes.backdrop} open={open} onClick={handleClose}>
6
- <CircularProgress color="inherit" />
7
- </Backdrop>
8
- */
9
-
10
- import { makeStyles } from "@material-ui/core/styles";
11
- import { LinearProgress, Box } from "@material-ui/core";
12
- import useCount from "../hooks/useCount.js"; //3,014,823 have signed. Let’s get to 4,500,000!
13
-
14
- import { useTranslation } from "react-i18next";
15
- var useStyles = makeStyles(function (theme) {
16
- return {
17
- root: {
18
- fontSize: theme.typography.pxToRem(18),
19
- color: theme.palette.text.primary,
20
- width: '100%',
21
- '& > * + *': {
22
- marginTop: theme.spacing(2)
23
- }
24
- }
25
- };
26
- });
27
-
28
- var nextStep = function nextStep(value) {
29
- var steps = [100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 150000, 2000000, 5000000, 1000000];
30
- var next = false;
31
- steps.some(function (step, i) {
32
- if (value < step) {
33
- next = step;
34
- return true;
35
- }
36
-
37
- return false;
38
- });
39
- return next;
40
- };
41
-
42
- var normalise = function normalise(value, max) {
43
- return value * 100 / max;
44
- };
45
-
46
- export default function Progress(props) {
47
- var _useTranslation = useTranslation(),
48
- t = _useTranslation.t;
49
-
50
- var count = props.count;
51
- count = useCount(props.actionPage) || props.count;
52
- var classes = useStyles();
53
- var goal = nextStep(count);
54
- if (!count) return null;
55
- return /*#__PURE__*/React.createElement(Box, {
56
- className: classes.root
57
- }, t("progress", {
58
- count: count,
59
- goal: goal
60
- }), /*#__PURE__*/React.createElement(LinearProgress, {
61
- variant: "determinate",
62
- value: normalise(count, goal)
63
- }));
64
- }
@@ -1,345 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
-
3
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
-
5
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
-
7
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
-
9
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
-
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
-
15
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
-
17
- import React, { useEffect, useState } from "react";
18
- import PropTypes from "prop-types";
19
- import { Container, Grid } from "@material-ui/core";
20
- /*import Backdrop from '@material-ui/core/Backdrop';
21
- import CircularProgress from '@material-ui/core/CircularProgress';
22
-
23
- <Backdrop className={classes.backdrop} open={open} onClick={handleClose}>
24
- <CircularProgress color="inherit" />
25
- </Backdrop>
26
- */
27
-
28
- import useElementWidth from "../hooks/useElementWidth";
29
- import Url from "../lib/urlparser.js";
30
- import { useCampaignConfig } from "../hooks/useConfig";
31
- import useData from "../hooks/useData";
32
- import { makeStyles } from "@material-ui/core/styles";
33
- import { Button, Snackbar } from "@material-ui/core";
34
- import TextField from "./TextField";
35
- import Alert from "@material-ui/lab/Alert";
36
- import SendIcon from "@material-ui/icons/Send";
37
- import DoneIcon from "@material-ui/icons/Done";
38
- import useForm from "react-hook-form";
39
- import useGeoLocation from "../hooks/useGeoLocation";
40
- import { useTranslation } from "react-i18next";
41
- import Consent from "./Consent";
42
- import countries from "../data/countries.json";
43
- import Organisation from "./Organisation";
44
- import { addActionContact } from "../lib/server.js";
45
- import uuid from "../lib/uuid.js";
46
- var useStyles = makeStyles(function (theme) {
47
- return {
48
- container: {
49
- display: "flex",
50
- flexWrap: "wrap"
51
- },
52
- textField: {
53
- marginLeft: theme.spacing(0),
54
- marginRight: theme.spacing(0),
55
- width: "100%"
56
- },
57
- "#petition-form": {
58
- position: "relative"
59
- },
60
- "@global": {
61
- "select:-moz-focusring": {
62
- color: "transparent",
63
- textShadow: "0 0 0 #000"
64
- },
65
- "input:invalid + fieldset": {
66
- borderColor: "pink",
67
- borderWidth: 1
68
- }
69
- }
70
- };
71
- });
72
- export default function Register(props) {
73
- var _config$component, _config$component$reg;
74
-
75
- var classes = useStyles();
76
- var config = useCampaignConfig();
77
-
78
- var _useData = useData(),
79
- _useData2 = _slicedToArray(_useData, 2),
80
- data = _useData2[0],
81
- setData = _useData2[1]; // const setConfig = useCallback((d) => _setConfig(d), [_setConfig]);
82
-
83
-
84
- var _useTranslation = useTranslation(),
85
- t = _useTranslation.t;
86
-
87
- var width = useElementWidth("#proca-register");
88
-
89
- var _useState = useState(true),
90
- _useState2 = _slicedToArray(_useState, 2),
91
- compact = _useState2[0],
92
- setCompact = _useState2[1];
93
-
94
- if (compact && width > 450 || !compact && width <= 450) setCompact(width <= 450);
95
-
96
- var _useState3 = useState("default"),
97
- _useState4 = _slicedToArray(_useState3, 2),
98
- status = _useState4[0],
99
- setStatus = _useState4[1];
100
-
101
- var form = useForm({
102
- // mode: "onBlur",
103
- // nativeValidation: true,
104
- defaultValues: data
105
- });
106
- var handleSubmit = form.handleSubmit,
107
- setValue = form.setValue,
108
- setError = form.setError,
109
- watch = form.watch,
110
- formState = form.formState; // const { register, handleSubmit, setValue, errors } = useForm({ mode: 'onBlur', defaultValues: defaultValues });
111
-
112
- var country = watch("country") || "";
113
- var location = useGeoLocation({
114
- api: "https://country.proca.foundation",
115
- country: country
116
- });
117
-
118
- if (location.country && !country) {
119
- if (!countries.find(function (d) {
120
- return d.iso === location.country;
121
- })) {
122
- console.log("visitor from ", location, "but not on our list");
123
- location.country = countries.find(function (d) {
124
- return d.iso === "ZZ";
125
- }) ? "ZZ" : ""; // if "other" exists, set it
126
- }
127
-
128
- if (location.country && country !== location.country) {
129
- setValue("country", location.country);
130
- }
131
- }
132
-
133
- var onSubmit = /*#__PURE__*/function () {
134
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
135
- var result;
136
- return regeneratorRuntime.wrap(function _callee$(_context) {
137
- while (1) {
138
- switch (_context.prev = _context.next) {
139
- case 0:
140
- data.tracking = Url.utm();
141
- _context.next = 3;
142
- return addActionContact(config.actionType || "register", config.actionPage, data);
143
-
144
- case 3:
145
- result = _context.sent;
146
-
147
- if (!result.errors) {
148
- _context.next = 8;
149
- break;
150
- }
151
-
152
- result.errors.forEach(function (error) {
153
- console.log(error);
154
- });
155
- setStatus("error");
156
- return _context.abrupt("return");
157
-
158
- case 8:
159
- setStatus("success");
160
- setData(data);
161
- uuid(result.addAction); // set the global uuid as signature's fingerprint
162
-
163
- if (props.done) props.done({
164
- errors: result.errors,
165
- uuid: uuid(),
166
- firstname: data.firstname,
167
- country: data.country
168
- });
169
-
170
- case 12:
171
- case "end":
172
- return _context.stop();
173
- }
174
- }
175
- }, _callee);
176
- }));
177
-
178
- return function onSubmit(_x) {
179
- return _ref.apply(this, arguments);
180
- };
181
- }();
182
-
183
- useEffect(function () {
184
- var inputs = document.querySelectorAll("input, select, textarea"); // register({ name: "country" });
185
- // todo: workaround until the feature is native react-form ?
186
-
187
- inputs.forEach(function (input) {
188
- input.oninvalid = function (e) {
189
- setError(e.target.attributes.name.nodeValue, e.type, e.target.validationMessage);
190
- };
191
- });
192
- }, [setError]);
193
-
194
- function Error(props) {
195
- if (props.display) return /*#__PURE__*/React.createElement(Snackbar, {
196
- open: true,
197
- autoHideDuration: 6000
198
- }, /*#__PURE__*/React.createElement(Alert, {
199
- severity: "error"
200
- }, "Sorry, we couldn't save your signature!", /*#__PURE__*/React.createElement("br", null), "The techies have been informed."));
201
- return null;
202
- }
203
-
204
- function Success(props) {
205
- if (props.display) return /*#__PURE__*/React.createElement(Snackbar, {
206
- open: true,
207
- autoHideDuration: 6000
208
- }, /*#__PURE__*/React.createElement(Alert, {
209
- severity: "success"
210
- }, "Done, Thank you for your support!"));
211
- return null;
212
- }
213
-
214
- if (status === "success") {
215
- return /*#__PURE__*/React.createElement(Container, {
216
- component: "main",
217
- maxWidth: "sm"
218
- }, /*#__PURE__*/React.createElement(Grid, {
219
- container: true,
220
- spacing: 1
221
- }, /*#__PURE__*/React.createElement(Grid, {
222
- item: true,
223
- xs: 12
224
- }, /*#__PURE__*/React.createElement(DoneIcon, {
225
- color: "action",
226
- fontSize: "large",
227
- my: 4
228
- }))));
229
- }
230
-
231
- return /*#__PURE__*/React.createElement("form", {
232
- className: classes.container,
233
- id: "proca-register",
234
- onSubmit: handleSubmit(onSubmit),
235
- method: "post",
236
- url: "http://localhost"
237
- }, /*#__PURE__*/React.createElement(Success, {
238
- display: status === "success"
239
- }), /*#__PURE__*/React.createElement(Error, {
240
- display: status === "error"
241
- }), /*#__PURE__*/React.createElement(Container, {
242
- component: "main",
243
- maxWidth: "sm"
244
- }, /*#__PURE__*/React.createElement(Grid, {
245
- container: true,
246
- spacing: 1
247
- }, ((_config$component = config.component) === null || _config$component === void 0 ? void 0 : (_config$component$reg = _config$component.register) === null || _config$component$reg === void 0 ? void 0 : _config$component$reg.field.organisation) && /*#__PURE__*/React.createElement(Organisation, {
248
- form: form,
249
- compact: compact
250
- }), /*#__PURE__*/React.createElement(Grid, {
251
- item: true,
252
- xs: 12,
253
- sm: compact ? 12 : 6
254
- }, /*#__PURE__*/React.createElement(TextField, {
255
- form: form,
256
- name: "firstname",
257
- label: t("First name"),
258
- placeholder: "eg. Leonardo",
259
- autoComplete: "given-name",
260
- required: true
261
- })), /*#__PURE__*/React.createElement(Grid, {
262
- item: true,
263
- xs: 12,
264
- sm: compact ? 12 : 6
265
- }, /*#__PURE__*/React.createElement(TextField, {
266
- form: form,
267
- name: "lastname",
268
- label: t("Last name"),
269
- autoComplete: "family-name",
270
- placeholder: "eg. Da Vinci"
271
- })), /*#__PURE__*/React.createElement(Grid, {
272
- item: true,
273
- xs: 12
274
- }, /*#__PURE__*/React.createElement(TextField, {
275
- form: form,
276
- name: "email",
277
- type: "email",
278
- label: t("Email"),
279
- autoComplete: "email",
280
- placeholder: "your.email@example.org",
281
- required: true
282
- })), /*#__PURE__*/React.createElement(Grid, {
283
- item: true,
284
- xs: 12,
285
- sm: compact ? 12 : 3
286
- }, /*#__PURE__*/React.createElement(TextField, {
287
- form: form,
288
- name: "postcode",
289
- label: t("Postal Code"),
290
- autoComplete: "postal-code"
291
- })), /*#__PURE__*/React.createElement(Grid, {
292
- item: true,
293
- xs: 12,
294
- sm: compact ? 12 : 9
295
- }, /*#__PURE__*/React.createElement(TextField, {
296
- select: true,
297
- form: form,
298
- id: "country",
299
- name: "country",
300
- label: t("Country"),
301
- value: country,
302
- SelectProps: {
303
- native: true,
304
- MenuProps: {
305
- className: classes.menu
306
- }
307
- },
308
- required: true
309
- }, /*#__PURE__*/React.createElement("option", {
310
- key: "",
311
- value: ""
312
- }), countries.map(function (option) {
313
- return /*#__PURE__*/React.createElement("option", {
314
- key: option.iso,
315
- value: option.iso
316
- }, option.name);
317
- }))), /*#__PURE__*/React.createElement(Grid, {
318
- item: true,
319
- xs: 12
320
- }, /*#__PURE__*/React.createElement(TextField, {
321
- form: form,
322
- name: "comment",
323
- multiline: true,
324
- rowsMax: "20",
325
- label: t("Comment")
326
- })), /*#__PURE__*/React.createElement(Consent, {
327
- organisation: props.organisation,
328
- privacy_url: config.privacyUrl,
329
- form: form
330
- }), /*#__PURE__*/React.createElement(Grid, {
331
- item: true,
332
- xs: 12
333
- }, /*#__PURE__*/React.createElement(Button, {
334
- color: "primary",
335
- variant: "contained",
336
- fullWidth: true,
337
- type: "submit",
338
- size: "large",
339
- disabled: formState.isSubmitting,
340
- endIcon: /*#__PURE__*/React.createElement(SendIcon, null)
341
- }, " ", t("register"))))));
342
- }
343
- Register.propTypes = {
344
- actionPage: PropTypes.number.isRequired
345
- };
@@ -1,177 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from "react"; //import { Container, Grid } from "@material-ui/core";
4
-
5
- import { IconButton // ButtonGroup,
6
- // Button,
7
- , Card, CardHeader, CardActions, CardContent, CardMedia } from "@material-ui/core";
8
- import metadataparser from "page-metadata-parser";
9
- import uuid from "../lib/uuid";
10
- import { addAction } from "../lib/server";
11
- import Url from "../lib/urlparser";
12
- import { useTranslation } from "react-i18next";
13
- import useConfig from "../hooks/useConfig";
14
- import { EmailShareButton, FacebookShareButton, FacebookMessengerShareButton // InstapaperShareButton,
15
- // LineShareButton,
16
- , LinkedinShareButton // LivejournalShareButton,
17
- // MailruShareButton,
18
- // OKShareButton,
19
- // PinterestShareButton,
20
- // PocketShareButton,
21
- , RedditShareButton, TelegramShareButton // TumblrShareButton,
22
- , TwitterShareButton // ViberShareButton,
23
- // VKShareButton,
24
- , WhatsappShareButton // WorkplaceShareButton,
25
- , FacebookIcon, FacebookMessengerIcon, TwitterIcon, LinkedinIcon, TelegramIcon, WhatsappIcon, RedditIcon, EmailIcon } from "react-share";
26
- import { makeStyles } from "@material-ui/core/styles";
27
- var useStyles = makeStyles(function (theme) {
28
- return {
29
- media: {
30
- height: 0,
31
- paddingTop: "52.5%" // FB ratio
32
-
33
- },
34
- aamargin: {
35
- margin: theme.spacing(1),
36
- "& > *": {
37
- margin: theme.spacing(1)
38
- }
39
- },
40
- root: {
41
- "& p": {
42
- fontSize: theme.typography.pxToRem(16)
43
- },
44
- "& h3": {
45
- fontSize: theme.typography.pxToRem(20)
46
- }
47
- },
48
- widroot: {
49
- "& Button": {
50
- justifyContent: "left"
51
- },
52
- "& span": {
53
- justifyContent: "left",
54
- padding: "5px 10px"
55
- },
56
- "& > *": {
57
- margin: theme.spacing(1)
58
- }
59
- }
60
- };
61
- });
62
- /*
63
- const Transition = React.forwardRef(function Transition(props, ref) {
64
- return <Slide direction="up" ref={ref} {...props} />;
65
- });
66
- */
67
-
68
- export default function ShareAction(props) {
69
- var classes = useStyles();
70
-
71
- var _useConfig = useConfig(),
72
- config = _useConfig.config;
73
-
74
- var actionPage = config.actionPage;
75
- var metadata = metadataparser.getMetadata(window.document, window.location);
76
-
77
- var _useTranslation = useTranslation(),
78
- t = _useTranslation.t;
79
-
80
- var shareUrl = function shareUrl(component) {
81
- var url = new URL(window.location.href);
82
- var params = url.searchParams;
83
- params.set("utm_source", "share");
84
- params.set("utm_medium", component.render.displayName.replace("ShareButton-", ""));
85
- params.set("utm_campaign", uuid());
86
- return url.toString();
87
- };
88
-
89
- return /*#__PURE__*/React.createElement("div", {
90
- className: classes.root
91
- }, /*#__PURE__*/React.createElement("h3", null, t("share.title")), /*#__PURE__*/React.createElement("p", null, t("share.intro")), /*#__PURE__*/React.createElement(Card, {
92
- className: classes.root
93
- }, /*#__PURE__*/React.createElement(CardHeader, {
94
- title: metadata.title,
95
- subheader: metadata.provider
96
- }), metadata.image ? /*#__PURE__*/React.createElement(CardMedia, {
97
- className: classes.media,
98
- image: metadata.image,
99
- title: metadata.title
100
- }) : null, /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement("p", null, metadata.description)), /*#__PURE__*/React.createElement(CardActions, null, /*#__PURE__*/React.createElement(ActionIcon, {
101
- icon: WhatsappIcon,
102
- title: props["share-whatsapp"] || props.share,
103
- windowWidth: 715,
104
- windowHeight: 544,
105
- component: WhatsappShareButton
106
- }), /*#__PURE__*/React.createElement(ActionIcon, {
107
- icon: FacebookMessengerIcon,
108
- title: props["share-whatsapp"] || props.share,
109
- appId: "634127320642564",
110
- component: FacebookMessengerShareButton
111
- }), /*#__PURE__*/React.createElement(ActionIcon, {
112
- icon: FacebookIcon,
113
- component: FacebookShareButton
114
- }), /*#__PURE__*/React.createElement(ActionIcon, {
115
- icon: TwitterIcon,
116
- title: props["share-twitter"] || props.share,
117
- component: TwitterShareButton
118
- }), /*#__PURE__*/React.createElement(ActionIcon, {
119
- icon: TelegramIcon,
120
- component: TelegramShareButton
121
- }), /*#__PURE__*/React.createElement(ActionIcon, {
122
- icon: EmailIcon,
123
- component: EmailShareButton,
124
- subject: t("share.email.subject") || t("share.message"),
125
- body: t("share.email.body") || t("share.message"),
126
- separator: " "
127
- }), /*#__PURE__*/React.createElement(ActionIcon, {
128
- icon: RedditIcon,
129
- component: RedditShareButton
130
- }), /*#__PURE__*/React.createElement(ActionIcon, {
131
- icon: LinkedinIcon,
132
- component: LinkedinShareButton
133
- }))));
134
-
135
- function ActionIcon(props) {
136
- var medium = props.component.render.displayName.replace("ShareButton-", "");
137
-
138
- function addShare(event) {
139
- addAction(actionPage, event, {
140
- uuid: uuid(),
141
- payload: [{
142
- key: "medium",
143
- value: medium
144
- }],
145
- tracking: Url.utm()
146
- });
147
- }
148
-
149
- function after(props) {
150
- addShare("share_close");
151
- console.log("closing " + medium);
152
- }
153
-
154
- function before(props) {
155
- addShare("share_click");
156
- console.log("clicking " + medium);
157
- }
158
-
159
- var drillProps = _extends({}, props);
160
-
161
- delete drillProps.icon;
162
- return /*#__PURE__*/React.createElement(IconButton, _extends({}, drillProps, {
163
- component: props.component,
164
- url: shareUrl(props.component),
165
- title: props.title || props.share || t("share.message"),
166
- beforeOnClick: function beforeOnClick() {
167
- return before(props);
168
- },
169
- onShareWindowClose: function onShareWindowClose() {
170
- return after(props);
171
- }
172
- }), props.icon ? props.icon({
173
- round: true,
174
- size: 48
175
- }) : null);
176
- }
177
- }