@thebase/ui 1.1.7 → 1.2.1

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 (56) hide show
  1. package/CHANGELOG.md +70 -1
  2. package/README.md +22 -4
  3. package/bin/create-baseui-app.mjs +28 -2
  4. package/dist/baseui.apidoc.esm.js +64 -64
  5. package/dist/baseui.apidoc.min.js +64 -64
  6. package/dist/baseui.esm.js +42 -61
  7. package/dist/baseui.i18n.esm.js +2 -0
  8. package/dist/baseui.i18n.min.js +2 -0
  9. package/dist/baseui.icons.esm.js +1 -1
  10. package/dist/baseui.min.css +2 -2
  11. package/dist/baseui.min.js +61 -61
  12. package/dist/baseui.pwa.esm.js +71 -9
  13. package/dist/baseui.registry.json +13 -9
  14. package/dist/baseui.templates.xml +311 -311
  15. package/dist/baseui.vite.esm.js +116 -0
  16. package/dist/runtime/lazy/apidoc.logic.js +20 -0
  17. package/dist/runtime/milkdown/milkdown-editor.js +1 -1
  18. package/dist/runtime/milkdown/milkdown-text-editor.js +1 -1
  19. package/dist/themes/baseui-dark.css +80 -1
  20. package/dist/themes/baseui-dark.min.css +1 -0
  21. package/dist/themes/baseui-light.css +81 -1
  22. package/dist/themes/baseui-light.min.css +1 -0
  23. package/dist/types/i18n.d.ts +25 -0
  24. package/dist/types/index.d.ts +2 -0
  25. package/dist/types/pwa.d.ts +1 -45
  26. package/dist/types/vite.d.ts +4 -0
  27. package/docs/analytics.md +3 -3
  28. package/docs/base-ui-skill.md +54 -0
  29. package/docs/blocks.md +1 -1
  30. package/docs/components/accordion.md +4 -4
  31. package/docs/components/apidoc.md +1 -1
  32. package/docs/components/block-viewer.md +1 -1
  33. package/docs/components/breadcrumb.md +1 -1
  34. package/docs/components/button.md +1 -1
  35. package/docs/components/code-editor.md +1 -1
  36. package/docs/components/data-table.md +2 -2
  37. package/docs/components/dialog.md +5 -5
  38. package/docs/components/form.md +29 -29
  39. package/docs/components/input.md +1 -1
  40. package/docs/components/markdown.md +1 -1
  41. package/docs/components/pwa.md +1 -1
  42. package/docs/components/shell.md +2 -2
  43. package/docs/components/sidebar.md +16 -16
  44. package/docs/components/text-editor.md +1 -1
  45. package/docs/components/theme-button.md +1 -1
  46. package/docs/components/toast.md +10 -10
  47. package/docs/components/typography.md +21 -2
  48. package/docs/i18n.md +119 -0
  49. package/docs/icons.md +1 -1
  50. package/docs/installation.md +3 -2
  51. package/docs/owl-components.md +1 -1
  52. package/docs/registry.md +1 -0
  53. package/docs/runtime-api.md +5 -3
  54. package/docs/theming.md +33 -3
  55. package/docs/usage-guide.md +23 -6
  56. package/package.json +13 -1
package/docs/i18n.md ADDED
@@ -0,0 +1,119 @@
1
+ # i18n service
2
+
3
+ Instructions for adding translations to a page or app with the Base UI i18n service (`@thebase/ui/i18n`). It is optional and standalone: no Owl, Bootstrap or component runtime, and it is not part of the main bundles.
4
+
5
+ - **Audience:** developers adding a language switcher or translating an existing page.
6
+ - **Runnable example:** `examples/i18n/` (open `/examples/i18n/` from `npm run dev`).
7
+ - **Real-world use:** `emvhub/i18n.js` and the `i18n/*.po` folders beside each emvhub module.
8
+
9
+ ## 1. How it works
10
+
11
+ You write every text in the default language and wrap it in `t()`. Each module keeps its translations in an `i18n/<code>.po` folder next to it and loads them with `loadCatalog(import.meta.url)`. The service picks one language per page load and fills a shared lookup; `t()` returns the translation, or the original text when none exists.
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ A["init(config)"] --> B["loadCatalog(import.meta.url)"]
16
+ B --> C{"Pick language"}
17
+ C -->|"?lang= → saved choice → browser → default"| D["Fetch ./i18n/code.po"]
18
+ D --> E["Finished entries join the lookup"]
19
+ E --> F["t(text) returns translation"]
20
+ G["setLanguage(code)"] -->|"saves choice, reloads"| B
21
+ ```
22
+
23
+ ## 2. Install
24
+
25
+ | How you load it | Use |
26
+ | --- | --- |
27
+ | ES module | `import { init, t, loadCatalog } from "@thebase/ui/i18n"` (file: `dist/baseui.i18n.esm.js`) |
28
+ | Import map | map `@base/i18n` to the ESM file, then `import … from "@base/i18n"` |
29
+ | Script tag | `dist/baseui.i18n.min.js` sets `window.thebase.i18n` |
30
+
31
+ ## 3. Quick start
32
+
33
+ 1. Map the module in your HTML:
34
+
35
+ ```html
36
+ <script type="importmap">
37
+ { "imports": { "@base/i18n": "https://cdn.jsdelivr.net/npm/@thebase/ui@<version>/dist/baseui.i18n.esm.js" } }
38
+ </script>
39
+ ```
40
+
41
+ 2. Configure once, then load the catalog next to your module:
42
+
43
+ ```js
44
+ import { init, t, loadCatalog, languages, currentLanguage, setLanguage, translateHead } from "@base/i18n";
45
+
46
+ init({ languages: [{ code: "en", label: "English" }, { code: "vi", label: "Tiếng Việt" }], storageKey: "my-lang" });
47
+ await loadCatalog(import.meta.url); // fetches ./i18n/vi.po when Vietnamese is picked
48
+ translateHead();
49
+ document.querySelector("h1").textContent = t("Hello {name}", { name: "An" });
50
+ ```
51
+
52
+ 3. Add `i18n/vi.po` beside the module:
53
+
54
+ ```po
55
+ msgid ""
56
+ msgstr "Language: vi\n"
57
+
58
+ msgid "Hello {name}"
59
+ msgstr "Xin chào {name}"
60
+ ```
61
+
62
+ ## 4. API reference
63
+
64
+ | Function | Purpose |
65
+ | --- | --- |
66
+ | `init(options)` | Sets languages and defaults. Call once, before the first `loadCatalog()`; it throws afterwards. |
67
+ | `loadCatalog(moduleUrl)` | Picks the language on the first call, then fetches `<catalogDir>/<code>.po` next to `moduleUrl` once. Returns a promise; await it before using `t()`. No request is made for the default language. |
68
+ | `t(text, params?)` | Returns the translation or the original text; replaces `{name}` placeholders from `params`. |
69
+ | `languages()` | The configured `{ code, label }` list, for a switcher. |
70
+ | `currentLanguage()` | The code in use, to mark the active switcher item. |
71
+ | `setLanguage(code)` | Saves the choice and reloads the page with `?lang=<code>`. |
72
+ | `translateHead()` | Translates `document.title` and the meta description. |
73
+ | `parsePo(text)` | Parses `.po` text into a `Map` of original text → `{ id, str, fuzzy }` (useful in tooling and tests). |
74
+
75
+ ### `init()` options
76
+
77
+ | Option | Default | Meaning |
78
+ | --- | --- | --- |
79
+ | `languages` | `[{ code: "en", label: "English" }]` | Languages the page can show; `code` is the `.po` file name, `label` is shown in the language's own words. |
80
+ | `defaultLanguage` | first language | The language your texts are written in; no catalog is loaded for it. |
81
+ | `storageKey` | `"thebase-lang"` | `localStorage` key that remembers the visitor's choice. |
82
+ | `queryParam` | `"lang"` | URL parameter that forces a language. |
83
+ | `catalogDir` | `"i18n"` | Folder beside each module that holds the `.po` files. |
84
+ | `headDescription` | `meta[name="description"]` | Selector of the tag `translateHead()` translates. |
85
+
86
+ Language order: URL parameter, saved choice, browser languages (first two letters), default.
87
+
88
+ ## 5. Writing `.po` files
89
+
90
+ - One block per text: `msgid` (original, exact match) and `msgstr` (translation). Long texts may continue on following quoted lines.
91
+ - Entries with an empty `msgstr` or a `#, fuzzy` flag are ignored, so unfinished work never reaches visitors.
92
+ - Text matching is exact and case-sensitive. Changing a source string in code means updating its `msgid`.
93
+ - Keep placeholders identical in both: `{name}` in the `msgid` must appear as `{name}` in the `msgstr`.
94
+ - Never build a sentence from joined fragments; use one text with placeholders.
95
+
96
+ ## 6. Multi-module apps
97
+
98
+ Each module loads its own catalog, but language selection and `init()` must happen once and first. Create one local file that every module imports:
99
+
100
+ ```js
101
+ // i18n.js
102
+ import { init } from "@base/i18n";
103
+
104
+ init({ languages: [{ code: "en", label: "English" }, { code: "vi", label: "Tiếng Việt" }], storageKey: "my-lang" });
105
+ export * from "@base/i18n";
106
+ ```
107
+
108
+ Because ES modules evaluate dependencies first, `init()` runs before any module's top-level `await loadCatalog(import.meta.url)`. A module that shares another folder's texts loads both: `await Promise.all([loadCatalog(import.meta.url), loadCatalog(new URL("../lib/", import.meta.url))])`.
109
+
110
+ ## 7. Gotchas
111
+
112
+ | Symptom | Cause and fix |
113
+ | --- | --- |
114
+ | `init() must be called before the first loadCatalog()` | A module loaded a catalog first. Route all imports through the single local file above. |
115
+ | Texts stay in English | The `msgid` differs from the code string, the entry is fuzzy or empty, or the `.po` URL 404s (check `catalogDir` and `moduleUrl`). Failed fetches are silent by design. |
116
+ | Module-level texts untranslated | `t()` ran before `await loadCatalog(...)` finished. Await it at the top of the module. |
117
+ | Switching language reloads the page | By design: every text is redrawn in the new language. |
118
+ | Choice not remembered | Storage is blocked; the `?lang=` link still works for that visit. |
119
+ | Offline/PWA | Precache each `i18n/<code>.po` in your service worker (see `emvhub/baseui.pwa.config.js`). |
package/docs/icons.md CHANGED
@@ -22,7 +22,7 @@ Load the normal the Base UI assets. No separate icon script is required.
22
22
  <script src="https://cdn.jsdelivr.net/npm/@thebase/ui@latest/dist/baseui.min.js" defer></script>
23
23
  ```
24
24
 
25
- `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable. Pin an exact version (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) instead of `@latest` for production. `b-icon` also works with the [pure Base `Icon` component](components/icon.md) — the recommended API in an application; the classic script above is for pages using the static `b-ui` API.
25
+ `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable. Pin an exact version (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) instead of `@latest` for production. `b-icon` also works with the [pure Base `Icon` component](components/icon.md) — the recommended API in an application; the classic script above is for pages using the static `b-ui` API.
26
26
 
27
27
  The build publishes every Lucide SVG to `dist/icons/lucide/` and writes the generated icon manifest to `dist/icons/lucide.json`.
28
28
 
@@ -4,7 +4,7 @@ See the [Usage Guide](usage-guide.md) for the end-to-end integration path (choos
4
4
 
5
5
  The Base UI is distributed as one CSS file and one JavaScript file for browser use. `dist/baseui.min.js` is fully self-contained: Bootstrap's JS bundle (Popper.js included) and the Owl runtime are embedded ahead of the Base UI's own code, in load order (Bootstrap, then Owl, then the Base UI) — nothing else needs to load first. Both install paths below load this same file; the Base component API is the recommended way to consume the Base UI in an application, with the base static markup (`b-ui`) API available as a lighter-weight alternative for non-Owl pages.
6
6
 
7
- The snippets below use the `@latest` tag for readability. Pin an exact version instead (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) for any production page — `@latest` can silently change what your page loads the moment a new version is published.
7
+ The snippets below use the `@latest` tag for readability. Pin an exact version instead (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) for any production page — `@latest` can silently change what your page loads the moment a new version is published.
8
8
 
9
9
  ## Base component install (recommended)
10
10
 
@@ -43,7 +43,7 @@ For static HTML, a server-rendered page, or a Base HUB website page that has no
43
43
 
44
44
  Bootstrap 5 is the bundled baseline CSS framework, and its JS bundle now drives the Base UI's interactive components directly.
45
45
 
46
- `@thebase/ui` is published on npm, so [unpkg](https://unpkg.com/@thebase/ui@latest/) mirrors the same files as an alternative CDN (`https://unpkg.com/@thebase/ui@latest/dist/baseui.min.css` / `baseui.min.js`) if jsDelivr is unreachable in your environment. Pin an exact version (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) instead of `@latest` for production.
46
+ `@thebase/ui` is published on npm, so [unpkg](https://unpkg.com/@thebase/ui@latest/) mirrors the same files as an alternative CDN (`https://unpkg.com/@thebase/ui@latest/dist/baseui.min.css` / `baseui.min.js`) if jsDelivr is unreachable in your environment. Pin an exact version (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) instead of `@latest` for production.
47
47
 
48
48
  For npm/self-hosted usage:
49
49
 
@@ -77,6 +77,7 @@ Production pages should use pinned version URLs. `latest` is for demos and exper
77
77
  | Owl templates XML | `@thebase/ui/dist/baseui.templates.xml` | `@base/templates` | `dist/baseui.templates.xml` |
78
78
  | Registry metadata | `@thebase/ui/registry` | none; fetch the JSON file | `dist/baseui.registry.json` |
79
79
  | Optional analytics service (`init`, `track`) | `@thebase/ui/analytics` | none; import the file URL or load the `<script>` build (sets `window.thebase.analytics`) | `dist/baseui.analytics.esm.js`, `dist/baseui.analytics.min.js` |
80
+ | Optional i18n service (`init`, `t`, `loadCatalog`) | `@thebase/ui/i18n` | `@base/i18n` (as in `emvhub/index.html`); or load the `<script>` build (sets `window.thebase.i18n`) | `dist/baseui.i18n.esm.js`, `dist/baseui.i18n.min.js` |
80
81
  | Standalone ApiDoc (`mountApiDoc`) | `@thebase/ui/apidoc` | none; embeds Owl + its templates, still needs `baseui.min.css`; set `assetBase` for the language logos | `dist/baseui.apidoc.esm.js`, `dist/baseui.apidoc.min.js` |
81
82
 
82
83
  `@base/templates` points to XML, not JavaScript. Resolve and fetch it (`fetch(import.meta.resolve("@base/templates"))`) before mounting an application that uses the Base UI component classes.
@@ -55,7 +55,7 @@ Everything — the static `b-ui` runtime, the Owl framework, every Base componen
55
55
  </script>
56
56
  ```
57
57
 
58
- `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable — swap the host in each URL above. For a self-hosted build, replace the CDN host with your own served path (e.g. `/dist/baseui.esm.js`). These snippets use `@latest` for readability; pin an exact version (e.g. `@1.1.6`, or `@1` to take only non-breaking updates) in production so a new release can't change what your page loads.
58
+ `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable — swap the host in each URL above. For a self-hosted build, replace the CDN host with your own served path (e.g. `/dist/baseui.esm.js`). These snippets use `@latest` for readability; pin an exact version (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) in production so a new release can't change what your page loads.
59
59
 
60
60
  No `@odoo/owl` import appears anywhere in that snippet — `@base/owl` is the only Owl entry point the Base UI components and consumer apps need. Because `@base/owl`, `@base/component`, and `@base/theme` all point at the exact same `dist/baseui.esm.js` URL, the browser fetches and evaluates it once and every key shares the same module instance — no separate classic `<script>` needs to load first to set up a shared global.
61
61
 
package/docs/registry.md CHANGED
@@ -14,6 +14,7 @@ The Base UI ships as bundled files only — there is no per-component source dis
14
14
  - `baseui.icons.esm.js` — the 2000+ generated `Icon<Name>` components (`IconEye`, `IconSearch`, ...), split out because they'd blow the main bundle's size budget. The one deliberate exception to "everything is one bundle".
15
15
  - `baseui.templates.xml` — every Base component's compiled `<templates>` body, concatenated into one file. Load this into the Owl `App`'s `templates` config before mounting; `.xml` files under `src/components/` are authoring sources, not something a consumer app loads directly.
16
16
  - `baseui.analytics.esm.js` / `baseui.analytics.min.js` — the optional, standalone cookieless analytics service (`@thebase/ui/analytics`). Not part of the main bundles and needs no other Base UI file; see [Analytics](analytics.md).
17
+ - `baseui.i18n.esm.js` / `baseui.i18n.min.js` — the optional, standalone gettext-style i18n service (`@thebase/ui/i18n`). Not part of the main bundles and needs no other Base UI file; see [i18n](i18n.md).
17
18
  - `icons/lucide.json` — the built-in icon manifest.
18
19
 
19
20
  ## Component export policy
@@ -14,9 +14,11 @@ thebase.theme.set("dark")
14
14
  thebase.theme.set({ primary: "#0f6cbd" })
15
15
  thebase.analytics.init({ domain, endpoint })
16
16
  thebase.track(eventName, options)
17
+ thebase.i18n.init({ languages, defaultLanguage })
18
+ thebase.i18n.t(text, params)
17
19
  ```
18
20
 
19
- `thebase.analytics` is set only when the optional `dist/baseui.analytics.min.js` is loaded (it is not in the main bundles), and `thebase.track` is bound once it is initialized — see [Analytics](analytics.md).
21
+ `thebase.analytics` is set only when the optional `dist/baseui.analytics.min.js` is loaded (it is not in the main bundles), and `thebase.track` is bound once it is initialized — see [Analytics](analytics.md). Likewise `thebase.i18n` is set only when the optional `dist/baseui.i18n.min.js` is loaded — see [i18n](i18n.md).
20
22
 
21
23
  The static runtime calls `autoMount()` when imported through `dist/baseui.esm.js` or `dist/baseui.min.js`. Existing `[b-ui]` and `[b-icon]` markers are enhanced automatically once the DOM is ready.
22
24
 
@@ -38,8 +40,8 @@ Mounted components dispatch lifecycle events on their root element:
38
40
  ```js
39
41
  import { cn } from "@thebase/ui";
40
42
 
41
- cn("btn", isActive && "active", ["bu-button", className]);
42
- // "btn active bu-button my-class" (when isActive is truthy and className is "my-class")
43
+ cn("btn", isActive && "active", ["b-button", className]);
44
+ // "btn active b-button my-class" (when isActive is truthy and className is "my-class")
43
45
  ```
44
46
 
45
47
  It's a standalone named export — `import { cn } from "@thebase/ui"` in npm/bundler apps, or `BaseUIBundle.cn` in the browser IIFE global — not a method on `BaseUI` itself. Use it to build your own components' class lists on top of the Base UI's conventions.
package/docs/theming.md CHANGED
@@ -13,6 +13,36 @@ thebase.theme.set("dark");
13
13
  thebase.theme.set({ primary: "#0057d8", radius: "0.5rem" });
14
14
  ```
15
15
 
16
+ ## Make your own theme
17
+
18
+ `dist/baseui.min.css` is the only stylesheet an app loads; it already includes the default light and dark themes. A custom theme is two small files, `baseui-light.css` and `baseui-dark.css` (readable copies in `dist/themes/`, minified `.min.css` versions beside them), loaded after it.
19
+
20
+ 1. Build one visually in the **theme creator** (the **Theme** tab of the examples app (`examples/index.html#/theme`)): pick a base colour, accent and radius, preview Base UI live in light or dark, then download `baseui-light.css` and `baseui-dark.css`.
21
+ 2. Or download the two files from `dist/themes/` (or copy `src/themes/`) and edit the values by hand.
22
+ 3. Load them after the Base UI stylesheet:
23
+
24
+ ```html
25
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.1/dist/baseui.min.css">
26
+ <link rel="stylesheet" href="/css/baseui-light.css">
27
+ <link rel="stylesheet" href="/css/baseui-dark.css">
28
+ ```
29
+
30
+ Each file declares the same variables on its own selector (`light`: `:root`, `[b-theme="light"]`, `.light`; `dark`: `[b-theme="dark"]`, `.dark`), so loading yours after the defaults replaces them. Edit only the values; keep the selectors and variable names. The tokens you will usually change:
31
+
32
+ | Token | Controls |
33
+ | --- | --- |
34
+ | `--b-background`, `--b-foreground` | Page background and text |
35
+ | `--b-surface`, `--b-card`, `--b-popover` (+ `-foreground`) | Raised surfaces |
36
+ | `--b-primary`, `--b-primary-rgb`, `--b-primary-foreground` | Primary buttons, links, active states (keep `-rgb` in sync with the colour) |
37
+ | `--b-secondary`, `--b-muted`, `--b-accent` (+ `-foreground`) | Subtle fills and hover states |
38
+ | `--b-danger`, `--b-success`, `--b-warning`, `--b-info` (each with `-rgb` and `-foreground`) | Error/destructive, success, warning and info states: buttons (`.btn-success` …), badges, alerts, Bootstrap `text-*`/`bg-*` helpers |
39
+ | `--b-border`, `--b-input`, `--b-ring` | Borders, field outlines, focus ring |
40
+ | `--b-chart-1` … `--b-chart-5`, `--b-sidebar-*` | Charts and the sidebar |
41
+ | `--base-radius` | Corner roundness; every `--b-radius-*` step is derived from it |
42
+ | `--b-overlay` | Backdrop behind dialogs and sheets |
43
+
44
+ To change a few values without a full theme, override them on `:root` / `[b-theme="dark"]` in your own CSS, or at runtime with `thebase.theme.set({ primary: "#0057d8", radius: "0.5rem" })`.
45
+
16
46
  The Base UI maps semantic tokens such as `--b-background`, `--b-primary`, `--b-border`, and `--b-radius` into Bootstrap 5 variables. Radius tokens are sourced from the shorter public alias family `--base-radius`, `--base-radius-sm`, `--base-radius-md`, `--base-radius-lg`, `--base-radius-xl`, `--base-radius-2xl`, `--base-radius-3xl`, `--base-radius-4xl`, and `--base-radius-full`, then mirrored to `--b-radius*` for component CSS.
17
47
 
18
48
  For a reusable theme toggle with persistence, URL override, button-label sync, and iframe preview sync, import the theme helper:
@@ -38,7 +68,7 @@ For a reusable theme toggle with persistence, URL override, button-label sync, a
38
68
  </script>
39
69
  ```
40
70
 
41
- `https://unpkg.com/@thebase/ui@latest/dist/baseui.esm.js` mirrors the same file as an alternative CDN if jsDelivr is unreachable. Pin an exact version (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) instead of `@latest` for production. Npm/bundler consumers can import the same API from `@thebase/ui`.
71
+ `https://unpkg.com/@thebase/ui@latest/dist/baseui.esm.js` mirrors the same file as an alternative CDN if jsDelivr is unreachable. Pin an exact version (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) instead of `@latest` for production. Npm/bundler consumers can import the same API from `@thebase/ui`.
42
72
 
43
73
  For a ready-made icon button, use the Base UI component instead of wiring your own click handler:
44
74
 
@@ -50,6 +80,6 @@ The documentation and example pages use the same theme infrastructure. Owl examp
50
80
 
51
81
  ## Design tokens
52
82
 
53
- The default light/dark palettes and radius follow the current [shadcn/ui](https://ui.shadcn.com) Base UI neutral theme: black/neutral primary on white in light mode, neutral-900/50 foreground-background inversion in dark mode, neutral `--b-secondary`/`--b-muted`/`--b-accent` surfaces, `--base-radius: var(--radius, 0.625rem)`, and a derived radius scale (`--base-radius-sm|md|lg|xl`, mirrored as `--b-radius-sm|md|lg|xl`) and shadow scale (`--b-shadow-sm|md|lg`) for consistent elevation across popovers, menus, dialogs, and toasts. The Base UI reads an existing upstream `--radius` value when present, but it does not redefine `--radius` back to `--b-radius`; that one-way bridge avoids CSS custom-property cycles. `--b-card`/`--b-popover` alias `--b-surface` for shadcn-token-name parity.
83
+ The default light/dark palettes and radius follow the current [shadcn/ui](https://ui.shadcn.com) Base UI neutral theme: black/neutral primary on white in light mode, neutral-900/50 foreground-background inversion in dark mode, neutral `--b-secondary`/`--b-muted`/`--b-accent` surfaces, `--base-radius: var(--radius, 0.625rem)` (set in the theme files), and a derived radius scale (`--base-radius-sm|md|lg|xl`, mirrored as `--b-radius-sm|md|lg|xl`) and shadow scale (`--b-shadow-sm|md|lg`) for consistent elevation across popovers, menus, dialogs, and toasts. The Base UI reads an existing upstream `--radius` value when present, but it does not redefine `--radius` back to `--b-radius`; that one-way bridge avoids CSS custom-property cycles. `--b-card`/`--b-popover` alias `--b-surface` for shadcn-token-name parity.
54
84
 
55
- Because the Base UI ships Bootstrap's stock precompiled CSS, most `.btn-*`/badge colors are not driven by `--bs-*` variables directly — `src/styles/baseui.css` re-points the `.btn-primary`/`.btn-secondary`/`.btn-danger`/`.btn-outline-secondary`/`.btn-light` variants at the Base UI tokens so `thebase.theme.set(...)` overrides actually render. Badges use their own `bu-badge-*` classes (`src/components/badge/badge.css`) instead of Bootstrap's `text-bg-*`, which hardcode non-overridable colors.
85
+ Because the Base UI ships Bootstrap's stock precompiled CSS, most `.btn-*`/badge colors are not driven by `--bs-*` variables directly — `src/styles/base-extensions.css` re-points the `.btn-primary`/`.btn-secondary`/`.btn-danger`/`.btn-outline-secondary`/`.btn-light` variants at the Base UI tokens so `thebase.theme.set(...)` overrides actually render. Badges use their own `b-badge-*` classes (`src/components/badge/badge.css`) instead of Bootstrap's `text-bg-*`, which hardcode non-overridable colors.
@@ -32,7 +32,7 @@ Save this as an `.html` file and open it — no build step, no server required.
32
32
  </html>
33
33
  ```
34
34
 
35
- `https://cdn.jsdelivr.net/npm/@thebase/ui@latest/dist/...` is the real jsDelivr URL for the published `@thebase/ui` npm package's `latest` tag, used here for a copy-paste-and-go quick start. Pin an exact version instead (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) for production, so a new release can't change what your page loads. See [Installation](installation.md) for jsDelivr/unpkg/npm/self-hosted paths.
35
+ `https://cdn.jsdelivr.net/npm/@thebase/ui@latest/dist/...` is the real jsDelivr URL for the published `@thebase/ui` npm package's `latest` tag, used here for a copy-paste-and-go quick start. Pin an exact version instead (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) for production, so a new release can't change what your page loads. See [Installation](installation.md) for jsDelivr/unpkg/npm/self-hosted paths.
36
36
 
37
37
  The static bundle calls `thebase.mountAll()` automatically on `DOMContentLoaded`, so initial `[b-ui]` and `[b-icon]` markup mounts without an extra script. Call `thebase.mountAll(root)` yourself only after injecting new markup or when mounting a specific fragment. If the consumer is itself an application, use [step 2](#2-install-pure-owl-api--recommended) instead — that's the recommended path.
38
38
 
@@ -63,7 +63,7 @@ Both APIs come from the same package and the same CSS file, and can be mixed on
63
63
  </script>
64
64
  ```
65
65
 
66
- `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable — swap the host in each URL above. Pin an exact version (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) instead of `@latest` for production.
66
+ `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable — swap the host in each URL above. Pin an exact version (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) instead of `@latest` for production.
67
67
 
68
68
  ```html
69
69
  <script type="module">
@@ -103,7 +103,7 @@ Two rules that account for most integration failures — see [Base Components](o
103
103
  <script src="https://cdn.jsdelivr.net/npm/@thebase/ui@latest/dist/baseui.min.js" defer></script>
104
104
  ```
105
105
 
106
- `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable. Pin an exact version (e.g. `@1.1.7`, or `@1` to take only non-breaking updates) instead of `@latest` for production.
106
+ `https://unpkg.com/@thebase/ui@latest/dist/...` mirrors the same files as an alternative CDN if jsDelivr is unreachable. Pin an exact version (e.g. `@1.2.1`, or `@1` to take only non-breaking updates) instead of `@latest` for production.
107
107
 
108
108
  **Option B — npm (bundler-based apps: Vite, webpack, etc.):**
109
109
 
@@ -120,7 +120,7 @@ import "@thebase/ui"; // side-effect import: registers window.thebase and auto-m
120
120
 
121
121
  Rule that applies to both options:
122
122
 
123
- - Production pages must use a pinned version (e.g. `@thebase/ui@1.1.7` or `@thebase/ui@1`), never `@latest`.
123
+ - Production pages must use a pinned version (e.g. `@thebase/ui@1.2.1` or `@thebase/ui@1`), never `@latest`.
124
124
 
125
125
  Mount markup:
126
126
 
@@ -219,7 +219,7 @@ export default {
219
219
  },
220
220
  serviceWorker: {
221
221
  cacheName: "my-app-cache-v1",
222
- cdnVersion: "1.1.7", // pin to match the importmap in index.html
222
+ cdnVersion: "1.2.1", // pin to match the importmap in index.html
223
223
  appFiles: ["/app.css", "/app.js", "/app.xml", "/favicon.svg", "/icons/icon-192.png", "/icons/icon-512.png"],
224
224
  },
225
225
  };
@@ -227,9 +227,17 @@ export default {
227
227
 
228
228
  ```sh
229
229
  npx create-baseui-app pwa . --config baseui.pwa.config.js
230
- # writes ./manifest.webmanifest and ./sw.js
230
+ # writes ./manifest.webmanifest, ./sw.js, ./sw-register.js and ./version.json
231
231
  ```
232
232
 
233
+ **Auto-reload on a new deploy.** The generated `sw.js` fetches `version.json` (never cached) on activate, on
234
+ every page navigation and when the page posts `"check-version"`. When the value differs from the last one it
235
+ saw, it wipes the caches, re-precaches the app shell and posts `"version-changed"` to every open page.
236
+ `sw-register.js` (load it with `<script type="module" src="/sw-register.js">`, replacing your own
237
+ `serviceWorker.register`) registers the worker, reloads on that message and re-checks when the tab becomes
238
+ visible. `version.json` is a content hash of `sw.js`, the manifest and every `appFiles` entry found under
239
+ `<path>`, so re-run the `pwa` command as the last step of every deploy.
240
+
233
241
  Re-run the command whenever `appFiles`, the CDN pin, or manifest fields change — both output files are
234
242
  fully regenerated, never hand-patched. Only `manifest.name`, `serviceWorker.cacheName`, and
235
243
  `serviceWorker.cdnVersion` are required; everything else (icons, theme/background color, display
@@ -239,6 +247,15 @@ files are kept, so your own icons win). Serving icons from another folder? Set `
239
247
  service worker) and `manifestUrl` (service worker) in the config. See
240
248
  `dist/types/pwa.d.ts` for the full config shape.
241
249
 
250
+ **Default in every scaffolded project.** `create-baseui-app create|init` projects ship
251
+ `plugins: [baseuiPwa({ name })]` (from `@thebase/ui/vite`) in `vite.config.js`. Each `vite build` then emits
252
+ `manifest.webmanifest`, `sw.js`, `sw-register.js`, `version.json` (hash of the built bundle) and the default
253
+ icons into `dist/`, and injects the manifest link, theme color and register script into every page — no
254
+ config file, no extra command. Every deploy with changed code therefore reloads open pages automatically.
255
+ `vite dev` is untouched. Options: `name`, `description`, `themeColor` and the other manifest fields, plus
256
+ `cdnVersion` (only for apps that load BaseUI from the CDN). For an existing project, add the plugin to
257
+ `vite.config.js` (`convert` prints this hint). Remove the plugin to opt out.
258
+
242
259
  ## 6. Copy a block instead of assembling from primitives
243
260
 
244
261
  For common layouts (dashboard shells, sidebars, login/signup forms, charts), copy a ready-made block from the gallery instead of composing primitives by hand: [Blocks](blocks.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thebase/ui",
3
- "version": "1.1.7",
3
+ "version": "1.2.1",
4
4
  "description": "CDN-installable Bootstrap 5 UI component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/baseui.min.js",
@@ -25,6 +25,11 @@
25
25
  "import": "./dist/baseui.analytics.esm.js",
26
26
  "default": "./dist/baseui.analytics.min.js"
27
27
  },
28
+ "./i18n": {
29
+ "types": "./dist/types/i18n.d.ts",
30
+ "import": "./dist/baseui.i18n.esm.js",
31
+ "default": "./dist/baseui.i18n.min.js"
32
+ },
28
33
  "./apidoc": {
29
34
  "types": "./dist/types/apidoc.d.ts",
30
35
  "import": "./dist/baseui.apidoc.esm.js",
@@ -34,6 +39,10 @@
34
39
  "types": "./dist/types/pwa.d.ts",
35
40
  "import": "./dist/baseui.pwa.esm.js"
36
41
  },
42
+ "./vite": {
43
+ "types": "./dist/types/vite.d.ts",
44
+ "import": "./dist/baseui.vite.esm.js"
45
+ },
37
46
  "./dist/baseui.templates.xml": "./dist/baseui.templates.xml"
38
47
  },
39
48
  "files": [
@@ -44,9 +53,12 @@
44
53
  "dist/baseui.icons.esm.js",
45
54
  "dist/baseui.analytics.esm.js",
46
55
  "dist/baseui.analytics.min.js",
56
+ "dist/baseui.i18n.esm.js",
57
+ "dist/baseui.i18n.min.js",
47
58
  "dist/baseui.apidoc.esm.js",
48
59
  "dist/baseui.apidoc.min.js",
49
60
  "dist/baseui.pwa.esm.js",
61
+ "dist/baseui.vite.esm.js",
50
62
  "dist/baseui.templates.xml",
51
63
  "dist/icons",
52
64
  "dist/pwa-icons",