@tesouro/embedded-components-react 0.5.95 → 0.5.97

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 (50) hide show
  1. package/README.md +5 -5
  2. package/dist/experimental/index.d.ts +3 -274
  3. package/dist/experimental/index.js +2 -4
  4. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index2.js +13 -0
  5. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index3.js +18 -0
  6. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index4.js +29 -0
  7. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index5.js +29 -0
  8. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index6.js +29 -0
  9. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/data-access/dist/index7.js +22 -0
  10. package/dist/libs/tesouro-embedded-components-react/cards-widget/create-card/feature/dist/index2.js +5 -0
  11. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index3.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index4.js +2 -2
  13. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index5.js +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index6.js +4 -4
  15. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index7.js +4 -4
  16. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index8.js +15 -15
  17. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardArt.js +2 -2
  18. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/CardControlRow.js +2 -2
  19. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/CardControls.js +2 -2
  20. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/MerchantCategoriesControl.js +2 -2
  21. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/PerTransactionMaximumControl.js +2 -2
  22. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/SpendLimitControl.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/labels.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CardControls/limitDecimalPlaces.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/CreateCardWidget.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/ManualAddressFields.js +2 -2
  27. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/PreparingView.js +2 -2
  28. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/SetupView.js +4 -4
  29. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/SuccessView.js +2 -2
  30. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/labels.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/lib/CreateCardWidget/types.js +1 -1
  32. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index2.js +3 -2
  33. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +2 -2
  34. package/dist/libs/tesouro-embedded-components-react/cards-widget/shared/util/dist/lib/widgetName.js +4 -0
  35. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index.js +1 -3
  36. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +86 -77
  37. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/experimental/InvoiceSettings.d.ts +0 -902
  40. package/dist/experimental/InvoiceSettings.js +0 -3
  41. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index2.js +0 -13
  42. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index3.js +0 -18
  43. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index4.js +0 -29
  44. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js +0 -29
  45. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index6.js +0 -29
  46. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index7.js +0 -22
  47. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index2.js +0 -4
  48. /package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/data-access/dist/index.js +0 -0
  49. /package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/feature/dist/index.js +0 -0
  50. /package/dist/libs/tesouro-embedded-components-react/{create-card-widget → cards-widget/create-card}/ui/dist/index.js +0 -0
@@ -1,902 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo, Ref } from 'react';
3
- import { FallbackProps } from 'react-error-boundary';
4
-
5
- type AuthToken = string | undefined;
6
- interface Auth {
7
- /**
8
- * Which part of the request do we use to send the auth?
9
- *
10
- * @default 'header'
11
- */
12
- in?: 'header' | 'query' | 'cookie';
13
- /**
14
- * A unique identifier for the security scheme.
15
- *
16
- * Defined only when there are multiple security schemes whose `Auth`
17
- * shape would otherwise be identical.
18
- */
19
- key?: string;
20
- /**
21
- * Header or query parameter name.
22
- *
23
- * @default 'Authorization'
24
- */
25
- name?: string;
26
- scheme?: 'basic' | 'bearer';
27
- type: 'apiKey' | 'http';
28
- }
29
-
30
- interface SerializerOptions<T> {
31
- /**
32
- * @default true
33
- */
34
- explode: boolean;
35
- style: T;
36
- }
37
- type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
38
- type ObjectStyle = 'form' | 'deepObject';
39
-
40
- type QuerySerializer = (query: Record<string, unknown>) => string;
41
- type BodySerializer = (body: unknown) => unknown;
42
- type QuerySerializerOptionsObject = {
43
- allowReserved?: boolean;
44
- array?: Partial<SerializerOptions<ArrayStyle>>;
45
- object?: Partial<SerializerOptions<ObjectStyle>>;
46
- };
47
- type QuerySerializerOptions = QuerySerializerOptionsObject & {
48
- /**
49
- * Per-parameter serialization overrides. When provided, these settings
50
- * override the global array/object settings for specific parameter names.
51
- */
52
- parameters?: Record<string, QuerySerializerOptionsObject>;
53
- };
54
-
55
- type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
56
- type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
57
- /**
58
- * Returns the final request URL.
59
- */
60
- buildUrl: BuildUrlFn;
61
- getConfig: () => Config;
62
- request: RequestFn;
63
- setConfig: (config: Config) => Config;
64
- } & {
65
- [K in HttpMethod]: MethodFn;
66
- } & ([SseFn] extends [never] ? {
67
- sse?: never;
68
- } : {
69
- sse: {
70
- [K in HttpMethod]: SseFn;
71
- };
72
- });
73
- interface Config$1 {
74
- /**
75
- * Auth token or a function returning auth token. The resolved value will be
76
- * added to the request payload as defined by its `security` array.
77
- */
78
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
79
- /**
80
- * A function for serializing request body parameter. By default,
81
- * {@link JSON.stringify()} will be used.
82
- */
83
- bodySerializer?: BodySerializer | null;
84
- /**
85
- * An object containing any HTTP headers that you want to pre-populate your
86
- * `Headers` object with.
87
- *
88
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
89
- */
90
- headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
91
- /**
92
- * The request method.
93
- *
94
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
95
- */
96
- method?: Uppercase<HttpMethod>;
97
- /**
98
- * A function for serializing request query parameters. By default, arrays
99
- * will be exploded in form style, objects will be exploded in deepObject
100
- * style, and reserved characters are percent-encoded.
101
- *
102
- * This method will have no effect if the native `paramsSerializer()` Axios
103
- * API function is used.
104
- *
105
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
106
- */
107
- querySerializer?: QuerySerializer | QuerySerializerOptions;
108
- /**
109
- * A function validating request data. This is useful if you want to ensure
110
- * the request conforms to the desired shape, so it can be safely sent to
111
- * the server.
112
- */
113
- requestValidator?: (data: unknown) => Promise<unknown>;
114
- /**
115
- * A function transforming response data before it's returned. This is useful
116
- * for post-processing data, e.g., converting ISO strings into Date objects.
117
- */
118
- responseTransformer?: (data: unknown) => Promise<unknown>;
119
- /**
120
- * A function validating response data. This is useful if you want to ensure
121
- * the response conforms to the desired shape, so it can be safely passed to
122
- * the transformers and returned to the user.
123
- */
124
- responseValidator?: (data: unknown) => Promise<unknown>;
125
- }
126
-
127
- type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
128
- /**
129
- * Fetch API implementation. You can use this option to provide a custom
130
- * fetch instance.
131
- *
132
- * @default globalThis.fetch
133
- */
134
- fetch?: typeof fetch;
135
- /**
136
- * Implementing clients can call request interceptors inside this hook.
137
- */
138
- onRequest?: (url: string, init: RequestInit) => Promise<Request>;
139
- /**
140
- * Callback invoked when a network or parsing error occurs during streaming.
141
- *
142
- * This option applies only if the endpoint returns a stream of events.
143
- *
144
- * @param error The error that occurred.
145
- */
146
- onSseError?: (error: unknown) => void;
147
- /**
148
- * Callback invoked when an event is streamed from the server.
149
- *
150
- * This option applies only if the endpoint returns a stream of events.
151
- *
152
- * @param event Event streamed from the server.
153
- * @returns Nothing (void).
154
- */
155
- onSseEvent?: (event: StreamEvent<TData>) => void;
156
- serializedBody?: RequestInit['body'];
157
- /**
158
- * Default retry delay in milliseconds.
159
- *
160
- * This option applies only if the endpoint returns a stream of events.
161
- *
162
- * @default 3000
163
- */
164
- sseDefaultRetryDelay?: number;
165
- /**
166
- * Maximum number of retry attempts before giving up.
167
- */
168
- sseMaxRetryAttempts?: number;
169
- /**
170
- * Maximum retry delay in milliseconds.
171
- *
172
- * Applies only when exponential backoff is used.
173
- *
174
- * This option applies only if the endpoint returns a stream of events.
175
- *
176
- * @default 30000
177
- */
178
- sseMaxRetryDelay?: number;
179
- /**
180
- * Optional sleep function for retry backoff.
181
- *
182
- * Defaults to using `setTimeout`.
183
- */
184
- sseSleepFn?: (ms: number) => Promise<void>;
185
- url: string;
186
- };
187
- interface StreamEvent<TData = unknown> {
188
- data: TData;
189
- event?: string;
190
- id?: string;
191
- retry?: number;
192
- }
193
- type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
194
- stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
195
- };
196
-
197
- type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
198
- /** response may be undefined due to a network error where no response object is produced */
199
- response: Res | undefined,
200
- /** request may be undefined, because error may be from building the request object itself */
201
- request: Req | undefined, options: Options) => Err | Promise<Err>;
202
- type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
203
- type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
204
- declare class Interceptors<Interceptor> {
205
- fns: Array<Interceptor | null>;
206
- clear(): void;
207
- eject(id: number | Interceptor): void;
208
- exists(id: number | Interceptor): boolean;
209
- getInterceptorIndex(id: number | Interceptor): number;
210
- update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
211
- use(fn: Interceptor): number;
212
- }
213
- interface Middleware<Req, Res, Err, Options> {
214
- error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
215
- request: Interceptors<ReqInterceptor<Req, Options>>;
216
- response: Interceptors<ResInterceptor<Res, Req, Options>>;
217
- }
218
-
219
- type ResponseStyle = 'data' | 'fields';
220
- interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
221
- /**
222
- * Base URL for all requests made by this client.
223
- */
224
- baseUrl?: T['baseUrl'];
225
- /**
226
- * Fetch API implementation. You can use this option to provide a custom
227
- * fetch instance.
228
- *
229
- * @default globalThis.fetch
230
- */
231
- fetch?: typeof fetch;
232
- /**
233
- * Please don't use the Fetch client for Next.js applications. The `next`
234
- * options won't have any effect.
235
- *
236
- * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
237
- */
238
- next?: never;
239
- /**
240
- * Return the response data parsed in a specified format. By default, `auto`
241
- * will infer the appropriate method from the `Content-Type` response header.
242
- * You can override this behavior with any of the {@link Body} methods.
243
- * Select `stream` if you don't want to parse response data at all.
244
- *
245
- * @default 'auto'
246
- */
247
- parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
248
- /**
249
- * Should we return only data or multiple fields (data, error, response, etc.)?
250
- *
251
- * @default 'fields'
252
- */
253
- responseStyle?: ResponseStyle;
254
- /**
255
- * Throw an error instead of returning it in the response?
256
- *
257
- * @default false
258
- */
259
- throwOnError?: T['throwOnError'];
260
- }
261
- interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
262
- responseStyle: TResponseStyle;
263
- throwOnError: ThrowOnError;
264
- }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
265
- /**
266
- * Any body that you want to add to your request.
267
- *
268
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
269
- */
270
- body?: unknown;
271
- path?: Record<string, unknown>;
272
- query?: Record<string, unknown>;
273
- /**
274
- * Security mechanism(s) to use for the request.
275
- */
276
- security?: ReadonlyArray<Auth>;
277
- url: Url;
278
- }
279
- interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
280
- headers: Headers;
281
- serializedBody?: string;
282
- }
283
- 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 : {
284
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
285
- request: Request;
286
- response: Response;
287
- }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
288
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
289
- error: undefined;
290
- } | {
291
- data: undefined;
292
- error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
293
- }) & {
294
- /** request may be undefined, because error may be from building the request object itself */
295
- request?: Request;
296
- /** response may be undefined, because error may be from building the request object itself or from a network error */
297
- response?: Response;
298
- }>;
299
- interface ClientOptions$1 {
300
- baseUrl?: string;
301
- responseStyle?: ResponseStyle;
302
- throwOnError?: boolean;
303
- }
304
- 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>;
305
- type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
306
- 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>;
307
- type BuildUrlFn = <TData extends {
308
- body?: unknown;
309
- path?: Record<string, unknown>;
310
- query?: Record<string, unknown>;
311
- url: string;
312
- }>(options: TData & Options<TData>) => string;
313
- type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
314
- interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
315
- };
316
- interface TDataShape {
317
- body?: unknown;
318
- headers?: unknown;
319
- path?: unknown;
320
- query?: unknown;
321
- url: string;
322
- }
323
- type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
324
- 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'>);
325
-
326
- type ClientOptions = {
327
- 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 & {});
328
- };
329
-
330
- type EmbeddedClient = Client;
331
- type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
332
- type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
333
-
334
- type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
335
- children?: ReactNode;
336
- };
337
- type LinkComponent = ComponentType<LinkComponentProps>;
338
- /**
339
- * The UI frameworks a widget's UI layer can render with.
340
- *
341
- * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
342
- * implicit fallback, so existing consumers that select nothing keep rendering
343
- * shadcn.
344
- * - `tecton` — the Tecton implementation.
345
- *
346
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
347
- * convention.
348
- */
349
- declare const UIFramework: {
350
- readonly Shadcn: "shadcn";
351
- readonly Tecton: "tecton";
352
- };
353
- type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
354
-
355
- /**
356
- * The implementation a widget renders with.
357
- *
358
- * - `native` — the Tesouro-native implementation. This is the default and the
359
- * implicit fallback, so consumers that select nothing keep rendering native.
360
- * - `monite` — the Monite SDK implementation.
361
- *
362
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
363
- * convention.
364
- */
365
- declare const Implementation: {
366
- readonly Native: "native";
367
- readonly Monite: "monite";
368
- };
369
- type Implementation = (typeof Implementation)[keyof typeof Implementation];
370
- /**
371
- * The settable fields of the widget config cascade.
372
- *
373
- * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
374
- * It intentionally excludes `initResponse`, which is populated automatically by the
375
- * provider after a successful fetch and must never be set manually.
376
- *
377
- * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
378
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
379
- * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
380
- * (e.g. after logout or deliberate de-scoping).
381
- *
382
- * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
383
- * @see {@link RootWidgetProvider}
384
- * @see {@link WidgetProvider}
385
- * @see {@link setGlobalWidgetConfig}
386
- */
387
- interface WidgetConfigInput {
388
- /**
389
- * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
390
- *
391
- * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
392
- * Changing this recreates the underlying HTTP client so all subsequent requests
393
- * go to the new host.
394
- */
395
- baseUrl?: BaseUrl;
396
- /**
397
- * Bearer token used to authenticate widget requests.
398
- *
399
- * Injected as `Authorization: Bearer <token>` on every outgoing request via an
400
- * interceptor on the scoped HTTP client. Token updates are picked up immediately
401
- * without recreating the client.
402
- *
403
- * - `string` — send this token on all requests from this level downward.
404
- * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
405
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
406
- */
407
- widgetToken?: string | null;
408
- /**
409
- * Organization ID forwarded as the `x-organization-id` request header.
410
- *
411
- * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
412
- * so individual data-access hooks can opt in per-request.
413
- *
414
- * - `string` — use this organization for downstream data requests.
415
- * - `null` — explicitly cleared; queries that require an org ID will be disabled.
416
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
417
- *
418
- * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
419
- * value), the resolved org defaults to the loaded `initResponse.organizationId`
420
- * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
421
- * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
422
- * level wins, and an explicit `null` is preserved and never falls back.
423
- *
424
- * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
425
- * default does not propagate into a descendant that owns its own fetch (its own
426
- * `baseUrl`/`widgetToken`); such a descendant defaults to its own
427
- * `initResponse.organizationId` instead, so it never sends an ancestor's org with
428
- * its own token.
429
- */
430
- organizationId?: string | null;
431
- /**
432
- * Optional post-creation hook for the scoped HTTP client.
433
- *
434
- * Called once after the provider creates its scoped {@link EmbeddedClient} and
435
- * applies the built-in `Authorization: Bearer` interceptor. Receives the
436
- * fully-configured client and must return the client to be used for the lifetime of
437
- * this provider level — either the same instance (with additional interceptors
438
- * attached) or a new client entirely.
439
- *
440
- * **Order:** The built-in auth interceptor is always applied first. `configClient`
441
- * is called on top of it, so any interceptors you add here run after auth is set.
442
- *
443
- * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
444
- * scoped client whenever any prop is set — including `configClient` alone, without
445
- * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
446
- * client creation and never calls this function.
447
- *
448
- * **Stability:** The function reference is included in the client creation memo's
449
- * dependency array. Passing an unstable (inline) function recreates the client on
450
- * every render. Stabilize with `useCallback` or define the function outside the
451
- * component.
452
- *
453
- * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
454
- * {@link WidgetProvider} that creates its own scoped client will use the resolved
455
- * `configClient` from the cascade unless it provides its own override.
456
- *
457
- * @example
458
- * ```tsx
459
- * const addLogging = useCallback(
460
- * (client: EmbeddedClient) => {
461
- * client.interceptors.request.use((req) => {
462
- * console.log('[widget]', req.method, req.url);
463
- * return req;
464
- * });
465
- * return client;
466
- * },
467
- * [],
468
- * );
469
- *
470
- * <RootWidgetProvider
471
- * baseUrl="https://api.tesouro.com"
472
- * widgetToken={token}
473
- * configClient={addLogging}
474
- * >
475
- * <App />
476
- * </RootWidgetProvider>
477
- * ```
478
- */
479
- configClient?: (client: EmbeddedClient) => EmbeddedClient;
480
- /**
481
- * Overrides the widget-gateway routing decision for the scoped HTTP client.
482
- *
483
- * Any caller reaching the Tesouro API with a widget token must route data
484
- * requests through the widget gateway: prefix the path with
485
- * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
486
- * provider applies both automatically per request when the request origin is
487
- * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
488
- * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
489
- * init round-trip) always pass through untouched.
490
- *
491
- * - `undefined` — decide from the request origin, as above. Inherits from
492
- * the nearest ancestor or global store like every other config field.
493
- * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
494
- * custom domain in front of the gateway).
495
- * - `false` — never apply it. For hosts that route widget requests their own
496
- * way, such as a same-origin BFF whose `configClient` retargets every
497
- * request.
498
- *
499
- * Independent of {@link configClient}: a host that only adds a header keeps
500
- * the built-in routing, and the built-in interceptor runs before any
501
- * `configClient` interceptor.
502
- */
503
- gatewayRouting?: boolean;
504
- /**
505
- * Component the embedded widgets should render in place of plain `<a>` tags.
506
- *
507
- * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
508
- * Cascades like other config: provider prop > nearest ancestor > global store.
509
- * When no value is set anywhere, widgets fall back to a plain `<a>` element.
510
- */
511
- linkComponent?: LinkComponent;
512
- /**
513
- * Which UI framework the widget UI layer should render with.
514
- *
515
- * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
516
- * Tecton implementation behind the same outward-facing API. The selection is
517
- * a presentation concern only — it cascades through the provider tree exactly
518
- * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
519
- * it never appears in any widget's feature-library or component props.
520
- *
521
- * - `'shadcn'` — the shadcn/Tailwind implementation.
522
- * - `'tecton'` — the Tecton implementation.
523
- * - `null` / `undefined` — not set at this level; inherit from the nearest
524
- * ancestor or global store, falling back to `shadcn` when unset everywhere.
525
- * `shadcn` is the implicit default, so existing consumers need no changes.
526
- */
527
- uiFramework?: UIFramework | null;
528
- /**
529
- * Which implementation a widget renders with.
530
- *
531
- * Lets a consuming context bind widgets to either the Tesouro-native or the
532
- * Monite SDK implementation behind the same outward-facing API. It cascades
533
- * through the provider tree exactly like {@link linkComponent} and
534
- * {@link uiFramework} — provider prop > nearest ancestor > global store — and
535
- * is read via `useImplementation`.
536
- *
537
- * - `'native'` — the Tesouro-native implementation.
538
- * - `'monite'` — the Monite SDK implementation.
539
- * - `null` / `undefined` — not set at this level; inherit from the nearest
540
- * ancestor or global store, falling back to `native` when unset everywhere.
541
- * `native` is the implicit default, so existing consumers need no changes.
542
- */
543
- implementation?: Implementation | null;
544
- }
545
- /**
546
- * Props shared by every analytics-owner-capable widget provider.
547
- *
548
- * Combines the full settable cascade ({@link WidgetConfigInput}) with the
549
- * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
550
- * and {@link WidgetProvider} build their public props on top of this; the latter
551
- * adds error-boundary props of its own.
552
- *
553
- * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
554
- */
555
- interface WidgetProviderBaseProps extends WidgetConfigInput {
556
- /**
557
- * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
558
- *
559
- * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
560
- * standalone {@link WidgetProvider} with no parent provider. When `false`,
561
- * owner-bound `track` calls in this subtree become no-ops and the PostHog
562
- * installer is never dynamically imported for this owner's environment.
563
- * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
564
- * `console.warn` is emitted to make the no-op discoverable).
565
- */
566
- analytics?: boolean;
567
- }
568
-
569
- /**
570
- * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
571
- * the error-boundary fallback and the disclosures gate. A host overrides any
572
- * subset through the `providerLabels` prop, which cascades like
573
- * `disclosuresAcceptance`.
574
- *
575
- * Not named `Labels` on the public surface: a widget's own `labels` prop is a
576
- * different thing, and these two travel together on every widget's props type.
577
- */
578
- interface WidgetProviderLabels {
579
- /** Default copy for the built-in error boundary fallback. */
580
- errorBoundaryFallback: string;
581
- /** Heading when init reports disclosures are required and not yet accepted. */
582
- disclosuresRequiredTitle: string;
583
- /** Heading while a token-only refresh leaves init stale for the live token. */
584
- disclosuresRefreshingTitle: string;
585
- /** Supporting copy while the accept action is withheld for a stale init. */
586
- disclosuresRefreshingDescription: string;
587
- }
588
-
589
- /**
590
- * Props for {@link WidgetProvider}.
591
- *
592
- * All fields are optional. When **all** are omitted the provider is a transparent
593
- * pass-through: no fetch is issued and all resolved values cascade unchanged from
594
- * the nearest ancestor.
595
- */
596
- interface WidgetProviderProps extends WidgetProviderBaseProps {
597
- /**
598
- * Fallback rendered when a render-time exception is caught inside this
599
- * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
600
- * render-prop receiving `{ error, resetErrorBoundary }` from
601
- * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
602
- * comes from `providerLabels.errorBoundaryFallback`.
603
- */
604
- errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
605
- /**
606
- * Called once when the boundary catches an error, before the fallback
607
- * renders. Use for telemetry / error tracking / partner logging. Exceptions
608
- * thrown from `onError` propagate per `react-error-boundary` semantics.
609
- */
610
- onError?: (error: unknown, info: ErrorInfo) => void;
611
- /**
612
- * Accept surface shown when the caller owes disclosures — an INVITED
613
- * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
614
- * activate) or an ACTIVE user who owes a new version. Pass
615
- * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
616
- * WidgetProvider cannot import the widget itself (cycle).
617
- */
618
- disclosuresAcceptance?: ReactNode;
619
- /**
620
- * Overrides for the copy this provider renders in place of the widget: the
621
- * built-in error-boundary fallback and the disclosures gate. Any subset;
622
- * unlisted keys keep their defaults. Cascades like `linkComponent`.
623
- *
624
- * Named `providerLabels` rather than `labels` because a widget's own
625
- * `labels` prop sits alongside this one on the same props type.
626
- */
627
- providerLabels?: Partial<WidgetProviderLabels>;
628
- }
629
-
630
- /**
631
- * Co-located user-facing strings for this component. It takes a
632
- * `labels?: Partial<…Labels>` prop merged over the `*_LABELS_EN` default.
633
- *
634
- * Flat, deliberately: a nested group would need `PartialDeep` from type-fest
635
- * plus an explicit per-group merge (AGENTS.md), and none of this copy groups
636
- * naturally.
637
- *
638
- * The English strings are ported verbatim from the Monite `templateSettings`
639
- * screen so the native widget reads identically during side-by-side review
640
- * (EMBD-5846). Reword in a separate commit, never inside the port.
641
- */
642
- interface InvoiceSettingsPanelLabels {
643
- submitButton: string;
644
- /**
645
- * Copy for the load-failure state. No Monite counterpart: its screen had no
646
- * error branch at all, so this is new rather than ported.
647
- */
648
- errorTitle: string;
649
- errorDescription: string;
650
- errorRetry: string;
651
- /**
652
- * Accessible name for the loading spinner. The shared `Spinner` takes no
653
- * `labels` prop — its English default is an attribute on the element it
654
- * renders, overridable only through `aria-label` — so without this the panel
655
- * would announce English to a screen reader on an otherwise localized page.
656
- */
657
- loading: string;
658
- }
659
-
660
- /**
661
- * Co-located user-facing strings for this component. It takes a
662
- * `labels?: Partial<…Labels>` prop merged over the `*_LABELS_EN` default.
663
- *
664
- * Flat, deliberately: a nested group would need `PartialDeep` from type-fest
665
- * plus an explicit per-group merge (AGENTS.md), and none of this copy groups
666
- * naturally.
667
- *
668
- * The English strings are ported verbatim from the Monite `templateSettings`
669
- * screen so the native widget reads identically during side-by-side review
670
- * (EMBD-5846). Reword in a separate commit, never inside the port.
671
- */
672
- interface InvoiceNumberingSectionLabels {
673
- title: string;
674
- description: string;
675
- previewLabel: string;
676
- invoicePrefixLabel: string;
677
- startingNumberLabel: string;
678
- digitCountLabel: string;
679
- includeDateLabel: string;
680
- }
681
-
682
- /**
683
- * Co-located user-facing strings for this component. It takes a
684
- * `labels?: Partial<…Labels>` prop merged over the `*_LABELS_EN` default.
685
- *
686
- * Flat, deliberately: a nested group would need `PartialDeep` from type-fest
687
- * plus an explicit per-group merge (AGENTS.md), and none of this copy groups
688
- * naturally.
689
- *
690
- * The English strings are ported verbatim from the Monite `templateSettings`
691
- * screen so the native widget reads identically during side-by-side review
692
- * (EMBD-5846). Reword in a separate commit, never inside the port.
693
- */
694
- interface PdfSettingsSectionLabels {
695
- title: string;
696
- description: string;
697
- bankDetailsTitle: string;
698
- bankDetailsDescription: string;
699
- /** Accessible name for the bank-details switch. */
700
- bankDetailsToggle: string;
701
- paidInvoicesTitle: string;
702
- paidInvoicesDescription: string;
703
- /** Emphasised second line under the paid-invoices description. */
704
- paidInvoicesWarning: string;
705
- /** Accessible name for the paid-invoices switch. */
706
- paidInvoicesToggle: string;
707
- }
708
-
709
- /**
710
- * Co-located user-facing strings for this component. It takes a
711
- * `labels?: Partial<…Labels>` prop merged over the `*_LABELS_EN` default.
712
- *
713
- * Flat, deliberately: a nested group would need `PartialDeep` from type-fest
714
- * plus an explicit per-group merge (AGENTS.md), and none of this copy groups
715
- * naturally.
716
- *
717
- * The English strings are ported verbatim from the Monite `templateSettings`
718
- * screen so the native widget reads identically during side-by-side review
719
- * (EMBD-5846). Reword in a separate commit, never inside the port.
720
- */
721
- interface DiscardChangesDialogLabels {
722
- title: string;
723
- /** First paragraph of the body. */
724
- message: string;
725
- /** Second paragraph of the body. */
726
- question: string;
727
- confirmButton: string;
728
- cancelButton: string;
729
- }
730
-
731
- /**
732
- * Co-located user-facing strings for the logo dropzone. Ported from Monite's
733
- * `DragAndDropBox`, with the accessibility copy its markup never had.
734
- */
735
- interface LogoDropzoneLabels {
736
- dropPrefix: string;
737
- browseAction: string;
738
- /**
739
- * The accepted formats and the size cap, already formatted. The component is
740
- * presentational, so it never turns a numeric limit into copy: the owner
741
- * holds the cap and the units, and overrides this label from its own
742
- * constant.
743
- */
744
- fileTypesHint: string;
745
- /** Shown when `status` is `'error'` and the owner supplied no message. */
746
- genericError: string;
747
- /** Accessible name for the progress bar, while an upload is in flight. */
748
- uploadProgress: string;
749
- /** Announced once an upload finishes, where the bar carries no meaning. */
750
- uploadComplete: string;
751
- /** Accessible name for the button that clears a failed upload. */
752
- dismissError: string;
753
- }
754
-
755
- /**
756
- * Co-located user-facing strings for the branding section. Ported from Monite's
757
- * `LogoSection`, plus the accessible names its icon buttons carried inline.
758
- */
759
- interface LogoSectionLabels {
760
- title: string;
761
- description: string;
762
- uploadTitle: string;
763
- uploadDescription: string;
764
- /** Alt text for the current logo. */
765
- logoAlt: string;
766
- /** Shown over the current logo while a file is dragged across it. */
767
- dropToReplace: string;
768
- /** Accessible name for the icon button that replaces the logo. */
769
- editLogo: string;
770
- /** Accessible name for the icon button that removes the logo. */
771
- deleteLogo: string;
772
- }
773
-
774
- /**
775
- * Validation copy for the invoice-settings form.
776
- *
777
- * It lives in the feature layer rather than beside the controls it appears
778
- * under, because the messages are produced by the schema, not by a component:
779
- * the UI takes already-resolved strings through its `errors` prop and has no
780
- * idea a rule exists. Passing them into the schema keeps the validators pure —
781
- * they format a message, they do not look one up — and keeps every string a
782
- * consumer can see in one overridable place.
783
- *
784
- * Exposed on the widget as `messageLabels`, matching the channel the chart of
785
- * accounts and tags widgets use for the same job.
786
- */
787
- interface InvoiceSettingsMessageLabels {
788
- invoicePrefixRequired: string;
789
- invoicePrefixTooLong: string;
790
- customPrefixTooLong: string;
791
- digitCountTooLow: string;
792
- digitCountTooHigh: string;
793
- /**
794
- * The four document prefixes this screen does not render. A user cannot
795
- * reach this message through the UI; it exists so a value that arrives empty
796
- * from the API fails loudly in tests rather than silently patching a blank
797
- * prefix over a good one.
798
- */
799
- documentPrefixRequired: string;
800
- /**
801
- * `nextNumber` is the number the API will issue next for that document type,
802
- * which is the floor it will accept.
803
- */
804
- numberBelowNext: (nextNumber: number) => string;
805
- /**
806
- * Logo rejections. The first two are decided here rather than by the API, so
807
- * the user hears about a bad file before uploading it; the third stands in
808
- * for an API failure whose own message is not written for an end user.
809
- */
810
- logoWrongFormat: string;
811
- logoTooLarge: (maxSizeMb: number) => string;
812
- logoUploadFailed: string;
813
- /**
814
- * The dropzone's format-and-size hint. It lives here, beside the rejection
815
- * copy, because both are formatted from the one cap this widget enforces —
816
- * the UI lib ships its own default, and a hint that advertised a different
817
- * number from the one being enforced is exactly the drift this prevents.
818
- */
819
- logoFileTypesHint: (maxSizeMb: number) => string;
820
- /**
821
- * Toast copy, ported verbatim from the Monite hooks these replace
822
- * (`usePatchEntitySettings`, `useDeleteEntityLogo`) so the native widget
823
- * reads identically during side-by-side review. Reword in a separate commit,
824
- * never inside the port.
825
- *
826
- * `settingsSaveFailed` has no Monite counterpart — that mutation toasted only
827
- * on success, so a failed save said nothing at all. There is no inline
828
- * surface for it on this screen, unlike a rejected logo.
829
- */
830
- settingsSaved: string;
831
- settingsSaveFailed: string;
832
- logoDeleted: string;
833
- logoDeleteFailed: string;
834
- }
835
-
836
- /**
837
- * Label override channels, one per surface the widget mounts, matching the
838
- * chart-of-accounts and tags widgets. A single `labels` bag would collide the
839
- * moment two of these components named a key the same way.
840
- */
841
- interface InvoiceSettingsLabelProps {
842
- panelLabels?: Partial<InvoiceSettingsPanelLabels>;
843
- numberingLabels?: Partial<InvoiceNumberingSectionLabels>;
844
- pdfLabels?: Partial<PdfSettingsSectionLabels>;
845
- logoLabels?: Partial<LogoSectionLabels>;
846
- dropzoneLabels?: Partial<LogoDropzoneLabels>;
847
- discardLabels?: Partial<DiscardChangesDialogLabels>;
848
- /** Validation and upload-rejection copy. */
849
- messageLabels?: Partial<InvoiceSettingsMessageLabels>;
850
- }
851
- /**
852
- * What a host can ask this widget before navigating away from it.
853
- *
854
- * Widgets never touch the host's router, so the widget cannot stop a navigation
855
- * itself — it can only answer whether one is safe. The host asks, the user
856
- * answers the discard dialog, and the host proceeds or does not.
857
- *
858
- * ```tsx
859
- * const invoiceSettings = useRef<InvoiceSettingsHandle>(null);
860
- * // ...before switching away from the Invoices section:
861
- * if (await invoiceSettings.current?.confirmLeave()) setSection(next);
862
- * ```
863
- *
864
- * **Nothing calls this yet — the Settings shell wires it in EMBD-5849**, and
865
- * until it does the discard dialog cannot appear. That is not a regression from
866
- * the screen this replaces: Monite opened the same dialog from exactly one
867
- * place, its side sheet's close handler, and no caller in this repo has ever
868
- * passed the `isDialog` prop that renders the sheet. The dialog has been
869
- * unreachable in both mounts of `TemplateSettings` for as long as they have
870
- * existed.
871
- *
872
- * The bug that makes wiring it worth doing is real and predates this port: the
873
- * shell's `TabsContent` has no `forceMount`, so switching sections unmounts
874
- * this widget and throws away unsaved edits with no warning. An unmount cannot
875
- * be blocked from inside, so `onSectionChange` is the only place to intervene —
876
- * which is why this is a question the host asks rather than something the
877
- * widget enforces.
878
- */
879
- interface InvoiceSettingsHandle {
880
- /** `true` when there is nothing unsaved, or the user chose to discard. */
881
- confirmLeave: () => Promise<boolean>;
882
- }
883
- type InvoiceSettingsProps = WidgetProviderProps & InvoiceSettingsLabelProps & {
884
- ref?: Ref<InvoiceSettingsHandle>;
885
- };
886
- /**
887
- * Entity invoice settings: document numbering, PDF options and the logo.
888
- *
889
- * Native throughout as of EMBD-5848 — it was a thin wrapper over Monite's
890
- * `TemplateSettings` from EMBD-5846 until the presentational layer (EMBD-5845,
891
- * EMBD-5847) and the REST hooks (EMBD-5844) were both in place. The Settings
892
- * widget's Invoices tab still mounts the Monite screen until EMBD-5849 cuts it
893
- * over; that screen goes in EMBD-5850.
894
- *
895
- * `WidgetProvider` rather than `MoniteRegionProvider`: nothing here renders
896
- * Monite any more, so the Monite wrapper and its `finopsThemeColors` prop have
897
- * both gone from this widget's public surface.
898
- */
899
- declare function InvoiceSettings({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, analytics, disclosuresAcceptance, providerLabels, errorFallback, onError, ref, ...labelProps }: InvoiceSettingsProps): React.JSX.Element;
900
-
901
- export { InvoiceSettings };
902
- export type { InvoiceSettingsHandle, InvoiceSettingsProps };