@gopherium/godmin 0.24.0 → 0.24.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.
- package/README.md +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/unsaved-text.d.ts +14 -0
- package/dist/unsaved-text.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ two lines do for you.
|
|
|
52
52
|
|
|
53
53
|
| Entry point | Contents |
|
|
54
54
|
| --- | --- |
|
|
55
|
-
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `MenuCount`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `viewNarrows`, `offeredView`, `offeredSize`, `sizedView`, `useMediaQuery`, `useTokenDocument`, the breakpoints `RAIL_BREAKPOINT`, `EDGE_BREAKPOINT`, `DENSE_BREAKPOINT`, `SHEET_BREAKPOINT`, `TITLE_BREAKPOINT` and `SMALL_VIEWPORT`, `SUPPORTED_WPDS` |
|
|
55
|
+
| `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `PageTabs`, `PageTab`, `SectionTitle`, `InitialsAvatar`, `NavScreen`, `MenuCount`, `ErrorNotice`, `LoadMore`, `LogList`, `LogItem`, `LogTime`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `RepeatRows`, `RowControls`, `useRowKeys`, `keyFromLabel`, `listChromeCatalogFor`, `LIST_CHROME_DOMAIN`, `ListEmpty`, `ConfirmBody`, `RenameBody`, `FormBody`, `FileButton`, `useServerPaging`, `pageWindow`, `paginationOf`, `runEach`, `bulkNotes`, `useListRun`, `useBulkRun`, `RunConfirm`, `useUnsavedText`, `markLatest`, `viewNarrows`, `offeredView`, `offeredSize`, `sizedView`, `useMediaQuery`, `useTokenDocument`, the breakpoints `RAIL_BREAKPOINT`, `EDGE_BREAKPOINT`, `DENSE_BREAKPOINT`, `SHEET_BREAKPOINT`, `TITLE_BREAKPOINT` and `SMALL_VIEWPORT`, `SUPPORTED_WPDS` |
|
|
56
56
|
| `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
|
|
57
57
|
| `@gopherium/godmin/dates` | `startListDates`, `listDate`, the only entry that loads `@wordpress/date` |
|
|
58
58
|
| `@gopherium/godmin/dialogs` | `ConfirmDialog`, `FormDialog`, the only entry that loads `@wordpress/components`. Load `@wordpress/components/build-style/style.css` once in your app, as DataViews asks |
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export { offeredSize, pageWindow, paginationOf, sizedView, useServerPaging } fro
|
|
|
46
46
|
export type { PagedView, PageWindow, PaginationInfo, ServedPage, ServedSize, ServerPaging } from './server-page.js';
|
|
47
47
|
export { Toaster, useToaster } from './toaster.js';
|
|
48
48
|
export type { ToastAction, ToasterHandle, ToasterProps } from './toaster.js';
|
|
49
|
+
export { markLatest, useUnsavedText } from './unsaved-text.js';
|
|
50
|
+
export type { UnsavedText } from './unsaved-text.js';
|
|
49
51
|
export { useMediaQuery } from './use-media-query.js';
|
|
50
52
|
export { useTokenDocument } from './use-token-document.js';
|
|
51
53
|
export { offeredView, viewNarrows } from './view-guard.js';
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { RepeatRows, RowControls } from './rows.js';
|
|
|
24
24
|
export { RunConfirm } from './run-confirm.js';
|
|
25
25
|
export { offeredSize, pageWindow, paginationOf, sizedView, useServerPaging } from './server-page.js';
|
|
26
26
|
export { Toaster, useToaster } from './toaster.js';
|
|
27
|
+
export { markLatest, useUnsavedText } from './unsaved-text.js';
|
|
27
28
|
export { useMediaQuery } from './use-media-query.js';
|
|
28
29
|
export { useTokenDocument } from './use-token-document.js';
|
|
29
30
|
export { offeredView, viewNarrows } from './view-guard.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** What a failed write left unsaved, by the id of the item it was typed for, the text of one field unless named. */
|
|
2
|
+
export type UnsavedText<Value = string> = Map<string, Value>;
|
|
3
|
+
/**
|
|
4
|
+
* Returns what failed writes left unsaved, the same store for as long as the screen stays.
|
|
5
|
+
* @returns The store a row form takes its first value from when it opens again.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useUnsavedText<Value = string>(): UnsavedText<Value>;
|
|
8
|
+
/**
|
|
9
|
+
* Marks a write as the latest one sent for an item, the only one that may keep its text.
|
|
10
|
+
* @param unsaved - The store the latest writes of the item are marked on.
|
|
11
|
+
* @param id - The item the write goes to.
|
|
12
|
+
* @returns The check telling whether no later write went to the item since.
|
|
13
|
+
*/
|
|
14
|
+
export declare function markLatest(unsaved: UnsavedText<unknown>, id: string): () => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Returns what failed writes left unsaved, the same store for as long as the screen stays.
|
|
5
|
+
* @returns The store a row form takes its first value from when it opens again.
|
|
6
|
+
*/
|
|
7
|
+
export function useUnsavedText() {
|
|
8
|
+
const [held] = useState(() => new Map());
|
|
9
|
+
return held;
|
|
10
|
+
}
|
|
11
|
+
/** The latest write each store sent, by the id of the item it went to. */
|
|
12
|
+
const latestWrites = new WeakMap();
|
|
13
|
+
/**
|
|
14
|
+
* Marks a write as the latest one sent for an item, the only one that may keep its text.
|
|
15
|
+
* @param unsaved - The store the latest writes of the item are marked on.
|
|
16
|
+
* @param id - The item the write goes to.
|
|
17
|
+
* @returns The check telling whether no later write went to the item since.
|
|
18
|
+
*/
|
|
19
|
+
export function markLatest(unsaved, id) {
|
|
20
|
+
const writes = latestWrites.get(unsaved) ?? new Map();
|
|
21
|
+
latestWrites.set(unsaved, writes);
|
|
22
|
+
const write = Symbol(id);
|
|
23
|
+
writes.set(id, write);
|
|
24
|
+
return () => writes.get(id) === write;
|
|
25
|
+
}
|
package/package.json
CHANGED