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

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/dist/components.js +37233 -474
  2. package/dist/components.js.map +1 -1
  3. package/dist/index.js +37233 -474
  4. package/dist/index.js.map +1 -1
  5. package/package.json +22 -31
  6. package/.babelrc +0 -3
  7. package/dist/index.cjs.js +0 -10388
  8. package/dist/index.esm.js +0 -10349
  9. package/dist/index.umd.js +0 -10361
  10. package/rollup.config.js +0 -57
  11. package/src/actions/AuthActions.js +0 -83
  12. package/src/actions/LocalActions.js +0 -8
  13. package/src/actions/NavActions.js +0 -8
  14. package/src/actions/ScheduledActionsActions.js +0 -8
  15. package/src/actions/TemplateActions.js +0 -15
  16. package/src/actions/UsersActions.js +0 -95
  17. package/src/actions/index.js +0 -6
  18. package/src/actions/types.js +0 -23
  19. package/src/analytics.js +0 -183
  20. package/src/apis/analyticsActions.js +0 -53
  21. package/src/apis/authActions.js +0 -58
  22. package/src/apis/fileActions.js +0 -152
  23. package/src/apis/index.js +0 -10
  24. package/src/apis/profileActions.js +0 -133
  25. package/src/apis/scheduledActionsActions.js +0 -12
  26. package/src/apis/stringActions.js +0 -25
  27. package/src/apis/templateActions.js +0 -41
  28. package/src/apis/typeActions.js +0 -186
  29. package/src/apis/userActions.js +0 -169
  30. package/src/apis/utilityActions.js +0 -35
  31. package/src/colours.js +0 -134
  32. package/src/components/AddButton.js +0 -27
  33. package/src/components/AnalyticsFilter.js +0 -115
  34. package/src/components/Attachment.js +0 -27
  35. package/src/components/AudienceIncluder.js +0 -175
  36. package/src/components/AudienceSelector.js +0 -700
  37. package/src/components/Button.js +0 -66
  38. package/src/components/CheckBox.js +0 -77
  39. package/src/components/ColourOptions.js +0 -197
  40. package/src/components/ColourPicker.js +0 -267
  41. package/src/components/Comment.js +0 -46
  42. package/src/components/CommentSection.js +0 -116
  43. package/src/components/DatePicker.js +0 -290
  44. package/src/components/DropdownInput.js +0 -223
  45. package/src/components/DurationInput.js +0 -51
  46. package/src/components/ExportCsvPopup.js +0 -222
  47. package/src/components/FileInput.js +0 -389
  48. package/src/components/GenericInput.js +0 -169
  49. package/src/components/Header.js +0 -82
  50. package/src/components/HubSidebar.js +0 -134
  51. package/src/components/ImageInput.js +0 -987
  52. package/src/components/InputGroup.js +0 -18
  53. package/src/components/MakerPopup.js +0 -310
  54. package/src/components/MoreMenu.js +0 -22
  55. package/src/components/OptionsSection.js +0 -84
  56. package/src/components/OverlayPage.js +0 -74
  57. package/src/components/OverlayPageBottomButtons.js +0 -48
  58. package/src/components/OverlayPageContents.js +0 -48
  59. package/src/components/OverlayPageSection.js +0 -38
  60. package/src/components/P60Icon.js +0 -40
  61. package/src/components/PageTitle.js +0 -13
  62. package/src/components/Popup.js +0 -104
  63. package/src/components/ProfilePic.js +0 -50
  64. package/src/components/RadioButton.js +0 -144
  65. package/src/components/Reactions.js +0 -77
  66. package/src/components/SVGIcon.js +0 -33
  67. package/src/components/SideNavItem.js +0 -98
  68. package/src/components/StatBox.js +0 -49
  69. package/src/components/StatusButton.js +0 -22
  70. package/src/components/SuccessPopup.js +0 -57
  71. package/src/components/Tabs.js +0 -56
  72. package/src/components/Tag.js +0 -62
  73. package/src/components/Text.js +0 -20
  74. package/src/components/TextFormatPopup.js +0 -54
  75. package/src/components/TimePicker.js +0 -225
  76. package/src/components/UserListing.js +0 -111
  77. package/src/components/index.js +0 -46
  78. package/src/components/svg-icons.json +0 -821
  79. package/src/config.js +0 -25
  80. package/src/helper/HelpDeskWidget.js +0 -16
  81. package/src/helper/api/getUrl.js +0 -15
  82. package/src/helper/api/getUrlParams.js +0 -9
  83. package/src/helper/api/safeReadParams.js +0 -6
  84. package/src/helper/auth/getUserFromState.js +0 -8
  85. package/src/helper/colours/getAppColourFromState.js +0 -10
  86. package/src/helper/files/canvasImageUploader.js +0 -159
  87. package/src/helper/files/generateImageName.js +0 -10
  88. package/src/helper/files/get1400.js +0 -32
  89. package/src/helper/files/getExtension.js +0 -9
  90. package/src/helper/files/getFileName.js +0 -13
  91. package/src/helper/files/getThumb300.js +0 -36
  92. package/src/helper/files/isVideo.js +0 -8
  93. package/src/helper/helper.js +0 -97
  94. package/src/helper/index.js +0 -44
  95. package/src/helper/site/getMerchantsFromState.js +0 -9
  96. package/src/helper/site/getSiteLevelFromState.js +0 -34
  97. package/src/helper/site/getSiteName.js +0 -16
  98. package/src/helper/site/getSiteNameFromRoles.js +0 -12
  99. package/src/helper/site/getSiteSettingFromState.js +0 -10
  100. package/src/helper/storage/readJSONFromStorage.js +0 -9
  101. package/src/helper/storage/readStorageWithCookie.js +0 -22
  102. package/src/helper/storage/setLocalStorage.js +0 -5
  103. package/src/helper/strings/getFirstName.js +0 -10
  104. package/src/helper/strings/htmlDecode.js +0 -4
  105. package/src/helper/strings/htmlEncode.js +0 -4
  106. package/src/helper/strings/isEmail.js +0 -11
  107. package/src/helper/strings/isUrl.js +0 -13
  108. package/src/helper/strings/onlyAlphanumeric.js +0 -8
  109. package/src/helper/strings/randomString.js +0 -10
  110. package/src/helper/strings/toParagraphed.js +0 -17
  111. package/src/index.js +0 -12
  112. package/src/reducers/ScheduledActionsReducer.js +0 -14
  113. package/src/reducers/TemplatesReducer.js +0 -29
  114. package/src/reducers/index.js +0 -7
  115. package/src/session.js +0 -289
  116. package/src/urls.js +0 -21
@@ -1,116 +0,0 @@
1
- import React, { Component } from 'react';
2
- import FontAwesome from 'react-fontawesome';
3
- import _ from 'lodash';
4
- import Textarea from 'react-textarea-autosize';
5
- import { Text } from './Text';
6
- import { Comment } from './Comment';
7
- import { getFirstName, getPluralOptions } from '../helper';
8
- import { ProfilePic } from './ProfilePic';
9
-
10
- class CommentSection extends Component {
11
- constructor(props) {
12
- super(props);
13
-
14
- this.state = {
15
- commentInput: '',
16
- };
17
- }
18
-
19
- onHandleChange = (event) => {
20
- var stateChange = {};
21
- stateChange[event.target.getAttribute('id')] = event.target.value;
22
- this.setState(stateChange);
23
- };
24
-
25
- onAddComment = async () => {
26
- const { commentInput } = this.state;
27
- this.setState({ commentInput: '' });
28
- this.props.onAddComment(commentInput);
29
- };
30
-
31
- getComments = () => {
32
- if (!this.props.onlyParents) {
33
- return this.props.comments;
34
- }
35
- return _.filter(this.props.comments, (c) => {
36
- return !c.ParentId;
37
- });
38
- };
39
-
40
- renderReplyText = (c) => {
41
- if (!this.props.onOpenThread) {
42
- return null;
43
- }
44
-
45
- const threadComments = _.filter(this.props.comments, (innerC) => {
46
- return innerC.ParentId === c.Id;
47
- });
48
- if (_.isEmpty(threadComments)) {
49
- return (
50
- <div className="comment_reply">
51
- <Text
52
- className="comment_reply_button"
53
- type="button"
54
- onClick={() => {
55
- this.props.onOpenThread(c);
56
- }}
57
- >{`Reply to ${getFirstName(c.User ? c.User.displayName : 'comment')}`}</Text>
58
- </div>
59
- );
60
- }
61
-
62
- const profilePics = _.take(
63
- _.uniqBy(threadComments, (c) => c.UserId),
64
- 3,
65
- );
66
- return (
67
- <div className="comment_reply comment_reply-hasReplies">
68
- {profilePics.map((c) => {
69
- return <ProfilePic className="comment_reply_profilePic" size={20} image={c.User.profilePic} />;
70
- })}
71
- <Text
72
- className="comment_reply_button"
73
- type="button"
74
- onClick={() => {
75
- this.props.onOpenThread(c);
76
- }}
77
- >{`${threadComments.length} repl${getPluralOptions(threadComments.length, 'y', 'ies')}`}</Text>
78
- </div>
79
- );
80
- };
81
-
82
- render() {
83
- return (
84
- <div>
85
- {this.props.includeTitle && (
86
- <Text type="formTitleSmall" className="marginBottom-16">
87
- Comments
88
- </Text>
89
- )}
90
- <div className="commentSection">
91
- {this.getComments().map((c) => (
92
- <Comment key={c.Id} comment={c} bottomContent={this.renderReplyText(c)} />
93
- ))}
94
- </div>
95
- <div className="commentReply">
96
- <div
97
- className={`commentReply_button${!_.isEmpty(this.state.commentInput) ? ' commentReply_button-active' : ''}`}
98
- onClick={this.onAddComment}
99
- >
100
- <FontAwesome className="commentReply_icon" name="paper-plane-o" />
101
- </div>
102
- <Textarea
103
- id="commentInput"
104
- placeholder="Reply here..."
105
- type="text"
106
- className="commentReply_input"
107
- value={this.state.commentInput}
108
- onChange={(e) => this.onHandleChange(e)}
109
- />
110
- </div>
111
- </div>
112
- );
113
- }
114
- }
115
-
116
- export { CommentSection };
@@ -1,290 +0,0 @@
1
- import React, { Component } from 'react';
2
- import moment from 'moment';
3
- import _ from 'lodash';
4
- import { P60Icon } from './P60Icon';
5
-
6
- class DatePicker extends Component {
7
- state = {
8
- shownMonth: new Date(),
9
- grid: [],
10
- };
11
-
12
- UNSAFE_componentWillMount() {
13
- this.onNewProps(this.props, true);
14
- }
15
-
16
- UNSAFE_componentWillReceiveProps(nextProps) {
17
- this.onNewProps(nextProps);
18
- }
19
-
20
- onNewProps(nextProps, forceUpdate) {
21
- if (!!nextProps.shownMonth && nextProps.shownMonth !== this.props.shownMonth) {
22
- const shownMonth = new Date(nextProps.shownMonth.getFullYear(), nextProps.shownMonth.getMonth() + 1, 0);
23
- this.setState({ shownMonth });
24
- this.generateGrid(shownMonth);
25
- } else if (this.props.multiple && nextProps.selectedDates !== this.props.selectedDates) {
26
- this.generateGrid(this.state.shownMonth, nextProps.selectedDates);
27
- } else if (forceUpdate || nextProps.selectedDate !== this.props.selectedDate) {
28
- let dateToUse = nextProps.selectedDate;
29
- if (!(dateToUse instanceof Date)) {
30
- dateToUse = new Date(dateToUse);
31
- }
32
- if (isNaN(dateToUse)) {
33
- dateToUse = new Date();
34
- }
35
- const shownMonth = this.props.shownMonth ? this.state.shownMonth : dateToUse;
36
- this.setState({
37
- shownMonth: shownMonth,
38
- selectedDate: dateToUse,
39
- });
40
- this.generateGrid(shownMonth, dateToUse);
41
- }
42
- }
43
-
44
- getDate() {
45
- if (!this.props.selectedDate) {
46
- return 'Select day';
47
- }
48
- return moment(this.props.selectedDate).format('dddd, Do MMMM');
49
- }
50
-
51
- getShortDate() {
52
- if (!this.props.selectedDate) {
53
- return '';
54
- }
55
- return moment(this.props.selectedDate).format('DD/MM/YYYY');
56
- }
57
-
58
- getMonth() {
59
- return moment(this.state.shownMonth).format('MMMM YYYY');
60
- }
61
-
62
- isDateSelected(date, selectedDate) {
63
- if (this.props.multiple) {
64
- return _.includes(selectedDate, date.format('DD-MM-YYYY'));
65
- }
66
- return date.isSame(selectedDate, 'date');
67
- }
68
-
69
- isDateEnabled(date) {
70
- if (this.props.enabledDates) {
71
- const found = this.props.enabledDates.find((d) => moment(d.day).format('YYYYMMDD') === date.format('YYYYMMDD'));
72
- if (found) return found.enabled;
73
- }
74
- return null;
75
- }
76
-
77
- changeMonth(change) {
78
- const newShownDate = new Date(this.state.shownMonth.getFullYear(), this.state.shownMonth.getMonth() + 1 + change, 0);
79
- this.setState(
80
- {
81
- shownMonth: newShownDate,
82
- },
83
- () => {
84
- if (this.props.changeMonth) this.props.changeMonth(this.state.shownMonth);
85
- },
86
- );
87
- this.generateGrid(newShownDate);
88
- }
89
-
90
- selectRange(date) {
91
- const d1 = moment(this.state.lastSelected, 'DD-MM-YYYY');
92
- const d2 = moment(date, 'DD-MM-YYYY');
93
-
94
- let startDate, endDate;
95
-
96
- if (d1.valueOf() > d2.valueOf()) {
97
- // clicked an earlier day
98
- startDate = moment(d2);
99
- endDate = moment(d1);
100
- } else {
101
- // clicked a later day
102
- startDate = moment(d1);
103
- endDate = moment(d2);
104
- }
105
-
106
- const dateRange = [startDate.format('DD-MM-YYYY')];
107
- while (startDate.format('DD-MM-YYYY') !== endDate.format('DD-MM-YYYY')) {
108
- startDate.add(1, 'd');
109
- dateRange.push(startDate.format('DD-MM-YYYY'));
110
- }
111
-
112
- if (
113
- (_.includes(this.props.selectedDates, d2.format('DD-MM-YYYY')) && !_.includes(this.props.selectedDates, d1.format('DD-MM-YYYY'))) ||
114
- !_.some(dateRange, (d) => {
115
- return !_.includes(this.props.selectedDates, d);
116
- })
117
- ) {
118
- // the first clicked date was just de-selected and then clicked on a selected date
119
- // or every date in the range is already selected, then
120
- // de-select the range
121
- this.props.selectDate(
122
- _.filter(this.props.selectedDates, (d) => {
123
- return !_.includes(dateRange, d);
124
- }),
125
- );
126
- } else {
127
- // select the range
128
- const newSelection = [...this.props.selectedDates, ...dateRange];
129
- this.props.selectDate(_.uniq(newSelection));
130
- }
131
- }
132
-
133
- selectDate(date, e) {
134
- const enabled = this.isDateEnabled(date);
135
- const isBeforeMinDate = this.props.minDate && moment(date).isBefore(this.props.minDate);
136
- console.log('selected a date', { date, enabled, isBeforeMinDate });
137
- if (enabled === false || isBeforeMinDate) return;
138
-
139
- if (this.props.multiple) {
140
- const dateKey = moment(date).format('DD-MM-YYYY');
141
-
142
- if (e.shiftKey && this.state.lastSelected && this.state.lastSelected !== dateKey) {
143
- // shift-click to select range
144
- this.selectRange(dateKey);
145
- } else {
146
- // toggle single date
147
- const index = this.props.selectedDates.indexOf(dateKey);
148
- const newSelection = [...this.props.selectedDates];
149
- if (index > -1) {
150
- newSelection.splice(index, 1);
151
- } else {
152
- newSelection.push(dateKey);
153
- }
154
- this.props.selectDate(newSelection);
155
- }
156
- this.setState({
157
- lastSelected: dateKey,
158
- });
159
- } else {
160
- this.props.selectDate(moment(date).format('YYYY-MM-DD'));
161
- }
162
- }
163
-
164
- generateGrid(date, selectedDate) {
165
- const month = moment(date);
166
- let dateToTarget = moment(date).endOf('month');
167
- let dateToModify = moment(date).startOf('month');
168
- const selectedDateToUse = this.props.multiple
169
- ? selectedDate || this.props.selectedDates || []
170
- : moment(selectedDate || this.state.selectedDate);
171
-
172
- // set dateToModify to be Sunday of that week
173
- while (dateToModify.day() !== 0) {
174
- dateToModify = dateToModify.add(-1, 'day');
175
- }
176
-
177
- const rows = [[]];
178
-
179
- while (dateToTarget.day() !== 6) {
180
- dateToTarget = dateToTarget.add(1, 'day');
181
- }
182
- dateToTarget = dateToTarget.add(1, 'day'); // add an extra day to complete the week
183
-
184
- while (!dateToModify.isSame(dateToTarget, 'day')) {
185
- if (rows[rows.length - 1].length === 7) {
186
- // week has filled - add new row
187
- rows.push([]);
188
- }
189
- const thisDate = moment(dateToModify);
190
-
191
- rows[rows.length - 1].push({
192
- date: thisDate,
193
- dateKey: thisDate.format('DD-MM-YYYY'),
194
- display: thisDate.date(),
195
- isFaded: !thisDate.isSame(month, 'month'),
196
- isToday: thisDate.isSame(moment(), 'date'),
197
- isSelected: this.isDateSelected(thisDate, selectedDateToUse),
198
- isEnabled: this.isDateEnabled(thisDate),
199
- });
200
-
201
- dateToModify = dateToModify.add(1, 'day');
202
- }
203
-
204
- // console.log('generateGrid', JSON.stringify(rows, null, 2));
205
- this.setState({
206
- grid: rows,
207
- });
208
- }
209
-
210
- renderGrid() {
211
- return this.state.grid.map((row, index) => {
212
- return (
213
- <div className="datepicker__row marginTop-8" key={index}>
214
- {row.map((date) => {
215
- let classes = 'datepicker__date';
216
- if (date.isFaded) {
217
- classes += ' datepicker__date--faded';
218
- }
219
- if (date.isToday) {
220
- classes += ' datepicker__date--today';
221
- }
222
- if (date.isSelected) {
223
- classes += ' datepicker__date--selected';
224
- }
225
- if (typeof date.isEnabled === 'boolean') {
226
- classes += date.isEnabled ? ' datepicker__date--enabled' : ' datepicker__date--disabled';
227
- }
228
- return (
229
- <div className={classes} key={date.dateKey}>
230
- <div className="datepicker__date__inner" onClick={(e) => this.selectDate(date.date, e)}>
231
- {date.display}
232
- </div>
233
- </div>
234
- );
235
- })}
236
- </div>
237
- );
238
- });
239
- }
240
-
241
- renderTop() {
242
- if (this.props.hideTop) {
243
- return null;
244
- }
245
- if (this.props.multiple) {
246
- return (
247
- <div className="datepicker__multitop">
248
- <p className="datepicker__multitop__text">Shift + Click to select a range of dates</p>
249
- </div>
250
- );
251
- }
252
- return (
253
- <div className="datepicker__top">
254
- <p className="datepicker__title truncate">{this.getDate()}</p>
255
- </div>
256
- );
257
- }
258
-
259
- render() {
260
- return (
261
- <div className="datepicker noselect" style={this.props.style}>
262
- {this.renderTop()}
263
- <div className="datepicker__bottom">
264
- <div className="datepicker__bottomHeader">
265
- {/* <div className='datepicker__selectedDate'>
266
- <p className='datepicker__selectedDateText'>{this.getShortDate()}</p>
267
- </div> */}
268
- <div className="datepicker__monthSelector">
269
- <P60Icon className="datepicker__monthChevron" icon="chevron_left" onClick={this.changeMonth.bind(this, -1)} />
270
- <p className="datepicker__selectedMonth">{this.getMonth()}</p>
271
- <P60Icon className="datepicker__monthChevron" icon="chevron_right" onClick={this.changeMonth.bind(this, 1)} />
272
- </div>
273
- </div>
274
- <div className="datepicker__row marginTop-16">
275
- <p className="datepicker__colHeader">SUN</p>
276
- <p className="datepicker__colHeader">MON</p>
277
- <p className="datepicker__colHeader">TUE</p>
278
- <p className="datepicker__colHeader">WED</p>
279
- <p className="datepicker__colHeader">THU</p>
280
- <p className="datepicker__colHeader">FRI</p>
281
- <p className="datepicker__colHeader">SAT</p>
282
- </div>
283
- {this.renderGrid()}
284
- </div>
285
- </div>
286
- );
287
- }
288
- }
289
-
290
- export { DatePicker };
@@ -1,223 +0,0 @@
1
- import React, { Component } from 'react';
2
- import _ from 'lodash';
3
- import FontAwesome from 'react-fontawesome';
4
- import { INACTIVE_TEXT } from '../colours';
5
-
6
- class DropdownInput extends Component {
7
- constructor(props) {
8
- super(props);
9
- this.state = {
10
- width: 0,
11
- height: 0,
12
- open: false,
13
- };
14
-
15
- this.setWrapperRef = this.setWrapperRef.bind(this);
16
- this.handleClickOutside = this.handleClickOutside.bind(this);
17
- }
18
-
19
- componentDidMount() {
20
- document.addEventListener('mousedown', this.handleClickOutside);
21
- }
22
-
23
- componentWillUnmount() {
24
- document.removeEventListener('mousedown', this.handleClickOutside);
25
- }
26
-
27
- setWrapperRef(node) {
28
- this.wrapperRef = node;
29
- }
30
-
31
- handleClickOutside(event) {
32
- if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {
33
- this.setState({ open: false });
34
- }
35
- }
36
-
37
- getAutoComplete() {
38
- if (!_.isUndefined(this.props.autoComplete)) {
39
- return this.props.autoComplete ? 'on' : 'off';
40
- }
41
- return 'off';
42
- }
43
-
44
- getClassNames() {
45
- let string = '';
46
- if (this.props.className) {
47
- string += `${this.props.className} `;
48
- }
49
- if (!_.isUndefined(this.props.disabled) && this.props.disabled) {
50
- string = 'genericInput-disabled ';
51
- }
52
- if (this.props.large) {
53
- string += 'genericInput-large ';
54
- }
55
- if (!_.isUndefined(this.props.showError) && this.props.showError()) {
56
- return string + 'genericInput-error';
57
- }
58
- if (!_.isUndefined(this.props.isValid) && this.props.isValid()) {
59
- return string + 'genericInput-valid';
60
- }
61
- return string;
62
- }
63
-
64
- getLabelStyle() {
65
- const style = {};
66
- if (_.isEmpty(this.props.value) && !this.props.alwaysShowLabel) {
67
- style.opacity = 0;
68
- }
69
- if (!_.isUndefined(this.props.ignoreValue) && this.props.value === this.props.ignoreValue && !this.props.alwaysShowLabel) {
70
- style.opacity = 0;
71
- }
72
- // if (this.props.isRequired) {
73
- // style.marginLeft = 12;
74
- // }
75
- return style;
76
- }
77
-
78
- renderError() {
79
- if (!_.isUndefined(this.props.showError) && this.props.showError()) {
80
- return <div className={'fieldLabel fieldLabel-warning'}>{this.props.errorMessage ? this.props.errorMessage : 'Required'}</div>;
81
- }
82
- return null;
83
- }
84
-
85
- renderHelp() {
86
- if (!_.isUndefined(this.props.help)) {
87
- return <div className="genericInput-help">{this.props.help}</div>;
88
- }
89
- return null;
90
- }
91
-
92
- open() {
93
- if (this.props.disabled) {
94
- return;
95
- }
96
- this.setState({ open: !this.state.open });
97
- }
98
-
99
- renderOption() {
100
- if (!this.state.open) {
101
- return null;
102
- }
103
- return (
104
- <div style={styles.dropdownItemsWrapper}>
105
- {_.values(this.props.options).map((cat) => {
106
- return (
107
- <div
108
- key={cat.Key}
109
- className="subtleHover fontRegular fontSize-16 text-dark"
110
- style={styles.dropDownOption}
111
- onClick={() => {
112
- this.props.onSelect(cat.Key);
113
- }}
114
- >
115
- {cat.Title}
116
- </div>
117
- );
118
- })}
119
- </div>
120
- );
121
- }
122
-
123
- getBottomBorder() {
124
- if (!_.isUndefined(this.props.disabled) && this.props.disabled) {
125
- return 'dropdownInput-bottomBorder--disabled';
126
- }
127
- if (!_.isUndefined(this.props.showError) && this.props.showError()) {
128
- return 'dropdownInput-bottomBorder--error';
129
- }
130
- return '';
131
- }
132
-
133
- renderInput() {
134
- return (
135
- <div style={styles.row}>
136
- {this.props.isRequired && <div className="inputRequired " />}
137
- <div
138
- onClick={this.open.bind(this)}
139
- className={`dropdownInput-bottomBorder ${this.getBottomBorder()} ${!this.props.disabled ? 'pointer' : ''}`}
140
- >
141
- <input
142
- id={this.props.id}
143
- placeholder={!_.isUndefined(this.props.placeholder) ? this.props.placeholder : this.props.label}
144
- type={!_.isUndefined(this.props.type) ? this.props.type : 'text'}
145
- className={`genericInput ${!this.props.disabled ? 'pointer' : ''}`}
146
- value={this.props.value}
147
- onChange={this.props.onChange}
148
- onKeyPress={this.props.onEnter}
149
- style={{ ...this.props.inputStyle }}
150
- disabled
151
- autoComplete="false"
152
- />
153
- <div style={styles.chevronWrapper}>
154
- <FontAwesome
155
- style={{
156
- ...styles.chevron,
157
- color: !_.isUndefined(this.props.disabled) && this.props.disabled ? 'transparent' : INACTIVE_TEXT,
158
- }}
159
- name={this.state.open ? 'chevron-up' : 'chevron-down'}
160
- />
161
- </div>
162
- {this.renderOption()}
163
- </div>
164
- </div>
165
- );
166
- }
167
-
168
- render() {
169
- return (
170
- <div
171
- ref={this.setWrapperRef}
172
- className={`dropdownInput ${this.getClassNames()}`}
173
- style={{ marginBottom: 16, position: 'relative', ...this.props.style }}
174
- >
175
- <div style={{ ...styles.row, marginBottom: 0, justifyContent: 'space-between' }}>
176
- {!_.isUndefined(this.props.label) && (
177
- <div className="fieldLabel" style={this.getLabelStyle()}>
178
- {this.props.label}
179
- </div>
180
- )}
181
- {this.renderError()}
182
- </div>
183
- {/* Render either generic input or large text area */}
184
- {this.renderInput()}
185
- {/* Render bottom help info */}
186
- {this.renderHelp()}
187
- </div>
188
- );
189
- }
190
- }
191
-
192
- const styles = {
193
- row: {
194
- display: 'flex',
195
- flexDirection: 'row',
196
- alignItems: 'center',
197
- },
198
- chevronWrapper: {
199
- display: 'flex',
200
- flexDirection: 'column',
201
- justifyContent: 'center',
202
- },
203
- chevron: {
204
- fontSize: 12,
205
- paddingBottom: 4,
206
- },
207
- dropdownItemsWrapper: {
208
- backgroundColor: '#fff',
209
- position: 'absolute',
210
- width: '100%',
211
- top: 35,
212
- boxShadow: '2px 2px 10px rgba(106, 163, 216, 0.7)',
213
- zIndex: 90,
214
- borderRadius: 4,
215
- paddingTop: 4,
216
- paddingBottom: 4,
217
- },
218
- dropDownOption: {
219
- padding: '4px 16px',
220
- },
221
- };
222
-
223
- export { DropdownInput };
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import { Text } from './Text';
3
-
4
- function DurationInput({ handleChange, label, value, className, labelWidth }) {
5
- const hours = Math.floor(value / 60);
6
- const minutes = value % 60;
7
-
8
- const handleHourChange = (event) => {
9
- const newHours = Math.max(0, Math.min(+event.target.value, 24));
10
- handleChange(newHours * 60 + minutes);
11
- };
12
-
13
- const handleMinuteChange = (event) => {
14
- const newMinutes = Math.max(0, Math.min(+event.target.value, 59));
15
- handleChange(hours * 60 + newMinutes);
16
- };
17
-
18
- return (
19
- <div className={`flex flex-center ${className ? className : ''}`}>
20
- {label && (
21
- <Text type="formTitleSmall" style={{ marginRight: '10px', width: labelWidth || 50 }}>
22
- {label}
23
- </Text>
24
- )}
25
- <input
26
- className="genericInput"
27
- type="number"
28
- min="0"
29
- max="24"
30
- value={hours}
31
- onChange={handleHourChange}
32
- style={{ width: 50, marginRight: 5 }}
33
- />
34
- <Text type="formTitleSmall" style={{ marginRight: 10 }}>
35
- Hour(s)
36
- </Text>
37
- <input
38
- className="genericInput"
39
- type="number"
40
- min="0"
41
- max="59"
42
- value={minutes}
43
- onChange={handleMinuteChange}
44
- style={{ width: 50, marginRight: 5 }}
45
- />
46
- <Text type="formTitleSmall">Minute(s)</Text>
47
- </div>
48
- );
49
- }
50
-
51
- export { DurationInput };