@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
@@ -1,16 +0,0 @@
1
- import { getFieldPathToField } from "./getFieldPathToField";
2
-
3
- export const formatPasteData = ({ schema, newVal, path }) => {
4
- const pathToField = getFieldPathToField(schema);
5
- const column = pathToField[path];
6
- if (column.type === "genericSelect") {
7
- if (newVal?.__genSelCol === path) {
8
- newVal = newVal.__strVal;
9
- } else {
10
- newVal = undefined;
11
- }
12
- } else {
13
- newVal = Object.hasOwn(newVal, "__strVal") ? newVal.__strVal : newVal;
14
- }
15
- return newVal;
16
- };
package/src/getAllRows.js DELETED
@@ -1,11 +0,0 @@
1
- export const getAllRows = e => {
2
- const el = e.target.querySelector(".data-table-container")
3
- ? e.target.querySelector(".data-table-container")
4
- : e.target.closest(".data-table-container");
5
-
6
- const allRowEls = el.querySelectorAll(".rt-tr");
7
- if (!allRowEls || !allRowEls.length) {
8
- return;
9
- }
10
- return allRowEls;
11
- };
@@ -1,7 +0,0 @@
1
- export const getCellCopyText = cellWrapper => {
2
- const text = cellWrapper && cellWrapper.getAttribute("data-copy-text");
3
- const jsonText = cellWrapper && cellWrapper.getAttribute("data-copy-json");
4
-
5
- const textContent = text || cellWrapper.textContent || "";
6
- return [textContent, jsonText];
7
- };
@@ -1,36 +0,0 @@
1
- import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
2
-
3
- export const getCellInfo = ({
4
- columnIndex,
5
- columnPath,
6
- rowId,
7
- schema,
8
- entities,
9
- rowIndex,
10
- isEntityDisabled,
11
- entity
12
- }) => {
13
- const leftpath = schema.fields[columnIndex - 1]?.path;
14
- const rightpath = schema.fields[columnIndex + 1]?.path;
15
- const cellIdToLeft = leftpath && `${rowId}:${leftpath}`;
16
- const cellIdToRight = rightpath && `${rowId}:${rightpath}`;
17
- const rowAboveId =
18
- entities[rowIndex - 1] &&
19
- getIdOrCodeOrIndex(entities[rowIndex - 1], rowIndex - 1);
20
- const rowBelowId =
21
- entities[rowIndex + 1] &&
22
- getIdOrCodeOrIndex(entities[rowIndex + 1], rowIndex + 1);
23
- const cellIdAbove = rowAboveId && `${rowAboveId}:${columnPath}`;
24
- const cellIdBelow = rowBelowId && `${rowBelowId}:${columnPath}`;
25
-
26
- const cellId = `${rowId}:${columnPath}`;
27
- const rowDisabled = isEntityDisabled(entity);
28
- return {
29
- cellId,
30
- cellIdAbove,
31
- cellIdToRight,
32
- cellIdBelow,
33
- cellIdToLeft,
34
- rowDisabled
35
- };
36
- };
package/src/getCellVal.js DELETED
@@ -1,20 +0,0 @@
1
- import { get } from "lodash-es";
2
- import { isString } from "lodash-es";
3
- import { isTruthy } from "./isTruthy";
4
-
5
- export const getCellVal = (ent, path, col) => {
6
- const isBool = col?.type === "boolean";
7
- let selectedCellVal = get(ent, path, "");
8
- if (isBool) {
9
- if (isString(selectedCellVal)) {
10
- selectedCellVal = selectedCellVal.toLowerCase();
11
- }
12
- selectedCellVal =
13
- selectedCellVal === "true" ||
14
- selectedCellVal === true ||
15
- selectedCellVal === 1 ||
16
- selectedCellVal === "yes";
17
- selectedCellVal = isTruthy(selectedCellVal);
18
- }
19
- return selectedCellVal;
20
- };
@@ -1,35 +0,0 @@
1
- import dayjs from "dayjs";
2
- import LocalizedFormat from "dayjs/plugin/localizedFormat";
3
- import localeData from "dayjs/plugin/localeData";
4
-
5
- dayjs.extend(localeData);
6
- dayjs.extend(LocalizedFormat);
7
- const userLocale = Intl.DateTimeFormat().resolvedOptions().locale;
8
-
9
- if (userLocale) {
10
- const requireLocale = (newLocale, skipCall) => {
11
- if (dayjs.locale() !== newLocale) {
12
- try {
13
- require(`dayjs/locale/${newLocale}.js`);
14
- dayjs.locale(newLocale);
15
- } catch (error) {
16
- // error
17
- if (!skipCall && newLocale.includes("-")) {
18
- requireLocale(newLocale.split("-")[0], true);
19
- }
20
- }
21
- }
22
- };
23
- const localeToUse = userLocale.toLowerCase();
24
- requireLocale(localeToUse);
25
- }
26
-
27
- export default function getDayjsFormatter(format) {
28
- return {
29
- formatDate: date => dayjs(date).format(format),
30
- parseDate: str => dayjs(str, format).toDate(),
31
- placeholder: format?.toLowerCase().includes("l")
32
- ? dayjs.Ls[dayjs.locale()]?.formats[format.toUpperCase()]
33
- : format
34
- };
35
- }
@@ -1,7 +0,0 @@
1
- export const getFieldPathToField = schema => {
2
- const fieldPathToField = {};
3
- schema.fields.forEach(f => {
4
- fieldPathToField[f.path] = f;
5
- });
6
- return fieldPathToField;
7
- };
@@ -1,9 +0,0 @@
1
- export const getIdOrCodeOrIndex = (record, rowIndex) => {
2
- if (record.id || record.id === 0) {
3
- return record.id;
4
- } else if (record.code) {
5
- return record.code;
6
- } else {
7
- return rowIndex;
8
- }
9
- };
@@ -1,11 +0,0 @@
1
- export const getLastSelectedEntity = idMap => {
2
- let lastSelectedEnt;
3
- let latestTime;
4
- Object.values(idMap).forEach(({ time, entity }) => {
5
- if (!latestTime || time > latestTime) {
6
- lastSelectedEnt = entity;
7
- latestTime = time;
8
- }
9
- });
10
- return lastSelectedEnt;
11
- };
@@ -1,25 +0,0 @@
1
- export const getNewEntToSelect = ({
2
- type,
3
- lastSelectedIndex,
4
- entities,
5
- isEntityDisabled
6
- }) => {
7
- let newIndexToSelect;
8
- if (type === "up") {
9
- newIndexToSelect = lastSelectedIndex - 1;
10
- } else {
11
- newIndexToSelect = lastSelectedIndex + 1;
12
- }
13
- const newEntToSelect = entities[newIndexToSelect];
14
- if (!newEntToSelect) return;
15
- if (isEntityDisabled && isEntityDisabled(newEntToSelect)) {
16
- return getNewEntToSelect({
17
- type,
18
- lastSelectedIndex: newIndexToSelect,
19
- entities,
20
- isEntityDisabled
21
- });
22
- } else {
23
- return newEntToSelect;
24
- }
25
- };
package/src/getNewName.js DELETED
@@ -1,31 +0,0 @@
1
- export function getNewName(list, targetName) {
2
- const usedNumbers = [];
3
-
4
- for (let i = 0; i < list.length; i++) {
5
- const currentName = list[i].name;
6
- const baseName = currentName.replace(/\(\d+\)\.csv$/, ".csv");
7
-
8
- if (baseName === targetName) {
9
- const match = currentName.match(/\((\d+)\)\.csv$/);
10
- if (match) {
11
- usedNumbers[parseInt(match[1])] = true;
12
- } else {
13
- usedNumbers[0] = true;
14
- }
15
- }
16
- }
17
-
18
- let newName = targetName;
19
- for (let i = 0; i <= usedNumbers.length; i++) {
20
- if (!usedNumbers[i]) {
21
- if (i === 0) {
22
- newName = targetName;
23
- } else {
24
- newName = targetName.replace(".csv", `(${i}).csv`);
25
- }
26
- break;
27
- }
28
- }
29
-
30
- return newName;
31
- }
@@ -1,28 +0,0 @@
1
- import { getCellCopyText } from "./getCellCopyText";
2
- import { flatMap } from "lodash-es";
3
-
4
- export const getRowCopyText = (rowEl, { specificColumn } = {}) => {
5
- //takes in a row element
6
- if (!rowEl) return [];
7
- const textContent = [];
8
- const jsonText = [];
9
-
10
- for (const cellEl of rowEl.children) {
11
- const cellChild = cellEl.querySelector(`[data-copy-text]`);
12
- if (!cellChild) {
13
- if (specificColumn) continue; //strip it
14
- continue; //just leave it blank
15
- }
16
- if (
17
- specificColumn &&
18
- cellChild.getAttribute("data-test") !== specificColumn
19
- ) {
20
- continue;
21
- }
22
- const [t, j] = getCellCopyText(cellChild);
23
- textContent.push(t);
24
- jsonText.push(j);
25
- }
26
-
27
- return [flatMap(textContent).join("\t"), jsonText];
28
- };
@@ -1,5 +0,0 @@
1
- export default function getTableConfigFromStorage(formName) {
2
- let tableConfig = window.localStorage.getItem(formName);
3
- tableConfig = tableConfig && JSON.parse(tableConfig);
4
- return tableConfig;
5
- }
@@ -1,28 +0,0 @@
1
- import React from "react";
2
-
3
- export default function getTextFromEl(el, options = {}) {
4
- const { lowerCase } = options;
5
- if (React.isValidElement(el)) {
6
- return el && el.props && el.props.children
7
- ? (el.props.children.reduce
8
- ? el.props.children
9
- : [el.props.children]
10
- ).reduce((acc, child) => {
11
- if (child && child.props && child.props.children) {
12
- acc += getTextFromEl(child);
13
- } else if (typeof child === "string") {
14
- if (lowerCase) {
15
- acc += child.toLowerCase();
16
- } else {
17
- acc += child;
18
- }
19
- } else if (typeof child === "number") {
20
- acc += child + "";
21
- }
22
- return acc;
23
- }, "")
24
- : "";
25
- } else {
26
- return el;
27
- }
28
- }
package/src/getVals.js DELETED
@@ -1,8 +0,0 @@
1
- import { isFunction } from "lodash-es";
2
-
3
- export function getVals(values) {
4
- if (isFunction(values)) {
5
- return values();
6
- }
7
- return values;
8
- }
@@ -1,21 +0,0 @@
1
- import { getAllRows } from "./getAllRows";
2
- import { getIdOrCodeOrIndex } from "./getIdOrCodeOrIndex";
3
- import { handleCopyRows } from "./handleCopyRows";
4
-
5
- export const handleCopyColumn = (e, cellWrapper, selectedRecords) => {
6
- const specificColumn = cellWrapper.getAttribute("data-test");
7
- let rowElsToCopy = getAllRows(e);
8
- if (!rowElsToCopy) return;
9
- if (selectedRecords) {
10
- const ids = selectedRecords.map(e => getIdOrCodeOrIndex(e)?.toString());
11
- rowElsToCopy = Array.from(rowElsToCopy).filter(rowEl => {
12
- const id = rowEl.closest(".rt-tr-group")?.getAttribute("data-test-id");
13
- return id !== undefined && ids.includes(id);
14
- });
15
- }
16
- if (!rowElsToCopy) return;
17
- handleCopyRows(rowElsToCopy, {
18
- specificColumn,
19
- onFinishMsg: "Column Copied"
20
- });
21
- };
@@ -1,15 +0,0 @@
1
- import copy from "copy-to-clipboard";
2
-
3
- export const handleCopyHelper = (stringToCopy, jsonToCopy, message) => {
4
- !window.Cypress &&
5
- copy(stringToCopy, {
6
- onCopy: clipboardData => {
7
- clipboardData.setData("application/json", JSON.stringify(jsonToCopy));
8
- },
9
- // keep this so that pasting into spreadsheets works.
10
- format: "text/plain"
11
- });
12
- if (message) {
13
- window.toastr.success(message);
14
- }
15
- };
@@ -1,23 +0,0 @@
1
- import download from "downloadjs";
2
- import { getRowCopyText } from "./getRowCopyText";
3
- import { handleCopyHelper } from "./handleCopyHelper";
4
-
5
- export const handleCopyRows = (
6
- rowElsToCopy,
7
- { specificColumn, onFinishMsg, isDownload } = {}
8
- ) => {
9
- let textToCopy = [];
10
- const jsonToCopy = [];
11
- rowElsToCopy.forEach(rowEl => {
12
- const [t, j] = getRowCopyText(rowEl, { specificColumn });
13
- textToCopy.push(t);
14
- jsonToCopy.push(j);
15
- });
16
- textToCopy = textToCopy.filter(text => text).join("\n");
17
- if (!textToCopy) return window.toastr.warning("No text to copy");
18
- if (isDownload) {
19
- download(textToCopy.replaceAll("\t", ","), "tableData.csv", "text/csv");
20
- } else {
21
- handleCopyHelper(textToCopy, jsonToCopy, onFinishMsg || "Row Copied");
22
- }
23
- };
@@ -1,16 +0,0 @@
1
- import { getAllRows } from "./getAllRows";
2
- import { handleCopyRows } from "./handleCopyRows";
3
-
4
- export const handleCopyTable = (e, opts) => {
5
- try {
6
- const allRowEls = getAllRows(e);
7
- if (!allRowEls) return;
8
- handleCopyRows(allRowEls, {
9
- ...opts,
10
- onFinishMsg: "Table Copied"
11
- });
12
- } catch (error) {
13
- console.error(`error:`, error);
14
- window.toastr.error("Error copying rows.");
15
- }
16
- };
@@ -1,24 +0,0 @@
1
- export const onEnterHelper = callback => ({
2
- onKeyDown: event => {
3
- if (event.key === "Enter") {
4
- callback(event);
5
- }
6
- }
7
- });
8
-
9
- export const onBlurHelper = callback => ({
10
- onBlur: event => {
11
- callback(event);
12
- }
13
- });
14
-
15
- export const onEnterOrBlurHelper = callback => ({
16
- onKeyDown: function (event) {
17
- if (event.key === "Enter") {
18
- callback(event);
19
- }
20
- },
21
- onBlur: function (event) {
22
- callback(event);
23
- }
24
- });
@@ -1,131 +0,0 @@
1
- import React, { useMemo } from "react";
2
- import { useHotkeys } from "@blueprintjs/core";
3
- import { startCase } from "lodash-es";
4
-
5
- // This has been mostly superseded by blueprint's KeyCombo component, but may
6
- // still be useful for cases where we need plain text
7
- export function comboToLabel(def, useSymbols = true) {
8
- const combo = typeof def === "string" ? def : def.combo;
9
-
10
- if (useSymbols) {
11
- let parts = combo.replace("++", "+plus").split("+");
12
- parts = parts.map(p => symbols[p] || startCase(p) || p);
13
- return parts.join("");
14
- } else {
15
- return combo
16
- .split("+")
17
- .map(p => startCase(p) || p)
18
- .join(" + ")
19
- .replace("Meta", isMac ? "Cmd" : "Ctrl")
20
- .replace("Mod", isMac ? "Cmd" : "Ctrl")
21
- .replace("Alt", isMac ? "Option" : "Alt");
22
- }
23
- }
24
-
25
- // HOF to get hotkey combos by id
26
- export const hotkeysById =
27
- (hotkeys, mode = "raw") =>
28
- id => {
29
- const def = getHotkeyProps(hotkeys[id]);
30
- return (
31
- def &&
32
- (mode === "raw" ? def.combo : comboToLabel(def.combo, mode === "symbols"))
33
- );
34
- };
35
-
36
- // Translate shorthand array if needed
37
- export const getHotkeyProps = (def, id) => {
38
- let out;
39
- if (typeof def === "string") {
40
- out = { combo: def };
41
- } else if (def instanceof Array) {
42
- out = { combo: def[0], label: def[1], ...(def[2] || {}) };
43
- } else {
44
- out = def;
45
- }
46
- out.label = out.label || startCase(id);
47
- return out;
48
- };
49
-
50
- /*
51
- * HOC to add hotkey support to components. Use this instead of blueprint's one.
52
- *
53
- * Arguments:
54
- * - hotkeySpec: either a named hotkey section previously registered, or an
55
- * object mapping command ids to hotkey definitions, where each hotkey can
56
- * be either:
57
- * - a string consisting in the key combo (e.g. 'ctrl+shift+x')
58
- * - an array holding the combo, label, and an object with any other props
59
- * - an object holding all props
60
- * - handlers: an object mapping command ids to handler functions
61
- * - options: an object that may specify the follownig options:
62
- * - functional: boolean indicating if the wrapped component will be a
63
- * functional stateless component instead of a class-based one
64
- *
65
- * Returns a function that can be invoked with a component class, or a
66
- * stateless component function (if specified in the options) and returns
67
- * the decorated class. It may also be invoked without arguments to generate a
68
- * dummy ad-hoc component with no output.
69
- *
70
- */
71
- export const withHotkeys = (hotkeys, handlers) => {
72
- return ({ children } = {}) => {
73
- const memoedHotkeys = useMemo(
74
- () =>
75
- Object.keys(hotkeys).map(id => {
76
- const { ...props } = getHotkeyProps(hotkeys[id], id);
77
- return {
78
- key: id,
79
- global: props.global !== false,
80
- onKeyDown: function (e) {
81
- return handlers[id](e);
82
- },
83
- ...props
84
- };
85
- }),
86
- []
87
- );
88
-
89
- const { handleKeyDown, handleKeyUp } = useHotkeys(memoedHotkeys);
90
- const newProps = {
91
- tabIndex: 0,
92
- onKeyDown: handleKeyDown,
93
- onKeyUp: handleKeyUp
94
- };
95
- return children ? ( //tnr: if children are passed, we'll clone them with the new props
96
- React.cloneElement(children, newProps)
97
- ) : (
98
- //if not, then we'll return a div that can be used
99
- <div className="hotkeyHandler" {...newProps}></div>
100
- );
101
- };
102
- };
103
-
104
- const isMac = navigator.userAgent.includes("Mac OS X");
105
-
106
- // TODO maybe avoid using symbols by default when not on Mac?
107
- // Anyway, alternative 'Key + Key' description is provided as well
108
- const symbols = {
109
- cmd: "⌘",
110
- meta: "⌘",
111
- ctrl: "⌃",
112
- alt: "⌥",
113
- shift: "⇧",
114
- esc: "␛", //'⎋',
115
- enter: "⏎",
116
- backspace: "⌫",
117
- plus: "+",
118
- tab: "⇥",
119
- space: "␣",
120
- capslock: "⇪",
121
- pageup: "⇞",
122
- pagedown: "⇟",
123
- home: "↖",
124
- end: "↘",
125
- left: "←",
126
- right: "→",
127
- up: "↑",
128
- down: "↓"
129
- };
130
-
131
- symbols.mod = symbols[isMac ? "meta" : "ctrl"];
@@ -1,27 +0,0 @@
1
- export function initializeHasuraWhereAndFilter(
2
- additionalFilter,
3
- where = {},
4
- currentParams
5
- ) {
6
- where._and = where._and || [];
7
- where._or = where._or || [];
8
- if (typeof additionalFilter === "function") {
9
- const newWhere = additionalFilter(where, currentParams);
10
- if (newWhere) {
11
- where = {
12
- ...where,
13
- ...newWhere
14
- };
15
- }
16
- } else if (typeof additionalFilter === "object")
17
- where._and.push(additionalFilter);
18
- }
19
-
20
- export const addCustomColumnFilters = (where, fields, currentParams) => {
21
- fields.forEach(field => {
22
- const { customColumnFilter, filterDisabled } = field;
23
- if (filterDisabled || !customColumnFilter) return;
24
- customColumnFilter(where, currentParams);
25
- });
26
- };
27
-
@@ -1,24 +0,0 @@
1
- const keyCount = {};
2
- export const isBeingCalledExcessively = ({ uniqName }) => {
3
- if (process.env.NODE_ENV !== "development") {
4
- return;
5
- }
6
- if (!uniqName) {
7
- throw new Error("uniqName is required");
8
- }
9
- // if this function is hit more than 10 times in a row in 2 seconds with the same uniqName then throw an error
10
- if (keyCount[uniqName + "_timeout"]) {
11
- clearTimeout(keyCount[uniqName + "_timeout"]);
12
- }
13
- keyCount[uniqName] = keyCount[uniqName] || 0;
14
- keyCount[uniqName]++;
15
-
16
- keyCount[uniqName + "_timeout"] = setTimeout(() => {
17
- keyCount[uniqName] = 0;
18
- }, 2000);
19
-
20
- if (keyCount[uniqName] > 20) {
21
- keyCount[uniqName] = 0;
22
- throw new Error(`isBeingCalledExcessively: ${uniqName}`);
23
- }
24
- };
@@ -1,20 +0,0 @@
1
- export const isBottomRightCornerOfRectangle = ({
2
- cellId,
3
- selectionGrid,
4
- lastRowIndex,
5
- lastCellIndex,
6
- entityMap,
7
- pathToIndex
8
- }) => {
9
- selectionGrid.forEach(row => {
10
- // remove undefineds from start of row
11
- while (row[0] === undefined && row.length) row.shift();
12
- });
13
- const [rowId, cellPath] = cellId.split(":");
14
- const ent = entityMap[rowId];
15
- if (!ent) return;
16
- const { i } = ent;
17
- const cellIndex = pathToIndex[cellPath];
18
- const isBottomRight = i === lastRowIndex && cellIndex === lastCellIndex;
19
- return isBottomRight;
20
- };
@@ -1,15 +0,0 @@
1
- export function isEntityClean(e) {
2
- if (typeof e !== "object" || e === null) {
3
- return true; // or return false depending on what you want for non-object inputs
4
- }
5
- let isClean = true;
6
- for (const [key, val] of Object.entries(e)) {
7
- if (key === "id") continue;
8
- if (key === "_isClean") continue;
9
- if (val) {
10
- isClean = false;
11
- break;
12
- }
13
- }
14
- return isClean;
15
- }
package/src/isTruthy.js DELETED
@@ -1,12 +0,0 @@
1
- export function isTruthy(v) {
2
- if (!v) return false;
3
- if (typeof v === "string") {
4
- if (v.toLowerCase() === "false") {
5
- return false;
6
- }
7
- if (v.toLowerCase() === "no") {
8
- return false;
9
- }
10
- }
11
- return true;
12
- }
@@ -1,3 +0,0 @@
1
- export function isValueEmpty(val) {
2
- return val === undefined || val === null || val === "";
3
- }