@teselagen/ui 0.9.8 → 0.10.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.
- package/DataTable/index.d.ts +3 -3
- package/index.cjs.js +21120 -21239
- package/index.es.js +21028 -21147
- package/package.json +2 -1
- package/src/DataTable/PagingTool.js +2 -2
- package/src/DataTable/RenderCell.js +8 -4
- package/src/DataTable/index.js +1210 -224
- package/src/DataTable/utils/useTableEntities.js +3 -2
- package/src/DataTable/utils/withTableParams.js +8 -7
- package/src/UploadCsvWizard.js +7 -5
- package/src/utils/hooks/useDeepEqualMemo.js +2 -2
- package/src/utils/isEqualIgnoreFunctions.js +23 -0
- package/src/utils/pureNoFunc.js +4 -20
- package/utils/isEqualIgnoreFunctions.d.ts +1 -0
- package/DataTable/EditabelCell.d.ts +0 -7
- package/DataTable/ReactTable.d.ts +0 -78
- package/DataTable/defaultProps.d.ts +0 -43
- package/DataTable/utils/computePresets.d.ts +0 -1
- package/DataTable/utils/types/Entity.d.ts +0 -9
- package/DataTable/utils/types/Field.d.ts +0 -4
- package/DataTable/utils/types/OrderBy.d.ts +0 -11
- package/DataTable/utils/types/Schema.d.ts +0 -4
- package/DataTable/utils/useDeepEqualMemo.d.ts +0 -1
- package/DataTable/utils/useHotKeysWrapper.d.ts +0 -29
- package/DataTable/utils/useTableParams.d.ts +0 -49
- package/src/DataTable/Columns.jsx +0 -945
- package/src/DataTable/EditabelCell.js +0 -44
- package/src/DataTable/EditabelCell.jsx +0 -44
- package/src/DataTable/ReactTable.js +0 -738
- package/src/DataTable/RenderCell.jsx +0 -191
- package/src/DataTable/defaultProps.js +0 -45
- package/src/DataTable/utils/computePresets.js +0 -42
- package/src/DataTable/utils/convertSchema.ts +0 -79
- package/src/DataTable/utils/formatPasteData.ts +0 -34
- package/src/DataTable/utils/getAllRows.ts +0 -11
- package/src/DataTable/utils/getCellCopyText.ts +0 -7
- package/src/DataTable/utils/getCellInfo.ts +0 -46
- package/src/DataTable/utils/getFieldPathToField.ts +0 -10
- package/src/DataTable/utils/getIdOrCodeOrIndex.ts +0 -14
- package/src/DataTable/utils/getLastSelectedEntity.ts +0 -15
- package/src/DataTable/utils/getNewEntToSelect.ts +0 -32
- package/src/DataTable/utils/initializeHasuraWhereAndFilter.ts +0 -35
- package/src/DataTable/utils/isBottomRightCornerOfRectangle.ts +0 -27
- package/src/DataTable/utils/isEntityClean.ts +0 -15
- package/src/DataTable/utils/primarySelectedValue.ts +0 -1
- package/src/DataTable/utils/removeCleanRows.ts +0 -26
- package/src/DataTable/utils/selection.ts +0 -11
- package/src/DataTable/utils/types/Entity.ts +0 -13
- package/src/DataTable/utils/types/Field.ts +0 -4
- package/src/DataTable/utils/types/OrderBy.ts +0 -15
- package/src/DataTable/utils/types/Schema.ts +0 -5
- package/src/DataTable/utils/useDeepEqualMemo.js +0 -10
- package/src/DataTable/utils/useHotKeysWrapper.js +0 -395
- package/src/DataTable/utils/useTableEntities.ts +0 -60
- package/src/DataTable/utils/useTableParams.js +0 -361
- package/src/DataTable/utils/utils.ts +0 -39
- package/src/Timeline/TimelineEvent.tsx +0 -36
- package/src/Timeline/index.tsx +0 -21
- package/src/utils/browserUtils.ts +0 -3
- package/src/utils/determineBlackOrWhiteTextColor.ts +0 -11
- package/src/utils/getTextFromEl.ts +0 -45
- package/src/utils/handlerHelpers.ts +0 -32
- package/src/utils/hooks/index.ts +0 -1
- package/src/utils/hooks/useDeepEqualMemo.ts +0 -10
- package/src/utils/hooks/useStableReference.ts +0 -9
- package/src/utils/hotkeyUtils.tsx +0 -155
- package/src/utils/isBeingCalledExcessively.ts +0 -37
- package/style.css +0 -10537
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { useHotkeys } from "@blueprintjs/core";
|
|
3
|
-
import { startCase } from "lodash-es";
|
|
4
|
-
|
|
5
|
-
type Out = {
|
|
6
|
-
combo: string;
|
|
7
|
-
label: string;
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
global?: boolean;
|
|
10
|
-
};
|
|
11
|
-
type Hotkeys = {
|
|
12
|
-
[key: string]: string | [string, string, object] | Out;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// This has been mostly superseded by blueprint's KeyCombo component, but may
|
|
16
|
-
// still be useful for cases where we need plain text
|
|
17
|
-
export function comboToLabel(
|
|
18
|
-
def: string | { combo: string },
|
|
19
|
-
useSymbols = true
|
|
20
|
-
) {
|
|
21
|
-
const combo = typeof def === "string" ? def : def.combo;
|
|
22
|
-
|
|
23
|
-
if (useSymbols) {
|
|
24
|
-
let parts = combo.replace("++", "+plus").split("+");
|
|
25
|
-
parts = parts.map(p =>
|
|
26
|
-
p in symbols ? symbols[p as keyof typeof symbols] : startCase(p) || p
|
|
27
|
-
);
|
|
28
|
-
return parts.join("");
|
|
29
|
-
} else {
|
|
30
|
-
return combo
|
|
31
|
-
.split("+")
|
|
32
|
-
.map(p => startCase(p) || p)
|
|
33
|
-
.join(" + ")
|
|
34
|
-
.replace("Meta", isMac ? "Cmd" : "Ctrl")
|
|
35
|
-
.replace("Mod", isMac ? "Cmd" : "Ctrl")
|
|
36
|
-
.replace("Alt", isMac ? "Option" : "Alt");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// HOF to get hotkey combos by id
|
|
41
|
-
export const hotkeysById =
|
|
42
|
-
(hotkeys: Hotkeys, mode = "raw") =>
|
|
43
|
-
(id: string) => {
|
|
44
|
-
const def = getHotkeyProps(hotkeys[id]);
|
|
45
|
-
return (
|
|
46
|
-
def &&
|
|
47
|
-
(mode === "raw" ? def.combo : comboToLabel(def.combo, mode === "symbols"))
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Translate shorthand array if needed
|
|
52
|
-
export const getHotkeyProps = (
|
|
53
|
-
def: string | [string, string, object] | Out,
|
|
54
|
-
id?: string
|
|
55
|
-
) => {
|
|
56
|
-
let out: Out;
|
|
57
|
-
if (typeof def === "string") {
|
|
58
|
-
out = { combo: def, label: def };
|
|
59
|
-
} else if (def instanceof Array) {
|
|
60
|
-
out = { combo: def[0], label: def[1], ...(def[2] || {}) };
|
|
61
|
-
} else {
|
|
62
|
-
out = def;
|
|
63
|
-
}
|
|
64
|
-
out.label = out.label || startCase(id);
|
|
65
|
-
return out;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/*
|
|
69
|
-
* HOC to add hotkey support to components. Use this instead of blueprint's one.
|
|
70
|
-
*
|
|
71
|
-
* Arguments:
|
|
72
|
-
* - hotkeySpec: either a named hotkey section previously registered, or an
|
|
73
|
-
* object mapping command ids to hotkey definitions, where each hotkey can
|
|
74
|
-
* be either:
|
|
75
|
-
* - a string consisting in the key combo (e.g. 'ctrl+shift+x')
|
|
76
|
-
* - an array holding the combo, label, and an object with any other props
|
|
77
|
-
* - an object holding all props
|
|
78
|
-
* - handlers: an object mapping command ids to handler functions
|
|
79
|
-
* - options: an object that may specify the follownig options:
|
|
80
|
-
* - functional: boolean indicating if the wrapped component will be a
|
|
81
|
-
* functional stateless component instead of a class-based one
|
|
82
|
-
*
|
|
83
|
-
* Returns a function that can be invoked with a component class, or a
|
|
84
|
-
* stateless component function (if specified in the options) and returns
|
|
85
|
-
* the decorated class. It may also be invoked without arguments to generate a
|
|
86
|
-
* dummy ad-hoc component with no output.
|
|
87
|
-
*
|
|
88
|
-
*/
|
|
89
|
-
export const withHotkeys = (
|
|
90
|
-
hotkeys: Hotkeys,
|
|
91
|
-
handlers: { [key: string]: (e: KeyboardEvent) => void }
|
|
92
|
-
) => {
|
|
93
|
-
return ({ children }: { children?: React.ReactElement } = {}) => {
|
|
94
|
-
const memoedHotkeys = useMemo(
|
|
95
|
-
() =>
|
|
96
|
-
Object.keys(hotkeys).map(id => {
|
|
97
|
-
const { ...props } = getHotkeyProps(hotkeys[id], id);
|
|
98
|
-
return {
|
|
99
|
-
key: id,
|
|
100
|
-
global: props.global !== false,
|
|
101
|
-
onKeyDown: function (e: KeyboardEvent) {
|
|
102
|
-
return handlers[id](e);
|
|
103
|
-
},
|
|
104
|
-
...props
|
|
105
|
-
};
|
|
106
|
-
}),
|
|
107
|
-
[]
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const { handleKeyDown, handleKeyUp } = useHotkeys(memoedHotkeys);
|
|
111
|
-
const newProps = {
|
|
112
|
-
tabIndex: 0,
|
|
113
|
-
onKeyDown: handleKeyDown,
|
|
114
|
-
onKeyUp: handleKeyUp
|
|
115
|
-
};
|
|
116
|
-
return children ? ( //tnr: if children are passed, we'll clone them with the new props
|
|
117
|
-
React.cloneElement(children, newProps)
|
|
118
|
-
) : (
|
|
119
|
-
//if not, then we'll return a div that can be used
|
|
120
|
-
<div className="hotkeyHandler" {...newProps} />
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const isMac = navigator.userAgent.includes("Mac OS X");
|
|
126
|
-
|
|
127
|
-
const cmd = "⌘";
|
|
128
|
-
const meta = "⌘";
|
|
129
|
-
const ctrl = "⌃";
|
|
130
|
-
|
|
131
|
-
// TODO maybe avoid using symbols by default when not on Mac?
|
|
132
|
-
// Anyway, alternative 'Key + Key' description is provided as well
|
|
133
|
-
const symbols = {
|
|
134
|
-
cmd,
|
|
135
|
-
meta,
|
|
136
|
-
ctrl,
|
|
137
|
-
alt: "⌥",
|
|
138
|
-
shift: "⇧",
|
|
139
|
-
esc: "␛", //'⎋',
|
|
140
|
-
enter: "⏎",
|
|
141
|
-
backspace: "⌫",
|
|
142
|
-
plus: "+",
|
|
143
|
-
tab: "⇥",
|
|
144
|
-
space: "␣",
|
|
145
|
-
capslock: "⇪",
|
|
146
|
-
pageup: "⇞",
|
|
147
|
-
pagedown: "⇟",
|
|
148
|
-
home: "↖",
|
|
149
|
-
end: "↘",
|
|
150
|
-
left: "←",
|
|
151
|
-
right: "→",
|
|
152
|
-
up: "↑",
|
|
153
|
-
down: "↓",
|
|
154
|
-
mod: isMac ? cmd : ctrl
|
|
155
|
-
} as const;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const keyCount: { [key: string]: number | null } = {};
|
|
2
|
-
const timeout: { [key: string]: NodeJS.Timeout | null } = {};
|
|
3
|
-
|
|
4
|
-
// if this function is hit more than 20 times in a row in 2 seconds with the same uniqName then throw an error
|
|
5
|
-
export const isBeingCalledExcessively = ({
|
|
6
|
-
uniqName
|
|
7
|
-
}: {
|
|
8
|
-
uniqName: string;
|
|
9
|
-
}) => {
|
|
10
|
-
if (process.env["NODE_ENV"] !== "development") {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (!uniqName) {
|
|
14
|
-
throw new Error("uniqName is required");
|
|
15
|
-
}
|
|
16
|
-
// Initialize the count if it doesn't exist
|
|
17
|
-
keyCount[uniqName] = keyCount[uniqName] || 0;
|
|
18
|
-
(keyCount[uniqName] as number)++;
|
|
19
|
-
|
|
20
|
-
// Only set the timeout if it doesn't exist already to ensure it runs exactly once every 2 seconds
|
|
21
|
-
if (!timeout[uniqName]) {
|
|
22
|
-
timeout[uniqName] = setTimeout(() => {
|
|
23
|
-
keyCount[uniqName] = 0;
|
|
24
|
-
timeout[uniqName] = null;
|
|
25
|
-
}, 2000);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if ((keyCount[uniqName] as number) > 20) {
|
|
29
|
-
keyCount[uniqName] = 0;
|
|
30
|
-
// Also clear the timeout when throwing an error
|
|
31
|
-
if (timeout[uniqName]) {
|
|
32
|
-
clearTimeout(timeout[uniqName]);
|
|
33
|
-
timeout[uniqName] = null;
|
|
34
|
-
}
|
|
35
|
-
throw new Error(`isBeingCalledExcessively: ${uniqName}`);
|
|
36
|
-
}
|
|
37
|
-
};
|