This commit is contained in:
Mateusz Gruszczyński committed 2026-11-28 17:36:53 +01:00
1 parent 5b6d4a7903
commit 4d1087e357
160 files changed
+2407 -1933

No files matched your search

+2 -7
View File
@@ -99,9 +99,6 @@ window.rustProxyChoicePicker = (() => {
const maxHint = el("small", t("aclPickerLimit"), "fine acl-picker-limit");
dropdown.append(search, optionsBox, empty, maxHint); details.append(dropdown);
const selectedTags = el("div", undefined, "acl-picker-selected"); root.append(details, selectedTags);
// Option rows are built on the first open: long lists (countries) would
// otherwise add thousands of DOM nodes per picker. `state` is the source of
// truth for every option; `checks` holds only rendered checkboxes.
const items = [...(options.items || [])], state = new Map(), checks = new Map(), order = [];
let rendered = false;
const isChosen = id => state.get(id) === true;
@@ -223,14 +220,12 @@ window.rustProxyChipInput = (() => {
window.rustProxyCountryPicker = (() => {
const CODES = "AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS XK YE YT ZA ZM ZW".split(" ");
// Country names are resolved once per language: constructing Intl.DisplayNames
// for every lookup was a large part of rendering many country pickers.
const countryNames = new Map();
const nameOf = code => {
const lang = document.documentElement.lang || "en";
let names = countryNames.get(lang);
if (!names) { let display = null; try { display = new Intl.DisplayNames([lang], { type: "region" }); } catch { /* unsupported locale */ } names = { display, cache: new Map() }; countryNames.set(lang, names); }
if (!names.cache.has(code)) { let name = code; try { name = names.display?.of(code) || code; } catch { /* unknown region */ } names.cache.set(code, name); }
if (!names) { let display = null; try { display = new Intl.DisplayNames([lang], { type: "region" }); } catch { } names = { display, cache: new Map() }; countryNames.set(lang, names); }
if (!names.cache.has(code)) { let name = code; try { name = names.display?.of(code) || code; } catch { } names.cache.set(code, name); }
return names.cache.get(code);
};
const parse = text => [...new Set(String(text || "").split(/[\s,;]+/).map(value => value.trim().toUpperCase()).filter(Boolean))];