@repraze/kernelkit 0.1.0-alpha.3 → 0.1.0-alpha.5

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 (203) hide show
  1. package/README.md +17 -0
  2. package/dist/components/alert-dialog.d.ts.map +1 -1
  3. package/dist/components/alert-dialog.js +4 -1
  4. package/dist/components/alert-dialog.js.map +1 -1
  5. package/dist/components/alert.js +3 -3
  6. package/dist/components/alert.js.map +1 -1
  7. package/dist/components/badge.js +1 -1
  8. package/dist/components/badge.js.map +1 -1
  9. package/dist/components/button.js +1 -1
  10. package/dist/components/button.js.map +1 -1
  11. package/dist/components/calendar.d.ts +8 -1
  12. package/dist/components/calendar.d.ts.map +1 -1
  13. package/dist/components/calendar.js +33 -11
  14. package/dist/components/calendar.js.map +1 -1
  15. package/dist/components/callout.js +2 -2
  16. package/dist/components/callout.js.map +1 -1
  17. package/dist/components/combobox.js +1 -1
  18. package/dist/components/combobox.js.map +1 -1
  19. package/dist/components/date-picker.d.ts +11 -5
  20. package/dist/components/date-picker.d.ts.map +1 -1
  21. package/dist/components/date-picker.js +29 -7
  22. package/dist/components/date-picker.js.map +1 -1
  23. package/dist/components/description-list.d.ts +26 -0
  24. package/dist/components/description-list.d.ts.map +1 -0
  25. package/dist/components/description-list.js +59 -0
  26. package/dist/components/description-list.js.map +1 -0
  27. package/dist/components/locale.d.ts +19 -0
  28. package/dist/components/locale.d.ts.map +1 -0
  29. package/dist/components/locale.js +54 -0
  30. package/dist/components/locale.js.map +1 -0
  31. package/dist/components/popover.d.ts +1 -1
  32. package/dist/components/popover.d.ts.map +1 -1
  33. package/dist/components/popover.js +2 -2
  34. package/dist/components/popover.js.map +1 -1
  35. package/dist/components/progress.d.ts +19 -6
  36. package/dist/components/progress.d.ts.map +1 -1
  37. package/dist/components/progress.js +18 -3
  38. package/dist/components/progress.js.map +1 -1
  39. package/dist/components/search-dialog.d.ts +6 -1
  40. package/dist/components/search-dialog.d.ts.map +1 -1
  41. package/dist/components/search-dialog.js +13 -1
  42. package/dist/components/search-dialog.js.map +1 -1
  43. package/dist/components/search-trigger.d.ts +4 -1
  44. package/dist/components/search-trigger.d.ts.map +1 -1
  45. package/dist/components/search-trigger.js +5 -2
  46. package/dist/components/search-trigger.js.map +1 -1
  47. package/dist/components/shimmer.d.ts +13 -0
  48. package/dist/components/shimmer.d.ts.map +1 -0
  49. package/dist/components/shimmer.js +21 -0
  50. package/dist/components/shimmer.js.map +1 -0
  51. package/dist/components/spinner.d.ts +28 -6
  52. package/dist/components/spinner.d.ts.map +1 -1
  53. package/dist/components/spinner.js +66 -14
  54. package/dist/components/spinner.js.map +1 -1
  55. package/dist/components/stepper.d.ts +64 -0
  56. package/dist/components/stepper.d.ts.map +1 -0
  57. package/dist/components/stepper.js +167 -0
  58. package/dist/components/stepper.js.map +1 -0
  59. package/dist/components/tag-input.d.ts +47 -0
  60. package/dist/components/tag-input.d.ts.map +1 -0
  61. package/dist/components/tag-input.js +211 -0
  62. package/dist/components/tag-input.js.map +1 -0
  63. package/dist/components/time-input.d.ts +75 -0
  64. package/dist/components/time-input.d.ts.map +1 -0
  65. package/dist/components/time-input.js +341 -0
  66. package/dist/components/time-input.js.map +1 -0
  67. package/dist/components/time-select.d.ts +49 -0
  68. package/dist/components/time-select.d.ts.map +1 -0
  69. package/dist/components/time-select.js +178 -0
  70. package/dist/components/time-select.js.map +1 -0
  71. package/dist/components/timeline.d.ts +41 -0
  72. package/dist/components/timeline.d.ts.map +1 -0
  73. package/dist/components/timeline.js +83 -0
  74. package/dist/components/timeline.js.map +1 -0
  75. package/dist/components/toast.d.ts.map +1 -1
  76. package/dist/components/toast.js +4 -2
  77. package/dist/components/toast.js.map +1 -1
  78. package/dist/components/tree.d.ts +87 -0
  79. package/dist/components/tree.d.ts.map +1 -0
  80. package/dist/components/tree.js +516 -0
  81. package/dist/components/tree.js.map +1 -0
  82. package/dist/docs/doc-kit.d.ts +72 -0
  83. package/dist/docs/doc-kit.d.ts.map +1 -0
  84. package/dist/docs/doc-kit.js +45 -0
  85. package/dist/docs/doc-kit.js.map +1 -0
  86. package/dist/docs/doc-page.d.ts +27 -0
  87. package/dist/docs/doc-page.d.ts.map +1 -0
  88. package/dist/docs/doc-page.js +33 -0
  89. package/dist/docs/doc-page.js.map +1 -0
  90. package/dist/docs/docs-index.d.ts +60 -0
  91. package/dist/docs/docs-index.d.ts.map +1 -0
  92. package/dist/docs/docs-index.js +45 -0
  93. package/dist/docs/docs-index.js.map +1 -0
  94. package/dist/docs/docs-nav.d.ts +13 -0
  95. package/dist/docs/docs-nav.d.ts.map +1 -0
  96. package/dist/docs/docs-nav.js +8 -0
  97. package/dist/docs/docs-nav.js.map +1 -0
  98. package/dist/docs/docs-search.d.ts +19 -0
  99. package/dist/docs/docs-search.d.ts.map +1 -0
  100. package/dist/docs/docs-search.js +33 -0
  101. package/dist/docs/docs-search.js.map +1 -0
  102. package/dist/docs/index.d.ts +7 -0
  103. package/dist/docs/index.d.ts.map +1 -0
  104. package/dist/docs/index.js +7 -0
  105. package/dist/docs/index.js.map +1 -0
  106. package/dist/docs/review-matrix.d.ts +25 -0
  107. package/dist/docs/review-matrix.d.ts.map +1 -0
  108. package/dist/docs/review-matrix.js +31 -0
  109. package/dist/docs/review-matrix.js.map +1 -0
  110. package/dist/hooks/use-theme-palette.d.ts +8 -0
  111. package/dist/hooks/use-theme-palette.d.ts.map +1 -0
  112. package/dist/hooks/use-theme-palette.js +24 -0
  113. package/dist/hooks/use-theme-palette.js.map +1 -0
  114. package/dist/hooks/use-time-format.d.ts +23 -0
  115. package/dist/hooks/use-time-format.d.ts.map +1 -0
  116. package/dist/hooks/use-time-format.js +52 -0
  117. package/dist/hooks/use-time-format.js.map +1 -0
  118. package/dist/lib/color.d.ts +5 -1
  119. package/dist/lib/color.d.ts.map +1 -1
  120. package/dist/lib/color.js +14 -2
  121. package/dist/lib/color.js.map +1 -1
  122. package/dist/lib/recipes.d.ts +5 -4
  123. package/dist/lib/recipes.d.ts.map +1 -1
  124. package/dist/lib/recipes.js +7 -5
  125. package/dist/lib/recipes.js.map +1 -1
  126. package/dist/provider/theme-provider.d.ts +10 -1
  127. package/dist/provider/theme-provider.d.ts.map +1 -1
  128. package/dist/provider/theme-provider.js +23 -8
  129. package/dist/provider/theme-provider.js.map +1 -1
  130. package/dist/site/brand.d.ts +20 -0
  131. package/dist/site/brand.d.ts.map +1 -0
  132. package/dist/site/brand.js +17 -0
  133. package/dist/site/brand.js.map +1 -0
  134. package/dist/site/github-icon.d.ts +4 -0
  135. package/dist/site/github-icon.d.ts.map +1 -0
  136. package/dist/site/github-icon.js +6 -0
  137. package/dist/site/github-icon.js.map +1 -0
  138. package/dist/site/index.d.ts +6 -0
  139. package/dist/site/index.d.ts.map +1 -0
  140. package/dist/site/index.js +6 -0
  141. package/dist/site/index.js.map +1 -0
  142. package/dist/site/suite-footer.d.ts +24 -0
  143. package/dist/site/suite-footer.d.ts.map +1 -0
  144. package/dist/site/suite-footer.js +19 -0
  145. package/dist/site/suite-footer.js.map +1 -0
  146. package/dist/site/suite-header.d.ts +40 -0
  147. package/dist/site/suite-header.d.ts.map +1 -0
  148. package/dist/site/suite-header.js +19 -0
  149. package/dist/site/suite-header.js.map +1 -0
  150. package/dist/site/use-page-title.d.ts +3 -0
  151. package/dist/site/use-page-title.d.ts.map +1 -0
  152. package/dist/site/use-page-title.js +8 -0
  153. package/dist/site/use-page-title.js.map +1 -0
  154. package/dist/vite/index.d.ts +65 -0
  155. package/dist/vite/index.d.ts.map +1 -0
  156. package/dist/vite/index.js +242 -0
  157. package/dist/vite/index.js.map +1 -0
  158. package/package.json +39 -3
  159. package/src/components/alert-dialog.tsx +4 -1
  160. package/src/components/alert.tsx +3 -3
  161. package/src/components/badge.tsx +1 -1
  162. package/src/components/button.tsx +1 -1
  163. package/src/components/calendar.tsx +48 -4
  164. package/src/components/callout.tsx +2 -2
  165. package/src/components/combobox.tsx +1 -1
  166. package/src/components/date-picker.tsx +43 -9
  167. package/src/components/description-list.tsx +107 -0
  168. package/src/components/locale.tsx +67 -0
  169. package/src/components/popover.tsx +3 -1
  170. package/src/components/progress.tsx +70 -4
  171. package/src/components/search-dialog.tsx +14 -1
  172. package/src/components/search-trigger.tsx +8 -2
  173. package/src/components/shimmer.tsx +36 -0
  174. package/src/components/spinner.tsx +126 -23
  175. package/src/components/stepper.tsx +346 -0
  176. package/src/components/tag-input.tsx +345 -0
  177. package/src/components/time-input.tsx +578 -0
  178. package/src/components/time-select.tsx +291 -0
  179. package/src/components/timeline.tsx +190 -0
  180. package/src/components/toast.tsx +4 -4
  181. package/src/components/tree.tsx +832 -0
  182. package/src/docs/doc-kit.tsx +176 -0
  183. package/src/docs/doc-page.tsx +126 -0
  184. package/src/docs/docs-index.ts +108 -0
  185. package/src/docs/docs-nav.tsx +47 -0
  186. package/src/docs/docs-search.tsx +88 -0
  187. package/src/docs/index.ts +6 -0
  188. package/src/docs/review-matrix.tsx +67 -0
  189. package/src/hooks/use-theme-palette.ts +25 -0
  190. package/src/hooks/use-time-format.ts +72 -0
  191. package/src/lib/color.ts +19 -2
  192. package/src/lib/recipes.ts +7 -5
  193. package/src/provider/theme-provider.tsx +34 -9
  194. package/src/site/brand.tsx +41 -0
  195. package/src/site/github-icon.tsx +10 -0
  196. package/src/site/index.ts +5 -0
  197. package/src/site/suite-footer.tsx +68 -0
  198. package/src/site/suite-header.tsx +114 -0
  199. package/src/site/use-page-title.ts +8 -0
  200. package/src/styles/kernelkit.css +58 -0
  201. package/src/styles/site.css +15 -0
  202. package/src/vite/client.d.ts +11 -0
  203. package/src/vite/index.ts +298 -0
@@ -0,0 +1,242 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Vite plugins shared by the suite's sites (Node-side: no React, nothing here reaches the browser).
4
+ *
5
+ * ```ts
6
+ * import {docsMetaPlugin, faviconPlugin, spaFallback, suiteSourceConditions, themeScriptPlugin} from "@repraze/kernelkit/vite";
7
+ * ```
8
+ *
9
+ * `vite` is only imported for its types; `typescript` is loaded lazily by docsMetaPlugin / extractFunction.
10
+ */
11
+ import { lstatSync, readdirSync, readFileSync } from "node:fs";
12
+ import { copyFile } from "node:fs/promises";
13
+ import { createRequire } from "node:module";
14
+ import { dirname, join, resolve } from "node:path";
15
+ import { themeScript } from "../provider/theme.js";
16
+ /**
17
+ * Inline the kit's pre-paint theme script into index.html, so the stored mode, contrast, accent and radius
18
+ * apply before first paint. Replaces the marker comment, or goes first in <head> when there is none.
19
+ */
20
+ export function themeScriptPlugin({ storageKey, defaults, marker = "<!-- kernelkit:theme-script -->", prelude, }) {
21
+ const source = [prelude, themeScript({ storageKey, defaults })].filter(Boolean).join("\n");
22
+ return {
23
+ name: "kernelkit-theme-script",
24
+ transformIndexHtml: (html) => html.includes(marker)
25
+ ? html.replace(marker, `<script>${source}</script>`)
26
+ : { html, tags: [{ tag: "script", children: source, injectTo: "head-prepend" }] },
27
+ };
28
+ }
29
+ // ─── favicon ────────────────────────────────────────────────────────────────────────────────────
30
+ /**
31
+ * Serve (dev) and emit (build) `favicon.svg` from the brand mark's SVG, so the icon never drifts from the
32
+ * logo. Link it with `href="%BASE_URL%favicon.svg"` so it works under a Pages base path.
33
+ */
34
+ export function faviconPlugin(svg, fileName = "favicon.svg") {
35
+ const source = typeof svg === "function" ? svg() : svg;
36
+ return {
37
+ name: "kernelkit-favicon",
38
+ configureServer(server) {
39
+ server.middlewares.use((req, res, next) => {
40
+ if (req.url?.split("?")[0]?.endsWith(`/${fileName}`)) {
41
+ res.setHeader("Content-Type", "image/svg+xml");
42
+ res.end(source);
43
+ return;
44
+ }
45
+ next();
46
+ });
47
+ },
48
+ generateBundle() {
49
+ this.emitFile({ type: "asset", fileName, source });
50
+ },
51
+ };
52
+ }
53
+ // ─── SPA fallback ───────────────────────────────────────────────────────────────────────────────
54
+ /** GitHub Pages has no SPA rewrites: copy index.html to 404.html so deep links load the app. */
55
+ export function spaFallback() {
56
+ return {
57
+ name: "kernelkit-spa-fallback",
58
+ apply: "build",
59
+ async writeBundle({ dir }) {
60
+ if (dir) {
61
+ await copyFile(join(dir, "index.html"), join(dir, "404.html"));
62
+ }
63
+ },
64
+ };
65
+ }
66
+ // ─── linked suite packages ──────────────────────────────────────────────────────────────────────
67
+ /** Is `node_modules/<name>` a symlink (npm link, a workspace), looking up from `root`? */
68
+ function isLinked(name, root) {
69
+ for (let dir = resolve(root);; dir = dirname(dir)) {
70
+ try {
71
+ return lstatSync(join(dir, "node_modules", name)).isSymbolicLink();
72
+ }
73
+ catch {
74
+ // not installed here: look in the parent
75
+ }
76
+ if (dirname(dir) === dir) {
77
+ return false;
78
+ }
79
+ }
80
+ }
81
+ const DEDUPE = ["react", "react-dom", "@base-ui/react", "cmdk", "lucide-react"];
82
+ /**
83
+ * For each suite package (`@repraze/kernelkit`…) that is symlinked into node_modules (`npm link`, a
84
+ * workspace): serve it from its TypeScript sources (its `@repraze/source` exports condition), unbundled,
85
+ * so edits there hot-reload; dedupe React-context packages, since a linked package sits outside this tree.
86
+ * Installed from npm: nothing changes, its built dist is used and pre-bundled like any dependency.
87
+ */
88
+ export function suiteSourceConditions(packages, options = {}) {
89
+ const { dedupe = DEDUPE, condition = "@repraze/source" } = options;
90
+ return {
91
+ name: "kernelkit-suite-source-conditions",
92
+ enforce: "pre",
93
+ config(config) {
94
+ const linked = packages.filter((name) => isLinked(name, config.root ?? process.cwd()));
95
+ if (!linked.length) {
96
+ return undefined;
97
+ }
98
+ return {
99
+ resolve: { conditions: [condition, ...DEFAULT_CLIENT_CONDITIONS], dedupe },
100
+ optimizeDeps: { exclude: linked },
101
+ };
102
+ },
103
+ };
104
+ }
105
+ /** Vite's `defaultClientConditions`, inlined so this module needs no runtime import of vite. */
106
+ const DEFAULT_CLIENT_CONDITIONS = ["module", "browser", "development|production"];
107
+ // ─── docs manifest and demo sources ─────────────────────────────────────────────────────────────
108
+ const require = createRequire(import.meta.url);
109
+ let typescript;
110
+ /** TypeScript, loaded on first use (the sites already have it): only docs sites pay for it. */
111
+ const ts = () => (typescript ??= require("typescript"));
112
+ /** Static value of a string/number expression: literals, no-substitution templates, "a" + "b". */
113
+ function literal(node) {
114
+ const t = ts();
115
+ if (t.isStringLiteral(node) || t.isNoSubstitutionTemplateLiteral(node)) {
116
+ return node.text;
117
+ }
118
+ if (t.isNumericLiteral(node)) {
119
+ return Number(node.text);
120
+ }
121
+ if (t.isParenthesizedExpression(node)) {
122
+ return literal(node.expression);
123
+ }
124
+ if (t.isBinaryExpression(node) && node.operatorToken.kind === t.SyntaxKind.PlusToken) {
125
+ const a = literal(node.left);
126
+ const b = literal(node.right);
127
+ return a !== undefined && b !== undefined ? `${a}${b}` : undefined;
128
+ }
129
+ return undefined;
130
+ }
131
+ /** A docs page's manifest entry, read from its `defineDoc({...})` call without running it. */
132
+ export function readDocMeta(file, slug, source = readFileSync(file, "utf8")) {
133
+ const t = ts();
134
+ const sf = t.createSourceFile(file, source, t.ScriptTarget.Latest, true);
135
+ let meta;
136
+ const visit = (node) => {
137
+ if (!meta &&
138
+ t.isCallExpression(node) &&
139
+ t.isIdentifier(node.expression) &&
140
+ node.expression.text === "defineDoc" &&
141
+ node.arguments[0] &&
142
+ t.isObjectLiteralExpression(node.arguments[0])) {
143
+ const props = {};
144
+ for (const p of node.arguments[0].properties) {
145
+ if (t.isPropertyAssignment(p) && t.isIdentifier(p.name)) {
146
+ props[p.name.text] = literal(p.initializer);
147
+ }
148
+ }
149
+ if (typeof props.title !== "string" || typeof props.category !== "string") {
150
+ throw new Error(`${file}: defineDoc needs literal "title" and "category" (read at build time)`);
151
+ }
152
+ meta = {
153
+ slug,
154
+ title: props.title,
155
+ category: props.category,
156
+ description: typeof props.description === "string" ? props.description : "",
157
+ ...(typeof props.order === "number" ? { order: props.order } : {}),
158
+ };
159
+ }
160
+ t.forEachChild(node, visit);
161
+ };
162
+ visit(sf);
163
+ if (!meta) {
164
+ throw new Error(`${file}: no defineDoc({...}) call found`);
165
+ }
166
+ return meta;
167
+ }
168
+ /** Each top-level function or const of a file, by name, as written (without `export `). */
169
+ export function extractFunctions(source, fileName = "doc.tsx") {
170
+ const t = ts();
171
+ const sf = t.createSourceFile(fileName, source, t.ScriptTarget.Latest, true, t.ScriptKind.TSX);
172
+ const out = {};
173
+ const text = (node) => source.slice(node.getStart(sf), node.getEnd()).replace(/^export /, "");
174
+ for (const statement of sf.statements) {
175
+ if (t.isFunctionDeclaration(statement) && statement.name) {
176
+ out[statement.name.text] = text(statement);
177
+ }
178
+ else if (t.isVariableStatement(statement)) {
179
+ for (const decl of statement.declarationList.declarations) {
180
+ if (t.isIdentifier(decl.name)) {
181
+ out[decl.name.text] = text(statement);
182
+ }
183
+ }
184
+ }
185
+ }
186
+ return out;
187
+ }
188
+ /**
189
+ * A demo's own source: its declaration from `export function Name` (or `export const Name`) to its
190
+ * closing brace, parsed with TypeScript, so code after it (a `Notes()` helper, constants) stays out.
191
+ */
192
+ export function extractFunction(source, name) {
193
+ return extractFunctions(source)[name] ?? "";
194
+ }
195
+ const META_ID = "virtual:docs-meta";
196
+ const META_RESOLVED = `\0${META_ID}`;
197
+ const SOURCES_QUERY = "demo-sources";
198
+ /**
199
+ * The docs build step, for `@repraze/kernelkit/docs`:
200
+ * - `virtual:docs-meta`: title, category, description and order of every page in `docsDir`, read
201
+ * statically from its `defineDoc({...})` call, so the nav and search don't pull every page's demos into
202
+ * the main bundle;
203
+ * - `<page>.tsx?demo-sources`: `{functions}`, each demo's own source for its Code tab (see extractFunction).
204
+ *
205
+ * Types: add `@repraze/kernelkit/vite/client` to the site's tsconfig `types`.
206
+ */
207
+ export function docsMetaPlugin(docsDir) {
208
+ const dir = resolve(docsDir);
209
+ return {
210
+ name: "kernelkit-docs-meta",
211
+ enforce: "pre",
212
+ resolveId: (id) => (id === META_ID ? META_RESOLVED : undefined),
213
+ load(id) {
214
+ if (id === META_RESOLVED) {
215
+ const files = readdirSync(dir).filter((f) => f.endsWith(".tsx"));
216
+ const metas = files.map((f) => {
217
+ const file = join(dir, f);
218
+ this.addWatchFile(file);
219
+ return readDocMeta(file, f.replace(/\.tsx$/, ""));
220
+ });
221
+ return `export default ${JSON.stringify(metas)};`;
222
+ }
223
+ const [file = "", query = ""] = id.split("?");
224
+ if (query.split("&").includes(SOURCES_QUERY)) {
225
+ this.addWatchFile(file);
226
+ const functions = extractFunctions(readFileSync(file, "utf8"), file);
227
+ return { code: `export default ${JSON.stringify({ functions })};`, moduleType: "js" };
228
+ }
229
+ return undefined;
230
+ },
231
+ // a docs page added, removed or retitled → refresh the manifest
232
+ handleHotUpdate({ file, server }) {
233
+ if (file.startsWith(dir)) {
234
+ const mod = server.moduleGraph.getModuleById(META_RESOLVED);
235
+ if (mod) {
236
+ server.moduleGraph.invalidateModule(mod);
237
+ }
238
+ }
239
+ },
240
+ };
241
+ }
242
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B;;;;;;;;GAQG;AACH,OAAO,EAAC,SAAS,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAKjD,OAAO,EAAC,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAelE;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAC9B,UAAU,EACV,QAAQ,EACR,MAAM,GAAG,iCAAiC,EAC1C,OAAO,GACgB;IACvB,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,EAAC,UAAU,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,OAAO;QACH,IAAI,EAAE,wBA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AAO,EAAC,IAAI,EAAE,kBAAkB,IAAI,CAAC,SAAS,CAAC,EAAC,SAAS,EAAC,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;YACtF,CAAC;YACD,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,gEAAgE;QAChE,eAAe,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC;YAC1B,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;gBAC5D,IAAI,GAAG,EAAE,CAAC;oBACN,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;gBAC7C,CAAC;YACL,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repraze/kernelkit",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "Modern, techy React components: every shadcn component on Base UI, Tailwind v4 and cva, themed by TermiColor.",
5
5
  "keywords": [
6
6
  "react",
@@ -56,7 +56,26 @@
56
56
  "types": "./dist/provider/theme.d.ts",
57
57
  "default": "./dist/provider/theme.js"
58
58
  },
59
+ "./docs": {
60
+ "@repraze/source": "./src/docs/index.ts",
61
+ "types": "./dist/docs/index.d.ts",
62
+ "default": "./dist/docs/index.js"
63
+ },
64
+ "./site": {
65
+ "@repraze/source": "./src/site/index.ts",
66
+ "types": "./dist/site/index.d.ts",
67
+ "default": "./dist/site/index.js"
68
+ },
69
+ "./vite": {
70
+ "@repraze/source": "./src/vite/index.ts",
71
+ "types": "./dist/vite/index.d.ts",
72
+ "default": "./dist/vite/index.js"
73
+ },
74
+ "./vite/client": {
75
+ "types": "./src/vite/client.d.ts"
76
+ },
59
77
  "./styles.css": "./src/styles/kernelkit.css",
78
+ "./site.css": "./src/styles/site.css",
60
79
  "./package.json": "./package.json"
61
80
  },
62
81
  "files": [
@@ -83,7 +102,11 @@
83
102
  "input-otp": "^1.5.0",
84
103
  "react-resizable-panels": "^4.19.1",
85
104
  "@tanstack/react-virtual": "^3.14.26",
86
- "@shadcn/react": "^0.3.1"
105
+ "@shadcn/react": "^0.3.1",
106
+ "@fontsource-variable/geist": "^5.2.0",
107
+ "@fontsource-variable/jetbrains-mono": "^5.2.0",
108
+ "typescript": ">=5.0",
109
+ "vite": ">=7.0"
87
110
  },
88
111
  "peerDependenciesMeta": {
89
112
  "recharts": {
@@ -115,6 +138,18 @@
115
138
  },
116
139
  "@shadcn/react": {
117
140
  "optional": true
141
+ },
142
+ "@fontsource-variable/geist": {
143
+ "optional": true
144
+ },
145
+ "@fontsource-variable/jetbrains-mono": {
146
+ "optional": true
147
+ },
148
+ "typescript": {
149
+ "optional": true
150
+ },
151
+ "vite": {
152
+ "optional": true
118
153
  }
119
154
  },
120
155
  "dependencies": {
@@ -141,6 +176,7 @@
141
176
  "input-otp": "^1.5.0",
142
177
  "react-resizable-panels": "^4.19.1",
143
178
  "@tanstack/react-virtual": "^3.14.26",
144
- "@shadcn/react": "^0.3.1"
179
+ "@shadcn/react": "^0.3.1",
180
+ "vite": "^8.3.6"
145
181
  }
146
182
  }
@@ -93,7 +93,10 @@ function AlertDialogMedia({
93
93
  data-color={color}
94
94
  className={cn(
95
95
  "mb-2 inline-flex size-10 items-center justify-center rounded-lg border border-border bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-5",
96
- color && [colorVariants[color], "border-(--c)/40 bg-(--c-tint) text-foreground *:[svg]:text-(--c)"],
96
+ color && [
97
+ colorVariants[color],
98
+ "border-(--c)/40 bg-(--c-tint) text-foreground *:[svg]:text-(--c-soft-text)",
99
+ ],
97
100
  className,
98
101
  )}
99
102
  {...props}
@@ -17,8 +17,8 @@ const alertCva = cva(
17
17
  variants: {
18
18
  color: colorVariants,
19
19
  variant: {
20
- soft: [statusSurface.soft, "text-foreground *:[svg]:text-(--c)"],
21
- outline: [statusSurface.outline, "text-card-foreground *:[svg]:text-(--c)"],
20
+ soft: [statusSurface.soft, "text-foreground *:[svg]:text-(--c-text)"],
21
+ outline: [statusSurface.outline, "text-card-foreground *:[svg]:text-(--c-text)"],
22
22
  },
23
23
  },
24
24
  compoundVariants: [
@@ -73,7 +73,7 @@ function AlertTitle({className, ...props}: React.ComponentProps<"div">) {
73
73
  data-slot="alert-title"
74
74
  className={cn(
75
75
  heading,
76
- "group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-(--c)",
76
+ "group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-(--c-text)",
77
77
  className,
78
78
  )}
79
79
  {...props}
@@ -25,7 +25,7 @@ const badgeCva = cva(
25
25
  color: colorVariants,
26
26
  variant: {
27
27
  solid: "bg-(--c-fill) text-(--c-fill-fg) [a]:hover:bg-(--c-fill)/85",
28
- soft: "bg-(--c)/12 text-(--c) dark:bg-(--c)/20 [a]:hover:bg-(--c)/20 dark:[a]:hover:bg-(--c)/30",
28
+ soft: "bg-(--c)/12 text-(--c-soft-text) dark:bg-(--c)/20 [a]:hover:bg-(--c)/20 dark:[a]:hover:bg-(--c)/30",
29
29
  outline: "border-border text-foreground [a]:hover:bg-hover",
30
30
  ghost: "text-foreground [a]:hover:bg-hover",
31
31
  link: "text-(--c) underline-offset-4 hover:underline",
@@ -27,7 +27,7 @@ const buttonCva = cva(
27
27
  color: colorVariants,
28
28
  variant: {
29
29
  solid: "bg-(--c-fill) text-(--c-fill-fg) hover:bg-(--c-fill)/85 aria-expanded:bg-(--c-fill)/85",
30
- soft: "bg-(--c)/12 text-(--c) hover:bg-(--c)/20 aria-expanded:bg-(--c)/20 dark:bg-(--c)/20 dark:hover:bg-(--c)/30",
30
+ soft: "bg-(--c)/12 text-(--c-soft-text) hover:bg-(--c)/20 aria-expanded:bg-(--c)/20 dark:bg-(--c)/20 dark:hover:bg-(--c)/30",
31
31
  outline: "border-input bg-transparent hover:bg-hover aria-expanded:bg-hover",
32
32
  ghost: "text-foreground hover:bg-hover aria-expanded:bg-hover",
33
33
  link: "text-(--c) underline-offset-4 hover:underline",
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import {Button, buttonVariants} from "@repraze/kernelkit/components/button";
4
+ import {useLocale, weekStart} from "@repraze/kernelkit/components/locale";
4
5
  import {cn} from "cn";
5
6
  import {ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon} from "lucide-react";
6
7
  import * as React from "react";
@@ -13,6 +14,37 @@ import {type DayButton, DayPicker, getDefaultClassNames, type Locale} from "reac
13
14
  * - today: primary dot under the number + medium weight
14
15
  * - outside days: muted text; disabled: muted text + line-through
15
16
  */
17
+ /** DayPicker props minus `locale`, keeping the `mode` union intact (a plain Omit would collapse it). */
18
+ type CalendarBaseProps =
19
+ React.ComponentProps<typeof DayPicker> extends infer P ? (P extends unknown ? Omit<P, "locale"> : never) : never;
20
+
21
+ /** DayPicker formatters from Intl: the caption, weekday names, day numbers (native digits) and dropdowns. */
22
+ function intlFormatters(locale: string) {
23
+ try {
24
+ const caption = new Intl.DateTimeFormat(locale, {month: "long", year: "numeric"});
25
+ // "short" is the full name in some languages (Arabic): fall back to "narrow" when it won't fit a cell
26
+ const short = new Intl.DateTimeFormat(locale, {weekday: "short"});
27
+ const long = Array.from({length: 7}, (_, i) => short.format(new Date(2000, 0, 2 + i))).some(
28
+ (d) => d.length > 4,
29
+ );
30
+ const weekday = long ? new Intl.DateTimeFormat(locale, {weekday: "narrow"}) : short;
31
+ const day = new Intl.DateTimeFormat(locale, {day: "numeric"});
32
+ const month = new Intl.DateTimeFormat(locale, {month: "short"});
33
+ const year = new Intl.DateTimeFormat(locale, {year: "numeric"});
34
+ return {
35
+ formatCaption: (date: Date) => caption.format(date),
36
+ formatWeekdayName: (date: Date) => weekday.format(date),
37
+ // the day part only: ja formats "14日", the grid wants "14" (native digits kept: "١٤" in ar-EG)
38
+ formatDay: (date: Date) =>
39
+ day.formatToParts(date).find((p) => p.type === "day")?.value ?? String(date.getDate()),
40
+ formatMonthDropdown: (date: Date) => month.format(date),
41
+ formatYearDropdown: (date: Date) => year.format(date),
42
+ };
43
+ } catch {
44
+ return {};
45
+ }
46
+ }
47
+
16
48
  function Calendar({
17
49
  className,
18
50
  classNames,
@@ -22,11 +54,20 @@ function Calendar({
22
54
  locale,
23
55
  formatters,
24
56
  components,
57
+ weekStartsOn,
25
58
  ...props
26
- }: React.ComponentProps<typeof DayPicker> & {
59
+ }: CalendarBaseProps & {
27
60
  buttonVariant?: React.ComponentProps<typeof Button>["variant"];
61
+ /**
62
+ * A BCP 47 tag (`"fr-FR"`) or nothing: month and weekday names, digits and the first day of the week
63
+ * come from `Intl` (prop › LocaleProvider › browser). A date-fns `Locale` object uses date-fns instead.
64
+ */
65
+ locale?: Partial<Locale> | string;
28
66
  }) {
29
67
  const defaultClassNames = getDefaultClassNames();
68
+ const dateFnsLocale = typeof locale === "object" ? locale : undefined;
69
+ const tag = useLocale(typeof locale === "string" ? locale : undefined);
70
+ const intl = React.useMemo(() => (dateFnsLocale ? null : intlFormatters(tag)), [dateFnsLocale, tag]);
30
71
 
31
72
  return (
32
73
  <DayPicker
@@ -38,9 +79,12 @@ function Calendar({
38
79
  className,
39
80
  )}
40
81
  captionLayout={captionLayout}
41
- locale={locale}
82
+ locale={dateFnsLocale}
83
+ lang={dateFnsLocale ? undefined : tag}
84
+ weekStartsOn={weekStartsOn ?? (dateFnsLocale ? undefined : weekStart(tag))}
42
85
  formatters={{
43
- formatMonthDropdown: (date) => date.toLocaleString(locale?.code, {month: "short"}),
86
+ formatMonthDropdown: (date) => date.toLocaleString(dateFnsLocale?.code ?? tag, {month: "short"}),
87
+ ...intl,
44
88
  ...formatters,
45
89
  }}
46
90
  classNames={{
@@ -128,7 +172,7 @@ function Calendar({
128
172
 
129
173
  return <ChevronDownIcon className={cn("size-4", className)} {...props} />;
130
174
  },
131
- DayButton: ({...props}) => <CalendarDayButton locale={locale} {...props} />,
175
+ DayButton: ({...props}) => <CalendarDayButton locale={dateFnsLocale} {...props} />,
132
176
  WeekNumber: ({children, ...props}) => {
133
177
  return (
134
178
  <td {...props}>
@@ -41,10 +41,10 @@ const calloutVariants = cva(
41
41
  );
42
42
 
43
43
  const calloutHeader =
44
- "flex min-h-8 w-full items-center gap-1.5 py-1.5 pr-3 pl-4 text-left text-xs text-(--c) group-data-[color=neutral]/callout:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5";
44
+ "flex min-h-8 w-full items-center gap-1.5 py-1.5 pr-3 pl-4 text-left text-xs text-(--c-text) group-data-[color=neutral]/callout:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5";
45
45
 
46
46
  const calloutBody =
47
- "py-2 pr-3 pl-4 text-sm leading-relaxed [&_a]:text-(--c) [&_a]:underline [&_a]:underline-offset-3 group-data-[color=neutral]/callout:[&_a]:text-foreground [&_p:not(:last-child)]:mb-2 border-(--callout-line)";
47
+ "py-2 pr-3 pl-4 text-sm leading-relaxed [&_a]:text-(--c-text) [&_a]:underline [&_a]:underline-offset-3 group-data-[color=neutral]/callout:[&_a]:text-foreground [&_p:not(:last-child)]:mb-2 border-(--callout-line)";
48
48
 
49
49
  interface CalloutProps extends Omit<React.ComponentProps<"div">, "color" | "title"> {
50
50
  /** Status or hue of the indicator, header and border. */
@@ -229,7 +229,7 @@ function ComboboxChip({
229
229
  <ComboboxPrimitive.Chip
230
230
  data-slot="combobox-chip"
231
231
  className={cn(
232
- "flex h-5.5 w-fit items-center justify-center gap-1 rounded-md border border-border bg-secondary px-1.5 text-xs font-medium whitespace-nowrap text-secondary-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0 outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50",
232
+ "flex h-5.5 w-fit items-center justify-center gap-1 rounded-md border border-border bg-foreground/10 px-1.5 text-xs font-medium whitespace-nowrap text-foreground hc:bg-transparent has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0 outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50",
233
233
  className,
234
234
  )}
235
235
  {...props}
@@ -2,6 +2,7 @@
2
2
 
3
3
  import {Button} from "@repraze/kernelkit/components/button";
4
4
  import {Calendar} from "@repraze/kernelkit/components/calendar";
5
+ import {useLocale} from "@repraze/kernelkit/components/locale";
5
6
  import {Popover, PopoverContent, PopoverTrigger} from "@repraze/kernelkit/components/popover";
6
7
  import {cn} from "cn";
7
8
  import {format as formatDate} from "date-fns";
@@ -14,8 +15,13 @@ type CalendarProps = React.ComponentProps<typeof Calendar>;
14
15
  interface DatePickerBaseProps {
15
16
  /** Trigger text when nothing is picked. */
16
17
  placeholder?: React.ReactNode;
17
- /** date-fns format string for the trigger label. */
18
- format?: string;
18
+ /**
19
+ * Trigger label: `Intl.DateTimeFormat` options (default `{dateStyle: "long"}`, `"medium"` for ranges), a
20
+ * function, or a date-fns pattern string.
21
+ */
22
+ format?: DateFormat;
23
+ /** BCP 47 tag for the label and the calendar; defaults to LocaleProvider › browser. */
24
+ locale?: string;
19
25
  size?: "sm" | "default" | "lg";
20
26
  disabled?: boolean;
21
27
  "aria-invalid"?: boolean;
@@ -27,6 +33,27 @@ interface DatePickerBaseProps {
27
33
  align?: "start" | "center" | "end";
28
34
  }
29
35
 
36
+ type DateFormat = Intl.DateTimeFormatOptions | string | ((date: Date) => string);
37
+
38
+ /** One date in the trigger. */
39
+ function formatOne(date: Date, format: DateFormat, locale: string) {
40
+ if (typeof format === "function") {
41
+ return format(date);
42
+ }
43
+ if (typeof format === "string") {
44
+ return formatDate(date, format);
45
+ }
46
+ return new Intl.DateTimeFormat(locale, format).format(date);
47
+ }
48
+
49
+ /** A range in the trigger: Intl's formatRange shares what both ends have in common ("Nov 14 – 20, 2026"). */
50
+ function formatRange(from: Date, to: Date, format: DateFormat, locale: string) {
51
+ if (typeof format === "object") {
52
+ return new Intl.DateTimeFormat(locale, format).formatRange(from, to);
53
+ }
54
+ return `${formatOne(from, format, locale)} – ${formatOne(to, format, locale)}`;
55
+ }
56
+
30
57
  function useControllable<T>(value: T | undefined, defaultValue: T | undefined, onChange?: (value: T) => void) {
31
58
  const [inner, setInner] = React.useState(defaultValue);
32
59
  const controlled = value !== undefined;
@@ -59,7 +86,8 @@ function DatePickerTrigger({
59
86
  variant="outline"
60
87
  size={size}
61
88
  className={cn(
62
- "w-60 justify-start text-left font-normal data-empty:text-muted-foreground data-popup-open:bg-hover [&>svg]:text-muted-foreground",
89
+ // a field like Select's trigger, not an outline button: it sits beside inputs and TimeInput
90
+ "w-60 justify-start bg-field text-start font-normal hover:bg-field-hover aria-expanded:bg-field-hover data-empty:text-muted-foreground data-popup-open:bg-field-hover [&>svg]:text-muted-foreground",
63
91
  className,
64
92
  )}
65
93
  {...props}
@@ -84,7 +112,8 @@ function DatePicker({
84
112
  defaultValue = null,
85
113
  onValueChange,
86
114
  placeholder = "Pick a date",
87
- format = "PPP",
115
+ format = {dateStyle: "long"},
116
+ locale: localeProp,
88
117
  calendarProps,
89
118
  align = "start",
90
119
  className,
@@ -92,17 +121,19 @@ function DatePicker({
92
121
  }: DatePickerProps) {
93
122
  const [open, setOpen] = React.useState(false);
94
123
  const [date, setDate] = useControllable<Date | null>(value, defaultValue, onValueChange);
124
+ const locale = useLocale(localeProp);
95
125
 
96
126
  return (
97
127
  <Popover open={open} onOpenChange={setOpen}>
98
128
  <DatePickerTrigger
99
- label={date ? formatDate(date, format) : undefined}
129
+ label={date ? formatOne(date, format, locale) : undefined}
100
130
  placeholder={placeholder}
101
131
  className={className}
102
132
  {...trigger}
103
133
  />
104
134
  <PopoverContent data-slot="date-picker-content" className="w-auto p-0" align={align}>
105
135
  <Calendar
136
+ locale={locale}
106
137
  {...calendarProps}
107
138
  mode="single"
108
139
  selected={date ?? undefined}
@@ -131,7 +162,8 @@ function DateRangePicker({
131
162
  defaultValue = null,
132
163
  onValueChange,
133
164
  placeholder = "Pick a date range",
134
- format = "LLL d, y",
165
+ format = {dateStyle: "medium"},
166
+ locale: localeProp,
135
167
  numberOfMonths = 2,
136
168
  calendarProps,
137
169
  align = "start",
@@ -139,10 +171,11 @@ function DateRangePicker({
139
171
  ...trigger
140
172
  }: DateRangePickerProps) {
141
173
  const [range, setRange] = useControllable<DateRange | null>(value, defaultValue, onValueChange);
174
+ const locale = useLocale(localeProp);
142
175
  const label = range?.from
143
176
  ? range.to
144
- ? `${formatDate(range.from, format)} – ${formatDate(range.to, format)}`
145
- : formatDate(range.from, format)
177
+ ? formatRange(range.from, range.to, format, locale)
178
+ : formatOne(range.from, format, locale)
146
179
  : undefined;
147
180
 
148
181
  return (
@@ -150,6 +183,7 @@ function DateRangePicker({
150
183
  <DatePickerTrigger label={label} placeholder={placeholder} className={cn("w-72", className)} {...trigger} />
151
184
  <PopoverContent data-slot="date-picker-content" className="w-auto p-0" align={align}>
152
185
  <Calendar
186
+ locale={locale}
153
187
  {...calendarProps}
154
188
  mode="range"
155
189
  numberOfMonths={numberOfMonths}
@@ -163,4 +197,4 @@ function DateRangePicker({
163
197
  }
164
198
 
165
199
  export {DatePicker, DatePickerTrigger, DateRangePicker};
166
- export type {DatePickerProps, DateRangePickerProps};
200
+ export type {DateFormat, DatePickerProps, DateRangePickerProps};