dce-reactkit 1.0.19 → 2.0.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 (203) hide show
  1. package/.eslintrc.js +95 -0
  2. package/lib/components/LoadingSpinner.d.ts +6 -0
  3. package/lib/components/LoadingSpinner.js +41 -0
  4. package/lib/components/LoadingSpinner.js.map +1 -0
  5. package/lib/components/Modal.d.ts +69 -0
  6. package/lib/components/Modal.js +315 -0
  7. package/lib/components/Modal.js.map +1 -0
  8. package/lib/helpers/abbreviate.d.ts +9 -0
  9. package/lib/helpers/abbreviate.js +21 -0
  10. package/lib/helpers/abbreviate.js.map +1 -0
  11. package/lib/helpers/avg.d.ts +8 -0
  12. package/lib/helpers/avg.js +24 -0
  13. package/lib/helpers/avg.js.map +1 -0
  14. package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  15. package/lib/helpers/ceilToNumDecimals.js +15 -0
  16. package/lib/helpers/ceilToNumDecimals.js.map +1 -0
  17. package/lib/helpers/floorToNumDecimals.d.ts +9 -0
  18. package/lib/helpers/floorToNumDecimals.js +15 -0
  19. package/lib/helpers/floorToNumDecimals.js.map +1 -0
  20. package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  21. package/lib/helpers/forceNumIntoBounds.js +15 -0
  22. package/lib/helpers/forceNumIntoBounds.js.map +1 -0
  23. package/lib/helpers/padDecimalZeros.d.ts +10 -0
  24. package/lib/helpers/padDecimalZeros.js +30 -0
  25. package/lib/helpers/padDecimalZeros.js.map +1 -0
  26. package/lib/helpers/padZerosLeft.d.ts +9 -0
  27. package/lib/helpers/padZerosLeft.js +21 -0
  28. package/lib/helpers/padZerosLeft.js.map +1 -0
  29. package/lib/helpers/roundToNumDecimals.d.ts +9 -0
  30. package/lib/helpers/roundToNumDecimals.js +15 -0
  31. package/lib/helpers/roundToNumDecimals.js.map +1 -0
  32. package/lib/helpers/sum.d.ts +8 -0
  33. package/lib/helpers/sum.js +15 -0
  34. package/lib/helpers/sum.js.map +1 -0
  35. package/lib/helpers/waitMs.d.ts +7 -0
  36. package/lib/helpers/waitMs.js +55 -0
  37. package/lib/helpers/waitMs.js.map +1 -0
  38. package/lib/types/Variant.d.ts +15 -0
  39. package/lib/types/Variant.js +19 -0
  40. package/lib/types/Variant.js.map +1 -0
  41. package/package.json +21 -39
  42. package/src/components/LoadingSpinner.tsx +105 -0
  43. package/src/components/Modal.tsx +447 -0
  44. package/src/helpers/abbreviate.tsx +23 -0
  45. package/src/helpers/avg.tsx +22 -0
  46. package/src/helpers/ceilToNumDecimals.tsx +13 -0
  47. package/src/helpers/floorToNumDecimals.tsx +13 -0
  48. package/src/helpers/forceNumIntoBounds.tsx +19 -0
  49. package/src/helpers/padDecimalZeros.tsx +32 -0
  50. package/src/helpers/padZerosLeft.tsx +21 -0
  51. package/src/helpers/roundToNumDecimals.tsx +13 -0
  52. package/src/helpers/sum.tsx +16 -0
  53. package/src/helpers/waitMs.tsx +12 -0
  54. package/src/types/Variant.tsx +16 -0
  55. package/tsconfig.json +24 -0
  56. package/index.js +0 -1
  57. package/lib/Bar.js +0 -169
  58. package/lib/Donut.js +0 -145
  59. package/lib/DownloadButton.js +0 -81
  60. package/lib/Histogram.js +0 -193
  61. package/lib/Scatter.js +0 -162
  62. package/lib/StackedBar.js +0 -243
  63. package/lib/common/chart/Holder/index.js +0 -182
  64. package/lib/common/chart/Holder/style.css +0 -41
  65. package/lib/common/chart/colors.js +0 -12
  66. package/lib/common/csvToString.js +0 -23
  67. package/lib/common/isFloat.js +0 -14
  68. package/lib/common/isInteger.js +0 -24
  69. package/lib/common/math.js +0 -21
  70. package/lib/common/validators.js +0 -18
  71. package/lib/glyph/Adjust.js +0 -13
  72. package/lib/glyph/Angle.js +0 -44
  73. package/lib/glyph/Archive.js +0 -13
  74. package/lib/glyph/Arrow.js +0 -49
  75. package/lib/glyph/ArrowsHorizontal.js +0 -13
  76. package/lib/glyph/ArrowsVertical.js +0 -13
  77. package/lib/glyph/Award.js +0 -13
  78. package/lib/glyph/Ban.js +0 -13
  79. package/lib/glyph/Barcode.js +0 -13
  80. package/lib/glyph/Bed.js +0 -13
  81. package/lib/glyph/Bell.js +0 -35
  82. package/lib/glyph/Bolt.js +0 -13
  83. package/lib/glyph/Bookmark.js +0 -37
  84. package/lib/glyph/Bug.js +0 -13
  85. package/lib/glyph/Calendar.js +0 -13
  86. package/lib/glyph/Check.js +0 -36
  87. package/lib/glyph/Checkbox.js +0 -40
  88. package/lib/glyph/Chevron.js +0 -63
  89. package/lib/glyph/Circle.js +0 -15
  90. package/lib/glyph/Cog.js +0 -13
  91. package/lib/glyph/DoubleAngle.js +0 -45
  92. package/lib/glyph/Download.js +0 -13
  93. package/lib/glyph/Ellipsis.js +0 -36
  94. package/lib/glyph/Envelope.js +0 -13
  95. package/lib/glyph/File.js +0 -37
  96. package/lib/glyph/IdCard.js +0 -13
  97. package/lib/glyph/Menu.js +0 -13
  98. package/lib/glyph/Minus.js +0 -13
  99. package/lib/glyph/Move.js +0 -13
  100. package/lib/glyph/Plus.js +0 -13
  101. package/lib/glyph/Square.js +0 -47
  102. package/lib/glyph/Teacher.js +0 -13
  103. package/lib/glyph/TextAlign.js +0 -53
  104. package/lib/glyph/Times.js +0 -36
  105. package/lib/glyph/WarningTriangle.js +0 -13
  106. package/lib/index.js +0 -1
  107. package/src-old/common/csvToString.js +0 -5
  108. package/src-old/common/isFloat.js +0 -3
  109. package/src-old/common/isInteger.js +0 -14
  110. package/src-old/common/math.js +0 -16
  111. package/src-old/common/validators.js +0 -14
  112. package/src-old/components/Alert.js +0 -79
  113. package/src-old/components/Button.js +0 -64
  114. package/src-old/components/CSV/autoMatch.js +0 -174
  115. package/src-old/components/CSV/getNumCols.js +0 -15
  116. package/src-old/components/CSV/index.js +0 -743
  117. package/src-old/components/Card.js +0 -64
  118. package/src-old/components/Chart/Bar.js +0 -169
  119. package/src-old/components/Chart/Donut.js +0 -160
  120. package/src-old/components/Chart/Histogram.js +0 -189
  121. package/src-old/components/Chart/Scatter.js +0 -162
  122. package/src-old/components/Chart/colors.js +0 -20
  123. package/src-old/components/Checkbox/index.js +0 -106
  124. package/src-old/components/Checkbox/style.css +0 -11
  125. package/src-old/components/DatePicker.js +0 -59
  126. package/src-old/components/DownloadButton.js +0 -72
  127. package/src-old/components/Dropdown.js +0 -120
  128. package/src-old/components/Layout/LeftAddon.js +0 -63
  129. package/src-old/components/Layout/RightAddon.js +0 -64
  130. package/src-old/components/Layout/TwoCol.js +0 -67
  131. package/src-old/components/Modal.js +0 -161
  132. package/src-old/components/PhotoRoster.js +0 -152
  133. package/src-old/components/Pills.js +0 -117
  134. package/src-old/components/Radio.js +0 -94
  135. package/src-old/components/Splash/Error.js +0 -62
  136. package/src-old/components/Splash/Load/index.js +0 -32
  137. package/src-old/components/Splash/Load/style.css +0 -51
  138. package/src-old/components/Stat/General.js +0 -252
  139. package/src-old/components/Stat/helpers/calcAverage.js +0 -20
  140. package/src-old/components/Stat/helpers/calcExtremes.js +0 -27
  141. package/src-old/components/Stat/helpers/calcMedian.js +0 -32
  142. package/src-old/components/Stat/helpers/calcStdDev.js +0 -30
  143. package/src-old/components/Stat/helpers/calcSum.js +0 -8
  144. package/src-old/components/UserProfile/index.js +0 -151
  145. package/src-old/components/UserProfile/style.css +0 -33
  146. package/src-old/components/Well.js +0 -28
  147. package/src-old/components/Wizard/Question/CSV.js +0 -307
  148. package/src-old/components/Wizard/Question/Chooser/Assignment.js +0 -108
  149. package/src-old/components/Wizard/Question/Chooser/Course.js +0 -214
  150. package/src-old/components/Wizard/Question/Chooser/helpers/divideIntoSections.js +0 -16
  151. package/src-old/components/Wizard/Question/Chooser/helpers/genGetItemsPromise.js +0 -20
  152. package/src-old/components/Wizard/Question/Chooser/helpers/preprocessSections.js +0 -36
  153. package/src-old/components/Wizard/Question/Chooser/index.js +0 -306
  154. package/src-old/components/Wizard/Question/Form/Field/CheckableItem.js +0 -155
  155. package/src-old/components/Wizard/Question/Form/Field/Input.js +0 -149
  156. package/src-old/components/Wizard/Question/Form/Field/NumberItem.js +0 -374
  157. package/src-old/components/Wizard/Question/Form/Field/index.js +0 -34
  158. package/src-old/components/Wizard/Question/Form/Field/readme.md +0 -7
  159. package/src-old/components/Wizard/Question/Form/index.js +0 -175
  160. package/src-old/components/Wizard/Question/Form/style.css +0 -3
  161. package/src-old/components/Wizard/Question/OneButton.js +0 -80
  162. package/src-old/components/Wizard/Question/index.js +0 -46
  163. package/src-old/components/Wizard/Question/readme.md +0 -10
  164. package/src-old/components/Wizard/QuestionGroup/AnswerAll.js +0 -126
  165. package/src-old/components/Wizard/QuestionGroup/AnswerAny.js +0 -60
  166. package/src-old/components/Wizard/index.js +0 -233
  167. package/src-old/components/Wizard/style.css +0 -21
  168. package/src-old/glyphs/Adjust.js +0 -13
  169. package/src-old/glyphs/Angle.js +0 -57
  170. package/src-old/glyphs/Archive.js +0 -13
  171. package/src-old/glyphs/Arrow.js +0 -85
  172. package/src-old/glyphs/ArrowsHorizontal.js +0 -13
  173. package/src-old/glyphs/ArrowsVertical.js +0 -13
  174. package/src-old/glyphs/Award.js +0 -13
  175. package/src-old/glyphs/Ban.js +0 -13
  176. package/src-old/glyphs/Barcode.js +0 -13
  177. package/src-old/glyphs/Bed.js +0 -13
  178. package/src-old/glyphs/Bell.js +0 -34
  179. package/src-old/glyphs/Bolt.js +0 -13
  180. package/src-old/glyphs/Bookmark.js +0 -36
  181. package/src-old/glyphs/Bug.js +0 -13
  182. package/src-old/glyphs/Calendar.js +0 -13
  183. package/src-old/glyphs/Check.js +0 -34
  184. package/src-old/glyphs/Checkbox.js +0 -42
  185. package/src-old/glyphs/Chevron.js +0 -88
  186. package/src-old/glyphs/Circle.js +0 -16
  187. package/src-old/glyphs/Cog.js +0 -13
  188. package/src-old/glyphs/DoubleAngle.js +0 -58
  189. package/src-old/glyphs/Download.js +0 -13
  190. package/src-old/glyphs/Ellipsis.js +0 -35
  191. package/src-old/glyphs/Envelope.js +0 -13
  192. package/src-old/glyphs/File.js +0 -40
  193. package/src-old/glyphs/IdCard.js +0 -13
  194. package/src-old/glyphs/Menu.js +0 -13
  195. package/src-old/glyphs/Minus.js +0 -13
  196. package/src-old/glyphs/Move.js +0 -13
  197. package/src-old/glyphs/Plus.js +0 -13
  198. package/src-old/glyphs/Square.js +0 -48
  199. package/src-old/glyphs/Teacher.js +0 -13
  200. package/src-old/glyphs/TextAlign.js +0 -58
  201. package/src-old/glyphs/Times.js +0 -34
  202. package/src-old/glyphs/WarningTriangle.js +0 -13
  203. package/src-old/index.js +0 -1
@@ -1,162 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import rechart components
5
- import {
6
- ResponsiveContainer,
7
- ScatterChart as ScatterChartLib,
8
- Scatter,
9
- XAxis,
10
- YAxis,
11
- CartesianGrid,
12
- Tooltip,
13
- Legend,
14
- } from 'recharts';
15
-
16
- // Import helpers
17
- import csvToString from '../../common/csvToString';
18
-
19
- // Import other components
20
- import Holder from './Holder';
21
-
22
- // Import default colors
23
- import colors from './colors';
24
-
25
- class ScatterChart extends Component {
26
- render() {
27
- // Deconstruct props
28
- const {
29
- title,
30
- color,
31
- width,
32
- height,
33
- xLabel,
34
- xUnit,
35
- yLabel,
36
- yUnit,
37
- data,
38
- noTooltipOnHover,
39
- noDownload,
40
- showLegend,
41
- seriesName,
42
- } = this.props;
43
-
44
- // Create download content
45
- let csvContents;
46
- if (!noDownload) {
47
- const xField = `${xLabel}${xUnit ? ' (' + xUnit + ')' : ''}`;
48
- const yField = `${yLabel}${yUnit ? ' (' + yUnit + ')' : ''}`;
49
- const csv = {
50
- fields: [xField, yField],
51
- data: data.map((datum) => {
52
- return [datum.x, datum.y];
53
- }),
54
- };
55
- csvContents = csvToString(csv);
56
- }
57
-
58
- return (
59
- <Holder
60
- title={title}
61
- xLabel={xLabel}
62
- xUnit={xUnit}
63
- yLabel={yLabel}
64
- yUnit={yUnit}
65
- width={width}
66
- height={height}
67
- csvContents={csvContents}
68
- >
69
- <ResponsiveContainer
70
- width="100%"
71
- height="100%"
72
- >
73
- <ScatterChartLib>
74
- <CartesianGrid />
75
- <YAxis
76
- dataKey="y"
77
- type="number"
78
- name={yLabel}
79
- />
80
- <XAxis
81
- dataKey="x"
82
- type="number"
83
- name={xLabel}
84
- />
85
- {!noTooltipOnHover && (
86
- <Tooltip
87
- cursor={{
88
- strokeDasharray: '3 3',
89
- }}
90
- />
91
- )}
92
- {showLegend && (
93
- <Legend />
94
- )}
95
- <Scatter
96
- name={seriesName}
97
- data={data}
98
- fill={color}
99
- />
100
- </ScatterChartLib>
101
- </ResponsiveContainer>
102
- </Holder>
103
- );
104
- }
105
- }
106
-
107
- ScatterChart.propTypes = {
108
- // Title of the chart
109
- title: PropTypes.string,
110
- // CSS color (#123456 or 'white') for the points
111
- color: PropTypes.string,
112
- // Width ('100%' or 50)
113
- width: PropTypes.oneOfType([
114
- PropTypes.string,
115
- PropTypes.number,
116
- ]),
117
- // Height ('100%' or 50)
118
- height: PropTypes.oneOfType([
119
- PropTypes.string,
120
- PropTypes.number,
121
- ]),
122
- // Label for the x axis
123
- xLabel: PropTypes.string,
124
- // Unit for the x axis
125
- xUnit: PropTypes.string,
126
- // Label for the y axis
127
- yLabel: PropTypes.string,
128
- // Unit for the y axis
129
- yUnit: PropTypes.string,
130
- // Array of data objects
131
- data: PropTypes.arrayOf(
132
- PropTypes.shape({
133
- x: PropTypes.number,
134
- y: PropTypes.number,
135
- })
136
- ).isRequired,
137
- // If true, no tooltip is shown when hovering over a point
138
- noTooltipOnHover: PropTypes.bool,
139
- // If true, no download button is shown
140
- noDownload: PropTypes.bool,
141
- // Name of the series (included and required for legend)
142
- seriesName: PropTypes.string,
143
- // If true, legend is included
144
- showLegend: PropTypes.bool,
145
- };
146
-
147
- ScatterChart.defaultProps = {
148
- title: null,
149
- color: colors.defaultBlue,
150
- width: '100%',
151
- height: '500px',
152
- xLabel: 'x-axis',
153
- xUnit: null,
154
- yLabel: 'y-axis',
155
- yUnit: null,
156
- seriesName: 'Chart',
157
- noTooltipOnHover: false,
158
- noDownload: false,
159
- showLegend: false,
160
- };
161
-
162
- export default ScatterChart;
@@ -1,20 +0,0 @@
1
- export default {
2
- defaultBlue: '#419bf7',
3
- assortment: [
4
- '#ec4f6a',
5
- '#f19542',
6
- '#f6c353',
7
- '#61cbcc',
8
- '#419bf7',
9
- '#005392',
10
- '#7d5297',
11
- '#d261ab',
12
- '#7edfcf',
13
- '#5eac88',
14
-
15
- '#f4ce63',
16
- '#929000',
17
- '#5e5e5e',
18
- '#008e00',
19
- ],
20
- };
@@ -1,106 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import bootstrap components
5
- import { Button } from 'reactstrap';
6
- // Import bootstrap stylesheet
7
- import 'bootstrap/dist/css/bootstrap.min.css';
8
-
9
- // Import custom styles
10
- import './style.css';
11
-
12
- // Import glyphs
13
- import Check from '../../glyphs/Check';
14
-
15
- /* Same properties as button component, plus:
16
- * - onChange: (index, optionText) function
17
- */
18
-
19
- class Checkbox extends Component {
20
- constructor(props) {
21
- super(props);
22
-
23
- // Deconstruct props
24
- const { startChecked } = this.props;
25
- const checked = !!startChecked;
26
-
27
- // Initialize state
28
- this.state = {
29
- checked,
30
- };
31
-
32
- // Bind functions
33
- this.onClick = this.onClick.bind(this);
34
-
35
- // Update parent
36
- const { onChange } = this.props;
37
- if (onChange) {
38
- onChange(checked);
39
- }
40
- }
41
-
42
- onClick() {
43
- // Toggle checkbox
44
- let { checked } = this.state;
45
- checked = !checked;
46
- this.setState({
47
- checked,
48
- });
49
-
50
- // Call onChange handler
51
- const { onChange } = this.props;
52
- if (onChange) {
53
- onChange(checked);
54
- }
55
- }
56
-
57
- render() {
58
- // Extract properties
59
- const { light } = this.props;
60
-
61
- // Deconstruct state
62
- const { checked } = this.state;
63
-
64
- // Create the checkbox
65
- return (
66
- <Button
67
- title={checked ? 'Click to uncheck' : 'Click to check'}
68
- onClick={this.onClick}
69
- color={(
70
- light
71
- ? 'light'
72
- : 'dark'
73
- )}
74
- style={{
75
- border: (light ? '2px solid black' : null),
76
- }}
77
- >
78
- {checked
79
- ? (<Check grow="10" />)
80
- : (<Check grow="3" opacity="0.2" />)
81
- }
82
- </Button>
83
- );
84
- }
85
- }
86
-
87
- Checkbox.propTypes = {
88
- // If true, the checkbox starts checked (when initialized)
89
- startChecked: PropTypes.bool,
90
- /**
91
- * If included, this function is called when the checkbox is toggled with a
92
- * boolean (is checked) as an argument
93
- * @param {boolean} isChecked true if the checkbox was just checked
94
- */
95
- onChange: PropTypes.func,
96
- // If true, the light theme is applied to the checkbox
97
- light: PropTypes.bool,
98
- };
99
-
100
- Checkbox.defaultProps = {
101
- startChecked: false,
102
- onChange: null,
103
- light: false,
104
- };
105
-
106
- export default Checkbox;
@@ -1,11 +0,0 @@
1
- /* Class that disables text selection (so that drags on the checkbox don't look
2
- strange) */
3
- .no-select {
4
- -webkit-touch-callout: none; /* iOS Safari */
5
- -webkit-user-select: none; /* Safari */
6
- -khtml-user-select: none; /* Konqueror HTML */
7
- -moz-user-select: none; /* Firefox */
8
- -ms-user-select: none; /* Internet Explorer/Edge */
9
- user-select: none; /* Non-prefixed version, currently
10
- supported by Chrome and Opera */
11
- }
@@ -1,59 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import date picker
5
- import ReactDatePicker from 'react-datepicker';
6
- import 'react-datepicker/dist/react-datepicker.css';
7
-
8
- class DatePicker extends Component {
9
- constructor(props) {
10
- super(props);
11
-
12
- // Initialize date
13
- const { defaultDate } = this.props;
14
- this.defaultDate = (defaultDate || new Date());
15
- this.state = {
16
- date: this.defaultDate,
17
- };
18
-
19
- // Bind functions
20
- this.onDateChanged = this.onDateChanged.bind(this);
21
- }
22
-
23
- onDateChanged(date) {
24
- // Update state
25
- this.setState({
26
- date,
27
- });
28
-
29
- // Update parent via handler
30
- const { onChange } = this.props;
31
- onChange(date);
32
- }
33
-
34
- render() {
35
- // Deconstruct state
36
- const { date } = this.state;
37
-
38
- return (
39
- <ReactDatePicker
40
- selected={date}
41
- onChange={this.onDateChanged}
42
- className="form-control"
43
- />
44
- );
45
- }
46
- }
47
-
48
- DatePicker.propTypes = {
49
- /* The default date to display in the chooser */
50
- defaultDate: PropTypes.instanceOf(Date),
51
- /* Handler to call when date is changed */
52
- onChange: PropTypes.func.isRequired,
53
- };
54
-
55
- DatePicker.defaultProps = {
56
- defaultDate: null,
57
- };
58
-
59
- export default DatePicker;
@@ -1,72 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import file download button
5
- import DownloadLink from 'react-download-link';
6
-
7
- // Import glyphs
8
- import Download from '../glyphs/Download';
9
-
10
- // Import bootstrap stylesheet
11
- import 'bootstrap/dist/css/bootstrap.min.css';
12
-
13
- class DownloadButton extends Component {
14
- render() {
15
- const {
16
- text,
17
- filename,
18
- contents,
19
- large,
20
- marginLeft,
21
- marginRight,
22
- marginTop,
23
- marginBottom,
24
- } = this.props;
25
-
26
- return (
27
- <DownloadLink
28
- filename={filename}
29
- exportFile={() => { return contents; }}
30
- label={
31
- (
32
- <span>
33
- <Download className="mr-2" />
34
- {text}
35
- </span>
36
- )
37
- }
38
- tagName="div"
39
- className={`btn btn-dark text-white${large ? ' btn-lg' : ''}`}
40
- style={{
41
- textDecoration: 'none !important',
42
- marginLeft,
43
- marginRight,
44
- marginTop,
45
- marginBottom,
46
- }}
47
- />
48
- );
49
- }
50
- }
51
-
52
- DownloadButton.propTypes = {
53
- text: PropTypes.string,
54
- filename: PropTypes.string.isRequired,
55
- contents: PropTypes.string.isRequired,
56
- large: PropTypes.bool,
57
- marginLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
58
- marginRight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
59
- marginTop: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
60
- marginBottom: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
61
- };
62
-
63
- DownloadButton.defaultProps = {
64
- text: 'Download',
65
- large: false,
66
- marginLeft: null,
67
- marginRight: null,
68
- marginTop: null,
69
- marginBottom: null,
70
- };
71
-
72
- export default DownloadButton;
@@ -1,120 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import genUUID from 'uuid/v1';
4
-
5
- // Import bootstrap components
6
- import {
7
- Dropdown as BootstrapDropdown,
8
- DropdownToggle,
9
- DropdownMenu,
10
- DropdownItem,
11
- } from 'reactstrap';
12
- // Import bootstrap stylesheet
13
- import 'bootstrap/dist/css/bootstrap.min.css';
14
-
15
- class Dropdown extends Component {
16
- constructor(props) {
17
- super(props);
18
-
19
- // Initialize state
20
- this.state = {
21
- dropdownOpen: false,
22
- };
23
-
24
- // Bind functions
25
- this.toggle = this.toggle.bind(this);
26
- }
27
-
28
- toggle() {
29
- const { dropdownOpen } = this.state;
30
-
31
- this.setState({
32
- dropdownOpen: !dropdownOpen,
33
- });
34
- }
35
-
36
- render() {
37
- // Deconstruct props
38
- const {
39
- title,
40
- color,
41
- rightAligned,
42
- inline,
43
- items,
44
- ...props
45
- } = this.props;
46
-
47
- // Deconstruct state
48
- const { dropdownOpen } = this.state;
49
-
50
- const itemElements = items.map((item) => {
51
- return (
52
- <DropdownItem
53
- header={item.header}
54
- divider={item.divider}
55
- disabled={item.disabled}
56
- onClick={item.onClick}
57
- key={genUUID()}
58
- >
59
- {item.text}
60
- </DropdownItem>
61
- );
62
- });
63
-
64
- return (
65
- <BootstrapDropdown
66
- isOpen={dropdownOpen}
67
- toggle={this.toggle}
68
- className={inline ? 'd-inline-block' : null}
69
- >
70
- <DropdownToggle
71
- color={color}
72
- caret
73
- {...props}
74
- >
75
- {title}
76
- </DropdownToggle>
77
- <DropdownMenu
78
- right={rightAligned}
79
- >
80
- {itemElements}
81
- </DropdownMenu>
82
- </BootstrapDropdown>
83
- );
84
- }
85
- }
86
-
87
- Dropdown.propTypes = {
88
- /* Title/label of the dropdown */
89
- title: PropTypes.string.isRequired,
90
- /* The bootstrap color of the dropdown button */
91
- color: PropTypes.string,
92
- /* If true, the dropdown menu is right-aligned (left-aligned otherwise) */
93
- rightAligned: PropTypes.bool,
94
- /* If true, the dropdown menu is inserted in-line (instead of block) */
95
- inline: PropTypes.bool,
96
- /* The dropdown items */
97
- items: PropTypes.arrayOf(
98
- PropTypes.shape({
99
- /* The title of the item */
100
- text: PropTypes.string,
101
- /* If true, this item is a divider (text is ignored) */
102
- divider: PropTypes.bool,
103
- /* If true, this item is a header item (not clickable) */
104
- header: PropTypes.bool,
105
- /* If true, this item is disabled (not clickable) */
106
- disabled: PropTypes.bool,
107
- /* Handler to call when item is clicked */
108
- onClick: PropTypes.func,
109
- })
110
- ),
111
- };
112
-
113
- Dropdown.defaultProps = {
114
- color: 'secondary',
115
- rightAligned: false,
116
- inline: false,
117
- items: [],
118
- };
119
-
120
- export default Dropdown;
@@ -1,63 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import bootstrap stylesheet
5
- import 'bootstrap/dist/css/bootstrap.min.css';
6
-
7
- /*
8
- Looks like:
9
- ...............................................................................
10
- | .............. ............................................................ |
11
- | | Left Addon | | Right area fills the rest of the space (second child) | |
12
- | '''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
13
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
14
- */
15
-
16
- class LeftAddon extends Component {
17
- render() {
18
- const {
19
- children,
20
- centerVertically,
21
- } = this.props;
22
- const leftChild = (children.length > 0 ? children[0] : {});
23
- const rightChild = (children.length > 1 ? children[1] : {});
24
-
25
- // Create classnames
26
- const leftClassName = (
27
- 'flex-column' + (centerVertically ? ' align-self-center' : '')
28
- );
29
- const rightClassName = (
30
- 'flex-column flex-fill' + (centerVertically ? ' align-self-center' : '')
31
- );
32
-
33
- return (
34
- <div className="d-flex flex-row">
35
- <div className={leftClassName}>
36
- {leftChild}
37
- </div>
38
- <div
39
- className={rightClassName}
40
- >
41
- <div className="d-inline-block">
42
- {rightChild}
43
- </div>
44
- </div>
45
- </div>
46
- );
47
- }
48
- }
49
-
50
- LeftAddon.propTypes = {
51
- /* Must have two children: first child is the item that's added on the left,
52
- * the second child is the item that spans the rest of the row
53
- */
54
- children: PropTypes.arrayOf(PropTypes.node).isRequired,
55
- // If true, the items are vertically centered
56
- centerVertically: PropTypes.bool,
57
- };
58
-
59
- LeftAddon.defaultProps = {
60
- centerVertically: false,
61
- };
62
-
63
- export default LeftAddon;
@@ -1,64 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import bootstrap stylesheet
5
- import 'bootstrap/dist/css/bootstrap.min.css';
6
-
7
- /*
8
- Looks like:
9
- ................................................................................
10
- | ............................................................ ............... |
11
- | | Left area fills the rest of the space (first child) | | Right Addon | |
12
- | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''' |
13
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
14
- */
15
-
16
- class RightAddon extends Component {
17
- render() {
18
- const {
19
- children,
20
- centerVertically,
21
- } = this.props;
22
- const leftChild = (children.length > 0 ? children[0] : {});
23
- const rightChild = (children.length > 1 ? children[1] : {});
24
-
25
- // Create classnames
26
- const leftClassName = (
27
- 'flex-column flex-fill' + (centerVertically ? ' align-self-center' : '')
28
- );
29
- const rightClassName = (
30
- 'flex-column' + (centerVertically ? ' align-self-center' : '')
31
- );
32
-
33
- return (
34
- <div className="d-flex flex-row">
35
- <div className={leftClassName}>
36
- {leftChild}
37
- </div>
38
- <div
39
- className={rightClassName}
40
- >
41
- <div className="d-inline-block">
42
- {rightChild}
43
- </div>
44
- </div>
45
- </div>
46
- );
47
- }
48
- }
49
-
50
- RightAddon.propTypes = {
51
- /* Must have two children: first child is the item on the left that fills up
52
- * the ret of the space, the second child is the item that's added on the
53
- * right
54
- */
55
- children: PropTypes.arrayOf(PropTypes.node).isRequired,
56
- // If true, the items are vertically centered
57
- centerVertically: PropTypes.bool,
58
- };
59
-
60
- RightAddon.defaultProps = {
61
- centerVertically: false,
62
- };
63
-
64
- export default RightAddon;