@hanzo/ui 4.6.0 → 4.8.2
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/assets/general.tsx +1 -1
- package/assets/hanzo-logo.tsx +3 -1
- package/assets/index.ts +119 -5
- package/blocks/auth/index.ts +6 -0
- package/blocks/auth/login-2fa.tsx +165 -0
- package/blocks/auth/login-basic.tsx +94 -0
- package/blocks/auth/login-social.tsx +148 -0
- package/blocks/auth/magic-link.tsx +129 -0
- package/blocks/auth/password-reset.tsx +97 -0
- package/blocks/auth/signup.tsx +157 -0
- package/blocks/data-display/activity-feed.tsx +242 -0
- package/blocks/data-display/data-table.tsx +235 -0
- package/blocks/data-display/stats-grid.tsx +194 -0
- package/blocks/ecommerce/checkout.tsx +242 -0
- package/blocks/ecommerce/index.ts +7 -0
- package/blocks/ecommerce/product-detail.tsx +257 -0
- package/blocks/ecommerce/product-grid.tsx +148 -0
- package/blocks/ecommerce/shopping-cart.tsx +181 -0
- package/blocks/marketing/cta-section.tsx +207 -0
- package/blocks/marketing/faq.tsx +159 -0
- package/blocks/marketing/features-grid.tsx +156 -0
- package/blocks/marketing/hero-section.tsx +192 -0
- package/blocks/marketing/index.ts +6 -0
- package/blocks/marketing/pricing-table.tsx +121 -0
- package/blocks/marketing/testimonials.tsx +196 -0
- package/components/index.ts +4 -51
- package/dist/index.js +9351 -0
- package/dist/index.mjs +9340 -0
- package/dist/lib/utils.js +47 -0
- package/dist/lib/utils.mjs +28 -0
- package/dist/src/utils.js +47 -0
- package/dist/src/utils.mjs +28 -0
- package/dist/tailwind/index.js +2050 -0
- package/dist/tailwind/index.mjs +2019 -0
- package/dist/types/index.js +79 -0
- package/dist/types/index.mjs +56 -0
- package/dist/util/format-text.js +51 -0
- package/dist/util/format-text.mjs +32 -0
- package/dist/util/index.js +384 -0
- package/dist/util/index.mjs +363 -0
- package/frameworks/core/index.ts +6 -0
- package/frameworks/core/utils/index.ts +64 -0
- package/frameworks/react/components/button.tsx +26 -0
- package/frameworks/react/components/index.ts +5 -0
- package/frameworks/react/hooks/index.ts +5 -0
- package/frameworks/react/index.ts +9 -0
- package/frameworks/react/package.json +8 -0
- package/frameworks/react/utils/index.ts +2 -0
- package/frameworks/react-native/index.ts +9 -0
- package/frameworks/react-native/package.json +8 -0
- package/frameworks/registry.json +371 -0
- package/frameworks/setup.sh +69 -0
- package/frameworks/svelte/index.ts +9 -0
- package/frameworks/svelte/package.json +8 -0
- package/frameworks/tracker.json +1854 -0
- package/frameworks/vue/index.ts +9 -0
- package/frameworks/vue/package.json +8 -0
- package/package.json +192 -28
- package/primitives/accordion.tsx +1 -1
- package/primitives/alert-dialog.tsx +1 -1
- package/primitives/alert.tsx +1 -1
- package/primitives/avatar.tsx +1 -1
- package/primitives/badge.tsx +2 -1
- package/primitives/breadcrumb.tsx +1 -1
- package/primitives/button.tsx +37 -47
- package/primitives/card.tsx +1 -1
- package/primitives/carousel.tsx +3 -2
- package/primitives/chat/chat-input-area.tsx +5 -4
- package/primitives/chat/chat-input.tsx +2 -2
- package/primitives/chat/files-preview.tsx +5 -4
- package/primitives/chat/message-list.tsx +2 -1
- package/primitives/chat/sqlite-preview.tsx +8 -8
- package/primitives/checkbox.tsx +2 -1
- package/primitives/command.tsx +3 -1
- package/primitives/context-menu.tsx +1 -1
- package/primitives/dialog.tsx +6 -1
- package/primitives/drawer.tsx +4 -1
- package/primitives/dropdown-menu.tsx +1 -1
- package/primitives/file-uploader.tsx +4 -2
- package/primitives/form.tsx +1 -1
- package/primitives/hover-card.tsx +1 -1
- package/primitives/icons/github.tsx +2 -2
- package/primitives/icons/youtube-logo.tsx +1 -1
- package/primitives/index-common.ts +7 -6
- package/primitives/input-otp.tsx +1 -1
- package/primitives/input.tsx +2 -1
- package/primitives/label.tsx +2 -1
- package/primitives/markdown-preview.tsx +3 -0
- package/primitives/mermaid.tsx +13 -18
- package/primitives/next/image.tsx +2 -1
- package/primitives/next/inline-icon.tsx +14 -14
- package/primitives/next/media-stack.tsx +2 -19
- package/primitives/pagination.tsx +1 -1
- package/primitives/popover.tsx +4 -2
- package/primitives/progress.tsx +2 -1
- package/primitives/prompt-textarea.tsx +1 -1
- package/primitives/radio-group.tsx +1 -1
- package/primitives/scroll-area.tsx +1 -1
- package/primitives/search-input.tsx +1 -1
- package/primitives/select.tsx +1 -1
- package/primitives/separator.tsx +2 -1
- package/primitives/sheet.tsx +1 -1
- package/primitives/skeleton.tsx +1 -0
- package/primitives/slider.tsx +2 -1
- package/primitives/stepper.tsx +1 -1
- package/primitives/switch.tsx +2 -1
- package/primitives/table.tsx +1 -1
- package/primitives/tabs.tsx +1 -1
- package/primitives/textarea.tsx +2 -1
- package/primitives/textfield.tsx +1 -0
- package/primitives/toggle-group.tsx +1 -1
- package/primitives/toggle.tsx +1 -1
- package/primitives/tooltip.tsx +1 -1
- package/src/hooks/use-copy-clipboard.ts +1 -1
- package/src/index-lean.ts +87 -0
- package/src/index.ts +54 -0
- package/src/registry/api.ts +1 -1
- package/src/utils.ts +19 -1
- package/tailwind/tailwind.config.hanzo-preset.js +7 -7
- package/tailwind/typo-plugin/index.js +1 -1
- package/types/animation-def.ts +1 -1
- package/types/index.ts +2 -1
- package/util/blob.ts +9 -4
- package/util/date.ts +2 -1
- package/util/format-text.ts +2 -1
- package/util/index.ts +103 -0
- package/util/spread-to-transform.ts +9 -8
- package/MCP-INSTRUCTIONS.md +0 -73
- package/README-MCP.md +0 -175
- package/dist/button.d.ts +0 -1
- package/dist/button.js +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/index.js +0 -7
- package/dist/hooks/use-click-away.d.ts +0 -2
- package/dist/hooks/use-click-away.js +0 -23
- package/dist/hooks/use-combined-refs.d.ts +0 -3
- package/dist/hooks/use-combined-refs.js +0 -18
- package/dist/hooks/use-copy-clipboard.d.ts +0 -9
- package/dist/hooks/use-copy-clipboard.js +0 -21
- package/dist/hooks/use-debounce.d.ts +0 -1
- package/dist/hooks/use-debounce.js +0 -13
- package/dist/hooks/use-fill-ids.d.ts +0 -8
- package/dist/hooks/use-fill-ids.js +0 -20
- package/dist/hooks/use-map.d.ts +0 -1
- package/dist/hooks/use-map.js +0 -20
- package/dist/hooks/use-measure.d.ts +0 -8
- package/dist/hooks/use-measure.js +0 -25
- package/dist/hooks/use-reverse-video-playback.d.ts +0 -1
- package/dist/hooks/use-reverse-video-playback.js +0 -41
- package/dist/hooks/use-scroll-restoration.d.ts +0 -8
- package/dist/hooks/use-scroll-restoration.js +0 -36
- package/dist/mcp/enhanced-server.d.ts +0 -29
- package/dist/mcp/enhanced-server.js +0 -1128
- package/dist/mcp/index.d.ts +0 -28
- package/dist/mcp/index.js +0 -436
- package/dist/registry/api.d.ts +0 -37
- package/dist/registry/api.js +0 -129
- package/dist/registry/index.d.ts +0 -353
- package/dist/registry/index.js +0 -45
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -1
- package/environment.d.ts +0 -6
- package/public/r/accordion.json +0 -11
- package/public/r/alert.json +0 -11
- package/public/r/avatar.json +0 -11
- package/public/r/badge.json +0 -11
- package/public/r/button.json +0 -11
- package/public/r/card.json +0 -11
- package/public/r/checkbox.json +0 -11
- package/public/r/default.json +0 -6
- package/public/r/dialog.json +0 -11
- package/public/r/input.json +0 -11
- package/public/r/label.json +0 -11
- package/public/r/new-york.json +0 -6
- package/public/r/popover.json +0 -11
- package/public/r/select.json +0 -11
- package/public/r/table.json +0 -11
- package/public/r/tabs.json +0 -11
- package/public/r/toast.json +0 -11
- package/registry.json +0 -184
- package/test/test-registry.js +0 -73
- package/test-imports.mjs +0 -19
- package/tsconfig.json +0 -22
- package/utils.ts +0 -9
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// util/date.ts
|
|
5
|
+
var formatDateToUSLocaleString = /* @__PURE__ */ __name((date) => {
|
|
6
|
+
if (!date) return "-";
|
|
7
|
+
return new Date(date).toLocaleDateString("en-US", {
|
|
8
|
+
year: "numeric",
|
|
9
|
+
month: "numeric",
|
|
10
|
+
day: "numeric"
|
|
11
|
+
});
|
|
12
|
+
}, "formatDateToUSLocaleString");
|
|
13
|
+
var formatDateToLocaleStringWithTime = /* @__PURE__ */ __name((date) => {
|
|
14
|
+
if (!date) return "-";
|
|
15
|
+
return new Date(date).toLocaleDateString("en-US", {
|
|
16
|
+
year: "numeric",
|
|
17
|
+
month: "numeric",
|
|
18
|
+
day: "numeric",
|
|
19
|
+
hour: "numeric",
|
|
20
|
+
minute: "numeric"
|
|
21
|
+
});
|
|
22
|
+
}, "formatDateToLocaleStringWithTime");
|
|
23
|
+
var getRelativeDateLabel = /* @__PURE__ */ __name((date) => {
|
|
24
|
+
const today = /* @__PURE__ */ new Date();
|
|
25
|
+
const yesterday = /* @__PURE__ */ new Date();
|
|
26
|
+
yesterday.setDate(today.getDate() - 1);
|
|
27
|
+
if (date.toDateString() === today.toDateString()) {
|
|
28
|
+
return "today";
|
|
29
|
+
} else if (date.toDateString() === yesterday.toDateString()) {
|
|
30
|
+
return "yesterday";
|
|
31
|
+
} else {
|
|
32
|
+
return date.toDateString();
|
|
33
|
+
}
|
|
34
|
+
}, "getRelativeDateLabel");
|
|
35
|
+
var groupMessagesByDate = /* @__PURE__ */ __name((messages) => {
|
|
36
|
+
const groupedMessages = {};
|
|
37
|
+
for (const message of messages) {
|
|
38
|
+
const date = new Date(message.createdAt ?? "").toDateString();
|
|
39
|
+
if (!groupedMessages[date]) {
|
|
40
|
+
groupedMessages[date] = [];
|
|
41
|
+
}
|
|
42
|
+
groupedMessages[date].push(message);
|
|
43
|
+
}
|
|
44
|
+
return groupedMessages;
|
|
45
|
+
}, "groupMessagesByDate");
|
|
46
|
+
var formatDateToMonthAndDay = /* @__PURE__ */ __name((date) => {
|
|
47
|
+
const today = /* @__PURE__ */ new Date();
|
|
48
|
+
if (date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear()) {
|
|
49
|
+
return date.toLocaleTimeString("en-US", {
|
|
50
|
+
hour: "numeric",
|
|
51
|
+
minute: "numeric",
|
|
52
|
+
hour12: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const month = date.getMonth() + 1;
|
|
56
|
+
const day = date.getDate();
|
|
57
|
+
return `${month}/${day}`;
|
|
58
|
+
}, "formatDateToMonthAndDay");
|
|
59
|
+
|
|
60
|
+
// util/file.ts
|
|
61
|
+
var getFileName = /* @__PURE__ */ __name((fileName) => {
|
|
62
|
+
const nameParts = fileName.split(".");
|
|
63
|
+
return nameParts.slice(0, -1).join(".");
|
|
64
|
+
}, "getFileName");
|
|
65
|
+
var getFileExt = /* @__PURE__ */ __name((fileName) => {
|
|
66
|
+
const nameParts = fileName.split(".");
|
|
67
|
+
return nameParts.pop() || "";
|
|
68
|
+
}, "getFileExt");
|
|
69
|
+
var isFileTypeImageOrPdf = /* @__PURE__ */ __name((file) => {
|
|
70
|
+
if (!file) return false;
|
|
71
|
+
return file?.type.startsWith("image/") || file?.type.startsWith("application/pdf");
|
|
72
|
+
}, "isFileTypeImageOrPdf");
|
|
73
|
+
|
|
74
|
+
// util/create-shadow-root.ts
|
|
75
|
+
import { createRoot } from "react-dom/client";
|
|
76
|
+
function createShadowRoot(tagName, styles) {
|
|
77
|
+
const container = document.createElement(tagName);
|
|
78
|
+
const shadow = container.attachShadow({ mode: "open" });
|
|
79
|
+
const globalStyleSheet = new CSSStyleSheet();
|
|
80
|
+
globalStyleSheet.replaceSync(styles);
|
|
81
|
+
shadow.adoptedStyleSheets = [globalStyleSheet];
|
|
82
|
+
const html = document.querySelector("html");
|
|
83
|
+
html.prepend(container);
|
|
84
|
+
return createRoot(shadow);
|
|
85
|
+
}
|
|
86
|
+
__name(createShadowRoot, "createShadowRoot");
|
|
87
|
+
|
|
88
|
+
// util/timing.ts
|
|
89
|
+
function delay(e = 1e3) {
|
|
90
|
+
return new Promise((t) => setTimeout(t, e));
|
|
91
|
+
}
|
|
92
|
+
__name(delay, "delay");
|
|
93
|
+
|
|
94
|
+
// util/blob.ts
|
|
95
|
+
var blobToBase64 = /* @__PURE__ */ __name((blob) => {
|
|
96
|
+
const reader = new FileReader();
|
|
97
|
+
reader.readAsDataURL(blob);
|
|
98
|
+
return new Promise((resolve) => {
|
|
99
|
+
reader.onloadend = () => {
|
|
100
|
+
resolve(reader.result);
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}, "blobToBase64");
|
|
104
|
+
var dataUrlToFile = /* @__PURE__ */ __name((dataUrl, filename) => {
|
|
105
|
+
const arr = dataUrl.split(",");
|
|
106
|
+
if (arr.length < 2) {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
const mimeArr = arr[0].match(/:(.*?);/);
|
|
110
|
+
if (!mimeArr || mimeArr.length < 2) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
const mime = mimeArr[1];
|
|
114
|
+
const binaryString = atob(arr[1]);
|
|
115
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
116
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
117
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
118
|
+
}
|
|
119
|
+
return new File([bytes], filename, { type: mime });
|
|
120
|
+
}, "dataUrlToFile");
|
|
121
|
+
|
|
122
|
+
// util/copy-to-clipboard.ts
|
|
123
|
+
async function copyToClipboard(text) {
|
|
124
|
+
try {
|
|
125
|
+
await navigator.clipboard.writeText(text);
|
|
126
|
+
} catch {
|
|
127
|
+
const textarea = document.createElement("textarea");
|
|
128
|
+
textarea.style.position = "fixed";
|
|
129
|
+
textarea.style.top = "-9999px";
|
|
130
|
+
textarea.style.left = "-9999px";
|
|
131
|
+
textarea.innerText = text;
|
|
132
|
+
document.body.appendChild(textarea);
|
|
133
|
+
textarea.focus();
|
|
134
|
+
textarea.select();
|
|
135
|
+
document.execCommand("copy");
|
|
136
|
+
textarea.remove();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
__name(copyToClipboard, "copyToClipboard");
|
|
140
|
+
|
|
141
|
+
// util/format-text.ts
|
|
142
|
+
var formatText = /* @__PURE__ */ __name((text) => {
|
|
143
|
+
const camelToSpaces = text.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
144
|
+
const snakeToSpaces = camelToSpaces.replace(/_/g, " ");
|
|
145
|
+
return snakeToSpaces.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
146
|
+
}, "formatText");
|
|
147
|
+
var formatCamelCaseText = /* @__PURE__ */ __name((text) => {
|
|
148
|
+
const words = text.split(/(?=[A-Z])/);
|
|
149
|
+
const formattedWords = words.map((word) => {
|
|
150
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
151
|
+
});
|
|
152
|
+
const result = formattedWords.join(" ");
|
|
153
|
+
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
154
|
+
}, "formatCamelCaseText");
|
|
155
|
+
var getVersionFromTool = /* @__PURE__ */ __name((toolRouterKey) => {
|
|
156
|
+
if (toolRouterKey.version) {
|
|
157
|
+
return toolRouterKey.version;
|
|
158
|
+
}
|
|
159
|
+
const parts = toolRouterKey.name.split(":::");
|
|
160
|
+
if (parts.length === 4) {
|
|
161
|
+
return parts[3];
|
|
162
|
+
}
|
|
163
|
+
return "latest";
|
|
164
|
+
}, "getVersionFromTool");
|
|
165
|
+
|
|
166
|
+
// util/toasts.tsx
|
|
167
|
+
import { toast } from "sonner";
|
|
168
|
+
import { jsx } from "react/jsx-runtime";
|
|
169
|
+
var submitRegistrationNoCodeNonPristineError = /* @__PURE__ */ __name(() => {
|
|
170
|
+
return toast.error(
|
|
171
|
+
/* @__PURE__ */ jsx("div", { children: "Your Hanzo Node is currently locked by existing keys, please restore your connection or reset your Hanzo Node Storage" }),
|
|
172
|
+
{ position: "bottom-center" }
|
|
173
|
+
);
|
|
174
|
+
}, "submitRegistrationNoCodeNonPristineError");
|
|
175
|
+
var submitRegistrationNoCodeError = /* @__PURE__ */ __name(() => {
|
|
176
|
+
return toast.error(/* @__PURE__ */ jsx("div", { children: "Error connecting to your Hanzo Node" }), {
|
|
177
|
+
position: "bottom-center"
|
|
178
|
+
});
|
|
179
|
+
}, "submitRegistrationNoCodeError");
|
|
180
|
+
|
|
181
|
+
// util/debounce.ts
|
|
182
|
+
var debounce = /* @__PURE__ */ __name((func, delay2) => {
|
|
183
|
+
let timeoutId = null;
|
|
184
|
+
return (...args) => {
|
|
185
|
+
if (timeoutId) {
|
|
186
|
+
clearTimeout(timeoutId);
|
|
187
|
+
}
|
|
188
|
+
timeoutId = setTimeout(() => {
|
|
189
|
+
func(...args);
|
|
190
|
+
}, delay2);
|
|
191
|
+
};
|
|
192
|
+
}, "debounce");
|
|
193
|
+
|
|
194
|
+
// util/spread-to-transform.ts
|
|
195
|
+
function spreadToTransform(t) {
|
|
196
|
+
let transformStrings = [];
|
|
197
|
+
const scaleVal = "scale" in t ? t.scale : void 0;
|
|
198
|
+
if (scaleVal) {
|
|
199
|
+
if (typeof scaleVal === "number") {
|
|
200
|
+
transformStrings.push(`scale(${scaleVal})`);
|
|
201
|
+
} else if (Array.isArray(scaleVal) && scaleVal.length == 2 && typeof scaleVal[0] === "number") {
|
|
202
|
+
transformStrings.push(`scale(${scaleVal[0]}, ${scaleVal[1]})`);
|
|
203
|
+
} else {
|
|
204
|
+
throw new Error("parsing MediaTransform: Unrecognized value for 'scale'!");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return transformStrings.length > 0 ? { transform: transformStrings.join(" ") } : {};
|
|
208
|
+
}
|
|
209
|
+
__name(spreadToTransform, "spreadToTransform");
|
|
210
|
+
var spread_to_transform_default = spreadToTransform;
|
|
211
|
+
|
|
212
|
+
// util/specifier.ts
|
|
213
|
+
var getPrimaryStartingWith = /* @__PURE__ */ __name((s, toFind) => {
|
|
214
|
+
const tokenArray = s.split(" ");
|
|
215
|
+
return tokenArray.find((tok) => tok.startsWith(`${toFind}-`));
|
|
216
|
+
}, "getPrimaryStartingWith");
|
|
217
|
+
var getTShirtSize = /* @__PURE__ */ __name((s) => {
|
|
218
|
+
const subTokenArray = s.split("-");
|
|
219
|
+
return subTokenArray[subTokenArray.length - 1];
|
|
220
|
+
}, "getTShirtSize");
|
|
221
|
+
var getTypographySize = /* @__PURE__ */ __name((s) => {
|
|
222
|
+
const subTokenArray = s.split("-");
|
|
223
|
+
return subTokenArray[subTokenArray.length - 1];
|
|
224
|
+
}, "getTypographySize");
|
|
225
|
+
var getDim = /* @__PURE__ */ __name((s) => {
|
|
226
|
+
const subTokenArray = s.split("-");
|
|
227
|
+
const dimStr = subTokenArray[subTokenArray.length - 1];
|
|
228
|
+
if (dimStr) {
|
|
229
|
+
const dimTokenArray = s.split("x");
|
|
230
|
+
return dimTokenArray ? {
|
|
231
|
+
w: Number(dimTokenArray[0]),
|
|
232
|
+
h: Number(dimTokenArray[1])
|
|
233
|
+
} : void 0;
|
|
234
|
+
}
|
|
235
|
+
return void 0;
|
|
236
|
+
}, "getDim");
|
|
237
|
+
function getSpecifierData(main, getPrimary, getData, def) {
|
|
238
|
+
const primary = getPrimary(main);
|
|
239
|
+
if (primary) {
|
|
240
|
+
return getData(primary) ?? def;
|
|
241
|
+
}
|
|
242
|
+
return def ?? void 0;
|
|
243
|
+
}
|
|
244
|
+
__name(getSpecifierData, "getSpecifierData");
|
|
245
|
+
|
|
246
|
+
// util/number-abbreviate.ts
|
|
247
|
+
var ABBR_SYMBOLS_ARRAY = ["K", "M", "B", "T"];
|
|
248
|
+
|
|
249
|
+
// util/index.ts
|
|
250
|
+
import { clsx } from "clsx";
|
|
251
|
+
import { twMerge } from "tailwind-merge";
|
|
252
|
+
function cn(...inputs) {
|
|
253
|
+
return twMerge(clsx(inputs));
|
|
254
|
+
}
|
|
255
|
+
__name(cn, "cn");
|
|
256
|
+
function formatDate(input) {
|
|
257
|
+
const date = new Date(input);
|
|
258
|
+
return date.toLocaleDateString("en-US", {
|
|
259
|
+
month: "long",
|
|
260
|
+
day: "numeric",
|
|
261
|
+
year: "numeric"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
__name(formatDate, "formatDate");
|
|
265
|
+
function absoluteUrl(path) {
|
|
266
|
+
if (typeof window !== "undefined") return path;
|
|
267
|
+
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}${path}`;
|
|
268
|
+
return `http://localhost:${process.env.PORT ?? 3e3}${path}`;
|
|
269
|
+
}
|
|
270
|
+
__name(absoluteUrl, "absoluteUrl");
|
|
271
|
+
function constrain(value, minOrConstrainTo, max) {
|
|
272
|
+
if (typeof value === "number" && typeof minOrConstrainTo === "number" && typeof max === "number") {
|
|
273
|
+
return Math.min(Math.max(value, minOrConstrainTo), max);
|
|
274
|
+
}
|
|
275
|
+
if (typeof value === "object" && typeof minOrConstrainTo === "object") {
|
|
276
|
+
const dim = value;
|
|
277
|
+
const constrainTo = minOrConstrainTo;
|
|
278
|
+
const aspectRatio = dim.w / dim.h;
|
|
279
|
+
const constrainAspectRatio = constrainTo.w / constrainTo.h;
|
|
280
|
+
if (aspectRatio > constrainAspectRatio) {
|
|
281
|
+
return {
|
|
282
|
+
w: constrainTo.w,
|
|
283
|
+
h: constrainTo.w / aspectRatio
|
|
284
|
+
};
|
|
285
|
+
} else {
|
|
286
|
+
return {
|
|
287
|
+
w: constrainTo.h * aspectRatio,
|
|
288
|
+
h: constrainTo.h
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
throw new Error("Invalid parameters for constrain function");
|
|
293
|
+
}
|
|
294
|
+
__name(constrain, "constrain");
|
|
295
|
+
function round(value) {
|
|
296
|
+
return Math.round(value * 100) / 100;
|
|
297
|
+
}
|
|
298
|
+
__name(round, "round");
|
|
299
|
+
function pxToRem(px, base = 16) {
|
|
300
|
+
return `${px / base}rem`;
|
|
301
|
+
}
|
|
302
|
+
__name(pxToRem, "pxToRem");
|
|
303
|
+
function pxToEm(px, base = 16) {
|
|
304
|
+
return `${px / base}em`;
|
|
305
|
+
}
|
|
306
|
+
__name(pxToEm, "pxToEm");
|
|
307
|
+
function containsToken(text, token) {
|
|
308
|
+
return text.toLowerCase().includes(token.toLowerCase());
|
|
309
|
+
}
|
|
310
|
+
__name(containsToken, "containsToken");
|
|
311
|
+
function ldMerge(...objects) {
|
|
312
|
+
const result = {};
|
|
313
|
+
for (const obj of objects) {
|
|
314
|
+
if (obj && typeof obj === "object") {
|
|
315
|
+
Object.assign(result, obj);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
__name(ldMerge, "ldMerge");
|
|
321
|
+
function asNum(value, defaultValue = 0) {
|
|
322
|
+
const num = Number(value);
|
|
323
|
+
return isNaN(num) ? defaultValue : num;
|
|
324
|
+
}
|
|
325
|
+
__name(asNum, "asNum");
|
|
326
|
+
export {
|
|
327
|
+
ABBR_SYMBOLS_ARRAY,
|
|
328
|
+
absoluteUrl,
|
|
329
|
+
asNum,
|
|
330
|
+
blobToBase64,
|
|
331
|
+
cn,
|
|
332
|
+
constrain,
|
|
333
|
+
containsToken,
|
|
334
|
+
copyToClipboard,
|
|
335
|
+
createShadowRoot,
|
|
336
|
+
dataUrlToFile,
|
|
337
|
+
debounce,
|
|
338
|
+
delay,
|
|
339
|
+
formatCamelCaseText,
|
|
340
|
+
formatDate,
|
|
341
|
+
formatDateToLocaleStringWithTime,
|
|
342
|
+
formatDateToMonthAndDay,
|
|
343
|
+
formatDateToUSLocaleString,
|
|
344
|
+
formatText,
|
|
345
|
+
getDim,
|
|
346
|
+
getFileExt,
|
|
347
|
+
getFileName,
|
|
348
|
+
getPrimaryStartingWith,
|
|
349
|
+
getRelativeDateLabel,
|
|
350
|
+
getSpecifierData,
|
|
351
|
+
getTShirtSize,
|
|
352
|
+
getTypographySize,
|
|
353
|
+
getVersionFromTool,
|
|
354
|
+
groupMessagesByDate,
|
|
355
|
+
isFileTypeImageOrPdf,
|
|
356
|
+
ldMerge,
|
|
357
|
+
pxToEm,
|
|
358
|
+
pxToRem,
|
|
359
|
+
round,
|
|
360
|
+
spread_to_transform_default as spreadToTransform,
|
|
361
|
+
submitRegistrationNoCodeError,
|
|
362
|
+
submitRegistrationNoCodeNonPristineError
|
|
363
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Core utilities shared across all frameworks
|
|
2
|
+
import { type ClassValue, clsx } from 'clsx'
|
|
3
|
+
import { twMerge } from 'tailwind-merge'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Merge class names with Tailwind CSS support
|
|
7
|
+
* Works across all frameworks
|
|
8
|
+
*/
|
|
9
|
+
export function cn(...inputs: ClassValue[]) {
|
|
10
|
+
return twMerge(clsx(inputs))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Format bytes to human readable string
|
|
15
|
+
*/
|
|
16
|
+
export function formatBytes(bytes: number, decimals = 2) {
|
|
17
|
+
if (bytes === 0) return '0 Bytes'
|
|
18
|
+
|
|
19
|
+
const k = 1024
|
|
20
|
+
const dm = decimals < 0 ? 0 : decimals
|
|
21
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
22
|
+
|
|
23
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
24
|
+
|
|
25
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Debounce function
|
|
30
|
+
*/
|
|
31
|
+
export function debounce<T extends (...args: any[]) => any>(
|
|
32
|
+
func: T,
|
|
33
|
+
wait: number
|
|
34
|
+
): (...args: Parameters<T>) => void {
|
|
35
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null
|
|
36
|
+
|
|
37
|
+
return (...args: Parameters<T>) => {
|
|
38
|
+
if (timeoutId !== null) {
|
|
39
|
+
clearTimeout(timeoutId)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
timeoutId = setTimeout(() => {
|
|
43
|
+
func(...args)
|
|
44
|
+
}, wait)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Throttle function
|
|
50
|
+
*/
|
|
51
|
+
export function throttle<T extends (...args: any[]) => any>(
|
|
52
|
+
func: T,
|
|
53
|
+
limit: number
|
|
54
|
+
): (...args: Parameters<T>) => void {
|
|
55
|
+
let inThrottle: boolean
|
|
56
|
+
|
|
57
|
+
return (...args: Parameters<T>) => {
|
|
58
|
+
if (!inThrottle) {
|
|
59
|
+
func(...args)
|
|
60
|
+
inThrottle = true
|
|
61
|
+
setTimeout(() => (inThrottle = false), limit)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../../core/utils'
|
|
3
|
+
|
|
4
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link'
|
|
6
|
+
size?: 'default' | 'sm' | 'lg' | 'icon'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
10
|
+
({ className, variant = 'default', size = 'default', ...props }, ref) => {
|
|
11
|
+
return (
|
|
12
|
+
<button
|
|
13
|
+
className={cn(
|
|
14
|
+
'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
ref={ref}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
Button.displayName = 'Button'
|
|
25
|
+
|
|
26
|
+
export default Button
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// React Native components entry point
|
|
2
|
+
// Export all React Native components for @hanzo/ui
|
|
3
|
+
|
|
4
|
+
export * from './components'
|
|
5
|
+
export * from './hooks'
|
|
6
|
+
export * from './utils'
|
|
7
|
+
|
|
8
|
+
// Re-export core utilities (adapted for React Native)
|
|
9
|
+
export { cn } from '../core/utils'
|