@rivinia/i18n 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,67 @@
2
2
 
3
3
  Pre-1.0 policy: a minor bump may break, a patch is a bug fix.
4
4
 
5
+ ## 0.8.0 - 2026-10-31
6
+
7
+ The language picker: a third entry point, `@rivinia/i18n/select`, composed from
8
+ `@rivinia/select` instead of re-implementing a listbox. Additive — no core or `/ui`
9
+ signature changed, and no new dependency for consumers that do not import it.
10
+
11
+ - **`@rivinia/i18n/select` entry point.** Own FESM and types chunk, exported as
12
+ `exports["./select"]`. `@rivinia/select` (`^0.7.0`) is declared as an **optional**
13
+ peer: the core and `/ui` entry points never import it, so an application that does
14
+ not import `@rivinia/i18n/select` neither installs the peer nor pays for its code.
15
+ The core and `/ui` FESMs in this tarball are byte-identical to 0.7.2's.
16
+ - **`RiviniaLanguageSelect` (`rv-language-select`).** One trigger, one option per
17
+ configured language, in declared order, showing the native name. Managed
18
+ (`[manager]`, structurally satisfied by `RiviniaI18n`) or presentational
19
+ (`[languages]` + `[current]`); a manager wins over the presentational inputs. The
20
+ managed path goes through `setLanguageAsync()`, which never rejects, so the trigger
21
+ never keeps a failed pick: after a failure it falls back to the manager's current
22
+ language.
23
+ - **A later intent outvotes a switch still in flight.** Managed picks are
24
+ last-wins: resolving an older `setLanguageAsync()` after the user has picked again
25
+ emits nothing. That includes re-picking the language that is _currently_ current —
26
+ no manager call is made for it, but it still supersedes the pending switch, whose
27
+ confirmation must not surface as a change the user never asked for
28
+ (`projects/i18n/tests/language-select.spec.ts`, holds the manager's promise open and
29
+ re-picks the current language; it fails without the guard).
30
+ - **Each row name carries `lang` and `dir`.** `العربية` is pronounced as Arabic and
31
+ laid out right-to-left even while the page runs `en`; the language id is an
32
+ accessible hint when the native name differs from it. The closed trigger is
33
+ `rv-select`'s own value span and inherits the page language — the marking starts at
34
+ the panel (documented in the README).
35
+ - **`languageSelectOptions(languages)` and `LanguageSelectOption`.** The pure mapper
36
+ the component uses, exported for consumers who want `rv-select` with their own
37
+ trigger or row. It preserves order and resolves each name as `nativeName` →
38
+ `Intl.DisplayNames` → id, the same rule as `/ui`.
39
+ - **`RiviniaLanguageManager` and `LanguageLike` are re-exported** from this entry, so
40
+ a consumer importing only `/select` does not need `@rivinia/i18n/ui` on the side.
41
+ - **The picker owns a width floor.** The host is `inline-block` with
42
+ `min-inline-size: 14rem`. `rv-select`'s own `min-width: min(14rem, 100%)` cannot
43
+ supply it: inside a shrink-to-fit host that `100%` resolves to `0`, so a bare
44
+ `<rv-language-select [manager]="i18n" />` rendered the trigger, the panel and every
45
+ row one character wide, and `English` wrapped as `En / gli / sh`. Caught in the
46
+ packed build in a browser, not by a build or a test double; the `i18n-e2e` suite now
47
+ measures the host, the panel and the row line count in Chromium and Firefox, and both
48
+ geometry tests fail when the floor is removed.
49
+ - Packaging/build: the new entry consumes `@rivinia/select/ui` from dist, so
50
+ `build:select` runs before `build:i18n`. No new byte budget for anyone else: the
51
+ tarball grows by the `/select` FESM, its map and its types, and the pack gate checks
52
+ the built FESM — only `fesm2022/rivinia-i18n-select.mjs` may mention
53
+ `@rivinia/select/ui`.
54
+ - Proven end-to-end: 371 tests in 35 files; the repo's `i18n-e2e` Playwright suite
55
+ green (96 tests across Chromium, system Chrome and Firefox, four of them the new
56
+ `/select` page); two clean consumers built from the packed tarball — one without the
57
+ peer (its JS contains no select code at all) and one with the peer and a lazy route
58
+ (the picker lands in a 45.71 kB / 10.72 kB chunk, zero occurrences of
59
+ `rv-language-select` in the initial bundle); and a real-browser run of the packed
60
+ build in Chromium and Firefox, 30 checks each over a three-language `ar`/`en`/`de`
61
+ demo: rows' `lang`/`dir`, managed pick flipping `<html lang>` to the locale
62
+ (`de-DE`) and `dir`, a presentational pick leaving the manager untouched, and no
63
+ console, page or network errors. WebKit was **not run** — the host is missing
64
+ `libavif.so.16`, so MiniBrowser cannot launch.
65
+
5
66
  ## 0.7.2 - 2026-10-30
6
67
 
7
68
  - **Fixed: a view-transition switch kept the previous dictionary.** With
package/README.md CHANGED
@@ -17,10 +17,12 @@ Concretely: the text lives in JSON files, components ask for a key, and the whol
17
17
  app — text, direction, dates, numbers — follows the language the user picked.
18
18
  Arabic is a first-class target, not an afterthought of an English layout.
19
19
 
20
- - Package version: **0.7.2**
21
- - Peer dependency: **`@angular/core` `^22.0.0`** (plus `@angular-devkit/schematics` for `ng add`)
22
- - Entry points: **`@rivinia/i18n`** (headless core) and **`@rivinia/i18n/ui`**
23
- (the standalone language toggle)
20
+ - Package version: **0.8.0**
21
+ - Peer dependency: **`@angular/core` `^22.0.0`** (plus `@angular-devkit/schematics` for `ng add`,
22
+ and an optional `@rivinia/select` `^0.7.0` for the `/select` entry point)
23
+ - Entry points: **`@rivinia/i18n`** (headless core), **`@rivinia/i18n/ui`**
24
+ (the standalone language toggle) and **`@rivinia/i18n/select`** (the
25
+ multi-language picker)
24
26
  - `sideEffects: false`; no runtime import beyond `@angular/core`; loaders are lazy chunks
25
27
  - No `HttpClient` peer — the built-in loaders use `fetch`
26
28
 
@@ -511,6 +513,33 @@ button, and works with the service (`[manager]`) or without it (`[languages]` +
511
513
  templates, presentational mode, styling hooks and the accessibility contract are in the
512
514
  [toggle reference](#toggle-reference).
513
515
 
516
+ ### The language select
517
+
518
+ The toggle flips between exactly two languages. For `ar`, `en`, `de`, … use the
519
+ third entry point, which composes `@rivinia/select` into a list:
520
+
521
+ ```bash
522
+ npm install @rivinia/select
523
+ ```
524
+
525
+ ```ts
526
+ import { RiviniaLanguageSelect } from '@rivinia/i18n/select';
527
+ // <rv-language-select [manager]="i18n" label="Language" />
528
+ ```
529
+
530
+ Every language becomes one row, in the order declared, with its native name. Each row
531
+ name carries `lang` and `dir`, so `العربية` is pronounced as Arabic even while the page
532
+ runs `en`. The closed trigger is `rv-select`'s own text and carries no `lang`, so the
533
+ marking starts at the panel. Managed mode (`[manager]`) calls `setLanguageAsync` and emits
534
+ `(languageChange)` only after the switch is confirmed; presentational mode
535
+ (`[languages]` + `[current]`) emits synchronously. `searchable` adds the filter box for
536
+ long lists, and `variant="premium"` applies the select's premium skin.
537
+
538
+ `@rivinia/select` is an **optional peer**: the core and `/ui` entry points never
539
+ import it, so an application that does not import `@rivinia/i18n/select` does not
540
+ install it and its bundle does not grow. The full contract is in the
541
+ [select reference](#select-reference).
542
+
514
543
  ### Server-side rendering
515
544
 
516
545
  The default loader works on the server: `REQUEST` plus `<base href>` produce an absolute
@@ -1093,8 +1122,9 @@ supported shape for three or more languages, not something the toggle turns into
1093
1122
  - **Inside a menu.** The toggle is a plain `<button>` in normal flow, so it can sit in a
1094
1123
  panel that already exists — `@rivinia/menu/ui` ships the menu primitives. The menu's
1095
1124
  focus trap and keyboard model with this control inside it have **not** been tested.
1096
- - **Beside a native `<select>`.** For three or more languages, bind the select to the
1097
- service and leave the toggle out:
1125
+ - **Beside a native `<select>`.** For three or more languages, prefer the ready-made
1126
+ [language select](#select-reference) and leave the toggle out. If you need a native
1127
+ element instead, bind it to the service:
1098
1128
 
1099
1129
  ```html
1100
1130
  <select (change)="i18n.setLanguage($any($event.target).value)">
@@ -1117,6 +1147,149 @@ A globe does not name a language it cannot represent, and it says "switch langua
1117
1147
  without saying which. An app that wants its own mark passes `[icon]`, or draws one
1118
1148
  inside `rvLanguageTrigger`; either way the accessible name is unaffected.
1119
1149
 
1150
+ ### Select reference
1151
+
1152
+ The `@rivinia/i18n/select` entry point ships the multi-language picker and the pure
1153
+ mapper behind it:
1154
+
1155
+ ```ts
1156
+ import { RiviniaLanguageSelect, languageSelectOptions } from '@rivinia/i18n/select';
1157
+ ```
1158
+
1159
+ **Every export of this entry point is Experimental in 0.8.0**:
1160
+ `RiviniaLanguageSelect`, `languageSelectOptions`, `LanguageSelectOption`, and the
1161
+ re-exported `LanguageLike` / `RiviniaLanguageManager`. The select is a composition over
1162
+ `@rivinia/select/ui`; its public surface may follow that package's pre-1.0 changes.
1163
+
1164
+ #### Managed, with `RiviniaI18n`
1165
+
1166
+ ```ts
1167
+ import { Component, inject } from '@angular/core';
1168
+ import { RiviniaI18n } from '@rivinia/i18n';
1169
+ import { RiviniaLanguageSelect } from '@rivinia/i18n/select';
1170
+
1171
+ @Component({
1172
+ selector: 'app-header',
1173
+ imports: [RiviniaLanguageSelect],
1174
+ template: `<rv-language-select
1175
+ [manager]="i18n"
1176
+ [label]="label()"
1177
+ [searchable]="true"
1178
+ (languageChange)="onLanguage($event)"
1179
+ />`,
1180
+ })
1181
+ export class Header {
1182
+ readonly i18n = inject(RiviniaI18n<'ar' | 'en' | 'de'>);
1183
+ readonly label = this.i18n.t('common.language');
1184
+ }
1185
+ ```
1186
+
1187
+ `RiviniaI18n` satisfies `RiviniaLanguageManager` structurally, so pass the service
1188
+ directly. Managed state wins: `[languages]`, `[current]` and `[busy]` are ignored while
1189
+ `manager` is set. The trigger shows the current language's native name; the panel lists
1190
+ every language in declaration order.
1191
+
1192
+ `(languageChange)` fires **after** `setLanguageAsync` confirms the id, matching the
1193
+ toggle's contract. A manager that leaves the language unchanged emits nothing and the
1194
+ trigger returns to the real current language. While the manager reports
1195
+ `loadingState() === 'loading'`, the control is disabled, so a second pick cannot race the
1196
+ first.
1197
+
1198
+ #### Presentational, without a manager
1199
+
1200
+ ```html
1201
+ <rv-language-select
1202
+ [languages]="languages"
1203
+ [current]="language()"
1204
+ [busy]="switching()"
1205
+ label="Language"
1206
+ (languageChange)="language.set($event)"
1207
+ />
1208
+ ```
1209
+
1210
+ With no manager, `languages` + `current` describe the state and `languageChange` is the
1211
+ only side effect. Presentational mode is synchronous; the picked row stays selected until
1212
+ `[current]` changes, then the trigger follows the new value.
1213
+
1214
+ #### Inputs and output
1215
+
1216
+ | Input | Type | Default | Meaning |
1217
+ | ------------------- | ------------------------- | ------------------ | --------------------------------------------------------------------------------- |
1218
+ | `manager` | `RiviniaLanguageManager` | — | Managed mode; wins over `languages` / `current` / `busy`. |
1219
+ | `languages` | `readonly LanguageLike[]` | `[]` | Presentational language list. |
1220
+ | `current` | `string` | — | Presentational current id. |
1221
+ | `label` | `string \| null` | `null` | Visible caption; also the trigger's accessible name and the panel's default name. |
1222
+ | `ariaLabel` | `string \| null` | `null` | Accessible name when there is no visible caption. |
1223
+ | `popupLabel` | `string \| null` | `null` | Explicit panel name; defaults to `label`, then `ariaLabel`. |
1224
+ | `placeholder` | `string` | `'Select…'` | Trigger text when nothing is selected. |
1225
+ | `searchable` | `boolean` | `false` | Show the filter box. |
1226
+ | `searchLabel` | `string` | `'Search options'` | Filter box accessible name. |
1227
+ | `searchPlaceholder` | `string` | `'Search…'` | Filter box placeholder. |
1228
+ | `emptyLabel` | `string` | `'No results'` | Shown when the filter matches nothing. |
1229
+ | `variant` | `'simple' \| 'premium'` | `'simple'` | Passed to `rv-select`. |
1230
+ | `disabled` | `boolean` | `false` | Blocks opening and picking. |
1231
+ | `busy` | `boolean` | `false` | Presentational loading state. |
1232
+
1233
+ | Output | Payload | When |
1234
+ | ---------------- | -------- | ------------------------------------------------------------------------- |
1235
+ | `languageChange` | `string` | After a managed switch confirms, or synchronously in presentational mode. |
1236
+
1237
+ #### Sizing
1238
+
1239
+ The host is `inline-block` with a `min-inline-size: 14rem` floor. `rv-select` cannot
1240
+ supply it: its own `min-width: min(14rem, 100%)` resolves that `100%` to `0` inside a
1241
+ shrink-to-fit host, so without the floor the trigger, the panel and every row collapse to
1242
+ one character per line (`English` becomes `En / gli / sh`). Widen it with ordinary CSS —
1243
+ `rv-language-select { inline-size: 100% }` in a form row — and the panel follows the
1244
+ trigger within `rv-select`'s own limits. The `i18n-e2e` suite measures this in Chromium
1245
+ and Firefox.
1246
+
1247
+ #### Rows and accessibility
1248
+
1249
+ Each row carries `lang` and `dir` on the visible name, so a screen reader pronounces
1250
+ `العربية` as Arabic even when the page runs `en`, and the name lays out in its own
1251
+ direction. The closed trigger is `rv-select`'s value span and has no `lang`/`dir` hook of
1252
+ its own, so it inherits the page's language — the marking lives in the panel. The row's
1253
+ accessible name is its visible text: the native name, plus the
1254
+ language id as a hint when the two differ. The id is not repeated when the label already
1255
+ is the id.
1256
+
1257
+ `languageSelectOptions(languages)` is the pure mapper used by the component. It preserves
1258
+ order, resolves the name with the same rule as `/ui` (`nativeName` → `Intl.DisplayNames` →
1259
+ id), and returns:
1260
+
1261
+ ```ts
1262
+ interface LanguageSelectOption extends RiviniaSelectOption {
1263
+ readonly lang: string;
1264
+ readonly dir?: 'ltr' | 'rtl';
1265
+ }
1266
+ ```
1267
+
1268
+ Use it directly when you want `rv-select` with your own trigger or row:
1269
+
1270
+ ```ts
1271
+ import { languageSelectOptions } from '@rivinia/i18n/select';
1272
+
1273
+ readonly options = computed(() => languageSelectOptions(this.i18n.languages()));
1274
+ ```
1275
+
1276
+ #### Optional peer and bundle isolation
1277
+
1278
+ `@rivinia/select` is declared as an **optional peer** of `@rivinia/i18n`:
1279
+
1280
+ ```json
1281
+ {
1282
+ "peerDependencies": { "@rivinia/select": "^0.7.0" },
1283
+ "peerDependenciesMeta": { "@rivinia/select": { "optional": true } }
1284
+ }
1285
+ ```
1286
+
1287
+ The core and `/ui` entry points never import it. Only
1288
+ `fesm2022/rivinia-i18n-select.mjs` contains `@rivinia/select/ui`, so an application that
1289
+ does not import `@rivinia/i18n/select` neither installs the peer nor pays for its code.
1290
+ The unit surface spec checks the sources for this; the release gates then inspect the
1291
+ built FESM.
1292
+
1120
1293
  ### SSR reference
1121
1294
 
1122
1295
  The default loader works on the server: `REQUEST` plus `<base href>` produce an absolute
@@ -1161,6 +1334,9 @@ import {
1161
1334
  customLoader,
1162
1335
  formatIcu,
1163
1336
  } from '@rivinia/i18n';
1337
+
1338
+ import { RiviniaLanguageToggle, RiviniaLanguageTrigger } from '@rivinia/i18n/ui';
1339
+ import { RiviniaLanguageSelect, languageSelectOptions } from '@rivinia/i18n/select';
1164
1340
  ```
1165
1341
 
1166
1342
  ### API stability
@@ -1169,26 +1345,30 @@ Every export is classified so the 1.0 freeze is predictable. **Internal** symbol
1169
1345
  exist only so the package's own tests can import them; they may move to an
1170
1346
  `@rivinia/i18n/internal` entry point (or disappear) before 1.0.
1171
1347
 
1172
- | Export | Kind | Tier |
1173
- | ---------------------------------------------------------------------------------------------- | ---------------- | ------------ |
1174
- | `RiviniaI18n` | service | Stable |
1175
- | `provideRiviniaI18n`, `defineRiviniaI18n`, `injectRiviniaI18n` | providers | Stable |
1176
- | `RvTranslatePipe` (`rvTranslate`) | pipe | Stable |
1177
- | `RiviniaI18nConfig` | type | Stable |
1178
- | `Language`, `Direction`, `Translation`, `TranslateParams`, `StorageStrategy`, `SwitchStrategy` | types | Stable |
1179
- | `RiviniaLoadError` | class | Stable |
1180
- | `MissingKeyEvent`, `MissingParamEvent` | types | Stable |
1181
- | `TranslationLoader`, `LoaderDescriptor`, `LoaderContext` | types | Stable |
1182
- | `jsonLoader`, `httpLoader`, `remoteLoader`, `customLoader` | loader factories | Stable |
1183
- | `HttpLoaderOptions`, `RemoteLoaderOptions` | types | Stable |
1184
- | `formatIcu`, `IcuFormatOptions` | ICU API | Stable |
1185
- | `RegisteredI18nKey`, `RiviniaI18nKeyRegistry` | typed-keys types | Stable |
1186
- | `ViewTransitionConfig`, `ViewTransitionInfo` | types | Experimental |
1187
- | `ViewTransitionService` | service | Internal |
1188
- | `parseCookie`, `serializeCookie` | cookie helpers | Internal |
1189
- | `browserLanguages`, `detectBrowserLanguage` | helpers | Internal |
1190
- | `RiviniaLanguageToggle` (`rv-language-toggle`), `RiviniaLanguageTrigger` (`rvLanguageTrigger`) | `/ui` components | Experimental |
1191
- | `RiviniaLanguageManager`, `LanguageLike`, `RiviniaLanguageTriggerContext` | `/ui` types | Experimental |
1348
+ | Export | Kind | Tier |
1349
+ | ---------------------------------------------------------------------------------------------- | ------------------- | ------------ |
1350
+ | `RiviniaI18n` | service | Stable |
1351
+ | `provideRiviniaI18n`, `defineRiviniaI18n`, `injectRiviniaI18n` | providers | Stable |
1352
+ | `RvTranslatePipe` (`rvTranslate`) | pipe | Stable |
1353
+ | `RiviniaI18nConfig` | type | Stable |
1354
+ | `Language`, `Direction`, `Translation`, `TranslateParams`, `StorageStrategy`, `SwitchStrategy` | types | Stable |
1355
+ | `RiviniaLoadError` | class | Stable |
1356
+ | `MissingKeyEvent`, `MissingParamEvent` | types | Stable |
1357
+ | `TranslationLoader`, `LoaderDescriptor`, `LoaderContext` | types | Stable |
1358
+ | `jsonLoader`, `httpLoader`, `remoteLoader`, `customLoader` | loader factories | Stable |
1359
+ | `HttpLoaderOptions`, `RemoteLoaderOptions` | types | Stable |
1360
+ | `formatIcu`, `IcuFormatOptions` | ICU API | Stable |
1361
+ | `RegisteredI18nKey`, `RiviniaI18nKeyRegistry` | typed-keys types | Stable |
1362
+ | `ViewTransitionConfig`, `ViewTransitionInfo` | types | Experimental |
1363
+ | `ViewTransitionService` | service | Internal |
1364
+ | `parseCookie`, `serializeCookie` | cookie helpers | Internal |
1365
+ | `browserLanguages`, `detectBrowserLanguage` | helpers | Internal |
1366
+ | `RiviniaLanguageToggle` (`rv-language-toggle`), `RiviniaLanguageTrigger` (`rvLanguageTrigger`) | `/ui` components | Experimental |
1367
+ | `RiviniaLanguageManager`, `LanguageLike`, `RiviniaLanguageTriggerContext` | `/ui` types | Experimental |
1368
+ | `RiviniaLanguageSelect` (`rv-language-select`) | `/select` component | Experimental |
1369
+ | `languageSelectOptions` | `/select` helper | Experimental |
1370
+ | `LanguageSelectOption` | `/select` type | Experimental |
1371
+ | `LanguageLike`, `RiviniaLanguageManager` (re-exported) | `/select` types | Experimental |
1192
1372
 
1193
1373
  ### Migration 0.5.0 to 0.6.0
1194
1374
 
@@ -0,0 +1,391 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, computed, input, linkedSignal, output } from "@angular/core";
3
+ import { RiviniaSelectComponent } from "@rivinia/select/ui";
4
+ const cache = /* @__PURE__ */ new Map();
5
+ function languageName(entry) {
6
+ if (entry.nativeName) return entry.nativeName;
7
+ const locale = entry.locale ?? entry.id;
8
+ const key = `${locale}\u0000${entry.id}`;
9
+ const cached = cache.get(key);
10
+ if (cached !== void 0) return cached;
11
+ let name = entry.id;
12
+ if (typeof Intl !== "undefined" && typeof Intl.DisplayNames === "function") try {
13
+ name = new Intl.DisplayNames([locale], { type: "language" }).of(entry.id) ?? entry.id;
14
+ } catch {
15
+ name = entry.id;
16
+ }
17
+ cache.set(key, name);
18
+ return name;
19
+ }
20
+ function languageSelectOptions(languages) {
21
+ return languages.map((language) => {
22
+ const label = languageName(language);
23
+ const option = {
24
+ id: language.id,
25
+ label,
26
+ lang: language.id
27
+ };
28
+ if (language.dir !== void 0) option.dir = language.dir;
29
+ if (label !== language.id) option.hint = language.id;
30
+ return option;
31
+ });
32
+ }
33
+ var RiviniaLanguageSelect = class RiviniaLanguageSelect {
34
+ manager = input(...ngDevMode ? [void 0, { debugName: "manager" }] : /* istanbul ignore next */ []);
35
+ languages = input([], ...ngDevMode ? [{ debugName: "languages" }] : /* istanbul ignore next */ []);
36
+ current = input(...ngDevMode ? [void 0, { debugName: "current" }] : /* istanbul ignore next */ []);
37
+ label = input(null, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
38
+ ariaLabel = input(null, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
39
+ popupLabel = input(null, ...ngDevMode ? [{ debugName: "popupLabel" }] : /* istanbul ignore next */ []);
40
+ placeholder = input("Select…", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
41
+ searchable = input(false, ...ngDevMode ? [{ debugName: "searchable" }] : /* istanbul ignore next */ []);
42
+ searchLabel = input("Search options", ...ngDevMode ? [{ debugName: "searchLabel" }] : /* istanbul ignore next */ []);
43
+ searchPlaceholder = input("Search…", ...ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []);
44
+ emptyLabel = input("No results", ...ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []);
45
+ variant = input("simple", ...ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []);
46
+ disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
47
+ busy = input(false, ...ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []);
48
+ languageChange = output();
49
+ sourceLanguages = computed(() => this.manager()?.languages() ?? this.languages(), ...ngDevMode ? [{ debugName: "sourceLanguages" }] : /* istanbul ignore next */ []);
50
+ options = computed(() => languageSelectOptions(this.sourceLanguages()), ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
51
+ currentId = computed(() => this.manager()?.currentLanguage() ?? this.current() ?? "", ...ngDevMode ? [{ debugName: "currentId" }] : /* istanbul ignore next */ []);
52
+ isBusy = computed(() => {
53
+ const manager = this.manager();
54
+ return manager ? manager.loadingState() === "loading" : this.busy();
55
+ }, ...ngDevMode ? [{ debugName: "isBusy" }] : /* istanbul ignore next */ []);
56
+ isDisabled = computed(() => this.disabled() || this.isBusy(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
57
+ panelLabel = computed(() => this.popupLabel() ?? this.label() ?? this.ariaLabel(), ...ngDevMode ? [{ debugName: "panelLabel" }] : /* istanbul ignore next */ []);
58
+ selected = linkedSignal(() => this.currentId() || null, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
59
+ request = 0;
60
+ onSelectionChange(value) {
61
+ if (typeof value !== "string" || value.length === 0) {
62
+ this.selected.set(this.currentId() || null);
63
+ return;
64
+ }
65
+ if (value === this.currentId()) {
66
+ this.request += 1;
67
+ this.selected.set(this.currentId() || null);
68
+ return;
69
+ }
70
+ if (this.isDisabled()) {
71
+ this.selected.set(this.currentId() || null);
72
+ return;
73
+ }
74
+ const manager = this.manager();
75
+ if (!manager) {
76
+ this.languageChange.emit(value);
77
+ return;
78
+ }
79
+ const request = ++this.request;
80
+ manager.setLanguageAsync(value).then(() => {
81
+ if (request !== this.request) return;
82
+ if (manager.currentLanguage() === value) this.languageChange.emit(value);
83
+ else this.selected.set(this.currentId() || null);
84
+ }).catch(() => {
85
+ if (request === this.request) this.selected.set(this.currentId() || null);
86
+ });
87
+ }
88
+ static ɵfac = i0.ɵɵngDeclareFactory({
89
+ minVersion: "12.0.0",
90
+ version: "22.2.3",
91
+ ngImport: i0,
92
+ type: RiviniaLanguageSelect,
93
+ deps: [],
94
+ target: i0.ɵɵFactoryTarget.Component
95
+ });
96
+ static ɵcmp = i0.ɵɵngDeclareComponent({
97
+ minVersion: "17.0.0",
98
+ version: "22.2.3",
99
+ type: RiviniaLanguageSelect,
100
+ isStandalone: true,
101
+ selector: "rv-language-select",
102
+ inputs: {
103
+ manager: {
104
+ classPropertyName: "manager",
105
+ publicName: "manager",
106
+ isSignal: true,
107
+ isRequired: false,
108
+ transformFunction: null
109
+ },
110
+ languages: {
111
+ classPropertyName: "languages",
112
+ publicName: "languages",
113
+ isSignal: true,
114
+ isRequired: false,
115
+ transformFunction: null
116
+ },
117
+ current: {
118
+ classPropertyName: "current",
119
+ publicName: "current",
120
+ isSignal: true,
121
+ isRequired: false,
122
+ transformFunction: null
123
+ },
124
+ label: {
125
+ classPropertyName: "label",
126
+ publicName: "label",
127
+ isSignal: true,
128
+ isRequired: false,
129
+ transformFunction: null
130
+ },
131
+ ariaLabel: {
132
+ classPropertyName: "ariaLabel",
133
+ publicName: "ariaLabel",
134
+ isSignal: true,
135
+ isRequired: false,
136
+ transformFunction: null
137
+ },
138
+ popupLabel: {
139
+ classPropertyName: "popupLabel",
140
+ publicName: "popupLabel",
141
+ isSignal: true,
142
+ isRequired: false,
143
+ transformFunction: null
144
+ },
145
+ placeholder: {
146
+ classPropertyName: "placeholder",
147
+ publicName: "placeholder",
148
+ isSignal: true,
149
+ isRequired: false,
150
+ transformFunction: null
151
+ },
152
+ searchable: {
153
+ classPropertyName: "searchable",
154
+ publicName: "searchable",
155
+ isSignal: true,
156
+ isRequired: false,
157
+ transformFunction: null
158
+ },
159
+ searchLabel: {
160
+ classPropertyName: "searchLabel",
161
+ publicName: "searchLabel",
162
+ isSignal: true,
163
+ isRequired: false,
164
+ transformFunction: null
165
+ },
166
+ searchPlaceholder: {
167
+ classPropertyName: "searchPlaceholder",
168
+ publicName: "searchPlaceholder",
169
+ isSignal: true,
170
+ isRequired: false,
171
+ transformFunction: null
172
+ },
173
+ emptyLabel: {
174
+ classPropertyName: "emptyLabel",
175
+ publicName: "emptyLabel",
176
+ isSignal: true,
177
+ isRequired: false,
178
+ transformFunction: null
179
+ },
180
+ variant: {
181
+ classPropertyName: "variant",
182
+ publicName: "variant",
183
+ isSignal: true,
184
+ isRequired: false,
185
+ transformFunction: null
186
+ },
187
+ disabled: {
188
+ classPropertyName: "disabled",
189
+ publicName: "disabled",
190
+ isSignal: true,
191
+ isRequired: false,
192
+ transformFunction: null
193
+ },
194
+ busy: {
195
+ classPropertyName: "busy",
196
+ publicName: "busy",
197
+ isSignal: true,
198
+ isRequired: false,
199
+ transformFunction: null
200
+ }
201
+ },
202
+ outputs: { languageChange: "languageChange" },
203
+ host: { properties: {
204
+ "attr.data-busy": "isBusy() ? \"\" : null",
205
+ "attr.data-disabled": "isDisabled() ? \"\" : null"
206
+ } },
207
+ ngImport: i0,
208
+ template: "<ng-template #languageRow let-option>\n <span\n class=\"rv-select-label rv-language-select__name\"\n [attr.lang]=\"option.lang\"\n [attr.dir]=\"option.dir ?? 'auto'\"\n >{{ option.label }}</span>\n @if (option.hint) {\n <span class=\"rv-select-hint\">{{ option.hint }}</span>\n }\n @if (option.id === selected()) {\n <svg\n class=\"rv-select-check\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n aria-hidden=\"true\"\n >\n <path d=\"M3 8.5 6.5 12 13 4.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n }\n</ng-template>\n\n<rv-select\n [options]=\"options()\"\n [(value)]=\"selected\"\n [label]=\"label()\"\n [ariaLabel]=\"ariaLabel()\"\n [popupLabel]=\"panelLabel()\"\n [placeholder]=\"placeholder()\"\n [searchable]=\"searchable()\"\n [searchLabel]=\"searchLabel()\"\n [searchPlaceholder]=\"searchPlaceholder()\"\n [emptyLabel]=\"emptyLabel()\"\n [variant]=\"variant()\"\n [disabled]=\"isDisabled()\"\n [optionTemplate]=\"languageRow\"\n (selectionChange)=\"onSelectionChange($event)\"\n/>\n",
209
+ styles: [":host{display:inline-block;min-inline-size:14rem}.rv-language-select__name{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}\n"],
210
+ dependencies: [{
211
+ kind: "component",
212
+ type: RiviniaSelectComponent,
213
+ selector: "rv-select",
214
+ inputs: [
215
+ "select",
216
+ "mode",
217
+ "variant",
218
+ "options",
219
+ "searchable",
220
+ "placeholder",
221
+ "label",
222
+ "ariaLabel",
223
+ "popupLabel",
224
+ "searchLabel",
225
+ "optionTemplate",
226
+ "listTemplate",
227
+ "loading",
228
+ "loadingLabel",
229
+ "searchPlaceholder",
230
+ "emptyLabel",
231
+ "placement",
232
+ "value",
233
+ "disabled",
234
+ "touched",
235
+ "errors",
236
+ "invalid"
237
+ ],
238
+ outputs: [
239
+ "reachEnd",
240
+ "panelReady",
241
+ "selectionChange",
242
+ "opened",
243
+ "closed",
244
+ "valueChange",
245
+ "touch"
246
+ ]
247
+ }],
248
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
249
+ });
250
+ };
251
+ i0.ɵɵngDeclareClassMetadata({
252
+ minVersion: "12.0.0",
253
+ version: "22.2.3",
254
+ ngImport: i0,
255
+ type: RiviniaLanguageSelect,
256
+ decorators: [{
257
+ type: Component,
258
+ args: [{
259
+ selector: "rv-language-select",
260
+ imports: [RiviniaSelectComponent],
261
+ changeDetection: ChangeDetectionStrategy.OnPush,
262
+ host: {
263
+ "[attr.data-busy]": "isBusy() ? \"\" : null",
264
+ "[attr.data-disabled]": "isDisabled() ? \"\" : null"
265
+ },
266
+ template: "<ng-template #languageRow let-option>\n <span\n class=\"rv-select-label rv-language-select__name\"\n [attr.lang]=\"option.lang\"\n [attr.dir]=\"option.dir ?? 'auto'\"\n >{{ option.label }}</span>\n @if (option.hint) {\n <span class=\"rv-select-hint\">{{ option.hint }}</span>\n }\n @if (option.id === selected()) {\n <svg\n class=\"rv-select-check\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n aria-hidden=\"true\"\n >\n <path d=\"M3 8.5 6.5 12 13 4.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n }\n</ng-template>\n\n<rv-select\n [options]=\"options()\"\n [(value)]=\"selected\"\n [label]=\"label()\"\n [ariaLabel]=\"ariaLabel()\"\n [popupLabel]=\"panelLabel()\"\n [placeholder]=\"placeholder()\"\n [searchable]=\"searchable()\"\n [searchLabel]=\"searchLabel()\"\n [searchPlaceholder]=\"searchPlaceholder()\"\n [emptyLabel]=\"emptyLabel()\"\n [variant]=\"variant()\"\n [disabled]=\"isDisabled()\"\n [optionTemplate]=\"languageRow\"\n (selectionChange)=\"onSelectionChange($event)\"\n/>\n",
267
+ styles: [":host{display:inline-block;min-inline-size:14rem}.rv-language-select__name{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}\n"]
268
+ }]
269
+ }],
270
+ propDecorators: {
271
+ manager: [{
272
+ type: i0.Input,
273
+ args: [{
274
+ isSignal: true,
275
+ alias: "manager",
276
+ required: false
277
+ }]
278
+ }],
279
+ languages: [{
280
+ type: i0.Input,
281
+ args: [{
282
+ isSignal: true,
283
+ alias: "languages",
284
+ required: false
285
+ }]
286
+ }],
287
+ current: [{
288
+ type: i0.Input,
289
+ args: [{
290
+ isSignal: true,
291
+ alias: "current",
292
+ required: false
293
+ }]
294
+ }],
295
+ label: [{
296
+ type: i0.Input,
297
+ args: [{
298
+ isSignal: true,
299
+ alias: "label",
300
+ required: false
301
+ }]
302
+ }],
303
+ ariaLabel: [{
304
+ type: i0.Input,
305
+ args: [{
306
+ isSignal: true,
307
+ alias: "ariaLabel",
308
+ required: false
309
+ }]
310
+ }],
311
+ popupLabel: [{
312
+ type: i0.Input,
313
+ args: [{
314
+ isSignal: true,
315
+ alias: "popupLabel",
316
+ required: false
317
+ }]
318
+ }],
319
+ placeholder: [{
320
+ type: i0.Input,
321
+ args: [{
322
+ isSignal: true,
323
+ alias: "placeholder",
324
+ required: false
325
+ }]
326
+ }],
327
+ searchable: [{
328
+ type: i0.Input,
329
+ args: [{
330
+ isSignal: true,
331
+ alias: "searchable",
332
+ required: false
333
+ }]
334
+ }],
335
+ searchLabel: [{
336
+ type: i0.Input,
337
+ args: [{
338
+ isSignal: true,
339
+ alias: "searchLabel",
340
+ required: false
341
+ }]
342
+ }],
343
+ searchPlaceholder: [{
344
+ type: i0.Input,
345
+ args: [{
346
+ isSignal: true,
347
+ alias: "searchPlaceholder",
348
+ required: false
349
+ }]
350
+ }],
351
+ emptyLabel: [{
352
+ type: i0.Input,
353
+ args: [{
354
+ isSignal: true,
355
+ alias: "emptyLabel",
356
+ required: false
357
+ }]
358
+ }],
359
+ variant: [{
360
+ type: i0.Input,
361
+ args: [{
362
+ isSignal: true,
363
+ alias: "variant",
364
+ required: false
365
+ }]
366
+ }],
367
+ disabled: [{
368
+ type: i0.Input,
369
+ args: [{
370
+ isSignal: true,
371
+ alias: "disabled",
372
+ required: false
373
+ }]
374
+ }],
375
+ busy: [{
376
+ type: i0.Input,
377
+ args: [{
378
+ isSignal: true,
379
+ alias: "busy",
380
+ required: false
381
+ }]
382
+ }],
383
+ languageChange: [{
384
+ type: i0.Output,
385
+ args: ["languageChange"]
386
+ }]
387
+ }
388
+ });
389
+ export { RiviniaLanguageSelect, languageSelectOptions };
390
+
391
+ //# sourceMappingURL=rivinia-i18n-select.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rivinia-i18n-select.mjs","names":[],"sources":["../../../projects/i18n/select/src/lib/utils/language-name.ts","../../../projects/i18n/select/src/lib/utils/language-select-options.ts","../../../projects/i18n/select/src/lib/components/language-select/language-select.ts","../../../projects/i18n/select/src/lib/components/language-select/language-select.html"],"sourcesContent":["import type { LanguageLike } from '@rivinia/i18n/ui';\n\n/*\n * Deliberately duplicated from `@rivinia/i18n/ui` instead of imported at\n * runtime. The select entry point must not pull the UI chunk (toggle, trigger,\n * template, CSS) into its own bundle; the helper is small and the chunk\n * boundary is worth more than the duplication.\n */\n\n/** One lookup per (locale, id); the key cannot collide because of the NUL separator. */\nconst cache = new Map<string, string>();\n\n/** Resolution order: `nativeName` → `Intl.DisplayNames` → the raw id, never empty. */\nexport function languageName(entry: LanguageLike): string {\n if (entry.nativeName) {\n return entry.nativeName;\n }\n\n const locale = entry.locale ?? entry.id;\n const key = `${locale}\\u0000${entry.id}`;\n const cached = cache.get(key);\n if (cached !== undefined) {\n return cached;\n }\n\n let name = entry.id;\n if (typeof Intl !== 'undefined' && typeof Intl.DisplayNames === 'function') {\n try {\n name = new Intl.DisplayNames([locale], { type: 'language' }).of(entry.id) ?? entry.id;\n } catch {\n name = entry.id;\n }\n }\n\n cache.set(key, name);\n return name;\n}\n","import type { LanguageLike } from '@rivinia/i18n/ui';\nimport type { LanguageSelectOption } from '../models/language-select-option';\nimport { languageName } from './language-name';\n\n/**\n * Map languages to `rv-select` options, in the order given.\n *\n * The visible name follows the same rule as the `/ui` toggle\n * (`nativeName` → `Intl.DisplayNames` → id). The id is repeated as `lang`, and\n * as a `hint` only when it adds information — a row whose label already is\n * the id would otherwise print the same text twice.\n */\nexport function languageSelectOptions(\n languages: readonly LanguageLike[],\n): readonly LanguageSelectOption[] {\n return languages.map((language) => {\n const label = languageName(language);\n const option: {\n id: string;\n label: string;\n lang: string;\n dir?: LanguageLike['dir'];\n hint?: string;\n } = {\n id: language.id,\n label,\n lang: language.id,\n };\n\n if (language.dir !== undefined) {\n option.dir = language.dir;\n }\n if (label !== language.id) {\n option.hint = language.id;\n }\n\n return option;\n });\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n computed,\n input,\n linkedSignal,\n output,\n} from '@angular/core';\nimport type { LanguageLike, RiviniaLanguageManager } from '@rivinia/i18n/ui';\nimport { RiviniaSelectComponent } from '@rivinia/select/ui';\nimport type { RiviniaSelectVariant, SelectChange } from '@rivinia/select/ui';\nimport type { LanguageSelectOption } from '../../models/language-select-option';\nimport { languageSelectOptions } from '../../utils/language-select-options';\n\n/**\n * Multi-language picker: `rv-select` with every language as one row.\n *\n * The i18n core and `/ui` entry point do not know this component exists. It is\n * the only chunk that imports `@rivinia/select/ui`, which is why the peer stays\n * optional for consumers that never import `@rivinia/i18n/select`.\n *\n * ```html\n * <rv-language-select [manager]=\"i18n\" label=\"Language\" />\n * <rv-language-select [languages]=\"languages\" [current]=\"current()\" (languageChange)=\"set($event)\" />\n * ```\n *\n * Managed mode wins over `[languages]` / `[current]` / `[busy]`. The event is\n * emitted only after `setLanguageAsync` confirms the id, matching the toggle's\n * contract; a manager that leaves the language unchanged emits nothing and the\n * trigger returns to the real current language.\n */\n@Component({\n selector: 'rv-language-select',\n imports: [RiviniaSelectComponent],\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './language-select.html',\n styleUrl: './language-select.css',\n host: {\n '[attr.data-busy]': 'isBusy() ? \"\" : null',\n '[attr.data-disabled]': 'isDisabled() ? \"\" : null',\n },\n})\nexport class RiviniaLanguageSelect {\n readonly manager = input<RiviniaLanguageManager>();\n readonly languages = input<readonly LanguageLike[]>([]);\n readonly current = input<string>();\n readonly label = input<string | null>(null);\n readonly ariaLabel = input<string | null>(null);\n readonly popupLabel = input<string | null>(null);\n readonly placeholder = input('Select…');\n readonly searchable = input(false);\n readonly searchLabel = input('Search options');\n readonly searchPlaceholder = input('Search…');\n readonly emptyLabel = input('No results');\n readonly variant = input<RiviniaSelectVariant>('simple');\n readonly disabled = input(false);\n readonly busy = input(false);\n\n readonly languageChange = output<string>();\n\n protected readonly sourceLanguages = computed<readonly LanguageLike[]>(\n () => this.manager()?.languages() ?? this.languages(),\n );\n\n protected readonly options = computed<readonly LanguageSelectOption[]>(() =>\n languageSelectOptions(this.sourceLanguages()),\n );\n\n protected readonly currentId = computed(\n () => this.manager()?.currentLanguage() ?? this.current() ?? '',\n );\n\n protected readonly isBusy = computed(() => {\n const manager = this.manager();\n return manager ? manager.loadingState() === 'loading' : this.busy();\n });\n\n protected readonly isDisabled = computed(() => this.disabled() || this.isBusy());\n\n protected readonly panelLabel = computed(\n () => this.popupLabel() ?? this.label() ?? this.ariaLabel(),\n );\n\n /**\n * The select's single value. Linked to the current language, but writable so\n * a pick paints immediately while a managed switch is in flight. When the\n * manager confirms (or refuses), the linked computation re-syncs it.\n */\n protected readonly selected = linkedSignal<SelectChange>(() => this.currentId() || null);\n\n /** Discards the confirmation of a switch that a later pick superseded. */\n private request = 0;\n\n protected onSelectionChange(value: SelectChange): void {\n if (typeof value !== 'string' || value.length === 0) {\n this.selected.set(this.currentId() || null);\n return;\n }\n if (value === this.currentId()) {\n // Re-picking the language that is already current is still a newer\n // intent: it outvotes a switch still in flight, whose confirmation must\n // not surface as a change the user never asked for.\n this.request += 1;\n this.selected.set(this.currentId() || null);\n return;\n }\n if (this.isDisabled()) {\n this.selected.set(this.currentId() || null);\n return;\n }\n\n const manager = this.manager();\n if (!manager) {\n this.languageChange.emit(value);\n return;\n }\n\n const request = ++this.request;\n void manager\n .setLanguageAsync(value)\n .then(() => {\n if (request !== this.request) {\n return;\n }\n if (manager.currentLanguage() === value) {\n this.languageChange.emit(value);\n } else {\n this.selected.set(this.currentId() || null);\n }\n })\n .catch(() => {\n if (request === this.request) {\n this.selected.set(this.currentId() || null);\n }\n });\n }\n}\n","<ng-template #languageRow let-option>\n <span\n class=\"rv-select-label rv-language-select__name\"\n [attr.lang]=\"option.lang\"\n [attr.dir]=\"option.dir ?? 'auto'\"\n >{{ option.label }}</span>\n @if (option.hint) {\n <span class=\"rv-select-hint\">{{ option.hint }}</span>\n }\n @if (option.id === selected()) {\n <svg\n class=\"rv-select-check\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n aria-hidden=\"true\"\n >\n <path d=\"M3 8.5 6.5 12 13 4.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n </svg>\n }\n</ng-template>\n\n<rv-select\n [options]=\"options()\"\n [(value)]=\"selected\"\n [label]=\"label()\"\n [ariaLabel]=\"ariaLabel()\"\n [popupLabel]=\"panelLabel()\"\n [placeholder]=\"placeholder()\"\n [searchable]=\"searchable()\"\n [searchLabel]=\"searchLabel()\"\n [searchPlaceholder]=\"searchPlaceholder()\"\n [emptyLabel]=\"emptyLabel()\"\n [variant]=\"variant()\"\n [disabled]=\"isDisabled()\"\n [optionTemplate]=\"languageRow\"\n (selectionChange)=\"onSelectionChange($event)\"\n/>\n"],"mappings":";;;AAUA,MAAM,wBAAQ,IAAI,IAAG;AAGrB,SAAgB,aAAa,OAAmB;CAC9C,IAAI,MAAM,YACR,OAAO,MAAM;CAGf,MAAM,SAAS,MAAM,UAAU,MAAM;CACrC,MAAM,MAAM,GAAG,OAAM,QAAS,MAAM;CACpC,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,QACb,OAAO;CAGT,IAAI,OAAO,MAAM;CACjB,IAAI,OAAO,SAAS,eAAe,OAAO,KAAK,iBAAiB,YAC9D,IAAI;EACF,OAAO,IAAI,KAAK,aAAa,CAAC,MAAM,GAAG,EAAE,MAAM,WAAU,CAAE,CAAC,CAAC,GAAG,MAAM,EAAE,KAAK,MAAM;CACrF,QAAQ;EACN,OAAO,MAAM;CACf;CAGF,MAAM,IAAI,KAAK,IAAI;CACnB,OAAO;AACT;ACxBA,SAAgB,sBACd,WAAkC;CAElC,OAAO,UAAU,KAAK,aAAY;EAChC,MAAM,QAAQ,aAAa,QAAQ;EACnC,MAAM,SAMF;GACF,IAAI,SAAS;GACb;GACA,MAAM,SAAS;EAChB;EAED,IAAI,SAAS,QAAQ,QACnB,OAAO,MAAM,SAAS;EAExB,IAAI,UA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YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAqB,YAAA,CAAA;EAXjC,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAoB,SACrB,CAAC,sBAAsB;GAAC,iBAChB,wBAAwB;GAAM,MAGzC;IACJ,oBAAoB;IACpB,wBAAwB;GACzB;GAAA,UAAA;GAAA,QAAA,CAAA,gIAAA;EAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivinia/i18n",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Headless Angular language manager: signals, RTL, SSR-safe loaders, fallback language, missing-key reporting, ICU plurals, typed keys.",
5
5
  "keywords": [
6
6
  "angular",
@@ -32,11 +32,15 @@
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@angular-devkit/schematics": "^22.0.0",
35
- "@angular/core": "^22.0.0"
35
+ "@angular/core": "^22.0.0",
36
+ "@rivinia/select": "^0.7.0"
36
37
  },
37
38
  "peerDependenciesMeta": {
38
39
  "@angular-devkit/schematics": {
39
40
  "optional": true
41
+ },
42
+ "@rivinia/select": {
43
+ "optional": true
40
44
  }
41
45
  },
42
46
  "sideEffects": false,
@@ -51,6 +55,10 @@
51
55
  "types": "./types/rivinia-i18n.d.ts",
52
56
  "default": "./fesm2022/rivinia-i18n.mjs"
53
57
  },
58
+ "./select": {
59
+ "types": "./types/rivinia-i18n-select.d.ts",
60
+ "default": "./fesm2022/rivinia-i18n-select.mjs"
61
+ },
54
62
  "./ui": {
55
63
  "types": "./types/rivinia-i18n-ui.d.ts",
56
64
  "default": "./fesm2022/rivinia-i18n-ui.mjs"
@@ -0,0 +1,149 @@
1
+ import { LanguageLike, LanguageLike as LanguageLike$1, RiviniaLanguageManager, RiviniaLanguageManager as RiviniaLanguageManager$1 } from "@rivinia/i18n/ui";
2
+ import { RiviniaSelectVariant, SelectChange } from "@rivinia/select/ui";
3
+ import { RiviniaSelectOption } from "@rivinia/select";
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * A select option for one language. `RiviniaSelectOption` already carries the
7
+ * `id` (the language id) and the visible `label`; the extra fields exist so a
8
+ * custom row can put `lang`/`dir` on the name instead of inheriting the page's.
9
+ */
10
+ interface LanguageSelectOption extends RiviniaSelectOption {
11
+ /** The language id, repeated as the row's `lang`. */
12
+ readonly lang: string;
13
+ /** The language direction, when the source entry declares one. */
14
+ readonly dir?: LanguageLike$1['dir'];
15
+ }
16
+ /**
17
+ * Multi-language picker: `rv-select` with every language as one row.
18
+ *
19
+ * The i18n core and `/ui` entry point do not know this component exists. It is
20
+ * the only chunk that imports `@rivinia/select/ui`, which is why the peer stays
21
+ * optional for consumers that never import `@rivinia/i18n/select`.
22
+ *
23
+ * ```html
24
+ * <rv-language-select [manager]="i18n" label="Language" />
25
+ * <rv-language-select [languages]="languages" [current]="current()" (languageChange)="set($event)" />
26
+ * ```
27
+ *
28
+ * Managed mode wins over `[languages]` / `[current]` / `[busy]`. The event is
29
+ * emitted only after `setLanguageAsync` confirms the id, matching the toggle's
30
+ * contract; a manager that leaves the language unchanged emits nothing and the
31
+ * trigger returns to the real current language.
32
+ */
33
+ export declare class RiviniaLanguageSelect {
34
+ readonly manager: import("@angular/core").InputSignal<RiviniaLanguageManager$1 | undefined>;
35
+ readonly languages: import("@angular/core").InputSignal<readonly LanguageLike$1[]>;
36
+ readonly current: import("@angular/core").InputSignal<string | undefined>;
37
+ readonly label: import("@angular/core").InputSignal<string | null>;
38
+ readonly ariaLabel: import("@angular/core").InputSignal<string | null>;
39
+ readonly popupLabel: import("@angular/core").InputSignal<string | null>;
40
+ readonly placeholder: import("@angular/core").InputSignal<string>;
41
+ readonly searchable: import("@angular/core").InputSignal<boolean>;
42
+ readonly searchLabel: import("@angular/core").InputSignal<string>;
43
+ readonly searchPlaceholder: import("@angular/core").InputSignal<string>;
44
+ readonly emptyLabel: import("@angular/core").InputSignal<string>;
45
+ readonly variant: import("@angular/core").InputSignal<RiviniaSelectVariant>;
46
+ readonly disabled: import("@angular/core").InputSignal<boolean>;
47
+ readonly busy: import("@angular/core").InputSignal<boolean>;
48
+ readonly languageChange: import("@angular/core").OutputEmitterRef<string>;
49
+ protected readonly sourceLanguages: import("@angular/core").Signal<readonly LanguageLike$1[]>;
50
+ protected readonly options: import("@angular/core").Signal<readonly LanguageSelectOption[]>;
51
+ protected readonly currentId: import("@angular/core").Signal<string>;
52
+ protected readonly isBusy: import("@angular/core").Signal<boolean>;
53
+ protected readonly isDisabled: import("@angular/core").Signal<boolean>;
54
+ protected readonly panelLabel: import("@angular/core").Signal<string | null>;
55
+ /**
56
+ * The select's single value. Linked to the current language, but writable so
57
+ * a pick paints immediately while a managed switch is in flight. When the
58
+ * manager confirms (or refuses), the linked computation re-syncs it.
59
+ */
60
+ protected readonly selected: import("@angular/core").WritableSignal<SelectChange>;
61
+ /** Discards the confirmation of a switch that a later pick superseded. */
62
+ private request;
63
+ protected onSelectionChange(value: SelectChange): void;
64
+ static ɵfac: i0.ɵɵFactoryDeclaration<RiviniaLanguageSelect, never>;
65
+ static ɵcmp: i0.ɵɵComponentDeclaration<RiviniaLanguageSelect, "rv-language-select", never, {
66
+ "manager": {
67
+ "alias": "manager";
68
+ "required": false;
69
+ "isSignal": true;
70
+ };
71
+ "languages": {
72
+ "alias": "languages";
73
+ "required": false;
74
+ "isSignal": true;
75
+ };
76
+ "current": {
77
+ "alias": "current";
78
+ "required": false;
79
+ "isSignal": true;
80
+ };
81
+ "label": {
82
+ "alias": "label";
83
+ "required": false;
84
+ "isSignal": true;
85
+ };
86
+ "ariaLabel": {
87
+ "alias": "ariaLabel";
88
+ "required": false;
89
+ "isSignal": true;
90
+ };
91
+ "popupLabel": {
92
+ "alias": "popupLabel";
93
+ "required": false;
94
+ "isSignal": true;
95
+ };
96
+ "placeholder": {
97
+ "alias": "placeholder";
98
+ "required": false;
99
+ "isSignal": true;
100
+ };
101
+ "searchable": {
102
+ "alias": "searchable";
103
+ "required": false;
104
+ "isSignal": true;
105
+ };
106
+ "searchLabel": {
107
+ "alias": "searchLabel";
108
+ "required": false;
109
+ "isSignal": true;
110
+ };
111
+ "searchPlaceholder": {
112
+ "alias": "searchPlaceholder";
113
+ "required": false;
114
+ "isSignal": true;
115
+ };
116
+ "emptyLabel": {
117
+ "alias": "emptyLabel";
118
+ "required": false;
119
+ "isSignal": true;
120
+ };
121
+ "variant": {
122
+ "alias": "variant";
123
+ "required": false;
124
+ "isSignal": true;
125
+ };
126
+ "disabled": {
127
+ "alias": "disabled";
128
+ "required": false;
129
+ "isSignal": true;
130
+ };
131
+ "busy": {
132
+ "alias": "busy";
133
+ "required": false;
134
+ "isSignal": true;
135
+ };
136
+ }, {
137
+ "languageChange": "languageChange";
138
+ }, never, never, true, never>;
139
+ }
140
+ /**
141
+ * Map languages to `rv-select` options, in the order given.
142
+ *
143
+ * The visible name follows the same rule as the `/ui` toggle
144
+ * (`nativeName` → `Intl.DisplayNames` → id). The id is repeated as `lang`, and
145
+ * as a `hint` only when it adds information — a row whose label already is
146
+ * the id would otherwise print the same text twice.
147
+ */
148
+ export declare function languageSelectOptions(languages: readonly LanguageLike$1[]): readonly LanguageSelectOption[];
149
+ export type { LanguageLike, LanguageSelectOption, RiviniaLanguageManager };