@teselagen/ui 0.7.35 → 0.8.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 (128) hide show
  1. package/index.cjs.js +1 -2
  2. package/index.es.js +1 -2
  3. package/package.json +1 -1
  4. package/src/DataTable/Columns.js +1 -1
  5. package/src/DataTable/DisplayOptions.js +1 -1
  6. package/src/DataTable/FilterAndSortMenu.js +30 -27
  7. package/src/DataTable/index.js +14 -3
  8. package/src/DataTable/utils/queryParams.js +771 -64
  9. package/src/DataTable/utils/withTableParams.js +16 -3
  10. package/src/index.js +0 -1
  11. package/src/utils/isBeingCalledExcessively.js +14 -7
  12. package/AdvancedOptions.js +0 -33
  13. package/AssignDefaultsModeContext.js +0 -22
  14. package/CellDragHandle.js +0 -132
  15. package/ColumnFilterMenu.js +0 -62
  16. package/Columns.js +0 -979
  17. package/DataTable/utils/filterLocalEntitiesToHasura.d.ts +0 -5
  18. package/DataTable/utils/initializeHasuraWhereAndFilter.d.ts +0 -2
  19. package/DataTable/utils/tableQueryParamsToHasuraClauses.d.ts +0 -26
  20. package/DisabledLoadingComponent.js +0 -15
  21. package/DisplayOptions.js +0 -199
  22. package/DropdownButton.js +0 -36
  23. package/DropdownCell.js +0 -61
  24. package/EditableCell.js +0 -44
  25. package/FillWindow.css +0 -6
  26. package/FillWindow.js +0 -69
  27. package/FilterAndSortMenu.js +0 -391
  28. package/FormSeparator.js +0 -9
  29. package/LoadingDots.js +0 -14
  30. package/MatchHeaders.js +0 -234
  31. package/PagingTool.js +0 -225
  32. package/RenderCell.js +0 -191
  33. package/SearchBar.js +0 -69
  34. package/SimpleStepViz.js +0 -22
  35. package/SortableColumns.js +0 -100
  36. package/TableFormTrackerContext.js +0 -10
  37. package/Tag.js +0 -112
  38. package/ThComponent.js +0 -44
  39. package/TimelineEvent.js +0 -31
  40. package/UploadCsvWizard.css +0 -4
  41. package/UploadCsvWizard.js +0 -719
  42. package/Uploader.js +0 -1278
  43. package/adHoc.js +0 -10
  44. package/autoTooltip.js +0 -201
  45. package/basicHandleActionsWithFullState.js +0 -14
  46. package/browserUtils.js +0 -3
  47. package/combineReducersWithFullState.js +0 -14
  48. package/commandControls.js +0 -82
  49. package/commandUtils.js +0 -112
  50. package/constants.js +0 -1
  51. package/convertSchema.js +0 -69
  52. package/customIcons.js +0 -361
  53. package/dataTableEnhancer.js +0 -41
  54. package/defaultFormatters.js +0 -32
  55. package/defaultValidators.js +0 -40
  56. package/determineBlackOrWhiteTextColor.js +0 -4
  57. package/editCellHelper.js +0 -44
  58. package/formatPasteData.js +0 -16
  59. package/getAllRows.js +0 -11
  60. package/getCellCopyText.js +0 -7
  61. package/getCellInfo.js +0 -36
  62. package/getCellVal.js +0 -20
  63. package/getDayjsFormatter.js +0 -35
  64. package/getFieldPathToField.js +0 -7
  65. package/getIdOrCodeOrIndex.js +0 -9
  66. package/getLastSelectedEntity.js +0 -11
  67. package/getNewEntToSelect.js +0 -25
  68. package/getNewName.js +0 -31
  69. package/getRowCopyText.js +0 -28
  70. package/getTableConfigFromStorage.js +0 -5
  71. package/getTextFromEl.js +0 -28
  72. package/getVals.js +0 -8
  73. package/handleCopyColumn.js +0 -21
  74. package/handleCopyHelper.js +0 -15
  75. package/handleCopyRows.js +0 -23
  76. package/handleCopyTable.js +0 -16
  77. package/handlerHelpers.js +0 -24
  78. package/hotkeyUtils.js +0 -131
  79. package/index.js +0 -1
  80. package/isBeingCalledExcessively.js +0 -32
  81. package/isBottomRightCornerOfRectangle.js +0 -20
  82. package/isEntityClean.js +0 -15
  83. package/isTruthy.js +0 -12
  84. package/isValueEmpty.js +0 -3
  85. package/itemUpload.js +0 -84
  86. package/menuUtils.js +0 -433
  87. package/popoverOverflowModifiers.js +0 -11
  88. package/primarySelectedValue.js +0 -1
  89. package/pureNoFunc.js +0 -31
  90. package/queryParams.js +0 -1058
  91. package/removeCleanRows.js +0 -22
  92. package/renderOnDoc.js +0 -32
  93. package/rerenderOnWindowResize.js +0 -26
  94. package/rowClick.js +0 -181
  95. package/selection.js +0 -8
  96. package/showAppSpinner.js +0 -12
  97. package/showDialogOnDocBody.js +0 -33
  98. package/showProgressToast.js +0 -22
  99. package/sortify.js +0 -73
  100. package/src/DataTable/utils/filterLocalEntitiesToHasura.js +0 -236
  101. package/src/DataTable/utils/filterLocalEntitiesToHasura.test.js +0 -587
  102. package/src/DataTable/utils/initializeHasuraWhereAndFilter.js +0 -26
  103. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.js +0 -253
  104. package/src/DataTable/utils/tableQueryParamsToHasuraClauses.test.js +0 -206
  105. package/style.css +0 -29
  106. package/tagUtils.js +0 -45
  107. package/tgFormValues.js +0 -35
  108. package/tg_modalState.js +0 -47
  109. package/throwFormError.js +0 -16
  110. package/toastr.js +0 -148
  111. package/tryToMatchSchemas.js +0 -264
  112. package/typeToCommonType.js +0 -6
  113. package/useDeepEqualMemo.js +0 -15
  114. package/useDialog.js +0 -63
  115. package/useStableReference.js +0 -9
  116. package/useTableEntities.js +0 -38
  117. package/useTraceUpdate.js +0 -19
  118. package/utils.js +0 -37
  119. package/validateTableWideErrors.js +0 -160
  120. package/viewColumn.js +0 -97
  121. package/withField.js +0 -20
  122. package/withFields.js +0 -11
  123. package/withLocalStorage.js +0 -11
  124. package/withSelectTableRecords.js +0 -43
  125. package/withSelectedEntities.js +0 -65
  126. package/withStore.js +0 -10
  127. package/withTableParams.js +0 -301
  128. package/wrapDialog.js +0 -116
@@ -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/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
- }
package/getRowCopyText.js DELETED
@@ -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
- }
package/getTextFromEl.js DELETED
@@ -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/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
- };
package/handleCopyRows.js DELETED
@@ -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
- };
package/handlerHelpers.js DELETED
@@ -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
- });
package/hotkeyUtils.js DELETED
@@ -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"];
package/index.js DELETED
@@ -1 +0,0 @@
1
- export { useDeepEqualMemo } from "./useDeepEqualMemo";
@@ -1,32 +0,0 @@
1
- const keyCount = {};
2
- // if this function is hit more than 20 times in a row in 2 seconds with the same uniqName then throw an error
3
- export const isBeingCalledExcessively = ({ uniqName }) => {
4
- if (process.env.NODE_ENV !== "development") {
5
- return;
6
- }
7
- if (!uniqName) {
8
- throw new Error("uniqName is required");
9
- }
10
- // Initialize the count if it doesn't exist
11
- keyCount[uniqName] = keyCount[uniqName] || 0;
12
- keyCount[uniqName]++;
13
-
14
- // Only set the timeout if it doesn't exist already to ensure it runs exactly once every 2 seconds
15
- if (!keyCount[uniqName + "_timeout"]) {
16
- keyCount[uniqName + "_timeout"] = setTimeout(() => {
17
- keyCount[uniqName] = 0;
18
- keyCount[uniqName + "_timeout"] = null;
19
- }, 2000);
20
- }
21
-
22
- if (keyCount[uniqName] > 20) {
23
- keyCount[uniqName] = 0;
24
- // Also clear the timeout when throwing an error
25
- if (keyCount[uniqName + "_timeout"]) {
26
- clearTimeout(keyCount[uniqName + "_timeout"]);
27
- keyCount[uniqName + "_timeout"] = null;
28
- }
29
- throw new Error(`isBeingCalledExcessively: ${uniqName}`);
30
- }
31
- };
32
-
@@ -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
- };
package/isEntityClean.js DELETED
@@ -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/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
- }
package/isValueEmpty.js DELETED
@@ -1,3 +0,0 @@
1
- export function isValueEmpty(val) {
2
- return val === undefined || val === null || val === "";
3
- }
package/itemUpload.js DELETED
@@ -1,84 +0,0 @@
1
- import React from "react";
2
- import {
3
- ProgressBar,
4
- Intent,
5
- Button,
6
- Tooltip,
7
- Position,
8
- Icon
9
- } from "@blueprintjs/core";
10
-
11
- const itemUpload = props => {
12
- const item = props.item;
13
- const name = nameShortener(item.name);
14
-
15
- return (
16
- <div className="item-upload-container" key={item.id}>
17
- <div className="item-upload">
18
- <div>
19
- {!props.saved ? (
20
- <Tooltip
21
- content={
22
- <span>
23
- {`Click to
24
- ${props.active ? "abort this uploading" : "remove this file"}`}
25
- </span>
26
- }
27
- position={Position.LEFT}
28
- usePortal={true}
29
- >
30
- <Button
31
- intent={Intent.DANGER}
32
- minimal
33
- icon="delete"
34
- onClick={props.onCancel}
35
- />
36
- </Tooltip>
37
- ) : null}
38
- </div>
39
- <div>
40
- <span>{name}</span>
41
- </div>
42
- <div>
43
- {props.active ? `${props.value}%` : null}
44
- {props.error ? (
45
- <Tooltip content={props.error} usePortal={true}>
46
- <Icon icon="error" intent={Intent.DANGER} />
47
- </Tooltip>
48
- ) : null}
49
- {props.saved ? (
50
- <Tooltip content={"File Saved"} usePortal={true}>
51
- <Icon icon="saved" intent={Intent.SUCCESS} />
52
- </Tooltip>
53
- ) : null}
54
- </div>
55
- </div>
56
- {props.active ? (
57
- <ProgressBar intent={Intent.PRIMARY} value={props.value / 100} />
58
- ) : null}
59
- </div>
60
- );
61
- };
62
-
63
- /**
64
- * Short file names length to display
65
- * @param {*} itemName
66
- */
67
- const nameShortener = itemName => {
68
- if (itemName.length > 40) {
69
- let name = "";
70
- const arr = itemName.split(".");
71
- name += `${arr[0].substring(0, 20)}...`;
72
- if (arr.length >= 2) {
73
- name += `${arr[arr.length - 2].substring(
74
- arr[arr.length - 2].length - 5,
75
- arr[arr.length - 2].length
76
- )}`;
77
- name += `.${arr[arr.length - 1]}`;
78
- }
79
- return name;
80
- }
81
- return itemName;
82
- };
83
-
84
- export default itemUpload;