@celestia-island/hikari 0.40.2 → 0.40.3
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/package.json
CHANGED
|
@@ -117,6 +117,26 @@ describe("HkPhoneInput", () => {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
it("still finds the PRC row when searching the short alias", async () => {
|
|
121
|
+
const { container } = mountPhone();
|
|
122
|
+
await openPicker(container);
|
|
123
|
+
// The row renders the formal zh name (中华人民共和国), which no longer
|
|
124
|
+
// contains 中国 as a substring — the catalog's zhAlias keeps the old
|
|
125
|
+
// short form reachable from the search field.
|
|
126
|
+
const search = document.querySelector<HTMLInputElement>(
|
|
127
|
+
".hk-affix-search .hk-input-element",
|
|
128
|
+
);
|
|
129
|
+
expect(search, "popup search field renders").toBeTruthy();
|
|
130
|
+
search!.value = "中国";
|
|
131
|
+
search!.dispatchEvent(new Event("input"));
|
|
132
|
+
await nextTick();
|
|
133
|
+
await nextTick();
|
|
134
|
+
const rows = pickerRows();
|
|
135
|
+
expect(rows.length).toBeGreaterThan(0);
|
|
136
|
+
expect(rows[0].textContent).toContain("China");
|
|
137
|
+
expect(rows[0].textContent).toContain("+86");
|
|
138
|
+
});
|
|
139
|
+
|
|
120
140
|
it("picks a country from the list and refocuses the number field", async () => {
|
|
121
141
|
const { container, events } = mountPhone();
|
|
122
142
|
await openPicker(container);
|
|
@@ -102,14 +102,15 @@ export const HkPhoneInput = defineComponent({
|
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
/** Picker rows come from the shared affix catalog shape; the
|
|
105
|
-
* keywords haystack keeps the old filter reach: en/zh names
|
|
106
|
-
* code, bare and zero-prefixed
|
|
105
|
+
* keywords haystack keeps the old filter reach: en/zh names plus
|
|
106
|
+
* the optional zh search alias, ISO code, bare and zero-prefixed
|
|
107
|
+
* dial digits ("86"/"0086"). */
|
|
107
108
|
const dialOptions = computed<readonly HkAffixOption[]>(() =>
|
|
108
109
|
props.countries.map((c) => ({
|
|
109
110
|
key: c.iso,
|
|
110
111
|
label: dialCodeName(c, locale),
|
|
111
112
|
meta: `+${c.dial}`,
|
|
112
|
-
keywords: `${c.en} ${c.zh} ${c.iso} +${c.dial} 00${c.dial}`,
|
|
113
|
+
keywords: `${c.en} ${c.zh} ${c.zhAlias ?? ""} ${c.iso} +${c.dial} 00${c.dial}`,
|
|
113
114
|
})),
|
|
114
115
|
);
|
|
115
116
|
|
|
@@ -12,7 +12,13 @@ import {
|
|
|
12
12
|
|
|
13
13
|
describe("dialCodes catalog", () => {
|
|
14
14
|
it("starts with China and contains the expected shape", () => {
|
|
15
|
-
expect(DIAL_CODES[0]).toMatchObject({
|
|
15
|
+
expect(DIAL_CODES[0]).toMatchObject({
|
|
16
|
+
iso: "cn",
|
|
17
|
+
dial: "86",
|
|
18
|
+
en: "China",
|
|
19
|
+
zh: "中华人民共和国",
|
|
20
|
+
zhAlias: "中国",
|
|
21
|
+
});
|
|
16
22
|
for (const entry of DIAL_CODES) {
|
|
17
23
|
expect(entry.iso).toMatch(/^[a-z]{2}$/);
|
|
18
24
|
expect(entry.dial).toMatch(/^\d+$/);
|
package/src/data/dialCodes.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface DialCodeEntry {
|
|
|
19
19
|
en: string;
|
|
20
20
|
/** Simplified Chinese country name. */
|
|
21
21
|
zh: string;
|
|
22
|
+
/** Search-only Chinese alias — never rendered as the display name.
|
|
23
|
+
* HkPhoneInput folds it into the popup's keyword haystack so the old
|
|
24
|
+
* short form still finds the entry after a formal rename (e.g. the
|
|
25
|
+
* PRC row renamed to 中华人民共和国 no longer contains 中国 as a
|
|
26
|
+
* substring). */
|
|
27
|
+
zhAlias?: string;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
/** Flag glyph for an ISO 3166-1 alpha-2 code (regional indicators). */
|
|
@@ -43,7 +49,7 @@ export function dialCodeName(entry: DialCodeEntry, locale: string): string {
|
|
|
43
49
|
* prefixes like +1 / +7).
|
|
44
50
|
*/
|
|
45
51
|
export const DIAL_CODES: readonly DialCodeEntry[] = [
|
|
46
|
-
{ iso: "cn", dial: "86", en: "China", zh: "中国" },
|
|
52
|
+
{ iso: "cn", dial: "86", en: "China", zh: "中华人民共和国", zhAlias: "中国" },
|
|
47
53
|
{ iso: "hk", dial: "852", en: "Hong Kong (China)", zh: "中国香港" },
|
|
48
54
|
{ iso: "mo", dial: "853", en: "Macau (China)", zh: "中国澳门" },
|
|
49
55
|
{ iso: "tw", dial: "886", en: "Taiwan (China)", zh: "中国台湾" },
|