@teselagen/ui 0.7.32 → 0.7.33-beta.2

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 (254) hide show
  1. package/AdvancedOptions.js +33 -0
  2. package/AssignDefaultsModeContext.js +22 -0
  3. package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +5 -0
  4. package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +2 -0
  5. package/DataTable/utils/queryParams.d.ts +8 -12
  6. package/DataTable/utils/simplifyHasuraWhere.d.ts +1 -0
  7. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +14 -0
  8. package/DropdownButton.js +36 -0
  9. package/FillWindow.css +6 -0
  10. package/FillWindow.js +69 -0
  11. package/{src/DataTable/FilterAndSortMenu.js → FilterAndSortMenu.js} +27 -30
  12. package/MatchHeaders.js +234 -0
  13. package/SimpleStepViz.js +22 -0
  14. package/Tag.js +112 -0
  15. package/UploadCsvWizard.css +4 -0
  16. package/UploadCsvWizard.js +719 -0
  17. package/autoTooltip.js +201 -0
  18. package/constants.js +1 -0
  19. package/customIcons.js +361 -0
  20. package/filterLocalEntitiesToHasura.js +216 -0
  21. package/index.cjs.js +695 -967
  22. package/index.d.ts +1 -0
  23. package/index.es.js +695 -967
  24. package/initializeHasuraWhereAndFilter.js +27 -0
  25. package/{src/utils/isBeingCalledExcessively.js → isBeingCalledExcessively.js} +0 -1
  26. package/package.json +1 -1
  27. package/queryParams.js +336 -0
  28. package/rerenderOnWindowResize.js +26 -0
  29. package/showAppSpinner.js +12 -0
  30. package/showDialogOnDocBody.js +33 -0
  31. package/simplifyHasuraWhere.js +80 -0
  32. package/src/CellDragHandle.js +132 -0
  33. package/src/ColumnFilterMenu.js +62 -0
  34. package/src/Columns.js +979 -0
  35. package/src/DisabledLoadingComponent.js +15 -0
  36. package/src/DisplayOptions.js +199 -0
  37. package/src/DropdownCell.js +61 -0
  38. package/src/EditableCell.js +44 -0
  39. package/src/FilterAndSortMenu.js +388 -0
  40. package/src/FormSeparator.js +9 -0
  41. package/src/LoadingDots.js +14 -0
  42. package/src/PagingTool.js +225 -0
  43. package/src/RenderCell.js +191 -0
  44. package/src/SearchBar.js +69 -0
  45. package/src/SortableColumns.js +100 -0
  46. package/src/TableFormTrackerContext.js +10 -0
  47. package/src/ThComponent.js +44 -0
  48. package/src/TimelineEvent.js +31 -0
  49. package/src/Uploader.js +1278 -0
  50. package/src/adHoc.js +10 -0
  51. package/src/basicHandleActionsWithFullState.js +14 -0
  52. package/src/browserUtils.js +3 -0
  53. package/src/combineReducersWithFullState.js +14 -0
  54. package/src/commandControls.js +82 -0
  55. package/src/commandUtils.js +112 -0
  56. package/src/convertSchema.js +69 -0
  57. package/src/dataTableEnhancer.js +41 -0
  58. package/src/defaultFormatters.js +32 -0
  59. package/src/defaultValidators.js +40 -0
  60. package/src/determineBlackOrWhiteTextColor.js +4 -0
  61. package/src/editCellHelper.js +44 -0
  62. package/src/filterLocalEntitiesToHasura.js +216 -0
  63. package/src/formatPasteData.js +16 -0
  64. package/src/getAllRows.js +11 -0
  65. package/src/getCellCopyText.js +7 -0
  66. package/src/getCellInfo.js +36 -0
  67. package/src/getCellVal.js +20 -0
  68. package/src/getDayjsFormatter.js +35 -0
  69. package/src/getFieldPathToField.js +7 -0
  70. package/src/getIdOrCodeOrIndex.js +9 -0
  71. package/src/getLastSelectedEntity.js +11 -0
  72. package/src/getNewEntToSelect.js +25 -0
  73. package/src/getNewName.js +31 -0
  74. package/src/getRowCopyText.js +28 -0
  75. package/src/getTableConfigFromStorage.js +5 -0
  76. package/src/getTextFromEl.js +28 -0
  77. package/src/getVals.js +8 -0
  78. package/src/handleCopyColumn.js +21 -0
  79. package/src/handleCopyHelper.js +15 -0
  80. package/src/handleCopyRows.js +23 -0
  81. package/src/handleCopyTable.js +16 -0
  82. package/src/handlerHelpers.js +24 -0
  83. package/src/hotkeyUtils.js +131 -0
  84. package/src/index.js +1 -87
  85. package/src/initializeHasuraWhereAndFilter.js +27 -0
  86. package/src/isBeingCalledExcessively.js +24 -0
  87. package/src/isBottomRightCornerOfRectangle.js +20 -0
  88. package/src/isEntityClean.js +15 -0
  89. package/src/isTruthy.js +12 -0
  90. package/src/isValueEmpty.js +3 -0
  91. package/src/itemUpload.js +84 -0
  92. package/src/menuUtils.js +433 -0
  93. package/src/popoverOverflowModifiers.js +11 -0
  94. package/src/primarySelectedValue.js +1 -0
  95. package/src/pureNoFunc.js +31 -0
  96. package/src/queryParams.js +336 -0
  97. package/src/removeCleanRows.js +22 -0
  98. package/src/renderOnDoc.js +32 -0
  99. package/src/rowClick.js +181 -0
  100. package/src/selection.js +8 -0
  101. package/src/showProgressToast.js +22 -0
  102. package/src/simplifyHasuraWhere.js +80 -0
  103. package/src/sortify.js +73 -0
  104. package/src/style.css +24 -260
  105. package/src/tableQueryParamsToHasuraClauses.js +113 -0
  106. package/src/{DataTable/utils/withTableParams.js → withTableParams.js} +1 -14
  107. package/tableQueryParamsToHasuraClauses.js +113 -0
  108. package/tagUtils.js +45 -0
  109. package/tgFormValues.js +35 -0
  110. package/tg_modalState.js +47 -0
  111. package/throwFormError.js +16 -0
  112. package/toastr.js +148 -0
  113. package/tryToMatchSchemas.js +264 -0
  114. package/typeToCommonType.js +6 -0
  115. package/useDeepEqualMemo.js +15 -0
  116. package/useDialog.js +63 -0
  117. package/useStableReference.js +9 -0
  118. package/useTableEntities.js +38 -0
  119. package/useTraceUpdate.js +19 -0
  120. package/utils.js +37 -0
  121. package/validateTableWideErrors.js +160 -0
  122. package/viewColumn.js +97 -0
  123. package/withField.js +20 -0
  124. package/withFields.js +11 -0
  125. package/withLocalStorage.js +11 -0
  126. package/withSelectTableRecords.js +43 -0
  127. package/withSelectedEntities.js +65 -0
  128. package/withStore.js +10 -0
  129. package/withTableParams.js +288 -0
  130. package/wrapDialog.js +116 -0
  131. package/src/AdvancedOptions.spec.js +0 -26
  132. package/src/AsyncValidateFieldSpinner/index.js +0 -12
  133. package/src/BlueprintError/index.js +0 -14
  134. package/src/BounceLoader/index.js +0 -16
  135. package/src/BounceLoader/style.css +0 -45
  136. package/src/CollapsibleCard/index.js +0 -68
  137. package/src/CollapsibleCard/style.css +0 -23
  138. package/src/DNALoader/index.js +0 -20
  139. package/src/DNALoader/style.css +0 -251
  140. package/src/DataTable/index.js +0 -3213
  141. package/src/DataTable/style.css +0 -608
  142. package/src/DataTable/utils/index.js +0 -55
  143. package/src/DataTable/utils/queryParams.js +0 -1058
  144. package/src/DialogFooter/index.js +0 -86
  145. package/src/DialogFooter/style.css +0 -9
  146. package/src/FormComponents/index.js +0 -1266
  147. package/src/FormComponents/style.css +0 -275
  148. package/src/FormComponents/utils.js +0 -6
  149. package/src/HotkeysDialog/index.js +0 -79
  150. package/src/HotkeysDialog/style.css +0 -54
  151. package/src/InfoHelper/index.js +0 -78
  152. package/src/InfoHelper/style.css +0 -7
  153. package/src/IntentText/index.js +0 -18
  154. package/src/Loading/index.js +0 -70
  155. package/src/Loading/style.css +0 -4
  156. package/src/MenuBar/index.js +0 -423
  157. package/src/MenuBar/style.css +0 -45
  158. package/src/PromptUnsavedChanges/index.js +0 -38
  159. package/src/ResizableDraggableDialog/index.js +0 -141
  160. package/src/ResizableDraggableDialog/style.css +0 -42
  161. package/src/ScrollToTop/index.js +0 -72
  162. package/src/TagSelect/index.js +0 -69
  163. package/src/TagSelect/style.css +0 -13
  164. package/src/TgHtmlSelect/index.js +0 -20
  165. package/src/TgSelect/index.js +0 -537
  166. package/src/TgSelect/style.css +0 -61
  167. package/src/TgSuggest/index.js +0 -124
  168. package/src/Timeline/index.js +0 -15
  169. package/src/enhancers/withDialog/index.js +0 -196
  170. package/src/showConfirmationDialog/index.js +0 -148
  171. /package/{src/DataTable/CellDragHandle.js → CellDragHandle.js} +0 -0
  172. /package/{src/DataTable/ColumnFilterMenu.js → ColumnFilterMenu.js} +0 -0
  173. /package/{src/DataTable/Columns.js → Columns.js} +0 -0
  174. /package/{src/DataTable/DisabledLoadingComponent.js → DisabledLoadingComponent.js} +0 -0
  175. /package/{src/DataTable/DisplayOptions.js → DisplayOptions.js} +0 -0
  176. /package/{src/DataTable/DropdownCell.js → DropdownCell.js} +0 -0
  177. /package/{src/DataTable/EditableCell.js → EditableCell.js} +0 -0
  178. /package/{src/FormComponents/FormSeparator.js → FormSeparator.js} +0 -0
  179. /package/{src/FormComponents/LoadingDots.js → LoadingDots.js} +0 -0
  180. /package/{src/DataTable/PagingTool.js → PagingTool.js} +0 -0
  181. /package/{src/DataTable/RenderCell.js → RenderCell.js} +0 -0
  182. /package/{src/DataTable/SearchBar.js → SearchBar.js} +0 -0
  183. /package/{src/DataTable/SortableColumns.js → SortableColumns.js} +0 -0
  184. /package/{src/DataTable/TableFormTrackerContext.js → TableFormTrackerContext.js} +0 -0
  185. /package/{src/DataTable/ThComponent.js → ThComponent.js} +0 -0
  186. /package/{src/Timeline/TimelineEvent.js → TimelineEvent.js} +0 -0
  187. /package/{src/FormComponents/Uploader.js → Uploader.js} +0 -0
  188. /package/{src/utils/adHoc.js → adHoc.js} +0 -0
  189. /package/{src/utils/basicHandleActionsWithFullState.js → basicHandleActionsWithFullState.js} +0 -0
  190. /package/{src/utils/browserUtils.js → browserUtils.js} +0 -0
  191. /package/{src/utils/combineReducersWithFullState.js → combineReducersWithFullState.js} +0 -0
  192. /package/{src/utils/commandControls.js → commandControls.js} +0 -0
  193. /package/{src/utils/commandUtils.js → commandUtils.js} +0 -0
  194. /package/{src/DataTable/utils/convertSchema.js → convertSchema.js} +0 -0
  195. /package/{src/DataTable/dataTableEnhancer.js → dataTableEnhancer.js} +0 -0
  196. /package/{src/DataTable/defaultFormatters.js → defaultFormatters.js} +0 -0
  197. /package/{src/DataTable/defaultValidators.js → defaultValidators.js} +0 -0
  198. /package/{src/utils/determineBlackOrWhiteTextColor.js → determineBlackOrWhiteTextColor.js} +0 -0
  199. /package/{src/DataTable/editCellHelper.js → editCellHelper.js} +0 -0
  200. /package/{src/DataTable/utils/formatPasteData.js → formatPasteData.js} +0 -0
  201. /package/{src/DataTable/utils/getAllRows.js → getAllRows.js} +0 -0
  202. /package/{src/DataTable/utils/getCellCopyText.js → getCellCopyText.js} +0 -0
  203. /package/{src/DataTable/utils/getCellInfo.js → getCellInfo.js} +0 -0
  204. /package/{src/DataTable/getCellVal.js → getCellVal.js} +0 -0
  205. /package/{src/utils/getDayjsFormatter.js → getDayjsFormatter.js} +0 -0
  206. /package/{src/DataTable/utils/getFieldPathToField.js → getFieldPathToField.js} +0 -0
  207. /package/{src/DataTable/utils/getIdOrCodeOrIndex.js → getIdOrCodeOrIndex.js} +0 -0
  208. /package/{src/DataTable/utils/getLastSelectedEntity.js → getLastSelectedEntity.js} +0 -0
  209. /package/{src/DataTable/utils/getNewEntToSelect.js → getNewEntToSelect.js} +0 -0
  210. /package/{src/FormComponents/getNewName.js → getNewName.js} +0 -0
  211. /package/{src/DataTable/utils/getRowCopyText.js → getRowCopyText.js} +0 -0
  212. /package/{src/DataTable/utils/getTableConfigFromStorage.js → getTableConfigFromStorage.js} +0 -0
  213. /package/{src/utils/getTextFromEl.js → getTextFromEl.js} +0 -0
  214. /package/{src/DataTable/getVals.js → getVals.js} +0 -0
  215. /package/{src/DataTable/utils/handleCopyColumn.js → handleCopyColumn.js} +0 -0
  216. /package/{src/DataTable/utils/handleCopyHelper.js → handleCopyHelper.js} +0 -0
  217. /package/{src/DataTable/utils/handleCopyRows.js → handleCopyRows.js} +0 -0
  218. /package/{src/DataTable/utils/handleCopyTable.js → handleCopyTable.js} +0 -0
  219. /package/{src/utils/handlerHelpers.js → handlerHelpers.js} +0 -0
  220. /package/{src/utils/hotkeyUtils.js → hotkeyUtils.js} +0 -0
  221. /package/{src/utils/hooks/index.js → index.js} +0 -0
  222. /package/{src/DataTable/utils/isBottomRightCornerOfRectangle.js → isBottomRightCornerOfRectangle.js} +0 -0
  223. /package/{src/DataTable/utils/isEntityClean.js → isEntityClean.js} +0 -0
  224. /package/{src/DataTable/isTruthy.js → isTruthy.js} +0 -0
  225. /package/{src/DataTable/isValueEmpty.js → isValueEmpty.js} +0 -0
  226. /package/{src/FormComponents/itemUpload.js → itemUpload.js} +0 -0
  227. /package/{src/utils/menuUtils.js → menuUtils.js} +0 -0
  228. /package/{src/utils/popoverOverflowModifiers.js → popoverOverflowModifiers.js} +0 -0
  229. /package/{src/DataTable/utils/primarySelectedValue.js → primarySelectedValue.js} +0 -0
  230. /package/{src/utils/pureNoFunc.js → pureNoFunc.js} +0 -0
  231. /package/{src/DataTable/utils/removeCleanRows.js → removeCleanRows.js} +0 -0
  232. /package/{src/utils/renderOnDoc.js → renderOnDoc.js} +0 -0
  233. /package/{src/DataTable/utils/rowClick.js → rowClick.js} +0 -0
  234. /package/{src/DataTable/utils/selection.js → selection.js} +0 -0
  235. /package/{src/utils/showProgressToast.js → showProgressToast.js} +0 -0
  236. /package/{src/FormComponents/sortify.js → sortify.js} +0 -0
  237. /package/src/{utils/tagUtils.js → tagUtils.js} +0 -0
  238. /package/src/{utils/tgFormValues.js → tgFormValues.js} +0 -0
  239. /package/src/{enhancers/withDialog/tg_modalState.js → tg_modalState.js} +0 -0
  240. /package/src/{FormComponents/tryToMatchSchemas.js → tryToMatchSchemas.js} +0 -0
  241. /package/src/{utils/hooks/useDeepEqualMemo.js → useDeepEqualMemo.js} +0 -0
  242. /package/src/{utils/hooks/useStableReference.js → useStableReference.js} +0 -0
  243. /package/src/{DataTable/utils/useTableEntities.js → useTableEntities.js} +0 -0
  244. /package/src/{utils/useTraceUpdate.js → useTraceUpdate.js} +0 -0
  245. /package/src/{DataTable/utils/utils.js → utils.js} +0 -0
  246. /package/src/{DataTable/validateTableWideErrors.js → validateTableWideErrors.js} +0 -0
  247. /package/src/{DataTable/viewColumn.js → viewColumn.js} +0 -0
  248. /package/src/{enhancers/withField.js → withField.js} +0 -0
  249. /package/src/{enhancers/withFields.js → withFields.js} +0 -0
  250. /package/src/{enhancers/withLocalStorage.js → withLocalStorage.js} +0 -0
  251. /package/src/{utils/withSelectTableRecords.js → withSelectTableRecords.js} +0 -0
  252. /package/src/{DataTable/utils/withSelectedEntities.js → withSelectedEntities.js} +0 -0
  253. /package/src/{utils/withStore.js → withStore.js} +0 -0
  254. /package/{src/Timeline/style.css → style.css} +0 -0
@@ -1,61 +0,0 @@
1
- .tg-select {
2
- width: 100%;
3
- min-width: 170px;
4
- }
5
- .tg-select.tg-select-as-tag {
6
- /* background-color: red; */
7
- border-radius: 4px;
8
- width: fit-content;
9
- color: white;
10
- border: 2px solid white;
11
- }
12
- .tg-select.tg-select-as-tag .bp3-tag.bp3-minimal.bp3-intent-primary {
13
- color: white !important;
14
- }
15
- .tg-select.do-not-fill-width {
16
- width: auto;
17
- min-width: 50px;
18
- }
19
- .tg-select.tg-small .bp3-input {
20
- min-height: 25px;
21
- height: 25px;
22
- }
23
- .tg-select.tg-small input {
24
- line-height: 10.5px;
25
- }
26
- .tg-select.tg-small .bp3-tag-input .bp3-input-ghost {
27
- line-height: 10.5px;
28
- }
29
- .tg-select.tg-small .bp3-tag-input .bp3-tag-input-values {
30
- margin-top: 2px;
31
- }
32
- .tg-select input {
33
- font-size: 14px;
34
- }
35
- .tg-select-option {
36
- width: fit-content;
37
- min-width: 100%;
38
- }
39
- /* Fix cutoff placeholder */
40
- .tg-select .bp3-input-ghost[placeholder] {
41
- width: 80%;
42
- text-overflow: ellipsis;
43
- }
44
-
45
- .tg-single-select input {
46
- position: absolute;
47
- top: 5px;
48
- }
49
- .tg-single-select .bp3-tag {
50
- background-color: initial !important;
51
- font-size: 14px;
52
- }
53
- .tg-single-select .bp3-popover-open .bp3-tag {
54
- opacity: 0.6;
55
- }
56
- .bp3-multi-select-popover .bp3-menu,
57
- .bp3-select-popover .bp3-menu {
58
- max-width: 400px;
59
- max-height: 300px;
60
- overflow: auto;
61
- }
@@ -1,124 +0,0 @@
1
- import { Suggest } from "@blueprintjs/select";
2
- import { Keys } from "@blueprintjs/core";
3
- import React, { useCallback, useMemo, useRef } from "react";
4
- import classNames from "classnames";
5
- import { itemListPredicate } from "../TgSelect";
6
-
7
- const itemRenderer = (i = "", { index, handleClick, modifiers }) => (
8
- <div //we specifically don't use a BP MenuItem component here because the menu item is too slow when 100s are loaded and will cause the component to lag
9
- onClick={handleClick}
10
- key={index}
11
- className={classNames(
12
- "tg-select-option bp3-menu-item bp3-fill bp3-text-overflow-ellipsis",
13
- {
14
- "bp3-active": modifiers.active
15
- }
16
- )}
17
- >
18
- {i}
19
- </div>
20
- );
21
-
22
- const TgSuggest = ({
23
- disabled,
24
- inputProps: _inputProps,
25
- intent,
26
- isLoading,
27
- isSimpleSearch,
28
- multi,
29
- noResultsText,
30
- notCreateable,
31
- onBlur,
32
- onChange,
33
- optionRenderer, //pull this one out here so it doesn't get passsed along
34
- options,
35
- placeholder,
36
- popoverProps: _popoverProps,
37
- value,
38
- ...rest
39
- }) => {
40
- const inputRef = useRef(null);
41
-
42
- const handleItemSelect = useCallback(
43
- item => {
44
- inputRef.current && inputRef.current.blur();
45
- return onChange?.(item);
46
- },
47
- [onChange]
48
- );
49
-
50
- const _itemListPredicate = useCallback(
51
- (queryString, item) => {
52
- return itemListPredicate(queryString, item, isSimpleSearch);
53
- },
54
- [isSimpleSearch]
55
- );
56
-
57
- const popoverProps = useMemo(
58
- () => ({
59
- minimal: true,
60
- className: classNames("tg-select", {
61
- "tg-single-select": !multi
62
- }),
63
- wrapperTagName: "div",
64
- usePortal: false,
65
- canEscapeKeyClose: true,
66
- ..._popoverProps
67
- }),
68
- [multi, _popoverProps]
69
- );
70
-
71
- const onKeyDown = useCallback(e => {
72
- const { which } = e;
73
- if (which === Keys.ENTER) {
74
- e.preventDefault();
75
- e.stopPropagation(); //this prevents the dialog it is in from closing
76
- }
77
- if (which === Keys.ESCAPE || which === Keys.TAB) {
78
- // By default the escape key will not trigger a blur on the
79
- // input element. It must be done explicitly.
80
- if (inputRef.current != null) {
81
- inputRef.current.blur();
82
- }
83
- e.preventDefault();
84
- e.stopPropagation(); //this prevents dialog's it is in from closing
85
- }
86
- }, []);
87
-
88
- const inputProps = useMemo(
89
- () => ({
90
- inputRef: n => {
91
- if (n) inputRef.current = n;
92
- },
93
- placeholder: placeholder || "Type here...",
94
- disabled: disabled, // tg: adding isLoading will cause the input to be blurred when using generic select asReactSelect (don't do it),
95
- intent: intent,
96
- ..._inputProps
97
- }),
98
- [disabled, _inputProps, intent, placeholder]
99
- );
100
-
101
- return (
102
- <Suggest
103
- closeOnSelect
104
- items={options}
105
- query={value}
106
- popoverProps={popoverProps}
107
- onKeyDown={onKeyDown}
108
- onItemSelect={handleItemSelect}
109
- noResults={null}
110
- resetOnSelect={false}
111
- onQueryChange={onChange}
112
- itemRenderer={itemRenderer}
113
- itemListPredicate={_itemListPredicate}
114
- selectedItem={value}
115
- inputValueRenderer={item => item}
116
- inputProps={inputProps}
117
- isSimpleSearch={isSimpleSearch}
118
- onChange={onChange}
119
- {...rest}
120
- />
121
- );
122
- };
123
-
124
- export default TgSuggest;
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import "./style.css";
3
-
4
- function Timeline(props) {
5
- return (
6
- <div className="tg-timeline">
7
- {props.children.length > 1 && <div className="tg-timeline-line" />}
8
- {props.children}
9
- </div>
10
- );
11
- }
12
-
13
- export { default as TimelineEvent } from "./TimelineEvent";
14
-
15
- export default Timeline;
@@ -1,196 +0,0 @@
1
- import React from "react";
2
- import { Dialog } from "@blueprintjs/core";
3
- import { connect } from "react-redux";
4
- import { lifecycle, compose } from "recompose";
5
- import { camelCase } from "lodash-es";
6
- import { nanoid } from "nanoid";
7
- import ResizableDraggableDialog from "../../ResizableDraggableDialog";
8
-
9
- /**
10
- * usage:
11
- * in container:
12
- * compose(
13
- * withDialog({ title: "Select Aliquot(s) From", other bp dialog props here })
14
- * )
15
- *
16
- *
17
- * in react component
18
- * import MyDialogEnhancedComponent from "./MyDialogEnhancedComponent"
19
- *
20
- * render() {
21
- * return <div>
22
- * <MyDialogEnhancedComponent
23
- * dialogProps={} //bp dialog overrides can go here
24
- * target={<button>Open Dialog</button> } //target can also be passed as a child component
25
- * myRandomProp={'yuppp'} //pass any other props like normal to the component
26
- *
27
- * />
28
- * </div>
29
- * }
30
- */
31
-
32
- // or programatically:
33
- // const ProgramaticDialog = withDialog({
34
- // dialogName: "programaticDialog", //giving it a unique dialogName means you can
35
- // title: "Programatic Dialog Demo"
36
- // })(DialogInner);
37
- //
38
- // add the no target dialog somewhere on the page
39
- // <ProgramaticDialog></ProgramaticDialog> //this just renders without any target
40
- //
41
- // somewhere else on the page:
42
- // <Button>Click To Open Dialog</Button>
43
-
44
- export default function withDialog(topLevelDialogProps) {
45
- function dialogHoc(WrappedComponent) {
46
- return class DialogWrapper extends React.Component {
47
- componentWillUnmount() {
48
- const { dispatch, dialogName, uniqueName } = this.props;
49
- if (dialogName) {
50
- dispatch({
51
- type: "TG_UNREGISTER_MODAL",
52
- name: dialogName,
53
- uniqueName
54
- });
55
- }
56
- }
57
- render() {
58
- const {
59
- target,
60
- noTarget,
61
- isDialogOpen,
62
- showModal,
63
- dialogName,
64
- onClickRename,
65
- hideModal,
66
- fetchPolicy = "network-only",
67
- children,
68
- onCloseHook,
69
- dialogProps,
70
- title,
71
- isDraggable,
72
- alreadyRendering,
73
- ...rest
74
- } = this.props;
75
- const extraDialogProps = {
76
- ...topLevelDialogProps,
77
- ...dialogProps
78
- };
79
- const _onCloseHook = onCloseHook || extraDialogProps.onCloseHook;
80
- const { noButtonClickPropagate } = {
81
- ...this.props,
82
- ...extraDialogProps
83
- };
84
- const isOpen = isDialogOpen || extraDialogProps.isOpen;
85
- const targetEl = target || children;
86
- // if (!targetEl && !dialogName)
87
- // throw new Error(
88
- // "withDialog error: Please provide a target or child element to the withDialog() enhanced component. If you really don't want a target, please pass a 'noTarget=true' prop"
89
- // );
90
- const DialogToUse =
91
- isDraggable || extraDialogProps.isDraggable
92
- ? ResizableDraggableDialog
93
- : Dialog;
94
- return (
95
- <React.Fragment>
96
- {isOpen && (
97
- <DialogToUse
98
- onClose={function () {
99
- hideModal();
100
- _onCloseHook && _onCloseHook();
101
- }}
102
- className={dialogName || camelCase()}
103
- title={title}
104
- isOpen={isOpen}
105
- canEscapeKeyClose={false}
106
- canOutsideClickClose={false}
107
- {...extraDialogProps}
108
- >
109
- <WrappedComponent
110
- {...{
111
- ...rest,
112
- fetchPolicy,
113
- ssr: false,
114
- hideModal
115
- }}
116
- />
117
- </DialogToUse>
118
- )}
119
- {targetEl &&
120
- React.cloneElement(targetEl, {
121
- [onClickRename || "onClick"]: e => {
122
- showModal();
123
- if (noButtonClickPropagate) {
124
- e.preventDefault();
125
- e.stopPropagation();
126
- }
127
- }
128
- })}
129
- </React.Fragment>
130
- );
131
- }
132
- };
133
- }
134
-
135
- return compose(
136
- connect(({ tg_modalState }) => {
137
- return { ...topLevelDialogProps, tg_modalState };
138
- }),
139
- lifecycle({
140
- componentWillMount: function () {
141
- const { dispatch, dialogName } = this.props;
142
- const uniqueName = nanoid();
143
- const nameToUse = dialogName || uniqueName;
144
- this.setState({
145
- nameToUse,
146
- uniqueName
147
- });
148
- if (dialogName) {
149
- dispatch({
150
- type: "TG_REGISTER_MODAL",
151
- name: dialogName,
152
- uniqueName
153
- });
154
- }
155
- }
156
- }),
157
- connect(
158
- function ({ tg_modalState }, { nameToUse, uniqueName }) {
159
- const dialogState = tg_modalState[nameToUse] || {};
160
- const { open, __registeredAs, ...rest } = dialogState;
161
- const newProps = {
162
- ...rest,
163
- isDialogOpen:
164
- open &&
165
- (__registeredAs
166
- ? Object.keys(__registeredAs)[
167
- Object.keys(__registeredAs).length - 1
168
- ] === uniqueName
169
- : true)
170
- };
171
- return newProps;
172
- },
173
- function (dispatch, { nameToUse, hideModal, showModal }) {
174
- return {
175
- showModal:
176
- showModal ||
177
- function () {
178
- dispatch({
179
- type: "TG_SHOW_MODAL",
180
- name: nameToUse
181
- });
182
- },
183
- hideModal:
184
- hideModal ||
185
- function () {
186
- dispatch({
187
- type: "TG_HIDE_MODAL",
188
- name: nameToUse
189
- });
190
- }
191
- };
192
- }
193
- ),
194
- dialogHoc
195
- );
196
- }
@@ -1,148 +0,0 @@
1
- import React, { Component } from "react";
2
- import { Button, Classes, Dialog, Intent } from "@blueprintjs/core";
3
- import { renderOnDoc } from "../utils/renderOnDoc";
4
- import DialogFooter from "../DialogFooter";
5
-
6
- // usage
7
- // const doAction = await showConfirmationDialog({
8
- // text:
9
- // "Are you sure you want to re-run this tool? Downstream tools with linked outputs will need to be re-run as well!",
10
- // intent: Intent.DANGER, //applied to the right most confirm button
11
- // confirmButtonText: "Yep!",
12
- // cancelButtonText: "Nope",
13
- // canEscapeKeyCancel: true //this is false by default
14
- // });
15
- // console.info("doAction:", doAction);
16
-
17
- // const doAction = await showConfirmationDialog({
18
- // thirdButtonText: 'Click me'
19
- // thirdButtonIntent: 'primary'
20
- // });
21
- // console.info("doAction:", doAction); //logs thirdButtonClicked
22
- //returns a promise that resolves with true or false depending on if the user cancels or not!
23
- export default function showConfirmationDialog(opts) {
24
- return new Promise(resolve => {
25
- renderOnDoc(handleClose => {
26
- return <AlertWrapper {...{ ...opts, handleClose, resolve }} />;
27
- });
28
- });
29
- }
30
-
31
- export class AlertWrapper extends Component {
32
- state = { isOpen: true };
33
- render() {
34
- const {
35
- title,
36
- handleClose,
37
- text,
38
- resolve,
39
- noCancelButton,
40
- content,
41
- className,
42
- thirdButtonNotMinimal,
43
- thirdButtonClassName,
44
- thirdButtonText,
45
- thirdButtonIntent,
46
- fourthButtonNotMinimal,
47
- fourthButtonClassName,
48
- fourthButtonText,
49
- fourthButtonIntent,
50
- handleSubmit,
51
- canEscapeKeyCancel,
52
- confirmButtonText = "OK",
53
- cancelButtonText = "Cancel",
54
- intent = Intent.PRIMARY,
55
- ...rest
56
- } = this.props;
57
- const doClose = confirm => {
58
- handleClose();
59
- this.setState({ isOpen: false });
60
- resolve(confirm);
61
- };
62
- return (
63
- <Dialog
64
- title={title}
65
- className={(title ? "" : "bp3-alert") + ` ${className || ""}`}
66
- isOpen={this.state.isOpen}
67
- intent={intent}
68
- cancelButtonText={cancelButtonText}
69
- onCancel={cancelButtonText ? () => doClose(false) : undefined}
70
- onConfirm={
71
- handleSubmit ? handleSubmit(v => doClose(v)) : () => doClose(true)
72
- }
73
- {...rest}
74
- {...(noCancelButton && {
75
- onCancel: undefined,
76
- cancelButtonText: undefined
77
- })}
78
- >
79
- <div
80
- className={title ? "bp3-dialog-body" : "bp3-alert-contents"}
81
- style={{ padding: 5 }}
82
- >
83
- {content}
84
- {text && <div style={{ marginBottom: 10 }}>{text}</div>}
85
- </div>
86
- <DialogFooter
87
- {...{
88
- onBackClick:
89
- cancelButtonText && !noCancelButton
90
- ? () => doClose(false)
91
- : undefined,
92
- onClick: handleSubmit
93
- ? handleSubmit(v => doClose(v))
94
- : () => doClose(true),
95
- noCancel: true,
96
- additionalButtons:
97
- thirdButtonText || fourthButtonText ? (
98
- <React.Fragment>
99
- {!!fourthButtonText && (
100
- <Button
101
- className={
102
- (!fourthButtonNotMinimal ? Classes.MINIMAL : "") +
103
- " " +
104
- fourthButtonClassName
105
- }
106
- intent={fourthButtonIntent}
107
- text={fourthButtonText}
108
- onClick={
109
- handleSubmit
110
- ? handleSubmit(v =>
111
- doClose({ ...v, fourthButtonClicked: true })
112
- )
113
- : () => doClose("fourthButtonClicked")
114
- }
115
- ></Button>
116
- )}
117
- {!!thirdButtonText && (
118
- <Button
119
- className={
120
- (!thirdButtonNotMinimal ? Classes.MINIMAL : "") +
121
- " " +
122
- thirdButtonClassName
123
- }
124
- intent={thirdButtonIntent}
125
- text={thirdButtonText}
126
- onClick={
127
- handleSubmit
128
- ? handleSubmit(v =>
129
- doClose({ ...v, thirdButtonClicked: true })
130
- )
131
- : () => {
132
- doClose("thirdButtonClicked");
133
- }
134
- }
135
- ></Button>
136
- )}
137
- </React.Fragment>
138
- ) : undefined,
139
- containerClassname: title ? "" : "bp3-alert-footer",
140
- backText: noCancelButton ? "" : cancelButtonText,
141
- text: confirmButtonText,
142
- intent
143
- }}
144
- ></DialogFooter>
145
- </Dialog>
146
- );
147
- }
148
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes