virtual-ui-lib 1.0.15 → 1.0.16

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 CHANGED
@@ -31,7 +31,8 @@ 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
35
36
  });
36
37
  module.exports = __toCommonJS(index_exports);
37
38
 
@@ -201,9 +202,80 @@ var Card = ({
201
202
  )
202
203
  );
203
204
  };
205
+
206
+ // src/components/Dropdown/Dropdown.jsx
207
+ var import_react4 = __toESM(require("react"));
208
+ var Dropdown = ({
209
+ options = ["Option 1", "Option 2", "Option 3"],
210
+ defaultValue = "Option 1",
211
+ bg = "#1e293b",
212
+ accent = "#7c3aed",
213
+ textColor = "#f1f5f9",
214
+ borderColor = "rgba(255,255,255,0.1)",
215
+ radius = "10px",
216
+ onSelect
217
+ }) => {
218
+ const [open, setOpen] = (0, import_react4.useState)(false);
219
+ const [selected, setSelected] = (0, import_react4.useState)(defaultValue);
220
+ const dropdownRef = (0, import_react4.useRef)(null);
221
+ const handleClickOutside = (event) => {
222
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
223
+ setOpen(false);
224
+ }
225
+ };
226
+ const handleKeyDown = (event) => {
227
+ if (event.key === "ArrowDown") {
228
+ }
229
+ };
230
+ (0, import_react4.useEffect)(() => {
231
+ document.addEventListener("mousedown", handleClickOutside);
232
+ document.addEventListener("keydown", handleKeyDown);
233
+ return () => {
234
+ document.removeEventListener("mousedown", handleClickOutside);
235
+ document.removeEventListener("keydown", handleKeyDown);
236
+ };
237
+ });
238
+ const handleOptionSelect = (option) => {
239
+ setSelected(option);
240
+ onSelect && onSelect(option);
241
+ setOpen(false);
242
+ };
243
+ 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: {
244
+ background: bg,
245
+ color: textColor,
246
+ border: `1px solid ${borderColor}`,
247
+ borderRadius: radius,
248
+ padding: "10px 16px",
249
+ cursor: "pointer",
250
+ fontSize: "16px",
251
+ display: "flex",
252
+ alignItems: "center",
253
+ gap: "5px"
254
+ } }, selected, " ", /* @__PURE__ */ import_react4.default.createElement("span", { style: { marginLeft: "auto" } }, "\u25BC")), open && /* @__PURE__ */ import_react4.default.createElement("div", { style: {
255
+ position: "absolute",
256
+ top: "100%",
257
+ left: 0,
258
+ right: 0,
259
+ background: bg,
260
+ border: `1px solid ${borderColor}`,
261
+ borderRadius: radius,
262
+ boxShadow: "0 4px 10px rgba(0,0,0,0.2)",
263
+ zIndex: 100,
264
+ marginTop: "4px",
265
+ animation: "fadeIn 0.3s ease, slideDown 0.3s ease"
266
+ } }, options.map((option) => /* @__PURE__ */ import_react4.default.createElement("div", { key: option, onClick: () => handleOptionSelect(option), style: {
267
+ padding: "10px 15px",
268
+ color: option === selected ? accent : textColor,
269
+ background: option === selected ? "rgba(124,58,237,0.1)" : "transparent",
270
+ borderRadius: radius,
271
+ cursor: "pointer",
272
+ transition: "background 0.2s"
273
+ }, onMouseEnter: (e) => e.currentTarget.style.background = "rgba(124,58,237,0.05)", onMouseLeave: (e) => e.currentTarget.style.background = "transparent" }, option))));
274
+ };
204
275
  // Annotate the CommonJS export names for ESM import in node:
205
276
  0 && (module.exports = {
206
277
  AlertBanner,
207
278
  Button,
208
- Card
279
+ Card,
280
+ Dropdown
209
281
  });
package/dist/index.mjs CHANGED
@@ -164,8 +164,79 @@ 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
+ };
167
237
  export {
168
238
  AlertBanner,
169
239
  Button,
170
- Card
240
+ Card,
241
+ Dropdown
171
242
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-ui-lib",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Virtual UI React Component Library",
5
5
  "author": "Ankush",
6
6
  "license": "ISC",