@thebase/ui 1.2.0 → 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.
- package/CHANGELOG.md +9 -0
- package/README.md +17 -3
- package/dist/baseui.esm.js +1 -1
- package/dist/baseui.i18n.esm.js +2 -0
- package/dist/baseui.i18n.min.js +2 -0
- package/dist/baseui.min.js +27 -27
- package/dist/baseui.registry.json +2 -2
- package/dist/types/i18n.d.ts +25 -0
- package/dist/types/index.d.ts +2 -0
- package/docs/analytics.md +3 -3
- package/docs/blocks.md +1 -1
- package/docs/i18n.md +119 -0
- package/docs/icons.md +1 -1
- package/docs/installation.md +3 -2
- package/docs/owl-components.md +1 -1
- package/docs/registry.md +1 -0
- package/docs/runtime-api.md +3 -1
- package/docs/theming.md +2 -2
- package/docs/usage-guide.md +5 -5
- package/package.json +8 -1
|
@@ -1690,8 +1690,8 @@
|
|
|
1690
1690
|
"integrity": {
|
|
1691
1691
|
"baseui.min.css": "sha384-ZHn0002xs5Vgxz9uxfop7VtPOQAh6E5rIJO01L/a2zmeIBWoZyFt6cnVrx75Dvuv",
|
|
1692
1692
|
"bootstrap.bundle.min.js": "sha384-RMbllTJcplkCRnELNTOc5Kz/3AvFDE/rNlJqWqfgmRWruobClBdfwvl10akQZkR1",
|
|
1693
|
-
"baseui.min.js": "sha384-
|
|
1694
|
-
"baseui.esm.js": "sha384-
|
|
1693
|
+
"baseui.min.js": "sha384-aD8d00QW67jb6lvNvF5zTVnL6PhUxwsFM6zCf1h8PAy9HoYQCyDTuRZYoh0WRw9E",
|
|
1694
|
+
"baseui.esm.js": "sha384-frdLhpMXVNCzoVdnDtpd/y9IzPJzmNgBdKKYDYQCtLm/an9wp+LjCVPvbSpKar4O",
|
|
1695
1695
|
"baseui.icons.esm.js": "sha384-ZfEsbs5m2fWdNSu4Ql+ul4mOxhfl1HviBlbxZGZ/4ud905I8Csa6/ekJjNSVkjQ0",
|
|
1696
1696
|
"baseui.templates.xml": "sha384-+f/GUQVnonSoB2Q38NEa6hialYS8zT1NAAeGBtV6Kvtio+W4hOlpzihhvaCwKipc",
|
|
1697
1697
|
"baseui.block-viewer.esm.js": "sha384-vOMuFxKFmcXlJnc7tF4g9+ZcZJs3E8oLe2pgyOp5ZWqJ9zsmW7S8gcS5kFIWRnY4",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** gettext (.po) translation service. Call `init` before the first `loadCatalog`. */
|
|
2
|
+
export interface BaseUII18nLanguage { code: string; label: string }
|
|
3
|
+
export interface BaseUII18nConfig {
|
|
4
|
+
/** Languages the page can show; `code` is the .po file name. Defaults to English only. */
|
|
5
|
+
languages?: BaseUII18nLanguage[];
|
|
6
|
+
/** Language the texts are written in (no catalog is loaded for it). Defaults to the first language. */
|
|
7
|
+
defaultLanguage?: string;
|
|
8
|
+
/** localStorage key remembering the visitor's choice. Defaults to "thebase-lang". */
|
|
9
|
+
storageKey?: string;
|
|
10
|
+
/** Query parameter that forces a language. Defaults to "lang". */
|
|
11
|
+
queryParam?: string;
|
|
12
|
+
/** Folder (next to each module) holding `<code>.po`. Defaults to "i18n". */
|
|
13
|
+
catalogDir?: string;
|
|
14
|
+
/** Selector of the meta description `translateHead` translates. */
|
|
15
|
+
headDescription?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface BaseUII18nEntry { id: string; str: string; fuzzy: boolean }
|
|
18
|
+
export function init(config?: BaseUII18nConfig): void;
|
|
19
|
+
export function languages(): BaseUII18nLanguage[];
|
|
20
|
+
export function t(text: string, params?: Record<string, string | number>): string;
|
|
21
|
+
export function parsePo(text: string): Map<string, BaseUII18nEntry>;
|
|
22
|
+
export function loadCatalog(moduleUrl: string | URL): Promise<void>;
|
|
23
|
+
export function currentLanguage(): string;
|
|
24
|
+
export function translateHead(): void;
|
|
25
|
+
export function setLanguage(code: string): void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface BaseUIApi {
|
|
|
27
27
|
theme: { set(modeOrTokens: string | Record<string, string>): void };
|
|
28
28
|
/** Set by dist/baseui.analytics.min.js (the optional analytics service). */
|
|
29
29
|
analytics?: import("./analytics").BaseUIAnalytics;
|
|
30
|
+
/** Set by dist/baseui.i18n.min.js (the optional i18n service). */
|
|
31
|
+
i18n?: typeof import("./i18n");
|
|
30
32
|
/** Bound by `analytics.init()` (unless `bindToWindow: false`). */
|
|
31
33
|
track?: import("./analytics").BaseUIAnalytics["track"];
|
|
32
34
|
}
|
package/docs/analytics.md
CHANGED
|
@@ -13,12 +13,12 @@ init({ backendUrl: "https://stats.example.com" });
|
|
|
13
13
|
```html
|
|
14
14
|
<!-- ES module from the CDN (or map it as "@base/analytics" in an import map) -->
|
|
15
15
|
<script type="module">
|
|
16
|
-
import { init } from "https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.
|
|
16
|
+
import { init } from "https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.1/dist/baseui.analytics.esm.js";
|
|
17
17
|
init({ backendUrl: "https://stats.example.com" });
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
20
|
<!-- Classic script tag: sets window.thebase.analytics (load order vs dist/baseui.min.js doesn't matter) -->
|
|
21
|
-
<script src="https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.1/dist/baseui.analytics.min.js"></script>
|
|
22
22
|
<script>
|
|
23
23
|
thebase.analytics.init({ backendUrl: "https://stats.example.com" });
|
|
24
24
|
</script>
|
|
@@ -228,7 +228,7 @@ curl -i -X POST http://localhost:8080/api/event -H 'Content-Type: text/plain' \
|
|
|
228
228
|
|
|
229
229
|
[`examples/analytics/`](../examples/analytics/dashboard/?backend=http://localhost:8080) contains a working dashboard plus two complete sample backends: [`server-go`](../examples/analytics/server-go/main.go) (Fiber v3) and [`server-fastapi`](../examples/analytics/server-fastapi/main.py). Each one extends the receivers above with an in-memory store, a daily-salted cookieless visitor hash, a `GET /api/stats` endpoint, and static hosting for the dashboard.
|
|
230
230
|
|
|
231
|
-
The dashboard ([`dashboard/`](../examples/analytics/dashboard/?backend=http://localhost:8080)) is a pure application that loads `@thebase/ui@1.2.
|
|
231
|
+
The dashboard ([`dashboard/`](../examples/analytics/dashboard/?backend=http://localhost:8080)) is a pure application that loads `@thebase/ui@1.2.1` from jsDelivr: KPI `Card`s, an area `Chart`, top pages/sources/events `Table`s, site and period `NativeSelect`s, and a `ThemeButton`. It refreshes every 30 s and tracks its own visits through `@thebase/ui/analytics`, so a fresh backend has data straight away.
|
|
232
232
|
|
|
233
233
|
```sh
|
|
234
234
|
# Go (1.25+)
|
package/docs/blocks.md
CHANGED
|
@@ -13,7 +13,7 @@ Blocks are not standalone runtime components. Paste the markup and load the norm
|
|
|
13
13
|
<script src="https://cdn.jsdelivr.net/npm/@thebase/ui@latest/dist/baseui.min.js" defer></script>
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
`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.
|
|
16
|
+
`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. Blocks are static markup, so they only need the static `b-ui` runtime above — see [Usage Guide](usage-guide.md) if the surrounding page is itself an application and you'd rather compose the equivalent layout from [Base Components](owl-components.md).
|
|
17
17
|
|
|
18
18
|
Use `b-block` to select the block style:
|
|
19
19
|
|
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.2.
|
|
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
|
|
package/docs/installation.md
CHANGED
|
@@ -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.2.
|
|
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.2.
|
|
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.
|
package/docs/owl-components.md
CHANGED
|
@@ -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.2.
|
|
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
|
package/docs/runtime-api.md
CHANGED
|
@@ -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
|
|
package/docs/theming.md
CHANGED
|
@@ -22,7 +22,7 @@ thebase.theme.set({ primary: "#0057d8", radius: "0.5rem" });
|
|
|
22
22
|
3. Load them after the Base UI stylesheet:
|
|
23
23
|
|
|
24
24
|
```html
|
|
25
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.
|
|
25
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@thebase/ui@1.2.1/dist/baseui.min.css">
|
|
26
26
|
<link rel="stylesheet" href="/css/baseui-light.css">
|
|
27
27
|
<link rel="stylesheet" href="/css/baseui-dark.css">
|
|
28
28
|
```
|
|
@@ -68,7 +68,7 @@ For a reusable theme toggle with persistence, URL override, button-label sync, a
|
|
|
68
68
|
</script>
|
|
69
69
|
```
|
|
70
70
|
|
|
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.
|
|
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`.
|
|
72
72
|
|
|
73
73
|
For a ready-made icon button, use the Base UI component instead of wiring your own click handler:
|
|
74
74
|
|
package/docs/usage-guide.md
CHANGED
|
@@ -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.2.
|
|
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.2.
|
|
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.2.
|
|
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.2.
|
|
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.2.
|
|
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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thebase/ui",
|
|
3
|
-
"version": "1.2.
|
|
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",
|
|
@@ -48,6 +53,8 @@
|
|
|
48
53
|
"dist/baseui.icons.esm.js",
|
|
49
54
|
"dist/baseui.analytics.esm.js",
|
|
50
55
|
"dist/baseui.analytics.min.js",
|
|
56
|
+
"dist/baseui.i18n.esm.js",
|
|
57
|
+
"dist/baseui.i18n.min.js",
|
|
51
58
|
"dist/baseui.apidoc.esm.js",
|
|
52
59
|
"dist/baseui.apidoc.min.js",
|
|
53
60
|
"dist/baseui.pwa.esm.js",
|