proca 0.8.1 → 1.1.5
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/README.md +1079 -28
- package/package.json +94 -101
- package/proca-cli +8 -0
- package/src/commands/action/count.mjs +61 -0
- package/src/commands/action/list.mjs +204 -0
- package/src/commands/action/replay.mjs +54 -0
- package/src/commands/campaign/add.mjs +101 -0
- package/src/commands/campaign/delete.mjs +61 -0
- package/src/commands/campaign/get.mjs +107 -0
- package/src/commands/campaign/list.mjs +156 -0
- package/src/commands/campaign/queries.graphql +19 -0
- package/src/commands/config/add.mjs +101 -0
- package/src/commands/config/get.mjs +33 -0
- package/src/commands/config/set.mjs +103 -0
- package/src/commands/config/token.mjs +34 -0
- package/src/commands/config/user.mjs +76 -0
- package/src/commands/org/add.mjs +66 -0
- package/src/commands/org/crm.mjs +88 -0
- package/src/commands/org/delete.mjs +48 -0
- package/src/commands/org/get.mjs +97 -0
- package/src/commands/org/join.mjs +77 -0
- package/src/commands/supporter/count.mjs +96 -0
- package/src/commands/user/get.mjs +91 -0
- package/src/commands/user/leave.mjs +52 -0
- package/src/commands/user/list.mjs +71 -0
- package/src/commands/widget/add.mjs +101 -0
- package/src/commands/widget/cache.mjs +29 -0
- package/src/commands/widget/get.mjs +59 -0
- package/src/commands/widget/list.mjs +116 -0
- package/src/config.mjs +36 -0
- package/src/generated/schema.json +10677 -0
- package/src/hooks/help.mjs +14 -0
- package/src/hooks/init.mjs +20 -0
- package/src/index.mjs +1 -0
- package/src/procaCommand.mjs +242 -0
- package/src/queries/campaign.mjs +21 -0
- package/src/queries/widget.mjs +12 -0
- package/src/urql.mjs +60 -0
- package/src/util/twitter.mjs +23 -0
- package/theme.json +29 -0
- package/LICENSE +0 -661
- package/dist/App.css +0 -22
- package/dist/App.js +0 -25
- package/dist/App.test.js +0 -8
- package/dist/Wizard.js +0 -32
- package/dist/components/Alert.js +0 -49
- package/dist/components/Clickify.js +0 -26
- package/dist/components/Consent.js +0 -120
- package/dist/components/Country.js +0 -94
- package/dist/components/Dialog.js +0 -84
- package/dist/components/Disabled.js +0 -3
- package/dist/components/Emoji.js +0 -12
- package/dist/components/FAB.js +0 -70
- package/dist/components/Html.js +0 -56
- package/dist/components/Loader.js +0 -14
- package/dist/components/Openletter.js +0 -443
- package/dist/components/Organisation.js +0 -181
- package/dist/components/Petition.js +0 -16
- package/dist/components/ProcaRoot.js +0 -23
- package/dist/components/ProcaStyle.js +0 -94
- package/dist/components/ProgressCounter.js +0 -64
- package/dist/components/Register.js +0 -345
- package/dist/components/Share.js +0 -177
- package/dist/components/TextField.js +0 -58
- package/dist/components/Twitter.js +0 -127
- package/dist/components/TwitterAction.js +0 -111
- package/dist/components/TwitterList.js +0 -25
- package/dist/components/TwitterText.js +0 -42
- package/dist/components/Widget.js +0 -266
- package/dist/components/bespoke/Download.js +0 -49
- package/dist/components/bespoke/Register-CH.js +0 -505
- package/dist/data/countries.json +0 -114
- package/dist/hooks/useConfig.js +0 -217
- package/dist/hooks/useCount.js +0 -95
- package/dist/hooks/useData.js +0 -59
- package/dist/hooks/useElementWidth.js +0 -46
- package/dist/hooks/useGeoLocation.js +0 -45
- package/dist/hooks/useLayout.js +0 -63
- package/dist/images/Twitter.js +0 -16
- package/dist/images/Twitter.svg +0 -1
- package/dist/index.css +0 -13
- package/dist/index.js +0 -114
- package/dist/lib/domparser.js +0 -12
- package/dist/lib/i18n.js +0 -40
- package/dist/lib/init.js +0 -7
- package/dist/lib/server.js +0 -331
- package/dist/lib/urlparser.js +0 -65
- package/dist/lib/uuid.js +0 -30
- package/dist/locales/README.md +0 -37
- package/dist/locales/common.json +0 -189
- package/dist/locales/de/common.json +0 -46
- package/dist/locales/de/index.js +0 -0
- package/dist/locales/en/common.json +0 -45
- package/dist/locales/fr/common.json +0 -51
- package/dist/locales/index.js +0 -27
- package/dist/locales/it/common.json +0 -46
- package/dist/logo.svg +0 -1
- package/dist/module.js +0 -14
- package/dist/slingshot.xcf +0 -0
- package/dist/tmp.config/0.json +0 -21
- package/dist/tmp.config/2.json +0 -11
- package/dist/tmp.config/20.json +0 -29
- package/dist/tmp.config/28.json +0 -14
- package/dist/tmp.config/32.json +0 -34
- package/dist/tmp.config/35.json +0 -14
- package/dist/tmp.config/null.json +0 -1
|
@@ -1,58 +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";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { useLayout } from "../hooks/useLayout";
|
|
6
|
-
import { makeStyles } from "@material-ui/core/styles";
|
|
7
|
-
import { TextField } from "@material-ui/core";
|
|
8
|
-
var useStyles = makeStyles(function (theme) {
|
|
9
|
-
return {
|
|
10
|
-
container: {
|
|
11
|
-
display: "flex",
|
|
12
|
-
flexWrap: "wrap"
|
|
13
|
-
},
|
|
14
|
-
textField: {
|
|
15
|
-
marginLeft: theme.spacing(0),
|
|
16
|
-
marginRight: theme.spacing(0),
|
|
17
|
-
width: "100%"
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
export default (function (props) {
|
|
22
|
-
var _useTranslation = useTranslation(),
|
|
23
|
-
t = _useTranslation.t;
|
|
24
|
-
|
|
25
|
-
var layout = useLayout();
|
|
26
|
-
var classes = useStyles();
|
|
27
|
-
|
|
28
|
-
var handleBlur = function handleBlur(e) {
|
|
29
|
-
e.target.checkValidity();
|
|
30
|
-
|
|
31
|
-
if (e.target.validity.valid) {
|
|
32
|
-
clearError(e.target.attributes.name.nodeValue);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var _props$form = props.form,
|
|
38
|
-
errors = _props$form.errors,
|
|
39
|
-
register = _props$form.register,
|
|
40
|
-
clearError = _props$form.clearError,
|
|
41
|
-
watch = _props$form.watch;
|
|
42
|
-
var value = watch(props.name) || "";
|
|
43
|
-
return /*#__PURE__*/React.createElement(TextField, _extends({
|
|
44
|
-
id: props.name,
|
|
45
|
-
name: props.name,
|
|
46
|
-
label: t(props.name),
|
|
47
|
-
inputRef: register,
|
|
48
|
-
onBlur: handleBlur,
|
|
49
|
-
InputLabelProps: {
|
|
50
|
-
shrink: value.length > 0
|
|
51
|
-
},
|
|
52
|
-
className: classes.textField,
|
|
53
|
-
error: !!(errors && errors[props.name]),
|
|
54
|
-
helperText: errors && errors[props.name] && errors[props.name].message,
|
|
55
|
-
variant: layout.variant,
|
|
56
|
-
margin: layout.margin
|
|
57
|
-
}, props));
|
|
58
|
-
});
|
|
@@ -1,127 +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, { useState, useEffect, useCallback, Fragment } from "react";
|
|
18
|
-
import TwitterList from "./TwitterList";
|
|
19
|
-
import Dialog from "./Dialog";
|
|
20
|
-
import Country from "./Country";
|
|
21
|
-
import Register from "./Register";
|
|
22
|
-
import useConfig from "../hooks/useConfig";
|
|
23
|
-
import { useTranslation } from "react-i18next";
|
|
24
|
-
|
|
25
|
-
var Component = function Component(props) {
|
|
26
|
-
var _useState = useState([]),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
profiles = _useState2[0],
|
|
29
|
-
setProfiles = _useState2[1]; // const [filter, setFilter] = useState({country:null});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _useState3 = useState([]),
|
|
33
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
-
allProfiles = _useState4[0],
|
|
35
|
-
setAllProfiles = _useState4[1];
|
|
36
|
-
|
|
37
|
-
var _useState5 = useState(false),
|
|
38
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
39
|
-
dialog = _useState6[0],
|
|
40
|
-
viewDialog = _useState6[1];
|
|
41
|
-
|
|
42
|
-
var _useConfig = useConfig(),
|
|
43
|
-
config = _useConfig.config;
|
|
44
|
-
|
|
45
|
-
var _useTranslation = useTranslation(),
|
|
46
|
-
t = _useTranslation.t;
|
|
47
|
-
|
|
48
|
-
useEffect(function () {
|
|
49
|
-
var fetchData = /*#__PURE__*/function () {
|
|
50
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url) {
|
|
51
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
52
|
-
while (1) {
|
|
53
|
-
switch (_context.prev = _context.next) {
|
|
54
|
-
case 0:
|
|
55
|
-
_context.next = 2;
|
|
56
|
-
return fetch(url).then(function (res) {
|
|
57
|
-
if (!res.ok) throw res.error();
|
|
58
|
-
return res.json();
|
|
59
|
-
}).then(function (d) {
|
|
60
|
-
if (typeof config.hook["twitter:load"] === "function") {
|
|
61
|
-
config.hook["twitter:load"](d);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setAllProfiles(d);
|
|
65
|
-
}).catch(function (error) {
|
|
66
|
-
console.log(error);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
case 2:
|
|
70
|
-
case "end":
|
|
71
|
-
return _context.stop();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}, _callee);
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
return function fetchData(_x) {
|
|
78
|
-
return _ref.apply(this, arguments);
|
|
79
|
-
};
|
|
80
|
-
}();
|
|
81
|
-
|
|
82
|
-
if (props.targets.twitter_url) fetchData(props.targets.twitter_url);
|
|
83
|
-
}, [props.targets.twitter_url, config.hook, setAllProfiles]);
|
|
84
|
-
var filterProfiles = useCallback(function (country) {
|
|
85
|
-
// setProfiles(allProfiles);
|
|
86
|
-
if (!country) return;
|
|
87
|
-
country = country.toLowerCase();
|
|
88
|
-
var d = allProfiles.filter(function (d) {
|
|
89
|
-
return d.country === country || d.country === "";
|
|
90
|
-
});
|
|
91
|
-
setProfiles(d);
|
|
92
|
-
}, [allProfiles]);
|
|
93
|
-
useEffect(function () {
|
|
94
|
-
// setFilter({country:config.country});
|
|
95
|
-
filterProfiles(config.country);
|
|
96
|
-
/* if (typeof config.hook["twitter:load"] === "function") {
|
|
97
|
-
let d = allProfiles;
|
|
98
|
-
config.hook["twitter:load"](d);
|
|
99
|
-
setProfiles(d);
|
|
100
|
-
}*/
|
|
101
|
-
}, [config.country, filterProfiles]);
|
|
102
|
-
|
|
103
|
-
var handleDone = function handleDone(d) {
|
|
104
|
-
viewDialog(true);
|
|
105
|
-
}; // <TwitterText text={actionText} handleChange={handleChange} label="Your message to them"/>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Dialog, {
|
|
109
|
-
dialog: dialog,
|
|
110
|
-
actionPage: props.actionPage,
|
|
111
|
-
content: Register,
|
|
112
|
-
name: config.param.dialogTitle || t("Let's keep in touch")
|
|
113
|
-
}, /*#__PURE__*/React.createElement(Register, {
|
|
114
|
-
actionPage: props.actionPage
|
|
115
|
-
})), /*#__PURE__*/React.createElement(Country, null), /*#__PURE__*/React.createElement(TwitterList, {
|
|
116
|
-
profiles: profiles,
|
|
117
|
-
actionPage: props.actionPage,
|
|
118
|
-
actionUrl: config.param.actionUrl || props.actionUrl,
|
|
119
|
-
actionText: config.param.twitterText || props.actionText,
|
|
120
|
-
done: handleDone
|
|
121
|
-
}));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
Component.defaultProps = {
|
|
125
|
-
actionText: ".{@} you should check that!"
|
|
126
|
-
};
|
|
127
|
-
export default Component;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
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."); }
|
|
4
|
-
|
|
5
|
-
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); }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
|
-
import React, { useState } from 'react';
|
|
14
|
-
import ListItem from '@material-ui/core/ListItem';
|
|
15
|
-
import ListItemText from '@material-ui/core/ListItemText';
|
|
16
|
-
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
|
17
|
-
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
|
|
18
|
-
import Avatar from '@material-ui/core/Avatar';
|
|
19
|
-
import SvgIcon from '@material-ui/core/SvgIcon';
|
|
20
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
21
|
-
import PropTypes from "prop-types"; // TODO: use it to check tweets' length https://www.npmjs.com/package/twitter-text
|
|
22
|
-
//import { ReactComponent as TwitterIcon } from '../images/Twitter.svg';
|
|
23
|
-
|
|
24
|
-
import TwitterIcon from "../images/Twitter.js";
|
|
25
|
-
import { addAction } from "../lib/server";
|
|
26
|
-
import uuid from "../lib/uuid";
|
|
27
|
-
|
|
28
|
-
var component = function TwitterAction(profile) {
|
|
29
|
-
var _useState = useState(false),
|
|
30
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
-
disabled = _useState2[0],
|
|
32
|
-
disable = _useState2[1];
|
|
33
|
-
|
|
34
|
-
var _useState3 = useState(false),
|
|
35
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
-
selected = _useState4[0],
|
|
37
|
-
select = _useState4[1];
|
|
38
|
-
|
|
39
|
-
var img = function img() {
|
|
40
|
-
return profile.profile_image_url_https;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
function addTweet(event, screenName) {
|
|
44
|
-
addAction(profile.actionPage, event, {
|
|
45
|
-
uuid: uuid(),
|
|
46
|
-
// tracking: Url.utm(),
|
|
47
|
-
payload: [{
|
|
48
|
-
key: "screen_name",
|
|
49
|
-
value: screenName
|
|
50
|
-
}]
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var tweet = function tweet(e) {
|
|
55
|
-
var t = typeof profile.actionText == "function" ? profile.actionText(profile) : profile.actionText;
|
|
56
|
-
if (t.indexOf("{@}") !== -1) t = t.replace("{@}", "@" + profile.screen_name);else t = ".@" + profile.screen_name + " " + t;
|
|
57
|
-
|
|
58
|
-
if (profile.actionUrl) {
|
|
59
|
-
if (t.indexOf("{url}") !== -1) t = t.replace("{url}", profile.actionUrl);else t = t + " " + profile.actionUrl;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var url = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(t);
|
|
63
|
-
var win = window.open(url, "tweet-" + profile.screen_name, "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=550");
|
|
64
|
-
select(true);
|
|
65
|
-
addTweet("twitter_click", profile.screen_name);
|
|
66
|
-
var timer = setInterval(function () {
|
|
67
|
-
if (win.closed) {
|
|
68
|
-
clearInterval(timer);
|
|
69
|
-
disable(true);
|
|
70
|
-
select(false);
|
|
71
|
-
addTweet("twitter_close", profile.screen_name);
|
|
72
|
-
if (profile.done instanceof Function) profile.done();
|
|
73
|
-
}
|
|
74
|
-
}, 1000);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return /*#__PURE__*/React.createElement(ListItem, {
|
|
78
|
-
alignItems: "flex-start",
|
|
79
|
-
selected: selected,
|
|
80
|
-
disabled: disabled,
|
|
81
|
-
button: true,
|
|
82
|
-
onClick: tweet,
|
|
83
|
-
divider: true
|
|
84
|
-
}, /*#__PURE__*/React.createElement(ListItemAvatar, null, /*#__PURE__*/React.createElement(Avatar, {
|
|
85
|
-
src: img()
|
|
86
|
-
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
87
|
-
primary: profile.name,
|
|
88
|
-
secondary: profile.description
|
|
89
|
-
}), /*#__PURE__*/React.createElement(ListItemSecondaryAction, null, /*#__PURE__*/React.createElement(IconButton, {
|
|
90
|
-
edge: "end",
|
|
91
|
-
"aria-label": "Tweet",
|
|
92
|
-
onClick: tweet
|
|
93
|
-
}, /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement(TwitterIcon, null)))));
|
|
94
|
-
}; //component.defaultProps = {
|
|
95
|
-
// screen_name = "eucampaign";
|
|
96
|
-
// text
|
|
97
|
-
// via
|
|
98
|
-
//}
|
|
99
|
-
// you can have actionText (text of function(profile))
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
component.propTypes = {
|
|
103
|
-
screen_name: PropTypes.string.isRequired,
|
|
104
|
-
name: PropTypes.string,
|
|
105
|
-
image: PropTypes.string,
|
|
106
|
-
url: PropTypes.string,
|
|
107
|
-
actionUrl: PropTypes.string,
|
|
108
|
-
description: PropTypes.string,
|
|
109
|
-
className: PropTypes.string
|
|
110
|
-
};
|
|
111
|
-
export default component;
|
|
@@ -1,25 +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';
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import List from '@material-ui/core/List';
|
|
6
|
-
import TwitterAction from "./TwitterAction";
|
|
7
|
-
|
|
8
|
-
var component = function component(props) {
|
|
9
|
-
return /*#__PURE__*/React.createElement(List, null, props.profiles.map(function (d) {
|
|
10
|
-
return /*#__PURE__*/React.createElement(TwitterAction, _extends({
|
|
11
|
-
key: d.id,
|
|
12
|
-
actionPage: props.actionPage,
|
|
13
|
-
done: props.done,
|
|
14
|
-
actionUrl: props.actionUrl,
|
|
15
|
-
actionText: props.actionText
|
|
16
|
-
}, d));
|
|
17
|
-
}));
|
|
18
|
-
}; // you can have actionText (text of function(profile))
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
component.propTypes = {
|
|
22
|
-
actionUrl: PropTypes.string,
|
|
23
|
-
actionText: PropTypes.string.isRequired
|
|
24
|
-
};
|
|
25
|
-
export default component;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
-
import Input from '@material-ui/core/Input';
|
|
4
|
-
import InputLabel from '@material-ui/core/InputLabel';
|
|
5
|
-
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
6
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
7
|
-
import TextField from '@material-ui/core/TextField';
|
|
8
|
-
import Grid from '@material-ui/core/Grid';
|
|
9
|
-
import EditIcon from '@material-ui/icons/Edit';
|
|
10
|
-
var useStyles = makeStyles({
|
|
11
|
-
fullWidth: {
|
|
12
|
-
width: '100%'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
export default function Component(props) {
|
|
16
|
-
var classes = useStyles();
|
|
17
|
-
return /*#__PURE__*/React.createElement(Grid, {
|
|
18
|
-
container: true,
|
|
19
|
-
spacing: 1,
|
|
20
|
-
alignItems: "stretch"
|
|
21
|
-
}, /*#__PURE__*/React.createElement(Grid, {
|
|
22
|
-
item: true,
|
|
23
|
-
xs: 12
|
|
24
|
-
}, /*#__PURE__*/React.createElement(TextField, {
|
|
25
|
-
label: props.label,
|
|
26
|
-
className: classes.fullWidth,
|
|
27
|
-
fullWidth: true,
|
|
28
|
-
onChange: props.handleChange,
|
|
29
|
-
value: props.text,
|
|
30
|
-
InputProps: {
|
|
31
|
-
startAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
|
|
32
|
-
position: "start"
|
|
33
|
-
}, /*#__PURE__*/React.createElement(EditIcon, null))
|
|
34
|
-
}
|
|
35
|
-
})));
|
|
36
|
-
}
|
|
37
|
-
Component.defaultProps = {
|
|
38
|
-
handleChange: function handleChange() {
|
|
39
|
-
return console.log("Warning: you should set a change event handler");
|
|
40
|
-
},
|
|
41
|
-
label: "Tweet"
|
|
42
|
-
};
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
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); }
|
|
8
|
-
|
|
9
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
-
|
|
11
|
-
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."); }
|
|
12
|
-
|
|
13
|
-
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); }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
-
|
|
21
|
-
import React, { useState, useRef, useCallback } from "react";
|
|
22
|
-
import ProcaRoot from "./ProcaRoot";
|
|
23
|
-
import { initConfigState } from "../hooks/useConfig";
|
|
24
|
-
import Url from "../lib/urlparser.js";
|
|
25
|
-
import { getAllData } from "../lib/domparser"; //import { useTheme } from "@material-ui/core/styles";
|
|
26
|
-
|
|
27
|
-
import { useMediaQuery } from "@material-ui/core";
|
|
28
|
-
import { initDataState } from "../hooks/useData";
|
|
29
|
-
/* warning, magic trick ahead: in the webpack config-overwrite, we set Conditional_XX either as the real component, or a dummy empty one if the step isn't part of the journey */
|
|
30
|
-
|
|
31
|
-
import Loader from "./Loader";
|
|
32
|
-
import Petition from "Conditional_Petition"; //import Button from "Conditional_FAB";
|
|
33
|
-
|
|
34
|
-
import Button from "./FAB";
|
|
35
|
-
import Share from "Conditional_Share";
|
|
36
|
-
import Twitter from "Conditional_Twitter"; //import Dialog from "Conditional_Dialog";
|
|
37
|
-
|
|
38
|
-
import Dialog from "./Dialog";
|
|
39
|
-
import Clickify from "Conditional_Clickify";
|
|
40
|
-
import Html from "Conditional_Html"; // bespoke
|
|
41
|
-
|
|
42
|
-
import RegisterCH from "Conditional_bespoke/Register-CH";
|
|
43
|
-
import Download from "Conditional_bespoke/Download"; // import Slide from '@material-ui/core/Slide'; do the sliding transition thing
|
|
44
|
-
|
|
45
|
-
var allSteps = {
|
|
46
|
-
loader: Loader,
|
|
47
|
-
petition: Petition,
|
|
48
|
-
button: Button,
|
|
49
|
-
share: Share,
|
|
50
|
-
twitter: Twitter,
|
|
51
|
-
clickify: Clickify,
|
|
52
|
-
html: Html,
|
|
53
|
-
dialog: Dialog,
|
|
54
|
-
"register.CH": RegisterCH,
|
|
55
|
-
download: Download
|
|
56
|
-
}; // handling case of components returning multiple Components/functions
|
|
57
|
-
|
|
58
|
-
if (!Dialog instanceof Function) {
|
|
59
|
-
allSteps.dialog = Dialog.Open;
|
|
60
|
-
allSteps.close = Dialog.Close;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var steps = {};
|
|
64
|
-
process.widget.journey.forEach(function (d) {
|
|
65
|
-
if (d instanceof Array) {
|
|
66
|
-
// substep case
|
|
67
|
-
d.forEach(function (e) {
|
|
68
|
-
return steps[e] = allSteps[e];
|
|
69
|
-
});
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
steps[d] = allSteps[d];
|
|
74
|
-
});
|
|
75
|
-
var config = {
|
|
76
|
-
data: Url.data(),
|
|
77
|
-
utm: Url.utm(),
|
|
78
|
-
hook: {},
|
|
79
|
-
param: {}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
var Widget = function Widget(props) {
|
|
83
|
-
var _useState = useState(0),
|
|
84
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
85
|
-
current = _useState2[0],
|
|
86
|
-
setCurrent = _useState2[1];
|
|
87
|
-
|
|
88
|
-
var _React$useState = React.useState(),
|
|
89
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
90
|
-
updateState = _React$useState2[1];
|
|
91
|
-
|
|
92
|
-
var forceUpdate = useCallback(function () {
|
|
93
|
-
return updateState({});
|
|
94
|
-
}, []);
|
|
95
|
-
var Action = null; // const theme = useTheme();
|
|
96
|
-
// const isMobile = useMediaQuery(theme.breakpoints.down("sm"),{noSsr:true});
|
|
97
|
-
|
|
98
|
-
var isMobile = useMediaQuery("(max-width:768px)", {
|
|
99
|
-
noSsr: true
|
|
100
|
-
});
|
|
101
|
-
var depths = []; // one entry per action in the journey, 0 = top level, 1 = top level avec substeps, 2 = substeps
|
|
102
|
-
|
|
103
|
-
var topMulti = useRef(); // latest Action level 0 rendered
|
|
104
|
-
|
|
105
|
-
var propsJourney = _extends([], props.journey);
|
|
106
|
-
|
|
107
|
-
initDataState(Url.data());
|
|
108
|
-
|
|
109
|
-
if (isMobile) {
|
|
110
|
-
var j = _extends([], props.journey);
|
|
111
|
-
|
|
112
|
-
if (j[0] !== "dialog") j.unshift("dialog");
|
|
113
|
-
propsJourney = ["button", j];
|
|
114
|
-
steps["button"] = allSteps["button"];
|
|
115
|
-
steps["dialog"] = allSteps["dialog"];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
var journey = propsJourney.flat();
|
|
119
|
-
|
|
120
|
-
if (current === false) {
|
|
121
|
-
setCurrent(0);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (props.loader) {
|
|
126
|
-
config.loader = props.loader;
|
|
127
|
-
journey.unshift("loader");
|
|
128
|
-
steps["loader"] = Loader;
|
|
129
|
-
depths.push(0);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
propsJourney.forEach(function (d) {
|
|
133
|
-
if (d instanceof Array) {
|
|
134
|
-
d.forEach(function (e, i) {
|
|
135
|
-
depths.push(i > 0 ? 2 : 1);
|
|
136
|
-
}); // the first of a multistep is on level 1 (eg dialog, sinon 2)
|
|
137
|
-
} else depths.push(0);
|
|
138
|
-
});
|
|
139
|
-
initConfigState(props);
|
|
140
|
-
if (props) config = _objectSpread({}, config, {}, props);
|
|
141
|
-
config.param = getAllData(config.selector);
|
|
142
|
-
config.actionPage = parseInt(config.actionPage, 10);
|
|
143
|
-
|
|
144
|
-
var getActions = function getActions() {
|
|
145
|
-
return steps;
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
var go = function go(action) {
|
|
149
|
-
var i = null;
|
|
150
|
-
|
|
151
|
-
if (typeof action === "number" && action <= journey.length) {
|
|
152
|
-
i = action - 1;
|
|
153
|
-
if (i === current) return forceUpdate(); //trick to force refresh
|
|
154
|
-
} else {
|
|
155
|
-
if (!action) return nextStep();
|
|
156
|
-
i = journey.indexOf(action);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (i === -1) {
|
|
160
|
-
console.error("can't find '", action, "'. options: ", journey);
|
|
161
|
-
global.proca.Alert("not possible to go to '" + action + "'", "error");
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (depths[i] === 1) {
|
|
166
|
-
// we jump 2 if start of a sub (dialog + 1st substep) {
|
|
167
|
-
topMulti.current = journey[i];
|
|
168
|
-
setCurrent(i + 1);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
setCurrent(i);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var nextTopStep = function nextTopStep() {
|
|
176
|
-
var next = depths.findIndex(function (d, i) {
|
|
177
|
-
return i > current && d === 0;
|
|
178
|
-
});
|
|
179
|
-
if (next === -1) return setCurrent(0);
|
|
180
|
-
setCurrent(next);
|
|
181
|
-
}; // called once an action has finished to decide what to do next.
|
|
182
|
-
// the result is whatever the action that has finished wants to share to the journey
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var nextStep = function nextStep(result) {
|
|
187
|
-
// nextStep checks if there is a bespoke action to run after the current step (created by calling proca.after)
|
|
188
|
-
//console.log(config.hook);
|
|
189
|
-
if (typeof steps[journey[current]].after === "function") {
|
|
190
|
-
if (steps[journey[current]].after(result) === false) {
|
|
191
|
-
console.log("the custom 'after' returned false, we do not go to the next step");
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (current < journey.length && depths[current + 1] === 1) {
|
|
197
|
-
// we jump 2 if start of a sub (dialog + 1st substep) {
|
|
198
|
-
topMulti.current = journey[current + 1];
|
|
199
|
-
setCurrent(current + 2);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (current < journey.length - 1) {
|
|
204
|
-
setCurrent(current + 1);
|
|
205
|
-
} else {
|
|
206
|
-
console.error("end of the journey, no more steps");
|
|
207
|
-
setCurrent(0);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
if (current >= journey.length) {
|
|
212
|
-
console.log("journey went off track, reset to the first step");
|
|
213
|
-
setCurrent(0); // might happen if the journey is dynamically modified, eg FAB on isMobile-> return to wide screen
|
|
214
|
-
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
switch (depths[current]) {
|
|
219
|
-
case 0:
|
|
220
|
-
Action = steps[journey[current]];
|
|
221
|
-
|
|
222
|
-
if (!Action) {
|
|
223
|
-
console.log(current, journey, steps, steps[journey[current]]);
|
|
224
|
-
return "FATAL Error, check the log";
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return /*#__PURE__*/React.createElement(ProcaRoot, {
|
|
228
|
-
go: go,
|
|
229
|
-
actions: getActions,
|
|
230
|
-
config: config
|
|
231
|
-
}, /*#__PURE__*/React.createElement(Action, {
|
|
232
|
-
actionPage: config.actionPage,
|
|
233
|
-
done: nextStep
|
|
234
|
-
}));
|
|
235
|
-
//break;
|
|
236
|
-
|
|
237
|
-
case 1:
|
|
238
|
-
case 2:
|
|
239
|
-
var SubAction = steps[journey[current]];
|
|
240
|
-
Action = steps[topMulti.current];
|
|
241
|
-
return /*#__PURE__*/React.createElement(ProcaRoot, {
|
|
242
|
-
go: go,
|
|
243
|
-
actions: getActions,
|
|
244
|
-
config: config
|
|
245
|
-
}, /*#__PURE__*/React.createElement(Action, {
|
|
246
|
-
actionPage: config.actionPage,
|
|
247
|
-
done: nextTopStep
|
|
248
|
-
}, /*#__PURE__*/React.createElement(SubAction, {
|
|
249
|
-
actionPage: config.actionPage,
|
|
250
|
-
done: nextStep
|
|
251
|
-
})));
|
|
252
|
-
//break;
|
|
253
|
-
|
|
254
|
-
default:
|
|
255
|
-
throw Error("Oops, it should be a sub step");
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
Widget.getSteps = function () {
|
|
260
|
-
return allSteps;
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
Widget.jump = function (step) {// name of the step of true to skip to next action
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export default Widget;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Card from '@material-ui/core/Card';
|
|
3
|
-
import CardActions from '@material-ui/core/CardActions';
|
|
4
|
-
import CardContent from '@material-ui/core/CardContent';
|
|
5
|
-
import Button from '@material-ui/core/Button';
|
|
6
|
-
import Typography from '@material-ui/core/Typography';
|
|
7
|
-
import SaveIcon from '@material-ui/icons/SaveAlt';
|
|
8
|
-
import { useTranslation } from "react-i18next";
|
|
9
|
-
import useConfig from "../../hooks/useConfig";
|
|
10
|
-
|
|
11
|
-
var url = function url(data, param) {
|
|
12
|
-
var postcardUrl = "https://collect-pdf.campax.org?" + "postalcode=" + data.postcode + "&canton=" + data.region + "&birthdate=" + data.birthdate + "&address=" + data.address + "&locality=" + data.locality;
|
|
13
|
-
if (param.pdfUrl) postcardUrl += "&pdf=" + encodeURIComponent(param.pdfUrl);
|
|
14
|
-
if (param.marginTop) postcardUrl += "&top=" + param.marginTop;
|
|
15
|
-
return postcardUrl;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function Download(props) {
|
|
19
|
-
var _useTranslation = useTranslation(),
|
|
20
|
-
t = _useTranslation.t;
|
|
21
|
-
|
|
22
|
-
var _useConfig = useConfig(),
|
|
23
|
-
config = _useConfig.config;
|
|
24
|
-
|
|
25
|
-
var next = function next() {
|
|
26
|
-
if (props.done instanceof Function) props.done();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var handleDownload = function handleDownload() {
|
|
30
|
-
console.log(config.data);
|
|
31
|
-
window.open(config.data.postcardUrl, 'pdf', 'toolbar=0,status=0,width=548,height=775');
|
|
32
|
-
next();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(Typography, {
|
|
36
|
-
variant: "h5",
|
|
37
|
-
gutterBottom: true
|
|
38
|
-
}, t("Thank you")), /*#__PURE__*/React.createElement("p", null, t("Download explanation"))), /*#__PURE__*/React.createElement(CardActions, null, /*#__PURE__*/React.createElement(Button, {
|
|
39
|
-
variant: "contained",
|
|
40
|
-
color: "primary",
|
|
41
|
-
onClick: handleDownload,
|
|
42
|
-
startIcon: /*#__PURE__*/React.createElement(SaveIcon, null)
|
|
43
|
-
}, t("Download")), /*#__PURE__*/React.createElement(Button, {
|
|
44
|
-
onClick: next
|
|
45
|
-
}, t("Next"))));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export default Download;
|
|
49
|
-
export { url };
|