use-chisel 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ export declare const STORAGE_SCHEMA_VERSION: 1;
2
+ export type StoredElementChange = {
3
+ selector: string;
4
+ sourceHint?: string;
5
+ text?: string;
6
+ styles: Partial<Record<string, string>>;
7
+ asset?: {
8
+ fileName: string;
9
+ mimeType: string;
10
+ size: number;
11
+ };
12
+ };
13
+ export type StoredVersion = {
14
+ id: string;
15
+ name: string;
16
+ elements: Record<string, StoredElementChange>;
17
+ };
18
+ export type VersionEnvelope = {
19
+ schemaVersion: typeof STORAGE_SCHEMA_VERSION;
20
+ activeVersionId: string;
21
+ versions: StoredVersion[];
22
+ };
23
+ export type StorageResult = {
24
+ envelope?: VersionEnvelope;
25
+ warning?: string;
26
+ migrated: boolean;
27
+ };
28
+ export declare function createVersionEnvelope(versions: StoredVersion[], activeVersionId: string): VersionEnvelope;
29
+ export declare function parseVersionStorage(raw: string | null): StorageResult;
30
+ export declare function isVersionEnvelope(value: unknown): value is VersionEnvelope;
@@ -0,0 +1 @@
1
+ export declare const themeCSS = "\n:is(.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box) :focus{outline:none}\n.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:light;--chisel-ui-panel-shadow:0 4px 20px rgba(0,0,0,.08);--chisel-ui-canvas:#f7f7f7;--chisel-ui-surface:#ffffff;--chisel-ui-raised:#f5f5f5;--chisel-ui-inset:#eeeeee;--chisel-ui-hover:#f0f0f0;--chisel-ui-selected:#eaeaea;--chisel-ui-border:#e2e2e2;--chisel-ui-border-strong:#c4c4c4;--chisel-ui-text:#242424;--chisel-ui-secondary:#626262;--chisel-ui-muted:#686868;--chisel-ui-focus:#2468d3;--chisel-ui-accent-text:#2468d3;--chisel-ui-accent-surface:#edf4ff;--chisel-ui-action:#242424;--chisel-ui-action-text:#ffffff;--chisel-ui-danger:#b33737;--chisel-ui-avatar:#ededed;--chisel-ui-avatar-text:#565656;--chisel-ui-scrollbar:#c2c2c2;--chisel-ui-checker-light:#e5e5e5;--chisel-ui-checker-dark:#c7c7c7;}\n@media(prefers-color-scheme:dark){.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:dark;--chisel-ui-panel-shadow:0 4px 20px #0003;--chisel-ui-canvas:#171717;--chisel-ui-surface:#222222;--chisel-ui-raised:#2a2a2a;--chisel-ui-inset:#191919;--chisel-ui-hover:#303030;--chisel-ui-selected:#383838;--chisel-ui-border:#3c3c3c;--chisel-ui-border-strong:#555555;--chisel-ui-text:#ededed;--chisel-ui-secondary:#b7b7b7;--chisel-ui-muted:#a5a5a5;--chisel-ui-focus:#8bb9ff;--chisel-ui-accent-text:#8bb9ff;--chisel-ui-accent-surface:#253447;--chisel-ui-action:#ededed;--chisel-ui-action-text:#111111;--chisel-ui-danger:#ffa5a5;--chisel-ui-avatar:#383838;--chisel-ui-avatar-text:#cccccc;--chisel-ui-scrollbar:#50504d;--chisel-ui-checker-light:#555555;--chisel-ui-checker-dark:#333333;}\n}\n\n.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-font:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,\"Segoe UI\",sans-serif;--chisel-ui-space:4px;--chisel-ui-control:40px;--chisel-ui-radius:8px;--chisel-ui-text-size:13px;--chisel-ui-small:12px;--chisel-ui-motion:120ms cubic-bezier(.2,0,0,1);--chisel-ui-popover-shadow:0 2px 6px #0000000f,0 12px 36px #0000001f;}\n@media(prefers-color-scheme:dark){.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-popover-shadow:0 0 0 1px #ffffff0d,0 4px 12px #0003,0 16px 40px #0004;}}\n";
@@ -0,0 +1,6 @@
1
+ export default function ColorPicker({ label, value, onChange, disabled }: {
2
+ label: string;
3
+ value: string;
4
+ onChange(value: string): void;
5
+ disabled: boolean;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ export type HSV = {
2
+ h: number;
3
+ s: number;
4
+ v: number;
5
+ a: number;
6
+ };
7
+ export declare function rgbToHsv(r: number, g: number, b: number, a?: number): HSV;
8
+ export declare function hsvToHex({ h, s, v, a }: HSV): string;
9
+ export declare function readColor(value: string): HSV;
@@ -0,0 +1,28 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ import { type StyleChange } from "./style-changes";
3
+ import type { WorkspaceAttachment } from "./comments";
4
+ export type { StyleChange } from "./style-changes";
5
+ export type WorkspaceComposerProps = {
6
+ text: string;
7
+ onText(value: string): void;
8
+ disabled: boolean;
9
+ commentId?: string;
10
+ onAttachmentDraftChange?(hasDraft: boolean): void;
11
+ onSubmit(text: string, body?: unknown, attachmentTokens?: string[], attachments?: WorkspaceAttachment[]): Promise<boolean>;
12
+ renderContent(editor: ReactNode, hasAttachments?: boolean, uploading?: boolean, actions?: ReactNode): ReactNode;
13
+ };
14
+ export default function CommentBox({ target, text, onText, onCancel, onPost, style, changes, editing, commentId, renderComposer, hasExistingAttachments, onDraftChange, hidden }: {
15
+ target: Element;
16
+ text: string;
17
+ onText(value: string): void;
18
+ onCancel(): void;
19
+ onPost(changes: StyleChange[], text: string, body?: unknown, attachmentTokens?: string[], attachments?: WorkspaceAttachment[]): Promise<boolean>;
20
+ style: CSSProperties;
21
+ hidden?: boolean;
22
+ changes?: StyleChange[];
23
+ hasExistingAttachments?: boolean;
24
+ editing?: boolean;
25
+ commentId?: string;
26
+ renderComposer?: (props: WorkspaceComposerProps) => ReactNode;
27
+ onDraftChange?(hasDraft: boolean): void;
28
+ }): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export default function CommentDragHandle({ onMoveStart }: {
2
+ onMoveStart?: () => void;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,80 @@
1
+ import type { StyleChange } from "./style-changes";
2
+ export type CommentAnchor = {
3
+ x: number;
4
+ y: number;
5
+ selector?: string;
6
+ offsetX?: number;
7
+ offsetY?: number;
8
+ tag?: string;
9
+ };
10
+ export type WorkspaceAttachment = {
11
+ id: string;
12
+ name: string;
13
+ mimeType: string;
14
+ size: number;
15
+ previewUrl?: string;
16
+ };
17
+ export type WorkspaceReply = {
18
+ id?: string;
19
+ text: string;
20
+ author: string;
21
+ authorId: string;
22
+ authorImage?: string | null;
23
+ attachments?: WorkspaceAttachment[];
24
+ body?: unknown;
25
+ date?: string;
26
+ pending?: boolean;
27
+ };
28
+ export type WorkspaceComment = CommentAnchor & {
29
+ id: string;
30
+ path: string;
31
+ text: string;
32
+ author: string;
33
+ authorId?: string;
34
+ authorImage?: string | null;
35
+ date: string;
36
+ resolved: boolean;
37
+ replies: (string | WorkspaceReply)[];
38
+ changes?: StyleChange[];
39
+ attachments?: WorkspaceAttachment[];
40
+ body?: unknown;
41
+ pending?: boolean;
42
+ };
43
+ export type CommentMutation = {
44
+ type: "create";
45
+ comment: WorkspaceComment;
46
+ body?: unknown;
47
+ attachmentTokens?: string[];
48
+ } | {
49
+ type: "edit";
50
+ id: string;
51
+ text: string;
52
+ changes: StyleChange[];
53
+ body?: unknown;
54
+ attachmentTokens?: string[];
55
+ } | {
56
+ type: "reply";
57
+ id: string;
58
+ reply: WorkspaceReply;
59
+ body?: unknown;
60
+ attachmentTokens?: string[];
61
+ } | {
62
+ type: "resolve";
63
+ id: string;
64
+ resolved: boolean;
65
+ };
66
+ export type CommentStore = {
67
+ list(): Promise<WorkspaceComment[]>;
68
+ mutate(change: CommentMutation): Promise<WorkspaceComment>;
69
+ delete?(id: string): Promise<void>;
70
+ subscribe?(onChange: () => void): () => void;
71
+ };
72
+ export declare function applyCommentMutation(comments: WorkspaceComment[], change: CommentMutation): WorkspaceComment;
73
+ export declare function mergeComment(comments: WorkspaceComment[], comment: WorkspaceComment): WorkspaceComment[];
74
+ export declare function removeComment(comments: WorkspaceComment[], id: string): WorkspaceComment[];
75
+ export declare function commentParticipants(comment: WorkspaceComment): {
76
+ author: string;
77
+ authorImage?: string | null;
78
+ }[];
79
+ export declare function filterComments(comments: WorkspaceComment[], filter: string, search: string): WorkspaceComment[];
80
+ export declare function commentAge(date: string, now?: number): string;
@@ -0,0 +1,13 @@
1
+ type Size = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ export declare function composerPosition(pin: {
6
+ x: number;
7
+ y: number;
8
+ }, card: Size, viewport: Size): {
9
+ left: number;
10
+ top: number;
11
+ maxHeight: number;
12
+ };
13
+ export {};
@@ -0,0 +1,11 @@
1
+ type Confirmation = {
2
+ title: string;
3
+ description: string;
4
+ action: string;
5
+ danger?: boolean;
6
+ };
7
+ export declare function useConfirmation(): {
8
+ confirm: (next: Confirmation) => Promise<boolean>;
9
+ dialog: import("react").JSX.Element | null;
10
+ };
11
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare function createHoverDismiss(onClose: () => void): {
2
+ cancel: () => void;
3
+ schedule(): void;
4
+ };
@@ -0,0 +1 @@
1
+ export declare function modeShortcut(event: KeyboardEvent): "comment" | "edit" | "view" | "toggle-comments" | undefined;
@@ -0,0 +1,7 @@
1
+ export default function PageControl({ path, routes, disabled, onNavigate, onOpen }: {
2
+ path: string;
3
+ routes: string[];
4
+ disabled: boolean;
5
+ onNavigate(input: string): Promise<boolean>;
6
+ onOpen?(): void;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare function normalizePreviewPath(input: string, origin: string, currentPath?: string): string | null;
2
+ export declare function previewPagePath(path: string): string;
3
+ export declare function previewPath(win: Pick<Window, "location">): string | null;
4
+ export declare function observePreviewNavigation(win: Window, onNavigate: (path: string) => void): () => void;
@@ -0,0 +1,3 @@
1
+ export declare function ChiselPreview({ projectName }: {
2
+ projectName?: string;
3
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ export type StyleChange = {
2
+ property: string;
3
+ before: string;
4
+ after: string;
5
+ };
6
+ export declare function linkedStyleUpdates(property: string, value: string, pair: readonly string[], initial: Record<string, string>): Record<string, string>;
7
+ export declare function commentStyleValues(current: Record<string, string>, changes: StyleChange[]): {
8
+ initial: {
9
+ [x: string]: string;
10
+ };
11
+ values: {
12
+ [x: string]: string;
13
+ };
14
+ };
15
+ export declare function previewStyleChanges(target: Element, changes: StyleChange[]): () => void;
@@ -0,0 +1 @@
1
+ export declare function ChiselWorkspaceStyles(): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function animateThread(card: HTMLElement, closing?: boolean, previous?: Animation | null): Animation | null;
@@ -0,0 +1,51 @@
1
+ import { type ReactNode } from "react";
2
+ import { type WorkspaceComposerProps } from "./comment-box";
3
+ import { type WorkspaceAttachment, type WorkspaceComment as Comment, type CommentStore } from "./comments";
4
+ export type WorkspaceUser = {
5
+ id: string;
6
+ name: string;
7
+ email: string;
8
+ image?: string | null;
9
+ };
10
+ export type WorkspaceCollaboration = {
11
+ status: string;
12
+ participants: {
13
+ id: string;
14
+ name: string;
15
+ image?: string | null;
16
+ path: string;
17
+ }[];
18
+ unreadThreadIds: readonly string[];
19
+ markRead(id: string): void;
20
+ setPage(path: string): void;
21
+ };
22
+ export type WorkspaceThreadProps = {
23
+ comment: Comment;
24
+ expanded: boolean;
25
+ reply: string;
26
+ saving: boolean;
27
+ canResolve: boolean;
28
+ submittingReply?: boolean;
29
+ onReplyText(text: string): void;
30
+ onReply(text: string, body?: unknown, attachmentTokens?: string[], attachments?: WorkspaceAttachment[]): Promise<boolean>;
31
+ onResolve(): void;
32
+ onExpand(): void;
33
+ replyAuthor?: Pick<WorkspaceUser, "name" | "image">;
34
+ onAttachmentDraftChange?(hasDraft: boolean): void;
35
+ };
36
+ export type WorkspaceCommentUI = {
37
+ className?: string;
38
+ renderComposer(props: WorkspaceComposerProps): ReactNode;
39
+ renderThread(props: WorkspaceThreadProps): ReactNode;
40
+ };
41
+ export declare function elementSelector(element: Element): string;
42
+ export default function ChiselWorkspace({ user, validateSession, signOut, commentStore, canManageComments, getReviewLink, collaboration, commentUI }: {
43
+ user: WorkspaceUser;
44
+ validateSession: () => Promise<boolean>;
45
+ signOut: () => Promise<void>;
46
+ commentStore?: CommentStore;
47
+ canManageComments?: boolean;
48
+ getReviewLink?: (rotate?: boolean) => Promise<string>;
49
+ collaboration?: WorkspaceCollaboration;
50
+ commentUI?: WorkspaceCommentUI;
51
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export { default as ChiselWorkspace } from "./workspace/workspace";
2
+ export type { WorkspaceUser, WorkspaceCollaboration, WorkspaceCommentUI, WorkspaceThreadProps } from "./workspace/workspace";
3
+ export { ChiselPreview } from "./workspace/preview";
4
+ export { ChiselWorkspaceStyles } from "./workspace/styles";
5
+ export type { CommentStore, CommentMutation, WorkspaceComment, WorkspaceReply, WorkspaceAttachment } from "./workspace/comments";
6
+ export type { WorkspaceComposerProps } from "./workspace/comment-box";