@vibes.diy/base 14.3.457 → 14.3.459
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/attachments/attachment-types.d.ts +1 -0
- package/attachments/attachment-types.js +9 -0
- package/attachments/composer-file-paste.d.ts +7 -0
- package/attachments/composer-file-paste.js +25 -0
- package/attachments/process-attachment.js +3 -3
- package/components/AttachmentRow.js +8 -1
- package/components/AttachmentThumb.d.ts +7 -0
- package/components/AttachmentThumb.js +24 -0
- package/components/ChatMessageRow.js +1 -1
- package/components/HandlePickerMenu.js +1 -1
- package/components/HiddenMenuWrapper.js +3 -3
- package/components/HiddenMenuWrapper.styles.js +1 -1
- package/components/SharePanelView.js +1 -1
- package/components/SubTabStrip.js +4 -4
- package/components/VibesButton.js +3 -3
- package/components/VibesPanel.js +2 -2
- package/components/ViewerTagView.js +1 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/vibe-menu/VibeMenu.js +7 -2
- package/components/vibe-menu/cards/share-actions.d.ts +6 -2
- package/components/vibe-menu/cards/share-actions.js +6 -8
- package/components/vibe-menu/cards/share-parts.js +12 -3
- package/components/vibe-menu/geometry.d.ts +6 -0
- package/components/vibe-menu/geometry.js +4 -0
- package/components/vibe-menu/parts/Composer.d.ts +6 -1
- package/components/vibe-menu/parts/Composer.js +36 -8
- package/components/vibe-menu/parts/SectionStrip.js +2 -0
- package/components/vibe-menu/parts/StarterChips.d.ts +12 -31
- package/components/vibe-menu/parts/StarterChips.js +6 -11
- package/components/vibe-menu/parts/StatusChipRow.js +1 -1
- package/components/vibe-menu/parts/use-composer-draft.d.ts +1 -0
- package/components/vibe-menu/parts/use-composer-draft.js +3 -0
- package/components/vibe-menu/shell/VibeMenuShell.d.ts +2 -0
- package/components/vibe-menu/shell/VibeMenuShell.js +16 -8
- package/components/vibe-menu/shell/shell.styles.d.ts +1 -0
- package/components/vibe-menu/shell/shell.styles.js +66 -1
- package/components/vibe-menu/shell/useMenuSequencer.js +3 -1
- package/components/vibe-menu/slices.d.ts +6 -1
- package/components/vibe-menu/slices.js +2 -0
- package/components/vibe-menu/vibe-menu.styles.d.ts +1 -1
- package/components/vibe-menu/vibe-menu.styles.js +14 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +5 -5
- package/theme/tokens.d.ts +5 -0
- package/theme/tokens.js +5 -0
- package/utils/normalize-avatar-image.js +3 -3
|
@@ -6,6 +6,7 @@ export declare const IMAGE_JPEG_QUALITY = 0.8;
|
|
|
6
6
|
export declare const IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/webp", "image/gif"];
|
|
7
7
|
export declare const OFFICE_EXTENSIONS: readonly ["pdf", "docx", "pptx", "xlsx", "odt", "odp", "ods", "rtf", "csv", "md", "html"];
|
|
8
8
|
export declare const ATTACHMENT_ACCEPT: string;
|
|
9
|
+
export declare function isAcceptedAttachmentFile(file: Pick<File, "name" | "type">): boolean;
|
|
9
10
|
export interface PromptAttachment {
|
|
10
11
|
readonly name: string;
|
|
11
12
|
readonly kind: "image" | "text";
|
|
@@ -6,3 +6,12 @@ export const IMAGE_JPEG_QUALITY = 0.8;
|
|
|
6
6
|
export const IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/gif"];
|
|
7
7
|
export const OFFICE_EXTENSIONS = ["pdf", "docx", "pptx", "xlsx", "odt", "odp", "ods", "rtf", "csv", "md", "html"];
|
|
8
8
|
export const ATTACHMENT_ACCEPT = [...IMAGE_MIME_TYPES, ...OFFICE_EXTENSIONS.map((e) => `.${e}`), "text/*", "application/json"].join(",");
|
|
9
|
+
export function isAcceptedAttachmentFile(file) {
|
|
10
|
+
if (IMAGE_MIME_TYPES.includes(file.type))
|
|
11
|
+
return true;
|
|
12
|
+
if (file.type.startsWith("text/") || file.type === "application/json")
|
|
13
|
+
return true;
|
|
14
|
+
const dot = file.name.lastIndexOf(".");
|
|
15
|
+
const ext = dot >= 0 ? file.name.slice(dot + 1).toLowerCase() : "";
|
|
16
|
+
return OFFICE_EXTENSIONS.includes(ext);
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClipboardEvent } from "react";
|
|
2
|
+
export declare function filesFromPaste(clipboardData: DataTransfer | null | undefined): File[];
|
|
3
|
+
export declare function composerFilePaste(options: {
|
|
4
|
+
readonly onFiles: (files: File[]) => void;
|
|
5
|
+
readonly isPasteAllowed?: () => boolean;
|
|
6
|
+
readonly onBeforePaste?: () => boolean;
|
|
7
|
+
}): (event: ClipboardEvent) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isAcceptedAttachmentFile } from "./attachment-types.js";
|
|
2
|
+
export function filesFromPaste(clipboardData) {
|
|
3
|
+
if (clipboardData === null || clipboardData === undefined)
|
|
4
|
+
return [];
|
|
5
|
+
const files = Array.from(clipboardData.files ?? []);
|
|
6
|
+
if (files.length > 0)
|
|
7
|
+
return files;
|
|
8
|
+
return Array.from(clipboardData.items ?? [])
|
|
9
|
+
.filter((item) => item.kind === "file")
|
|
10
|
+
.map((item) => item.getAsFile())
|
|
11
|
+
.filter((file) => file !== null);
|
|
12
|
+
}
|
|
13
|
+
export function composerFilePaste(options) {
|
|
14
|
+
return (event) => {
|
|
15
|
+
const files = filesFromPaste(event.clipboardData).filter(isAcceptedAttachmentFile);
|
|
16
|
+
if (files.length === 0)
|
|
17
|
+
return;
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
if (options.isPasteAllowed?.() === false)
|
|
20
|
+
return;
|
|
21
|
+
if (options.onBeforePaste?.() === false)
|
|
22
|
+
return;
|
|
23
|
+
options.onFiles(files);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -19,7 +19,7 @@ function textAttachment(file, text) {
|
|
|
19
19
|
}
|
|
20
20
|
async function processImage(file) {
|
|
21
21
|
const bitmap = await decodeToBitmap(file);
|
|
22
|
-
if (
|
|
22
|
+
if (bitmap === undefined)
|
|
23
23
|
return { ok: false, error: "Couldn't decode this image" };
|
|
24
24
|
const rResult = await exception2Result(async () => {
|
|
25
25
|
const { width, height } = fitWithin(bitmap.width, bitmap.height, IMAGE_MAX_DIMENSION);
|
|
@@ -27,11 +27,11 @@ async function processImage(file) {
|
|
|
27
27
|
canvas.width = width;
|
|
28
28
|
canvas.height = height;
|
|
29
29
|
const ctx = canvas.getContext("2d");
|
|
30
|
-
if (
|
|
30
|
+
if (ctx === null)
|
|
31
31
|
return { ok: false, error: "Couldn't process this image" };
|
|
32
32
|
ctx.drawImage(bitmap, 0, 0, width, height);
|
|
33
33
|
const blob = await new Promise((res) => canvas.toBlob(res, "image/jpeg", IMAGE_JPEG_QUALITY));
|
|
34
|
-
if (
|
|
34
|
+
if (blob === null)
|
|
35
35
|
return { ok: false, error: "Couldn't re-encode this image" };
|
|
36
36
|
return {
|
|
37
37
|
ok: true,
|
|
@@ -3,6 +3,7 @@ import { useEffect, useRef } from "react";
|
|
|
3
3
|
import { ATTACHMENT_ACCEPT } from "../attachments/attachment-types.js";
|
|
4
4
|
import { attachmentRemoveName, leftOutSentence } from "../attachments/use-attachments.js";
|
|
5
5
|
import { PaperclipIcon } from "./icons/PaperclipIcon.js";
|
|
6
|
+
import { AttachmentThumb, chipThumbBlob } from "./AttachmentThumb.js";
|
|
6
7
|
export function AttachmentButton({ onFiles, onBeforeSelect, onCancel, disabled, className, }) {
|
|
7
8
|
const inputRef = useRef(null);
|
|
8
9
|
const onCancelRef = useRef(onCancel);
|
|
@@ -43,6 +44,12 @@ export function AttachmentChips({ chips, onRemove, leftOut, noteStyle, }) {
|
|
|
43
44
|
chips.length > 0 ? React.createElement(ChipList, { chips: chips, onRemove: onRemove }) : null,
|
|
44
45
|
note !== undefined ? (React.createElement("p", { "aria-live": "polite", "data-testid": "attachment-left-out", style: noteStyle ?? { fontSize: 12, opacity: 0.75, margin: "6px 2px 0" } }, note)) : null));
|
|
45
46
|
}
|
|
47
|
+
function ChipGlyph({ chip }) {
|
|
48
|
+
const blob = chipThumbBlob(chip);
|
|
49
|
+
if (blob !== undefined)
|
|
50
|
+
return React.createElement(AttachmentThumb, { blob: blob });
|
|
51
|
+
return React.createElement("span", { "aria-hidden": true }, chip.status === "processing" ? "⏳" : chip.kind === "image" ? "🖼" : "📄");
|
|
52
|
+
}
|
|
46
53
|
function ChipList({ chips, onRemove }) {
|
|
47
54
|
return (React.createElement("div", { "aria-live": "polite", style: { display: "flex", flexWrap: "wrap", gap: 6, marginTop: 8 }, "data-testid": "attachment-chips" }, chips.map((chip, index) => (React.createElement("span", { key: chip.id, "data-status": chip.status, title: chip.error, className: chip.status === "error"
|
|
48
55
|
? "border border-red-400 text-red-600 dark:text-red-400"
|
|
@@ -55,7 +62,7 @@ function ChipList({ chips, onRemove }) {
|
|
|
55
62
|
fontSize: 12,
|
|
56
63
|
maxWidth: 220,
|
|
57
64
|
} },
|
|
58
|
-
React.createElement(
|
|
65
|
+
React.createElement(ChipGlyph, { chip: chip }),
|
|
59
66
|
React.createElement("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, chip.name),
|
|
60
67
|
chip.status === "error" && React.createElement("span", null, chip.error),
|
|
61
68
|
React.createElement("button", { type: "button", "aria-label": attachmentRemoveName(index), onClick: () => onRemove(chip.id), style: { background: "none", border: "none", cursor: "pointer", padding: 0, lineHeight: 1 } }, "\u00D7"))))));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { AttachmentChip } from "../attachments/use-attachments.js";
|
|
3
|
+
export declare function chipThumbBlob(chip: AttachmentChip): Blob | undefined;
|
|
4
|
+
export declare function AttachmentThumb(props: {
|
|
5
|
+
readonly blob: Blob;
|
|
6
|
+
readonly className?: string;
|
|
7
|
+
}): React.ReactElement | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const THUMB_STYLE = { flex: "none", width: 20, height: 20, borderRadius: 5, objectFit: "cover" };
|
|
3
|
+
export function chipThumbBlob(chip) {
|
|
4
|
+
if (chip.status !== "ready" || chip.kind !== "image")
|
|
5
|
+
return undefined;
|
|
6
|
+
return chip.payload?.processed;
|
|
7
|
+
}
|
|
8
|
+
export function AttachmentThumb(props) {
|
|
9
|
+
const { blob } = props;
|
|
10
|
+
const [src, setSrc] = React.useState(undefined);
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
if (typeof URL.createObjectURL !== "function")
|
|
13
|
+
return;
|
|
14
|
+
const url = URL.createObjectURL(blob);
|
|
15
|
+
setSrc(url);
|
|
16
|
+
return () => {
|
|
17
|
+
URL.revokeObjectURL(url);
|
|
18
|
+
setSrc(undefined);
|
|
19
|
+
};
|
|
20
|
+
}, [blob]);
|
|
21
|
+
if (src === undefined)
|
|
22
|
+
return null;
|
|
23
|
+
return React.createElement("img", { className: props.className, style: THUMB_STYLE, src: src, alt: "", "aria-hidden": "true", "data-attachment-thumb": "" });
|
|
24
|
+
}
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
export function ChatMessageRow({ role, platform, fontSize = "1rem", opacity, rowAttrs, contentAttrs, children, }) {
|
|
3
3
|
const user = role === "user";
|
|
4
4
|
return (React.createElement("div", { className: "grid grid-cols-[3.25rem_minmax(0,1fr)] pr-4 pl-2", ...rowAttrs },
|
|
5
|
-
React.createElement("div", { className: `pt-[5px] pr-2 text-right font-mono text-[0.6rem] uppercase tracking-wide ${platform ? "text-blue-500 opacity-80 dark:text-blue-400" : "opacity-50"}` }, user &&
|
|
5
|
+
React.createElement("div", { className: `pt-[5px] pr-2 text-right font-mono text-[0.6rem] uppercase tracking-wide ${platform ? "text-blue-500 opacity-80 dark:text-blue-400" : "opacity-50"}` }, user && platform !== true ? "you" : "vibes"),
|
|
6
6
|
React.createElement("div", { ...contentAttrs, className: `relative min-w-0${user ? " bg-black/[0.05] dark:bg-white/[0.06]" : ""}`, style: {
|
|
7
7
|
borderLeft: `3px solid ${platform ? "rgba(59, 130, 246, 0.55)" : user ? "var(--vibes-card-text)" : "rgba(128,128,128,0.55)"}`,
|
|
8
8
|
padding: "0.25rem 0.75rem 0.35rem 0.75rem",
|
|
@@ -40,7 +40,7 @@ export function NewHandleForm({ busy, onCancel, onCreate, onRandom, }) {
|
|
|
40
40
|
const sanitized = sanitizeHandle(draft);
|
|
41
41
|
const valid = sanitized.length > 0;
|
|
42
42
|
const submit = () => {
|
|
43
|
-
if (valid &&
|
|
43
|
+
if (valid && busy !== true)
|
|
44
44
|
onCreate(sanitized);
|
|
45
45
|
};
|
|
46
46
|
return (React.createElement("div", { style: { padding: "2px 4px 4px" } },
|
|
@@ -26,7 +26,7 @@ export function HiddenMenuWrapper({ children, menuContent, triggerBounce, showVi
|
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
const styleId = "vibes-drop-to-close-keyframes";
|
|
28
28
|
const existingStyle = document.getElementById(styleId);
|
|
29
|
-
if (
|
|
29
|
+
if (existingStyle === null) {
|
|
30
30
|
const style = document.createElement("style");
|
|
31
31
|
style.id = styleId;
|
|
32
32
|
style.textContent = `
|
|
@@ -100,7 +100,7 @@ export function HiddenMenuWrapper({ children, menuContent, triggerBounce, showVi
|
|
|
100
100
|
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
101
101
|
useIsomorphicLayoutEffect(() => {
|
|
102
102
|
const menuEl = menuRef.current;
|
|
103
|
-
if (
|
|
103
|
+
if (menuEl === null)
|
|
104
104
|
return;
|
|
105
105
|
const scheduleSetHeight = (h) => {
|
|
106
106
|
if (rafIdRef.current != null && cancelRef.current) {
|
|
@@ -153,7 +153,7 @@ export function HiddenMenuWrapper({ children, menuContent, triggerBounce, showVi
|
|
|
153
153
|
}, []);
|
|
154
154
|
useEffect(() => {
|
|
155
155
|
const menuEl = menuRef.current;
|
|
156
|
-
if (
|
|
156
|
+
if (menuEl === null)
|
|
157
157
|
return;
|
|
158
158
|
const defer = (cb) => {
|
|
159
159
|
if (typeof queueMicrotask === "function") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
if (typeof document !== "undefined") {
|
|
2
2
|
const styleId = "hidden-menu-wrapper-vars";
|
|
3
|
-
if (
|
|
3
|
+
if (document.getElementById(styleId) === null) {
|
|
4
4
|
const style = document.createElement("style");
|
|
5
5
|
style.id = styleId;
|
|
6
6
|
style.textContent = `
|
|
@@ -91,7 +91,7 @@ export function SharePanelView({ url, copied, onCopy, embedSnippet, embedCopied,
|
|
|
91
91
|
{ value: "request", label: "People you approve" },
|
|
92
92
|
{ value: "public", label: "Anyone with the link" },
|
|
93
93
|
].map((opt) => {
|
|
94
|
-
const active =
|
|
94
|
+
const active = accessPending !== true && opt.value === access;
|
|
95
95
|
const publicAccent = opt.value === "public"
|
|
96
96
|
? active
|
|
97
97
|
? { background: "var(--vibes-blue, #3b82f6)", borderColor: "var(--vibes-blue, #3b82f6)", color: "#fff" }
|
|
@@ -4,10 +4,10 @@ export function SubTabStrip({ tabs, active, onSelect, ariaLabel, compact = false
|
|
|
4
4
|
const [moreRight, setMoreRight] = React.useState(false);
|
|
5
5
|
const ensureActiveVisible = React.useCallback(() => {
|
|
6
6
|
const list = listRef.current;
|
|
7
|
-
if (
|
|
7
|
+
if (list === null)
|
|
8
8
|
return;
|
|
9
9
|
const tab = list.querySelector(`[data-tab-key="${CSS.escape(active)}"]`);
|
|
10
|
-
if (
|
|
10
|
+
if (tab === null)
|
|
11
11
|
return;
|
|
12
12
|
const style = globalThis.getComputedStyle(list);
|
|
13
13
|
const padLeft = parseFloat(style.paddingLeft) || 0;
|
|
@@ -23,7 +23,7 @@ export function SubTabStrip({ tabs, active, onSelect, ariaLabel, compact = false
|
|
|
23
23
|
}, [active]);
|
|
24
24
|
const measureOverflow = React.useCallback(() => {
|
|
25
25
|
const list = listRef.current;
|
|
26
|
-
if (
|
|
26
|
+
if (list === null)
|
|
27
27
|
return;
|
|
28
28
|
setMoreRight(list.scrollWidth - list.clientWidth - list.scrollLeft > 1);
|
|
29
29
|
}, []);
|
|
@@ -31,7 +31,7 @@ export function SubTabStrip({ tabs, active, onSelect, ariaLabel, compact = false
|
|
|
31
31
|
ensureActiveVisible();
|
|
32
32
|
measureOverflow();
|
|
33
33
|
const list = listRef.current;
|
|
34
|
-
if (
|
|
34
|
+
if (list === null || typeof ResizeObserver === "undefined")
|
|
35
35
|
return;
|
|
36
36
|
const ro = new ResizeObserver(() => {
|
|
37
37
|
ensureActiveVisible();
|
|
@@ -34,12 +34,12 @@ export function VibesButton({ variant = "blue", children, onHover, onUnhover, ic
|
|
|
34
34
|
isHovered,
|
|
35
35
|
isActive,
|
|
36
36
|
isMobile,
|
|
37
|
-
hasIcon:
|
|
37
|
+
hasIcon: IconComponent !== undefined,
|
|
38
38
|
});
|
|
39
39
|
const mergedStyle = VibesButtonStyles.getMergedButtonStyle(baseStyle, ignoreDarkMode, customStyle);
|
|
40
|
-
const iconContainerStyle = VibesButtonStyles.getIconContainerStyle(buttonVariant, isMobile,
|
|
40
|
+
const iconContainerStyle = VibesButtonStyles.getIconContainerStyle(buttonVariant, isMobile, IconComponent !== undefined);
|
|
41
41
|
const iconStyle = VibesButtonStyles.getIconStyle(isMobile, isHovered, isActive);
|
|
42
|
-
const contentWrapperStyle = VibesButtonStyles.getContentWrapperStyle(isMobile,
|
|
42
|
+
const contentWrapperStyle = VibesButtonStyles.getContentWrapperStyle(isMobile, IconComponent !== undefined);
|
|
43
43
|
return (React.createElement(React.Fragment, null,
|
|
44
44
|
React.createElement("style", null, bounceKeyframes),
|
|
45
45
|
React.createElement("button", { ...props, className: className, onMouseEnter: () => setHovered(true), onMouseLeave: () => {
|
package/components/VibesPanel.js
CHANGED
|
@@ -36,7 +36,7 @@ export function VibesPanel({ style, className, token, } = {}) {
|
|
|
36
36
|
};
|
|
37
37
|
const handleInviteSubmit = (e) => {
|
|
38
38
|
e.preventDefault();
|
|
39
|
-
if (
|
|
39
|
+
if (email.trim() === "")
|
|
40
40
|
return;
|
|
41
41
|
setInviteStatus("sending");
|
|
42
42
|
setInviteMessage("");
|
|
@@ -77,7 +77,7 @@ export function VibesPanel({ style, className, token, } = {}) {
|
|
|
77
77
|
React.createElement("label", { htmlFor: emailId, style: VibesPanelStyles.getInviteLabelPanelStyle() }, "Invite by email"),
|
|
78
78
|
React.createElement(BrutalistCard, { size: "md", style: VibesPanelStyles.getInviteInputWrapperPanelStyle() },
|
|
79
79
|
React.createElement("input", { id: emailId, type: "email", placeholder: "friend@example.com", value: email, onChange: (e) => setEmail(e.target.value), style: VibesPanelStyles.getInviteInputStyle(), autoComplete: "email", required: true })),
|
|
80
|
-
React.createElement(VibesButton, { variant: BLUE, type: "submit", disabled:
|
|
80
|
+
React.createElement(VibesButton, { variant: BLUE, type: "submit", disabled: email.trim() === "" }, "Send Invite"))) : (React.createElement(BrutalistCard, { id: "invite-status", role: "status", "aria-live": "polite", size: "sm", variant: inviteStatus === "sending" ? "default" : inviteStatus === "error" ? "error" : "success", style: VibesPanelStyles.getInviteStatusStyle() }, inviteStatus === "sending" ? "Inviting..." : inviteMessage)),
|
|
81
81
|
React.createElement(VibesButton, { variant: YELLOW, onClick: handleBackClick, icon: "back" }, "Back"))) : (React.createElement(React.Fragment, null,
|
|
82
82
|
React.createElement(VibesButton, { variant: BLUE, onClick: handleLogoutClick, icon: "login" }, "Logout"),
|
|
83
83
|
React.createElement(VibesButton, { variant: RED, onClick: handleMutateClick, icon: "remix" }, "Remix"),
|
|
@@ -86,7 +86,7 @@ export function ViewerTagView({ slug, displayName, avatarUrl, editable, anonymou
|
|
|
86
86
|
}
|
|
87
87
|
async function handleFileChange(e) {
|
|
88
88
|
const file = e.target.files?.[0];
|
|
89
|
-
if (
|
|
89
|
+
if (file === undefined || onPickFile === undefined)
|
|
90
90
|
return;
|
|
91
91
|
setUploading(true);
|
|
92
92
|
try {
|
package/components/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./QrCode.js";
|
|
|
25
25
|
export * from "./SharePanelView.js";
|
|
26
26
|
export * from "./FilesPanelView.js";
|
|
27
27
|
export * from "./AttachmentRow.js";
|
|
28
|
+
export * from "./AttachmentThumb.js";
|
|
28
29
|
export * from "./BuildCard.js";
|
|
29
30
|
export * from "./NotificationDetailView.js";
|
|
30
31
|
export * from "./ChatMessageRow.js";
|
package/components/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from "./QrCode.js";
|
|
|
25
25
|
export * from "./SharePanelView.js";
|
|
26
26
|
export * from "./FilesPanelView.js";
|
|
27
27
|
export * from "./AttachmentRow.js";
|
|
28
|
+
export * from "./AttachmentThumb.js";
|
|
28
29
|
export * from "./BuildCard.js";
|
|
29
30
|
export * from "./NotificationDetailView.js";
|
|
30
31
|
export * from "./ChatMessageRow.js";
|
|
@@ -51,8 +51,13 @@ export function VibeMenu(props) {
|
|
|
51
51
|
const ownerTap = viewer.role === "owner" && pending === false;
|
|
52
52
|
const badged = props.badges.pendingRequests > 0;
|
|
53
53
|
const openingViewer = { role: viewer.role, canEditSource: viewer.canEditSource, identityPending: viewer.identityPending };
|
|
54
|
-
const shellDispatch = ownerTap || badged
|
|
54
|
+
const shellDispatch = ownerTap || badged || props.pillOpensSection !== undefined
|
|
55
55
|
? (event) => {
|
|
56
|
+
if (event.type === "PILL_TAP" && state.phase === "collapsed" && props.pillOpensSection !== undefined) {
|
|
57
|
+
props.onPillOpen?.();
|
|
58
|
+
dispatch({ type: "OPEN", section: props.pillOpensSection });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
56
61
|
const tapped = badgedTabEvent(event, props.badges.pendingRequests, openingViewer);
|
|
57
62
|
dispatch(ownerTap ? ownerSwitchEvent(state, tapped) : tapped);
|
|
58
63
|
}
|
|
@@ -208,5 +213,5 @@ export function VibeMenu(props) {
|
|
|
208
213
|
share,
|
|
209
214
|
account,
|
|
210
215
|
queued: draft.queued.length,
|
|
211
|
-
}), codeMode: codeOpen && codeModeOn, logOpen: logShowing, badges: props.badges, closedStatus: props.closedStatus, onChiclet: onChiclet, frameCap: props.frameCap === true, frame: props.frame, reducedMotion: props.reducedMotion, switchActivity: props.switchActivity, settledAtMount: props.settledAtMount, switchHiddenAtMount: props.switchHiddenAtMount, chips: chips, hiddenChips: props.badges.hidden, onHideChip: props.badges.onHide, onChipsShown: props.badges.onShown, chipsInside: codeOpen && code.promptContent === undefined, labeled: props.labeledMenu }));
|
|
216
|
+
}), codeMode: codeOpen && codeModeOn, logOpen: logShowing, badges: props.badges, closedStatus: props.closedStatus, onChiclet: onChiclet, frameCap: props.frameCap === true, dock: props.dock === true, frame: props.frame, reducedMotion: props.reducedMotion, switchActivity: props.switchActivity, settledAtMount: props.settledAtMount, switchHiddenAtMount: props.switchHiddenAtMount, chips: chips, hiddenChips: props.badges.hidden, onHideChip: props.badges.onHide, onChipsShown: props.badges.onShown, chipsInside: codeOpen && code.promptContent === undefined, labeled: props.labeledMenu }));
|
|
212
217
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Result } from "@adviser/cement";
|
|
2
2
|
export interface ShareFailure {
|
|
3
3
|
readonly text: string;
|
|
4
|
-
retry()
|
|
4
|
+
readonly retry?: () => void;
|
|
5
5
|
}
|
|
6
6
|
export type ShareFailures = ReadonlyMap<string, ShareFailure>;
|
|
7
7
|
export interface ShareActions {
|
|
@@ -9,5 +9,9 @@ export interface ShareActions {
|
|
|
9
9
|
readonly busy: ReadonlySet<string>;
|
|
10
10
|
run(key: string, failureText: ShareFailureText, action: () => Promise<Result<void>>): Promise<Result<void>>;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export interface ShareFinalFailure {
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly retry: false;
|
|
15
|
+
}
|
|
16
|
+
export type ShareFailureText = string | ((error: Error) => string | ShareFinalFailure);
|
|
13
17
|
export declare function useShareActions(): ShareActions;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useState } from "react";
|
|
2
|
-
function
|
|
3
|
-
|
|
2
|
+
function failureFor(failureText, error, retry) {
|
|
3
|
+
const said = typeof failureText === "string" ? failureText : failureText(error);
|
|
4
|
+
return typeof said === "string" ? { text: said, retry } : { text: said.text };
|
|
4
5
|
}
|
|
5
6
|
function withoutKey(failures, key) {
|
|
6
7
|
if (failures.has(key) === false)
|
|
@@ -22,12 +23,9 @@ export function useShareActions() {
|
|
|
22
23
|
return next;
|
|
23
24
|
});
|
|
24
25
|
if (res.isErr()) {
|
|
25
|
-
setFailures((prev) => new Map(prev).set(key, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
void runAction(key, failureText, action);
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
26
|
+
setFailures((prev) => new Map(prev).set(key, failureFor(failureText, res.Err(), function retry() {
|
|
27
|
+
void runAction(key, failureText, action);
|
|
28
|
+
})));
|
|
31
29
|
}
|
|
32
30
|
return res;
|
|
33
31
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { APPROVE_DATA_ONLY } from "../slices.js";
|
|
2
|
+
import { APPROVE_DATA_ONLY, REQUEST_ALREADY_ANSWERED, REQUEST_ALREADY_IN_OTHER_ROLE } from "../slices.js";
|
|
3
3
|
import { Chip } from "../parts/Chip.js";
|
|
4
4
|
import { Row } from "../parts/Row.js";
|
|
5
5
|
import { MemberRequest, MemberRow, memberDisplayName } from "../parts/MemberRow.js";
|
|
@@ -50,7 +50,7 @@ export function FailureLines({ failures, keys }) {
|
|
|
50
50
|
return null;
|
|
51
51
|
return (React.createElement(React.Fragment, null, shown.map(([key, failure]) => (React.createElement("p", { key: key, className: "vm-fail", role: "alert" },
|
|
52
52
|
React.createElement("span", null, failure.text),
|
|
53
|
-
React.createElement(Chip, { label: "Retry", onClick: failure.retry }))))));
|
|
53
|
+
failure.retry === undefined ? null : React.createElement(Chip, { label: "Retry", onClick: failure.retry }))))));
|
|
54
54
|
}
|
|
55
55
|
export function PublishLine({ publish }) {
|
|
56
56
|
if (publish.state === "published")
|
|
@@ -63,8 +63,15 @@ export function PublishLine({ publish }) {
|
|
|
63
63
|
publish.state === "locked" ? (React.createElement(Chip, { label: "Unlock", onClick: publish.onUnlock })) : (React.createElement(Chip, { label: failed ? "Retry" : "Publish", onClick: publish.onPublish })),
|
|
64
64
|
publish.state === "old" ? React.createElement(Chip, { label: "View latest", ghost: true, onClick: publish.onViewLatest }) : null));
|
|
65
65
|
}
|
|
66
|
+
function alreadyAnswered(handle) {
|
|
67
|
+
return { text: `@${handle}'s request was already answered.`, retry: false };
|
|
68
|
+
}
|
|
66
69
|
function approveFailureText(handle) {
|
|
67
70
|
return function text(error) {
|
|
71
|
+
if (error.message === REQUEST_ALREADY_ANSWERED)
|
|
72
|
+
return alreadyAnswered(handle);
|
|
73
|
+
if (error.message === REQUEST_ALREADY_IN_OTHER_ROLE)
|
|
74
|
+
return { text: `@${handle} is already in. Change their access under Members.`, retry: false };
|
|
68
75
|
if (error.message === APPROVE_DATA_ONLY.codeFailed)
|
|
69
76
|
return `@${handle} has Data access. Code access didn't go through. Try again`;
|
|
70
77
|
if (error.message === APPROVE_DATA_ONLY.codeNeedsHandle)
|
|
@@ -73,7 +80,9 @@ function approveFailureText(handle) {
|
|
|
73
80
|
};
|
|
74
81
|
}
|
|
75
82
|
export function RequestBlock({ request, share, actions, }) {
|
|
76
|
-
return (React.createElement(MemberRequest, { key: request.key, who: request.key, handle: request.handle, ...(request.name === undefined ? {} : { name: request.name }), pending: actions.busy.has(request.key), onApprove: ({ data, code }) => void actions.run(request.key, approveFailureText(request.handle), () => share.onApprove(request.key, data, code)), onDecline: () => void actions.run(request.key,
|
|
83
|
+
return (React.createElement(MemberRequest, { key: request.key, who: request.key, handle: request.handle, ...(request.name === undefined ? {} : { name: request.name }), pending: actions.busy.has(request.key), onApprove: ({ data, code }) => void actions.run(request.key, approveFailureText(request.handle), () => share.onApprove(request.key, data, code)), onDecline: () => void actions.run(request.key, (error) => error.message === REQUEST_ALREADY_ANSWERED
|
|
84
|
+
? alreadyAnswered(request.handle)
|
|
85
|
+
: `Couldn't answer @${request.handle}. Try again`, () => share.onDecline(request.key)) }));
|
|
77
86
|
}
|
|
78
87
|
export function OwnerMemberRow({ member, share, actions, nav, }) {
|
|
79
88
|
const failure = `Couldn't change ${memberDisplayName(member)}'s access. Try again`;
|
|
@@ -26,3 +26,9 @@ export declare function switchInsetCss(viewport: MenuViewport): {
|
|
|
26
26
|
bottom: string;
|
|
27
27
|
};
|
|
28
28
|
export declare const LOG_PEEK_PX = 120;
|
|
29
|
+
export declare const SPLIT_BUILDER_QUERY = "(orientation: landscape) and (pointer: coarse) and (min-width: 900px) and (min-height: 480px)";
|
|
30
|
+
export declare function matchesSplitShape(v: {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
coarse: boolean;
|
|
34
|
+
}): boolean;
|
|
@@ -33,3 +33,7 @@ export function switchInsetCss(viewport) {
|
|
|
33
33
|
return { right: `${px}px`, bottom: `calc(${px}px + env(safe-area-inset-bottom, 0px))` };
|
|
34
34
|
}
|
|
35
35
|
export const LOG_PEEK_PX = 120;
|
|
36
|
+
export const SPLIT_BUILDER_QUERY = "(orientation: landscape) and (pointer: coarse) and (min-width: 900px) and (min-height: 480px)";
|
|
37
|
+
export function matchesSplitShape(v) {
|
|
38
|
+
return v.coarse === true && v.width > v.height && v.width >= 900 && v.height >= 480;
|
|
39
|
+
}
|
|
@@ -87,12 +87,16 @@ export interface ComposerRefusedSend {
|
|
|
87
87
|
readonly ideas: readonly string[];
|
|
88
88
|
}
|
|
89
89
|
export interface ComposerNewAppDoor {
|
|
90
|
-
readonly onStartNewApp: (text: string) => void;
|
|
90
|
+
readonly onStartNewApp: (text: string, attachments: readonly PromptAttachment[]) => void;
|
|
91
91
|
}
|
|
92
|
+
declare function changeBoxAsk(files: readonly {
|
|
93
|
+
readonly kind: string;
|
|
94
|
+
}[], words: boolean): string;
|
|
92
95
|
export declare const CHANGE_BOX_HINT_COPY: Readonly<{
|
|
93
96
|
readonly lead: "Changes this app";
|
|
94
97
|
readonly door: "New idea? Start a new app";
|
|
95
98
|
readonly ask: "Start a new app with these words?";
|
|
99
|
+
readonly askWith: typeof changeBoxAsk;
|
|
96
100
|
readonly yes: "Yes";
|
|
97
101
|
readonly keep: "Keep editing";
|
|
98
102
|
}>;
|
|
@@ -133,3 +137,4 @@ export declare function stopGuardHolds(now: number, armedAt: number | undefined)
|
|
|
133
137
|
export declare function useStopGuardHolds(armedAt: number | undefined, now?: () => number): boolean;
|
|
134
138
|
export declare function latestStopArm(...armedAt: readonly (number | undefined)[]): number | undefined;
|
|
135
139
|
export declare function Composer(props: ComposerProps): React.ReactElement;
|
|
140
|
+
export {};
|
|
@@ -2,11 +2,13 @@ import * as React from "react";
|
|
|
2
2
|
import { attachmentRemoveName, leftOutSentence, } from "../../../attachments/use-attachments.js";
|
|
3
3
|
import { ATTACHMENT_ACCEPT } from "../../../attachments/attachment-types.js";
|
|
4
4
|
import { composerFileDrop } from "../../../attachments/composer-file-drop.js";
|
|
5
|
+
import { composerFilePaste } from "../../../attachments/composer-file-paste.js";
|
|
5
6
|
import { Glyph } from "./Glyph.js";
|
|
6
7
|
import { SendCap } from "./SendCap.js";
|
|
7
8
|
import { useHeldEnterFocus } from "./held-enter-focus.js";
|
|
8
9
|
import { foldKeyboardAfterSend } from "./fold-keyboard.js";
|
|
9
10
|
import { FacesGlyph } from "./ThinkingLine.js";
|
|
11
|
+
import { AttachmentThumb, chipThumbBlob } from "../../AttachmentThumb.js";
|
|
10
12
|
import { DictationCancelIcon, DictationCheckIcon, DictationSpinner, DictationWave, MicIcon, joinDictated, useDictation, } from "../../dictation/dictation.js";
|
|
11
13
|
import { REFUSED_SEND_COPY, REFUSED_SEND_IDEAS, changeRefusedSendLine, refusedSendKind, } from "./refused-send.js";
|
|
12
14
|
function RefusedSendLine(props) {
|
|
@@ -69,46 +71,71 @@ function useIdeaHeld(hold, draft, seed) {
|
|
|
69
71
|
}, [via, text, onIdeaHeld]);
|
|
70
72
|
return via !== undefined;
|
|
71
73
|
}
|
|
74
|
+
function changeBoxAsk(files, words) {
|
|
75
|
+
if (files.length === 0)
|
|
76
|
+
return "Start a new app with these words?";
|
|
77
|
+
const photos = files.every((f) => f.kind === "image");
|
|
78
|
+
const noun = photos ? "photo" : "file";
|
|
79
|
+
if (words) {
|
|
80
|
+
return files.length === 1
|
|
81
|
+
? `Start a new app with these words and ${noun}?`
|
|
82
|
+
: `Start a new app with these words and ${files.length} ${noun}s?`;
|
|
83
|
+
}
|
|
84
|
+
return files.length === 1 ? `Start a new app with this ${noun}?` : `Start a new app with these ${files.length} ${noun}s?`;
|
|
85
|
+
}
|
|
72
86
|
export const CHANGE_BOX_HINT_COPY = Object.freeze({
|
|
73
87
|
lead: "Changes this app",
|
|
74
88
|
door: "New idea? Start a new app",
|
|
75
89
|
ask: "Start a new app with these words?",
|
|
90
|
+
askWith: changeBoxAsk,
|
|
76
91
|
yes: "Yes",
|
|
77
92
|
keep: "Keep editing",
|
|
78
93
|
});
|
|
79
94
|
function ChangeBoxHintLine(props) {
|
|
80
95
|
const { door, draft } = props;
|
|
96
|
+
const files = draft.attachments.readyAttachments;
|
|
97
|
+
const riding = draft.attachments.attachments.filter((c) => c.status !== "error");
|
|
98
|
+
const busy = draft.attachments.busy;
|
|
99
|
+
const holding = `${draft.text}\u0000${riding.length}`;
|
|
81
100
|
const [askedFor, setAskedFor] = React.useState(undefined);
|
|
82
|
-
if (askedFor !== undefined && askedFor !==
|
|
101
|
+
if (askedFor !== undefined && askedFor !== holding)
|
|
83
102
|
setAskedFor(undefined);
|
|
84
103
|
const typed = draft.text.trim();
|
|
85
|
-
if (typed === "")
|
|
104
|
+
if (typed === "" && riding.length === 0)
|
|
86
105
|
return null;
|
|
87
106
|
if (draft.suggestion !== undefined && draft.suggestion === draft.text)
|
|
88
107
|
return null;
|
|
89
108
|
function carry() {
|
|
109
|
+
if (busy)
|
|
110
|
+
return;
|
|
90
111
|
setAskedFor(undefined);
|
|
91
112
|
draft.setText("");
|
|
92
|
-
|
|
113
|
+
draft.attachments.clear();
|
|
114
|
+
door.onStartNewApp(typed, files);
|
|
93
115
|
}
|
|
94
|
-
if (askedFor ===
|
|
116
|
+
if (askedFor === holding) {
|
|
95
117
|
return (React.createElement("p", { className: "vm-door-line", "data-change-box-hint": "", "data-change-box-confirm": "", "aria-live": "polite" },
|
|
96
|
-
React.createElement("span", null, CHANGE_BOX_HINT_COPY.
|
|
118
|
+
React.createElement("span", null, CHANGE_BOX_HINT_COPY.askWith(riding, typed !== "")),
|
|
97
119
|
React.createElement("span", { "aria-hidden": "true" }, " \u00B7 "),
|
|
98
|
-
React.createElement("button", { type: "button", className: "vm-door", onClick: carry }, CHANGE_BOX_HINT_COPY.yes),
|
|
120
|
+
React.createElement("button", { type: "button", className: "vm-door", onClick: carry, disabled: busy }, CHANGE_BOX_HINT_COPY.yes),
|
|
99
121
|
React.createElement("span", { "aria-hidden": "true" }, " \u00B7 "),
|
|
100
122
|
React.createElement("button", { type: "button", className: "vm-door", onClick: () => setAskedFor(undefined) }, CHANGE_BOX_HINT_COPY.keep)));
|
|
101
123
|
}
|
|
102
124
|
return (React.createElement("p", { className: "vm-door-line", "data-change-box-hint": "" },
|
|
103
125
|
React.createElement("span", null, CHANGE_BOX_HINT_COPY.lead),
|
|
104
126
|
React.createElement("span", { "aria-hidden": "true" }, " \u00B7 "),
|
|
105
|
-
React.createElement("button", { type: "button", className: "vm-door", onClick: () => setAskedFor(
|
|
127
|
+
React.createElement("button", { type: "button", className: "vm-door", onClick: () => setAskedFor(holding) }, CHANGE_BOX_HINT_COPY.door)));
|
|
128
|
+
}
|
|
129
|
+
function ChipThumb(props) {
|
|
130
|
+
const blob = chipThumbBlob(props.chip);
|
|
131
|
+
return blob === undefined ? null : React.createElement(AttachmentThumb, { blob: blob, className: "vm-chip-thumb" });
|
|
106
132
|
}
|
|
107
133
|
function StagedAttachments(props) {
|
|
108
134
|
if (props.chips.length === 0)
|
|
109
135
|
return null;
|
|
110
136
|
return (React.createElement("div", { className: "vm-picks vm-attachments", "aria-live": "polite" }, props.chips.map((chip, index) => (React.createElement("button", { key: chip.id, className: "vm-chip is-name is-ghost", type: "button", "data-status": chip.status, title: chip.error, "aria-label": attachmentRemoveName(index), onClick: () => props.onRemove(chip.id) },
|
|
111
137
|
chip.status === "processing" ? React.createElement(FacesGlyph, { size: 12, ink: "current" }) : null,
|
|
138
|
+
React.createElement(ChipThumb, { chip: chip }),
|
|
112
139
|
React.createElement("span", null, chip.name))))));
|
|
113
140
|
}
|
|
114
141
|
export const STOP_GUARD_MS = 4000;
|
|
@@ -413,6 +440,7 @@ export function Composer(props) {
|
|
|
413
440
|
}
|
|
414
441
|
const stopHeldLabel = transcribing || dictationArmed.current ? "Adding your words…" : "Sending…";
|
|
415
442
|
const drop = composerFileDrop({ onFiles: attachments.add });
|
|
443
|
+
const paste = composerFilePaste({ onFiles: attachments.add });
|
|
416
444
|
const leftOutNote = leftOutSentence(attachments.leftOut);
|
|
417
445
|
const next = composer.hold?.next;
|
|
418
446
|
const sendCap = next !== undefined ? (React.createElement("button", { ref: nextCap, className: "vm-cap", type: "button", "data-next": "", "data-composer-submit": "vibe", disabled: composer.disabled === true || next.busy === true, "aria-busy": next.busy === true ? true : undefined, onClick: () => {
|
|
@@ -426,7 +454,7 @@ export function Composer(props) {
|
|
|
426
454
|
} }),
|
|
427
455
|
React.createElement(StagedAttachments, { chips: attachments.attachments, onRemove: attachments.remove }),
|
|
428
456
|
leftOutNote !== undefined ? (React.createElement("p", { className: "vm-attach-note", "aria-live": "polite", "data-testid": "attachment-left-out" }, leftOutNote)) : null,
|
|
429
|
-
React.createElement("label", { ref: box, className: [building ? "vm-composer is-building" : "vm-composer", dictating ? "is-dictating" : ""].join(" ").trim(), onDragOver: drop.onDragOver, onDrop: drop.onDrop },
|
|
457
|
+
React.createElement("label", { ref: box, className: [building ? "vm-composer is-building" : "vm-composer", dictating ? "is-dictating" : ""].join(" ").trim(), onDragOver: drop.onDragOver, onDrop: drop.onDrop, onPaste: paste },
|
|
430
458
|
React.createElement("textarea", { ref: props.fieldRef, rows: 1, value: draft.text, placeholder: transcribing ? "Writing down what you said…" : (props.placeholder ?? composer.placeholder), "aria-label": composer.cap === "Remix this" ? "Describe your remix" : "Describe a change", disabled: composer.disabled, onChange: (event) => {
|
|
431
459
|
if (dictation.note !== undefined)
|
|
432
460
|
dictation.clearNote();
|
|
@@ -13,6 +13,8 @@ export function tabFootprintRect(tab) {
|
|
|
13
13
|
if (run === null)
|
|
14
14
|
return box;
|
|
15
15
|
const r = run.getBoundingClientRect();
|
|
16
|
+
if (r.width === 0 && r.height === 0)
|
|
17
|
+
return box;
|
|
16
18
|
const left = Math.min(box.left, r.left);
|
|
17
19
|
const top = Math.min(box.top, r.top);
|
|
18
20
|
return new DOMRect(left, top, Math.max(box.right, r.right) - left, Math.max(box.bottom, r.bottom) - top);
|