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