@myrasec/eu-captcha-vue 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -25,6 +25,20 @@ You can test the integration using any fake sitekey. If a sitekey
25
25
  does not exist, then the captcha runs with default parameters which
26
26
  allow traffic to pass.
27
27
 
28
+ You can also set additional properties: theme, width
29
+
30
+ To switch between light/dark theme:
31
+
32
+ ```
33
+ <EuCaptcha sitekey={captchaSitekey} theme="dark" />
34
+ ```
35
+
36
+ To define the width of the widget (default is 330). Please specify a number.
37
+
38
+ ```
39
+ <EuCaptcha sitekey={captchaSitekey} width=280 />
40
+ ```
41
+
28
42
  ## Querying state
29
43
 
30
44
  Before submitting a form to a server, please ensure that EuCaptcha is done.
@@ -1,70 +1,72 @@
1
- import { ref as d, createElementBlock as f, openBlock as m } from "vue";
2
- let o = {
1
+ import { ref as f, createElementBlock as h, openBlock as m } from "vue";
2
+ let r = {
3
3
  sitekey: "-",
4
4
  locale: "",
5
- theme: "light"
5
+ theme: "light",
6
+ width: 330
6
7
  }, l = {
7
8
  done: !1,
8
9
  registered: !1
9
- }, i = null;
10
- function h(e) {
11
- return typeof window > "u" ? Promise.reject("Cannot load script on server") : i || (i = new Promise((t, r) => {
10
+ }, o = null;
11
+ function y(e) {
12
+ return typeof window > "u" ? Promise.reject("Cannot load script on server") : o || (o = new Promise((t, i) => {
12
13
  if (document.querySelector(`script[src="${e}"]`)) {
13
14
  t();
14
15
  return;
15
16
  }
16
17
  const n = document.createElement("script");
17
- n.src = e, n.async = !0, n.onload = () => t(), n.onerror = () => r(new Error(`Failed to load ${e}`)), document.head.appendChild(n);
18
- }), i);
18
+ n.src = e, n.async = !0, n.onload = () => t(), n.onerror = () => i(new Error(`Failed to load ${e}`)), document.head.appendChild(n);
19
+ }), o);
19
20
  }
20
21
  function p(e) {
21
22
  e.data.type === "euCaptchaCompleted" && (l.done = !0);
22
23
  }
23
- function $() {
24
+ function x() {
24
25
  return l.done;
25
26
  }
26
- function y(e, t) {
27
- e = e || {}, typeof e.sitekey == "string" && (o.sitekey = e.sitekey), typeof e.locale == "string" && (o.locale = e.locale), typeof e.theme == "string" && (o.theme = e.theme), h("https://cdn.eu-captcha.eu/verify.js").then(() => {
27
+ function w(e, t) {
28
+ e = e || {}, typeof e.sitekey == "string" && (r.sitekey = e.sitekey), typeof e.locale == "string" && (r.locale = e.locale), typeof e.theme == "string" && (r.theme = e.theme), typeof e.width == "number" && (r.width = e.width), y("https://cdn.eu-captcha.eu/verify.js").then(() => {
28
29
  l.registered || (l.registered = !0, window.addEventListener("message", p, !1)), t && t();
29
- }).catch((r) => {
30
- console.error("error during load of eu captcha library: " + r);
30
+ }).catch((i) => {
31
+ console.error("error during load of eu captcha library: " + i);
31
32
  });
32
33
  }
33
- let c = null, s = null;
34
- const u = d("");
34
+ let c = null, d = null, s = null;
35
+ const u = f("");
35
36
  function g() {
36
37
  u.value = window.getEuCaptchaElement(
37
- c ?? o.sitekey,
38
- s ?? o.theme
38
+ c ?? r.sitekey,
39
+ d ?? r.theme,
40
+ s ?? r.width
39
41
  );
40
42
  }
41
43
  const k = {
42
- props: ["sitekey", "theme"],
44
+ props: ["sitekey", "theme", "width"],
43
45
  setup(e) {
44
- e.sitekey && (c = e.sitekey), e.theme && (s = e.theme);
46
+ e.sitekey && (c = e.sitekey), e.theme && (d = e.theme), e.width && (s = e.width);
45
47
  },
46
48
  data() {
47
- return y(null, g), {
49
+ return w(null, g), {
48
50
  htmlContent: u
49
51
  };
50
52
  }
51
53
  }, _ = (e, t) => {
52
- const r = e.__vccOpts || e;
54
+ const i = e.__vccOpts || e;
53
55
  for (const [n, a] of t)
54
- r[n] = a;
55
- return r;
56
+ i[n] = a;
57
+ return i;
56
58
  }, C = ["innerHTML"];
57
- function E(e, t, r, n, a, v) {
58
- return m(), f("div", { innerHTML: a.htmlContent }, null, 8, C);
59
+ function E(e, t, i, n, a, b) {
60
+ return m(), h("div", { innerHTML: a.htmlContent }, null, 8, C);
59
61
  }
60
- const w = /* @__PURE__ */ _(k, [["render", E]]), x = {
62
+ const v = /* @__PURE__ */ _(k, [["render", E]]), L = {
61
63
  install: (e) => {
62
- e.component("b-upload-files-modal", w);
64
+ e.component("b-upload-files-modal", v);
63
65
  }
64
66
  };
65
67
  export {
66
- w as EuCaptcha,
67
- x as default,
68
- $ as isEuCaptchaDone,
69
- y as loadEuCaptcha
68
+ v as EuCaptcha,
69
+ L as default,
70
+ x as isEuCaptchaDone,
71
+ w as loadEuCaptcha
70
72
  };
@@ -1 +1 @@
1
- (function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t["@myra/eu-captcha-vue"]={},t.Vue))})(this,(function(t,o){"use strict";let a={sitekey:"-",locale:"",theme:"light"},c={done:!1,registered:!1},l=null;function p(e){return typeof window>"u"?Promise.reject("Cannot load script on server"):l||(l=new Promise((n,r)=>{if(document.querySelector(`script[src="${e}"]`)){n();return}const i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>n(),i.onerror=()=>r(new Error(`Failed to load ${e}`)),document.head.appendChild(i)}),l)}function y(e){e.data.type==="euCaptchaCompleted"&&(c.done=!0)}function g(){return c.done}function s(e,n){e=e||{},typeof e.sitekey=="string"&&(a.sitekey=e.sitekey),typeof e.locale=="string"&&(a.locale=e.locale),typeof e.theme=="string"&&(a.theme=e.theme),p("https://cdn.eu-captcha.eu/verify.js").then(()=>{c.registered||(c.registered=!0,window.addEventListener("message",y,!1)),n&&n()}).catch(r=>{console.error("error during load of eu captcha library: "+r)})}let d=null,f=null;const h=o.ref("");function _(){h.value=window.getEuCaptchaElement(d??a.sitekey,f??a.theme)}const C={props:["sitekey","theme"],setup(e){e.sitekey&&(d=e.sitekey),e.theme&&(f=e.theme)},data(){return s(null,_),{htmlContent:h}}},E=(e,n)=>{const r=e.__vccOpts||e;for(const[i,u]of n)r[i]=u;return r},k=["innerHTML"];function v(e,n,r,i,u,b){return o.openBlock(),o.createElementBlock("div",{innerHTML:u.htmlContent},null,8,k)}const m=E(C,[["render",v]]),w={install:e=>{e.component("b-upload-files-modal",m)}};t.EuCaptcha=m,t.default=w,t.isEuCaptchaDone=g,t.loadEuCaptcha=s,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(t=typeof globalThis<"u"?globalThis:t||self,r(t["@myra/eu-captcha-vue"]={},t.Vue))})(this,(function(t,r){"use strict";let o={sitekey:"-",locale:"",theme:"light",width:330},a={done:!1,registered:!1},c=null;function y(e){return typeof window>"u"?Promise.reject("Cannot load script on server"):c||(c=new Promise((n,l)=>{if(document.querySelector(`script[src="${e}"]`)){n();return}const i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>n(),i.onerror=()=>l(new Error(`Failed to load ${e}`)),document.head.appendChild(i)}),c)}function w(e){e.data.type==="euCaptchaCompleted"&&(a.done=!0)}function g(){return a.done}function d(e,n){e=e||{},typeof e.sitekey=="string"&&(o.sitekey=e.sitekey),typeof e.locale=="string"&&(o.locale=e.locale),typeof e.theme=="string"&&(o.theme=e.theme),typeof e.width=="number"&&(o.width=e.width),y("https://cdn.eu-captcha.eu/verify.js").then(()=>{a.registered||(a.registered=!0,window.addEventListener("message",w,!1)),n&&n()}).catch(l=>{console.error("error during load of eu captcha library: "+l)})}let s=null,f=null,h=null;const m=r.ref("");function _(){m.value=window.getEuCaptchaElement(s??o.sitekey,f??o.theme,h??o.width)}const C={props:["sitekey","theme","width"],setup(e){e.sitekey&&(s=e.sitekey),e.theme&&(f=e.theme),e.width&&(h=e.width)},data(){return d(null,_),{htmlContent:m}}},E=(e,n)=>{const l=e.__vccOpts||e;for(const[i,u]of n)l[i]=u;return l},k=["innerHTML"];function v(e,n,l,i,u,M){return r.openBlock(),r.createElementBlock("div",{innerHTML:u.htmlContent},null,8,k)}const p=E(C,[["render",v]]),b={install:e=>{e.component("b-upload-files-modal",p)}};t.EuCaptcha=p,t.default=b,t.isEuCaptchaDone=g,t.loadEuCaptcha=d,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrasec/eu-captcha-vue",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/eu-captcha-vue.umd.cjs",
package/publish.sh ADDED
@@ -0,0 +1,5 @@
1
+ #! /bin/sh
2
+
3
+ npm run build || exit 1
4
+
5
+ npm publish --public