@luzmo/lucero 2.7.0 → 2.7.1
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.d.ts +4 -1
- package/components/{question-box-BAyRPZ8j.js → question-box-CxzEveid.js} +148 -144
- package/components/question-box-DmTWFlRn.cjs +401 -0
- package/custom-elements.json +1 -1
- package/package.json +1 -1
- package/standalone/question-box.js +52 -52
- package/components/question-box-D7s2xNAD.cjs +0 -401
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
/*! * Lucero - The design system for Luzmo.
|
|
2
|
-
*
|
|
3
|
-
* Copyright © 2026 Luzmo
|
|
4
|
-
* All rights reserved.
|
|
5
|
-
* Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
|
|
6
|
-
* This license allows users with a current active Luzmo account to use Lucero.
|
|
7
|
-
* This license terminates automatically if a user no longer has an active Luzmo account.
|
|
8
|
-
* Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
|
|
9
|
-
*
|
|
10
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
-
* SOFTWARE.
|
|
17
|
-
* */
|
|
18
|
-
require("./tokens.cjs");const e=require("./decorate-SO02l0A6.cjs"),t=require("./sized-mixin-CSajkMro.cjs"),n=require("./roving-tabindex-BUFR8hPH.cjs");require("./icon-BlbMP3mJ.cjs");const r=require("./language-resolution-B7D3hQ6_.cjs");require("./action-button-CL4ZlryE.cjs"),require("./badge-DzElGOcl.cjs"),require("./button-BGEWdRbY.cjs"),require("./checkbox-NSSgVzJg.cjs"),require("./field-group/index.cjs"),require("./text-field-CZixBD87.cjs"),require("./radio-Dd-GgUMm.cjs");let i=require("lit"),a=require("lit/decorators.js"),o=require("@luzmo/icons"),s=require("lit/directives/if-defined.js"),c=require("lit/directives/repeat.js");var l=`: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)}`,u=`__other__`,d={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.`},f=e=>`${e}Other`,p=e=>!!e.other||e.options.length===0,m=e=>typeof e.other==`object`&&e.other?e.other:{},h=e=>Object.fromEntries(Object.entries(e)),g=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})},_=(e,t)=>{let n=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},v=e=>{let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n},y=e=>{let t=new Set(e.options.map(e=>e.value));return p(e)&&t.add(u),t},b=(e,t)=>{let n=t[e.id];return e.type===`single`?typeof n==`string`&&n?[n]:[]:Array.isArray(n)?v(n):[]},x=(e,t)=>b(e,t).includes(u),S=e=>{let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0));return{...d,...t}},C=(e,t)=>{let n=e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`{${e}}`,r);return n},w=e=>{let t=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=f(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+ +!!p(n);if(n.type===`multiple`&&i>a)throw TypeError(`luzmo-question-box: minSelected exceeds the available options on "${n.id}".`);let o=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: "${u}" 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)}}},T=(e,t)=>{let n=Object.fromEntries([]);for(let r of e){let e=y(r),i=t[r.id],a=Object.hasOwn(t,r.id);if(r.type===`single`)typeof i==`string`&&e.has(i)?g(n,r.id,i):!a&&typeof r.default==`string`&&(e.has(r.default)||r.options.length===0)&&g(n,r.id,r.options.length===0?u:r.default);else{let t=[...r.options.map(e=>e.value),...p(r)?[u]:[]],o=v(Array.isArray(i)?i.filter(t=>e.has(t)):[]);if(o.length>0)g(n,r.id,t.filter(e=>o.includes(e)));else if(!a&&Array.isArray(r.default)){let i=v(r.default.filter(t=>e.has(t)));i.length>0&&g(n,r.id,t.filter(e=>i.includes(e)))}}let o=f(r.id),s=t[o];typeof s==`string`?g(n,o,s):!a&&r.options.length===0&&typeof r.default==`string`&&g(n,o,r.default)}return n},E=e=>e.minSelected??+!!e.required,D=(e,t)=>{let n=E(e),r=e.maxSelected;return n>0&&r!==void 0?C(t.selectionRangeDescription,{min:String(n),max:String(r)}):n===1?t.requiredSelectionDescription:n>1?C(t.minSelectedError,{min:String(n)}):r===void 0?void 0:C(t.maxSelectedError,{max:String(r)})},O=(e,t)=>{let n=b(e,t),r=E(e),i=e.maxSelected;if(n.length<r)return r<=1?`missing`:`minimum`;if(i!==void 0&&n.length>i)return`maximum`;if(x(e,t)&&!String(t[f(e.id)]??``).trim())return`otherText`},k=(e,t)=>O(e,t)!==void 0,A=(e,t,n)=>{switch(O(e,t)){case`minimum`:return C(n.minSelectedError,{min:String(E(e))});case`maximum`:return C(n.maxSelectedError,{max:String(e.maxSelected)});case`otherText`:return n.otherRequiredError;default:return}},j=(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&&b(e,r).length>=a},M=(e,t)=>C(e===1?t.selectedCountOne:t.selectedCount,{count:String(e)}),N,ee=(e,t)=>{try{return N?.language!==t&&(N={language:t,formatter:new Intl.ListFormat(t,{style:`narrow`,type:`conjunction`})}),N.formatter.format(e)}catch{return e.join(`, `)}},te=(e,t)=>e.recommended?C(t.recommendedSuffix,{label:e.label,recommended:t.recommended}):e.label,ne=e=>{let t=e.options.map(e=>({const:e.value,title:e.label}));return p(e)&&e.options.length>0&&t.push({const:u,title:typeof e.other==`object`&&e.other.label||d.other}),t},re=e=>{let t={type:`string`};return typeof e.other==`object`&&e.other.label&&(t.title=e.other.label),t},ie=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=ne(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),p(r)&&t.push([f(r.id),re(r)])}let r=Object.fromEntries(t);return n.length>0?{type:`object`,properties:r,required:n}:{type:`object`,properties:r}},ae=(e,t)=>String(t[f(e.id)]??``).trim(),P=(e,t)=>{let n=[];for(let r of e){let e=ae(r,t);if(r.options.length===0){e&&n.push([r.id,e]);continue}let i=b(r,t);r.type===`single`?i[0]&&n.push([r.id,i[0]]):i.length>0&&n.push([r.id,[...i]]),p(r)&&x(r,t)&&e&&n.push([f(r.id),e])}return Object.fromEntries(n)},F=e=>!!e&&typeof e==`object`&&!Array.isArray(e),I=e=>F(e)?e:{},L=e=>{let t=e.oneOf??e.items?.anyOf;if(Array.isArray(t)){let e=[],n=new Set;for(let r of t)F(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=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:[]}},R=e=>f(e),z=e=>e.format!==void 0||e.minLength!==void 0||e.maxLength!==void 0||e.pattern!==void 0,B=e=>e.type===`string`&&!L(e).declared&&!z(e),V=e=>{if(e.type!==`object`||!e.properties)return[];let t=e.properties,n=new Set(e.required??[]),r=new Set;for(let e of Object.keys(t)){let n=R(e),i=L(I(t[e])),a=I(t[n]);n in t&&B(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=I(a),s=L(o),c=s.options.some(e=>e.value===u),l=R(e);if(c&&!r.has(l))continue;let d=s.options.filter(e=>e.value!==u);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&&z(o))continue;let f={id:e,type:o.type===`array`?`multiple`:`single`,title:o.title||e,options:d};if(o.description&&(f.description=o.description),n.has(e)&&(f.required=!0),o.type===`array`?(o.minItems!==void 0&&(f.minSelected=o.minItems),o.maxItems!==void 0&&(f.maxSelected=o.maxItems),Array.isArray(o.default)&&o.default.length>0&&(f.default=o.default)):typeof o.default==`string`&&(f.default=o.default),c&&l in t){let e=I(t[l]);f.other=!e.title||{label:e.title}}i.push(f)}return i};function H(e){switch(e){case`s`:return`xs`;case`m`:return`s`;case`l`:return`m`;default:return`l`}}function U(e){switch(e){case`m`:return`xs`;case`l`:return`s`;case`xl`:case`xxl`:return`m`;default:return`xxs`}}function W(e){return e.step>=e.questions.length-1}function G(e,t){let n=e.selectedValues(t);return n.length===0?``:ee(n.map(n=>{if(n===`__other__`)return String(e.value[f(t.id)]??e.copy.other);let r=t.options.find(e=>e.value===n);return r?te(r,e.copy):n}),e.language)}function K(e,t){let n=G(e,t),r=e.copy.answer.split(`{answer}`).map((e,t)=>i.html`${t>0?i.html`<span class="summary-answer">${n}</span>`:i.nothing}${e}`);return i.html`<span class="summary-value">${r}</span>`}function q(e){let t=e.copy,n=e.questions.reduce((t,n)=>t+e.selectedValues(n).length,0);return i.html`
|
|
19
|
-
<div class="card resolved">
|
|
20
|
-
<div class="summary">
|
|
21
|
-
<h2 class="summary-heading" id="resolved-title" tabindex="-1">
|
|
22
|
-
${n===1?t.answerTitle:t.answersTitle}
|
|
23
|
-
</h2>
|
|
24
|
-
${(0,c.repeat)(e.questions,e=>e.id,t=>i.html`
|
|
25
|
-
<div class="summary-row">
|
|
26
|
-
<span class="summary-title">${t.title}</span>
|
|
27
|
-
${K(e,t)}
|
|
28
|
-
</div>
|
|
29
|
-
`)}
|
|
30
|
-
</div>
|
|
31
|
-
<div class="summary-actions">
|
|
32
|
-
${!e.submitted||e.showChange?i.html`
|
|
33
|
-
<luzmo-button
|
|
34
|
-
id="change-button"
|
|
35
|
-
dir=${e.dir}
|
|
36
|
-
variant="primary"
|
|
37
|
-
treatment=${e.submitted?`fill`:`outline`}
|
|
38
|
-
size=${e.size}
|
|
39
|
-
?disabled=${e.disabled}
|
|
40
|
-
@click=${e.handlers.change}
|
|
41
|
-
>${t.change}</luzmo-button
|
|
42
|
-
>
|
|
43
|
-
`:i.nothing}
|
|
44
|
-
${e.submitted?i.nothing:i.html`
|
|
45
|
-
<luzmo-button
|
|
46
|
-
id="review-submit-button"
|
|
47
|
-
dir=${e.dir}
|
|
48
|
-
variant="primary"
|
|
49
|
-
size=${e.size}
|
|
50
|
-
?disabled=${e.disabled||e.readonly}
|
|
51
|
-
@click=${e.handlers.primary}
|
|
52
|
-
>${t.submit}</luzmo-button
|
|
53
|
-
>
|
|
54
|
-
`}
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
`}function J(e,t,n){let r=e.optionIndicator===`letters`&&n<26?String.fromCharCode(65+n):String(n+1);return i.html`
|
|
58
|
-
<span
|
|
59
|
-
class=${t.description?`option-content option-content--detailed`:`option-content`}
|
|
60
|
-
>
|
|
61
|
-
<span class="option-number" aria-hidden="true">${r}</span>
|
|
62
|
-
<span class="option-copy">
|
|
63
|
-
<span class="option-heading">
|
|
64
|
-
<span class="option-text">
|
|
65
|
-
<span class="option-label">${t.label}</span>
|
|
66
|
-
${t.hint?i.html`<span class="option-hint">${t.hint}</span>`:i.nothing}
|
|
67
|
-
</span>
|
|
68
|
-
${t.recommended?i.html`<luzmo-badge
|
|
69
|
-
class="recommended-label"
|
|
70
|
-
dir=${e.dir}
|
|
71
|
-
variant="neutral"
|
|
72
|
-
treatment="subtle"
|
|
73
|
-
size=${H(e.size)}
|
|
74
|
-
>${e.copy.recommended}</luzmo-badge
|
|
75
|
-
>`:i.nothing}
|
|
76
|
-
</span>
|
|
77
|
-
${t.description?i.html`<span class="option-description"
|
|
78
|
-
>${t.description}</span
|
|
79
|
-
>`:i.nothing}
|
|
80
|
-
</span>
|
|
81
|
-
</span>
|
|
82
|
-
`}function Y(e,t){return e.disabledReason?i.html`<span class="visually-hidden" id="option-reason-${t}"
|
|
83
|
-
>${e.disabledReason}</span
|
|
84
|
-
>`:i.nothing}function oe(e,t){return t?i.html`
|
|
85
|
-
<luzmo-help-text
|
|
86
|
-
id="question-error"
|
|
87
|
-
dir=${e.dir}
|
|
88
|
-
slot="negative-help-text"
|
|
89
|
-
>${t}</luzmo-help-text
|
|
90
|
-
>
|
|
91
|
-
`:i.nothing}function X(e,t){if(t.type!==`multiple`)return i.nothing;let n=e.showError?e.questionError(t):void 0;return i.html`
|
|
92
|
-
<span class="selected-count" aria-live="polite"
|
|
93
|
-
>${n?i.html`<luzmo-help-text
|
|
94
|
-
id="question-error"
|
|
95
|
-
class="status-error"
|
|
96
|
-
dir=${e.dir}
|
|
97
|
-
variant="negative"
|
|
98
|
-
>${n}</luzmo-help-text
|
|
99
|
-
>`:M(e.selectedValues(t).length,e.copy)}</span
|
|
100
|
-
>
|
|
101
|
-
`}function se(e,t){return i.html`
|
|
102
|
-
<div class="other-actions">
|
|
103
|
-
${X(e,t)}
|
|
104
|
-
${e.hideSkip?i.nothing:i.html`
|
|
105
|
-
<luzmo-button
|
|
106
|
-
id="other-skip-button"
|
|
107
|
-
dir=${e.dir}
|
|
108
|
-
variant="primary"
|
|
109
|
-
size=${H(e.size)}
|
|
110
|
-
quiet
|
|
111
|
-
?disabled=${e.disabled}
|
|
112
|
-
@click=${e.handlers.skip}
|
|
113
|
-
>${e.copy.skip}</luzmo-button
|
|
114
|
-
>
|
|
115
|
-
`}
|
|
116
|
-
<luzmo-button
|
|
117
|
-
id="other-primary-button"
|
|
118
|
-
dir=${e.dir}
|
|
119
|
-
class="other-primary"
|
|
120
|
-
variant="primary"
|
|
121
|
-
treatment="outline"
|
|
122
|
-
size=${H(e.size)}
|
|
123
|
-
?disabled=${e.disabled||e.readonly||e.questionInvalid(t)}
|
|
124
|
-
@click=${e.handlers.primary}
|
|
125
|
-
>${W(e)?e.copy.submit:e.copy.continue}</luzmo-button
|
|
126
|
-
>
|
|
127
|
-
</div>
|
|
128
|
-
`}function ce(e,t){return e.isOtherSelected(t)&&String(e.value[f(t.id)]??``).trim().length>0}function Z(e,t){let n=m(t),r=f(t.id),a=e.isOtherSelected(t),o=e.optionDisabled(t,{value:u,label:n.label||e.copy.other},a),s=e.showError&&a&&!!e.questionError(t);return i.html`
|
|
129
|
-
<luzmo-text-field
|
|
130
|
-
id="other-field"
|
|
131
|
-
dir=${e.dir}
|
|
132
|
-
class="other-field"
|
|
133
|
-
size=${e.size}
|
|
134
|
-
label=${n.label||e.copy.other}
|
|
135
|
-
placeholder=${n.placeholder||e.copy.otherPlaceholder}
|
|
136
|
-
border="none"
|
|
137
|
-
multiline
|
|
138
|
-
grows
|
|
139
|
-
rows="1"
|
|
140
|
-
.value=${String(e.value[r]??``)}
|
|
141
|
-
?disabled=${o}
|
|
142
|
-
?readonly=${e.readonly}
|
|
143
|
-
?invalid=${s}
|
|
144
|
-
@keydown=${e.handlers.otherKeydown}
|
|
145
|
-
@input=${e.handlers.otherInput}
|
|
146
|
-
@change=${e.handlers.otherChange}
|
|
147
|
-
></luzmo-text-field>
|
|
148
|
-
`}function le(e,t){let n=ce(e,t);return t.type===`multiple`||e.hideSkip&&!n?i.nothing:i.html`
|
|
149
|
-
<luzmo-button
|
|
150
|
-
id="other-row-action"
|
|
151
|
-
dir=${e.dir}
|
|
152
|
-
class="other-primary"
|
|
153
|
-
variant="primary"
|
|
154
|
-
treatment="outline"
|
|
155
|
-
size=${H(e.size)}
|
|
156
|
-
?disabled=${n?e.disabled||e.readonly||e.questionInvalid(t):e.disabled}
|
|
157
|
-
@click=${n?e.handlers.primary:e.handlers.skip}
|
|
158
|
-
>${n?W(e)?e.copy.submit:e.copy.continue:e.copy.skip}</luzmo-button
|
|
159
|
-
>
|
|
160
|
-
`}function ue(e,t,n){let r=e.selectedValues(t)[0]??``,a=t.options.some(e=>e.description)?`options options--descriptive`:`options`;return i.html`
|
|
161
|
-
<luzmo-radio-group
|
|
162
|
-
id="options"
|
|
163
|
-
dir=${e.dir}
|
|
164
|
-
class=${a}
|
|
165
|
-
vertical
|
|
166
|
-
label=${t.title}
|
|
167
|
-
manual-selection
|
|
168
|
-
aria-readonly=${(0,s.ifDefined)(e.readonly?`true`:void 0)}
|
|
169
|
-
aria-required=${(0,s.ifDefined)(t.required?`true`:void 0)}
|
|
170
|
-
.selected=${r}
|
|
171
|
-
?invalid=${!!n}
|
|
172
|
-
@change=${e.handlers.radioChange}
|
|
173
|
-
@focusin=${e.handlers.focusIn}
|
|
174
|
-
@focusout=${e.handlers.focusOut}
|
|
175
|
-
>
|
|
176
|
-
${(0,c.repeat)(t.options,e=>e.value,(n,a)=>i.html`
|
|
177
|
-
<luzmo-radio
|
|
178
|
-
class="numbered-option"
|
|
179
|
-
dir=${e.dir}
|
|
180
|
-
value=${n.value}
|
|
181
|
-
data-option-index=${a}
|
|
182
|
-
size=${e.size}
|
|
183
|
-
emphasized
|
|
184
|
-
?disabled=${e.optionDisabled(t,n,n.value===r)}
|
|
185
|
-
?readonly=${e.readonly}
|
|
186
|
-
aria-describedby=${(0,s.ifDefined)(n.disabledReason?`option-reason-${a}`:void 0)}
|
|
187
|
-
@click=${e.handlers.radioClick}
|
|
188
|
-
@change=${e.handlers.radioChange}
|
|
189
|
-
>
|
|
190
|
-
${J(e,n,a)}
|
|
191
|
-
${Y(n,a)}
|
|
192
|
-
</luzmo-radio>
|
|
193
|
-
`)}
|
|
194
|
-
${p(t)?i.html`
|
|
195
|
-
<div class="other-option-row">
|
|
196
|
-
<div class="other-option-answer">
|
|
197
|
-
<luzmo-radio
|
|
198
|
-
class="numbered-option other-option"
|
|
199
|
-
dir=${e.dir}
|
|
200
|
-
value=${u}
|
|
201
|
-
data-option-index=${t.options.length}
|
|
202
|
-
size=${e.size}
|
|
203
|
-
emphasized
|
|
204
|
-
aria-label=${m(t).label||e.copy.other}
|
|
205
|
-
?disabled=${e.disabled}
|
|
206
|
-
?readonly=${e.readonly}
|
|
207
|
-
@change=${e.handlers.radioChange}
|
|
208
|
-
>
|
|
209
|
-
<span class="option-number option-edit" aria-hidden="true">
|
|
210
|
-
<luzmo-icon
|
|
211
|
-
block
|
|
212
|
-
dir=${e.dir}
|
|
213
|
-
.size=${U(e.size)}
|
|
214
|
-
.icon=${o.luzmoPencil}
|
|
215
|
-
></luzmo-icon>
|
|
216
|
-
</span>
|
|
217
|
-
</luzmo-radio>
|
|
218
|
-
${Z(e,t)}
|
|
219
|
-
</div>
|
|
220
|
-
${le(e,t)}
|
|
221
|
-
</div>
|
|
222
|
-
`:i.nothing}
|
|
223
|
-
${oe(e,n)}
|
|
224
|
-
</luzmo-radio-group>
|
|
225
|
-
`}function Q(e,t,n){let r=new Set(e.selectedValues(t)),a=e.isOtherSelected(t),l=t.options.some(e=>e.description)?`options options--descriptive`:`options`,d=D(t,e.copy);return i.html`
|
|
226
|
-
${d?i.html`<span class="visually-hidden" id="selection-requirement"
|
|
227
|
-
>${d}</span
|
|
228
|
-
>`:i.nothing}
|
|
229
|
-
<luzmo-field-group
|
|
230
|
-
id="options"
|
|
231
|
-
dir=${e.dir}
|
|
232
|
-
class=${l}
|
|
233
|
-
vertical
|
|
234
|
-
label=${t.title}
|
|
235
|
-
aria-describedby=${(0,s.ifDefined)(d?`selection-requirement`:void 0)}
|
|
236
|
-
?invalid=${!!n}
|
|
237
|
-
@focusin=${e.handlers.focusIn}
|
|
238
|
-
@focusout=${e.handlers.focusOut}
|
|
239
|
-
>
|
|
240
|
-
${(0,c.repeat)(t.options,e=>e.value,(n,a)=>i.html`
|
|
241
|
-
<luzmo-checkbox
|
|
242
|
-
class="numbered-option"
|
|
243
|
-
dir=${e.dir}
|
|
244
|
-
data-value=${n.value}
|
|
245
|
-
data-option-index=${a}
|
|
246
|
-
size=${e.size}
|
|
247
|
-
emphasized
|
|
248
|
-
?checked=${r.has(n.value)}
|
|
249
|
-
?disabled=${e.optionDisabled(t,n,r.has(n.value))}
|
|
250
|
-
?readonly=${e.readonly}
|
|
251
|
-
aria-describedby=${(0,s.ifDefined)(n.disabledReason?`option-reason-${a}`:void 0)}
|
|
252
|
-
@change=${e.handlers.checkboxChange}
|
|
253
|
-
>
|
|
254
|
-
${J(e,n,a)}
|
|
255
|
-
${Y(n,a)}
|
|
256
|
-
</luzmo-checkbox>
|
|
257
|
-
`)}
|
|
258
|
-
${p(t)?i.html`
|
|
259
|
-
<div class="other-option-row other-option-row--multiple">
|
|
260
|
-
<div class="other-option-answer">
|
|
261
|
-
<luzmo-checkbox
|
|
262
|
-
class="numbered-option other-option"
|
|
263
|
-
dir=${e.dir}
|
|
264
|
-
data-value=${u}
|
|
265
|
-
data-option-index=${t.options.length}
|
|
266
|
-
size=${e.size}
|
|
267
|
-
emphasized
|
|
268
|
-
?checked=${a}
|
|
269
|
-
?disabled=${e.optionDisabled(t,{value:u,label:e.copy.other},a)}
|
|
270
|
-
?readonly=${e.readonly}
|
|
271
|
-
@change=${e.handlers.checkboxChange}
|
|
272
|
-
>
|
|
273
|
-
<span class="option-number option-edit" aria-hidden="true">
|
|
274
|
-
<luzmo-icon
|
|
275
|
-
block
|
|
276
|
-
dir=${e.dir}
|
|
277
|
-
.size=${U(e.size)}
|
|
278
|
-
.icon=${o.luzmoPencil}
|
|
279
|
-
></luzmo-icon>
|
|
280
|
-
</span>
|
|
281
|
-
<span class="visually-hidden"
|
|
282
|
-
>${m(t).label||e.copy.other}</span
|
|
283
|
-
>
|
|
284
|
-
</luzmo-checkbox>
|
|
285
|
-
${Z(e,t)}
|
|
286
|
-
</div>
|
|
287
|
-
</div>
|
|
288
|
-
${se(e,t)}
|
|
289
|
-
`:i.nothing}
|
|
290
|
-
</luzmo-field-group>
|
|
291
|
-
`}function de(e,t){let n=e.copy,r=C(n.progress,{current:String(e.step+1),total:String(e.questions.length)}),a=!e.questionInvalid(t);return i.html`
|
|
292
|
-
<header class="header">
|
|
293
|
-
<div class="heading">
|
|
294
|
-
<h2 class="title" id="question-title" tabindex="-1">
|
|
295
|
-
${t.title}
|
|
296
|
-
</h2>
|
|
297
|
-
${t.description?i.html`<p class="description" id="question-description">
|
|
298
|
-
${t.description}
|
|
299
|
-
</p>`:i.nothing}
|
|
300
|
-
</div>
|
|
301
|
-
<div class="header-actions">
|
|
302
|
-
${e.questions.length>1?i.html`
|
|
303
|
-
<nav class="step-navigation" aria-label=${r}>
|
|
304
|
-
<luzmo-action-button
|
|
305
|
-
id="back-button"
|
|
306
|
-
dir=${e.dir}
|
|
307
|
-
quiet
|
|
308
|
-
size=${H(e.size)}
|
|
309
|
-
label=${n.back}
|
|
310
|
-
?disabled=${e.disabled||e.step===0}
|
|
311
|
-
@click=${e.handlers.back}
|
|
312
|
-
>
|
|
313
|
-
<div slot="icon">
|
|
314
|
-
<luzmo-icon
|
|
315
|
-
block
|
|
316
|
-
dir=${e.dir}
|
|
317
|
-
.size=${H(e.size)}
|
|
318
|
-
.icon=${o.luzmoAngleLeft}
|
|
319
|
-
></luzmo-icon>
|
|
320
|
-
</div>
|
|
321
|
-
</luzmo-action-button>
|
|
322
|
-
<p class="progress" id="progress" aria-live="polite">
|
|
323
|
-
${r}
|
|
324
|
-
</p>
|
|
325
|
-
<luzmo-action-button
|
|
326
|
-
id="continue-button"
|
|
327
|
-
dir=${e.dir}
|
|
328
|
-
quiet
|
|
329
|
-
size=${H(e.size)}
|
|
330
|
-
label=${n.continue}
|
|
331
|
-
?disabled=${e.disabled||e.readonly||W(e)||!a}
|
|
332
|
-
@click=${e.handlers.primary}
|
|
333
|
-
>
|
|
334
|
-
<div slot="icon">
|
|
335
|
-
<luzmo-icon
|
|
336
|
-
block
|
|
337
|
-
dir=${e.dir}
|
|
338
|
-
.size=${H(e.size)}
|
|
339
|
-
.icon=${o.luzmoAngleRight}
|
|
340
|
-
></luzmo-icon>
|
|
341
|
-
</div>
|
|
342
|
-
</luzmo-action-button>
|
|
343
|
-
</nav>
|
|
344
|
-
`:i.nothing}
|
|
345
|
-
${e.hideClose?i.nothing:i.html`
|
|
346
|
-
<luzmo-close-button
|
|
347
|
-
id="close-button"
|
|
348
|
-
dir=${e.dir}
|
|
349
|
-
class="close"
|
|
350
|
-
label=${n.close}
|
|
351
|
-
size=${e.size}
|
|
352
|
-
?disabled=${e.disabled}
|
|
353
|
-
@click=${e.handlers.cancel}
|
|
354
|
-
></luzmo-close-button>
|
|
355
|
-
`}
|
|
356
|
-
</div>
|
|
357
|
-
</header>
|
|
358
|
-
`}function fe(e,t){let n=e.copy,r=!e.questionInvalid(t);return i.html`
|
|
359
|
-
<footer class="footer">
|
|
360
|
-
<div class="status">${X(e,t)}</div>
|
|
361
|
-
<div class="actions">
|
|
362
|
-
${e.hideSkip?i.nothing:i.html`
|
|
363
|
-
<luzmo-button
|
|
364
|
-
id="skip-button"
|
|
365
|
-
dir=${e.dir}
|
|
366
|
-
variant="primary"
|
|
367
|
-
treatment="outline"
|
|
368
|
-
size=${H(e.size)}
|
|
369
|
-
?disabled=${e.disabled}
|
|
370
|
-
@click=${e.handlers.skip}
|
|
371
|
-
>${n.skip}</luzmo-button
|
|
372
|
-
>
|
|
373
|
-
`}
|
|
374
|
-
${W(e)&&t.type===`multiple`?i.html`
|
|
375
|
-
<luzmo-button
|
|
376
|
-
id="submit-button"
|
|
377
|
-
dir=${e.dir}
|
|
378
|
-
variant="primary"
|
|
379
|
-
treatment="outline"
|
|
380
|
-
size=${H(e.size)}
|
|
381
|
-
?disabled=${e.disabled||e.readonly||!r}
|
|
382
|
-
@click=${e.handlers.primary}
|
|
383
|
-
>${n.submit}</luzmo-button
|
|
384
|
-
>
|
|
385
|
-
`:i.nothing}
|
|
386
|
-
</div>
|
|
387
|
-
</footer>
|
|
388
|
-
`}function pe(e){if(e.questions.length===0)return i.nothing;if(e.resolved)return q(e);let t=e.questions[e.step];if(!t)return i.nothing;let n=e.showError?e.questionError(t):void 0,r=!p(t)&&(t.type===`multiple`||!e.hideSkip),a=[e.questions.length>1?`progress`:``,t.description?`question-description`:``,n?`question-error`:``].filter(Boolean).join(` `)||void 0;return i.html`
|
|
389
|
-
<div class="card" @click=${e.handlers.contentClick}>
|
|
390
|
-
${de(e,t)}
|
|
391
|
-
<div
|
|
392
|
-
class="body"
|
|
393
|
-
role="group"
|
|
394
|
-
aria-labelledby="question-title"
|
|
395
|
-
aria-describedby=${(0,s.ifDefined)(a)}
|
|
396
|
-
>
|
|
397
|
-
${t.type===`single`?ue(e,t,n):Q(e,t,n)}
|
|
398
|
-
</div>
|
|
399
|
-
${r?fe(e,t):i.nothing}
|
|
400
|
-
</div>
|
|
401
|
-
`}var $=class extends t.n(e.n,{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 r.t(this),this._radioChangeAdvanced=!1,this.multipleChoiceRoving=new n.t(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.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.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[f(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[f(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),...p(t)?[u]:[]].filter(e=>i.has(e));this.commitAnswer(t.id,v(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[f(t.id)]??``).trim()&&this.handlePrimary()}}static get styles(){let e=super.styles;return[...Array.isArray(e)?e:e?[e]:[],(0,i.unsafeCSS)(l)]}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`)){w(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=T(this.questions,this.value);_(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 pe(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 S(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`,P(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=h(this.value);g(r,e,t),this.assignValue(r,n)}commitOther(e,t,n){let r=h(this.value);g(r,f(e.id),t);let i=t.trim().length>0;if(e.type===`single`)i?g(r,e.id,u):r[e.id]===`__other__`&&g(r,e.id,``);else{let t=new Set(this.selectedValues(e));i?t.add(u):t.delete(u),g(r,e.id,[...e.options.map(e=>e.value),u].filter(e=>t.has(e)))}this.assignValue(r,n)}assignValue(e,t){_(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 b(e,this.value)}isOtherSelected(e){return x(e,this.value)}questionError(e){return A(e,this.value,this.copy)}questionInvalid(e){return k(e,this.value)}optionDisabled(e,t,n){return j(e,t,n,this.value,this.disabled)}};e.t([(0,a.property)({attribute:!1})],$.prototype,`questions`,void 0),e.t([(0,a.property)({attribute:!1})],$.prototype,`value`,void 0),e.t([(0,a.property)({attribute:!1})],$.prototype,`labels`,void 0),e.t([(0,a.property)({reflect:!0})],$.prototype,`dir`,void 0),e.t([(0,a.property)({type:Boolean,reflect:!0})],$.prototype,`disabled`,void 0),e.t([(0,a.property)({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),e.t([(0,a.property)({type:Boolean,reflect:!0,attribute:`hide-close`})],$.prototype,`hideClose`,void 0),e.t([(0,a.property)({type:Boolean,reflect:!0,attribute:`hide-skip`})],$.prototype,`hideSkip`,void 0),e.t([(0,a.property)({type:Boolean,reflect:!0,attribute:`show-change`})],$.prototype,`showChange`,void 0),e.t([(0,a.property)({reflect:!0,attribute:`option-indicator`})],$.prototype,`optionIndicator`,null),e.t([(0,a.state)()],$.prototype,`_step`,void 0),e.t([(0,a.state)()],$.prototype,`_resolved`,void 0),e.t([(0,a.state)()],$.prototype,`_submitted`,void 0),e.t([(0,a.state)()],$.prototype,`_showError`,void 0),e.t([(0,a.query)(`#question-title`)],$.prototype,`questionTitle`,void 0),e.t([(0,a.query)(`#other-field`)],$.prototype,`otherField`,void 0),e.t([(0,a.query)(`#options`)],$.prototype,`optionsGroup`,void 0),e.t([(0,a.query)(`#resolved-title`)],$.prototype,`resolvedTitle`,void 0),typeof customElements<`u`&&!customElements.get(`luzmo-question-box`)&&customElements.define(`luzmo-question-box`,$),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
|