virtual-ui-lib 1.0.39 → 1.0.40
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 +27 -0
- package/dist/index.mjs +26 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ 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,
|
|
33
34
|
StatCard: () => StatCard,
|
|
34
35
|
ToastNotification: () => ToastNotification
|
|
@@ -234,8 +235,34 @@ var OtpInput = ({
|
|
|
234
235
|
}
|
|
235
236
|
)), otp.join("").length === length && /* @__PURE__ */ import_react3.default.createElement("span", { style: { color: "#4ade80", fontSize: "20px" } }, "\u2705"));
|
|
236
237
|
};
|
|
238
|
+
|
|
239
|
+
// src/components/CodeBlock/CodeBlock.jsx
|
|
240
|
+
var import_react4 = __toESM(require("react"));
|
|
241
|
+
var CodeBlock = ({
|
|
242
|
+
code = "const hello = 'Hello, world!';\nconsole.log(hello);",
|
|
243
|
+
language = "JavaScript",
|
|
244
|
+
filename = "example.js",
|
|
245
|
+
bg = "#0d1117",
|
|
246
|
+
textColor = "#c9d1d9",
|
|
247
|
+
tokenColors = { string: "#a5d6e9", keyword: "#f9bc41", variable: "#a6e22e" },
|
|
248
|
+
showLineNumbers = true,
|
|
249
|
+
wrapWords = false
|
|
250
|
+
}) => {
|
|
251
|
+
const [copied, setCopied] = (0, import_react4.useState)(false);
|
|
252
|
+
const handleCopy = () => {
|
|
253
|
+
navigator.clipboard.writeText(code).then(() => {
|
|
254
|
+
setCopied(true);
|
|
255
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
const formatCode = () => {
|
|
259
|
+
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>`))));
|
|
260
|
+
};
|
|
261
|
+
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"));
|
|
262
|
+
};
|
|
237
263
|
// Annotate the CommonJS export names for ESM import in node:
|
|
238
264
|
0 && (module.exports = {
|
|
265
|
+
CodeBlock,
|
|
239
266
|
OtpInput,
|
|
240
267
|
StatCard,
|
|
241
268
|
ToastNotification
|
package/dist/index.mjs
CHANGED
|
@@ -197,7 +197,33 @@ 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
|
+
};
|
|
200
225
|
export {
|
|
226
|
+
CodeBlock,
|
|
201
227
|
OtpInput,
|
|
202
228
|
StatCard,
|
|
203
229
|
ToastNotification
|