shru-design-system 0.1.1 → 0.1.2

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.js CHANGED
@@ -9,6 +9,7 @@ var jsxRuntime = require('react/jsx-runtime');
9
9
  var DialogPrimitive = require('@radix-ui/react-dialog');
10
10
  var lucideReact = require('lucide-react');
11
11
  var SelectPrimitive = require('@radix-ui/react-select');
12
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
12
13
 
13
14
  function _interopNamespace(e) {
14
15
  if (e && e.__esModule) return e;
@@ -31,6 +32,7 @@ function _interopNamespace(e) {
31
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
33
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
33
34
  var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
35
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
34
36
 
35
37
  // src/atoms/Button.tsx
36
38
  function cn(...inputs) {
@@ -382,6 +384,847 @@ function SelectScrollDownButton({
382
384
  }
383
385
  );
384
386
  }
387
+ function TooltipProvider({
388
+ delayDuration = 0,
389
+ ...props
390
+ }) {
391
+ return /* @__PURE__ */ jsxRuntime.jsx(
392
+ TooltipPrimitive__namespace.Provider,
393
+ {
394
+ "data-slot": "tooltip-provider",
395
+ delayDuration,
396
+ ...props
397
+ }
398
+ );
399
+ }
400
+ function Tooltip({
401
+ ...props
402
+ }) {
403
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
404
+ }
405
+ function TooltipTrigger({
406
+ ...props
407
+ }) {
408
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
409
+ }
410
+ function TooltipContent({
411
+ className,
412
+ sideOffset = 0,
413
+ children,
414
+ side,
415
+ ...props
416
+ }) {
417
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
418
+ TooltipPrimitive__namespace.Content,
419
+ {
420
+ "data-slot": "tooltip-content",
421
+ sideOffset,
422
+ side,
423
+ className: cn(
424
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
425
+ className
426
+ ),
427
+ ...props,
428
+ children: [
429
+ children,
430
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
431
+ ]
432
+ }
433
+ ) });
434
+ }
435
+
436
+ // src/themes/themeConfig.ts
437
+ var baseThemeCategories = {
438
+ color: {
439
+ name: "Color",
440
+ order: 1,
441
+ themes: {
442
+ white: {
443
+ name: "White",
444
+ file: "color/white.json",
445
+ icon: "\u{1F3A8}",
446
+ description: "Light theme with white background"
447
+ },
448
+ dark: {
449
+ name: "Dark",
450
+ file: "color/dark.json",
451
+ icon: "\u{1F319}",
452
+ description: "Dark theme with dark background"
453
+ }
454
+ }
455
+ },
456
+ typography: {
457
+ name: "Typography",
458
+ order: 2,
459
+ themes: {
460
+ sans: {
461
+ name: "Sans",
462
+ file: "typography/sans.json",
463
+ icon: "\u{1F4DD}",
464
+ description: "Sans-serif font family"
465
+ },
466
+ serif: {
467
+ name: "Serif",
468
+ file: "typography/serif.json",
469
+ icon: "\u{1F4D6}",
470
+ description: "Serif font family"
471
+ }
472
+ }
473
+ },
474
+ shape: {
475
+ name: "Shape",
476
+ order: 3,
477
+ themes: {
478
+ smooth: {
479
+ name: "Smooth",
480
+ file: "shape/smooth.json",
481
+ icon: "\u{1F532}",
482
+ description: "Smooth rounded corners"
483
+ },
484
+ sharp: {
485
+ name: "Sharp",
486
+ file: "shape/sharp.json",
487
+ icon: "\u2B1C",
488
+ description: "Sharp square corners"
489
+ }
490
+ }
491
+ },
492
+ density: {
493
+ name: "Density",
494
+ order: 4,
495
+ themes: {
496
+ comfortable: {
497
+ name: "Comfortable",
498
+ file: "density/comfortable.json",
499
+ icon: "\u{1F4CF}",
500
+ description: "Comfortable spacing"
501
+ },
502
+ compact: {
503
+ name: "Compact",
504
+ file: "density/compact.json",
505
+ icon: "\u{1F4D0}",
506
+ description: "Compact spacing"
507
+ }
508
+ }
509
+ },
510
+ animation: {
511
+ name: "Animation",
512
+ order: 5,
513
+ themes: {
514
+ gentle: {
515
+ name: "Gentle",
516
+ file: "animation/gentle.json",
517
+ icon: "\u2728",
518
+ description: "Gentle animations"
519
+ },
520
+ brisk: {
521
+ name: "Brisk",
522
+ file: "animation/brisk.json",
523
+ icon: "\u26A1",
524
+ description: "Fast, brisk animations"
525
+ }
526
+ }
527
+ },
528
+ custom: {
529
+ name: "Custom",
530
+ order: 10,
531
+ // Highest priority
532
+ themes: {
533
+ brand: {
534
+ name: "Brand",
535
+ file: "custom/brand.json",
536
+ icon: "\u{1F3AF}",
537
+ description: "Brand-specific theme"
538
+ },
539
+ minimal: {
540
+ name: "Minimal",
541
+ file: "custom/minimal.json",
542
+ icon: "\u{1F3AA}",
543
+ description: "Minimal theme"
544
+ }
545
+ }
546
+ }
547
+ };
548
+ var discoveredThemesCache = null;
549
+ async function discoverThemes() {
550
+ if (discoveredThemesCache) {
551
+ return discoveredThemesCache;
552
+ }
553
+ const discovered = JSON.parse(JSON.stringify(baseThemeCategories));
554
+ try {
555
+ const tokensBase = typeof window !== "undefined" && window.__THEME_TOKENS_BASE__ ? window.__THEME_TOKENS_BASE__ : "/tokens";
556
+ const knownCategories = Object.keys(baseThemeCategories);
557
+ for (const category of knownCategories) {
558
+ const categoryPath = `${tokensBase}/themes/${category}`;
559
+ }
560
+ discoveredThemesCache = discovered;
561
+ return discovered;
562
+ } catch (error) {
563
+ console.warn("Error discovering themes:", error);
564
+ return baseThemeCategories;
565
+ }
566
+ }
567
+ function registerTheme(category, themeId, metadata) {
568
+ if (!discoveredThemesCache) {
569
+ discoveredThemesCache = JSON.parse(JSON.stringify(baseThemeCategories));
570
+ }
571
+ const cache = discoveredThemesCache;
572
+ if (!cache[category]) {
573
+ cache[category] = {
574
+ name: category.charAt(0).toUpperCase() + category.slice(1),
575
+ order: 99,
576
+ // Custom categories get high order
577
+ themes: {}
578
+ };
579
+ }
580
+ cache[category].themes[themeId] = {
581
+ name: metadata.name,
582
+ file: metadata.file,
583
+ icon: metadata.icon || "\u{1F3A8}",
584
+ description: metadata.description || ""
585
+ };
586
+ return cache;
587
+ }
588
+ async function getThemeCategories() {
589
+ return await discoverThemes();
590
+ }
591
+ function getThemeFilePath(category, themeId) {
592
+ const categories = discoveredThemesCache || baseThemeCategories;
593
+ const theme = categories[category]?.themes[themeId];
594
+ if (!theme) return null;
595
+ return `/tokens/themes/${theme.file}`;
596
+ }
597
+ async function getThemesForCategory(category) {
598
+ const categories = await getThemeCategories();
599
+ return categories[category]?.themes || {};
600
+ }
601
+ async function getTheme(category, themeId) {
602
+ const categories = await getThemeCategories();
603
+ return categories[category]?.themes[themeId] || null;
604
+ }
605
+
606
+ // src/themes/themeUtils.ts
607
+ function getThemeName(selectedThemes) {
608
+ const parts = [];
609
+ if (selectedThemes.color) parts.push(selectedThemes.color);
610
+ if (selectedThemes.typography) parts.push(selectedThemes.typography);
611
+ if (selectedThemes.shape) parts.push(selectedThemes.shape);
612
+ if (selectedThemes.density) parts.push(selectedThemes.density);
613
+ if (selectedThemes.animation) parts.push(selectedThemes.animation);
614
+ return parts.length > 0 ? parts.join("-") : "default";
615
+ }
616
+ function validateThemeSelection(selectedThemes, themeCategories) {
617
+ const errors = [];
618
+ for (const [category, themeId] of Object.entries(selectedThemes)) {
619
+ if (!themeId) continue;
620
+ const categoryConfig = themeCategories[category];
621
+ if (!categoryConfig) {
622
+ errors.push(`Unknown category: ${category}`);
623
+ continue;
624
+ }
625
+ const theme = categoryConfig.themes[themeId];
626
+ if (!theme) {
627
+ errors.push(`Theme ${themeId} not found in category ${category}`);
628
+ }
629
+ }
630
+ return {
631
+ valid: errors.length === 0,
632
+ errors
633
+ };
634
+ }
635
+ function getDefaultThemes() {
636
+ return {
637
+ color: "white",
638
+ typography: "sans",
639
+ shape: "smooth",
640
+ density: "comfortable",
641
+ animation: "gentle"
642
+ };
643
+ }
644
+ function deepClone(obj) {
645
+ return JSON.parse(JSON.stringify(obj));
646
+ }
647
+ function isObject(item) {
648
+ return item && typeof item === "object" && !Array.isArray(item);
649
+ }
650
+ function deepMerge(target, source) {
651
+ const output = { ...target };
652
+ if (isObject(target) && isObject(source)) {
653
+ Object.keys(source).forEach((key) => {
654
+ if (isObject(source[key])) {
655
+ if (!(key in target)) {
656
+ Object.assign(output, { [key]: source[key] });
657
+ } else {
658
+ output[key] = deepMerge(target[key], source[key]);
659
+ }
660
+ } else {
661
+ Object.assign(output, { [key]: source[key] });
662
+ }
663
+ });
664
+ }
665
+ return output;
666
+ }
667
+ var tokenCache = /* @__PURE__ */ new Map();
668
+ async function loadTokenFile(path) {
669
+ if (tokenCache.has(path)) {
670
+ return deepClone(tokenCache.get(path));
671
+ }
672
+ try {
673
+ const response = await fetch(path);
674
+ if (!response.ok) {
675
+ throw new Error(`Failed to load ${path}: ${response.statusText}`);
676
+ }
677
+ const data = await response.json();
678
+ tokenCache.set(path, data);
679
+ return deepClone(data);
680
+ } catch (error) {
681
+ console.error(`Error loading token file ${path}:`, error);
682
+ throw error;
683
+ }
684
+ }
685
+ function resolveReferences(tokens, palette) {
686
+ const resolved = JSON.parse(JSON.stringify(tokens));
687
+ function resolveValue(value) {
688
+ if (typeof value !== "string") return value;
689
+ const match = value.match(/^\{([^}]+)\}$/);
690
+ if (!match) return value;
691
+ const path = match[1].split(".");
692
+ let current = { palette, ...resolved };
693
+ for (const key of path) {
694
+ if (current && typeof current === "object" && key in current) {
695
+ current = current[key];
696
+ } else {
697
+ console.warn(`Token reference not found: {${match[1]}}`);
698
+ return value;
699
+ }
700
+ }
701
+ return typeof current === "string" ? current : value;
702
+ }
703
+ function traverse(obj) {
704
+ for (const key in obj) {
705
+ if (typeof obj[key] === "object" && obj[key] !== null) {
706
+ traverse(obj[key]);
707
+ } else {
708
+ obj[key] = resolveValue(obj[key]);
709
+ }
710
+ }
711
+ }
712
+ traverse(resolved);
713
+ return resolved;
714
+ }
715
+ function flattenToCSS(tokens, prefix = "", result = {}, isColorContext = false) {
716
+ for (const key in tokens) {
717
+ const value = tokens[key];
718
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
719
+ const enteringColor = key === "color" && prefix === "";
720
+ const inColorContext = isColorContext || enteringColor;
721
+ if (enteringColor) {
722
+ flattenToCSS(value, "", result, true);
723
+ } else if (inColorContext) {
724
+ flattenToCSS(value, "", result, true);
725
+ } else {
726
+ const newPrefix = prefix ? `${prefix}-${key}` : key;
727
+ flattenToCSS(value, newPrefix, result, false);
728
+ }
729
+ } else {
730
+ let cssKey;
731
+ if (isColorContext || prefix === "" && key === "color") {
732
+ cssKey = `--${key}`;
733
+ } else if (prefix === "") {
734
+ cssKey = `--${key}`;
735
+ } else {
736
+ cssKey = `--${prefix}-${key}`;
737
+ }
738
+ result[cssKey] = value;
739
+ }
740
+ }
741
+ return result;
742
+ }
743
+ function mapToTailwindVars(cssVars) {
744
+ const mapped = { ...cssVars };
745
+ if (cssVars["--radius-button"]) {
746
+ mapped["--radius"] = cssVars["--radius-button"];
747
+ }
748
+ if (cssVars["--radius-card"]) {
749
+ mapped["--radius-lg"] = cssVars["--radius-card"];
750
+ }
751
+ if (cssVars["--font-body"]) {
752
+ mapped["--font-sans"] = cssVars["--font-body"];
753
+ }
754
+ if (cssVars["--spacing-base"]) {
755
+ mapped["--spacing"] = cssVars["--spacing-base"];
756
+ } else if (cssVars["--spacing-component-md"]) {
757
+ mapped["--spacing"] = cssVars["--spacing-component-md"];
758
+ }
759
+ return mapped;
760
+ }
761
+ function generateCSSString(cssVars) {
762
+ const mappedVars = mapToTailwindVars(cssVars);
763
+ const vars = Object.entries(mappedVars).map(([key, value]) => ` ${key}: ${value};`).join("\n");
764
+ return `:root {
765
+ ${vars}
766
+ }`;
767
+ }
768
+ function applyThemeCSS(css) {
769
+ let styleTag = document.getElementById("dynamic-theme");
770
+ if (!styleTag) {
771
+ styleTag = document.createElement("style");
772
+ styleTag.id = "dynamic-theme";
773
+ document.head.appendChild(styleTag);
774
+ }
775
+ styleTag.textContent = css;
776
+ }
777
+ async function generateAndApplyTheme(selectedThemes = {}) {
778
+ try {
779
+ const themeCategories = await getThemeCategories();
780
+ const validation = validateThemeSelection(selectedThemes, themeCategories);
781
+ if (!validation.valid) {
782
+ console.error("Invalid theme selection:", validation.errors);
783
+ throw new Error(`Invalid theme selection: ${validation.errors.join(", ")}`);
784
+ }
785
+ const base = await loadTokenFile("/tokens/base.json");
786
+ const palettes = await loadTokenFile("/tokens/palettes.json");
787
+ const palette = palettes.palette;
788
+ let merged = deepMerge(base, { palette });
789
+ const categoryOrder = Object.values(themeCategories).sort((a, b) => a.order - b.order).map((cat) => cat.name.toLowerCase());
790
+ for (const category of categoryOrder) {
791
+ if (category === "custom") continue;
792
+ const themeId = selectedThemes[category];
793
+ if (!themeId) continue;
794
+ const themePath = `/tokens/themes/${category}/${themeId}.json`;
795
+ const themeData = await loadTokenFile(themePath);
796
+ merged = deepMerge(merged, themeData);
797
+ }
798
+ if (selectedThemes.custom) {
799
+ const customPath = `/tokens/themes/custom/${selectedThemes.custom}.json`;
800
+ const customData = await loadTokenFile(customPath);
801
+ merged = deepMerge(merged, customData);
802
+ }
803
+ const resolved = resolveReferences(merged, palette);
804
+ const cssVars = flattenToCSS(resolved);
805
+ const css = generateCSSString(cssVars);
806
+ if (typeof document !== "undefined") {
807
+ applyThemeCSS(css);
808
+ }
809
+ return {
810
+ success: true,
811
+ themeName: getThemeName(selectedThemes),
812
+ cssVars
813
+ };
814
+ } catch (error) {
815
+ console.error("Error generating theme:", error);
816
+ throw error;
817
+ }
818
+ }
819
+
820
+ // src/themes/useTheme.tsx
821
+ var STORAGE_KEY = "design-system-theme";
822
+ function useTheme() {
823
+ const [selectedThemes, setSelectedThemes] = React.useState(getDefaultThemes());
824
+ const [isLoading, setIsLoading] = React.useState(false);
825
+ const [error, setError] = React.useState(null);
826
+ const applyTheme = React.useCallback(async (themes) => {
827
+ setIsLoading(true);
828
+ setError(null);
829
+ try {
830
+ await generateAndApplyTheme(themes);
831
+ if (typeof window !== "undefined") {
832
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(themes));
833
+ }
834
+ } catch (err) {
835
+ const errorMessage = err instanceof Error ? err.message : "Failed to apply theme";
836
+ setError(errorMessage);
837
+ console.error("Theme application error:", err);
838
+ } finally {
839
+ setIsLoading(false);
840
+ }
841
+ }, []);
842
+ React.useEffect(() => {
843
+ if (typeof window !== "undefined") {
844
+ const stored = localStorage.getItem(STORAGE_KEY);
845
+ if (stored) {
846
+ try {
847
+ const parsed = JSON.parse(stored);
848
+ setSelectedThemes(parsed);
849
+ applyTheme(parsed);
850
+ } catch {
851
+ const defaults = getDefaultThemes();
852
+ setSelectedThemes(defaults);
853
+ applyTheme(defaults);
854
+ }
855
+ } else {
856
+ const defaults = getDefaultThemes();
857
+ applyTheme(defaults);
858
+ }
859
+ }
860
+ }, [applyTheme]);
861
+ const updateTheme = React.useCallback(async (category, themeId) => {
862
+ const newThemes = {
863
+ ...selectedThemes,
864
+ [category]: themeId || void 0
865
+ };
866
+ setSelectedThemes(newThemes);
867
+ await applyTheme(newThemes);
868
+ }, [selectedThemes, applyTheme]);
869
+ const resetToDefaults = React.useCallback(async () => {
870
+ const defaults = getDefaultThemes();
871
+ setSelectedThemes(defaults);
872
+ await applyTheme(defaults);
873
+ }, [applyTheme]);
874
+ const getAvailableThemes = React.useCallback(async (category) => {
875
+ const categories = await getThemeCategories();
876
+ return categories[category]?.themes || {};
877
+ }, []);
878
+ return {
879
+ selectedThemes,
880
+ updateTheme,
881
+ resetToDefaults,
882
+ isLoading,
883
+ error,
884
+ getAvailableThemes
885
+ };
886
+ }
887
+
888
+ // src/themes/ui/ThemeToggle/useThemeToggle.ts
889
+ function useThemeToggle() {
890
+ const { selectedThemes, updateTheme, isLoading, getAvailableThemes } = useTheme();
891
+ const [isOpen, setIsOpen] = React.useState(false);
892
+ const [selectedCategory, setSelectedCategory] = React.useState(null);
893
+ const [themeCategories, setThemeCategories] = React.useState(null);
894
+ const menuRef = React.useRef(null);
895
+ React.useEffect(() => {
896
+ getThemeCategories().then(setThemeCategories);
897
+ }, []);
898
+ React.useEffect(() => {
899
+ function handleClickOutside(event) {
900
+ if (menuRef.current && !menuRef.current.contains(event.target)) {
901
+ setIsOpen(false);
902
+ setSelectedCategory(null);
903
+ }
904
+ }
905
+ if (isOpen) {
906
+ document.addEventListener("mousedown", handleClickOutside);
907
+ return () => document.removeEventListener("mousedown", handleClickOutside);
908
+ }
909
+ }, [isOpen]);
910
+ const handleCategoryClick = React.useCallback((categoryKey) => {
911
+ setSelectedCategory(categoryKey);
912
+ }, []);
913
+ const handleThemeSelect = React.useCallback(async (category, themeId) => {
914
+ const currentTheme = selectedThemes[category];
915
+ const newTheme = currentTheme === themeId ? void 0 : themeId;
916
+ await updateTheme(category, newTheme);
917
+ }, [selectedThemes, updateTheme]);
918
+ const handleBack = React.useCallback(() => {
919
+ setSelectedCategory(null);
920
+ }, []);
921
+ const toggleMenu = React.useCallback(() => {
922
+ setIsOpen((prev) => {
923
+ if (!prev) {
924
+ setSelectedCategory(null);
925
+ }
926
+ return !prev;
927
+ });
928
+ }, []);
929
+ const categories = themeCategories ? Object.entries(themeCategories).sort(([, a], [, b]) => (a.order || 0) - (b.order || 0)) : [];
930
+ return {
931
+ selectedThemes,
932
+ isLoading,
933
+ getAvailableThemes,
934
+ isOpen,
935
+ selectedCategory,
936
+ themeCategories,
937
+ categories,
938
+ menuRef,
939
+ handleCategoryClick,
940
+ handleThemeSelect,
941
+ handleBack,
942
+ toggleMenu
943
+ };
944
+ }
945
+
946
+ // src/themes/ui/ThemeToggle/themeToggleConfig.ts
947
+ var categoryIcons = {
948
+ color: "\u{1F3A8}",
949
+ typography: "\u{1F4DD}",
950
+ shape: "\u{1F532}",
951
+ density: "\u{1F4CF}",
952
+ animation: "\u2728"
953
+ };
954
+ var positionClasses = {
955
+ "bottom-right": "bottom-6 right-6",
956
+ "bottom-left": "bottom-6 left-6",
957
+ "top-right": "top-6 right-6",
958
+ "top-left": "top-6 left-6"
959
+ };
960
+ function getArcConfig(position) {
961
+ switch (position) {
962
+ case "bottom-right":
963
+ return { startAngle: -60, endAngle: -180, sweep: -150 };
964
+ case "bottom-left":
965
+ return { startAngle: -120, endAngle: 0, sweep: 150 };
966
+ case "top-right":
967
+ return { startAngle: 60, endAngle: 0, sweep: 150 };
968
+ case "top-left":
969
+ return { startAngle: 120, endAngle: 0, sweep: -150 };
970
+ }
971
+ }
972
+
973
+ // src/themes/ui/ThemeToggle/themeToggleUtils.ts
974
+ function getPositionOnArc(angleDeg, radius) {
975
+ const rad = angleDeg * Math.PI / 180;
976
+ return {
977
+ x: Math.cos(rad) * radius,
978
+ y: Math.sin(rad) * radius
979
+ };
980
+ }
981
+ function ThemeToggle({
982
+ className,
983
+ position = "bottom-right"
984
+ }) {
985
+ const {
986
+ selectedThemes,
987
+ isLoading,
988
+ getAvailableThemes,
989
+ isOpen,
990
+ selectedCategory,
991
+ categories,
992
+ menuRef,
993
+ handleCategoryClick,
994
+ handleThemeSelect,
995
+ handleBack,
996
+ toggleMenu
997
+ } = useThemeToggle();
998
+ return /* @__PURE__ */ jsxRuntime.jsxs(
999
+ "div",
1000
+ {
1001
+ ref: menuRef,
1002
+ id: "theme-toggle",
1003
+ className: cn("fixed z-50", positionClasses[position], className),
1004
+ children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx(
1006
+ "button",
1007
+ {
1008
+ onClick: toggleMenu,
1009
+ className: cn(
1010
+ "w-14 h-14 rounded-full bg-primary text-primary-foreground",
1011
+ "shadow-lg hover:shadow-xl",
1012
+ "flex items-center justify-center",
1013
+ "relative z-10",
1014
+ "transition-all duration-200",
1015
+ "hover:scale-110 active:scale-95",
1016
+ isOpen && "rotate-90"
1017
+ ),
1018
+ "aria-label": "Theme settings",
1019
+ title: "Theme settings",
1020
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1021
+ "svg",
1022
+ {
1023
+ width: "24",
1024
+ height: "24",
1025
+ viewBox: "0 0 24 24",
1026
+ fill: "none",
1027
+ stroke: "currentColor",
1028
+ strokeWidth: "2",
1029
+ strokeLinecap: "round",
1030
+ strokeLinejoin: "round",
1031
+ children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73 2.15l.22.38a2 2 0 0 1 0 2.73l-.22.38a2 2 0 0 0 2.15 2.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-2.15l-.22-.38a2 2 0 0 1 0-2.73l.22-.38a2 2 0 0 0-2.15-2.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),
1033
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "3" })
1034
+ ]
1035
+ }
1036
+ )
1037
+ }
1038
+ ),
1039
+ isOpen && /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pointer-events-none", children: !selectedCategory ? /* @__PURE__ */ jsxRuntime.jsx(
1040
+ CategoryRing,
1041
+ {
1042
+ categories,
1043
+ onCategoryClick: handleCategoryClick,
1044
+ selectedThemes,
1045
+ position
1046
+ }
1047
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1048
+ ThemeRingAsync,
1049
+ {
1050
+ category: selectedCategory,
1051
+ getAvailableThemes,
1052
+ selectedTheme: selectedThemes[selectedCategory],
1053
+ onThemeSelect: (themeId) => handleThemeSelect(selectedCategory, themeId),
1054
+ onBack: handleBack,
1055
+ isLoading,
1056
+ position
1057
+ }
1058
+ ) }) })
1059
+ ]
1060
+ }
1061
+ );
1062
+ }
1063
+ function RadialWheel({
1064
+ items,
1065
+ position,
1066
+ radius,
1067
+ buttonSize,
1068
+ startOffset = 0.75
1069
+ }) {
1070
+ const arcConfig = getArcConfig(position);
1071
+ const totalItems = items.length;
1072
+ const angleStep = Math.abs(arcConfig.sweep) / totalItems;
1073
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0", children: items.map((item, index) => {
1074
+ const angle = arcConfig.startAngle + angleStep * (index + startOffset) * Math.sign(arcConfig.sweep);
1075
+ const pos = getPositionOnArc(angle, radius);
1076
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1077
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
1078
+ "button",
1079
+ {
1080
+ onClick: item.onClick,
1081
+ disabled: item.disabled,
1082
+ className: cn(
1083
+ "absolute rounded-full",
1084
+ "bg-background border-2 shadow-lg",
1085
+ "flex items-center justify-center text-lg",
1086
+ "pointer-events-auto",
1087
+ "transition-all duration-200",
1088
+ "hover:scale-110 active:scale-95",
1089
+ "disabled:opacity-50 disabled:cursor-not-allowed",
1090
+ item.isSelected ? "border-primary bg-primary text-primary-foreground" : "border-border hover:border-primary/50",
1091
+ item.className
1092
+ ),
1093
+ style: {
1094
+ width: `${buttonSize}px`,
1095
+ height: `${buttonSize}px`,
1096
+ left: `${pos.x}px`,
1097
+ top: `${pos.y}px`
1098
+ },
1099
+ "aria-label": item.label,
1100
+ children: item.content
1101
+ }
1102
+ ) }),
1103
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "right", sideOffset: 8, children: item.label })
1104
+ ] }, item.id);
1105
+ }) });
1106
+ }
1107
+ function CategoryRing({
1108
+ categories,
1109
+ onCategoryClick,
1110
+ selectedThemes,
1111
+ position
1112
+ }) {
1113
+ const radius = 60;
1114
+ const buttonSize = 40;
1115
+ const items = categories.map(([categoryKey, category]) => {
1116
+ const hasSelection = !!selectedThemes[categoryKey];
1117
+ return {
1118
+ id: categoryKey,
1119
+ content: categoryIcons[categoryKey] || "\u2699\uFE0F",
1120
+ label: category.name,
1121
+ onClick: () => onCategoryClick(categoryKey),
1122
+ isSelected: hasSelection,
1123
+ className: hasSelection ? "bg-primary/10" : void 0
1124
+ };
1125
+ });
1126
+ return /* @__PURE__ */ jsxRuntime.jsx(
1127
+ RadialWheel,
1128
+ {
1129
+ items,
1130
+ position,
1131
+ radius,
1132
+ buttonSize,
1133
+ startOffset: 0.5
1134
+ }
1135
+ );
1136
+ }
1137
+ function ThemeRingAsync({
1138
+ category,
1139
+ getAvailableThemes,
1140
+ selectedTheme,
1141
+ onThemeSelect,
1142
+ onBack,
1143
+ isLoading,
1144
+ position
1145
+ }) {
1146
+ const [themes, setThemes] = React.useState({});
1147
+ React.useEffect(() => {
1148
+ getAvailableThemes(category).then(setThemes);
1149
+ }, [category, getAvailableThemes]);
1150
+ const themeEntries = Object.entries(themes);
1151
+ const radius = 65;
1152
+ const buttonSize = 40;
1153
+ const backButtonSize = 36;
1154
+ const arcConfig = getArcConfig(position);
1155
+ const backButtonPos = getPositionOnArc(arcConfig.startAngle, radius);
1156
+ const items = themeEntries.map(([themeId, theme]) => ({
1157
+ id: themeId,
1158
+ content: theme.icon,
1159
+ label: theme.name,
1160
+ onClick: () => !isLoading && onThemeSelect(themeId),
1161
+ isSelected: selectedTheme === themeId,
1162
+ disabled: isLoading,
1163
+ className: "text-base"
1164
+ // Smaller text for theme icons
1165
+ }));
1166
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-0", children: [
1167
+ /* @__PURE__ */ jsxRuntime.jsx(
1168
+ "button",
1169
+ {
1170
+ onClick: onBack,
1171
+ className: cn(
1172
+ "absolute rounded-full",
1173
+ "bg-muted border border-border shadow-md",
1174
+ "flex items-center justify-center",
1175
+ "pointer-events-auto",
1176
+ "transition-all duration-200",
1177
+ "hover:scale-110 active:scale-95"
1178
+ ),
1179
+ style: {
1180
+ width: `${backButtonSize}px`,
1181
+ height: `${backButtonSize}px`,
1182
+ left: `${backButtonPos.x}px`,
1183
+ top: `${backButtonPos.y}px`
1184
+ },
1185
+ "aria-label": "Back",
1186
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1187
+ "svg",
1188
+ {
1189
+ width: "16",
1190
+ height: "16",
1191
+ viewBox: "0 0 24 24",
1192
+ fill: "none",
1193
+ stroke: "currentColor",
1194
+ strokeWidth: "2",
1195
+ strokeLinecap: "round",
1196
+ strokeLinejoin: "round",
1197
+ children: [
1198
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" }),
1199
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" })
1200
+ ]
1201
+ }
1202
+ )
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ jsxRuntime.jsx(
1206
+ RadialWheel,
1207
+ {
1208
+ items,
1209
+ position,
1210
+ radius,
1211
+ buttonSize,
1212
+ startOffset: 1
1213
+ }
1214
+ ),
1215
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx(
1216
+ "div",
1217
+ {
1218
+ className: "absolute w-12 h-12 rounded-full bg-primary/20 border-2 border-primary animate-pulse pointer-events-none",
1219
+ style: {
1220
+ left: "50%",
1221
+ top: "50%",
1222
+ transform: "translate(-50%, -50%)"
1223
+ }
1224
+ }
1225
+ )
1226
+ ] });
1227
+ }
385
1228
 
386
1229
  exports.Badge = Badge;
387
1230
  exports.Button = Button;
@@ -405,7 +1248,19 @@ exports.SelectScrollUpButton = SelectScrollUpButton;
405
1248
  exports.SelectSeparator = SelectSeparator;
406
1249
  exports.SelectTrigger = SelectTrigger;
407
1250
  exports.SelectValue = SelectValue;
1251
+ exports.ThemeToggle = ThemeToggle;
1252
+ exports.Tooltip = Tooltip;
1253
+ exports.TooltipContent = TooltipContent;
1254
+ exports.TooltipProvider = TooltipProvider;
1255
+ exports.TooltipTrigger = TooltipTrigger;
408
1256
  exports.badgeVariants = badgeVariants;
409
1257
  exports.buttonVariants = buttonVariants;
1258
+ exports.getTheme = getTheme;
1259
+ exports.getThemeCategories = getThemeCategories;
1260
+ exports.getThemeFilePath = getThemeFilePath;
1261
+ exports.getThemesForCategory = getThemesForCategory;
1262
+ exports.registerTheme = registerTheme;
1263
+ exports.useTheme = useTheme;
1264
+ exports.useThemeToggle = useThemeToggle;
410
1265
  //# sourceMappingURL=index.js.map
411
1266
  //# sourceMappingURL=index.js.map