@oottoo-core/oottoo-ui 0.0.1 → 0.0.3

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.
@@ -0,0 +1 @@
1
+ :root{--o-primary: #3b82f6;--o-primary-hover: #2563eb;--o-primary-active: #1d4ed8;--o-success: #22c55e;--o-warning: #f59e0b;--o-error: #ef4444;--o-info: #3b82f6;--o-white: #ffffff;--o-gray-100: #f3f4f6;--o-gray-200: #e5e7eb;--o-gray-300: #d1d5db;--o-gray-400: #9ca3af;--o-gray-500: #6b7280;--o-gray-600: #4b5563;--o-gray-700: #374151;--o-gray-800: #1f2937;--o-gray-900: #111827;--o-font-sans: ui-sans-serif, system-ui, -apple-system, sans-serif;--o-font-mono: ui-monospace, monospace;--o-space-1: .25rem;--o-space-2: .5rem;--o-space-3: .75rem;--o-space-4: 1rem;--o-space-6: 1.5rem;--o-space-8: 2rem;--o-radius-sm: .25rem;--o-radius-md: .375rem;--o-radius-lg: .5rem;--o-radius-xl: .75rem;--o-radius-full: 9999px;--o-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--o-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1);--o-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1);--o-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / .1);--o-transition-fast: .15s ease;--o-transition-base: .2s ease;--o-transition-slow: .3s ease}.o-button{display:inline-flex;align-items:center;justify-content:center;gap:var(--o-space-2);padding:var(--o-space-2) var(--o-space-4);font-family:var(--o-font-sans);font-size:.875rem;font-weight:500;line-height:1.25rem;border-radius:var(--o-radius-md);border:1px solid transparent;cursor:pointer;transition:all var(--o-transition-fast)}.o-button:disabled{opacity:.5;cursor:not-allowed}.o-button--primary{background-color:var(--o-primary);color:var(--o-white)}.o-button--primary:hover:not(:disabled){background-color:var(--o-primary-hover)}.o-button--secondary{background-color:var(--o-gray-200);color:var(--o-gray-800)}.o-button--secondary:hover:not(:disabled){background-color:var(--o-gray-300)}.o-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background-color:#00000080;display:flex;align-items:center;justify-content:center;z-index:50}.o-modal-content{background-color:var(--o-white);border-radius:var(--o-radius-lg);box-shadow:var(--o-shadow-xl);max-width:90vw;max-height:90vh;overflow:auto;padding:var(--o-space-6)}.o-loading{display:inline-flex;animation:o-spin 1s linear infinite}@keyframes o-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.o-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.o-vechain-login{display:inline-flex;align-items:center;justify-content:center;gap:var(--o-space-2);padding:var(--o-space-2) var(--o-space-4);font-family:var(--o-font-sans);font-size:.875rem;font-weight:500;line-height:1.25rem;border-radius:var(--o-radius-md);border:1px solid transparent;cursor:pointer;transition:all var(--o-transition-fast);background-color:var(--o-primary);color:var(--o-white)}.o-vechain-login:hover:not(:disabled){background-color:var(--o-primary-hover)}.o-vechain-login:disabled{opacity:.7;cursor:not-allowed}.o-vechain-login--primary{background-color:var(--o-primary);color:var(--o-white)}.o-vechain-login--primary:hover:not(:disabled){background-color:var(--o-primary-hover)}.o-vechain-login--secondary{background-color:var(--o-gray-200);color:var(--o-gray-800)}.o-vechain-login--secondary:hover:not(:disabled){background-color:var(--o-gray-300)}.o-vechain-login--ghost{background-color:transparent;color:var(--o-primary);border-color:var(--o-primary)}.o-vechain-login--ghost:hover:not(:disabled){background-color:var(--o-primary);color:var(--o-white)}.o-vechain-login--sm{padding:var(--o-space-1) var(--o-space-3);font-size:.75rem}.o-vechain-login--md{padding:var(--o-space-2) var(--o-space-4);font-size:.875rem}.o-vechain-login--lg{padding:var(--o-space-3) var(--o-space-6);font-size:1rem}.o-vechain-login--connected{background-color:var(--o-success)}.o-vechain-login--connected:hover:not(:disabled){background-color:#16a34a}.o-vechain-login--loading{cursor:wait}.o-vechain-login__icon{display:inline-flex;align-items:center;justify-content:center}.o-vechain-login__disconnect-icon{display:inline-flex;align-items:center;justify-content:center;margin-left:var(--o-space-1);opacity:.8}.o-vechain-login__text{white-space:nowrap}.o-modal-enter-active[data-v-882f88c1],.o-modal-leave-active[data-v-882f88c1]{transition:opacity var(--o-transition-base)}.o-modal-enter-from[data-v-882f88c1],.o-modal-leave-to[data-v-882f88c1]{opacity:0}
@@ -1,5 +1,6 @@
1
- import { computed as i, openBlock as a, createElementBlock as c, normalizeClass as y, renderSlot as m, onMounted as g, onUnmounted as h, createBlock as v, Teleport as k, createVNode as _, Transition as z, withCtx as O, withModifiers as b, normalizeStyle as u, createElementVNode as d, createCommentVNode as p, inject as w } from "vue";
2
- const x = ["disabled", "type"], S = {
1
+ import { computed as p, openBlock as l, createElementBlock as d, normalizeClass as x, renderSlot as S, onMounted as E, onUnmounted as L, createBlock as D, Teleport as W, createVNode as H, Transition as K, withCtx as T, withModifiers as R, normalizeStyle as f, createElementVNode as u, createCommentVNode as y, inject as j, ref as O, watch as U, unref as v, toDisplayString as q } from "vue";
2
+ import { useVeChainWallet as F } from "@oottoo-core/oottoo-fns";
3
+ const G = ["disabled", "type"], J = {
3
4
  __name: "OButton",
4
5
  props: {
5
6
  /**
@@ -36,29 +37,29 @@ const x = ["disabled", "type"], S = {
36
37
  }
37
38
  },
38
39
  emits: ["click"],
39
- setup(e, { emit: o }) {
40
- const t = e, n = o, s = (l) => {
41
- t.disabled || n("click", l);
42
- }, r = i(() => [
40
+ setup(e, { emit: i }) {
41
+ const n = e, o = i, c = (r) => {
42
+ n.disabled || o("click", r);
43
+ }, t = p(() => [
43
44
  "o-button",
44
- `o-button--${t.variant}`,
45
- `o-button--${t.size}`
45
+ `o-button--${n.variant}`,
46
+ `o-button--${n.size}`
46
47
  ]);
47
- return (l, f) => (a(), c("button", {
48
- class: y(r.value),
48
+ return (r, m) => (l(), d("button", {
49
+ class: x(t.value),
49
50
  disabled: e.disabled,
50
51
  type: e.type,
51
- onClick: s
52
+ onClick: c
52
53
  }, [
53
- m(l.$slots, "default")
54
- ], 10, x));
54
+ S(r.$slots, "default")
55
+ ], 10, G));
55
56
  }
56
- }, C = (e, o) => {
57
- const t = e.__vccOpts || e;
58
- for (const [n, s] of o)
59
- t[n] = s;
60
- return t;
61
- }, $ = { class: "o-modal-content" }, B = {
57
+ }, P = (e, i) => {
58
+ const n = e.__vccOpts || e;
59
+ for (const [o, c] of i)
60
+ n[o] = c;
61
+ return n;
62
+ }, Q = { class: "o-modal-content" }, X = {
62
63
  __name: "OModal",
63
64
  props: {
64
65
  /**
@@ -77,35 +78,35 @@ const x = ["disabled", "type"], S = {
77
78
  }
78
79
  },
79
80
  emits: ["close"],
80
- setup(e, { emit: o }) {
81
- const t = e, n = o, s = () => {
82
- n("close");
83
- }, r = (l) => {
84
- l.key === "Escape" && t.isOpen && s();
81
+ setup(e, { emit: i }) {
82
+ const n = e, o = i, c = () => {
83
+ o("close");
84
+ }, t = (r) => {
85
+ r.key === "Escape" && n.isOpen && c();
85
86
  };
86
- return g(() => {
87
- document.addEventListener("keydown", r);
88
- }), h(() => {
89
- document.removeEventListener("keydown", r);
90
- }), (l, f) => (a(), v(k, { to: "body" }, [
91
- _(z, { name: "o-modal" }, {
92
- default: O(() => [
93
- e.isOpen ? (a(), c("div", {
87
+ return E(() => {
88
+ document.addEventListener("keydown", t);
89
+ }), L(() => {
90
+ document.removeEventListener("keydown", t);
91
+ }), (r, m) => (l(), D(W, { to: "body" }, [
92
+ H(K, { name: "o-modal" }, {
93
+ default: T(() => [
94
+ e.isOpen ? (l(), d("div", {
94
95
  key: 0,
95
96
  class: "o-modal-overlay",
96
- style: u({ zIndex: e.zIndex }),
97
- onClick: b(s, ["self"])
97
+ style: f({ zIndex: e.zIndex }),
98
+ onClick: R(c, ["self"])
98
99
  }, [
99
- d("div", $, [
100
- m(l.$slots, "default", {}, void 0, !0)
100
+ u("div", Q, [
101
+ S(r.$slots, "default", {}, void 0, !0)
101
102
  ])
102
- ], 4)) : p("", !0)
103
+ ], 4)) : y("", !0)
103
104
  ]),
104
105
  _: 3
105
106
  })
106
107
  ]));
107
108
  }
108
- }, I = /* @__PURE__ */ C(B, [["__scopeId", "data-v-11d6d987"]]), M = ["width", "height"], L = {
109
+ }, Y = /* @__PURE__ */ P(X, [["__scopeId", "data-v-882f88c1"]]), Z = ["width", "height"], ee = {
109
110
  __name: "OLoading",
110
111
  props: {
111
112
  /**
@@ -133,24 +134,24 @@ const x = ["disabled", "type"], S = {
133
134
  }
134
135
  },
135
136
  setup(e) {
136
- const o = e, t = {
137
+ const i = e, n = {
137
138
  sm: 16,
138
139
  md: 24,
139
140
  lg: 32
140
- }, n = i(() => t[o.size]);
141
- return (s, r) => e.loading ? (a(), c("div", {
141
+ }, o = p(() => n[i.size]);
142
+ return (c, t) => e.loading ? (l(), d("div", {
142
143
  key: 0,
143
144
  class: "o-loading",
144
- style: u({ color: e.color })
145
+ style: f({ color: e.color })
145
146
  }, [
146
- (a(), c("svg", {
147
- width: n.value,
148
- height: n.value,
147
+ (l(), d("svg", {
148
+ width: o.value,
149
+ height: o.value,
149
150
  viewBox: "0 0 24 24",
150
151
  fill: "none",
151
152
  xmlns: "http://www.w3.org/2000/svg"
152
- }, [...r[0] || (r[0] = [
153
- d("circle", {
153
+ }, [...t[0] || (t[0] = [
154
+ u("circle", {
154
155
  cx: "12",
155
156
  cy: "12",
156
157
  r: "10",
@@ -161,16 +162,16 @@ const x = ["disabled", "type"], S = {
161
162
  "stroke-dashoffset": "20",
162
163
  opacity: "0.25"
163
164
  }, null, -1),
164
- d("path", {
165
+ u("path", {
165
166
  d: "M12 2C6.477 2 2 6.477 2 12",
166
167
  stroke: "currentColor",
167
168
  "stroke-width": "4",
168
169
  "stroke-linecap": "round"
169
170
  }, null, -1)
170
- ])], 8, M))
171
- ], 4)) : p("", !0);
171
+ ])], 8, Z))
172
+ ], 4)) : y("", !0);
172
173
  }
173
- }, E = ["innerHTML"], N = {
174
+ }, te = ["innerHTML"], ne = {
174
175
  __name: "OIcon",
175
176
  props: {
176
177
  /**
@@ -196,33 +197,186 @@ const x = ["disabled", "type"], S = {
196
197
  }
197
198
  },
198
199
  setup(e) {
199
- const o = e, t = i(
200
- () => typeof o.size == "number" ? `${o.size}px` : o.size
201
- ), n = w("oIcons", void 0), s = i(() => n ? n(o.name) : "");
202
- return (r, l) => (a(), c("span", {
200
+ const i = e, n = p(
201
+ () => typeof i.size == "number" ? `${i.size}px` : i.size
202
+ ), o = j("oIcons", void 0), c = p(() => o ? o(i.name) : "");
203
+ return (t, r) => (l(), d("span", {
203
204
  class: "o-icon",
204
- style: u({
205
- width: t.value,
206
- height: t.value,
205
+ style: f({
206
+ width: n.value,
207
+ height: n.value,
207
208
  color: e.color
208
209
  }),
209
- innerHTML: s.value
210
- }, null, 12, E));
210
+ innerHTML: c.value
211
+ }, null, 12, te));
212
+ }
213
+ }, oe = ["disabled"], se = {
214
+ key: 0,
215
+ class: "o-vechain-login__text"
216
+ }, ie = {
217
+ key: 1,
218
+ class: "o-vechain-login__text"
219
+ }, ae = {
220
+ key: 2,
221
+ class: "o-vechain-login__text"
222
+ }, ce = {
223
+ key: 3,
224
+ class: "o-vechain-login__disconnect-icon"
225
+ }, le = {
226
+ __name: "OVeChainLogin",
227
+ props: {
228
+ /**
229
+ * Variante visual del botón
230
+ * @values 'primary', 'secondary', 'ghost'
231
+ */
232
+ variant: {
233
+ type: String,
234
+ default: "primary",
235
+ validator: (e) => ["primary", "secondary", "ghost"].includes(e)
236
+ },
237
+ /**
238
+ * Tamaño del botón
239
+ * @values 'sm', 'md', 'lg'
240
+ */
241
+ size: {
242
+ type: String,
243
+ default: "md",
244
+ validator: (e) => ["sm", "md", "lg"].includes(e)
245
+ },
246
+ /**
247
+ * Nodo VeChain a utilizar
248
+ * @values 'mainnet', 'testnet'
249
+ */
250
+ network: {
251
+ type: String,
252
+ default: "mainnet",
253
+ validator: (e) => ["mainnet", "testnet"].includes(e)
254
+ }
255
+ },
256
+ emits: [
257
+ /** Se emite cuando se conecta una wallet */
258
+ "connected",
259
+ /** Se emite cuando se desconecta la wallet */
260
+ "disconnected",
261
+ /** Se emite cuando hay un error de conexión */
262
+ "error"
263
+ ],
264
+ setup(e, { emit: i }) {
265
+ const n = e, o = i, c = O(null), t = O(null), {
266
+ address: r,
267
+ isConnected: m,
268
+ isConnecting: h,
269
+ setAddress: $,
270
+ clearWallet: k,
271
+ setError: g,
272
+ startConnecting: B,
273
+ stopConnecting: _,
274
+ shortenAddress: M
275
+ } = F(), C = {
276
+ mainnet: "https://mainnet.vechain.org",
277
+ testnet: "https://testnet.vechain.org"
278
+ }, A = async () => {
279
+ try {
280
+ const { DAppKit: s } = await import("./index-Bywq0IP9.js").then((a) => a.A);
281
+ t.value || (t.value = document.createElement("vdk-button"), t.value.setAttribute("node-url", C[n.network]), document.addEventListener("vdk-connected", w), document.addEventListener("vdk-disconnected", b), t.value.style.display = "none", document.body.appendChild(t.value));
282
+ } catch (s) {
283
+ console.error("Error initializing VeChain DApp Kit:", s), g(s.message), o("error", s.message);
284
+ }
285
+ }, w = (s) => {
286
+ var z;
287
+ const a = (z = s.detail) == null ? void 0 : z.address;
288
+ a && ($(a), o("connected", a)), _();
289
+ }, b = () => {
290
+ k(), o("disconnected");
291
+ }, I = async () => {
292
+ var s;
293
+ if (m.value) {
294
+ V();
295
+ return;
296
+ }
297
+ B();
298
+ try {
299
+ t.value ? t.value.click() : (s = c.value) == null || s.click();
300
+ } catch (a) {
301
+ g(a.message), o("error", a.message), _();
302
+ }
303
+ }, V = () => {
304
+ try {
305
+ if (t.value) {
306
+ const s = new CustomEvent("vdk-disconnect");
307
+ document.dispatchEvent(s);
308
+ }
309
+ k(), o("disconnected");
310
+ } catch (s) {
311
+ g(s.message), o("error", s.message);
312
+ }
313
+ }, N = p(() => [
314
+ "o-vechain-login",
315
+ `o-vechain-login--${n.variant}`,
316
+ `o-vechain-login--${n.size}`,
317
+ {
318
+ "o-vechain-login--connected": m.value,
319
+ "o-vechain-login--loading": h.value
320
+ }
321
+ ]);
322
+ return E(() => {
323
+ A();
324
+ }), L(() => {
325
+ document.removeEventListener("vdk-connected", w), document.removeEventListener("vdk-disconnected", b), t.value && t.value.parentNode && t.value.parentNode.removeChild(t.value);
326
+ }), U(() => n.network, () => {
327
+ t.value && t.value.setAttribute("node-url", C[n.network]);
328
+ }), (s, a) => (l(), d("button", {
329
+ ref_key: "walletButtonRef",
330
+ ref: c,
331
+ class: x(N.value),
332
+ disabled: v(h),
333
+ type: "button",
334
+ onClick: I
335
+ }, [
336
+ a[1] || (a[1] = u("span", { class: "o-vechain-login__icon" }, [
337
+ u("svg", {
338
+ viewBox: "0 0 24 24",
339
+ fill: "currentColor",
340
+ width: "1em",
341
+ height: "1em"
342
+ }, [
343
+ u("path", { d: "M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" })
344
+ ])
345
+ ], -1)),
346
+ v(h) ? (l(), d("span", se, " Connecting... ")) : v(m) ? (l(), d("span", ie, q(v(M)(v(r))), 1)) : (l(), d("span", ae, " Connect Wallet ")),
347
+ v(m) ? (l(), d("span", ce, [...a[0] || (a[0] = [
348
+ u("svg", {
349
+ viewBox: "0 0 24 24",
350
+ fill: "none",
351
+ stroke: "currentColor",
352
+ width: "1em",
353
+ height: "1em"
354
+ }, [
355
+ u("path", {
356
+ "stroke-linecap": "round",
357
+ "stroke-linejoin": "round",
358
+ "stroke-width": "2",
359
+ d: "M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
360
+ })
361
+ ], -1)
362
+ ])])) : y("", !0)
363
+ ], 10, oe));
211
364
  }
212
- }, V = {
365
+ }, ue = {
213
366
  /**
214
367
  * Instala el plugin en la aplicación Vue
215
368
  *
216
369
  * @param {import('vue').App} app - Instancia de la aplicación
217
370
  */
218
371
  install(e) {
219
- e.component("OButton", S), e.component("OModal", I), e.component("OLoading", L), e.component("OIcon", N);
372
+ e.component("OButton", J), e.component("OModal", Y), e.component("OLoading", ee), e.component("OIcon", ne), e.component("OVeChainLogin", le);
220
373
  }
221
374
  };
222
375
  export {
223
- S as OButton,
224
- N as OIcon,
225
- L as OLoading,
226
- I as OModal,
227
- V as default
376
+ J as OButton,
377
+ ne as OIcon,
378
+ ee as OLoading,
379
+ Y as OModal,
380
+ le as OVeChainLogin,
381
+ ue as default
228
382
  };