@postnord/web-components
Version:
PostNord Web Components
668 lines (664 loc) • 52.1 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
'use strict';
var index = require('./index-CfUQZtlH.js');
var index$1 = require('./index-CNdVg5VI.js');
var alert_exclamation_circle = require('./alert_exclamation_circle-BiBEJK9P.js');
var chevron_down = require('./chevron_down-BLU6_yOG.js');
var close = require('./close-Bn5ieKko.js');
var index$2 = require('./index.cjs.js');
const translations = {
SELECT_AN_OPTION: {
en: 'Select an option',
sv: 'Välj ett alternativ',
da: 'Vælg en mulighed',
fi: 'Valitse vaihtoehto',
no: 'Velg et alternativ',
},
SELECT_ALL_OPTIONS: {
en: 'Select all options',
sv: 'Välj alla alternativ',
da: 'Vælg alle muligheder',
fi: 'Valitse kaikki vaihtoehdot',
no: 'Velg alle alternativer',
},
SELECT_FOUND_OPTIONS: {
en: 'Select {number} options',
sv: 'Välj {number} alternativ',
da: 'Vælg {number} muligheder',
fi: 'Valitse {number} vaihtoehtoa',
no: 'Velg {number} alternativer',
},
SELECTED_OPTIONS: {
en: 'Selected options.',
sv: 'Valda alternativ.',
da: 'Valgte muligheder.',
fi: 'Valitut vaihtoehdot.',
no: 'Valgte alternativer.',
},
BUTTON_OPEN: {
en: 'Open list',
sv: 'Öppna listan',
da: 'Open list',
fi: 'Open list',
no: 'Open list',
},
BUTTON_CLOSE: {
en: 'Close list',
sv: 'Stäng listan',
da: 'Close list',
fi: 'Close list',
no: 'Close list',
},
REMOVE: {
en: 'Remove',
sv: 'Ta bort',
da: 'Remove',
fi: 'Remove',
no: 'Remove',
},
REMOVED: {
en: 'Removed',
sv: 'Tog bort',
da: 'Fjernet',
fi: 'Poistettu',
no: 'Fjernet',
},
MORE_OPTION: {
en: 'more option.',
sv: 'alternativ till.',
da: 'mulighed mere.',
fi: 'vaihtoehto lisää.',
no: 'alternativ til.',
},
MORE_OPTIONS: {
en: 'more options.',
sv: 'fler alternativ.',
da: 'more options.',
fi: 'more options.',
no: 'more options.',
},
SEARCH: {
en: 'Search',
sv: 'Sök',
da: 'Søg',
fi: 'Hae',
no: 'Søk',
},
RESULTS_FOUND: {
en: 'options found',
sv: 'alternativ hittades',
da: 'muligheder fundet',
fi: 'vaihtoehtoja löytyi',
no: 'alternativer funnet',
},
NO_SEARCH_RESULTS: {
en: 'No options found',
sv: 'Inga alternativ hittades',
da: 'Ingen muligheder fundet',
fi: 'Vaihtoehtoja ei löytynyt',
no: 'Finner ingen alternativer',
},
NO_OPTIONS: {
en: 'No options available',
sv: 'Inga alternativ tillgängliga',
da: 'Ingen tilgængelige muligheder',
fi: 'Ei vaihtoehtoja',
no: 'Ingen tilgjengelige alternativer',
},
};
const pnMultiselectCss = () => `${index.transformTag("pn-multiselect")}{display:inline-block}${index.transformTag("pn-multiselect")} .pn-multiselect{position:relative;border:0;margin:0;padding:0}${index.transformTag("pn-multiselect")} .pn-multiselect[data-icon]{--pn-input-offset-left:2em}${index.transformTag("pn-multiselect")} .pn-multiselect[data-icon] .pn-multiselect-element{padding-left:2.75em}${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-label{color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-label[data-compact]{color:#2d2013}${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element{padding-right:5.5em;border-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:hover{border-color:#500715}${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill,${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill:hover,${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill:focus,${index.transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${index.transformTag("pn-multiselect")} .pn-multiselect-label{width:100%;cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-label{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${index.transformTag("pn-multiselect")} .pn-multiselect-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${index.transformTag("pn-multiselect")} .pn-multiselect-label>span{font-size:0.875em}${index.transformTag("pn-multiselect")} .pn-multiselect-label[data-compact]{justify-content:start}${index.transformTag("pn-multiselect")} .pn-multiselect-sr-only{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}${index.transformTag("pn-multiselect")} .pn-multiselect-group{position:relative;padding:0;margin:0}${index.transformTag("pn-multiselect")} .pn-multiselect-input{position:relative}${index.transformTag("pn-multiselect")} .pn-multiselect-input>${index.transformTag("pn-icon")}{pointer-events:none;position:absolute;top:0.75em;right:3.5em}${index.transformTag("pn-multiselect")} .pn-multiselect-input>${index.transformTag("pn-icon")}[data-custom]{left:0.75em;right:unset}${index.transformTag("pn-multiselect")} .pn-multiselect-button{cursor:pointer;position:absolute;right:0.75em;top:50%;transform:translateY(-50%);padding:0;margin:0;border:0;width:2em;height:2em;font-size:1em;border-radius:50%;background-color:transparent;-webkit-tap-highlight-color:transparent;transition-property:background-color, outline-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-button{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${index.transformTag("pn-multiselect")} .pn-multiselect-button:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-button>${index.transformTag("pn-icon")}>svg>path{transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-button>${index.transformTag("pn-icon")}>svg>path{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-button>${index.transformTag("pn-icon")}>svg>path{transition-delay:0.2s;transform-origin:center;transform:rotate(0deg)}${index.transformTag("pn-multiselect")} .pn-multiselect-button:hover{background-color:#effbff}${index.transformTag("pn-multiselect")} .pn-multiselect-button[aria-expanded=true]{background-color:#effbff}${index.transformTag("pn-multiselect")} .pn-multiselect-button[aria-expanded=true]>${index.transformTag("pn-icon")}>svg>path{transform:rotate(180deg);transition-delay:0s}${index.transformTag("pn-multiselect")} .pn-multiselect-element{cursor:text;text-align:left;transition-delay:0.1s, 0.1s, 0s;width:100%;display:flex;align-items:center;justify-content:space-between;gap:0.5em;overflow:hidden;text-overflow:ellipsis;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em 3.5em 0.75em 0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${index.transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill,${index.transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill:hover,${index.transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill:focus,${index.transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${index.transformTag("pn-multiselect")} .pn-multiselect-element{outline:0.2rem solid transparent;outline-offset:0.2rem}${index.transformTag("pn-multiselect")} .pn-multiselect-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-element{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-element{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${index.transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]::placeholder{color:transparent}${index.transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]:focus+.pn-multiselect-label,${index.transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]:not(:placeholder-shown)+.pn-multiselect-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${index.transformTag("pn-multiselect")} .pn-multiselect-element::placeholder{color:#5e554a;font-weight:normal}${index.transformTag("pn-multiselect")} .pn-multiselect-element:hover{border-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${index.transformTag("pn-multiselect")} .pn-multiselect-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2;pointer-events:none}${index.transformTag("pn-multiselect")} .pn-multiselect-element:disabled+.pn-multiselect-button{pointer-events:none}${index.transformTag("pn-multiselect")} .pn-multiselect-element:disabled+.pn-multiselect-button path{fill:#5e554a}${index.transformTag("pn-multiselect")} .pn-multiselect-element:placeholder{color:#5e554a;font-weight:normal}${index.transformTag("pn-multiselect")} .pn-multiselect-element[type=input]:hover{cursor:pointer;color:#2d2013;background-color:#effbff;transition-delay:0s}${index.transformTag("pn-multiselect")} .pn-multiselect-element[type=input]:hover[aria-invalid=true]{background-color:#fdefee}${index.transformTag("pn-multiselect")} .pn-multiselect-element:focus-visible{transition-delay:0s}${index.transformTag("pn-multiselect")} .pn-multiselect-element::-webkit-search-cancel-button,${index.transformTag("pn-multiselect")} .pn-multiselect-element::-webkit-search-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}${index.transformTag("pn-multiselect")} .pn-multiselect-options{scroll-behavior:smooth;position:absolute;z-index:10;top:calc(100% + 0.5em);left:0;right:0;background-color:#ffffff;box-shadow:0em 0.075em 0.225em 0em rgba(0, 0, 0, 0.1), 0em 0.4em 0.9em 0em rgba(0, 0, 0, 0.13);border-radius:0.5em;list-style:none;margin:0;padding:0;width:var(--pn-select-options-width);max-height:var(--pn-select-max-height);overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;visibility:hidden;transform-origin:top left}${index.transformTag("pn-multiselect")} .pn-multiselect-options[data-open]{visibility:visible}${index.transformTag("pn-multiselect")} .pn-multiselect-options[data-upwards]{top:unset;bottom:calc(100% + 0.5em);transform-origin:bottom left;box-shadow:0 -0.0625em 0.125em rgba(0, 0, 0, 0.2)}${index.transformTag("pn-multiselect")} .pn-multiselect-options[data-moving]{overflow:hidden;visibility:visible}${index.transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${index.transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${index.transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${index.transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${index.transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-corner,${index.transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-button{display:none}${index.transformTag("pn-multiselect")} .pn-multiselect-options>${index.transformTag("pn-input")}{padding:0.5em}${index.transformTag("pn-multiselect")} .pn-multiselect-optgroup{list-style:none;padding:0}${index.transformTag("pn-multiselect")} .pn-multiselect-optgroup>.pn-multiselect-option>.pn-multiselect-option-content{padding-left:2em}${index.transformTag("pn-multiselect")} .pn-multiselect-chips{list-style:none;display:flex;flex-wrap:wrap;gap:0.5em;padding:0;margin:0.5em 0 0 0;color:#5e554a;font-weight:400}${index.transformTag("pn-multiselect")} .pn-multiselect-chips:empty{display:none}${index.transformTag("pn-multiselect")} .pn-multiselect-chip{margin:0;display:inline-flex;align-items:center;gap:0.25em;background-color:#ffffff;border-radius:0.5em;padding:0.125em 0.25em 0.125em 0.5em;line-height:1.5em;border:0.0625em solid #5e554a;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, outline-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-chip{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-chip:focus-within{color:#005d92;outline-color:#005d92;background-color:#effbff;border-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-chip[data-count]{pointer-events:none;border:0;padding-left:0;padding-right:0;background-color:unset}${index.transformTag("pn-multiselect")} .pn-multiselect-chip-label{font-size:0.875em;white-space:nowrap}${index.transformTag("pn-multiselect")} .pn-multiselect-chip-button{cursor:pointer;font-size:1em;padding:0.25em;height:1.5em;width:1.5em;border:0;background-color:unset;border-radius:50%;transition-property:background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-chip-button{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-chip-button{-webkit-tap-highlight-color:transparent}${index.transformTag("pn-multiselect")} .pn-multiselect-chip-button:hover{background-color:#8eddf9}${index.transformTag("pn-multiselect")} .pn-multiselect-chip-button:focus{outline:0}${index.transformTag("pn-multiselect")} .pn-multiselect-no-results{margin:0;padding:0.75em}${index.transformTag("pn-multiselect")} .pn-multiselect-description{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${index.transformTag("pn-multiselect")} .pn-multiselect-description[role=alert]{color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect-option{position:relative;margin:0;padding:0}${index.transformTag("pn-multiselect")} .pn-multiselect-option .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input{cursor:pointer;position:absolute;opacity:0;left:0;top:0;height:100%;width:100%;margin:0;-webkit-tap-highlight-color:transparent}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled{pointer-events:none}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled+.pn-multiselect-option-content{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2;pointer-events:none}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#f3f2f2;border-color:#969087}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled+.pn-multiselect-option-content path{fill:#5e554a}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled:checked+.pn-multiselect-option-content{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#969087;border-color:#969087}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled:checked+.pn-multiselect-option-content path{fill:#5e554a}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]+.pn-multiselect-option-content .pn-ripple{background-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked+.pn-multiselect-option-content{background-color:#fdefee}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#a70707;border-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:focus-visible+.pn-multiselect-option-content{background-color:#fdefee}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#500715;border-color:#500715}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:hover+.pn-multiselect-option-content{background-color:#fef7f6}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#500715;border-color:#500715}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:hover+.pn-multiselect-option-content{background-color:#fef7f6}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#fdefee;border-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{outline-color:#a70707;background-color:#fdefee;border-color:#a70707}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:hover+.pn-multiselect-option-content{background-color:#effbff}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#005d92;background-color:#e0f8ff}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{outline-color:#005d92;background-color:#e0f8ff;border-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked+.pn-multiselect-option-content{background-color:#e0f8ff}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#005d92;background-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox svg polyline.pn-multiselect-option-checkbox-checkmark-path{transition-delay:0.2s;stroke-dashoffset:0}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:hover+.pn-multiselect-option-content{background-color:#effbff}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#0d234b;background-color:#0d234b}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:focus-visible+.pn-multiselect-option-content{background-color:#e0f8ff}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#0d234b;background-color:#0d234b}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#005d92;border-color:#005d92}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate+.pn-multiselect-option-content svg .pn-multiselect-option-checkbox-checkmark-path{stroke-dashoffset:23}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate+.pn-multiselect-option-content svg .pn-multiselect-option-checkbox-indeterminate-path{stroke-dashoffset:0}${index.transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#0d234b;border-color:#0d234b}${index.transformTag("pn-multiselect")} .pn-multiselect-option-content{position:relative;overflow:hidden;z-index:-1;display:flex;align-items:center;padding:0.75em 1em;gap:0.5em;background-color:#ffffff;transition-property:background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-option-content{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-option-text{flex:1;text-overflow:ellipsis;overflow:hidden}${index.transformTag("pn-multiselect")} .pn-multiselect-option-helper{color:#5e554a;margin:0}${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox{background-color:#ffffff;flex:0 0 1.5em;width:1.5em;height:1.5em;border:0.0625em solid #969087;border-radius:0.25em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, border-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline{stroke:#ffffff;stroke-linecap:round;stroke-dasharray:23;transition-property:stroke-dashoffset;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline{transition-duration:0s;transition-delay:0s}}${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline{transition-delay:0s}${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline.pn-multiselect-option-checkbox-checkmark-path{stroke-dashoffset:23}${index.transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline.pn-multiselect-option-checkbox-indeterminate-path{stroke-dashoffset:23}`;
const PnMultiselect = class extends index.Mixin(index$1.animateHeightFactory) {
constructor(hostRef) {
super();
index.registerInstance(this, hostRef);
this.toggleSelect = index.createEvent(this, "toggleSelect");
this.allOptions = index.createEvent(this, "allOptions");
this.selectedOption = index.createEvent(this, "selectedOption");
this.selectedAllOptions = index.createEvent(this, "selectedAllOptions");
this.searchInput = index.createEvent(this, "searchInput");
}
id = `pn-multiselect-${index$2.uuidv4()}`;
idLegend = `${this.id}-legend`;
idButton = `${this.id}-button`;
idOptions = `${this.id}-options`;
idHelper = `${this.id}-text`;
idChips = `${this.id}-chips`;
idSr = `${this.id}-sr`;
elGroup;
elButton;
elInput;
elList;
elChips;
srTimer;
get hostElement() { return index.getElement(this); }
isSearching = false;
/** Layout state. */
open = false;
upwards = false;
srMessage;
/** Label placed above the select */
label;
/** Display a helper text underneath the select */
helpertext;
/**
* This is what will be shown on load if no value is used.
* The `placeholder` will override the default text used if you have the `search` prop active.
*/
placeholder;
/** HTML name of the checkbox elements. Used for each checkbox inside the multiselect. */
name;
/** Select HTML id */
selectId = this.id;
/** HTML name of the input element.*/
selectName;
/** Display an icon to the left of the select input */
icon;
/** Set the date picker label as compact. If used, the `placeholder` will no longer be displayed. @since v7.21.0 */
compact = false;
/** Manually set the language, not needed if you have the pnTopbar available */
language = null;
/**
* Array of options.
* @hide true
**/
options;
/**
* Adds a "Select all" option into the list.
* If you use the search feature at the same time, clicking this option will only toggle the options found.
* @see {@link search}
* @category Features
**/
selectAll = false;
/**
* Set a custom value for the "Select all value" option.
* @see {@link selectAll}
* @category Features
*/
allValue = 'pn_multiselect_all';
/**
* Allow the user to search among the options.
* The selected options will now display underneath the multiselect element.
*
* @category Features
**/
search = false;
/** Set the search query of the multiselect.
*
* @see {@link search}
* @category Features
*/
searchQuery = '';
/**
* Decide how many items should be shown before ellipsis. Requires the `search` prop to work.
*
* @see {@link search}
* @category Features
**/
itemCount = 5;
/**
* Use a custom max-height for the dropdown list.
* @description The component will automatically set the max height of the dropdown list on its own.
* It takes the `pn-topbar` into account and will open in the direction that fits best.
* Use this prop to override this behaviour and use a custom max-height.
* @category Features
**/
maxHeight;
/**
* Force the dropdown to always open upwards.
* @category Features
**/
top = false;
/**
* Force the dropdown to always open downwards.
* @category Features
**/
bottom = false;
/** Set the select as required. @category Validation */
required = false;
/** Disable the select. @category Validation */
disabled = false;
/** Trigger the invalid state. @category Validation */
invalid = false;
/** Display an error message and trigger the invalid state. @category Validation */
error;
handleOpen() {
if (this.open) {
this.addGlobalEventListeners();
this.handleDirection();
this.handleMaxHeight();
this.handleWidth();
}
else {
this.removeGlobalEventListeners();
}
this.dropdownHandler();
}
handleSearch() {
if (!this.search)
this.options = [
...this.options.map(option => {
const item = {
...option,
hide: false,
};
if (item?.group?.length)
item.group.map(opt => ({ ...opt, hide: false }));
return item;
}),
];
}
handleSearchQuery() {
if (this.search && typeof this.searchQuery === 'string')
this.handleInputSearch();
}
handleSelectId() {
const id = this.selectId;
this.idLegend = `${id}-legend`;
this.idButton = `${id}-button`;
this.idOptions = `${id}-options`;
this.idHelper = `${id}-text`;
this.idChips = `${id}-chips`;
this.idSr = `${id}-sr`;
}
/**
* If the select is open and you resize the window.
* Remove all css props and disable the animations entierly.
**/
handleResize() {
if (!this.open)
return;
this.toggleOpen(false);
this.elList.style.removeProperty('--pn-select-options-width');
this.elList.style.removeProperty('--pn-select-max-height');
}
/** Dispatched everytime the multiselect is opened or closed. */
toggleSelect;
/** This event contains the entire options array with the new props. Dispatched everytime you make changes to any option. */
allOptions;
/** Dispatched when you toggle an option. Includes all the props of the option. */
selectedOption;
/**
* This event is dispatched when the user toggles the "Choose all options" box.
* Also triggers when you click the "Select {number} options" if you are performing a search at the same time.
**/
selectedAllOptions;
/**
* Contains the search text and the options found for that query.
* Dispacthed everytime you change the search query.
**/
searchInput;
async componentWillLoad() {
this.handleSelectId();
if (this.language === null)
await index$2.awaitTopbar(this.hostElement);
}
componentDidLoad() {
if (!!this.searchQuery?.length)
this.handleSearchQuery();
}
globalEvents = (event) => {
const target = event.target;
const isWithinCalendar = target?.closest(this.hostElement.localName);
if (!isWithinCalendar)
this.toggleOpen(false);
};
addGlobalEventListeners() {
const root = this.hostElement.getRootNode();
root.addEventListener('click', this.globalEvents);
}
removeGlobalEventListeners() {
const root = this.hostElement.getRootNode();
root.removeEventListener('click', this.globalEvents);
}
dropdownHandler() {
if (this.open)
this.openDropdown(this.elList);
else
this.closeDropdown(this.elList);
}
emitEvents(option, all) {
this.allOptions.emit(this.options);
if (option)
return this.selectedOption.emit(option);
const data = {
checked: all,
searching: this.isSearching,
};
if (this.search && this.optionsTotal() !== this.optionsSearch().length) {
data.query = this.searchQuery;
data.found = this.optionsSearch();
}
this.selectedAllOptions.emit(data);
}
optionsChecked() {
const list = this.options?.reduce((sum, item) => {
const subgroup = item.group ? [...item.group.filter(({ checked }) => checked)] : [];
if (item.checked)
sum.push(item);
if (subgroup?.length)
sum.push(...subgroup);
return sum;
}, []);
return list;
}
optionsTotal() {
return this.options?.reduce((sum, item) => sum + (item?.group?.length ? item.group.length + 1 : 1), 0);
}
optionsIndex(val) {
const findNested = ({ group = [] }) => group?.findIndex(({ value }) => value === val);
const indexGroup = this.options.findIndex(option => option.value === val || findNested(option) !== -1);
const indexNested = findNested(this.options?.[indexGroup]);
return {
indexGroup,
indexNested,
};
}
optionsCheckedTotal() {
return this.optionsChecked()?.length;
}
optionsCheckedPreview() {
return this.optionsChecked()?.slice(0, this.itemCount);
}
optionsCheckedLabels() {
return this.optionsChecked()
?.map(({ label }) => label)
?.join(', ')
?.trim();
}
optionsSearch() {
const list = this.options?.reduce((sum, item) => {
const subgroup = item.group ? [...item.group.filter(({ hide }) => !hide)] : [];
if (!item.hide)
sum.push(item);
if (subgroup?.length)
sum.push(...subgroup);
return sum;
}, []);
return list;
}
noResults() {
return this.optionsSearch()?.length === 0;
}
isIndeterminate(groupIndex) {
const option = this.options?.[groupIndex];
if (option?.group?.length) {
const all = option.group.every(({ checked }) => checked);
const none = option.group.every(({ checked }) => !checked);
return !(all || none);
}
return false;
}
optionSelect({ val, checked, chip }) {
if (val === this.allValue)
return this.optionSelectAll(checked);
const options = this.options;
const { indexGroup, indexNested } = this.optionsIndex(val);
const group = options[indexGroup]?.group;
const nested = group?.[indexNested];
if (nested?.value) {
options[indexGroup].group[indexNested].checked = checked;
const allSiblingsChecked = group?.every(({ checked }) => checked);
if (allSiblingsChecked)
options[indexGroup].checked = true;
else
options[indexGroup].checked = false;
}
else {
options[indexGroup].checked = checked;
if (group?.length)
options[indexGroup].group = group?.map(opt => ({ ...opt, checked: checked }));
}
const option = indexNested === -1 ? options[indexGroup] : options[indexGroup].group[indexNested];
this.emitEvents(option);
this.options = [...options];
if (typeof chip === 'number') {
this.handleSrMesssage(`${this.translate('REMOVED')} ${option.label}`);
requestAnimationFrame(() => {
const index = chip === this.optionsCheckedTotal() ? chip - 1 : chip;
const btn = Array.from(this.elChips.children)?.[index];
btn?.querySelector('button').focus({ preventScroll: true });
});
}
}
optionSelectAll(checked) {
this.options = [
...this.options.map(option => {
const opt = {
...option,
checked: this.isSearching ? (option.hide ? option.checked : checked) : checked,
};
if (opt.group)
opt.group = [
...opt.group.map(item => ({
...item,
checked: this.isSearching ? (item.hide ? item.checked : checked) : checked,
})),
];
const allChecked = opt?.group?.every(({ checked }) => checked);
if (opt?.group?.length)
opt.checked = allChecked;
return opt;
}),
];
this.emitEvents(null, checked);
}
optionSelected(val) {
return !!this.optionsChecked()?.find(({ value, checked }) => value === val && checked);
}
translate(prop) {
const text = translations?.[prop]?.[this.language || index$2.en];
if (text.includes('{number}'))
return text.replace('{number}', this.optionsSearch().length);
return text;
}
getRect(element) {
return element?.getBoundingClientRect();
}
ripple({ clientX, clientY, target }) {
const isKeyboard = clientX === 0 && clientY === 0;
const element = target.nextElementSibling;
const { x, width, y, top } = this.getRect(element);
const clientCor = isKeyboard ? { clientX: x + width - 24, clientY: y - top } : { clientX, clientY };
index$2.ripple(clientCor, element);
}
handleSrMesssage(text) {
this.srMessage = text;
clearTimeout(this.srTimer);
this.srTimer = setTimeout(() => (this.srMessage = null), 2000);
}
handleDirection() {
if (this.top)
return (this.upwards = true);
if (this.bottom)
return (this.upwards = false);
const { bottom, top } = this.getRect(this.elInput);
const oneEm = 16;
/*
* Take the inner window height and subtract the elements bottom and 1em (16px)
* If the max height of this calculation is less than the space above the element, open it upwards.
* Do another calculation with the top value - 1em.
*/
const offsetTop = window.innerHeight - bottom - oneEm;
const offsetBottom = top - oneEm;
/** Always point downwards, unless the space to the bottom is less than half of the top offset space. */
this.upwards = offsetBottom / 2 > offsetTop;
}
handleMaxHeight() {
if (this.maxHeight)
return this.elGroup.style.setProperty('--pn-select-max-height', this.maxHeight);
const { bottom, top } = this.getRect(this.elInput);
const inputHeight = this.upwards ? top : bottom;
const offsetTop = index$2.getTotalHeightOffset();
const offset = this.upwards ? offsetTop + 16 : 16;
const maxHeight = this.upwards ? inputHeight - offset : window.innerHeight - inputHeight - offset;
this.elGroup.style.setProperty('--pn-select-max-height', `${Math.ceil(maxHeight)}px`);
}
handleWidth() {
const { width } = this.getRect(this.elInput);
this.elGroup.style.setProperty('--pn-select-options-width', `${Math.ceil(width)}px`);
}
setFocus() {
if (this.search)
this.elInput.focus({ preventScroll: true });
else
this.elButton.focus({ preventScroll: true });
}
hasError() {
return this.invalid || !!this.error;
}
hasMessage() {
return !!this.helpertext || !!this.error;
}
toggleOpen(state) {
if (typeof state === 'boolean' && state === this.open)
return;
this.open = state ?? !this.open;
this.toggleSelect.emit({ open: this.open });
}
handleInputKeyboard(event) {
event.stopImmediatePropagation();
const { code } = event;
if (code === 'Escape')
return this.toggleOpen(false);
if (!this.open && code.match(/^(Space|Enter)$|Arrow|^Key.*$/))
this.toggleOpen();
}
setSearchQuery(value) {
if (!this.open)
this.toggleOpen(true);
this.searchQuery = value;
}
handleInputSearch() {
if (this.isEmpty())
return;
const term = this.searchQuery;
const performSearch = ({ label, helpertext, value }) => {
return `${label} ${helpertext} ${value}`.trim().toLowerCase().includes(term.toLowerCase());
};
const options = this.options.map(option => {
const foundNested = option?.group?.map(item => ({ ...item, hide: !performSearch(item) })) || [];
const found = performSearch(option) || foundNested?.some(({ hide }) => !hide);
option.hide = !found;
if (option?.group?.length)
option.group = [...foundNested];
return option;
});
this.isSearching = term !== '';
this.options = [...options];
this.searchInput.emit({ query: term, found: this.optionsSearch() });
}
getListItem(index) {
const { value } = this.options[index];
return this.elList.querySelector(`.pn-multiselect-option-input[value='${value}']`);
}
getOptionIndex(val, triggers, code) {
const total = this.optionsTotal() - 1;
if (code === 'End')
return total;
if (code === 'Home')
return 0;
const valIndex = this.options.findIndex(({ value }) => value === val);
const count = triggers.find(item => typeof item === 'number');
const index = valIndex + count;
if (index >= total)
return total;
if (index <= 0)
return 0;
return index;
}
checkboxNav(e, val) {
const { code } = e;
const arrowUp = code === 'ArrowUp' && -1;
const arrowDown = code === 'ArrowDown' && 1;
const pageUp = code === 'PageUp' && -10;
const pageDown = code === 'PageDown' && 10;
const home = code === 'Home' && 0;
const end = code === 'End' && this.optionsTotal() - 1;
const tab = code === 'Tab';
const space = code === 'Space';
const enter = code === 'Enter';
const escape = code === 'Escape';
const triggers = [arrowUp, arrowDown, pageUp, pageDown, home, end, tab, space, enter, escape];
if (!triggers.some(item => typeof item === 'number' || item))
return;
if (tab || space || enter)
return;
e.stopImmediatePropagation();
e.preventDefault();
if (escape) {
this.setFocus();
return this.toggleOpen(false);
}
const item = this.getOptionIndex(val, triggers, code);
return this.getListItem(item)?.focus();
}
handleBlur(event) {
const target = event.target;
const related = event.relatedTarget;
const jumpingToChips = (related || target)?.className === 'pn-multiselect-chip-button';
if (jumpingToChips)
this.toggleOpen(false);
}
handleLabel() {
if (this.disabled)
return;
this.setFocus();
}
/** Check if there are no options in the list. */
isEmpty() {
return (this.options?.length || 0) === 0;
}
showSelectAll() {
return this.selectAll && !this.isEmpty() && !this.noResults();
}
/** Check if the empty/nothing found should be visible. */
showEmptyOption() {
return (this.isSearching && this.noResults()) || this.isEmpty();
}
getPlaceholder() {
const autoTranslation = this.search ? 'SEARCH' : 'SELECT_AN_OPTION';
return this.placeholder || this.translate(autoTranslation);
}
handleChange({ target }) {
const { value, checked } = target;
this.optionSelect({ val: value, checked });
}
/** Display the "X more selected options" text. */
additonalOptions() {
const count = this.optionsCheckedTotal() - this.itemCount;
const single = `MORE_OPTION${count === 1 ? '' : 'S'}`;
return `${count} ${this.translate(single)}`;
}
describedBy() {
const list = [this.search && this.idChips, this.srMessage && this.idSr, !!this.helpertext && this.idHelper].filter(Boolean);
if (list.length)
return list.join(' ');
return null;
}
renderOption({ label, value, checked, helpertext, icon, id = `${this.selectId}-${value || label}`, invalid, disabled, hide, group, }, indexGroup, indexNested) {
return (index.h("li", { class: "pn-multiselect-option", key: id, hidden: hide }, index.h("input", { type: "checkbox", id: id, class: "pn-multiselect-option-input", checked: checked ?? this.optionSelected(value), indeterminate: indexNested === undefined && this.isIndeterminate(indexGroup), name: this.name, value: value, disabled: this.disabled || disabled, required: this.required, "aria-invalid": invalid ? 'true' : null, "aria-describedby": helpertext ? `${id}-helper` : null, onClick: (event) => this.ripple(event), onKeyDown: (event) => this.checkboxNav(event, value), onBlur: (event) => this.handleBlur(event) }), index.h("div", { class: "pn-multiselect-option-content" }, !!icon && index.h("pn-icon", { icon: icon, color: "blue900" }), index.h("div", { class: "pn-multiselect-option-text" }, index.h("label", { class: "pn-multiselect-option-label", htmlFor: id }, index.h("span", null, label)), helpertext && (index.h("p", { class: "pn-multiselect-option-helper", id: `${id}-helper` }, helpertext))), index.h("div", { class: "pn-multiselect-option-checkbox" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, index.h("polyline", { class: "pn-multiselect-option-checkbox-checkmark-path", points: "4,12 9,17 20,6", "stroke-width": "3" }), index.h("polyline", { class: "pn-multiselect-option-checkbox-indeterminate-path", points: "4,12 20,12", "stroke-width": "3" })))), group?.length && (index.h("ul", { class: "pn-multiselect-optgroup" }, group?.map((option, i) => this.renderOption(option, indexGroup, i))))));
}
renderOptions() {
return (index.h("ul", { id: this.idOptions, class: "pn-multiselect-options", "data-open": this.open, "data-upwards": this.upwards, onChange: (event) => this.handleChange(event), style: { height: '0px' }, ref: el => (this.elList = el) }, this.showSelectAll() &&
this.renderOption({
label: this.translate(`SELECT_${this.isSearching ? 'FOUND' : 'ALL'}_OPTIONS`),
value: this.allValue,
checked: this.optionsTotal() === this.optionsCheckedTotal(),
}), this.options?.map((option, index) => this.renderOption(option, index)), this.showEmptyOption() && (index.h("li", { class: "pn-multiselect-option" }, index.h("div", { class: "pn-multiselect-option-content", role: "alert" }, index.h("div", { class: "pn-multiselect-option-text" }, index.h("span", { class: "pn-multiselect-option-label" }, this.translate(this.isEmpty() ? 'NO_OPTIONS' : 'NO_SEARCH_RESULTS'))))))));
}
renderChips() {
return (index.h("ul", { id: this.idChips, class: "pn-multiselect-chips", "aria-label": this.translate('SELECTED_OPTIONS'), ref: el => (this.elChips = el) }, this.optionsCheckedPreview()?.map(({ label, value }, index$1) => (index.h("li", { class: "pn-multiselect-chip", "aria-setsize": this.optionsCheckedTotal(), "aria-posinset": index$1 + 1, key: `${label}-${value}` }, index.h("span", { class: "pn-multiselect-chip-label" }, label), index.h("button", { type: "button", class: "pn-multiselect-chip-button", "aria-label": `${this.translate('REMOVE')} ${label}`, onClick: () => this.optionSelect({ val: value, checked: false, chip: index$1 }) }, index.h("pn-icon", { icon: close.close, small: true, color: "blue700" }))))), this.optionsCheckedTotal() > this.itemCount && (index.h("li", { class: "pn-multiselect-chip", "data-count": true }, index.h("span", { class: "pn-multiselect-chip-label" }, "+ ", this.additonalOptions())))));
}
renderLabel(compactLabel = false) {
if (!this.label)
return null;
const Tag = compactLabel ? 'div' : 'legend';
const id = compactLabel ? null : this.idLegend;
const attrs = compactLabel ? { inert: true } : { onClick: () => this.handleLabel() };
return (index.h(Tag, { id: id, class: { 'pn-multiselect-label': true, 'pn-multiselect-sr-only': this.compact && !compactLabel }, "data-compact": this.compact, ...attrs }, index.h("span", null, this.label), !!this.optionsChecked()?.length && (index.h("span", null, this.optionsCheckedTotal(), "/", this.optionsTotal()))));
}
render() {
return (index.h(index.Host, { key: '55af777ec6dd7165b4d16bdad6ec784fe81b8f20' }, index.h("fieldset", { key: '41a5e9a45b3460a96676d606c458a062efe6ab80', class: "pn-multiselect", "data-icon": !!this.icon, "data-error": this.hasError(), disabled: this.disabled }, this.renderLabel(), index.h("div", { key: 'fb6874e8d17a70ec0e1e21bf3474575b01c3e669', class: "pn-multiselect-group", ref: el => (this.elGroup = el) }, index.h("div", { key: 'ab6aa995337f5a80e2026d98fe69399571249c24', class: "pn-multiselect-input" }, !!this.icon && index.h("pn-icon", { key: '0d9495e8864e266a6ababc752781b6e9c75595c3', class: "pn-multiselect-icon", "data-custom": true, icon: this.icon }), index.h("input", { key: '6b5adbc27ab64b9cdb7f53a99d2f4cd9a2185e47', tabindex: this.search ? null : '-1', type: this.search ? 'search' : 'input', id: this.selectId, class: "pn-multiselect-element", value: this.search ? this.searchQuery : this.optionsCheckedLabels(), name: this.selectName, placeholder: this.getPlaceholder(), required: this.search ? null : this.required, "aria-labelledby": this.idLegend, "aria-describedby": this.describedBy(), "aria-controls": `${this.idOptions} ${this.search ? this.idChips : ''}`, "aria-invalid": this.hasError()?.toString(), disabled: this.disabled, readonly: !this.search, "data-compact": this.compact, onClick: () => (this.search && this.open ? null : this.toggleOpen()), onKeyDo