@danxbot/ui 3.13.0 → 4.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.
@@ -1,6 +1,12 @@
1
+ import { type ConfidenceScore } from "./types";
1
2
  export interface ConfidenceMeterProps {
2
- /** 0..1, or null when nothing scored it. */
3
- confidence: number | null;
3
+ /**
4
+ * A 0–1 score from `confidenceScore()`, or null when nothing scored it.
5
+ *
6
+ * Deliberately NOT a plain number — see the header. A raw literal will not
7
+ * type-check, which is what keeps a "4 out of 5" out of a percentage.
8
+ */
9
+ confidence: ConfidenceScore | null;
4
10
  /**
5
11
  * What to say when there is no score.
6
12
  *
@@ -0,0 +1,17 @@
1
+ import type { ProvenanceConfidence } from "./types";
2
+ export interface ConfidenceReadoutProps {
3
+ confidence: ProvenanceConfidence | null;
4
+ /**
5
+ * What to say when nothing scored it.
6
+ *
7
+ * Text rather than an empty bar, because a bar at zero and a bar with nothing
8
+ * to show look identical and mean opposite things.
9
+ */
10
+ unscoredLabel?: string;
11
+ /** What a RATING is of, at the head of its accessible name. @default "Confidence" */
12
+ ratingLabel?: string;
13
+ /** Hides the band name on a SCORE, for dense rows where the bar is enough. */
14
+ compact?: boolean;
15
+ className?: string;
16
+ }
17
+ export declare function ConfidenceReadout({ confidence, unscoredLabel, ratingLabel, compact, className, }: ConfidenceReadoutProps): import("react").JSX.Element;
@@ -0,0 +1,109 @@
1
+ import { type VariantProps } from "tailwind-variants";
2
+ declare const pips: import("tailwind-variants").TVReturnType<{
3
+ size: {
4
+ xs: {
5
+ root: string;
6
+ pip: string;
7
+ };
8
+ sm: {
9
+ root: string;
10
+ pip: string;
11
+ };
12
+ };
13
+ band: {
14
+ high: {
15
+ pip: string;
16
+ };
17
+ moderate: {
18
+ pip: string;
19
+ };
20
+ low: {
21
+ pip: string;
22
+ };
23
+ };
24
+ }, {
25
+ root: string;
26
+ pip: string;
27
+ }, undefined, {
28
+ size: {
29
+ xs: {
30
+ root: string;
31
+ pip: string;
32
+ };
33
+ sm: {
34
+ root: string;
35
+ pip: string;
36
+ };
37
+ };
38
+ band: {
39
+ high: {
40
+ pip: string;
41
+ };
42
+ moderate: {
43
+ pip: string;
44
+ };
45
+ low: {
46
+ pip: string;
47
+ };
48
+ };
49
+ }, {
50
+ root: string;
51
+ pip: string;
52
+ }, import("tailwind-variants").TVReturnTypeLike<{
53
+ size: {
54
+ xs: {
55
+ root: string;
56
+ pip: string;
57
+ };
58
+ sm: {
59
+ root: string;
60
+ pip: string;
61
+ };
62
+ };
63
+ band: {
64
+ high: {
65
+ pip: string;
66
+ };
67
+ moderate: {
68
+ pip: string;
69
+ };
70
+ low: {
71
+ pip: string;
72
+ };
73
+ };
74
+ }, {
75
+ root: string;
76
+ pip: string;
77
+ }>>;
78
+ /** How big the ticks are. See the two variants above for where each is used. */
79
+ export type RatingPipsSize = NonNullable<VariantProps<typeof pips>["size"]>;
80
+ export interface RatingPipsProps {
81
+ /**
82
+ * The rating itself, on `scale`. Null when nothing rated it — which draws the
83
+ * empty box rather than nothing at all, so the row keeps its height.
84
+ */
85
+ rating: number | null;
86
+ /** The top of the scale — the "5" in "4 out of 5". */
87
+ scale: number;
88
+ /**
89
+ * What the rating is OF, used verbatim at the head of the accessible name and
90
+ * the tooltip: `"<label> 3 of 5"`.
91
+ *
92
+ * A default that named the consumer's domain would be a lie in every other
93
+ * consumer, so it is the blandest true word.
94
+ *
95
+ * @default "Confidence"
96
+ */
97
+ label?: string;
98
+ /**
99
+ * Draw the pips at full marks too.
100
+ *
101
+ * @default false — see "FULL MARKS DRAW NOTHING" above.
102
+ */
103
+ showWhenFull?: boolean;
104
+ /** @default "sm" */
105
+ size?: RatingPipsSize;
106
+ className?: string;
107
+ }
108
+ export declare function RatingPips({ rating, scale, label, showWhenFull, size, className, }: RatingPipsProps): import("react").JSX.Element;
109
+ export {};
@@ -1,5 +1,7 @@
1
1
  export * from "./types";
2
2
  export * from "./ConfidenceMeter";
3
+ export * from "./ConfidenceReadout";
4
+ export * from "./RatingPips";
3
5
  export * from "./ProvenanceBadge";
4
6
  export * from "./ProvenanceDetail";
5
7
  export * from "./ProvenanceDisclosure";
@@ -56,8 +56,12 @@ export interface ProvenanceRecord {
56
56
  /** Null when it failed, or when the viewer may not see it. */
57
57
  value: ReactNode | null;
58
58
  state: ProvenanceState;
59
- /** 0..1. Null when nothing scored it. */
60
- confidence: number | null;
59
+ /**
60
+ * How sure the author was, on whichever scale they said it — `scoredConfidence`
61
+ * for a continuous 0–1 figure, `ratedConfidence` for "4 out of 5". Null when
62
+ * nothing scored it, which is a different claim from a score of zero.
63
+ */
64
+ confidence: ProvenanceConfidence | null;
61
65
  source: ProvenanceSource | null;
62
66
  reasoning: string | null;
63
67
  check: ProvenanceCheck | null;
@@ -73,6 +77,73 @@ export interface ProvenanceRecord {
73
77
  */
74
78
  redacted?: boolean;
75
79
  }
80
+ declare const CONFIDENCE_SCORE: unique symbol;
81
+ /**
82
+ * A confidence on the CONTINUOUS 0–1 scale — the one thing that may be drawn as
83
+ * a percentage.
84
+ *
85
+ * Nominal on purpose. It IS a number at runtime and arithmetic on it behaves
86
+ * exactly as it reads, but a raw `0.94` is not assignable to it. `confidenceScore`
87
+ * is the only way in, and is therefore the one place a range can be checked.
88
+ */
89
+ export type ConfidenceScore = number & {
90
+ readonly [CONFIDENCE_SCORE]: "score";
91
+ };
92
+ /**
93
+ * Mint a 0–1 score.
94
+ *
95
+ * Out of range is CLAMPED and warned about rather than thrown: the caller most
96
+ * likely to be out of range is one holding a rating on some other scale, and a
97
+ * blank page is a worse outcome than a bar at one end with a line in the console
98
+ * naming the function that fixes it.
99
+ */
100
+ export declare function confidenceScore(value: number): ConfidenceScore;
101
+ /**
102
+ * HOW SURE THE AUTHOR WAS, carrying WHICH KIND OF SCALE it was said on.
103
+ *
104
+ * Never written as a literal — see the brand above. `scoredConfidence` and
105
+ * `ratedConfidence` are the two doors, and which door a value came through is
106
+ * what the renderer dispatches on.
107
+ */
108
+ export type ProvenanceConfidence =
109
+ /** Continuous 0–1. Drawn as a banded meter with its percentage. */
110
+ {
111
+ readonly kind: "score";
112
+ readonly score: ConfidenceScore;
113
+ }
114
+ /**
115
+ * `rating` out of `scale`, both whole numbers. Drawn as pips — one per point
116
+ * — because the scale's own granularity is the finest thing that can honestly
117
+ * be shown.
118
+ */
119
+ | {
120
+ readonly kind: "rating";
121
+ readonly rating: number;
122
+ readonly scale: number;
123
+ };
124
+ /** A continuous 0–1 confidence, for a record. */
125
+ export declare function scoredConfidence(value: number): ProvenanceConfidence;
126
+ /**
127
+ * A discrete `rating` out of `scale`, for a record.
128
+ *
129
+ * The denominator travels WITH the number, because "4" means nothing on its own
130
+ * and every consumer that has had to pass a rating around without one has ended
131
+ * up hard-coding the scale at the far end.
132
+ */
133
+ export declare function ratedConfidence(rating: number, scale: number): ProvenanceConfidence;
76
134
  /** 0..1 to a band. A bare percentage invites false precision. */
77
135
  export type ConfidenceBand = "high" | "moderate" | "low";
78
- export declare function confidenceBand(confidence: number): ConfidenceBand;
136
+ export declare function confidenceBand(confidence: ConfidenceScore): ConfidenceBand;
137
+ /**
138
+ * A RATING to the same three bands, so pips and a meter agree about what
139
+ * "moderate" looks like.
140
+ *
141
+ * Full marks are their own band — `high` — and the rest fall where the same
142
+ * thresholds put them once the rating is read as a fraction of its own scale.
143
+ * That is the only conversion to a fraction anywhere in this file, and it feeds
144
+ * a COLOUR rather than a printed figure, which is the distinction the whole
145
+ * split rests on: a band is a judgement three values wide and survives the trip;
146
+ * a percentage is a figure and does not.
147
+ */
148
+ export declare function ratingBand(rating: number, scale: number): ConfidenceBand;
149
+ export {};
@@ -109,7 +109,7 @@ export { AmbiguousTimeError, addDays, addDuration, addMonths, atMidnight, atTime
109
109
  export { allDayBandSegment, dayKey, daySlots, isAllDay, packBand, packLanes, snapFractionToInstant, timeSegments, timedBandSegment, type AllDayEvent, type BandInput, type BandOptions, type BandPlacement, type BandResult, type BandSegment, type CalendarEvent, type CalendarEventId, type CalendarView, type DaySlot, type DragKind, type EventDraft, type EventPalette, type LaneInput, type LaneOptions, type LanePlacement, type PaletteEntry, type TimeSegment, type TimedEvent, type VisibleRange, } from "./lib/calendar";
110
110
  export { RBACProvider, useRBAC, AccountMenu, DevToolsPopover, RolePermissionMatrix, ProfilePage, RolesPermissionsPage, type RBACProviderProps, type RBACHookResult, type AccountMenuProps, type DevToolsPopoverProps, type RolePermissionMatrixProps, type Permission, type Role, type User, type Team, type TeamMembership, } from "./components/rbac";
111
111
  export { UseCaseCard, RoadmapItemCard, RoadmapSwimlaneBoard, UseCaseLedgerPage, RoadmapPage, PhaseManager, TrackManager, deriveRoadmapItemStatus, isFullyBuilt, isUnbuilt, trackIds, trackProgress, toneForIndex, CATEGORY_TONES, type Domain, type Phase, type Track, type RoadmapItem, type RoadmapItemStatus, type UseCase, type UseCaseStatus, type UseCaseDecision, type UseCaseCardProps, type RoadmapItemCardProps, type RoadmapSwimlaneBoardProps, type UseCaseLedgerPageProps, type RoadmapPageProps, type PhaseManagerProps, type TrackManagerProps, } from "./components/roadmap";
112
- export { ProvenanceDisclosure, ProvenanceDetail, ProvenanceBadge, ConfidenceMeter, provenanceStateLabel, confidenceBand, type ProvenanceRecord, type ProvenanceState, type ProvenanceSource, type ProvenanceCheck, type ProvenanceCall, type ProvenanceSignoff, type ConfidenceBand, type ProvenanceDisclosureProps, type ProvenanceDetailProps, type ProvenanceDetailTitleAs, type ProvenanceTriggerBadge, type ProvenanceBadgeProps, type ProvenanceBadgeAppearance, type ConfidenceMeterProps, } from "./components/provenance";
112
+ export { ProvenanceDisclosure, ProvenanceDetail, ProvenanceBadge, ConfidenceReadout, ConfidenceMeter, RatingPips, provenanceStateLabel, confidenceBand, ratingBand, confidenceScore, scoredConfidence, ratedConfidence, type ProvenanceRecord, type ProvenanceState, type ProvenanceSource, type ProvenanceCheck, type ProvenanceCall, type ProvenanceSignoff, type ConfidenceBand, type ConfidenceScore, type ProvenanceConfidence, type ConfidenceReadoutProps, type RatingPipsProps, type RatingPipsSize, type ProvenanceDisclosureProps, type ProvenanceDetailProps, type ProvenanceDetailTitleAs, type ProvenanceTriggerBadge, type ProvenanceBadgeProps, type ProvenanceBadgeAppearance, type ConfidenceMeterProps, } from "./components/provenance";
113
113
  export { createSimStore, resetSimStores, useSimSettings, setSimSettings, getNetworkSpeed, getDataSource, simulateLatency, SimNetworkError, type SimStore, type SimStoreOptions, type SimSettings, type NetworkSpeed, type DataSource, type SimNamespace, } from "./lib/sim";
114
114
  export { NodeCanvas, LAYOUT_DEFAULTS, layoutTree, pathToNode, type NodeCanvasProps, type CanvasEdge, type CanvasLayout, type CanvasNode, type CanvasOrientation, type LayoutOptions, type NodeRenderContext, type NodeRenderer, type PlacedNode, } from "./components/node-canvas";
115
115
  export { defineRecordType, resetRecordTypes, useRecord, useRecords, useStaleness, write, writeAll, peekRecord, readState, readStaleness, subscribeToKey, subscribeToStaleness, retainKeys, sweepRecords, setRecordStoreTenant, getRecordStoreTenant, flushRecordNotifications, resetRecordStore, recordStoreStats, UNKNOWN_STATE, normalizeTypeName, normalizeTimestamp, recordKey, isRecordRef, type RecordRef, type ReadOptions, type RecordPayload, type RecordState, type RecordTypeOptions, type RecordTypeToken, type StalenessEntry, type WriteAllResult, type WriteOptions, type WriteResult, type WriteSource, type WriteVerdict, } from "./lib/records";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danxbot/ui",
3
- "version": "3.13.0",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "description": "Danxbot — a domain-agnostic React design system with motion as a first-class primitive.",
6
6
  "license": "MIT",