@performant-software/semantic-components 0.5.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 (218) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/build/index.js +2 -0
  4. package/build/index.js.map +1 -0
  5. package/build/main.css +786 -0
  6. package/index.js +1 -0
  7. package/package.json +37 -0
  8. package/src/components/AccordionDataList.css +8 -0
  9. package/src/components/AccordionDataList.js +224 -0
  10. package/src/components/AccordionList.css +27 -0
  11. package/src/components/AccordionList.js +596 -0
  12. package/src/components/AccordionSelector.css +3 -0
  13. package/src/components/AccordionSelector.js +359 -0
  14. package/src/components/ArrowButtons.css +4 -0
  15. package/src/components/ArrowButtons.js +38 -0
  16. package/src/components/AssociatedDropdown.css +44 -0
  17. package/src/components/AssociatedDropdown.js +338 -0
  18. package/src/components/BooleanIcon.css +0 -0
  19. package/src/components/BooleanIcon.js +33 -0
  20. package/src/components/CancelButton.css +0 -0
  21. package/src/components/CancelButton.js +25 -0
  22. package/src/components/ColorButton.css +4 -0
  23. package/src/components/ColorButton.js +34 -0
  24. package/src/components/ColorPickerModal.css +3 -0
  25. package/src/components/ColorPickerModal.js +77 -0
  26. package/src/components/ColumnResize.css +9 -0
  27. package/src/components/ColumnResize.js +20 -0
  28. package/src/components/DataList.css +0 -0
  29. package/src/components/DataList.js +531 -0
  30. package/src/components/DataTable.css +43 -0
  31. package/src/components/DataTable.js +596 -0
  32. package/src/components/DataTableColumnSelector.css +10 -0
  33. package/src/components/DataTableColumnSelector.js +146 -0
  34. package/src/components/DateInput.css +6 -0
  35. package/src/components/DateInput.js +58 -0
  36. package/src/components/DatePicker.css +72 -0
  37. package/src/components/DatePicker.js +81 -0
  38. package/src/components/DescriptorField.css +0 -0
  39. package/src/components/DescriptorField.js +42 -0
  40. package/src/components/DownloadButton.css +0 -0
  41. package/src/components/DownloadButton.js +23 -0
  42. package/src/components/Draggable.css +0 -0
  43. package/src/components/Draggable.js +94 -0
  44. package/src/components/DropdownButton.css +3 -0
  45. package/src/components/DropdownButton.js +65 -0
  46. package/src/components/DropdownMenu.css +0 -0
  47. package/src/components/DropdownMenu.js +68 -0
  48. package/src/components/EditModal.css +8 -0
  49. package/src/components/EditModal.js +99 -0
  50. package/src/components/EditPage.css +7 -0
  51. package/src/components/EditPage.js +249 -0
  52. package/src/components/EmbeddedList.css +7 -0
  53. package/src/components/EmbeddedList.js +278 -0
  54. package/src/components/FileInputButton.css +0 -0
  55. package/src/components/FileInputButton.js +54 -0
  56. package/src/components/FileUpload.css +31 -0
  57. package/src/components/FileUpload.js +188 -0
  58. package/src/components/FileUploadModal.css +0 -0
  59. package/src/components/FileUploadModal.js +408 -0
  60. package/src/components/FuzzyDate.css +8 -0
  61. package/src/components/FuzzyDate.js +575 -0
  62. package/src/components/GoogleMap.css +0 -0
  63. package/src/components/GoogleMap.js +105 -0
  64. package/src/components/GooglePlacesSearch.css +0 -0
  65. package/src/components/GooglePlacesSearch.js +43 -0
  66. package/src/components/HorizontalCards.css +50 -0
  67. package/src/components/HorizontalCards.js +226 -0
  68. package/src/components/ItemCollection.css +3 -0
  69. package/src/components/ItemCollection.js +159 -0
  70. package/src/components/ItemList.css +0 -0
  71. package/src/components/ItemList.js +126 -0
  72. package/src/components/Items.css +19 -0
  73. package/src/components/Items.js +365 -0
  74. package/src/components/ItemsToggle.css +0 -0
  75. package/src/components/ItemsToggle.js +168 -0
  76. package/src/components/KeyboardField.css +4 -0
  77. package/src/components/KeyboardField.js +147 -0
  78. package/src/components/LazyDocument.css +21 -0
  79. package/src/components/LazyDocument.js +113 -0
  80. package/src/components/LazyImage.css +21 -0
  81. package/src/components/LazyImage.js +119 -0
  82. package/src/components/LazyVideo.css +21 -0
  83. package/src/components/LazyVideo.js +131 -0
  84. package/src/components/LinkButton.css +8 -0
  85. package/src/components/LinkButton.js +23 -0
  86. package/src/components/LinkLabel.css +8 -0
  87. package/src/components/LinkLabel.js +29 -0
  88. package/src/components/List.css +8 -0
  89. package/src/components/List.js +761 -0
  90. package/src/components/ListFilters.css +0 -0
  91. package/src/components/ListFilters.js +408 -0
  92. package/src/components/ListLoader.css +8 -0
  93. package/src/components/ListLoader.js +32 -0
  94. package/src/components/ListTable.css +3 -0
  95. package/src/components/ListTable.js +86 -0
  96. package/src/components/LoginModal.css +7 -0
  97. package/src/components/LoginModal.js +102 -0
  98. package/src/components/MasonryGrid.css +48 -0
  99. package/src/components/MasonryGrid.js +202 -0
  100. package/src/components/MediaGallery.css +37 -0
  101. package/src/components/MediaGallery.js +148 -0
  102. package/src/components/MediaGrid.css +72 -0
  103. package/src/components/MediaGrid.js +74 -0
  104. package/src/components/MediaList.css +3 -0
  105. package/src/components/MediaList.js +98 -0
  106. package/src/components/ModalDropdown.css +11 -0
  107. package/src/components/ModalDropdown.js +84 -0
  108. package/src/components/NestedAccordion.css +41 -0
  109. package/src/components/NestedAccordion.js +276 -0
  110. package/src/components/PhotoViewer.css +3 -0
  111. package/src/components/PhotoViewer.js +36 -0
  112. package/src/components/PlayButton.css +3 -0
  113. package/src/components/PlayButton.js +37 -0
  114. package/src/components/RemoteDropdown.css +13 -0
  115. package/src/components/RemoteDropdown.js +368 -0
  116. package/src/components/SaveButton.css +0 -0
  117. package/src/components/SaveButton.js +31 -0
  118. package/src/components/Section.css +0 -0
  119. package/src/components/Section.js +41 -0
  120. package/src/components/Selectize.css +11 -0
  121. package/src/components/Selectize.js +297 -0
  122. package/src/components/SelectizeHeader.css +3 -0
  123. package/src/components/SelectizeHeader.js +40 -0
  124. package/src/components/TabbedModal.css +14 -0
  125. package/src/components/TabbedModal.js +165 -0
  126. package/src/components/TabsMenu.css +0 -0
  127. package/src/components/TabsMenu.js +35 -0
  128. package/src/components/TagsList.css +0 -0
  129. package/src/components/TagsList.js +43 -0
  130. package/src/components/Thumbnail.css +0 -0
  131. package/src/components/Thumbnail.js +47 -0
  132. package/src/components/Toaster.css +9 -0
  133. package/src/components/Toaster.js +73 -0
  134. package/src/components/VideoFrameSelector.css +3 -0
  135. package/src/components/VideoFrameSelector.js +148 -0
  136. package/src/components/VideoPlayer.css +3 -0
  137. package/src/components/VideoPlayer.js +55 -0
  138. package/src/components/VideoPlayerButton.css +17 -0
  139. package/src/components/VideoPlayerButton.js +17 -0
  140. package/src/components/ViewXML.css +0 -0
  141. package/src/components/ViewXML.js +72 -0
  142. package/src/i18n/en.json +204 -0
  143. package/src/i18n/i18n.js +24 -0
  144. package/src/index.js +76 -0
  145. package/types/components/AccordionDataList.js.flow +224 -0
  146. package/types/components/AccordionList.js.flow +596 -0
  147. package/types/components/AccordionSelector.js.flow +359 -0
  148. package/types/components/ArrowButtons.js.flow +38 -0
  149. package/types/components/AssociatedDropdown.js.flow +338 -0
  150. package/types/components/BooleanIcon.js.flow +33 -0
  151. package/types/components/CancelButton.js.flow +25 -0
  152. package/types/components/ColorButton.js.flow +34 -0
  153. package/types/components/ColorPickerModal.js.flow +77 -0
  154. package/types/components/ColumnResize.js.flow +20 -0
  155. package/types/components/DataList.js.flow +531 -0
  156. package/types/components/DataTable.js.flow +596 -0
  157. package/types/components/DataTableColumnSelector.js.flow +146 -0
  158. package/types/components/DataView.js.flow +125 -0
  159. package/types/components/DateInput.js.flow +58 -0
  160. package/types/components/DatePicker.js.flow +81 -0
  161. package/types/components/DescriptorField.js.flow +42 -0
  162. package/types/components/DownloadButton.js.flow +23 -0
  163. package/types/components/Draggable.js.flow +94 -0
  164. package/types/components/DropdownButton.js.flow +65 -0
  165. package/types/components/DropdownMenu.js.flow +68 -0
  166. package/types/components/EditModal.js.flow +99 -0
  167. package/types/components/EditPage.js.flow +249 -0
  168. package/types/components/EmbeddedList.js.flow +278 -0
  169. package/types/components/FileInputButton.js.flow +54 -0
  170. package/types/components/FileUpload.js.flow +188 -0
  171. package/types/components/FileUploadModal.js.flow +408 -0
  172. package/types/components/FuzzyDate.js.flow +575 -0
  173. package/types/components/GoogleMap.js.flow +105 -0
  174. package/types/components/GooglePlacesSearch.js.flow +43 -0
  175. package/types/components/HorizontalCards.js.flow +226 -0
  176. package/types/components/ItemCollection.js.flow +159 -0
  177. package/types/components/ItemList.js.flow +126 -0
  178. package/types/components/Items.js.flow +365 -0
  179. package/types/components/ItemsToggle.js.flow +168 -0
  180. package/types/components/KeyboardField.js.flow +147 -0
  181. package/types/components/LazyDocument.js.flow +113 -0
  182. package/types/components/LazyImage.js.flow +119 -0
  183. package/types/components/LazyVideo.js.flow +131 -0
  184. package/types/components/LinkButton.js.flow +23 -0
  185. package/types/components/LinkLabel.js.flow +29 -0
  186. package/types/components/List.js.flow +761 -0
  187. package/types/components/ListFilters.js.flow +408 -0
  188. package/types/components/ListLoader.js.flow +32 -0
  189. package/types/components/ListTable.js.flow +86 -0
  190. package/types/components/LoginModal.js.flow +102 -0
  191. package/types/components/MasonryGrid.js.flow +202 -0
  192. package/types/components/MediaGallery.js.flow +148 -0
  193. package/types/components/MediaGrid.js.flow +74 -0
  194. package/types/components/MediaList.js.flow +98 -0
  195. package/types/components/MenuBar.js.flow +77 -0
  196. package/types/components/MenuSidebar.js.flow +72 -0
  197. package/types/components/ModalDropdown.js.flow +84 -0
  198. package/types/components/NestedAccordion.js.flow +276 -0
  199. package/types/components/PhotoViewer.js.flow +36 -0
  200. package/types/components/PlayButton.js.flow +37 -0
  201. package/types/components/RemoteDropdown.js.flow +368 -0
  202. package/types/components/SaveButton.js.flow +31 -0
  203. package/types/components/Section.js.flow +41 -0
  204. package/types/components/Selectize.js.flow +297 -0
  205. package/types/components/SelectizeHeader.js.flow +40 -0
  206. package/types/components/TabbedModal.js.flow +165 -0
  207. package/types/components/TabsMenu.js.flow +35 -0
  208. package/types/components/TagsList.js.flow +43 -0
  209. package/types/components/Thumbnail.js.flow +47 -0
  210. package/types/components/Toaster.js.flow +73 -0
  211. package/types/components/VideoFrameSelector.js.flow +148 -0
  212. package/types/components/VideoPlayer.js.flow +55 -0
  213. package/types/components/VideoPlayerButton.js.flow +17 -0
  214. package/types/components/ViewXML.js.flow +72 -0
  215. package/types/hooks/Imageable.js.flow +54 -0
  216. package/types/i18n/i18n.js.flow +24 -0
  217. package/types/index.js.flow +78 -0
  218. package/webpack.config.js +3 -0
@@ -0,0 +1,338 @@
1
+ // @flow
2
+
3
+ import { Timer } from '@performant-software/shared-components';
4
+ import React, { Component } from 'react';
5
+ import { Button, Dropdown, Message } from 'semantic-ui-react';
6
+ import _ from 'underscore';
7
+ import EditModal from './EditModal';
8
+ import i18n from '../i18n/i18n';
9
+ import Toaster from './Toaster';
10
+ import './AssociatedDropdown.css';
11
+
12
+ type Option = {
13
+ key: number | string,
14
+ value: number | string,
15
+ text: string
16
+ };
17
+
18
+ type Props = {
19
+ className?: string,
20
+ collectionName: string,
21
+ modal?: {
22
+ component: Component<{}>,
23
+ props: any,
24
+ onSave: (item: any) => Promise<any>,
25
+ state: any
26
+ },
27
+ onSearch: (search: string) => Promise<any>,
28
+ onSelection: (item: any) => void,
29
+ placeholder?: string,
30
+ renderOption: (option: any) => Option,
31
+ required?: boolean,
32
+ searchQuery: string,
33
+ value: ?number,
34
+ upward?: boolean
35
+ };
36
+
37
+ type State = {
38
+ items: Array<any>,
39
+ loading: boolean,
40
+ modalAdd: boolean,
41
+ options: Array<Option>,
42
+ saved: boolean,
43
+ searchQuery: string,
44
+ value: ?number | ?string
45
+ };
46
+
47
+ const TIMEOUT = 500;
48
+
49
+ class AssociatedDropdown extends Component<Props, State> {
50
+ static defaultProps: any;
51
+
52
+ timeout: ?TimeoutID;
53
+
54
+ /**
55
+ * Constructs a new AssociatedDropdown component.
56
+ *
57
+ * @param props
58
+ */
59
+ constructor(props: Props) {
60
+ super(props);
61
+
62
+ this.state = {
63
+ items: [],
64
+ loading: false,
65
+ modalAdd: false,
66
+ options: [],
67
+ saved: false,
68
+ searchQuery: props.searchQuery || '',
69
+ value: props.value || ''
70
+ };
71
+
72
+ this.timeout = null;
73
+ }
74
+
75
+ /**
76
+ * Sets the new search query and value on the state.
77
+ *
78
+ * @param prevProps
79
+ */
80
+ componentDidUpdate(prevProps: Props) {
81
+ if (prevProps.value !== this.props.value) {
82
+ const { searchQuery, value } = this.props;
83
+ this.setState({ searchQuery, value });
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Clears the search timer.
89
+ */
90
+ clearSearchTimer() {
91
+ clearTimeout(this.timeout);
92
+ }
93
+
94
+ /**
95
+ * Clears the search query value if an option was not selected.
96
+ */
97
+ onBlur() {
98
+ this.setState((state) => {
99
+ let searchQuery = '';
100
+
101
+ if (state.value) {
102
+ searchQuery = this.props.searchQuery;
103
+ }
104
+
105
+ return { searchQuery };
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Clears the search query and value.
111
+ */
112
+ onClear() {
113
+ this.setState({ searchQuery: '', value: '' }, () => {
114
+ this.props.onSelection(this.state.value);
115
+ });
116
+ }
117
+
118
+ /**
119
+ * Clears the search query and executes the search.
120
+ */
121
+ onOpen() {
122
+ this.setState({ searchQuery: '' }, this.onSearch.bind(this));
123
+ }
124
+
125
+ /**
126
+ * Resets the search query and value on the state.
127
+ *
128
+ * @param e
129
+ * @param value
130
+ */
131
+ onOptionSelection(e: Event, { value }: { value: any }) {
132
+ this.setState((state) => {
133
+ const option = _.findWhere(state.options, { value }) || {};
134
+ this.setState({ searchQuery: option.text, value: option.value });
135
+ });
136
+
137
+ const item = _.findWhere(this.state.items, { id: value });
138
+ this.props.onSelection(item);
139
+ }
140
+
141
+ /**
142
+ * Executes the search to load the options.
143
+ */
144
+ onSearch() {
145
+ this.setState({ loading: true }, this.search.bind(this));
146
+ }
147
+
148
+ /**
149
+ * Sets the search query on the state.
150
+ *
151
+ * @param e
152
+ * @param searchQuery
153
+ */
154
+ onSearchChange(e: Event, { searchQuery }: { searchQuery: string }) {
155
+ this.setState({ searchQuery });
156
+ }
157
+
158
+ search() {
159
+ this.props
160
+ .onSearch(this.state.searchQuery)
161
+ .then(({ data }) => {
162
+ const items = data[this.props.collectionName];
163
+ const options = items.map(this.props.renderOption.bind(this));
164
+
165
+ this.setState({ items, options, loading: false });
166
+ });
167
+ }
168
+
169
+ /**
170
+ * Renders the AssociatedDropdown component.
171
+ *
172
+ * @returns {*}
173
+ */
174
+ render() {
175
+ return (
176
+ <div
177
+ className='association-dropdown'
178
+ >
179
+ <div className='dropdown-container'>
180
+ <Dropdown
181
+ className={`inline-dropdown ${this.props.className || ''}`}
182
+ disabled={this.state.loading}
183
+ loading={this.state.loading}
184
+ onBlur={this.onBlur.bind(this)}
185
+ onChange={this.onOptionSelection.bind(this)}
186
+ onOpen={this.onOpen.bind(this)}
187
+ onSearchChange={this.onSearchChange.bind(this)}
188
+ options={this.state.options}
189
+ placeholder={this.props.placeholder}
190
+ search={() => this.state.options}
191
+ searchInput={{
192
+ 'aria-label': this.props.collectionName,
193
+ className: 'dropdown-search-input',
194
+ onKeyDown: Timer.clearSearchTimer.bind(this),
195
+ onKeyUp: Timer.setSearchTimer.bind(this, this.onSearch.bind(this))
196
+ }}
197
+ searchQuery={this.state.searchQuery}
198
+ selectOnBlur={false}
199
+ selection
200
+ upward={this.props.upward}
201
+ value={this.state.value}
202
+ />
203
+ </div>
204
+ <Button.Group
205
+ className='buttons'
206
+ >
207
+ { this.renderEditButton() }
208
+ { this.renderAddButton() }
209
+ { this.renderClearButton() }
210
+ </Button.Group>
211
+ { this.renderAddModal() }
212
+ { this.state.saved && (
213
+ <Toaster
214
+ onDismiss={() => this.setState({ saved: false })}
215
+ type={Toaster.MessageTypes.positive}
216
+ >
217
+ <Message.Header
218
+ content={i18n.t('Common.messages.save.header')}
219
+ />
220
+ <Message.Content
221
+ content={i18n.t('Common.messages.save.content')}
222
+ />
223
+ </Toaster>
224
+ )}
225
+ </div>
226
+ );
227
+ }
228
+
229
+ /**
230
+ * Renders the add button (if applicable).
231
+ *
232
+ * @returns {null|*}
233
+ */
234
+ renderAddButton() {
235
+ if (!this.props.modal) {
236
+ return null;
237
+ }
238
+
239
+ return (
240
+ <Button
241
+ basic
242
+ content={i18n.t('Common.buttons.add')}
243
+ icon='plus'
244
+ onClick={() => this.setState({ modalAdd: true })}
245
+ type='button'
246
+ />
247
+ );
248
+ }
249
+
250
+ /**
251
+ * Renders the edit button (if applicable).
252
+ *
253
+ * @returns {null|*}
254
+ */
255
+ renderEditButton() {
256
+ if (!this.props.modal || !this.props.modal.props || !this.props.modal.props.onInitialize || !this.state.value) {
257
+ return null;
258
+ }
259
+
260
+ return (
261
+ <Button
262
+ basic
263
+ content={i18n.t('Common.buttons.edit')}
264
+ icon='pencil'
265
+ onClick={() => this.setState({ modalAdd: true })}
266
+ type='button'
267
+ />
268
+ );
269
+ }
270
+
271
+ /**
272
+ * Renders the add association button.
273
+ *
274
+ * @returns {null|*}
275
+ */
276
+ renderAddModal() {
277
+ if (!(this.state.modalAdd && this.props.modal)) {
278
+ return null;
279
+ }
280
+
281
+ const {
282
+ component, props, onSave
283
+ } = this.props.modal;
284
+
285
+ return (
286
+ <EditModal
287
+ component={component}
288
+ item={{ id: this.state.value }}
289
+ onClose={() => this.setState({ modalAdd: false })}
290
+ onSave={(item) => onSave(item)
291
+ .then((record) => {
292
+ this.props.onSelection(record);
293
+ this.setState({ modalAdd: false, saved: true });
294
+ })}
295
+ {...props}
296
+ />
297
+ );
298
+ }
299
+
300
+ /**
301
+ * Renders the clear button.
302
+ *
303
+ * @returns {*}
304
+ */
305
+ renderClearButton() {
306
+ if (this.props.required) {
307
+ return null;
308
+ }
309
+
310
+ return (
311
+ <Button
312
+ basic
313
+ content={i18n.t('Common.buttons.clear')}
314
+ icon='times'
315
+ onClick={this.onClear.bind(this)}
316
+ type='button'
317
+ />
318
+ );
319
+ }
320
+
321
+ /**
322
+ * Sets the search timer.
323
+ */
324
+ setSearchTimer() {
325
+ clearTimeout(this.timeout);
326
+ this.timeout = setTimeout(this.onSearch.bind(this), TIMEOUT);
327
+ }
328
+ }
329
+
330
+ AssociatedDropdown.defaultProps = {
331
+ className: '',
332
+ modal: null,
333
+ placeholder: null,
334
+ required: false,
335
+ upward: false
336
+ };
337
+
338
+ export default AssociatedDropdown;
@@ -0,0 +1,33 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import { Icon } from 'semantic-ui-react';
5
+
6
+ type Props = {
7
+ value: boolean
8
+ };
9
+
10
+ const ICON_FALSE = 'times circle outline';
11
+ const ICON_TRUE = 'check circle outline';
12
+
13
+ const COLOR_FALSE = 'red';
14
+ const COLOR_TRUE = 'green';
15
+
16
+ const BooleanIcon = (props: Props) => {
17
+ let name = ICON_FALSE;
18
+ let color = COLOR_FALSE;
19
+
20
+ if (props.value) {
21
+ name = ICON_TRUE;
22
+ color = COLOR_TRUE;
23
+ }
24
+
25
+ return (
26
+ <Icon
27
+ color={color}
28
+ name={name}
29
+ />
30
+ );
31
+ };
32
+
33
+ export default BooleanIcon;
@@ -0,0 +1,25 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import { Button } from 'semantic-ui-react';
5
+ import i18n from '../i18n/i18n';
6
+
7
+ type Props = {
8
+ disabled: boolean,
9
+ onClick: () => void
10
+ };
11
+
12
+ const CancelButton = (props: Props) => (
13
+ <Button
14
+ disabled={props.disabled}
15
+ inverted
16
+ onClick={props.onClick.bind(this)}
17
+ primary
18
+ size='medium'
19
+ type='button'
20
+ >
21
+ { i18n.t('Common.buttons.cancel') }
22
+ </Button>
23
+ );
24
+
25
+ export default CancelButton;
@@ -0,0 +1,34 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import { Button } from 'semantic-ui-react';
5
+ import './ColorButton.css';
6
+
7
+ type Props = {
8
+ color: string,
9
+ height?: number,
10
+ onClick?: () => void,
11
+ width?: number
12
+ }
13
+
14
+ const ColorButton = (props: Props) => (
15
+ <Button
16
+ className='color-button'
17
+ onClick={props.onClick && props.onClick.bind(this)}
18
+ style={{
19
+ backgroundColor: props.color,
20
+ cursor: props.onClick ? 'pointer' : 'default',
21
+ height: props.height,
22
+ width: props.width
23
+ }}
24
+ title='color-button'
25
+ />
26
+ );
27
+
28
+ ColorButton.defaultProps = {
29
+ height: undefined,
30
+ onClick: undefined,
31
+ width: undefined
32
+ };
33
+
34
+ export default ColorButton;
@@ -0,0 +1,77 @@
1
+ // @flow
2
+
3
+ import React, { Component } from 'react';
4
+ import { SketchPicker } from 'react-color';
5
+ import { Button, Modal } from 'semantic-ui-react';
6
+ import i18n from '../i18n/i18n';
7
+ import './ColorPickerModal.css';
8
+
9
+ type Props = {
10
+ color: string,
11
+ onClose: () => void,
12
+ onSave: (selectedColor: string) => void,
13
+ open: boolean
14
+ };
15
+
16
+ type State = {
17
+ selectedColor: string
18
+ };
19
+
20
+ class ColorPickerModal extends Component<Props, State> {
21
+ /**
22
+ * Constructs a new ColorPickerModal component.
23
+ *
24
+ * @param props
25
+ */
26
+ constructor(props: Props) {
27
+ super(props);
28
+
29
+ this.state = {
30
+ selectedColor: props.color
31
+ };
32
+ }
33
+
34
+ /**
35
+ * Renders the ColorPickerModal component.
36
+ *
37
+ * @returns {*}
38
+ */
39
+ render() {
40
+ return (
41
+ <Modal
42
+ className='color-picker-modal'
43
+ onClose={this.props.onClose.bind(this)}
44
+ open={this.props.open}
45
+ >
46
+ <Modal.Content>
47
+ <SketchPicker
48
+ color={this.state.selectedColor}
49
+ disableAlpha={false}
50
+ onChangeComplete={(selectedColor) => this.setState({ selectedColor })}
51
+ />
52
+ </Modal.Content>
53
+ <Modal.Actions>
54
+ <Button
55
+ onClick={this.props.onSave.bind(this, this.state.selectedColor)}
56
+ primary
57
+ size='medium'
58
+ type='submit'
59
+ >
60
+ { i18n.t('Common.buttons.save') }
61
+ </Button>
62
+ <Button
63
+ inverted
64
+ onClick={this.props.onClose.bind(this)}
65
+ primary
66
+ size='medium'
67
+ type='button'
68
+ >
69
+ { i18n.t('Common.buttons.cancel') }
70
+ </Button>
71
+ </Modal.Actions>
72
+ </Modal>
73
+ );
74
+ }
75
+ }
76
+
77
+ export default ColorPickerModal;
@@ -0,0 +1,20 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import './ColumnResize.css';
5
+
6
+ type Props = {
7
+ onMouseDown: (e: MouseEvent) => void
8
+ };
9
+
10
+ const ColumnResize = (props: Props) => (
11
+ <div
12
+ className='column-resize'
13
+ onMouseDown={props.onMouseDown.bind(this)}
14
+ role='presentation'
15
+ >
16
+ &nbsp;
17
+ </div>
18
+ );
19
+
20
+ export default ColumnResize;