@thehammer/template-verification 0.2.21 → 0.2.23

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,23 @@
1
+ import type { ConfidenceLevel } from "@danxbot/ui/pure";
2
+ /**
3
+ * THE LETTER'S CONFIDENCE BAR — the Vue twin of `@danxbot/ui`'s React
4
+ * `ConfidenceBar`, drawn to the same spec from the same tokens (SG-901):
5
+ *
6
+ * not rated dotted grey outline across the whole slot, no fill
7
+ * 1..5 a fill 20% of the slot long per level, in that level's colour
8
+ * (dark red, light red, yellow, light green, dark green), no track
9
+ *
10
+ * The colours are the `--confidence-*` custom properties from
11
+ * `@danxbot/ui/confidence.css`, never a local palette. `data-theme="light"`
12
+ * resolves them to their light-theme values: this bar is drawn on a letter, and
13
+ * a letter is paper whatever the reader's OS theme is.
14
+ *
15
+ * The slot is one fixed size in every state, so a mark never changes size when a
16
+ * rating arrives. Each fill class is written out whole, never assembled at
17
+ * runtime — Tailwind finds classes by scanning source text.
18
+ */
19
+ type __VLS_Props = {
20
+ level: ConfidenceLevel | null;
21
+ };
22
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ export default _default;
@@ -1,14 +1,19 @@
1
- import type { VerificationStatus } from "../types";
1
+ import type { ConfidenceState } from "../types";
2
2
  /**
3
- * Pure presentational confidence/status glyph. Given either a raw integer
4
- * confidence (1-5) or an explicit status, renders a colored glyph and optional
5
- * label. Buckets the INTEGER never string-matches the confidence (see
6
- * {@link bucketConfidence}). No interactivity.
3
+ * A machine value's confidence mark in the letter the SAME scale the Demand
4
+ * Desk draws (SG-901): a bar as long as the level, in the level's colour, dotted
5
+ * when nothing rated it. It used to be a ✔/⚠/✕ glyph in three colour buckets, so
6
+ * a 4 and a 5 were identical here while the screen beside the letter drew them
7
+ * differently.
8
+ *
9
+ * `failed` is not a level — the extraction or its citation correction did not
10
+ * produce an answer (SG-189) — so it keeps its own red ⊗ chip rather than a bar.
11
+ *
12
+ * Presentational only; the button around it (in `VerifiedField`) owns the
13
+ * interaction and the accessible name.
7
14
  */
8
15
  type __VLS_Props = {
9
- confidence?: number | null;
10
- status?: VerificationStatus;
11
- showLabel?: boolean;
16
+ state: ConfidenceState;
12
17
  };
13
18
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
19
  export default _default;
@@ -119,6 +119,28 @@ type __VLS_Props = {
119
119
  field?: string;
120
120
  original?: string | number | null;
121
121
  format?: (value: unknown) => string;
122
+ /**
123
+ * SG-974: text to render, styled as an italic placeholder, in place of the
124
+ * default-slot fallback when this field has no value. Rendered INSIDE
125
+ * `.tv-field-value` — the same box the real value would occupy — rather
126
+ * than left for the host template to draw beside `<VerifiedField>` as its
127
+ * own separate markup.
128
+ *
129
+ * That distinction is the whole point, not a style preference. The mark's
130
+ * anchor is a zero-size box glued to the trailing edge of whatever
131
+ * `.tv-field-value` rendered (see the header docblock's "ANCHORING"
132
+ * section) — when there is no value, that box renders NOTHING and
133
+ * collapses to zero width, so the anchor lands at the field's own
134
+ * starting point. A placeholder a host template draws AFTER
135
+ * `<VerifiedField>` as a sibling (`v-if="!value"`) therefore renders
136
+ * AFTER that zero-width point too, putting the mark to the LEFT of the
137
+ * placeholder it is supposed to trail — exactly the reported bug (SG-974).
138
+ * Accepting the placeholder text here and rendering it as the value
139
+ * box's own content puts it before the anchor in the same inline flow
140
+ * the anchor already tracks, so the mark lands to its right in every
141
+ * state, the same guarantee a real value already gets.
142
+ */
143
+ placeholder?: string;
122
144
  };
123
145
  declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
124
146
  default?: ((props: {
package/dist/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export { default as VerificationChrome } from "./components/VerificationChrome.v
33
33
  export { default as ConfidenceIcon } from "./components/ConfidenceIcon.vue";
34
34
  export { TEMPLATE_MESSAGE_SOURCE, TEMPLATE_PROTOCOL_VERSION, DATA_POINT_ACTIVATED, embedderOrigin, notifyDataPointActivated, } from "./lib/hostBridge";
35
35
  export type { DataPointActivatedMessage, DataPointActivation, } from "./lib/hostBridge";
36
- export { bucketConfidence, STATUS_COLORS, STATUS_LABELS, } from "./lib/confidence";
36
+ export { ratingLevel, confidenceStateOf, confidenceStateLabel, CONFIDENCE_SCALE, } from "./lib/confidence";
37
37
  export { resolveDataPoint, resolveCandidates, RESOLUTION_PRIORITY, } from "./lib/resolveDataPoint";
38
38
  export { hasDiscrepancy, candidatesDisagree } from "./lib/discrepancy";
39
39
  export { walkDataPoints } from "./lib/walk";
@@ -41,4 +41,4 @@ export type { WalkedDataPoint } from "./lib/walk";
41
41
  export { computeProgress } from "./lib/progress";
42
42
  export type { VerificationProgress } from "./lib/progress";
43
43
  export { CHROME_CLASS, EDITABLE_CLASS, ENABLED_STORAGE_KEY } from "./constants";
44
- export type { VerificationStatus, ResolvedSource, SourceChoice, VerificationSource, ExtractedCandidate, HumanCitation, OverrideCandidate, ClaimCandidate, CandidateSet, DataPointAnchor, ResolvedValue, DataPointMeta, MetaCarrier, SaveOverrideArgs, SaveOverrideFn, } from "./types";
44
+ export type { ConfidenceState, ResolvedSource, SourceChoice, VerificationSource, ExtractedCandidate, HumanCitation, OverrideCandidate, ClaimCandidate, CandidateSet, DataPointAnchor, ResolvedValue, DataPointMeta, MetaCarrier, SaveOverrideArgs, SaveOverrideFn, } from "./types";
@@ -1,25 +1,28 @@
1
- import type { VerificationStatus } from "../types";
1
+ import { type ConfidenceLevel } from "@danxbot/ui/pure";
2
+ import type { ConfidenceState } from "../types";
2
3
  /**
3
- * Bucket the INTEGER confidence (1-5) into a verification status.
4
+ * THE LETTER'S CONFIDENCE SCALE IS THE DEMAND DESK'S — SG-901.
4
5
  *
5
- * null / undefined unverifiable (no extraction provenance)
6
- * <= 2 → low
7
- * == 3 → medium
8
- * >= 4 → high
9
- *
10
- * IMPORTANT: this buckets the NUMBER. The host app once shipped a confidence
11
- * component that string-matched "high"/"medium"/"low"; real data is the integer
12
- * 1-5, so that component silently fell through to "none" for every value. Do NOT
13
- * reintroduce string matching here — bucket the integer.
6
+ * The level a rating maps to and each level's words come from `@danxbot/ui/pure`,
7
+ * and the colours from `@danxbot/ui/confidence.css` (imported by `styles.css`).
8
+ * Both are bundled into this package at build time, so a template installs
9
+ * nothing new, and there is still exactly one copy of the scale: this overlay used
10
+ * to keep its own three buckets, and a 4 and a 5 read the same in the letter
11
+ * while the screen beside it drew them differently.
14
12
  */
15
- export declare function bucketConfidence(confidence?: number | null): VerificationStatus;
13
+ /** The top of the scale the extractor self-rates on. */
14
+ export declare const CONFIDENCE_SCALE = 5;
16
15
  /**
17
- * Tailwind pill-badge classes per status (bg tint + text + ring), for
18
- * ConfidenceIcon's soft-badge treatment. Each value's color family (green/
19
- * yellow/red/gray) is load-bearing ConfidenceIcon.test.ts asserts the
20
- * rendered class list CONTAINS that literal color word, so any restyle must
21
- * keep the same family per status even if the shade/utility changes.
16
+ * A raw confidence to the level it draws as, or null when there is no rating.
17
+ *
18
+ * Only a real number counts. The host once shipped a component that string-matched
19
+ * "high"/"medium"/"low", and real data is the integer 1-5, so that component silently
20
+ * showed nothing for every value. A non-number is "no rating", never matched.
22
21
  */
23
- export declare const STATUS_COLORS: Record<VerificationStatus, string>;
24
- /** Human-readable status label. */
25
- export declare const STATUS_LABELS: Record<VerificationStatus, string>;
22
+ export declare function ratingLevel(confidence: unknown): ConfidenceLevel | null;
23
+ /** A machine value's mark: its failure first, else its level, else unrated. */
24
+ export declare function confidenceStateOf(confidence: unknown, failed: boolean): ConfidenceState;
25
+ export declare const UNRATED_LABEL = "Not rated";
26
+ export declare const FAILED_LABEL = "Failed";
27
+ /** The words for a mark — the level's own word, "Not rated", or "Failed". */
28
+ export declare function confidenceStateLabel(state: ConfidenceState): string;