@peasant-labs/fairtrade 0.0.39 → 0.0.40

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,3 +1,14 @@
1
+ /**
2
+ * The words of a wrapped command and the spaces between them, as the line breaks them: a lone "|"
3
+ * keeps to the word after it, so a pipe never starts or ends a line on its own.
4
+ * @param {string} command
5
+ * @returns {Array<{ word: string } | { space: string }>}
6
+ */
7
+ export function commandWords(command: string): Array<{
8
+ word: string;
9
+ } | {
10
+ space: string;
11
+ }>;
1
12
  /**
2
13
  * CommandBlock — a square `$ command` block: a mono command line with a leading dim `$`, and a copy
3
14
  * button that flips to an olive check + the word "copied" for ~1.5s.
@@ -6,12 +6,14 @@
6
6
  *
7
7
  * redaction: variant="redaction", pass `matches` = [{ category, confidence, original,
8
8
  * replacement, oldNo, newNo }]. each match is a del→add pair with a category/
9
- * confidence badge and a per-match keep/revert button.
9
+ * confidence badge and a per-match keep/revert button. `category` is the engine's
10
+ * (RedactionCategory: secrets, pii, paths, project) and shows as the engine's label;
11
+ * an unknown category (a rule name, a display label) shows an alert and no match.
10
12
  *
11
13
  * @param {object} props
12
14
  * @param {string} props.file - the file path shown in the header (mono, not lowercased)
13
15
  * @param {Array<{header?:string, lines:Array<{type:'add'|'del'|'ctx', oldNo?:number|string, newNo?:number|string, text:string}>}>} [props.hunks] - structured hunks (default variant)
14
- * @param {Array<{category:string, confidence:number, original:string, replacement:string, oldNo?:number|string, newNo?:number|string}>} [props.matches] - redaction matches (redaction variant)
16
+ * @param {Array<{category:import('@peasant-labs/schema').RedactionCategory, confidence:number, original:string, replacement:string, oldNo?:number|string, newNo?:number|string}>} [props.matches] - redaction matches (redaction variant)
15
17
  * @param {'default'|'redaction'} [props.variant='default']
16
18
  * @param {string} [props.className]
17
19
  */
@@ -27,7 +29,7 @@ export default function DiffView({ file, hunks, matches, variant, className, ...
27
29
  }>;
28
30
  }>;
29
31
  matches?: Array<{
30
- category: string;
32
+ category: import("@peasant-labs/schema").RedactionCategory;
31
33
  confidence: number;
32
34
  original: string;
33
35
  replacement: string;
@@ -4,15 +4,19 @@
4
4
  * @param {object} props
5
5
  * @param {PublishState} props.state
6
6
  * @param {number} [props.collectives] - how many collectives can read it (published, new-turns, publishing); left out of the words when omitted.
7
- * @param {number} [props.newTurns] - turns recorded since the last publish (new-turns).
7
+ * @param {number} [props.newTurns] - turns recorded since the last publish (new-turns); the label says "needs update".
8
8
  * @param {string} [props.collective] - the collective(s) the project's auto-publish rule targets (auto-publish).
9
+ * @param {'public'|'private'} [props.visibility] - published: who can find it beyond its collectives, as the host knows
10
+ * it. "published, public" and "published, private" are said only from this; without it a transcript no
11
+ * collective reads is just "published".
9
12
  * @param {string} [props.className]
10
13
  */
11
- export function PublishStateLabel({ state, collectives, newTurns, collective, className, ...rest }: {
14
+ export function PublishStateLabel({ state, collectives, newTurns, collective, visibility, className, ...rest }: {
12
15
  state: PublishState;
13
16
  collectives?: number;
14
17
  newTurns?: number;
15
18
  collective?: string;
19
+ visibility?: "public" | "private";
16
20
  className?: string;
17
21
  }): import("react").JSX.Element;
18
22
  /**
@@ -25,16 +29,18 @@ export function PublishStateLabel({ state, collectives, newTurns, collective, cl
25
29
  * @param {number} [props.collectives]
26
30
  * @param {number} [props.newTurns]
27
31
  * @param {string} [props.collective]
32
+ * @param {'public'|'private'} [props.visibility]
28
33
  * @param {() => void} [props.onAction] - the one button. omit it and no button renders.
29
34
  * @param {string} [props.actionLabel] - replaces the state's default label.
30
35
  * @param {import('./Menu.jsx').MenuItem[]} [props.moreItems] - an optional overflow menu after the button.
31
36
  * @param {string} [props.className]
32
37
  */
33
- export function PublishBar({ state, collectives, newTurns, collective, onAction, actionLabel, moreItems, className, ...rest }: {
38
+ export function PublishBar({ state, collectives, newTurns, collective, visibility, onAction, actionLabel, moreItems, className, ...rest }: {
34
39
  state: PublishState;
35
40
  collectives?: number;
36
41
  newTurns?: number;
37
42
  collective?: string;
43
+ visibility?: "public" | "private";
38
44
  onAction?: () => void;
39
45
  actionLabel?: string;
40
46
  moreItems?: import("./Menu.jsx").MenuItem[];
@@ -96,7 +102,7 @@ export function CollectivePicker({ suggestions, onAdd, query: queryProp, onQuery
96
102
  * checkbox, then the done state with the village link. The host drives `state`; the popup never
97
103
  * advances on its own.
98
104
  *
99
- * States: `connect` (this computer is not signed in to village), `waiting-github` (after continue
105
+ * States: `connect` (this computer is not signed in to peasant online), `waiting-github` (after continue
100
106
  * with github), `checking` (the redaction check is running), `scan-failed` (publish is off,
101
107
  * re-scan stays on), `no-collective` (signed in, in no collective), `ready`, `publishing`,
102
108
  * `stopped` (a named step failed; the host names any changes already applied), `done`, `waits-approval` (done, and
@@ -108,7 +114,7 @@ export function CollectivePicker({ suggestions, onAdd, query: queryProp, onQuery
108
114
  * @param {string} props.title - the session title, kept in its case.
109
115
  * @param {'publish'|'update'} [props.mode='publish']
110
116
  * @param {PublishDialogState} props.state - one of PUBLISH_DIALOG_STATES.
111
- * @param {{ matches?: import('./Redaction.jsx').RedactionMatch[], matchCount?: number, total?: number, failure?: string, failureDetail?: string, failureAction?: { label: string, onSelect: () => void, busy?: boolean } }} [props.scan] - the host's scan result. `failure` is one plain line; `failureAction` is a button in the failure box (the one action that fixes it); `failureDetail`, the actionable detail (what, why, where, the fix), shows as pre-wrapped mono text behind a "details" disclosure in the failure box. `matchCount` is the full occurrence count when `matches` contains only examples. Until it carries a
117
+ * @param {{ matches?: import('./Redaction.jsx').RedactionMatch[], matchCount?: number, total?: number, failure?: string, failureDetail?: string, failureAction?: { label: string, onSelect: () => void, busy?: boolean }, note?: { line: string, detail?: string } }} [props.scan] - the host's scan result. `note` is a quiet line under a finished scan's count (what the scanned copy leaves out, and why), with its detail behind a "details" disclosure; it is information, not an alert, and publishing stays on. `failure` is one plain line; `failureAction` is a button in the failure box (the one action that fixes it); `failureDetail`, the actionable detail (what, why, where, the fix), shows as pre-wrapped mono text behind a "details" disclosure in the failure box. `matchCount` is the full occurrence count when `matches` contains only examples. Until it carries a
112
118
  * `matches` list, the popup says the transcript is not scanned and keeps publish off. A match with `kept: true` leaves un-redacted, and the
113
119
  * popup says so and opens the matches.
114
120
  * @param {() => void} [props.onRescan]
@@ -125,13 +131,18 @@ export function CollectivePicker({ suggestions, onAdd, query: queryProp, onQuery
125
131
  * @param {string} [props.primaryLabel] - replaces the derived primary label.
126
132
  * @param {() => void} [props.onPublish]
127
133
  * @param {() => void} [props.onConnect] - `continue with github`.
128
- * @param {string} [props.joinHref] - `create or join one on village`.
134
+ * @param {string} [props.joinHref] - `create or join one on peasant online`.
129
135
  * @param {string} [props.stoppedAt] - the step that failed, in words ("setting who can read it").
136
+ * @param {string} [props.stoppedDetail] - stopped state: the host's actionable detail, pre-wrapped mono text behind a
137
+ * "details" disclosure in the stopped box.
138
+ * @param {{ line: string, detail?: string, onRetry?: () => void, busy?: boolean }} [props.accessFailure] - the
139
+ * collectives could not be read. "who can read it" shows the line, a retry for that read and the detail in
140
+ * place of the access list and picker, and publishing stays off. The dialog's state stays the host's.
130
141
  * @param {() => void} [props.onRecover] - stopped-state prerequisite read/sign-in recovery only; may run before a scan or audience exists, but never with an explicitly refused review. Mutually exclusive with onRetry. Must not publish.
131
142
  * @param {() => void} [props.onRetry] - stopped-state actual publication retry; requires a valid review and audience. Mutually exclusive with onRecover.
132
143
  * @param {{ url: string, collectives: string[], pending?: string[], pullRequest?: { number: number, branch: string, href?: string } }} [props.done]
133
144
  */
134
- export function PublishDialog({ open, onClose, title, mode, state, scan, onRescan, checking, changes, access, onRemove, onRestore, picker, autoPublish, accessSummary, primaryLabel, onPublish, onConnect, joinHref, stoppedAt, onRecover, onRetry, done, }: {
145
+ export function PublishDialog({ open, onClose, title, mode, state, scan, onRescan, checking, changes, access, onRemove, onRestore, picker, autoPublish, accessSummary, primaryLabel, onPublish, onConnect, joinHref, stoppedAt, stoppedDetail, accessFailure, onRecover, onRetry, done, }: {
135
146
  open: boolean;
136
147
  onClose: () => void;
137
148
  title: string;
@@ -148,6 +159,10 @@ export function PublishDialog({ open, onClose, title, mode, state, scan, onResca
148
159
  onSelect: () => void;
149
160
  busy?: boolean;
150
161
  };
162
+ note?: {
163
+ line: string;
164
+ detail?: string;
165
+ };
151
166
  };
152
167
  onRescan?: () => void;
153
168
  checking?: {
@@ -176,6 +191,13 @@ export function PublishDialog({ open, onClose, title, mode, state, scan, onResca
176
191
  onConnect?: () => void;
177
192
  joinHref?: string;
178
193
  stoppedAt?: string;
194
+ stoppedDetail?: string;
195
+ accessFailure?: {
196
+ line: string;
197
+ detail?: string;
198
+ onRetry?: () => void;
199
+ busy?: boolean;
200
+ };
179
201
  onRecover?: () => void;
180
202
  onRetry?: () => void;
181
203
  done?: {
@@ -11,11 +11,13 @@
11
11
  * @property {React.ComponentType<{size?: number}>} [stateIcon] override icon for the
12
12
  * .sw-state marker; defaults to CircleCheck (on) / Circle (off).
13
13
  * @property {string} [id] id for the control; links the label's `for`.
14
+ * @property {boolean} [stateMarker=true] show the on/off word beside the switch; off where the
15
+ * host already says the state (a settings row).
14
16
  */
15
17
  /**
16
18
  * @param {SwitchProps} props
17
19
  */
18
- export default function Switch({ checked, defaultChecked, onChange, disabled, busy, label, onText, offText, stateIcon: StateIcon, id, }: SwitchProps): import("react").JSX.Element;
20
+ export default function Switch({ checked, defaultChecked, onChange, disabled, busy, label, onText, offText, stateIcon: StateIcon, id, stateMarker, }: SwitchProps): import("react").JSX.Element;
19
21
  export type SwitchProps = {
20
22
  /**
21
23
  * controlled on/off state; pair with onChange.
@@ -60,4 +62,9 @@ export type SwitchProps = {
60
62
  * id for the control; links the label's `for`.
61
63
  */
62
64
  id?: string;
65
+ /**
66
+ * show the on/off word beside the switch; off where the
67
+ * host already says the state (a settings row).
68
+ */
69
+ stateMarker?: boolean;
63
70
  };
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Compact token count: 1234 → "1.2k", 62_000 → "62k", 1_234_567 → "1.23M".
2
+ * Compact token count, the library's one count format: 1234 → "1.2k", 62_000 → "62k",
3
+ * 1_234_567 → "1.2M", 66_731_500_000 → "66.7B". A negative count is not a count and reads "—".
3
4
  * @param {number | null | undefined} n
4
5
  * @returns {string}
5
6
  */
@@ -1,4 +1,35 @@
1
- /** Compact counts use one decimal place and lowercase magnitude suffixes. */
2
- export function formatCount(value: any): string;
3
- /** Calendar dates are stable across host locales; date-only inputs stay on their UTC day. */
4
- export function formatDate(value: any): string;
1
+ /**
2
+ * Compact count, one decimal at most: 999 → "999", 1234 → "1.2k", 66_731_500_000 → "66.7B".
3
+ * @param {unknown} value
4
+ * @returns {string}
5
+ */
6
+ export function formatCount(value: unknown): string;
7
+ /**
8
+ * Exact grouped integer: 272000 → "272,000". A bigint or a string of digits stays exact past the
9
+ * JS-safe range; any other value is rounded.
10
+ * @param {unknown} value
11
+ * @returns {string}
12
+ */
13
+ export function formatInteger(value: unknown): string;
14
+ /**
15
+ * A cost in US dollars at cents: "$0.30", "$1,234.56", "$0.00" for zero, "<$0.01" for a positive
16
+ * amount under one cent. Accepts the recorded decimal string as it arrives.
17
+ * @param {unknown} value
18
+ * @returns {string}
19
+ */
20
+ export function formatCost(value: unknown): string;
21
+ /**
22
+ * A decimal at fixed places: 0.99 → "0.99", 0.5 with 2 places → "0.50".
23
+ * @param {unknown} value
24
+ * @param {number} places
25
+ * @returns {string}
26
+ */
27
+ export function formatDecimal(value: unknown, places: number): string;
28
+ /**
29
+ * Calendar dates are stable across host locales; date-only inputs stay on their UTC day.
30
+ * @param {string | number | Date} value
31
+ * @returns {string}
32
+ */
33
+ export function formatDate(value: string | number | Date): string;
34
+ /** What every formatter shows for a missing or unreadable value. */
35
+ export const MISSING_NUMBER: "\u2014";
@@ -55,6 +55,7 @@ export { default as Breadcrumb, Steps } from "./Breadcrumb.jsx";
55
55
  export { default as Tooltip, Popover } from "./Tooltip.jsx";
56
56
  export { Avatar, AvatarGroup, Kbd, KbdChord, Tag } from "./Avatar.jsx";
57
57
  export { default as BrandMark, resolveBrand } from "./BrandMark.jsx";
58
+ export { formatCount, formatInteger, formatCost, formatDecimal, MISSING_NUMBER } from "./format.js";
58
59
  export { providerAccent, providerDisplayName } from "./provider-policy.js";
59
60
  export { Skeleton, Progress, Spinner, Toast, FeedbackPanel } from "./Feedback.jsx";
60
61
  export { DataTableToolbar, DataTablePaginationControls } from "./DataTableControls.jsx";