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

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 (115) hide show
  1. package/package.json +1 -1
  2. package/src/style.css +10 -26
  3. package/AdvancedOptions.js +0 -33
  4. package/AssignDefaultsModeContext.js +0 -22
  5. package/CellDragHandle.js +0 -132
  6. package/ColumnFilterMenu.js +0 -62
  7. package/Columns.js +0 -979
  8. package/DisabledLoadingComponent.js +0 -15
  9. package/DisplayOptions.js +0 -199
  10. package/DropdownButton.js +0 -36
  11. package/DropdownCell.js +0 -61
  12. package/EditableCell.js +0 -44
  13. package/FillWindow.css +0 -6
  14. package/FillWindow.js +0 -69
  15. package/FilterAndSortMenu.js +0 -388
  16. package/FormSeparator.js +0 -9
  17. package/LoadingDots.js +0 -14
  18. package/MatchHeaders.js +0 -234
  19. package/PagingTool.js +0 -225
  20. package/RenderCell.js +0 -191
  21. package/SearchBar.js +0 -69
  22. package/SimpleStepViz.js +0 -22
  23. package/SortableColumns.js +0 -100
  24. package/TableFormTrackerContext.js +0 -10
  25. package/Tag.js +0 -112
  26. package/ThComponent.js +0 -44
  27. package/TimelineEvent.js +0 -31
  28. package/UploadCsvWizard.css +0 -4
  29. package/UploadCsvWizard.js +0 -719
  30. package/Uploader.js +0 -1278
  31. package/adHoc.js +0 -10
  32. package/autoTooltip.js +0 -201
  33. package/basicHandleActionsWithFullState.js +0 -14
  34. package/browserUtils.js +0 -3
  35. package/combineReducersWithFullState.js +0 -14
  36. package/commandControls.js +0 -82
  37. package/commandUtils.js +0 -112
  38. package/constants.js +0 -1
  39. package/convertSchema.js +0 -69
  40. package/customIcons.js +0 -361
  41. package/dataTableEnhancer.js +0 -41
  42. package/defaultFormatters.js +0 -32
  43. package/defaultValidators.js +0 -40
  44. package/determineBlackOrWhiteTextColor.js +0 -4
  45. package/editCellHelper.js +0 -44
  46. package/filterLocalEntitiesToHasura.js +0 -216
  47. package/formatPasteData.js +0 -16
  48. package/getAllRows.js +0 -11
  49. package/getCellCopyText.js +0 -7
  50. package/getCellInfo.js +0 -36
  51. package/getCellVal.js +0 -20
  52. package/getDayjsFormatter.js +0 -35
  53. package/getFieldPathToField.js +0 -7
  54. package/getIdOrCodeOrIndex.js +0 -9
  55. package/getLastSelectedEntity.js +0 -11
  56. package/getNewEntToSelect.js +0 -25
  57. package/getNewName.js +0 -31
  58. package/getRowCopyText.js +0 -28
  59. package/getTableConfigFromStorage.js +0 -5
  60. package/getTextFromEl.js +0 -28
  61. package/getVals.js +0 -8
  62. package/handleCopyColumn.js +0 -21
  63. package/handleCopyHelper.js +0 -15
  64. package/handleCopyRows.js +0 -23
  65. package/handleCopyTable.js +0 -16
  66. package/handlerHelpers.js +0 -24
  67. package/hotkeyUtils.js +0 -131
  68. package/index.js +0 -1
  69. package/initializeHasuraWhereAndFilter.js +0 -27
  70. package/isBeingCalledExcessively.js +0 -24
  71. package/isBottomRightCornerOfRectangle.js +0 -20
  72. package/isEntityClean.js +0 -15
  73. package/isTruthy.js +0 -12
  74. package/isValueEmpty.js +0 -3
  75. package/itemUpload.js +0 -84
  76. package/menuUtils.js +0 -433
  77. package/popoverOverflowModifiers.js +0 -11
  78. package/primarySelectedValue.js +0 -1
  79. package/pureNoFunc.js +0 -31
  80. package/queryParams.js +0 -336
  81. package/removeCleanRows.js +0 -22
  82. package/renderOnDoc.js +0 -32
  83. package/rerenderOnWindowResize.js +0 -26
  84. package/rowClick.js +0 -181
  85. package/selection.js +0 -8
  86. package/showAppSpinner.js +0 -12
  87. package/showDialogOnDocBody.js +0 -33
  88. package/showProgressToast.js +0 -22
  89. package/simplifyHasuraWhere.js +0 -80
  90. package/sortify.js +0 -73
  91. package/style.css +0 -29
  92. package/tableQueryParamsToHasuraClauses.js +0 -113
  93. package/tagUtils.js +0 -45
  94. package/tgFormValues.js +0 -35
  95. package/tg_modalState.js +0 -47
  96. package/throwFormError.js +0 -16
  97. package/toastr.js +0 -148
  98. package/tryToMatchSchemas.js +0 -264
  99. package/typeToCommonType.js +0 -6
  100. package/useDeepEqualMemo.js +0 -15
  101. package/useDialog.js +0 -63
  102. package/useStableReference.js +0 -9
  103. package/useTableEntities.js +0 -38
  104. package/useTraceUpdate.js +0 -19
  105. package/utils.js +0 -37
  106. package/validateTableWideErrors.js +0 -160
  107. package/viewColumn.js +0 -97
  108. package/withField.js +0 -20
  109. package/withFields.js +0 -11
  110. package/withLocalStorage.js +0 -11
  111. package/withSelectTableRecords.js +0 -43
  112. package/withSelectedEntities.js +0 -65
  113. package/withStore.js +0 -10
  114. package/withTableParams.js +0 -288
  115. package/wrapDialog.js +0 -116
package/adHoc.js DELETED
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { compose } from "recompose";
3
-
4
- //adHoc allows you to add dynamic HOCs to a component
5
- export default func => WrappedComponent => props => {
6
- const calledFunc = func(props);
7
- const composeArgs = Array.isArray(calledFunc) ? calledFunc : [calledFunc];
8
- const ComposedAndWrapped = compose(...composeArgs)(WrappedComponent);
9
- return <ComposedAndWrapped {...props} />;
10
- };
package/autoTooltip.js DELETED
@@ -1,201 +0,0 @@
1
- import tippy, { followCursor } from "tippy.js";
2
- import "tippy.js/dist/tippy.css";
3
-
4
- let isDragging = false;
5
- let canSetDragging = false;
6
- document.addEventListener("mousedown", () => {
7
- canSetDragging = true;
8
- isDragging = false;
9
- });
10
- document.addEventListener("mousemove", () => {
11
- if (canSetDragging) {
12
- isDragging = true;
13
- }
14
- });
15
- document.addEventListener("mouseup", () => {
16
- canSetDragging = false;
17
- isDragging = false;
18
- });
19
-
20
- let tippys = [];
21
- let recentlyHidden = false;
22
- let clearMe;
23
- (function () {
24
- let lastMouseOverElement = null;
25
- document.addEventListener("mouseover", function (event) {
26
- const element = event.target;
27
-
28
- if (element instanceof Element && element !== lastMouseOverElement) {
29
- lastMouseOverElement = element;
30
-
31
- const id = "tippyEllipsizedEl";
32
- // eslint-disable-next-line no-inner-declarations
33
- function clearOldTippys(maybeInst) {
34
- //clear old tippys
35
- tippys = tippys.filter(t => {
36
- const areeq = maybeInst?.reference?.isEqualNode(t.reference);
37
- if (!areeq) {
38
- t.destroy();
39
- return false;
40
- }
41
- return true;
42
- });
43
- }
44
- let innerRun = false;
45
- const inner = (
46
- content,
47
- el,
48
- { dataTitle, dataAvoid, dataAvoidBackup }
49
- ) => {
50
- innerRun = true;
51
- document.querySelectorAll(`.${id}`).forEach(elem => {
52
- elem.classList.remove(id);
53
- });
54
-
55
- el.classList.add(id);
56
- const inst = tippy(`.${id}`, {
57
- theme: "teselagen",
58
- plugins: [followCursor],
59
- content,
60
- delay:
61
- dataTitle && !recentlyHidden
62
- ? [1300, 1300]
63
- : dataTitle
64
- ? [150, 150]
65
- : [0, 0],
66
- allowHTML: true,
67
- ...(dataTitle && {
68
- followCursor: dataTitle ? "initial" : false
69
- }),
70
- onHidden() {
71
- recentlyHidden = true;
72
- clearMe && clearTimeout(clearMe);
73
- clearMe = setTimeout(() => {
74
- if (tippys.length === 0) recentlyHidden = false;
75
- }, 700);
76
- },
77
- ...(dataAvoid && {
78
- popperOptions: {
79
- modifiers: [
80
- {
81
- name: "myModifier",
82
- enabled: true,
83
- phase: "beforeWrite",
84
- requires: ["computeStyles"],
85
- requiresIfExists: ["offset"],
86
- fn({ state }) {
87
- // console.log(`state:`, state);
88
- // state.styles.popper.bottom = 20 + "px";
89
- const customBoundary =
90
- document.querySelector(dataAvoid) ||
91
- document.querySelector(dataAvoidBackup);
92
-
93
- if (!customBoundary) return;
94
- const a = customBoundary.getBoundingClientRect();
95
- // console.log(
96
- // `state.rects.reference.y:`,
97
- // state.rects.reference.y
98
- // );
99
- // console.log(`a.top:`, a.top);
100
-
101
- if (a.top < state.rects.reference.y) {
102
- const b = Math.abs(
103
- Math.abs(a.top - state.rects.reference.y) - 10
104
- );
105
- state.styles.popper.bottom = b + "px";
106
- }
107
-
108
- // const overflow = detectOverflow(state, {
109
- // boundary: customBoundary,
110
- // altBoundary: true
111
- // });
112
- // console.log(`overflow:`, overflow);
113
- // if (overflow.bottom > 0) {
114
- // const a = Math.abs(overflow.bottom);
115
- // state.styles.popper.bottom = a + "px";
116
- // }
117
- }
118
- }
119
- ]
120
- }
121
- })
122
- });
123
-
124
- if (dataTitle) {
125
- inst[0]?.popper?.classList.add("isDataTitle");
126
- }
127
- clearOldTippys(...inst);
128
-
129
- if (!dataTitle) {
130
- inst.forEach(i => {
131
- i.show();
132
- });
133
- }
134
-
135
- tippys = [...tippys, ...inst];
136
- if (content === el.getAttribute("title")) {
137
- el.removeAttribute("title");
138
- }
139
- };
140
- const levels = 6;
141
- let dataTip;
142
- let dataTipStop;
143
- let el = element;
144
- for (let index = 0; index < levels; index++) {
145
- if (!el) continue;
146
-
147
- const style = window.getComputedStyle(el);
148
- const whiteSpace = style.getPropertyValue("white-space");
149
- const textOverflow = style.getPropertyValue("text-overflow");
150
- const dataTitle = el.getAttribute("data-title");
151
- const dataAvoid = el.getAttribute("data-avoid");
152
- const dataAvoidBackup = el.getAttribute("data-avoid-backup");
153
- dataTip = el.getAttribute("data-tip") || dataTitle;
154
- const isEllipsized =
155
- whiteSpace === "nowrap" && textOverflow === "ellipsis";
156
-
157
- const opts = {
158
- dataTitle,
159
- dataAvoid,
160
- dataAvoidBackup
161
- };
162
- if (
163
- dataTip &&
164
- !document.body.classList.contains("drag-active") &&
165
- !isDragging
166
- ) {
167
- if (dataTipStop) break;
168
-
169
- inner(dataTip, el, opts);
170
- break;
171
- } else if (
172
- isEllipsized &&
173
- el.offsetWidth < el.scrollWidth - 4 && //the -4 is adding a teeny bit of tolerance to fix issues with the column headers getting tooltips even when fully visible
174
- !el.classList.contains("no-data-tip") &&
175
- !parentIncludesNoChildDataTip(el, 0) &&
176
- !document.body.classList.contains("drag-active") &&
177
- el.textContent &&
178
- el.textContent?.trim?.().length !== 0
179
- ) {
180
- inner(el.textContent, el, opts);
181
- break;
182
- } else if (isEllipsized && el.offsetWidth >= el.scrollWidth) {
183
- // break; //tnr: i don't think we need this..
184
- }
185
- el = el.parentElement;
186
- }
187
-
188
- if (!innerRun) {
189
- clearOldTippys();
190
- }
191
- }
192
- });
193
- })();
194
-
195
- function parentIncludesNoChildDataTip(el, count) {
196
- if (count > 4) return false;
197
- if (!el) return false;
198
- // if attr data-no-child-data-tip is preset on the element, then we don't want to show a tooltip on any of its children
199
- if (el.getAttribute("data-no-child-data-tip")) return true;
200
- return parentIncludesNoChildDataTip(el.parentElement, count + 1);
201
- }
@@ -1,14 +0,0 @@
1
- export default function basicHandleActionsWithFullState(
2
- handlers,
3
- defaultState
4
- ) {
5
- return (state = defaultState, action, fullState) => {
6
- const { type } = action;
7
- const handler = handlers[type];
8
- if (handler) {
9
- return handler(state, action, fullState);
10
- } else {
11
- return state;
12
- }
13
- };
14
- }
package/browserUtils.js DELETED
@@ -1,3 +0,0 @@
1
- export const isSafari = /^((?!chrome|android).)*safari/i.test(
2
- navigator.userAgent
3
- );
@@ -1,14 +0,0 @@
1
- export default function combineReducers(reducers = {}) {
2
- const reducerKeys = Object.keys(reducers);
3
- return function combination(state = {}, action, fullState) {
4
- let hasChanged = false;
5
- const nextState = {};
6
- fullState = fullState || state;
7
- for (let i = 0; i < reducerKeys.length; i++) {
8
- const key = reducerKeys[i];
9
- nextState[key] = reducers[key](state[key], action, fullState);
10
- hasChanged = hasChanged || nextState[key] !== state[key];
11
- }
12
- return hasChanged ? nextState : state;
13
- };
14
- }
@@ -1,82 +0,0 @@
1
- import React from "react";
2
- import { Tooltip, Checkbox, Button, Switch } from "@blueprintjs/core";
3
-
4
- export const withCommand =
5
- mappings =>
6
- WrappedComponent =>
7
- ({ cmd, cmdOptions = {}, ...props }) => {
8
- const mappedProps = {};
9
- Object.keys(mappings).forEach(k => {
10
- mappedProps[k] =
11
- mappings[k] === "execute"
12
- ? event => cmd.execute({ event })
13
- : typeof mappings[k] === "function"
14
- ? mappings[k](cmd, props)
15
- : cmd[mappings[k]];
16
- });
17
-
18
- let out = <WrappedComponent {...mappedProps} {...props} />;
19
- const tooltip =
20
- cmd.tooltip || (typeof cmd.isDisabled === "string" && cmd.isDisabled);
21
- if (tooltip && !cmdOptions.ignoreTooltip) {
22
- out = <Tooltip content={tooltip}>{out}</Tooltip>;
23
- }
24
-
25
- return cmd.isHidden && !cmdOptions.ignoreHidden ? null : out;
26
- };
27
-
28
- export const CmdCheckbox = withCommand({
29
- onChange: "execute",
30
- label: (cmd, props) =>
31
- props.name ||
32
- (props.prefix && (
33
- <React.Fragment>
34
- {props.prefix}
35
- {cmd.name}
36
- </React.Fragment>
37
- )) ||
38
- cmd.name,
39
- disabled: "isDisabled",
40
- checked: "isActive"
41
- })(Checkbox);
42
-
43
- export const CmdSwitch = withCommand({
44
- onChange: "execute",
45
- label: (cmd, props) =>
46
- props.name ||
47
- (props.prefix && (
48
- <React.Fragment>
49
- {props.prefix}
50
- {cmd.name}
51
- </React.Fragment>
52
- )) ||
53
- cmd.name,
54
- disabled: "isDisabled",
55
- checked: "isActive"
56
- })(Switch);
57
-
58
- const Div = ({ onChange, children }) => {
59
- return <div onClick={onChange}>{children}</div>;
60
- };
61
-
62
- export const CmdDiv = withCommand({
63
- onChange: "execute",
64
- children: (cmd, props) =>
65
- props.name ||
66
- (props.prefix && (
67
- <React.Fragment>
68
- {props.prefix}
69
- {cmd.name}
70
- </React.Fragment>
71
- )) ||
72
- cmd.name,
73
- disabled: "isDisabled",
74
- checked: "isActive"
75
- })(Div);
76
-
77
- export const CmdButton = withCommand({
78
- onClick: "execute",
79
- text: cmd => (cmd.isActive === false && cmd.inactiveName) || cmd.name,
80
- icon: "icon",
81
- disabled: "isDisabled"
82
- })(Button);
package/commandUtils.js DELETED
@@ -1,112 +0,0 @@
1
- import { startCase } from "lodash-es";
2
-
3
- // Generic factory function to create command objects.
4
- // TODO add documentation
5
- export function genericCommandFactory(config) {
6
- const out = {};
7
- // eslint-disable-next-line no-unused-vars
8
- for (const cmdId in config.commandDefs) {
9
- const def = config.commandDefs[cmdId];
10
- const command = { id: cmdId };
11
- command.execute = (...execArgs) => {
12
- config.handleReturn(
13
- cmdId,
14
- def.handler &&
15
- def.handler.apply(command, config.getArguments(cmdId, execArgs))
16
- );
17
- };
18
-
19
- const properties = [
20
- "icon",
21
- "name",
22
- "component",
23
- "shortName",
24
- "description",
25
- "hotkey",
26
- "hotkeyProps",
27
- "isDisabled",
28
- "submenu",
29
- "isActive",
30
- "isHidden",
31
- "tooltip",
32
- "inactiveIcon",
33
- "inactiveName"
34
- ];
35
-
36
- properties.forEach(prop => {
37
- if (def[prop] !== undefined) {
38
- if (typeof def[prop] === "function") {
39
- Object.defineProperty(command, prop, {
40
- get: () => {
41
- return def[prop].apply(command, config.getArguments(cmdId, []));
42
- }
43
- });
44
- } else {
45
- command[prop] = def[prop];
46
- }
47
- }
48
- });
49
-
50
- // If no name was specified in the definition, let's try to give some
51
- // auto-generated names
52
- if (!def.name) {
53
- command.name = startCase(cmdId);
54
- if (def.toggle && cmdId.startsWith("toggle")) {
55
- command.name = startCase(cmdId.replace("toggle", def.toggle[0] || ""));
56
- command.inactiveName = startCase(
57
- cmdId.replace("toggle", def.toggle[1] || "")
58
- );
59
- command.shortName = startCase(cmdId.replace("toggle", ""));
60
- }
61
- }
62
-
63
- out[cmdId] = command;
64
- }
65
-
66
- return out;
67
- }
68
-
69
- // Extract hotkey props from the given commands or command defs, returning
70
- // a mapping of command ids to hotkey prop objects
71
- export function getCommandHotkeys(commandsOrDefs) {
72
- const hotkeyDefs = {};
73
- Object.keys(commandsOrDefs).forEach(cmdId => {
74
- if (commandsOrDefs[cmdId].hotkey) {
75
- hotkeyDefs[cmdId] = {
76
- combo: commandsOrDefs[cmdId].hotkey,
77
- label: commandsOrDefs[cmdId].name || startCase(cmdId),
78
- ...commandsOrDefs[cmdId].hotkeyProps
79
- };
80
- }
81
- });
82
-
83
- return hotkeyDefs;
84
- }
85
-
86
- // Extract handler functions from the given commands, returning a mapping of
87
- // command ids to handlers (directly - no checks added).
88
- export function getCommandHandlers(commands) {
89
- const handlers = {};
90
- Object.keys(commands).forEach(cmdId => {
91
- handlers[cmdId] = commands[cmdId].execute;
92
- });
93
-
94
- return handlers;
95
- }
96
-
97
- // Get hotkey handler functions for the given commands, returning a mapping of
98
- // command ids to hotkey handlers.
99
- export function getCommandHotkeyHandlers(commands) {
100
- const handlers = {};
101
- Object.keys(commands).forEach(cmdId => {
102
- if (commands[cmdId].hotkey) {
103
- handlers[cmdId] = event => {
104
- if (!commands[cmdId].isDisabled && !commands[cmdId].isHidden) {
105
- commands[cmdId].execute({ event, viaHotkey: true });
106
- }
107
- };
108
- }
109
- });
110
-
111
- return handlers;
112
- }
package/constants.js DELETED
@@ -1 +0,0 @@
1
- export const SAFE_UPSERT_PAGE_SIZE = 50;
package/convertSchema.js DELETED
@@ -1,69 +0,0 @@
1
- import { camelCase } from "lodash-es";
2
- import { startCase, keyBy, map } from "lodash-es";
3
-
4
- function convertSchema(schema) {
5
- let schemaToUse = schema;
6
- if (!schemaToUse.fields && Array.isArray(schema)) {
7
- schemaToUse = {
8
- fields: schema
9
- };
10
- }
11
- schemaToUse = {
12
- ...schemaToUse
13
- };
14
- schemaToUse.fields = schemaToUse.fields.map((field, i) => {
15
- let fieldToUse = field;
16
- if (typeof field === "string") {
17
- fieldToUse = {
18
- displayName: startCase(camelCase(field)),
19
- path: field,
20
- type: "string"
21
- };
22
- } else if (!field.type) {
23
- fieldToUse = {
24
- ...field,
25
- type: "string"
26
- };
27
- }
28
- if (!fieldToUse.displayName) {
29
- fieldToUse = {
30
- ...fieldToUse,
31
- displayName: startCase(camelCase(fieldToUse.path))
32
- };
33
- }
34
- // paths are needed for column resizing
35
- if (!fieldToUse.path) {
36
- fieldToUse = {
37
- ...fieldToUse,
38
- filterDisabled: true,
39
- sortDisabled: true,
40
- path: "fake-path" + i
41
- };
42
- }
43
- return fieldToUse;
44
- });
45
- return schemaToUse;
46
- }
47
-
48
- export function mergeSchemas(_originalSchema, _overrideSchema) {
49
- const originalSchema = convertSchema(_originalSchema);
50
- const overrideSchema = convertSchema(_overrideSchema);
51
-
52
- const overridesByKey = keyBy(overrideSchema.fields, "path");
53
- return {
54
- ...originalSchema,
55
- ...overrideSchema,
56
- fields: originalSchema.fields
57
- .map(f => {
58
- const override = overridesByKey[f.path];
59
- if (override) {
60
- delete overridesByKey[f.path];
61
- return override;
62
- }
63
- return f;
64
- })
65
- .concat(map(overridesByKey))
66
- };
67
- }
68
-
69
- export default convertSchema;