sliftutils 0.18.0 → 0.20.0
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/index.d.ts +1 -0
- package/package.json +1 -1
- package/render-utils/Table.tsx +3 -2
- package/storage/FileFolderAPI.d.ts +1 -0
- package/storage/FileFolderAPI.tsx +11 -4
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/render-utils/Table.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { formatValue, JSXFormatter, toSpaceCase } from "./GenericFormat";
|
|
|
4
4
|
import { observer } from "./observer";
|
|
5
5
|
import { canHaveChildren } from "socket-function/src/types";
|
|
6
6
|
import { showFullscreenModal } from "./FullscreenModal";
|
|
7
|
+
import { observable } from "mobx";
|
|
7
8
|
|
|
8
9
|
// Null means the column is removed
|
|
9
10
|
export type ColumnType<T = unknown, Row extends RowType = RowType> = undefined | null | {
|
|
@@ -35,9 +36,9 @@ export class Table<RowT extends RowType> extends preact.Component<TableType<RowT
|
|
|
35
36
|
|
|
36
37
|
getRowFields?: (row: RowT) => preact.JSX.HTMLAttributes<HTMLTableRowElement>;
|
|
37
38
|
}> {
|
|
38
|
-
state = {
|
|
39
|
+
state = observable({
|
|
39
40
|
limit: this.props.initialLimit || 100,
|
|
40
|
-
};
|
|
41
|
+
});
|
|
41
42
|
render() {
|
|
42
43
|
let { columns, rows, excludeEmptyColumns } = this.props;
|
|
43
44
|
|
|
@@ -46,7 +46,14 @@ let displayData = observable({
|
|
|
46
46
|
ui: undefined as undefined | preact.ComponentChildren,
|
|
47
47
|
}, undefined, { deep: false });
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
let fileAPIKey = "";
|
|
50
|
+
function getFileAPIKey() {
|
|
51
|
+
if (!fileAPIKey) throw new Error("Must call setFileAPIKey before using file system. Just pass any key. This prevents reusing the file system api that other development apps might be using.");
|
|
52
|
+
return fileAPIKey;
|
|
53
|
+
}
|
|
54
|
+
export function setFileAPIKey(key: string) {
|
|
55
|
+
fileAPIKey = key;
|
|
56
|
+
}
|
|
50
57
|
|
|
51
58
|
@observer
|
|
52
59
|
class DirectoryPrompter extends preact.Component {
|
|
@@ -206,7 +213,7 @@ export const getDirectoryHandle = lazy(async function getDirectoryHandle(): Prom
|
|
|
206
213
|
|
|
207
214
|
let handle: DirectoryWrapper | undefined;
|
|
208
215
|
|
|
209
|
-
let storedId = localStorage.getItem(
|
|
216
|
+
let storedId = localStorage.getItem(getFileAPIKey());
|
|
210
217
|
if (storedId) {
|
|
211
218
|
let doneLoad = false;
|
|
212
219
|
setTimeout(() => {
|
|
@@ -234,7 +241,7 @@ export const getDirectoryHandle = lazy(async function getDirectoryHandle(): Prom
|
|
|
234
241
|
const handle = await window.showDirectoryPicker();
|
|
235
242
|
await handle.requestPermission({ mode: "readwrite" });
|
|
236
243
|
let storedId = await storeFileSystemPointer({ mode: "readwrite", handle });
|
|
237
|
-
localStorage.setItem(
|
|
244
|
+
localStorage.setItem(getFileAPIKey(), storedId);
|
|
238
245
|
fileCallback(handle as any);
|
|
239
246
|
}}
|
|
240
247
|
>
|
|
@@ -265,7 +272,7 @@ export const getFileStorage = lazy(async function getFileStorage(): Promise<File
|
|
|
265
272
|
return wrapHandle(handle);
|
|
266
273
|
});
|
|
267
274
|
export function resetStorageLocation() {
|
|
268
|
-
localStorage.removeItem(
|
|
275
|
+
localStorage.removeItem(getFileAPIKey());
|
|
269
276
|
window.location.reload();
|
|
270
277
|
}
|
|
271
278
|
|