@withone/connect 0.9.0 → 0.10.0
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 +2 -4
- package/dist/button.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/types.d.ts +2 -4
- package/dist/vue.cjs.js +1 -1
- package/dist/vue.d.ts +0 -9
- package/dist/vue.esm.js +1 -1
- package/dist/wrapper-options.d.ts +0 -1
- package/package.json +1 -1
- package/src/button.ts +13 -14
- package/src/types.ts +3 -6
- package/src/vue.ts +0 -1
- package/src/wrapper-options.ts +0 -3
package/README.md
CHANGED
|
@@ -87,7 +87,6 @@ import { ConnectButton } from "@withone/connect/react";
|
|
|
87
87
|
<ConnectButton
|
|
88
88
|
authorizeUrl="/api/one/authorize"
|
|
89
89
|
platforms={["stripe", "google-calendar", "gmail"]}
|
|
90
|
-
moreCount={274}
|
|
91
90
|
onSuccess={() => refreshAppState()}
|
|
92
91
|
onError={(message) => showBanner(message)}
|
|
93
92
|
/>
|
|
@@ -113,7 +112,7 @@ import { ConnectButton } from "@withone/connect/vue";
|
|
|
113
112
|
|
|
114
113
|
```html
|
|
115
114
|
<!-- Plain HTML or any other framework: importing the package registers the element -->
|
|
116
|
-
<one-connect-button authorize-url="/api/one/authorize" platforms="stripe, notion"
|
|
115
|
+
<one-connect-button authorize-url="/api/one/authorize" platforms="stripe, notion"></one-connect-button>
|
|
117
116
|
<script type="module">
|
|
118
117
|
import "@withone/connect";
|
|
119
118
|
document.querySelector("one-connect-button").addEventListener("success", () => location.reload());
|
|
@@ -123,8 +122,7 @@ import { ConnectButton } from "@withone/connect/vue";
|
|
|
123
122
|
| Prop (attribute) | What it does |
|
|
124
123
|
|---|---|
|
|
125
124
|
| `authorizeUrl` (`authorize-url`) | Your authorize route. Relative paths resolve against the page. Required. |
|
|
126
|
-
| `platforms` | Connector slugs: `["stripe", "google-calendar"]`. Logos and names come from One. To override either, pass `{ slug, name, imageUrl }`. As an attribute: `"stripe, notion"`. |
|
|
127
|
-
| `moreCount` (`more-count`) | The `+N` chip after the first three logos |
|
|
125
|
+
| `platforms` | Connector slugs: `["stripe", "google-calendar"]`. Logos and names come from One. To override either, pass `{ slug, name, imageUrl }`. As an attribute: `"stripe, notion"`. The first three render as logos; anything beyond them becomes a `+N` chip. |
|
|
128
126
|
| `label` | Button text. Default "Connect your apps". |
|
|
129
127
|
| `connectedLabel` (`connected-label`) | Text after a successful return. Default "Connected". |
|
|
130
128
|
| `variant` | `default` pill · `accent` brand-colored pill · `block` card with a description |
|
package/dist/button.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const mountConnectButton: (container: HTMLElement, options: Conne
|
|
|
8
8
|
* HTMLElement.
|
|
9
9
|
*
|
|
10
10
|
* Attributes: authorize-url (required), app-theme, label, variant,
|
|
11
|
-
* theme, platforms ("stripe, notion" or a JSON array),
|
|
11
|
+
* theme, platforms ("stripe, notion" or a JSON array),
|
|
12
12
|
* description, accent-color, connected-label.
|
|
13
13
|
* Events: "success" and "error" (detail: message), plus the matching
|
|
14
14
|
* onSuccess and onError function properties that React 19, Vue and
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e="one_connect",t="one_connect_message";let n=!1;const o=o=>{if("undefined"!=typeof window&&!n){const r=function(n){var o;const r=new URLSearchParams(n),i=r.get(e);if("success"!==i&&"error"!==i)return null;const c=null!==(o=r.get(t))&&void 0!==o?o:void 0;return c?{status:i,message:c}:{status:i}}(window.location.search);if(r){n=!0;const i=()=>{(function(n){const o=new URLSearchParams(n);return o.has(e)||o.has(t)})(window.location.search)&&window.history.replaceState(null,"",function(n){const o=new URLSearchParams(n.search);o.delete(e),o.delete(t);const r=o.toString();return`${n.pathname}${r?`?${r}`:""}${n.hash}`}(window.location))};i();for(const e of[50,500,2e3])window.setTimeout(i,e);window.setTimeout(()=>{try{var e,t,n;"success"===r.status?null===(e=o.onSuccess)||void 0===e||e.call(o):null===(t=o.onError)||void 0===t||t.call(o,null!==(n=r.message)&&void 0!==n?n:"The connection was not completed.")}catch{}},0)}}return{open:()=>{"undefined"!=typeof window&&window.location.assign((()=>{try{const e=new URL(o.authorizeUrl,"undefined"==typeof window?void 0:window.location.origin);return o.appTheme&&(e.hash=`one_theme=${o.appTheme}`),e.toString()}catch{return o.authorizeUrl}})())}}};function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function c(e){return e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function l(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function a(e){var t,n,o,r;const a="string"==typeof e?{slug:e}:e,s=null!==(t=a.slug)&&void 0!==t&&t.trim()?i(a.slug):null!==(n=a.name)&&void 0!==n&&n.trim()?i(a.name):"";return s?{slug:s,name:(null===(o=a.name)||void 0===o?void 0:o.trim())||c(s),imageUrl:(null===(r=a.imageUrl)||void 0===r?void 0:r.trim())||l(s)}:null}function s(e){return(null!=e?e:[]).map(a).filter(e=>null!==e)}function d(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const p="one-connect-button-styles",u="cubic-bezier(.2,.9,.25,1)",m="#CCFF00",h="#3FE3A5",b="#0A0C0B",f={buttonBackground:b,buttonForeground:"#FFFFFF",surface:"#FFFFFF",foreground:b,muted:"#6B7280",line:"#D1D5DB",shadow:"0 1px 2px rgba(10,12,11,.08), 0 4px 14px rgba(10,12,11,.06)"},w={buttonBackground:"#F2F5F3",buttonForeground:b,surface:"#101312",foreground:"#F2F5F3",muted:"#8A938E",line:"#2A302D",shadow:"0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35)"};const g=(e,t)=>{var n,r,i;!function(){if("undefined"==typeof document||document.getElementById(p))return;const e=document.createElement("style");e.id=p,e.textContent=[`.owcb{font:500 14.5px/1.2 inherit;font-family:inherit;letter-spacing:-.01em;cursor:pointer;border:0;display:inline-flex;align-items:center;gap:12px;padding:12px 16px 12px 14px;border-radius:12px;transition:transform .2s ${u},box-shadow .2s ${u},opacity .2s ${u}}`,".owcb:hover{transform:translateY(-1px)}",".owcb:active{transform:translateY(0)}",`.owcb:focus-visible{outline:2px solid ${h};outline-offset:3px}`,".owcb[disabled]{cursor:default;opacity:.75;transform:none}",".owcb-stack{display:inline-flex;align-items:center;flex-shrink:0}",`.owcb-chip{width:22px;height:22px;border-radius:6px;display:grid;place-items:center;overflow:hidden;margin-left:-7px;transition:margin-left .28s ${u};position:relative;background:#FFFFFF}`,".owcb-chip:first-child{margin-left:0}",".owcb-chip img{width:14px;height:14px;display:block;object-fit:contain}",`.owcb-chip.owcb-more{font-family:ui-monospace,monospace;font-size:9px;font-weight:500;letter-spacing:-.02em;color:${b}}`,`.owcb-chip.owcb-letter{font:600 10px ui-monospace,monospace;color:${b}}`,".owcb:hover .owcb-chip{margin-left:-2px}",".owcb:hover .owcb-chip:first-child{margin-left:0}",".owcb-label{white-space:nowrap}",`.owcb-arrow{opacity:.5;transition:transform .2s ${u},opacity .2s ${u}}`,".owcb:hover .owcb-arrow{transform:translateX(2px);opacity:.8}",".owcb-spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;opacity:.7;animation:owcb-spin .7s linear infinite}","@keyframes owcb-spin{to{transform:rotate(360deg)}}",".owcb.owcb-block{display:flex;flex-direction:column;align-items:stretch;width:100%;max-width:420px;text-align:left;padding:16px;border-radius:14px;gap:0}",".owcb-block-top{display:flex;align-items:center;justify-content:space-between;gap:12px}",".owcb-block-title{font-size:15px;font-weight:600;letter-spacing:-.01em}",".owcb-block-sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400}",".owcb-block-foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:400}","@media (prefers-reduced-motion:reduce){.owcb,.owcb-chip,.owcb-arrow{transition:none}.owcb-spinner{animation-duration:1.4s}}"].join("\n"),document.head.appendChild(e)}();const c="dark"===t.theme?w:f,l=null!==(n=t.variant)&&void 0!==n?n:"default",a=null!==(r=t.label)&&void 0!==r?r:"Connect your apps",d=null!==(i=t.connectedLabel)&&void 0!==i?i:"Connected";let g="idle",v=!1;const x=o({...t.connect,onSuccess:()=>{var e,n;E("connected"),null===(e=(n=t.connect).onSuccess)||void 0===e||e.call(n)},onError:e=>{var n,o;E("idle"),null===(n=(o=t.connect).onError)||void 0===n||n.call(o,e)}}),y=document.createElement("button");y.type="button",y.className="block"===l?"owcb owcb-block":"owcb",y.addEventListener("click",()=>{"connecting"!==g&&(E("connecting"),x.open())});const C=()=>"connecting"===g?"Connecting…":"connected"===g?d:a,k=()=>{var e,n;const o="accent"===l,r="block"===l,i=r?c.surface:o?null!==(e=t.accentColor)&&void 0!==e?e:m:c.buttonBackground,a=r?c.foreground:o?b:c.buttonForeground,d=r?c.surface:i;y.style.background="connected"!==g||r?i:h,y.style.color="connected"!==g||r?a:b,y.style.boxShadow=r?`inset 0 0 0 1px ${c.line}`:"connected"===g?"none":o?`0 1px 2px rgba(10,12,11,.1), 0 6px 20px ${null!==(n=t.accentColor)&&void 0!==n?n:m}38`:c.shadow,y.disabled="connecting"===g,y.innerHTML="";const p=function(e,t){var n;const o=s(e.platforms);if(0===o.length&&!e.moreCount)return null;const r=document.createElement("span");r.className="owcb-stack",r.setAttribute("aria-hidden","true");for(const e of o.slice(0,3)){const n=document.createElement("span");n.className="owcb-chip",n.title=e.name,n.style.boxShadow=`0 0 0 1.5px ${t}`;const o=document.createElement("img");o.alt="",o.src=e.imageUrl,o.addEventListener("error",()=>{o.remove(),n.classList.add("owcb-letter"),n.textContent=e.name.charAt(0).toUpperCase()}),n.appendChild(o),r.appendChild(n)}const i=(null!==(n=e.moreCount)&&void 0!==n?n:0)+Math.max(0,o.length-3);if(i>0){const e=document.createElement("span");e.className="owcb-chip owcb-more",e.style.boxShadow=`0 0 0 1.5px ${t}`,e.textContent=`+${i}`,r.appendChild(e)}return r}(t,d);if(r){const e=document.createElement("span");e.className="owcb-block-top";const n=document.createElement("span");if(n.className="owcb-block-title",n.textContent=C(),e.appendChild(n),"connecting"===g){const t=document.createElement("span");t.className="owcb-spinner",e.appendChild(t)}else p&&e.appendChild(p);if(y.appendChild(e),t.description&&"idle"===g){const e=document.createElement("span");e.className="owcb-block-sub",e.style.color=c.muted,e.textContent=t.description,y.appendChild(e)}const o=document.createElement("span");return o.className="owcb-block-foot",o.style.color=c.muted,o.style.borderTop=`1px solid ${c.line}`,o.innerHTML=`<span style="font-size:11px;color:${c.muted}">Secured by</span><span style="display:inline-flex;color:${c.foreground}"><svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.4" style="flex-shrink:0"><circle cx="12" cy="12" r="8.5"/></svg></span><span style="font-size:12px;font-weight:600;letter-spacing:-0.02em;color:${c.foreground}">one</span>`,void y.appendChild(o)}if("connecting"===g){const e=document.createElement("span");e.className="owcb-spinner",y.appendChild(e)}else if("connected"===g){const e=document.createElement("span");e.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px"><path d="M3 8.5l3.5 3.5L13 5"/></svg>',e.style.display="inline-flex",y.appendChild(e)}else p&&y.appendChild(p);const u=document.createElement("span");if(u.className="owcb-label",u.textContent=C(),y.appendChild(u),"idle"===g){const e=document.createElement("span");e.innerHTML='<svg class="owcb-arrow" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3l5 5-5 5"/></svg>',e.style.display="inline-flex",y.appendChild(e)}},E=e=>{v||(g=e,k())};return k(),e.appendChild(y),{setState:E,destroy:()=>{v=!0,y.remove()}}};function v(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),r(this,"onSuccess",null),r(this,"onError",null),r(this,"handle",null)}connectedCallback(){this.mount()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.handle&&this.mount()}mount(){var e,t,n,o,r;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null;const i=this.getAttribute("authorize-url");if(!i)return;const c=this.getAttribute("more-count"),l=c?parseInt(c,10):NaN;this.handle=g(this,{connect:{authorizeUrl:i,appTheme:x(this,"app-theme",["light","dark"]),onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:e=>{var t;null===(t=this.onError)||void 0===t||t.call(this,e),this.dispatchEvent(new CustomEvent("error",{detail:e}))}},label:null!==(t=this.getAttribute("label"))&&void 0!==t?t:void 0,variant:x(this,"variant",["default","accent","block"]),theme:x(this,"theme",["light","dark"]),platforms:d(this.getAttribute("platforms")),moreCount:Number.isFinite(l)?l:void 0,description:null!==(n=this.getAttribute("description"))&&void 0!==n?n:void 0,accentColor:null!==(o=this.getAttribute("accent-color"))&&void 0!==o?o:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0})}}r(e,"observedAttributes",["authorize-url","app-theme","label","variant","theme","platforms","more-count","description","accent-color","connected-label"]),customElements.define("one-connect-button",e)}}function x(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}v(),exports.mountConnectButton=g,exports.normalizePlatform=a,exports.normalizePlatforms=s,exports.optionsFromProps=function(e,t=e){return{connect:{authorizeUrl:e.authorizeUrl,appTheme:e.appTheme,onSuccess:()=>{var e;return null===(e=t.onSuccess)||void 0===e?void 0:e.call(t)},onError:e=>{var n;return null===(n=t.onError)||void 0===n?void 0:n.call(t,e)}},label:e.label,variant:e.variant,theme:e.theme,platforms:e.platforms,moreCount:e.moreCount,description:e.description,accentColor:e.accentColor,connectedLabel:e.connectedLabel}},exports.parsePlatformsAttribute=d,exports.propsIdentity=function(e){var t;return JSON.stringify([e.authorizeUrl,e.appTheme,e.label,e.variant,e.theme,null!==(t=e.platforms)&&void 0!==t?t:[],e.moreCount,e.description,e.accentColor,e.connectedLabel])},exports.registerConnectButton=v,exports.useOneConnect=o;
|
|
1
|
+
"use strict";const e="one_connect",t="one_connect_message";let n=!1;const o=o=>{if("undefined"!=typeof window&&!n){const r=function(n){var o;const r=new URLSearchParams(n),i=r.get(e);if("success"!==i&&"error"!==i)return null;const c=null!==(o=r.get(t))&&void 0!==o?o:void 0;return c?{status:i,message:c}:{status:i}}(window.location.search);if(r){n=!0;const i=()=>{(function(n){const o=new URLSearchParams(n);return o.has(e)||o.has(t)})(window.location.search)&&window.history.replaceState(null,"",function(n){const o=new URLSearchParams(n.search);o.delete(e),o.delete(t);const r=o.toString();return`${n.pathname}${r?`?${r}`:""}${n.hash}`}(window.location))};i();for(const e of[50,500,2e3])window.setTimeout(i,e);window.setTimeout(()=>{try{var e,t,n;"success"===r.status?null===(e=o.onSuccess)||void 0===e||e.call(o):null===(t=o.onError)||void 0===t||t.call(o,null!==(n=r.message)&&void 0!==n?n:"The connection was not completed.")}catch{}},0)}}return{open:()=>{"undefined"!=typeof window&&window.location.assign((()=>{try{const e=new URL(o.authorizeUrl,"undefined"==typeof window?void 0:window.location.origin);return o.appTheme&&(e.hash=`one_theme=${o.appTheme}`),e.toString()}catch{return o.authorizeUrl}})())}}};function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function c(e){return e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function l(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function a(e){var t,n,o,r;const a="string"==typeof e?{slug:e}:e,s=null!==(t=a.slug)&&void 0!==t&&t.trim()?i(a.slug):null!==(n=a.name)&&void 0!==n&&n.trim()?i(a.name):"";return s?{slug:s,name:(null===(o=a.name)||void 0===o?void 0:o.trim())||c(s),imageUrl:(null===(r=a.imageUrl)||void 0===r?void 0:r.trim())||l(s)}:null}function s(e){return(null!=e?e:[]).map(a).filter(e=>null!==e)}function d(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const p="one-connect-button-styles",u="cubic-bezier(.2,.9,.25,1)",C="#CCFF00",h="#3FE3A5",m="#0A0C0B",f={buttonBackground:m,buttonForeground:"#FFFFFF",surface:"#FFFFFF",foreground:m,muted:"#6B7280",line:"#D1D5DB",shadow:"0 1px 2px rgba(10,12,11,.08), 0 4px 14px rgba(10,12,11,.06)"},b={buttonBackground:"#F2F5F3",buttonForeground:m,surface:"#101312",foreground:"#F2F5F3",muted:"#8A938E",line:"#2A302D",shadow:"0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35)"};const w=(e,t)=>{var n,r,i;!function(){if("undefined"==typeof document||document.getElementById(p))return;const e=document.createElement("style");e.id=p,e.textContent=[`.owcb{font:500 14.5px/1.2 inherit;font-family:inherit;letter-spacing:-.01em;cursor:pointer;border:0;display:inline-flex;align-items:center;gap:12px;padding:12px 16px 12px 14px;border-radius:12px;transition:transform .2s ${u},box-shadow .2s ${u},opacity .2s ${u}}`,".owcb:hover{transform:translateY(-1px)}",".owcb:active{transform:translateY(0)}",`.owcb:focus-visible{outline:2px solid ${h};outline-offset:3px}`,".owcb[disabled]{cursor:default;opacity:.75;transform:none}",".owcb-stack{display:inline-flex;align-items:center;flex-shrink:0}",`.owcb-chip{width:22px;height:22px;border-radius:6px;display:grid;place-items:center;overflow:hidden;margin-left:-7px;transition:margin-left .28s ${u};position:relative;background:#FFFFFF}`,".owcb-chip:first-child{margin-left:0}",".owcb-chip img{width:14px;height:14px;display:block;object-fit:contain}",`.owcb-chip.owcb-more{font-family:ui-monospace,monospace;font-size:9px;font-weight:500;letter-spacing:-.02em;color:${m}}`,`.owcb-chip.owcb-letter{font:600 10px ui-monospace,monospace;color:${m}}`,".owcb:hover .owcb-chip{margin-left:-2px}",".owcb:hover .owcb-chip:first-child{margin-left:0}",".owcb-label{white-space:nowrap}",`.owcb-arrow{opacity:.5;transition:transform .2s ${u},opacity .2s ${u}}`,".owcb:hover .owcb-arrow{transform:translateX(2px);opacity:.8}",".owcb-spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;opacity:.7;animation:owcb-spin .7s linear infinite}","@keyframes owcb-spin{to{transform:rotate(360deg)}}",".owcb.owcb-block{display:flex;flex-direction:column;align-items:stretch;width:100%;max-width:420px;text-align:left;padding:16px;border-radius:14px;gap:0}",".owcb-block-top{display:flex;align-items:center;justify-content:space-between;gap:12px}",".owcb-block-title{font-size:15px;font-weight:600;letter-spacing:-.01em}",".owcb-block-sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400}",".owcb-block-foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:400}","@media (prefers-reduced-motion:reduce){.owcb,.owcb-chip,.owcb-arrow{transition:none}.owcb-spinner{animation-duration:1.4s}}"].join("\n"),document.head.appendChild(e)}();const c="dark"===t.theme?b:f,l=null!==(n=t.variant)&&void 0!==n?n:"default",a=null!==(r=t.label)&&void 0!==r?r:"Connect your apps",d=null!==(i=t.connectedLabel)&&void 0!==i?i:"Connected";let w="idle",g=!1;const v=o({...t.connect,onSuccess:()=>{var e,n;E("connected"),null===(e=(n=t.connect).onSuccess)||void 0===e||e.call(n)},onError:e=>{var n,o;E("idle"),null===(n=(o=t.connect).onError)||void 0===n||n.call(o,e)}}),x=document.createElement("button");x.type="button",x.className="block"===l?"owcb owcb-block":"owcb",x.addEventListener("click",()=>{"connecting"!==w&&(E("connecting"),v.open())});const y=()=>"connecting"===w?"Connecting…":"connected"===w?d:a,k=()=>{var e,n;const o="accent"===l,r="block"===l,i=r?c.surface:o?null!==(e=t.accentColor)&&void 0!==e?e:C:c.buttonBackground,a=r?c.foreground:o?m:c.buttonForeground,d=r?c.surface:i;x.style.background="connected"!==w||r?i:h,x.style.color="connected"!==w||r?a:m,x.style.boxShadow=r?`inset 0 0 0 1px ${c.line}`:"connected"===w?"none":o?`0 1px 2px rgba(10,12,11,.1), 0 6px 20px ${null!==(n=t.accentColor)&&void 0!==n?n:C}38`:c.shadow,x.disabled="connecting"===w,x.innerHTML="";const p=function(e,t){const n=s(e.platforms);if(0===n.length)return null;const o=document.createElement("span");o.className="owcb-stack",o.setAttribute("aria-hidden","true");for(const e of n.slice(0,3)){const n=document.createElement("span");n.className="owcb-chip",n.title=e.name,n.style.boxShadow=`0 0 0 1.5px ${t}`;const r=document.createElement("img");r.alt="",r.src=e.imageUrl,r.addEventListener("error",()=>{r.remove(),n.classList.add("owcb-letter"),n.textContent=e.name.charAt(0).toUpperCase()}),n.appendChild(r),o.appendChild(n)}const r=Math.max(0,n.length-3);if(r>0){const e=document.createElement("span");e.className="owcb-chip owcb-more",e.style.boxShadow=`0 0 0 1.5px ${t}`,e.textContent=`+${r}`,o.appendChild(e)}return o}(t,d);if(r){const e=document.createElement("span");e.className="owcb-block-top";const n=document.createElement("span");if(n.className="owcb-block-title",n.textContent=y(),e.appendChild(n),"connecting"===w){const t=document.createElement("span");t.className="owcb-spinner",e.appendChild(t)}else p&&e.appendChild(p);if(x.appendChild(e),t.description&&"idle"===w){const e=document.createElement("span");e.className="owcb-block-sub",e.style.color=c.muted,e.textContent=t.description,x.appendChild(e)}const o=document.createElement("span");return o.className="owcb-block-foot",o.style.color=c.muted,o.style.borderTop=`1px solid ${c.line}`,o.innerHTML=`<span style="font-size:11px;color:${c.muted}">Secured by</span><span style="display:inline-flex;color:${c.foreground}"><svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" style="flex-shrink:0;display:block"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg></span>`,void x.appendChild(o)}if("connecting"===w){const e=document.createElement("span");e.className="owcb-spinner",x.appendChild(e)}else if("connected"===w){const e=document.createElement("span");e.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px"><path d="M3 8.5l3.5 3.5L13 5"/></svg>',e.style.display="inline-flex",x.appendChild(e)}else p&&x.appendChild(p);const u=document.createElement("span");if(u.className="owcb-label",u.textContent=y(),x.appendChild(u),"idle"===w){const e=document.createElement("span");e.innerHTML='<svg class="owcb-arrow" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3l5 5-5 5"/></svg>',e.style.display="inline-flex",x.appendChild(e)}},E=e=>{g||(w=e,k())};return k(),e.appendChild(x),{setState:E,destroy:()=>{g=!0,x.remove()}}};function g(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),r(this,"onSuccess",null),r(this,"onError",null),r(this,"handle",null)}connectedCallback(){this.mount()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.handle&&this.mount()}mount(){var e,t,n,o,r;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null;const i=this.getAttribute("authorize-url");i&&(this.handle=w(this,{connect:{authorizeUrl:i,appTheme:v(this,"app-theme",["light","dark"]),onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:e=>{var t;null===(t=this.onError)||void 0===t||t.call(this,e),this.dispatchEvent(new CustomEvent("error",{detail:e}))}},label:null!==(t=this.getAttribute("label"))&&void 0!==t?t:void 0,variant:v(this,"variant",["default","accent","block"]),theme:v(this,"theme",["light","dark"]),platforms:d(this.getAttribute("platforms")),description:null!==(n=this.getAttribute("description"))&&void 0!==n?n:void 0,accentColor:null!==(o=this.getAttribute("accent-color"))&&void 0!==o?o:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0}))}}r(e,"observedAttributes",["authorize-url","app-theme","label","variant","theme","platforms","description","accent-color","connected-label"]),customElements.define("one-connect-button",e)}}function v(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}g(),exports.mountConnectButton=w,exports.normalizePlatform=a,exports.normalizePlatforms=s,exports.optionsFromProps=function(e,t=e){return{connect:{authorizeUrl:e.authorizeUrl,appTheme:e.appTheme,onSuccess:()=>{var e;return null===(e=t.onSuccess)||void 0===e?void 0:e.call(t)},onError:e=>{var n;return null===(n=t.onError)||void 0===n?void 0:n.call(t,e)}},label:e.label,variant:e.variant,theme:e.theme,platforms:e.platforms,description:e.description,accentColor:e.accentColor,connectedLabel:e.connectedLabel}},exports.parsePlatformsAttribute=d,exports.propsIdentity=function(e){var t;return JSON.stringify([e.authorizeUrl,e.appTheme,e.label,e.variant,e.theme,null!==(t=e.platforms)&&void 0!==t?t:[],e.description,e.accentColor,e.connectedLabel])},exports.registerConnectButton=g,exports.useOneConnect=o;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="one_connect",t="one_connect_message";let n=!1;const o=o=>{if("undefined"!=typeof window&&!n){const r=function(n){var o;const r=new URLSearchParams(n),i=r.get(e);if("success"!==i&&"error"!==i)return null;const c=null!==(o=r.get(t))&&void 0!==o?o:void 0;return c?{status:i,message:c}:{status:i}}(window.location.search);if(r){n=!0;const i=()=>{(function(n){const o=new URLSearchParams(n);return o.has(e)||o.has(t)})(window.location.search)&&window.history.replaceState(null,"",function(n){const o=new URLSearchParams(n.search);o.delete(e),o.delete(t);const r=o.toString();return`${n.pathname}${r?`?${r}`:""}${n.hash}`}(window.location))};i();for(const e of[50,500,2e3])window.setTimeout(i,e);window.setTimeout(()=>{try{var e,t,n;"success"===r.status?null===(e=o.onSuccess)||void 0===e||e.call(o):null===(t=o.onError)||void 0===t||t.call(o,null!==(n=r.message)&&void 0!==n?n:"The connection was not completed.")}catch{}},0)}}return{open:()=>{"undefined"!=typeof window&&window.location.assign((()=>{try{const e=new URL(o.authorizeUrl,"undefined"==typeof window?void 0:window.location.origin);return o.appTheme&&(e.hash=`one_theme=${o.appTheme}`),e.toString()}catch{return o.authorizeUrl}})())}}};function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function c(e){return e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function l(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function a(e){var t,n,o,r;const a="string"==typeof e?{slug:e}:e,s=null!==(t=a.slug)&&void 0!==t&&t.trim()?i(a.slug):null!==(n=a.name)&&void 0!==n&&n.trim()?i(a.name):"";return s?{slug:s,name:(null===(o=a.name)||void 0===o?void 0:o.trim())||c(s),imageUrl:(null===(r=a.imageUrl)||void 0===r?void 0:r.trim())||l(s)}:null}function s(e){return(null!=e?e:[]).map(a).filter(e=>null!==e)}function d(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const u="one-connect-button-styles",p="cubic-bezier(.2,.9,.25,1)",m="#CCFF00",h="#3FE3A5",b="#0A0C0B",f={buttonBackground:b,buttonForeground:"#FFFFFF",surface:"#FFFFFF",foreground:b,muted:"#6B7280",line:"#D1D5DB",shadow:"0 1px 2px rgba(10,12,11,.08), 0 4px 14px rgba(10,12,11,.06)"},w={buttonBackground:"#F2F5F3",buttonForeground:b,surface:"#101312",foreground:"#F2F5F3",muted:"#8A938E",line:"#2A302D",shadow:"0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35)"};const g=(e,t)=>{var n,r,i;!function(){if("undefined"==typeof document||document.getElementById(u))return;const e=document.createElement("style");e.id=u,e.textContent=[`.owcb{font:500 14.5px/1.2 inherit;font-family:inherit;letter-spacing:-.01em;cursor:pointer;border:0;display:inline-flex;align-items:center;gap:12px;padding:12px 16px 12px 14px;border-radius:12px;transition:transform .2s ${p},box-shadow .2s ${p},opacity .2s ${p}}`,".owcb:hover{transform:translateY(-1px)}",".owcb:active{transform:translateY(0)}",`.owcb:focus-visible{outline:2px solid ${h};outline-offset:3px}`,".owcb[disabled]{cursor:default;opacity:.75;transform:none}",".owcb-stack{display:inline-flex;align-items:center;flex-shrink:0}",`.owcb-chip{width:22px;height:22px;border-radius:6px;display:grid;place-items:center;overflow:hidden;margin-left:-7px;transition:margin-left .28s ${p};position:relative;background:#FFFFFF}`,".owcb-chip:first-child{margin-left:0}",".owcb-chip img{width:14px;height:14px;display:block;object-fit:contain}",`.owcb-chip.owcb-more{font-family:ui-monospace,monospace;font-size:9px;font-weight:500;letter-spacing:-.02em;color:${b}}`,`.owcb-chip.owcb-letter{font:600 10px ui-monospace,monospace;color:${b}}`,".owcb:hover .owcb-chip{margin-left:-2px}",".owcb:hover .owcb-chip:first-child{margin-left:0}",".owcb-label{white-space:nowrap}",`.owcb-arrow{opacity:.5;transition:transform .2s ${p},opacity .2s ${p}}`,".owcb:hover .owcb-arrow{transform:translateX(2px);opacity:.8}",".owcb-spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;opacity:.7;animation:owcb-spin .7s linear infinite}","@keyframes owcb-spin{to{transform:rotate(360deg)}}",".owcb.owcb-block{display:flex;flex-direction:column;align-items:stretch;width:100%;max-width:420px;text-align:left;padding:16px;border-radius:14px;gap:0}",".owcb-block-top{display:flex;align-items:center;justify-content:space-between;gap:12px}",".owcb-block-title{font-size:15px;font-weight:600;letter-spacing:-.01em}",".owcb-block-sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400}",".owcb-block-foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:400}","@media (prefers-reduced-motion:reduce){.owcb,.owcb-chip,.owcb-arrow{transition:none}.owcb-spinner{animation-duration:1.4s}}"].join("\n"),document.head.appendChild(e)}();const c="dark"===t.theme?w:f,l=null!==(n=t.variant)&&void 0!==n?n:"default",a=null!==(r=t.label)&&void 0!==r?r:"Connect your apps",d=null!==(i=t.connectedLabel)&&void 0!==i?i:"Connected";let g="idle",v=!1;const x=o({...t.connect,onSuccess:()=>{var e,n;E("connected"),null===(e=(n=t.connect).onSuccess)||void 0===e||e.call(n)},onError:e=>{var n,o;E("idle"),null===(n=(o=t.connect).onError)||void 0===n||n.call(o,e)}}),y=document.createElement("button");y.type="button",y.className="block"===l?"owcb owcb-block":"owcb",y.addEventListener("click",()=>{"connecting"!==g&&(E("connecting"),x.open())});const C=()=>"connecting"===g?"Connecting…":"connected"===g?d:a,k=()=>{var e,n;const o="accent"===l,r="block"===l,i=r?c.surface:o?null!==(e=t.accentColor)&&void 0!==e?e:m:c.buttonBackground,a=r?c.foreground:o?b:c.buttonForeground,d=r?c.surface:i;y.style.background="connected"!==g||r?i:h,y.style.color="connected"!==g||r?a:b,y.style.boxShadow=r?`inset 0 0 0 1px ${c.line}`:"connected"===g?"none":o?`0 1px 2px rgba(10,12,11,.1), 0 6px 20px ${null!==(n=t.accentColor)&&void 0!==n?n:m}38`:c.shadow,y.disabled="connecting"===g,y.innerHTML="";const u=function(e,t){var n;const o=s(e.platforms);if(0===o.length&&!e.moreCount)return null;const r=document.createElement("span");r.className="owcb-stack",r.setAttribute("aria-hidden","true");for(const e of o.slice(0,3)){const n=document.createElement("span");n.className="owcb-chip",n.title=e.name,n.style.boxShadow=`0 0 0 1.5px ${t}`;const o=document.createElement("img");o.alt="",o.src=e.imageUrl,o.addEventListener("error",()=>{o.remove(),n.classList.add("owcb-letter"),n.textContent=e.name.charAt(0).toUpperCase()}),n.appendChild(o),r.appendChild(n)}const i=(null!==(n=e.moreCount)&&void 0!==n?n:0)+Math.max(0,o.length-3);if(i>0){const e=document.createElement("span");e.className="owcb-chip owcb-more",e.style.boxShadow=`0 0 0 1.5px ${t}`,e.textContent=`+${i}`,r.appendChild(e)}return r}(t,d);if(r){const e=document.createElement("span");e.className="owcb-block-top";const n=document.createElement("span");if(n.className="owcb-block-title",n.textContent=C(),e.appendChild(n),"connecting"===g){const t=document.createElement("span");t.className="owcb-spinner",e.appendChild(t)}else u&&e.appendChild(u);if(y.appendChild(e),t.description&&"idle"===g){const e=document.createElement("span");e.className="owcb-block-sub",e.style.color=c.muted,e.textContent=t.description,y.appendChild(e)}const o=document.createElement("span");return o.className="owcb-block-foot",o.style.color=c.muted,o.style.borderTop=`1px solid ${c.line}`,o.innerHTML=`<span style="font-size:11px;color:${c.muted}">Secured by</span><span style="display:inline-flex;color:${c.foreground}"><svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.4" style="flex-shrink:0"><circle cx="12" cy="12" r="8.5"/></svg></span><span style="font-size:12px;font-weight:600;letter-spacing:-0.02em;color:${c.foreground}">one</span>`,void y.appendChild(o)}if("connecting"===g){const e=document.createElement("span");e.className="owcb-spinner",y.appendChild(e)}else if("connected"===g){const e=document.createElement("span");e.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px"><path d="M3 8.5l3.5 3.5L13 5"/></svg>',e.style.display="inline-flex",y.appendChild(e)}else u&&y.appendChild(u);const p=document.createElement("span");if(p.className="owcb-label",p.textContent=C(),y.appendChild(p),"idle"===g){const e=document.createElement("span");e.innerHTML='<svg class="owcb-arrow" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3l5 5-5 5"/></svg>',e.style.display="inline-flex",y.appendChild(e)}},E=e=>{v||(g=e,k())};return k(),e.appendChild(y),{setState:E,destroy:()=>{v=!0,y.remove()}}};function v(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),r(this,"onSuccess",null),r(this,"onError",null),r(this,"handle",null)}connectedCallback(){this.mount()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.handle&&this.mount()}mount(){var e,t,n,o,r;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null;const i=this.getAttribute("authorize-url");if(!i)return;const c=this.getAttribute("more-count"),l=c?parseInt(c,10):NaN;this.handle=g(this,{connect:{authorizeUrl:i,appTheme:x(this,"app-theme",["light","dark"]),onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:e=>{var t;null===(t=this.onError)||void 0===t||t.call(this,e),this.dispatchEvent(new CustomEvent("error",{detail:e}))}},label:null!==(t=this.getAttribute("label"))&&void 0!==t?t:void 0,variant:x(this,"variant",["default","accent","block"]),theme:x(this,"theme",["light","dark"]),platforms:d(this.getAttribute("platforms")),moreCount:Number.isFinite(l)?l:void 0,description:null!==(n=this.getAttribute("description"))&&void 0!==n?n:void 0,accentColor:null!==(o=this.getAttribute("accent-color"))&&void 0!==o?o:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0})}}r(e,"observedAttributes",["authorize-url","app-theme","label","variant","theme","platforms","more-count","description","accent-color","connected-label"]),customElements.define("one-connect-button",e)}}function x(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}function y(e,t=e){return{connect:{authorizeUrl:e.authorizeUrl,appTheme:e.appTheme,onSuccess:()=>{var e;return null===(e=t.onSuccess)||void 0===e?void 0:e.call(t)},onError:e=>{var n;return null===(n=t.onError)||void 0===n?void 0:n.call(t,e)}},label:e.label,variant:e.variant,theme:e.theme,platforms:e.platforms,moreCount:e.moreCount,description:e.description,accentColor:e.accentColor,connectedLabel:e.connectedLabel}}function C(e){var t;return JSON.stringify([e.authorizeUrl,e.appTheme,e.label,e.variant,e.theme,null!==(t=e.platforms)&&void 0!==t?t:[],e.moreCount,e.description,e.accentColor,e.connectedLabel])}v();export{g as mountConnectButton,a as normalizePlatform,s as normalizePlatforms,y as optionsFromProps,d as parsePlatformsAttribute,C as propsIdentity,v as registerConnectButton,o as useOneConnect};
|
|
1
|
+
const e="one_connect",t="one_connect_message";let n=!1;const o=o=>{if("undefined"!=typeof window&&!n){const r=function(n){var o;const r=new URLSearchParams(n),i=r.get(e);if("success"!==i&&"error"!==i)return null;const c=null!==(o=r.get(t))&&void 0!==o?o:void 0;return c?{status:i,message:c}:{status:i}}(window.location.search);if(r){n=!0;const i=()=>{(function(n){const o=new URLSearchParams(n);return o.has(e)||o.has(t)})(window.location.search)&&window.history.replaceState(null,"",function(n){const o=new URLSearchParams(n.search);o.delete(e),o.delete(t);const r=o.toString();return`${n.pathname}${r?`?${r}`:""}${n.hash}`}(window.location))};i();for(const e of[50,500,2e3])window.setTimeout(i,e);window.setTimeout(()=>{try{var e,t,n;"success"===r.status?null===(e=o.onSuccess)||void 0===e||e.call(o):null===(t=o.onError)||void 0===t||t.call(o,null!==(n=r.message)&&void 0!==n?n:"The connection was not completed.")}catch{}},0)}}return{open:()=>{"undefined"!=typeof window&&window.location.assign((()=>{try{const e=new URL(o.authorizeUrl,"undefined"==typeof window?void 0:window.location.origin);return o.appTheme&&(e.hash=`one_theme=${o.appTheme}`),e.toString()}catch{return o.authorizeUrl}})())}}};function r(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function c(e){return e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function l(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function a(e){var t,n,o,r;const a="string"==typeof e?{slug:e}:e,s=null!==(t=a.slug)&&void 0!==t&&t.trim()?i(a.slug):null!==(n=a.name)&&void 0!==n&&n.trim()?i(a.name):"";return s?{slug:s,name:(null===(o=a.name)||void 0===o?void 0:o.trim())||c(s),imageUrl:(null===(r=a.imageUrl)||void 0===r?void 0:r.trim())||l(s)}:null}function s(e){return(null!=e?e:[]).map(a).filter(e=>null!==e)}function d(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const p="one-connect-button-styles",u="cubic-bezier(.2,.9,.25,1)",C="#CCFF00",h="#3FE3A5",m="#0A0C0B",f={buttonBackground:m,buttonForeground:"#FFFFFF",surface:"#FFFFFF",foreground:m,muted:"#6B7280",line:"#D1D5DB",shadow:"0 1px 2px rgba(10,12,11,.08), 0 4px 14px rgba(10,12,11,.06)"},b={buttonBackground:"#F2F5F3",buttonForeground:m,surface:"#101312",foreground:"#F2F5F3",muted:"#8A938E",line:"#2A302D",shadow:"0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35)"};const w=(e,t)=>{var n,r,i;!function(){if("undefined"==typeof document||document.getElementById(p))return;const e=document.createElement("style");e.id=p,e.textContent=[`.owcb{font:500 14.5px/1.2 inherit;font-family:inherit;letter-spacing:-.01em;cursor:pointer;border:0;display:inline-flex;align-items:center;gap:12px;padding:12px 16px 12px 14px;border-radius:12px;transition:transform .2s ${u},box-shadow .2s ${u},opacity .2s ${u}}`,".owcb:hover{transform:translateY(-1px)}",".owcb:active{transform:translateY(0)}",`.owcb:focus-visible{outline:2px solid ${h};outline-offset:3px}`,".owcb[disabled]{cursor:default;opacity:.75;transform:none}",".owcb-stack{display:inline-flex;align-items:center;flex-shrink:0}",`.owcb-chip{width:22px;height:22px;border-radius:6px;display:grid;place-items:center;overflow:hidden;margin-left:-7px;transition:margin-left .28s ${u};position:relative;background:#FFFFFF}`,".owcb-chip:first-child{margin-left:0}",".owcb-chip img{width:14px;height:14px;display:block;object-fit:contain}",`.owcb-chip.owcb-more{font-family:ui-monospace,monospace;font-size:9px;font-weight:500;letter-spacing:-.02em;color:${m}}`,`.owcb-chip.owcb-letter{font:600 10px ui-monospace,monospace;color:${m}}`,".owcb:hover .owcb-chip{margin-left:-2px}",".owcb:hover .owcb-chip:first-child{margin-left:0}",".owcb-label{white-space:nowrap}",`.owcb-arrow{opacity:.5;transition:transform .2s ${u},opacity .2s ${u}}`,".owcb:hover .owcb-arrow{transform:translateX(2px);opacity:.8}",".owcb-spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;opacity:.7;animation:owcb-spin .7s linear infinite}","@keyframes owcb-spin{to{transform:rotate(360deg)}}",".owcb.owcb-block{display:flex;flex-direction:column;align-items:stretch;width:100%;max-width:420px;text-align:left;padding:16px;border-radius:14px;gap:0}",".owcb-block-top{display:flex;align-items:center;justify-content:space-between;gap:12px}",".owcb-block-title{font-size:15px;font-weight:600;letter-spacing:-.01em}",".owcb-block-sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400}",".owcb-block-foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:400}","@media (prefers-reduced-motion:reduce){.owcb,.owcb-chip,.owcb-arrow{transition:none}.owcb-spinner{animation-duration:1.4s}}"].join("\n"),document.head.appendChild(e)}();const c="dark"===t.theme?b:f,l=null!==(n=t.variant)&&void 0!==n?n:"default",a=null!==(r=t.label)&&void 0!==r?r:"Connect your apps",d=null!==(i=t.connectedLabel)&&void 0!==i?i:"Connected";let w="idle",g=!1;const v=o({...t.connect,onSuccess:()=>{var e,n;E("connected"),null===(e=(n=t.connect).onSuccess)||void 0===e||e.call(n)},onError:e=>{var n,o;E("idle"),null===(n=(o=t.connect).onError)||void 0===n||n.call(o,e)}}),x=document.createElement("button");x.type="button",x.className="block"===l?"owcb owcb-block":"owcb",x.addEventListener("click",()=>{"connecting"!==w&&(E("connecting"),v.open())});const y=()=>"connecting"===w?"Connecting…":"connected"===w?d:a,k=()=>{var e,n;const o="accent"===l,r="block"===l,i=r?c.surface:o?null!==(e=t.accentColor)&&void 0!==e?e:C:c.buttonBackground,a=r?c.foreground:o?m:c.buttonForeground,d=r?c.surface:i;x.style.background="connected"!==w||r?i:h,x.style.color="connected"!==w||r?a:m,x.style.boxShadow=r?`inset 0 0 0 1px ${c.line}`:"connected"===w?"none":o?`0 1px 2px rgba(10,12,11,.1), 0 6px 20px ${null!==(n=t.accentColor)&&void 0!==n?n:C}38`:c.shadow,x.disabled="connecting"===w,x.innerHTML="";const p=function(e,t){const n=s(e.platforms);if(0===n.length)return null;const o=document.createElement("span");o.className="owcb-stack",o.setAttribute("aria-hidden","true");for(const e of n.slice(0,3)){const n=document.createElement("span");n.className="owcb-chip",n.title=e.name,n.style.boxShadow=`0 0 0 1.5px ${t}`;const r=document.createElement("img");r.alt="",r.src=e.imageUrl,r.addEventListener("error",()=>{r.remove(),n.classList.add("owcb-letter"),n.textContent=e.name.charAt(0).toUpperCase()}),n.appendChild(r),o.appendChild(n)}const r=Math.max(0,n.length-3);if(r>0){const e=document.createElement("span");e.className="owcb-chip owcb-more",e.style.boxShadow=`0 0 0 1.5px ${t}`,e.textContent=`+${r}`,o.appendChild(e)}return o}(t,d);if(r){const e=document.createElement("span");e.className="owcb-block-top";const n=document.createElement("span");if(n.className="owcb-block-title",n.textContent=y(),e.appendChild(n),"connecting"===w){const t=document.createElement("span");t.className="owcb-spinner",e.appendChild(t)}else p&&e.appendChild(p);if(x.appendChild(e),t.description&&"idle"===w){const e=document.createElement("span");e.className="owcb-block-sub",e.style.color=c.muted,e.textContent=t.description,x.appendChild(e)}const o=document.createElement("span");return o.className="owcb-block-foot",o.style.color=c.muted,o.style.borderTop=`1px solid ${c.line}`,o.innerHTML=`<span style="font-size:11px;color:${c.muted}">Secured by</span><span style="display:inline-flex;color:${c.foreground}"><svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" style="flex-shrink:0;display:block"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg></span>`,void x.appendChild(o)}if("connecting"===w){const e=document.createElement("span");e.className="owcb-spinner",x.appendChild(e)}else if("connected"===w){const e=document.createElement("span");e.innerHTML='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="width:16px;height:16px"><path d="M3 8.5l3.5 3.5L13 5"/></svg>',e.style.display="inline-flex",x.appendChild(e)}else p&&x.appendChild(p);const u=document.createElement("span");if(u.className="owcb-label",u.textContent=y(),x.appendChild(u),"idle"===w){const e=document.createElement("span");e.innerHTML='<svg class="owcb-arrow" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3l5 5-5 5"/></svg>',e.style.display="inline-flex",x.appendChild(e)}},E=e=>{g||(w=e,k())};return k(),e.appendChild(x),{setState:E,destroy:()=>{g=!0,x.remove()}}};function g(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),r(this,"onSuccess",null),r(this,"onError",null),r(this,"handle",null)}connectedCallback(){this.mount()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.handle&&this.mount()}mount(){var e,t,n,o,r;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null;const i=this.getAttribute("authorize-url");i&&(this.handle=w(this,{connect:{authorizeUrl:i,appTheme:v(this,"app-theme",["light","dark"]),onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:e=>{var t;null===(t=this.onError)||void 0===t||t.call(this,e),this.dispatchEvent(new CustomEvent("error",{detail:e}))}},label:null!==(t=this.getAttribute("label"))&&void 0!==t?t:void 0,variant:v(this,"variant",["default","accent","block"]),theme:v(this,"theme",["light","dark"]),platforms:d(this.getAttribute("platforms")),description:null!==(n=this.getAttribute("description"))&&void 0!==n?n:void 0,accentColor:null!==(o=this.getAttribute("accent-color"))&&void 0!==o?o:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0}))}}r(e,"observedAttributes",["authorize-url","app-theme","label","variant","theme","platforms","description","accent-color","connected-label"]),customElements.define("one-connect-button",e)}}function v(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}function x(e,t=e){return{connect:{authorizeUrl:e.authorizeUrl,appTheme:e.appTheme,onSuccess:()=>{var e;return null===(e=t.onSuccess)||void 0===e?void 0:e.call(t)},onError:e=>{var n;return null===(n=t.onError)||void 0===n?void 0:n.call(t,e)}},label:e.label,variant:e.variant,theme:e.theme,platforms:e.platforms,description:e.description,accentColor:e.accentColor,connectedLabel:e.connectedLabel}}function y(e){var t;return JSON.stringify([e.authorizeUrl,e.appTheme,e.label,e.variant,e.theme,null!==(t=e.platforms)&&void 0!==t?t:[],e.description,e.accentColor,e.connectedLabel])}g();export{w as mountConnectButton,a as normalizePlatform,s as normalizePlatforms,x as optionsFromProps,d as parsePlatformsAttribute,y as propsIdentity,g as registerConnectButton,o as useOneConnect};
|
package/dist/types.d.ts
CHANGED
|
@@ -60,11 +60,9 @@ export interface ConnectButtonOptions {
|
|
|
60
60
|
variant?: ConnectButtonVariant;
|
|
61
61
|
/** Matches the host page, not One's page (that is connect.appTheme). */
|
|
62
62
|
theme?: OneConnectTheme;
|
|
63
|
-
/** Connector chips. The first three render; the rest fold into
|
|
64
|
-
*
|
|
63
|
+
/** Connector chips. The first three render; the rest fold into a "+N"
|
|
64
|
+
* chip, so that count only ever describes this list. */
|
|
65
65
|
platforms?: ConnectButtonPlatformInput[];
|
|
66
|
-
/** Extra count for the "+N" chip, e.g. 274 for "the whole catalog". */
|
|
67
|
-
moreCount?: number;
|
|
68
66
|
/** Sub-line on the block variant, shown while idle. */
|
|
69
67
|
description?: string;
|
|
70
68
|
/** Fill of the accent variant; One's lime when omitted. */
|
package/dist/vue.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("vue"),t=require("@withone/connect");const
|
|
1
|
+
"use strict";var e=require("vue"),t=require("@withone/connect");const n=e.defineComponent({name:"OneConnectButton",props:{authorizeUrl:{type:String,required:!0},appTheme:{type:String,default:void 0},label:{type:String,default:void 0},variant:{type:String,default:void 0},theme:{type:String,default:void 0},platforms:{type:Array,default:void 0},description:{type:String,default:void 0},accentColor:{type:String,default:void 0},connectedLabel:{type:String,default:void 0}},emits:{success:()=>!0,error:e=>"string"==typeof e},setup(n,{emit:o}){const r=e.ref(null);let i=null;const u=()=>{var e;null===(e=i)||void 0===e||e.destroy(),i=null,r.value&&(i=t.mountConnectButton(r.value,t.optionsFromProps({...n},{onSuccess:()=>o("success"),onError:e=>o("error",e)})))};return e.onMounted(u),e.watch(()=>t.propsIdentity({...n}),u),e.onBeforeUnmount(()=>{var e;null===(e=i)||void 0===e||e.destroy(),i=null}),()=>e.h("div",{ref:r})}});exports.ConnectButton=n;
|
package/dist/vue.d.ts
CHANGED
|
@@ -25,10 +25,6 @@ export declare const ConnectButton: import("vue").DefineComponent<import("vue").
|
|
|
25
25
|
type: PropType<ConnectButtonPlatformInput[]>;
|
|
26
26
|
default: undefined;
|
|
27
27
|
};
|
|
28
|
-
moreCount: {
|
|
29
|
-
type: NumberConstructor;
|
|
30
|
-
default: undefined;
|
|
31
|
-
};
|
|
32
28
|
description: {
|
|
33
29
|
type: StringConstructor;
|
|
34
30
|
default: undefined;
|
|
@@ -71,10 +67,6 @@ export declare const ConnectButton: import("vue").DefineComponent<import("vue").
|
|
|
71
67
|
type: PropType<ConnectButtonPlatformInput[]>;
|
|
72
68
|
default: undefined;
|
|
73
69
|
};
|
|
74
|
-
moreCount: {
|
|
75
|
-
type: NumberConstructor;
|
|
76
|
-
default: undefined;
|
|
77
|
-
};
|
|
78
70
|
description: {
|
|
79
71
|
type: StringConstructor;
|
|
80
72
|
default: undefined;
|
|
@@ -97,7 +89,6 @@ export declare const ConnectButton: import("vue").DefineComponent<import("vue").
|
|
|
97
89
|
platforms: ConnectButtonPlatformInput[];
|
|
98
90
|
description: string;
|
|
99
91
|
appTheme: OneConnectTheme;
|
|
100
|
-
moreCount: number;
|
|
101
92
|
accentColor: string;
|
|
102
93
|
connectedLabel: string;
|
|
103
94
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/vue.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineComponent as e,ref as t,onMounted as r,watch as o,onBeforeUnmount as n,h as i}from"vue";import{propsIdentity as l,mountConnectButton as u,optionsFromProps as d}from"@withone/connect";const a=e({name:"OneConnectButton",props:{authorizeUrl:{type:String,required:!0},appTheme:{type:String,default:void 0},label:{type:String,default:void 0},variant:{type:String,default:void 0},theme:{type:String,default:void 0},platforms:{type:Array,default:void 0},
|
|
1
|
+
import{defineComponent as e,ref as t,onMounted as r,watch as o,onBeforeUnmount as n,h as i}from"vue";import{propsIdentity as l,mountConnectButton as u,optionsFromProps as d}from"@withone/connect";const a=e({name:"OneConnectButton",props:{authorizeUrl:{type:String,required:!0},appTheme:{type:String,default:void 0},label:{type:String,default:void 0},variant:{type:String,default:void 0},theme:{type:String,default:void 0},platforms:{type:Array,default:void 0},description:{type:String,default:void 0},accentColor:{type:String,default:void 0},connectedLabel:{type:String,default:void 0}},emits:{success:()=>!0,error:e=>"string"==typeof e},setup(e,{emit:a}){const p=t(null);let s=null;const c=()=>{var t;null===(t=s)||void 0===t||t.destroy(),s=null,p.value&&(s=u(p.value,d({...e},{onSuccess:()=>a("success"),onError:e=>a("error",e)})))};return r(c),o(()=>l({...e}),c),n(()=>{var e;null===(e=s)||void 0===e||e.destroy(),s=null}),()=>i("div",{ref:p})}});export{a as ConnectButton};
|
|
@@ -15,7 +15,6 @@ export interface ConnectButtonProps {
|
|
|
15
15
|
theme?: OneConnectTheme;
|
|
16
16
|
/** Connector slugs, or objects to override name or logo. */
|
|
17
17
|
platforms?: ConnectButtonPlatformInput[];
|
|
18
|
-
moreCount?: number;
|
|
19
18
|
description?: string;
|
|
20
19
|
accentColor?: string;
|
|
21
20
|
connectedLabel?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@withone/connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "One Connect for your app: the button your users press, the two backend routes as one import, and a server client that calls One with the grant. Users keep their connections in One; your app holds only what they granted.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
package/src/button.ts
CHANGED
|
@@ -58,8 +58,13 @@ const DARK: Palette = {
|
|
|
58
58
|
shadow: "0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35)",
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
/** One's lockup — the mark and the wordmark as one asset, every fill set
|
|
62
|
+
* to `currentColor` so a single copy works on either palette. Inlined
|
|
63
|
+
* rather than fetched: this is the trust mark, and it has to draw even
|
|
64
|
+
* behind a strict content policy or offline. Source:
|
|
65
|
+
* core-ui/public/logo/logo-full-dark.svg (viewBox 3152x990). */
|
|
66
|
+
const ONE_LOCKUP_SVG =
|
|
67
|
+
'<svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" style="flex-shrink:0;display:block"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg>';
|
|
63
68
|
const ARROW_SVG =
|
|
64
69
|
'<svg class="owcb-arrow" width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3l5 5-5 5"/></svg>';
|
|
65
70
|
const TICK_SVG =
|
|
@@ -104,7 +109,7 @@ function buildStack(
|
|
|
104
109
|
chipRing: string,
|
|
105
110
|
): HTMLElement | null {
|
|
106
111
|
const platforms = normalizePlatforms(options.platforms);
|
|
107
|
-
if (platforms.length === 0
|
|
112
|
+
if (platforms.length === 0) return null;
|
|
108
113
|
const stack = document.createElement("span");
|
|
109
114
|
stack.className = "owcb-stack";
|
|
110
115
|
stack.setAttribute("aria-hidden", "true");
|
|
@@ -124,9 +129,9 @@ function buildStack(
|
|
|
124
129
|
chip.appendChild(img);
|
|
125
130
|
stack.appendChild(chip);
|
|
126
131
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
// Only ever the apps the caller listed beyond the first three: the chip
|
|
133
|
+
// can never claim a number that has nothing to do with them.
|
|
134
|
+
const extra = Math.max(0, platforms.length - MAX_VISIBLE_CHIPS);
|
|
130
135
|
if (extra > 0) {
|
|
131
136
|
const more = document.createElement("span");
|
|
132
137
|
more.className = "owcb-chip owcb-more";
|
|
@@ -237,8 +242,7 @@ export const mountConnectButton = (
|
|
|
237
242
|
foot.style.borderTop = `1px solid ${palette.line}`;
|
|
238
243
|
foot.innerHTML =
|
|
239
244
|
`<span style="font-size:11px;color:${palette.muted}">Secured by</span>` +
|
|
240
|
-
`<span style="display:inline-flex;color:${palette.foreground}">${
|
|
241
|
-
`<span style="font-size:12px;font-weight:600;letter-spacing:-0.02em;color:${palette.foreground}">one</span>`;
|
|
245
|
+
`<span style="display:inline-flex;color:${palette.foreground}">${ONE_LOCKUP_SVG}</span>`;
|
|
242
246
|
button.appendChild(foot);
|
|
243
247
|
return;
|
|
244
248
|
}
|
|
@@ -295,7 +299,7 @@ export const mountConnectButton = (
|
|
|
295
299
|
* HTMLElement.
|
|
296
300
|
*
|
|
297
301
|
* Attributes: authorize-url (required), app-theme, label, variant,
|
|
298
|
-
* theme, platforms ("stripe, notion" or a JSON array),
|
|
302
|
+
* theme, platforms ("stripe, notion" or a JSON array),
|
|
299
303
|
* description, accent-color, connected-label.
|
|
300
304
|
* Events: "success" and "error" (detail: message), plus the matching
|
|
301
305
|
* onSuccess and onError function properties that React 19, Vue and
|
|
@@ -314,7 +318,6 @@ export function registerConnectButton(): void {
|
|
|
314
318
|
"variant",
|
|
315
319
|
"theme",
|
|
316
320
|
"platforms",
|
|
317
|
-
"more-count",
|
|
318
321
|
"description",
|
|
319
322
|
"accent-color",
|
|
320
323
|
"connected-label",
|
|
@@ -344,9 +347,6 @@ export function registerConnectButton(): void {
|
|
|
344
347
|
const authorizeUrl = this.getAttribute("authorize-url");
|
|
345
348
|
if (!authorizeUrl) return;
|
|
346
349
|
|
|
347
|
-
const moreCountRaw = this.getAttribute("more-count");
|
|
348
|
-
const moreCount = moreCountRaw ? parseInt(moreCountRaw, 10) : NaN;
|
|
349
|
-
|
|
350
350
|
this.handle = mountConnectButton(this, {
|
|
351
351
|
connect: {
|
|
352
352
|
authorizeUrl,
|
|
@@ -364,7 +364,6 @@ export function registerConnectButton(): void {
|
|
|
364
364
|
variant: attributeAs(this, "variant", ["default", "accent", "block"]),
|
|
365
365
|
theme: attributeAs(this, "theme", ["light", "dark"]),
|
|
366
366
|
platforms: parsePlatformsAttribute(this.getAttribute("platforms")),
|
|
367
|
-
moreCount: Number.isFinite(moreCount) ? moreCount : undefined,
|
|
368
367
|
description: this.getAttribute("description") ?? undefined,
|
|
369
368
|
accentColor: this.getAttribute("accent-color") ?? undefined,
|
|
370
369
|
connectedLabel: this.getAttribute("connected-label") ?? undefined,
|
package/src/types.ts
CHANGED
|
@@ -42,8 +42,7 @@ export interface OneConnectReturn {
|
|
|
42
42
|
* object to override either.
|
|
43
43
|
*/
|
|
44
44
|
export type ConnectButtonPlatformInput =
|
|
45
|
-
| string
|
|
46
|
-
| { slug?: string; name?: string; imageUrl?: string };
|
|
45
|
+
string | { slug?: string; name?: string; imageUrl?: string };
|
|
47
46
|
|
|
48
47
|
/** A normalized chip: what the button actually draws. */
|
|
49
48
|
export interface ConnectButtonPlatform {
|
|
@@ -66,11 +65,9 @@ export interface ConnectButtonOptions {
|
|
|
66
65
|
variant?: ConnectButtonVariant;
|
|
67
66
|
/** Matches the host page, not One's page (that is connect.appTheme). */
|
|
68
67
|
theme?: OneConnectTheme;
|
|
69
|
-
/** Connector chips. The first three render; the rest fold into
|
|
70
|
-
*
|
|
68
|
+
/** Connector chips. The first three render; the rest fold into a "+N"
|
|
69
|
+
* chip, so that count only ever describes this list. */
|
|
71
70
|
platforms?: ConnectButtonPlatformInput[];
|
|
72
|
-
/** Extra count for the "+N" chip, e.g. 274 for "the whole catalog". */
|
|
73
|
-
moreCount?: number;
|
|
74
71
|
/** Sub-line on the block variant, shown while idle. */
|
|
75
72
|
description?: string;
|
|
76
73
|
/** Fill of the accent variant; One's lime when omitted. */
|
package/src/vue.ts
CHANGED
|
@@ -44,7 +44,6 @@ export const ConnectButton = defineComponent({
|
|
|
44
44
|
type: Array as PropType<ConnectButtonPlatformInput[]>,
|
|
45
45
|
default: undefined,
|
|
46
46
|
},
|
|
47
|
-
moreCount: { type: Number, default: undefined },
|
|
48
47
|
description: { type: String, default: undefined },
|
|
49
48
|
accentColor: { type: String, default: undefined },
|
|
50
49
|
connectedLabel: { type: String, default: undefined },
|
package/src/wrapper-options.ts
CHANGED
|
@@ -21,7 +21,6 @@ export interface ConnectButtonProps {
|
|
|
21
21
|
theme?: OneConnectTheme;
|
|
22
22
|
/** Connector slugs, or objects to override name or logo. */
|
|
23
23
|
platforms?: ConnectButtonPlatformInput[];
|
|
24
|
-
moreCount?: number;
|
|
25
24
|
description?: string;
|
|
26
25
|
accentColor?: string;
|
|
27
26
|
connectedLabel?: string;
|
|
@@ -47,7 +46,6 @@ export function optionsFromProps(
|
|
|
47
46
|
variant: props.variant,
|
|
48
47
|
theme: props.theme,
|
|
49
48
|
platforms: props.platforms,
|
|
50
|
-
moreCount: props.moreCount,
|
|
51
49
|
description: props.description,
|
|
52
50
|
accentColor: props.accentColor,
|
|
53
51
|
connectedLabel: props.connectedLabel,
|
|
@@ -63,7 +61,6 @@ export function propsIdentity(props: ConnectButtonProps): string {
|
|
|
63
61
|
props.variant,
|
|
64
62
|
props.theme,
|
|
65
63
|
props.platforms ?? [],
|
|
66
|
-
props.moreCount,
|
|
67
64
|
props.description,
|
|
68
65
|
props.accentColor,
|
|
69
66
|
props.connectedLabel,
|