@kungal/ui-core 2.52.1 → 2.54.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 +37 -0
- package/dist/index.cjs +137 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +133 -1
- package/dist/index.js.map +1 -1
- package/dist/locale/en.cjs +24 -0
- package/dist/locale/en.cjs.map +1 -1
- package/dist/locale/en.d.cts +1 -1
- package/dist/locale/en.d.ts +1 -1
- package/dist/locale/en.js +24 -0
- package/dist/locale/en.js.map +1 -1
- package/dist/{types-Dc-w7UpA.d.cts → types-KUpDlvb1.d.cts} +34 -1
- package/dist/{types-Dc-w7UpA.d.ts → types-KUpDlvb1.d.ts} +34 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @kungal/ui-core
|
|
2
2
|
|
|
3
|
+
## 2.54.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5ca083f: Menus gain separators, shortcut hints and one level of submenu, and a new `KunKbd` shows keyboard shortcuts. Everything is additive: existing `items` arrays and props render exactly as before.
|
|
8
|
+
|
|
9
|
+
**KunContextMenu and KunDropdown** share one item list, so an app can render the same command list as a right-click menu, a ⋯ menu and a long-press menu. `items` now takes `KunMenuEntry[]`, which is an item or `{ type: 'separator' }`. `KunContextMenuItem[]` arrays are still accepted.
|
|
10
|
+
|
|
11
|
+
- **Separators.** Leading, trailing and repeated separators are dropped, so a list filtered per context never shows a stray line.
|
|
12
|
+
- **Shortcuts.** `shortcut: 'Mod+C'` shows ⌘C on Apple and Ctrl+C elsewhere at the item's end. It is display only; your app still binds the key. Screen readers read the item's label as its name and the shortcut as its description.
|
|
13
|
+
- **Submenus.** `children` opens a submenu, one level deep.
|
|
14
|
+
- Opening: hover (after 100 ms), →, Enter or a tap.
|
|
15
|
+
- Closing: ← and Escape close one level, as the WAI-ARIA menu pattern specifies; Tab closes the whole menu.
|
|
16
|
+
- A 300 ms grace period and a safe triangle keep the submenu open while the pointer moves diagonally towards it.
|
|
17
|
+
- An item with `children` never emits `select`; if a filter leaves it no child items, it shows disabled. Selecting a submenu item emits that item and closes everything.
|
|
18
|
+
- **Keyboard.** KunContextMenu now has the type-ahead KunDropdown already had. ↑ in a menu with nothing focused yet, such as right after a click opened it, now goes to the last item. Before, it went to the second-to-last.
|
|
19
|
+
- **Link items.** Enter or Space on an `href` item now follows the link. Before, it emitted `select` and closed without navigating.
|
|
20
|
+
|
|
21
|
+
**KunKbd** takes `keys` in the aria-keyshortcuts grammar plus `Mod`: `+` joins a chord and a space separates a sequence, e.g. `'Mod+K'`, `'Shift+Delete'`, `'G G'`.
|
|
22
|
+
|
|
23
|
+
- **Order.** Modifiers sort into each platform's order: ⌃⌥⇧⌘ on Apple, Ctrl+Win+Alt+Shift elsewhere.
|
|
24
|
+
- **Screen readers** hear key names ("Command K"), not glyphs.
|
|
25
|
+
- **Size** is in em, so it follows the surrounding text.
|
|
26
|
+
- **Variants.** `variant="plain"` is the one-line form menus use: ⇧⌘Z, or Ctrl+Shift+Z.
|
|
27
|
+
- **Server rendering.** The server cannot know the visitor's keyboard, so it renders the Ctrl form; a Mac switches to ⌘ once the page has mounted. Components created afterwards, such as a menu or tooltip opening, start in the right form.
|
|
28
|
+
- **Related APIs:**
|
|
29
|
+
- `KunTooltip` gains `shortcut`: `text="Search" shortcut="Mod+K"` renders "Search Ctrl K".
|
|
30
|
+
- `KunCommandPalette`'s `trigger` slot also passes `keys` for use with KunKbd.
|
|
31
|
+
- `useKunShortcutPlatform()` and `formatKunShortcut()` are exported for your own markup.
|
|
32
|
+
- The parser and formatter live in `@kungal/ui-core`, so the Flutter port renders the same labels.
|
|
33
|
+
|
|
34
|
+
**KunChip and KunTagInput:** the × remove button now has a 24×24 px hit area. The glyph did not change size: it was 14 px in KunChip and 18 px in KunTagInput, which is under WCAG 2.2's 24 px minimum. The hit area is not clipped: in Chromium, a clipped one measured worse than none, because it switches off the browser's own tap adjustment.
|
|
35
|
+
|
|
36
|
+
`useKunFloating`'s `offset` option now accepts floating-ui's full `OffsetOptions` (for example `{ mainAxis, crossAxis }`), not just a number.
|
|
37
|
+
|
|
38
|
+
## 2.53.0
|
|
39
|
+
|
|
3
40
|
## 2.52.1
|
|
4
41
|
|
|
5
42
|
## 2.52.0
|
package/dist/index.cjs
CHANGED
|
@@ -458,6 +458,30 @@ var zh_CN_default = {
|
|
|
458
458
|
reveal: "显示密码",
|
|
459
459
|
hide: "隐藏密码"
|
|
460
460
|
},
|
|
461
|
+
kbd: {
|
|
462
|
+
control: "Ctrl",
|
|
463
|
+
alt: "Alt",
|
|
464
|
+
option: "Option",
|
|
465
|
+
shift: "Shift",
|
|
466
|
+
command: "Command",
|
|
467
|
+
meta: "Windows 键",
|
|
468
|
+
enter: "回车",
|
|
469
|
+
escape: "Esc",
|
|
470
|
+
backspace: "退格",
|
|
471
|
+
delete: "删除",
|
|
472
|
+
tab: "Tab",
|
|
473
|
+
space: "空格",
|
|
474
|
+
up: "上箭头",
|
|
475
|
+
down: "下箭头",
|
|
476
|
+
left: "左箭头",
|
|
477
|
+
right: "右箭头",
|
|
478
|
+
pageUp: "向上翻页",
|
|
479
|
+
pageDown: "向下翻页",
|
|
480
|
+
home: "Home",
|
|
481
|
+
end: "End",
|
|
482
|
+
plus: "加号",
|
|
483
|
+
then: "然后"
|
|
484
|
+
},
|
|
461
485
|
lightbox: {
|
|
462
486
|
label: "图片查看器",
|
|
463
487
|
close: "关闭",
|
|
@@ -552,6 +576,114 @@ var zh_CN_default = {
|
|
|
552
576
|
// src/locale/zh-CN.ts
|
|
553
577
|
var KUN_CATALOG_ZH_CN = zh_CN_default;
|
|
554
578
|
|
|
579
|
+
// src/shortcut.ts
|
|
580
|
+
var ALIASES = {
|
|
581
|
+
mod: "Mod",
|
|
582
|
+
ctrl: "Control",
|
|
583
|
+
control: "Control",
|
|
584
|
+
alt: "Alt",
|
|
585
|
+
option: "Alt",
|
|
586
|
+
opt: "Alt",
|
|
587
|
+
shift: "Shift",
|
|
588
|
+
meta: "Meta",
|
|
589
|
+
cmd: "Meta",
|
|
590
|
+
command: "Meta",
|
|
591
|
+
super: "Meta",
|
|
592
|
+
win: "Meta",
|
|
593
|
+
enter: "Enter",
|
|
594
|
+
return: "Enter",
|
|
595
|
+
esc: "Escape",
|
|
596
|
+
escape: "Escape",
|
|
597
|
+
backspace: "Backspace",
|
|
598
|
+
del: "Delete",
|
|
599
|
+
delete: "Delete",
|
|
600
|
+
tab: "Tab",
|
|
601
|
+
space: "Space",
|
|
602
|
+
spacebar: "Space",
|
|
603
|
+
up: "ArrowUp",
|
|
604
|
+
arrowup: "ArrowUp",
|
|
605
|
+
down: "ArrowDown",
|
|
606
|
+
arrowdown: "ArrowDown",
|
|
607
|
+
left: "ArrowLeft",
|
|
608
|
+
arrowleft: "ArrowLeft",
|
|
609
|
+
right: "ArrowRight",
|
|
610
|
+
arrowright: "ArrowRight",
|
|
611
|
+
pageup: "PageUp",
|
|
612
|
+
pgup: "PageUp",
|
|
613
|
+
pagedown: "PageDown",
|
|
614
|
+
pgdn: "PageDown",
|
|
615
|
+
home: "Home",
|
|
616
|
+
end: "End",
|
|
617
|
+
plus: "+"
|
|
618
|
+
};
|
|
619
|
+
var MODIFIER_ORDER = {
|
|
620
|
+
apple: ["Control", "Alt", "Shift", "Meta"],
|
|
621
|
+
other: ["Control", "Meta", "Alt", "Shift"]
|
|
622
|
+
};
|
|
623
|
+
var NAMED = {
|
|
624
|
+
Control: { apple: "⌃", other: "Ctrl", spoken: () => "control" },
|
|
625
|
+
Alt: { apple: "⌥", other: "Alt", spoken: (p) => p === "apple" ? "option" : "alt" },
|
|
626
|
+
Shift: { apple: "⇧", other: "Shift", spoken: () => "shift" },
|
|
627
|
+
Meta: { apple: "⌘", other: "Win", spoken: (p) => p === "apple" ? "command" : "meta" },
|
|
628
|
+
Enter: { apple: "↩", other: "Enter", spoken: () => "enter" },
|
|
629
|
+
Escape: { apple: "Esc", other: "Esc", spoken: () => "escape" },
|
|
630
|
+
Backspace: { apple: "⌫", other: "Backspace", spoken: () => "backspace" },
|
|
631
|
+
Delete: { apple: "⌦", other: "Del", spoken: () => "delete" },
|
|
632
|
+
Tab: { apple: "⇥", other: "Tab", spoken: () => "tab" },
|
|
633
|
+
Space: { apple: "Space", other: "Space", spoken: () => "space" },
|
|
634
|
+
ArrowUp: { apple: "↑", other: "↑", spoken: () => "up" },
|
|
635
|
+
ArrowDown: { apple: "↓", other: "↓", spoken: () => "down" },
|
|
636
|
+
ArrowLeft: { apple: "←", other: "←", spoken: () => "left" },
|
|
637
|
+
ArrowRight: { apple: "→", other: "→", spoken: () => "right" },
|
|
638
|
+
PageUp: { apple: "PgUp", other: "PgUp", spoken: () => "pageUp" },
|
|
639
|
+
PageDown: { apple: "PgDn", other: "PgDn", spoken: () => "pageDown" },
|
|
640
|
+
Home: { apple: "Home", other: "Home", spoken: () => "home" },
|
|
641
|
+
End: { apple: "End", other: "End", spoken: () => "end" },
|
|
642
|
+
"+": { apple: "+", other: "+", spoken: () => "plus" }
|
|
643
|
+
};
|
|
644
|
+
var canonicalKey = (token) => {
|
|
645
|
+
const alias = ALIASES[token.toLowerCase()];
|
|
646
|
+
if (alias) return alias;
|
|
647
|
+
if (/^f\d{1,2}$/i.test(token)) return token.toUpperCase();
|
|
648
|
+
return token.length === 1 ? token.toUpperCase() : token;
|
|
649
|
+
};
|
|
650
|
+
var splitChord = (chord) => {
|
|
651
|
+
if (chord === "+") return ["+"];
|
|
652
|
+
const plusKey = chord.endsWith("++");
|
|
653
|
+
const body = plusKey ? chord.slice(0, -2) : chord;
|
|
654
|
+
const keys = body.split("+").filter(Boolean);
|
|
655
|
+
return plusKey ? [...keys, "+"] : keys;
|
|
656
|
+
};
|
|
657
|
+
var parseKunShortcut = (keys) => keys.trim().split(/\s+/).filter(Boolean).map((chord) => splitChord(chord).map(canonicalKey)).filter((chord) => chord.length > 0);
|
|
658
|
+
var resolveKunShortcut = (keys, platform) => {
|
|
659
|
+
const order = MODIFIER_ORDER[platform];
|
|
660
|
+
return parseKunShortcut(keys).map((chord) => {
|
|
661
|
+
const resolved = chord.map(
|
|
662
|
+
(key) => key === "Mod" ? platform === "apple" ? "Meta" : "Control" : key
|
|
663
|
+
);
|
|
664
|
+
const modifiers = order.filter((m) => resolved.includes(m));
|
|
665
|
+
const rest = resolved.filter((k, i) => !order.includes(k) && resolved.indexOf(k) === i);
|
|
666
|
+
return [...modifiers, ...rest].map((key) => {
|
|
667
|
+
const named = NAMED[key];
|
|
668
|
+
return named ? { key, label: named[platform], spoken: named.spoken(platform) } : { key, label: key, spoken: null };
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
var formatKunShortcut = (keys, platform) => resolveKunShortcut(keys, platform).map((chord) => chord.map((k) => k.label).join(platform === "apple" ? "" : "+")).join(" ");
|
|
673
|
+
var speakKunShortcut = (sequence, name, then) => sequence.map((chord) => chord.map((k) => k.spoken ? name(k.spoken) : k.label).join(" ")).join(` ${then} `);
|
|
674
|
+
|
|
675
|
+
// src/menu.ts
|
|
676
|
+
var normalizeKunMenuSeparators = (entries) => {
|
|
677
|
+
const out = [];
|
|
678
|
+
for (const entry of entries) {
|
|
679
|
+
const last = out[out.length - 1];
|
|
680
|
+
if (entry.type === "separator" && (!last || last.type === "separator")) continue;
|
|
681
|
+
out.push(entry);
|
|
682
|
+
}
|
|
683
|
+
while (out.length && out[out.length - 1].type === "separator") out.pop();
|
|
684
|
+
return out;
|
|
685
|
+
};
|
|
686
|
+
|
|
555
687
|
// src/random.ts
|
|
556
688
|
var randomNum = (lowerValue, upperValue) => Math.floor(Math.random() * (upperValue - lowerValue + 1) + lowerValue);
|
|
557
689
|
|
|
@@ -1582,6 +1714,7 @@ exports.buildKunChatEntityTree = buildKunChatEntityTree;
|
|
|
1582
1714
|
exports.cn = cn;
|
|
1583
1715
|
exports.decodeIfEncoded = decodeIfEncoded;
|
|
1584
1716
|
exports.formatKunChatMarkdown = formatKunChatMarkdown;
|
|
1717
|
+
exports.formatKunShortcut = formatKunShortcut;
|
|
1585
1718
|
exports.getKunIcon = getKunIcon;
|
|
1586
1719
|
exports.getRandomSticker = getRandomSticker;
|
|
1587
1720
|
exports.groupKunChatMessages = groupKunChatMessages;
|
|
@@ -1608,13 +1741,17 @@ exports.kunTextClasses = kunTextClasses;
|
|
|
1608
1741
|
exports.kunVariantClasses = kunVariantClasses;
|
|
1609
1742
|
exports.layoutKunChatAlbum = layoutKunChatAlbum;
|
|
1610
1743
|
exports.normalizeKunChatEntities = normalizeKunChatEntities;
|
|
1744
|
+
exports.normalizeKunMenuSeparators = normalizeKunMenuSeparators;
|
|
1611
1745
|
exports.parseKunChatMarkdown = parseKunChatMarkdown;
|
|
1746
|
+
exports.parseKunShortcut = parseKunShortcut;
|
|
1612
1747
|
exports.pickAvatarFallback = pickAvatarFallback;
|
|
1613
1748
|
exports.randomNum = randomNum;
|
|
1614
1749
|
exports.registerKunIcon = registerKunIcon;
|
|
1615
1750
|
exports.registerKunIcons = registerKunIcons;
|
|
1751
|
+
exports.resolveKunShortcut = resolveKunShortcut;
|
|
1616
1752
|
exports.resolveRounded = resolveRounded;
|
|
1617
1753
|
exports.sliceKunChatEntities = sliceKunChatEntities;
|
|
1754
|
+
exports.speakKunShortcut = speakKunShortcut;
|
|
1618
1755
|
exports.translateKunMessage = translateKunMessage;
|
|
1619
1756
|
//# sourceMappingURL=index.cjs.map
|
|
1620
1757
|
//# sourceMappingURL=index.cjs.map
|