@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,27 @@
|
|
|
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
|
+
export interface TagOption {
|
|
13
|
+
readonly value: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly color: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TagMultiSelectTranslations {
|
|
18
|
+
readonly placeholder: string;
|
|
19
|
+
readonly empty: string;
|
|
20
|
+
}
|
|
21
|
+
export interface TagMultiSelectProps {
|
|
22
|
+
readonly selectedIds: readonly string[];
|
|
23
|
+
readonly onChange: (ids: string[]) => void;
|
|
24
|
+
readonly loadTags: () => Promise<TagOption[]>;
|
|
25
|
+
readonly translations: TagMultiSelectTranslations;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,0BAA0B,CAAC;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-elements/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared UI component library for Open Elements applications",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/open-elements/open-elements-ui.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./styles/brand.css": "./dist/brand.css"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": [
|
|
26
|
+
"**/*.css"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"react-dom": "^19.0.0",
|
|
31
|
+
"@base-ui/react": "^1.3.0",
|
|
32
|
+
"radix-ui": "^1.4.0",
|
|
33
|
+
"lucide-react": "^0.500.0",
|
|
34
|
+
"class-variance-authority": "^0.7.0",
|
|
35
|
+
"clsx": "^2.1.0",
|
|
36
|
+
"tailwind-merge": "^3.0.0",
|
|
37
|
+
"react-day-picker": "^9.14.0",
|
|
38
|
+
"date-fns": "^4.1.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
|
+
"@types/react-dom": "^19.0.0",
|
|
43
|
+
"typescript": "^5.0.0",
|
|
44
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
45
|
+
"vitest": "^3.0.0",
|
|
46
|
+
"jsdom": "^26.0.0",
|
|
47
|
+
"@testing-library/react": "^16.0.0",
|
|
48
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
49
|
+
"eslint": "^9.0.0",
|
|
50
|
+
"@eslint/js": "^9.0.0",
|
|
51
|
+
"typescript-eslint": "^8.0.0",
|
|
52
|
+
"prettier": "^3.0.0",
|
|
53
|
+
"react": "^19.0.0",
|
|
54
|
+
"react-dom": "^19.0.0",
|
|
55
|
+
"@base-ui/react": "^1.3.0",
|
|
56
|
+
"radix-ui": "^1.4.0",
|
|
57
|
+
"lucide-react": "^0.500.0",
|
|
58
|
+
"class-variance-authority": "^0.7.0",
|
|
59
|
+
"clsx": "^2.1.0",
|
|
60
|
+
"tailwind-merge": "^3.0.0",
|
|
61
|
+
"react-day-picker": "^9.14.0",
|
|
62
|
+
"date-fns": "^4.1.0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsc -p tsconfig.build.json && pnpm run build:css",
|
|
66
|
+
"build:css": "cp src/styles/brand.css dist/brand.css",
|
|
67
|
+
"clean": "rm -rf dist",
|
|
68
|
+
"prebuild": "pnpm run clean",
|
|
69
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
70
|
+
"test": "vitest run",
|
|
71
|
+
"test:watch": "vitest",
|
|
72
|
+
"lint": "eslint src/",
|
|
73
|
+
"format": "prettier --write src/",
|
|
74
|
+
"format:check": "prettier --check src/",
|
|
75
|
+
"typecheck": "tsc --noEmit"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Button } from "../button";
|
|
4
|
+
|
|
5
|
+
describe("Button", () => {
|
|
6
|
+
it("renders with children", () => {
|
|
7
|
+
render(<Button>Click me</Button>);
|
|
8
|
+
expect(screen.getByText("Click me")).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("applies default variant classes", () => {
|
|
12
|
+
render(<Button>Default</Button>);
|
|
13
|
+
const button = screen.getByText("Default");
|
|
14
|
+
expect(button).toHaveAttribute("data-variant", "default");
|
|
15
|
+
expect(button).toHaveAttribute("data-size", "default");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("applies destructive variant", () => {
|
|
19
|
+
render(<Button variant="destructive">Delete</Button>);
|
|
20
|
+
const button = screen.getByText("Delete");
|
|
21
|
+
expect(button).toHaveAttribute("data-variant", "destructive");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("applies custom className", () => {
|
|
25
|
+
render(<Button className="my-custom-class">Custom</Button>);
|
|
26
|
+
const button = screen.getByText("Custom");
|
|
27
|
+
expect(button.className).toContain("my-custom-class");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("renders as button element by default", () => {
|
|
31
|
+
render(<Button>Normal</Button>);
|
|
32
|
+
const button = screen.getByText("Normal");
|
|
33
|
+
expect(button.tagName).toBe("BUTTON");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("sets data-slot attribute", () => {
|
|
37
|
+
render(<Button>Slot</Button>);
|
|
38
|
+
const button = screen.getByText("Slot");
|
|
39
|
+
expect(button).toHaveAttribute("data-slot", "button");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Input } from "../input";
|
|
4
|
+
|
|
5
|
+
describe("Input", () => {
|
|
6
|
+
it("renders an input element", () => {
|
|
7
|
+
render(<Input placeholder="Type here" />);
|
|
8
|
+
expect(screen.getByPlaceholderText("Type here")).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("applies data-slot attribute", () => {
|
|
12
|
+
render(<Input placeholder="test" />);
|
|
13
|
+
const input = screen.getByPlaceholderText("test");
|
|
14
|
+
expect(input).toHaveAttribute("data-slot", "input");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("accepts type prop", () => {
|
|
18
|
+
render(<Input type="email" placeholder="email" />);
|
|
19
|
+
const input = screen.getByPlaceholderText("email");
|
|
20
|
+
expect(input).toHaveAttribute("type", "email");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("applies custom className", () => {
|
|
24
|
+
render(<Input className="custom-class" placeholder="custom" />);
|
|
25
|
+
const input = screen.getByPlaceholderText("custom");
|
|
26
|
+
expect(input.className).toContain("custom-class");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
3
|
+
import { TagMultiSelect } from "../tag-multi-select";
|
|
4
|
+
import type { TagOption, TagMultiSelectTranslations } from "../../types";
|
|
5
|
+
|
|
6
|
+
const mockTranslations: TagMultiSelectTranslations = {
|
|
7
|
+
placeholder: "Choose tags...",
|
|
8
|
+
empty: "No tags available",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const mockTags: TagOption[] = [
|
|
12
|
+
{ value: "1", label: "VIP", color: "#FF0000" },
|
|
13
|
+
{ value: "2", label: "Partner", color: "#00FF00" },
|
|
14
|
+
{ value: "3", label: "Lead", color: "#0000FF" },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
describe("TagMultiSelect", () => {
|
|
18
|
+
it("calls loadTags on mount", async () => {
|
|
19
|
+
const loadTags = vi.fn().mockResolvedValue(mockTags);
|
|
20
|
+
|
|
21
|
+
render(
|
|
22
|
+
<TagMultiSelect
|
|
23
|
+
selectedIds={[]}
|
|
24
|
+
onChange={() => {}}
|
|
25
|
+
loadTags={loadTags}
|
|
26
|
+
translations={mockTranslations}
|
|
27
|
+
/>,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
await waitFor(() => {
|
|
31
|
+
expect(loadTags).toHaveBeenCalledTimes(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("displays placeholder from translations", () => {
|
|
36
|
+
const loadTags = vi.fn().mockResolvedValue([]);
|
|
37
|
+
|
|
38
|
+
render(
|
|
39
|
+
<TagMultiSelect
|
|
40
|
+
selectedIds={[]}
|
|
41
|
+
onChange={() => {}}
|
|
42
|
+
loadTags={loadTags}
|
|
43
|
+
translations={mockTranslations}
|
|
44
|
+
/>,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const inputs = screen.getAllByPlaceholderText("Choose tags...");
|
|
48
|
+
expect(inputs.length).toBeGreaterThanOrEqual(1);
|
|
49
|
+
expect(inputs[0]).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("shows empty message when no tags loaded", async () => {
|
|
53
|
+
const loadTags = vi.fn().mockResolvedValue([]);
|
|
54
|
+
|
|
55
|
+
render(
|
|
56
|
+
<TagMultiSelect
|
|
57
|
+
selectedIds={[]}
|
|
58
|
+
onChange={() => {}}
|
|
59
|
+
loadTags={loadTags}
|
|
60
|
+
translations={mockTranslations}
|
|
61
|
+
/>,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
const msgs = screen.getAllByText("No tags available");
|
|
66
|
+
expect(msgs.length).toBeGreaterThanOrEqual(1);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("handles loadTags failure without crashing", async () => {
|
|
71
|
+
const loadTags = vi.fn().mockRejectedValue(new Error("Network error"));
|
|
72
|
+
|
|
73
|
+
render(
|
|
74
|
+
<TagMultiSelect
|
|
75
|
+
selectedIds={[]}
|
|
76
|
+
onChange={() => {}}
|
|
77
|
+
loadTags={loadTags}
|
|
78
|
+
translations={mockTranslations}
|
|
79
|
+
/>,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
await waitFor(() => {
|
|
83
|
+
expect(loadTags).toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const msgs = screen.getAllByText("No tags available");
|
|
87
|
+
expect(msgs.length).toBeGreaterThanOrEqual(1);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("renders selected tags as chips with correct colors", async () => {
|
|
91
|
+
const loadTags = vi.fn().mockResolvedValue(mockTags);
|
|
92
|
+
|
|
93
|
+
render(
|
|
94
|
+
<TagMultiSelect
|
|
95
|
+
selectedIds={["1"]}
|
|
96
|
+
onChange={() => {}}
|
|
97
|
+
loadTags={loadTags}
|
|
98
|
+
translations={mockTranslations}
|
|
99
|
+
/>,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
await waitFor(() => {
|
|
103
|
+
const chip = screen.getByText("VIP");
|
|
104
|
+
expect(chip).toBeInTheDocument();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("uses fallback color for invalid hex", async () => {
|
|
109
|
+
const loadTags = vi
|
|
110
|
+
.fn()
|
|
111
|
+
.mockResolvedValue([{ value: "1", label: "Bad Color", color: "not-a-color" }]);
|
|
112
|
+
|
|
113
|
+
render(
|
|
114
|
+
<TagMultiSelect
|
|
115
|
+
selectedIds={["1"]}
|
|
116
|
+
onChange={() => {}}
|
|
117
|
+
loadTags={loadTags}
|
|
118
|
+
translations={mockTranslations}
|
|
119
|
+
/>,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
await waitFor(() => {
|
|
123
|
+
const chips = screen.getAllByText("Bad Color");
|
|
124
|
+
const chipEl = chips.find((el) => el.closest("[data-slot='combobox-chip']"));
|
|
125
|
+
expect(chipEl).toBeTruthy();
|
|
126
|
+
expect(chipEl!.closest("[data-slot='combobox-chip']")).toHaveStyle({
|
|
127
|
+
backgroundColor: "#6B7280",
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Textarea } from "../textarea";
|
|
4
|
+
|
|
5
|
+
describe("Textarea", () => {
|
|
6
|
+
it("renders a textarea element", () => {
|
|
7
|
+
render(<Textarea placeholder="Write here" />);
|
|
8
|
+
expect(screen.getByPlaceholderText("Write here")).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("applies data-slot attribute", () => {
|
|
12
|
+
render(<Textarea placeholder="test" />);
|
|
13
|
+
const textarea = screen.getByPlaceholderText("test");
|
|
14
|
+
expect(textarea).toHaveAttribute("data-slot", "textarea");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("applies custom className", () => {
|
|
18
|
+
render(<Textarea className="custom-class" placeholder="custom" />);
|
|
19
|
+
const textarea = screen.getByPlaceholderText("custom");
|
|
20
|
+
expect(textarea.className).toContain("custom-class");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
import { Button } from "./button";
|
|
8
|
+
|
|
9
|
+
function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
|
|
10
|
+
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function AlertDialogTrigger({
|
|
14
|
+
...props
|
|
15
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
|
|
16
|
+
return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function AlertDialogPortal({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
|
|
20
|
+
return <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function AlertDialogOverlay({
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
|
|
27
|
+
return (
|
|
28
|
+
<AlertDialogPrimitive.Overlay
|
|
29
|
+
data-slot="alert-dialog-overlay"
|
|
30
|
+
className={cn(
|
|
31
|
+
"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function AlertDialogContent({
|
|
40
|
+
className,
|
|
41
|
+
size = "default",
|
|
42
|
+
...props
|
|
43
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
|
|
44
|
+
size?: "default" | "sm";
|
|
45
|
+
}) {
|
|
46
|
+
return (
|
|
47
|
+
<AlertDialogPortal>
|
|
48
|
+
<AlertDialogOverlay />
|
|
49
|
+
<AlertDialogPrimitive.Content
|
|
50
|
+
data-slot="alert-dialog-content"
|
|
51
|
+
data-size={size}
|
|
52
|
+
className={cn(
|
|
53
|
+
"group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg",
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
</AlertDialogPortal>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
data-slot="alert-dialog-header"
|
|
66
|
+
className={cn(
|
|
67
|
+
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
|
|
68
|
+
className,
|
|
69
|
+
)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
76
|
+
return (
|
|
77
|
+
<div
|
|
78
|
+
data-slot="alert-dialog-footer"
|
|
79
|
+
className={cn(
|
|
80
|
+
"flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function AlertDialogTitle({
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
|
92
|
+
return (
|
|
93
|
+
<AlertDialogPrimitive.Title
|
|
94
|
+
data-slot="alert-dialog-title"
|
|
95
|
+
className={cn(
|
|
96
|
+
"text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function AlertDialogDescription({
|
|
105
|
+
className,
|
|
106
|
+
...props
|
|
107
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
|
108
|
+
return (
|
|
109
|
+
<AlertDialogPrimitive.Description
|
|
110
|
+
data-slot="alert-dialog-description"
|
|
111
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function AlertDialogMedia({ className, ...props }: React.ComponentProps<"div">) {
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
data-slot="alert-dialog-media"
|
|
121
|
+
className={cn(
|
|
122
|
+
"mb-2 inline-flex size-16 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-8",
|
|
123
|
+
className,
|
|
124
|
+
)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function AlertDialogAction({
|
|
131
|
+
className,
|
|
132
|
+
variant = "default",
|
|
133
|
+
size = "default",
|
|
134
|
+
...props
|
|
135
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Action> &
|
|
136
|
+
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
|
137
|
+
return (
|
|
138
|
+
<Button variant={variant} size={size} asChild>
|
|
139
|
+
<AlertDialogPrimitive.Action
|
|
140
|
+
data-slot="alert-dialog-action"
|
|
141
|
+
className={cn(className)}
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
</Button>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function AlertDialogCancel({
|
|
149
|
+
className,
|
|
150
|
+
variant = "outline",
|
|
151
|
+
size = "default",
|
|
152
|
+
...props
|
|
153
|
+
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &
|
|
154
|
+
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
|
155
|
+
return (
|
|
156
|
+
<Button variant={variant} size={size} asChild>
|
|
157
|
+
<AlertDialogPrimitive.Cancel
|
|
158
|
+
data-slot="alert-dialog-cancel"
|
|
159
|
+
className={cn(className)}
|
|
160
|
+
{...props}
|
|
161
|
+
/>
|
|
162
|
+
</Button>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
AlertDialog,
|
|
168
|
+
AlertDialogAction,
|
|
169
|
+
AlertDialogCancel,
|
|
170
|
+
AlertDialogContent,
|
|
171
|
+
AlertDialogDescription,
|
|
172
|
+
AlertDialogFooter,
|
|
173
|
+
AlertDialogHeader,
|
|
174
|
+
AlertDialogMedia,
|
|
175
|
+
AlertDialogOverlay,
|
|
176
|
+
AlertDialogPortal,
|
|
177
|
+
AlertDialogTitle,
|
|
178
|
+
AlertDialogTrigger,
|
|
179
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
|
|
7
|
+
const badgeVariants = cva(
|
|
8
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
13
|
+
secondary: "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
18
|
+
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
19
|
+
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
function Badge({
|
|
29
|
+
className,
|
|
30
|
+
variant = "default",
|
|
31
|
+
asChild = false,
|
|
32
|
+
...props
|
|
33
|
+
}: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
34
|
+
const Comp = asChild ? Slot.Root : "span";
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Comp
|
|
38
|
+
data-slot="badge"
|
|
39
|
+
data-variant={variant}
|
|
40
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../lib/utils";
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
13
|
+
destructive:
|
|
14
|
+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
|
|
15
|
+
outline:
|
|
16
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
17
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
18
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
19
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
23
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
24
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
25
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
26
|
+
icon: "size-9",
|
|
27
|
+
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
28
|
+
"icon-sm": "size-8",
|
|
29
|
+
"icon-lg": "size-10",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: "default",
|
|
34
|
+
size: "default",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
function Button({
|
|
40
|
+
className,
|
|
41
|
+
variant = "default",
|
|
42
|
+
size = "default",
|
|
43
|
+
asChild = false,
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<"button"> &
|
|
46
|
+
VariantProps<typeof buttonVariants> & {
|
|
47
|
+
asChild?: boolean;
|
|
48
|
+
}) {
|
|
49
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Comp
|
|
53
|
+
data-slot="button"
|
|
54
|
+
data-variant={variant}
|
|
55
|
+
data-size={size}
|
|
56
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { Button, buttonVariants };
|