@peers-app/peers-ui 0.34.14 → 0.34.15
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/dist/apps-home/app-menu.d.ts +1 -2
- package/dist/apps-home/app-menu.js +29 -25
- package/dist/command-palette/command-palette-ui.js +13 -12
- package/dist/components/autocomplete-chips.d.ts +18 -0
- package/dist/components/autocomplete-chips.js +49 -0
- package/dist/components/autocomplete.d.ts +88 -0
- package/dist/components/autocomplete.js +346 -0
- package/dist/components/confirm-button.d.ts +26 -0
- package/dist/components/confirm-button.js +55 -0
- package/dist/components/data-grid/autocomplete.d.ts +1 -31
- package/dist/components/data-grid/autocomplete.js +5 -197
- package/dist/components/empty-state.d.ts +16 -0
- package/dist/components/empty-state.js +16 -0
- package/dist/components/group-switcher.d.ts +3 -3
- package/dist/components/group-switcher.js +22 -17
- package/dist/components/inline-create-form.d.ts +22 -0
- package/dist/components/inline-create-form.js +56 -0
- package/dist/components/list-row.d.ts +33 -0
- package/dist/components/list-row.js +30 -0
- package/dist/components/list-screen.d.ts +31 -3
- package/dist/components/list-screen.js +61 -28
- package/dist/components/markdown-editor/format-bar.js +15 -40
- package/dist/components/markdown-editor/link-plugin.js +38 -9
- package/dist/components/markdown-editor/selection-bar-place.d.ts +37 -0
- package/dist/components/markdown-editor/selection-bar-place.js +107 -0
- package/dist/components/menu-button.d.ts +34 -0
- package/dist/components/menu-button.js +66 -0
- package/dist/components/screen-header.d.ts +35 -0
- package/dist/components/screen-header.js +30 -0
- package/dist/components/search-field.d.ts +22 -0
- package/dist/components/search-field.js +22 -0
- package/dist/components/segmented-control.d.ts +25 -0
- package/dist/components/segmented-control.js +18 -0
- package/dist/components/typeahead.d.ts +9 -0
- package/dist/components/typeahead.js +7 -0
- package/dist/groups/groups-client.d.ts +23 -1
- package/dist/groups/groups-client.js +31 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +14 -1
- package/dist/isolated-screens/config.js +1 -9
- package/dist/isolated-screens/folder-picker-control.d.ts +57 -0
- package/dist/isolated-screens/folder-picker-control.js +217 -0
- package/dist/isolated-screens/folder-picker-host.d.ts +57 -0
- package/dist/isolated-screens/folder-picker-host.js +178 -0
- package/dist/isolated-screens/folder-picker-protocol.d.ts +75 -0
- package/dist/isolated-screens/folder-picker-protocol.js +104 -0
- package/dist/isolated-screens/frame-bridge.js +8 -0
- package/dist/isolated-screens/frame-document.js +2 -1
- package/dist/isolated-screens/frame-microphone.d.ts +55 -0
- package/dist/isolated-screens/frame-microphone.js +265 -0
- package/dist/isolated-screens/frame-permissions.d.ts +19 -0
- package/dist/isolated-screens/frame-permissions.js +32 -0
- package/dist/isolated-screens/frame-protocol.d.ts +26 -0
- package/dist/isolated-screens/frame-protocol.js +9 -0
- package/dist/isolated-screens/frame-pvars.d.ts +27 -0
- package/dist/isolated-screens/frame-pvars.js +101 -14
- package/dist/isolated-screens/global-widgets.d.ts +1 -2
- package/dist/isolated-screens/index.d.ts +2 -0
- package/dist/isolated-screens/index.js +3 -1
- package/dist/isolated-screens/isolated-screen.d.ts +21 -0
- package/dist/isolated-screens/isolated-screen.js +88 -5
- package/dist/isolated-screens/local-folder-picker.d.ts +55 -0
- package/dist/isolated-screens/local-folder-picker.js +143 -0
- package/dist/isolated-screens/microphone-host.d.ts +110 -0
- package/dist/isolated-screens/microphone-host.js +397 -0
- package/dist/isolated-screens/microphone-prompt.d.ts +20 -0
- package/dist/isolated-screens/microphone-prompt.js +60 -0
- package/dist/isolated-screens/piece-frames.js +5 -94
- package/dist/isolated-screens/piece-reach.d.ts +1 -0
- package/dist/isolated-screens/port-channel.d.ts +21 -11
- package/dist/isolated-screens/port-channel.js +15 -5
- package/dist/isolated-screens/slot-rect.d.ts +38 -0
- package/dist/isolated-screens/slot-rect.js +121 -0
- package/dist/isolated-screens/test-ports.d.ts +17 -0
- package/dist/isolated-screens/test-ports.js +25 -3
- package/dist/mentions/mention-chooser.js +1 -1
- package/dist/notifications/notifications-screen.js +1 -1
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -0
- package/dist/screens/data-explorer/data-explorer.js +28 -10
- package/dist/screens/data-explorer/query-executor.d.ts +1 -0
- package/dist/screens/data-explorer/query-executor.js +3 -1
- package/dist/screens/groups/group-list.d.ts +13 -3
- package/dist/screens/groups/group-list.js +88 -11
- package/dist/screens/identity/identity-routes.d.ts +16 -0
- package/dist/screens/identity/identity-routes.js +27 -10
- package/dist/screens/identity/identity-screen.js +4 -1
- package/dist/screens/invites/activity-view.d.ts +3 -1
- package/dist/screens/invites/activity-view.js +7 -3
- package/dist/screens/invites/pending-invites-list.d.ts +8 -4
- package/dist/screens/invites/pending-invites-list.js +44 -45
- package/dist/screens/network-viewer/graph/network-graph-controls.js +3 -3
- package/dist/screens/packages/local-folder-grants-panel.d.ts +2 -0
- package/dist/screens/packages/local-folder-grants-panel.js +1 -1
- package/dist/screens/packages/package-info.js +2 -1
- package/dist/screens/packages/package-list.d.ts +2 -2
- package/dist/screens/packages/package-list.js +89 -105
- package/dist/screens/packages/package-microphone-panel.d.ts +14 -0
- package/dist/screens/packages/package-microphone-panel.js +62 -0
- package/dist/screens/packages/package-runtime-status.d.ts +10 -2
- package/dist/screens/packages/package-runtime-status.js +17 -4
- package/dist/screens/peer-types/peer-type-details.js +3 -2
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -1
- package/dist/screens/peer-types/peer-type-list.js +4 -4
- package/dist/screens/settings/settings-page.js +1 -4
- package/dist/screens/tools/tool-details.js +2 -1
- package/dist/screens/tools/tool-list.d.ts +1 -1
- package/dist/screens/tools/tool-list.js +22 -60
- package/dist/screens/variables/variable-details.js +5 -4
- package/dist/screens/variables/variable-list.d.ts +17 -0
- package/dist/screens/variables/variable-list.js +72 -28
- package/dist/tabs-layout/network-status-details.d.ts +4 -4
- package/dist/tabs-layout/network-status-details.js +6 -5
- package/dist/tabs-layout/network-status-indicator.d.ts +1 -0
- package/dist/tabs-layout/network-status-indicator.js +1 -0
- package/dist/tabs-layout/tab-bar-shortcuts.d.ts +46 -0
- package/dist/tabs-layout/tab-bar-shortcuts.js +140 -0
- package/dist/tabs-layout/tabs-layout.js +11 -9
- package/dist/theme.css +326 -6
- package/dist/ui-contracts/popover-surface.d.ts +3 -0
- package/dist/ui-contracts/popover-surface.js +6 -3
- package/dist/ui-defaults/list-screen.js +10 -4
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A search box: a magnifier at the left and the browser's own clear button. It only searches;
|
|
4
|
+
* a screen's actions (New, Add) are buttons in its header ({@link ScreenHeader}).
|
|
5
|
+
*
|
|
6
|
+
* @param props.value - What's typed.
|
|
7
|
+
* @param props.onChange - Called with the new text as the user types.
|
|
8
|
+
* @param props.placeholder - Its hint, also its name for assistive technology, such as
|
|
9
|
+
* "Search packages".
|
|
10
|
+
* @param props.autoFocus - Focus it when the screen opens.
|
|
11
|
+
* @param props.onKeyDown - Keys typed in the field, for a screen that moves through its results.
|
|
12
|
+
* @param props.className - Classes for the field's wrapper, in place of its bottom margin
|
|
13
|
+
* (`mb-3`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function SearchField(props: {
|
|
16
|
+
value: string;
|
|
17
|
+
onChange: (value: string) => void;
|
|
18
|
+
placeholder: string;
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchField = SearchField;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* A search box: a magnifier at the left and the browser's own clear button. It only searches;
|
|
7
|
+
* a screen's actions (New, Add) are buttons in its header ({@link ScreenHeader}).
|
|
8
|
+
*
|
|
9
|
+
* @param props.value - What's typed.
|
|
10
|
+
* @param props.onChange - Called with the new text as the user types.
|
|
11
|
+
* @param props.placeholder - Its hint, also its name for assistive technology, such as
|
|
12
|
+
* "Search packages".
|
|
13
|
+
* @param props.autoFocus - Focus it when the screen opens.
|
|
14
|
+
* @param props.onKeyDown - Keys typed in the field, for a screen that moves through its results.
|
|
15
|
+
* @param props.className - Classes for the field's wrapper, in place of its bottom margin
|
|
16
|
+
* (`mb-3`).
|
|
17
|
+
*/
|
|
18
|
+
function SearchField(props) {
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `position-relative ${props.className ?? "mb-3"}`, children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-search position-absolute text-body-secondary", style: { left: 12, top: "50%", transform: "translateY(-50%)", pointerEvents: "none" }, "aria-hidden": "true" }), (0, jsx_runtime_1.jsx)("input", { type: "search", className: "form-control ps-5", value: props.value, onChange: (event) => props.onChange(event.target.value), onKeyDown: props.onKeyDown, placeholder: props.placeholder, "aria-label": props.placeholder,
|
|
20
|
+
// biome-ignore lint/a11y/noAutofocus: a list screen's search takes the keyboard on the desktop, as before
|
|
21
|
+
autoFocus: props.autoFocus })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** One choice in a {@link SegmentedControl}. */
|
|
2
|
+
export interface SegmentedChoice<T extends string> {
|
|
3
|
+
/** The value it stands for. */
|
|
4
|
+
value: T;
|
|
5
|
+
/** What it says. */
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Two to four named choices side by side, one of them on: a compact control for a setting with
|
|
10
|
+
* a few values, such as a look ("Simple" or "With shortcuts"). Each choice is a button with
|
|
11
|
+
* `aria-pressed`, inside a group named by `label`.
|
|
12
|
+
*
|
|
13
|
+
* @param props.label - The setting's name, for assistive technology.
|
|
14
|
+
* @param props.choices - The choices, in order.
|
|
15
|
+
* @param props.value - The choice that's on.
|
|
16
|
+
* @param props.onChange - Called with the choice picked.
|
|
17
|
+
* @param props.className - Classes added to the group, such as `flex-grow-1` to fill a row.
|
|
18
|
+
*/
|
|
19
|
+
export declare function SegmentedControl<T extends string>(props: {
|
|
20
|
+
label: string;
|
|
21
|
+
choices: readonly SegmentedChoice<T>[];
|
|
22
|
+
value: T;
|
|
23
|
+
onChange: (value: T) => void;
|
|
24
|
+
className?: string;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SegmentedControl = SegmentedControl;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* Two to four named choices side by side, one of them on: a compact control for a setting with
|
|
7
|
+
* a few values, such as a look ("Simple" or "With shortcuts"). Each choice is a button with
|
|
8
|
+
* `aria-pressed`, inside a group named by `label`.
|
|
9
|
+
*
|
|
10
|
+
* @param props.label - The setting's name, for assistive technology.
|
|
11
|
+
* @param props.choices - The choices, in order.
|
|
12
|
+
* @param props.value - The choice that's on.
|
|
13
|
+
* @param props.onChange - Called with the choice picked.
|
|
14
|
+
* @param props.className - Classes added to the group, such as `flex-grow-1` to fill a row.
|
|
15
|
+
*/
|
|
16
|
+
function SegmentedControl(props) {
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: `peers-segmented ${props.className ?? ""}`, role: "group", "aria-label": props.label, children: props.choices.map((choice) => ((0, jsx_runtime_1.jsx)("button", { type: "button", "aria-pressed": choice.value === props.value, onClick: () => props.onChange(choice.value), children: choice.label }, choice.value))) }));
|
|
18
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
+
/** A choice in a {@link Typeahead}: anything with an id. */
|
|
2
3
|
export interface TypeaheadItem {
|
|
4
|
+
/** Identifies the choice among the results and the picks. */
|
|
3
5
|
id: string;
|
|
4
6
|
[key: string]: unknown;
|
|
5
7
|
}
|
|
@@ -18,5 +20,12 @@ interface TypeaheadProps<T extends TypeaheadItem> {
|
|
|
18
20
|
debounceMs?: number;
|
|
19
21
|
maxResults?: number;
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* A search box that picks one or several items from async results, shown as badges.
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Use `Autocomplete` (peers-ui's standard picker): it keeps the pick in the box,
|
|
27
|
+
* supports sections, a footer and keys, and portals its popup. Typeahead stays for packages that
|
|
28
|
+
* still use it.
|
|
29
|
+
*/
|
|
21
30
|
export declare function Typeahead<T extends TypeaheadItem>(props: TypeaheadProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
22
31
|
export {};
|
|
@@ -55,6 +55,13 @@ const typeaheadStyles = `
|
|
|
55
55
|
white-space: nowrap;
|
|
56
56
|
}
|
|
57
57
|
`;
|
|
58
|
+
/**
|
|
59
|
+
* A search box that picks one or several items from async results, shown as badges.
|
|
60
|
+
*
|
|
61
|
+
* @deprecated Use `Autocomplete` (peers-ui's standard picker): it keeps the pick in the box,
|
|
62
|
+
* supports sections, a footer and keys, and portals its popup. Typeahead stays for packages that
|
|
63
|
+
* still use it.
|
|
64
|
+
*/
|
|
58
65
|
function Typeahead(props) {
|
|
59
66
|
const { placeholder = "Search...", searchFn, onSelectionChange, renderItem, renderBadge, selectedItems = [], multiSelect = false, maxSelections, className = "form-control", disabled = false, minSearchLength = 1, debounceMs = 300, maxResults = 10, } = props;
|
|
60
67
|
const [query, setQuery] = (0, react_1.useState)("");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IGroupInfo, type IGroupsConsumer, type IHostContractConsumer, type Observable } from "@peers-app/peers-sdk";
|
|
1
|
+
import { type IGroupInfo, type IGroupsConsumer, type IHostContractConsumer, type IOrderableGroup, type Observable } from "@peers-app/peers-sdk";
|
|
2
2
|
/**
|
|
3
3
|
* System Groups bound to the person's Personal context, so it lists every group they're in.
|
|
4
4
|
* Stable, for `useHostContract`.
|
|
@@ -27,3 +27,25 @@ export declare function useGroups(): IGroupInfo[] | undefined;
|
|
|
27
27
|
export declare function useGroup(groupId: string | undefined): IGroupInfo | undefined;
|
|
28
28
|
/** The System Groups tools, bound to Personal. */
|
|
29
29
|
export declare function groupsTools(): Promise<IGroupsConsumer["tools"]>;
|
|
30
|
+
/**
|
|
31
|
+
* The person's group order as System Groups lists it: the ids of their groups but Personal, in
|
|
32
|
+
* the order they put them in. Empty before System Groups answers, and on a Peers without it.
|
|
33
|
+
*
|
|
34
|
+
* @param listed - System Groups' list ({@link useGroups}).
|
|
35
|
+
*/
|
|
36
|
+
export declare function listedGroupOrder(listed: readonly IGroupInfo[] | undefined): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Things that each belong to a group, in the person's group order: Personal first, then the
|
|
39
|
+
* order's groups, then the rest by name (all by name, with no order).
|
|
40
|
+
*
|
|
41
|
+
* @param items - What to order; not changed.
|
|
42
|
+
* @param order - Group ids in order ({@link listedGroupOrder}).
|
|
43
|
+
* @param groupOf - An item's group: its id, name, and whether it's Personal.
|
|
44
|
+
*/
|
|
45
|
+
export declare function inGroupOrder<T>(items: readonly T[], order: readonly string[], groupOf: (item: T) => IOrderableGroup): T[];
|
|
46
|
+
/**
|
|
47
|
+
* Save the order the person's groups are listed in, everywhere that lists them.
|
|
48
|
+
*
|
|
49
|
+
* @param groupIds - Their groups' ids in order, Personal left out.
|
|
50
|
+
*/
|
|
51
|
+
export declare function saveGroupOrder(groupIds: string[]): Promise<void>;
|
|
@@ -5,6 +5,9 @@ exports.groupsObservable = groupsObservable;
|
|
|
5
5
|
exports.useGroups = useGroups;
|
|
6
6
|
exports.useGroup = useGroup;
|
|
7
7
|
exports.groupsTools = groupsTools;
|
|
8
|
+
exports.listedGroupOrder = listedGroupOrder;
|
|
9
|
+
exports.inGroupOrder = inGroupOrder;
|
|
10
|
+
exports.saveGroupOrder = saveGroupOrder;
|
|
8
11
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
9
12
|
const use_observable_1 = require("../hooks/use-observable");
|
|
10
13
|
/**
|
|
@@ -79,3 +82,31 @@ function useGroup(groupId) {
|
|
|
79
82
|
async function groupsTools() {
|
|
80
83
|
return (await exports.groupsContract.get()).tools;
|
|
81
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The person's group order as System Groups lists it: the ids of their groups but Personal, in
|
|
87
|
+
* the order they put them in. Empty before System Groups answers, and on a Peers without it.
|
|
88
|
+
*
|
|
89
|
+
* @param listed - System Groups' list ({@link useGroups}).
|
|
90
|
+
*/
|
|
91
|
+
function listedGroupOrder(listed) {
|
|
92
|
+
return (listed ?? []).filter((group) => !group.personal).map((group) => group.groupId);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Things that each belong to a group, in the person's group order: Personal first, then the
|
|
96
|
+
* order's groups, then the rest by name (all by name, with no order).
|
|
97
|
+
*
|
|
98
|
+
* @param items - What to order; not changed.
|
|
99
|
+
* @param order - Group ids in order ({@link listedGroupOrder}).
|
|
100
|
+
* @param groupOf - An item's group: its id, name, and whether it's Personal.
|
|
101
|
+
*/
|
|
102
|
+
function inGroupOrder(items, order, groupOf) {
|
|
103
|
+
return (0, peers_sdk_1.orderGroups)(items.map((item) => ({ ...groupOf(item), item })), order).map((entry) => entry.item);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Save the order the person's groups are listed in, everywhere that lists them.
|
|
107
|
+
*
|
|
108
|
+
* @param groupIds - Their groups' ids in order, Personal left out.
|
|
109
|
+
*/
|
|
110
|
+
async function saveGroupOrder(groupIds) {
|
|
111
|
+
await (await groupsTools()).setGroupOrder({ groupIds });
|
|
112
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
export { type Command, executeCommand, registerCommand, unregisterCommand, } from "./command-palette/command-palette";
|
|
2
|
+
export { Autocomplete, type AutocompleteOptionState, type AutocompleteProps, HighlightMatch, } from "./components/autocomplete";
|
|
3
|
+
export * from "./components/autocomplete-chips";
|
|
2
4
|
export * from "./components/color-picker";
|
|
5
|
+
export * from "./components/confirm-button";
|
|
3
6
|
export * from "./components/data-grid";
|
|
7
|
+
export * from "./components/empty-state";
|
|
4
8
|
export * from "./components/icon";
|
|
5
9
|
export * from "./components/icon-picker";
|
|
6
10
|
export { configureIconSearchIndexes, type IconSearchIndexSource, type IIconSearchIndexSources, } from "./components/icon-search";
|
|
11
|
+
export * from "./components/inline-create-form";
|
|
7
12
|
export * from "./components/inverse-lazy-list";
|
|
13
|
+
export * from "./components/list-row";
|
|
8
14
|
export type { IEditorEffects, IMarkdownEditorProps, IMarkdownFormatRowProps, } from "./components/markdown-editor/editor";
|
|
9
15
|
export { MarkdownEditor, MarkdownFormatRow } from "./components/markdown-editor/editor";
|
|
10
16
|
export * from "./components/markdown-editor/editor-inline";
|
|
11
17
|
export type { EditorFormat, IFormatState, ISelectionAction, } from "./components/markdown-editor/format";
|
|
12
18
|
export { ALL_FORMATS, INLINE_FORMATS } from "./components/markdown-editor/format";
|
|
13
19
|
export * from "./components/markdown-with-mentions";
|
|
20
|
+
export * from "./components/menu-button";
|
|
14
21
|
export * from "./components/responsive-section-nav";
|
|
22
|
+
export * from "./components/screen-header";
|
|
23
|
+
export * from "./components/search-field";
|
|
24
|
+
export * from "./components/segmented-control";
|
|
15
25
|
export * from "./components/sortable-list";
|
|
16
26
|
export * from "./components/tabs";
|
|
17
27
|
export { Typeahead, type TypeaheadItem } from "./components/typeahead";
|
package/dist/index.js
CHANGED
|
@@ -14,20 +14,29 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.inspectUI = exports.FRAME_SELECTOR_PREFIX = exports.actOnUI = exports.updateActiveTabTitle = exports.goToTabPath = exports.closeCurrentTab = exports.activeTabs = exports.activeTabId = exports.setRootLayout = exports.selectedRootLayoutId = exports.getRootLayouts = exports.getRootLayout = exports.DEFAULT_ROOT_LAYOUT_ID = exports.TabsLayoutApp = exports.RootLayoutHost = exports.LayoutPicker = exports.unregisterGlobalOverlay = exports.registerGlobalOverlay = exports.globalOverlays = exports.notificationHostControls = exports.openMention = exports.useMentionPlace = exports.MentionGroupContext = exports.MentionChip = exports.openLink = exports.windowWidth = exports.windowHeight = exports.mainContentPath = exports.isDesktop = exports.Typeahead = exports.INLINE_FORMATS = exports.ALL_FORMATS = exports.MarkdownFormatRow = exports.MarkdownEditor = exports.configureIconSearchIndexes = exports.unregisterCommand = exports.registerCommand = exports.executeCommand = void 0;
|
|
17
|
+
exports.inspectUI = exports.FRAME_SELECTOR_PREFIX = exports.actOnUI = exports.updateActiveTabTitle = exports.goToTabPath = exports.closeCurrentTab = exports.activeTabs = exports.activeTabId = exports.setRootLayout = exports.selectedRootLayoutId = exports.getRootLayouts = exports.getRootLayout = exports.DEFAULT_ROOT_LAYOUT_ID = exports.TabsLayoutApp = exports.RootLayoutHost = exports.LayoutPicker = exports.unregisterGlobalOverlay = exports.registerGlobalOverlay = exports.globalOverlays = exports.notificationHostControls = exports.openMention = exports.useMentionPlace = exports.MentionGroupContext = exports.MentionChip = exports.openLink = exports.windowWidth = exports.windowHeight = exports.mainContentPath = exports.isDesktop = exports.Typeahead = exports.INLINE_FORMATS = exports.ALL_FORMATS = exports.MarkdownFormatRow = exports.MarkdownEditor = exports.configureIconSearchIndexes = exports.HighlightMatch = exports.Autocomplete = exports.unregisterCommand = exports.registerCommand = exports.executeCommand = void 0;
|
|
18
18
|
// Commands in the command palette, with optional shortcuts. From a package's frame they go to the
|
|
19
19
|
// host's palette, under the package's name.
|
|
20
20
|
var command_palette_1 = require("./command-palette/command-palette");
|
|
21
21
|
Object.defineProperty(exports, "executeCommand", { enumerable: true, get: function () { return command_palette_1.executeCommand; } });
|
|
22
22
|
Object.defineProperty(exports, "registerCommand", { enumerable: true, get: function () { return command_palette_1.registerCommand; } });
|
|
23
23
|
Object.defineProperty(exports, "unregisterCommand", { enumerable: true, get: function () { return command_palette_1.unregisterCommand; } });
|
|
24
|
+
// The standard picker: one item from a list, by typing (data-grid re-exports Autocomplete too).
|
|
25
|
+
var autocomplete_1 = require("./components/autocomplete");
|
|
26
|
+
Object.defineProperty(exports, "Autocomplete", { enumerable: true, get: function () { return autocomplete_1.Autocomplete; } });
|
|
27
|
+
Object.defineProperty(exports, "HighlightMatch", { enumerable: true, get: function () { return autocomplete_1.HighlightMatch; } });
|
|
28
|
+
__exportStar(require("./components/autocomplete-chips"), exports);
|
|
24
29
|
__exportStar(require("./components/color-picker"), exports);
|
|
30
|
+
__exportStar(require("./components/confirm-button"), exports);
|
|
25
31
|
__exportStar(require("./components/data-grid"), exports);
|
|
32
|
+
__exportStar(require("./components/empty-state"), exports);
|
|
26
33
|
__exportStar(require("./components/icon"), exports);
|
|
27
34
|
__exportStar(require("./components/icon-picker"), exports);
|
|
28
35
|
var icon_search_1 = require("./components/icon-search");
|
|
29
36
|
Object.defineProperty(exports, "configureIconSearchIndexes", { enumerable: true, get: function () { return icon_search_1.configureIconSearchIndexes; } });
|
|
37
|
+
__exportStar(require("./components/inline-create-form"), exports);
|
|
30
38
|
__exportStar(require("./components/inverse-lazy-list"), exports);
|
|
39
|
+
__exportStar(require("./components/list-row"), exports);
|
|
31
40
|
var editor_1 = require("./components/markdown-editor/editor");
|
|
32
41
|
Object.defineProperty(exports, "MarkdownEditor", { enumerable: true, get: function () { return editor_1.MarkdownEditor; } });
|
|
33
42
|
Object.defineProperty(exports, "MarkdownFormatRow", { enumerable: true, get: function () { return editor_1.MarkdownFormatRow; } });
|
|
@@ -36,7 +45,11 @@ var format_1 = require("./components/markdown-editor/format");
|
|
|
36
45
|
Object.defineProperty(exports, "ALL_FORMATS", { enumerable: true, get: function () { return format_1.ALL_FORMATS; } });
|
|
37
46
|
Object.defineProperty(exports, "INLINE_FORMATS", { enumerable: true, get: function () { return format_1.INLINE_FORMATS; } });
|
|
38
47
|
__exportStar(require("./components/markdown-with-mentions"), exports);
|
|
48
|
+
__exportStar(require("./components/menu-button"), exports);
|
|
39
49
|
__exportStar(require("./components/responsive-section-nav"), exports);
|
|
50
|
+
__exportStar(require("./components/screen-header"), exports);
|
|
51
|
+
__exportStar(require("./components/search-field"), exports);
|
|
52
|
+
__exportStar(require("./components/segmented-control"), exports);
|
|
40
53
|
__exportStar(require("./components/sortable-list"), exports);
|
|
41
54
|
__exportStar(require("./components/tabs"), exports);
|
|
42
55
|
var typeahead_1 = require("./components/typeahead");
|
|
@@ -12,17 +12,9 @@ let runtimeSource;
|
|
|
12
12
|
* can't do for it yet. The list only shrinks: each entry goes when its reason does.
|
|
13
13
|
*/
|
|
14
14
|
exports.SHARED_WINDOW_PACKAGES = new Map([
|
|
15
|
-
[
|
|
16
|
-
"00mwi9ux5ate4rpcr26wdedph",
|
|
17
|
-
"Operator: Talk uses the microphone, which a frame's opaque origin can't open (Chromium and WebKit refuse it even with allow=microphone), and its settings write a secret variable (the OpenAI key), which frames can't. Its declared widget draws in the window.",
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
"00mp0gayf4f9hotacqsobyv6w",
|
|
21
|
-
"Voice Hub: it uses the microphone and wake word models, and reads its skills' widgets' DOM (Voice Skill widgets as a UI contract, embedded-ui.md slice 5)",
|
|
22
|
-
],
|
|
23
15
|
[
|
|
24
16
|
"00mkhtkl95byv5o2xsw12mi2x",
|
|
25
|
-
"Family Hub: it
|
|
17
|
+
"Family Hub: it uses Electron's <webview> for Google Photos short links and the any-page screensaver (a host-drawn web view is task 00mvik93fo14vuz86fnyzi22k), and draws an older Voice Skill provider's widget by UI id",
|
|
26
18
|
],
|
|
27
19
|
]);
|
|
28
20
|
/**
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ILocalFolderGrantInfo } from "@peers-app/peers-sdk";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import type { IFolderPickerRequest } from "./folder-picker-protocol";
|
|
4
|
+
/**
|
|
5
|
+
* The picker's look, with nothing to click: a framed screen's slot draws it hidden, so the slot is
|
|
6
|
+
* as big as the buttons the host draws over it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function FolderPickerFace(props: {
|
|
9
|
+
request: IFolderPickerRequest;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
/** Where Peers draws a picker: over this slot of the frame the host made with this id. */
|
|
12
|
+
export interface IFolderPickerPlace {
|
|
13
|
+
frameId: string;
|
|
14
|
+
slotId: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The picker a press in the host's window landed on, if any: on its buttons or in its ▾ menu.
|
|
18
|
+
*
|
|
19
|
+
* @param target - The press's target.
|
|
20
|
+
*/
|
|
21
|
+
export declare function folderPickerPressAt(target: Element | null): IFolderPickerPlace | undefined;
|
|
22
|
+
/** What a parent can do with the control: focus it, as Tab arrives at its slot. */
|
|
23
|
+
export interface IFolderPickerControlHandle {
|
|
24
|
+
focus(edge: "first" | "last"): void;
|
|
25
|
+
}
|
|
26
|
+
/** What {@link FolderPickerControl} takes. */
|
|
27
|
+
export interface IFolderPickerControlProps {
|
|
28
|
+
request: IFolderPickerRequest;
|
|
29
|
+
/** The package the grant is for; none makes a grant for the person (Peers' own screens). */
|
|
30
|
+
packageId?: string;
|
|
31
|
+
onPicked: (grant: ILocalFolderGrantInfo) => void;
|
|
32
|
+
onFailed: (message: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Over a slot: the buttons fill it, take no Tab stop of their own, and Tab leaving them goes
|
|
35
|
+
* back to the screen through this.
|
|
36
|
+
*/
|
|
37
|
+
overSlot?: {
|
|
38
|
+
onTabOut: (direction: "next" | "previous") => void;
|
|
39
|
+
place: IFolderPickerPlace;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** One folder the package already has on this device, and the groups it's used in. */
|
|
43
|
+
interface IExistingFolder {
|
|
44
|
+
absolutePath: string;
|
|
45
|
+
groupIds: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The folders a package has on this device that a request may use: whole folders, at least as
|
|
49
|
+
* writable as asked for.
|
|
50
|
+
*/
|
|
51
|
+
export declare function existingFolders(grants: readonly ILocalFolderGrantInfo[], packageId: string | undefined, request: Pick<IFolderPickerRequest, "mode">): IExistingFolder[];
|
|
52
|
+
/**
|
|
53
|
+
* Peers' folder picker buttons. A click opens the OS picker (or uses a folder from the ▾ menu) and
|
|
54
|
+
* grants it with System Local Folders, as the person, for `packageId`.
|
|
55
|
+
*/
|
|
56
|
+
export declare const FolderPickerControl: React.ForwardRefExoticComponent<IFolderPickerControlProps & React.RefAttributes<IFolderPickerControlHandle>>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FolderPickerControl = void 0;
|
|
4
|
+
exports.FolderPickerFace = FolderPickerFace;
|
|
5
|
+
exports.folderPickerPressAt = folderPickerPressAt;
|
|
6
|
+
exports.existingFolders = existingFolders;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const group_names_1 = require("../notifications/group-names");
|
|
11
|
+
const local_folders_ipc_1 = require("../screens/packages/local-folders-ipc");
|
|
12
|
+
const popover_surface_1 = require("../ui-contracts/popover-surface");
|
|
13
|
+
/**
|
|
14
|
+
* The buttons of Peers' folder picker, drawn by Peers: over a framed screen's slot by its host
|
|
15
|
+
* (`folder-picker-host.tsx`), or in the window for a screen that runs there
|
|
16
|
+
* (`local-folder-picker.tsx`). A click opens the OS picker and grants what's picked to the
|
|
17
|
+
* package; the ▾ lists folders the package already has on this device.
|
|
18
|
+
*/
|
|
19
|
+
/** Why a grant failed, in words for the person. A host without System Local Folders says so. */
|
|
20
|
+
function errorText(error) {
|
|
21
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
22
|
+
// A transport may wrap the provider's message.
|
|
23
|
+
return /No contract provider registered for \S+|Permission denied: contract \S+ is not available locally/i.test(message)
|
|
24
|
+
? "Folders on this device need the Peers desktop app"
|
|
25
|
+
: message;
|
|
26
|
+
}
|
|
27
|
+
/** The picker can be cancelled. A file validation error includes the name the person picked. */
|
|
28
|
+
function grantError(error) {
|
|
29
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
30
|
+
// checkGrantFiles includes the filename verbatim in these diagnostics. It can contain the
|
|
31
|
+
// entire cancellation or missing-provider message, including any apparent wrapper.
|
|
32
|
+
if (/Not a file name: |files names [\s\S]* twice| is not (?:an available|a regular) file| cannot be opened under its normalized name/.test(message))
|
|
33
|
+
return message;
|
|
34
|
+
if (/\b(?:file|folder) selection was cancelled\b/i.test(message))
|
|
35
|
+
return undefined;
|
|
36
|
+
return errorText(message);
|
|
37
|
+
}
|
|
38
|
+
function buttonClass(request) {
|
|
39
|
+
return `btn btn-${request.variant}${request.size ? ` btn-${request.size}` : ""}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The picker's look, with nothing to click: a framed screen's slot draws it hidden, so the slot is
|
|
43
|
+
* as big as the buttons the host draws over it.
|
|
44
|
+
*/
|
|
45
|
+
function FolderPickerFace(props) {
|
|
46
|
+
const { request } = props;
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: "btn-group", "aria-hidden": "true", style: { visibility: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("span", { className: buttonClass(request), children: [request.icon ? (0, jsx_runtime_1.jsx)("i", { className: `bi bi-${request.icon} me-1` }) : null, request.label] }), request.offerExisting ? ((0, jsx_runtime_1.jsx)("span", { className: `${buttonClass(request)} dropdown-toggle dropdown-toggle-split` })) : null] }));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The attributes that mark what Peers draws for a picker over a frame's slot (its buttons, and its
|
|
51
|
+
* ▾ menu, which sits elsewhere in the window), so a press there counts as inside that slot.
|
|
52
|
+
*/
|
|
53
|
+
function placeMarks(place) {
|
|
54
|
+
return place
|
|
55
|
+
? {
|
|
56
|
+
"data-peers-folder-picker-frame": place.frameId,
|
|
57
|
+
"data-peers-folder-picker-slot": place.slotId,
|
|
58
|
+
}
|
|
59
|
+
: {};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The picker a press in the host's window landed on, if any: on its buttons or in its ▾ menu.
|
|
63
|
+
*
|
|
64
|
+
* @param target - The press's target.
|
|
65
|
+
*/
|
|
66
|
+
function folderPickerPressAt(target) {
|
|
67
|
+
const marked = target?.closest("[data-peers-folder-picker-frame]");
|
|
68
|
+
const frameId = marked?.dataset.peersFolderPickerFrame;
|
|
69
|
+
const slotId = marked?.dataset.peersFolderPickerSlot;
|
|
70
|
+
return frameId && slotId ? { frameId, slotId } : undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The folders a package has on this device that a request may use: whole folders, at least as
|
|
74
|
+
* writable as asked for.
|
|
75
|
+
*/
|
|
76
|
+
function existingFolders(grants, packageId, request) {
|
|
77
|
+
const byPath = new Map();
|
|
78
|
+
for (const grant of grants) {
|
|
79
|
+
if (grant.packageId !== packageId || grant.files !== undefined)
|
|
80
|
+
continue;
|
|
81
|
+
if (request.mode === "readwrite" && grant.mode !== "readwrite")
|
|
82
|
+
continue;
|
|
83
|
+
const known = byPath.get(grant.absolutePath);
|
|
84
|
+
if (known) {
|
|
85
|
+
if (!known.groupIds.includes(grant.groupId))
|
|
86
|
+
known.groupIds.push(grant.groupId);
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
byPath.set(grant.absolutePath, {
|
|
90
|
+
absolutePath: grant.absolutePath,
|
|
91
|
+
groupIds: [grant.groupId],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return [...byPath.values()].sort((a, b) => a.absolutePath.localeCompare(b.absolutePath));
|
|
95
|
+
}
|
|
96
|
+
function folderName(absolutePath) {
|
|
97
|
+
const parts = absolutePath.split(absolutePath.startsWith("/") ? "/" : /[\\/]/).filter(Boolean);
|
|
98
|
+
return parts[parts.length - 1] ?? absolutePath;
|
|
99
|
+
}
|
|
100
|
+
/** The ▾ menu: the package's folders on this device, then the picker. */
|
|
101
|
+
function ExistingFoldersMenu(props) {
|
|
102
|
+
const names = (0, group_names_1.useGroupNames)();
|
|
103
|
+
const { grants, packageId, mode, anchor } = props;
|
|
104
|
+
const close = (0, react_1.useRef)(props.onClose);
|
|
105
|
+
close.current = props.onClose;
|
|
106
|
+
// The menu sits outside the screen, so it stays up when the screen's tab is switched away or the
|
|
107
|
+
// ▾ scrolls out of sight: close it then, so it can't act for a screen the person can't see.
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
109
|
+
if (!anchor || typeof IntersectionObserver === "undefined")
|
|
110
|
+
return;
|
|
111
|
+
// Touching the clip edge can still count as intersecting with zero area. A positive
|
|
112
|
+
// threshold makes crossing from a visible sliver to zero observable too.
|
|
113
|
+
const watch = new IntersectionObserver((entries) => {
|
|
114
|
+
if (entries.some((entry) => !entry.isIntersecting || entry.intersectionRatio === 0)) {
|
|
115
|
+
close.current();
|
|
116
|
+
}
|
|
117
|
+
}, { threshold: Number.EPSILON });
|
|
118
|
+
watch.observe(anchor);
|
|
119
|
+
return () => watch.disconnect();
|
|
120
|
+
}, [anchor]);
|
|
121
|
+
// A mode change can make a listed folder ineligible. Moving the slot keeps the same choices.
|
|
122
|
+
const folders = (0, react_1.useMemo)(() => (Array.isArray(grants) ? existingFolders(grants, packageId, { mode }) : grants), [grants, packageId, mode]);
|
|
123
|
+
return ((0, jsx_runtime_1.jsx)(popover_surface_1.PopoverSurface, { anchor: props.anchor, onClose: props.onClose, label: "Folders", children: (0, jsx_runtime_1.jsx)("div", { ...placeMarks(props.place), style: { maxHeight: "inherit" }, children: (0, jsx_runtime_1.jsxs)("div", { className: "dropdown-menu show position-static shadow", style: { maxWidth: 420, maxHeight: "inherit", overflowY: "auto" }, children: [folders === undefined ? ((0, jsx_runtime_1.jsx)("div", { className: "dropdown-item-text text-body-secondary small", children: "Loading\u2026" })) : typeof folders === "string" ? ((0, jsx_runtime_1.jsx)("div", { className: "dropdown-item-text text-danger small", children: folders })) : folders.length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "dropdown-item-text text-body-secondary small", children: "No folders to choose from yet" })) : (folders.map((folder) => ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "dropdown-item", title: folder.absolutePath, onClick: () => props.onChoose(folder.absolutePath), children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-folder me-2" }), folderName(folder.absolutePath), (0, jsx_runtime_1.jsx)("span", { className: "text-body-secondary small ms-2", children: folder.groupIds.map((id) => names.get(id) ?? "another group").join(", ") })] }, folder.absolutePath)))), (0, jsx_runtime_1.jsx)("div", { className: "dropdown-divider" }), (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "dropdown-item", onClick: () => props.onChoose(undefined), children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-folder2-open me-2" }), "Another folder\u2026"] })] }) }) }));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Peers' folder picker buttons. A click opens the OS picker (or uses a folder from the ▾ menu) and
|
|
127
|
+
* grants it with System Local Folders, as the person, for `packageId`.
|
|
128
|
+
*/
|
|
129
|
+
exports.FolderPickerControl = (0, react_1.forwardRef)(function FolderPickerControl(props, ref) {
|
|
130
|
+
const { request, packageId, overSlot } = props;
|
|
131
|
+
const main = (0, react_1.useRef)(null);
|
|
132
|
+
const caret = (0, react_1.useRef)(null);
|
|
133
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
134
|
+
// The ▾ menu: closed, loading, why it couldn't load, or the package's grants on this device.
|
|
135
|
+
const [menu, setMenu] = (0, react_1.useState)(false);
|
|
136
|
+
const latest = (0, react_1.useRef)(props);
|
|
137
|
+
latest.current = props;
|
|
138
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
139
|
+
focus: (edge) => (edge === "last" && caret.current ? caret.current : main.current)?.focus(),
|
|
140
|
+
}));
|
|
141
|
+
async function grant(absolutePath) {
|
|
142
|
+
if (request.disabled || busy)
|
|
143
|
+
return;
|
|
144
|
+
setBusy(true);
|
|
145
|
+
const input = {
|
|
146
|
+
groupId: request.groupId,
|
|
147
|
+
mode: request.mode,
|
|
148
|
+
...(packageId ? { packageId } : {}),
|
|
149
|
+
...(absolutePath ? { absolutePath } : request.pick === "files" ? { pick: "files" } : {}),
|
|
150
|
+
};
|
|
151
|
+
let granted;
|
|
152
|
+
try {
|
|
153
|
+
granted = await local_folders_ipc_1.localFoldersConsumer.get().then(({ tools }) => {
|
|
154
|
+
// Membership can change after the frame mounts its slot.
|
|
155
|
+
if (overSlot &&
|
|
156
|
+
request.groupId !== (0, peers_sdk_1.peekUserContext)()?.userId &&
|
|
157
|
+
!(0, peers_sdk_1.peekUserContext)()?.groupDataContexts.has(request.groupId)) {
|
|
158
|
+
throw new Error("That group isn't available to this screen");
|
|
159
|
+
}
|
|
160
|
+
return tools.requestGrant(input);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const message = grantError(error);
|
|
165
|
+
if (message !== undefined)
|
|
166
|
+
latest.current.onFailed(message);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
finally {
|
|
170
|
+
setBusy(false);
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
latest.current.onPicked(granted);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
// A shared-window callback can throw here. The grant has already succeeded.
|
|
177
|
+
console.error("Folder picker onPicked failed", error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function openMenu() {
|
|
181
|
+
setMenu(undefined);
|
|
182
|
+
try {
|
|
183
|
+
const { grants } = await (await local_folders_ipc_1.localFoldersConsumer.get()).tools.listGrants();
|
|
184
|
+
setMenu((open) => (open === false ? open : grants));
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
setMenu((open) => (open === false ? open : errorText(error)));
|
|
188
|
+
latest.current.onFailed(errorText(error));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Over a slot the buttons take no Tab stops in the window: Tab moves between them here, and
|
|
192
|
+
// out of them back to the screen around the slot.
|
|
193
|
+
const onTab = (event, on) => {
|
|
194
|
+
if (!overSlot || event.key !== "Tab")
|
|
195
|
+
return;
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
if (on === "main" && !event.shiftKey && caret.current)
|
|
198
|
+
caret.current.focus();
|
|
199
|
+
else if (on === "caret" && event.shiftKey)
|
|
200
|
+
main.current?.focus();
|
|
201
|
+
else
|
|
202
|
+
overSlot.onTabOut(event.shiftKey ? "previous" : "next");
|
|
203
|
+
};
|
|
204
|
+
const disabled = request.disabled || busy;
|
|
205
|
+
// A ▾ menu that can't show is closed, not hidden: only the person's click on ▾ opens it again,
|
|
206
|
+
// so a screen that disables the picker and enables it again can't put a named folder, focused,
|
|
207
|
+
// under the person's next key press or click.
|
|
208
|
+
if (menu !== false && (disabled || !request.offerExisting))
|
|
209
|
+
setMenu(false);
|
|
210
|
+
const fill = overSlot
|
|
211
|
+
? { width: "100%", height: "100%" }
|
|
212
|
+
: undefined;
|
|
213
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: "btn-group", style: fill, children: [(0, jsx_runtime_1.jsxs)("button", { ref: main, type: "button", className: buttonClass(request), disabled: disabled, "aria-busy": busy || undefined, tabIndex: overSlot ? -1 : undefined, onKeyDown: (event) => onTab(event, "main"), onClick: () => void grant(undefined), children: [request.icon ? (0, jsx_runtime_1.jsx)("i", { className: `bi bi-${request.icon} me-1` }) : null, request.label] }), request.offerExisting ? ((0, jsx_runtime_1.jsx)("button", { ref: caret, type: "button", className: `${buttonClass(request)} dropdown-toggle dropdown-toggle-split`, disabled: disabled, "aria-label": "Folders this app already uses", "aria-expanded": !disabled && menu !== false, tabIndex: overSlot ? -1 : undefined, onKeyDown: (event) => onTab(event, "caret"), onClick: () => (menu === false ? void openMenu() : setMenu(false)) })) : null, menu !== false && request.offerExisting && !disabled ? ((0, jsx_runtime_1.jsx)(ExistingFoldersMenu, { anchor: caret.current, grants: menu, packageId: packageId, mode: request.mode, place: overSlot?.place, onClose: () => setMenu(false), onChoose: (absolutePath) => {
|
|
214
|
+
setMenu(false);
|
|
215
|
+
void grant(absolutePath);
|
|
216
|
+
} })) : null] }));
|
|
217
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { type IFolderPickerControlHandle } from "./folder-picker-control";
|
|
4
|
+
import { type IFolderPickerRequest } from "./folder-picker-protocol";
|
|
5
|
+
import type { IPortChannel } from "./port-channel";
|
|
6
|
+
import type { ISlotClip, ISlotRect } from "./slot-rect";
|
|
7
|
+
/**
|
|
8
|
+
* The host's side of Peers' folder picker in a framed screen (`folder-picker-protocol.ts`): it
|
|
9
|
+
* keeps the screen's picker slots, and draws its own buttons over them. The grant is made for the
|
|
10
|
+
* frame's package, which the host knows; nothing the screen sends names it.
|
|
11
|
+
*/
|
|
12
|
+
/** One picker a framed screen placed: what it asks for, and where its slot is. */
|
|
13
|
+
export interface IFolderPickerSlot {
|
|
14
|
+
slotId: string;
|
|
15
|
+
request: IFolderPickerRequest;
|
|
16
|
+
/** Where the slot is, in the frame's coordinates, and the part of it that shows. */
|
|
17
|
+
rect?: ISlotRect;
|
|
18
|
+
clip?: ISlotClip;
|
|
19
|
+
}
|
|
20
|
+
/** The host's folder pickers for one frame: what its session keeps. */
|
|
21
|
+
export interface IFolderPickerHost {
|
|
22
|
+
/** A picker drawn over a slot registers its buttons, so focus from the screen reaches them. */
|
|
23
|
+
register(slotId: string, control: IFolderPickerControlHandle | null): void;
|
|
24
|
+
/** Stop listening to the frame. */
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Listen to a frame's folder picker messages.
|
|
29
|
+
*
|
|
30
|
+
* @param channel - The frame's channel.
|
|
31
|
+
* @param opts.slots - The frame's pickers, which its component draws.
|
|
32
|
+
* @param opts.hasFocus - Whether the frame still has the focus: focus the user moved elsewhere
|
|
33
|
+
* before a notice arrived stays there.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installFolderPickerHost(channel: IPortChannel, opts: {
|
|
36
|
+
slots: Observable<IFolderPickerSlot[]>;
|
|
37
|
+
hasFocus: () => boolean;
|
|
38
|
+
}): IFolderPickerHost;
|
|
39
|
+
/** What a picker over a slot needs from its frame's session. */
|
|
40
|
+
export interface IFolderPickerSession {
|
|
41
|
+
readonly folderPickers: IFolderPickerHost;
|
|
42
|
+
/** Send the frame a notice. */
|
|
43
|
+
slotNotify(type: string, payload: Record<string, unknown>): void;
|
|
44
|
+
/** Hand focus back to the screen, beside the slot. */
|
|
45
|
+
focusBack(slotId: string, direction: "next" | "previous"): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Peers' folder picker buttons over a framed screen's slot, placed and clipped where the slot
|
|
49
|
+
* shows. What's picked is granted to `packageId`, the frame's package.
|
|
50
|
+
*/
|
|
51
|
+
export declare function FolderPickerOverSlot(props: {
|
|
52
|
+
slot: IFolderPickerSlot;
|
|
53
|
+
/** The host's id for the frame that placed the picker. */
|
|
54
|
+
frameId: string;
|
|
55
|
+
packageId: string;
|
|
56
|
+
session: React.MutableRefObject<IFolderPickerSession | undefined>;
|
|
57
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|