@g4rcez/components 0.0.1

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.
Files changed (139) hide show
  1. package/.idea/bigweld.iml +12 -0
  2. package/.idea/codeStyles/Project.xml +72 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +30 -0
  5. package/.idea/jsLibraryMappings.xml +6 -0
  6. package/.idea/modules.xml +8 -0
  7. package/.idea/prettier.xml +7 -0
  8. package/.idea/reason.xml +6 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.prettierrc.json +13 -0
  11. package/README.md +35 -0
  12. package/app/client-table.tsx +35 -0
  13. package/app/favicon.ico +0 -0
  14. package/app/layout.tsx +39 -0
  15. package/app/page.tsx +72 -0
  16. package/dist/components/core/button.d.ts +21 -0
  17. package/dist/components/core/button.d.ts.map +1 -0
  18. package/dist/components/core/polymorph.d.ts +10 -0
  19. package/dist/components/core/polymorph.d.ts.map +1 -0
  20. package/dist/components/display/card.d.ts +4 -0
  21. package/dist/components/display/card.d.ts.map +1 -0
  22. package/dist/components/floating/dropdown.d.ts +11 -0
  23. package/dist/components/floating/dropdown.d.ts.map +1 -0
  24. package/dist/components/floating/tooltip.d.ts +9 -0
  25. package/dist/components/floating/tooltip.d.ts.map +1 -0
  26. package/dist/components/form/autocomplete.d.ts +16 -0
  27. package/dist/components/form/autocomplete.d.ts.map +1 -0
  28. package/dist/components/form/file-upload.d.ts +12 -0
  29. package/dist/components/form/file-upload.d.ts.map +1 -0
  30. package/dist/components/form/form.d.ts +4 -0
  31. package/dist/components/form/form.d.ts.map +1 -0
  32. package/dist/components/form/input-field.d.ts +25 -0
  33. package/dist/components/form/input-field.d.ts.map +1 -0
  34. package/dist/components/form/input.d.ts +9 -0
  35. package/dist/components/form/input.d.ts.map +1 -0
  36. package/dist/components/form/select.d.ts +11 -0
  37. package/dist/components/form/select.d.ts.map +1 -0
  38. package/dist/components/form/switch.d.ts +7 -0
  39. package/dist/components/form/switch.d.ts.map +1 -0
  40. package/dist/components/index.d.ts +15 -0
  41. package/dist/components/index.d.ts.map +1 -0
  42. package/dist/components/table/filter.d.ts +70 -0
  43. package/dist/components/table/filter.d.ts.map +1 -0
  44. package/dist/components/table/group.d.ts +17 -0
  45. package/dist/components/table/group.d.ts.map +1 -0
  46. package/dist/components/table/index.d.ts +28 -0
  47. package/dist/components/table/index.d.ts.map +1 -0
  48. package/dist/components/table/metadata.d.ts +3 -0
  49. package/dist/components/table/metadata.d.ts.map +1 -0
  50. package/dist/components/table/sort.d.ts +28 -0
  51. package/dist/components/table/sort.d.ts.map +1 -0
  52. package/dist/components/table/table-lib.d.ts +99 -0
  53. package/dist/components/table/table-lib.d.ts.map +1 -0
  54. package/dist/components/table/thead.d.ts +7 -0
  55. package/dist/components/table/thead.d.ts.map +1 -0
  56. package/dist/hooks/use-form.d.ts +28 -0
  57. package/dist/hooks/use-form.d.ts.map +1 -0
  58. package/dist/hooks/use-previous.d.ts +2 -0
  59. package/dist/hooks/use-previous.d.ts.map +1 -0
  60. package/dist/hooks/use-reactive.d.ts +2 -0
  61. package/dist/hooks/use-reactive.d.ts.map +1 -0
  62. package/dist/index.css +1670 -0
  63. package/dist/index.d.ts +7 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.mjs +21864 -0
  66. package/dist/index.mjs.map +1 -0
  67. package/dist/index.umd.js +151 -0
  68. package/dist/index.umd.js.map +1 -0
  69. package/dist/lib/dom.d.ts +6 -0
  70. package/dist/lib/dom.d.ts.map +1 -0
  71. package/dist/lib/fns.d.ts +5 -0
  72. package/dist/lib/fns.d.ts.map +1 -0
  73. package/dist/next.svg +1 -0
  74. package/dist/styles/design-tokens.d.ts +26 -0
  75. package/dist/styles/design-tokens.d.ts.map +1 -0
  76. package/dist/tailwind.config.d.ts +32 -0
  77. package/dist/tailwind.config.d.ts.map +1 -0
  78. package/dist/tailwind.config.js +153 -0
  79. package/dist/types.d.ts +9 -0
  80. package/dist/types.d.ts.map +1 -0
  81. package/dist/vercel.svg +1 -0
  82. package/docs/README.md +36 -0
  83. package/docs/next.config.mjs +4 -0
  84. package/docs/package.json +28 -0
  85. package/docs/pnpm-lock.yaml +1030 -0
  86. package/docs/postcss.config.mjs +8 -0
  87. package/docs/public/next.svg +1 -0
  88. package/docs/public/vercel.svg +1 -0
  89. package/docs/src/app/favicon.ico +0 -0
  90. package/docs/src/app/globals.css +33 -0
  91. package/docs/src/app/layout.tsx +22 -0
  92. package/docs/src/app/page.tsx +10 -0
  93. package/docs/tailwind.config.ts +15 -0
  94. package/docs/tsconfig.json +26 -0
  95. package/next-env.d.ts +5 -0
  96. package/next.config.mjs +4 -0
  97. package/package.json +72 -0
  98. package/postcss.config.mjs +8 -0
  99. package/public/next.svg +1 -0
  100. package/public/vercel.svg +1 -0
  101. package/src/components/core/button.tsx +91 -0
  102. package/src/components/core/polymorph.tsx +17 -0
  103. package/src/components/display/card.tsx +8 -0
  104. package/src/components/floating/dropdown.tsx +93 -0
  105. package/src/components/floating/tooltip.tsx +67 -0
  106. package/src/components/form/autocomplete.tsx +222 -0
  107. package/src/components/form/file-upload.tsx +129 -0
  108. package/src/components/form/form.tsx +28 -0
  109. package/src/components/form/input-field.tsx +105 -0
  110. package/src/components/form/input.tsx +73 -0
  111. package/src/components/form/select.tsx +58 -0
  112. package/src/components/form/switch.tsx +40 -0
  113. package/src/components/index.ts +14 -0
  114. package/src/components/table/filter.tsx +186 -0
  115. package/src/components/table/group.tsx +123 -0
  116. package/src/components/table/index.tsx +207 -0
  117. package/src/components/table/metadata.tsx +55 -0
  118. package/src/components/table/sort.tsx +141 -0
  119. package/src/components/table/table-lib.ts +130 -0
  120. package/src/components/table/thead.tsx +108 -0
  121. package/src/hooks/use-form.ts +155 -0
  122. package/src/hooks/use-previous.ts +9 -0
  123. package/src/hooks/use-reactive.ts +10 -0
  124. package/src/index.css +37 -0
  125. package/src/index.ts +6 -0
  126. package/src/lib/dom.ts +27 -0
  127. package/src/lib/fns.ts +23 -0
  128. package/src/styles/dark.json +66 -0
  129. package/src/styles/design-tokens.ts +57 -0
  130. package/src/styles/light.json +49 -0
  131. package/src/types.ts +11 -0
  132. package/styles.config.ts +42 -0
  133. package/tailwind.config.ts +11 -0
  134. package/tsconfig.json +55 -0
  135. package/tsconfig.lib.json +50 -0
  136. package/tsconfig.lib.tsbuildinfo +1 -0
  137. package/tsconfig.tailwind.json +32 -0
  138. package/tsconfig.tsbuildinfo +1 -0
  139. package/vite.config.mts +39 -0
@@ -0,0 +1,8 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ const config = {
3
+ plugins: {
4
+ tailwindcss: {},
5
+ },
6
+ };
7
+
8
+ export default config;
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
Binary file
@@ -0,0 +1,33 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ --foreground-rgb: 0, 0, 0;
7
+ --background-start-rgb: 214, 219, 220;
8
+ --background-end-rgb: 255, 255, 255;
9
+ }
10
+
11
+ @media (prefers-color-scheme: dark) {
12
+ :root {
13
+ --foreground-rgb: 255, 255, 255;
14
+ --background-start-rgb: 0, 0, 0;
15
+ --background-end-rgb: 0, 0, 0;
16
+ }
17
+ }
18
+
19
+ body {
20
+ color: rgb(var(--foreground-rgb));
21
+ background: linear-gradient(
22
+ to bottom,
23
+ transparent,
24
+ rgb(var(--background-end-rgb))
25
+ )
26
+ rgb(var(--background-start-rgb));
27
+ }
28
+
29
+ @layer utilities {
30
+ .text-balance {
31
+ text-wrap: balance;
32
+ }
33
+ }
@@ -0,0 +1,22 @@
1
+ import type { Metadata } from "next";
2
+ import { Inter } from "next/font/google";
3
+ import "./globals.css";
4
+
5
+ const inter = Inter({ subsets: ["latin"] });
6
+
7
+ export const metadata: Metadata = {
8
+ title: "Create Next App",
9
+ description: "Generated by create next app",
10
+ };
11
+
12
+ export default function RootLayout({
13
+ children,
14
+ }: Readonly<{
15
+ children: React.ReactNode;
16
+ }>) {
17
+ return (
18
+ <html lang="en">
19
+ <body className={inter.className}>{children}</body>
20
+ </html>
21
+ );
22
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Button } from "unamed";
3
+
4
+ export default function Home() {
5
+ return (
6
+ <main className="flex min-h-screen text-sla flex-col items-center justify-between p-24">
7
+ <Button>Testing</Button>
8
+ </main>
9
+ );
10
+ }
@@ -0,0 +1,15 @@
1
+ import type { Config } from "tailwindcss";
2
+
3
+ const config: Config = {
4
+ content: ["./src/pages/**/*.{js,ts,jsx,tsx,mdx}", "./src/components/**/*.{js,ts,jsx,tsx,mdx}", "./src/app/**/*.{js,ts,jsx,tsx,mdx}"],
5
+ theme: {
6
+ extend: {
7
+ backgroundImage: {
8
+ "gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
9
+ "gradient-conic": "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
10
+ },
11
+ },
12
+ },
13
+ plugins: [],
14
+ };
15
+ export default config;
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["dom", "dom.iterable", "esnext"],
4
+ "allowJs": true,
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "esModuleInterop": true,
9
+ "module": "esnext",
10
+ "moduleResolution": "bundler",
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "jsx": "preserve",
14
+ "incremental": true,
15
+ "plugins": [
16
+ {
17
+ "name": "next"
18
+ }
19
+ ],
20
+ "paths": {
21
+ "~/*": ["./src/*"]
22
+ }
23
+ },
24
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }
package/next-env.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/basic-features/typescript for more information.
@@ -0,0 +1,4 @@
1
+ /** @type {import('next').NextConfig} */
2
+ const nextConfig = {};
3
+
4
+ export default nextConfig;
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@g4rcez/components",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "build": "vite build; npm run lib:types; npm run preset; npm run lib:css",
6
+ "dev": "next dev",
7
+ "format": "npx prettier --write .",
8
+ "lib:css": "tailwind -i ./src/index.css -o ./dist/index.css",
9
+ "lib:tailwind": "tsc -p tsconfig.tailwind.json",
10
+ "lib:types": "tsc -p tsconfig.lib.json",
11
+ "lint": "next lint",
12
+ "preset": "tsc -p tsconfig.tailwind.json"
13
+ },
14
+ "source": "./src/index.ts",
15
+ "types": "./dist/index.d.ts",
16
+ "main": "./dist/index.js",
17
+ "module": "./dist/index.cjs",
18
+ "exports": {
19
+ ".": {
20
+ "types": {
21
+ "import": "./dist/index.d.ts",
22
+ "require": "./dist/index.d.ts",
23
+ "default": "./dist/index.d.ts"
24
+ },
25
+ "default": {
26
+ "type": "./dist/index.d.ts",
27
+ "import": "./dist/index.cjs",
28
+ "require": "./dist/index.cjs",
29
+ "default": "./dist/index.js"
30
+ }
31
+ },
32
+ "./styles.config": "./dist/tailwind.config.js"
33
+ },
34
+ "dependencies": {
35
+ "@dnd-kit/core": "6.1.0",
36
+ "@floating-ui/react": "0.26.19",
37
+ "@vitejs/plugin-react": "4.3.1",
38
+ "class-variance-authority": "0.7.0",
39
+ "clsx": "2.1.1",
40
+ "framer-motion": "11.2.13",
41
+ "fuzzy-search": "3.2.1",
42
+ "linq-arrays": "3.2.5",
43
+ "lucide-react": "0.400.0",
44
+ "pretty-bytes": "6.1.1",
45
+ "qs": "6.12.2",
46
+ "react": "18",
47
+ "react-dom": "18",
48
+ "react-dropzone": "14.2.3",
49
+ "react-virtuoso": "4.7.11",
50
+ "sidekicker": "0.1.8",
51
+ "storage-manager-js": "4.2.6-5",
52
+ "tailwind-merge": "2.3.0",
53
+ "the-mask-input": "3.3.12",
54
+ "use-typed-reducer": "4.2.1",
55
+ "vite": "5.3.3",
56
+ "zod": "3.23.8"
57
+ },
58
+ "devDependencies": {
59
+ "@types/fuzzy-search": "2.1.5",
60
+ "@types/node": "20.14.10",
61
+ "@types/qs": "6.9.15",
62
+ "@types/react": "18.3.3",
63
+ "@types/react-dom": "18.3.0",
64
+ "next": "14.2.4",
65
+ "postcss": "8.4.39",
66
+ "prettier": "3.3.2",
67
+ "tailwindcss": "3.4.4",
68
+ "tslib": "2.6.3",
69
+ "typescript": "5.5.3",
70
+ "vite-tsconfig-paths": "4.3.2"
71
+ }
72
+ }
@@ -0,0 +1,8 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ const config = {
3
+ plugins: {
4
+ tailwindcss: {},
5
+ },
6
+ };
7
+
8
+ export default config;
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
@@ -0,0 +1,91 @@
1
+ import { cva, type VariantProps } from "class-variance-authority";
2
+ import React, { forwardRef } from "react";
3
+ import { Polymorph, PolymorphicProps } from "~/components/core/polymorph";
4
+ import { css } from "~/lib/dom";
5
+ import { Label } from "~/types";
6
+
7
+ const buttonVariants = cva(
8
+ "inline-flex gap-1.5 text-main-foreground border-2 border-transparent items-center hover:bg-opacity-80 justify-center align-middle cursor-pointer whitespace-nowrap font-medium transition-colors ease-in disabled:cursor-not-allowed disabled:bg-opacity-50 disabled:text-opacity-60 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-ring",
9
+ {
10
+ variants: {
11
+ size: {
12
+ default: "h-10 px-4 py-2",
13
+ big: "h-12 px-6 py-4",
14
+ small: "h-10 p-2 text-sm",
15
+ icon: "p-1",
16
+ },
17
+ rounded: {
18
+ rough: "rounded-sm",
19
+ default: "rounded-md",
20
+ squared: "rounded-none",
21
+ circle: "rounded-full aspect-square",
22
+ },
23
+ theme: {
24
+ raw: "",
25
+ main: "bg-primary text-primary-foreground",
26
+ loading: "animate-pulse bg-disabled duration-700 opacity-70",
27
+ disabled: "bg-disabled duration-700 opacity-70",
28
+ },
29
+ },
30
+ defaultVariants: { theme: "main", size: "default", rounded: "default" },
31
+ }
32
+ );
33
+
34
+ export type ButtonProps<T extends React.ElementType = "button"> = PolymorphicProps<
35
+ VariantProps<typeof buttonVariants> & Partial<{ icon: Label; loading: boolean }>,
36
+ T
37
+ >;
38
+
39
+ export const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => any = forwardRef(function Button(
40
+ { className, icon, loading, theme, type = "button", size, rounded, ...props }: ButtonProps,
41
+ ref: React.ForwardedRef<HTMLButtonElement>
42
+ ) {
43
+ const disabled = loading || props.disabled;
44
+ return (
45
+ <Polymorph
46
+ {...props}
47
+ ref={ref}
48
+ type={type}
49
+ data-theme={theme}
50
+ disabled={disabled}
51
+ as={props.as ?? "button"}
52
+ onClick={disabled ? undefined : props.onClick}
53
+ className={css(
54
+ buttonVariants({
55
+ size,
56
+ rounded,
57
+ theme: loading ? "loading" : disabled ? "disabled" : theme,
58
+ }),
59
+ className
60
+ )}
61
+ >
62
+ {props.children}
63
+ {icon}
64
+ </Polymorph>
65
+ );
66
+ }) as never;
67
+
68
+ type Props = {
69
+ active: string;
70
+ buttons: ButtonProps[];
71
+ };
72
+
73
+ export const ButtonGroup = (props: Props) => (
74
+ <ul className="border-main-bg text-main-foreground flex w-full flex-row rounded-md border-2">
75
+ {props.buttons.map((button) => (
76
+ <li key={`button-group-${button.name}`} className="flex flex-1">
77
+ <button
78
+ {...button}
79
+ type={button.type || "button"}
80
+ data-active={props.active === button.name ? "true" : "false"}
81
+ className={css(
82
+ "border-main-bg flex flex-1 items-center gap-1.5 rounded-sm border-r-2 px-4 py-2 last:border-r-0 hover:bg-opacity-80",
83
+ "hover:bg-main-bg hover:text-main cursor-pointer justify-center whitespace-nowrap align-middle font-medium",
84
+ "focus-visible:ring-ring shadow-sm focus-visible:outline-none focus-visible:ring-2 disabled:text-opacity-80",
85
+ "data-[active=true]:bg-main-bg text-body data-[active=true]:text-main transition-colors ease-in disabled:cursor-not-allowed disabled:bg-opacity-50"
86
+ )}
87
+ />
88
+ </li>
89
+ ))}
90
+ </ul>
91
+ );
@@ -0,0 +1,17 @@
1
+ import React, { forwardRef } from "react";
2
+ import { Override } from "~/types";
3
+
4
+ type Polymorphism<T extends React.ElementType> = React.PropsWithChildren<{ as?: T }>;
5
+
6
+ export type Props<T extends React.ElementType = React.ElementType> = Polymorphism<T> & Omit<React.ComponentPropsWithRef<T>, keyof Polymorphism<T>>;
7
+
8
+ export type PolymorphicProps<P extends {}, T extends React.ElementType = React.ElementType> = Omit<
9
+ T extends string ? Override<React.ComponentProps<T> & Props<T>, P> : Override<Props<T>, P>,
10
+ keyof Polymorphism<T>
11
+ > &
12
+ Polymorphism<T>;
13
+
14
+ export const Polymorph = forwardRef(function Polymorph<T extends React.ElementType>({ as, ...props }: Props<T>, ref: React.ForwardedRef<any>) {
15
+ const Component = as || "span";
16
+ return <Component {...props} ref={ref} />;
17
+ });
@@ -0,0 +1,8 @@
1
+ import React, { PropsWithChildren } from "react";
2
+ import { Polymorph } from "~/components/core/polymorph";
3
+ import { css } from "~/lib/dom";
4
+
5
+ export type CardProps = React.ComponentProps<"div">;
6
+ export const Card = (props: PropsWithChildren<CardProps>) => {
7
+ return <Polymorph {...props} as="div" className={css("rounded-lg bg-card-background p-8 border-card-border border shadow", props.className)} />;
8
+ };
@@ -0,0 +1,93 @@
1
+ import {
2
+ arrow,
3
+ autoUpdate,
4
+ flip,
5
+ FloatingArrow,
6
+ FloatingFocusManager,
7
+ offset,
8
+ shift,
9
+ useClick,
10
+ useDismiss,
11
+ useFloating,
12
+ useId,
13
+ useInteractions,
14
+ useRole,
15
+ } from "@floating-ui/react";
16
+ import React, { Fragment, PropsWithChildren, useMemo, useRef, useState } from "react";
17
+
18
+ type DropdownProps = {
19
+ open?: boolean;
20
+ arrow?: boolean;
21
+ onChange?: (nextValue: boolean) => void;
22
+ trigger: React.ReactElement | React.ReactNode;
23
+ title?: React.ReactNode | React.ReactElement | string;
24
+ };
25
+
26
+ export const Dropdown = (props: PropsWithChildren<DropdownProps>) => {
27
+ const [open, setOpen] = useState(props.open);
28
+ const arrowRef = useRef(null);
29
+ const middleware = useMemo(
30
+ () => [
31
+ offset(10),
32
+ flip({ fallbackAxisSideDirection: "end" }),
33
+ shift(),
34
+ arrow({
35
+ padding: 5,
36
+ element: arrowRef,
37
+ }),
38
+ ],
39
+ [props.arrow]
40
+ );
41
+ const { refs, floatingStyles, context } = useFloating({
42
+ open,
43
+ transform: true,
44
+ whileElementsMounted: autoUpdate,
45
+ middleware,
46
+ onOpenChange: (nextValue, event) => {
47
+ const element = (event as any)?.relatedTarget as HTMLElement;
48
+ if (element) {
49
+ if (element.dataset.floating === "true" && !nextValue) return;
50
+ }
51
+ setOpen(nextValue);
52
+ props.onChange?.(nextValue);
53
+ },
54
+ });
55
+
56
+ const click = useClick(context);
57
+ const dismiss = useDismiss(context);
58
+ const role = useRole(context);
59
+
60
+ const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
61
+
62
+ const headingId = useId();
63
+
64
+ return (
65
+ <Fragment>
66
+ <button ref={refs.setReference} {...getReferenceProps()}>
67
+ {props.trigger}
68
+ </button>
69
+ {open && (
70
+ <FloatingFocusManager returnFocus visuallyHiddenDismiss restoreFocus context={context} modal={false}>
71
+ <div
72
+ className="bg-floating-background isolate z-floating border shadow-2xl p-6 border-floating-border rounded-lg"
73
+ ref={refs.setFloating}
74
+ style={floatingStyles}
75
+ aria-labelledby={headingId}
76
+ {...getFloatingProps()}
77
+ >
78
+ <FloatingArrow
79
+ ref={arrowRef}
80
+ context={context}
81
+ strokeWidth={0.1}
82
+ className="fill-floating-background stroke-floating-border"
83
+ />
84
+ <header className="mb-2">
85
+ <h3 className="leading-snug font-medium text-2xl tracking-tight text-left">{props.title}</h3>
86
+ </header>
87
+ {props.children}
88
+ </div>
89
+ </FloatingFocusManager>
90
+ )}
91
+ </Fragment>
92
+ );
93
+ };
@@ -0,0 +1,67 @@
1
+ import {
2
+ arrow,
3
+ autoUpdate,
4
+ flip,
5
+ FloatingArrow,
6
+ FloatingPortal,
7
+ offset,
8
+ shift,
9
+ useDismiss,
10
+ useFloating,
11
+ useFocus,
12
+ useHover,
13
+ useInteractions,
14
+ useRole,
15
+ } from "@floating-ui/react";
16
+ import React, { Fragment, useRef, useState } from "react";
17
+ import { Polymorph, PolymorphicProps } from "~/components/core/polymorph";
18
+ import { Label, Override } from "~/types";
19
+
20
+ type TooltipProps = Override<PolymorphicProps<React.ComponentProps<"button">, "div">, { title: Label }>;
21
+
22
+ export const Tooltip = ({ children, as, title, ...props }: TooltipProps) => {
23
+ const [isOpen, setIsOpen] = useState(false);
24
+ const arrowRef = useRef(null);
25
+ const Component = as || "div";
26
+ const { refs, floatingStyles, context } = useFloating({
27
+ open: isOpen,
28
+ onOpenChange: setIsOpen,
29
+ whileElementsMounted: autoUpdate,
30
+ transform: true,
31
+ middleware: [
32
+ offset(5),
33
+ flip({ fallbackAxisSideDirection: "start" }),
34
+ shift(),
35
+ arrow({
36
+ element: arrowRef,
37
+ padding: 5,
38
+ }),
39
+ ],
40
+ });
41
+ const hover = useHover(context, { move: false });
42
+ const focus = useFocus(context);
43
+ const dismiss = useDismiss(context);
44
+ const role = useRole(context, { role: "tooltip" });
45
+ const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role]);
46
+
47
+ return (
48
+ <Fragment>
49
+ <Component ref={refs.setReference} {...getReferenceProps(props)}>
50
+ {title}
51
+ </Component>
52
+ <FloatingPortal>
53
+ {isOpen && (
54
+ <Polymorph
55
+ ref={refs.setFloating}
56
+ style={floatingStyles}
57
+ {...getFloatingProps()}
58
+ className="bg-tooltip-background text-foreground border border-tooltip-border p-4 rounded-lg"
59
+ >
60
+ <FloatingArrow ref={arrowRef} context={context} strokeWidth={0.1} className="fill-tooltip-background stroke-tooltip-border" />
61
+ {children}
62
+ </Polymorph>
63
+ )}
64
+ </FloatingPortal>
65
+ </Fragment>
66
+ );
67
+ };