@devfellowship/components 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.
@@ -0,0 +1,5 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ declare function cn(...inputs: ClassValue[]): string;
4
+
5
+ export { cn as c };
@@ -0,0 +1,5 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ declare function cn(...inputs: ClassValue[]): string;
4
+
5
+ export { cn as c };
package/dist/utils.cjs ADDED
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/index.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ cn: () => cn,
24
+ formatCurrency: () => formatCurrency,
25
+ formatDate: () => formatDate,
26
+ formatDateShort: () => formatDateShort,
27
+ formatDuration: () => formatDuration,
28
+ formatMonthYear: () => formatMonthYear,
29
+ formatRelativeTime: () => formatRelativeTime,
30
+ shortenId: () => shortenId
31
+ });
32
+ module.exports = __toCommonJS(utils_exports);
33
+
34
+ // src/lib/utils.ts
35
+ var import_clsx = require("clsx");
36
+ var import_tailwind_merge = require("tailwind-merge");
37
+ function cn(...inputs) {
38
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
39
+ }
40
+
41
+ // src/utils/formatters.ts
42
+ function formatCurrency(value) {
43
+ return new Intl.NumberFormat("pt-BR", {
44
+ style: "currency",
45
+ currency: "BRL"
46
+ }).format(value);
47
+ }
48
+ function formatDate(date) {
49
+ return new Date(date).toLocaleDateString("pt-BR", {
50
+ day: "2-digit",
51
+ month: "2-digit",
52
+ year: "numeric",
53
+ hour: "2-digit",
54
+ minute: "2-digit"
55
+ });
56
+ }
57
+ function formatDateShort(date) {
58
+ return new Date(date).toLocaleDateString("pt-BR", {
59
+ day: "2-digit",
60
+ month: "2-digit",
61
+ year: "numeric"
62
+ });
63
+ }
64
+ function formatMonthYear(date) {
65
+ return new Date(date).toLocaleDateString("pt-BR", {
66
+ month: "short",
67
+ year: "numeric"
68
+ });
69
+ }
70
+ function formatRelativeTime(dateString) {
71
+ const diff = Date.now() - new Date(dateString).getTime();
72
+ const seconds = Math.floor(diff / 1e3);
73
+ const minutes = Math.floor(seconds / 60);
74
+ const hours = Math.floor(minutes / 60);
75
+ const days = Math.floor(hours / 24);
76
+ const months = Math.floor(days / 30);
77
+ const years = Math.floor(days / 365);
78
+ if (years > 0) return `${years} ${years === 1 ? "year" : "years"} ago`;
79
+ if (months > 0) return `${months} ${months === 1 ? "month" : "months"} ago`;
80
+ if (days > 0) return `${days} ${days === 1 ? "day" : "days"} ago`;
81
+ if (hours > 0) return `${hours} ${hours === 1 ? "hour" : "hours"} ago`;
82
+ if (minutes > 0) return `${minutes} ${minutes === 1 ? "minute" : "minutes"} ago`;
83
+ return `${seconds} ${seconds === 1 ? "second" : "seconds"} ago`;
84
+ }
85
+ function shortenId(id) {
86
+ return `${id.slice(0, 8)}...${id.slice(-8)}`;
87
+ }
88
+ function formatDuration(seconds) {
89
+ if (!seconds) return "00:00";
90
+ const h = Math.floor(seconds / 3600);
91
+ const m = Math.floor(seconds % 3600 / 60);
92
+ const s = Math.floor(seconds % 60);
93
+ if (h > 0) {
94
+ return `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
95
+ }
96
+ return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ cn,
101
+ formatCurrency,
102
+ formatDate,
103
+ formatDateShort,
104
+ formatDuration,
105
+ formatMonthYear,
106
+ formatRelativeTime,
107
+ shortenId
108
+ });
@@ -0,0 +1,26 @@
1
+ export { c as cn } from './utils-Cbsgs0XP.cjs';
2
+ import 'clsx';
3
+
4
+ /**
5
+ * Shared formatters — ported from dfl-learn/formatters.ts
6
+ * Identical patterns found across dfl-financing, dfl-payments, dfl-learn, dfl-documents.
7
+ */
8
+ /** Format a number as BRL currency: R$ 1.234,56 */
9
+ declare function formatCurrency(value: number): string;
10
+ /** Format an ISO date string as DD/MM/YYYY HH:MM */
11
+ declare function formatDate(date: string): string;
12
+ /** Format an ISO date string as DD/MM/YYYY (date only) */
13
+ declare function formatDateShort(date: string): string;
14
+ /** Format an ISO date string as "abr. 2026" */
15
+ declare function formatMonthYear(date: string): string;
16
+ /**
17
+ * Format a date as relative time: "3 minutes ago", "2 days ago", etc.
18
+ * Language: English (suitable for international UIs).
19
+ */
20
+ declare function formatRelativeTime(dateString: string): string;
21
+ /** Shorten a UUID-style id to "xxxxxxxx...xxxxxxxx" */
22
+ declare function shortenId(id: string): string;
23
+ /** Format seconds to mm:ss or hh:mm:ss */
24
+ declare function formatDuration(seconds: number): string;
25
+
26
+ export { formatCurrency, formatDate, formatDateShort, formatDuration, formatMonthYear, formatRelativeTime, shortenId };
@@ -0,0 +1,26 @@
1
+ export { c as cn } from './utils-Cbsgs0XP.js';
2
+ import 'clsx';
3
+
4
+ /**
5
+ * Shared formatters — ported from dfl-learn/formatters.ts
6
+ * Identical patterns found across dfl-financing, dfl-payments, dfl-learn, dfl-documents.
7
+ */
8
+ /** Format a number as BRL currency: R$ 1.234,56 */
9
+ declare function formatCurrency(value: number): string;
10
+ /** Format an ISO date string as DD/MM/YYYY HH:MM */
11
+ declare function formatDate(date: string): string;
12
+ /** Format an ISO date string as DD/MM/YYYY (date only) */
13
+ declare function formatDateShort(date: string): string;
14
+ /** Format an ISO date string as "abr. 2026" */
15
+ declare function formatMonthYear(date: string): string;
16
+ /**
17
+ * Format a date as relative time: "3 minutes ago", "2 days ago", etc.
18
+ * Language: English (suitable for international UIs).
19
+ */
20
+ declare function formatRelativeTime(dateString: string): string;
21
+ /** Shorten a UUID-style id to "xxxxxxxx...xxxxxxxx" */
22
+ declare function shortenId(id: string): string;
23
+ /** Format seconds to mm:ss or hh:mm:ss */
24
+ declare function formatDuration(seconds: number): string;
25
+
26
+ export { formatCurrency, formatDate, formatDateShort, formatDuration, formatMonthYear, formatRelativeTime, shortenId };
package/dist/utils.js ADDED
@@ -0,0 +1,74 @@
1
+ // src/lib/utils.ts
2
+ import { clsx } from "clsx";
3
+ import { twMerge } from "tailwind-merge";
4
+ function cn(...inputs) {
5
+ return twMerge(clsx(inputs));
6
+ }
7
+
8
+ // src/utils/formatters.ts
9
+ function formatCurrency(value) {
10
+ return new Intl.NumberFormat("pt-BR", {
11
+ style: "currency",
12
+ currency: "BRL"
13
+ }).format(value);
14
+ }
15
+ function formatDate(date) {
16
+ return new Date(date).toLocaleDateString("pt-BR", {
17
+ day: "2-digit",
18
+ month: "2-digit",
19
+ year: "numeric",
20
+ hour: "2-digit",
21
+ minute: "2-digit"
22
+ });
23
+ }
24
+ function formatDateShort(date) {
25
+ return new Date(date).toLocaleDateString("pt-BR", {
26
+ day: "2-digit",
27
+ month: "2-digit",
28
+ year: "numeric"
29
+ });
30
+ }
31
+ function formatMonthYear(date) {
32
+ return new Date(date).toLocaleDateString("pt-BR", {
33
+ month: "short",
34
+ year: "numeric"
35
+ });
36
+ }
37
+ function formatRelativeTime(dateString) {
38
+ const diff = Date.now() - new Date(dateString).getTime();
39
+ const seconds = Math.floor(diff / 1e3);
40
+ const minutes = Math.floor(seconds / 60);
41
+ const hours = Math.floor(minutes / 60);
42
+ const days = Math.floor(hours / 24);
43
+ const months = Math.floor(days / 30);
44
+ const years = Math.floor(days / 365);
45
+ if (years > 0) return `${years} ${years === 1 ? "year" : "years"} ago`;
46
+ if (months > 0) return `${months} ${months === 1 ? "month" : "months"} ago`;
47
+ if (days > 0) return `${days} ${days === 1 ? "day" : "days"} ago`;
48
+ if (hours > 0) return `${hours} ${hours === 1 ? "hour" : "hours"} ago`;
49
+ if (minutes > 0) return `${minutes} ${minutes === 1 ? "minute" : "minutes"} ago`;
50
+ return `${seconds} ${seconds === 1 ? "second" : "seconds"} ago`;
51
+ }
52
+ function shortenId(id) {
53
+ return `${id.slice(0, 8)}...${id.slice(-8)}`;
54
+ }
55
+ function formatDuration(seconds) {
56
+ if (!seconds) return "00:00";
57
+ const h = Math.floor(seconds / 3600);
58
+ const m = Math.floor(seconds % 3600 / 60);
59
+ const s = Math.floor(seconds % 60);
60
+ if (h > 0) {
61
+ return `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
62
+ }
63
+ return `${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}`;
64
+ }
65
+ export {
66
+ cn,
67
+ formatCurrency,
68
+ formatDate,
69
+ formatDateShort,
70
+ formatDuration,
71
+ formatMonthYear,
72
+ formatRelativeTime,
73
+ shortenId
74
+ };
package/package.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "name": "@devfellowship/components",
3
+ "version": "0.1.0",
4
+ "description": "DFL Design System — UI components, hooks, utils and providers",
5
+ "type": "module",
6
+ "sideEffects": [
7
+ "**/*.css"
8
+ ],
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./hooks": {
16
+ "types": "./dist/hooks.d.ts",
17
+ "import": "./dist/hooks.js",
18
+ "require": "./dist/hooks.cjs"
19
+ },
20
+ "./utils": {
21
+ "types": "./dist/utils.d.ts",
22
+ "import": "./dist/utils.js",
23
+ "require": "./dist/utils.cjs"
24
+ },
25
+ "./providers": {
26
+ "types": "./dist/providers.d.ts",
27
+ "import": "./dist/providers.js",
28
+ "require": "./dist/providers.cjs"
29
+ },
30
+ "./styles": "./dist/styles/theme.css",
31
+ "./tailwind": "./dist/styles/tailwind.css"
32
+ },
33
+ "main": "./dist/index.cjs",
34
+ "module": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "files": [
37
+ "dist"
38
+ ],
39
+ "scripts": {
40
+ "build": "tsup",
41
+ "build:watch": "tsup --watch",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run",
44
+ "prepublishOnly": "npm run build",
45
+ "storybook": "storybook dev -p 6006",
46
+ "build-storybook": "storybook build"
47
+ },
48
+ "peerDependencies": {
49
+ "@supabase/supabase-js": ">=2.0.0",
50
+ "react": ">=18.0.0",
51
+ "react-dom": ">=18.0.0",
52
+ "tailwindcss": ">=4.0.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "tailwindcss": {
56
+ "optional": true
57
+ },
58
+ "@supabase/supabase-js": {
59
+ "optional": true
60
+ }
61
+ },
62
+ "devDependencies": {
63
+ "@storybook/addon-a11y": "^8.6.18",
64
+ "@storybook/addon-essentials": "^8.6.14",
65
+ "@storybook/addon-themes": "^8.6.18",
66
+ "@storybook/blocks": "^8.6.14",
67
+ "@storybook/react": "^8.6.18",
68
+ "@storybook/react-vite": "^8.6.18",
69
+ "@supabase/supabase-js": "^2.49.4",
70
+ "@tailwindcss/vite": "^4.2.2",
71
+ "@testing-library/jest-dom": "^6.6.3",
72
+ "@testing-library/react": "^16.3.0",
73
+ "@types/react": "^18.3.28",
74
+ "@types/react-dom": "^18.3.7",
75
+ "@vitejs/plugin-react": "^4.7.0",
76
+ "jsdom": "^26.1.0",
77
+ "react": "^18.3.0",
78
+ "react-dom": "^18.3.0",
79
+ "storybook": "^8.6.18",
80
+ "tailwindcss": "^4.2.2",
81
+ "tsup": "^8.5.1",
82
+ "typescript": "^5.9.3",
83
+ "vite": "^5.4.21",
84
+ "vitest": "^3.1.1"
85
+ },
86
+ "dependencies": {
87
+ "@radix-ui/react-accordion": "^1.2.0",
88
+ "@radix-ui/react-alert-dialog": "^1.1.1",
89
+ "@radix-ui/react-avatar": "^1.1.0",
90
+ "@radix-ui/react-checkbox": "^1.1.1",
91
+ "@radix-ui/react-collapsible": "^1.1.0",
92
+ "@radix-ui/react-dialog": "^1.1.2",
93
+ "@radix-ui/react-dropdown-menu": "^2.1.1",
94
+ "@radix-ui/react-label": "^2.1.0",
95
+ "@radix-ui/react-popover": "^1.1.1",
96
+ "@radix-ui/react-progress": "^1.1.0",
97
+ "@radix-ui/react-radio-group": "^1.3.8",
98
+ "@radix-ui/react-scroll-area": "^1.1.0",
99
+ "@radix-ui/react-select": "^2.1.1",
100
+ "@radix-ui/react-separator": "^1.1.0",
101
+ "@radix-ui/react-slot": "^1.1.0",
102
+ "@radix-ui/react-switch": "^1.1.0",
103
+ "@radix-ui/react-tabs": "^1.1.0",
104
+ "@radix-ui/react-toast": "^1.2.1",
105
+ "@radix-ui/react-tooltip": "^1.1.4",
106
+ "@testing-library/dom": "^10.4.1",
107
+ "class-variance-authority": "^0.7.1",
108
+ "clsx": "^2.1.1",
109
+ "lucide-react": "^0.462.0",
110
+ "react-hook-form": "^7.72.1",
111
+ "tailwind-merge": "^2.5.2"
112
+ }
113
+ }