@umbra.ui/core 0.1.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/components/controls/Dropdown/types.d.ts +5 -0
- package/dist/components/controls/Dropdown/types.d.ts.map +1 -0
- package/dist/components/controls/Dropdown/types.js +1 -0
- package/dist/components/controls/SegmentedControl/types.d.ts +6 -0
- package/dist/components/controls/SegmentedControl/types.d.ts.map +1 -0
- package/dist/components/controls/SegmentedControl/types.js +1 -0
- package/dist/components/dialogs/Alert/types.d.ts +7 -0
- package/dist/components/dialogs/Alert/types.d.ts.map +1 -0
- package/dist/components/dialogs/Alert/types.js +1 -0
- package/dist/components/dialogs/Toast/types.d.ts +34 -0
- package/dist/components/dialogs/Toast/types.d.ts.map +1 -0
- package/dist/components/dialogs/Toast/types.js +10 -0
- package/dist/components/dialogs/Toast/useToast.d.ts +36 -0
- package/dist/components/dialogs/Toast/useToast.d.ts.map +1 -0
- package/dist/components/dialogs/Toast/useToast.js +90 -0
- package/dist/components/indicators/Tooltip/tooltip.d.ts +3 -0
- package/dist/components/indicators/Tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/indicators/Tooltip/tooltip.js +33 -0
- package/dist/components/indicators/Tooltip/types.d.ts +14 -0
- package/dist/components/indicators/Tooltip/types.d.ts.map +1 -0
- package/dist/components/indicators/Tooltip/types.js +1 -0
- package/dist/components/indicators/Tooltip/useTooltip.d.ts +18 -0
- package/dist/components/indicators/Tooltip/useTooltip.d.ts.map +1 -0
- package/dist/components/indicators/Tooltip/useTooltip.js +57 -0
- package/dist/components/inputs/Tags/tag-bar-styles.d.ts +14 -0
- package/dist/components/inputs/Tags/tag-bar-styles.d.ts.map +1 -0
- package/dist/components/inputs/Tags/tag-bar-styles.js +313 -0
- package/dist/components/inputs/Tags/types.d.ts +93 -0
- package/dist/components/inputs/Tags/types.d.ts.map +1 -0
- package/dist/components/inputs/Tags/types.js +216 -0
- package/dist/components/inputs/search/types.d.ts +9 -0
- package/dist/components/inputs/search/types.d.ts.map +1 -0
- package/dist/components/inputs/search/types.js +1 -0
- package/dist/components/navigation/adaptive/types.d.ts +16 -0
- package/dist/components/navigation/adaptive/types.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/types.js +1 -0
- package/dist/components/navigation/adaptive/useAdaptiveLayout.d.ts +27 -0
- package/dist/components/navigation/adaptive/useAdaptiveLayout.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useAdaptiveLayout.js +40 -0
- package/dist/components/navigation/adaptive/useBreakpoints.d.ts +6 -0
- package/dist/components/navigation/adaptive/useBreakpoints.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useBreakpoints.js +37 -0
- package/dist/components/navigation/adaptive/useContainerMonitor.d.ts +93 -0
- package/dist/components/navigation/adaptive/useContainerMonitor.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useContainerMonitor.js +145 -0
- package/dist/components/navigation/adaptive/useViewAnimation.d.ts +31 -0
- package/dist/components/navigation/adaptive/useViewAnimation.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useViewAnimation.js +591 -0
- package/dist/components/navigation/adaptive/useViewResize.d.ts +52 -0
- package/dist/components/navigation/adaptive/useViewResize.d.ts.map +1 -0
- package/dist/components/navigation/adaptive/useViewResize.js +146 -0
- package/dist/components/navigation/navstack/useNavigationStack.d.ts +25 -0
- package/dist/components/navigation/navstack/useNavigationStack.d.ts.map +1 -0
- package/dist/components/navigation/navstack/useNavigationStack.js +133 -0
- package/dist/components/navigation/slideover/useSlideoverController.d.ts +20 -0
- package/dist/components/navigation/slideover/useSlideoverController.d.ts.map +1 -0
- package/dist/components/navigation/slideover/useSlideoverController.js +267 -0
- package/dist/components/navigation/splitview/useSplitViewController.d.ts +20 -0
- package/dist/components/navigation/splitview/useSplitViewController.d.ts.map +1 -0
- package/dist/components/navigation/splitview/useSplitViewController.js +325 -0
- package/dist/components/navigation/tabcontroller/types.d.ts +21 -0
- package/dist/components/navigation/tabcontroller/types.d.ts.map +1 -0
- package/dist/components/navigation/tabcontroller/types.js +1 -0
- package/dist/components/navigation/tabcontroller/useTabController.d.ts +5 -0
- package/dist/components/navigation/tabcontroller/useTabController.d.ts.map +1 -0
- package/dist/components/navigation/tabcontroller/useTabController.js +10 -0
- package/dist/components/navigation/types.d.ts +8 -0
- package/dist/components/navigation/types.d.ts.map +1 -0
- package/dist/components/navigation/types.js +1 -0
- package/dist/components/pickers/CollectionPicker/types.d.ts +11 -0
- package/dist/components/pickers/CollectionPicker/types.d.ts.map +1 -0
- package/dist/components/pickers/CollectionPicker/types.js +1 -0
- package/dist/components/pickers/ColorPicker/colors.d.ts +13 -0
- package/dist/components/pickers/ColorPicker/colors.d.ts.map +1 -0
- package/dist/components/pickers/ColorPicker/colors.js +266 -0
- package/dist/components/pickers/FilePicker/types.d.ts +10 -0
- package/dist/components/pickers/FilePicker/types.d.ts.map +1 -0
- package/dist/components/pickers/FilePicker/types.js +1 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/theme.d.ts +73 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +279 -0
- package/dist/themes/blank.d.ts +7 -0
- package/dist/themes/blank.d.ts.map +1 -0
- package/dist/themes/blank.js +543 -0
- package/dist/themes/crimson-dark.d.ts +4 -0
- package/dist/themes/crimson-dark.d.ts.map +1 -0
- package/dist/themes/crimson-dark.js +552 -0
- package/dist/themes/cyan-light.d.ts +4 -0
- package/dist/themes/cyan-light.d.ts.map +1 -0
- package/dist/themes/cyan-light.js +552 -0
- package/dist/themes/dark.d.ts +4 -0
- package/dist/themes/dark.d.ts.map +1 -0
- package/dist/themes/dark.js +551 -0
- package/dist/themes/gold-dark.d.ts +4 -0
- package/dist/themes/gold-dark.d.ts.map +1 -0
- package/dist/themes/gold-dark.js +552 -0
- package/dist/themes/grass-dark.d.ts +4 -0
- package/dist/themes/grass-dark.d.ts.map +1 -0
- package/dist/themes/grass-dark.js +552 -0
- package/dist/themes/indigo.d.ts +4 -0
- package/dist/themes/indigo.d.ts.map +1 -0
- package/dist/themes/indigo.js +552 -0
- package/dist/themes/light.d.ts +4 -0
- package/dist/themes/light.d.ts.map +1 -0
- package/dist/themes/light.js +551 -0
- package/dist/themes/orange-dark.d.ts +4 -0
- package/dist/themes/orange-dark.d.ts.map +1 -0
- package/dist/themes/orange-dark.js +551 -0
- package/dist/themes/orange-light.d.ts +4 -0
- package/dist/themes/orange-light.d.ts.map +1 -0
- package/dist/themes/orange-light.js +551 -0
- package/package.json +62 -0
- package/src/components/controls/Button/Button.vue +417 -0
- package/src/components/controls/Button/README.md +348 -0
- package/src/components/controls/Button/theme.css +200 -0
- package/src/components/controls/Checkbox/Checkbox.vue +164 -0
- package/src/components/controls/Checkbox/README.md +441 -0
- package/src/components/controls/Checkbox/theme.css +36 -0
- package/src/components/controls/Dropdown/Dropdown.vue +476 -0
- package/src/components/controls/Dropdown/README.md +370 -0
- package/src/components/controls/Dropdown/theme.css +50 -0
- package/src/components/controls/Dropdown/types.ts +6 -0
- package/src/components/controls/IconButton/IconButton.vue +267 -0
- package/src/components/controls/IconButton/README.md +502 -0
- package/src/components/controls/IconButton/theme.css +89 -0
- package/src/components/controls/Radio/README.md +591 -0
- package/src/components/controls/Radio/Radio.vue +89 -0
- package/src/components/controls/Radio/theme.css +14 -0
- package/src/components/controls/RangeSlider/README.md +608 -0
- package/src/components/controls/RangeSlider/RangeSlider.vue +535 -0
- package/src/components/controls/RangeSlider/theme.css +80 -0
- package/src/components/controls/SegmentedControl/README.md +587 -0
- package/src/components/controls/SegmentedControl/SegmentedControl.vue +284 -0
- package/src/components/controls/SegmentedControl/theme.css +60 -0
- package/src/components/controls/SegmentedControl/types.ts +5 -0
- package/src/components/controls/Slider/README.md +627 -0
- package/src/components/controls/Slider/Slider.vue +260 -0
- package/src/components/controls/Slider/theme.css +74 -0
- package/src/components/controls/Stepper/README.md +601 -0
- package/src/components/controls/Stepper/Stepper.vue +103 -0
- package/src/components/controls/Stepper/theme.css +53 -0
- package/src/components/controls/Switch/README.md +667 -0
- package/src/components/controls/Switch/Switch.vue +127 -0
- package/src/components/controls/Switch/theme.css +42 -0
- package/src/components/dialogs/Alert/Alert.vue +218 -0
- package/src/components/dialogs/Alert/README.md +450 -0
- package/src/components/dialogs/Alert/theme.css +44 -0
- package/src/components/dialogs/Alert/types.ts +11 -0
- package/src/components/dialogs/Toast/README.md +522 -0
- package/src/components/dialogs/Toast/Toast.vue +296 -0
- package/src/components/dialogs/Toast/ToastContainer.vue +330 -0
- package/src/components/dialogs/Toast/theme.css +44 -0
- package/src/components/dialogs/Toast/types.ts +46 -0
- package/src/components/dialogs/Toast/useToast.ts +127 -0
- package/src/components/indicators/ProgressBar/ProgressBar.vue +98 -0
- package/src/components/indicators/ProgressBar/README.md +744 -0
- package/src/components/indicators/ProgressBar/theme.css +36 -0
- package/src/components/indicators/Tooltip/README.md +723 -0
- package/src/components/indicators/Tooltip/TooltipProvider.vue +142 -0
- package/src/components/indicators/Tooltip/theme.css +18 -0
- package/src/components/indicators/Tooltip/tooltip.ts +48 -0
- package/src/components/indicators/Tooltip/types.ts +15 -0
- package/src/components/indicators/Tooltip/useTooltip.ts +71 -0
- package/src/components/inputs/AutogrowTextView/AutogrowTextView.vue +110 -0
- package/src/components/inputs/AutogrowTextView/README.md +643 -0
- package/src/components/inputs/AutogrowTextView/theme.css +28 -0
- package/src/components/inputs/InputCard/InputCard.vue +600 -0
- package/src/components/inputs/InputCard/README.md +636 -0
- package/src/components/inputs/InputEmail/InputEmail.vue +698 -0
- package/src/components/inputs/InputEmail/README.md +764 -0
- package/src/components/inputs/InputNumber/InputNumber.vue +300 -0
- package/src/components/inputs/InputNumber/README.md +749 -0
- package/src/components/inputs/InputPhone/InputPhone.vue +645 -0
- package/src/components/inputs/InputPhone/README.md +636 -0
- package/src/components/inputs/InputSecure/InputSecure.vue +646 -0
- package/src/components/inputs/InputSecure/README.md +771 -0
- package/src/components/inputs/InputText/InputText.vue +225 -0
- package/src/components/inputs/InputText/README.md +844 -0
- package/src/components/inputs/OTP/OTP.vue +349 -0
- package/src/components/inputs/OTP/README.md +736 -0
- package/src/components/inputs/OTP/theme.css +50 -0
- package/src/components/inputs/StringCapture/README.md +718 -0
- package/src/components/inputs/StringCapture/StringCapture.vue +315 -0
- package/src/components/inputs/StringCapture/theme.css +86 -0
- package/src/components/inputs/Tags/README.md +897 -0
- package/src/components/inputs/Tags/TagBar.vue +793 -0
- package/src/components/inputs/Tags/TagCreation.vue +219 -0
- package/src/components/inputs/Tags/TagPicker.vue +380 -0
- package/src/components/inputs/Tags/tag-bar-styles.ts +354 -0
- package/src/components/inputs/Tags/theme.css +121 -0
- package/src/components/inputs/Tags/types.ts +346 -0
- package/src/components/inputs/search/README.md +759 -0
- package/src/components/inputs/search/SearchBar.vue +394 -0
- package/src/components/inputs/search/SearchResults.vue +310 -0
- package/src/components/inputs/search/theme.css +187 -0
- package/src/components/inputs/search/types.ts +8 -0
- package/src/components/inputs/theme.css +102 -0
- package/src/components/menus/ActionMenu/ActionMenu.vue +383 -0
- package/src/components/menus/ActionMenu/README.md +825 -0
- package/src/components/menus/ActionMenu/theme.css +93 -0
- package/src/components/models/Popover/Popover.vue +551 -0
- package/src/components/models/Popover/README.md +885 -0
- package/src/components/models/Popover/theme.css +52 -0
- package/src/components/models/Sheet/README.md +1159 -0
- package/src/components/models/Sheet/Sheet.vue +465 -0
- package/src/components/models/Sheet/theme.css +72 -0
- package/src/components/models/Sidebar/README.md +1228 -0
- package/src/components/models/Sidebar/Sidebar.vue +480 -0
- package/src/components/models/Sidebar/theme.css +90 -0
- package/src/components/navigation/adaptive/AdaptiveLayout.vue +779 -0
- package/src/components/navigation/adaptive/AdaptiveLayoutBreadcrumbs.vue +192 -0
- package/src/components/navigation/adaptive/AdaptiveLayoutMenuButton.vue +149 -0
- package/src/components/navigation/adaptive/README.md +768 -0
- package/src/components/navigation/adaptive/types.ts +19 -0
- package/src/components/navigation/adaptive/useAdaptiveLayout.ts +89 -0
- package/src/components/navigation/adaptive/useBreakpoints.ts +41 -0
- package/src/components/navigation/adaptive/useContainerMonitor.ts +214 -0
- package/src/components/navigation/adaptive/useViewAnimation.ts +721 -0
- package/src/components/navigation/adaptive/useViewResize.ts +211 -0
- package/src/components/navigation/navstack/NavigationStack.vue +180 -0
- package/src/components/navigation/navstack/README.md +994 -0
- package/src/components/navigation/navstack/useNavigationStack.ts +164 -0
- package/src/components/navigation/slideover/README.md +1275 -0
- package/src/components/navigation/slideover/SlideoverController.vue +287 -0
- package/src/components/navigation/slideover/useSlideoverController.ts +320 -0
- package/src/components/navigation/splitview/README.md +1115 -0
- package/src/components/navigation/splitview/SplitViewController.vue +176 -0
- package/src/components/navigation/splitview/useSplitViewController.ts +388 -0
- package/src/components/navigation/tabcontroller/README.md +919 -0
- package/src/components/navigation/tabcontroller/TabController.vue +307 -0
- package/src/components/navigation/tabcontroller/TabItem.vue +57 -0
- package/src/components/navigation/tabcontroller/types.ts +24 -0
- package/src/components/navigation/tabcontroller/useTabController.ts +18 -0
- package/src/components/navigation/theme.css +91 -0
- package/src/components/navigation/types.ts +7 -0
- package/src/components/pickers/CollectionPicker/CollectionPicker.vue +398 -0
- package/src/components/pickers/CollectionPicker/README.md +1115 -0
- package/src/components/pickers/CollectionPicker/theme.css +14 -0
- package/src/components/pickers/CollectionPicker/types.ts +11 -0
- package/src/components/pickers/ColorPicker/ColorPicker.vue +376 -0
- package/src/components/pickers/ColorPicker/README.md +1439 -0
- package/src/components/pickers/ColorPicker/colors.ts +299 -0
- package/src/components/pickers/ColorPicker/theme.css +32 -0
- package/src/components/pickers/DatePicker/DatePicker.vue +660 -0
- package/src/components/pickers/DatePicker/README.md +1195 -0
- package/src/components/pickers/DatePicker/theme.css +22 -0
- package/src/components/pickers/FilePicker/FilePicker.vue +534 -0
- package/src/components/pickers/FilePicker/README.md +1542 -0
- package/src/components/pickers/FilePicker/theme.css +48 -0
- package/src/components/pickers/FilePicker/types.ts +10 -0
- package/src/components/pickers/IconPicker/IconPicker.vue +327 -0
- package/src/components/pickers/IconPicker/README.md +1161 -0
- package/src/components/pickers/IconPicker/theme.css +28 -0
- package/src/components/pickers/theme.css +82 -0
- package/src/components/views/MarkdownViewer/MarkdownViewer.vue +442 -0
- package/src/components/views/MarkdownViewer/README.md +833 -0
- package/src/components/views/MarkdownViewer/theme.css +130 -0
- package/src/index.ts +263 -0
- package/src/theme.ts +378 -0
- package/src/themes/crimson-dark.ts +556 -0
- package/src/themes/cyan-light.ts +556 -0
- package/src/themes/dark.ts +557 -0
- package/src/themes/gold-dark.ts +556 -0
- package/src/themes/grass-dark.ts +556 -0
- package/src/themes/indigo.ts +556 -0
- package/src/themes/light.ts +557 -0
- package/src/themes/orange-dark.ts +557 -0
- package/src/themes/orange-light.ts +557 -0
- package/src/vue.d.ts +45 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import tinycolor from "tinycolor2";
|
|
2
|
+
import * as colors from "@umbra-ui/colors";
|
|
3
|
+
import { ThemeObject } from "../../../index";
|
|
4
|
+
import { getThemeConfig } from "../../../theme";
|
|
5
|
+
|
|
6
|
+
// Core interfaces
|
|
7
|
+
export interface TagItem {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
style?: TagStyleConfig;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Simplified style configuration - direct CSS properties
|
|
14
|
+
export interface TagStyleConfig {
|
|
15
|
+
// Direct CSS properties for full control
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
border?: string;
|
|
19
|
+
borderRadius?: string;
|
|
20
|
+
padding?: string;
|
|
21
|
+
fontSize?: string;
|
|
22
|
+
fontWeight?: string;
|
|
23
|
+
boxShadow?: string;
|
|
24
|
+
|
|
25
|
+
// Optional hover state
|
|
26
|
+
hover?: {
|
|
27
|
+
backgroundColor?: string;
|
|
28
|
+
color?: string;
|
|
29
|
+
border?: string;
|
|
30
|
+
transform?: string;
|
|
31
|
+
boxShadow?: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Helper properties for convenience
|
|
35
|
+
size?: TagSize;
|
|
36
|
+
colorScheme?: ColorScheme; // Can still use predefined colors if desired
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type TagSize = "sm" | "md" | "lg";
|
|
40
|
+
export type ColorScheme = SolidColorName | string; // Radix color name or hex
|
|
41
|
+
|
|
42
|
+
export type SolidColorName =
|
|
43
|
+
| "gray"
|
|
44
|
+
| "mauve"
|
|
45
|
+
| "slate"
|
|
46
|
+
| "sage"
|
|
47
|
+
| "olive"
|
|
48
|
+
| "sand"
|
|
49
|
+
| "tomato"
|
|
50
|
+
| "red"
|
|
51
|
+
| "ruby"
|
|
52
|
+
| "crimson"
|
|
53
|
+
| "pink"
|
|
54
|
+
| "plum"
|
|
55
|
+
| "purple"
|
|
56
|
+
| "violet"
|
|
57
|
+
| "iris"
|
|
58
|
+
| "indigo"
|
|
59
|
+
| "blue"
|
|
60
|
+
| "cyan"
|
|
61
|
+
| "teal"
|
|
62
|
+
| "jade"
|
|
63
|
+
| "green"
|
|
64
|
+
| "grass"
|
|
65
|
+
| "bronze"
|
|
66
|
+
| "gold"
|
|
67
|
+
| "brown"
|
|
68
|
+
| "orange"
|
|
69
|
+
| "amber"
|
|
70
|
+
| "yellow"
|
|
71
|
+
| "lime"
|
|
72
|
+
| "mint"
|
|
73
|
+
| "sky";
|
|
74
|
+
|
|
75
|
+
// Simplified style interface that matches CSS directly
|
|
76
|
+
export interface TagStyle {
|
|
77
|
+
container: {
|
|
78
|
+
backgroundColor: string;
|
|
79
|
+
color: string;
|
|
80
|
+
border: string;
|
|
81
|
+
borderRadius: string;
|
|
82
|
+
padding: string;
|
|
83
|
+
fontSize?: string;
|
|
84
|
+
fontWeight?: string;
|
|
85
|
+
boxShadow?: string;
|
|
86
|
+
};
|
|
87
|
+
hover?: {
|
|
88
|
+
backgroundColor?: string;
|
|
89
|
+
color?: string;
|
|
90
|
+
border?: string;
|
|
91
|
+
transform?: string;
|
|
92
|
+
boxShadow?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Clean data interface (no callbacks)
|
|
97
|
+
export interface TagData {
|
|
98
|
+
query: string;
|
|
99
|
+
allTags: TagItem[];
|
|
100
|
+
selectedTags: TagItem[];
|
|
101
|
+
matchIndex: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Color mode detection function that uses theme or falls back to system
|
|
105
|
+
export const getColorMode = (): "light" | "dark" => {
|
|
106
|
+
const config = getThemeConfig();
|
|
107
|
+
// If a theme is provided, use its color mode
|
|
108
|
+
if (config?.customThemeColorMode) {
|
|
109
|
+
return config.customThemeColorMode;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Otherwise fall back to system preference
|
|
113
|
+
return window.matchMedia?.("(prefers-color-scheme: dark)").matches
|
|
114
|
+
? "dark"
|
|
115
|
+
: "light";
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Size presets
|
|
119
|
+
const SIZE_PRESETS: Record<TagSize, { padding: string; fontSize: string }> = {
|
|
120
|
+
sm: { padding: "0.125rem 0.375rem", fontSize: "0.75rem" },
|
|
121
|
+
md: { padding: "0.235rem 0.588rem", fontSize: "0.875rem" },
|
|
122
|
+
lg: { padding: "0.375rem 0.75rem", fontSize: "1rem" },
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Helper to get Radix colors based on color mode
|
|
126
|
+
const getRadixColor = (
|
|
127
|
+
colorName: SolidColorName,
|
|
128
|
+
step: number,
|
|
129
|
+
alpha = false
|
|
130
|
+
): string => {
|
|
131
|
+
const isDark = getColorMode() === "dark";
|
|
132
|
+
const colorKey = isDark ? `${colorName}Dark` : colorName;
|
|
133
|
+
const alphaKey = alpha ? "A" : "";
|
|
134
|
+
const colorScale = (colors as any)[`${colorKey}${alphaKey}`];
|
|
135
|
+
|
|
136
|
+
if (!colorScale) {
|
|
137
|
+
console.warn(`Color scale ${colorKey}${alphaKey} not found`);
|
|
138
|
+
return "#808080";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const stepKey = `${colorName}${alphaKey}${step}`;
|
|
142
|
+
return colorScale[stepKey] || "#808080";
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Check if a string is a valid Radix color name
|
|
146
|
+
const isRadixColor = (color: string): color is SolidColorName => {
|
|
147
|
+
const radixColors: SolidColorName[] = [
|
|
148
|
+
"gray",
|
|
149
|
+
"mauve",
|
|
150
|
+
"slate",
|
|
151
|
+
"sage",
|
|
152
|
+
"olive",
|
|
153
|
+
"sand",
|
|
154
|
+
"tomato",
|
|
155
|
+
"red",
|
|
156
|
+
"ruby",
|
|
157
|
+
"crimson",
|
|
158
|
+
"pink",
|
|
159
|
+
"plum",
|
|
160
|
+
"purple",
|
|
161
|
+
"violet",
|
|
162
|
+
"iris",
|
|
163
|
+
"indigo",
|
|
164
|
+
"blue",
|
|
165
|
+
"cyan",
|
|
166
|
+
"teal",
|
|
167
|
+
"jade",
|
|
168
|
+
"green",
|
|
169
|
+
"grass",
|
|
170
|
+
"bronze",
|
|
171
|
+
"gold",
|
|
172
|
+
"brown",
|
|
173
|
+
"orange",
|
|
174
|
+
"amber",
|
|
175
|
+
"yellow",
|
|
176
|
+
"lime",
|
|
177
|
+
"mint",
|
|
178
|
+
"sky",
|
|
179
|
+
];
|
|
180
|
+
return radixColors.includes(color as SolidColorName);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// Default style values
|
|
184
|
+
const DEFAULT_STYLE: TagStyle = {
|
|
185
|
+
container: {
|
|
186
|
+
backgroundColor: "var(--default-tag-background-color)",
|
|
187
|
+
color: "var(--default-tag-color)",
|
|
188
|
+
border: "1px solid var(--default-tag-border)",
|
|
189
|
+
borderRadius: "var(--default-tag-border-radius)",
|
|
190
|
+
padding: "var(--default-tag-padding)",
|
|
191
|
+
fontSize: "var(--default-tag-font-size)",
|
|
192
|
+
fontWeight: "var(--default-tag-font-weight)",
|
|
193
|
+
},
|
|
194
|
+
hover: {
|
|
195
|
+
backgroundColor: "var(--default-tag-hover-background-color)",
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Generate default style from color scheme
|
|
200
|
+
const generateDefaultStyleFromColor = (colorScheme: string): TagStyle => {
|
|
201
|
+
if (isRadixColor(colorScheme)) {
|
|
202
|
+
// Use Radix color scale
|
|
203
|
+
return {
|
|
204
|
+
container: {
|
|
205
|
+
backgroundColor: getRadixColor(colorScheme, 5, true),
|
|
206
|
+
color: getRadixColor(colorScheme, 11),
|
|
207
|
+
border: `1px solid ${getRadixColor(colorScheme, 7)}`,
|
|
208
|
+
borderRadius: "0.375rem",
|
|
209
|
+
padding: SIZE_PRESETS.md.padding,
|
|
210
|
+
fontSize: SIZE_PRESETS.md.fontSize,
|
|
211
|
+
},
|
|
212
|
+
hover: {
|
|
213
|
+
backgroundColor: getRadixColor(colorScheme, 5, true),
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
} else {
|
|
217
|
+
// Use custom hex color
|
|
218
|
+
const baseColor = tinycolor(colorScheme);
|
|
219
|
+
const isDark = getColorMode() === "dark";
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
container: {
|
|
223
|
+
backgroundColor: isDark
|
|
224
|
+
? baseColor.setAlpha(0.2).toRgbString()
|
|
225
|
+
: baseColor.setAlpha(0.15).toRgbString(),
|
|
226
|
+
color: isDark
|
|
227
|
+
? baseColor.lighten(20).toHexString()
|
|
228
|
+
: baseColor.darken(20).toHexString(),
|
|
229
|
+
border: `1px solid ${baseColor.setAlpha(0.3).toRgbString()}`,
|
|
230
|
+
borderRadius: "0.375rem",
|
|
231
|
+
padding: SIZE_PRESETS.md.padding,
|
|
232
|
+
fontSize: SIZE_PRESETS.md.fontSize,
|
|
233
|
+
},
|
|
234
|
+
hover: {
|
|
235
|
+
backgroundColor: isDark
|
|
236
|
+
? baseColor.setAlpha(0.3).toRgbString()
|
|
237
|
+
: baseColor.setAlpha(0.25).toRgbString(),
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// Main style generation function - much simpler!
|
|
244
|
+
export const generateTagStyle = (config: TagStyleConfig = {}): TagStyle => {
|
|
245
|
+
let baseStyle: TagStyle = { ...DEFAULT_STYLE };
|
|
246
|
+
|
|
247
|
+
// If a color scheme is provided, generate default colors from it
|
|
248
|
+
if (config.colorScheme) {
|
|
249
|
+
baseStyle = generateDefaultStyleFromColor(config.colorScheme);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Apply size preset if provided
|
|
253
|
+
if (config.size) {
|
|
254
|
+
const sizeConfig = SIZE_PRESETS[config.size];
|
|
255
|
+
baseStyle.container.padding = sizeConfig.padding;
|
|
256
|
+
baseStyle.container.fontSize = sizeConfig.fontSize;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Direct CSS property overrides - these take precedence
|
|
260
|
+
const style: TagStyle = {
|
|
261
|
+
container: {
|
|
262
|
+
...baseStyle.container,
|
|
263
|
+
backgroundColor:
|
|
264
|
+
config.backgroundColor ?? baseStyle.container.backgroundColor,
|
|
265
|
+
color: config.color ?? baseStyle.container.color,
|
|
266
|
+
border: config.border ?? baseStyle.container.border,
|
|
267
|
+
borderRadius: config.borderRadius ?? baseStyle.container.borderRadius,
|
|
268
|
+
padding: config.padding ?? baseStyle.container.padding,
|
|
269
|
+
fontSize: config.fontSize ?? baseStyle.container.fontSize,
|
|
270
|
+
fontWeight: config.fontWeight ?? baseStyle.container.fontWeight,
|
|
271
|
+
boxShadow: config.boxShadow ?? baseStyle.container.boxShadow,
|
|
272
|
+
},
|
|
273
|
+
hover: config.hover
|
|
274
|
+
? {
|
|
275
|
+
...baseStyle.hover,
|
|
276
|
+
...config.hover,
|
|
277
|
+
}
|
|
278
|
+
: baseStyle.hover,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
return style;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// Helper to create tag with style
|
|
285
|
+
export const createStyledTag = (
|
|
286
|
+
id: string,
|
|
287
|
+
title: string,
|
|
288
|
+
styleConfig?: TagStyleConfig
|
|
289
|
+
): TagItem => ({
|
|
290
|
+
id,
|
|
291
|
+
title,
|
|
292
|
+
style: styleConfig,
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Preset color schemes using Radix colors
|
|
296
|
+
export const COLOR_PRESETS = {
|
|
297
|
+
primary: "blue",
|
|
298
|
+
success: "green",
|
|
299
|
+
warning: "amber",
|
|
300
|
+
danger: "red",
|
|
301
|
+
info: "cyan",
|
|
302
|
+
neutral: "gray",
|
|
303
|
+
} as const;
|
|
304
|
+
|
|
305
|
+
// Example preset styles that developers can use or override
|
|
306
|
+
export const TAG_STYLE_PRESETS = {
|
|
307
|
+
default: {
|
|
308
|
+
borderRadius: "999px",
|
|
309
|
+
padding: "0.235rem 0.588rem",
|
|
310
|
+
},
|
|
311
|
+
rounded: {
|
|
312
|
+
borderRadius: "0.375rem",
|
|
313
|
+
padding: "0.235rem 0.588rem",
|
|
314
|
+
},
|
|
315
|
+
square: {
|
|
316
|
+
borderRadius: "0",
|
|
317
|
+
padding: "0.235rem 0.588rem",
|
|
318
|
+
},
|
|
319
|
+
pill: {
|
|
320
|
+
borderRadius: "999px",
|
|
321
|
+
padding: "0.25rem 0.75rem",
|
|
322
|
+
},
|
|
323
|
+
minimal: {
|
|
324
|
+
backgroundColor: "transparent",
|
|
325
|
+
border: "none",
|
|
326
|
+
padding: "0.125rem 0.375rem",
|
|
327
|
+
},
|
|
328
|
+
} as const;
|
|
329
|
+
|
|
330
|
+
// Utility class for managing tag themes (simplified)
|
|
331
|
+
export class TagTheme {
|
|
332
|
+
private defaultStyle: TagStyleConfig;
|
|
333
|
+
|
|
334
|
+
constructor(defaultStyle: TagStyleConfig = {}) {
|
|
335
|
+
this.defaultStyle = defaultStyle;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
generateStyle(overrides?: TagStyleConfig): TagStyle {
|
|
339
|
+
return generateTagStyle({ ...this.defaultStyle, ...overrides });
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Create a tag with the theme's default style
|
|
343
|
+
createTag(id: string, title: string, overrides?: TagStyleConfig): TagItem {
|
|
344
|
+
return createStyledTag(id, title, { ...this.defaultStyle, ...overrides });
|
|
345
|
+
}
|
|
346
|
+
}
|