@pelatform/ui 1.5.3 → 1.5.4

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.
@@ -1906,7 +1906,7 @@ var ImageInput = ({
1906
1906
 
1907
1907
  function LanguageSwitcher({
1908
1908
  className,
1909
- type = "toggle",
1909
+ type = "dropdown",
1910
1910
  variant = "ghost",
1911
1911
  size = "md",
1912
1912
  showNames = true,
@@ -1932,7 +1932,7 @@ function LanguageSwitcher({
1932
1932
  if (!i18nEnabled && (_nullishCoalesce(_optionalChain([languages, 'optionalAccess', _51 => _51.length]), () => ( 0))) <= 1) {
1933
1933
  return null;
1934
1934
  }
1935
- if (type === "toggle") {
1935
+ if (type === "dropdown") {
1936
1936
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkHILACSFAcjs.DropdownMenu, { children: [
1937
1937
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHILACSFAcjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1938
1938
  _chunkBXUKTDPNcjs.Button,
@@ -1951,28 +1951,36 @@ function LanguageSwitcher({
1951
1951
  ]
1952
1952
  }
1953
1953
  ) }),
1954
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHILACSFAcjs.DropdownMenuContent, { align: "end", className: "min-w-[150px]", children: languages.map((lang) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1955
- _chunkHILACSFAcjs.DropdownMenuItem,
1954
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1955
+ _chunkHILACSFAcjs.DropdownMenuContent,
1956
1956
  {
1957
- onClick: () => handleLanguageChange(lang.code),
1958
- className: _chunkCJXIPSTGcjs.cn.call(void 0, "gap-2", currentLocale === lang.code && "bg-accent"),
1959
- children: [
1960
- showFlags && lang.flag ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1961
- Image2,
1962
- {
1963
- src: _chunkWI36EFUScjs.getFlagUrl.call(void 0, lang.flag),
1964
- alt: `${lang.name} flag`,
1965
- className: "size-4 rounded-full object-cover",
1966
- width: 24,
1967
- height: 24
1968
- }
1969
- ) : showFlags ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Globe, { className: "size-4" }) : null,
1970
- showNames && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: lang.name }),
1971
- currentLocale === lang.code && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "ms-auto text-muted-foreground text-xs", children: "\u2713" })
1972
- ]
1973
- },
1974
- lang.code
1975
- )) })
1957
+ align: "end",
1958
+ className: "min-w-[150px]",
1959
+ onCloseAutoFocus: (e) => e.preventDefault(),
1960
+ children: languages.map((lang) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1961
+ _chunkHILACSFAcjs.DropdownMenuItem,
1962
+ {
1963
+ onClick: () => handleLanguageChange(lang.code),
1964
+ className: _chunkCJXIPSTGcjs.cn.call(void 0, "gap-2", currentLocale === lang.code && "bg-accent"),
1965
+ children: [
1966
+ showFlags && lang.flag ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1967
+ Image2,
1968
+ {
1969
+ src: _chunkWI36EFUScjs.getFlagUrl.call(void 0, lang.flag),
1970
+ alt: `${lang.name} flag`,
1971
+ className: "size-4 rounded-full object-cover",
1972
+ width: 24,
1973
+ height: 24
1974
+ }
1975
+ ) : showFlags ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Globe, { className: "size-4" }) : null,
1976
+ showNames && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm", children: lang.name }),
1977
+ currentLocale === lang.code && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "ms-auto text-muted-foreground text-xs", children: "\u2713" })
1978
+ ]
1979
+ },
1980
+ lang.code
1981
+ ))
1982
+ }
1983
+ )
1976
1984
  ] });
1977
1985
  }
1978
1986
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkHILACSFAcjs.DropdownMenuSub, { children: [
@@ -2100,6 +2108,7 @@ function ModeSwitcher({
2100
2108
  _nullishCoalesce(withLabel, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: label.light })))
2101
2109
  ] });
2102
2110
  };
2111
+ const isActive = (val) => theme === val;
2103
2112
  if (type === "toogle") {
2104
2113
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2105
2114
  _chunkBXUKTDPNcjs.Button,
@@ -2116,6 +2125,60 @@ function ModeSwitcher({
2116
2125
  }
2117
2126
  );
2118
2127
  }
2128
+ if (type === "dropdown") {
2129
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkHILACSFAcjs.DropdownMenu, { children: [
2130
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHILACSFAcjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2131
+ _chunkBXUKTDPNcjs.Button,
2132
+ {
2133
+ variant,
2134
+ size,
2135
+ className: _chunkCJXIPSTGcjs.cn.call(void 0,
2136
+ "group/toggle size-8 px-0 text-foreground ring-0! focus:outline-none! focus:ring-0! focus-visible:outline-none! focus-visible:ring-0! focus-visible:ring-offset-0!",
2137
+ className
2138
+ ),
2139
+ children: [
2140
+ getCurrentIcon(),
2141
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", children: "Toggle theme" })
2142
+ ]
2143
+ }
2144
+ ) }),
2145
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkHILACSFAcjs.DropdownMenuContent, { align: "end", onCloseAutoFocus: (e) => e.preventDefault(), children: [
2146
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2147
+ _chunkHILACSFAcjs.DropdownMenuItem,
2148
+ {
2149
+ className: isActive("light") ? "bg-accent" : "",
2150
+ onClick: () => setTheme("light"),
2151
+ children: [
2152
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Sun, {}),
2153
+ label.light
2154
+ ]
2155
+ }
2156
+ ),
2157
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2158
+ _chunkHILACSFAcjs.DropdownMenuItem,
2159
+ {
2160
+ className: isActive("dark") ? "bg-accent" : "",
2161
+ onClick: () => setTheme("dark"),
2162
+ children: [
2163
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Moon, {}),
2164
+ label.dark
2165
+ ]
2166
+ }
2167
+ ),
2168
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2169
+ _chunkHILACSFAcjs.DropdownMenuItem,
2170
+ {
2171
+ className: isActive("system") ? "bg-accent" : "",
2172
+ onClick: () => setTheme("system"),
2173
+ children: [
2174
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.Monitor, {}),
2175
+ label.system
2176
+ ]
2177
+ }
2178
+ )
2179
+ ] })
2180
+ ] });
2181
+ }
2119
2182
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2120
2183
  _chunkHILACSFAcjs.DropdownMenuItem,
2121
2184
  {
@@ -2226,8 +2226,8 @@ interface LocaleOption {
2226
2226
  interface LanguageSwitcherProps extends SharedImage {
2227
2227
  /** Additional CSS classes */
2228
2228
  className?: string;
2229
- /** UI type: standalone toggle button or submenu dropdown */
2230
- type?: 'toggle' | 'dropdown';
2229
+ /** UI type: standalone dropdown or submenu dropdown */
2230
+ type?: 'dropdown' | 'sub-dropdown';
2231
2231
  /** Button variant style (for toggle type) */
2232
2232
  variant?: 'ghost' | 'outline' | 'secondary';
2233
2233
  /** Button size (for toggle type) */
@@ -2308,8 +2308,8 @@ interface ModeSwitcherProps {
2308
2308
  size?: 'sm' | 'md' | 'lg';
2309
2309
  /** Custom cycle order for themes (defaults to system -> light -> dark) */
2310
2310
  cycleOrder?: ThemeMode[];
2311
- /** Button type: 'toggle' for a single button or 'dropdown' for a menu with options */
2312
- type?: 'toogle' | 'dropdown';
2311
+ /** Button type: 'toggle' for a single button or 'dropdown' and 'sub-dropdown' for a menu with options */
2312
+ type?: 'toogle' | 'dropdown' | 'sub-dropdown';
2313
2313
  /** Labels for each theme mode (optional) */
2314
2314
  label?: {
2315
2315
  system?: string;
@@ -2226,8 +2226,8 @@ interface LocaleOption {
2226
2226
  interface LanguageSwitcherProps extends SharedImage {
2227
2227
  /** Additional CSS classes */
2228
2228
  className?: string;
2229
- /** UI type: standalone toggle button or submenu dropdown */
2230
- type?: 'toggle' | 'dropdown';
2229
+ /** UI type: standalone dropdown or submenu dropdown */
2230
+ type?: 'dropdown' | 'sub-dropdown';
2231
2231
  /** Button variant style (for toggle type) */
2232
2232
  variant?: 'ghost' | 'outline' | 'secondary';
2233
2233
  /** Button size (for toggle type) */
@@ -2308,8 +2308,8 @@ interface ModeSwitcherProps {
2308
2308
  size?: 'sm' | 'md' | 'lg';
2309
2309
  /** Custom cycle order for themes (defaults to system -> light -> dark) */
2310
2310
  cycleOrder?: ThemeMode[];
2311
- /** Button type: 'toggle' for a single button or 'dropdown' for a menu with options */
2312
- type?: 'toogle' | 'dropdown';
2311
+ /** Button type: 'toggle' for a single button or 'dropdown' and 'sub-dropdown' for a menu with options */
2312
+ type?: 'toogle' | 'dropdown' | 'sub-dropdown';
2313
2313
  /** Labels for each theme mode (optional) */
2314
2314
  label?: {
2315
2315
  system?: string;
@@ -1906,7 +1906,7 @@ import { Globe, Languages } from "lucide-react";
1906
1906
  import { jsx as jsx34, jsxs as jsxs23 } from "react/jsx-runtime";
1907
1907
  function LanguageSwitcher({
1908
1908
  className,
1909
- type = "toggle",
1909
+ type = "dropdown",
1910
1910
  variant = "ghost",
1911
1911
  size = "md",
1912
1912
  showNames = true,
@@ -1932,7 +1932,7 @@ function LanguageSwitcher({
1932
1932
  if (!i18nEnabled && (languages?.length ?? 0) <= 1) {
1933
1933
  return null;
1934
1934
  }
1935
- if (type === "toggle") {
1935
+ if (type === "dropdown") {
1936
1936
  return /* @__PURE__ */ jsxs23(DropdownMenu, { children: [
1937
1937
  /* @__PURE__ */ jsx34(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs23(
1938
1938
  Button,
@@ -1951,28 +1951,36 @@ function LanguageSwitcher({
1951
1951
  ]
1952
1952
  }
1953
1953
  ) }),
1954
- /* @__PURE__ */ jsx34(DropdownMenuContent, { align: "end", className: "min-w-[150px]", children: languages.map((lang) => /* @__PURE__ */ jsxs23(
1955
- DropdownMenuItem,
1954
+ /* @__PURE__ */ jsx34(
1955
+ DropdownMenuContent,
1956
1956
  {
1957
- onClick: () => handleLanguageChange(lang.code),
1958
- className: cn("gap-2", currentLocale === lang.code && "bg-accent"),
1959
- children: [
1960
- showFlags && lang.flag ? /* @__PURE__ */ jsx34(
1961
- Image2,
1962
- {
1963
- src: getFlagUrl(lang.flag),
1964
- alt: `${lang.name} flag`,
1965
- className: "size-4 rounded-full object-cover",
1966
- width: 24,
1967
- height: 24
1968
- }
1969
- ) : showFlags ? /* @__PURE__ */ jsx34(Globe, { className: "size-4" }) : null,
1970
- showNames && /* @__PURE__ */ jsx34("span", { className: "text-sm", children: lang.name }),
1971
- currentLocale === lang.code && /* @__PURE__ */ jsx34("span", { className: "ms-auto text-muted-foreground text-xs", children: "\u2713" })
1972
- ]
1973
- },
1974
- lang.code
1975
- )) })
1957
+ align: "end",
1958
+ className: "min-w-[150px]",
1959
+ onCloseAutoFocus: (e) => e.preventDefault(),
1960
+ children: languages.map((lang) => /* @__PURE__ */ jsxs23(
1961
+ DropdownMenuItem,
1962
+ {
1963
+ onClick: () => handleLanguageChange(lang.code),
1964
+ className: cn("gap-2", currentLocale === lang.code && "bg-accent"),
1965
+ children: [
1966
+ showFlags && lang.flag ? /* @__PURE__ */ jsx34(
1967
+ Image2,
1968
+ {
1969
+ src: getFlagUrl(lang.flag),
1970
+ alt: `${lang.name} flag`,
1971
+ className: "size-4 rounded-full object-cover",
1972
+ width: 24,
1973
+ height: 24
1974
+ }
1975
+ ) : showFlags ? /* @__PURE__ */ jsx34(Globe, { className: "size-4" }) : null,
1976
+ showNames && /* @__PURE__ */ jsx34("span", { className: "text-sm", children: lang.name }),
1977
+ currentLocale === lang.code && /* @__PURE__ */ jsx34("span", { className: "ms-auto text-muted-foreground text-xs", children: "\u2713" })
1978
+ ]
1979
+ },
1980
+ lang.code
1981
+ ))
1982
+ }
1983
+ )
1976
1984
  ] });
1977
1985
  }
1978
1986
  return /* @__PURE__ */ jsxs23(DropdownMenuSub, { children: [
@@ -2100,6 +2108,7 @@ function ModeSwitcher({
2100
2108
  withLabel ?? /* @__PURE__ */ jsx36("span", { children: label.light })
2101
2109
  ] });
2102
2110
  };
2111
+ const isActive = (val) => theme === val;
2103
2112
  if (type === "toogle") {
2104
2113
  return /* @__PURE__ */ jsxs24(
2105
2114
  Button,
@@ -2116,6 +2125,60 @@ function ModeSwitcher({
2116
2125
  }
2117
2126
  );
2118
2127
  }
2128
+ if (type === "dropdown") {
2129
+ return /* @__PURE__ */ jsxs24(DropdownMenu, { children: [
2130
+ /* @__PURE__ */ jsx36(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs24(
2131
+ Button,
2132
+ {
2133
+ variant,
2134
+ size,
2135
+ className: cn(
2136
+ "group/toggle size-8 px-0 text-foreground ring-0! focus:outline-none! focus:ring-0! focus-visible:outline-none! focus-visible:ring-0! focus-visible:ring-offset-0!",
2137
+ className
2138
+ ),
2139
+ children: [
2140
+ getCurrentIcon(),
2141
+ /* @__PURE__ */ jsx36("span", { className: "sr-only", children: "Toggle theme" })
2142
+ ]
2143
+ }
2144
+ ) }),
2145
+ /* @__PURE__ */ jsxs24(DropdownMenuContent, { align: "end", onCloseAutoFocus: (e) => e.preventDefault(), children: [
2146
+ /* @__PURE__ */ jsxs24(
2147
+ DropdownMenuItem,
2148
+ {
2149
+ className: isActive("light") ? "bg-accent" : "",
2150
+ onClick: () => setTheme("light"),
2151
+ children: [
2152
+ /* @__PURE__ */ jsx36(Sun, {}),
2153
+ label.light
2154
+ ]
2155
+ }
2156
+ ),
2157
+ /* @__PURE__ */ jsxs24(
2158
+ DropdownMenuItem,
2159
+ {
2160
+ className: isActive("dark") ? "bg-accent" : "",
2161
+ onClick: () => setTheme("dark"),
2162
+ children: [
2163
+ /* @__PURE__ */ jsx36(Moon, {}),
2164
+ label.dark
2165
+ ]
2166
+ }
2167
+ ),
2168
+ /* @__PURE__ */ jsxs24(
2169
+ DropdownMenuItem,
2170
+ {
2171
+ className: isActive("system") ? "bg-accent" : "",
2172
+ onClick: () => setTheme("system"),
2173
+ children: [
2174
+ /* @__PURE__ */ jsx36(Monitor, {}),
2175
+ label.system
2176
+ ]
2177
+ }
2178
+ )
2179
+ ] })
2180
+ ] });
2181
+ }
2119
2182
  return /* @__PURE__ */ jsx36(
2120
2183
  DropdownMenuItem,
2121
2184
  {