@tesouro/embedded-components-react 0.10.0 → 0.10.5

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.
Files changed (41) hide show
  1. package/dist/experimental/index.d.ts +2 -108
  2. package/dist/experimental/index.js +4 -5
  3. package/dist/index.d.ts +3 -0
  4. package/dist/lib/BankAccountsWidget.d.ts +3 -0
  5. package/dist/lib/WidgetSuite.d.ts +3 -0
  6. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/lib/BalancesWidget/BalancesWidgetContext.js +39 -36
  7. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/lib/BalancesWidget/BalancesWidgetFeature.js +6 -6
  8. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index9.js +31 -22
  9. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index6.js +44 -31
  10. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index7.js +3 -0
  11. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/ui/dist/index8.js +59 -56
  12. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/lib/InsightsWidget/useDismissedInsightIds.js +77 -38
  13. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  14. package/dist/packages/shared-ui-shadcn/dist/index.js +3374 -3474
  15. package/package.json +1 -1
  16. package/dist/experimental/ApprovalRequests.d.ts +0 -706
  17. package/dist/experimental/ApprovalRequests.js +0 -2
  18. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index.js +0 -9
  19. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index2.js +0 -9
  20. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index3.js +0 -71
  21. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index4.js +0 -33
  22. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index5.js +0 -34
  23. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index6.js +0 -26
  24. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/data-access/dist/index7.js +0 -30
  25. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/index.js +0 -1
  26. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js +0 -89
  27. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/buildApprovalRequestRows.js +0 -44
  28. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/canDecideApprovalRequest.js +0 -7
  29. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/constants.js +0 -18
  30. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/labels.js +0 -28
  31. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/permissions.js +0 -8
  32. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js +0 -93
  33. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestNames.js +0 -65
  34. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsFilters.js +0 -148
  35. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestsTable.js +0 -73
  36. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/analytics/events.js +0 -3
  37. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index.js +0 -5
  38. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index2.js +0 -47
  39. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index3.js +0 -142
  40. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index4.js +0 -136
  41. package/dist/libs/tesouro-embedded-components-react/approval-requests-widget/ui/dist/index5.js +0 -43
@@ -1,706 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } from 'react';
3
- import { PartialDeep } from 'type-fest';
4
- import { FallbackProps } from 'react-error-boundary';
5
-
6
- type AuthToken = string | undefined;
7
- interface Auth {
8
- /**
9
- * Which part of the request do we use to send the auth?
10
- *
11
- * @default 'header'
12
- */
13
- in?: 'header' | 'query' | 'cookie';
14
- /**
15
- * A unique identifier for the security scheme.
16
- *
17
- * Defined only when there are multiple security schemes whose `Auth`
18
- * shape would otherwise be identical.
19
- */
20
- key?: string;
21
- /**
22
- * Header or query parameter name.
23
- *
24
- * @default 'Authorization'
25
- */
26
- name?: string;
27
- scheme?: 'basic' | 'bearer';
28
- type: 'apiKey' | 'http';
29
- }
30
-
31
- interface SerializerOptions<T> {
32
- /**
33
- * @default true
34
- */
35
- explode: boolean;
36
- style: T;
37
- }
38
- type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
39
- type ObjectStyle = 'form' | 'deepObject';
40
-
41
- type QuerySerializer = (query: Record<string, unknown>) => string;
42
- type BodySerializer = (body: unknown) => unknown;
43
- type QuerySerializerOptionsObject = {
44
- allowReserved?: boolean;
45
- array?: Partial<SerializerOptions<ArrayStyle>>;
46
- object?: Partial<SerializerOptions<ObjectStyle>>;
47
- };
48
- type QuerySerializerOptions = QuerySerializerOptionsObject & {
49
- /**
50
- * Per-parameter serialization overrides. When provided, these settings
51
- * override the global array/object settings for specific parameter names.
52
- */
53
- parameters?: Record<string, QuerySerializerOptionsObject>;
54
- };
55
-
56
- type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
57
- type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
58
- /**
59
- * Returns the final request URL.
60
- */
61
- buildUrl: BuildUrlFn;
62
- getConfig: () => Config;
63
- request: RequestFn;
64
- setConfig: (config: Config) => Config;
65
- } & {
66
- [K in HttpMethod]: MethodFn;
67
- } & ([SseFn] extends [never] ? {
68
- sse?: never;
69
- } : {
70
- sse: {
71
- [K in HttpMethod]: SseFn;
72
- };
73
- });
74
- interface Config$1 {
75
- /**
76
- * Auth token or a function returning auth token. The resolved value will be
77
- * added to the request payload as defined by its `security` array.
78
- */
79
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
80
- /**
81
- * A function for serializing request body parameter. By default,
82
- * {@link JSON.stringify()} will be used.
83
- */
84
- bodySerializer?: BodySerializer | null;
85
- /**
86
- * An object containing any HTTP headers that you want to pre-populate your
87
- * `Headers` object with.
88
- *
89
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
90
- */
91
- headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
92
- /**
93
- * The request method.
94
- *
95
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
96
- */
97
- method?: Uppercase<HttpMethod>;
98
- /**
99
- * A function for serializing request query parameters. By default, arrays
100
- * will be exploded in form style, objects will be exploded in deepObject
101
- * style, and reserved characters are percent-encoded.
102
- *
103
- * This method will have no effect if the native `paramsSerializer()` Axios
104
- * API function is used.
105
- *
106
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
107
- */
108
- querySerializer?: QuerySerializer | QuerySerializerOptions;
109
- /**
110
- * A function validating request data. This is useful if you want to ensure
111
- * the request conforms to the desired shape, so it can be safely sent to
112
- * the server.
113
- */
114
- requestValidator?: (data: unknown) => Promise<unknown>;
115
- /**
116
- * A function transforming response data before it's returned. This is useful
117
- * for post-processing data, e.g., converting ISO strings into Date objects.
118
- */
119
- responseTransformer?: (data: unknown) => Promise<unknown>;
120
- /**
121
- * A function validating response data. This is useful if you want to ensure
122
- * the response conforms to the desired shape, so it can be safely passed to
123
- * the transformers and returned to the user.
124
- */
125
- responseValidator?: (data: unknown) => Promise<unknown>;
126
- }
127
-
128
- type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
129
- /**
130
- * Fetch API implementation. You can use this option to provide a custom
131
- * fetch instance.
132
- *
133
- * @default globalThis.fetch
134
- */
135
- fetch?: typeof fetch;
136
- /**
137
- * Implementing clients can call request interceptors inside this hook.
138
- */
139
- onRequest?: (url: string, init: RequestInit) => Promise<Request>;
140
- /**
141
- * Callback invoked when a network or parsing error occurs during streaming.
142
- *
143
- * This option applies only if the endpoint returns a stream of events.
144
- *
145
- * @param error The error that occurred.
146
- */
147
- onSseError?: (error: unknown) => void;
148
- /**
149
- * Callback invoked when an event is streamed from the server.
150
- *
151
- * This option applies only if the endpoint returns a stream of events.
152
- *
153
- * @param event Event streamed from the server.
154
- * @returns Nothing (void).
155
- */
156
- onSseEvent?: (event: StreamEvent<TData>) => void;
157
- serializedBody?: RequestInit['body'];
158
- /**
159
- * Default retry delay in milliseconds.
160
- *
161
- * This option applies only if the endpoint returns a stream of events.
162
- *
163
- * @default 3000
164
- */
165
- sseDefaultRetryDelay?: number;
166
- /**
167
- * Maximum number of retry attempts before giving up.
168
- */
169
- sseMaxRetryAttempts?: number;
170
- /**
171
- * Maximum retry delay in milliseconds.
172
- *
173
- * Applies only when exponential backoff is used.
174
- *
175
- * This option applies only if the endpoint returns a stream of events.
176
- *
177
- * @default 30000
178
- */
179
- sseMaxRetryDelay?: number;
180
- /**
181
- * Optional sleep function for retry backoff.
182
- *
183
- * Defaults to using `setTimeout`.
184
- */
185
- sseSleepFn?: (ms: number) => Promise<void>;
186
- url: string;
187
- };
188
- interface StreamEvent<TData = unknown> {
189
- data: TData;
190
- event?: string;
191
- id?: string;
192
- retry?: number;
193
- }
194
- type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
195
- stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
196
- };
197
-
198
- type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
199
- /** response may be undefined due to a network error where no response object is produced */
200
- response: Res | undefined,
201
- /** request may be undefined, because error may be from building the request object itself */
202
- request: Req | undefined, options: Options) => Err | Promise<Err>;
203
- type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
204
- type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
205
- declare class Interceptors<Interceptor> {
206
- fns: Array<Interceptor | null>;
207
- clear(): void;
208
- eject(id: number | Interceptor): void;
209
- exists(id: number | Interceptor): boolean;
210
- getInterceptorIndex(id: number | Interceptor): number;
211
- update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
212
- use(fn: Interceptor): number;
213
- }
214
- interface Middleware<Req, Res, Err, Options> {
215
- error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
216
- request: Interceptors<ReqInterceptor<Req, Options>>;
217
- response: Interceptors<ResInterceptor<Res, Req, Options>>;
218
- }
219
-
220
- type ResponseStyle = 'data' | 'fields';
221
- interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
222
- /**
223
- * Base URL for all requests made by this client.
224
- */
225
- baseUrl?: T['baseUrl'];
226
- /**
227
- * Fetch API implementation. You can use this option to provide a custom
228
- * fetch instance.
229
- *
230
- * @default globalThis.fetch
231
- */
232
- fetch?: typeof fetch;
233
- /**
234
- * Please don't use the Fetch client for Next.js applications. The `next`
235
- * options won't have any effect.
236
- *
237
- * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
238
- */
239
- next?: never;
240
- /**
241
- * Return the response data parsed in a specified format. By default, `auto`
242
- * will infer the appropriate method from the `Content-Type` response header.
243
- * You can override this behavior with any of the {@link Body} methods.
244
- * Select `stream` if you don't want to parse response data at all.
245
- *
246
- * @default 'auto'
247
- */
248
- parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
249
- /**
250
- * Should we return only data or multiple fields (data, error, response, etc.)?
251
- *
252
- * @default 'fields'
253
- */
254
- responseStyle?: ResponseStyle;
255
- /**
256
- * Throw an error instead of returning it in the response?
257
- *
258
- * @default false
259
- */
260
- throwOnError?: T['throwOnError'];
261
- }
262
- interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
263
- responseStyle: TResponseStyle;
264
- throwOnError: ThrowOnError;
265
- }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
266
- /**
267
- * Any body that you want to add to your request.
268
- *
269
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
270
- */
271
- body?: unknown;
272
- path?: Record<string, unknown>;
273
- query?: Record<string, unknown>;
274
- /**
275
- * Security mechanism(s) to use for the request.
276
- */
277
- security?: ReadonlyArray<Auth>;
278
- url: Url;
279
- }
280
- interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
281
- headers: Headers;
282
- serializedBody?: string;
283
- }
284
- type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
285
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
286
- request: Request;
287
- response: Response;
288
- }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
289
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
290
- error: undefined;
291
- } | {
292
- data: undefined;
293
- error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
294
- }) & {
295
- /** request may be undefined, because error may be from building the request object itself */
296
- request?: Request;
297
- /** response may be undefined, because error may be from building the request object itself or from a network error */
298
- response?: Response;
299
- }>;
300
- interface ClientOptions$1 {
301
- baseUrl?: string;
302
- responseStyle?: ResponseStyle;
303
- throwOnError?: boolean;
304
- }
305
- type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
306
- type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
307
- type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
308
- type BuildUrlFn = <TData extends {
309
- body?: unknown;
310
- path?: Record<string, unknown>;
311
- query?: Record<string, unknown>;
312
- url: string;
313
- }>(options: TData & Options<TData>) => string;
314
- type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
315
- interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
316
- };
317
- interface TDataShape {
318
- body?: unknown;
319
- headers?: unknown;
320
- path?: unknown;
321
- query?: unknown;
322
- url: string;
323
- }
324
- type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
325
- type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
326
-
327
- type ClientOptions = {
328
- baseUrl: 'https://api.stage.tesouro.com' | 'https://api.sandbox.stage.tesouro.com' | 'https://api.stage.business-banking.app' | 'https://api.tesouro.com' | 'https://api.sandbox.tesouro.com' | 'https://api.business-banking.app' | (string & {});
329
- };
330
- type ApprovalRequestStatus = 'waiting' | 'approved' | 'rejected' | 'canceled';
331
-
332
- type EmbeddedClient = Client;
333
- type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
334
- type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
335
-
336
- interface FilterMenuButtonLabels {
337
- /** Button text, followed by "(N)" when `activeCount` is set. */
338
- filters: string;
339
- }
340
-
341
- interface FilterTagLabels {
342
- /**
343
- * Accessible name for the editable tag body. `{label}` is substituted with
344
- * the tag's own text; keep the placeholder when overriding.
345
- */
346
- edit: string;
347
- /** Accessible name for the × dismiss button. `{label}` is substituted. */
348
- remove: string;
349
- }
350
-
351
- type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
352
- children?: ReactNode;
353
- };
354
- type LinkComponent = ComponentType<LinkComponentProps>;
355
- /**
356
- * The UI frameworks a widget's UI layer can render with.
357
- *
358
- * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
359
- * implicit fallback, so existing consumers that select nothing keep rendering
360
- * shadcn.
361
- * - `tecton` — the Tecton implementation.
362
- *
363
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
364
- * convention.
365
- */
366
- declare const UIFramework: {
367
- readonly Shadcn: "shadcn";
368
- readonly Tecton: "tecton";
369
- };
370
- type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
371
-
372
- /**
373
- * The settable fields of the widget config cascade.
374
- *
375
- * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
376
- * It intentionally excludes `initResponse`, which is populated automatically by the
377
- * provider after a successful fetch and must never be set manually.
378
- *
379
- * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
380
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
381
- * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
382
- * (e.g. after logout or deliberate de-scoping).
383
- *
384
- * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
385
- * @see {@link RootWidgetProvider}
386
- * @see {@link WidgetProvider}
387
- * @see {@link setGlobalWidgetConfig}
388
- */
389
- interface WidgetConfigInput {
390
- /**
391
- * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
392
- *
393
- * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
394
- * Changing this recreates the underlying HTTP client so all subsequent requests
395
- * go to the new host.
396
- */
397
- baseUrl?: BaseUrl;
398
- /**
399
- * Bearer token used to authenticate widget requests.
400
- *
401
- * Injected as `Authorization: Bearer <token>` on every outgoing request via an
402
- * interceptor on the scoped HTTP client. Token updates are picked up immediately
403
- * without recreating the client.
404
- *
405
- * - `string` — send this token on all requests from this level downward.
406
- * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
407
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
408
- */
409
- widgetToken?: string | null;
410
- /**
411
- * Organization ID forwarded as the `x-organization-id` request header.
412
- *
413
- * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
414
- * so individual data-access hooks can opt in per-request.
415
- *
416
- * - `string` — use this organization for downstream data requests.
417
- * - `null` — explicitly cleared; queries that require an org ID will be disabled.
418
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
419
- *
420
- * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
421
- * value), the resolved org defaults to the loaded `initResponse.organizationId`
422
- * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
423
- * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
424
- * level wins, and an explicit `null` is preserved and never falls back.
425
- *
426
- * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
427
- * default does not propagate into a descendant that owns its own fetch (its own
428
- * `baseUrl`/`widgetToken`); such a descendant defaults to its own
429
- * `initResponse.organizationId` instead, so it never sends an ancestor's org with
430
- * its own token.
431
- */
432
- organizationId?: string | null;
433
- /**
434
- * Optional post-creation hook for the scoped HTTP client.
435
- *
436
- * Called once after the provider creates its scoped {@link EmbeddedClient} and
437
- * applies the built-in `Authorization: Bearer` interceptor. Receives the
438
- * fully-configured client and must return the client to be used for the lifetime of
439
- * this provider level — either the same instance (with additional interceptors
440
- * attached) or a new client entirely.
441
- *
442
- * **Order:** The built-in auth interceptor is always applied first. `configClient`
443
- * is called on top of it, so any interceptors you add here run after auth is set.
444
- *
445
- * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
446
- * scoped client whenever any prop is set — including `configClient` alone, without
447
- * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
448
- * client creation and never calls this function.
449
- *
450
- * **Stability:** The function reference is included in the client creation memo's
451
- * dependency array. Passing an unstable (inline) function recreates the client on
452
- * every render. Stabilize with `useCallback` or define the function outside the
453
- * component.
454
- *
455
- * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
456
- * {@link WidgetProvider} that creates its own scoped client will use the resolved
457
- * `configClient` from the cascade unless it provides its own override.
458
- *
459
- * @example
460
- * ```tsx
461
- * const addLogging = useCallback(
462
- * (client: EmbeddedClient) => {
463
- * client.interceptors.request.use((req) => {
464
- * console.log('[widget]', req.method, req.url);
465
- * return req;
466
- * });
467
- * return client;
468
- * },
469
- * [],
470
- * );
471
- *
472
- * <RootWidgetProvider
473
- * baseUrl="https://api.tesouro.com"
474
- * widgetToken={token}
475
- * configClient={addLogging}
476
- * >
477
- * <App />
478
- * </RootWidgetProvider>
479
- * ```
480
- */
481
- configClient?: (client: EmbeddedClient) => EmbeddedClient;
482
- /**
483
- * Overrides the widget-gateway routing decision for the scoped HTTP client.
484
- *
485
- * Any caller reaching the Tesouro API with a widget token must route data
486
- * requests through the widget gateway: prefix the path with
487
- * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
488
- * provider applies both automatically per request when the request origin is
489
- * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
490
- * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
491
- * init round-trip) always pass through untouched.
492
- *
493
- * - `undefined` — decide from the request origin, as above. Inherits from
494
- * the nearest ancestor or global store like every other config field.
495
- * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
496
- * custom domain in front of the gateway).
497
- * - `false` — never apply it. For hosts that route widget requests their own
498
- * way, such as a same-origin BFF whose `configClient` retargets every
499
- * request.
500
- *
501
- * Independent of {@link configClient}: a host that only adds a header keeps
502
- * the built-in routing, and the built-in interceptor runs before any
503
- * `configClient` interceptor.
504
- */
505
- gatewayRouting?: boolean;
506
- /**
507
- * Component the embedded widgets should render in place of plain `<a>` tags.
508
- *
509
- * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
510
- * Cascades like other config: provider prop > nearest ancestor > global store.
511
- * When no value is set anywhere, widgets fall back to a plain `<a>` element.
512
- */
513
- linkComponent?: LinkComponent;
514
- /**
515
- * Which UI framework the widget UI layer should render with.
516
- *
517
- * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
518
- * Tecton implementation behind the same outward-facing API. The selection is
519
- * a presentation concern only — it cascades through the provider tree exactly
520
- * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
521
- * it never appears in any widget's feature-library or component props.
522
- *
523
- * - `'shadcn'` — the shadcn/Tailwind implementation.
524
- * - `'tecton'` — the Tecton implementation.
525
- * - `null` / `undefined` — not set at this level; inherit from the nearest
526
- * ancestor or global store, falling back to `shadcn` when unset everywhere.
527
- * `shadcn` is the implicit default, so existing consumers need no changes.
528
- */
529
- uiFramework?: UIFramework | null;
530
- }
531
- /**
532
- * Props shared by every analytics-owner-capable widget provider.
533
- *
534
- * Combines the full settable cascade ({@link WidgetConfigInput}) with the
535
- * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
536
- * and {@link WidgetProvider} build their public props on top of this; the latter
537
- * adds error-boundary props of its own.
538
- *
539
- * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
540
- */
541
- interface WidgetProviderBaseProps extends WidgetConfigInput {
542
- /**
543
- * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
544
- *
545
- * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
546
- * standalone {@link WidgetProvider} with no parent provider. When `false`,
547
- * owner-bound `track` calls in this subtree become no-ops and the PostHog
548
- * installer is never dynamically imported for this owner's environment.
549
- * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
550
- * `console.warn` is emitted to make the no-op discoverable).
551
- */
552
- analytics?: boolean;
553
- }
554
-
555
- /**
556
- * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
557
- * the error-boundary fallback and the disclosures gate. A host overrides any
558
- * subset through the `providerLabels` prop, which cascades like
559
- * `disclosuresAcceptance`.
560
- *
561
- * Not named `Labels` on the public surface: a widget's own `labels` prop is a
562
- * different thing, and these two travel together on every widget's props type.
563
- */
564
- interface WidgetProviderLabels {
565
- /** Default copy for the built-in error boundary fallback. */
566
- errorBoundaryFallback: string;
567
- /** Heading when init reports disclosures are required and not yet accepted. */
568
- disclosuresRequiredTitle: string;
569
- /** Heading while a token-only refresh leaves init stale for the live token. */
570
- disclosuresRefreshingTitle: string;
571
- /** Supporting copy while the accept action is withheld for a stale init. */
572
- disclosuresRefreshingDescription: string;
573
- }
574
-
575
- /**
576
- * Props for {@link WidgetProvider}.
577
- *
578
- * All fields are optional. When **all** are omitted the provider is a transparent
579
- * pass-through: no fetch is issued and all resolved values cascade unchanged from
580
- * the nearest ancestor.
581
- */
582
- interface WidgetProviderProps extends WidgetProviderBaseProps {
583
- /**
584
- * Fallback rendered when a render-time exception is caught inside this
585
- * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
586
- * render-prop receiving `{ error, resetErrorBoundary }` from
587
- * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
588
- * comes from `providerLabels.errorBoundaryFallback`.
589
- */
590
- errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
591
- /**
592
- * Called once when the boundary catches an error, before the fallback
593
- * renders. Use for telemetry / error tracking / partner logging. Exceptions
594
- * thrown from `onError` propagate per `react-error-boundary` semantics.
595
- */
596
- onError?: (error: unknown, info: ErrorInfo) => void;
597
- /**
598
- * Accept surface shown when the caller owes disclosures — an INVITED
599
- * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
600
- * activate) or an ACTIVE user who owes a new version. Pass
601
- * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
602
- * WidgetProvider cannot import the widget itself (cycle).
603
- */
604
- disclosuresAcceptance?: ReactNode;
605
- /**
606
- * Overrides for the copy this provider renders in place of the widget: the
607
- * built-in error-boundary fallback and the disclosures gate. Any subset;
608
- * unlisted keys keep their defaults. Cascades like `linkComponent`.
609
- *
610
- * Named `providerLabels` rather than `labels` because a widget's own
611
- * `labels` prop sits alongside this one on the same props type.
612
- */
613
- providerLabels?: Partial<WidgetProviderLabels>;
614
- }
615
-
616
- interface ApprovalRequestsFilterBarLabels {
617
- fields: {
618
- status: string;
619
- addedBy: string;
620
- requestedOn: string;
621
- };
622
- fieldMenuLabel: string;
623
- onlyMine: string;
624
- userSearchLabel: string;
625
- userSearchPlaceholder: string;
626
- userEmpty: string;
627
- userLoading: string;
628
- userError: string;
629
- clearAll: string;
630
- filterMenuButton: FilterMenuButtonLabels;
631
- filterTag: FilterTagLabels;
632
- }
633
- interface ApprovalRequestsScreenLabels {
634
- columnInvoiceNumber: string;
635
- columnVendor: string;
636
- columnIssueDate: string;
637
- columnDueDate: string;
638
- columnStatus: string;
639
- columnAmount: string;
640
- columnAddedBy: string;
641
- columnActions: string;
642
- rowActions: string;
643
- approve: string;
644
- reject: string;
645
- /** Read by screen readers in a cell whose name is still loading. */
646
- loadingValue: string;
647
- errorTitle: string;
648
- errorDescription: string;
649
- errorRetry: string;
650
- filterBar: ApprovalRequestsFilterBarLabels;
651
- accessRestrictedTitle: string;
652
- accessRestrictedDescription: string;
653
- }
654
- interface RejectApprovalRequestDialogLabels {
655
- title: string;
656
- description: string;
657
- reason: string;
658
- optionalNote: string;
659
- confirm: string;
660
- cancel: string;
661
- close: string;
662
- }
663
-
664
- interface ApprovalRequestsFilterLabels {
665
- statusChip: (value: string) => string;
666
- addedByChip: (name: string) => string;
667
- requestedOnChip: (range: string) => string;
668
- moreSelected: (first: string, count: number) => string;
669
- dateRange: (from: string, to: string) => string;
670
- }
671
- interface ApprovalRequestsListLabels {
672
- emptyTitle: string;
673
- emptyDescription: string;
674
- filterEmptyTitle: string;
675
- filterEmptyDescription: string;
676
- /** Shown in a cell whose value the request's payable does not carry. */
677
- missingValue: string;
678
- /** Shown for a vendor or creator this session may not read, or whose lookup failed. */
679
- unavailableValue: string;
680
- status: Record<ApprovalRequestStatus, string>;
681
- filters: ApprovalRequestsFilterLabels;
682
- }
683
- /** Toast copy for approve and reject; the error copy is the fallback when the API gives no reason. */
684
- interface ApprovalRequestsMessageLabels {
685
- approved: string;
686
- rejected: string;
687
- approveError: string;
688
- rejectError: string;
689
- }
690
-
691
- interface ApprovalRequestsWidgetOwnProps {
692
- screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
693
- listLabels?: PartialDeep<ApprovalRequestsListLabels>;
694
- rejectDialogLabels?: PartialDeep<RejectApprovalRequestDialogLabels>;
695
- messageLabels?: PartialDeep<ApprovalRequestsMessageLabels>;
696
- }
697
- /** Public props for {@link ApprovalRequestsWidget}. */
698
- type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
699
- /**
700
- * Self-contained approval requests widget, a native port of Monite's approval
701
- * requests (FOPS-97). Exported only from the package's `/experimental` entry.
702
- */
703
- declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, messageLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
704
-
705
- export { ApprovalRequestsWidget };
706
- export type { ApprovalRequestsWidgetProps };