@open-elements/ui 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/LICENSE +201 -0
- package/README.md +37 -0
- package/dist/brand.css +48 -0
- package/dist/components/alert-dialog.d.ts +19 -0
- package/dist/components/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog.js +66 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +37 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +11 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +48 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +9 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +58 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +10 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +43 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/combobox.d.ts +25 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +85 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/dialog.d.ts +18 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +59 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/health-status.d.ts +12 -0
- package/dist/components/health-status.d.ts.map +1 -0
- package/dist/components/health-status.js +8 -0
- package/dist/components/health-status.js.map +1 -0
- package/dist/components/input-group.d.ts +17 -0
- package/dist/components/input-group.d.ts.map +1 -0
- package/dist/components/input-group.js +82 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +4 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +19 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.d.ts +5 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/label.js +21 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/language-switch.d.ts +2 -0
- package/dist/components/language-switch.d.ts.map +1 -0
- package/dist/components/language-switch.js +13 -0
- package/dist/components/language-switch.js.map +1 -0
- package/dist/components/popover.d.ts +11 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +45 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/select.d.ts +16 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +60 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +5 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/separator.js +21 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +15 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sheet.js +62 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +53 -0
- package/dist/components/sidebar.d.ts.map +1 -0
- package/dist/components/sidebar.js +44 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.d.ts +3 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +19 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/table.d.ts +11 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +48 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tag-chips.d.ts +8 -0
- package/dist/components/tag-chips.d.ts.map +1 -0
- package/dist/components/tag-chips.js +22 -0
- package/dist/components/tag-chips.js.map +1 -0
- package/dist/components/tag-form.d.ts +29 -0
- package/dist/components/tag-form.d.ts.map +1 -0
- package/dist/components/tag-form.js +84 -0
- package/dist/components/tag-form.js.map +1 -0
- package/dist/components/tag-multi-select.d.ts +4 -0
- package/dist/components/tag-multi-select.d.ts.map +1 -0
- package/dist/components/tag-multi-select.js +30 -0
- package/dist/components/tag-multi-select.js.map +1 -0
- package/dist/components/textarea.d.ts +4 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +19 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/tooltip.d.ts +8 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +26 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/i18n/de.d.ts +7 -0
- package/dist/i18n/de.d.ts.map +1 -0
- package/dist/i18n/de.js +7 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/en.d.ts +7 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +7 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/language-context.d.ts +14 -0
- package/dist/i18n/language-context.d.ts.map +1 -0
- package/dist/i18n/language-context.js +77 -0
- package/dist/i18n/language-context.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +77 -0
- package/src/components/__tests__/button.test.tsx +41 -0
- package/src/components/__tests__/input.test.tsx +28 -0
- package/src/components/__tests__/tag-multi-select.test.tsx +131 -0
- package/src/components/__tests__/textarea.test.tsx +22 -0
- package/src/components/alert-dialog.tsx +179 -0
- package/src/components/badge.tsx +46 -0
- package/src/components/button.tsx +62 -0
- package/src/components/calendar.tsx +180 -0
- package/src/components/card.tsx +75 -0
- package/src/components/combobox.tsx +277 -0
- package/src/components/dialog.tsx +144 -0
- package/src/components/health-status.tsx +37 -0
- package/src/components/input-group.tsx +158 -0
- package/src/components/input.tsx +21 -0
- package/src/components/label.tsx +21 -0
- package/src/components/language-switch.tsx +36 -0
- package/src/components/popover.tsx +74 -0
- package/src/components/select.tsx +175 -0
- package/src/components/separator.tsx +28 -0
- package/src/components/sheet.tsx +134 -0
- package/src/components/sidebar.tsx +290 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/table.tsx +92 -0
- package/src/components/tag-chips.tsx +47 -0
- package/src/components/tag-form.tsx +200 -0
- package/src/components/tag-multi-select.tsx +84 -0
- package/src/components/textarea.tsx +18 -0
- package/src/components/tooltip.tsx +32 -0
- package/src/i18n/de.ts +6 -0
- package/src/i18n/en.ts +6 -0
- package/src/i18n/language-context.tsx +104 -0
- package/src/index.ts +156 -0
- package/src/lib/__tests__/utils.test.ts +29 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/brand.css +48 -0
- package/src/test/setup.ts +1 -0
- package/src/types/index.ts +29 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import type { TagOption, TagMultiSelectProps, TagMultiSelectTranslations } from "../types";
|
|
5
|
+
import {
|
|
6
|
+
Combobox,
|
|
7
|
+
ComboboxChips,
|
|
8
|
+
ComboboxChip,
|
|
9
|
+
ComboboxChipsInput,
|
|
10
|
+
ComboboxContent,
|
|
11
|
+
ComboboxItem,
|
|
12
|
+
ComboboxList,
|
|
13
|
+
useComboboxAnchor,
|
|
14
|
+
} from "./combobox";
|
|
15
|
+
|
|
16
|
+
function isValidHex(color: string): boolean {
|
|
17
|
+
return /^#[0-9A-Fa-f]{6}$/.test(color);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getContrastColor(hex: string): string {
|
|
21
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
22
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
23
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
24
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
25
|
+
return luminance > 0.5 ? "#1A1A1A" : "#FFFFFF";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function TagMultiSelect({
|
|
29
|
+
selectedIds,
|
|
30
|
+
onChange,
|
|
31
|
+
loadTags,
|
|
32
|
+
translations,
|
|
33
|
+
}: TagMultiSelectProps) {
|
|
34
|
+
const [tagOptions, setTagOptions] = useState<TagOption[]>([]);
|
|
35
|
+
const anchorRef = useComboboxAnchor();
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
loadTags()
|
|
39
|
+
.then((tags) => setTagOptions(tags))
|
|
40
|
+
.catch(() => {});
|
|
41
|
+
}, [loadTags]);
|
|
42
|
+
|
|
43
|
+
const selectedOptions = tagOptions.filter((opt) => selectedIds.includes(opt.value));
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Combobox
|
|
47
|
+
multiple
|
|
48
|
+
value={selectedOptions}
|
|
49
|
+
onValueChange={(options: TagOption[]) => onChange(options.map((o) => o.value))}
|
|
50
|
+
>
|
|
51
|
+
<ComboboxChips ref={anchorRef}>
|
|
52
|
+
{selectedOptions.map((opt) => {
|
|
53
|
+
const bgColor = isValidHex(opt.color) ? opt.color : "#6B7280";
|
|
54
|
+
const textColor = isValidHex(opt.color) ? getContrastColor(opt.color) : "#FFFFFF";
|
|
55
|
+
return (
|
|
56
|
+
<ComboboxChip key={opt.value} style={{ backgroundColor: bgColor, color: textColor }}>
|
|
57
|
+
{opt.label}
|
|
58
|
+
</ComboboxChip>
|
|
59
|
+
);
|
|
60
|
+
})}
|
|
61
|
+
<ComboboxChipsInput placeholder={translations.placeholder} />
|
|
62
|
+
</ComboboxChips>
|
|
63
|
+
<ComboboxContent anchor={anchorRef}>
|
|
64
|
+
{tagOptions.length === 0 ? (
|
|
65
|
+
<p className="py-2 text-center text-sm text-muted-foreground">{translations.empty}</p>
|
|
66
|
+
) : (
|
|
67
|
+
<ComboboxList>
|
|
68
|
+
{tagOptions.map((opt) => (
|
|
69
|
+
<ComboboxItem key={opt.value} value={opt}>
|
|
70
|
+
<span
|
|
71
|
+
className="inline-block h-4 w-4 rounded-full shrink-0"
|
|
72
|
+
style={{ backgroundColor: isValidHex(opt.color) ? opt.color : "#6B7280" }}
|
|
73
|
+
/>
|
|
74
|
+
{opt.label}
|
|
75
|
+
</ComboboxItem>
|
|
76
|
+
))}
|
|
77
|
+
</ComboboxList>
|
|
78
|
+
)}
|
|
79
|
+
</ComboboxContent>
|
|
80
|
+
</Combobox>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type { TagMultiSelectProps, TagMultiSelectTranslations, TagOption };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
|
|
5
|
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
6
|
+
return (
|
|
7
|
+
<textarea
|
|
8
|
+
data-slot="textarea"
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Textarea };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
|
|
8
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
9
|
+
|
|
10
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
11
|
+
|
|
12
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
13
|
+
|
|
14
|
+
const TooltipContent = React.forwardRef<
|
|
15
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
17
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
18
|
+
<TooltipPrimitive.Portal>
|
|
19
|
+
<TooltipPrimitive.Content
|
|
20
|
+
ref={ref}
|
|
21
|
+
sideOffset={sideOffset}
|
|
22
|
+
className={cn(
|
|
23
|
+
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground 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",
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
</TooltipPrimitive.Portal>
|
|
29
|
+
));
|
|
30
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
31
|
+
|
|
32
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
package/src/i18n/de.ts
ADDED
package/src/i18n/en.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, useEffect, useState, useCallback, useMemo } from "react";
|
|
4
|
+
|
|
5
|
+
export type Language = "de" | "en";
|
|
6
|
+
|
|
7
|
+
const STORAGE_KEY = "language";
|
|
8
|
+
|
|
9
|
+
interface LanguageContextValue<T = Record<string, unknown>> {
|
|
10
|
+
readonly language: Language;
|
|
11
|
+
readonly setLanguage: (lang: Language) => void;
|
|
12
|
+
readonly t: T;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
const LanguageContext = createContext<LanguageContextValue<any> | null>(null);
|
|
17
|
+
|
|
18
|
+
function detectLanguage(): Language {
|
|
19
|
+
try {
|
|
20
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
21
|
+
if (stored === "de" || stored === "en") {
|
|
22
|
+
return stored;
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
// localStorage not available
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof navigator !== "undefined") {
|
|
29
|
+
const browserLang = navigator.language;
|
|
30
|
+
if (browserLang.startsWith("de")) {
|
|
31
|
+
return "de";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return "en";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface LanguageProviderProps<T> {
|
|
39
|
+
readonly translations: Record<Language, T>;
|
|
40
|
+
readonly defaultLanguage?: Language;
|
|
41
|
+
readonly children: React.ReactNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function LanguageProvider<T>({
|
|
45
|
+
translations,
|
|
46
|
+
children,
|
|
47
|
+
defaultLanguage,
|
|
48
|
+
}: LanguageProviderProps<T>) {
|
|
49
|
+
const [language, setLanguageState] = useState<Language>(defaultLanguage ?? "en");
|
|
50
|
+
const [mounted, setMounted] = useState(!!defaultLanguage);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!defaultLanguage) {
|
|
54
|
+
const detected = detectLanguage();
|
|
55
|
+
setLanguageState(detected);
|
|
56
|
+
document.documentElement.lang = detected;
|
|
57
|
+
setMounted(true);
|
|
58
|
+
} else {
|
|
59
|
+
document.documentElement.lang = defaultLanguage;
|
|
60
|
+
}
|
|
61
|
+
}, [defaultLanguage]);
|
|
62
|
+
|
|
63
|
+
const setLanguage = useCallback((lang: Language) => {
|
|
64
|
+
setLanguageState(lang);
|
|
65
|
+
document.documentElement.lang = lang;
|
|
66
|
+
try {
|
|
67
|
+
localStorage.setItem(STORAGE_KEY, lang);
|
|
68
|
+
} catch {
|
|
69
|
+
// localStorage not available
|
|
70
|
+
}
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (mounted) {
|
|
75
|
+
try {
|
|
76
|
+
localStorage.setItem(STORAGE_KEY, language);
|
|
77
|
+
} catch {
|
|
78
|
+
// localStorage not available
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, [language, mounted]);
|
|
82
|
+
|
|
83
|
+
const t = useMemo(() => translations[language], [translations, language]);
|
|
84
|
+
|
|
85
|
+
const value = useMemo(() => ({ language, setLanguage, t }), [language, setLanguage, t]);
|
|
86
|
+
|
|
87
|
+
return <LanguageContext.Provider value={value}>{children}</LanguageContext.Provider>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function useTranslations<T = Record<string, unknown>>(): T {
|
|
91
|
+
const context = useContext(LanguageContext);
|
|
92
|
+
if (!context) {
|
|
93
|
+
throw new Error("useTranslations must be used within a LanguageProvider");
|
|
94
|
+
}
|
|
95
|
+
return context.t as T;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function useLanguage(): { language: Language; setLanguage: (lang: Language) => void } {
|
|
99
|
+
const context = useContext(LanguageContext);
|
|
100
|
+
if (!context) {
|
|
101
|
+
throw new Error("useLanguage must be used within a LanguageProvider");
|
|
102
|
+
}
|
|
103
|
+
return { language: context.language, setLanguage: context.setLanguage };
|
|
104
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Components
|
|
2
|
+
export { Button, buttonVariants } from "./components/button";
|
|
3
|
+
export { Input } from "./components/input";
|
|
4
|
+
export { Textarea } from "./components/textarea";
|
|
5
|
+
export {
|
|
6
|
+
InputGroup,
|
|
7
|
+
InputGroupAddon,
|
|
8
|
+
InputGroupButton,
|
|
9
|
+
InputGroupText,
|
|
10
|
+
InputGroupInput,
|
|
11
|
+
InputGroupTextarea,
|
|
12
|
+
} from "./components/input-group";
|
|
13
|
+
export {
|
|
14
|
+
Combobox,
|
|
15
|
+
ComboboxInput,
|
|
16
|
+
ComboboxContent,
|
|
17
|
+
ComboboxList,
|
|
18
|
+
ComboboxItem,
|
|
19
|
+
ComboboxGroup,
|
|
20
|
+
ComboboxLabel,
|
|
21
|
+
ComboboxCollection,
|
|
22
|
+
ComboboxEmpty,
|
|
23
|
+
ComboboxSeparator,
|
|
24
|
+
ComboboxChips,
|
|
25
|
+
ComboboxChip,
|
|
26
|
+
ComboboxChipsInput,
|
|
27
|
+
ComboboxTrigger,
|
|
28
|
+
ComboboxValue,
|
|
29
|
+
useComboboxAnchor,
|
|
30
|
+
} from "./components/combobox";
|
|
31
|
+
export { TagMultiSelect } from "./components/tag-multi-select";
|
|
32
|
+
export type {
|
|
33
|
+
TagMultiSelectProps,
|
|
34
|
+
TagMultiSelectTranslations,
|
|
35
|
+
TagOption,
|
|
36
|
+
} from "./components/tag-multi-select";
|
|
37
|
+
|
|
38
|
+
// shadcn/ui components
|
|
39
|
+
export {
|
|
40
|
+
AlertDialog,
|
|
41
|
+
AlertDialogAction,
|
|
42
|
+
AlertDialogCancel,
|
|
43
|
+
AlertDialogContent,
|
|
44
|
+
AlertDialogDescription,
|
|
45
|
+
AlertDialogFooter,
|
|
46
|
+
AlertDialogHeader,
|
|
47
|
+
AlertDialogMedia,
|
|
48
|
+
AlertDialogOverlay,
|
|
49
|
+
AlertDialogPortal,
|
|
50
|
+
AlertDialogTitle,
|
|
51
|
+
AlertDialogTrigger,
|
|
52
|
+
} from "./components/alert-dialog";
|
|
53
|
+
export { Badge, badgeVariants } from "./components/badge";
|
|
54
|
+
export { Calendar, CalendarDayButton } from "./components/calendar";
|
|
55
|
+
export {
|
|
56
|
+
Card,
|
|
57
|
+
CardHeader,
|
|
58
|
+
CardFooter,
|
|
59
|
+
CardTitle,
|
|
60
|
+
CardAction,
|
|
61
|
+
CardDescription,
|
|
62
|
+
CardContent,
|
|
63
|
+
} from "./components/card";
|
|
64
|
+
export {
|
|
65
|
+
Dialog,
|
|
66
|
+
DialogClose,
|
|
67
|
+
DialogContent,
|
|
68
|
+
DialogDescription,
|
|
69
|
+
DialogFooter,
|
|
70
|
+
DialogHeader,
|
|
71
|
+
DialogOverlay,
|
|
72
|
+
DialogPortal,
|
|
73
|
+
DialogTitle,
|
|
74
|
+
DialogTrigger,
|
|
75
|
+
} from "./components/dialog";
|
|
76
|
+
export { Label } from "./components/label";
|
|
77
|
+
export {
|
|
78
|
+
Popover,
|
|
79
|
+
PopoverTrigger,
|
|
80
|
+
PopoverContent,
|
|
81
|
+
PopoverAnchor,
|
|
82
|
+
PopoverHeader,
|
|
83
|
+
PopoverTitle,
|
|
84
|
+
PopoverDescription,
|
|
85
|
+
} from "./components/popover";
|
|
86
|
+
export {
|
|
87
|
+
Select,
|
|
88
|
+
SelectContent,
|
|
89
|
+
SelectGroup,
|
|
90
|
+
SelectItem,
|
|
91
|
+
SelectLabel,
|
|
92
|
+
SelectScrollDownButton,
|
|
93
|
+
SelectScrollUpButton,
|
|
94
|
+
SelectSeparator,
|
|
95
|
+
SelectTrigger,
|
|
96
|
+
SelectValue,
|
|
97
|
+
} from "./components/select";
|
|
98
|
+
export { Separator } from "./components/separator";
|
|
99
|
+
export {
|
|
100
|
+
Sheet,
|
|
101
|
+
SheetTrigger,
|
|
102
|
+
SheetClose,
|
|
103
|
+
SheetContent,
|
|
104
|
+
SheetHeader,
|
|
105
|
+
SheetFooter,
|
|
106
|
+
SheetTitle,
|
|
107
|
+
SheetDescription,
|
|
108
|
+
} from "./components/sheet";
|
|
109
|
+
export { Skeleton } from "./components/skeleton";
|
|
110
|
+
export {
|
|
111
|
+
Table,
|
|
112
|
+
TableHeader,
|
|
113
|
+
TableBody,
|
|
114
|
+
TableFooter,
|
|
115
|
+
TableHead,
|
|
116
|
+
TableRow,
|
|
117
|
+
TableCell,
|
|
118
|
+
TableCaption,
|
|
119
|
+
} from "./components/table";
|
|
120
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from "./components/tooltip";
|
|
121
|
+
|
|
122
|
+
// App-level components
|
|
123
|
+
export { LanguageSwitch } from "./components/language-switch";
|
|
124
|
+
export { HealthStatus } from "./components/health-status";
|
|
125
|
+
export type { HealthStatusProps, HealthStatusTranslations } from "./components/health-status";
|
|
126
|
+
export { TagChips } from "./components/tag-chips";
|
|
127
|
+
export type { TagChipsProps } from "./components/tag-chips";
|
|
128
|
+
export { TagForm } from "./components/tag-form";
|
|
129
|
+
export type { TagFormProps, TagFormTranslations } from "./components/tag-form";
|
|
130
|
+
export {
|
|
131
|
+
Sidebar,
|
|
132
|
+
SidebarHeader,
|
|
133
|
+
NavItem,
|
|
134
|
+
CollapsibleGroup,
|
|
135
|
+
UserSection,
|
|
136
|
+
} from "./components/sidebar";
|
|
137
|
+
export type {
|
|
138
|
+
SidebarProps,
|
|
139
|
+
SidebarHeaderProps,
|
|
140
|
+
NavItemProps,
|
|
141
|
+
CollapsibleGroupProps,
|
|
142
|
+
UserSectionProps,
|
|
143
|
+
UserSectionTranslations,
|
|
144
|
+
} from "./components/sidebar";
|
|
145
|
+
|
|
146
|
+
// Types
|
|
147
|
+
export type { TagDto } from "./types";
|
|
148
|
+
|
|
149
|
+
// Utilities
|
|
150
|
+
export { cn } from "./lib/utils";
|
|
151
|
+
|
|
152
|
+
// i18n
|
|
153
|
+
export { LanguageProvider, useTranslations, useLanguage } from "./i18n/language-context";
|
|
154
|
+
export type { Language } from "./i18n/language-context";
|
|
155
|
+
export { de } from "./i18n/de";
|
|
156
|
+
export { en } from "./i18n/en";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { cn } from "../utils";
|
|
3
|
+
|
|
4
|
+
describe("cn", () => {
|
|
5
|
+
it("merges class names", () => {
|
|
6
|
+
expect(cn("foo", "bar")).toBe("foo bar");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("handles conditional classes", () => {
|
|
10
|
+
const condition = false;
|
|
11
|
+
expect(cn("foo", condition && "bar", "baz")).toBe("foo baz");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("deduplicates tailwind classes", () => {
|
|
15
|
+
expect(cn("px-2", "px-4")).toBe("px-4");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("handles undefined and null values", () => {
|
|
19
|
+
expect(cn("foo", undefined, null, "bar")).toBe("foo bar");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("handles empty input", () => {
|
|
23
|
+
expect(cn()).toBe("");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("merges conflicting tailwind utilities", () => {
|
|
27
|
+
expect(cn("text-red-500", "text-blue-500")).toBe("text-blue-500");
|
|
28
|
+
});
|
|
29
|
+
});
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@theme {
|
|
2
|
+
/* Open Elements Brand Colors */
|
|
3
|
+
--color-oe-dark: #020144;
|
|
4
|
+
--color-oe-black: #000000;
|
|
5
|
+
--color-oe-white: #ffffff;
|
|
6
|
+
--color-oe-gray-mid: #b0aea5;
|
|
7
|
+
--color-oe-gray-light: #e8e6dc;
|
|
8
|
+
--color-oe-green: #5cba9e;
|
|
9
|
+
--color-oe-green-light: #bee3d8;
|
|
10
|
+
--color-oe-green-lighter: #def1ec;
|
|
11
|
+
--color-oe-green-dark: #3e9279;
|
|
12
|
+
--color-oe-red: #e63277;
|
|
13
|
+
--color-oe-red-light: #f5adc9;
|
|
14
|
+
--color-oe-red-lighter: #fad6e4;
|
|
15
|
+
--color-oe-red-dark: #bb1756;
|
|
16
|
+
--color-oe-blue: #5db9f5;
|
|
17
|
+
--color-oe-blue-light: #bee3fb;
|
|
18
|
+
--color-oe-blue-lighter: #dff1fd;
|
|
19
|
+
--color-oe-blue-dark: #2496ef;
|
|
20
|
+
--color-oe-yellow: #f1e34b;
|
|
21
|
+
--color-oe-yellow-light: #f9f4b7;
|
|
22
|
+
--color-oe-yellow-lighter: #fcf9db;
|
|
23
|
+
--color-oe-yellow-dark: #dccb12;
|
|
24
|
+
|
|
25
|
+
/* shadcn/ui semantic tokens mapped to Open Elements brand */
|
|
26
|
+
--color-background: #ffffff;
|
|
27
|
+
--color-foreground: #000000;
|
|
28
|
+
--color-card: #ffffff;
|
|
29
|
+
--color-card-foreground: #000000;
|
|
30
|
+
--color-popover: #ffffff;
|
|
31
|
+
--color-popover-foreground: #000000;
|
|
32
|
+
--color-muted: #e8e6dc;
|
|
33
|
+
--color-muted-foreground: #b0aea5;
|
|
34
|
+
--color-accent: #e8e6dc;
|
|
35
|
+
--color-accent-foreground: #000000;
|
|
36
|
+
--color-primary: #5cba9e;
|
|
37
|
+
--color-primary-foreground: #ffffff;
|
|
38
|
+
--color-secondary: #e8e6dc;
|
|
39
|
+
--color-secondary-foreground: #000000;
|
|
40
|
+
--color-destructive: #e63277;
|
|
41
|
+
--color-destructive-foreground: #ffffff;
|
|
42
|
+
--color-border: #e8e6dc;
|
|
43
|
+
--color-input: #e8e6dc;
|
|
44
|
+
--color-ring: #5cba9e;
|
|
45
|
+
|
|
46
|
+
--font-heading: "Montserrat", sans-serif;
|
|
47
|
+
--font-body: "Lato", sans-serif;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface TagDto {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly description: string | null;
|
|
5
|
+
readonly color: string;
|
|
6
|
+
readonly createdAt: string;
|
|
7
|
+
readonly updatedAt: string;
|
|
8
|
+
readonly companyCount: number | null;
|
|
9
|
+
readonly contactCount: number | null;
|
|
10
|
+
readonly taskCount: number | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TagOption {
|
|
14
|
+
readonly value: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly color: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TagMultiSelectTranslations {
|
|
20
|
+
readonly placeholder: string;
|
|
21
|
+
readonly empty: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface TagMultiSelectProps {
|
|
25
|
+
readonly selectedIds: readonly string[];
|
|
26
|
+
readonly onChange: (ids: string[]) => void;
|
|
27
|
+
readonly loadTags: () => Promise<TagOption[]>;
|
|
28
|
+
readonly translations: TagMultiSelectTranslations;
|
|
29
|
+
}
|