|
1 | 1 | /** |
2 | | - * svelte-range-slider-pips ~ 4.0.2 |
| 2 | + * svelte-range-slider-pips ~ 4.0.3 |
3 | 3 | * Multi-Thumb, Accessible, Beautiful Range Slider with Pips |
4 | 4 | * Project home: https://simeydotme.github.io/svelte-range-slider-pips/ |
5 | 5 | * © 2025 Simon Goellner <[email protected]> ~ MPL-2.0 License |
6 | | - * Published: 21/6/2025 |
| 6 | + * Published: 23/6/2025 |
7 | 7 | */ |
8 | 8 | (function (global, factory) { |
9 | 9 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
|
2915 | 2915 | : [/*values*/ child_ctx[3][0], /*values*/ child_ctx[3][1]]; |
2916 | 2916 |
|
2917 | 2917 | child_ctx[31] = constants_0[0]; |
2918 | | - child_ctx[92] = constants_0[1]; |
| 2918 | + child_ctx[91] = constants_0[1]; |
2919 | 2919 | return child_ctx; |
2920 | 2920 | } |
2921 | 2921 |
|
2922 | 2922 | function get_each_context(ctx, list, i) { |
2923 | 2923 | const child_ctx = ctx.slice(); |
2924 | 2924 | child_ctx[8] = list[i]; |
2925 | | - child_ctx[95] = i; |
| 2925 | + child_ctx[94] = i; |
2926 | 2926 |
|
2927 | | - const constants_0 = `${/*focus*/ child_ctx[34] && /*activeHandle*/ child_ctx[37] === /*index*/ child_ctx[95] |
| 2927 | + const constants_0 = `${/*focus*/ child_ctx[34] && /*activeHandle*/ child_ctx[37] === /*index*/ child_ctx[94] |
2928 | 2928 | ? 3 |
2929 | 2929 | : ''}`; |
2930 | 2930 |
|
2931 | | - child_ctx[93] = constants_0; |
| 2931 | + child_ctx[92] = constants_0; |
2932 | 2932 | return child_ctx; |
2933 | 2933 | } |
2934 | 2934 |
|
2935 | 2935 | function get_if_ctx(ctx) { |
2936 | 2936 | const child_ctx = ctx.slice(); |
2937 | 2937 | const constants_0 = valueAsPercent(/*value*/ child_ctx[8], /*min*/ child_ctx[1], /*max*/ child_ctx[2], /*precision*/ child_ctx[9]); |
2938 | | - child_ctx[96] = constants_0; |
2939 | | - const constants_1 = /*handleFormatter*/ child_ctx[5](/*value*/ child_ctx[8], /*index*/ child_ctx[95], /*percent*/ child_ctx[96]); |
2940 | | - child_ctx[97] = constants_1; |
| 2938 | + child_ctx[95] = constants_0; |
| 2939 | + const constants_1 = /*handleFormatter*/ child_ctx[5](/*value*/ child_ctx[8], /*index*/ child_ctx[94], /*percent*/ child_ctx[95]); |
| 2940 | + child_ctx[96] = constants_1; |
2941 | 2941 | return child_ctx; |
2942 | 2942 | } |
2943 | 2943 |
|
2944 | | - // (775:6) {#if float} |
| 2944 | + // (776:6) {#if float} |
2945 | 2945 | function create_if_block_9(ctx) { |
2946 | 2946 | let span; |
2947 | 2947 | let if_block0_anchor; |
2948 | 2948 | let html_tag; |
2949 | | - let raw_value = /*formattedValue*/ ctx[97] + ""; |
| 2949 | + let raw_value = /*formattedValue*/ ctx[96] + ""; |
2950 | 2950 | let html_anchor; |
2951 | 2951 | let if_block0 = /*prefix*/ ctx[25] && create_if_block_11(ctx); |
2952 | 2952 | let if_block1 = /*suffix*/ ctx[26] && create_if_block_10(ctx); |
|
2984 | 2984 | if_block0 = null; |
2985 | 2985 | } |
2986 | 2986 |
|
2987 | | - if (dirty[0] & /*handleFormatter, values, min, max, precision*/ 558 && raw_value !== (raw_value = /*formattedValue*/ ctx[97] + "")) html_tag.p(raw_value); |
| 2987 | + if (dirty[0] & /*handleFormatter, values, min, max, precision*/ 558 && raw_value !== (raw_value = /*formattedValue*/ ctx[96] + "")) html_tag.p(raw_value); |
2988 | 2988 |
|
2989 | 2989 | if (/*suffix*/ ctx[26]) { |
2990 | 2990 | if (if_block1) { |
|
3010 | 3010 | }; |
3011 | 3011 | } |
3012 | 3012 |
|
3013 | | - // (779:10) {#if prefix} |
| 3013 | + // (780:10) {#if prefix} |
3014 | 3014 | function create_if_block_11(ctx) { |
3015 | 3015 | let span; |
3016 | 3016 | let t; |
|
3036 | 3036 | }; |
3037 | 3037 | } |
3038 | 3038 |
|
3039 | | - // (779:95) {#if suffix} |
| 3039 | + // (780:95) {#if suffix} |
3040 | 3040 | function create_if_block_10(ctx) { |
3041 | 3041 | let span; |
3042 | 3042 | let t; |
|
3062 | 3062 | }; |
3063 | 3063 | } |
3064 | 3064 |
|
3065 | | - // (752:2) {#each values as value, index} |
| 3065 | + // (753:2) {#each values as value, index} |
3066 | 3066 | function create_each_block(ctx) { |
3067 | 3067 | let span1; |
3068 | 3068 | let span0; |
|
3088 | 3088 | attr(span0, "class", "rangeNub"); |
3089 | 3089 | attr(span1, "role", "slider"); |
3090 | 3090 | attr(span1, "class", "rangeHandle"); |
3091 | | - attr(span1, "data-handle", /*index*/ ctx[95]); |
3092 | | - attr(span1, "style", span1_style_value = "z-index: " + /*zindex*/ ctx[93] + "; " + (/*isMounted*/ ctx[33] ? '' : 'opacity: 0;')); |
3093 | | - attr(span1, "aria-label", span1_aria_label_value = /*ariaLabels*/ ctx[7][/*index*/ ctx[95]]); |
| 3091 | + attr(span1, "data-handle", /*index*/ ctx[94]); |
| 3092 | + attr(span1, "style", span1_style_value = "z-index: " + /*zindex*/ ctx[92] + "; " + (/*isMounted*/ ctx[33] ? '' : 'opacity: 0;')); |
| 3093 | + attr(span1, "aria-label", span1_aria_label_value = /*ariaLabels*/ ctx[7][/*index*/ ctx[94]]); |
3094 | 3094 |
|
3095 | | - attr(span1, "aria-valuemin", span1_aria_valuemin_value = /*range*/ ctx[10] === true && /*index*/ ctx[95] === 1 |
| 3095 | + attr(span1, "aria-valuemin", span1_aria_valuemin_value = /*range*/ ctx[10] === true && /*index*/ ctx[94] === 1 |
3096 | 3096 | ? /*values*/ ctx[3][0] |
3097 | 3097 | : /*min*/ ctx[1]); |
3098 | 3098 |
|
3099 | | - attr(span1, "aria-valuemax", span1_aria_valuemax_value = /*range*/ ctx[10] === true && /*index*/ ctx[95] === 0 |
| 3099 | + attr(span1, "aria-valuemax", span1_aria_valuemax_value = /*range*/ ctx[10] === true && /*index*/ ctx[94] === 0 |
3100 | 3100 | ? /*values*/ ctx[3][1] |
3101 | 3101 | : /*max*/ ctx[2]); |
3102 | 3102 |
|
3103 | 3103 | attr(span1, "aria-valuenow", span1_aria_valuenow_value = /*value*/ ctx[8]); |
3104 | | - attr(span1, "aria-valuetext", span1_aria_valuetext_value = /*ariaLabelFormatter*/ ctx[56](/*value*/ ctx[8], /*index*/ ctx[95])); |
| 3104 | + attr(span1, "aria-valuetext", span1_aria_valuetext_value = /*ariaLabelFormatter*/ ctx[56](/*value*/ ctx[8], /*index*/ ctx[94])); |
3105 | 3105 | attr(span1, "aria-orientation", span1_aria_orientation_value = /*vertical*/ ctx[13] ? 'vertical' : 'horizontal'); |
3106 | 3106 | attr(span1, "aria-disabled", /*disabled*/ ctx[18]); |
3107 | 3107 | attr(span1, "tabindex", span1_tabindex_value = /*disabled*/ ctx[18] ? -1 : 0); |
3108 | | - toggle_class(span1, "rsActive", /*focus*/ ctx[34] && /*activeHandle*/ ctx[37] === /*index*/ ctx[95]); |
3109 | | - toggle_class(span1, "rsPress", /*handlePressed*/ ctx[35] && /*activeHandle*/ ctx[37] === /*index*/ ctx[95]); |
3110 | | - set_style(span1, "--handle-pos", /*$springPositions*/ ctx[42][/*index*/ ctx[95]]); |
| 3108 | + toggle_class(span1, "rsActive", /*focus*/ ctx[34] && /*activeHandle*/ ctx[37] === /*index*/ ctx[94]); |
| 3109 | + toggle_class(span1, "rsPress", /*handlePressed*/ ctx[35] && /*activeHandle*/ ctx[37] === /*index*/ ctx[94]); |
| 3110 | + set_style(span1, "--handle-pos", /*$springPositions*/ ctx[42][/*index*/ ctx[94]]); |
3111 | 3111 | }, |
3112 | 3112 | m(target, anchor) { |
3113 | 3113 | insert(target, span1, anchor); |
|
3139 | 3139 | if_block = null; |
3140 | 3140 | } |
3141 | 3141 |
|
3142 | | - if (dirty[1] & /*focus, activeHandle, isMounted*/ 76 && span1_style_value !== (span1_style_value = "z-index: " + /*zindex*/ ctx[93] + "; " + (/*isMounted*/ ctx[33] ? '' : 'opacity: 0;'))) { |
| 3142 | + if (dirty[1] & /*focus, activeHandle, isMounted*/ 76 && span1_style_value !== (span1_style_value = "z-index: " + /*zindex*/ ctx[92] + "; " + (/*isMounted*/ ctx[33] ? '' : 'opacity: 0;'))) { |
3143 | 3143 | attr(span1, "style", span1_style_value); |
3144 | 3144 | } |
3145 | 3145 |
|
3146 | | - if (dirty[0] & /*ariaLabels*/ 128 && span1_aria_label_value !== (span1_aria_label_value = /*ariaLabels*/ ctx[7][/*index*/ ctx[95]])) { |
| 3146 | + if (dirty[0] & /*ariaLabels*/ 128 && span1_aria_label_value !== (span1_aria_label_value = /*ariaLabels*/ ctx[7][/*index*/ ctx[94]])) { |
3147 | 3147 | attr(span1, "aria-label", span1_aria_label_value); |
3148 | 3148 | } |
3149 | 3149 |
|
3150 | | - if (dirty[0] & /*range, values, min*/ 1034 && span1_aria_valuemin_value !== (span1_aria_valuemin_value = /*range*/ ctx[10] === true && /*index*/ ctx[95] === 1 |
| 3150 | + if (dirty[0] & /*range, values, min*/ 1034 && span1_aria_valuemin_value !== (span1_aria_valuemin_value = /*range*/ ctx[10] === true && /*index*/ ctx[94] === 1 |
3151 | 3151 | ? /*values*/ ctx[3][0] |
3152 | 3152 | : /*min*/ ctx[1])) { |
3153 | 3153 | attr(span1, "aria-valuemin", span1_aria_valuemin_value); |
3154 | 3154 | } |
3155 | 3155 |
|
3156 | | - if (dirty[0] & /*range, values, max*/ 1036 && span1_aria_valuemax_value !== (span1_aria_valuemax_value = /*range*/ ctx[10] === true && /*index*/ ctx[95] === 0 |
| 3156 | + if (dirty[0] & /*range, values, max*/ 1036 && span1_aria_valuemax_value !== (span1_aria_valuemax_value = /*range*/ ctx[10] === true && /*index*/ ctx[94] === 0 |
3157 | 3157 | ? /*values*/ ctx[3][1] |
3158 | 3158 | : /*max*/ ctx[2])) { |
3159 | 3159 | attr(span1, "aria-valuemax", span1_aria_valuemax_value); |
|
3163 | 3163 | attr(span1, "aria-valuenow", span1_aria_valuenow_value); |
3164 | 3164 | } |
3165 | 3165 |
|
3166 | | - if (dirty[0] & /*values*/ 8 && span1_aria_valuetext_value !== (span1_aria_valuetext_value = /*ariaLabelFormatter*/ ctx[56](/*value*/ ctx[8], /*index*/ ctx[95]))) { |
| 3166 | + if (dirty[0] & /*values*/ 8 && span1_aria_valuetext_value !== (span1_aria_valuetext_value = /*ariaLabelFormatter*/ ctx[56](/*value*/ ctx[8], /*index*/ ctx[94]))) { |
3167 | 3167 | attr(span1, "aria-valuetext", span1_aria_valuetext_value); |
3168 | 3168 | } |
3169 | 3169 |
|
|
3180 | 3180 | } |
3181 | 3181 |
|
3182 | 3182 | if (dirty[1] & /*focus, activeHandle*/ 72) { |
3183 | | - toggle_class(span1, "rsActive", /*focus*/ ctx[34] && /*activeHandle*/ ctx[37] === /*index*/ ctx[95]); |
| 3183 | + toggle_class(span1, "rsActive", /*focus*/ ctx[34] && /*activeHandle*/ ctx[37] === /*index*/ ctx[94]); |
3184 | 3184 | } |
3185 | 3185 |
|
3186 | 3186 | if (dirty[1] & /*handlePressed, activeHandle*/ 80) { |
3187 | | - toggle_class(span1, "rsPress", /*handlePressed*/ ctx[35] && /*activeHandle*/ ctx[37] === /*index*/ ctx[95]); |
| 3187 | + toggle_class(span1, "rsPress", /*handlePressed*/ ctx[35] && /*activeHandle*/ ctx[37] === /*index*/ ctx[94]); |
3188 | 3188 | } |
3189 | 3189 |
|
3190 | 3190 | const style_changed = dirty[1] & /*focus, activeHandle, isMounted*/ 76; |
3191 | 3191 |
|
3192 | 3192 | if (dirty[1] & /*$springPositions, focus, activeHandle, isMounted*/ 2124 || style_changed) { |
3193 | | - set_style(span1, "--handle-pos", /*$springPositions*/ ctx[42][/*index*/ ctx[95]]); |
| 3193 | + set_style(span1, "--handle-pos", /*$springPositions*/ ctx[42][/*index*/ ctx[94]]); |
3194 | 3194 | } |
3195 | 3195 | }, |
3196 | 3196 | d(detaching) { |
|
3205 | 3205 | }; |
3206 | 3206 | } |
3207 | 3207 |
|
3208 | | - // (786:2) {#if limits} |
| 3208 | + // (787:2) {#if limits} |
3209 | 3209 | function create_if_block_8(ctx) { |
3210 | 3210 | let span; |
3211 | 3211 | let span_style_value; |
|
3232 | 3232 | }; |
3233 | 3233 | } |
3234 | 3234 |
|
3235 | | - // (793:2) {#if hasRange} |
| 3235 | + // (794:2) {#if hasRange} |
3236 | 3236 | function create_if_block_1(ctx) { |
3237 | 3237 | let span; |
3238 | 3238 | let span_style_value; |
|
3299 | 3299 | }; |
3300 | 3300 | } |
3301 | 3301 |
|
3302 | | - // (802:6) {#if rangeFloat} |
| 3302 | + // (803:6) {#if rangeFloat} |
3303 | 3303 | function create_if_block_2(ctx) { |
3304 | 3304 | let span; |
3305 | 3305 |
|
|
3349 | 3349 | }; |
3350 | 3350 | } |
3351 | 3351 |
|
3352 | | - // (811:10) {:else} |
| 3352 | + // (812:10) {:else} |
3353 | 3353 | function create_else_block(ctx) { |
3354 | 3354 | let if_block0_anchor; |
3355 | 3355 | let html_tag; |
|
3364 | 3364 | let t4; |
3365 | 3365 | let if_block2_anchor; |
3366 | 3366 | let html_tag_1; |
3367 | | - let raw1_value = /*second*/ ctx[92] + ""; |
| 3367 | + let raw1_value = /*second*/ ctx[91] + ""; |
3368 | 3368 | let html_anchor_1; |
3369 | 3369 | let if_block3_anchor; |
3370 | 3370 | let if_block0 = /*prefix*/ ctx[25] && create_if_block_7(ctx); |
|
3453 | 3453 | if_block2 = null; |
3454 | 3454 | } |
3455 | 3455 |
|
3456 | | - if (dirty[0] & /*reversed, values*/ 65544 && raw1_value !== (raw1_value = /*second*/ ctx[92] + "")) html_tag_1.p(raw1_value); |
| 3456 | + if (dirty[0] & /*reversed, values*/ 65544 && raw1_value !== (raw1_value = /*second*/ ctx[91] + "")) html_tag_1.p(raw1_value); |
3457 | 3457 |
|
3458 | 3458 | if (/*suffix*/ ctx[26]) { |
3459 | 3459 | if (if_block3) { |
|
3492 | 3492 | }; |
3493 | 3493 | } |
3494 | 3494 |
|
3495 | | - // (804:10) {#if rangeFormatter} |
| 3495 | + // (805:10) {#if rangeFormatter} |
3496 | 3496 | function create_if_block_3(ctx) { |
3497 | 3497 | let html_tag; |
3498 | 3498 | let raw_value = /*rangeFormatter*/ ctx[6](/*values*/ ctx[3][0], /*values*/ ctx[3][1], valueAsPercent(/*values*/ ctx[3][0], /*min*/ ctx[1], /*max*/ ctx[2], /*precision*/ ctx[9]), valueAsPercent(/*values*/ ctx[3][1], /*min*/ ctx[1], /*max*/ ctx[2], /*precision*/ ctx[9])) + ""; |
|
3520 | 3520 | }; |
3521 | 3521 | } |
3522 | 3522 |
|
3523 | | - // (813:12) {#if prefix} |
| 3523 | + // (814:12) {#if prefix} |
3524 | 3524 | function create_if_block_7(ctx) { |
3525 | 3525 | let span; |
3526 | 3526 | let t; |
|
3546 | 3546 | }; |
3547 | 3547 | } |
3548 | 3548 |
|
3549 | | - // (813:88) {#if suffix} |
| 3549 | + // (814:88) {#if suffix} |
3550 | 3550 | function create_if_block_6(ctx) { |
3551 | 3551 | let span; |
3552 | 3552 | let t; |
|
3572 | 3572 | }; |
3573 | 3573 | } |
3574 | 3574 |
|
3575 | | - // (817:12) {#if prefix} |
| 3575 | + // (818:12) {#if prefix} |
3576 | 3576 | function create_if_block_5(ctx) { |
3577 | 3577 | let span; |
3578 | 3578 | let t; |
|
3598 | 3598 | }; |
3599 | 3599 | } |
3600 | 3600 |
|
3601 | | - // (817:89) {#if suffix} |
| 3601 | + // (818:89) {#if suffix} |
3602 | 3602 | function create_if_block_4(ctx) { |
3603 | 3603 | let span; |
3604 | 3604 | let t; |
|
3624 | 3624 | }; |
3625 | 3625 | } |
3626 | 3626 |
|
3627 | | - // (825:2) {#if pips} |
| 3627 | + // (826:2) {#if pips} |
3628 | 3628 | function create_if_block(ctx) { |
3629 | 3629 | let rangepips; |
3630 | 3630 | let current; |
|
3961 | 3961 | }; |
3962 | 3962 | } |
3963 | 3963 |
|
| 3964 | + /** |
| 3965 | + * trim the values array based on whether the property |
| 3966 | + * for 'range' is 'min', 'max', or truthy. This is because we |
| 3967 | + * do not want more than one handle for a min/max range, and we do |
| 3968 | + * not want more than two handles for a true range. |
| 3969 | + * @param {array} values the input values for the rangeSlider |
| 3970 | + * @param {boolean | 'min' | 'max'} range the range property of the rangeSlider |
| 3971 | + * @return {array} the range array for creating a rangeSlider |
| 3972 | + **/ |
| 3973 | + function trimRange(values, range) { |
| 3974 | + if (range === 'min' || range === 'max') { |
| 3975 | + return values.slice(0, 1); |
| 3976 | + } else if (range) { |
| 3977 | + return values.slice(0, 2); |
| 3978 | + } else { |
| 3979 | + return values; |
| 3980 | + } |
| 3981 | + } |
| 3982 | + |
3964 | 3983 | function instance($$self, $$props, $$invalidate) { |
3965 | 3984 | let hasRange; |
3966 | 3985 | let orientationStart; |
|
4207 | 4226 | return isHandle || isChild; |
4208 | 4227 | } |
4209 | 4228 |
|
4210 | | - /** |
4211 | | - * trim the values array based on whether the property |
4212 | | - * for 'range' is 'min', 'max', or truthy. This is because we |
4213 | | - * do not want more than one handle for a min/max range, and we do |
4214 | | - * not want more than two handles for a true range. |
4215 | | - * @param {array} values the input values for the rangeSlider |
4216 | | - * @return {array} the range array for creating a rangeSlider |
4217 | | - **/ |
4218 | | - function trimRange(values) { |
4219 | | - if (range === 'min' || range === 'max') { |
4220 | | - return values.slice(0, 1); |
4221 | | - } else if (range) { |
4222 | | - return values.slice(0, 2); |
4223 | | - } else { |
4224 | | - return values; |
4225 | | - } |
4226 | | - } |
4227 | | - |
4228 | 4229 | /** |
4229 | 4230 | * helper to return closest handle to user interaction |
4230 | 4231 | * @param {object} clientPos the client {x,y} positions to check against |
|
4747 | 4748 | (updateValues()); |
4748 | 4749 | } |
4749 | 4750 |
|
4750 | | - if ($$self.$$.dirty[0] & /*values, min, max, step, precision, limits, slider*/ 528911 | $$self.$$.dirty[1] & /*springValues, springPositions, spring*/ 1610612738 | $$self.$$.dirty[2] & /*valueLength*/ 1) { |
| 4751 | + if ($$self.$$.dirty[0] & /*values, range, min, max, step, precision, limits, slider*/ 529935 | $$self.$$.dirty[1] & /*springValues, springPositions, spring*/ 1610612738 | $$self.$$.dirty[2] & /*valueLength*/ 1) { |
4751 | 4752 | { |
4752 | 4753 | // if a range, then trim so it remains as a min/max (only 2 handles) |
4753 | | - const trimmedValues = trimRange(values); |
| 4754 | + const trimmedValues = trimRange(values, range); |
4754 | 4755 |
|
4755 | 4756 | // and also align the handles to the steps/limits |
4756 | 4757 | const trimmedAlignedValues = trimmedValues.map(v => constrainAndAlignValue(v, min, max, step, precision, limits)); |
4757 | 4758 |
|
4758 | 4759 | // update the values if they needed to be fixed |
4759 | | - if (!(values.length === trimmedAlignedValues.length) || !values.every((element, index) => coerceFloat(element, precision) === trimmedAlignedValues[index])) { |
| 4760 | + if (!(values.length === trimmedAlignedValues.length) || !values.every((item, i) => coerceFloat(item, precision) === trimmedAlignedValues[i])) { |
4760 | 4761 | $$invalidate(3, values = trimmedAlignedValues); |
4761 | 4762 | } |
4762 | 4763 |
|
|
0 commit comments