virtual-ui-lib 1.0.39 → 1.0.41
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/dist/index.js +75 -0
- package/dist/index.mjs +73 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29,7 +29,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/index.js
|
|
30
30
|
var index_exports = {};
|
|
31
31
|
__export(index_exports, {
|
|
32
|
+
CodeBlock: () => CodeBlock,
|
|
32
33
|
OtpInput: () => OtpInput,
|
|
34
|
+
SmartButton: () => SmartButton,
|
|
33
35
|
StatCard: () => StatCard,
|
|
34
36
|
ToastNotification: () => ToastNotification
|
|
35
37
|
});
|
|
@@ -234,9 +236,82 @@ var OtpInput = ({
|
|
|
234
236
|
}
|
|
235
237
|
)), otp.join("").length === length && /* @__PURE__ */ import_react3.default.createElement("span", { style: { color: "#4ade80", fontSize: "20px" } }, "\u2705"));
|
|
236
238
|
};
|
|
239
|
+
|
|
240
|
+
// src/components/CodeBlock/CodeBlock.jsx
|
|
241
|
+
var import_react4 = __toESM(require("react"));
|
|
242
|
+
var CodeBlock = ({
|
|
243
|
+
code = "const hello = 'Hello, world!';\nconsole.log(hello);",
|
|
244
|
+
language = "JavaScript",
|
|
245
|
+
filename = "example.js",
|
|
246
|
+
bg = "#0d1117",
|
|
247
|
+
textColor = "#c9d1d9",
|
|
248
|
+
tokenColors = { string: "#a5d6e9", keyword: "#f9bc41", variable: "#a6e22e" },
|
|
249
|
+
showLineNumbers = true,
|
|
250
|
+
wrapWords = false
|
|
251
|
+
}) => {
|
|
252
|
+
const [copied, setCopied] = (0, import_react4.useState)(false);
|
|
253
|
+
const handleCopy = () => {
|
|
254
|
+
navigator.clipboard.writeText(code).then(() => {
|
|
255
|
+
setCopied(true);
|
|
256
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
const formatCode = () => {
|
|
260
|
+
return code.split("\n").map((line, index) => /* @__PURE__ */ import_react4.default.createElement("div", { key: index, style: { display: "flex" } }, showLineNumbers && /* @__PURE__ */ import_react4.default.createElement("span", { style: { marginRight: "10px", color: "#58a6ff" } }, index + 1), /* @__PURE__ */ import_react4.default.createElement("span", { style: { color: tokenColors.string } }, line.replace(/(\'.*?\')/g, (match) => `<span style='color:${tokenColors.string}'>${match}</span>`))));
|
|
261
|
+
};
|
|
262
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", { style: { background: bg, borderRadius: "8px", padding: "16px", fontFamily: "monospace", position: "relative" } }, filename && /* @__PURE__ */ import_react4.default.createElement("div", { style: { color: textColor, fontWeight: "bold", marginBottom: "8px" } }, filename), /* @__PURE__ */ import_react4.default.createElement("div", { style: { overflowX: wrapWords ? "auto" : "hidden", whiteSpace: wrapWords ? "normal" : "pre" } }, formatCode()), /* @__PURE__ */ import_react4.default.createElement("button", { onClick: handleCopy, style: { position: "absolute", top: "10px", right: "10px", background: copied ? "#28a745" : "#58a6ff", color: "white", border: "none", borderRadius: "4px", padding: "8px 12px", cursor: "pointer", fontSize: "14px", marginLeft: "10px" } }, copied ? "\u2713 Copied" : "Copy"), /* @__PURE__ */ import_react4.default.createElement("button", { onClick: () => wrapWords = !wrapWords, style: { position: "absolute", top: "10px", right: "90px", background: "#58a6ff", color: "white", border: "none", borderRadius: "4px", padding: "8px 12px", cursor: "pointer", fontSize: "14px" } }, wrapWords ? "Wrap Off" : "Wrap On"));
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/components/SmartButton/SmartButton.jsx
|
|
266
|
+
var import_react5 = __toESM(require("react"));
|
|
267
|
+
var SmartButton = ({
|
|
268
|
+
buttonText = "Submit",
|
|
269
|
+
isLoading = false,
|
|
270
|
+
isDisabled = false,
|
|
271
|
+
icon = null,
|
|
272
|
+
success = false,
|
|
273
|
+
error = false,
|
|
274
|
+
bg = "#7c3aed",
|
|
275
|
+
textColor = "#fff",
|
|
276
|
+
padding = "12px 20px",
|
|
277
|
+
radius = "8px",
|
|
278
|
+
onClick = () => {
|
|
279
|
+
}
|
|
280
|
+
}) => {
|
|
281
|
+
const bgColor = success ? "#059669" : error ? "#ef4444" : bg;
|
|
282
|
+
const cursorStyle = isDisabled ? "not-allowed" : "pointer";
|
|
283
|
+
return /* @__PURE__ */ import_react5.default.createElement(
|
|
284
|
+
"button",
|
|
285
|
+
{
|
|
286
|
+
onClick: !isDisabled && !isLoading ? onClick : () => {
|
|
287
|
+
},
|
|
288
|
+
disabled: isDisabled,
|
|
289
|
+
style: {
|
|
290
|
+
background: bgColor,
|
|
291
|
+
color: textColor,
|
|
292
|
+
padding,
|
|
293
|
+
borderRadius: radius,
|
|
294
|
+
border: "none",
|
|
295
|
+
cursor: cursorStyle,
|
|
296
|
+
transition: "background 0.3s ease"
|
|
297
|
+
},
|
|
298
|
+
onMouseEnter: (e) => {
|
|
299
|
+
if (!isDisabled && !isLoading) {
|
|
300
|
+
e.currentTarget.style.background = "#6d28d9";
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
onMouseLeave: (e) => {
|
|
304
|
+
e.currentTarget.style.background = bgColor;
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
isLoading ? /* @__PURE__ */ import_react5.default.createElement("span", null, "Loading...") : /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, icon && /* @__PURE__ */ import_react5.default.createElement("span", { style: { marginRight: "8px" } }, icon), buttonText)
|
|
308
|
+
);
|
|
309
|
+
};
|
|
237
310
|
// Annotate the CommonJS export names for ESM import in node:
|
|
238
311
|
0 && (module.exports = {
|
|
312
|
+
CodeBlock,
|
|
239
313
|
OtpInput,
|
|
314
|
+
SmartButton,
|
|
240
315
|
StatCard,
|
|
241
316
|
ToastNotification
|
|
242
317
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -197,8 +197,81 @@ var OtpInput = ({
|
|
|
197
197
|
}
|
|
198
198
|
)), otp.join("").length === length && /* @__PURE__ */ React3.createElement("span", { style: { color: "#4ade80", fontSize: "20px" } }, "\u2705"));
|
|
199
199
|
};
|
|
200
|
+
|
|
201
|
+
// src/components/CodeBlock/CodeBlock.jsx
|
|
202
|
+
import React4, { useState as useState4 } from "react";
|
|
203
|
+
var CodeBlock = ({
|
|
204
|
+
code = "const hello = 'Hello, world!';\nconsole.log(hello);",
|
|
205
|
+
language = "JavaScript",
|
|
206
|
+
filename = "example.js",
|
|
207
|
+
bg = "#0d1117",
|
|
208
|
+
textColor = "#c9d1d9",
|
|
209
|
+
tokenColors = { string: "#a5d6e9", keyword: "#f9bc41", variable: "#a6e22e" },
|
|
210
|
+
showLineNumbers = true,
|
|
211
|
+
wrapWords = false
|
|
212
|
+
}) => {
|
|
213
|
+
const [copied, setCopied] = useState4(false);
|
|
214
|
+
const handleCopy = () => {
|
|
215
|
+
navigator.clipboard.writeText(code).then(() => {
|
|
216
|
+
setCopied(true);
|
|
217
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
const formatCode = () => {
|
|
221
|
+
return code.split("\n").map((line, index) => /* @__PURE__ */ React4.createElement("div", { key: index, style: { display: "flex" } }, showLineNumbers && /* @__PURE__ */ React4.createElement("span", { style: { marginRight: "10px", color: "#58a6ff" } }, index + 1), /* @__PURE__ */ React4.createElement("span", { style: { color: tokenColors.string } }, line.replace(/(\'.*?\')/g, (match) => `<span style='color:${tokenColors.string}'>${match}</span>`))));
|
|
222
|
+
};
|
|
223
|
+
return /* @__PURE__ */ React4.createElement("div", { style: { background: bg, borderRadius: "8px", padding: "16px", fontFamily: "monospace", position: "relative" } }, filename && /* @__PURE__ */ React4.createElement("div", { style: { color: textColor, fontWeight: "bold", marginBottom: "8px" } }, filename), /* @__PURE__ */ React4.createElement("div", { style: { overflowX: wrapWords ? "auto" : "hidden", whiteSpace: wrapWords ? "normal" : "pre" } }, formatCode()), /* @__PURE__ */ React4.createElement("button", { onClick: handleCopy, style: { position: "absolute", top: "10px", right: "10px", background: copied ? "#28a745" : "#58a6ff", color: "white", border: "none", borderRadius: "4px", padding: "8px 12px", cursor: "pointer", fontSize: "14px", marginLeft: "10px" } }, copied ? "\u2713 Copied" : "Copy"), /* @__PURE__ */ React4.createElement("button", { onClick: () => wrapWords = !wrapWords, style: { position: "absolute", top: "10px", right: "90px", background: "#58a6ff", color: "white", border: "none", borderRadius: "4px", padding: "8px 12px", cursor: "pointer", fontSize: "14px" } }, wrapWords ? "Wrap Off" : "Wrap On"));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/components/SmartButton/SmartButton.jsx
|
|
227
|
+
import React5 from "react";
|
|
228
|
+
var SmartButton = ({
|
|
229
|
+
buttonText = "Submit",
|
|
230
|
+
isLoading = false,
|
|
231
|
+
isDisabled = false,
|
|
232
|
+
icon = null,
|
|
233
|
+
success = false,
|
|
234
|
+
error = false,
|
|
235
|
+
bg = "#7c3aed",
|
|
236
|
+
textColor = "#fff",
|
|
237
|
+
padding = "12px 20px",
|
|
238
|
+
radius = "8px",
|
|
239
|
+
onClick = () => {
|
|
240
|
+
}
|
|
241
|
+
}) => {
|
|
242
|
+
const bgColor = success ? "#059669" : error ? "#ef4444" : bg;
|
|
243
|
+
const cursorStyle = isDisabled ? "not-allowed" : "pointer";
|
|
244
|
+
return /* @__PURE__ */ React5.createElement(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
onClick: !isDisabled && !isLoading ? onClick : () => {
|
|
248
|
+
},
|
|
249
|
+
disabled: isDisabled,
|
|
250
|
+
style: {
|
|
251
|
+
background: bgColor,
|
|
252
|
+
color: textColor,
|
|
253
|
+
padding,
|
|
254
|
+
borderRadius: radius,
|
|
255
|
+
border: "none",
|
|
256
|
+
cursor: cursorStyle,
|
|
257
|
+
transition: "background 0.3s ease"
|
|
258
|
+
},
|
|
259
|
+
onMouseEnter: (e) => {
|
|
260
|
+
if (!isDisabled && !isLoading) {
|
|
261
|
+
e.currentTarget.style.background = "#6d28d9";
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
onMouseLeave: (e) => {
|
|
265
|
+
e.currentTarget.style.background = bgColor;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
isLoading ? /* @__PURE__ */ React5.createElement("span", null, "Loading...") : /* @__PURE__ */ React5.createElement(React5.Fragment, null, icon && /* @__PURE__ */ React5.createElement("span", { style: { marginRight: "8px" } }, icon), buttonText)
|
|
269
|
+
);
|
|
270
|
+
};
|
|
200
271
|
export {
|
|
272
|
+
CodeBlock,
|
|
201
273
|
OtpInput,
|
|
274
|
+
SmartButton,
|
|
202
275
|
StatCard,
|
|
203
276
|
ToastNotification
|
|
204
277
|
};
|