@regardio/react 0.5.7 → 0.7.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/dist/background-slideshow/index.d.mts +34 -0
- package/dist/background-slideshow/index.mjs +110 -0
- package/dist/blurry-gradient/index.d.mts +16 -0
- package/dist/blurry-gradient/index.mjs +93 -0
- package/dist/button/index.d.mts +2 -0
- package/dist/button/index.mjs +3 -0
- package/dist/button-BiSQpBbc.mjs +129 -0
- package/dist/carousel/index.d.mts +74 -0
- package/dist/carousel/index.mjs +136 -0
- package/dist/checkbox/index.d.mts +28 -0
- package/dist/checkbox/index.mjs +70 -0
- package/dist/checkbox-group/index.d.mts +16 -0
- package/dist/checkbox-group/index.mjs +29 -0
- package/dist/chunk-BTpB_u-K.mjs +18 -0
- package/dist/countdown/index.d.mts +4 -0
- package/dist/countdown/index.mjs +58 -0
- package/dist/field/index.d.mts +68 -0
- package/dist/field/index.mjs +115 -0
- package/dist/fieldset/index.d.mts +34 -0
- package/dist/fieldset/index.mjs +61 -0
- package/dist/form/index.d.mts +21 -0
- package/dist/form/index.mjs +31 -0
- package/dist/generic-error/index.d.mts +44 -0
- package/dist/generic-error/index.mjs +57 -0
- package/dist/grid/index.d.mts +101 -0
- package/dist/grid/index.mjs +219 -0
- package/dist/heading/index.d.mts +27 -0
- package/dist/heading/index.mjs +28 -0
- package/dist/highlight/index.d.mts +17 -0
- package/dist/highlight/index.mjs +35 -0
- package/dist/hooks/use-current-route-data.d.mts +8 -0
- package/dist/hooks/use-current-route-data.mjs +22 -0
- package/dist/hooks/{use-focus-search.d.ts → use-focus-search.d.mts} +4 -3
- package/dist/hooks/use-focus-search.mjs +23 -0
- package/dist/hooks/use-matches-data.d.mts +10 -0
- package/dist/hooks/use-matches-data.mjs +23 -0
- package/dist/hooks/use-media-query.d.mts +9 -0
- package/dist/hooks/use-media-query.mjs +28 -0
- package/dist/hooks/use-mobile.d.mts +4 -0
- package/dist/hooks/use-mobile.mjs +22 -0
- package/dist/hooks/use-nonce.d.mts +6 -0
- package/dist/hooks/use-nonce.mjs +13 -0
- package/dist/hooks/use-orientation.d.mts +12 -0
- package/dist/hooks/use-orientation.mjs +32 -0
- package/dist/hooks/use-user.d.mts +53 -0
- package/dist/hooks/use-user.mjs +39 -0
- package/dist/icon-button/index.d.mts +28 -0
- package/dist/icon-button/index.mjs +36 -0
- package/dist/if/index.d.mts +13 -0
- package/dist/if/index.mjs +21 -0
- package/dist/iframe/index.d.mts +11 -0
- package/dist/iframe/index.mjs +15 -0
- package/dist/index-Bj5_XfEC.d.mts +29 -0
- package/dist/index-C_evL5vG.d.mts +35 -0
- package/dist/input/index.d.mts +2 -0
- package/dist/input/index.mjs +3 -0
- package/dist/input-CtR6aRVi.mjs +73 -0
- package/dist/link/index.d.mts +71 -0
- package/dist/link/index.mjs +129 -0
- package/dist/list/index.d.mts +72 -0
- package/dist/list/index.mjs +54 -0
- package/dist/markdown-container/index.d.mts +23 -0
- package/dist/markdown-container/index.mjs +71 -0
- package/dist/password-input/index.d.mts +23 -0
- package/dist/password-input/index.mjs +92 -0
- package/dist/picture/index.d.mts +39 -0
- package/dist/picture/index.mjs +3 -0
- package/dist/picture-DkX3W5zl.mjs +69 -0
- package/dist/protected-email/index.d.mts +24 -0
- package/dist/protected-email/index.mjs +37 -0
- package/dist/radio/index.d.mts +28 -0
- package/dist/radio/index.mjs +72 -0
- package/dist/radio-group/index.d.mts +16 -0
- package/dist/radio-group/index.mjs +29 -0
- package/dist/slider/index.d.mts +63 -0
- package/dist/slider/index.mjs +133 -0
- package/dist/switch/index.d.mts +29 -0
- package/dist/switch/index.mjs +87 -0
- package/dist/text/index.d.mts +25 -0
- package/dist/text/index.mjs +32 -0
- package/dist/text-EQC4zJbE.mjs +52 -0
- package/dist/toggle/index.d.mts +25 -0
- package/dist/toggle/index.mjs +82 -0
- package/dist/utils/author/index.d.mts +4 -0
- package/dist/utils/author/index.mjs +26 -0
- package/dist/utils/text/{index.d.ts → index.d.mts} +9 -8
- package/dist/utils/text/index.mjs +3 -0
- package/package.json +131 -83
- package/src/background-slideshow/background-slideshow.tsx +1 -2
- package/src/blurry-gradient/blurry-gradient.tsx +1 -1
- package/src/button/button.stories.tsx +161 -0
- package/src/button/button.test.tsx +73 -0
- package/src/button/button.tsx +118 -0
- package/src/button/index.ts +2 -0
- package/src/carousel/carousel-content.tsx +17 -14
- package/src/carousel/carousel-item.tsx +18 -18
- package/src/carousel/carousel-next.tsx +22 -17
- package/src/carousel/carousel-previous.tsx +22 -17
- package/src/carousel/carousel-root.tsx +91 -86
- package/src/checkbox/checkbox.stories.tsx +118 -0
- package/src/checkbox/checkbox.tsx +102 -0
- package/src/checkbox/index.ts +2 -0
- package/src/checkbox-group/checkbox-group.tsx +40 -0
- package/src/checkbox-group/index.ts +2 -0
- package/src/countdown/countdown.tsx +1 -1
- package/src/field/field.stories.tsx +105 -0
- package/src/field/field.test.tsx +61 -0
- package/src/field/field.tsx +186 -0
- package/src/field/index.ts +12 -0
- package/src/fieldset/fieldset.stories.tsx +204 -0
- package/src/fieldset/fieldset.test.tsx +63 -0
- package/src/fieldset/fieldset.tsx +86 -0
- package/src/fieldset/index.ts +7 -0
- package/src/form/form.stories.tsx +230 -0
- package/src/form/form.test.tsx +68 -0
- package/src/form/form.tsx +38 -0
- package/src/form/index.ts +2 -0
- package/src/generic-error/generic-error.tsx +2 -3
- package/src/grid/grid-item.tsx +77 -36
- package/src/grid/grid-root.tsx +49 -22
- package/src/heading/heading.tsx +7 -3
- package/src/highlight/highlight.tsx +1 -1
- package/src/hooks/use-current-route-data.ts +4 -2
- package/src/hooks/use-focus-search.ts +3 -1
- package/src/hooks/use-matches-data.ts +2 -0
- package/src/hooks/use-media-query.ts +2 -0
- package/src/hooks/use-mobile.ts +3 -1
- package/src/hooks/use-nonce.ts +3 -3
- package/src/hooks/use-orientation.ts +2 -0
- package/src/hooks/use-user.tsx +3 -2
- package/src/icon-button/icon-button.stories.tsx +128 -7
- package/src/icon-button/icon-button.test.tsx +152 -0
- package/src/icon-button/icon-button.tsx +43 -9
- package/src/if/if.tsx +3 -1
- package/src/input/index.ts +2 -0
- package/src/input/input.stories.tsx +151 -0
- package/src/input/input.test.tsx +65 -0
- package/src/input/input.tsx +113 -0
- package/src/link/link.tsx +4 -3
- package/src/list/list-item.tsx +10 -13
- package/src/list/list-root-context.ts +3 -3
- package/src/list/list-root.tsx +10 -13
- package/src/password-input/index.ts +1 -1
- package/src/password-input/password-input.tsx +104 -27
- package/src/protected-email/protected-email.tsx +6 -1
- package/src/radio/index.ts +2 -0
- package/src/radio/radio.tsx +103 -0
- package/src/radio-group/index.ts +2 -0
- package/src/radio-group/radio-group.tsx +40 -0
- package/src/slider/index.ts +18 -0
- package/src/slider/slider.tsx +201 -0
- package/src/switch/index.ts +2 -0
- package/src/switch/switch.stories.tsx +118 -0
- package/src/switch/switch.tsx +112 -0
- package/src/text/text.tsx +6 -1
- package/src/toggle/index.ts +2 -0
- package/src/toggle/toggle.stories.tsx +232 -0
- package/src/toggle/toggle.test.tsx +149 -0
- package/src/toggle/toggle.tsx +88 -0
- package/src/utils/text/text.tsx +8 -16
- package/dist/background-slideshow/index.d.ts +0 -24
- package/dist/background-slideshow/index.js +0 -165
- package/dist/blurry-gradient/index.d.ts +0 -16
- package/dist/blurry-gradient/index.js +0 -128
- package/dist/carousel/index.d.ts +0 -36
- package/dist/carousel/index.js +0 -171
- package/dist/countdown/index.d.ts +0 -5
- package/dist/countdown/index.js +0 -73
- package/dist/generic-error/index.d.ts +0 -43
- package/dist/generic-error/index.js +0 -47
- package/dist/grid/index.d.ts +0 -1196
- package/dist/grid/index.js +0 -239
- package/dist/heading/index.d.ts +0 -24
- package/dist/heading/index.js +0 -99
- package/dist/highlight/index.d.ts +0 -13
- package/dist/highlight/index.js +0 -59
- package/dist/hooks/use-current-route-data.d.ts +0 -7
- package/dist/hooks/use-current-route-data.js +0 -16
- package/dist/hooks/use-focus-search.js +0 -19
- package/dist/hooks/use-matches-data.d.ts +0 -9
- package/dist/hooks/use-matches-data.js +0 -15
- package/dist/hooks/use-media-query.d.ts +0 -8
- package/dist/hooks/use-media-query.js +0 -20
- package/dist/hooks/use-mobile.d.ts +0 -3
- package/dist/hooks/use-mobile.js +0 -19
- package/dist/hooks/use-nonce.d.ts +0 -7
- package/dist/hooks/use-nonce.js +0 -8
- package/dist/hooks/use-orientation.d.ts +0 -11
- package/dist/hooks/use-orientation.js +0 -29
- package/dist/hooks/use-user.d.ts +0 -50
- package/dist/hooks/use-user.js +0 -25
- package/dist/icon-button/index.d.ts +0 -9
- package/dist/icon-button/index.js +0 -17
- package/dist/if/index.d.ts +0 -10
- package/dist/if/index.js +0 -24
- package/dist/iframe/index.d.ts +0 -10
- package/dist/iframe/index.js +0 -17
- package/dist/link/index.d.ts +0 -55
- package/dist/link/index.js +0 -195
- package/dist/list/index.d.ts +0 -69
- package/dist/list/index.js +0 -65
- package/dist/markdown-container/index.d.ts +0 -22
- package/dist/markdown-container/index.js +0 -128
- package/dist/password-input/index.d.ts +0 -11
- package/dist/password-input/index.js +0 -46
- package/dist/picture/index.d.ts +0 -38
- package/dist/picture/index.js +0 -68
- package/dist/protected-email/index.d.ts +0 -20
- package/dist/protected-email/index.js +0 -30
- package/dist/text/index.d.ts +0 -20
- package/dist/text/index.js +0 -38
- package/dist/utils/author/index.d.ts +0 -3
- package/dist/utils/author/index.js +0 -33
- package/dist/utils/text/index.js +0 -73
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Descriptor returned from getErrorDescriptor to help apps localize messages.
|
|
5
|
-
*/
|
|
6
|
-
type ErrorDescriptor = {
|
|
7
|
-
type: 'http';
|
|
8
|
-
status: number;
|
|
9
|
-
statusText: string;
|
|
10
|
-
defaultId: string;
|
|
11
|
-
defaultMessage: string;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'error';
|
|
14
|
-
defaultId: string;
|
|
15
|
-
defaultMessage: string;
|
|
16
|
-
message?: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
} | {
|
|
19
|
-
type: 'unknown';
|
|
20
|
-
defaultId: string;
|
|
21
|
-
defaultMessage: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Compute a normalized error descriptor from a React Router error.
|
|
25
|
-
* Apps can use this to map to i18n keys.
|
|
26
|
-
*/
|
|
27
|
-
declare function getErrorDescriptor(error: unknown): ErrorDescriptor;
|
|
28
|
-
/**
|
|
29
|
-
* GenericError
|
|
30
|
-
*
|
|
31
|
-
* A reusable error boundary component for React Router apps.
|
|
32
|
-
* - Displays status-based messages for route responses
|
|
33
|
-
* - Shows stack traces in development for non-response errors
|
|
34
|
-
*
|
|
35
|
-
* For localization, apps may either:
|
|
36
|
-
* - Wrap this component and use `getErrorDescriptor(useRouteError())` to map to i18n keys
|
|
37
|
-
* - Or provide a custom `renderMessage` to override the displayed details
|
|
38
|
-
*/
|
|
39
|
-
declare function GenericError({ renderMessage, }?: {
|
|
40
|
-
renderMessage?: (descriptor: ErrorDescriptor) => ReactElement;
|
|
41
|
-
}): ReactElement;
|
|
42
|
-
|
|
43
|
-
export { type ErrorDescriptor, GenericError, getErrorDescriptor };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { isRouteErrorResponse, useRouteError } from 'react-router';
|
|
2
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
// src/generic-error/generic-error.tsx
|
|
5
|
-
function getErrorDescriptor(error) {
|
|
6
|
-
if (isRouteErrorResponse(error)) {
|
|
7
|
-
const status = error.status;
|
|
8
|
-
const statusText = error.statusText || "Error";
|
|
9
|
-
return {
|
|
10
|
-
defaultId: status === 404 ? "errors.404" : "errors.http",
|
|
11
|
-
defaultMessage: status === 404 ? "Not found" : `Error ${status}`,
|
|
12
|
-
status,
|
|
13
|
-
statusText,
|
|
14
|
-
type: "http"
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (error instanceof Error) {
|
|
18
|
-
return {
|
|
19
|
-
defaultId: "errors.runtime",
|
|
20
|
-
defaultMessage: "An unexpected error occurred.",
|
|
21
|
-
message: error.message,
|
|
22
|
-
type: "error",
|
|
23
|
-
...error.stack ? { stack: error.stack } : {}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
defaultId: "errors.unknown",
|
|
28
|
-
defaultMessage: "An unexpected error occurred.",
|
|
29
|
-
type: "unknown"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function GenericError({
|
|
33
|
-
renderMessage
|
|
34
|
-
} = {}) {
|
|
35
|
-
const error = useRouteError();
|
|
36
|
-
const descriptor = getErrorDescriptor(error);
|
|
37
|
-
const title = descriptor.type === "http" ? `Error ${descriptor.status}` : "Error";
|
|
38
|
-
return /* @__PURE__ */ jsxs("main", { className: "pt-2xl p-sm container mx-auto", children: [
|
|
39
|
-
/* @__PURE__ */ jsx("h1", { children: title }),
|
|
40
|
-
renderMessage ? renderMessage(descriptor) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
|
-
/* @__PURE__ */ jsx("p", { children: descriptor.type === "http" ? descriptor.defaultMessage : descriptor.type === "error" ? descriptor.message || descriptor.defaultMessage : descriptor.defaultMessage }),
|
|
42
|
-
import.meta.env.DEV && descriptor.type === "error" && descriptor.stack && /* @__PURE__ */ jsx("pre", { className: "w-full p-sm overflow-x-auto", children: /* @__PURE__ */ jsx("code", { children: descriptor.stack }) })
|
|
43
|
-
] })
|
|
44
|
-
] });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { GenericError, getErrorDescriptor };
|