@teselagen/ui 0.7.33-beta.2 → 0.7.33-beta.4

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 (248) hide show
  1. package/package.json +1 -1
  2. package/src/AdvancedOptions.spec.js +26 -0
  3. package/src/AsyncValidateFieldSpinner/index.js +12 -0
  4. package/src/BlueprintError/index.js +14 -0
  5. package/src/BounceLoader/index.js +16 -0
  6. package/src/BounceLoader/style.css +45 -0
  7. package/src/CollapsibleCard/index.js +68 -0
  8. package/src/CollapsibleCard/style.css +23 -0
  9. package/src/DNALoader/index.js +20 -0
  10. package/src/DNALoader/style.css +251 -0
  11. package/src/DataTable/index.js +3209 -0
  12. package/src/DataTable/style.css +608 -0
  13. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +515 -0
  14. package/src/DataTable/utils/index.js +55 -0
  15. package/src/DataTable/utils/simplifyHasuraWhere.test.js +73 -0
  16. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +219 -0
  17. package/src/DialogFooter/index.js +86 -0
  18. package/src/DialogFooter/style.css +9 -0
  19. package/src/FormComponents/index.js +1266 -0
  20. package/src/FormComponents/style.css +275 -0
  21. package/src/FormComponents/utils.js +6 -0
  22. package/src/HotkeysDialog/index.js +79 -0
  23. package/src/HotkeysDialog/style.css +54 -0
  24. package/src/InfoHelper/index.js +78 -0
  25. package/src/InfoHelper/style.css +7 -0
  26. package/src/IntentText/index.js +18 -0
  27. package/src/Loading/index.js +70 -0
  28. package/src/Loading/style.css +4 -0
  29. package/src/MenuBar/index.js +423 -0
  30. package/src/MenuBar/style.css +45 -0
  31. package/src/PromptUnsavedChanges/index.js +38 -0
  32. package/src/ResizableDraggableDialog/index.js +141 -0
  33. package/src/ResizableDraggableDialog/style.css +42 -0
  34. package/src/ScrollToTop/index.js +72 -0
  35. package/src/TagSelect/index.js +69 -0
  36. package/src/TagSelect/style.css +13 -0
  37. package/src/TgHtmlSelect/index.js +20 -0
  38. package/src/TgSelect/index.js +537 -0
  39. package/src/TgSelect/style.css +61 -0
  40. package/src/TgSuggest/index.js +124 -0
  41. package/src/Timeline/index.js +15 -0
  42. package/src/enhancers/withDialog/index.js +196 -0
  43. package/src/index.js +88 -1
  44. package/src/showConfirmationDialog/index.js +148 -0
  45. package/src/style.css +260 -24
  46. package/AdvancedOptions.js +0 -33
  47. package/AssignDefaultsModeContext.js +0 -22
  48. package/DropdownButton.js +0 -36
  49. package/FillWindow.css +0 -6
  50. package/FillWindow.js +0 -69
  51. package/MatchHeaders.js +0 -234
  52. package/SimpleStepViz.js +0 -22
  53. package/Tag.js +0 -112
  54. package/UploadCsvWizard.css +0 -4
  55. package/UploadCsvWizard.js +0 -719
  56. package/autoTooltip.js +0 -201
  57. package/constants.js +0 -1
  58. package/customIcons.js +0 -361
  59. package/rerenderOnWindowResize.js +0 -26
  60. package/showAppSpinner.js +0 -12
  61. package/showDialogOnDocBody.js +0 -33
  62. package/src/CellDragHandle.js +0 -132
  63. package/src/ColumnFilterMenu.js +0 -62
  64. package/src/Columns.js +0 -979
  65. package/src/DisabledLoadingComponent.js +0 -15
  66. package/src/DisplayOptions.js +0 -199
  67. package/src/DropdownCell.js +0 -61
  68. package/src/EditableCell.js +0 -44
  69. package/src/FilterAndSortMenu.js +0 -388
  70. package/src/FormSeparator.js +0 -9
  71. package/src/LoadingDots.js +0 -14
  72. package/src/PagingTool.js +0 -225
  73. package/src/RenderCell.js +0 -191
  74. package/src/SearchBar.js +0 -69
  75. package/src/SortableColumns.js +0 -100
  76. package/src/TableFormTrackerContext.js +0 -10
  77. package/src/ThComponent.js +0 -44
  78. package/src/TimelineEvent.js +0 -31
  79. package/src/Uploader.js +0 -1278
  80. package/src/adHoc.js +0 -10
  81. package/src/basicHandleActionsWithFullState.js +0 -14
  82. package/src/browserUtils.js +0 -3
  83. package/src/combineReducersWithFullState.js +0 -14
  84. package/src/commandControls.js +0 -82
  85. package/src/commandUtils.js +0 -112
  86. package/src/convertSchema.js +0 -69
  87. package/src/dataTableEnhancer.js +0 -41
  88. package/src/defaultFormatters.js +0 -32
  89. package/src/defaultValidators.js +0 -40
  90. package/src/determineBlackOrWhiteTextColor.js +0 -4
  91. package/src/editCellHelper.js +0 -44
  92. package/src/filterLocalEntitiesToHasura.js +0 -216
  93. package/src/formatPasteData.js +0 -16
  94. package/src/getAllRows.js +0 -11
  95. package/src/getCellCopyText.js +0 -7
  96. package/src/getCellInfo.js +0 -36
  97. package/src/getCellVal.js +0 -20
  98. package/src/getDayjsFormatter.js +0 -35
  99. package/src/getFieldPathToField.js +0 -7
  100. package/src/getIdOrCodeOrIndex.js +0 -9
  101. package/src/getLastSelectedEntity.js +0 -11
  102. package/src/getNewEntToSelect.js +0 -25
  103. package/src/getNewName.js +0 -31
  104. package/src/getRowCopyText.js +0 -28
  105. package/src/getTableConfigFromStorage.js +0 -5
  106. package/src/getTextFromEl.js +0 -28
  107. package/src/getVals.js +0 -8
  108. package/src/handleCopyColumn.js +0 -21
  109. package/src/handleCopyHelper.js +0 -15
  110. package/src/handleCopyRows.js +0 -23
  111. package/src/handleCopyTable.js +0 -16
  112. package/src/handlerHelpers.js +0 -24
  113. package/src/hotkeyUtils.js +0 -131
  114. package/src/initializeHasuraWhereAndFilter.js +0 -27
  115. package/src/isBeingCalledExcessively.js +0 -24
  116. package/src/isBottomRightCornerOfRectangle.js +0 -20
  117. package/src/isEntityClean.js +0 -15
  118. package/src/isTruthy.js +0 -12
  119. package/src/isValueEmpty.js +0 -3
  120. package/src/itemUpload.js +0 -84
  121. package/src/menuUtils.js +0 -433
  122. package/src/popoverOverflowModifiers.js +0 -11
  123. package/src/primarySelectedValue.js +0 -1
  124. package/src/pureNoFunc.js +0 -31
  125. package/src/queryParams.js +0 -336
  126. package/src/removeCleanRows.js +0 -22
  127. package/src/renderOnDoc.js +0 -32
  128. package/src/rowClick.js +0 -181
  129. package/src/selection.js +0 -8
  130. package/src/showProgressToast.js +0 -22
  131. package/src/simplifyHasuraWhere.js +0 -80
  132. package/src/sortify.js +0 -73
  133. package/tableQueryParamsToHasuraClauses.js +0 -113
  134. package/tagUtils.js +0 -45
  135. package/tgFormValues.js +0 -35
  136. package/tg_modalState.js +0 -47
  137. package/throwFormError.js +0 -16
  138. package/toastr.js +0 -148
  139. package/tryToMatchSchemas.js +0 -264
  140. package/typeToCommonType.js +0 -6
  141. package/useDeepEqualMemo.js +0 -15
  142. package/useDialog.js +0 -63
  143. package/useStableReference.js +0 -9
  144. package/useTableEntities.js +0 -38
  145. package/useTraceUpdate.js +0 -19
  146. package/utils.js +0 -37
  147. package/validateTableWideErrors.js +0 -160
  148. package/viewColumn.js +0 -97
  149. package/withField.js +0 -20
  150. package/withFields.js +0 -11
  151. package/withLocalStorage.js +0 -11
  152. package/withSelectTableRecords.js +0 -43
  153. package/withSelectedEntities.js +0 -65
  154. package/withStore.js +0 -10
  155. package/withTableParams.js +0 -288
  156. package/wrapDialog.js +0 -116
  157. /package/{CellDragHandle.js → src/DataTable/CellDragHandle.js} +0 -0
  158. /package/{ColumnFilterMenu.js → src/DataTable/ColumnFilterMenu.js} +0 -0
  159. /package/{Columns.js → src/DataTable/Columns.js} +0 -0
  160. /package/{DisabledLoadingComponent.js → src/DataTable/DisabledLoadingComponent.js} +0 -0
  161. /package/{DisplayOptions.js → src/DataTable/DisplayOptions.js} +0 -0
  162. /package/{DropdownCell.js → src/DataTable/DropdownCell.js} +0 -0
  163. /package/{EditableCell.js → src/DataTable/EditableCell.js} +0 -0
  164. /package/{FilterAndSortMenu.js → src/DataTable/FilterAndSortMenu.js} +0 -0
  165. /package/{PagingTool.js → src/DataTable/PagingTool.js} +0 -0
  166. /package/{RenderCell.js → src/DataTable/RenderCell.js} +0 -0
  167. /package/{SearchBar.js → src/DataTable/SearchBar.js} +0 -0
  168. /package/{SortableColumns.js → src/DataTable/SortableColumns.js} +0 -0
  169. /package/{TableFormTrackerContext.js → src/DataTable/TableFormTrackerContext.js} +0 -0
  170. /package/{ThComponent.js → src/DataTable/ThComponent.js} +0 -0
  171. /package/{dataTableEnhancer.js → src/DataTable/dataTableEnhancer.js} +0 -0
  172. /package/{defaultFormatters.js → src/DataTable/defaultFormatters.js} +0 -0
  173. /package/{defaultValidators.js → src/DataTable/defaultValidators.js} +0 -0
  174. /package/{editCellHelper.js → src/DataTable/editCellHelper.js} +0 -0
  175. /package/{getCellVal.js → src/DataTable/getCellVal.js} +0 -0
  176. /package/{getVals.js → src/DataTable/getVals.js} +0 -0
  177. /package/{isTruthy.js → src/DataTable/isTruthy.js} +0 -0
  178. /package/{isValueEmpty.js → src/DataTable/isValueEmpty.js} +0 -0
  179. /package/{convertSchema.js → src/DataTable/utils/convertSchema.js} +0 -0
  180. /package/{filterLocalEntitiesToHasura.js → src/DataTable/utils/filterLocalEntitiesToHasura.js} +0 -0
  181. /package/{formatPasteData.js → src/DataTable/utils/formatPasteData.js} +0 -0
  182. /package/{getAllRows.js → src/DataTable/utils/getAllRows.js} +0 -0
  183. /package/{getCellCopyText.js → src/DataTable/utils/getCellCopyText.js} +0 -0
  184. /package/{getCellInfo.js → src/DataTable/utils/getCellInfo.js} +0 -0
  185. /package/{getFieldPathToField.js → src/DataTable/utils/getFieldPathToField.js} +0 -0
  186. /package/{getIdOrCodeOrIndex.js → src/DataTable/utils/getIdOrCodeOrIndex.js} +0 -0
  187. /package/{getLastSelectedEntity.js → src/DataTable/utils/getLastSelectedEntity.js} +0 -0
  188. /package/{getNewEntToSelect.js → src/DataTable/utils/getNewEntToSelect.js} +0 -0
  189. /package/{getRowCopyText.js → src/DataTable/utils/getRowCopyText.js} +0 -0
  190. /package/{getTableConfigFromStorage.js → src/DataTable/utils/getTableConfigFromStorage.js} +0 -0
  191. /package/{handleCopyColumn.js → src/DataTable/utils/handleCopyColumn.js} +0 -0
  192. /package/{handleCopyHelper.js → src/DataTable/utils/handleCopyHelper.js} +0 -0
  193. /package/{handleCopyRows.js → src/DataTable/utils/handleCopyRows.js} +0 -0
  194. /package/{handleCopyTable.js → src/DataTable/utils/handleCopyTable.js} +0 -0
  195. /package/{initializeHasuraWhereAndFilter.js → src/DataTable/utils/initializeHasuraWhereAndFilter.js} +0 -0
  196. /package/{isBottomRightCornerOfRectangle.js → src/DataTable/utils/isBottomRightCornerOfRectangle.js} +0 -0
  197. /package/{isEntityClean.js → src/DataTable/utils/isEntityClean.js} +0 -0
  198. /package/{primarySelectedValue.js → src/DataTable/utils/primarySelectedValue.js} +0 -0
  199. /package/{queryParams.js → src/DataTable/utils/queryParams.js} +0 -0
  200. /package/{removeCleanRows.js → src/DataTable/utils/removeCleanRows.js} +0 -0
  201. /package/{rowClick.js → src/DataTable/utils/rowClick.js} +0 -0
  202. /package/{selection.js → src/DataTable/utils/selection.js} +0 -0
  203. /package/{simplifyHasuraWhere.js → src/DataTable/utils/simplifyHasuraWhere.js} +0 -0
  204. /package/src/{tableQueryParamsToHasuraClauses.js → DataTable/utils/tableQueryParamsToHasuraClauses.js} +0 -0
  205. /package/src/{useTableEntities.js → DataTable/utils/useTableEntities.js} +0 -0
  206. /package/src/{utils.js → DataTable/utils/utils.js} +0 -0
  207. /package/src/{withSelectedEntities.js → DataTable/utils/withSelectedEntities.js} +0 -0
  208. /package/src/{withTableParams.js → DataTable/utils/withTableParams.js} +0 -0
  209. /package/src/{validateTableWideErrors.js → DataTable/validateTableWideErrors.js} +0 -0
  210. /package/src/{viewColumn.js → DataTable/viewColumn.js} +0 -0
  211. /package/{FormSeparator.js → src/FormComponents/FormSeparator.js} +0 -0
  212. /package/{LoadingDots.js → src/FormComponents/LoadingDots.js} +0 -0
  213. /package/{Uploader.js → src/FormComponents/Uploader.js} +0 -0
  214. /package/{getNewName.js → src/FormComponents/getNewName.js} +0 -0
  215. /package/{itemUpload.js → src/FormComponents/itemUpload.js} +0 -0
  216. /package/{sortify.js → src/FormComponents/sortify.js} +0 -0
  217. /package/src/{tryToMatchSchemas.js → FormComponents/tryToMatchSchemas.js} +0 -0
  218. /package/{TimelineEvent.js → src/Timeline/TimelineEvent.js} +0 -0
  219. /package/{style.css → src/Timeline/style.css} +0 -0
  220. /package/src/{tg_modalState.js → enhancers/withDialog/tg_modalState.js} +0 -0
  221. /package/src/{withField.js → enhancers/withField.js} +0 -0
  222. /package/src/{withFields.js → enhancers/withFields.js} +0 -0
  223. /package/src/{withLocalStorage.js → enhancers/withLocalStorage.js} +0 -0
  224. /package/{adHoc.js → src/utils/adHoc.js} +0 -0
  225. /package/{basicHandleActionsWithFullState.js → src/utils/basicHandleActionsWithFullState.js} +0 -0
  226. /package/{browserUtils.js → src/utils/browserUtils.js} +0 -0
  227. /package/{combineReducersWithFullState.js → src/utils/combineReducersWithFullState.js} +0 -0
  228. /package/{commandControls.js → src/utils/commandControls.js} +0 -0
  229. /package/{commandUtils.js → src/utils/commandUtils.js} +0 -0
  230. /package/{determineBlackOrWhiteTextColor.js → src/utils/determineBlackOrWhiteTextColor.js} +0 -0
  231. /package/{getDayjsFormatter.js → src/utils/getDayjsFormatter.js} +0 -0
  232. /package/{getTextFromEl.js → src/utils/getTextFromEl.js} +0 -0
  233. /package/{handlerHelpers.js → src/utils/handlerHelpers.js} +0 -0
  234. /package/{index.js → src/utils/hooks/index.js} +0 -0
  235. /package/src/{useDeepEqualMemo.js → utils/hooks/useDeepEqualMemo.js} +0 -0
  236. /package/src/{useStableReference.js → utils/hooks/useStableReference.js} +0 -0
  237. /package/{hotkeyUtils.js → src/utils/hotkeyUtils.js} +0 -0
  238. /package/{isBeingCalledExcessively.js → src/utils/isBeingCalledExcessively.js} +0 -0
  239. /package/{menuUtils.js → src/utils/menuUtils.js} +0 -0
  240. /package/{popoverOverflowModifiers.js → src/utils/popoverOverflowModifiers.js} +0 -0
  241. /package/{pureNoFunc.js → src/utils/pureNoFunc.js} +0 -0
  242. /package/{renderOnDoc.js → src/utils/renderOnDoc.js} +0 -0
  243. /package/{showProgressToast.js → src/utils/showProgressToast.js} +0 -0
  244. /package/src/{tagUtils.js → utils/tagUtils.js} +0 -0
  245. /package/src/{tgFormValues.js → utils/tgFormValues.js} +0 -0
  246. /package/src/{useTraceUpdate.js → utils/useTraceUpdate.js} +0 -0
  247. /package/src/{withSelectTableRecords.js → utils/withSelectTableRecords.js} +0 -0
  248. /package/src/{withStore.js → utils/withStore.js} +0 -0
package/src/sortify.js DELETED
@@ -1,73 +0,0 @@
1
- /*!
2
- * Copyright 2015-2016 Thomas Rosenau
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- /**
18
- * Create a “sorted” version of an object.
19
- *
20
- * JS engines internally keep track of an object's keys in the order of
21
- * creation time, i.e. {a:1,b:2} is treated differently from {b:2,a:1}.
22
- * That difference can be seen when JSON.stringify is called on that object.
23
- * This function normalizes any kind of object by rearranging the keys in
24
- * alphabetical order (numerical keys first, since v8 does so, and there's
25
- * nothing we can do about it).
26
- * @param {*} o The object to be sorted
27
- */
28
-
29
- /* eslint-disable */
30
- const sortKeys = o => {
31
- if (Array.isArray(o)) {
32
- return o.map(sortKeys);
33
- } else if (o instanceof Object) {
34
- // put numeric keys first
35
- let numeric = [];
36
- let nonNumeric = [];
37
- Object.keys(o).forEach(key => {
38
- if (/^(0|[1-9][0-9]*)$/.test(key)) {
39
- numeric.push(+key);
40
- } else {
41
- nonNumeric.push(key);
42
- }
43
- });
44
- // do the rearrangement
45
- return numeric
46
- .sort(function (a, b) {
47
- return a - b;
48
- })
49
- .concat(nonNumeric.sort())
50
- .reduce((result, key) => {
51
- result[key] = sortKeys(o[key]); // recurse!
52
- return result;
53
- }, {});
54
- }
55
- return o;
56
- };
57
-
58
- const jsonStringify = JSON.stringify.bind(JSON);
59
-
60
- const sortify = (value, replacer, space) => {
61
- // replacer, toJSON(), cyclic references and other stuff is better handled by native stringifier.
62
- // So we do JSON.stringify(sortKeys( JSON.parse(JSON.stringify()) )).
63
- // This approach is slightly slower but much safer than a manual stringification.
64
- let nativeJson = jsonStringify(value, replacer, 0);
65
- if (!nativeJson || (nativeJson[0] !== "{" && nativeJson[0] !== "[")) {
66
- // if value is not an Object or Array
67
- return nativeJson;
68
- }
69
- let cleanObj = JSON.parse(nativeJson);
70
- return jsonStringify(sortKeys(cleanObj), null, space);
71
- };
72
-
73
- export default sortify;
@@ -1,113 +0,0 @@
1
- export function tableQueryParamsToHasuraClauses({
2
- page,
3
- pageSize,
4
- searchTerm,
5
- filters,
6
- order,
7
- schema, // Add schema as a parameter
8
- additionalFilter
9
- }) {
10
- let where = {};
11
- const order_by = {};
12
- const limit = pageSize || 25;
13
- const offset = page && pageSize ? (page - 1) * pageSize : 0;
14
-
15
- if (searchTerm) {
16
- const searchTermFilters = [];
17
- schema.fields.forEach(field => {
18
- const { type, path, searchDisabled } = field;
19
- if (searchDisabled || field.filterDisabled || type === "color") return;
20
- const filterValue = searchTerm; // No cleaning needed here, we're using _ilike
21
-
22
- if (type === "string" || type === "lookup") {
23
- searchTermFilters.push({
24
- [path]: { _ilike: `%${filterValue}%` }
25
- });
26
- } else if (type === "boolean") {
27
- let regex;
28
- try {
29
- regex = new RegExp("^" + searchTerm, "ig");
30
- } catch (error) {
31
- //ignore
32
- }
33
- if (regex) {
34
- if ("true".replace(regex, "") !== "true") {
35
- searchTermFilters.push({
36
- [path]: { _eq: true }
37
- });
38
- } else if ("false".replace(regex, "") !== "false") {
39
- searchTermFilters.push({
40
- [path]: { _eq: false }
41
- });
42
- }
43
- }
44
- } else if (
45
- (type === "number" || type === "integer") &&
46
- !isNaN(filterValue)
47
- ) {
48
- searchTermFilters.push({
49
- [path]: { _eq: parseFloat(filterValue) }
50
- });
51
- }
52
- });
53
- if (searchTermFilters.length > 0) {
54
- if (Object.keys(where).length > 0) {
55
- where = { _and: [where, { _or: searchTermFilters }] };
56
- } else {
57
- where = { _or: searchTermFilters };
58
- }
59
- }
60
- }
61
-
62
- if (filters && filters.length > 0) {
63
- const filterClauses = filters.map(filter => {
64
- const { selectedFilter, filterOn, filterValue } = filter;
65
- switch (selectedFilter) {
66
- case "textContains":
67
- return { [filterOn]: { _ilike: `%${filterValue}%` } };
68
- case "textEquals":
69
- return { [filterOn]: { _eq: filterValue } };
70
- case "textNotEquals":
71
- return { [filterOn]: { _neq: filterValue } };
72
- case "numberEquals":
73
- return { [filterOn]: { _eq: parseFloat(filterValue) } };
74
- case "numberGreaterThan":
75
- return { [filterOn]: { _gt: parseFloat(filterValue) } };
76
- case "numberLessThan":
77
- return { [filterOn]: { _lt: parseFloat(filterValue) } };
78
- case "numberGreaterThanEquals":
79
- return { [filterOn]: { _gte: parseFloat(filterValue) } };
80
- case "numberLessThanEquals":
81
- return { [filterOn]: { _lte: parseFloat(filterValue) } };
82
- case "isNull":
83
- return { [filterOn]: { _is_null: true } };
84
- case "isNotNull":
85
- return { [filterOn]: { _is_null: false } };
86
- default:
87
- console.warn(`Unsupported filter type: ${selectedFilter}`);
88
- return {};
89
- }
90
- });
91
-
92
- if (filterClauses.length > 0) {
93
- if (Object.keys(where).length > 0) {
94
- where = { _and: [where, ...filterClauses] };
95
- } else {
96
- where = { _and: filterClauses };
97
- }
98
- }
99
- }
100
-
101
- if (order && order.length > 0) {
102
- order.forEach(item => {
103
- const field = item.startsWith("-") ? item.substring(1) : item;
104
- const direction = item.startsWith("-") ? "desc" : "asc";
105
- order_by[field] = direction;
106
- });
107
- }
108
-
109
- if (additionalFilter) {
110
- where = { _and: [where, additionalFilter] };
111
- }
112
- return { where, order_by, limit, offset };
113
- }
package/tagUtils.js DELETED
@@ -1,45 +0,0 @@
1
- import { flatMap, keyBy } from "lodash-es";
2
- import determineBlackOrWhiteTextColor from "./determineBlackOrWhiteTextColor";
3
-
4
- export function getTagsAndTagOptions(allTags) {
5
- return flatMap(allTags, tag => {
6
- if (tag.tagOptions && tag.tagOptions.length) {
7
- return tag.tagOptions.map(tagO => {
8
- const fullname = `${tag.name}: ${tagO.name}`;
9
- const value = `${tag.id}:${tagO.id}`;
10
- return {
11
- ...tagO,
12
- label: fullname,
13
- value,
14
- id: tagO.id
15
- };
16
- });
17
- }
18
- return {
19
- ...tag,
20
- label: tag.name,
21
- value: tag.id
22
- };
23
- });
24
- }
25
-
26
- export function getKeyedTagsAndTagOptions(tags) {
27
- return keyBy(getTagsAndTagOptions(tags), "value");
28
- }
29
-
30
- export function getTagColorStyle(color) {
31
- return color
32
- ? {
33
- style: {
34
- backgroundColor: color,
35
- color: determineBlackOrWhiteTextColor(color)
36
- }
37
- }
38
- : {};
39
- }
40
- export function getTagProps({ color, label, name }) {
41
- return {
42
- ...getTagColorStyle(color),
43
- children: label || name
44
- };
45
- }
package/tgFormValues.js DELETED
@@ -1,35 +0,0 @@
1
- import React, { useMemo } from "react";
2
- import { connect } from "react-redux";
3
- import { FormName, formValueSelector } from "redux-form";
4
-
5
- const tgFormValues =
6
- (...fieldNames) =>
7
- Component =>
8
- props => {
9
- return (
10
- <FormName>
11
- {formName => {
12
- const name = formName.form;
13
- const Wrapped = useMemo(() => {
14
- const selector = formValueSelector(name || "");
15
- const wrapper = connect(state => {
16
- const vals = {};
17
- fieldNames.forEach(name => {
18
- vals[name] = selector(state, name);
19
- });
20
- return vals;
21
- });
22
- return wrapper(Component);
23
- }, [name]);
24
- return <Wrapped {...props} />;
25
- }}
26
- </FormName>
27
- );
28
- };
29
- export default tgFormValues;
30
-
31
- export const tgFormValueSelector = (formName, ...fields) => {
32
- return connect(state => {
33
- return formValueSelector(formName)(state, ...fields);
34
- });
35
- };
package/tg_modalState.js DELETED
@@ -1,47 +0,0 @@
1
- import { omit } from "lodash-es";
2
-
3
- export default function tg_modalState(
4
- state = {},
5
- { type, name, uniqueName, props = {} }
6
- ) {
7
- const existingModalState = state[name] || {};
8
- const { __registeredAs = {} } = existingModalState;
9
- if (type === "TG_REGISTER_MODAL") {
10
- return {
11
- ...state,
12
- [name]: {
13
- ...existingModalState,
14
- __registeredAs: { ...__registeredAs, [uniqueName]: true }
15
- }
16
- };
17
- }
18
- if (type === "TG_UNREGISTER_MODAL") {
19
- return {
20
- ...state,
21
- [name]: {
22
- ...existingModalState,
23
- __registeredAs: omit(__registeredAs, uniqueName)
24
- }
25
- };
26
- }
27
- if (type === "TG_SHOW_MODAL") {
28
- return {
29
- ...state,
30
- [name]: {
31
- ...existingModalState,
32
- ...props,
33
- open: true
34
- }
35
- };
36
- }
37
- if (type === "TG_HIDE_MODAL") {
38
- return {
39
- ...state,
40
- [name]: {
41
- __registeredAs: existingModalState.__registeredAs,
42
- open: false
43
- }
44
- };
45
- }
46
- return state;
47
- }
package/throwFormError.js DELETED
@@ -1,16 +0,0 @@
1
- import { SubmissionError } from "redux-form";
2
-
3
- export const throwFormError = error => {
4
- if (error.message) {
5
- console.error("error:", error);
6
- }
7
- const errorToUse = error.message
8
- ? { _error: error.message }
9
- : typeof error === "string"
10
- ? { _error: error }
11
- : error;
12
- if (!errorToUse._error) {
13
- errorToUse._error = "Error Submitting Form";
14
- }
15
- throw new SubmissionError(errorToUse);
16
- };
package/toastr.js DELETED
@@ -1,148 +0,0 @@
1
- import { Position, Toaster, Intent, Classes } from "@blueprintjs/core";
2
- import classNames from "classnames";
3
-
4
- const TopToaster = Toaster.create({
5
- className: "top-toaster",
6
- position: Position.TOP
7
- });
8
-
9
- const BottomToaster = Toaster.create({
10
- className: "bottom-toaster",
11
- position: Position.BOTTOM
12
- });
13
-
14
- window.__tgClearAllToasts = () => {
15
- TopToaster.clear();
16
- BottomToaster.clear();
17
- };
18
-
19
- let counter = 5000;
20
- const generateToast = intent => (message, options) => {
21
- options = options || {};
22
- const toastToUse = options.bottom ? BottomToaster : TopToaster;
23
- let updatedTimeout;
24
- if (options.updateTimeout) {
25
- //generate a slightly different than default timeout to make the update stay on the page for a full 5 seconds
26
- if (counter > 5500) {
27
- updatedTimeout = --counter;
28
- } else {
29
- updatedTimeout = ++counter;
30
- }
31
- }
32
- if (intent === Intent.DANGER) {
33
- console.error("Toastr error message: ", message);
34
- }
35
- if (intent === Intent.WARNING) {
36
- console.error("Toastr warning message: ", message);
37
- }
38
-
39
- const maybeAddClearAll = () => {
40
- // wipe any existing clear all buttons
41
- const existingClearAllButtons =
42
- document.querySelectorAll(`.tg-clear-all-toasts`);
43
- existingClearAllButtons.forEach(button => {
44
- button.remove();
45
- });
46
- const activeToasts = document.querySelectorAll(
47
- `.bp3-toast:not(.bp3-toast-exit)`
48
- );
49
- if (activeToasts.length > 1) {
50
- // add custom clear all button
51
-
52
- const topToaster = document.querySelector(`.bp3-toast`);
53
- if (!topToaster) return;
54
- const closeButton = document.createElement("div");
55
- closeButton.classList.add(
56
- Classes.BUTTON,
57
- Classes.LARGE,
58
- Classes.INTENT_PRIMARY,
59
- "tg-clear-all-toasts"
60
- );
61
- closeButton.innerText = "Clear all";
62
- closeButton.onclick = window.__tgClearAllToasts;
63
- // position the button to the right of the message
64
- closeButton.style.position = "absolute";
65
- closeButton.style.right = "-100px";
66
-
67
- topToaster.appendChild(closeButton);
68
- }
69
- };
70
- const uniqKey = toastToUse.show(
71
- {
72
- intent,
73
- message,
74
- onDismiss: () => {
75
- if (options.onDismiss) {
76
- options.onDismiss();
77
- }
78
- setTimeout(() => {
79
- maybeAddClearAll();
80
- }, 0);
81
- },
82
- timeout:
83
- options.timeout ||
84
- updatedTimeout ||
85
- (!window.Cypress &&
86
- (intent === Intent.DANGER || intent === Intent.WARNING)
87
- ? 60000
88
- : undefined),
89
- action: options.action,
90
- icon: options.icon,
91
- className: classNames("preserve-newline", options.className)
92
- },
93
- options.key
94
- );
95
- setTimeout(() => {
96
- maybeAddClearAll();
97
- }, 0);
98
- function clear() {
99
- toastToUse.dismiss(uniqKey);
100
- setTimeout(() => {
101
- maybeAddClearAll();
102
- }, 0);
103
- }
104
- clear.key = uniqKey;
105
- return clear;
106
- };
107
-
108
- function preventDuplicates(func) {
109
- const previousToasts = {};
110
- return (message, options = {}) => {
111
- const clearToast = func(message, options);
112
- // no duplicate check for toasts with updates
113
-
114
- if (!options.key) {
115
- if (!options.key && previousToasts[message]) {
116
- previousToasts[message](); //clear it!
117
- }
118
-
119
- setTimeout(() => {
120
- delete previousToasts[message];
121
- }, options.timeout || 5000);
122
-
123
- previousToasts[message] = clearToast;
124
- }
125
- return clearToast;
126
- };
127
- }
128
-
129
- if (!window.toastr) window.toastr = {};
130
- if (!window.toastr.success) {
131
- window.toastr.success = preventDuplicates(generateToast(Intent.SUCCESS));
132
- }
133
-
134
- if (!window.toastr.error) {
135
- window.toastr.error = preventDuplicates(generateToast(Intent.DANGER));
136
- }
137
-
138
- if (!window.toastr.warning) {
139
- window.toastr.warning = preventDuplicates(generateToast(Intent.WARNING));
140
- }
141
-
142
- if (!window.toastr.info) {
143
- window.toastr.info = preventDuplicates(generateToast(Intent.PRIMARY));
144
- }
145
-
146
- if (!window.toastr.default) {
147
- window.toastr.default = preventDuplicates(generateToast(Intent.NONE));
148
- }