@schematichq/schematic-components 2.25.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,331 @@
1
+ import { BillingData } from '@schematichq/schematic-react';
2
+ import { BillingDataProvider } from '@schematichq/schematic-react';
3
+ import { BillingDataProviderProps } from '@schematichq/schematic-react';
4
+ import { BillingDataStatus } from '@schematichq/schematic-react';
5
+ import { Invoice } from '@schematichq/schematic-react';
6
+ import { InvoicePage } from '@schematichq/schematic-react';
7
+ import { InvoiceQuery } from '@schematichq/schematic-react';
8
+ import type { InvoiceStatus } from '@schematichq/schematic-react';
9
+ import { JSX } from 'react';
10
+ import { default as React_2 } from 'react';
11
+ import { ResourceHandle } from '@schematichq/schematic-react';
12
+ import { ResourceState } from '@schematichq/schematic-react';
13
+ import { SchematicI18nConfig } from '@schematichq/schematic-react';
14
+ import { SchematicI18nProvider } from '@schematichq/schematic-react';
15
+ import { SchematicI18nProviderProps } from '@schematichq/schematic-react';
16
+ import type { Translate } from '@schematichq/schematic-react';
17
+ import { useInvalidateBillingData } from '@schematichq/schematic-react';
18
+ import { useInvoices } from '@schematichq/schematic-react';
19
+ import { useSchematicI18n } from '@schematichq/schematic-react';
20
+ import { useSchematicLocale } from '@schematichq/schematic-react';
21
+ import { useSchematicStrings } from '@schematichq/schematic-react';
22
+ import { useSchematicTranslate } from '@schematichq/schematic-react';
23
+
24
+ export { BillingData }
25
+
26
+ export { BillingDataProvider }
27
+
28
+ export { BillingDataProviderProps }
29
+
30
+ export { BillingDataStatus }
31
+
32
+ /**
33
+ * The English copy, and the fallback for anything a host does not answer.
34
+ * It is a plain resource bundle, so it can be registered as one:
35
+ *
36
+ * ```ts
37
+ * i18n.addResourceBundle("en", "schematic", DEFAULT_STRINGS);
38
+ * ```
39
+ *
40
+ * Registering it is optional: the elements render the English themselves on
41
+ * a miss.
42
+ *
43
+ * Also typed as a catalogue so plural variants can sit beside the bare key
44
+ * they inflect.
45
+ */
46
+ export declare const DEFAULT_STRINGS: ElementStrings & StringCatalog;
47
+
48
+ export declare function deriveInvoiceList(page: InvoicePage, options: DeriveInvoiceListOptions): InvoiceList;
49
+
50
+ export declare interface DeriveInvoiceListOptions {
51
+ locale: string;
52
+ format?: InvoiceFormatters;
53
+ }
54
+
55
+ /** Props every element accepts on its root. */
56
+ export declare interface ElementProps {
57
+ className?: string;
58
+ /** BCP 47 tag for number, currency, and date formatting. Overrides the
59
+ * provider's `locale`; without either, the viewer's language, else `en-US`. */
60
+ locale?: string;
61
+ /** Overrides the provider's `strings` and its `translate`. */
62
+ strings?: StringOverrides;
63
+ }
64
+
65
+ /**
66
+ * Only the copy the elements render. A host building its own markup owns its
67
+ * own labels and headers; those are not keys here.
68
+ *
69
+ * Plural forms follow i18next's `key_one` / `key_other` convention, looked
70
+ * up by the bare `key` with `{ count }`.
71
+ */
72
+ export declare type ElementStrings = {
73
+ retry: string;
74
+ invoicesLoading: string;
75
+ invoicesHeader: string;
76
+ invoicesError: string;
77
+ invoicesUnavailable: string;
78
+ invoicesEmpty: string;
79
+ invoicesSeeMore: string;
80
+ invoicesSeeLess: string;
81
+ invoicesLoadMore: string;
82
+ invoicesChargeTooltip: string;
83
+ invoicesCreditTooltip: string;
84
+ invoicesUndated: string;
85
+ };
86
+
87
+ /**
88
+ * The singular or plural name of a feature or credit for a count.
89
+ *
90
+ * Configured forms win. Without a `pluralName`, English locales inflect the
91
+ * name with English suffix rules; other languages keep it as given rather
92
+ * than getting "Sitzplatzs". The category comes from `Intl.PluralRules`, so
93
+ * 0 is plural in English and "one" where a language says so.
94
+ */
95
+ export declare function featureName(named: {
96
+ name: string;
97
+ singularName?: string | null;
98
+ pluralName?: string | null;
99
+ }, count?: number, locale?: string): string;
100
+
101
+ /** Credits per use, readable down to 1e-10 rather than "0" or "1e-10". */
102
+ export declare function formatConsumptionRate(rate: number, locale: string): string;
103
+
104
+ /**
105
+ * Formats a minor-unit amount in its currency for the locale. Negative
106
+ * amounts format with the locale's sign; callers wanting accounting
107
+ * parentheses wrap the absolute value themselves.
108
+ */
109
+ export declare function formatCurrency(amountMinor: number, currency: string, locale: string, options?: FormatCurrencyOptions): string;
110
+
111
+ export declare interface FormatCurrencyOptions {
112
+ /**
113
+ * When the amount has sub-minor-unit precision (e.g. a $0.0015 per-unit
114
+ * price), render enough significant digits to show it instead of rounding
115
+ * to the currency's usual precision. Default true.
116
+ */
117
+ preserveSubUnitPrecision?: boolean;
118
+ }
119
+
120
+ /** "August 21, 2026", in the viewer's time zone. Empty for an Invalid Date. */
121
+ export declare function formatDate(date: Date, locale: string, options?: Intl.DateTimeFormatOptions): string;
122
+
123
+ export declare function formatNumber(value: number, locale: string, options?: Intl.NumberFormatOptions): string;
124
+
125
+ /** "8/21". Empty for an Invalid Date. */
126
+ export declare function formatShortDate(date: Date, locale: string): string;
127
+
128
+ /** Heading level an element's own heading renders at. Default 2. */
129
+ export declare type HeadingLevel = 2 | 3 | 4 | 5 | 6;
130
+
131
+ /**
132
+ * The HTTP status behind a failed billing read, or `undefined` for anything
133
+ * that was not an HTTP response (network error, missing provider, malformed
134
+ * response).
135
+ *
136
+ * Checked by shape rather than `instanceof`: a page with two copies of
137
+ * schematic-js has two `SchematicApiError` classes, and the shape matches both.
138
+ */
139
+ export declare function httpStatus(error: Error | undefined): number | undefined;
140
+
141
+ /**
142
+ * Fills `{{name}}` placeholders, i18next style. A placeholder with no value
143
+ * is left as written so the omission is visible.
144
+ */
145
+ export declare function interpolate(template: string, vars?: StringVars): string;
146
+
147
+ export { Invoice }
148
+
149
+ /** `amount` receives the signed value, unlike the default text. */
150
+ export declare interface InvoiceFormatters {
151
+ date?: (date: Date, locale: string) => string;
152
+ amount?: (amountMinor: number, currency: string, locale: string) => string;
153
+ }
154
+
155
+ export declare interface InvoiceList {
156
+ rows: InvoiceRow[];
157
+ /** Total on the server; `rows.length` is only what has been loaded. */
158
+ count: number;
159
+ hasMore: boolean;
160
+ }
161
+
162
+ export { InvoicePage }
163
+
164
+ export { InvoiceQuery }
165
+
166
+ /**
167
+ * The `Text` fields are what the element renders. The raw fields beside them
168
+ * let a host format differently without re-deriving.
169
+ */
170
+ export declare interface InvoiceRow {
171
+ id: string;
172
+ /** Never an Invalid Date, which throws when formatted. */
173
+ date: Date | null;
174
+ dateText: string;
175
+ /** Signed, in the currency's minor units: negative is a credit note. */
176
+ amountMinor: number;
177
+ /** ISO 4217 code, upper-cased. */
178
+ currency: string;
179
+ /** Absolute by default; `isCredit` carries the sign. */
180
+ amountText: string;
181
+ /** Negative invoices are credit notes; render `amountText` in parentheses. */
182
+ isCredit: boolean;
183
+ status: InvoiceStatus | null;
184
+ url: string | null;
185
+ }
186
+
187
+ /**
188
+ * The company's invoice history. Each row links its date to the hosted
189
+ * invoice and shows the amount beside it; rows past `limit` sit behind
190
+ * "See more".
191
+ */
192
+ export declare function Invoices({ className, collapsible, headingLevel, limit, locale: localeProp, query, showAmount, showDate, showHeader, strings, }: InvoicesProps): JSX.Element;
193
+
194
+ export declare interface InvoicesProps extends ElementProps {
195
+ /** Rows shown before "See more". Default 10. */
196
+ limit?: number;
197
+ /** The "Invoices" heading. Default true. */
198
+ showHeader?: boolean;
199
+ /** Heading level, so the card fits the host's outline. Default 2. */
200
+ headingLevel?: HeadingLevel;
201
+ /** The date on each row. Default true. */
202
+ showDate?: boolean;
203
+ /** The amount on each row. Default true. */
204
+ showAmount?: boolean;
205
+ /** Collapse to `limit` rows behind "See more". Default true. */
206
+ collapsible?: boolean;
207
+ /**
208
+ * Server-side filter, e.g. `{ includePending: true }` for invoices not yet
209
+ * due. The hook keys by value, so an inline object is fine.
210
+ */
211
+ query?: InvoiceQuery;
212
+ }
213
+
214
+ /**
215
+ * `locale` is the language the catalogue is written in, since that decides
216
+ * its plural forms: English for the defaults, the resolved locale for a
217
+ * host's overrides. Returns `undefined` on a miss so callers can fall
218
+ * through to the next source.
219
+ */
220
+ export declare function lookup(catalog: StringCatalog | undefined, key: string, vars?: StringVars, locale?: string): string | undefined;
221
+
222
+ /**
223
+ * `other` is required because every language has it. Supply whichever other
224
+ * categories the language uses: Polish needs `one`, `few`, and `many`;
225
+ * Japanese needs none.
226
+ */
227
+ export declare function plural(locale: string, count: number, forms: Partial<Record<Intl.LDMLPluralRule, string>> & {
228
+ other: string;
229
+ }): string;
230
+
231
+ /** The i18next plural suffixes a key can carry. */
232
+ declare type PluralSuffix = "zero" | "one" | "two" | "few" | "many" | "other";
233
+
234
+ /**
235
+ * The given tag, or the default when it is absent or `Intl` rejects it.
236
+ * Deliberately ignores `navigator`; `viewerLocale` does that reading.
237
+ */
238
+ export declare function resolveLocale(locale?: string): string;
239
+
240
+ export { ResourceHandle }
241
+
242
+ export { ResourceState }
243
+
244
+ /**
245
+ * Every token the stylesheet can reference, with the value used when the
246
+ * host sets none. Adding a token here is what makes it usable in the CSS;
247
+ * `withTokenDefaults` throws on any other.
248
+ */
249
+ export declare const SCHEMATIC_TOKENS: Record<string, string>;
250
+
251
+ export { SchematicI18nConfig }
252
+
253
+ export { SchematicI18nProvider }
254
+
255
+ export { SchematicI18nProviderProps }
256
+
257
+ /**
258
+ * Injects the default stylesheet. Render once, anywhere in the tree; omit
259
+ * it to style the class names yourself.
260
+ */
261
+ export declare const SchematicStyles: React_2.FC;
262
+
263
+ /**
264
+ * The stylesheet `<SchematicStyles />` injects: the rules above with every
265
+ * token's default inlined as a `var()` fallback.
266
+ */
267
+ export declare const schematicStylesCss: string;
268
+
269
+ /**
270
+ * Opt-in and separate from `<SchematicStyles />`: as a rule it has the
271
+ * cascade problem the fallbacks avoid.
272
+ */
273
+ export declare const schematicTokensCss: string;
274
+
275
+ /** A flat catalogue, the shape of both a host's `strings` and the defaults. */
276
+ export declare type StringCatalog = Record<string, string | undefined>;
277
+
278
+ export declare type StringKey = keyof ElementStrings;
279
+
280
+ /**
281
+ * Copy overrides, on the provider or on an element. Plural spellings are
282
+ * accepted so an override can vary by count rather than answering `1` and
283
+ * `14` with the same words.
284
+ */
285
+ export declare type StringOverrides = Partial<ElementStrings> & Partial<Record<`${StringKey}_${PluralSuffix}`, string>>;
286
+
287
+ /** Interpolation values, and `count` for the plural form. */
288
+ export declare type StringVars = Record<string, unknown>;
289
+
290
+ export { Translate }
291
+
292
+ export declare type Translator = (key: StringKey, vars?: StringVars) => string;
293
+
294
+ export { useInvalidateBillingData }
295
+
296
+ export { useInvoices }
297
+
298
+ /**
299
+ * The element's `locale` prop, else the provider's, else the viewer's.
300
+ *
301
+ * The viewer's language is left out of a server render and its hydration,
302
+ * or every formatted date and amount would mismatch. Set `locale` on the
303
+ * provider for a server-rendered page to match on first paint.
304
+ */
305
+ export declare function useResolvedLocale(locale?: string): string;
306
+
307
+ export { useSchematicI18n }
308
+
309
+ export { useSchematicLocale }
310
+
311
+ export { useSchematicStrings }
312
+
313
+ export { useSchematicTranslate }
314
+
315
+ /**
316
+ * Resolves copy in order: the element's `strings`, the provider's `strings`,
317
+ * the provider's `translate`, then the English default.
318
+ *
319
+ * `translate` is called with a sentinel `defaultValue` so a miss is
320
+ * detectable even from an i18next stack that answers every key: `undefined`,
321
+ * the sentinel, or the bare key echoed back all count as misses.
322
+ *
323
+ * `onMissingString` fires during render, so keep it to logging.
324
+ */
325
+ export declare function useTranslator(overrides?: StringOverrides, locale?: string): Translator;
326
+
327
+ /** Not for a server render or its hydration; `useResolvedLocale` reads it
328
+ * through `useSyncExternalStore`, which keeps it out of both. */
329
+ export declare function viewerLocale(): string | undefined;
330
+
331
+ export { }