@kungal/ui-core 2.53.0 → 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/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  export { ClassValue } from 'clsx';
3
- import { K as KunMessages, a as KunMessagePath, b as KunMessageCatalog } from './types-Dc-w7UpA.cjs';
4
- export { c as KunTranslate } from './types-Dc-w7UpA.cjs';
3
+ import { K as KunMessages, a as KunMessagePath, b as KunMessageCatalog } from './types-KUpDlvb1.cjs';
4
+ export { c as KunKbdKeyName, d as KunShortcutKey, e as KunShortcutPlatform, f as KunTranslate, g as formatKunShortcut, p as parseKunShortcut, r as resolveKunShortcut, s as speakKunShortcut } from './types-KUpDlvb1.cjs';
5
5
 
6
6
  type KunUIVariant = 'solid' | 'bordered' | 'light' | 'flat' | 'shadow';
7
7
  type KunUIColor = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info';
@@ -115,6 +115,14 @@ declare const translateKunMessage: (messages: KunMessages, path: KunMessagePath,
115
115
 
116
116
  declare const KUN_CATALOG_ZH_CN: KunMessageCatalog;
117
117
 
118
+ /** Drop separators that would render as stray lines: leading, trailing, and
119
+ * all but the first of a run. An app filters one command table per context
120
+ * (no "Delete" for a post you do not own) and its separators have to follow;
121
+ * React Spectrum S2 hides the same three cases. */
122
+ declare const normalizeKunMenuSeparators: <T extends {
123
+ type?: string;
124
+ }>(entries: readonly T[]) => T[];
125
+
118
126
  declare const randomNum: (lowerValue: number, upperValue: number) => number;
119
127
 
120
128
  declare const decodeIfEncoded: (text: string) => string;
@@ -508,4 +516,4 @@ declare const registerKunIcons: (icons: Record<string, KunIconData>) => void;
508
516
  declare const getKunIcon: (name: string) => KunIconData | undefined;
509
517
  declare const hasKunIcon: (name: string) => boolean;
510
518
 
511
- export { KUN_AVATAR_FALLBACK, KUN_CATALOG_ZH_CN, KUN_CHAT_ALBUM_LIMIT, KUN_CHAT_ALBUM_SIDE, KUN_CHAT_BLOCK_ENTITY_TYPES, KUN_CHAT_TEXT_LIMIT, KUN_CHAT_TYPING_INTERVAL, KUN_CHAT_TYPING_TIMEOUT, KUN_DEFAULT_ROUNDED, KUN_SHATTER_PHYSICS, KUN_SWIPE_DISMISS_PHYSICS, type KunAvatarDecoration, type KunChatAlbumLayout, type KunChatAlbumOptions, type KunChatAlbumSize, type KunChatAlbumTile, type KunChatContext, type KunChatDaySection, type KunChatEntity, type KunChatEntityNode, type KunChatEntityType, type KunChatFormattedText, type KunChatGroupOptions, type KunChatListRow, type KunChatMedia, type KunChatMessage, type KunChatPhoto, type KunChatReaction, type KunChatReactionOption, type KunChatReplyQuote, type KunChatReplyTo, type KunChatSendStatus, type KunChatServiceAction, type KunChatServiceActionType, type KunChatTextLeaf, type KunChatTextNode, type KunChatTypingEvent, type KunChatUser, type KunIconData, KunMessageCatalog, KunMessagePath, KunMessages, type KunSelectionSize, type KunUIColor, type KunUIRounded, type KunUISize, type KunUIVariant, type KunUser, buildKunChatEntityTree, cn, decodeIfEncoded, formatKunChatMarkdown, getKunIcon, getRandomSticker, groupKunChatMessages, hasKunIcon, kunBgClasses, kunBorderClasses, kunChatDayKey, kunChatMessageKey, kunChatTreeText, kunChipSizeClasses, kunControlSizeClasses, kunControlSquareClasses, kunFocusRingClasses, kunFocusRingWithinClasses, kunPanelRoundedClass, kunRingClasses, kunRoundedClasses, kunSelectionSizeClasses, kunSoftBgClasses, kunSolidBgClasses, kunSolidClasses, kunSolidFgClasses, kunTextClasses, kunVariantClasses, layoutKunChatAlbum, normalizeKunChatEntities, parseKunChatMarkdown, pickAvatarFallback, randomNum, registerKunIcon, registerKunIcons, resolveRounded, sliceKunChatEntities, translateKunMessage };
519
+ export { KUN_AVATAR_FALLBACK, KUN_CATALOG_ZH_CN, KUN_CHAT_ALBUM_LIMIT, KUN_CHAT_ALBUM_SIDE, KUN_CHAT_BLOCK_ENTITY_TYPES, KUN_CHAT_TEXT_LIMIT, KUN_CHAT_TYPING_INTERVAL, KUN_CHAT_TYPING_TIMEOUT, KUN_DEFAULT_ROUNDED, KUN_SHATTER_PHYSICS, KUN_SWIPE_DISMISS_PHYSICS, type KunAvatarDecoration, type KunChatAlbumLayout, type KunChatAlbumOptions, type KunChatAlbumSize, type KunChatAlbumTile, type KunChatContext, type KunChatDaySection, type KunChatEntity, type KunChatEntityNode, type KunChatEntityType, type KunChatFormattedText, type KunChatGroupOptions, type KunChatListRow, type KunChatMedia, type KunChatMessage, type KunChatPhoto, type KunChatReaction, type KunChatReactionOption, type KunChatReplyQuote, type KunChatReplyTo, type KunChatSendStatus, type KunChatServiceAction, type KunChatServiceActionType, type KunChatTextLeaf, type KunChatTextNode, type KunChatTypingEvent, type KunChatUser, type KunIconData, KunMessageCatalog, KunMessagePath, KunMessages, type KunSelectionSize, type KunUIColor, type KunUIRounded, type KunUISize, type KunUIVariant, type KunUser, buildKunChatEntityTree, cn, decodeIfEncoded, formatKunChatMarkdown, getKunIcon, getRandomSticker, groupKunChatMessages, hasKunIcon, kunBgClasses, kunBorderClasses, kunChatDayKey, kunChatMessageKey, kunChatTreeText, kunChipSizeClasses, kunControlSizeClasses, kunControlSquareClasses, kunFocusRingClasses, kunFocusRingWithinClasses, kunPanelRoundedClass, kunRingClasses, kunRoundedClasses, kunSelectionSizeClasses, kunSoftBgClasses, kunSolidBgClasses, kunSolidClasses, kunSolidFgClasses, kunTextClasses, kunVariantClasses, layoutKunChatAlbum, normalizeKunChatEntities, normalizeKunMenuSeparators, parseKunChatMarkdown, pickAvatarFallback, randomNum, registerKunIcon, registerKunIcons, resolveRounded, sliceKunChatEntities, translateKunMessage };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ClassValue } from 'clsx';
2
2
  export { ClassValue } from 'clsx';
3
- import { K as KunMessages, a as KunMessagePath, b as KunMessageCatalog } from './types-Dc-w7UpA.js';
4
- export { c as KunTranslate } from './types-Dc-w7UpA.js';
3
+ import { K as KunMessages, a as KunMessagePath, b as KunMessageCatalog } from './types-KUpDlvb1.js';
4
+ export { c as KunKbdKeyName, d as KunShortcutKey, e as KunShortcutPlatform, f as KunTranslate, g as formatKunShortcut, p as parseKunShortcut, r as resolveKunShortcut, s as speakKunShortcut } from './types-KUpDlvb1.js';
5
5
 
6
6
  type KunUIVariant = 'solid' | 'bordered' | 'light' | 'flat' | 'shadow';
7
7
  type KunUIColor = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info';
@@ -115,6 +115,14 @@ declare const translateKunMessage: (messages: KunMessages, path: KunMessagePath,
115
115
 
116
116
  declare const KUN_CATALOG_ZH_CN: KunMessageCatalog;
117
117
 
118
+ /** Drop separators that would render as stray lines: leading, trailing, and
119
+ * all but the first of a run. An app filters one command table per context
120
+ * (no "Delete" for a post you do not own) and its separators have to follow;
121
+ * React Spectrum S2 hides the same three cases. */
122
+ declare const normalizeKunMenuSeparators: <T extends {
123
+ type?: string;
124
+ }>(entries: readonly T[]) => T[];
125
+
118
126
  declare const randomNum: (lowerValue: number, upperValue: number) => number;
119
127
 
120
128
  declare const decodeIfEncoded: (text: string) => string;
@@ -508,4 +516,4 @@ declare const registerKunIcons: (icons: Record<string, KunIconData>) => void;
508
516
  declare const getKunIcon: (name: string) => KunIconData | undefined;
509
517
  declare const hasKunIcon: (name: string) => boolean;
510
518
 
511
- export { KUN_AVATAR_FALLBACK, KUN_CATALOG_ZH_CN, KUN_CHAT_ALBUM_LIMIT, KUN_CHAT_ALBUM_SIDE, KUN_CHAT_BLOCK_ENTITY_TYPES, KUN_CHAT_TEXT_LIMIT, KUN_CHAT_TYPING_INTERVAL, KUN_CHAT_TYPING_TIMEOUT, KUN_DEFAULT_ROUNDED, KUN_SHATTER_PHYSICS, KUN_SWIPE_DISMISS_PHYSICS, type KunAvatarDecoration, type KunChatAlbumLayout, type KunChatAlbumOptions, type KunChatAlbumSize, type KunChatAlbumTile, type KunChatContext, type KunChatDaySection, type KunChatEntity, type KunChatEntityNode, type KunChatEntityType, type KunChatFormattedText, type KunChatGroupOptions, type KunChatListRow, type KunChatMedia, type KunChatMessage, type KunChatPhoto, type KunChatReaction, type KunChatReactionOption, type KunChatReplyQuote, type KunChatReplyTo, type KunChatSendStatus, type KunChatServiceAction, type KunChatServiceActionType, type KunChatTextLeaf, type KunChatTextNode, type KunChatTypingEvent, type KunChatUser, type KunIconData, KunMessageCatalog, KunMessagePath, KunMessages, type KunSelectionSize, type KunUIColor, type KunUIRounded, type KunUISize, type KunUIVariant, type KunUser, buildKunChatEntityTree, cn, decodeIfEncoded, formatKunChatMarkdown, getKunIcon, getRandomSticker, groupKunChatMessages, hasKunIcon, kunBgClasses, kunBorderClasses, kunChatDayKey, kunChatMessageKey, kunChatTreeText, kunChipSizeClasses, kunControlSizeClasses, kunControlSquareClasses, kunFocusRingClasses, kunFocusRingWithinClasses, kunPanelRoundedClass, kunRingClasses, kunRoundedClasses, kunSelectionSizeClasses, kunSoftBgClasses, kunSolidBgClasses, kunSolidClasses, kunSolidFgClasses, kunTextClasses, kunVariantClasses, layoutKunChatAlbum, normalizeKunChatEntities, parseKunChatMarkdown, pickAvatarFallback, randomNum, registerKunIcon, registerKunIcons, resolveRounded, sliceKunChatEntities, translateKunMessage };
519
+ export { KUN_AVATAR_FALLBACK, KUN_CATALOG_ZH_CN, KUN_CHAT_ALBUM_LIMIT, KUN_CHAT_ALBUM_SIDE, KUN_CHAT_BLOCK_ENTITY_TYPES, KUN_CHAT_TEXT_LIMIT, KUN_CHAT_TYPING_INTERVAL, KUN_CHAT_TYPING_TIMEOUT, KUN_DEFAULT_ROUNDED, KUN_SHATTER_PHYSICS, KUN_SWIPE_DISMISS_PHYSICS, type KunAvatarDecoration, type KunChatAlbumLayout, type KunChatAlbumOptions, type KunChatAlbumSize, type KunChatAlbumTile, type KunChatContext, type KunChatDaySection, type KunChatEntity, type KunChatEntityNode, type KunChatEntityType, type KunChatFormattedText, type KunChatGroupOptions, type KunChatListRow, type KunChatMedia, type KunChatMessage, type KunChatPhoto, type KunChatReaction, type KunChatReactionOption, type KunChatReplyQuote, type KunChatReplyTo, type KunChatSendStatus, type KunChatServiceAction, type KunChatServiceActionType, type KunChatTextLeaf, type KunChatTextNode, type KunChatTypingEvent, type KunChatUser, type KunIconData, KunMessageCatalog, KunMessagePath, KunMessages, type KunSelectionSize, type KunUIColor, type KunUIRounded, type KunUISize, type KunUIVariant, type KunUser, buildKunChatEntityTree, cn, decodeIfEncoded, formatKunChatMarkdown, getKunIcon, getRandomSticker, groupKunChatMessages, hasKunIcon, kunBgClasses, kunBorderClasses, kunChatDayKey, kunChatMessageKey, kunChatTreeText, kunChipSizeClasses, kunControlSizeClasses, kunControlSquareClasses, kunFocusRingClasses, kunFocusRingWithinClasses, kunPanelRoundedClass, kunRingClasses, kunRoundedClasses, kunSelectionSizeClasses, kunSoftBgClasses, kunSolidBgClasses, kunSolidClasses, kunSolidFgClasses, kunTextClasses, kunVariantClasses, layoutKunChatAlbum, normalizeKunChatEntities, normalizeKunMenuSeparators, parseKunChatMarkdown, pickAvatarFallback, randomNum, registerKunIcon, registerKunIcons, resolveRounded, sliceKunChatEntities, translateKunMessage };
package/dist/index.js CHANGED
@@ -456,6 +456,30 @@ var zh_CN_default = {
456
456
  reveal: "显示密码",
457
457
  hide: "隐藏密码"
458
458
  },
459
+ kbd: {
460
+ control: "Ctrl",
461
+ alt: "Alt",
462
+ option: "Option",
463
+ shift: "Shift",
464
+ command: "Command",
465
+ meta: "Windows 键",
466
+ enter: "回车",
467
+ escape: "Esc",
468
+ backspace: "退格",
469
+ delete: "删除",
470
+ tab: "Tab",
471
+ space: "空格",
472
+ up: "上箭头",
473
+ down: "下箭头",
474
+ left: "左箭头",
475
+ right: "右箭头",
476
+ pageUp: "向上翻页",
477
+ pageDown: "向下翻页",
478
+ home: "Home",
479
+ end: "End",
480
+ plus: "加号",
481
+ then: "然后"
482
+ },
459
483
  lightbox: {
460
484
  label: "图片查看器",
461
485
  close: "关闭",
@@ -550,6 +574,114 @@ var zh_CN_default = {
550
574
  // src/locale/zh-CN.ts
551
575
  var KUN_CATALOG_ZH_CN = zh_CN_default;
552
576
 
577
+ // src/shortcut.ts
578
+ var ALIASES = {
579
+ mod: "Mod",
580
+ ctrl: "Control",
581
+ control: "Control",
582
+ alt: "Alt",
583
+ option: "Alt",
584
+ opt: "Alt",
585
+ shift: "Shift",
586
+ meta: "Meta",
587
+ cmd: "Meta",
588
+ command: "Meta",
589
+ super: "Meta",
590
+ win: "Meta",
591
+ enter: "Enter",
592
+ return: "Enter",
593
+ esc: "Escape",
594
+ escape: "Escape",
595
+ backspace: "Backspace",
596
+ del: "Delete",
597
+ delete: "Delete",
598
+ tab: "Tab",
599
+ space: "Space",
600
+ spacebar: "Space",
601
+ up: "ArrowUp",
602
+ arrowup: "ArrowUp",
603
+ down: "ArrowDown",
604
+ arrowdown: "ArrowDown",
605
+ left: "ArrowLeft",
606
+ arrowleft: "ArrowLeft",
607
+ right: "ArrowRight",
608
+ arrowright: "ArrowRight",
609
+ pageup: "PageUp",
610
+ pgup: "PageUp",
611
+ pagedown: "PageDown",
612
+ pgdn: "PageDown",
613
+ home: "Home",
614
+ end: "End",
615
+ plus: "+"
616
+ };
617
+ var MODIFIER_ORDER = {
618
+ apple: ["Control", "Alt", "Shift", "Meta"],
619
+ other: ["Control", "Meta", "Alt", "Shift"]
620
+ };
621
+ var NAMED = {
622
+ Control: { apple: "⌃", other: "Ctrl", spoken: () => "control" },
623
+ Alt: { apple: "⌥", other: "Alt", spoken: (p) => p === "apple" ? "option" : "alt" },
624
+ Shift: { apple: "⇧", other: "Shift", spoken: () => "shift" },
625
+ Meta: { apple: "⌘", other: "Win", spoken: (p) => p === "apple" ? "command" : "meta" },
626
+ Enter: { apple: "↩", other: "Enter", spoken: () => "enter" },
627
+ Escape: { apple: "Esc", other: "Esc", spoken: () => "escape" },
628
+ Backspace: { apple: "⌫", other: "Backspace", spoken: () => "backspace" },
629
+ Delete: { apple: "⌦", other: "Del", spoken: () => "delete" },
630
+ Tab: { apple: "⇥", other: "Tab", spoken: () => "tab" },
631
+ Space: { apple: "Space", other: "Space", spoken: () => "space" },
632
+ ArrowUp: { apple: "↑", other: "↑", spoken: () => "up" },
633
+ ArrowDown: { apple: "↓", other: "↓", spoken: () => "down" },
634
+ ArrowLeft: { apple: "←", other: "←", spoken: () => "left" },
635
+ ArrowRight: { apple: "→", other: "→", spoken: () => "right" },
636
+ PageUp: { apple: "PgUp", other: "PgUp", spoken: () => "pageUp" },
637
+ PageDown: { apple: "PgDn", other: "PgDn", spoken: () => "pageDown" },
638
+ Home: { apple: "Home", other: "Home", spoken: () => "home" },
639
+ End: { apple: "End", other: "End", spoken: () => "end" },
640
+ "+": { apple: "+", other: "+", spoken: () => "plus" }
641
+ };
642
+ var canonicalKey = (token) => {
643
+ const alias = ALIASES[token.toLowerCase()];
644
+ if (alias) return alias;
645
+ if (/^f\d{1,2}$/i.test(token)) return token.toUpperCase();
646
+ return token.length === 1 ? token.toUpperCase() : token;
647
+ };
648
+ var splitChord = (chord) => {
649
+ if (chord === "+") return ["+"];
650
+ const plusKey = chord.endsWith("++");
651
+ const body = plusKey ? chord.slice(0, -2) : chord;
652
+ const keys = body.split("+").filter(Boolean);
653
+ return plusKey ? [...keys, "+"] : keys;
654
+ };
655
+ var parseKunShortcut = (keys) => keys.trim().split(/\s+/).filter(Boolean).map((chord) => splitChord(chord).map(canonicalKey)).filter((chord) => chord.length > 0);
656
+ var resolveKunShortcut = (keys, platform) => {
657
+ const order = MODIFIER_ORDER[platform];
658
+ return parseKunShortcut(keys).map((chord) => {
659
+ const resolved = chord.map(
660
+ (key) => key === "Mod" ? platform === "apple" ? "Meta" : "Control" : key
661
+ );
662
+ const modifiers = order.filter((m) => resolved.includes(m));
663
+ const rest = resolved.filter((k, i) => !order.includes(k) && resolved.indexOf(k) === i);
664
+ return [...modifiers, ...rest].map((key) => {
665
+ const named = NAMED[key];
666
+ return named ? { key, label: named[platform], spoken: named.spoken(platform) } : { key, label: key, spoken: null };
667
+ });
668
+ });
669
+ };
670
+ var formatKunShortcut = (keys, platform) => resolveKunShortcut(keys, platform).map((chord) => chord.map((k) => k.label).join(platform === "apple" ? "" : "+")).join(" ");
671
+ var speakKunShortcut = (sequence, name, then) => sequence.map((chord) => chord.map((k) => k.spoken ? name(k.spoken) : k.label).join(" ")).join(` ${then} `);
672
+
673
+ // src/menu.ts
674
+ var normalizeKunMenuSeparators = (entries) => {
675
+ const out = [];
676
+ for (const entry of entries) {
677
+ const last = out[out.length - 1];
678
+ if (entry.type === "separator" && (!last || last.type === "separator")) continue;
679
+ out.push(entry);
680
+ }
681
+ while (out.length && out[out.length - 1].type === "separator") out.pop();
682
+ return out;
683
+ };
684
+
553
685
  // src/random.ts
554
686
  var randomNum = (lowerValue, upperValue) => Math.floor(Math.random() * (upperValue - lowerValue + 1) + lowerValue);
555
687
 
@@ -1565,6 +1697,6 @@ var registerKunIcons = (icons) => {
1565
1697
  var getKunIcon = (name) => registry.get(name);
1566
1698
  var hasKunIcon = (name) => registry.has(name);
1567
1699
 
1568
- export { KUN_AVATAR_FALLBACK, KUN_CATALOG_ZH_CN, KUN_CHAT_ALBUM_LIMIT, KUN_CHAT_ALBUM_SIDE, KUN_CHAT_BLOCK_ENTITY_TYPES, KUN_CHAT_TEXT_LIMIT, KUN_CHAT_TYPING_INTERVAL, KUN_CHAT_TYPING_TIMEOUT, KUN_DEFAULT_ROUNDED, KUN_SHATTER_PHYSICS, KUN_SWIPE_DISMISS_PHYSICS, buildKunChatEntityTree, cn, decodeIfEncoded, formatKunChatMarkdown, getKunIcon, getRandomSticker, groupKunChatMessages, hasKunIcon, kunBgClasses, kunBorderClasses, kunChatDayKey, kunChatMessageKey, kunChatTreeText, kunChipSizeClasses, kunControlSizeClasses, kunControlSquareClasses, kunFocusRingClasses, kunFocusRingWithinClasses, kunPanelRoundedClass, kunRingClasses, kunRoundedClasses, kunSelectionSizeClasses, kunSoftBgClasses, kunSolidBgClasses, kunSolidClasses, kunSolidFgClasses, kunTextClasses, kunVariantClasses, layoutKunChatAlbum, normalizeKunChatEntities, parseKunChatMarkdown, pickAvatarFallback, randomNum, registerKunIcon, registerKunIcons, resolveRounded, sliceKunChatEntities, translateKunMessage };
1700
+ export { KUN_AVATAR_FALLBACK, KUN_CATALOG_ZH_CN, KUN_CHAT_ALBUM_LIMIT, KUN_CHAT_ALBUM_SIDE, KUN_CHAT_BLOCK_ENTITY_TYPES, KUN_CHAT_TEXT_LIMIT, KUN_CHAT_TYPING_INTERVAL, KUN_CHAT_TYPING_TIMEOUT, KUN_DEFAULT_ROUNDED, KUN_SHATTER_PHYSICS, KUN_SWIPE_DISMISS_PHYSICS, buildKunChatEntityTree, cn, decodeIfEncoded, formatKunChatMarkdown, formatKunShortcut, getKunIcon, getRandomSticker, groupKunChatMessages, hasKunIcon, kunBgClasses, kunBorderClasses, kunChatDayKey, kunChatMessageKey, kunChatTreeText, kunChipSizeClasses, kunControlSizeClasses, kunControlSquareClasses, kunFocusRingClasses, kunFocusRingWithinClasses, kunPanelRoundedClass, kunRingClasses, kunRoundedClasses, kunSelectionSizeClasses, kunSoftBgClasses, kunSolidBgClasses, kunSolidClasses, kunSolidFgClasses, kunTextClasses, kunVariantClasses, layoutKunChatAlbum, normalizeKunChatEntities, normalizeKunMenuSeparators, parseKunChatMarkdown, parseKunShortcut, pickAvatarFallback, randomNum, registerKunIcon, registerKunIcons, resolveKunShortcut, resolveRounded, sliceKunChatEntities, speakKunShortcut, translateKunMessage };
1569
1701
  //# sourceMappingURL=index.js.map
1570
1702
  //# sourceMappingURL=index.js.map