@tetsuo-ai/marketplace-react 0.1.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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/chunk-5OTKSRHM.js +128 -0
- package/dist/chunk-5OTKSRHM.js.map +1 -0
- package/dist/chunk-ABS77JB2.js +94 -0
- package/dist/chunk-ABS77JB2.js.map +1 -0
- package/dist/chunk-GN5DYVN5.js +35 -0
- package/dist/chunk-GN5DYVN5.js.map +1 -0
- package/dist/chunk-KJMR6OGC.js +1198 -0
- package/dist/chunk-KJMR6OGC.js.map +1 -0
- package/dist/chunk-YORZNYZZ.js +107 -0
- package/dist/chunk-YORZNYZZ.js.map +1 -0
- package/dist/components/agenc-components.css +570 -0
- package/dist/components/index.cjs +1335 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +5 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.cjs +493 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +294 -0
- package/dist/hooks/index.d.ts +294 -0
- package/dist/hooks/index.js +339 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index-BLrlBVj-.d.cts +1129 -0
- package/dist/index-CKTYsNPH.d.ts +1129 -0
- package/dist/index.cjs +1690 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +235 -0
- package/dist/index.d.ts +235 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -0
- package/dist/signers/index.cjs +166 -0
- package/dist/signers/index.cjs.map +1 -0
- package/dist/signers/index.d.cts +136 -0
- package/dist/signers/index.d.ts +136 -0
- package/dist/signers/index.js +4 -0
- package/dist/signers/index.js.map +1 -0
- package/dist/testing/index.cjs +62 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +71 -0
- package/dist/testing/index.d.ts +71 -0
- package/dist/testing/index.js +60 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/theme/agenc-tailwind-preset.cjs +184 -0
- package/dist/theme/agenc-tokens.css +132 -0
- package/dist/types-jvISR6bc.d.cts +135 -0
- package/dist/types-jvISR6bc.d.ts +135 -0
- package/dist/useAgentTrackRecord-BLf1nrbu.d.cts +249 -0
- package/dist/useAgentTrackRecord-BLf1nrbu.d.ts +249 -0
- package/package.json +139 -0
- package/src/components/DisputeBanner.stories.tsx +39 -0
- package/src/components/DisputeBanner.tsx +110 -0
- package/src/components/HireButton.stories.tsx +72 -0
- package/src/components/HireButton.tsx +151 -0
- package/src/components/HireCheckoutModal.stories.tsx +107 -0
- package/src/components/HireCheckoutModal.tsx +284 -0
- package/src/components/ListingCard.stories.tsx +55 -0
- package/src/components/ListingCard.tsx +148 -0
- package/src/components/ListingGrid.stories.tsx +44 -0
- package/src/components/ListingGrid.tsx +137 -0
- package/src/components/Modal.tsx +121 -0
- package/src/components/PoweredByAgenC.tsx +85 -0
- package/src/components/ProviderCard.stories.tsx +61 -0
- package/src/components/ProviderCard.tsx +154 -0
- package/src/components/ReferrerDisclosure.tsx +67 -0
- package/src/components/ReviewPanel.stories.tsx +65 -0
- package/src/components/ReviewPanel.tsx +141 -0
- package/src/components/TaskTimeline.stories.tsx +43 -0
- package/src/components/TaskTimeline.tsx +156 -0
- package/src/components/__fixtures__/index.tsx +173 -0
- package/src/components/agenc-components.css +570 -0
- package/src/components/badges.tsx +115 -0
- package/src/components/format.ts +150 -0
- package/src/components/index.ts +102 -0
- package/src/components/primitives.tsx +236 -0
- package/src/components/strings.ts +131 -0
- package/src/components/useFocusTrap.ts +122 -0
- package/src/hooks/index.ts +90 -0
- package/src/hooks/internal.ts +70 -0
- package/src/hooks/useAgentTrackRecord.ts +166 -0
- package/src/hooks/useDispute.ts +130 -0
- package/src/hooks/useHire.ts +198 -0
- package/src/hooks/useListing.ts +138 -0
- package/src/hooks/useListings.ts +133 -0
- package/src/hooks/useReferrerEarnings.ts +134 -0
- package/src/hooks/useSubmissionReview.ts +179 -0
- package/src/hooks/useTaskStatus.ts +192 -0
- package/src/hooks/useWalletSigner.ts +99 -0
- package/src/index.ts +170 -0
- package/src/provider/AgencProvider.tsx +169 -0
- package/src/provider/context.ts +35 -0
- package/src/provider/index.ts +17 -0
- package/src/provider/network.ts +68 -0
- package/src/provider/referrer.ts +97 -0
- package/src/signers/README.md +130 -0
- package/src/signers/embedded-wallet-mock.ts +158 -0
- package/src/signers/embedded-wallet.ts +64 -0
- package/src/signers/index.ts +48 -0
- package/src/signers/strings.ts +39 -0
- package/src/signers/types.ts +158 -0
- package/src/signers/wallet-account.ts +128 -0
- package/src/signers/wallet-adapter.ts +149 -0
- package/src/strings/index.ts +119 -0
- package/src/testing/index.ts +24 -0
- package/src/theme/agenc-tailwind-preset.cjs +184 -0
- package/src/theme/agenc-tokens.css +132 -0
- package/src/theme/index.ts +94 -0
- package/src/transport/index.ts +164 -0
- package/src/types.ts +224 -0
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
import { ReactNode, ButtonHTMLAttributes, HTMLAttributes, RefObject } from 'react';
|
|
2
|
+
import { ListActiveListingsOptions, DecodedProgramAccount, ServiceListing, IndexerListing, IndexerHire, IndexerAgentTrackRecord, MarketplaceClient, ProgramAccountsTransport, CreateIndexerClientOptions, TaskStatus } from '@tetsuo-ai/marketplace-sdk';
|
|
3
|
+
import { Address, TransactionSigner, Rpc, GetProgramAccountsApi } from '@solana/kit';
|
|
4
|
+
import { e as HireStatus, b as AnyHireInput, i as ReviewStatus, c as DisputeStatus, a as AgentTrackRecord } from './useAgentTrackRecord-BLf1nrbu.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shared types for `@tetsuo-ai/marketplace-react`.
|
|
8
|
+
*
|
|
9
|
+
* Re-exported from the package root so hooks/components agents (and consumers)
|
|
10
|
+
* bind to one canonical set. SDK types are referenced by import, not copied.
|
|
11
|
+
*
|
|
12
|
+
* @module types
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Indexer connection config for the read transport. Mirrors the SDK's
|
|
17
|
+
* {@link CreateIndexerClientOptions} subset the provider needs (baseUrl is
|
|
18
|
+
* what flips the transport into indexer-first mode).
|
|
19
|
+
*/
|
|
20
|
+
interface IndexerConfig {
|
|
21
|
+
/** Base URL of the hosted indexer/storefront API. Presence = indexer-first. */
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
/** Optional API key (`X-Agenc-Api-Key`). Anonymous reads work without it. */
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A kit RPC capable of `getProgramAccounts`, or any SDK
|
|
28
|
+
* {@link ProgramAccountsTransport} — the gPA fallback read source.
|
|
29
|
+
*/
|
|
30
|
+
type GpaReadSource = Rpc<GetProgramAccountsApi> | ProgramAccountsTransport;
|
|
31
|
+
/**
|
|
32
|
+
* The unified read interface the provider exposes (indexer-first, gPA
|
|
33
|
+
* fallback). Both backends return parity shapes by SDK design, so a hook never
|
|
34
|
+
* branches on which one is live.
|
|
35
|
+
*
|
|
36
|
+
* - `listActiveListings` returns the SAME `Array<{ address, account }>` shape
|
|
37
|
+
* from both the indexer and the gPA path.
|
|
38
|
+
* - `getListing` returns the indexer's rich `IndexerListing` when available;
|
|
39
|
+
* the gPA fallback synthesizes the same shape from a decoded account.
|
|
40
|
+
* - `listingHires` / `agentTrackRecord` are indexer-native; the gPA fallback
|
|
41
|
+
* throws a descriptive {@link ReadTransportUnsupportedError} (no trustless
|
|
42
|
+
* gPA equivalent exists for an aggregated track record).
|
|
43
|
+
*/
|
|
44
|
+
interface ReadTransport {
|
|
45
|
+
/** Which backend is in use — for diagnostics and conditional UI. */
|
|
46
|
+
readonly kind: "indexer" | "gpa";
|
|
47
|
+
/** List active service listings (parity shape across both backends). */
|
|
48
|
+
listActiveListings(options?: ListActiveListingsOptions): Promise<Array<DecodedProgramAccount<ServiceListing>>>;
|
|
49
|
+
/** Fetch one listing by PDA. */
|
|
50
|
+
getListing(pda: Address | string): Promise<ReadListingResult>;
|
|
51
|
+
/** Hires of a listing (indexer-native; gPA fallback is unsupported). */
|
|
52
|
+
listingHires(pda: Address | string): Promise<IndexerHire[]>;
|
|
53
|
+
/** Agent track record (indexer-native; gPA fallback is unsupported). */
|
|
54
|
+
agentTrackRecord(pda: Address | string): Promise<IndexerAgentTrackRecord>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The unified `getListing` result. When the indexer backend is live this is the
|
|
58
|
+
* full {@link IndexerListing}; under the gPA fallback the `decoded` projection
|
|
59
|
+
* is absent and `account` carries the decoded on-chain bytes.
|
|
60
|
+
*/
|
|
61
|
+
interface ReadListingResult {
|
|
62
|
+
/** The listing PDA. */
|
|
63
|
+
address: Address;
|
|
64
|
+
/** The decoded on-chain account (always present). */
|
|
65
|
+
account: ServiceListing;
|
|
66
|
+
/** The indexer's rich projection, when the indexer backend served this. */
|
|
67
|
+
indexer?: IndexerListing;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Options for `createReadTransport`. Supplying `queryTransport` (a mock or a
|
|
71
|
+
* pre-built transport) overrides everything — this is the public test seam the
|
|
72
|
+
* provider re-exposes via `config.queryTransport`.
|
|
73
|
+
*/
|
|
74
|
+
interface CreateReadTransportConfig {
|
|
75
|
+
/** Indexer connection (presence of `baseUrl` selects the indexer backend). */
|
|
76
|
+
indexer?: IndexerConfig;
|
|
77
|
+
/** gPA fallback read source (kit RPC or a ProgramAccountsTransport). */
|
|
78
|
+
rpc?: GpaReadSource;
|
|
79
|
+
/**
|
|
80
|
+
* Full override: a ready-made {@link ReadTransport} (tests/mocks/SSR
|
|
81
|
+
* fixtures). Wins over `indexer` and `rpc`.
|
|
82
|
+
*/
|
|
83
|
+
queryTransport?: ReadTransport;
|
|
84
|
+
/** Override the SDK's indexer client factory options (advanced/tests). */
|
|
85
|
+
indexerClientOptions?: Partial<CreateIndexerClientOptions>;
|
|
86
|
+
}
|
|
87
|
+
/** Target Solana cluster for the provider's default endpoint resolution. */
|
|
88
|
+
type AgencNetwork = "localnet" | "devnet" | "mainnet";
|
|
89
|
+
/**
|
|
90
|
+
* Referrer configuration. Accepted + validated + stored ALWAYS; injected into
|
|
91
|
+
* hires only when {@link ReferrerCapability.live} is true (the P6.2 gate — not
|
|
92
|
+
* today). See {@link resolveReferrerCapability}.
|
|
93
|
+
*/
|
|
94
|
+
interface ReferrerConfig {
|
|
95
|
+
/** Referrer wallet that earns the fee. Must be a valid base58 address. */
|
|
96
|
+
wallet: string;
|
|
97
|
+
/**
|
|
98
|
+
* Referral fee in basis points (1 bps = 0.01%). Validated against
|
|
99
|
+
* `[REFERRER_FEE_BPS_MIN, REFERRER_FEE_BPS_MAX]`.
|
|
100
|
+
*/
|
|
101
|
+
feeBps: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A validated, normalized referrer config (the stored form). `wallet` is a
|
|
105
|
+
* branded kit {@link Address} once validation passes.
|
|
106
|
+
*/
|
|
107
|
+
interface ValidatedReferrerConfig {
|
|
108
|
+
/** Validated referrer wallet address. */
|
|
109
|
+
wallet: Address;
|
|
110
|
+
/** Validated referral fee in basis points. */
|
|
111
|
+
feeBps: number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The runtime answer to "can a referral fee actually be charged on this
|
|
115
|
+
* cluster?". Returned by `resolveReferrerCapability()`.
|
|
116
|
+
*
|
|
117
|
+
* THE P6.2 GATE: `live` is hardcoded `false` today because the on-chain
|
|
118
|
+
* referrer args + 4th settlement leg (PLAN.md P6.2) are unbuilt. When it ships,
|
|
119
|
+
* this resolver will consult P6.5 `getDeployedSurface` instead. Until then:
|
|
120
|
+
* referrer is never injected, earnings hooks return a documented not-live
|
|
121
|
+
* state, and disclosure UI may still show the pending-support copy.
|
|
122
|
+
*/
|
|
123
|
+
interface ReferrerCapability {
|
|
124
|
+
/** Whether referral settlement is live on the target cluster. */
|
|
125
|
+
live: boolean;
|
|
126
|
+
/** Human-readable reason, always set when `live` is false. */
|
|
127
|
+
reason?: string;
|
|
128
|
+
/** The validated referrer config under this provider, if one was supplied. */
|
|
129
|
+
referrer?: ValidatedReferrerConfig;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Full `<AgencProvider config={...}>` configuration.
|
|
133
|
+
*
|
|
134
|
+
* The `client` and `queryTransport` slots are PUBLIC API: the SDK's
|
|
135
|
+
* `startLocalMarketplace()` litesvm harness exposes a `{ client }` that plugs
|
|
136
|
+
* straight in for hook e2e, and mock read transports use `queryTransport`.
|
|
137
|
+
*/
|
|
138
|
+
interface AgencProviderConfig {
|
|
139
|
+
/** Target cluster; drives default RPC/indexer endpoint resolution. */
|
|
140
|
+
network?: AgencNetwork;
|
|
141
|
+
/** HTTP RPC endpoint. Overrides the network default. */
|
|
142
|
+
rpcUrl?: string;
|
|
143
|
+
/** WebSocket RPC endpoint (for subscriptions). Overrides the network default. */
|
|
144
|
+
rpcSubscriptionsUrl?: string;
|
|
145
|
+
/** Indexer connection — presence of `indexer.baseUrl` selects indexer-first. */
|
|
146
|
+
indexer?: IndexerConfig;
|
|
147
|
+
/** Referrer config (accepted + validated; injected only when P6.2 is live). */
|
|
148
|
+
referrer?: ReferrerConfig;
|
|
149
|
+
/** Signer for write operations (the kit `TransactionSigner`). */
|
|
150
|
+
signer?: TransactionSigner;
|
|
151
|
+
/**
|
|
152
|
+
* Pre-built write client override slot. When set, it is used verbatim and the
|
|
153
|
+
* provider builds no client from `rpcUrl`/`signer`. This is how
|
|
154
|
+
* `startLocalMarketplace().client` plugs in for hook e2e.
|
|
155
|
+
*/
|
|
156
|
+
client?: MarketplaceClient;
|
|
157
|
+
/**
|
|
158
|
+
* Pre-built read transport override slot (tests/mocks/SSR fixtures). Wins over
|
|
159
|
+
* `indexer`/`rpc` resolution.
|
|
160
|
+
*/
|
|
161
|
+
queryTransport?: ReadTransport;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The value exposed via React context by `<AgencProvider>` and read by
|
|
165
|
+
* `useAgencContext()`. Hooks bind to THIS shape.
|
|
166
|
+
*/
|
|
167
|
+
interface AgencContextValue {
|
|
168
|
+
/** Resolved target network. */
|
|
169
|
+
network: AgencNetwork;
|
|
170
|
+
/** The unified read transport (indexer-first, gPA fallback). */
|
|
171
|
+
read: ReadTransport;
|
|
172
|
+
/**
|
|
173
|
+
* The write client, or `null` when neither `client` nor `rpcUrl`+`signer`
|
|
174
|
+
* was supplied. Mutating hooks surface a clear error in that case.
|
|
175
|
+
*/
|
|
176
|
+
client: MarketplaceClient | null;
|
|
177
|
+
/** The configured signer, or `null`. */
|
|
178
|
+
signer: TransactionSigner | null;
|
|
179
|
+
/** Validated referrer config, or `null` when none was supplied. */
|
|
180
|
+
referrer: ValidatedReferrerConfig | null;
|
|
181
|
+
/**
|
|
182
|
+
* Resolve whether referral settlement is live on this cluster (the P6.2
|
|
183
|
+
* gate). Today always `{ live: false, ... }`.
|
|
184
|
+
*/
|
|
185
|
+
resolveReferrerCapability(): ReferrerCapability;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Minimal English string catalog + a `t(id, vars?)` resolver.
|
|
190
|
+
*
|
|
191
|
+
* Every user-facing string in this package and its downstream hooks/components
|
|
192
|
+
* routes through this module so a future `{ locale }` can resolve translations
|
|
193
|
+
* **without an API break** (PLAN_2 Part A design constraint). v1 ships English
|
|
194
|
+
* only; the resolver signature is already locale-shaped.
|
|
195
|
+
*
|
|
196
|
+
* ## Why a catalog and not inline literals
|
|
197
|
+
*
|
|
198
|
+
* Components published to third parties cannot assume the host's language. By
|
|
199
|
+
* keying every literal here:
|
|
200
|
+
* - adding a locale is a data change (a new {@link StringCatalog}), not a code
|
|
201
|
+
* change to every component;
|
|
202
|
+
* - the message ids are a stable contract the components agent binds to;
|
|
203
|
+
* - `{var}` interpolation is centralized and SSR-safe (pure string ops, no
|
|
204
|
+
* `Intl` global assumptions at module scope).
|
|
205
|
+
*
|
|
206
|
+
* @module strings
|
|
207
|
+
*/
|
|
208
|
+
/**
|
|
209
|
+
* The catalog shape: every message id maps to an English template. `{name}`
|
|
210
|
+
* placeholders are filled by {@link t} from the `vars` argument.
|
|
211
|
+
*/
|
|
212
|
+
interface StringCatalog {
|
|
213
|
+
readonly [id: string]: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Default English catalog. Keep ids namespaced by surface
|
|
217
|
+
* (`provider.*`, `referrer.*`, `transport.*`, `hire.*`, ...) so the components
|
|
218
|
+
* agent can extend it without collisions.
|
|
219
|
+
*/
|
|
220
|
+
declare const EN_STRINGS: {
|
|
221
|
+
readonly "provider.missingContext": "useAgencContext must be used within <AgencProvider>.";
|
|
222
|
+
readonly "provider.missingWriteClient": "No write client is configured. Pass config.client, or config.rpcUrl + config.signer, to <AgencProvider> before using a mutating hook.";
|
|
223
|
+
readonly "provider.missingSigner": "No signer is configured on <AgencProvider>. Connect a wallet or pass config.signer.";
|
|
224
|
+
readonly "referrer.invalidWallet": "Referrer wallet is not a valid base58 Solana address: {wallet}.";
|
|
225
|
+
readonly "referrer.invalidFeeBps": "Referrer feeBps must be an integer between {min} and {max} (basis points); got {feeBps}.";
|
|
226
|
+
readonly "referrer.notLive": "This site earns a referral fee (pending protocol support).";
|
|
227
|
+
readonly "referrer.notLiveReason": "Referral settlement is not yet deployed on this cluster (PLAN.md P6.2). Referrer config is accepted and validated but not injected into hires.";
|
|
228
|
+
readonly "transport.noReadSource": "No read source is configured. Pass an indexer baseUrl, an rpc/queryTransport, to <AgencProvider> or createReadTransport().";
|
|
229
|
+
readonly "state.loading": "Loading…";
|
|
230
|
+
readonly "state.empty": "Nothing to show yet.";
|
|
231
|
+
readonly "state.error": "Something went wrong.";
|
|
232
|
+
readonly "hire.cta": "Hire";
|
|
233
|
+
readonly "hire.pending": "Confirming…";
|
|
234
|
+
readonly "hire.funded": "Escrow funded.";
|
|
235
|
+
};
|
|
236
|
+
/** A message id present in the default English catalog. */
|
|
237
|
+
type StringId = keyof typeof EN_STRINGS;
|
|
238
|
+
/** Interpolation variables for {@link t}: `{name}` → `vars.name`. */
|
|
239
|
+
type StringVars = Record<string, string | number | bigint>;
|
|
240
|
+
/**
|
|
241
|
+
* Options for {@link t}. `locale` is accepted today (English-only) so adding
|
|
242
|
+
* real locales later does not break the call signature; `catalog` lets a host
|
|
243
|
+
* inject an override/extension catalog.
|
|
244
|
+
*/
|
|
245
|
+
interface TranslateOptions {
|
|
246
|
+
/** BCP-47 locale tag. v1 resolves everything to English regardless. */
|
|
247
|
+
locale?: string;
|
|
248
|
+
/** Override catalog (e.g. a future locale, or host-supplied copy). */
|
|
249
|
+
catalog?: StringCatalog;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Resolve a message id to its localized string with `{var}` interpolation.
|
|
253
|
+
*
|
|
254
|
+
* Unknown ids and unmatched placeholders are returned verbatim (the id itself,
|
|
255
|
+
* or the `{placeholder}` left intact) rather than throwing — a missing string
|
|
256
|
+
* must never crash a money-handling UI.
|
|
257
|
+
*
|
|
258
|
+
* @param id - The message id (a {@link StringId}, or any string for host
|
|
259
|
+
* catalogs).
|
|
260
|
+
* @param vars - Values for `{name}` placeholders in the template.
|
|
261
|
+
* @param options - Optional `locale` (forward-compatible) and `catalog`
|
|
262
|
+
* override.
|
|
263
|
+
* @returns The interpolated string.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```ts
|
|
267
|
+
* t("referrer.invalidFeeBps", { min: 0, max: 10000, feeBps: 99999 });
|
|
268
|
+
* // -> "Referrer feeBps must be an integer between 0 and 10000 ...; got 99999."
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function t(id: StringId | (string & {}), vars?: StringVars, options?: TranslateOptions): string;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Shared presentational primitives for the prebuilt components.
|
|
275
|
+
*
|
|
276
|
+
* These are the small, themable building blocks every higher-level component
|
|
277
|
+
* (ListingCard, HireCheckoutModal, ...) composes: a class-name joiner, a
|
|
278
|
+
* loading spinner, the canonical loading/empty/error state block, a status
|
|
279
|
+
* badge, and a button. They emit ONLY `--agenc-*`-driven class names (no
|
|
280
|
+
* CSS-in-JS), honor the `unstyled` white-label contract, and route every
|
|
281
|
+
* literal through {@link tc}.
|
|
282
|
+
*
|
|
283
|
+
* SSR-safe: pure render functions, no `window`/`document` at module scope.
|
|
284
|
+
*
|
|
285
|
+
* @module components/primitives
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
/** Join truthy class names with a single space. */
|
|
289
|
+
declare function cx(...parts: Array<string | false | null | undefined>): string;
|
|
290
|
+
/**
|
|
291
|
+
* Resolve the className a styled element should carry: when `unstyled`, only
|
|
292
|
+
* the caller's `extra` survives (white-label); otherwise the base `agenc-*`
|
|
293
|
+
* class plus `extra`.
|
|
294
|
+
*/
|
|
295
|
+
declare function elementClass(base: string, unstyled: boolean | undefined, extra?: string): string | undefined;
|
|
296
|
+
/**
|
|
297
|
+
* Resolve a COMPONENT ROOT className. Like {@link elementClass} but, when
|
|
298
|
+
* styled, ALSO prepends the {@link AGENC_THEME_CLASS} scope (`"agenc"`) so the
|
|
299
|
+
* `--agenc-*` tokens resolve even when the token sheet is scoped rather than
|
|
300
|
+
* global. When `unstyled`, ONLY the caller's `extra` survives — neither the
|
|
301
|
+
* scope class nor the component base class is emitted (true white-label).
|
|
302
|
+
*
|
|
303
|
+
* Use this for the outermost element of every prebuilt component; use
|
|
304
|
+
* {@link elementClass} for inner elements (which inherit the scope from the
|
|
305
|
+
* root and so don't repeat it).
|
|
306
|
+
*/
|
|
307
|
+
declare function rootClass(base: string, unstyled: boolean | undefined, extra?: string): string | undefined;
|
|
308
|
+
/** Common props every prebuilt component accepts. */
|
|
309
|
+
interface ThemableProps {
|
|
310
|
+
/** White-label mode: emit semantic markup + ARIA but no default theme class. */
|
|
311
|
+
unstyled?: boolean;
|
|
312
|
+
/** Extra class name appended to the component root. */
|
|
313
|
+
className?: string;
|
|
314
|
+
}
|
|
315
|
+
/** Variants the loading/empty/error block renders. */
|
|
316
|
+
type StateKind = "loading" | "empty" | "error";
|
|
317
|
+
/** Props for {@link StateMessage}. */
|
|
318
|
+
interface StateMessageProps extends ThemableProps {
|
|
319
|
+
/** Which state to render. */
|
|
320
|
+
kind: StateKind;
|
|
321
|
+
/** Override message (defaults to the catalog string for `kind`). */
|
|
322
|
+
message?: string;
|
|
323
|
+
/** Optional retry handler (renders a Retry button for `error`/`empty`). */
|
|
324
|
+
onRetry?: () => void;
|
|
325
|
+
/** Accessible role override. Defaults: `status` (loading) / `alert` (error). */
|
|
326
|
+
role?: HTMLAttributes<HTMLDivElement>["role"];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The canonical loading / empty / error block. Every read component renders
|
|
330
|
+
* this for its non-data states so screen readers get a consistent, polite
|
|
331
|
+
* announcement (`role="status"` for loading, `role="alert"` for error).
|
|
332
|
+
*/
|
|
333
|
+
declare function StateMessage({ kind, message, onRetry, role, unstyled, className, }: StateMessageProps): ReactNode;
|
|
334
|
+
/** Props for {@link Spinner}. */
|
|
335
|
+
interface SpinnerProps extends ThemableProps {
|
|
336
|
+
/** Accessible label (default "Loading…"). */
|
|
337
|
+
label?: string;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* An accessible, CSS-animated spinner. `role="status"` + visually-hidden label
|
|
341
|
+
* so a screen reader announces the loading state with no visible text.
|
|
342
|
+
*/
|
|
343
|
+
declare function Spinner({ label, unstyled, className }: SpinnerProps): ReactNode;
|
|
344
|
+
/** Visual intent of a {@link Badge}. */
|
|
345
|
+
type BadgeTone = "neutral" | "success" | "warning" | "danger" | "info";
|
|
346
|
+
/** Props for {@link Badge}. */
|
|
347
|
+
interface BadgeProps extends ThemableProps {
|
|
348
|
+
/** Color intent. */
|
|
349
|
+
tone?: BadgeTone;
|
|
350
|
+
/** Badge content. */
|
|
351
|
+
children: ReactNode;
|
|
352
|
+
/**
|
|
353
|
+
* Optional `title`/`aria-label` for an icon-only or abbreviated badge so it
|
|
354
|
+
* carries an accessible name.
|
|
355
|
+
*/
|
|
356
|
+
label?: string;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* A small status pill (verified / moderation / state). Themable via
|
|
360
|
+
* `--agenc-*`; tone maps to a semantic color token.
|
|
361
|
+
*/
|
|
362
|
+
declare function Badge({ tone, children, label, unstyled, className, }: BadgeProps): ReactNode;
|
|
363
|
+
/** Visual variant of a {@link Button}. */
|
|
364
|
+
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger";
|
|
365
|
+
/** Props for {@link Button}. */
|
|
366
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, ThemableProps {
|
|
367
|
+
/** Visual variant. */
|
|
368
|
+
variant?: ButtonVariant;
|
|
369
|
+
/** Show a spinner + disable while a related action is in flight. */
|
|
370
|
+
loading?: boolean;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* A themable, accessible button. Always a real `<button type="button">` (the
|
|
374
|
+
* default) so keyboard + screen-reader semantics are correct; `loading`
|
|
375
|
+
* disables it and shows an inline spinner with an accessible busy state.
|
|
376
|
+
*/
|
|
377
|
+
declare function Button({ variant, loading, unstyled, className, children, disabled, type, ...rest }: ButtonProps): ReactNode;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Shared status badges: moderation attestation + provider-verified.
|
|
381
|
+
*
|
|
382
|
+
* ## Moderation (P6.8 boundary — read before extending)
|
|
383
|
+
*
|
|
384
|
+
* Per PLAN_2 A3, `ListingCard`/`Checkout` surface moderation aggressively, but
|
|
385
|
+
* the UNATTESTED-listing render toggle is gated on the PLAN.md P6.8 [HUMAN]
|
|
386
|
+
* neutrality decision and is NOT built here. This badge therefore only ever
|
|
387
|
+
* SHOWS the attestation STATE (attested / pending / issues); it never gates
|
|
388
|
+
* whether a listing renders. The v1 read model does not project a standalone
|
|
389
|
+
* attestation verdict, so "attested" is inferred from the indexer listing
|
|
390
|
+
* projection's `metadataValid` (the strongest signal available today); a
|
|
391
|
+
* dedicated verdict slots in later without changing this surface.
|
|
392
|
+
*
|
|
393
|
+
* @module components/badges
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
/** The moderation state a badge can show (never a render gate). */
|
|
397
|
+
type ModerationState = "attested" | "pending" | "issues";
|
|
398
|
+
/**
|
|
399
|
+
* Derive a moderation display state from the indexer listing projection.
|
|
400
|
+
*
|
|
401
|
+
* - `null` projection (gPA fallback, no indexer) → `"pending"` (unknown, shown
|
|
402
|
+
* honestly as pending — never asserted as attested);
|
|
403
|
+
* - `metadataValid === true` → `"attested"`;
|
|
404
|
+
* - `metadataValid === false` (issues present) → `"issues"`.
|
|
405
|
+
*/
|
|
406
|
+
declare function moderationStateOf(moderation: IndexerListing | null | undefined): ModerationState;
|
|
407
|
+
/** Props for {@link ModerationBadge}. */
|
|
408
|
+
interface ModerationBadgeProps extends ThemableProps {
|
|
409
|
+
/** The indexer listing projection (carries `metadataValid`/`metadataIssues`). */
|
|
410
|
+
moderation: IndexerListing | null | undefined;
|
|
411
|
+
/** Pre-resolved state (overrides `moderation`-derived state). */
|
|
412
|
+
state?: ModerationState;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Show the listing's moderation attestation STATE (never a render gate).
|
|
416
|
+
*/
|
|
417
|
+
declare function ModerationBadge({ moderation, state, unstyled, className, }: ModerationBadgeProps): ReactNode;
|
|
418
|
+
/** Props for {@link VerifiedBadge}. */
|
|
419
|
+
interface VerifiedBadgeProps extends ThemableProps {
|
|
420
|
+
/** Whether the entity is verified. */
|
|
421
|
+
verified: boolean;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* A provider-verified pill (used by ProviderCard). Shows verified/unverified
|
|
425
|
+
* state with the appropriate tone.
|
|
426
|
+
*/
|
|
427
|
+
declare function VerifiedBadge({ verified, unstyled, className, }: VerifiedBadgeProps): ReactNode;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Component-layer string catalog (PLAN_2 A3).
|
|
431
|
+
*
|
|
432
|
+
* Every user-facing literal a prebuilt component renders routes through the
|
|
433
|
+
* shared {@link t} resolver and is keyed HERE, namespaced under
|
|
434
|
+
* `components.*` so it never collides with the foundation catalog
|
|
435
|
+
* (`provider.*`, `referrer.*`, `transport.*`, `state.*`, `hire.*`). A future
|
|
436
|
+
* locale extends this object — no component code changes.
|
|
437
|
+
*
|
|
438
|
+
* These are MERGED over `EN_STRINGS` at module load (see `mergedCatalog`) so a
|
|
439
|
+
* component calling `t("components.listingCard.priceLabel")` resolves without
|
|
440
|
+
* the caller threading a catalog. SSR-safe: a plain object literal, no globals.
|
|
441
|
+
*
|
|
442
|
+
* @module components/strings
|
|
443
|
+
*/
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* The component-surface English strings. Keys are namespaced by component
|
|
447
|
+
* (`components.<component>.<key>`) plus a few shared `components.common.*`.
|
|
448
|
+
*/
|
|
449
|
+
declare const EN_COMPONENT_STRINGS: {
|
|
450
|
+
readonly "components.common.loading": "Loading…";
|
|
451
|
+
readonly "components.common.empty": "Nothing to show yet.";
|
|
452
|
+
readonly "components.common.error": "Something went wrong.";
|
|
453
|
+
readonly "components.common.retry": "Retry";
|
|
454
|
+
readonly "components.common.close": "Close";
|
|
455
|
+
readonly "components.common.verified": "Verified";
|
|
456
|
+
readonly "components.common.unverified": "Unverified";
|
|
457
|
+
readonly "components.common.sol": "SOL";
|
|
458
|
+
readonly "components.common.lamports": "lamports";
|
|
459
|
+
readonly "components.listingCard.priceLabel": "Price";
|
|
460
|
+
readonly "components.listingCard.byProvider": "by {provider}";
|
|
461
|
+
readonly "components.listingCard.untitled": "Untitled service";
|
|
462
|
+
readonly "components.listingCard.hires": "{count} hires";
|
|
463
|
+
readonly "components.listingCard.category": "Category";
|
|
464
|
+
readonly "components.listingGrid.empty": "No listings match your filters yet.";
|
|
465
|
+
readonly "components.listingGrid.loadMore": "Load more";
|
|
466
|
+
readonly "components.listingGrid.error": "Could not load listings.";
|
|
467
|
+
readonly "components.hire.cta": "Hire";
|
|
468
|
+
readonly "components.hire.ctaPrice": "Hire — {price}";
|
|
469
|
+
readonly "components.hire.checkoutTitle": "Confirm hire";
|
|
470
|
+
readonly "components.hire.priceLabel": "You pay";
|
|
471
|
+
readonly "components.hire.escrowNote": "Funds are held in protocol escrow and released to the provider only when you accept the result.";
|
|
472
|
+
readonly "components.hire.confirm": "Confirm and fund escrow";
|
|
473
|
+
readonly "components.hire.cancel": "Cancel";
|
|
474
|
+
readonly "components.hire.pending": "Confirming…";
|
|
475
|
+
readonly "components.hire.success": "Escrow funded.";
|
|
476
|
+
readonly "components.hire.successDetail": "Your task is created. Track it below.";
|
|
477
|
+
readonly "components.hire.viewTask": "View task";
|
|
478
|
+
readonly "components.hire.errorTitle": "Hire failed";
|
|
479
|
+
readonly "components.hire.moderationAttested": "Moderation attested";
|
|
480
|
+
readonly "components.hire.moderationPending": "Moderation pending";
|
|
481
|
+
readonly "components.hire.moderationIssues": "Moderation issues found";
|
|
482
|
+
readonly "components.hire.notConnected": "Connect a wallet to hire.";
|
|
483
|
+
readonly "components.referrer.disclosure": "This site earns a referral fee.";
|
|
484
|
+
readonly "components.referrer.disclosurePending": "This site earns a referral fee (pending protocol support).";
|
|
485
|
+
readonly "components.referrer.feeBps": "{bps} bps";
|
|
486
|
+
readonly "components.taskTimeline.title": "Task progress";
|
|
487
|
+
readonly "components.taskTimeline.empty": "No task to track yet.";
|
|
488
|
+
readonly "components.taskTimeline.status.Open": "Open";
|
|
489
|
+
readonly "components.taskTimeline.status.InProgress": "In progress";
|
|
490
|
+
readonly "components.taskTimeline.status.PendingValidation": "Pending review";
|
|
491
|
+
readonly "components.taskTimeline.status.Completed": "Completed";
|
|
492
|
+
readonly "components.taskTimeline.status.Cancelled": "Cancelled";
|
|
493
|
+
readonly "components.taskTimeline.status.Disputed": "Disputed";
|
|
494
|
+
readonly "components.taskTimeline.status.RejectFrozen": "Rejected (frozen)";
|
|
495
|
+
readonly "components.review.title": "Review submission";
|
|
496
|
+
readonly "components.review.noSubmission": "Awaiting the worker's submission.";
|
|
497
|
+
readonly "components.review.accept": "Accept and release escrow";
|
|
498
|
+
readonly "components.review.reject": "Reject";
|
|
499
|
+
readonly "components.review.requestChanges": "Request changes";
|
|
500
|
+
readonly "components.review.accepted": "Result accepted. Escrow released.";
|
|
501
|
+
readonly "components.review.rejected": "Result rejected.";
|
|
502
|
+
readonly "components.review.changesRequested": "Changes requested.";
|
|
503
|
+
readonly "components.review.pending": "Submitting…";
|
|
504
|
+
readonly "components.review.errorTitle": "Review action failed";
|
|
505
|
+
readonly "components.dispute.title": "This task is in dispute.";
|
|
506
|
+
readonly "components.dispute.body": "A dispute has been opened. A protocol resolver decides the outcome; funds stay in escrow until then.";
|
|
507
|
+
readonly "components.dispute.initiate": "Open a dispute";
|
|
508
|
+
readonly "components.dispute.pending": "Opening dispute…";
|
|
509
|
+
readonly "components.dispute.opened": "Dispute opened.";
|
|
510
|
+
readonly "components.dispute.none": "No open dispute.";
|
|
511
|
+
readonly "components.dispute.errorTitle": "Could not open dispute";
|
|
512
|
+
readonly "components.provider.title": "Provider";
|
|
513
|
+
readonly "components.provider.completionRate": "Completion rate";
|
|
514
|
+
readonly "components.provider.disputeRate": "Dispute rate";
|
|
515
|
+
readonly "components.provider.completions": "{count} completed";
|
|
516
|
+
readonly "components.provider.disputes": "{count} disputes";
|
|
517
|
+
readonly "components.provider.provisional": "provisional";
|
|
518
|
+
readonly "components.provider.noData": "No track record yet.";
|
|
519
|
+
readonly "components.provider.unavailable": "Track record is unavailable on this read transport.";
|
|
520
|
+
readonly "components.poweredBy.label": "Powered by AgenC";
|
|
521
|
+
readonly "components.poweredBy.trustLink": "Learn how this works";
|
|
522
|
+
};
|
|
523
|
+
/** A component-surface message id. */
|
|
524
|
+
type ComponentStringId = keyof typeof EN_COMPONENT_STRINGS;
|
|
525
|
+
/**
|
|
526
|
+
* The default catalog every component resolves against: the foundation
|
|
527
|
+
* `EN_STRINGS` merged with {@link EN_COMPONENT_STRINGS}. A host-supplied catalog
|
|
528
|
+
* (`t(id, vars, { catalog })`) still wins per-call.
|
|
529
|
+
*/
|
|
530
|
+
declare const COMPONENT_CATALOG: StringCatalog;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Resolve a component string id against the merged component catalog by
|
|
534
|
+
* default. A per-call `options.catalog` (e.g. a future locale) still wins.
|
|
535
|
+
*
|
|
536
|
+
* This is the only resolver components call so every literal is overridable in
|
|
537
|
+
* one place.
|
|
538
|
+
*/
|
|
539
|
+
declare function tc(id: ComponentStringId | (string & {}), vars?: StringVars, options?: TranslateOptions): string;
|
|
540
|
+
/**
|
|
541
|
+
* Format a lamports `bigint` as a human SOL string with up to 9 decimal places,
|
|
542
|
+
* trailing zeros trimmed. Pure bigint math — no float rounding, no `Intl`.
|
|
543
|
+
*
|
|
544
|
+
* @example formatSol(1_500_000_000n) // "1.5"
|
|
545
|
+
* @example formatSol(1_000_000n) // "0.001"
|
|
546
|
+
* @example formatSol(0n) // "0"
|
|
547
|
+
*/
|
|
548
|
+
declare function formatSol(lamports: bigint): string;
|
|
549
|
+
/**
|
|
550
|
+
* A price label like `"1.5 SOL"` (SOL leg) — the only denomination the v1
|
|
551
|
+
* components render (SPL-priced listings surface the raw lamport-equivalent
|
|
552
|
+
* with the configured unit label by the caller; v1 assumes SOL).
|
|
553
|
+
*/
|
|
554
|
+
declare function formatPriceSol(lamports: bigint, options?: TranslateOptions): string;
|
|
555
|
+
/**
|
|
556
|
+
* Truncate a base58 address/string to `head…tail` for compact display.
|
|
557
|
+
*
|
|
558
|
+
* @example truncateAddress("So11111111111111111111111111111111111111112")
|
|
559
|
+
* // "So1111…1112"
|
|
560
|
+
*/
|
|
561
|
+
declare function truncateAddress(value: string | {
|
|
562
|
+
toString(): string;
|
|
563
|
+
} | null | undefined, head?: number, tail?: number): string;
|
|
564
|
+
/**
|
|
565
|
+
* Decode a listing's NUL-padded `name` byte field to a display string using the
|
|
566
|
+
* SDK's canonical decoder, falling back to an empty string on any decode error
|
|
567
|
+
* (a malformed on-chain name must never crash a card).
|
|
568
|
+
*/
|
|
569
|
+
declare function decodeListingName(listing: Pick<ServiceListing, "name">): string;
|
|
570
|
+
/**
|
|
571
|
+
* Decode a listing's `category` byte field, tolerant of malformed bytes.
|
|
572
|
+
*/
|
|
573
|
+
declare function decodeListingCategory(listing: Pick<ServiceListing, "category">): string;
|
|
574
|
+
/**
|
|
575
|
+
* Decode a listing's `tags` byte field to a string array, tolerant of malformed
|
|
576
|
+
* bytes (returns `[]` on error).
|
|
577
|
+
*/
|
|
578
|
+
declare function decodeListingTags(listing: Pick<ServiceListing, "tags">): string[];
|
|
579
|
+
/**
|
|
580
|
+
* Lowercase-hex a byte field (e.g. a spec hash) for display / comparison.
|
|
581
|
+
*/
|
|
582
|
+
declare function toHex(bytes: ArrayLike<number>): string;
|
|
583
|
+
/**
|
|
584
|
+
* Format a `[0,1]` rate as an integer percentage string, or a fallback when the
|
|
585
|
+
* rate is `null` (no denominator — the P6.6 provisional state).
|
|
586
|
+
*/
|
|
587
|
+
declare function formatRate(rate: number | null, fallback?: string): string;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* `<Modal>` — the accessible dialog primitive the checkout flow is built on.
|
|
591
|
+
*
|
|
592
|
+
* Accessibility is STRUCTURAL here (PLAN_2 A3): this is the surface a
|
|
593
|
+
* money-handling modal published to third parties renders into, so it ships
|
|
594
|
+
* with:
|
|
595
|
+
* - `role="dialog"` + `aria-modal="true"` + a labelled title
|
|
596
|
+
* (`aria-labelledby`) and optional description (`aria-describedby`);
|
|
597
|
+
* - a focus trap (initial focus in, Tab cycling, focus restore on close) via
|
|
598
|
+
* {@link useFocusTrap};
|
|
599
|
+
* - Escape-to-close and overlay-click-to-close (both opt-out-able);
|
|
600
|
+
* - a real `<button>` close affordance with an accessible name.
|
|
601
|
+
*
|
|
602
|
+
* SSR-safe: renders nothing while closed; all `document` access is inside the
|
|
603
|
+
* focus-trap effect. No portal is used (a portal needs `document.body`, which
|
|
604
|
+
* SSR lacks) — the dialog renders inline in the React tree behind a fixed
|
|
605
|
+
* overlay, which keeps it hydration-safe. Hosts that need a body portal can
|
|
606
|
+
* wrap it themselves on the client.
|
|
607
|
+
*
|
|
608
|
+
* @module components/Modal
|
|
609
|
+
*/
|
|
610
|
+
|
|
611
|
+
/** Props for {@link Modal}. */
|
|
612
|
+
interface ModalProps extends ThemableProps {
|
|
613
|
+
/** Whether the dialog is open. Renders nothing when false. */
|
|
614
|
+
open: boolean;
|
|
615
|
+
/** Called to request a close (Escape, overlay click, close button). */
|
|
616
|
+
onClose: () => void;
|
|
617
|
+
/** The dialog title (becomes the `aria-labelledby` target). */
|
|
618
|
+
title: ReactNode;
|
|
619
|
+
/** Dialog body. */
|
|
620
|
+
children: ReactNode;
|
|
621
|
+
/** Optional footer (actions). */
|
|
622
|
+
footer?: ReactNode;
|
|
623
|
+
/** Disable Escape-to-close (e.g. mid-transaction). Default false. */
|
|
624
|
+
disableEscapeClose?: boolean;
|
|
625
|
+
/** Disable overlay-click-to-close. Default false. */
|
|
626
|
+
disableOverlayClose?: boolean;
|
|
627
|
+
/** Hide the close (X) button (e.g. a forced confirmation step). Default false. */
|
|
628
|
+
hideCloseButton?: boolean;
|
|
629
|
+
/** Accessible label for the close button. */
|
|
630
|
+
closeLabel?: string;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* An accessible modal dialog.
|
|
634
|
+
*/
|
|
635
|
+
declare function Modal({ open, onClose, title, children, footer, disableEscapeClose, disableOverlayClose, hideCloseButton, closeLabel, unstyled, className, }: ModalProps): ReactNode;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* `useFocusTrap` — an accessible focus trap for the modal surface.
|
|
639
|
+
*
|
|
640
|
+
* `HireCheckoutModal` is a money-handling dialog published to third-party
|
|
641
|
+
* sites, so accessibility is STRUCTURAL (PLAN_2 A3): when the modal is open
|
|
642
|
+
* this hook
|
|
643
|
+
* - moves focus into the dialog (the first focusable element, or the dialog
|
|
644
|
+
* container itself);
|
|
645
|
+
* - cycles Tab / Shift+Tab within the dialog (a real trap, not just an
|
|
646
|
+
* initial focus);
|
|
647
|
+
* - RECAPTURES focus that escapes the dialog via a document-level `focusin`
|
|
648
|
+
* listener (a Tab from browser autofill UI, a third-party widget, or
|
|
649
|
+
* programmatic focus pulls focus back in — a container-scoped keydown alone
|
|
650
|
+
* never sees it);
|
|
651
|
+
* - invokes `onEscape` when Escape is pressed;
|
|
652
|
+
* - restores focus to the element that was focused before the dialog opened on
|
|
653
|
+
* close/unmount.
|
|
654
|
+
*
|
|
655
|
+
* SSR-safe: every `document` access happens inside `useEffect`, which never
|
|
656
|
+
* runs on the server. The hook is a no-op while `active` is false.
|
|
657
|
+
*
|
|
658
|
+
* @module components/useFocusTrap
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Trap keyboard focus within `containerRef` while `active`.
|
|
663
|
+
*
|
|
664
|
+
* @param containerRef - Ref to the dialog container element.
|
|
665
|
+
* @param active - Whether the trap is engaged (the modal is open).
|
|
666
|
+
* @param onEscape - Called when Escape is pressed inside the trap.
|
|
667
|
+
*/
|
|
668
|
+
declare function useFocusTrap(containerRef: RefObject<HTMLElement | null>, active: boolean, onEscape?: () => void): void;
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* `<ListingCard>` — a single service-listing card.
|
|
672
|
+
*
|
|
673
|
+
* Renders the decoded on-chain `ServiceListing` (name, category, price,
|
|
674
|
+
* provider, lifetime hires) plus the moderation attestation badge. It is a
|
|
675
|
+
* PRESENTATIONAL component: it takes already-fetched data (a `ListingRow` from
|
|
676
|
+
* `useListings`, or a `ServiceListing` + address) so it can be used inside a
|
|
677
|
+
* grid, a detail page, or SSR without owning a query.
|
|
678
|
+
*
|
|
679
|
+
* Themable via `--agenc-*`; `unstyled` strips the default classes. Every
|
|
680
|
+
* literal routes through the component catalog.
|
|
681
|
+
*
|
|
682
|
+
* @module components/ListingCard
|
|
683
|
+
*/
|
|
684
|
+
|
|
685
|
+
/** A decoded listing the card can render (matches `useListings`' `ListingRow`). */
|
|
686
|
+
interface ListingCardData {
|
|
687
|
+
/** The listing PDA. */
|
|
688
|
+
address: Address;
|
|
689
|
+
/** The decoded on-chain account. */
|
|
690
|
+
account: ServiceListing;
|
|
691
|
+
}
|
|
692
|
+
/** Props for {@link ListingCard}. */
|
|
693
|
+
interface ListingCardProps extends ThemableProps {
|
|
694
|
+
/** The decoded listing to render. */
|
|
695
|
+
listing: ListingCardData;
|
|
696
|
+
/**
|
|
697
|
+
* Optional indexer projection for the moderation badge. When absent the badge
|
|
698
|
+
* shows the honest "pending" state (never asserts attestation).
|
|
699
|
+
*/
|
|
700
|
+
moderation?: IndexerListing | null;
|
|
701
|
+
/**
|
|
702
|
+
* Click/hire handler. When provided the card renders a hire CTA (use
|
|
703
|
+
* {@link HireButton} for the full flow); when absent the card is display-only.
|
|
704
|
+
*/
|
|
705
|
+
onHire?: (listing: ListingCardData) => void;
|
|
706
|
+
/** Optional select handler (e.g. open a detail view) on the card body. */
|
|
707
|
+
onSelect?: (listing: ListingCardData) => void;
|
|
708
|
+
/** Hide the price row (e.g. a teaser card). Default false. */
|
|
709
|
+
hidePrice?: boolean;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Render one service listing as a card.
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```tsx
|
|
716
|
+
* <ListingCard listing={row} moderation={detail.moderation} onHire={open} />
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
declare function ListingCard({ listing, moderation, onHire, onSelect, hidePrice, unstyled, className, }: ListingCardProps): ReactNode;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* `<ListingGrid>` — a responsive grid of {@link ListingCard}s with the
|
|
723
|
+
* canonical loading / empty / error states.
|
|
724
|
+
*
|
|
725
|
+
* Presentational by design: it takes the `useListings` result fields
|
|
726
|
+
* (`listings`, `isLoading`, `error`, `hasMore`, `fetchMore`) rather than
|
|
727
|
+
* calling the hook itself, so it renders identically under SSR, in Ladle, and
|
|
728
|
+
* against the live transport. A host wires it to `useListings` in one line:
|
|
729
|
+
*
|
|
730
|
+
* ```tsx
|
|
731
|
+
* const q = useListings(filter);
|
|
732
|
+
* <ListingGrid {...q} onLoadMore={q.fetchMore} onHire={open} />
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @module components/ListingGrid
|
|
736
|
+
*/
|
|
737
|
+
|
|
738
|
+
/** Props for {@link ListingGrid}. */
|
|
739
|
+
interface ListingGridProps extends ThemableProps {
|
|
740
|
+
/** The listings to render (typically `useListings().listings`). */
|
|
741
|
+
listings: ListingCardData[];
|
|
742
|
+
/** True while the first load is in flight. Shows the loading state. */
|
|
743
|
+
isLoading?: boolean;
|
|
744
|
+
/** A load error. Shows the error state (with retry when `onRetry` given). */
|
|
745
|
+
error?: Error | null;
|
|
746
|
+
/** Whether more rows can be revealed (shows the "Load more" control). */
|
|
747
|
+
hasMore?: boolean;
|
|
748
|
+
/** Reveal the next page (typically `useListings().fetchMore`). */
|
|
749
|
+
onLoadMore?: () => void;
|
|
750
|
+
/** Retry handler for the error state. */
|
|
751
|
+
onRetry?: () => void;
|
|
752
|
+
/** Hire handler forwarded to each card. */
|
|
753
|
+
onHire?: (listing: ListingCardData) => void;
|
|
754
|
+
/** Select handler forwarded to each card. */
|
|
755
|
+
onSelect?: (listing: ListingCardData) => void;
|
|
756
|
+
/**
|
|
757
|
+
* Optional per-listing moderation projections, keyed by listing PDA string,
|
|
758
|
+
* for the moderation badge. Absent entries render the honest "pending" badge.
|
|
759
|
+
*/
|
|
760
|
+
moderationByPda?: Record<string, IndexerListing | null>;
|
|
761
|
+
/** Override the empty-state message. */
|
|
762
|
+
emptyMessage?: string;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* A grid of listing cards with loading/empty/error handling.
|
|
766
|
+
*/
|
|
767
|
+
declare function ListingGrid({ listings, isLoading, error, hasMore, onLoadMore, onRetry, onHire, onSelect, moderationByPda, emptyMessage, unstyled, className, }: ListingGridProps): ReactNode;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* `<HireCheckoutModal>` — the embeddable money path (PLAN_2 A3).
|
|
771
|
+
*
|
|
772
|
+
* The accessible, themable checkout dialog: it shows the price, the moderation
|
|
773
|
+
* attestation badge, the escrow-funding explanation, the referrer disclosure
|
|
774
|
+
* (P6.2-gated), and walks the buyer through idle → confirming → funded /
|
|
775
|
+
* error confirmation states.
|
|
776
|
+
*
|
|
777
|
+
* ## Accessibility (STRUCTURAL — this is published to third parties)
|
|
778
|
+
*
|
|
779
|
+
* Built on the accessible {@link Modal}: focus trap, Escape/overlay close
|
|
780
|
+
* (auto-disabled while a hire is in flight so the buyer can't dismiss a pending
|
|
781
|
+
* transaction), ARIA dialog roles, and live-region status announcements for
|
|
782
|
+
* the confirming/funded/error transitions.
|
|
783
|
+
*
|
|
784
|
+
* ## The P6.2 referrer gate
|
|
785
|
+
*
|
|
786
|
+
* The disclosure renders when a `referrer` is configured, with the pending-
|
|
787
|
+
* support copy until `referrerLive` is true (always false today). The modal
|
|
788
|
+
* NEVER computes or claims a fee was charged — it discloses configured intent
|
|
789
|
+
* only. Injection/earnings stay in the hooks, blocked on P6.2.
|
|
790
|
+
*
|
|
791
|
+
* ## Wiring
|
|
792
|
+
*
|
|
793
|
+
* Presentational by design: a host maps `useHire()` onto the props
|
|
794
|
+
* (`status`/`error`/`taskPda`/`onConfirm`). The connected
|
|
795
|
+
* {@link HireButton} shows the canonical wiring.
|
|
796
|
+
*
|
|
797
|
+
* @module components/HireCheckoutModal
|
|
798
|
+
*/
|
|
799
|
+
|
|
800
|
+
/** The listing being hired (decoded account + address). */
|
|
801
|
+
interface HireCheckoutListing {
|
|
802
|
+
/** The listing PDA. */
|
|
803
|
+
address: Address;
|
|
804
|
+
/** The decoded on-chain account (for price + name). */
|
|
805
|
+
account: ServiceListing;
|
|
806
|
+
}
|
|
807
|
+
/** Props for {@link HireCheckoutModal}. */
|
|
808
|
+
interface HireCheckoutModalProps {
|
|
809
|
+
/** Whether the modal is open. */
|
|
810
|
+
open: boolean;
|
|
811
|
+
/** Close request handler. */
|
|
812
|
+
onClose: () => void;
|
|
813
|
+
/** The listing under checkout. */
|
|
814
|
+
listing: HireCheckoutListing;
|
|
815
|
+
/**
|
|
816
|
+
* Confirm handler — runs the actual hire (e.g. `() => hire({...})`). Resolves
|
|
817
|
+
* when the hire settles; rejects with the typed `AgencError` to surface.
|
|
818
|
+
*/
|
|
819
|
+
onConfirm: () => void | Promise<void>;
|
|
820
|
+
/** Current hire status (map from `useHire().status`). Default "idle". */
|
|
821
|
+
status?: HireStatus;
|
|
822
|
+
/** The hire error to surface (map from `useHire().error`). */
|
|
823
|
+
error?: Error | null;
|
|
824
|
+
/** The minted Task PDA on success (map from `useHire().taskPda`). */
|
|
825
|
+
taskPda?: Address | null;
|
|
826
|
+
/** Optional handler when the buyer clicks "View task" after success. */
|
|
827
|
+
onViewTask?: (taskPda: Address) => void;
|
|
828
|
+
/** Indexer projection for the moderation badge. */
|
|
829
|
+
moderation?: IndexerListing | null;
|
|
830
|
+
/**
|
|
831
|
+
* Configured referrer (from provider context). When present the disclosure
|
|
832
|
+
* renders. Pass `null`/omit when no referrer is configured.
|
|
833
|
+
*/
|
|
834
|
+
referrer?: ValidatedReferrerConfig | null;
|
|
835
|
+
/**
|
|
836
|
+
* Whether referral settlement is live (P6.2). Always false today. Drives the
|
|
837
|
+
* disclosure copy only; never implies a fee was charged.
|
|
838
|
+
*/
|
|
839
|
+
referrerLive?: boolean;
|
|
840
|
+
/** Whether a signer/wallet is connected (gates the confirm button). */
|
|
841
|
+
connected?: boolean;
|
|
842
|
+
/** White-label mode. */
|
|
843
|
+
unstyled?: boolean;
|
|
844
|
+
/** Extra root class. */
|
|
845
|
+
className?: string;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* The hire checkout dialog.
|
|
849
|
+
*/
|
|
850
|
+
declare function HireCheckoutModal({ open, onClose, listing, onConfirm, status, error, taskPda, onViewTask, moderation, referrer, referrerLive, connected, unstyled, className, }: HireCheckoutModalProps): ReactNode;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* `<HireButton>` — the connected, drop-in hire entry point.
|
|
854
|
+
*
|
|
855
|
+
* This is the one component that binds the hooks directly: it renders a price-
|
|
856
|
+
* aware CTA that opens {@link HireCheckoutModal}, drives the hire through
|
|
857
|
+
* `useHire()`, resolves the signer via `useWalletSigner()`, and threads the
|
|
858
|
+
* provider's configured referrer + the P6.2 capability into the modal's
|
|
859
|
+
* disclosure (never injecting a fee — the gate lives in `useHire`).
|
|
860
|
+
*
|
|
861
|
+
* ## Why the caller supplies the hire input
|
|
862
|
+
*
|
|
863
|
+
* A hire needs caller-specific fields the listing alone can't provide
|
|
864
|
+
* (`creatorAgent` — the BUYER's registered agent PDA, or the humanless flag —
|
|
865
|
+
* and a fresh `taskId`). So `HireButton` takes a `buildHireInput(listing)`
|
|
866
|
+
* factory rather than guessing them. The compare-and-swap guards
|
|
867
|
+
* (`expectedPrice`/`expectedVersion`/`listingSpecHash`) are derived from the
|
|
868
|
+
* decoded listing by default and can be overridden in the returned input.
|
|
869
|
+
*
|
|
870
|
+
* @module components/HireButton
|
|
871
|
+
*/
|
|
872
|
+
|
|
873
|
+
/** Props for {@link HireButton}. */
|
|
874
|
+
interface HireButtonProps extends ThemableProps {
|
|
875
|
+
/** The listing to hire (decoded account + address). */
|
|
876
|
+
listing: HireCheckoutListing;
|
|
877
|
+
/**
|
|
878
|
+
* Build the per-hire input from the listing. Must return at least
|
|
879
|
+
* `creatorAgent` (standard hire) or `{ humanless: true }` plus a fresh
|
|
880
|
+
* `taskId` and the compare-and-swap guards. `listing` and the signer default
|
|
881
|
+
* to context. See `useHire` for the full input shape.
|
|
882
|
+
*/
|
|
883
|
+
buildHireInput: (listing: HireCheckoutListing) => AnyHireInput;
|
|
884
|
+
/** Called after a successful hire with the minted Task PDA. */
|
|
885
|
+
onHired?: (taskPda: Address) => void;
|
|
886
|
+
/** Called when the buyer clicks "View task" on the success screen. */
|
|
887
|
+
onViewTask?: (taskPda: Address) => void;
|
|
888
|
+
/** Show the price in the button label (`Hire — 1.5 SOL`). Default true. */
|
|
889
|
+
showPriceInLabel?: boolean;
|
|
890
|
+
/** Override the button label. */
|
|
891
|
+
label?: string;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* A connected hire button + checkout modal.
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```tsx
|
|
898
|
+
* <HireButton
|
|
899
|
+
* listing={row}
|
|
900
|
+
* buildHireInput={(l) => ({
|
|
901
|
+
* listing: l.address,
|
|
902
|
+
* creatorAgent: myAgentPda,
|
|
903
|
+
* taskId: randomId32(),
|
|
904
|
+
* expectedPrice: l.account.price,
|
|
905
|
+
* expectedVersion: l.account.version,
|
|
906
|
+
* })}
|
|
907
|
+
* onHired={(task) => router.push(`/tasks/${task}`)}
|
|
908
|
+
* />
|
|
909
|
+
* ```
|
|
910
|
+
*/
|
|
911
|
+
declare function HireButton({ listing, buildHireInput, onHired, onViewTask, showPriceInLabel, label, unstyled, className, }: HireButtonProps): ReactNode;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* `<ReferrerDisclosure>` — the "this site earns a referral fee" notice.
|
|
915
|
+
*
|
|
916
|
+
* ## THE P6.2 GATE (PLAN_2 §0 / the §0 referrer gate — read before editing)
|
|
917
|
+
*
|
|
918
|
+
* Disclosure is the ONE referrer surface allowed to render while the on-chain
|
|
919
|
+
* referrer leg is not live. It NEVER asserts that a fee was charged: when
|
|
920
|
+
* `live` is false it shows the "(pending protocol support)" copy. It is purely
|
|
921
|
+
* informational and reads no earnings. The actual injection / earnings remain
|
|
922
|
+
* blocked on P6.2 (handled by the hooks, not here). This component only
|
|
923
|
+
* DISCLOSES the configured intent.
|
|
924
|
+
*
|
|
925
|
+
* Render it only when a referrer is configured on the provider.
|
|
926
|
+
*
|
|
927
|
+
* @module components/ReferrerDisclosure
|
|
928
|
+
*/
|
|
929
|
+
|
|
930
|
+
/** Props for {@link ReferrerDisclosure}. */
|
|
931
|
+
interface ReferrerDisclosureProps extends ThemableProps {
|
|
932
|
+
/** The validated referrer config (from the provider context). */
|
|
933
|
+
referrer: ValidatedReferrerConfig;
|
|
934
|
+
/**
|
|
935
|
+
* Whether the referral fee is actually live on-chain (the P6.2 capability).
|
|
936
|
+
* ALWAYS false today — when false the copy shows the pending-support note and
|
|
937
|
+
* no fee is implied as charged. Defaults to false.
|
|
938
|
+
*/
|
|
939
|
+
live?: boolean;
|
|
940
|
+
/** Show the configured fee in bps alongside the disclosure. Default true. */
|
|
941
|
+
showFee?: boolean;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Disclose that the embedding site earns a referral fee. Honors the P6.2 gate:
|
|
945
|
+
* shows the pending-support copy until referral settlement is live.
|
|
946
|
+
*/
|
|
947
|
+
declare function ReferrerDisclosure({ referrer, live, showFee, unstyled, className, }: ReferrerDisclosureProps): ReactNode;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* `<TaskTimeline>` — the lifecycle progress of a hired task.
|
|
951
|
+
*
|
|
952
|
+
* Renders the canonical happy-path stages (Open → In progress → Pending review
|
|
953
|
+
* → Completed) as an ordered, accessible list with the current stage marked,
|
|
954
|
+
* and surfaces the terminal off-path states (Cancelled / Disputed / Rejected-
|
|
955
|
+
* frozen) when reached. Presentational: it takes a `TaskStatus | null` (from
|
|
956
|
+
* `useTaskStatus().status`) plus loading/error, so it renders under SSR and in
|
|
957
|
+
* Ladle without owning a reader.
|
|
958
|
+
*
|
|
959
|
+
* @module components/TaskTimeline
|
|
960
|
+
*/
|
|
961
|
+
|
|
962
|
+
/** Props for {@link TaskTimeline}. */
|
|
963
|
+
interface TaskTimelineProps extends ThemableProps {
|
|
964
|
+
/** The current task status (from `useTaskStatus().status`). */
|
|
965
|
+
status: TaskStatus | null;
|
|
966
|
+
/** True while loading the status. */
|
|
967
|
+
isLoading?: boolean;
|
|
968
|
+
/** A read error. */
|
|
969
|
+
error?: Error | null;
|
|
970
|
+
/** Retry handler for the error state. */
|
|
971
|
+
onRetry?: () => void;
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Render a task's lifecycle progress.
|
|
975
|
+
*/
|
|
976
|
+
declare function TaskTimeline({ status, isLoading, error, onRetry, unstyled, className, }: TaskTimelineProps): ReactNode;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* `<ReviewPanel>` — buyer-side settlement actions (accept / reject / request
|
|
980
|
+
* changes) for a submitted task.
|
|
981
|
+
*
|
|
982
|
+
* Presentational: it takes the three action handlers and a status/error (map
|
|
983
|
+
* from `useSubmissionReview()`), plus a `hasSubmission` flag that gates the
|
|
984
|
+
* actions until the worker has submitted. Each action is a real, keyboard-
|
|
985
|
+
* accessible button; the panel announces the settled outcome in a live region.
|
|
986
|
+
*
|
|
987
|
+
* The destructive verbs (reject, request changes) are visually distinguished
|
|
988
|
+
* but never hidden behind a confirm of their own — the host decides whether to
|
|
989
|
+
* wrap them; the panel keeps them clearly labelled and reversible-where-the-
|
|
990
|
+
* protocol-allows (request changes returns the task to the worker).
|
|
991
|
+
*
|
|
992
|
+
* @module components/ReviewPanel
|
|
993
|
+
*/
|
|
994
|
+
|
|
995
|
+
/** Props for {@link ReviewPanel}. */
|
|
996
|
+
interface ReviewPanelProps extends ThemableProps {
|
|
997
|
+
/** Whether the worker has submitted a result to review. */
|
|
998
|
+
hasSubmission?: boolean;
|
|
999
|
+
/** Accept handler (`useSubmissionReview().accept`-bound by the host). */
|
|
1000
|
+
onAccept?: () => void;
|
|
1001
|
+
/** Reject handler. */
|
|
1002
|
+
onReject?: () => void;
|
|
1003
|
+
/** Request-changes handler. */
|
|
1004
|
+
onRequestChanges?: () => void;
|
|
1005
|
+
/** Current action status (from `useSubmissionReview().status`). */
|
|
1006
|
+
status?: ReviewStatus;
|
|
1007
|
+
/** The action error to surface. */
|
|
1008
|
+
error?: Error | null;
|
|
1009
|
+
/**
|
|
1010
|
+
* Which verb most recently settled, for the success copy. Optional; when
|
|
1011
|
+
* given and `status === "success"` the matching message renders.
|
|
1012
|
+
*/
|
|
1013
|
+
settledAction?: "accept" | "reject" | "requestChanges";
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* The accept / reject / request-changes review panel.
|
|
1017
|
+
*/
|
|
1018
|
+
declare function ReviewPanel({ hasSubmission, onAccept, onReject, onRequestChanges, status, error, settledAction, unstyled, className, }: ReviewPanelProps): ReactNode;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* `<DisputeBanner>` — surfaces a task's dispute state + the entry point to open
|
|
1022
|
+
* one.
|
|
1023
|
+
*
|
|
1024
|
+
* Two modes, driven by `disputeOpen`:
|
|
1025
|
+
* - OPEN: a prominent `role="alert"` banner explaining funds stay in escrow
|
|
1026
|
+
* until a protocol resolver decides (matches the assignable single-resolver
|
|
1027
|
+
* model — no voting copy);
|
|
1028
|
+
* - NONE: an optional "Open a dispute" affordance (rendered only when
|
|
1029
|
+
* `onInitiate` is provided), with pending/opened/error states.
|
|
1030
|
+
*
|
|
1031
|
+
* Presentational: it takes `disputeOpen` + the initiate handler/status/error
|
|
1032
|
+
* (map from `useDispute()`), so it renders under SSR and in Ladle.
|
|
1033
|
+
*
|
|
1034
|
+
* @module components/DisputeBanner
|
|
1035
|
+
*/
|
|
1036
|
+
|
|
1037
|
+
/** Props for {@link DisputeBanner}. */
|
|
1038
|
+
interface DisputeBannerProps extends ThemableProps {
|
|
1039
|
+
/** Whether a dispute is currently open on the task. */
|
|
1040
|
+
disputeOpen?: boolean;
|
|
1041
|
+
/**
|
|
1042
|
+
* Open-a-dispute handler (`useDispute().initiate`-bound by the host). When
|
|
1043
|
+
* omitted, the no-dispute state renders informationally with no action.
|
|
1044
|
+
*/
|
|
1045
|
+
onInitiate?: () => void;
|
|
1046
|
+
/** Initiate-mutation status (from `useDispute().status`). */
|
|
1047
|
+
status?: DisputeStatus;
|
|
1048
|
+
/** The initiate error to surface. */
|
|
1049
|
+
error?: Error | null;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* The dispute banner / entry point.
|
|
1053
|
+
*/
|
|
1054
|
+
declare function DisputeBanner({ disputeOpen, onInitiate, status, error, unstyled, className, }: DisputeBannerProps): ReactNode;
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* `<ProviderCard>` — a provider's reputation summary.
|
|
1058
|
+
*
|
|
1059
|
+
* Renders the agent's track record (completion rate, dispute rate, completions,
|
|
1060
|
+
* dispute count, slash history count) plus a verified badge. Presentational: it
|
|
1061
|
+
* takes the projected `AgentTrackRecord | null` (from
|
|
1062
|
+
* `useAgentTrackRecord().trackRecord`) + loading/error, so it renders under SSR
|
|
1063
|
+
* and in Ladle.
|
|
1064
|
+
*
|
|
1065
|
+
* ## P6.6 honesty
|
|
1066
|
+
*
|
|
1067
|
+
* Rates are PROVISIONAL until P6.6 supplies true denominators. When the
|
|
1068
|
+
* `partial` flag is set the card marks the rates "(provisional)"; a `null` rate
|
|
1069
|
+
* renders as "—" (no denominator), never as a fabricated 0% or 100%.
|
|
1070
|
+
*
|
|
1071
|
+
* @module components/ProviderCard
|
|
1072
|
+
*/
|
|
1073
|
+
|
|
1074
|
+
/** Props for {@link ProviderCard}. */
|
|
1075
|
+
interface ProviderCardProps extends ThemableProps {
|
|
1076
|
+
/** The provider's agent PDA (for the heading). */
|
|
1077
|
+
agent?: Address | string | null;
|
|
1078
|
+
/** The projected track record (from `useAgentTrackRecord().trackRecord`). */
|
|
1079
|
+
trackRecord: AgentTrackRecord | null;
|
|
1080
|
+
/** Whether the provider is verified (shows the verified badge). */
|
|
1081
|
+
verified?: boolean;
|
|
1082
|
+
/** True while loading the track record. */
|
|
1083
|
+
isLoading?: boolean;
|
|
1084
|
+
/**
|
|
1085
|
+
* A read error. Under the gPA fallback the track record is unsupported; the
|
|
1086
|
+
* card shows the "unavailable on this transport" copy for that case.
|
|
1087
|
+
*/
|
|
1088
|
+
error?: Error | null;
|
|
1089
|
+
/** Retry handler for the error state. */
|
|
1090
|
+
onRetry?: () => void;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Render a provider reputation card.
|
|
1094
|
+
*/
|
|
1095
|
+
declare function ProviderCard({ agent, trackRecord, verified, isLoading, error, onRetry, unstyled, className, }: ProviderCardProps): ReactNode;
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* `<PoweredByAgenC>` — an optional attribution badge linking a trust page.
|
|
1099
|
+
*
|
|
1100
|
+
* A small, themable "Powered by AgenC" mark embedders can drop into a
|
|
1101
|
+
* storefront footer / checkout to link buyers to an explanation of the escrow +
|
|
1102
|
+
* moderation trust stack. Optional and fully white-labelable.
|
|
1103
|
+
*
|
|
1104
|
+
* SSR-safe; the link is a plain anchor (`rel="noopener noreferrer"` for safety
|
|
1105
|
+
* when it opens in a new tab). The `href` is scheme-validated (http/https/
|
|
1106
|
+
* mailto only; `javascript:`/`data:` fall back to the default trust href) so an
|
|
1107
|
+
* embedder wiring untrusted data into the prop cannot create a click-to-execute
|
|
1108
|
+
* XSS on a money surface.
|
|
1109
|
+
*
|
|
1110
|
+
* @module components/PoweredByAgenC
|
|
1111
|
+
*/
|
|
1112
|
+
|
|
1113
|
+
/** The default trust page the badge links to. */
|
|
1114
|
+
declare const DEFAULT_TRUST_HREF = "https://agenc.tech/trust";
|
|
1115
|
+
/** Props for {@link PoweredByAgenC}. */
|
|
1116
|
+
interface PoweredByAgenCProps extends ThemableProps {
|
|
1117
|
+
/** Trust-page URL. Defaults to {@link DEFAULT_TRUST_HREF}. */
|
|
1118
|
+
href?: string;
|
|
1119
|
+
/** Open the link in a new tab. Default true. */
|
|
1120
|
+
newTab?: boolean;
|
|
1121
|
+
/** Override the visible label. */
|
|
1122
|
+
label?: string;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* The "Powered by AgenC" attribution mark.
|
|
1126
|
+
*/
|
|
1127
|
+
declare function PoweredByAgenC({ href, newTab, label, unstyled, className, }: PoweredByAgenCProps): ReactNode;
|
|
1128
|
+
|
|
1129
|
+
export { type StringId as $, type AgencProviderConfig as A, Badge as B, type CreateReadTransportConfig as C, DEFAULT_TRUST_HREF as D, EN_COMPONENT_STRINGS as E, type PoweredByAgenCProps as F, type GpaReadSource as G, HireButton as H, type IndexerConfig as I, ProviderCard as J, type ProviderCardProps as K, ListingCard as L, Modal as M, type ReadListingResult as N, ReferrerDisclosure as O, PoweredByAgenC as P, type ReferrerDisclosureProps as Q, type ReferrerCapability as R, ReviewPanel as S, type ReviewPanelProps as T, Spinner as U, type ValidatedReferrerConfig as V, type SpinnerProps as W, type StateKind as X, StateMessage as Y, type StateMessageProps as Z, type StringCatalog as _, type AgencContextValue as a, type StringVars as a0, TaskTimeline as a1, type TaskTimelineProps as a2, type ThemableProps as a3, type TranslateOptions as a4, VerifiedBadge as a5, type VerifiedBadgeProps as a6, cx as a7, decodeListingCategory as a8, decodeListingName as a9, decodeListingTags as aa, elementClass as ab, formatPriceSol as ac, formatRate as ad, formatSol as ae, moderationStateOf as af, rootClass as ag, t as ah, tc as ai, toHex as aj, truncateAddress as ak, useFocusTrap as al, type ReferrerConfig as b, type AgencNetwork as c, type ReadTransport as d, type BadgeProps as e, type BadgeTone as f, Button as g, type ButtonProps as h, type ButtonVariant as i, COMPONENT_CATALOG as j, type ComponentStringId as k, DisputeBanner as l, type DisputeBannerProps as m, EN_STRINGS as n, type HireButtonProps as o, type HireCheckoutListing as p, HireCheckoutModal as q, type HireCheckoutModalProps as r, type ListingCardData as s, type ListingCardProps as t, ListingGrid as u, type ListingGridProps as v, type ModalProps as w, ModerationBadge as x, type ModerationBadgeProps as y, type ModerationState as z };
|