@kode4/react-foundation 0.1.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/DESIGN-SYSTEM.md +190 -0
- package/INSTRUCTIONS.md +694 -0
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/errors.d.ts +24 -0
- package/forms/Form/Form.d.ts +30 -0
- package/forms/Form/index.d.ts +1 -0
- package/forms/index.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/useMediaQuery.d.ts +8 -0
- package/index.d.ts +24 -0
- package/index.js +1679 -0
- package/index.js.map +1 -0
- package/internal/env.d.ts +1 -0
- package/internal/registry.d.ts +3 -0
- package/internal/type-utils.d.ts +6 -0
- package/layout/AppLayout/AppLayout.d.ts +18 -0
- package/layout/AppLayout/index.d.ts +1 -0
- package/layout/CenteredLayout/CenteredLayout.d.ts +12 -0
- package/layout/CenteredLayout/index.d.ts +1 -0
- package/layout/Columns/Columns.d.ts +35 -0
- package/layout/Columns/index.d.ts +1 -0
- package/layout/Container/Container.d.ts +5 -0
- package/layout/Container/index.d.ts +1 -0
- package/layout/DashboardGrid/DashboardGrid.d.ts +37 -0
- package/layout/DashboardGrid/index.d.ts +1 -0
- package/layout/FillHeight/FillHeight.d.ts +16 -0
- package/layout/FillHeight/index.d.ts +1 -0
- package/layout/Footer/Footer.d.ts +5 -0
- package/layout/Footer/index.d.ts +1 -0
- package/layout/Header/Header.d.ts +13 -0
- package/layout/Header/index.d.ts +1 -0
- package/layout/SideBar/SideBar.d.ts +6 -0
- package/layout/SideBar/index.d.ts +1 -0
- package/layout/SiteLayout/SiteLayout.d.ts +27 -0
- package/layout/SiteLayout/index.d.ts +1 -0
- package/layout/SkipLink/SkipLink.d.ts +9 -0
- package/layout/SkipLink/index.d.ts +1 -0
- package/layout/TopBar/TopBar.d.ts +32 -0
- package/layout/TopBar/index.d.ts +1 -0
- package/layout/index.d.ts +12 -0
- package/package.json +52 -0
- package/query/index.d.ts +1 -0
- package/query/sort.d.ts +19 -0
- package/router/DefaultErrorBoundary.d.ts +5 -0
- package/router/TypedLink/TypedLink.d.ts +22 -0
- package/router/TypedLink/index.d.ts +1 -0
- package/router/adapter.d.ts +27 -0
- package/router/chain.d.ts +17 -0
- package/router/context.d.ts +24 -0
- package/router/createAppRouter.d.ts +15 -0
- package/router/defineRoute.d.ts +11 -0
- package/router/index.d.ts +11 -0
- package/router/menu.d.ts +51 -0
- package/router/pathTo.d.ts +21 -0
- package/router/types.d.ts +72 -0
- package/router/useRoute.d.ts +22 -0
- package/style.css +3 -0
- package/theme/ModeToggle/ModeToggle.d.ts +6 -0
- package/theme/ModeToggle/index.d.ts +1 -0
- package/theme/ThemeProvider/ThemeProvider.d.ts +25 -0
- package/theme/ThemeProvider/index.d.ts +1 -0
- package/theme/Toaster/Toaster.d.ts +9 -0
- package/theme/Toaster/index.d.ts +2 -0
- package/theme/Toaster/toast.d.ts +38 -0
- package/theme/index.d.ts +3 -0
- package/ui/Accordion/Accordion.d.ts +7 -0
- package/ui/Accordion/index.d.ts +1 -0
- package/ui/Alert/Alert.d.ts +11 -0
- package/ui/Alert/index.d.ts +1 -0
- package/ui/AlertDialog/AlertDialog.d.ts +19 -0
- package/ui/AlertDialog/index.d.ts +1 -0
- package/ui/Avatar/Avatar.d.ts +7 -0
- package/ui/Avatar/index.d.ts +1 -0
- package/ui/AwaitErrorBlock/AwaitErrorBlock.d.ts +11 -0
- package/ui/AwaitErrorBlock/index.d.ts +1 -0
- package/ui/Badge/Badge.d.ts +10 -0
- package/ui/Badge/index.d.ts +1 -0
- package/ui/Button/Button.d.ts +13 -0
- package/ui/Button/index.d.ts +1 -0
- package/ui/Card/Card.d.ts +11 -0
- package/ui/Card/index.d.ts +1 -0
- package/ui/Checkbox/Checkbox.d.ts +5 -0
- package/ui/Checkbox/index.d.ts +1 -0
- package/ui/Command/Command.d.ts +19 -0
- package/ui/Command/index.d.ts +1 -0
- package/ui/Dialog/Dialog.d.ts +17 -0
- package/ui/Dialog/index.d.ts +1 -0
- package/ui/DropdownMenu/DropdownMenu.d.ts +28 -0
- package/ui/DropdownMenu/index.d.ts +1 -0
- package/ui/ErrorBlock/ErrorBlock.d.ts +21 -0
- package/ui/ErrorBlock/index.d.ts +1 -0
- package/ui/Input/Input.d.ts +4 -0
- package/ui/Input/index.d.ts +1 -0
- package/ui/Label/Label.d.ts +5 -0
- package/ui/Label/index.d.ts +1 -0
- package/ui/Pagination/Pagination.d.ts +17 -0
- package/ui/Pagination/index.d.ts +1 -0
- package/ui/Popover/Popover.d.ts +7 -0
- package/ui/Popover/index.d.ts +1 -0
- package/ui/Progress/Progress.d.ts +16 -0
- package/ui/Progress/index.d.ts +1 -0
- package/ui/RadioGroup/RadioGroup.d.ts +7 -0
- package/ui/RadioGroup/index.d.ts +1 -0
- package/ui/Select/Select.d.ts +16 -0
- package/ui/Select/index.d.ts +1 -0
- package/ui/Separator/Separator.d.ts +5 -0
- package/ui/Separator/index.d.ts +1 -0
- package/ui/Sheet/Sheet.d.ts +17 -0
- package/ui/Sheet/index.d.ts +1 -0
- package/ui/Skeleton/Skeleton.d.ts +4 -0
- package/ui/Skeleton/index.d.ts +1 -0
- package/ui/Spinner/Spinner.d.ts +35 -0
- package/ui/Spinner/index.d.ts +1 -0
- package/ui/Switch/Switch.d.ts +5 -0
- package/ui/Switch/index.d.ts +1 -0
- package/ui/Table/Table.d.ts +11 -0
- package/ui/Table/index.d.ts +1 -0
- package/ui/Tabs/Tabs.d.ts +8 -0
- package/ui/Tabs/index.d.ts +1 -0
- package/ui/Textarea/Textarea.d.ts +4 -0
- package/ui/Textarea/index.d.ts +1 -0
- package/ui/Tooltip/Tooltip.d.ts +7 -0
- package/ui/Tooltip/index.d.ts +1 -0
- package/ui/index.d.ts +29 -0
- package/utils.d.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kode4
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @kode4/react-foundation
|
|
2
|
+
|
|
3
|
+
Typed router, themed UI component library, and design system for kode4 projects.
|
|
4
|
+
|
|
5
|
+
- **Typed router** — a thin layer over React Router DOM v7 that makes route
|
|
6
|
+
definitions the single source of truth for paths, params, search, loaders,
|
|
7
|
+
guards, error boundaries, and menus (all Zod-validated, fully inferred).
|
|
8
|
+
- **UI component library** — 30+ components on Radix primitives (shadcn/ui as
|
|
9
|
+
the blueprint), styled entirely through CSS variables.
|
|
10
|
+
- **Design system** — semantic tokens with light/dark mode; responsive,
|
|
11
|
+
touch-first layout frames.
|
|
12
|
+
|
|
13
|
+
`src/lib` is the library (published as a public npm package). `src/demo` is the
|
|
14
|
+
showcase app that exercises it.
|
|
15
|
+
|
|
16
|
+
## Quickstart
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install
|
|
20
|
+
npm run dev # demo at http://localhost:5173
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Scripts
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run build # typecheck + boundary check + production bundle (demo)
|
|
27
|
+
npm run build:lib # build the publishable package into dist-lib/
|
|
28
|
+
npm run typecheck # tsc --noEmit
|
|
29
|
+
npm run lint # eslint
|
|
30
|
+
npm run format # prettier --write
|
|
31
|
+
npm run check:boundaries # enforce lib/demo import boundaries
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Publish: `npm run build:lib && npm publish ./dist-lib`.
|
|
35
|
+
|
|
36
|
+
## Consuming the library
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Button, defineRoute, useRoute } from '@kode4/react-foundation';
|
|
40
|
+
import '@kode4/react-foundation/styles.css'; // once, near the app root
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
See **[`INSTRUCTIONS.md`](./INSTRUCTIONS.md)** for the full consumer guide (router patterns,
|
|
44
|
+
component catalog, theming, data/forms idioms).
|
|
45
|
+
|
|
46
|
+
## Docs
|
|
47
|
+
|
|
48
|
+
- **[`INSTRUCTIONS.md`](./INSTRUCTIONS.md)** — building apps with the library (consumer contract).
|
|
49
|
+
- **[`DESIGN-SYSTEM.md`](./DESIGN-SYSTEM.md)** — theming tokens and the styling contract.
|
|
50
|
+
- **[`CLAUDE.md`](./CLAUDE.md)** — conventions for working inside the library repo.
|
|
51
|
+
- **[`roadmap.md`](./roadmap.md)** — planned components.
|
|
52
|
+
|
|
53
|
+
License: [MIT](./LICENSE).
|
package/errors.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured application error. Throw this in your own code
|
|
3
|
+
* when you want a machine-readable code alongside the message.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AppError extends Error {
|
|
6
|
+
code: string;
|
|
7
|
+
details?: unknown;
|
|
8
|
+
constructor(code: string, message: string, details?: unknown);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Consistent shape for displaying any error, regardless of origin.
|
|
12
|
+
*/
|
|
13
|
+
export type NormalizedError = {
|
|
14
|
+
code?: string;
|
|
15
|
+
message: string;
|
|
16
|
+
details?: unknown;
|
|
17
|
+
original: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Converts any thrown value into a consistent display shape.
|
|
21
|
+
* Handles AppError, React Router responses, standard Errors,
|
|
22
|
+
* strings, and unknown values.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeError(error: unknown): NormalizedError;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Slot } from 'radix-ui';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
|
+
import { type ControllerProps, type FieldPath, type FieldValues } from 'react-hook-form';
|
|
4
|
+
import { Label } from '../../ui/Label';
|
|
5
|
+
import './Form.css';
|
|
6
|
+
/**
|
|
7
|
+
* react-hook-form integration, mirroring shadcn's Form API:
|
|
8
|
+
* <Form> (FormProvider) → <FormField> (Controller) → <FormItem> with
|
|
9
|
+
* <FormLabel>/<FormControl>/<FormDescription>/<FormMessage>, all wired for
|
|
10
|
+
* accessibility (ids, aria-describedby, aria-invalid).
|
|
11
|
+
*/
|
|
12
|
+
export declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe, }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
13
|
+
export declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: ControllerProps<TFieldValues, TName>): import("react").JSX.Element;
|
|
14
|
+
export declare function useFormField(): {
|
|
15
|
+
invalid: boolean;
|
|
16
|
+
isDirty: boolean;
|
|
17
|
+
isTouched: boolean;
|
|
18
|
+
isValidating: boolean;
|
|
19
|
+
error?: import("react-hook-form").FieldError;
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
formItemId: string;
|
|
23
|
+
formDescriptionId: string;
|
|
24
|
+
formMessageId: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function FormItem({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
27
|
+
export declare function FormLabel({ className, ...props }: ComponentProps<typeof Label>): import("react").JSX.Element;
|
|
28
|
+
export declare function FormControl(props: ComponentProps<typeof Slot.Root>): import("react").JSX.Element;
|
|
29
|
+
export declare function FormDescription({ className, ...props }: ComponentProps<'p'>): import("react").JSX.Element;
|
|
30
|
+
export declare function FormMessage({ className, children, ...props }: ComponentProps<'p'>): import("react").JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Form';
|
package/forms/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Form';
|
package/hooks/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useMediaQuery';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactively tracks a CSS media query. Returns whether it currently matches and
|
|
3
|
+
* updates on change. Use for responsive behaviour that can't be pure CSS — e.g.
|
|
4
|
+
* swapping an inline nav for a mobile drawer.
|
|
5
|
+
*
|
|
6
|
+
* const isMobile = useMediaQuery('(max-width: 768px)');
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMediaQuery(query: string): boolean;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point of @kode4/react-foundation. Apps (including the demo)
|
|
3
|
+
* should import ONLY from here.
|
|
4
|
+
*
|
|
5
|
+
* Importing this barrel also loads the design system (theme.css) — no
|
|
6
|
+
* separate stylesheet import is needed by consumers.
|
|
7
|
+
*
|
|
8
|
+
* Convention: every folder in src/lib has an index.ts that re-exports its
|
|
9
|
+
* children with `export *`, so consumers never need to know the internal
|
|
10
|
+
* structure. When adding a folder or file, add it to the parent barrel.
|
|
11
|
+
* Exception: `internal/` folders are private and never re-exported.
|
|
12
|
+
*/
|
|
13
|
+
import './theme.css';
|
|
14
|
+
import './text.css';
|
|
15
|
+
import './surface.css';
|
|
16
|
+
export * from './errors';
|
|
17
|
+
export * from './forms';
|
|
18
|
+
export * from './hooks';
|
|
19
|
+
export * from './layout';
|
|
20
|
+
export * from './query';
|
|
21
|
+
export * from './router';
|
|
22
|
+
export * from './theme';
|
|
23
|
+
export * from './ui';
|
|
24
|
+
export * from './utils';
|