virtual-ui-lib 1.0.15 → 1.0.17
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 +121 -2
- package/dist/index.mjs +118 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,9 @@ var index_exports = {};
|
|
|
31
31
|
__export(index_exports, {
|
|
32
32
|
AlertBanner: () => AlertBanner,
|
|
33
33
|
Button: () => Button,
|
|
34
|
-
Card: () => Card
|
|
34
|
+
Card: () => Card,
|
|
35
|
+
Dropdown: () => Dropdown,
|
|
36
|
+
EmptyState: () => EmptyState
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(index_exports);
|
|
37
39
|
|
|
@@ -201,9 +203,126 @@ var Card = ({
|
|
|
201
203
|
)
|
|
202
204
|
);
|
|
203
205
|
};
|
|
206
|
+
|
|
207
|
+
// src/components/Dropdown/Dropdown.jsx
|
|
208
|
+
var import_react4 = __toESM(require("react"));
|
|
209
|
+
var Dropdown = ({
|
|
210
|
+
options = ["Option 1", "Option 2", "Option 3"],
|
|
211
|
+
defaultValue = "Option 1",
|
|
212
|
+
bg = "#1e293b",
|
|
213
|
+
accent = "#7c3aed",
|
|
214
|
+
textColor = "#f1f5f9",
|
|
215
|
+
borderColor = "rgba(255,255,255,0.1)",
|
|
216
|
+
radius = "10px",
|
|
217
|
+
onSelect
|
|
218
|
+
}) => {
|
|
219
|
+
const [open, setOpen] = (0, import_react4.useState)(false);
|
|
220
|
+
const [selected, setSelected] = (0, import_react4.useState)(defaultValue);
|
|
221
|
+
const dropdownRef = (0, import_react4.useRef)(null);
|
|
222
|
+
const handleClickOutside = (event) => {
|
|
223
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
224
|
+
setOpen(false);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const handleKeyDown = (event) => {
|
|
228
|
+
if (event.key === "ArrowDown") {
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
(0, import_react4.useEffect)(() => {
|
|
232
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
233
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
234
|
+
return () => {
|
|
235
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
236
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
const handleOptionSelect = (option) => {
|
|
240
|
+
setSelected(option);
|
|
241
|
+
onSelect && onSelect(option);
|
|
242
|
+
setOpen(false);
|
|
243
|
+
};
|
|
244
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", { style: { position: "relative", display: "inline-block", fontFamily: "system-ui, sans-serif" }, ref: dropdownRef }, /* @__PURE__ */ import_react4.default.createElement("button", { onClick: () => setOpen((prev) => !prev), style: {
|
|
245
|
+
background: bg,
|
|
246
|
+
color: textColor,
|
|
247
|
+
border: `1px solid ${borderColor}`,
|
|
248
|
+
borderRadius: radius,
|
|
249
|
+
padding: "10px 16px",
|
|
250
|
+
cursor: "pointer",
|
|
251
|
+
fontSize: "16px",
|
|
252
|
+
display: "flex",
|
|
253
|
+
alignItems: "center",
|
|
254
|
+
gap: "5px"
|
|
255
|
+
} }, selected, " ", /* @__PURE__ */ import_react4.default.createElement("span", { style: { marginLeft: "auto" } }, "\u25BC")), open && /* @__PURE__ */ import_react4.default.createElement("div", { style: {
|
|
256
|
+
position: "absolute",
|
|
257
|
+
top: "100%",
|
|
258
|
+
left: 0,
|
|
259
|
+
right: 0,
|
|
260
|
+
background: bg,
|
|
261
|
+
border: `1px solid ${borderColor}`,
|
|
262
|
+
borderRadius: radius,
|
|
263
|
+
boxShadow: "0 4px 10px rgba(0,0,0,0.2)",
|
|
264
|
+
zIndex: 100,
|
|
265
|
+
marginTop: "4px",
|
|
266
|
+
animation: "fadeIn 0.3s ease, slideDown 0.3s ease"
|
|
267
|
+
} }, options.map((option) => /* @__PURE__ */ import_react4.default.createElement("div", { key: option, onClick: () => handleOptionSelect(option), style: {
|
|
268
|
+
padding: "10px 15px",
|
|
269
|
+
color: option === selected ? accent : textColor,
|
|
270
|
+
background: option === selected ? "rgba(124,58,237,0.1)" : "transparent",
|
|
271
|
+
borderRadius: radius,
|
|
272
|
+
cursor: "pointer",
|
|
273
|
+
transition: "background 0.2s"
|
|
274
|
+
}, onMouseEnter: (e) => e.currentTarget.style.background = "rgba(124,58,237,0.05)", onMouseLeave: (e) => e.currentTarget.style.background = "transparent" }, option))));
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// src/components/EmptyState/EmptyState.jsx
|
|
278
|
+
var import_react5 = __toESM(require("react"));
|
|
279
|
+
var EmptyState = ({
|
|
280
|
+
mode = "default",
|
|
281
|
+
icon = "https://i.imgur.com/E9Gdppt.png",
|
|
282
|
+
message = "No data available. Please check back later.",
|
|
283
|
+
actionText = "Try Again",
|
|
284
|
+
onAction
|
|
285
|
+
}) => {
|
|
286
|
+
const [isVisible, setIsVisible] = (0, import_react5.useState)(false);
|
|
287
|
+
(0, import_react5.useEffect)(() => {
|
|
288
|
+
setIsVisible(true);
|
|
289
|
+
}, []);
|
|
290
|
+
const renderModeContent = () => {
|
|
291
|
+
switch (mode) {
|
|
292
|
+
case "action available":
|
|
293
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ import_react5.default.createElement("img", { src: icon, alt: "Empty State Icon", style: { width: "60px", marginBottom: "16px" } }), /* @__PURE__ */ import_react5.default.createElement("p", { style: { fontSize: "16px", color: "#64748b", margin: 0 } }, message), /* @__PURE__ */ import_react5.default.createElement("button", { onClick: onAction, style: {
|
|
294
|
+
marginTop: "20px",
|
|
295
|
+
padding: "10px 20px",
|
|
296
|
+
background: "#7c3aed",
|
|
297
|
+
color: "white",
|
|
298
|
+
border: "none",
|
|
299
|
+
borderRadius: "8px",
|
|
300
|
+
cursor: "pointer",
|
|
301
|
+
fontSize: "14px",
|
|
302
|
+
fontWeight: "600",
|
|
303
|
+
transition: "background 0.3s ease, transform 0.3s ease",
|
|
304
|
+
boxShadow: "0 4px 14px rgba(124,58,237,0.4)"
|
|
305
|
+
}, onMouseEnter: (e) => e.currentTarget.style.background = "#6d28d9", onMouseLeave: (e) => e.currentTarget.style.background = "#7c3aed" }, actionText));
|
|
306
|
+
case "illustration mode":
|
|
307
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ import_react5.default.createElement("img", { src: icon, alt: "Illustration", style: { width: "80px", marginBottom: "16px" } }), /* @__PURE__ */ import_react5.default.createElement("p", { style: { fontSize: "16px", color: "#64748b", margin: 0 } }, message));
|
|
308
|
+
default:
|
|
309
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ import_react5.default.createElement("img", { src: icon, alt: "Default Icon", style: { width: "60px", marginBottom: "16px" } }), /* @__PURE__ */ import_react5.default.createElement("p", { style: { fontSize: "16px", color: "#64748b", margin: 0 } }, message));
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { style: {
|
|
313
|
+
display: "flex",
|
|
314
|
+
justifyContent: "center",
|
|
315
|
+
alignItems: "center",
|
|
316
|
+
height: "100vh",
|
|
317
|
+
opacity: isVisible ? 1 : 0,
|
|
318
|
+
transition: "opacity 0.5s ease-in-out"
|
|
319
|
+
} }, renderModeContent());
|
|
320
|
+
};
|
|
204
321
|
// Annotate the CommonJS export names for ESM import in node:
|
|
205
322
|
0 && (module.exports = {
|
|
206
323
|
AlertBanner,
|
|
207
324
|
Button,
|
|
208
|
-
Card
|
|
325
|
+
Card,
|
|
326
|
+
Dropdown,
|
|
327
|
+
EmptyState
|
|
209
328
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -164,8 +164,125 @@ var Card = ({
|
|
|
164
164
|
)
|
|
165
165
|
);
|
|
166
166
|
};
|
|
167
|
+
|
|
168
|
+
// src/components/Dropdown/Dropdown.jsx
|
|
169
|
+
import React4, { useRef, useState as useState2, useEffect as useEffect2 } from "react";
|
|
170
|
+
var Dropdown = ({
|
|
171
|
+
options = ["Option 1", "Option 2", "Option 3"],
|
|
172
|
+
defaultValue = "Option 1",
|
|
173
|
+
bg = "#1e293b",
|
|
174
|
+
accent = "#7c3aed",
|
|
175
|
+
textColor = "#f1f5f9",
|
|
176
|
+
borderColor = "rgba(255,255,255,0.1)",
|
|
177
|
+
radius = "10px",
|
|
178
|
+
onSelect
|
|
179
|
+
}) => {
|
|
180
|
+
const [open, setOpen] = useState2(false);
|
|
181
|
+
const [selected, setSelected] = useState2(defaultValue);
|
|
182
|
+
const dropdownRef = useRef(null);
|
|
183
|
+
const handleClickOutside = (event) => {
|
|
184
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
185
|
+
setOpen(false);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const handleKeyDown = (event) => {
|
|
189
|
+
if (event.key === "ArrowDown") {
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
useEffect2(() => {
|
|
193
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
194
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
195
|
+
return () => {
|
|
196
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
197
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
const handleOptionSelect = (option) => {
|
|
201
|
+
setSelected(option);
|
|
202
|
+
onSelect && onSelect(option);
|
|
203
|
+
setOpen(false);
|
|
204
|
+
};
|
|
205
|
+
return /* @__PURE__ */ React4.createElement("div", { style: { position: "relative", display: "inline-block", fontFamily: "system-ui, sans-serif" }, ref: dropdownRef }, /* @__PURE__ */ React4.createElement("button", { onClick: () => setOpen((prev) => !prev), style: {
|
|
206
|
+
background: bg,
|
|
207
|
+
color: textColor,
|
|
208
|
+
border: `1px solid ${borderColor}`,
|
|
209
|
+
borderRadius: radius,
|
|
210
|
+
padding: "10px 16px",
|
|
211
|
+
cursor: "pointer",
|
|
212
|
+
fontSize: "16px",
|
|
213
|
+
display: "flex",
|
|
214
|
+
alignItems: "center",
|
|
215
|
+
gap: "5px"
|
|
216
|
+
} }, selected, " ", /* @__PURE__ */ React4.createElement("span", { style: { marginLeft: "auto" } }, "\u25BC")), open && /* @__PURE__ */ React4.createElement("div", { style: {
|
|
217
|
+
position: "absolute",
|
|
218
|
+
top: "100%",
|
|
219
|
+
left: 0,
|
|
220
|
+
right: 0,
|
|
221
|
+
background: bg,
|
|
222
|
+
border: `1px solid ${borderColor}`,
|
|
223
|
+
borderRadius: radius,
|
|
224
|
+
boxShadow: "0 4px 10px rgba(0,0,0,0.2)",
|
|
225
|
+
zIndex: 100,
|
|
226
|
+
marginTop: "4px",
|
|
227
|
+
animation: "fadeIn 0.3s ease, slideDown 0.3s ease"
|
|
228
|
+
} }, options.map((option) => /* @__PURE__ */ React4.createElement("div", { key: option, onClick: () => handleOptionSelect(option), style: {
|
|
229
|
+
padding: "10px 15px",
|
|
230
|
+
color: option === selected ? accent : textColor,
|
|
231
|
+
background: option === selected ? "rgba(124,58,237,0.1)" : "transparent",
|
|
232
|
+
borderRadius: radius,
|
|
233
|
+
cursor: "pointer",
|
|
234
|
+
transition: "background 0.2s"
|
|
235
|
+
}, onMouseEnter: (e) => e.currentTarget.style.background = "rgba(124,58,237,0.05)", onMouseLeave: (e) => e.currentTarget.style.background = "transparent" }, option))));
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/components/EmptyState/EmptyState.jsx
|
|
239
|
+
import React5, { useEffect as useEffect3, useState as useState3 } from "react";
|
|
240
|
+
var EmptyState = ({
|
|
241
|
+
mode = "default",
|
|
242
|
+
icon = "https://i.imgur.com/E9Gdppt.png",
|
|
243
|
+
message = "No data available. Please check back later.",
|
|
244
|
+
actionText = "Try Again",
|
|
245
|
+
onAction
|
|
246
|
+
}) => {
|
|
247
|
+
const [isVisible, setIsVisible] = useState3(false);
|
|
248
|
+
useEffect3(() => {
|
|
249
|
+
setIsVisible(true);
|
|
250
|
+
}, []);
|
|
251
|
+
const renderModeContent = () => {
|
|
252
|
+
switch (mode) {
|
|
253
|
+
case "action available":
|
|
254
|
+
return /* @__PURE__ */ React5.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React5.createElement("img", { src: icon, alt: "Empty State Icon", style: { width: "60px", marginBottom: "16px" } }), /* @__PURE__ */ React5.createElement("p", { style: { fontSize: "16px", color: "#64748b", margin: 0 } }, message), /* @__PURE__ */ React5.createElement("button", { onClick: onAction, style: {
|
|
255
|
+
marginTop: "20px",
|
|
256
|
+
padding: "10px 20px",
|
|
257
|
+
background: "#7c3aed",
|
|
258
|
+
color: "white",
|
|
259
|
+
border: "none",
|
|
260
|
+
borderRadius: "8px",
|
|
261
|
+
cursor: "pointer",
|
|
262
|
+
fontSize: "14px",
|
|
263
|
+
fontWeight: "600",
|
|
264
|
+
transition: "background 0.3s ease, transform 0.3s ease",
|
|
265
|
+
boxShadow: "0 4px 14px rgba(124,58,237,0.4)"
|
|
266
|
+
}, onMouseEnter: (e) => e.currentTarget.style.background = "#6d28d9", onMouseLeave: (e) => e.currentTarget.style.background = "#7c3aed" }, actionText));
|
|
267
|
+
case "illustration mode":
|
|
268
|
+
return /* @__PURE__ */ React5.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React5.createElement("img", { src: icon, alt: "Illustration", style: { width: "80px", marginBottom: "16px" } }), /* @__PURE__ */ React5.createElement("p", { style: { fontSize: "16px", color: "#64748b", margin: 0 } }, message));
|
|
269
|
+
default:
|
|
270
|
+
return /* @__PURE__ */ React5.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React5.createElement("img", { src: icon, alt: "Default Icon", style: { width: "60px", marginBottom: "16px" } }), /* @__PURE__ */ React5.createElement("p", { style: { fontSize: "16px", color: "#64748b", margin: 0 } }, message));
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
return /* @__PURE__ */ React5.createElement("div", { style: {
|
|
274
|
+
display: "flex",
|
|
275
|
+
justifyContent: "center",
|
|
276
|
+
alignItems: "center",
|
|
277
|
+
height: "100vh",
|
|
278
|
+
opacity: isVisible ? 1 : 0,
|
|
279
|
+
transition: "opacity 0.5s ease-in-out"
|
|
280
|
+
} }, renderModeContent());
|
|
281
|
+
};
|
|
167
282
|
export {
|
|
168
283
|
AlertBanner,
|
|
169
284
|
Button,
|
|
170
|
-
Card
|
|
285
|
+
Card,
|
|
286
|
+
Dropdown,
|
|
287
|
+
EmptyState
|
|
171
288
|
};
|