@inf-monkeys-tech/monkeys-design 2.0.439 → 2.0.440

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.
Files changed (35) hide show
  1. package/dist/{I18nSubMenu-MDIVPB3E.mjs → I18nSubMenu-7S5TO2WP.mjs} +1 -1
  2. package/dist/{I18nSubMenu-RTTG52OF.mjs → I18nSubMenu-G3GNE6ZR.mjs} +1 -1
  3. package/dist/{I18nSubMenu-BY5IGIDZ.js → I18nSubMenu-KKGFUUP4.js} +1 -1
  4. package/dist/I18nSubMenu-ZBYCK4XW.js +1 -0
  5. package/dist/{chunk-XMSQGUUG.mjs → chunk-2V4F4RF6.mjs} +1 -1
  6. package/dist/{chunk-7642OAHR.js → chunk-C3AKQ57B.js} +1 -1
  7. package/dist/chunk-ICHXWGKE.js +1 -0
  8. package/dist/chunk-IIAHYZLC.mjs +1 -0
  9. package/dist/{chunk-2VPEGVKU.mjs → chunk-M5WO5C64.mjs} +1 -1
  10. package/dist/{chunk-WYV5KVTD.js → chunk-P2CNUNQD.js} +1 -1
  11. package/dist/components/assembly/index.js +1 -1
  12. package/dist/components/assembly/index.mjs +1 -1
  13. package/dist/components/assembly/runtime.js +1 -1
  14. package/dist/components/assembly/runtime.mjs +1 -1
  15. package/dist/components/assembly/validation.js +1 -1
  16. package/dist/components/assembly/validation.mjs +1 -1
  17. package/dist/components/toolbar/index.d.mts +10 -14
  18. package/dist/components/toolbar/index.d.ts +10 -14
  19. package/dist/components/toolbar/index.js +18 -10
  20. package/dist/components/toolbar/index.js.map +1 -1
  21. package/dist/components/toolbar/index.mjs +16 -6
  22. package/dist/components/toolbar/index.mjs.map +1 -1
  23. package/dist/index.js +249 -249
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +19 -19
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/sources/3d0ca7e865e271c3c07d8e989171cec7aa332e58e3be65528a48505551b74e4c.tsx +132 -0
  28. package/dist/sources/f77b4bc374bfc17968c1cba04c235fb96c18fe47f7a9f656e01c04ff064a27dd.tsx +131 -0
  29. package/dist/styles.css +1 -1
  30. package/package.json +2 -2
  31. package/dist/I18nSubMenu-COEFAU6S.js +0 -1
  32. package/dist/chunk-L4JHU5HD.js +0 -1
  33. package/dist/chunk-TJWWFSDW.mjs +0 -1
  34. package/dist/sources/8239c27056c1a7c1d308d0f576e5580306a697197a7056adbd8a57ce8b89a660.tsx +0 -174
  35. package/dist/sources/e12214d74e4f69bbcc7ca180b77a4e64caeed5ffa953eb30d6343f11b9adeede.tsx +0 -241
@@ -0,0 +1,132 @@
1
+ import type { CSSProperties } from 'react';
2
+ import { Languages } from 'lucide-react';
3
+
4
+ import { zhCN } from '../../locale/zh-CN';
5
+ import { useMonkeysComponentAttributes, useMonkeysLocale } from '../../provider/context';
6
+ import { cn } from '../base/utils';
7
+ import {
8
+ DropdownMenu,
9
+ DropdownMenuCheckboxItem,
10
+ DropdownMenuContent,
11
+ DropdownMenuItem,
12
+ DropdownMenuPortal,
13
+ DropdownMenuSub,
14
+ DropdownMenuSubContent,
15
+ DropdownMenuSubTrigger,
16
+ DropdownMenuTrigger,
17
+ } from '../primitives/Menus';
18
+ import * as Tooltip from '../primitives/tooltip-adapter';
19
+
20
+ export interface I18nLanguage {
21
+ code: string;
22
+ label: string;
23
+ }
24
+
25
+ export interface I18nSelectorProps {
26
+ languages: I18nLanguage[];
27
+ currentLanguage: string;
28
+ onLanguageChange: (code: string) => void;
29
+ tooltip?: string;
30
+ className?: string;
31
+ }
32
+
33
+ export function I18nSelector({ languages, currentLanguage, onLanguageChange, tooltip, className }: I18nSelectorProps) {
34
+ const { messages } = useMonkeysLocale();
35
+ const componentAttributes = useMonkeysComponentAttributes();
36
+ const trigger = (
37
+ <DropdownMenuTrigger asChild>
38
+ <button
39
+ {...componentAttributes}
40
+ className={cn(
41
+ 'inline-flex h-8 w-8 items-center justify-center rounded-md text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden',
42
+ className,
43
+ )}
44
+ >
45
+ <Languages size={16} aria-hidden="true" />
46
+ <span className="sr-only">{tooltip ?? messages.toolbar.language.switch}</span>
47
+ </button>
48
+ </DropdownMenuTrigger>
49
+ );
50
+
51
+ return (
52
+ <DropdownMenu>
53
+ {tooltip ? (
54
+ <Tooltip.Provider delayDuration={300}>
55
+ <Tooltip.Root>
56
+ <Tooltip.Trigger asChild>{trigger}</Tooltip.Trigger>
57
+ <Tooltip.Portal>
58
+ <Tooltip.Content
59
+ className="rounded-md border border-border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95"
60
+ sideOffset={5}
61
+ >
62
+ {tooltip}
63
+ </Tooltip.Content>
64
+ </Tooltip.Portal>
65
+ </Tooltip.Root>
66
+ </Tooltip.Provider>
67
+ ) : (
68
+ trigger
69
+ )}
70
+ <DropdownMenuContent align="end" sideOffset={5}>
71
+ {languages.map(({ code, label }) => (
72
+ <DropdownMenuItem
73
+ key={code}
74
+ className={currentLanguage === code ? 'bg-accent' : undefined}
75
+ onSelect={() => onLanguageChange(code)}
76
+ >
77
+ {label}
78
+ </DropdownMenuItem>
79
+ ))}
80
+ </DropdownMenuContent>
81
+ </DropdownMenu>
82
+ );
83
+ }
84
+
85
+ export interface I18nSubMenuProps {
86
+ languages: I18nLanguage[];
87
+ currentLanguage: string;
88
+ onLanguageChange: (code: string) => void;
89
+ label?: string;
90
+ disabled?: boolean;
91
+ style?: CSSProperties;
92
+ sideOffset?: number;
93
+ }
94
+
95
+ /** Renders language preferences inside a Design DropdownMenu. */
96
+ export function I18nSubMenu({
97
+ languages,
98
+ currentLanguage,
99
+ onLanguageChange,
100
+ label,
101
+ disabled,
102
+ style,
103
+ sideOffset = 8,
104
+ }: I18nSubMenuProps) {
105
+ const { messages, provided } = useMonkeysLocale();
106
+ const componentAttributes = useMonkeysComponentAttributes();
107
+ const currentLabel = languages.find((language) => language.code === currentLanguage)?.label ?? currentLanguage;
108
+
109
+ return (
110
+ <DropdownMenuSub>
111
+ <DropdownMenuSubTrigger {...componentAttributes} disabled={disabled}>
112
+ <Languages aria-hidden="true" />
113
+ <span>{label ?? (provided ? messages : zhCN.messages).toolbar.language.label}</span>
114
+ <span className="ml-auto text-xs text-muted-foreground">{currentLabel}</span>
115
+ </DropdownMenuSubTrigger>
116
+ <DropdownMenuPortal>
117
+ <DropdownMenuSubContent sideOffset={sideOffset} style={style}>
118
+ {languages.map(({ code, label: optionLabel }) => (
119
+ <DropdownMenuCheckboxItem
120
+ key={code}
121
+ checked={currentLanguage === code}
122
+ disabled={currentLanguage === code}
123
+ onCheckedChange={() => onLanguageChange(code)}
124
+ >
125
+ {optionLabel}
126
+ </DropdownMenuCheckboxItem>
127
+ ))}
128
+ </DropdownMenuSubContent>
129
+ </DropdownMenuPortal>
130
+ </DropdownMenuSub>
131
+ );
132
+ }
@@ -0,0 +1,131 @@
1
+ import { Monitor, Moon, Sun, SunMoon } from 'lucide-react';
2
+
3
+ import { zhCN } from '../../locale/zh-CN';
4
+ import { useMonkeysComponentAttributes, useMonkeysLocale } from '../../provider/context';
5
+ import { cn } from '../base/utils';
6
+ import {
7
+ DropdownMenu,
8
+ DropdownMenuCheckboxItem,
9
+ DropdownMenuContent,
10
+ DropdownMenuItem,
11
+ DropdownMenuPortal,
12
+ DropdownMenuSub,
13
+ DropdownMenuSubContent,
14
+ DropdownMenuSubTrigger,
15
+ DropdownMenuTrigger,
16
+ } from '../primitives/Menus';
17
+ import * as Tooltip from '../primitives/tooltip-adapter';
18
+
19
+ export type DarkModeValue = 'auto' | 'light' | 'dark';
20
+
21
+ export interface DarkModeSelectorProps {
22
+ mode: DarkModeValue;
23
+ onModeChange: (mode: DarkModeValue) => void;
24
+ labels?: { auto?: string; light?: string; dark?: string };
25
+ tooltip?: string;
26
+ className?: string;
27
+ }
28
+
29
+ const modes: DarkModeValue[] = ['auto', 'light', 'dark'];
30
+ const modeIcons = { auto: Monitor, light: Sun, dark: Moon };
31
+
32
+ export function DarkModeSelector({ mode, onModeChange, labels = {}, tooltip, className }: DarkModeSelectorProps) {
33
+ const { messages } = useMonkeysLocale();
34
+ const componentAttributes = useMonkeysComponentAttributes();
35
+ const localeLabels = messages.toolbar.theme;
36
+ const TriggerIcon = modeIcons[mode];
37
+
38
+ const trigger = (
39
+ <DropdownMenuTrigger asChild>
40
+ <button
41
+ {...componentAttributes}
42
+ className={cn(
43
+ 'inline-flex h-8 w-8 items-center justify-center rounded-md text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-hidden',
44
+ className,
45
+ )}
46
+ >
47
+ <TriggerIcon size={16} aria-hidden="true" />
48
+ <span className="sr-only">{tooltip ?? localeLabels.toggle}</span>
49
+ </button>
50
+ </DropdownMenuTrigger>
51
+ );
52
+
53
+ return (
54
+ <DropdownMenu>
55
+ {tooltip ? (
56
+ <Tooltip.Provider delayDuration={300}>
57
+ <Tooltip.Root>
58
+ <Tooltip.Trigger asChild>{trigger}</Tooltip.Trigger>
59
+ <Tooltip.Portal>
60
+ <Tooltip.Content
61
+ className="rounded-md border border-border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95"
62
+ sideOffset={5}
63
+ >
64
+ {tooltip}
65
+ </Tooltip.Content>
66
+ </Tooltip.Portal>
67
+ </Tooltip.Root>
68
+ </Tooltip.Provider>
69
+ ) : (
70
+ trigger
71
+ )}
72
+ <DropdownMenuContent align="end" sideOffset={5}>
73
+ {modes.map((value) => {
74
+ const Icon = modeIcons[value];
75
+ return (
76
+ <DropdownMenuItem
77
+ key={value}
78
+ className={mode === value ? 'bg-accent' : undefined}
79
+ onSelect={() => onModeChange(value)}
80
+ >
81
+ <Icon aria-hidden="true" />
82
+ {labels[value] ?? localeLabels[value]}
83
+ </DropdownMenuItem>
84
+ );
85
+ })}
86
+ </DropdownMenuContent>
87
+ </DropdownMenu>
88
+ );
89
+ }
90
+
91
+ export interface DarkModeSubMenuProps {
92
+ mode: DarkModeValue;
93
+ onModeChange: (mode: DarkModeValue) => void;
94
+ label?: string;
95
+ labels?: { auto?: string; light?: string; dark?: string };
96
+ }
97
+
98
+ /** Renders appearance preferences inside a Design DropdownMenu. */
99
+ export function DarkModeSubMenu({ mode, onModeChange, label, labels = {} }: DarkModeSubMenuProps) {
100
+ const { messages, provided } = useMonkeysLocale();
101
+ const componentAttributes = useMonkeysComponentAttributes();
102
+ const localeLabels = (provided ? messages : zhCN.messages).toolbar.theme;
103
+
104
+ return (
105
+ <DropdownMenuSub>
106
+ <DropdownMenuSubTrigger {...componentAttributes}>
107
+ <SunMoon aria-hidden="true" />
108
+ <span>{label ?? localeLabels.label}</span>
109
+ <span className="ml-auto text-xs text-muted-foreground">{labels[mode] ?? localeLabels[mode]}</span>
110
+ </DropdownMenuSubTrigger>
111
+ <DropdownMenuPortal>
112
+ <DropdownMenuSubContent sideOffset={8}>
113
+ {modes.map((value) => {
114
+ const Icon = modeIcons[value];
115
+ return (
116
+ <DropdownMenuCheckboxItem
117
+ key={value}
118
+ checked={mode === value}
119
+ disabled={mode === value}
120
+ onCheckedChange={() => onModeChange(value)}
121
+ >
122
+ <Icon aria-hidden="true" />
123
+ {labels[value] ?? localeLabels[value]}
124
+ </DropdownMenuCheckboxItem>
125
+ );
126
+ })}
127
+ </DropdownMenuSubContent>
128
+ </DropdownMenuPortal>
129
+ </DropdownMenuSub>
130
+ );
131
+ }