@kerne/react 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/chunk-3R66S7BY.cjs +3312 -0
- package/dist/chunk-ZVL47U4B.js +3312 -0
- package/dist/{i18n-QilNgwqe.d.cts → fr-E5mmylSH.d.cts} +135 -3
- package/dist/{i18n-QilNgwqe.d.ts → fr-E5mmylSH.d.ts} +135 -3
- package/dist/index.cjs +51 -27
- package/dist/index.d.cts +61 -41
- package/dist/index.d.ts +61 -41
- package/dist/index.js +44 -20
- package/dist/ui/index.cjs +984 -1906
- package/dist/ui/index.d.cts +42 -96
- package/dist/ui/index.d.ts +42 -96
- package/dist/ui/index.js +1091 -2013
- package/package.json +11 -5
- package/dist/chunk-IZMRK3WK.js +0 -1285
- package/dist/chunk-TYNZ2WU7.cjs +0 -1285
|
@@ -201,7 +201,9 @@ interface KerneLocalization {
|
|
|
201
201
|
switchConfirmButton: string;
|
|
202
202
|
switchConfirmDismiss: string;
|
|
203
203
|
noPlans: string;
|
|
204
|
+
/** A plan with no price under the selected PriceLabel - which needn't be a billing interval (see PublicPriceLabel). */
|
|
204
205
|
notOnInterval: string;
|
|
206
|
+
differentCurrency: string;
|
|
205
207
|
loadFailed: string;
|
|
206
208
|
loadingPlan: string;
|
|
207
209
|
loadingPlans: string;
|
|
@@ -242,8 +244,61 @@ interface KerneLocalization {
|
|
|
242
244
|
billedAt: string;
|
|
243
245
|
/** "Save {percent}%" - the label-switch hint. */
|
|
244
246
|
save: string;
|
|
245
|
-
/**
|
|
247
|
+
/** The value column for a QUOTA with no ceiling. */
|
|
246
248
|
unlimited: string;
|
|
249
|
+
/** The value column for an entitlement that carries no figure - a boolean, or a quota with no declared ceiling. */
|
|
250
|
+
included: string;
|
|
251
|
+
/** The value column for a boolean the plan does NOT grant. */
|
|
252
|
+
notIncluded: string;
|
|
253
|
+
/** Replaces the amount when a plan costs nothing. */
|
|
254
|
+
free: string;
|
|
255
|
+
/** Replaces "/ month" beside `free`. */
|
|
256
|
+
forever: string;
|
|
257
|
+
/** The call to action on a plan that costs nothing. */
|
|
258
|
+
startFree: string;
|
|
259
|
+
/** "{days}-day trial, no card" - under the button that accepts the offer. */
|
|
260
|
+
trialNote: string;
|
|
261
|
+
/** Beside an allowance that keeps serving past its included amount, and bills. */
|
|
262
|
+
thenMetered: string;
|
|
263
|
+
/** Heading of the popover that explains a metered overage. */
|
|
264
|
+
meterTitle: string;
|
|
265
|
+
/** "Rate per {thing}" - the thing being counted, a customer or a slice. */
|
|
266
|
+
meterRatePer: string;
|
|
267
|
+
meterShape: string;
|
|
268
|
+
meterCounted: string;
|
|
269
|
+
meterResets: string;
|
|
270
|
+
meterCapped: string;
|
|
271
|
+
/** "{count} tiers, cheapest {amount}" / "one rate" - how the schedule is read. */
|
|
272
|
+
meterTiers: string;
|
|
273
|
+
meterFlat: string;
|
|
274
|
+
/** Whole quantity at the reached rate, vs each slice at its own. */
|
|
275
|
+
meterVolume: string;
|
|
276
|
+
meterGraduated: string;
|
|
277
|
+
/** "per {slice}" / "per customer", then how a partial block is counted. */
|
|
278
|
+
meterPerSlice: string;
|
|
279
|
+
meterPerCustomer: string;
|
|
280
|
+
/** "every {interval}" - the cadence the allowance actually comes back on. */
|
|
281
|
+
meterResetsEvery: string;
|
|
282
|
+
/** "{amount} per {slice}" on an allowance counted once per slice. */
|
|
283
|
+
perSlice: string;
|
|
284
|
+
meterRoundedUp: string;
|
|
285
|
+
meterRoundedDown: string;
|
|
286
|
+
meterResetsCycle: string;
|
|
287
|
+
meterResetsNever: string;
|
|
288
|
+
/** Stands in for the allowance when nothing is included and every unit bills. */
|
|
289
|
+
metered: string;
|
|
290
|
+
/** Prefixes a rate that falls as volume grows, e.g. "from $0.10 / GB". */
|
|
291
|
+
from: string;
|
|
292
|
+
/** Header of the block where a buyer sizes prepaid volume. */
|
|
293
|
+
sizeUpFront: string;
|
|
294
|
+
/** Caption beside it - prepaid steps bill on the plan's own cycle. */
|
|
295
|
+
billedWithPlan: string;
|
|
296
|
+
/** "{amount} {unit} included" under a sizing rail left at zero. */
|
|
297
|
+
includedAmount: string;
|
|
298
|
+
/** "+{amount} {unit} prepaid" once the rail moves. */
|
|
299
|
+
prepaidAmount: string;
|
|
300
|
+
/** Shown under a plan's hairline when it grants nothing the catalogue can list. */
|
|
301
|
+
nothingListed: string;
|
|
247
302
|
/** "+{count} more" - shown when `maxFeatures` truncates a plan's entitlement list. */
|
|
248
303
|
moreFeatures: string;
|
|
249
304
|
loading: string;
|
|
@@ -273,7 +328,7 @@ interface KerneLocalization {
|
|
|
273
328
|
signOut: string;
|
|
274
329
|
};
|
|
275
330
|
/**
|
|
276
|
-
* Keyed by the API's stable ErrorCode
|
|
331
|
+
* Keyed by the API's stable ErrorCode.
|
|
277
332
|
* Anything absent falls back to `generic` - never to the raw server message,
|
|
278
333
|
* which is written for an integrator and is always English.
|
|
279
334
|
*/
|
|
@@ -282,9 +337,86 @@ interface KerneLocalization {
|
|
|
282
337
|
};
|
|
283
338
|
}
|
|
284
339
|
declare const defaultLocalization: KerneLocalization;
|
|
340
|
+
/**
|
|
341
|
+
* Shallow-merges each top-level group of `override` onto `base` (the English pack by
|
|
342
|
+
* default) so a partial override keeps the rest. Pass a full pack (e.g. `fr`) as `base`
|
|
343
|
+
* to layer a few overrides on top of a whole-language translation instead of English.
|
|
344
|
+
*/
|
|
345
|
+
declare function mergeLocalization(override?: DeepPartial<KerneLocalization>, base?: KerneLocalization): KerneLocalization;
|
|
285
346
|
type DeepPartial<T> = {
|
|
286
347
|
[K in keyof T]?: Partial<T[K]>;
|
|
287
348
|
};
|
|
288
349
|
declare function useLocalization(): KerneLocalization;
|
|
289
350
|
|
|
290
|
-
|
|
351
|
+
/**
|
|
352
|
+
* Styling for the prebuilt components.
|
|
353
|
+
*
|
|
354
|
+
* A single stylesheet injected once at runtime, rather than a CSS file the
|
|
355
|
+
* host app has to import: the whole point of these components is that a tenant
|
|
356
|
+
* drops one in and it works, and "don't forget to import @kerne/react/styles.css"
|
|
357
|
+
* is exactly the step people forget. It also keeps the package dependency-free -
|
|
358
|
+
* no CSS-in-JS runtime, no Tailwind assumption about the host build.
|
|
359
|
+
*
|
|
360
|
+
* Everything visual resolves from `--kerne-*` custom properties, so a tenant
|
|
361
|
+
* restyles by setting those anywhere in their own CSS (no `!important` war, no
|
|
362
|
+
* forking) and `appearance` overrides them per instance.
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* The default palette's raw values, for a host that wants its OWN stylesheet to match Kerne's
|
|
366
|
+
* rather than reading them off the rendered page - `.dark` is only the tokens dark actually
|
|
367
|
+
* overrides, not the full set (unset ones inherit `.light`, same as the CSS does).
|
|
368
|
+
*/
|
|
369
|
+
declare const defaultTokens: {
|
|
370
|
+
light: Record<string, string>;
|
|
371
|
+
dark: Record<string, string>;
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Per-instance overrides of the same custom properties the stylesheet reads,
|
|
375
|
+
* applied as inline style so they win over the class defaults without
|
|
376
|
+
* specificity tricks.
|
|
377
|
+
*/
|
|
378
|
+
interface KerneAppearance {
|
|
379
|
+
/**
|
|
380
|
+
* `light` (default), `dark`, or `system` to follow the visitor's OS. Not
|
|
381
|
+
* defaulted to `system`: a light-only host would silently render a dark form
|
|
382
|
+
* for half its users.
|
|
383
|
+
*/
|
|
384
|
+
theme?: 'light' | 'dark' | 'system';
|
|
385
|
+
/**
|
|
386
|
+
* The brand colour. Drives the primary button, and - unless overridden below -
|
|
387
|
+
* its label, its hover, and the accent used for focus rings and links.
|
|
388
|
+
*/
|
|
389
|
+
primaryColor?: string;
|
|
390
|
+
/** Label on the primary button. Derived from `primaryColor` when omitted. */
|
|
391
|
+
primaryTextColor?: string;
|
|
392
|
+
/** Focus rings and links. Falls back to `primaryColor`. */
|
|
393
|
+
accentColor?: string;
|
|
394
|
+
textColor?: string;
|
|
395
|
+
borderColor?: string;
|
|
396
|
+
/** Background of error/info panels. */
|
|
397
|
+
panelColor?: string;
|
|
398
|
+
/**
|
|
399
|
+
* The ground the component sits on. Leave unset when embedding (the host's
|
|
400
|
+
* page shows through); set it when the component owns the viewport, so its
|
|
401
|
+
* text can never resolve against a background it doesn't know about.
|
|
402
|
+
*/
|
|
403
|
+
background?: string;
|
|
404
|
+
/** Opaque ground for the card variant, the account dropdown, a pressed segment. */
|
|
405
|
+
surfaceColor?: string;
|
|
406
|
+
/** `card` wraps the screen in a bordered, raised container. Defaults to `none`. */
|
|
407
|
+
surface?: 'none' | 'card';
|
|
408
|
+
fontFamily?: string;
|
|
409
|
+
/** Corner radius on inputs and buttons, e.g. `"0px"` for square. */
|
|
410
|
+
radius?: string;
|
|
411
|
+
/** Height of inputs and buttons. Defaults to `"44px"`. */
|
|
412
|
+
controlHeight?: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* French pack for the prebuilt components - see `KerneLocalization` for the full shape and
|
|
417
|
+
* `defaultLocalization` (English) for the reference this was translated from.
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
declare const fr: KerneLocalization;
|
|
421
|
+
|
|
422
|
+
export { type DeepPartial as D, type KerneLocalization as K, type KerneAppearance as a, defaultTokens as b, defaultLocalization as d, fr as f, mergeLocalization as m, useLocalization as u };
|
|
@@ -201,7 +201,9 @@ interface KerneLocalization {
|
|
|
201
201
|
switchConfirmButton: string;
|
|
202
202
|
switchConfirmDismiss: string;
|
|
203
203
|
noPlans: string;
|
|
204
|
+
/** A plan with no price under the selected PriceLabel - which needn't be a billing interval (see PublicPriceLabel). */
|
|
204
205
|
notOnInterval: string;
|
|
206
|
+
differentCurrency: string;
|
|
205
207
|
loadFailed: string;
|
|
206
208
|
loadingPlan: string;
|
|
207
209
|
loadingPlans: string;
|
|
@@ -242,8 +244,61 @@ interface KerneLocalization {
|
|
|
242
244
|
billedAt: string;
|
|
243
245
|
/** "Save {percent}%" - the label-switch hint. */
|
|
244
246
|
save: string;
|
|
245
|
-
/**
|
|
247
|
+
/** The value column for a QUOTA with no ceiling. */
|
|
246
248
|
unlimited: string;
|
|
249
|
+
/** The value column for an entitlement that carries no figure - a boolean, or a quota with no declared ceiling. */
|
|
250
|
+
included: string;
|
|
251
|
+
/** The value column for a boolean the plan does NOT grant. */
|
|
252
|
+
notIncluded: string;
|
|
253
|
+
/** Replaces the amount when a plan costs nothing. */
|
|
254
|
+
free: string;
|
|
255
|
+
/** Replaces "/ month" beside `free`. */
|
|
256
|
+
forever: string;
|
|
257
|
+
/** The call to action on a plan that costs nothing. */
|
|
258
|
+
startFree: string;
|
|
259
|
+
/** "{days}-day trial, no card" - under the button that accepts the offer. */
|
|
260
|
+
trialNote: string;
|
|
261
|
+
/** Beside an allowance that keeps serving past its included amount, and bills. */
|
|
262
|
+
thenMetered: string;
|
|
263
|
+
/** Heading of the popover that explains a metered overage. */
|
|
264
|
+
meterTitle: string;
|
|
265
|
+
/** "Rate per {thing}" - the thing being counted, a customer or a slice. */
|
|
266
|
+
meterRatePer: string;
|
|
267
|
+
meterShape: string;
|
|
268
|
+
meterCounted: string;
|
|
269
|
+
meterResets: string;
|
|
270
|
+
meterCapped: string;
|
|
271
|
+
/** "{count} tiers, cheapest {amount}" / "one rate" - how the schedule is read. */
|
|
272
|
+
meterTiers: string;
|
|
273
|
+
meterFlat: string;
|
|
274
|
+
/** Whole quantity at the reached rate, vs each slice at its own. */
|
|
275
|
+
meterVolume: string;
|
|
276
|
+
meterGraduated: string;
|
|
277
|
+
/** "per {slice}" / "per customer", then how a partial block is counted. */
|
|
278
|
+
meterPerSlice: string;
|
|
279
|
+
meterPerCustomer: string;
|
|
280
|
+
/** "every {interval}" - the cadence the allowance actually comes back on. */
|
|
281
|
+
meterResetsEvery: string;
|
|
282
|
+
/** "{amount} per {slice}" on an allowance counted once per slice. */
|
|
283
|
+
perSlice: string;
|
|
284
|
+
meterRoundedUp: string;
|
|
285
|
+
meterRoundedDown: string;
|
|
286
|
+
meterResetsCycle: string;
|
|
287
|
+
meterResetsNever: string;
|
|
288
|
+
/** Stands in for the allowance when nothing is included and every unit bills. */
|
|
289
|
+
metered: string;
|
|
290
|
+
/** Prefixes a rate that falls as volume grows, e.g. "from $0.10 / GB". */
|
|
291
|
+
from: string;
|
|
292
|
+
/** Header of the block where a buyer sizes prepaid volume. */
|
|
293
|
+
sizeUpFront: string;
|
|
294
|
+
/** Caption beside it - prepaid steps bill on the plan's own cycle. */
|
|
295
|
+
billedWithPlan: string;
|
|
296
|
+
/** "{amount} {unit} included" under a sizing rail left at zero. */
|
|
297
|
+
includedAmount: string;
|
|
298
|
+
/** "+{amount} {unit} prepaid" once the rail moves. */
|
|
299
|
+
prepaidAmount: string;
|
|
300
|
+
/** Shown under a plan's hairline when it grants nothing the catalogue can list. */
|
|
301
|
+
nothingListed: string;
|
|
247
302
|
/** "+{count} more" - shown when `maxFeatures` truncates a plan's entitlement list. */
|
|
248
303
|
moreFeatures: string;
|
|
249
304
|
loading: string;
|
|
@@ -273,7 +328,7 @@ interface KerneLocalization {
|
|
|
273
328
|
signOut: string;
|
|
274
329
|
};
|
|
275
330
|
/**
|
|
276
|
-
* Keyed by the API's stable ErrorCode
|
|
331
|
+
* Keyed by the API's stable ErrorCode.
|
|
277
332
|
* Anything absent falls back to `generic` - never to the raw server message,
|
|
278
333
|
* which is written for an integrator and is always English.
|
|
279
334
|
*/
|
|
@@ -282,9 +337,86 @@ interface KerneLocalization {
|
|
|
282
337
|
};
|
|
283
338
|
}
|
|
284
339
|
declare const defaultLocalization: KerneLocalization;
|
|
340
|
+
/**
|
|
341
|
+
* Shallow-merges each top-level group of `override` onto `base` (the English pack by
|
|
342
|
+
* default) so a partial override keeps the rest. Pass a full pack (e.g. `fr`) as `base`
|
|
343
|
+
* to layer a few overrides on top of a whole-language translation instead of English.
|
|
344
|
+
*/
|
|
345
|
+
declare function mergeLocalization(override?: DeepPartial<KerneLocalization>, base?: KerneLocalization): KerneLocalization;
|
|
285
346
|
type DeepPartial<T> = {
|
|
286
347
|
[K in keyof T]?: Partial<T[K]>;
|
|
287
348
|
};
|
|
288
349
|
declare function useLocalization(): KerneLocalization;
|
|
289
350
|
|
|
290
|
-
|
|
351
|
+
/**
|
|
352
|
+
* Styling for the prebuilt components.
|
|
353
|
+
*
|
|
354
|
+
* A single stylesheet injected once at runtime, rather than a CSS file the
|
|
355
|
+
* host app has to import: the whole point of these components is that a tenant
|
|
356
|
+
* drops one in and it works, and "don't forget to import @kerne/react/styles.css"
|
|
357
|
+
* is exactly the step people forget. It also keeps the package dependency-free -
|
|
358
|
+
* no CSS-in-JS runtime, no Tailwind assumption about the host build.
|
|
359
|
+
*
|
|
360
|
+
* Everything visual resolves from `--kerne-*` custom properties, so a tenant
|
|
361
|
+
* restyles by setting those anywhere in their own CSS (no `!important` war, no
|
|
362
|
+
* forking) and `appearance` overrides them per instance.
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* The default palette's raw values, for a host that wants its OWN stylesheet to match Kerne's
|
|
366
|
+
* rather than reading them off the rendered page - `.dark` is only the tokens dark actually
|
|
367
|
+
* overrides, not the full set (unset ones inherit `.light`, same as the CSS does).
|
|
368
|
+
*/
|
|
369
|
+
declare const defaultTokens: {
|
|
370
|
+
light: Record<string, string>;
|
|
371
|
+
dark: Record<string, string>;
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Per-instance overrides of the same custom properties the stylesheet reads,
|
|
375
|
+
* applied as inline style so they win over the class defaults without
|
|
376
|
+
* specificity tricks.
|
|
377
|
+
*/
|
|
378
|
+
interface KerneAppearance {
|
|
379
|
+
/**
|
|
380
|
+
* `light` (default), `dark`, or `system` to follow the visitor's OS. Not
|
|
381
|
+
* defaulted to `system`: a light-only host would silently render a dark form
|
|
382
|
+
* for half its users.
|
|
383
|
+
*/
|
|
384
|
+
theme?: 'light' | 'dark' | 'system';
|
|
385
|
+
/**
|
|
386
|
+
* The brand colour. Drives the primary button, and - unless overridden below -
|
|
387
|
+
* its label, its hover, and the accent used for focus rings and links.
|
|
388
|
+
*/
|
|
389
|
+
primaryColor?: string;
|
|
390
|
+
/** Label on the primary button. Derived from `primaryColor` when omitted. */
|
|
391
|
+
primaryTextColor?: string;
|
|
392
|
+
/** Focus rings and links. Falls back to `primaryColor`. */
|
|
393
|
+
accentColor?: string;
|
|
394
|
+
textColor?: string;
|
|
395
|
+
borderColor?: string;
|
|
396
|
+
/** Background of error/info panels. */
|
|
397
|
+
panelColor?: string;
|
|
398
|
+
/**
|
|
399
|
+
* The ground the component sits on. Leave unset when embedding (the host's
|
|
400
|
+
* page shows through); set it when the component owns the viewport, so its
|
|
401
|
+
* text can never resolve against a background it doesn't know about.
|
|
402
|
+
*/
|
|
403
|
+
background?: string;
|
|
404
|
+
/** Opaque ground for the card variant, the account dropdown, a pressed segment. */
|
|
405
|
+
surfaceColor?: string;
|
|
406
|
+
/** `card` wraps the screen in a bordered, raised container. Defaults to `none`. */
|
|
407
|
+
surface?: 'none' | 'card';
|
|
408
|
+
fontFamily?: string;
|
|
409
|
+
/** Corner radius on inputs and buttons, e.g. `"0px"` for square. */
|
|
410
|
+
radius?: string;
|
|
411
|
+
/** Height of inputs and buttons. Defaults to `"44px"`. */
|
|
412
|
+
controlHeight?: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* French pack for the prebuilt components - see `KerneLocalization` for the full shape and
|
|
417
|
+
* `defaultLocalization` (English) for the reference this was translated from.
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
declare const fr: KerneLocalization;
|
|
421
|
+
|
|
422
|
+
export { type DeepPartial as D, type KerneLocalization as K, type KerneAppearance as a, defaultTokens as b, defaultLocalization as d, fr as f, mergeLocalization as m, useLocalization as u };
|
package/dist/index.cjs
CHANGED
|
@@ -20,25 +20,28 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
var _chunk3R66S7BYcjs = require('./chunk-3R66S7BY.cjs');
|
|
24
27
|
|
|
25
28
|
// src/components.tsx
|
|
26
29
|
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
27
30
|
var _jsxruntime = require('react/jsx-runtime');
|
|
28
31
|
function Authenticated({ children, fallback = null }) {
|
|
29
|
-
const { isAuthenticated } =
|
|
32
|
+
const { isAuthenticated } = _chunk3R66S7BYcjs.useAuth.call(void 0, );
|
|
30
33
|
return isAuthenticated ? children : fallback;
|
|
31
34
|
}
|
|
32
35
|
function Unauthenticated({ children, fallback = null }) {
|
|
33
|
-
const { isAuthenticated } =
|
|
36
|
+
const { isAuthenticated } = _chunk3R66S7BYcjs.useAuth.call(void 0, );
|
|
34
37
|
return !isAuthenticated ? children : fallback;
|
|
35
38
|
}
|
|
36
39
|
function AuthLoading({ children }) {
|
|
37
|
-
const client =
|
|
40
|
+
const client = _chunk3R66S7BYcjs.useClient.call(void 0, );
|
|
38
41
|
return client.isLoading ? children : null;
|
|
39
42
|
}
|
|
40
43
|
function HasSubscription({ children, fallback = null }) {
|
|
41
|
-
const client =
|
|
44
|
+
const client = _chunk3R66S7BYcjs.useClient.call(void 0, );
|
|
42
45
|
const [hasSubscription, setHasSubscription] = _react2.default.useState(null);
|
|
43
46
|
_react2.default.useEffect(() => {
|
|
44
47
|
client.getSubscription().then((sub) => {
|
|
@@ -56,7 +59,7 @@ function Access({
|
|
|
56
59
|
requested,
|
|
57
60
|
fallback = null
|
|
58
61
|
}) {
|
|
59
|
-
const { allowed, isLoading } =
|
|
62
|
+
const { allowed, isLoading } = _chunk3R66S7BYcjs.useAccess.call(void 0, featureKey, requested);
|
|
60
63
|
if (isLoading) return null;
|
|
61
64
|
return allowed ? children : fallback;
|
|
62
65
|
}
|
|
@@ -67,7 +70,7 @@ function Protected({
|
|
|
67
70
|
authFallback = null,
|
|
68
71
|
billingFallback = null
|
|
69
72
|
}) {
|
|
70
|
-
const { isAuthenticated } =
|
|
73
|
+
const { isAuthenticated } = _chunk3R66S7BYcjs.useAuth.call(void 0, );
|
|
71
74
|
if (auth && !isAuthenticated) {
|
|
72
75
|
return authFallback;
|
|
73
76
|
}
|
|
@@ -80,6 +83,37 @@ function Protected({
|
|
|
80
83
|
// src/error-boundary.tsx
|
|
81
84
|
|
|
82
85
|
|
|
86
|
+
var STYLE_ELEMENT_ID = "kerne-error-boundary-styles";
|
|
87
|
+
var CSS = `
|
|
88
|
+
.kerne-eb { padding: 24px; text-align: center; color: #16171a; }
|
|
89
|
+
.kerne-eb-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 8px; }
|
|
90
|
+
.kerne-eb-body { color: #6b7280; margin: 0 auto 20px; max-width: 40ch; font-size: 14px; line-height: 1.5; }
|
|
91
|
+
.kerne-eb-code { color: #6f7681; margin: -12px 0 20px; font-size: 12px; }
|
|
92
|
+
.kerne-eb-button {
|
|
93
|
+
font: inherit; font-size: 14px; font-weight: 500; height: 44px;
|
|
94
|
+
padding: 0 20px; border-radius: 8px; border: none; cursor: pointer;
|
|
95
|
+
background: #16171a; color: #fff;
|
|
96
|
+
transition: background-color .12s ease;
|
|
97
|
+
}
|
|
98
|
+
.kerne-eb-button:hover { background: #2c2e33; }
|
|
99
|
+
.kerne-eb-button:focus-visible { outline: 2px solid #16171a; outline-offset: 2px; }
|
|
100
|
+
@media (prefers-color-scheme: dark) {
|
|
101
|
+
.kerne-eb { color: #f0f1f3; }
|
|
102
|
+
.kerne-eb-body { color: #9ba2ad; }
|
|
103
|
+
.kerne-eb-code { color: #838b96; }
|
|
104
|
+
.kerne-eb-button { background: #f0f1f3; color: #16181d; }
|
|
105
|
+
.kerne-eb-button:hover { background: #d8dade; }
|
|
106
|
+
.kerne-eb-button:focus-visible { outline-color: #f0f1f3; }
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
109
|
+
function ensureErrorBoundaryStylesInjected() {
|
|
110
|
+
if (typeof document === "undefined") return;
|
|
111
|
+
if (document.getElementById(STYLE_ELEMENT_ID)) return;
|
|
112
|
+
const style = document.createElement("style");
|
|
113
|
+
style.id = STYLE_ELEMENT_ID;
|
|
114
|
+
style.textContent = CSS;
|
|
115
|
+
document.head.appendChild(style);
|
|
116
|
+
}
|
|
83
117
|
var KerneErrorBoundary = (_class = class extends _react.Component {
|
|
84
118
|
constructor(props) {
|
|
85
119
|
super(props);_class.prototype.__init.call(this);;
|
|
@@ -110,28 +144,15 @@ var KerneErrorBoundary = (_class = class extends _react.Component {
|
|
|
110
144
|
}
|
|
111
145
|
return fallback;
|
|
112
146
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "
|
|
116
|
-
|
|
147
|
+
ensureErrorBoundaryStylesInjected();
|
|
148
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "kerne-eb", children: [
|
|
149
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "kerne-eb-title", children: "Something went wrong" }),
|
|
150
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "kerne-eb-body", children: error.message || "An unexpected error occurred" }),
|
|
151
|
+
error.code && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "kerne-eb-code", children: [
|
|
117
152
|
"Error code: ",
|
|
118
153
|
error.code
|
|
119
154
|
] }),
|
|
120
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
121
|
-
"button",
|
|
122
|
-
{
|
|
123
|
-
onClick: this.reset,
|
|
124
|
-
style: {
|
|
125
|
-
padding: "10px 20px",
|
|
126
|
-
backgroundColor: "#3b82f6",
|
|
127
|
-
color: "white",
|
|
128
|
-
border: "none",
|
|
129
|
-
borderRadius: "6px",
|
|
130
|
-
cursor: "pointer"
|
|
131
|
-
},
|
|
132
|
-
children: "Try again"
|
|
133
|
-
}
|
|
134
|
-
)
|
|
155
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "kerne-eb-button", onClick: this.reset, children: "Try again" })
|
|
135
156
|
] });
|
|
136
157
|
}
|
|
137
158
|
return this.props.children;
|
|
@@ -181,4 +202,7 @@ function useKerneError() {
|
|
|
181
202
|
|
|
182
203
|
|
|
183
204
|
|
|
184
|
-
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
exports.Access = Access; exports.AuthLoading = AuthLoading; exports.Authenticated = Authenticated; exports.HasSubscription = HasSubscription; exports.KerneClient = _chunk3R66S7BYcjs.KerneClient; exports.KerneContext = _chunk3R66S7BYcjs.KerneContext; exports.KerneErrorBoundary = KerneErrorBoundary; exports.KerneProvider = _chunk3R66S7BYcjs.KerneProvider; exports.Protected = Protected; exports.Unauthenticated = Unauthenticated; exports.defaultLocalization = _chunk3R66S7BYcjs.defaultLocalization; exports.fr = _chunk3R66S7BYcjs.fr; exports.mergeLocalization = _chunk3R66S7BYcjs.mergeLocalization; exports.useAccess = _chunk3R66S7BYcjs.useAccess; exports.useAuth = _chunk3R66S7BYcjs.useAuth; exports.useAuthConfig = _chunk3R66S7BYcjs.useAuthConfig; exports.useCancelSubscription = _chunk3R66S7BYcjs.useCancelSubscription; exports.useChangePlan = _chunk3R66S7BYcjs.useChangePlan; exports.useCheckout = _chunk3R66S7BYcjs.useCheckout; exports.useClient = _chunk3R66S7BYcjs.useClient; exports.useEntitlements = _chunk3R66S7BYcjs.useEntitlements; exports.useInvitation = _chunk3R66S7BYcjs.useInvitation; exports.useKerneError = useKerneError; exports.usePlanSwitch = _chunk3R66S7BYcjs.usePlanSwitch; exports.usePlans = _chunk3R66S7BYcjs.usePlans; exports.usePortal = _chunk3R66S7BYcjs.usePortal; exports.useReportUsage = _chunk3R66S7BYcjs.useReportUsage; exports.useSubscription = _chunk3R66S7BYcjs.useSubscription; exports.useUsage = _chunk3R66S7BYcjs.useUsage; exports.useUser = _chunk3R66S7BYcjs.useUser; exports.useWaitlist = _chunk3R66S7BYcjs.useWaitlist;
|