@luzmo/lucero 2.9.1 → 2.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/components/index.cjs +1 -1
- package/components/index.js +1 -1
- package/components/question-box/index.cjs +1 -1
- package/components/question-box/index.js +1 -1
- package/components/question-box/question-box-templates.d.ts +2 -0
- package/components/question-box/question-box.d.ts +6 -0
- package/components/question-box-B7JHOnKn.cjs +403 -0
- package/components/{question-box-BzYZzwyR.js → question-box-D3eWOKeD.js} +147 -137
- package/custom-elements.json +1 -1
- package/package.json +1 -1
- package/standalone/question-box.js +75 -73
- package/components/question-box-DvQ-Gi_Q.cjs +0 -401
package/package.json
CHANGED
|
@@ -17,46 +17,48 @@
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";import{b as r,c as i,d as a,f as o,i as s,l as c,v as l,x as u}from"./chunks/lucero-runtime-BkqJ2L5f.js";import{t as d}from"./chunks/luzmoAngleRight-B-rZQuxv.js";import{t as f}from"./chunks/luzmoAngleLeft-ebJO7ROy.js";import"./chunks/action-button-CFXQ66x-.js";import{t as ee}from"./chunks/roving-tabindex-CivopiNn.js";import"./chunks/icon-CYZJZELU.js";import{t as p}from"./chunks/language-resolution-BwIkGyuH.js";import"./chunks/badge-C1_QvLsq.js";import"./chunks/checkbox-DYjPiIwY.js";import"./field-group.js";import"./chunks/text-field-KnOMaj3Y.js";import"./chunks/button-lnvFyXi7.js";import{t as m}from"./chunks/repeat-CtNle5_O.js";import{t as te}from"./chunks/keyed-DYJaQjip.js";import"./chunks/radio-fCBCSuw9.js";var h={icon:[32,32,`M26 .25c-.97 0-1.97.3-2.7 1.04l-19 19a1 1 0 0 0-.2.3l-.03.04-4 10a1 1 0 0 0 1.3 1.3l10-4 .03-.02c.12-.05.3-.2.3-.2L27.42 12l3.3-3.3A3.78 3.78 0 0 0 31.75 6c0-.97-.3-1.97-1.04-2.7l-2-2A3.78 3.78 0 0 0 26 .24Zm0 2c.53 0 1.03.2 1.3.46l2 2c.26.26.45.76.45 1.29s-.2 1.03-.46 1.3L26 10.58 21.41 6l3.3-3.3c.26-.26.76-.45 1.29-.45Zm-6 5.16L24.59 12 12 24.59V24a1 1 0 0 0-1-1H9v-2a1 1 0 0 0-1-1h-.59Zm-.16 2.6a1 1 0 0 0-.55.28l-7 7a1 1 0 0 0 1.42 1.42l7-7a1 1 0 0 0-.87-1.7zM5.68 22H7v2a1 1 0 0 0 1 1h2v1.32l-5.4 2.16-1.08-1.08Z`],name:`pencil`},g=`:host{font-family:var(--question-box-font-family);font-size:var(--question-box-font-size);color:var(--highcontrast-question-box-color,var(--question-box-color));box-sizing:border-box;inline-size:100%;max-inline-size:var(--luzmo-question-box-max-inline-size,var(--question-box-max-inline-size));display:block}:host([disabled]){pointer-events:none}.card{gap:var(--question-box-gap);padding:var(--question-box-padding);box-sizing:border-box;border-width:var(--question-box-border-width);border-style:solid;border-color:var(--highcontrast-question-box-border-color,var(--question-box-border-color));border-radius:var(--question-box-border-radius);background-color:var(--highcontrast-question-box-background-color,var(--question-box-background-color));flex-direction:column;display:flex}.header{justify-content:space-between;align-items:flex-start;gap:var(--question-box-header-gap);display:flex}.header-actions,.step-navigation{align-items:center;display:flex}.header-actions{gap:var(--question-box-header-actions-gap);min-block-size:0;block-size:max(var(--question-box-title-font-size) * var(--question-box-title-line-height), var(--question-box-header-control-size) - 2 * (var(--question-box-padding) - var(--question-box-header-actions-inset)));flex-shrink:0;margin-inline-start:auto;overflow:visible}.step-navigation{gap:var(--question-box-copy-gap)}.heading{gap:var(--question-box-heading-copy-gap);flex-direction:column;min-inline-size:0;display:flex}.progress{font-size:var(--question-box-progress-font-size);color:var(--question-box-muted-color);margin:0}.title{font-size:var(--question-box-title-font-size);font-weight:var(--luzmo-font-weight-bold);line-height:var(--question-box-title-line-height);margin:0}.title:focus,.summary-heading:focus{outline:none}.title:focus-visible,.summary-heading:focus-visible{-webkit-text-decoration-color:var(--question-box-focus-ring-color);text-decoration-color:var(--question-box-focus-ring-color);text-decoration-line:underline;text-decoration-thickness:var(--question-box-focus-ring-width);text-underline-offset:var(--question-box-focus-ring-gap);outline:none}.description{color:var(--question-box-muted-color);font-size:inherit;margin:0;margin-block-start:var(--question-box-heading-copy-offset);line-height:1.4}.close{flex-shrink:0}.body{gap:var(--question-box-option-gap);max-block-size:var(--luzmo-question-box-body-max-block-size,var(--question-box-body-max-block-size));padding-block:var(--question-box-body-focus-inset);margin-block:calc(var(--question-box-body-focus-inset) * -1);flex-direction:column;display:flex;overflow:hidden auto}.body::-webkit-scrollbar{width:var(--luzmo-question-box-scrollbar-width,var(--question-box-scrollbar-width));height:var(--luzmo-question-box-scrollbar-width,var(--question-box-scrollbar-width))}.body::-webkit-scrollbar-track{background:var(--luzmo-question-box-scrollbar-track-background,var(--question-box-scrollbar-track-background));border-radius:var(--luzmo-question-box-scrollbar-track-border-radius,var(--question-box-scrollbar-track-border-radius))}.body::-webkit-scrollbar-thumb{background:var(--luzmo-question-box-scrollbar-thumb-background,var(--question-box-scrollbar-thumb-background));border-radius:var(--luzmo-question-box-scrollbar-thumb-border-radius,var(--question-box-scrollbar-thumb-border-radius))}.body::-webkit-scrollbar-thumb:hover{background:var(--luzmo-question-box-scrollbar-thumb-hover-background,var(--question-box-scrollbar-thumb-hover-background))}.body{scrollbar-width:var(--luzmo-scrollbar-width,thin);scrollbar-color:var(--luzmo-question-box-scrollbar-thumb-background,var(--question-box-scrollbar-thumb-background)) var(--luzmo-question-box-scrollbar-track-background,var(--question-box-scrollbar-track-background))}.options{box-sizing:border-box;flex-direction:column;inline-size:100%;min-inline-size:0;display:flex}.options--descriptive luzmo-radio,.options--descriptive luzmo-checkbox,.options--descriptive .other-option-answer{padding-block:var(--luzmo-question-box-descriptive-option-padding-block,var(--question-box-descriptive-option-padding-block))}.body:has(.options--descriptive){margin-block:calc(var(--question-box-option-padding-block) - var(--question-box-body-focus-inset) - var(--luzmo-question-box-descriptive-option-padding-block,var(--question-box-descriptive-option-padding-block)))}luzmo-radio,luzmo-checkbox{box-sizing:border-box;inline-size:100%;min-block-size:var(--question-box-option-min-block-size);padding-block:var(--question-box-option-padding-block);padding-inline:var(--question-box-option-padding-inline);border-block-end-width:var(--luzmo-question-box-divider-width,var(--question-box-divider-width));border-block-end-style:solid;border-block-end-color:var(--luzmo-question-box-divider-color,var(--question-box-divider-color));border-radius:var(--luzmo-border-radius-s);align-items:center;display:flex}luzmo-radio:hover,luzmo-checkbox:hover{background-color:var(--question-box-option-hover-background)}.other-option-row{align-items:center;gap:var(--question-box-option-gap);box-sizing:border-box;border-block-end-width:var(--luzmo-question-box-divider-width,var(--question-box-divider-width));border-block-end-style:solid;border-block-end-color:var(--luzmo-question-box-divider-color,var(--question-box-divider-color));inline-size:100%;max-inline-size:100%;display:flex}.other-option-answer{align-items:center;gap:var(--question-box-option-gap);box-sizing:border-box;min-inline-size:0;min-block-size:var(--question-box-option-min-block-size);padding-block:var(--question-box-option-padding-block);padding-inline:var(--question-box-option-padding-inline);border-radius:var(--luzmo-border-radius-s);flex:1;display:flex}.other-option-answer:hover{background-color:var(--question-box-option-hover-background)}luzmo-radio.other-option,luzmo-checkbox.other-option{border:0;flex:none;min-block-size:auto;inline-size:auto;padding:0}luzmo-radio.other-option{--luzmo-radio-button-top-to-control:0px}luzmo-radio.numbered-option{--luzmo-radio-button-control-size:0px;--luzmo-radio-button-top-to-control:0px;--luzmo-radio-text-to-control:0px;--luzmo-radio-border-width:0px;--luzmo-radio-focus-indicator-width:0px}luzmo-checkbox.numbered-option{--luzmo-checkbox-control-size:0px;--luzmo-checkbox-text-to-control:0px;--luzmo-checkbox-top-to-text:0px;--luzmo-checkbox-border-width:0px;--luzmo-checkbox-selected-border-width:0px;--luzmo-checkbox-focus-indicator-width:0px}luzmo-radio.numbered-option::part(control),luzmo-checkbox.numbered-option::part(control){display:none}luzmo-radio.other-option:hover,luzmo-checkbox.other-option:hover{background-color:#0000}.other-field{inline-size:auto;min-inline-size:0;max-inline-size:100%;min-block-size:var(--question-box-other-field-min-block-size);font-size:var(--question-box-other-field-font-size);--luzmo-text-field-width:100%;--luzmo-text-field-height:var(--question-box-other-field-min-block-size);--luzmo-text-field-background-color:transparent;--luzmo-text-field-background-color-disabled:transparent;--luzmo-text-field-placeholder-font-size:var(--question-box-other-field-font-size);--luzmo-text-field-border-width:0px;--luzmo-text-field-spacing-inline:0px;--luzmo-text-field-spacing-block-start:0px;--luzmo-text-field-spacing-block-end:0px;flex:1;justify-content:center}.other-primary{flex:none}.other-actions{box-sizing:border-box;justify-content:flex-end;align-items:center;gap:var(--question-box-copy-gap-detailed);inline-size:100%;padding-inline:var(--question-box-option-padding-inline);margin-block-start:var(--question-box-copy-gap-detailed);display:flex}.selected-count{font-size:var(--luzmo-question-box-selected-count-font-size,var(--question-box-selected-count-font-size))}.other-actions .selected-count{min-inline-size:0;margin-inline-end:auto}.other-actions luzmo-button{flex:none}.status-error{--luzmo-helptext-font-size:var(--luzmo-question-box-selected-count-font-size,var(--question-box-selected-count-font-size));--luzmo-helptext-min-height:0;--luzmo-helptext-top-to-text:0;--luzmo-helptext-bottom-to-text:0}.visually-hidden{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.option-content{align-items:flex-start;gap:var(--question-box-option-gap);inline-size:100%;display:flex}.option-number{forced-color-adjust:none;inline-size:var(--question-box-option-number-size);block-size:var(--question-box-option-number-size);box-sizing:border-box;border:var(--luzmo-border-width) solid var(--highcontrast-question-box-option-number-border-color,var(--question-box-option-number-border-color));border-radius:var(--luzmo-border-radius);color:var(--highcontrast-question-box-option-number-color,var(--question-box-option-number-color));background-color:var(--highcontrast-question-box-option-number-background,var(--question-box-option-number-background));transition:color var(--luzmo-animation-duration) ease-in-out, border-color var(--luzmo-animation-duration) ease-in-out, background-color var(--luzmo-animation-duration) ease-in-out;flex:none;justify-content:center;align-items:center;line-height:1;display:inline-flex}luzmo-radio[checked] .option-number,luzmo-checkbox[checked] .option-number{color:var(--highcontrast-question-box-option-number-selected-color,var(--question-box-option-number-selected-color));border-color:var(--highcontrast-question-box-option-number-selected-background,var(--question-box-option-number-selected-background));background-color:var(--highcontrast-question-box-option-number-selected-background,var(--question-box-option-number-selected-background))}luzmo-radio[data-focus-visible] .option-number,luzmo-checkbox[data-focus-visible] .option-number,.option-number--focused{outline:var(--luzmo-question-box-focus-ring-width,var(--question-box-focus-ring-width)) solid var(--highcontrast-question-box-focus-ring-color,var(--luzmo-question-box-focus-ring-color,var(--question-box-focus-ring-color)));outline-offset:var(--luzmo-question-box-focus-ring-gap,var(--question-box-focus-ring-gap))}luzmo-radio[disabled] .option-number,luzmo-checkbox[disabled] .option-number{opacity:.5}.option-copy{gap:var(--question-box-copy-gap);flex-direction:column;flex:1;min-inline-size:0;display:flex}.option-edit luzmo-icon{color:inherit}.option-heading{align-items:center;gap:var(--question-box-recommended-gap);min-block-size:var(--question-box-option-number-size);flex-wrap:wrap;display:flex}.option-text{align-items:baseline;gap:var(--question-box-recommended-gap);flex-wrap:wrap;min-inline-size:0;display:flex}.option-description{color:var(--question-box-muted-color);line-height:1.4}.option-hint{color:var(--question-box-muted-color);font-size:var(--luzmo-font-size-s)}.footer{justify-content:space-between;align-items:center;gap:var(--question-box-option-gap);flex-wrap:wrap;display:flex}.status{color:var(--question-box-muted-color);font-size:var(--luzmo-question-box-selected-count-font-size,var(--question-box-selected-count-font-size))}.actions{justify-content:flex-end;gap:var(--question-box-recommended-gap);flex-wrap:wrap;margin-inline-start:auto;display:flex}:host([dir=rtl]) .step-navigation luzmo-icon{transform:scaleX(-1)}.resolved{gap:var(--question-box-summary-gap)}.summary-actions{justify-content:flex-end;gap:var(--question-box-recommended-gap);flex-wrap:wrap;display:flex}.summary{gap:var(--question-box-option-gap);flex-direction:column;display:flex}.summary-heading{font-size:var(--question-box-title-font-size);line-height:var(--question-box-title-line-height);margin:0}.summary-row{gap:var(--question-box-copy-gap);flex-direction:column;display:flex}.summary-title{color:var(--question-box-muted-color);font-size:var(--luzmo-font-size-s)}.summary-answer{font-weight:var(--luzmo-font-weight-bold)}@media (prefers-reduced-motion:reduce){.option-number{transition-duration:0s}}@media (forced-colors:active){:host{--highcontrast-question-box-border-color:CanvasText;--highcontrast-question-box-background-color:Canvas;--highcontrast-question-box-color:CanvasText;--highcontrast-question-box-focus-ring-color:Highlight;--highcontrast-question-box-option-number-border-color:ButtonText;--highcontrast-question-box-option-number-color:ButtonText;--highcontrast-question-box-option-number-background:Canvas;--highcontrast-question-box-option-number-selected-background:Highlight;--highcontrast-question-box-option-number-selected-color:HighlightText}}:host{--question-box-font-family:var(--luzmo-font-family);--question-box-font-size:var(--luzmo-font-size-m);--question-box-color:var(--luzmo-font-color);--question-box-muted-color:color-mix(in srgb, var(--luzmo-font-color) 80%, var(--luzmo-background-color));--question-box-background-color:var(--luzmo-background-color);--question-box-border-color:var(--luzmo-border-color);--question-box-border-width:var(--luzmo-border-width);--question-box-border-radius:var(--luzmo-border-radius-l);--question-box-padding:var(--luzmo-spacing-5);--question-box-gap:var(--luzmo-spacing-4);--question-box-header-gap:var(--luzmo-spacing-3);--question-box-header-actions-gap:var(--luzmo-spacing-2);--question-box-header-actions-inset:var(--luzmo-spacing-2);--question-box-header-control-size:var(--luzmo-component-height);--question-box-max-inline-size:40rem;--question-box-body-max-block-size:24rem;--question-box-title-font-size:var(--question-box-font-size);--question-box-title-line-height:1.3;--question-box-progress-font-size:var(--luzmo-font-size-s);--question-box-selected-count-font-size:var(--luzmo-font-size-s);--question-box-option-min-block-size:var(--luzmo-component-height);--question-box-option-hover-background:var(--luzmo-background-color-hover);--question-box-option-number-size:var(--luzmo-component-height-xs);--question-box-descriptive-option-padding-block:var(--question-box-option-padding-block);--question-box-option-padding-block:var(--luzmo-spacing-1);--question-box-option-padding-inline:var(--luzmo-spacing-3);--question-box-option-gap:var(--luzmo-spacing-3);--question-box-heading-copy-gap:0px;--question-box-heading-copy-offset:calc(var(--question-box-font-size) * -.25);--question-box-copy-gap:var(--luzmo-spacing-1);--question-box-copy-gap-detailed:var(--luzmo-spacing-2);--question-box-recommended-gap:var(--luzmo-spacing-2);--question-box-summary-gap:var(--luzmo-spacing-4);--question-box-body-focus-inset:calc(var(--luzmo-indicator-gap) + var(--luzmo-indicator-width));--question-box-focus-ring-width:var(--luzmo-indicator-width);--question-box-focus-ring-gap:var(--luzmo-indicator-gap);--question-box-focus-ring-color:var(--luzmo-indicator-color);--question-box-divider-width:0px;--question-box-option-number-background:var(--luzmo-background-color);--question-box-option-number-border-color:var(--luzmo-border-color);--question-box-option-number-color:var(--luzmo-font-color);--question-box-option-number-selected-background:var(--luzmo-primary);--question-box-option-number-selected-color:var(--luzmo-primary-inverse-color);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size);--question-box-divider-color:var(--luzmo-border-color);--question-box-scrollbar-width:var(--luzmo-scrollbar-size);--question-box-scrollbar-track-background:var(--luzmo-scrollbar-track-background);--question-box-scrollbar-track-border-radius:var(--luzmo-scrollbar-track-border-radius);--question-box-scrollbar-thumb-background:var(--luzmo-scrollbar-thumb-background);--question-box-scrollbar-thumb-border-radius:var(--luzmo-scrollbar-thumb-border-radius);--question-box-scrollbar-thumb-hover-background:var(--luzmo-scrollbar-thumb-hover-background)}:host([size=s]){--question-box-padding:var(--luzmo-spacing-4);--question-box-font-size:var(--luzmo-font-size-s);--question-box-selected-count-font-size:var(--luzmo-font-size-xs);--question-box-title-font-size:var(--question-box-font-size);--question-box-header-control-size:var(--luzmo-component-height-s);--question-box-option-min-block-size:var(--luzmo-component-height-s);--question-box-option-number-size:var(--luzmo-component-height-xs);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size)}:host([size=l]){--question-box-font-size:var(--luzmo-font-size-l);--question-box-selected-count-font-size:var(--luzmo-font-size-m);--question-box-title-font-size:var(--question-box-font-size);--question-box-header-control-size:var(--luzmo-component-height-l);--question-box-option-min-block-size:var(--luzmo-component-height-l);--question-box-option-number-size:var(--luzmo-component-height-s);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size)}:host([size=xl]){--question-box-font-size:var(--luzmo-font-size-xl);--question-box-selected-count-font-size:var(--luzmo-font-size-l);--question-box-title-font-size:var(--question-box-font-size);--question-box-header-control-size:var(--luzmo-component-height-xl);--question-box-option-min-block-size:var(--luzmo-component-height-xl);--question-box-option-number-size:var(--luzmo-component-height);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size)}`,_=`__other__`,v={continue:`Next`,back:`Back`,submit:`Submit`,skip:`Skip`,change:`Change`,close:`Close`,other:`Something else`,otherPlaceholder:`Something else`,recommended:`Recommended`,answerTitle:`Answer`,answersTitle:`Answers`,progress:`{current} of {total}`,selectedCount:`{count} selected`,selectedCountOne:`{count} selected`,recommendedSuffix:`{label} ({recommended})`,answer:`{answer}`,requiredSelectionDescription:`Choose one or more options.`,selectionRangeDescription:`Choose between {min} and {max} options.`,minSelectedError:`Choose at least {min} options.`,maxSelectedError:`Choose at most {max} options.`,otherRequiredError:`Enter a value for this option.`},y=e=>`${e}Other`,b=e=>!!e.other||e.options.length===0,x=e=>typeof e.other==`object`&&e.other?e.other:{},S=e=>Object.fromEntries(Object.entries(e)),C=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})},w=(e,t)=>{let n=/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(Array.isArray(n)||Array.isArray(i)){if(!Array.isArray(n)||!Array.isArray(i)||n.length!==i.length||n.some((e,t)=>e!==i[t]))return!1}else if(n!==i)return!1}return!0},T=e=>{let t=/* @__PURE__ */ new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n},ne=e=>{let t=new Set(e.options.map(e=>e.value));return b(e)&&t.add(_),t},E=(e,t)=>{let n=t[e.id];return e.type===`single`?typeof n==`string`&&n?[n]:[]:Array.isArray(n)?T(n):[]},D=(e,t)=>E(e,t).includes(_),O=e=>{let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0));return{...v,...t}},k=(e,t)=>{let n=e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{${e}}`,r);return n},A=e=>{let t=/* @__PURE__ */ new Set;for(let n of e){if(!n.id)throw TypeError(`luzmo-question-box: every question needs an id.`);if(t.has(n.id))throw TypeError(`luzmo-question-box: duplicate question id "${n.id}".`);t.add(n.id);let r=y(n.id);if(e.some(e=>e.id===r))throw TypeError(`luzmo-question-box: question id "${r}" collides with Other text for "${n.id}".`);if(n.type!==`multiple`&&(n.minSelected!==void 0||n.maxSelected!==void 0))throw TypeError(`luzmo-question-box: minSelected and maxSelected only apply to multiple-choice question "${n.id}".`);for(let[e,t]of[[`minSelected`,n.minSelected],[`maxSelected`,n.maxSelected]])if(t!==void 0&&(!Number.isInteger(t)||t<0))throw TypeError(`luzmo-question-box: ${e} must be a non-negative integer on "${n.id}".`);let i=n.minSelected??+!!n.required;if(n.maxSelected!==void 0&&i>n.maxSelected)throw TypeError(`luzmo-question-box: minSelected cannot exceed maxSelected on "${n.id}".`);let a=n.options.filter(e=>!e.disabled).length+ +!!b(n);if(n.type===`multiple`&&i>a)throw TypeError(`luzmo-question-box: minSelected exceeds the available options on "${n.id}".`);let o=/* @__PURE__ */ new Set;for(let e of n.options){if(!e.value)throw TypeError(`luzmo-question-box: option values cannot be empty on "${n.id}".`);if(e.value===`__other__`)throw TypeError(`luzmo-question-box: "${_}" is reserved on "${n.id}".`);if(o.has(e.value))throw TypeError(`luzmo-question-box: duplicate option value "${e.value}" on "${n.id}".`);o.add(e.value)}}},j=(e,t)=>{let n=Object.fromEntries([]);for(let r of e){let e=ne(r),i=t[r.id],a=Object.hasOwn(t,r.id);if(r.type===`single`)typeof i==`string`&&e.has(i)?C(n,r.id,i):!a&&typeof r.default==`string`&&(e.has(r.default)||r.options.length===0)&&C(n,r.id,r.options.length===0?_:r.default);else{let t=[...r.options.map(e=>e.value),...b(r)?[_]:[]],o=T(Array.isArray(i)?i.filter(t=>e.has(t)):[]);if(o.length>0)C(n,r.id,t.filter(e=>o.includes(e)));else if(!a&&Array.isArray(r.default)){let i=T(r.default.filter(t=>e.has(t)));i.length>0&&C(n,r.id,t.filter(e=>i.includes(e)))}}let o=y(r.id),s=t[o];typeof s==`string`?C(n,o,s):!a&&r.options.length===0&&typeof r.default==`string`&&C(n,o,r.default)}return n},M=e=>e.minSelected??+!!e.required,re=(e,t)=>{let n=M(e),r=e.maxSelected;return n>0&&r!==void 0?k(t.selectionRangeDescription,{min:String(n),max:String(r)}):n===1?t.requiredSelectionDescription:n>1?k(t.minSelectedError,{min:String(n)}):r===void 0?void 0:k(t.maxSelectedError,{max:String(r)})},N=(e,t)=>{let n=E(e,t),r=M(e),i=e.maxSelected;if(n.length<r)return r<=1?`missing`:`minimum`;if(i!==void 0&&n.length>i)return`maximum`;if(D(e,t)&&!String(t[y(e.id)]??``).trim())return`otherText`},ie=(e,t)=>N(e,t)!==void 0,ae=(e,t,n)=>{switch(N(e,t)){case`minimum`:return k(n.minSelectedError,{min:String(M(e))});case`maximum`:return k(n.maxSelectedError,{max:String(e.maxSelected)});case`otherText`:return n.otherRequiredError;default:return}},oe=(e,t,n,r,i)=>{if(i||t.disabled)return!0;if(e.type!==`multiple`||n)return!1;let a=e.maxSelected;return a!==void 0&&E(e,r).length>=a},se=(e,t)=>k(e===1?t.selectedCountOne:t.selectedCount,{count:String(e)}),P,ce=(e,t)=>{try{return P?.language!==t&&(P={language:t,formatter:new Intl.ListFormat(t,{style:`narrow`,type:`conjunction`})}),P.formatter.format(e)}catch{return e.join(`, `)}},le=(e,t)=>e.recommended?k(t.recommendedSuffix,{label:e.label,recommended:t.recommended}):e.label,F=e=>{let t=e.options.map(e=>({const:e.value,title:e.label}));return b(e)&&e.options.length>0&&t.push({const:_,title:typeof e.other==`object`&&e.other.label||v.other}),t},I=e=>{let t={type:`string`};return typeof e.other==`object`&&e.other.label&&(t.title=e.other.label),t},L=e=>{let t=[],n=[];for(let r of e){if(r.options.length===0){let e={type:`string`};r.title&&(e.title=r.title),r.description&&(e.description=r.description),typeof r.default==`string`&&(e.default=r.default),t.push([r.id,e]),r.required&&n.push(r.id);continue}let e=F(r);if(r.type===`single`){let n={type:`string`,oneOf:e};r.title&&(n.title=r.title),r.description&&(n.description=r.description),typeof r.default==`string`&&r.options.some(e=>e.value===r.default)&&(n.default=r.default),t.push([r.id,n])}else{let n={type:`array`,items:{anyOf:e}};r.title&&(n.title=r.title),r.description&&(n.description=r.description);let i=r.minSelected??(r.required?1:void 0);if(i!==void 0&&(n.minItems=i),r.maxSelected!==void 0&&(n.maxItems=r.maxSelected),Array.isArray(r.default)){let t=new Set(e.map(e=>e.const)),i=r.default.filter(e=>t.has(e));i.length>0&&(n.default=i)}t.push([r.id,n])}r.required&&n.push(r.id),b(r)&&t.push([y(r.id),I(r)])}let r=Object.fromEntries(t);return n.length>0?{type:`object`,properties:r,required:n}:{type:`object`,properties:r}},R=(e,t)=>String(t[y(e.id)]??``).trim(),z=(e,t)=>{let n=[];for(let r of e){let e=R(r,t);if(r.options.length===0){e&&n.push([r.id,e]);continue}let i=E(r,t);r.type===`single`?i[0]&&n.push([r.id,i[0]]):i.length>0&&n.push([r.id,[...i]]),b(r)&&D(r,t)&&e&&n.push([y(r.id),e])}return Object.fromEntries(n)},B=e=>!!e&&typeof e==`object`&&!Array.isArray(e),V=e=>B(e)?e:{},H=e=>{let t=e.oneOf??e.items?.anyOf;if(Array.isArray(t)){let e=[],n=/* @__PURE__ */ new Set;for(let r of t)B(r)&&typeof r.const==`string`&&r.const&&!n.has(r.const)&&(n.add(r.const),e.push({value:r.const,label:typeof r.title==`string`&&r.title?r.title:r.const}));return{declared:!0,options:e}}let n=e.enum??e.items?.enum;if(Array.isArray(n)){let t=e.enumNames??e.items?.enumNames,r=/* @__PURE__ */ new Set,i=[];for(let[e,a]of n.entries()){if(typeof a!=`string`||!a||r.has(a))continue;r.add(a);let n=t?.[e];i.push({value:a,label:typeof n==`string`&&n?n:a})}return{declared:!0,options:i}}return{declared:!1,options:[]}},U=e=>y(e),W=e=>e.format!==void 0||e.minLength!==void 0||e.maxLength!==void 0||e.pattern!==void 0,ue=e=>e.type===`string`&&!H(e).declared&&!W(e),de=e=>{if(e.type!==`object`||!e.properties)return[];let t=e.properties,n=new Set(e.required??[]),r=/* @__PURE__ */ new Set;for(let e of Object.keys(t)){let n=U(e),i=H(V(t[e])),a=V(t[n]);n in t&&ue(a)&&i.options.some(e=>e.value===`__other__`)&&r.add(n)}let i=[];for(let[e,a]of Object.entries(t)){if(r.has(e))continue;let o=V(a),s=H(o),c=s.options.some(e=>e.value===_),l=U(e);if(c&&!r.has(l))continue;let u=s.options.filter(e=>e.value!==_);if(o.type===`number`||o.type===`integer`||o.type===`boolean`||o.type!==`string`&&o.type!==`array`||s.declared&&s.options.length===0||o.type===`array`&&!s.declared||o.type===`string`&&!s.declared&&W(o))continue;let d={id:e,type:o.type===`array`?`multiple`:`single`,title:o.title||e,options:u};if(o.description&&(d.description=o.description),n.has(e)&&(d.required=!0),o.type===`array`?(o.minItems!==void 0&&(d.minSelected=o.minItems),o.maxItems!==void 0&&(d.maxSelected=o.maxItems),Array.isArray(o.default)&&o.default.length>0&&(d.default=o.default)):typeof o.default==`string`&&(d.default=o.default),c&&l in t){let e=V(t[l]);d.other=!e.title||{label:e.title}}i.push(d)}return i};function G(e){switch(e){case`m`:return`xs`;case`l`:return`s`;case`xl`:case`xxl`:return`m`;default:return`xxs`}}function K(e){return e.step>=e.questions.length-1}function q(e,t){return e.disabled?!0:e.readonly?K(e):e.questionInvalid(t)}function fe(e,t){let n=e.selectedValues(t);return n.length===0?``:ce(n.map(n=>{if(n===`__other__`)return String(e.value[y(t.id)]??e.copy.other);let r=t.options.find(e=>e.value===n);return r?le(r,e.copy):n}),e.language)}function pe(n,r){let i=fe(n,r),a=n.copy.answer.split(`{answer}`).map((n,r)=>e`${r>0?e`<span class="summary-answer">${i}</span>`:t}${n}`);return e`<span class="summary-value">${a}</span>`}function me(n){let r=n.copy,i=n.questions.reduce((e,t)=>e+n.selectedValues(t).length,0);return e`
|
|
20
|
+
import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";import{b as r,c as i,d as a,f as o,i as s,l as c,v as l,x as u}from"./chunks/lucero-runtime-BkqJ2L5f.js";import{t as d}from"./chunks/luzmoAngleRight-B-rZQuxv.js";import{t as ee}from"./chunks/luzmoAngleLeft-ebJO7ROy.js";import"./chunks/action-button-CFXQ66x-.js";import{t as te}from"./chunks/roving-tabindex-CivopiNn.js";import"./chunks/icon-CYZJZELU.js";import{t as ne}from"./chunks/language-resolution-BwIkGyuH.js";import"./chunks/badge-C1_QvLsq.js";import"./chunks/checkbox-DYjPiIwY.js";import"./field-group.js";import"./chunks/text-field-KnOMaj3Y.js";import"./chunks/button-lnvFyXi7.js";import{t as f}from"./chunks/repeat-CtNle5_O.js";import{t as re}from"./chunks/keyed-DYJaQjip.js";import"./chunks/radio-fCBCSuw9.js";var p={icon:[32,32,`M26 .25c-.97 0-1.97.3-2.7 1.04l-19 19a1 1 0 0 0-.2.3l-.03.04-4 10a1 1 0 0 0 1.3 1.3l10-4 .03-.02c.12-.05.3-.2.3-.2L27.42 12l3.3-3.3A3.78 3.78 0 0 0 31.75 6c0-.97-.3-1.97-1.04-2.7l-2-2A3.78 3.78 0 0 0 26 .24Zm0 2c.53 0 1.03.2 1.3.46l2 2c.26.26.45.76.45 1.29s-.2 1.03-.46 1.3L26 10.58 21.41 6l3.3-3.3c.26-.26.76-.45 1.29-.45Zm-6 5.16L24.59 12 12 24.59V24a1 1 0 0 0-1-1H9v-2a1 1 0 0 0-1-1h-.59Zm-.16 2.6a1 1 0 0 0-.55.28l-7 7a1 1 0 0 0 1.42 1.42l7-7a1 1 0 0 0-.87-1.7zM5.68 22H7v2a1 1 0 0 0 1 1h2v1.32l-5.4 2.16-1.08-1.08Z`],name:`pencil`},m=`:host{font-family:var(--question-box-font-family);font-size:var(--question-box-font-size);color:var(--highcontrast-question-box-color,var(--question-box-color));box-sizing:border-box;inline-size:100%;max-inline-size:var(--luzmo-question-box-max-inline-size,var(--question-box-max-inline-size));display:block}:host([disabled]){pointer-events:none}.card{gap:var(--question-box-gap);padding:var(--question-box-padding);box-sizing:border-box;border-width:var(--question-box-border-width);border-style:solid;border-color:var(--highcontrast-question-box-border-color,var(--question-box-border-color));border-radius:var(--question-box-border-radius);background-color:var(--highcontrast-question-box-background-color,var(--question-box-background-color));flex-direction:column;display:flex}.header{justify-content:space-between;align-items:flex-start;gap:var(--question-box-header-gap);display:flex}.header-actions,.step-navigation{align-items:center;display:flex}.header-actions{gap:var(--question-box-header-actions-gap);min-block-size:0;block-size:max(var(--question-box-title-font-size) * var(--question-box-title-line-height), var(--question-box-header-control-size) - 2 * (var(--question-box-padding) - var(--question-box-header-actions-inset)));flex-shrink:0;margin-inline-start:auto;overflow:visible}.step-navigation{gap:var(--question-box-copy-gap)}.heading{gap:var(--question-box-heading-copy-gap);flex-direction:column;min-inline-size:0;display:flex}.progress{font-size:var(--question-box-progress-font-size);color:var(--question-box-muted-color);margin:0}.title{font-size:var(--question-box-title-font-size);font-weight:var(--luzmo-font-weight-bold);line-height:var(--question-box-title-line-height);margin:0}.title:focus,.summary-heading:focus{outline:none}.title:focus-visible,.summary-heading:focus-visible{-webkit-text-decoration-color:var(--question-box-focus-ring-color);text-decoration-color:var(--question-box-focus-ring-color);text-decoration-line:underline;text-decoration-thickness:var(--question-box-focus-ring-width);text-underline-offset:var(--question-box-focus-ring-gap);outline:none}.description{color:var(--question-box-muted-color);font-size:inherit;margin:0;margin-block-start:var(--question-box-heading-copy-offset);line-height:1.4}.close{flex-shrink:0}.body{gap:var(--question-box-option-gap);max-block-size:var(--luzmo-question-box-body-max-block-size,var(--question-box-body-max-block-size));padding-block:var(--question-box-body-focus-inset);margin-block:calc(var(--question-box-body-focus-inset) * -1);flex-direction:column;display:flex;overflow:hidden auto}.body::-webkit-scrollbar{width:var(--luzmo-question-box-scrollbar-width,var(--question-box-scrollbar-width));height:var(--luzmo-question-box-scrollbar-width,var(--question-box-scrollbar-width))}.body::-webkit-scrollbar-track{background:var(--luzmo-question-box-scrollbar-track-background,var(--question-box-scrollbar-track-background));border-radius:var(--luzmo-question-box-scrollbar-track-border-radius,var(--question-box-scrollbar-track-border-radius))}.body::-webkit-scrollbar-thumb{background:var(--luzmo-question-box-scrollbar-thumb-background,var(--question-box-scrollbar-thumb-background));border-radius:var(--luzmo-question-box-scrollbar-thumb-border-radius,var(--question-box-scrollbar-thumb-border-radius))}.body::-webkit-scrollbar-thumb:hover{background:var(--luzmo-question-box-scrollbar-thumb-hover-background,var(--question-box-scrollbar-thumb-hover-background))}.body{scrollbar-width:var(--luzmo-scrollbar-width,thin);scrollbar-color:var(--luzmo-question-box-scrollbar-thumb-background,var(--question-box-scrollbar-thumb-background)) var(--luzmo-question-box-scrollbar-track-background,var(--question-box-scrollbar-track-background))}.options{box-sizing:border-box;flex-direction:column;inline-size:100%;min-inline-size:0;display:flex}.options--descriptive luzmo-radio,.options--descriptive luzmo-checkbox,.options--descriptive .other-option-answer{padding-block:var(--luzmo-question-box-descriptive-option-padding-block,var(--question-box-descriptive-option-padding-block))}.body:has(.options--descriptive){margin-block:calc(var(--question-box-option-padding-block) - var(--question-box-body-focus-inset) - var(--luzmo-question-box-descriptive-option-padding-block,var(--question-box-descriptive-option-padding-block)))}luzmo-radio,luzmo-checkbox{box-sizing:border-box;inline-size:100%;min-block-size:var(--question-box-option-min-block-size);padding-block:var(--question-box-option-padding-block);padding-inline:var(--question-box-option-padding-inline);border-block-end-width:var(--luzmo-question-box-divider-width,var(--question-box-divider-width));border-block-end-style:solid;border-block-end-color:var(--luzmo-question-box-divider-color,var(--question-box-divider-color));border-radius:var(--luzmo-border-radius-s);align-items:center;display:flex}luzmo-radio:hover,luzmo-checkbox:hover{background-color:var(--question-box-option-hover-background)}.other-option-row{align-items:center;gap:var(--question-box-option-gap);box-sizing:border-box;border-block-end-width:var(--luzmo-question-box-divider-width,var(--question-box-divider-width));border-block-end-style:solid;border-block-end-color:var(--luzmo-question-box-divider-color,var(--question-box-divider-color));inline-size:100%;max-inline-size:100%;display:flex}.other-option-answer{align-items:center;gap:var(--question-box-option-gap);box-sizing:border-box;min-inline-size:0;min-block-size:var(--question-box-option-min-block-size);padding-block:var(--question-box-option-padding-block);padding-inline:var(--question-box-option-padding-inline);border-radius:var(--luzmo-border-radius-s);flex:1;display:flex}.other-option-answer:hover{background-color:var(--question-box-option-hover-background)}luzmo-radio.other-option,luzmo-checkbox.other-option{border:0;flex:none;min-block-size:auto;inline-size:auto;padding:0}luzmo-radio.other-option{--luzmo-radio-button-top-to-control:0px}luzmo-radio.numbered-option{--luzmo-radio-button-control-size:0px;--luzmo-radio-button-top-to-control:0px;--luzmo-radio-text-to-control:0px;--luzmo-radio-border-width:0px;--luzmo-radio-focus-indicator-width:0px}luzmo-checkbox.numbered-option{--luzmo-checkbox-control-size:0px;--luzmo-checkbox-text-to-control:0px;--luzmo-checkbox-top-to-text:0px;--luzmo-checkbox-border-width:0px;--luzmo-checkbox-selected-border-width:0px;--luzmo-checkbox-focus-indicator-width:0px}luzmo-radio.numbered-option::part(control),luzmo-checkbox.numbered-option::part(control){display:none}luzmo-radio.other-option:hover,luzmo-checkbox.other-option:hover{background-color:#0000}.other-field{inline-size:auto;min-inline-size:0;max-inline-size:100%;min-block-size:var(--question-box-other-field-min-block-size);font-size:var(--question-box-other-field-font-size);--luzmo-text-field-width:100%;--luzmo-text-field-height:var(--question-box-other-field-min-block-size);--luzmo-text-field-background-color:transparent;--luzmo-text-field-background-color-disabled:transparent;--luzmo-text-field-placeholder-font-size:var(--question-box-other-field-font-size);--luzmo-text-field-border-width:0px;--luzmo-text-field-spacing-inline:0px;--luzmo-text-field-spacing-block-start:0px;--luzmo-text-field-spacing-block-end:0px;flex:1;justify-content:center}.other-primary{flex:none}.other-actions{box-sizing:border-box;justify-content:flex-end;align-items:center;gap:var(--question-box-copy-gap-detailed);inline-size:100%;padding-inline:var(--question-box-option-padding-inline);margin-block-start:var(--question-box-copy-gap-detailed);display:flex}.selected-count{font-size:var(--luzmo-question-box-selected-count-font-size,var(--question-box-selected-count-font-size))}.other-actions .selected-count{min-inline-size:0;margin-inline-end:auto}.other-actions luzmo-button{flex:none}.status-error{--luzmo-helptext-font-size:var(--luzmo-question-box-selected-count-font-size,var(--question-box-selected-count-font-size));--luzmo-helptext-min-height:0;--luzmo-helptext-top-to-text:0;--luzmo-helptext-bottom-to-text:0}.visually-hidden{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.option-content{align-items:flex-start;gap:var(--question-box-option-gap);inline-size:100%;display:flex}.option-number{forced-color-adjust:none;inline-size:var(--question-box-option-number-size);block-size:var(--question-box-option-number-size);box-sizing:border-box;border:var(--luzmo-border-width) solid var(--highcontrast-question-box-option-number-border-color,var(--question-box-option-number-border-color));border-radius:var(--luzmo-border-radius);color:var(--highcontrast-question-box-option-number-color,var(--question-box-option-number-color));background-color:var(--highcontrast-question-box-option-number-background,var(--question-box-option-number-background));transition:color var(--luzmo-animation-duration) ease-in-out, border-color var(--luzmo-animation-duration) ease-in-out, background-color var(--luzmo-animation-duration) ease-in-out;flex:none;justify-content:center;align-items:center;line-height:1;display:inline-flex}luzmo-radio[checked] .option-number,luzmo-checkbox[checked] .option-number{color:var(--highcontrast-question-box-option-number-selected-color,var(--question-box-option-number-selected-color));border-color:var(--highcontrast-question-box-option-number-selected-background,var(--question-box-option-number-selected-background));background-color:var(--highcontrast-question-box-option-number-selected-background,var(--question-box-option-number-selected-background))}luzmo-radio[data-focus-visible] .option-number,luzmo-checkbox[data-focus-visible] .option-number,.option-number--focused{outline:var(--luzmo-question-box-focus-ring-width,var(--question-box-focus-ring-width)) solid var(--highcontrast-question-box-focus-ring-color,var(--luzmo-question-box-focus-ring-color,var(--question-box-focus-ring-color)));outline-offset:var(--luzmo-question-box-focus-ring-gap,var(--question-box-focus-ring-gap))}luzmo-radio[disabled] .option-number,luzmo-checkbox[disabled] .option-number{opacity:.5}.option-copy{gap:var(--question-box-copy-gap);flex-direction:column;flex:1;min-inline-size:0;display:flex}.option-edit luzmo-icon{color:inherit}.option-heading{align-items:center;gap:var(--question-box-recommended-gap);min-block-size:var(--question-box-option-number-size);flex-wrap:wrap;display:flex}.option-text{align-items:baseline;gap:var(--question-box-recommended-gap);flex-wrap:wrap;min-inline-size:0;display:flex}.option-description{color:var(--question-box-muted-color);line-height:1.4}.option-hint{color:var(--question-box-muted-color);font-size:var(--luzmo-font-size-s)}.footer{justify-content:space-between;align-items:center;gap:var(--question-box-option-gap);flex-wrap:wrap;display:flex}.status{color:var(--question-box-muted-color);font-size:var(--luzmo-question-box-selected-count-font-size,var(--question-box-selected-count-font-size))}.actions{justify-content:flex-end;gap:var(--question-box-recommended-gap);flex-wrap:wrap;margin-inline-start:auto;display:flex}:host([dir=rtl]) .step-navigation luzmo-icon{transform:scaleX(-1)}.resolved{gap:var(--question-box-summary-gap)}.summary-actions{justify-content:flex-end;gap:var(--question-box-recommended-gap);flex-wrap:wrap;display:flex}.summary{gap:var(--question-box-option-gap);flex-direction:column;display:flex}.summary-heading{font-size:var(--question-box-title-font-size);line-height:var(--question-box-title-line-height);margin:0}.summary-row{gap:var(--question-box-copy-gap);flex-direction:column;display:flex}.summary-value{color:var(--question-box-muted-color)}.summary-answer{color:var(--highcontrast-question-box-color,var(--question-box-color));font-weight:var(--luzmo-font-weight-semibold)}@media (prefers-reduced-motion:reduce){.option-number{transition-duration:0s}}@media (forced-colors:active){:host{--highcontrast-question-box-border-color:CanvasText;--highcontrast-question-box-background-color:Canvas;--highcontrast-question-box-color:CanvasText;--highcontrast-question-box-focus-ring-color:Highlight;--highcontrast-question-box-option-number-border-color:ButtonText;--highcontrast-question-box-option-number-color:ButtonText;--highcontrast-question-box-option-number-background:Canvas;--highcontrast-question-box-option-number-selected-background:Highlight;--highcontrast-question-box-option-number-selected-color:HighlightText}}:host{--question-box-font-family:var(--luzmo-font-family);--question-box-font-size:var(--luzmo-font-size-m);--question-box-color:var(--luzmo-font-color);--question-box-muted-color:color-mix(in srgb, var(--luzmo-font-color) 80%, var(--luzmo-background-color));--question-box-background-color:var(--luzmo-background-color);--question-box-border-color:var(--luzmo-border-color);--question-box-border-width:var(--luzmo-border-width);--question-box-border-radius:var(--luzmo-border-radius-l);--question-box-padding:var(--luzmo-spacing-5);--question-box-gap:var(--luzmo-spacing-4);--question-box-header-gap:var(--luzmo-spacing-3);--question-box-header-actions-gap:var(--luzmo-spacing-2);--question-box-header-actions-inset:var(--luzmo-spacing-2);--question-box-header-control-size:var(--luzmo-component-height);--question-box-max-inline-size:40rem;--question-box-body-max-block-size:24rem;--question-box-title-font-size:var(--question-box-font-size);--question-box-title-line-height:1.3;--question-box-progress-font-size:var(--luzmo-font-size-s);--question-box-selected-count-font-size:var(--luzmo-font-size-s);--question-box-option-min-block-size:var(--luzmo-component-height);--question-box-option-hover-background:var(--luzmo-background-color-hover);--question-box-option-number-size:var(--luzmo-component-height-xs);--question-box-descriptive-option-padding-block:var(--question-box-option-padding-block);--question-box-option-padding-block:var(--luzmo-spacing-1);--question-box-option-padding-inline:var(--luzmo-spacing-3);--question-box-option-gap:var(--luzmo-spacing-3);--question-box-heading-copy-gap:0px;--question-box-heading-copy-offset:calc(var(--question-box-font-size) * -.25);--question-box-copy-gap:var(--luzmo-spacing-1);--question-box-copy-gap-detailed:var(--luzmo-spacing-2);--question-box-recommended-gap:var(--luzmo-spacing-2);--question-box-summary-gap:var(--luzmo-spacing-4);--question-box-body-focus-inset:calc(var(--luzmo-indicator-gap) + var(--luzmo-indicator-width));--question-box-focus-ring-width:var(--luzmo-indicator-width);--question-box-focus-ring-gap:var(--luzmo-indicator-gap);--question-box-focus-ring-color:var(--luzmo-indicator-color);--question-box-divider-width:0px;--question-box-option-number-background:var(--luzmo-background-color);--question-box-option-number-border-color:var(--luzmo-border-color);--question-box-option-number-color:var(--luzmo-font-color);--question-box-option-number-selected-background:var(--luzmo-primary);--question-box-option-number-selected-color:var(--luzmo-primary-inverse-color);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size);--question-box-divider-color:var(--luzmo-border-color);--question-box-scrollbar-width:var(--luzmo-scrollbar-size);--question-box-scrollbar-track-background:var(--luzmo-scrollbar-track-background);--question-box-scrollbar-track-border-radius:var(--luzmo-scrollbar-track-border-radius);--question-box-scrollbar-thumb-background:var(--luzmo-scrollbar-thumb-background);--question-box-scrollbar-thumb-border-radius:var(--luzmo-scrollbar-thumb-border-radius);--question-box-scrollbar-thumb-hover-background:var(--luzmo-scrollbar-thumb-hover-background)}:host([size=s]){--question-box-padding:var(--luzmo-spacing-4);--question-box-font-size:var(--luzmo-font-size-s);--question-box-selected-count-font-size:var(--luzmo-font-size-xs);--question-box-title-font-size:var(--question-box-font-size);--question-box-header-control-size:var(--luzmo-component-height-s);--question-box-option-min-block-size:var(--luzmo-component-height-s);--question-box-option-number-size:var(--luzmo-component-height-xs);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size)}:host([size=l]){--question-box-font-size:var(--luzmo-font-size-l);--question-box-selected-count-font-size:var(--luzmo-font-size-m);--question-box-title-font-size:var(--question-box-font-size);--question-box-header-control-size:var(--luzmo-component-height-l);--question-box-option-min-block-size:var(--luzmo-component-height-l);--question-box-option-number-size:var(--luzmo-component-height-s);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size)}:host([size=xl]){--question-box-font-size:var(--luzmo-font-size-xl);--question-box-selected-count-font-size:var(--luzmo-font-size-l);--question-box-title-font-size:var(--question-box-font-size);--question-box-header-control-size:var(--luzmo-component-height-xl);--question-box-option-min-block-size:var(--luzmo-component-height-xl);--question-box-option-number-size:var(--luzmo-component-height);--question-box-other-field-min-block-size:var(--question-box-option-min-block-size);--question-box-other-field-font-size:var(--question-box-font-size)}`,h=`__other__`,g={continue:`Next`,back:`Back`,submit:`Submit`,skip:`Skip`,change:`Change`,close:`Close`,other:`Something else`,otherPlaceholder:`Something else`,recommended:`Recommended`,answerTitle:`Answer`,answersTitle:`Answers`,progress:`{current} of {total}`,selectedCount:`{count} selected`,selectedCountOne:`{count} selected`,recommendedSuffix:`{label} ({recommended})`,answer:`{answer}`,requiredSelectionDescription:`Choose one or more options.`,selectionRangeDescription:`Choose between {min} and {max} options.`,minSelectedError:`Choose at least {min} options.`,maxSelectedError:`Choose at most {max} options.`,otherRequiredError:`Enter a value for this option.`},_=e=>`${e}Other`,v=e=>!!e.other||e.options.length===0,y=e=>typeof e.other==`object`&&e.other?e.other:{},b=e=>Object.fromEntries(Object.entries(e)),x=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})},S=(e,t)=>{let n=/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n){let n=e[r],i=t[r];if(Array.isArray(n)||Array.isArray(i)){if(!Array.isArray(n)||!Array.isArray(i)||n.length!==i.length||n.some((e,t)=>e!==i[t]))return!1}else if(n!==i)return!1}return!0},C=e=>{let t=/* @__PURE__ */ new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n},ie=e=>{let t=new Set(e.options.map(e=>e.value));return v(e)&&t.add(h),t},w=(e,t)=>{let n=t[e.id];return e.type===`single`?typeof n==`string`&&n?[n]:[]:Array.isArray(n)?C(n):[]},T=(e,t)=>w(e,t).includes(h),E=e=>{let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0));return{...g,...t}},D=(e,t)=>{let n=e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{${e}}`,r);return n},ae=e=>{let t=/* @__PURE__ */ new Set;for(let n of e){if(!n.id)throw TypeError(`luzmo-question-box: every question needs an id.`);if(t.has(n.id))throw TypeError(`luzmo-question-box: duplicate question id "${n.id}".`);t.add(n.id);let r=_(n.id);if(e.some(e=>e.id===r))throw TypeError(`luzmo-question-box: question id "${r}" collides with Other text for "${n.id}".`);if(n.type!==`multiple`&&(n.minSelected!==void 0||n.maxSelected!==void 0))throw TypeError(`luzmo-question-box: minSelected and maxSelected only apply to multiple-choice question "${n.id}".`);for(let[e,t]of[[`minSelected`,n.minSelected],[`maxSelected`,n.maxSelected]])if(t!==void 0&&(!Number.isInteger(t)||t<0))throw TypeError(`luzmo-question-box: ${e} must be a non-negative integer on "${n.id}".`);let i=n.minSelected??+!!n.required;if(n.maxSelected!==void 0&&i>n.maxSelected)throw TypeError(`luzmo-question-box: minSelected cannot exceed maxSelected on "${n.id}".`);let a=n.options.filter(e=>!e.disabled).length+ +!!v(n);if(n.type===`multiple`&&i>a)throw TypeError(`luzmo-question-box: minSelected exceeds the available options on "${n.id}".`);let o=/* @__PURE__ */ new Set;for(let e of n.options){if(!e.value)throw TypeError(`luzmo-question-box: option values cannot be empty on "${n.id}".`);if(e.value===`__other__`)throw TypeError(`luzmo-question-box: "${h}" is reserved on "${n.id}".`);if(o.has(e.value))throw TypeError(`luzmo-question-box: duplicate option value "${e.value}" on "${n.id}".`);o.add(e.value)}}},O=(e,t)=>{let n=Object.fromEntries([]);for(let r of e){let e=ie(r),i=t[r.id],a=Object.hasOwn(t,r.id);if(r.type===`single`)typeof i==`string`&&e.has(i)?x(n,r.id,i):!a&&typeof r.default==`string`&&(e.has(r.default)||r.options.length===0)&&x(n,r.id,r.options.length===0?h:r.default);else{let t=[...r.options.map(e=>e.value),...v(r)?[h]:[]],o=C(Array.isArray(i)?i.filter(t=>e.has(t)):[]);if(o.length>0)x(n,r.id,t.filter(e=>o.includes(e)));else if(!a&&Array.isArray(r.default)){let i=C(r.default.filter(t=>e.has(t)));i.length>0&&x(n,r.id,t.filter(e=>i.includes(e)))}}let o=_(r.id),s=t[o];typeof s==`string`?x(n,o,s):!a&&r.options.length===0&&typeof r.default==`string`&&x(n,o,r.default)}return n},k=e=>e.minSelected??+!!e.required,A=(e,t)=>{let n=k(e),r=e.maxSelected;return n>0&&r!==void 0?D(t.selectionRangeDescription,{min:String(n),max:String(r)}):n===1?t.requiredSelectionDescription:n>1?D(t.minSelectedError,{min:String(n)}):r===void 0?void 0:D(t.maxSelectedError,{max:String(r)})},j=(e,t)=>{let n=w(e,t),r=k(e),i=e.maxSelected;if(n.length<r)return r<=1?`missing`:`minimum`;if(i!==void 0&&n.length>i)return`maximum`;if(T(e,t)&&!String(t[_(e.id)]??``).trim())return`otherText`},M=(e,t)=>j(e,t)!==void 0,N=(e,t,n)=>{switch(j(e,t)){case`minimum`:return D(n.minSelectedError,{min:String(k(e))});case`maximum`:return D(n.maxSelectedError,{max:String(e.maxSelected)});case`otherText`:return n.otherRequiredError;default:return}},P=(e,t,n,r,i)=>{if(i||t.disabled)return!0;if(e.type!==`multiple`||n)return!1;let a=e.maxSelected;return a!==void 0&&w(e,r).length>=a},oe=(e,t)=>D(e===1?t.selectedCountOne:t.selectedCount,{count:String(e)}),F,se=(e,t)=>{try{return F?.language!==t&&(F={language:t,formatter:new Intl.ListFormat(t,{style:`narrow`,type:`conjunction`})}),F.formatter.format(e)}catch{return e.join(`, `)}},ce=(e,t)=>e.recommended?D(t.recommendedSuffix,{label:e.label,recommended:t.recommended}):e.label,I=e=>{let t=e.options.map(e=>({const:e.value,title:e.label}));return v(e)&&e.options.length>0&&t.push({const:h,title:typeof e.other==`object`&&e.other.label||g.other}),t},L=e=>{let t={type:`string`};return typeof e.other==`object`&&e.other.label&&(t.title=e.other.label),t},R=e=>{let t=[],n=[];for(let r of e){if(r.options.length===0){let e={type:`string`};r.title&&(e.title=r.title),r.description&&(e.description=r.description),typeof r.default==`string`&&(e.default=r.default),t.push([r.id,e]),r.required&&n.push(r.id);continue}let e=I(r);if(r.type===`single`){let n={type:`string`,oneOf:e};r.title&&(n.title=r.title),r.description&&(n.description=r.description),typeof r.default==`string`&&r.options.some(e=>e.value===r.default)&&(n.default=r.default),t.push([r.id,n])}else{let n={type:`array`,items:{anyOf:e}};r.title&&(n.title=r.title),r.description&&(n.description=r.description);let i=r.minSelected??(r.required?1:void 0);if(i!==void 0&&(n.minItems=i),r.maxSelected!==void 0&&(n.maxItems=r.maxSelected),Array.isArray(r.default)){let t=new Set(e.map(e=>e.const)),i=r.default.filter(e=>t.has(e));i.length>0&&(n.default=i)}t.push([r.id,n])}r.required&&n.push(r.id),v(r)&&t.push([_(r.id),L(r)])}let r=Object.fromEntries(t);return n.length>0?{type:`object`,properties:r,required:n}:{type:`object`,properties:r}},z=(e,t)=>String(t[_(e.id)]??``).trim(),B=(e,t)=>{let n=[];for(let r of e){let e=z(r,t);if(r.options.length===0){e&&n.push([r.id,e]);continue}let i=w(r,t);r.type===`single`?i[0]&&n.push([r.id,i[0]]):i.length>0&&n.push([r.id,[...i]]),v(r)&&T(r,t)&&e&&n.push([_(r.id),e])}return Object.fromEntries(n)},V=e=>!!e&&typeof e==`object`&&!Array.isArray(e),H=e=>V(e)?e:{},U=e=>{let t=e.oneOf??e.items?.anyOf;if(Array.isArray(t)){let e=[],n=/* @__PURE__ */ new Set;for(let r of t)V(r)&&typeof r.const==`string`&&r.const&&!n.has(r.const)&&(n.add(r.const),e.push({value:r.const,label:typeof r.title==`string`&&r.title?r.title:r.const}));return{declared:!0,options:e}}let n=e.enum??e.items?.enum;if(Array.isArray(n)){let t=e.enumNames??e.items?.enumNames,r=/* @__PURE__ */ new Set,i=[];for(let[e,a]of n.entries()){if(typeof a!=`string`||!a||r.has(a))continue;r.add(a);let n=t?.[e];i.push({value:a,label:typeof n==`string`&&n?n:a})}return{declared:!0,options:i}}return{declared:!1,options:[]}},W=e=>_(e),G=e=>e.format!==void 0||e.minLength!==void 0||e.maxLength!==void 0||e.pattern!==void 0,le=e=>e.type===`string`&&!U(e).declared&&!G(e),ue=e=>{if(e.type!==`object`||!e.properties)return[];let t=e.properties,n=new Set(e.required??[]),r=/* @__PURE__ */ new Set;for(let e of Object.keys(t)){let n=W(e),i=U(H(t[e])),a=H(t[n]);n in t&&le(a)&&i.options.some(e=>e.value===`__other__`)&&r.add(n)}let i=[];for(let[e,a]of Object.entries(t)){if(r.has(e))continue;let o=H(a),s=U(o),c=s.options.some(e=>e.value===h),l=W(e);if(c&&!r.has(l))continue;let u=s.options.filter(e=>e.value!==h);if(o.type===`number`||o.type===`integer`||o.type===`boolean`||o.type!==`string`&&o.type!==`array`||s.declared&&s.options.length===0||o.type===`array`&&!s.declared||o.type===`string`&&!s.declared&&G(o))continue;let d={id:e,type:o.type===`array`?`multiple`:`single`,title:o.title||e,options:u};if(o.description&&(d.description=o.description),n.has(e)&&(d.required=!0),o.type===`array`?(o.minItems!==void 0&&(d.minSelected=o.minItems),o.maxItems!==void 0&&(d.maxSelected=o.maxItems),Array.isArray(o.default)&&o.default.length>0&&(d.default=o.default)):typeof o.default==`string`&&(d.default=o.default),c&&l in t){let e=H(t[l]);d.other=!e.title||{label:e.title}}i.push(d)}return i};function K(e){switch(e){case`m`:return`xs`;case`l`:return`s`;case`xl`:case`xxl`:return`m`;default:return`xxs`}}function q(e){return e.step>=e.questions.length-1}function J(e,t){return e.disabled?!0:e.readonly?q(e):e.questionInvalid(t)}function de(e,t){let n=e.selectedValues(t);return n.length===0?``:se(n.map(n=>{if(n===`__other__`)return String(e.value[_(t.id)]??e.copy.other);let r=t.options.find(e=>e.value===n);return r?ce(r,e.copy):n}),e.language)}function fe(n,r){let i=de(n,r),a=n.copy.answer.split(`{answer}`).map((n,r)=>e`${r>0?e`<span class="summary-answer">${i}</span>`:t}${n}`);return e`<span class="summary-value">${a}</span>`}function pe(n){let r=n.copy;return e`
|
|
21
|
+
<div class="summary-actions">
|
|
22
|
+
${!n.submitted||n.showChange?e`
|
|
23
|
+
<luzmo-button
|
|
24
|
+
id="change-button"
|
|
25
|
+
dir=${n.dir}
|
|
26
|
+
variant="primary"
|
|
27
|
+
treatment=${n.submitted?`fill`:`outline`}
|
|
28
|
+
size=${n.size}
|
|
29
|
+
?disabled=${n.disabled}
|
|
30
|
+
@click=${n.handlers.change}
|
|
31
|
+
>${r.change}</luzmo-button
|
|
32
|
+
>
|
|
33
|
+
`:t}
|
|
34
|
+
${n.submitted?t:e`
|
|
35
|
+
<luzmo-button
|
|
36
|
+
id="review-submit-button"
|
|
37
|
+
dir=${n.dir}
|
|
38
|
+
variant="primary"
|
|
39
|
+
size=${n.size}
|
|
40
|
+
?disabled=${n.disabled||n.readonly}
|
|
41
|
+
@click=${n.handlers.primary}
|
|
42
|
+
>${r.submit}</luzmo-button
|
|
43
|
+
>
|
|
44
|
+
`}
|
|
45
|
+
</div>
|
|
46
|
+
`}function me(n){let r=n.copy,i=n.questions.reduce((e,t)=>e+n.selectedValues(t).length,0);return e`
|
|
21
47
|
<div class="card resolved">
|
|
22
48
|
<div class="summary">
|
|
23
49
|
<h2 class="summary-heading" id="resolved-title" tabindex="-1">
|
|
24
50
|
${i===1?r.answerTitle:r.answersTitle}
|
|
25
51
|
</h2>
|
|
26
|
-
${
|
|
52
|
+
${f(n.questions,e=>e.id,t=>e`
|
|
27
53
|
<div class="summary-row">
|
|
28
54
|
<span class="summary-title">${t.title}</span>
|
|
29
|
-
${
|
|
55
|
+
${fe(n,t)}
|
|
30
56
|
</div>
|
|
31
57
|
`)}
|
|
32
58
|
</div>
|
|
33
|
-
|
|
34
|
-
${!n.submitted||n.showChange?e`
|
|
35
|
-
<luzmo-button
|
|
36
|
-
id="change-button"
|
|
37
|
-
dir=${n.dir}
|
|
38
|
-
variant="primary"
|
|
39
|
-
treatment=${n.submitted?`fill`:`outline`}
|
|
40
|
-
size=${n.size}
|
|
41
|
-
?disabled=${n.disabled}
|
|
42
|
-
@click=${n.handlers.change}
|
|
43
|
-
>${r.change}</luzmo-button
|
|
44
|
-
>
|
|
45
|
-
`:t}
|
|
46
|
-
${n.submitted?t:e`
|
|
47
|
-
<luzmo-button
|
|
48
|
-
id="review-submit-button"
|
|
49
|
-
dir=${n.dir}
|
|
50
|
-
variant="primary"
|
|
51
|
-
size=${n.size}
|
|
52
|
-
?disabled=${n.disabled||n.readonly}
|
|
53
|
-
@click=${n.handlers.primary}
|
|
54
|
-
>${r.submit}</luzmo-button
|
|
55
|
-
>
|
|
56
|
-
`}
|
|
57
|
-
</div>
|
|
59
|
+
${n.answered?t:pe(n)}
|
|
58
60
|
</div>
|
|
59
|
-
`}function
|
|
61
|
+
`}function Y(n,r,i){let a=n.optionIndicator===`letters`&&i<26?String.fromCharCode(65+i):String(i+1);return e`
|
|
60
62
|
<span
|
|
61
63
|
class=${r.description?`option-content option-content--detailed`:`option-content`}
|
|
62
64
|
>
|
|
@@ -81,7 +83,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
81
83
|
>`:t}
|
|
82
84
|
</span>
|
|
83
85
|
</span>
|
|
84
|
-
`}function
|
|
86
|
+
`}function X(n,r){return n.disabledReason?e`<span class="visually-hidden" id="option-reason-${r}"
|
|
85
87
|
>${n.disabledReason}</span
|
|
86
88
|
>`:t}function he(n,r){return r?e`
|
|
87
89
|
<luzmo-help-text
|
|
@@ -90,7 +92,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
90
92
|
slot="negative-help-text"
|
|
91
93
|
>${r}</luzmo-help-text
|
|
92
94
|
>
|
|
93
|
-
`:t}function
|
|
95
|
+
`:t}function Z(n,r){if(r.type!==`multiple`)return t;let i=n.showError?n.questionError(r):void 0;return e`
|
|
94
96
|
<span class="selected-count" aria-live="polite"
|
|
95
97
|
>${i?e`<luzmo-help-text
|
|
96
98
|
id="question-error"
|
|
@@ -98,11 +100,11 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
98
100
|
dir=${n.dir}
|
|
99
101
|
variant="negative"
|
|
100
102
|
>${i}</luzmo-help-text
|
|
101
|
-
>`:
|
|
103
|
+
>`:oe(n.selectedValues(r).length,n.copy)}</span
|
|
102
104
|
>
|
|
103
105
|
`}function ge(n,r){return e`
|
|
104
106
|
<div class="other-actions">
|
|
105
|
-
${
|
|
107
|
+
${Z(n,r)}
|
|
106
108
|
${n.hideSkip?t:e`
|
|
107
109
|
<luzmo-button
|
|
108
110
|
id="other-skip-button"
|
|
@@ -122,12 +124,12 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
122
124
|
variant="primary"
|
|
123
125
|
treatment="outline"
|
|
124
126
|
size=${c(n.size)}
|
|
125
|
-
?disabled=${
|
|
127
|
+
?disabled=${J(n,r)}
|
|
126
128
|
@click=${n.handlers.primary}
|
|
127
|
-
>${
|
|
129
|
+
>${q(n)?n.copy.submit:n.copy.continue}</luzmo-button
|
|
128
130
|
>
|
|
129
131
|
</div>
|
|
130
|
-
`}function _e(e,t){return e.isOtherSelected(t)&&String(e.value[
|
|
132
|
+
`}function _e(e,t){return e.isOtherSelected(t)&&String(e.value[_(t.id)]??``).trim().length>0}function Q(t,n){let r=y(n),i=_(n.id),a=t.isOtherSelected(n),o=t.optionDisabled(n,{value:h,label:r.label||t.copy.other},a),s=t.showError&&a&&!!t.questionError(n);return e`
|
|
131
133
|
<luzmo-text-field
|
|
132
134
|
id="other-field"
|
|
133
135
|
dir=${t.dir}
|
|
@@ -147,7 +149,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
147
149
|
@input=${t.handlers.otherInput}
|
|
148
150
|
@change=${t.handlers.otherChange}
|
|
149
151
|
></luzmo-text-field>
|
|
150
|
-
`}function
|
|
152
|
+
`}function ve(n,r){let i=_e(n,r);return r.type===`multiple`||n.hideSkip&&!i?t:e`
|
|
151
153
|
<luzmo-button
|
|
152
154
|
id="other-row-action"
|
|
153
155
|
dir=${n.dir}
|
|
@@ -155,11 +157,11 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
155
157
|
variant="primary"
|
|
156
158
|
treatment="outline"
|
|
157
159
|
size=${c(n.size)}
|
|
158
|
-
?disabled=${i?
|
|
160
|
+
?disabled=${i?J(n,r):n.disabled||n.readonly}
|
|
159
161
|
@click=${i?n.handlers.primary:n.handlers.skip}
|
|
160
|
-
>${i?
|
|
162
|
+
>${i?q(n)?n.copy.submit:n.copy.continue:n.copy.skip}</luzmo-button
|
|
161
163
|
>
|
|
162
|
-
`}function
|
|
164
|
+
`}function ye(n,r,i){let a=n.selectedValues(r)[0]??``,o=r.options.some(e=>e.description)?`options options--descriptive`:`options`;return e`
|
|
163
165
|
<luzmo-radio-group
|
|
164
166
|
id="options"
|
|
165
167
|
dir=${n.dir}
|
|
@@ -175,7 +177,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
175
177
|
@focusin=${n.handlers.focusIn}
|
|
176
178
|
@focusout=${n.handlers.focusOut}
|
|
177
179
|
>
|
|
178
|
-
${
|
|
180
|
+
${f(r.options,e=>e.value,(t,i)=>e`
|
|
179
181
|
<luzmo-radio
|
|
180
182
|
class="numbered-option"
|
|
181
183
|
dir=${n.dir}
|
|
@@ -189,21 +191,21 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
189
191
|
@click=${n.handlers.radioClick}
|
|
190
192
|
@change=${n.handlers.radioChange}
|
|
191
193
|
>
|
|
192
|
-
${
|
|
193
|
-
${
|
|
194
|
+
${Y(n,t,i)}
|
|
195
|
+
${X(t,i)}
|
|
194
196
|
</luzmo-radio>
|
|
195
197
|
`)}
|
|
196
|
-
${
|
|
198
|
+
${v(r)?e`
|
|
197
199
|
<div class="other-option-row">
|
|
198
200
|
<div class="other-option-answer">
|
|
199
201
|
<luzmo-radio
|
|
200
202
|
class="numbered-option other-option"
|
|
201
203
|
dir=${n.dir}
|
|
202
|
-
value=${
|
|
204
|
+
value=${h}
|
|
203
205
|
data-option-index=${r.options.length}
|
|
204
206
|
size=${n.size}
|
|
205
207
|
emphasized
|
|
206
|
-
aria-label=${
|
|
208
|
+
aria-label=${y(r).label||n.copy.other}
|
|
207
209
|
?disabled=${n.disabled}
|
|
208
210
|
?readonly=${n.readonly}
|
|
209
211
|
@change=${n.handlers.radioChange}
|
|
@@ -212,19 +214,19 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
212
214
|
<luzmo-icon
|
|
213
215
|
block
|
|
214
216
|
dir=${n.dir}
|
|
215
|
-
.size=${
|
|
216
|
-
.icon=${
|
|
217
|
+
.size=${K(n.size)}
|
|
218
|
+
.icon=${p}
|
|
217
219
|
></luzmo-icon>
|
|
218
220
|
</span>
|
|
219
221
|
</luzmo-radio>
|
|
220
|
-
${
|
|
222
|
+
${Q(n,r)}
|
|
221
223
|
</div>
|
|
222
|
-
${
|
|
224
|
+
${ve(n,r)}
|
|
223
225
|
</div>
|
|
224
226
|
`:t}
|
|
225
227
|
${he(n,i)}
|
|
226
228
|
</luzmo-radio-group>
|
|
227
|
-
`}function
|
|
229
|
+
`}function be(n,r,i){let a=new Set(n.selectedValues(r)),o=n.isOtherSelected(r),c=r.options.some(e=>e.description)?`options options--descriptive`:`options`,l=A(r,n.copy);return e`
|
|
228
230
|
${l?e`<span class="visually-hidden" id="selection-requirement"
|
|
229
231
|
>${l}</span
|
|
230
232
|
>`:t}
|
|
@@ -239,7 +241,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
239
241
|
@focusin=${n.handlers.focusIn}
|
|
240
242
|
@focusout=${n.handlers.focusOut}
|
|
241
243
|
>
|
|
242
|
-
${
|
|
244
|
+
${f(r.options,e=>e.value,(t,i)=>e`
|
|
243
245
|
<luzmo-checkbox
|
|
244
246
|
class="numbered-option"
|
|
245
247
|
dir=${n.dir}
|
|
@@ -253,22 +255,22 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
253
255
|
aria-describedby=${s(t.disabledReason?`option-reason-${i}`:void 0)}
|
|
254
256
|
@change=${n.handlers.checkboxChange}
|
|
255
257
|
>
|
|
256
|
-
${
|
|
257
|
-
${
|
|
258
|
+
${Y(n,t,i)}
|
|
259
|
+
${X(t,i)}
|
|
258
260
|
</luzmo-checkbox>
|
|
259
261
|
`)}
|
|
260
|
-
${
|
|
262
|
+
${v(r)?e`
|
|
261
263
|
<div class="other-option-row other-option-row--multiple">
|
|
262
264
|
<div class="other-option-answer">
|
|
263
265
|
<luzmo-checkbox
|
|
264
266
|
class="numbered-option other-option"
|
|
265
267
|
dir=${n.dir}
|
|
266
|
-
data-value=${
|
|
268
|
+
data-value=${h}
|
|
267
269
|
data-option-index=${r.options.length}
|
|
268
270
|
size=${n.size}
|
|
269
271
|
emphasized
|
|
270
272
|
?checked=${o}
|
|
271
|
-
?disabled=${n.optionDisabled(r,{value:
|
|
273
|
+
?disabled=${n.optionDisabled(r,{value:h,label:n.copy.other},o)}
|
|
272
274
|
?readonly=${n.readonly}
|
|
273
275
|
@change=${n.handlers.checkboxChange}
|
|
274
276
|
>
|
|
@@ -276,21 +278,21 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
276
278
|
<luzmo-icon
|
|
277
279
|
block
|
|
278
280
|
dir=${n.dir}
|
|
279
|
-
.size=${
|
|
280
|
-
.icon=${
|
|
281
|
+
.size=${K(n.size)}
|
|
282
|
+
.icon=${p}
|
|
281
283
|
></luzmo-icon>
|
|
282
284
|
</span>
|
|
283
285
|
<span class="visually-hidden"
|
|
284
|
-
>${
|
|
286
|
+
>${y(r).label||n.copy.other}</span
|
|
285
287
|
>
|
|
286
288
|
</luzmo-checkbox>
|
|
287
|
-
${
|
|
289
|
+
${Q(n,r)}
|
|
288
290
|
</div>
|
|
289
291
|
</div>
|
|
290
292
|
${ge(n,r)}
|
|
291
293
|
`:t}
|
|
292
294
|
</luzmo-field-group>
|
|
293
|
-
`}function
|
|
295
|
+
`}function xe(n,r){let i=n.copy,a=D(i.progress,{current:String(n.step+1),total:String(n.questions.length)});return e`
|
|
294
296
|
<header class="header">
|
|
295
297
|
<div class="heading">
|
|
296
298
|
<h2 class="title" id="question-title" tabindex="-1">
|
|
@@ -317,7 +319,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
317
319
|
block
|
|
318
320
|
dir=${n.dir}
|
|
319
321
|
.size=${c(n.size)}
|
|
320
|
-
.icon=${
|
|
322
|
+
.icon=${ee}
|
|
321
323
|
></luzmo-icon>
|
|
322
324
|
</div>
|
|
323
325
|
</luzmo-action-button>
|
|
@@ -330,7 +332,7 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
330
332
|
quiet
|
|
331
333
|
size=${c(n.size)}
|
|
332
334
|
label=${i.continue}
|
|
333
|
-
?disabled=${
|
|
335
|
+
?disabled=${J(n,r)||q(n)}
|
|
334
336
|
@click=${n.handlers.primary}
|
|
335
337
|
>
|
|
336
338
|
<div slot="icon">
|
|
@@ -357,9 +359,9 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
357
359
|
`}
|
|
358
360
|
</div>
|
|
359
361
|
</header>
|
|
360
|
-
`}function
|
|
362
|
+
`}function Se(n,r){let i=n.copy;return e`
|
|
361
363
|
<footer class="footer">
|
|
362
|
-
<div class="status">${
|
|
364
|
+
<div class="status">${Z(n,r)}</div>
|
|
363
365
|
<div class="actions">
|
|
364
366
|
${n.hideSkip?t:e`
|
|
365
367
|
<luzmo-button
|
|
@@ -373,31 +375,31 @@ import"./tokens.js";import{c as e,i as t,y as n}from"./chunks/lit-DWANyjiY.js";i
|
|
|
373
375
|
>${i.skip}</luzmo-button
|
|
374
376
|
>
|
|
375
377
|
`}
|
|
376
|
-
${
|
|
378
|
+
${q(n)&&r.type===`multiple`?e`
|
|
377
379
|
<luzmo-button
|
|
378
380
|
id="submit-button"
|
|
379
381
|
dir=${n.dir}
|
|
380
382
|
variant="primary"
|
|
381
383
|
treatment="outline"
|
|
382
384
|
size=${c(n.size)}
|
|
383
|
-
?disabled=${
|
|
385
|
+
?disabled=${J(n,r)}
|
|
384
386
|
@click=${n.handlers.primary}
|
|
385
387
|
>${i.submit}</luzmo-button
|
|
386
388
|
>
|
|
387
389
|
`:t}
|
|
388
390
|
</div>
|
|
389
391
|
</footer>
|
|
390
|
-
`}function
|
|
392
|
+
`}function Ce(n){if(n.questions.length===0)return t;if(n.resolved)return me(n);let r=n.questions[n.step];if(!r)return t;let i=n.showError?n.questionError(r):void 0,a=!v(r)&&(r.type===`multiple`||!n.hideSkip),o=[n.questions.length>1?`progress`:``,r.description?`question-description`:``,i?`question-error`:``].filter(Boolean).join(` `)||void 0;return e`
|
|
391
393
|
<div class="card" @click=${n.handlers.contentClick}>
|
|
392
|
-
${
|
|
394
|
+
${xe(n,r)}
|
|
393
395
|
<div
|
|
394
396
|
class="body"
|
|
395
397
|
role="group"
|
|
396
398
|
aria-labelledby="question-title"
|
|
397
399
|
aria-describedby=${s(o)}
|
|
398
400
|
>
|
|
399
|
-
${
|
|
401
|
+
${re(r.id,r.type===`single`?ye(n,r,i):be(n,r,i))}
|
|
400
402
|
</div>
|
|
401
|
-
${a?
|
|
403
|
+
${a?Se(n,r):t}
|
|
402
404
|
</div>
|
|
403
|
-
`}var $=class extends i(o,{validSizes:[`s`,`m`,`l`,`xl`]}){constructor(...e){super(...e),this.questions=[],this.value={},this.labels={},this.dir=`ltr`,this.disabled=!1,this.readonly=!1,this.hideClose=!1,this.hideSkip=!1,this.showChange=!1,this._optionIndicator=`numbers`,this._step=0,this._resolved=!1,this._submitted=!1,this._showError=!1,this.languageResolver=new p(this),this._radioChangeAdvanced=!1,this.multipleChoiceRoving=new ee(this,{direction:`vertical`,elements:()=>[...this.shadowRoot?.querySelectorAll(`luzmo-field-group#options luzmo-checkbox[data-option-index]`)??[]],focusInIndex:e=>{let t=e.findIndex(e=>e.checked&&!e.disabled);return t===-1?e.findIndex(e=>!e.disabled):t},isFocusableElement:e=>!e.disabled,listenerScope:()=>this.shadowRoot?.querySelector(`luzmo-field-group#options`)}),this.handleKeydown=e=>{if(this.disabled)return;let t=e.composedPath(),n=this.shadowRoot?.activeElement;if(e.key!==`Escape`&&this.otherField&&(t.includes(this.otherField)||n===this.otherField))return;let r=this.focusedOptionForEvent(e),i=this.currentQuestion;if(i?.type===`multiple`&&r&&this.multipleChoiceRoving.acceptsEventCode(e.code)&&!e.defaultPrevented){let t=this.multipleChoiceRoving.elements.indexOf(r);t!==-1&&(this.multipleChoiceRoving.currentIndex=t),this.multipleChoiceRoving.hostContainsFocus(),this.multipleChoiceRoving.handleKeydown(e);return}if(!this.readonly&&e.code===`Space`&&r&&!r.hasAttribute(`disabled`)){e.preventDefault();return}let a=this.optionIndicator===`letters`&&/^[a-z]$/i.test(e.key)?e.key.toUpperCase().charCodeAt(0)-65:this.optionIndicator===`numbers`&&/^[1-9]$/.test(e.key)?Number(e.key)-1:-1,o=!this.readonly&&r&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&a>=0?this.shadowRoot?.querySelector(`[data-option-index="${a}"]:not([disabled])`):void 0;if(o){e.preventDefault();let t=o.getAttribute(`value`)??o.dataset.value;if(i?.type===`single`&&t!==`__other__`&&this.selectedValues(i)[0]===t){this.advanceAfterSingleSelection();return}o.click()}else e.key===`Escape`&&(e.preventDefault(),!this.disabled&&this.cancel())},this.handleKeyup=e=>{if(this.disabled||this.readonly||e.code!==`Space`)return;let t=this.focusedOptionForEvent(e);t&&!t.hasAttribute(`disabled`)&&(e.preventDefault(),t.click())},this.handleFocusIn=e=>{let t=this.focusedOptionForEvent(e);this.markKeyboardFocus(t&&this.optionShowsKeyboardFocus(t)?t:void 0)},this.handleContentClick=e=>{this.disabled||e.composedPath().some(e=>e instanceof Element&&e.matches(`a[href], button, input, select, textarea, [contenteditable="true"], [data-option-index], #other-field, luzmo-action-button, luzmo-button, luzmo-close-button`))||this.focusOptions()},this.handleFocusOut=()=>{requestAnimationFrame(()=>{let e=this.shadowRoot?.activeElement;e instanceof HTMLElement&&e.dataset.optionIndex!==void 0||this.markKeyboardFocus()})},this.handleCancelClick=e=>{e.preventDefault(),this.cancel()},this.handleSkip=e=>{e.preventDefault(),!(this.disabled||this.readonly)&&this.emitResult(`decline`)},this.handleBack=e=>{e.preventDefault(),!(this.disabled||this._step===0)&&(this._showError=!1,--this._step,this.updateComplete.then(()=>this.moveFocus(this.questionTitle)))},this.handlePrimary=()=>{let e=this.currentQuestion;e&&!this.disabled&&(!this.readonly&&this.questionInvalid(e)?(this._showError=!0,this.focusOptions()):(this._showError=!1,this._step<this.questions.length-1?(this._step+=1,this.updateComplete.then(()=>this.moveFocus(this.questionTitle))):this.readonly||this.acceptFlow()))},this.handleChange=()=>{this._resolved=!1,this._submitted=!1,this._showError=!1,this.updateComplete.then(()=>this.focusOptions())},this.handleRadioChange=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.target.value||e.currentTarget.selected;n&&(n===`__other__`&&!String(this.value[y(t.id)]??``).trim()?(this.requestUpdate(),this.updateComplete.then(()=>this.moveFocus(this.otherField))):(this.commitAnswer(t.id,n,!0),n!==`__other__`&&(this._radioChangeAdvanced=!0,this.advanceAfterSingleSelection(),queueMicrotask(()=>{this._radioChangeAdvanced=!1}))))},this.handleRadioClick=e=>{if(this._radioChangeAdvanced||this.disabled||this.readonly)return;let t=this.currentQuestion,n=e.currentTarget;t?.type===`single`&&n.value!==`__other__`&&this.selectedValues(t)[0]===n.value&&this.advanceAfterSingleSelection()},this.handleCheckboxChange=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.currentTarget,r=n.dataset.value;if(!r)return;let i=new Set(this.selectedValues(t));if(r===`__other__`&&n.checked&&!String(this.value[y(t.id)]??``).trim()){n.checked=!1,this.moveFocus(this.otherField);return}n.checked?i.add(r):i.delete(r);let a=[...t.options.map(e=>e.value),...b(t)?[_]:[]].filter(e=>i.has(e));this.commitAnswer(t.id,T(a),!0),r===`__other__`&&n.checked&&this.updateComplete.then(()=>this.moveFocus(this.otherField))},this.handleOtherInput=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.currentTarget;this.commitOther(t,n.value,!1)},this.handleOtherChange=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.currentTarget;this.commitOther(t,n.value,!0)},this.handleOtherKeydown=e=>{if(e.key!==`Enter`||e.shiftKey||e.isComposing||this.disabled||this.readonly)return;e.preventDefault();let t=this.currentQuestion;t&&String(this.value[y(t.id)]??``).trim()&&this.handlePrimary()}}static get styles(){let e=super.styles;return[...Array.isArray(e)?e:e?[e]:[],n(g)]}get optionIndicator(){return this._optionIndicator}set optionIndicator(e){let t=this._optionIndicator;this._optionIndicator=e===`letters`?`letters`:`numbers`,this.requestUpdate(`optionIndicator`,t)}connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.handleKeydown),this.addEventListener(`keyup`,this.handleKeyup),this.addEventListener(`focusin`,this.handleFocusIn)}attributeChangedCallback(e,t,n){e===`option-indicator`&&n!==null&&n!==`numbers`&&n!==`letters`?this.setAttribute(`option-indicator`,`numbers`):super.attributeChangedCallback(e,t,n)}disconnectedCallback(){this.removeEventListener(`keydown`,this.handleKeydown),this.removeEventListener(`keyup`,this.handleKeyup),this.removeEventListener(`focusin`,this.handleFocusIn),super.disconnectedCallback()}focus(){this._resolved?this.moveFocus(this.resolvedTitle):this.focusOptions()}checkValidity(){return this.questions.every(e=>!this.questionInvalid(e))}submit(){this.disabled||this.readonly||this._submitted||this.acceptFlow()}reset(){this._resolved=!1,this._submitted=!1,this._showError=!1,this._step=0,this.value={}}cancel(){this.emitResult(`cancel`)}willUpdate(e){if(super.willUpdate(e),e.has(`questions`)||e.has(`value`)){if(e.has(`questions`)){A(this.questions);let t=(e.get(`questions`)??[]).map(e=>e.id),n=this.questions.map(e=>e.id);t.join(`\0`)!==n.join(`\0`)&&(this._step=0,this._resolved=!1,this._submitted=!1,this._showError=!1)}let t=j(this.questions,this.value);w(t,this.value)||(this.value=t)}e.has(`questions`)&&(this._step=Math.min(this._step,Math.max(0,this.questions.length-1)))}updated(e){super.updated(e),(e.has(`questions`)||e.has(`size`)||e.has(`disabled`)||e.has(`readonly`)||e.has(`_step`)||e.has(`_resolved`))&&this.multipleChoiceRoving.clearElementCache()}render(){return Se(this.renderContext)}get renderContext(){return{questions:this.questions,value:this.value,copy:this.copy,step:this._step,resolved:this._resolved,submitted:this._submitted,showError:this._showError,disabled:this.disabled,readonly:this.readonly,hideClose:this.hideClose,hideSkip:this.hideSkip,showChange:this.showChange,optionIndicator:this.optionIndicator,size:this.size,dir:this.dir,language:this.languageResolver.language,selectedValues:e=>this.selectedValues(e),isOtherSelected:e=>this.isOtherSelected(e),questionError:e=>this.questionError(e),questionInvalid:e=>this.questionInvalid(e),optionDisabled:(e,t,n)=>this.optionDisabled(e,t,n),handlers:this.renderHandlers}}get renderHandlers(){return{contentClick:this.handleContentClick,back:this.handleBack,primary:this.handlePrimary,skip:this.handleSkip,cancel:this.handleCancelClick,change:this.handleChange,radioChange:this.handleRadioChange,radioClick:this.handleRadioClick,checkboxChange:this.handleCheckboxChange,otherInput:this.handleOtherInput,otherChange:this.handleOtherChange,otherKeydown:this.handleOtherKeydown,focusIn:this.handleFocusIn,focusOut:this.handleFocusOut}}get copy(){return O(this.labels)}get currentQuestion(){return this.questions[this._step]}optionShowsKeyboardFocus(e){let t=e=>{if(!e)return!1;try{return e.matches(`:focus-visible`)||e.matches(`.focus-visible`)}catch{return e.matches(`.focus-visible`)}};return t(e)||t(e.shadowRoot?.activeElement)||this.hasVisibleFocusInTree()}markKeyboardFocus(e){this.shadowRoot?.querySelectorAll(`[data-focus-visible]`).forEach(e=>delete e.dataset.focusVisible),this.shadowRoot?.querySelectorAll(`.option-number--focused`).forEach(e=>e.classList.remove(`option-number--focused`)),e&&(e.dataset.focusVisible=``,e.querySelector(`.option-number`)?.classList.add(`option-number--focused`))}focusedOptionForEvent(e){let t=e.composedPath().find(e=>e instanceof HTMLElement&&e.dataset.optionIndex!==void 0);if(t)return t;let n=this.shadowRoot?.activeElement;return n instanceof HTMLElement&&n.dataset.optionIndex!==void 0?n:void 0}moveFocus(e){if(e)try{e.focus()}catch{try{HTMLElement.prototype.focus.call(e)}catch{return}}}focusOptions(){let e=this.optionsGroup;if(!e){this.moveFocus(this.questionTitle);return}let t=this.currentQuestion,n=t?.type===`single`?this.selectedValues(t)[0]:void 0,r=n?e.querySelector(`luzmo-radio[value="${CSS.escape(n)}"]:not([disabled])`):void 0,i=e.querySelector(`[data-option-index]:not([disabled])`);this.moveFocus(r??i??e)}advanceAfterSingleSelection(){this._step<this.questions.length-1?(this._step+=1,this.updateComplete.then(()=>this.moveFocus(this.questionTitle))):(this._resolved=!0,this._submitted=!1,this.updateComplete.then(()=>this.focus()))}acceptFlow(){let e=this.questions.findIndex(e=>this.questionInvalid(e));e===-1?(this._showError=!1,this._resolved=!0,this._submitted=!0,this.emitResult(`accept`,z(this.questions,this.value)),this.updateComplete.then(()=>this.focus())):(this._step=e,this._showError=!0,this.updateComplete.then(()=>this.focusOptions()))}commitAnswer(e,t,n){let r=S(this.value);C(r,e,t),this.assignValue(r,n)}commitOther(e,t,n){let r=S(this.value);C(r,y(e.id),t);let i=t.trim().length>0;if(e.type===`single`)i?C(r,e.id,_):r[e.id]===`__other__`&&C(r,e.id,``);else{let t=new Set(this.selectedValues(e));i?t.add(_):t.delete(_),C(r,e.id,[...e.options.map(e=>e.value),_].filter(e=>t.has(e)))}this.assignValue(r,n)}assignValue(e,t){w(e,this.value)||(this.value=e,this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0}))),t&&this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0}))}emitResult(e,t){let n=e===`accept`?{action:e,content:t}:{action:e};e===`accept`?this.dispatchEvent(new CustomEvent(`luzmo-submit`,{detail:n,bubbles:!0,composed:!0})):e===`decline`?this.dispatchEvent(new CustomEvent(`luzmo-decline`,{detail:n,bubbles:!0,composed:!0})):this.dispatchEvent(new CustomEvent(`luzmo-cancel`,{detail:n,bubbles:!0,composed:!0}))}selectedValues(e){return E(e,this.value)}isOtherSelected(e){return D(e,this.value)}questionError(e){return ae(e,this.value,this.copy)}questionInvalid(e){return ie(e,this.value)}optionDisabled(e,t,n){return oe(e,t,n,this.value,this.disabled)}};a([u({attribute:!1})],$.prototype,`questions`,void 0),a([u({attribute:!1})],$.prototype,`value`,void 0),a([u({attribute:!1})],$.prototype,`labels`,void 0),a([u({reflect:!0})],$.prototype,`dir`,void 0),a([u({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),a([u({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),a([u({type:Boolean,reflect:!0,attribute:`hide-close`})],$.prototype,`hideClose`,void 0),a([u({type:Boolean,reflect:!0,attribute:`hide-skip`})],$.prototype,`hideSkip`,void 0),a([u({type:Boolean,reflect:!0,attribute:`show-change`})],$.prototype,`showChange`,void 0),a([u({reflect:!0,attribute:`option-indicator`})],$.prototype,`optionIndicator`,null),a([r()],$.prototype,`_step`,void 0),a([r()],$.prototype,`_resolved`,void 0),a([r()],$.prototype,`_submitted`,void 0),a([r()],$.prototype,`_showError`,void 0),a([l(`#question-title`)],$.prototype,`questionTitle`,void 0),a([l(`#other-field`)],$.prototype,`otherField`,void 0),a([l(`#options`)],$.prototype,`optionsGroup`,void 0),a([l(`#resolved-title`)],$.prototype,`resolvedTitle`,void 0),typeof customElements<`u`&&!customElements.get(`luzmo-question-box`)&&customElements.define(`luzmo-question-box`,$);export{v as DEFAULT_QUESTION_BOX_LABELS,$ as LuzmoQuestionBox,_ as QUESTION_BOX_OTHER_VALUE,y as questionBoxOtherKey,L as questionsToRequestedSchema,de as requestedSchemaToQuestions,z as toElicitationContent};
|
|
405
|
+
`}var $=class extends i(o,{validSizes:[`s`,`m`,`l`,`xl`]}){constructor(...e){super(...e),this.questions=[],this.value={},this.labels={},this.dir=`ltr`,this.disabled=!1,this.readonly=!1,this.answered=!1,this.hideClose=!1,this.hideSkip=!1,this.showChange=!1,this._optionIndicator=`numbers`,this._step=0,this._resolved=!1,this._submitted=!1,this._showError=!1,this.languageResolver=new ne(this),this._radioChangeAdvanced=!1,this.multipleChoiceRoving=new te(this,{direction:`vertical`,elements:()=>[...this.shadowRoot?.querySelectorAll(`luzmo-field-group#options luzmo-checkbox[data-option-index]`)??[]],focusInIndex:e=>{let t=e.findIndex(e=>e.checked&&!e.disabled);return t===-1?e.findIndex(e=>!e.disabled):t},isFocusableElement:e=>!e.disabled,listenerScope:()=>this.shadowRoot?.querySelector(`luzmo-field-group#options`)}),this.handleKeydown=e=>{if(this.disabled||this.answered)return;let t=e.composedPath(),n=this.shadowRoot?.activeElement;if(e.key!==`Escape`&&this.otherField&&(t.includes(this.otherField)||n===this.otherField))return;let r=this.focusedOptionForEvent(e),i=this.currentQuestion;if(i?.type===`multiple`&&r&&this.multipleChoiceRoving.acceptsEventCode(e.code)&&!e.defaultPrevented){let t=this.multipleChoiceRoving.elements.indexOf(r);t!==-1&&(this.multipleChoiceRoving.currentIndex=t),this.multipleChoiceRoving.hostContainsFocus(),this.multipleChoiceRoving.handleKeydown(e);return}if(!this.readonly&&e.code===`Space`&&r&&!r.hasAttribute(`disabled`)){e.preventDefault();return}let a=this.optionIndicator===`letters`&&/^[a-z]$/i.test(e.key)?e.key.toUpperCase().charCodeAt(0)-65:this.optionIndicator===`numbers`&&/^[1-9]$/.test(e.key)?Number(e.key)-1:-1,o=!this.readonly&&r&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&a>=0?this.shadowRoot?.querySelector(`[data-option-index="${a}"]:not([disabled])`):void 0;if(o){e.preventDefault();let t=o.getAttribute(`value`)??o.dataset.value;if(i?.type===`single`&&t!==`__other__`&&this.selectedValues(i)[0]===t){this.advanceAfterSingleSelection();return}o.click()}else e.key===`Escape`&&(e.preventDefault(),!this.disabled&&this.cancel())},this.handleKeyup=e=>{if(this.disabled||this.readonly||this.answered||e.code!==`Space`)return;let t=this.focusedOptionForEvent(e);t&&!t.hasAttribute(`disabled`)&&(e.preventDefault(),t.click())},this.handleFocusIn=e=>{let t=this.focusedOptionForEvent(e);this.markKeyboardFocus(t&&this.optionShowsKeyboardFocus(t)?t:void 0)},this.handleContentClick=e=>{this.disabled||e.composedPath().some(e=>e instanceof Element&&e.matches(`a[href], button, input, select, textarea, [contenteditable="true"], [data-option-index], #other-field, luzmo-action-button, luzmo-button, luzmo-close-button`))||this.focusOptions()},this.handleFocusOut=()=>{requestAnimationFrame(()=>{let e=this.shadowRoot?.activeElement;e instanceof HTMLElement&&e.dataset.optionIndex!==void 0||this.markKeyboardFocus()})},this.handleCancelClick=e=>{e.preventDefault(),this.cancel()},this.handleSkip=e=>{e.preventDefault(),!(this.disabled||this.readonly)&&this.emitResult(`decline`)},this.handleBack=e=>{e.preventDefault(),!(this.disabled||this._step===0)&&(this._showError=!1,--this._step,this.updateComplete.then(()=>this.moveFocus(this.questionTitle)))},this.handlePrimary=()=>{let e=this.currentQuestion;e&&!this.disabled&&(!this.readonly&&this.questionInvalid(e)?(this._showError=!0,this.focusOptions()):(this._showError=!1,this._step<this.questions.length-1?(this._step+=1,this.updateComplete.then(()=>this.moveFocus(this.questionTitle))):this.readonly||this.acceptFlow()))},this.handleChange=()=>{this._resolved=!1,this._submitted=!1,this._showError=!1,this.updateComplete.then(()=>this.focusOptions())},this.handleRadioChange=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.target.value||e.currentTarget.selected;n&&(n===`__other__`&&!String(this.value[_(t.id)]??``).trim()?(this.requestUpdate(),this.updateComplete.then(()=>this.moveFocus(this.otherField))):(this.commitAnswer(t.id,n,!0),n!==`__other__`&&(this._radioChangeAdvanced=!0,this.advanceAfterSingleSelection(),queueMicrotask(()=>{this._radioChangeAdvanced=!1}))))},this.handleRadioClick=e=>{if(this._radioChangeAdvanced||this.disabled||this.readonly)return;let t=this.currentQuestion,n=e.currentTarget;t?.type===`single`&&n.value!==`__other__`&&this.selectedValues(t)[0]===n.value&&this.advanceAfterSingleSelection()},this.handleCheckboxChange=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.currentTarget,r=n.dataset.value;if(!r)return;let i=new Set(this.selectedValues(t));if(r===`__other__`&&n.checked&&!String(this.value[_(t.id)]??``).trim()){n.checked=!1,this.moveFocus(this.otherField);return}n.checked?i.add(r):i.delete(r);let a=[...t.options.map(e=>e.value),...v(t)?[h]:[]].filter(e=>i.has(e));this.commitAnswer(t.id,C(a),!0),r===`__other__`&&n.checked&&this.updateComplete.then(()=>this.moveFocus(this.otherField))},this.handleOtherInput=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.currentTarget;this.commitOther(t,n.value,!1)},this.handleOtherChange=e=>{if(e.stopPropagation(),this.disabled||this.readonly)return;let t=this.currentQuestion;if(!t)return;let n=e.currentTarget;this.commitOther(t,n.value,!0)},this.handleOtherKeydown=e=>{if(e.key!==`Enter`||e.shiftKey||e.isComposing||this.disabled||this.readonly)return;e.preventDefault();let t=this.currentQuestion;t&&String(this.value[_(t.id)]??``).trim()&&this.handlePrimary()}}static get styles(){let e=super.styles;return[...Array.isArray(e)?e:e?[e]:[],n(m)]}get optionIndicator(){return this._optionIndicator}set optionIndicator(e){let t=this._optionIndicator;this._optionIndicator=e===`letters`?`letters`:`numbers`,this.requestUpdate(`optionIndicator`,t)}connectedCallback(){super.connectedCallback(),this.addEventListener(`keydown`,this.handleKeydown),this.addEventListener(`keyup`,this.handleKeyup),this.addEventListener(`focusin`,this.handleFocusIn)}attributeChangedCallback(e,t,n){e===`option-indicator`&&n!==null&&n!==`numbers`&&n!==`letters`?this.setAttribute(`option-indicator`,`numbers`):super.attributeChangedCallback(e,t,n)}disconnectedCallback(){this.removeEventListener(`keydown`,this.handleKeydown),this.removeEventListener(`keyup`,this.handleKeyup),this.removeEventListener(`focusin`,this.handleFocusIn),super.disconnectedCallback()}focus(){this._resolved||this.answered?this.moveFocus(this.resolvedTitle):this.focusOptions()}checkValidity(){return this.questions.every(e=>!this.questionInvalid(e))}submit(){this.disabled||this.readonly||this.answered||this._submitted||this.acceptFlow()}reset(){this._resolved=!1,this._submitted=!1,this._showError=!1,this._step=0,this.value={}}cancel(){this.emitResult(`cancel`)}willUpdate(e){if(super.willUpdate(e),e.has(`questions`)||e.has(`value`)){if(e.has(`questions`)){ae(this.questions);let t=(e.get(`questions`)??[]).map(e=>e.id),n=this.questions.map(e=>e.id);t.join(`\0`)!==n.join(`\0`)&&(this._step=0,this._resolved=!1,this._submitted=!1,this._showError=!1)}let t=O(this.questions,this.value);S(t,this.value)||(this.value=t)}e.has(`questions`)&&(this._step=Math.min(this._step,Math.max(0,this.questions.length-1)))}updated(e){super.updated(e),(e.has(`questions`)||e.has(`size`)||e.has(`disabled`)||e.has(`readonly`)||e.has(`answered`)||e.has(`_step`)||e.has(`_resolved`))&&this.multipleChoiceRoving.clearElementCache()}render(){return Ce(this.renderContext)}get renderContext(){return{questions:this.questions,value:this.value,copy:this.copy,step:this._step,resolved:this._resolved||this.answered,answered:this.answered,submitted:this._submitted,showError:this._showError,disabled:this.disabled,readonly:this.readonly,hideClose:this.hideClose,hideSkip:this.hideSkip,showChange:this.showChange,optionIndicator:this.optionIndicator,size:this.size,dir:this.dir,language:this.languageResolver.language,selectedValues:e=>this.selectedValues(e),isOtherSelected:e=>this.isOtherSelected(e),questionError:e=>this.questionError(e),questionInvalid:e=>this.questionInvalid(e),optionDisabled:(e,t,n)=>this.optionDisabled(e,t,n),handlers:this.renderHandlers}}get renderHandlers(){return{contentClick:this.handleContentClick,back:this.handleBack,primary:this.handlePrimary,skip:this.handleSkip,cancel:this.handleCancelClick,change:this.handleChange,radioChange:this.handleRadioChange,radioClick:this.handleRadioClick,checkboxChange:this.handleCheckboxChange,otherInput:this.handleOtherInput,otherChange:this.handleOtherChange,otherKeydown:this.handleOtherKeydown,focusIn:this.handleFocusIn,focusOut:this.handleFocusOut}}get copy(){return E(this.labels)}get currentQuestion(){return this.questions[this._step]}optionShowsKeyboardFocus(e){let t=e=>{if(!e)return!1;try{return e.matches(`:focus-visible`)||e.matches(`.focus-visible`)}catch{return e.matches(`.focus-visible`)}};return t(e)||t(e.shadowRoot?.activeElement)||this.hasVisibleFocusInTree()}markKeyboardFocus(e){this.shadowRoot?.querySelectorAll(`[data-focus-visible]`).forEach(e=>delete e.dataset.focusVisible),this.shadowRoot?.querySelectorAll(`.option-number--focused`).forEach(e=>e.classList.remove(`option-number--focused`)),e&&(e.dataset.focusVisible=``,e.querySelector(`.option-number`)?.classList.add(`option-number--focused`))}focusedOptionForEvent(e){let t=e.composedPath().find(e=>e instanceof HTMLElement&&e.dataset.optionIndex!==void 0);if(t)return t;let n=this.shadowRoot?.activeElement;return n instanceof HTMLElement&&n.dataset.optionIndex!==void 0?n:void 0}moveFocus(e){if(e)try{e.focus()}catch{try{HTMLElement.prototype.focus.call(e)}catch{return}}}focusOptions(){let e=this.optionsGroup;if(!e){this.moveFocus(this.questionTitle);return}let t=this.currentQuestion,n=t?.type===`single`?this.selectedValues(t)[0]:void 0,r=n?e.querySelector(`luzmo-radio[value="${CSS.escape(n)}"]:not([disabled])`):void 0,i=e.querySelector(`[data-option-index]:not([disabled])`);this.moveFocus(r??i??e)}advanceAfterSingleSelection(){this._step<this.questions.length-1?(this._step+=1,this.updateComplete.then(()=>this.moveFocus(this.questionTitle))):(this._resolved=!0,this._submitted=!1,this.updateComplete.then(()=>this.focus()))}acceptFlow(){let e=this.questions.findIndex(e=>this.questionInvalid(e));e===-1?(this._showError=!1,this._resolved=!0,this._submitted=!0,this.emitResult(`accept`,B(this.questions,this.value)),this.updateComplete.then(()=>this.focus())):(this._step=e,this._showError=!0,this.updateComplete.then(()=>this.focusOptions()))}commitAnswer(e,t,n){let r=b(this.value);x(r,e,t),this.assignValue(r,n)}commitOther(e,t,n){let r=b(this.value);x(r,_(e.id),t);let i=t.trim().length>0;if(e.type===`single`)i?x(r,e.id,h):r[e.id]===`__other__`&&x(r,e.id,``);else{let t=new Set(this.selectedValues(e));i?t.add(h):t.delete(h),x(r,e.id,[...e.options.map(e=>e.value),h].filter(e=>t.has(e)))}this.assignValue(r,n)}assignValue(e,t){S(e,this.value)||(this.value=e,this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0}))),t&&this.dispatchEvent(new Event(`change`,{bubbles:!0,composed:!0}))}emitResult(e,t){let n=e===`accept`?{action:e,content:t}:{action:e};e===`accept`?this.dispatchEvent(new CustomEvent(`luzmo-submit`,{detail:n,bubbles:!0,composed:!0})):e===`decline`?this.dispatchEvent(new CustomEvent(`luzmo-decline`,{detail:n,bubbles:!0,composed:!0})):this.dispatchEvent(new CustomEvent(`luzmo-cancel`,{detail:n,bubbles:!0,composed:!0}))}selectedValues(e){return w(e,this.value)}isOtherSelected(e){return T(e,this.value)}questionError(e){return N(e,this.value,this.copy)}questionInvalid(e){return M(e,this.value)}optionDisabled(e,t,n){return P(e,t,n,this.value,this.disabled)}};a([u({attribute:!1})],$.prototype,`questions`,void 0),a([u({attribute:!1})],$.prototype,`value`,void 0),a([u({attribute:!1})],$.prototype,`labels`,void 0),a([u({reflect:!0})],$.prototype,`dir`,void 0),a([u({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),a([u({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),a([u({type:Boolean,reflect:!0})],$.prototype,`answered`,void 0),a([u({type:Boolean,reflect:!0,attribute:`hide-close`})],$.prototype,`hideClose`,void 0),a([u({type:Boolean,reflect:!0,attribute:`hide-skip`})],$.prototype,`hideSkip`,void 0),a([u({type:Boolean,reflect:!0,attribute:`show-change`})],$.prototype,`showChange`,void 0),a([u({reflect:!0,attribute:`option-indicator`})],$.prototype,`optionIndicator`,null),a([r()],$.prototype,`_step`,void 0),a([r()],$.prototype,`_resolved`,void 0),a([r()],$.prototype,`_submitted`,void 0),a([r()],$.prototype,`_showError`,void 0),a([l(`#question-title`)],$.prototype,`questionTitle`,void 0),a([l(`#other-field`)],$.prototype,`otherField`,void 0),a([l(`#options`)],$.prototype,`optionsGroup`,void 0),a([l(`#resolved-title`)],$.prototype,`resolvedTitle`,void 0),typeof customElements<`u`&&!customElements.get(`luzmo-question-box`)&&customElements.define(`luzmo-question-box`,$);export{g as DEFAULT_QUESTION_BOX_LABELS,$ as LuzmoQuestionBox,h as QUESTION_BOX_OTHER_VALUE,_ as questionBoxOtherKey,R as questionsToRequestedSchema,ue as requestedSchemaToQuestions,B as toElicitationContent};
|