(inDisabledFieldset = value)} class:bx--form-item={true} class:bx--form-item--fit={!fullWidth} class:bx--slider-form-item--vertical={orientation === "vertical"} {...wrapperProps} on:click on:mouseover on:mouseenter on:mouseleave >
{#if !hideRangeLabels} {formatRangeLabel(minLabel, min)} {/if}
0} class:bx--slider--with-mark-labels={hasMarkLabels} class:bx--slider--vertical={orientation === "vertical"} style:max-width={fullWidth ? "none" : undefined} style:--ccs-slider-sign={orientation === "vertical" ? undefined : trackSign(horizontalRtl)} use:pointerDrag={{ onStart: handleDragStart, onMove: calcValue, onEnd: handleDragEnd, }} on:pointerenter={readDirection} >
{ // Alt/Ctrl/Meta+Arrow belong to the browser (Alt/Cmd+Left is Back). if (effectiveDisabled || readonly || hasModifierKey(event)) return; readDirection(); if (event.key === "Home" || event.key === "End") { // Prevent the browser from also scrolling to the top/bottom of the page. event.preventDefault(); value = event.key === "Home" ? min : max; dispatch("input", value); dispatch("change", value); return; } // Left and right move the thumb the way they point, as they do // on a native range input in RTL. /** @type {Record} */ const keys = { ArrowDown: -1, ArrowLeft: horizontalRtl ? 1 : -1, ArrowRight: horizontalRtl ? -1 : 1, ArrowUp: 1, PageDown: -1, PageUp: 1, }; if (keys[event.key]) { // Prevent the arrow/page keys from also scrolling the page. event.preventDefault(); const isLargeStep = event.shiftKey || event.key === "PageUp" || event.key === "PageDown"; if (snapToMarks && resolvedMarks.length) { value = stepMarks( value, resolvedMarks, keys[event.key] * (isLargeStep ? stepMultiplier : 1), ); } else { const delta = step * (isLargeStep ? range / step / stepMultiplier : 1) * keys[event.key]; value = snapToStep(value + delta, { min, max, step }); } dispatch("input", value); dispatch("change", value); } }} >
{#if resolvedMarks.length > 0} {/if}
{#if !hideRangeLabels} {formatRangeLabel(maxLabel, max)} {/if}
{#if showInvalid} {:else if showWarn} {/if} { if (readonly) return; // An empty or unparsable entry keeps the current value. const next = parse( /** @type {HTMLInputElement} */ (event.target).value.trim(), true, ); if (next !== null) { value = clamp(next, min, max); dispatch("change", value); } // Show the value the slider holds. Svelte skips the update when a // clamped or rejected entry leaves `value` unchanged. /** @type {HTMLInputElement} */ (event.target).value = String(value); }} data-invalid={showInvalid || null} data-warn={showWarn || null} aria-invalid={showInvalid || null} aria-describedby={joinDescribedBy( resolveStatusDescribedBy({ showInvalid, showWarn, invalidText, warnText, helperText, errorId, warnId, helperId, }), ariaDescribedBy, )} on:focus on:focus={handleTextInputFocus} on:blur /> {#if readonly && !hideTextInput} {/if}
{#if showInvalid && invalidText} {/if} {#if showWarn && warnText}
{warnText}
{/if} {#if helperText && !showInvalid && !showWarn}
{helperText}
{/if} {#if readonly} {readonlyText} {/if}