@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.
Files changed (126) hide show
  1. package/DESIGN-SYSTEM.md +190 -0
  2. package/INSTRUCTIONS.md +694 -0
  3. package/LICENSE +21 -0
  4. package/README.md +53 -0
  5. package/errors.d.ts +24 -0
  6. package/forms/Form/Form.d.ts +30 -0
  7. package/forms/Form/index.d.ts +1 -0
  8. package/forms/index.d.ts +1 -0
  9. package/hooks/index.d.ts +1 -0
  10. package/hooks/useMediaQuery.d.ts +8 -0
  11. package/index.d.ts +24 -0
  12. package/index.js +1679 -0
  13. package/index.js.map +1 -0
  14. package/internal/env.d.ts +1 -0
  15. package/internal/registry.d.ts +3 -0
  16. package/internal/type-utils.d.ts +6 -0
  17. package/layout/AppLayout/AppLayout.d.ts +18 -0
  18. package/layout/AppLayout/index.d.ts +1 -0
  19. package/layout/CenteredLayout/CenteredLayout.d.ts +12 -0
  20. package/layout/CenteredLayout/index.d.ts +1 -0
  21. package/layout/Columns/Columns.d.ts +35 -0
  22. package/layout/Columns/index.d.ts +1 -0
  23. package/layout/Container/Container.d.ts +5 -0
  24. package/layout/Container/index.d.ts +1 -0
  25. package/layout/DashboardGrid/DashboardGrid.d.ts +37 -0
  26. package/layout/DashboardGrid/index.d.ts +1 -0
  27. package/layout/FillHeight/FillHeight.d.ts +16 -0
  28. package/layout/FillHeight/index.d.ts +1 -0
  29. package/layout/Footer/Footer.d.ts +5 -0
  30. package/layout/Footer/index.d.ts +1 -0
  31. package/layout/Header/Header.d.ts +13 -0
  32. package/layout/Header/index.d.ts +1 -0
  33. package/layout/SideBar/SideBar.d.ts +6 -0
  34. package/layout/SideBar/index.d.ts +1 -0
  35. package/layout/SiteLayout/SiteLayout.d.ts +27 -0
  36. package/layout/SiteLayout/index.d.ts +1 -0
  37. package/layout/SkipLink/SkipLink.d.ts +9 -0
  38. package/layout/SkipLink/index.d.ts +1 -0
  39. package/layout/TopBar/TopBar.d.ts +32 -0
  40. package/layout/TopBar/index.d.ts +1 -0
  41. package/layout/index.d.ts +12 -0
  42. package/package.json +52 -0
  43. package/query/index.d.ts +1 -0
  44. package/query/sort.d.ts +19 -0
  45. package/router/DefaultErrorBoundary.d.ts +5 -0
  46. package/router/TypedLink/TypedLink.d.ts +22 -0
  47. package/router/TypedLink/index.d.ts +1 -0
  48. package/router/adapter.d.ts +27 -0
  49. package/router/chain.d.ts +17 -0
  50. package/router/context.d.ts +24 -0
  51. package/router/createAppRouter.d.ts +15 -0
  52. package/router/defineRoute.d.ts +11 -0
  53. package/router/index.d.ts +11 -0
  54. package/router/menu.d.ts +51 -0
  55. package/router/pathTo.d.ts +21 -0
  56. package/router/types.d.ts +72 -0
  57. package/router/useRoute.d.ts +22 -0
  58. package/style.css +3 -0
  59. package/theme/ModeToggle/ModeToggle.d.ts +6 -0
  60. package/theme/ModeToggle/index.d.ts +1 -0
  61. package/theme/ThemeProvider/ThemeProvider.d.ts +25 -0
  62. package/theme/ThemeProvider/index.d.ts +1 -0
  63. package/theme/Toaster/Toaster.d.ts +9 -0
  64. package/theme/Toaster/index.d.ts +2 -0
  65. package/theme/Toaster/toast.d.ts +38 -0
  66. package/theme/index.d.ts +3 -0
  67. package/ui/Accordion/Accordion.d.ts +7 -0
  68. package/ui/Accordion/index.d.ts +1 -0
  69. package/ui/Alert/Alert.d.ts +11 -0
  70. package/ui/Alert/index.d.ts +1 -0
  71. package/ui/AlertDialog/AlertDialog.d.ts +19 -0
  72. package/ui/AlertDialog/index.d.ts +1 -0
  73. package/ui/Avatar/Avatar.d.ts +7 -0
  74. package/ui/Avatar/index.d.ts +1 -0
  75. package/ui/AwaitErrorBlock/AwaitErrorBlock.d.ts +11 -0
  76. package/ui/AwaitErrorBlock/index.d.ts +1 -0
  77. package/ui/Badge/Badge.d.ts +10 -0
  78. package/ui/Badge/index.d.ts +1 -0
  79. package/ui/Button/Button.d.ts +13 -0
  80. package/ui/Button/index.d.ts +1 -0
  81. package/ui/Card/Card.d.ts +11 -0
  82. package/ui/Card/index.d.ts +1 -0
  83. package/ui/Checkbox/Checkbox.d.ts +5 -0
  84. package/ui/Checkbox/index.d.ts +1 -0
  85. package/ui/Command/Command.d.ts +19 -0
  86. package/ui/Command/index.d.ts +1 -0
  87. package/ui/Dialog/Dialog.d.ts +17 -0
  88. package/ui/Dialog/index.d.ts +1 -0
  89. package/ui/DropdownMenu/DropdownMenu.d.ts +28 -0
  90. package/ui/DropdownMenu/index.d.ts +1 -0
  91. package/ui/ErrorBlock/ErrorBlock.d.ts +21 -0
  92. package/ui/ErrorBlock/index.d.ts +1 -0
  93. package/ui/Input/Input.d.ts +4 -0
  94. package/ui/Input/index.d.ts +1 -0
  95. package/ui/Label/Label.d.ts +5 -0
  96. package/ui/Label/index.d.ts +1 -0
  97. package/ui/Pagination/Pagination.d.ts +17 -0
  98. package/ui/Pagination/index.d.ts +1 -0
  99. package/ui/Popover/Popover.d.ts +7 -0
  100. package/ui/Popover/index.d.ts +1 -0
  101. package/ui/Progress/Progress.d.ts +16 -0
  102. package/ui/Progress/index.d.ts +1 -0
  103. package/ui/RadioGroup/RadioGroup.d.ts +7 -0
  104. package/ui/RadioGroup/index.d.ts +1 -0
  105. package/ui/Select/Select.d.ts +16 -0
  106. package/ui/Select/index.d.ts +1 -0
  107. package/ui/Separator/Separator.d.ts +5 -0
  108. package/ui/Separator/index.d.ts +1 -0
  109. package/ui/Sheet/Sheet.d.ts +17 -0
  110. package/ui/Sheet/index.d.ts +1 -0
  111. package/ui/Skeleton/Skeleton.d.ts +4 -0
  112. package/ui/Skeleton/index.d.ts +1 -0
  113. package/ui/Spinner/Spinner.d.ts +35 -0
  114. package/ui/Spinner/index.d.ts +1 -0
  115. package/ui/Switch/Switch.d.ts +5 -0
  116. package/ui/Switch/index.d.ts +1 -0
  117. package/ui/Table/Table.d.ts +11 -0
  118. package/ui/Table/index.d.ts +1 -0
  119. package/ui/Tabs/Tabs.d.ts +8 -0
  120. package/ui/Tabs/index.d.ts +1 -0
  121. package/ui/Textarea/Textarea.d.ts +4 -0
  122. package/ui/Textarea/index.d.ts +1 -0
  123. package/ui/Tooltip/Tooltip.d.ts +7 -0
  124. package/ui/Tooltip/index.d.ts +1 -0
  125. package/ui/index.d.ts +29 -0
  126. 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';
@@ -0,0 +1 @@
1
+ export * from './Form';
@@ -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';