@plusscommunities/pluss-core-web 1.7.3-beta.0 → 1.7.3-beta.1

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 (116) hide show
  1. package/.babelrc +3 -0
  2. package/dist/components.js +390 -33094
  3. package/dist/components.js.map +1 -1
  4. package/dist/index.cjs.js +10388 -0
  5. package/dist/index.esm.js +10349 -0
  6. package/dist/index.js +394 -33098
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.umd.js +10361 -0
  9. package/package.json +31 -22
  10. package/rollup.config.js +57 -0
  11. package/src/actions/AuthActions.js +83 -0
  12. package/src/actions/LocalActions.js +8 -0
  13. package/src/actions/NavActions.js +8 -0
  14. package/src/actions/ScheduledActionsActions.js +8 -0
  15. package/src/actions/TemplateActions.js +15 -0
  16. package/src/actions/UsersActions.js +95 -0
  17. package/src/actions/index.js +6 -0
  18. package/src/actions/types.js +23 -0
  19. package/src/analytics.js +183 -0
  20. package/src/apis/analyticsActions.js +53 -0
  21. package/src/apis/authActions.js +58 -0
  22. package/src/apis/fileActions.js +152 -0
  23. package/src/apis/index.js +10 -0
  24. package/src/apis/profileActions.js +133 -0
  25. package/src/apis/scheduledActionsActions.js +12 -0
  26. package/src/apis/stringActions.js +25 -0
  27. package/src/apis/templateActions.js +41 -0
  28. package/src/apis/typeActions.js +186 -0
  29. package/src/apis/userActions.js +169 -0
  30. package/src/apis/utilityActions.js +35 -0
  31. package/src/colours.js +134 -0
  32. package/src/components/AddButton.js +27 -0
  33. package/src/components/AnalyticsFilter.js +115 -0
  34. package/src/components/Attachment.js +27 -0
  35. package/src/components/AudienceIncluder.js +175 -0
  36. package/src/components/AudienceSelector.js +700 -0
  37. package/src/components/Button.js +66 -0
  38. package/src/components/CheckBox.js +77 -0
  39. package/src/components/ColourOptions.js +197 -0
  40. package/src/components/ColourPicker.js +267 -0
  41. package/src/components/Comment.js +46 -0
  42. package/src/components/CommentSection.js +116 -0
  43. package/src/components/DatePicker.js +290 -0
  44. package/src/components/DropdownInput.js +223 -0
  45. package/src/components/DurationInput.js +51 -0
  46. package/src/components/ExportCsvPopup.js +222 -0
  47. package/src/components/FileInput.js +389 -0
  48. package/src/components/GenericInput.js +169 -0
  49. package/src/components/Header.js +82 -0
  50. package/src/components/HubSidebar.js +134 -0
  51. package/src/components/ImageInput.js +987 -0
  52. package/src/components/InputGroup.js +18 -0
  53. package/src/components/MakerPopup.js +310 -0
  54. package/src/components/MoreMenu.js +22 -0
  55. package/src/components/OptionsSection.js +84 -0
  56. package/src/components/OverlayPage.js +74 -0
  57. package/src/components/OverlayPageBottomButtons.js +48 -0
  58. package/src/components/OverlayPageContents.js +48 -0
  59. package/src/components/OverlayPageSection.js +38 -0
  60. package/src/components/P60Icon.js +40 -0
  61. package/src/components/PageTitle.js +13 -0
  62. package/src/components/Popup.js +104 -0
  63. package/src/components/ProfilePic.js +50 -0
  64. package/src/components/RadioButton.js +144 -0
  65. package/src/components/Reactions.js +77 -0
  66. package/src/components/SVGIcon.js +33 -0
  67. package/src/components/SideNavItem.js +98 -0
  68. package/src/components/StatBox.js +49 -0
  69. package/src/components/StatusButton.js +22 -0
  70. package/src/components/SuccessPopup.js +57 -0
  71. package/src/components/Tabs.js +56 -0
  72. package/src/components/Tag.js +62 -0
  73. package/src/components/Text.js +20 -0
  74. package/src/components/TextFormatPopup.js +54 -0
  75. package/src/components/TimePicker.js +225 -0
  76. package/src/components/UserListing.js +111 -0
  77. package/src/components/index.js +46 -0
  78. package/src/components/svg-icons.json +821 -0
  79. package/src/config.js +25 -0
  80. package/src/helper/HelpDeskWidget.js +16 -0
  81. package/src/helper/api/getUrl.js +15 -0
  82. package/src/helper/api/getUrlParams.js +9 -0
  83. package/src/helper/api/safeReadParams.js +6 -0
  84. package/src/helper/auth/getUserFromState.js +8 -0
  85. package/src/helper/colours/getAppColourFromState.js +10 -0
  86. package/src/helper/files/canvasImageUploader.js +159 -0
  87. package/src/helper/files/generateImageName.js +10 -0
  88. package/src/helper/files/get1400.js +32 -0
  89. package/src/helper/files/getExtension.js +9 -0
  90. package/src/helper/files/getFileName.js +13 -0
  91. package/src/helper/files/getThumb300.js +36 -0
  92. package/src/helper/files/isVideo.js +8 -0
  93. package/src/helper/helper.js +97 -0
  94. package/src/helper/index.js +44 -0
  95. package/src/helper/site/getMerchantsFromState.js +9 -0
  96. package/src/helper/site/getSiteLevelFromState.js +34 -0
  97. package/src/helper/site/getSiteName.js +16 -0
  98. package/src/helper/site/getSiteNameFromRoles.js +12 -0
  99. package/src/helper/site/getSiteSettingFromState.js +10 -0
  100. package/src/helper/storage/readJSONFromStorage.js +9 -0
  101. package/src/helper/storage/readStorageWithCookie.js +22 -0
  102. package/src/helper/storage/setLocalStorage.js +5 -0
  103. package/src/helper/strings/getFirstName.js +10 -0
  104. package/src/helper/strings/htmlDecode.js +4 -0
  105. package/src/helper/strings/htmlEncode.js +4 -0
  106. package/src/helper/strings/isEmail.js +11 -0
  107. package/src/helper/strings/isUrl.js +13 -0
  108. package/src/helper/strings/onlyAlphanumeric.js +8 -0
  109. package/src/helper/strings/randomString.js +10 -0
  110. package/src/helper/strings/toParagraphed.js +17 -0
  111. package/src/index.js +12 -0
  112. package/src/reducers/ScheduledActionsReducer.js +14 -0
  113. package/src/reducers/TemplatesReducer.js +29 -0
  114. package/src/reducers/index.js +7 -0
  115. package/src/session.js +289 -0
  116. package/src/urls.js +21 -0
@@ -0,0 +1,169 @@
1
+ import React, { Component } from 'react';
2
+ import _ from 'lodash';
3
+ import Textarea from 'react-textarea-autosize';
4
+
5
+ class GenericInput extends Component {
6
+ componentDidUpdate(prevProps, prevState) {
7
+ if (!_.isUndefined(this.props.autofocus) && this.props.autofocus) {
8
+ this._input.focus();
9
+ }
10
+ }
11
+
12
+ getAutoComplete() {
13
+ if (!_.isUndefined(this.props.autoComplete)) {
14
+ return this.props.autoComplete ? 'on' : 'off';
15
+ }
16
+ return 'off';
17
+ }
18
+
19
+ isValid() {
20
+ if (!_.isUndefined(this.props.isValid) && typeof this.props.isValid === 'function') {
21
+ return this.props.isValid();
22
+ }
23
+ return this.props.isValid;
24
+ }
25
+
26
+ showError() {
27
+ return (
28
+ !_.isUndefined(this.props.showError) &&
29
+ ((typeof this.props.showError === 'function' && this.props.showError()) ||
30
+ (typeof this.props.showError === 'boolean' && this.props.showError))
31
+ );
32
+ }
33
+
34
+ getClassNames() {
35
+ let string = `${this.props.className} genericInputContainer`;
36
+ if (!_.isUndefined(this.props.disabled) && this.props.disabled) {
37
+ string += ' genericInput-disabled';
38
+ }
39
+ if (this.props.large) {
40
+ string += ' genericInput-large';
41
+ }
42
+ if (!_.isUndefined(this.props.type) && this.props.type === 'textarea') {
43
+ string += ' genericInput-textarea';
44
+ }
45
+ if (this.isValid()) {
46
+ return string + ' genericInput-valid';
47
+ }
48
+ if (this.showError()) {
49
+ return string + ' genericInput-error';
50
+ }
51
+ return string;
52
+ }
53
+
54
+ getLabelStyle() {
55
+ const style = {};
56
+ if (_.isEmpty(this.props.value) && !this.props.alwaysShowLabel) {
57
+ style.opacity = 0;
58
+ }
59
+ return style;
60
+ }
61
+
62
+ renderError() {
63
+ if (this.showError() && !this.isValid()) {
64
+ return <div className={'fieldLabel fieldLabel-warning'}>{this.props.errorMessage ? this.props.errorMessage : 'Required'}</div>;
65
+ }
66
+ return null;
67
+ }
68
+ renderHelp() {
69
+ if (!_.isEmpty(this.props.help)) {
70
+ return <div className="genericInput-help">{this.props.help}</div>;
71
+ }
72
+ return null;
73
+ }
74
+
75
+ renderInput() {
76
+ if (!_.isUndefined(this.props.inputComponent)) {
77
+ return (
78
+ <div style={{ ...styles.row, alignItems: 'flex-start' }}>
79
+ {this.props.isRequired && <div className="inputRequired " />}
80
+ {this.props.inputComponent}
81
+ {this.props.rightContent}
82
+ </div>
83
+ );
84
+ }
85
+ if (!_.isUndefined(this.props.type) && this.props.type === 'textarea') {
86
+ // Render expandable text area
87
+ return (
88
+ <div style={{ ...styles.row, alignItems: 'flex-start' }}>
89
+ {this.props.isRequired && <div className="inputRequired " />}
90
+ <Textarea
91
+ id={this.props.id}
92
+ placeholder={!_.isUndefined(this.props.placeholder) ? this.props.placeholder : this.props.label}
93
+ type={!_.isUndefined(this.props.type) ? this.props.type : 'text'}
94
+ className={`genericInput ${this.props.inputClass}`}
95
+ value={this.props.value || ''}
96
+ onChange={this.props.onChange}
97
+ onKeyPress={this.props.onKeyPress || this.props.onEnter}
98
+ onKeyDown={this.props.onKeyDown}
99
+ style={{ ...this.props.inputStyle }}
100
+ readOnly={!_.isUndefined(this.props.readOnly) ? this.props.readOnly : false}
101
+ disabled={!_.isUndefined(this.props.disabled) ? this.props.disabled : false}
102
+ autoComplete={this.getAutoComplete()}
103
+ maxLength={this.props.maxLength}
104
+ onFocus={this.props.onFocus}
105
+ onBlur={this.props.onBlur}
106
+ />
107
+ {this.props.rightContent}
108
+ </div>
109
+ );
110
+ }
111
+ // Render default input
112
+ return (
113
+ <div style={{ ...styles.row, ...this.props.textWrapperStyle }}>
114
+ {this.props.isRequired && <div className="inputRequired " />}
115
+ <input
116
+ ref={(c) => (this._input = c)}
117
+ id={this.props.id}
118
+ placeholder={!_.isUndefined(this.props.placeholder) ? this.props.placeholder : this.props.label}
119
+ type={!_.isUndefined(this.props.type) ? this.props.type : 'text'}
120
+ className={`genericInput ${this.props.inputClass}`}
121
+ value={this.props.value || ''}
122
+ onChange={this.props.onChange}
123
+ onClick={this.props.onClick}
124
+ onKeyPress={this.props.onKeyPress || this.props.onEnter}
125
+ onKeyDown={this.props.onKeyDown}
126
+ style={{ ...this.props.inputStyle }}
127
+ readOnly={!_.isUndefined(this.props.readOnly) ? this.props.readOnly : false}
128
+ disabled={!_.isUndefined(this.props.disabled) ? this.props.disabled : false}
129
+ autoComplete={this.getAutoComplete()}
130
+ autoFocus={!_.isUndefined(this.props.autofocus) ? this.props.autofocus : false}
131
+ maxLength={this.props.maxLength}
132
+ onFocus={this.props.onFocus}
133
+ onBlur={this.props.onBlur}
134
+ />
135
+ {this.props.rightContent}
136
+ </div>
137
+ );
138
+ }
139
+
140
+ render() {
141
+ return (
142
+ <div className={this.getClassNames()} style={{ ...this.props.style }}>
143
+ <div style={{ ...styles.row, marginBottom: 0, justifyContent: 'space-between' }}>
144
+ {!_.isUndefined(this.props.label) && (
145
+ <div className="fieldLabel" style={this.getLabelStyle()}>
146
+ {this.props.label}
147
+ </div>
148
+ )}
149
+ {this.renderError()}
150
+ </div>
151
+ {/* Render either generic input or large text area */}
152
+ {this.renderInput()}
153
+ {/* Render bottom help info */}
154
+ {this.renderHelp()}
155
+ </div>
156
+ );
157
+ }
158
+ }
159
+
160
+ const styles = {
161
+ row: {
162
+ display: 'flex',
163
+ flexDirection: 'row',
164
+ // marginBottom: 8,
165
+ alignItems: 'center',
166
+ },
167
+ };
168
+
169
+ export { GenericInput };
@@ -0,0 +1,82 @@
1
+ import React, { Component } from 'react';
2
+ import { withRouter } from 'react-router';
3
+ import { connect } from 'react-redux';
4
+ import { setNavData } from '../actions';
5
+ import { Button } from './Button';
6
+
7
+ class Header extends Component {
8
+ getHomeLink() {
9
+ this.props.history.replace('/');
10
+ }
11
+
12
+ goToHelpGuide = () => {
13
+ window.open('https://www.plusscommunities.com/user-guide', '_blank');
14
+ };
15
+
16
+ toggleSideMenu = () => {
17
+ this.props.setNavData({ isSideMenuOpen: !this.props.isSideMenuOpen });
18
+ };
19
+
20
+ renderRight() {
21
+ if (this.props.rightContent) {
22
+ return this.props.rightContent;
23
+ }
24
+ return (
25
+ <div className="flex flex-center">
26
+ <Button buttonType="primary" onClick={this.goToHelpGuide} narrow isActive className="marginRight-16">
27
+ Help Guide
28
+ </Button>
29
+ <div className="sideMenuButtonContainer"></div>
30
+ </div>
31
+ );
32
+ }
33
+
34
+ renderHeader() {
35
+ return (
36
+ <div className="header">
37
+ <div id="leftContainer" style={{ display: 'inline-block' }}>
38
+ {this.props.children && (
39
+ <div style={{ display: 'flex', height: '100%', alignItems: 'center', marginLeft: 16 }}>{this.props.children}</div>
40
+ )}
41
+ </div>
42
+ {this.renderRight()}
43
+ </div>
44
+ );
45
+ }
46
+
47
+ renderSimpleHeader() {
48
+ return (
49
+ <div className={`header header-simple ${this.props.fixed ? 'header-fixed' : ''}`}>
50
+ <div className="container1200 flex flex-center">
51
+ <img
52
+ className="header_logo"
53
+ src="https://pluss-prd-media.s3-ap-southeast-2.amazonaws.com/assets/plusscommunities-new.svg"
54
+ alt="logo"
55
+ />
56
+ </div>
57
+ </div>
58
+ );
59
+ }
60
+
61
+ renderContainerHeader() {
62
+ return <div className={`header header-simple ${this.props.fixed ? 'header-fixed' : ''}`}>{this.props.children}</div>;
63
+ }
64
+
65
+ render() {
66
+ if (this.props.simple) {
67
+ return this.renderSimpleHeader();
68
+ }
69
+ if (this.props.onlyContainer) {
70
+ return this.renderContainerHeader();
71
+ }
72
+ return this.renderHeader();
73
+ }
74
+ }
75
+
76
+ const mapStateToProps = (state) => {
77
+ return { auth: state.auth, isSideMenuOpen: state.nav.isSideMenuOpen };
78
+ };
79
+
80
+ let exportObj = connect(mapStateToProps, { setNavData })(withRouter(Header));
81
+
82
+ export { exportObj as Header };
@@ -0,0 +1,134 @@
1
+ import React, { PureComponent } from 'react';
2
+ import _ from 'lodash';
3
+ import { connect } from 'react-redux';
4
+ import { setNavData } from '../actions';
5
+ import { SideNavItem } from './SideNavItem';
6
+ import { Button } from './Button';
7
+ import { Text } from './Text';
8
+
9
+ class HubSidebar extends PureComponent {
10
+ constructor(props) {
11
+ super(props);
12
+
13
+ this.state = {
14
+ showSidebar: false,
15
+ };
16
+ }
17
+
18
+ componentDidMount() {
19
+ this.props.setNavData({
20
+ condensedSidebar: true,
21
+ });
22
+ setTimeout(() => {
23
+ this.setState({
24
+ showSidebar: true,
25
+ });
26
+ }, 50);
27
+ }
28
+
29
+ componentWillUnmount() {
30
+ this.props.setNavData({
31
+ condensedSidebar: false,
32
+ });
33
+ this.setState({
34
+ showSidebar: false,
35
+ });
36
+ }
37
+
38
+ renderButton(item, index) {
39
+ return (
40
+ <div key={`button_${index}`} className="hubSidebar_newButtonContainer">
41
+ <Button buttonType={item.buttonType || 'primary'} isActive leftIcon={item.icon} narrow onClick={item.onClick}>
42
+ {item.text}
43
+ </Button>
44
+ </div>
45
+ );
46
+ }
47
+
48
+ renderNewButton(item, index) {
49
+ return this.renderButton({ ...item, icon: 'plus' }, index);
50
+ }
51
+
52
+ renderNavItem(item, index) {
53
+ return (
54
+ <SideNavItem
55
+ Text={item.text}
56
+ Icon={item.icon}
57
+ Link={item.url}
58
+ isFontAwesome={item.isFontAwesome}
59
+ isSVG={item.isSVG}
60
+ key={`navitem_${index}`}
61
+ selected={item.selected}
62
+ onClick={item.onClick}
63
+ />
64
+ );
65
+ }
66
+
67
+ renderSection(section, index) {
68
+ return (
69
+ <div className="hubSidebar_section" key={`section_${index}`}>
70
+ <Text type="h3" className="hubSidebar_sectionTitle">
71
+ {section.title}
72
+ </Text>
73
+ {section.items.map((item, itemIndex) => {
74
+ switch (item.type) {
75
+ case 'button':
76
+ return this.renderButton(item, itemIndex);
77
+ case 'newButton':
78
+ return this.renderNewButton(item, itemIndex);
79
+ case 'navItem':
80
+ return this.renderNavItem(item, itemIndex);
81
+ default:
82
+ return null;
83
+ }
84
+ })}
85
+ </div>
86
+ );
87
+ }
88
+
89
+ renderHelpGuide = () => {
90
+ if (!this.props.helpGuide) return null
91
+
92
+ const { text, url } = this.props.helpGuide
93
+
94
+ const onHelpGuidePress = () => {
95
+ if (!url) return
96
+ window.open(url, '_blank')
97
+ }
98
+ return (
99
+ <div className="hubSidebar_helpGuideContainer">
100
+ <Button buttonType="outlined" isActive leftIcon="info-circle" narrow onClick={onHelpGuidePress}>
101
+ {text || 'Help Guide'}
102
+ </Button>
103
+ </div>
104
+ )
105
+ }
106
+
107
+ render() {
108
+ return (
109
+ <div
110
+ className={`hubSidebar${this.state.showSidebar ? ' hubSidebar-show' : ''} ${this.props.className ? this.props.className : ''}`}
111
+ style={this.props.style}
112
+ >
113
+ {/* Top Add Button */}
114
+ <div className="hubSidebar_content">
115
+ {/* Title */}
116
+ {this.props.sections.map((section, i) => {
117
+ return this.renderSection(section, i);
118
+ })}
119
+ </div>
120
+
121
+ {/* Help Guide Button. */}
122
+ {this.renderHelpGuide()}
123
+ </div>
124
+ );
125
+ }
126
+ }
127
+
128
+ const mapStateToProps = (state) => {
129
+ return { auth: state.auth, isSideMenuOpen: state.nav.isSideMenuOpen };
130
+ };
131
+
132
+ let exportObj = connect(mapStateToProps, { setNavData })(HubSidebar);
133
+
134
+ export { exportObj as HubSidebar };