@authhero/widget 0.6.2 → 0.7.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/dist/authhero-widget/authhero-widget.esm.js +1 -1
- package/dist/authhero-widget/index.esm.js +1 -1
- package/dist/authhero-widget/{p-7ee9b91f.entry.js → p-29e844e0.entry.js} +1 -1
- package/dist/authhero-widget/p-553c2cbe.entry.js +1 -0
- package/dist/cjs/authhero-node.cjs.entry.js +2 -2
- package/dist/cjs/authhero-widget.cjs.entry.js +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/collection/components/authhero-node/authhero-node.css +45 -7
- package/dist/collection/components/authhero-node/authhero-node.js +1 -1
- package/dist/collection/components/authhero-widget/authhero-widget.css +37 -4
- package/dist/components/authhero-node.js +1 -1
- package/dist/components/authhero-widget.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-03Jc7wx1.js → p-uGYnrdy5.js} +1 -1
- package/dist/esm/authhero-node.entry.js +2 -2
- package/dist/esm/authhero-widget.entry.js +1 -1
- package/dist/esm/index.js +1 -1
- package/hydrate/index.js +3 -3
- package/hydrate/index.mjs +3 -3
- package/package.json +2 -2
- package/dist/authhero-widget/p-21535878.entry.js +0 -1
|
@@ -84,7 +84,9 @@
|
|
|
84
84
|
border: 1px solid var(--ah-color-border, #c9cace);
|
|
85
85
|
border-radius: var(--ah-input-radius, 3px);
|
|
86
86
|
outline: none;
|
|
87
|
-
transition:
|
|
87
|
+
transition:
|
|
88
|
+
border-color 0.15s ease-out,
|
|
89
|
+
box-shadow 0.15s ease-out;
|
|
88
90
|
box-sizing: border-box;
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -203,7 +205,7 @@
|
|
|
203
205
|
margin-bottom: 16px;
|
|
204
206
|
}
|
|
205
207
|
|
|
206
|
-
.checkbox-wrapper input[type=
|
|
208
|
+
.checkbox-wrapper input[type="checkbox"] {
|
|
207
209
|
width: 18px;
|
|
208
210
|
height: 18px;
|
|
209
211
|
margin: 0;
|
|
@@ -239,7 +241,10 @@
|
|
|
239
241
|
border: none;
|
|
240
242
|
border-radius: var(--ah-btn-radius, 3px);
|
|
241
243
|
cursor: pointer;
|
|
242
|
-
transition:
|
|
244
|
+
transition:
|
|
245
|
+
background-color 0.15s ease,
|
|
246
|
+
border-color 0.15s ease,
|
|
247
|
+
transform 0.1s ease;
|
|
243
248
|
box-sizing: border-box;
|
|
244
249
|
}
|
|
245
250
|
|
|
@@ -261,12 +266,11 @@
|
|
|
261
266
|
.btn-primary {
|
|
262
267
|
background-color: var(--ah-color-primary, #635dff);
|
|
263
268
|
color: var(--ah-color-text-on-primary, #ffffff);
|
|
264
|
-
margin-top:
|
|
269
|
+
margin-top: 12px;
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
.btn-primary:not(:disabled):hover {
|
|
268
|
-
|
|
269
|
-
filter: brightness(0.9);
|
|
273
|
+
filter: brightness(0.85);
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
/* Secondary Button (Social/OIDC) */
|
|
@@ -295,6 +299,13 @@
|
|
|
295
299
|
text-decoration: underline;
|
|
296
300
|
}
|
|
297
301
|
|
|
302
|
+
/* Social buttons container */
|
|
303
|
+
.social-buttons {
|
|
304
|
+
display: flex;
|
|
305
|
+
flex-direction: column;
|
|
306
|
+
gap: 12px;
|
|
307
|
+
}
|
|
308
|
+
|
|
298
309
|
/* Social button */
|
|
299
310
|
.btn-social {
|
|
300
311
|
display: flex;
|
|
@@ -310,6 +321,33 @@
|
|
|
310
321
|
flex-shrink: 0;
|
|
311
322
|
}
|
|
312
323
|
|
|
324
|
+
/* Small screen: collapse social buttons to icon-only in a row only if 3+ buttons */
|
|
325
|
+
@media (max-width: 480px) {
|
|
326
|
+
/* Only apply icon-only layout when there are 3 or more social buttons */
|
|
327
|
+
.social-buttons:has(.btn-social:nth-child(3)) {
|
|
328
|
+
flex-direction: row;
|
|
329
|
+
flex-wrap: nowrap;
|
|
330
|
+
justify-content: stretch;
|
|
331
|
+
gap: 8px;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.social-buttons:has(.btn-social:nth-child(3)) .btn-social {
|
|
335
|
+
width: auto;
|
|
336
|
+
min-width: 0;
|
|
337
|
+
padding: 12px;
|
|
338
|
+
flex: 1 1 0;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.social-buttons:has(.btn-social:nth-child(3)) .btn-social span {
|
|
342
|
+
display: none;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.social-buttons:has(.btn-social:nth-child(3)) .social-icon {
|
|
346
|
+
width: 24px;
|
|
347
|
+
height: 24px;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
313
351
|
.btn-icon {
|
|
314
352
|
width: 20px;
|
|
315
353
|
height: 20px;
|
|
@@ -426,7 +464,7 @@
|
|
|
426
464
|
|
|
427
465
|
.divider::before,
|
|
428
466
|
.divider::after {
|
|
429
|
-
content:
|
|
467
|
+
content: "";
|
|
430
468
|
flex: 1;
|
|
431
469
|
border-bottom: 1px solid var(--ah-color-border-muted, #c9cace);
|
|
432
470
|
}
|
|
@@ -253,7 +253,7 @@ export class AuthheroNode {
|
|
|
253
253
|
// Default: no icon
|
|
254
254
|
return null;
|
|
255
255
|
};
|
|
256
|
-
return (h("div", { class: "social-buttons", part: "social-buttons" }, providers.map((provider) => (h("button", { type: "button", class: "btn btn-secondary btn-social", part: "button button-secondary button-social", "data-provider": provider, disabled: this.disabled, onClick: (e) => this.handleButtonClick(e, "
|
|
256
|
+
return (h("div", { class: "social-buttons", part: "social-buttons" }, providers.map((provider) => (h("button", { type: "button", class: "btn btn-secondary btn-social", part: "button button-secondary button-social", "data-provider": provider, disabled: this.disabled, onClick: (e) => this.handleButtonClick(e, "SOCIAL", provider), key: provider }, getProviderIcon(provider), h("span", null, "Continue with ", getProviderDisplayName(provider)))))));
|
|
257
257
|
}
|
|
258
258
|
// ===========================================================================
|
|
259
259
|
// Main Render
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
========================================================================== */
|
|
38
38
|
|
|
39
39
|
.widget-header {
|
|
40
|
-
padding: var(--ah-header-padding, 40px
|
|
40
|
+
padding: var(--ah-header-padding, 40px 48px 24px);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/* ==========================================================================
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
========================================================================== */
|
|
47
47
|
|
|
48
48
|
.widget-body {
|
|
49
|
-
padding: var(--ah-body-padding, 0
|
|
49
|
+
padding: var(--ah-body-padding, 0 48px 40px);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/* ==========================================================================
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
.logo-wrapper {
|
|
58
58
|
display: var(--ah-logo-display, flex);
|
|
59
59
|
justify-content: var(--ah-logo-align, center);
|
|
60
|
+
margin-bottom: 8px;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
.logo {
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
font-size: var(--ah-font-size-title, 24px);
|
|
77
78
|
font-weight: var(--ah-font-weight-title, 700);
|
|
78
79
|
text-align: var(--ah-title-align, center);
|
|
79
|
-
margin: var(--ah-title-margin, 24px 0
|
|
80
|
+
margin: var(--ah-title-margin, 24px 0 8px);
|
|
80
81
|
color: var(--ah-color-header, #1e212a);
|
|
81
82
|
line-height: 1.2;
|
|
82
83
|
}
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
.description {
|
|
85
86
|
font-size: var(--ah-font-size-description, 14px);
|
|
86
87
|
text-align: var(--ah-title-align, center);
|
|
87
|
-
margin: var(--ah-description-margin, 0);
|
|
88
|
+
margin: var(--ah-description-margin, 0 0 8px);
|
|
88
89
|
color: var(--ah-color-text, #1e212a);
|
|
89
90
|
line-height: 1.5;
|
|
90
91
|
}
|
|
@@ -242,3 +243,35 @@ form {
|
|
|
242
243
|
padding: 16px;
|
|
243
244
|
font-size: 14px;
|
|
244
245
|
}
|
|
246
|
+
|
|
247
|
+
/* ==========================================================================
|
|
248
|
+
Small Screen Adjustments
|
|
249
|
+
- Remove shadow and border-radius for edge-to-edge look
|
|
250
|
+
- Keep widget background color
|
|
251
|
+
- Full width spanning entire screen
|
|
252
|
+
========================================================================== */
|
|
253
|
+
|
|
254
|
+
@media (max-width: 480px) {
|
|
255
|
+
:host {
|
|
256
|
+
display: block;
|
|
257
|
+
width: 100%;
|
|
258
|
+
min-height: 100vh;
|
|
259
|
+
background-color: var(--ah-color-bg, #ffffff);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.widget-container {
|
|
263
|
+
box-shadow: none;
|
|
264
|
+
border-radius: 0;
|
|
265
|
+
max-width: none;
|
|
266
|
+
width: 100%;
|
|
267
|
+
margin: 0;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.widget-header {
|
|
271
|
+
padding: 24px 16px 16px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.widget-body {
|
|
275
|
+
padding: 0 16px 24px;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as o,d as
|
|
1
|
+
import{A as o,d as r}from"./p-uGYnrdy5.js";const s=o,p=r;export{s as AuthheroNode,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as e,H as i,c as r,h as s}from"./p-JzMtjMQb.js";import{d as a}from"./p-03Jc7wx1.js";function o(t,e){if(void 0!==e)return e+"px";switch(t){case"pill":return"9999px";case"rounded":return"8px";case"sharp":return"0";default:return}}function n(t){if(!t)return{};const e={};if(t.colors?.primary&&(e["--ah-color-primary"]=t.colors.primary,e["--ah-color-primary-hover"]=t.colors.primary),t.colors?.page_background){const i=t.colors.page_background;"solid"===i.type&&i.start?e["--ah-page-bg"]=i.start:"gradient"===i.type&&i.start&&i.end&&(e["--ah-page-bg"]=`linear-gradient(${i.angle_deg??180}deg, ${i.start}, ${i.end})`)}return t.logo_url&&(e["--ah-logo-url"]=`url(${t.logo_url})`),t.font?.url&&(e["--ah-font-url"]=t.font.url),e}function h(t){if(!t)return{};const e={};if(t.borders){const i=t.borders;void 0!==i.widget_corner_radius&&(e["--ah-widget-radius"]=i.widget_corner_radius+"px"),void 0!==i.widget_border_weight&&(e["--ah-widget-border-width"]=i.widget_border_weight+"px"),!1===i.show_widget_shadow&&(e["--ah-widget-shadow"]="none");const r=o(i.buttons_style,i.button_border_radius);r&&(e["--ah-btn-radius"]=r),void 0!==i.button_border_weight&&(e["--ah-btn-border-width"]=i.button_border_weight+"px");const s=o(i.inputs_style,i.input_border_radius);s&&(e["--ah-input-radius"]=s),void 0!==i.input_border_weight&&(e["--ah-input-border-width"]=i.input_border_weight+"px")}if(t.colors){const i=t.colors;i.primary_button&&(e["--ah-color-primary"]=i.primary_button,e["--ah-color-primary-hover"]=i.primary_button),i.primary_button_label&&(e["--ah-btn-primary-text"]=i.primary_button_label),i.secondary_button_border&&(e["--ah-btn-secondary-border"]=i.secondary_button_border),i.secondary_button_label&&(e["--ah-btn-secondary-text"]=i.secondary_button_label),i.body_text&&(e["--ah-color-text"]=i.body_text),i.header&&(e["--ah-color-text-header"]=i.header),i.input_labels_placeholders&&(e["--ah-color-text-label"]=i.input_labels_placeholders,e["--ah-color-text-muted"]=i.input_labels_placeholders),i.input_filled_text&&(e["--ah-color-input-text"]=i.input_filled_text),i.widget_background&&(e["--ah-color-bg"]=i.widget_background),i.input_background&&(e["--ah-color-input-bg"]=i.input_background),i.widget_border&&(e["--ah-widget-border-color"]=i.widget_border),i.input_border&&(e["--ah-color-border"]=i.input_border),i.links_focused_components&&(e["--ah-color-link"]=i.links_focused_components),i.base_focus_color&&(e["--ah-color-focus-ring"]=i.base_focus_color),i.base_hover_color&&(e["--ah-color-primary-hover"]=i.base_hover_color),i.error&&(e["--ah-color-error"]=i.error),i.success&&(e["--ah-color-success"]=i.success),i.icons&&(e["--ah-color-icon"]=i.icons)}if(t.fonts){const i=t.fonts,r=i.reference_text_size||16;i.font_url&&(e["--ah-font-url"]=i.font_url),i.reference_text_size&&(e["--ah-font-size-base"]=i.reference_text_size+"px"),i.title?.size&&(e["--ah-font-size-title"]=Math.round(i.title.size/100*r)+"px"),i.subtitle?.size&&(e["--ah-font-size-subtitle"]=Math.round(i.subtitle.size/100*r)+"px"),i.body_text?.size&&(e["--ah-font-size-body"]=Math.round(i.body_text.size/100*r)+"px"),i.input_labels?.size&&(e["--ah-font-size-label"]=Math.round(i.input_labels.size/100*r)+"px"),i.buttons_text?.size&&(e["--ah-font-size-btn"]=Math.round(i.buttons_text.size/100*r)+"px"),i.links?.size&&(e["--ah-font-size-link"]=Math.round(i.links.size/100*r)+"px"),"underlined"===i.links_style&&(e["--ah-link-decoration"]="underline"),void 0!==i.title?.bold&&(e["--ah-font-weight-title"]=i.title.bold?"700":"400"),void 0!==i.subtitle?.bold&&(e["--ah-font-weight-subtitle"]=i.subtitle.bold?"700":"400"),void 0!==i.body_text?.bold&&(e["--ah-font-weight-body"]=i.body_text.bold?"700":"400"),void 0!==i.input_labels?.bold&&(e["--ah-font-weight-label"]=i.input_labels.bold?"700":"400"),void 0!==i.buttons_text?.bold&&(e["--ah-font-weight-btn"]=i.buttons_text.bold?"600":"400"),void 0!==i.links?.bold&&(e["--ah-font-weight-link"]=i.links.bold?"700":"400")}if(t.widget){const i=t.widget;if(i.header_text_alignment&&(e["--ah-title-align"]=i.header_text_alignment),i.logo_height&&(e["--ah-logo-height"]=i.logo_height+"px"),i.logo_position){const t={center:"center",left:"flex-start",right:"flex-end"};"none"===i.logo_position?e["--ah-logo-display"]="none":e["--ah-logo-align"]=t[i.logo_position]??"center"}i.social_buttons_layout&&("top"===i.social_buttons_layout?(e["--ah-social-order"]="0",e["--ah-divider-order"]="1",e["--ah-fields-order"]="2"):(e["--ah-social-order"]="2",e["--ah-divider-order"]="1",e["--ah-fields-order"]="0"))}if(t.page_background){const i=t.page_background;i.background_color&&(e["--ah-page-bg"]=i.background_color),i.background_image_url&&(e["--ah-page-bg-image"]=`url(${i.background_image_url})`)}return e}const c=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.formSubmit=r(this,"formSubmit"),this.buttonClick=r(this,"buttonClick"),this.linkClick=r(this,"linkClick"),this.navigate=r(this,"navigate"),this.flowComplete=r(this,"flowComplete"),this.flowError=r(this,"flowError"),this.screenChange=r(this,"screenChange")}get el(){return this}screen;apiUrl;branding;theme;loading=!1;autoSubmit=!1;_screen;_branding;_theme;formData={};formSubmit;buttonClick;linkClick;navigate;flowComplete;flowError;screenChange;watchScreen(t){if("string"==typeof t)try{this._screen=JSON.parse(t)}catch{console.error("Failed to parse screen JSON")}else this._screen=t;this._screen&&this.screenChange.emit(this._screen)}watchBranding(t){if("string"==typeof t)try{this._branding=JSON.parse(t)}catch{console.error("Failed to parse branding JSON")}else this._branding=t;this.applyThemeStyles()}watchTheme(t){if("string"==typeof t)try{this._theme=JSON.parse(t)}catch{console.error("Failed to parse theme JSON")}else this._theme=t;this.applyThemeStyles()}applyThemeStyles(){const t=function(t,e){return{...n(t),...h(e)}}(this._branding,this._theme);!function(t,e){Object.entries(e).forEach((([e,i])=>{t.style.setProperty(e,i)}))}(this.el,t)}async componentWillLoad(){this.watchScreen(this.screen),this.watchBranding(this.branding),this.watchTheme(this.theme),this.apiUrl&&!this._screen&&await this.fetchScreen()}async fetchScreen(){if(this.apiUrl){this.loading=!0;try{const t=await fetch(this.apiUrl,{credentials:"include",headers:{Accept:"application/json"}});t.ok&&(this._screen=await t.json(),this._screen&&this.screenChange.emit(this._screen))}catch(t){console.error("Failed to fetch screen:",t)}finally{this.loading=!1}}}handleInputChange=(t,e)=>{this.formData={...this.formData,[t]:e}};handleSubmit=async t=>{if(t.preventDefault(),this._screen&&(this.formSubmit.emit({screen:this._screen,data:this.formData}),this.autoSubmit)){this.loading=!0;try{const t=await fetch(this._screen.action,{method:this._screen.method,credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({data:this.formData})}),e=t.headers.get("content-type");if(e?.includes("application/json")){const e=await t.json();e.redirect?(this.flowComplete.emit({redirectUrl:e.redirect}),this.navigate.emit({url:e.redirect})):e.screen?(this._screen=e.screen,this.formData={},this.screenChange.emit(e.screen),e.branding&&(this._branding=e.branding,this.applyThemeStyles())):e.complete&&this.flowComplete.emit({}),!t.ok&&e.screen&&(this._screen=e.screen,this.screenChange.emit(e.screen))}}catch(t){console.error("Form submission failed:",t),this.flowError.emit({message:t instanceof Error?t.message:"Form submission failed"})}finally{this.loading=!1}}};handleButtonClick=t=>{"submit"!==t.type?this.buttonClick.emit(t):this.handleSubmit({preventDefault:()=>{}})};handleLinkClick=(t,e)=>{this.linkClick.emit({id:e.id,href:e.href,text:e.text}),this.autoSubmit||t.preventDefault()};getScreenErrors(){return this._screen?.messages?.filter((t=>"error"===t.type))||[]}getScreenSuccesses(){return this._screen?.messages?.filter((t=>"success"===t.type))||[]}getOrderedComponents(){return this._screen?[...this._screen.components].filter((t=>!1!==t.visible)).sort(((t,e)=>(t.order??0)-(e.order??0))):[]}isSocialComponent(t){return"SOCIAL"===t.type}isDividerComponent(t){return"DIVIDER"===t.type}render(){if(this.loading&&!this._screen)return s("div",{class:"widget-container"},s("div",{class:"loading-spinner"}));if(!this._screen)return s("div",{class:"widget-container"},s("div",{class:"error-message"},"No screen configuration provided"));const t=this.getScreenErrors(),e=this.getScreenSuccesses(),i=this.getOrderedComponents(),r=i.filter((t=>this.isSocialComponent(t))),a=i.filter((t=>!this.isSocialComponent(t)&&!this.isDividerComponent(t))),o=i.some((t=>this.isDividerComponent(t))),n=this._theme?.widget?.logo_url||this._branding?.logo_url;return s("div",{class:"widget-container",part:"container"},s("header",{class:"widget-header",part:"header"},n&&s("div",{class:"logo-wrapper",part:"logo-wrapper"},s("img",{class:"logo",part:"logo",src:n,alt:"Logo"})),this._screen.title&&s("h1",{class:"title",part:"title"},this._screen.title),this._screen.description&&s("p",{class:"description",part:"description"},this._screen.description)),s("div",{class:"widget-body",part:"body"},t.map((t=>s("div",{class:"message message-error",part:"message message-error",key:t.id??t.text},t.text))),e.map((t=>s("div",{class:"message message-success",part:"message message-success",key:t.id??t.text},t.text))),s("form",{onSubmit:this.handleSubmit,part:"form"},s("div",{class:"form-content"},r.length>0&&s("div",{class:"social-section",part:"social-section"},r.map((t=>s("authhero-node",{key:t.id,component:t,value:this.formData[t.id],onFieldChange:t=>this.handleInputChange(t.detail.id,t.detail.value),onButtonClick:t=>this.handleButtonClick(t.detail),disabled:this.loading})))),r.length>0&&a.length>0&&o&&s("div",{class:"divider",part:"divider"},s("span",{class:"divider-text"},"Or")),s("div",{class:"fields-section",part:"fields-section"},a.map((t=>s("authhero-node",{key:t.id,component:t,value:this.formData[t.id],onFieldChange:t=>this.handleInputChange(t.detail.id,t.detail.value),onButtonClick:t=>this.handleButtonClick(t.detail),disabled:this.loading})))))),this._screen.links&&this._screen.links.length>0&&s("div",{class:"links",part:"links"},this._screen.links.map((t=>s("span",{class:"link-wrapper",part:"link-wrapper",key:t.id??t.href},t.linkText?s("span",null,t.text," ",s("a",{href:t.href,class:"link",part:"link",onClick:e=>this.handleLinkClick(e,{id:t.id,href:t.href,text:t.linkText||t.text})},t.linkText)):s("a",{href:t.href,class:"link",part:"link",onClick:e=>this.handleLinkClick(e,{id:t.id,href:t.href,text:t.text})},t.text)))))))}static get watchers(){return{screen:[{watchScreen:0}],branding:[{watchBranding:0}],theme:[{watchTheme:0}]}}static get style(){return":host{display:block;font-family:var(--ah-font-family, 'ulp-font', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif);font-size:var(--ah-font-size-base, 14px);line-height:var(--ah-line-height-base, 1.5);color:var(--ah-color-text, #1e212a);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.widget-container{max-width:var(--ah-widget-max-width, 400px);width:100%;margin:0 auto;background-color:var(--ah-color-bg, #ffffff);border-radius:var(--ah-widget-radius, 5px);box-shadow:var(--ah-widget-shadow, 0 4px 22px 0 rgba(0, 0, 0, 0.11));box-sizing:border-box}.widget-header{padding:var(--ah-header-padding, 40px 40px 24px)}.widget-body{padding:var(--ah-body-padding, 0 40px 40px)}.logo-wrapper{display:var(--ah-logo-display, flex);justify-content:var(--ah-logo-align, center)}.logo{display:block;height:var(--ah-logo-height, 52px);max-width:100%;width:auto;object-fit:contain}.title{font-size:var(--ah-font-size-title, 24px);font-weight:var(--ah-font-weight-title, 700);text-align:var(--ah-title-align, center);margin:var(--ah-title-margin, 24px 0 16px);color:var(--ah-color-header, #1e212a);line-height:1.2}.description{font-size:var(--ah-font-size-description, 14px);text-align:var(--ah-title-align, center);margin:var(--ah-description-margin, 0);color:var(--ah-color-text, #1e212a);line-height:1.5}.message{padding:12px 16px;border-radius:4px;margin-bottom:16px;font-size:14px;line-height:1.5}.message-error{background-color:var(--ah-color-error-bg, #ffeaea);color:var(--ah-color-error, #d03c38);border-left:3px solid var(--ah-color-error, #d03c38)}.message-success{background-color:var(--ah-color-success-bg, #e6f9f1);color:var(--ah-color-success, #13a769);border-left:3px solid var(--ah-color-success, #13a769)}form{display:flex;flex-direction:column}.form-content{display:flex;flex-direction:column}.social-section{display:flex;flex-direction:column;gap:8px;order:var(--ah-social-order, 2)}.fields-section{display:flex;flex-direction:column;order:var(--ah-fields-order, 0)}.divider{display:flex;align-items:center;text-align:center;margin:16px 0;order:var(--ah-divider-order, 1)}.divider::before,.divider::after{content:'';flex:1;border-bottom:1px solid var(--ah-color-border-muted, #c9cace)}.divider-text{padding:0 10px;font-size:12px;font-weight:400;color:var(--ah-color-text-muted, #65676e);text-transform:uppercase;letter-spacing:0}.links{display:flex;flex-direction:column;align-items:center;gap:8px;margin-top:16px}.link-wrapper{font-size:14px;color:var(--ah-color-text, #1e212a)}.link{color:var(--ah-color-link, #635dff);text-decoration:var(--ah-link-decoration, none);font-size:14px;font-weight:var(--ah-font-weight-link, 400);transition:color 150ms ease}.link:hover{text-decoration:underline}.link:focus-visible{outline:2px solid var(--ah-color-link, #635dff);outline-offset:2px;border-radius:2px}.loading-spinner{width:32px;height:32px;margin:24px auto;border:3px solid var(--ah-color-border-muted, #e0e1e3);border-top-color:var(--ah-color-primary, #635dff);border-radius:50%;animation:spin 0.8s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.error-message{text-align:center;color:var(--ah-color-error, #d03c38);padding:16px;font-size:14px}"}},[513,"authhero-widget",{screen:[1],apiUrl:[1,"api-url"],branding:[1],theme:[1],loading:[1028],autoSubmit:[4,"auto-submit"],_screen:[32],_branding:[32],_theme:[32],formData:[32]},void 0,{screen:[{watchScreen:0}],branding:[{watchBranding:0}],theme:[{watchTheme:0}]}]);function l(){"undefined"!=typeof customElements&&["authhero-widget","authhero-node"].forEach((e=>{switch(e){case"authhero-widget":customElements.get(t(e))||customElements.define(t(e),c);break;case"authhero-node":customElements.get(t(e))||a()}}))}l();const d=c,p=l;export{d as AuthheroWidget,p as defineCustomElement}
|
|
1
|
+
import{t,p as e,H as i,c as r,h as s}from"./p-JzMtjMQb.js";import{d as a}from"./p-uGYnrdy5.js";function o(t,e){if(void 0!==e)return e+"px";switch(t){case"pill":return"9999px";case"rounded":return"8px";case"sharp":return"0";default:return}}function n(t){if(!t)return{};const e={};if(t.colors?.primary&&(e["--ah-color-primary"]=t.colors.primary,e["--ah-color-primary-hover"]=t.colors.primary),t.colors?.page_background){const i=t.colors.page_background;"solid"===i.type&&i.start?e["--ah-page-bg"]=i.start:"gradient"===i.type&&i.start&&i.end&&(e["--ah-page-bg"]=`linear-gradient(${i.angle_deg??180}deg, ${i.start}, ${i.end})`)}return t.logo_url&&(e["--ah-logo-url"]=`url(${t.logo_url})`),t.font?.url&&(e["--ah-font-url"]=t.font.url),e}function h(t){if(!t)return{};const e={};if(t.borders){const i=t.borders;void 0!==i.widget_corner_radius&&(e["--ah-widget-radius"]=i.widget_corner_radius+"px"),void 0!==i.widget_border_weight&&(e["--ah-widget-border-width"]=i.widget_border_weight+"px"),!1===i.show_widget_shadow&&(e["--ah-widget-shadow"]="none");const r=o(i.buttons_style,i.button_border_radius);r&&(e["--ah-btn-radius"]=r),void 0!==i.button_border_weight&&(e["--ah-btn-border-width"]=i.button_border_weight+"px");const s=o(i.inputs_style,i.input_border_radius);s&&(e["--ah-input-radius"]=s),void 0!==i.input_border_weight&&(e["--ah-input-border-width"]=i.input_border_weight+"px")}if(t.colors){const i=t.colors;i.primary_button&&(e["--ah-color-primary"]=i.primary_button,e["--ah-color-primary-hover"]=i.primary_button),i.primary_button_label&&(e["--ah-btn-primary-text"]=i.primary_button_label),i.secondary_button_border&&(e["--ah-btn-secondary-border"]=i.secondary_button_border),i.secondary_button_label&&(e["--ah-btn-secondary-text"]=i.secondary_button_label),i.body_text&&(e["--ah-color-text"]=i.body_text),i.header&&(e["--ah-color-text-header"]=i.header),i.input_labels_placeholders&&(e["--ah-color-text-label"]=i.input_labels_placeholders,e["--ah-color-text-muted"]=i.input_labels_placeholders),i.input_filled_text&&(e["--ah-color-input-text"]=i.input_filled_text),i.widget_background&&(e["--ah-color-bg"]=i.widget_background),i.input_background&&(e["--ah-color-input-bg"]=i.input_background),i.widget_border&&(e["--ah-widget-border-color"]=i.widget_border),i.input_border&&(e["--ah-color-border"]=i.input_border),i.links_focused_components&&(e["--ah-color-link"]=i.links_focused_components),i.base_focus_color&&(e["--ah-color-focus-ring"]=i.base_focus_color),i.base_hover_color&&(e["--ah-color-primary-hover"]=i.base_hover_color),i.error&&(e["--ah-color-error"]=i.error),i.success&&(e["--ah-color-success"]=i.success),i.icons&&(e["--ah-color-icon"]=i.icons)}if(t.fonts){const i=t.fonts,r=i.reference_text_size||16;i.font_url&&(e["--ah-font-url"]=i.font_url),i.reference_text_size&&(e["--ah-font-size-base"]=i.reference_text_size+"px"),i.title?.size&&(e["--ah-font-size-title"]=Math.round(i.title.size/100*r)+"px"),i.subtitle?.size&&(e["--ah-font-size-subtitle"]=Math.round(i.subtitle.size/100*r)+"px"),i.body_text?.size&&(e["--ah-font-size-body"]=Math.round(i.body_text.size/100*r)+"px"),i.input_labels?.size&&(e["--ah-font-size-label"]=Math.round(i.input_labels.size/100*r)+"px"),i.buttons_text?.size&&(e["--ah-font-size-btn"]=Math.round(i.buttons_text.size/100*r)+"px"),i.links?.size&&(e["--ah-font-size-link"]=Math.round(i.links.size/100*r)+"px"),"underlined"===i.links_style&&(e["--ah-link-decoration"]="underline"),void 0!==i.title?.bold&&(e["--ah-font-weight-title"]=i.title.bold?"700":"400"),void 0!==i.subtitle?.bold&&(e["--ah-font-weight-subtitle"]=i.subtitle.bold?"700":"400"),void 0!==i.body_text?.bold&&(e["--ah-font-weight-body"]=i.body_text.bold?"700":"400"),void 0!==i.input_labels?.bold&&(e["--ah-font-weight-label"]=i.input_labels.bold?"700":"400"),void 0!==i.buttons_text?.bold&&(e["--ah-font-weight-btn"]=i.buttons_text.bold?"600":"400"),void 0!==i.links?.bold&&(e["--ah-font-weight-link"]=i.links.bold?"700":"400")}if(t.widget){const i=t.widget;if(i.header_text_alignment&&(e["--ah-title-align"]=i.header_text_alignment),i.logo_height&&(e["--ah-logo-height"]=i.logo_height+"px"),i.logo_position){const t={center:"center",left:"flex-start",right:"flex-end"};"none"===i.logo_position?e["--ah-logo-display"]="none":e["--ah-logo-align"]=t[i.logo_position]??"center"}i.social_buttons_layout&&("top"===i.social_buttons_layout?(e["--ah-social-order"]="0",e["--ah-divider-order"]="1",e["--ah-fields-order"]="2"):(e["--ah-social-order"]="2",e["--ah-divider-order"]="1",e["--ah-fields-order"]="0"))}if(t.page_background){const i=t.page_background;i.background_color&&(e["--ah-page-bg"]=i.background_color),i.background_image_url&&(e["--ah-page-bg-image"]=`url(${i.background_image_url})`)}return e}const c=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.formSubmit=r(this,"formSubmit"),this.buttonClick=r(this,"buttonClick"),this.linkClick=r(this,"linkClick"),this.navigate=r(this,"navigate"),this.flowComplete=r(this,"flowComplete"),this.flowError=r(this,"flowError"),this.screenChange=r(this,"screenChange")}get el(){return this}screen;apiUrl;branding;theme;loading=!1;autoSubmit=!1;_screen;_branding;_theme;formData={};formSubmit;buttonClick;linkClick;navigate;flowComplete;flowError;screenChange;watchScreen(t){if("string"==typeof t)try{this._screen=JSON.parse(t)}catch{console.error("Failed to parse screen JSON")}else this._screen=t;this._screen&&this.screenChange.emit(this._screen)}watchBranding(t){if("string"==typeof t)try{this._branding=JSON.parse(t)}catch{console.error("Failed to parse branding JSON")}else this._branding=t;this.applyThemeStyles()}watchTheme(t){if("string"==typeof t)try{this._theme=JSON.parse(t)}catch{console.error("Failed to parse theme JSON")}else this._theme=t;this.applyThemeStyles()}applyThemeStyles(){const t=function(t,e){return{...n(t),...h(e)}}(this._branding,this._theme);!function(t,e){Object.entries(e).forEach((([e,i])=>{t.style.setProperty(e,i)}))}(this.el,t)}async componentWillLoad(){this.watchScreen(this.screen),this.watchBranding(this.branding),this.watchTheme(this.theme),this.apiUrl&&!this._screen&&await this.fetchScreen()}async fetchScreen(){if(this.apiUrl){this.loading=!0;try{const t=await fetch(this.apiUrl,{credentials:"include",headers:{Accept:"application/json"}});t.ok&&(this._screen=await t.json(),this._screen&&this.screenChange.emit(this._screen))}catch(t){console.error("Failed to fetch screen:",t)}finally{this.loading=!1}}}handleInputChange=(t,e)=>{this.formData={...this.formData,[t]:e}};handleSubmit=async t=>{if(t.preventDefault(),this._screen&&(this.formSubmit.emit({screen:this._screen,data:this.formData}),this.autoSubmit)){this.loading=!0;try{const t=await fetch(this._screen.action,{method:this._screen.method,credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({data:this.formData})}),e=t.headers.get("content-type");if(e?.includes("application/json")){const e=await t.json();e.redirect?(this.flowComplete.emit({redirectUrl:e.redirect}),this.navigate.emit({url:e.redirect})):e.screen?(this._screen=e.screen,this.formData={},this.screenChange.emit(e.screen),e.branding&&(this._branding=e.branding,this.applyThemeStyles())):e.complete&&this.flowComplete.emit({}),!t.ok&&e.screen&&(this._screen=e.screen,this.screenChange.emit(e.screen))}}catch(t){console.error("Form submission failed:",t),this.flowError.emit({message:t instanceof Error?t.message:"Form submission failed"})}finally{this.loading=!1}}};handleButtonClick=t=>{"submit"!==t.type?this.buttonClick.emit(t):this.handleSubmit({preventDefault:()=>{}})};handleLinkClick=(t,e)=>{this.linkClick.emit({id:e.id,href:e.href,text:e.text}),this.autoSubmit||t.preventDefault()};getScreenErrors(){return this._screen?.messages?.filter((t=>"error"===t.type))||[]}getScreenSuccesses(){return this._screen?.messages?.filter((t=>"success"===t.type))||[]}getOrderedComponents(){return this._screen?[...this._screen.components].filter((t=>!1!==t.visible)).sort(((t,e)=>(t.order??0)-(e.order??0))):[]}isSocialComponent(t){return"SOCIAL"===t.type}isDividerComponent(t){return"DIVIDER"===t.type}render(){if(this.loading&&!this._screen)return s("div",{class:"widget-container"},s("div",{class:"loading-spinner"}));if(!this._screen)return s("div",{class:"widget-container"},s("div",{class:"error-message"},"No screen configuration provided"));const t=this.getScreenErrors(),e=this.getScreenSuccesses(),i=this.getOrderedComponents(),r=i.filter((t=>this.isSocialComponent(t))),a=i.filter((t=>!this.isSocialComponent(t)&&!this.isDividerComponent(t))),o=i.some((t=>this.isDividerComponent(t))),n=this._theme?.widget?.logo_url||this._branding?.logo_url;return s("div",{class:"widget-container",part:"container"},s("header",{class:"widget-header",part:"header"},n&&s("div",{class:"logo-wrapper",part:"logo-wrapper"},s("img",{class:"logo",part:"logo",src:n,alt:"Logo"})),this._screen.title&&s("h1",{class:"title",part:"title"},this._screen.title),this._screen.description&&s("p",{class:"description",part:"description"},this._screen.description)),s("div",{class:"widget-body",part:"body"},t.map((t=>s("div",{class:"message message-error",part:"message message-error",key:t.id??t.text},t.text))),e.map((t=>s("div",{class:"message message-success",part:"message message-success",key:t.id??t.text},t.text))),s("form",{onSubmit:this.handleSubmit,part:"form"},s("div",{class:"form-content"},r.length>0&&s("div",{class:"social-section",part:"social-section"},r.map((t=>s("authhero-node",{key:t.id,component:t,value:this.formData[t.id],onFieldChange:t=>this.handleInputChange(t.detail.id,t.detail.value),onButtonClick:t=>this.handleButtonClick(t.detail),disabled:this.loading})))),r.length>0&&a.length>0&&o&&s("div",{class:"divider",part:"divider"},s("span",{class:"divider-text"},"Or")),s("div",{class:"fields-section",part:"fields-section"},a.map((t=>s("authhero-node",{key:t.id,component:t,value:this.formData[t.id],onFieldChange:t=>this.handleInputChange(t.detail.id,t.detail.value),onButtonClick:t=>this.handleButtonClick(t.detail),disabled:this.loading})))))),this._screen.links&&this._screen.links.length>0&&s("div",{class:"links",part:"links"},this._screen.links.map((t=>s("span",{class:"link-wrapper",part:"link-wrapper",key:t.id??t.href},t.linkText?s("span",null,t.text," ",s("a",{href:t.href,class:"link",part:"link",onClick:e=>this.handleLinkClick(e,{id:t.id,href:t.href,text:t.linkText||t.text})},t.linkText)):s("a",{href:t.href,class:"link",part:"link",onClick:e=>this.handleLinkClick(e,{id:t.id,href:t.href,text:t.text})},t.text)))))))}static get watchers(){return{screen:[{watchScreen:0}],branding:[{watchBranding:0}],theme:[{watchTheme:0}]}}static get style(){return":host{display:block;font-family:var(--ah-font-family, 'ulp-font', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, sans-serif);font-size:var(--ah-font-size-base, 14px);line-height:var(--ah-line-height-base, 1.5);color:var(--ah-color-text, #1e212a);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.widget-container{max-width:var(--ah-widget-max-width, 400px);width:100%;margin:0 auto;background-color:var(--ah-color-bg, #ffffff);border-radius:var(--ah-widget-radius, 5px);box-shadow:var(--ah-widget-shadow, 0 4px 22px 0 rgba(0, 0, 0, 0.11));box-sizing:border-box}.widget-header{padding:var(--ah-header-padding, 40px 48px 24px)}.widget-body{padding:var(--ah-body-padding, 0 48px 40px)}.logo-wrapper{display:var(--ah-logo-display, flex);justify-content:var(--ah-logo-align, center);margin-bottom:8px}.logo{display:block;height:var(--ah-logo-height, 52px);max-width:100%;width:auto;object-fit:contain}.title{font-size:var(--ah-font-size-title, 24px);font-weight:var(--ah-font-weight-title, 700);text-align:var(--ah-title-align, center);margin:var(--ah-title-margin, 24px 0 8px);color:var(--ah-color-header, #1e212a);line-height:1.2}.description{font-size:var(--ah-font-size-description, 14px);text-align:var(--ah-title-align, center);margin:var(--ah-description-margin, 0 0 8px);color:var(--ah-color-text, #1e212a);line-height:1.5}.message{padding:12px 16px;border-radius:4px;margin-bottom:16px;font-size:14px;line-height:1.5}.message-error{background-color:var(--ah-color-error-bg, #ffeaea);color:var(--ah-color-error, #d03c38);border-left:3px solid var(--ah-color-error, #d03c38)}.message-success{background-color:var(--ah-color-success-bg, #e6f9f1);color:var(--ah-color-success, #13a769);border-left:3px solid var(--ah-color-success, #13a769)}form{display:flex;flex-direction:column}.form-content{display:flex;flex-direction:column}.social-section{display:flex;flex-direction:column;gap:8px;order:var(--ah-social-order, 2)}.fields-section{display:flex;flex-direction:column;order:var(--ah-fields-order, 0)}.divider{display:flex;align-items:center;text-align:center;margin:16px 0;order:var(--ah-divider-order, 1)}.divider::before,.divider::after{content:'';flex:1;border-bottom:1px solid var(--ah-color-border-muted, #c9cace)}.divider-text{padding:0 10px;font-size:12px;font-weight:400;color:var(--ah-color-text-muted, #65676e);text-transform:uppercase;letter-spacing:0}.links{display:flex;flex-direction:column;align-items:center;gap:8px;margin-top:16px}.link-wrapper{font-size:14px;color:var(--ah-color-text, #1e212a)}.link{color:var(--ah-color-link, #635dff);text-decoration:var(--ah-link-decoration, none);font-size:14px;font-weight:var(--ah-font-weight-link, 400);transition:color 150ms ease}.link:hover{text-decoration:underline}.link:focus-visible{outline:2px solid var(--ah-color-link, #635dff);outline-offset:2px;border-radius:2px}.loading-spinner{width:32px;height:32px;margin:24px auto;border:3px solid var(--ah-color-border-muted, #e0e1e3);border-top-color:var(--ah-color-primary, #635dff);border-radius:50%;animation:spin 0.8s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.error-message{text-align:center;color:var(--ah-color-error, #d03c38);padding:16px;font-size:14px}@media (max-width: 480px){:host{display:block;width:100%;min-height:100vh;background-color:var(--ah-color-bg, #ffffff)}.widget-container{box-shadow:none;border-radius:0;max-width:none;width:100%;margin:0}.widget-header{padding:24px 16px 16px}.widget-body{padding:0 16px 24px}}"}},[513,"authhero-widget",{screen:[1],apiUrl:[1,"api-url"],branding:[1],theme:[1],loading:[1028],autoSubmit:[4,"auto-submit"],_screen:[32],_branding:[32],_theme:[32],formData:[32]},void 0,{screen:[{watchScreen:0}],branding:[{watchBranding:0}],theme:[{watchTheme:0}]}]);function l(){"undefined"!=typeof customElements&&["authhero-widget","authhero-node"].forEach((e=>{switch(e){case"authhero-widget":customElements.get(t(e))||customElements.define(t(e),c);break;case"authhero-node":customElements.get(t(e))||a()}}))}l();const d=c,p=l;export{d as AuthheroWidget,p as defineCustomElement}
|