@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
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./build/index');
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@performant-software/semantic-components",
3
+ "version": "0.5.1",
4
+ "description": "A package of shared components based on the Semantic UI Framework.",
5
+ "license": "MIT",
6
+ "main": "./build/index.js",
7
+ "style": "./build/styles.css",
8
+ "scripts": {
9
+ "build": "webpack --mode production && flow-copy-source -v src types",
10
+ "postinstall": "yarn build"
11
+ },
12
+ "dependencies": {
13
+ "@performant-software/shared-components": "^0.5.1",
14
+ "@react-google-maps/api": "^2.8.1",
15
+ "flow-copy-source": "^2.0.9",
16
+ "i18next": "^19.4.4",
17
+ "react-calendar": "^3.3.0",
18
+ "react-color": "^2.18.1",
19
+ "react-dnd": "^11.1.3",
20
+ "react-dnd-html5-backend": "^11.1.3",
21
+ "react-i18next": "^11.4.0",
22
+ "react-syntax-highlighter": "^15.5.0",
23
+ "react-uuid": "^1.0.2",
24
+ "semantic-ui-css": "^2.4.1",
25
+ "semantic-ui-react": "^2.1.2",
26
+ "underscore": "^1.13.2"
27
+ },
28
+ "peerDependencies": {
29
+ "react": ">= 16.13.1 < 18.0.0",
30
+ "react-dom": ">= 16.13.1 < 18.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@performant-software/webpack-config": "^0.5.1",
34
+ "react": "^17.0.2",
35
+ "react-dom": "^17.0.2"
36
+ }
37
+ }
@@ -0,0 +1,8 @@
1
+ .accordion-data-list {
2
+ margin-bottom: 1em;
3
+ margin-top: 1em;
4
+ }
5
+
6
+ .accordion-data-list .ui.styled.accordion div[index="0"] .title {
7
+ border-top: none;
8
+ }
@@ -0,0 +1,224 @@
1
+ // @flow
2
+
3
+ import React, {
4
+ useCallback,
5
+ useEffect,
6
+ useMemo,
7
+ useRef,
8
+ type Element
9
+ } from 'react';
10
+ import _ from 'underscore';
11
+ import { Button, Checkbox, Dropdown } from 'semantic-ui-react';
12
+ import NestedAccordion from './NestedAccordion';
13
+ import useDataList, { SORT_ASCENDING } from './DataList';
14
+ import useList, { type Props as ListProps } from './List';
15
+ import './AccordionDataList.css';
16
+
17
+ type Sort = {
18
+ key: any,
19
+ value: any,
20
+ text: string,
21
+ direction?: string
22
+ };
23
+
24
+ type Props = ListProps & {
25
+ getChildItems: (items: ?Array<any>, item: any) => Array<any>,
26
+ getRootItems: (items: ?Array<any>) => Array<any>,
27
+ page: number,
28
+ onInit: () => void,
29
+ onSort: (column: string, direction: ?string, page?: number) => void,
30
+ selectable: boolean,
31
+ sort?: Array<Sort>,
32
+ sortColumn?: string,
33
+ sortDirection?: string
34
+ };
35
+
36
+ type AccordionProps = ListProps & {
37
+ getChildItems: (items: Array<any>, item: any) => Array<any>,
38
+ onItemToggle: (item: any) => void,
39
+ onRowSelect: (?any, ?any, ?any) => void,
40
+ renderItem: (item: any) => Element<any>,
41
+ rootItems: Array<any>,
42
+ selectable: boolean,
43
+ selectedRows: Array<{id: number}>,
44
+ showToggle: (item: any) => boolean
45
+ };
46
+
47
+ const Accordion = useList((props: AccordionProps) => {
48
+ /**
49
+ * Renders the actions for the passed item.
50
+ *
51
+ * @type {(function(*=): (null|*))|*}
52
+ */
53
+ const renderActions = useCallback((item) => {
54
+ const actions = _.filter(props.actions, (action) => !action.accept || action.accept(item));
55
+
56
+ if (_.isEmpty(actions)) {
57
+ return null;
58
+ }
59
+
60
+ return (
61
+ <Button.Group>
62
+ { _.map(actions, (action, index) => (
63
+ <Button
64
+ basic
65
+ color={action.color}
66
+ icon={action.icon}
67
+ key={`${action.name}-${index}`}
68
+ onClick={action.onClick && action.onClick.bind(this, item)}
69
+ title={action.title}
70
+ />
71
+ ))}
72
+ </Button.Group>
73
+ );
74
+ }, [props.actions]);
75
+
76
+ /**
77
+ * Renders the checkbox for the passed item.
78
+ *
79
+ * @type {(function(*=): (null|*))|*}
80
+ */
81
+ const renderCheckbox = useCallback((item) => {
82
+ if (!props.selectable) {
83
+ return null;
84
+ }
85
+
86
+ return (
87
+ <Checkbox
88
+ key={`select-checkbox-${item.id}`}
89
+ className='row-select-checkbox'
90
+ onClick={(e, el) => props.onRowSelect(el, item, e)}
91
+ checked={!!props.selectedRows.find((r) => r.id === item.id)}
92
+ />
93
+ );
94
+ }, [props.onRowSelect, props.selectable, props.selectedRows]);
95
+
96
+ return (
97
+ <div
98
+ className={['accordion-data-list', props.className || ''].join(' ')}
99
+ >
100
+ <NestedAccordion
101
+ getChildItems={props.getChildItems}
102
+ onItemToggle={(item) => props.onItemToggle && props.onItemToggle(item)}
103
+ renderItem={(item) => props.renderItem(item)}
104
+ renderRight={(item) => (
105
+ <>
106
+ { renderActions(item) }
107
+ { renderCheckbox(item) }
108
+ </>
109
+ )}
110
+ rootItems={props.rootItems}
111
+ showToggle={(item) => props.showToggle(item)}
112
+ />
113
+ </div>
114
+ );
115
+ });
116
+
117
+ const AccordionDataList = (props: Props) => {
118
+ const rootItems = useMemo(() => props.getRootItems(props.items), [props.items]);
119
+ const getChildItems = useCallback((item) => props.getChildItems(props.items, item), [props.items]);
120
+ const sortDropdown = useRef<?typeof Dropdown>();
121
+
122
+ /**
123
+ * Sets the current sort value.
124
+ *
125
+ * @type {unknown}
126
+ */
127
+ const sortValue = useMemo(() => {
128
+ const sort = _.find(props.sort, { value: props.sortColumn });
129
+ return sort && sort.text;
130
+ }, [props.sort, props.sortColumn]);
131
+
132
+ /**
133
+ * Toggles the sort property.
134
+ *
135
+ * @type {(function(*): void)|*}
136
+ */
137
+ const onSort = useCallback((sort) => {
138
+ if (!props.onSort) {
139
+ return;
140
+ }
141
+
142
+ let sortDirection;
143
+
144
+ if (sort.value !== props.sortColumn) {
145
+ sortDirection = sort.direction;
146
+ }
147
+
148
+ props.onSort(sort.value, sortDirection);
149
+ }, [props.onSort, props.sortColumn]);
150
+
151
+ /**
152
+ * Renders the sort dropdown.
153
+ *
154
+ * @type {(function(): (null|*))|*}
155
+ */
156
+ const renderSort = useCallback(() => {
157
+ if (_.isEmpty(props.sort)) {
158
+ return null;
159
+ }
160
+
161
+ return (
162
+ <Button.Group
163
+ basic
164
+ style={{
165
+ fontSize: 'inherit'
166
+ }}
167
+ >
168
+ <Button
169
+ content={sortValue}
170
+ icon={props.sortDirection === SORT_ASCENDING ? 'sort alphabet up' : 'sort alphabet down'}
171
+ onClick={(e) => sortDropdown.current && sortDropdown.current.handleClick(e)}
172
+ />
173
+ <Dropdown
174
+ className='button icon'
175
+ floating
176
+ options={_.map(props.sort, (sort) => ({
177
+ ...sort,
178
+ onClick: () => onSort(sort)
179
+ }))}
180
+ ref={sortDropdown}
181
+ trigger={<></>}
182
+ value={props.sortColumn}
183
+ />
184
+ </Button.Group>
185
+ );
186
+ }, [props.sort, props.sortColumn, props.sortDirection]);
187
+
188
+ /**
189
+ * Sorts the first column on component mount. If no sort properties are defined, the onInit prop is called.
190
+ */
191
+ useEffect(() => {
192
+ if (_.isEmpty(props.sort)) {
193
+ return props.onInit();
194
+ }
195
+
196
+ const { page } = props;
197
+ let { sortColumn = '', sortDirection = SORT_ASCENDING } = props;
198
+
199
+ if (!sortColumn) {
200
+ const defaultSort = _.first(props.sort);
201
+
202
+ if (defaultSort) {
203
+ sortColumn = defaultSort.value;
204
+
205
+ if (defaultSort.direction) {
206
+ sortDirection = defaultSort.direction;
207
+ }
208
+ }
209
+ }
210
+
211
+ return props.onSort(sortColumn, sortDirection, page);
212
+ }, []);
213
+
214
+ return (
215
+ <Accordion
216
+ {...props}
217
+ renderListHeader={renderSort}
218
+ rootItems={rootItems}
219
+ getChildItems={getChildItems}
220
+ />
221
+ );
222
+ };
223
+
224
+ export default useDataList(AccordionDataList);
@@ -0,0 +1,27 @@
1
+ .accordion-list .accordion-header {
2
+ text-align: right;
3
+ }
4
+
5
+ .accordion-list .accordion-header .add-button {
6
+ margin-left: 5px;
7
+ }
8
+
9
+ .accordion-list .accordion-header .input.search {
10
+ display: inline-block;
11
+ }
12
+
13
+ .accordion-list p.record-count {
14
+ text-align: right;
15
+ margin-top: 10px;
16
+ }
17
+
18
+ .accordion-list .footer {
19
+ margin-top: 15px;
20
+ }
21
+
22
+ .accordion-list .sub-header {
23
+ display: flex;
24
+ align-items: center;
25
+ justify-content: flex-end;
26
+ padding: .75em 1em;
27
+ }