@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,146 @@
1
+ // @flow
2
+
3
+ import React, { Component, type ComponentType } from 'react';
4
+ import { Checkbox, Dropdown, Icon } from 'semantic-ui-react';
5
+ import _ from 'underscore';
6
+ import Draggable from './Draggable';
7
+ import './DataTableColumnSelector.css';
8
+
9
+ import type { Column } from './DataTable';
10
+
11
+ type Props = {
12
+ className: string,
13
+ columns: Array<Column>
14
+ };
15
+
16
+ type State = {
17
+ columns: Array<Column>
18
+ };
19
+
20
+ /**
21
+ * Returns a function to wrap the passed component in a column selector. The ColumnSelector component will bind a
22
+ * renderListHeader function, which can be used in the wrapped component to render a column selector dropdown button.
23
+ *
24
+ * @param WrappedComponent
25
+ */
26
+ const useColumnSelector = (WrappedComponent: ComponentType<any>) => (
27
+ class extends Component<Props, State> {
28
+ static defaultProps = {
29
+ className: ''
30
+ };
31
+
32
+ /**
33
+ * Constructs a new DataTableColumnSelector component.
34
+ *
35
+ * @param props
36
+ */
37
+ constructor(props: Props) {
38
+ super(props);
39
+
40
+ this.state = {
41
+ columns: props.columns
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Toggles the hidden property for the passed column.
47
+ *
48
+ * @param column
49
+ */
50
+ onColumnCheckbox(column: Column) {
51
+ this.setState((state) => ({
52
+ columns: _.map(state.columns, (c) => (c.name === column.name ? { ...c, hidden: !c.hidden } : c))
53
+ }));
54
+ }
55
+
56
+ /**
57
+ * Drags/drops the column at the passed index to the new position.
58
+ *
59
+ * @param dragIndex
60
+ * @param hoverIndex
61
+ */
62
+ onDrag(dragIndex: number, hoverIndex: number) {
63
+ this.setState((state) => {
64
+ const columns = [];
65
+ const anchoredColumns = [];
66
+
67
+ // Preserve the index of any unlabeled columns
68
+ _.each(state.columns, (column, index) => {
69
+ if (column.label && column.label.length) {
70
+ columns.push(column);
71
+ } else {
72
+ anchoredColumns.push({ index, column });
73
+ }
74
+ });
75
+
76
+ const column = columns[dragIndex];
77
+ columns.splice(dragIndex, 1);
78
+ columns.splice(hoverIndex, 0, column);
79
+
80
+ // Add the unlabeled columns back in
81
+ _.each(anchoredColumns, (c) => columns.splice(c.index, 0, c.column));
82
+
83
+ return { columns };
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Renders the DataTableColumnSelector component.
89
+ *
90
+ * @returns {*}
91
+ */
92
+ render() {
93
+ return (
94
+ <WrappedComponent
95
+ {...this.props}
96
+ className={`data-table-column-selector ${this.props.className}`}
97
+ columns={this.state.columns}
98
+ renderListHeader={this.renderHeader.bind(this)}
99
+ />
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Renders the dropdown column selector.
105
+ *
106
+ * @returns {*}
107
+ */
108
+ renderHeader() {
109
+ return (
110
+ <Dropdown
111
+ basic
112
+ button
113
+ icon='cog'
114
+ className='icon configure-button open-right'
115
+ simple
116
+ >
117
+ <Dropdown.Menu>
118
+ { this.state.columns
119
+ .filter((c) => c.label && c.label.length)
120
+ .map((c, index) => (
121
+ <Draggable
122
+ id={c.name}
123
+ index={index}
124
+ key={c.name}
125
+ onDrag={this.onDrag.bind(this)}
126
+ >
127
+ <Dropdown.Item>
128
+ <Icon
129
+ name='bars'
130
+ />
131
+ <Checkbox
132
+ checked={!c.hidden}
133
+ label={c.label}
134
+ onClick={this.onColumnCheckbox.bind(this, c)}
135
+ />
136
+ </Dropdown.Item>
137
+ </Draggable>
138
+ ))}
139
+ </Dropdown.Menu>
140
+ </Dropdown>
141
+ );
142
+ }
143
+ }
144
+ );
145
+
146
+ export default useColumnSelector;
@@ -0,0 +1,6 @@
1
+ .date-input.ui.icon.input > i.icon.right {
2
+ cursor: pointer;
3
+ pointer-events: inherit;
4
+ left: auto;
5
+ right: 1px;
6
+ }
@@ -0,0 +1,58 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import { Icon, Input } from 'semantic-ui-react';
5
+ import './DateInput.css';
6
+
7
+ type Props = {
8
+ display?: string,
9
+ formatOptions?: any,
10
+ locale?: string,
11
+ onChange: (date: ?Date) => void,
12
+ onClick: () => void,
13
+ value?: ?Date
14
+ }
15
+
16
+ const DateInput = (props: Props) => {
17
+ const formatDate = () => {
18
+ let date = '';
19
+
20
+ if (props.display) {
21
+ date = props.display;
22
+ } else if (props.value) {
23
+ date = props.value.toLocaleDateString(props.locale, props.formatOptions);
24
+ }
25
+
26
+ return date;
27
+ };
28
+
29
+ return (
30
+ <Input
31
+ className='date-input icon'
32
+ icon='calendar alternate outline'
33
+ iconPosition='left'
34
+ >
35
+ <Icon
36
+ className='left icon'
37
+ name='calendar alternate outline'
38
+ />
39
+ <input
40
+ onClick={props.onClick.bind(this)}
41
+ readOnly
42
+ type='text'
43
+ value={formatDate()}
44
+ />
45
+ <Icon
46
+ className='right icon'
47
+ name='times'
48
+ onClick={(e) => {
49
+ e.stopPropagation();
50
+ e.preventDefault();
51
+ props.onChange(null);
52
+ }}
53
+ />
54
+ </Input>
55
+ );
56
+ };
57
+
58
+ export default DateInput;
@@ -0,0 +1,72 @@
1
+ div.react-calendar {
2
+ margin-top: 3em;
3
+ background: #fff;
4
+ color: rgba(0,0,0,.6)!important;
5
+ border: none;
6
+ border-radius: .28571429rem;
7
+ text-transform: none;
8
+ text-shadow: none;
9
+ box-shadow: 0 0 0 1px rgba(34,36,38,.15) inset;
10
+ padding: .58928571em .58928571em .58928571em;
11
+ }
12
+
13
+ .react-calendar,
14
+ .react-calendar button {
15
+ font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
16
+ }
17
+
18
+ .react-calendar button {
19
+ background: transparent none;
20
+ color: rgba(0,0,0,.87);
21
+ font-weight: 400;
22
+ border-radius: .28571429rem;
23
+ text-transform: none;
24
+ text-shadow: none;
25
+ }
26
+
27
+ .react-calendar button:focus,
28
+ .react-calendar .react-calendar__navigation button:enabled:focus {
29
+ background: transparent none;
30
+ }
31
+
32
+ .react-calendar button:enabled:hover,
33
+ .react-calendar .react-calendar__navigation button:enabled:hover {
34
+ background: #fff;
35
+ color: rgba(0,0,0,.6);
36
+ }
37
+
38
+ .react-calendar .react-calendar__month-view__days__day--neighboringMonth {
39
+ color: rgba(0,0,0,.4);
40
+ }
41
+
42
+ .react-calendar abbr[title] {
43
+ text-decoration: none;
44
+ }
45
+
46
+ .react-calendar .react-calendar__tile--now {
47
+ background-color: #fbbd08;
48
+ color: #fff;
49
+ }
50
+
51
+ .react-calendar .react-calendar__tile--now:enabled:hover {
52
+ background-color: #eaae00;
53
+ color: #fff;
54
+ }
55
+
56
+ .react-calendar .react-calendar__month-view__days__day--weekend {
57
+ color: #db2828;
58
+ }
59
+
60
+ .react-calendar .react-calendar__month-view__days__day--weekend:enabled:hover {
61
+ color: #d01919;
62
+ }
63
+
64
+ .react-calendar .react-calendar__tile--active {
65
+ background-color: #2185d0;
66
+ color: #fff;
67
+ }
68
+
69
+ .react-calendar .react-calendar__tile--active:enabled:hover {
70
+ background-color: #1678c2;
71
+ color: #fff;
72
+ }
@@ -0,0 +1,81 @@
1
+ // @flow
2
+
3
+ import React, { useEffect, useRef, useState } from 'react';
4
+ import Calendar from 'react-calendar';
5
+ import { Icon, Transition } from 'semantic-ui-react';
6
+ import DateInput from './DateInput';
7
+
8
+ import './DatePicker.css';
9
+
10
+ type Props = {
11
+ closeOnSelection?: boolean,
12
+ formatOptions?: any,
13
+ locale?: string,
14
+ onChange: (date: ?Date) => void,
15
+ value: ?Date
16
+ };
17
+
18
+ const DatePicker = (props: Props) => {
19
+ const [calendar, setCalendar] = useState(false);
20
+ const calendarWrapper = useRef<any>(null);
21
+
22
+ const onDocumentClick = (event: Event) => {
23
+ const calendarInstance = calendarWrapper.current;
24
+
25
+ if (calendarInstance && !calendarInstance.contains(event.target)) {
26
+ setCalendar(false);
27
+ }
28
+ };
29
+
30
+ useEffect(() => {
31
+ // Bind the event listener
32
+ document.addEventListener('mousedown', onDocumentClick);
33
+
34
+ // Unbind the event listener
35
+ return () => document.removeEventListener('mousedown', onDocumentClick);
36
+ }, [calendarWrapper]);
37
+
38
+ return (
39
+ <>
40
+ <DateInput
41
+ formatOptions={props.formatOptions}
42
+ locale={props.locale}
43
+ onChange={props.onChange.bind(this)}
44
+ onClick={() => setCalendar(true)}
45
+ value={props.value}
46
+ />
47
+ <Transition
48
+ visible={calendar}
49
+ >
50
+ <div
51
+ ref={calendarWrapper}
52
+ style={{
53
+ position: 'absolute',
54
+ zIndex: '999'
55
+ }}
56
+ >
57
+ <Calendar
58
+ locale={props.locale}
59
+ onChange={(date) => {
60
+ props.onChange(date);
61
+ if (props.closeOnSelection) {
62
+ setCalendar(false);
63
+ }
64
+ }}
65
+ next2Label={<Icon name='angle double right' />}
66
+ nextLabel={<Icon name='chevron right' />}
67
+ prev2Label={<Icon name='angle double left' />}
68
+ prevLabel={<Icon name='chevron left' />}
69
+ value={props.value}
70
+ />
71
+ </div>
72
+ </Transition>
73
+ </>
74
+ );
75
+ };
76
+
77
+ DatePicker.defaultProps = {
78
+ closeOnSelection: true
79
+ };
80
+
81
+ export default DatePicker;
File without changes
@@ -0,0 +1,42 @@
1
+ // @flow
2
+
3
+ import React, { type Component } from 'react';
4
+ import { Popup } from 'semantic-ui-react';
5
+
6
+ type Props = {
7
+ className?: string,
8
+ content: string,
9
+ delayInterval?: number,
10
+ renderPopup?: () => Component<any>,
11
+ popupContent?: string
12
+ }
13
+
14
+ /**
15
+ * Renders the DescriptorField component. This component can be used to static text as with a popup on hover.
16
+ *
17
+ * @param props
18
+ *
19
+ * @returns {*}
20
+ *
21
+ * @constructor
22
+ */
23
+ const DescriptorField = (props: Props) => (
24
+ <Popup
25
+ className={props.className}
26
+ content={props.popupContent}
27
+ hoverable
28
+ mouseEnterDelay={props.delayInterval}
29
+ trigger={props.renderPopup
30
+ ? props.renderPopup()
31
+ : (<span className='text'>{ props.content }</span>)}
32
+ wide
33
+ />
34
+ );
35
+
36
+ DescriptorField.defaultProps = {
37
+ delayInterval: 1000,
38
+ renderPopup: undefined,
39
+ popupContent: undefined
40
+ };
41
+
42
+ export default DescriptorField;
File without changes
@@ -0,0 +1,23 @@
1
+ // @flow
2
+
3
+ import React from 'react';
4
+ import uuid from 'react-uuid';
5
+ import { Button } from 'semantic-ui-react';
6
+
7
+ type Props = {
8
+ filename?: string,
9
+ url: string
10
+ };
11
+
12
+ const DownloadButton = ({ filename, url, ...button }: Props) => (
13
+ <a
14
+ download={filename || uuid()}
15
+ href={url}
16
+ >
17
+ <Button
18
+ {...button}
19
+ />
20
+ </a>
21
+ );
22
+
23
+ export default DownloadButton;
File without changes
@@ -0,0 +1,94 @@
1
+ // @flow
2
+
3
+ import React, { type Element, useRef } from 'react';
4
+ import { Ref } from 'semantic-ui-react';
5
+ import { useDrag, useDrop } from 'react-dnd';
6
+
7
+ type Props = {
8
+ children: Element<any>,
9
+ id: any,
10
+ index: number,
11
+ onDrag: (dragIndex: number, hoverIndex: number) => void
12
+ };
13
+
14
+ const TYPE_ANY = 'any';
15
+
16
+ const Draggable = (props: Props) => {
17
+ const { index, id } = props;
18
+
19
+ const ref = useRef(null);
20
+ const [, drop] = useDrop({
21
+ accept: TYPE_ANY,
22
+ hover(i, monitor) {
23
+ if (!ref.current) {
24
+ return;
25
+ }
26
+
27
+ const dragIndex = i.index;
28
+ const hoverIndex = index;
29
+
30
+ // Don't replace items with themselves
31
+ if (dragIndex === hoverIndex) {
32
+ return;
33
+ }
34
+
35
+ // Determine rectangle on screen
36
+ const hoverBoundingRect = ref.current.getBoundingClientRect();
37
+
38
+ // Get vertical middle
39
+ const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
40
+
41
+ // Determine mouse position
42
+ const clientOffset = monitor.getClientOffset();
43
+
44
+ // Get pixels to the top
45
+ const hoverClientY = clientOffset.y - hoverBoundingRect.top;
46
+
47
+ // Only perform the move when the mouse has crossed half of the items height
48
+ // When dragging downwards, only move when the cursor is below 50%
49
+ // When dragging upwards, only move when the cursor is above 50%
50
+ // Dragging downwards
51
+ if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
52
+ return;
53
+ }
54
+
55
+ // Dragging upwards
56
+ if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
57
+ return;
58
+ }
59
+
60
+ // Time to actually perform the action
61
+ props.onDrag(dragIndex, hoverIndex);
62
+
63
+ // // Note: we're mutating the monitor item here!
64
+ // // Generally it's better to avoid mutations,
65
+ // // but it's good here for the sake of performance
66
+ // // to avoid expensive index searches.
67
+ // eslint-disable-next-line no-param-reassign
68
+ i.index = hoverIndex;
69
+ },
70
+ });
71
+
72
+ const [{ isDragging }, drag] = useDrag({
73
+ item: { type: TYPE_ANY, id, index },
74
+ collect: (monitor) => ({
75
+ isDragging: monitor.isDragging(),
76
+ }),
77
+ });
78
+
79
+ drag(drop(ref));
80
+
81
+ if (ref && ref.current) {
82
+ ref.current.style.opacity = isDragging ? 0 : 1;
83
+ }
84
+
85
+ return (
86
+ <Ref
87
+ innerRef={ref}
88
+ >
89
+ { props.children }
90
+ </Ref>
91
+ );
92
+ };
93
+
94
+ export default Draggable;
@@ -0,0 +1,3 @@
1
+ .dropdown-button.ui.buttons {
2
+ font-size: unset;
3
+ }
@@ -0,0 +1,65 @@
1
+ // @flow
2
+
3
+ import React, { useRef } from 'react';
4
+ import { Button, Dropdown } from 'semantic-ui-react';
5
+ import './DropdownButton.css';
6
+
7
+ type Option = {
8
+ key: any,
9
+ value: any,
10
+ text: string
11
+ };
12
+
13
+ type Props = {
14
+ basic?: boolean,
15
+ color?: string,
16
+ direction?: string,
17
+ disabled?: boolean,
18
+ icon?: string,
19
+ options: Array<Option>,
20
+ onChange: (e: Event, { value: any }) => void,
21
+ scrolling?: boolean,
22
+ selectOnBlur?: boolean,
23
+ text: string,
24
+ value: any
25
+ };
26
+
27
+ const DropdownButton = (props: Props) => {
28
+ const dropdownRef = useRef();
29
+
30
+ return (
31
+ <Button.Group
32
+ basic={props.basic}
33
+ className='dropdown-button'
34
+ color={props.color}
35
+ >
36
+ <Button
37
+ content={props.text}
38
+ disabled={props.disabled}
39
+ icon={props.icon}
40
+ onClick={(e) => dropdownRef.current && dropdownRef.current.handleClick(e)}
41
+ />
42
+ <Dropdown
43
+ className='button icon'
44
+ direction={props.direction}
45
+ disabled={props.disabled}
46
+ floating
47
+ onChange={props.onChange.bind(this)}
48
+ options={props.options}
49
+ ref={dropdownRef}
50
+ scrolling={props.scrolling}
51
+ selectOnBlur={props.selectOnBlur}
52
+ trigger={<></>}
53
+ value={props.value}
54
+ />
55
+ </Button.Group>
56
+ );
57
+ };
58
+
59
+ DropdownButton.defaultProps = {
60
+ color: undefined,
61
+ icon: undefined,
62
+ selectOnBlur: false
63
+ };
64
+
65
+ export default DropdownButton;
File without changes
@@ -0,0 +1,68 @@
1
+ // @flow
2
+
3
+ import React, {
4
+ useCallback,
5
+ useEffect,
6
+ useRef,
7
+ useState,
8
+ type Node
9
+ } from 'react';
10
+ import { Dropdown, Ref } from 'semantic-ui-react';
11
+
12
+ type Props = {
13
+ children: Node,
14
+ onClick?: () => void
15
+ };
16
+
17
+ const DropdownMenu = (props: Props) => {
18
+ const [open, setOpen] = useState(false);
19
+ const ref = useRef();
20
+
21
+ const onMouseEnter = useCallback(() => setOpen(true), []);
22
+ const onMouseLeave = useCallback(() => setOpen(false), []);
23
+
24
+ /**
25
+ * Adds/removes the mouseenter/mouseleave events.
26
+ */
27
+ useEffect(() => {
28
+ if (ref.current) {
29
+ ref.current.addEventListener('mouseenter', onMouseEnter);
30
+ ref.current.addEventListener('mouseleave', onMouseLeave);
31
+ }
32
+
33
+ return () => {
34
+ if (ref.current) {
35
+ ref.current.removeEventListener('mouseenter', onMouseEnter);
36
+ ref.current.removeEventListener('mouseleave', onMouseLeave);
37
+ }
38
+ };
39
+ }, [ref]);
40
+
41
+ return (
42
+ <Ref
43
+ innerRef={ref}
44
+ >
45
+ <Dropdown
46
+ {...props}
47
+ open={open}
48
+ onClick={() => {
49
+ if (props.onClick) {
50
+ props.onClick();
51
+ }
52
+
53
+ setOpen(false);
54
+ }}
55
+ >
56
+ <Dropdown.Menu>
57
+ { props.children }
58
+ </Dropdown.Menu>
59
+ </Dropdown>
60
+ </Ref>
61
+ );
62
+ };
63
+
64
+ DropdownMenu.defaultProps = {
65
+ onClick: undefined
66
+ };
67
+
68
+ export default DropdownMenu;
@@ -0,0 +1,8 @@
1
+ .edit-modal-actions .saving.ui.inline.loader.active {
2
+ margin-left: 4px;
3
+ margin-top: -2px;
4
+ }
5
+
6
+ .ui.form .fields .wide.field.inline-dropdown {
7
+ margin-right: 25px;
8
+ }