@llumi/design-system 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -6
- package/custom-elements.json +68 -9
- package/dist/review.cjs +26 -26
- package/dist/review.js +26 -26
- package/dist/review.mjs +485 -391
- package/dist/types/components/review/review.element.d.ts +10 -4
- package/dist/types/components/review/review.machine.d.ts +6 -0
- package/dist/types/components/review/review.persistence.d.ts +16 -0
- package/dist/types/components/review/review.type.d.ts +5 -0
- package/package.json +1 -1
|
@@ -2,16 +2,17 @@ import { CustomTarget } from './custom-target.utils';
|
|
|
2
2
|
import { ReviewResult } from './review.type';
|
|
3
3
|
/**
|
|
4
4
|
* `<llumi-review>` — wraps light-DOM content for element- and text-selection
|
|
5
|
-
* review comments. Both events
|
|
5
|
+
* review comments. Both events bubble and are composed.
|
|
6
6
|
*
|
|
7
|
-
* @fires llumi-review-change - On every edit (comment added/edited/deleted, or overall comment changed).
|
|
8
|
-
* @fires llumi-review-submit - When the user clicks Submit / Approve.
|
|
7
|
+
* @fires llumi-review-change - On every edit (comment added/edited/deleted, or overall comment changed). `detail` is a `ReviewResult`.
|
|
8
|
+
* @fires llumi-review-submit - When the user clicks Submit / Approve. `detail` is `{ result: ReviewResult, clearPersisted: () => void }`; call `clearPersisted()` after a confirmed server save to discard the persisted draft.
|
|
9
9
|
*/
|
|
10
10
|
export declare class LlumiReview extends HTMLElement {
|
|
11
11
|
static observedAttributes: string[];
|
|
12
12
|
initialData?: ReviewResult;
|
|
13
13
|
customTargets?: CustomTarget[];
|
|
14
14
|
private actor;
|
|
15
|
+
private persistence;
|
|
15
16
|
private manager;
|
|
16
17
|
private rangeMap;
|
|
17
18
|
private hoveredComment;
|
|
@@ -24,10 +25,15 @@ export declare class LlumiReview extends HTMLElement {
|
|
|
24
25
|
private get shortcut();
|
|
25
26
|
private get barPosition();
|
|
26
27
|
private get defaultMode();
|
|
28
|
+
private get persistKey();
|
|
27
29
|
connectedCallback(): void;
|
|
28
30
|
disconnectedCallback(): void;
|
|
29
31
|
attributeChangedCallback(): void;
|
|
30
|
-
private
|
|
32
|
+
private buildDetailResult;
|
|
33
|
+
private emitChange;
|
|
34
|
+
private emitSubmit;
|
|
35
|
+
/** Clears the persisted draft for this element. No-op when persistence is off. */
|
|
36
|
+
clearPersisted(): void;
|
|
31
37
|
private mountChrome;
|
|
32
38
|
private onIconClick;
|
|
33
39
|
private syncFromSnapshot;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReviewPersistence } from './review.persistence';
|
|
1
2
|
import { ReviewComment, ReviewResult, SelectionRange } from './review.type';
|
|
2
3
|
export interface HighlightCallbacks {
|
|
3
4
|
activate: (commentedIds: Set<string>) => void;
|
|
@@ -16,6 +17,7 @@ type ReviewMachineContext = {
|
|
|
16
17
|
shortcut: string;
|
|
17
18
|
defaultMode: "idle" | "annotating";
|
|
18
19
|
highlights: HighlightCallbacks;
|
|
20
|
+
persistence: ReviewPersistence;
|
|
19
21
|
};
|
|
20
22
|
type ReviewMachineEvents = {
|
|
21
23
|
type: "TOGGLE";
|
|
@@ -61,6 +63,7 @@ type ReviewMachineInput = {
|
|
|
61
63
|
initialData?: ReviewResult;
|
|
62
64
|
defaultMode: "idle" | "annotating";
|
|
63
65
|
highlights: HighlightCallbacks;
|
|
66
|
+
persistence: ReviewPersistence;
|
|
64
67
|
};
|
|
65
68
|
export declare function buildReviewResult(context: Pick<ReviewMachineContext, "comments" | "overallComment">): ReviewResult;
|
|
66
69
|
export declare function createReviewMachine(): import('xstate').StateMachine<ReviewMachineContext, {
|
|
@@ -136,6 +139,9 @@ export declare function createReviewMachine(): import('xstate').StateMachine<Rev
|
|
|
136
139
|
} | {
|
|
137
140
|
type: "emitChanged";
|
|
138
141
|
params: import('xstate').NonReducibleUnknown;
|
|
142
|
+
} | {
|
|
143
|
+
type: "persistSave";
|
|
144
|
+
params: unknown;
|
|
139
145
|
} | {
|
|
140
146
|
type: "emitSubmitted";
|
|
141
147
|
params: import('xstate').NonReducibleUnknown;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReviewResult } from './review.type';
|
|
2
|
+
/**
|
|
3
|
+
* Storage engine for `<llumi-review>` drafts. Injected into the review machine
|
|
4
|
+
* via input (mirrors `HighlightCallbacks`). All access is best-effort: it never
|
|
5
|
+
* throws into the component.
|
|
6
|
+
*/
|
|
7
|
+
export interface ReviewPersistence {
|
|
8
|
+
/** Read + parse + validate. Returns undefined on miss or corruption. */
|
|
9
|
+
load(): ReviewResult | undefined;
|
|
10
|
+
/** Write JSON. An empty/`approved` result removes the key instead. */
|
|
11
|
+
save(result: ReviewResult): void;
|
|
12
|
+
/** Remove the stored draft. */
|
|
13
|
+
clear(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const noopPersistence: ReviewPersistence;
|
|
16
|
+
export declare function createReviewPersistence(key: string): ReviewPersistence;
|
|
@@ -18,6 +18,11 @@ export type ReviewResult = {
|
|
|
18
18
|
comments: ReviewComment[];
|
|
19
19
|
overallComment?: string;
|
|
20
20
|
};
|
|
21
|
+
export interface ReviewSubmitDetail {
|
|
22
|
+
result: ReviewResult;
|
|
23
|
+
/** Clears the persisted draft for this element. No-op when persistence is off. */
|
|
24
|
+
clearPersisted: () => void;
|
|
25
|
+
}
|
|
21
26
|
export type ReviewBarPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
22
27
|
export type ReviewMode = "idle" | "commenting" | "editing";
|
|
23
28
|
/**
|