All files / src/components/u-number-input.vue index.vue

38.88% Statements 14/36
5.26% Branches 2/38
9.09% Functions 1/11
41.17% Lines 14/34

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684      7x   7x     7x                                                                                       7x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         7x 7x                                                                                                                                                                                                                                                                                                                                             7x 7x 7x
<template>
    <u-input v-if="!isPreview" ref="input" :class="$style.root" :button-display="buttonDisplay" :value="formattedValue"
        :readonly="readonly" :disabled="disabled" :clearable="clearable"
        @keydown.native.up.prevent="increase" @keydown.native.down.prevent="decrease" @keydown.native.enter="onEnter"
        @input="onInput" @focus="onFocus" @blur="onBlur" v-bind="$attrs" v-on="listeners" v-click-outside="handleClickOutside"
        :hide-buttons="hideButtons" :color="formItemVM && formItemVM.color" :prefix="!!showPrefix" :suffix="!!showSuffix">
        <span :class="$style.button" v-if="!hideButtons" :disabled="currentValue >= max" role="up" v-repeat-click="increase"
            tabindex="0" @keydown.prevent></span>
        <span :class="$style.button" v-if="!hideButtons" :disabled="currentValue <= min" role="down" v-repeat-click="decrease"
            tabindex="0" @keydown.prevent></span>
        <slot></slot>
 
        <template #prefix>
            <span v-if="showPrefix">{{ unit && unit.value }}</span>
        </template>
        <template #suffix>
            <span v-if="showSuffix">{{ unit && unit.value }}</span>
        </template>
    </u-input>
    <u-preview v-else :text="currentValue"></u-preview>
</template>
 
<script>
import MField from '../m-field.vue';
import { repeatClick, clickOutside } from '../../directives';
import { noopFormatter, NumberFormatter } from '../../utils/Formatters';
import UPreview from '../u-text.vue';
import MPreview from '../u-text.vue/preview';
const isNil = (value) => (typeof value === 'string' && value.trim() === '') || value === null || value === undefined;
 
export default {
    name: 'u-number-input',
    component: {
        UPreview
    },
    directives: { repeatClick, clickOutside },
    mixins: [MField, MPreview],
    props: {
        // String 类型是为了验证抛出
        value: [Number, String],
        defaultValue: [String, Number],
        min: { type: Number, default: -Infinity },
        max: { type: Number, default: Infinity },
        step: { type: Number, default: 1, validator: (step) => step >= 0 },
        // 默认优先使用小数位数(废弃⚠️)
        precision: { type: Number, default: 1, validator: (precision) => precision >= 0 },
        // 小数位数
        decimalLength: { type: Number, validator: (value) => value >= 0 },
        formatter: { type: [String, Object] },
        hideButtons: { type: Boolean, default: false },
        // 按钮呈现形式 tail | bothEnds
        buttonDisplay: {
            type: String,
            default: 'tail',
        },
        readonly: { type: Boolean, default: false },
        disabled: { type: Boolean, default: false },
        preview: { type: Boolean, default: false },
        clearable: { type: Boolean, default: false },
        autofocus: { type: Boolean, default: false },
 
        // 高级格式化
        advancedFormat: {
            type: Object,
            default: () => ({
                enable: false,
                value: '',
            }),
        },
        thousandths: {
            type: Boolean,
            default: false,
        },
        decimalPlaces: {
            type: Object,
            default: () => ({
                places: '',
                omit: false,
            }),
        },
        percentSign: {
            type: Boolean,
            default: false,
        },
        unit: {
            type: Object,
            default: () => ({
                type: 'prefix',
                value: '',
            }),
        },
    },
    data() {
        // 根据初始值计算 fix 精度
        const currentPrecision = this.getCurrentPrecision(this.value);
        const data = {
            // 当前使用的精度,当 precision 为 0 时,使用动态精度
            currentPrecision,
            currentValue: this.fix(this.value, currentPrecision), // 格式化后的 value,与`<input>`中的实际值保持一致
            formattedValue: this.value,
            currentFormatter: undefined,
        };
 
        if (this.formatter instanceof Object)
            data.currentFormatter = this.formatter;
        else if (typeof this.formatter === 'string')
            data.currentFormatter = new NumberFormatter(this.formatter);
        else
            data.currentFormatter = noopFormatter; // 初始值需要在最小值和最大值范围之内
 
        // advancedFormat最高权限
        if (this.advancedFormat) {
            let formatter;
 
            if (this.advancedFormat.enable) {
                formatter = this.advancedFormat.value;
            } else if (this.thousandths || this.percentSign || this.decimalPlaces.places >= 0) {
                formatter = '0';
                // 千分位
                if (this.thousandths) {
                    formatter = `#,##0`;
                }
 
                // 小数位数
                if (this.decimalPlaces && this.decimalPlaces.places > 0) {
                    formatter += '.';
 
                    const char = this.decimalPlaces.omit ? '#' : '0';
                    for (let i = 0; i < this.decimalPlaces.places; i++) {
                        formatter += char;
                    }
                } else if (this.decimalPlaces && this.decimalPlaces.places === '') {
                    formatter += '.';
                    for (let i = 0; i < 17; i++) {
                        formatter += '#';
                    }
                }
 
                // 单位
                // if (this.unit && this.unit.value) {
                //     if (this.unit.type === 'prefix') {
                //         formatter = `${this.unit.value} ${formatter}`;
                //     } else if (this.unit.type === 'suffix') {
                //         formatter = `${formatter} ${this.unit.value}`;
                //     }
                // }
            }
 
            if (formatter) {
                data.currentFormatter = new NumberFormatter(formatter, !this.advancedFormat.enable && {
                    percentSign: this.percentSign, // 百分比
                });
            }
        }
 
        data.formattedValue = data.currentFormatter.format(data.currentValue);
 
        return data;
    },
    computed: {
        listeners() {
            const listeners = Object.assign({}, this.$listeners);
            ['input', 'change', 'focus', 'blur', 'update:value'].forEach((prop) => {
                delete listeners[prop];
            });
            return listeners;
        },
        showPrefix() {
            return this.unit && this.unit.type === 'prefix' && !!this.unit.value;
        },
        showSuffix() {
            return this.unit && this.unit.type === 'suffix' && !!this.unit.value;
        },
    },
    watch: {
        value(value, oldValue) {
            // 根据传入的 value 调整 fix 精度
            if (value === this.currentValue) {
                return;
            }
            const currentPrecision = (this.currentPrecision = this.getCurrentPrecision(value));
            const _oldValue = this.currentValue;
            const currentValue = (this.currentValue = this.fix(value, currentPrecision));
            this.formattedValue = this.currentFormatter.format(currentValue);
            // 修复blur 清空导致的问题,数据流混乱,只能这么改,哎😌
            this.$refs.input.currentValue = this.formattedValue;
            this.$emit('update', this.currentValue, this);
            // 当点击了form的创建按钮等调用了validate方法,fieldTouched值会变为true,不会走update validate
            // 所以这里需要再增加input emit
            this.$emit('input', this.currentValue, this);
            this.$emit('change', { value: this.currentValue, oldValue: _oldValue, formattedValue: this.formattedValue, valid: this.isValid(this.currentValue) }, this);
        },
        max(_value, oldValue) {
            // todo: 正常情况下,formattedValue应该设计为computed,目前在不影响的情况下,手动watch
            if (_value !== oldValue) {
                // 根据传入的 value 调整 fix 精度
                const value = this.value;
                const currentPrecision = (this.currentPrecision = this.getCurrentPrecision(value));
                const currentValue = (this.currentValue = this.fix(value, currentPrecision));
                this.formattedValue = this.currentFormatter.format(currentValue);
            }
        },
        min(_value, oldValue) {
            // todo: 正常情况下,formattedValue应该设计为computed,目前在不影响的情况下,手动watch
            if (_value !== oldValue) {
                // 根据传入的 value 调整 fix 精度
                const value = this.value;
                const currentPrecision = (this.currentPrecision = this.getCurrentPrecision(value));
                const currentValue = (this.currentValue = this.fix(value, currentPrecision));
                this.formattedValue = this.currentFormatter.format(currentValue);
            }
        },
    },
    created() {
        const value = this.currentValue;
        this.$emit('update', value, this);
    },
    mounted() {
        this.autofocus && this.$refs.input.focus();
    },
    methods: {
        strip(num, precision = 17) {
            return +parseFloat(num).toPrecision(precision);
        },
        fix(value, precision = this.currentPrecision) {
            return this.toFixed(value);
 
            // 为空时使用默认值
            // if ((typeof value === 'string' && value.trim() === '') || value === null || value === undefined)
            //     return value = this.defaultValue !== undefined ? this.defaultValue : '';
            // else if (isNaN(value))
            //     value = this.currentValue || this.defaultValue || 0;
 
            // value = +value; // 精度约束
            // value = Math.round(this.strip(value / precision)) * precision; // 最大最小约束
            // value = Math.min(Math.max(this.min, value), this.max); // 保留小数位数
            // value = +value.toFixed(precision < 1 ? -Math.floor(Math.log10(precision)) : 0);
            // return value;
        },
        // 值保留小数位
        toFixed(value) {
            // 为空时使用默认值
            if ((typeof value === 'string' && value.trim() === '') || value === null || value === undefined)
                return value = this.defaultValue !== undefined ? this.defaultValue : '';
            else if (isNaN(value))
                value = this.currentValue || this.defaultValue || 0;
 
            value = Math.min(Math.max(this.min, value), this.max);
 
            // 配置了新的精度
            if (this.decimalLength >= 0) {
                value = parseFloat(+value.toFixed(Math.floor(this.decimalLength)));
            } else if (this.precision > 0) {
                let decimalLength = 0;
                try {
                    // 判断precision是不是带小数
                    if (!Number.isInteger(this.precision)) {
                        // 取出小数位数
                        const numStr = this.precision.toString();
                        const decimalIndex = numStr.indexOf('.');
                        if (decimalIndex !== -1) {
                            decimalLength = numStr.slice(decimalIndex + 1).length;
                        }
                    }
                } catch (error) {
                    console.log(error);
                }
 
                value = parseFloat(+value.toFixed(Math.floor(decimalLength)));
            }
 
            return value;
        },
        /**
         * 根据值计算精度
         * @param {*} value 输入值
         */
        computePrecision(value) {
            // 优先使用精度设置的值
            if (this.precision !== 0 && this.step === 0)
                return this.precision;
            // 没有精度的情况下,需要判断value和step的值
            if ((typeof value === 'string' && value.trim() === '') || value === null || value === undefined)
                value = this.defaultValue !== undefined ? this.defaultValue : this.currentValue || 0;
            else if (isNaN(value))
                value = this.currentValue || this.defaultValue || 0;
            const arr = String(value).split('.');
            let precisionLength = arr[1] ? arr[1].length : 0;
            if (this.precision === 0 && this.step !== 0) {
                const arr = String(this.step).split('.');
                precisionLength = arr[1] && arr[1].length > precisionLength ? arr[1].length : precisionLength;
            }
            return precisionLength ? Math.pow(0.1, precisionLength).toFixed(precisionLength) : 1;
        },
        /**
         * 计算 fix 精度
         * @param {*} value 输入值
         */
        getCurrentPrecision(value) {
            return this.precision === 0 ? this.computePrecision(value) : this.precision;
        },
        isValid(value) {
            if (isNaN(value))
                return false;
            if (value < this.min || value > this.max)
                return false;
            return String(this.fix(value)) === String(value);
        },
        /**
         * 单纯输入
         * @param {*} value 输入值
         */
        input(value) {
            if (this.readonly || this.disabled)
                return;
            value = this.fix(value);
            const oldValue = this.currentValue;
            this.currentValue = value;
            const formattedValue = (this.formattedValue = this.currentFormatter.format(value));
            this.$refs.input.currentValue = formattedValue;
 
            this.$emit('input', value, this);
            this.$emit('update', value, this);
            this.$emit('update:value', value, this);
            this.$emit('change', { value, oldValue, formattedValue, valid: this.isValid(value) }, this);
        },
        /**
         * 按上下按钮发送 adjust 事件
         * @param {*} value
         */
        adjust(value) {
            const oldValue = this.currentValue;
 
            let cancel = false;
            this.$emit('before-adjust', {
                value,
                oldValue,
                formattedValue: this.currentFormatter.format(value),
                preventDefault: () => (cancel = true),
            }, this);
            if (cancel)
                return;
 
            this.input(value);
            this.$emit('adjust', {
                value: this.currentValue,
                oldValue,
                formattedValue: this.formattedValue,
            }, this);
            this.hasFocus = true;
        },
        increase() {
            const step = this.step === 0 ? this.computePrecision(this.currentValue) : this.step;
            this.adjust(+this.currentValue + (step - 0));
            this.preventBlur = true;
        },
        decrease() {
            const step = this.step === 0 ? this.computePrecision(this.currentValue) : +this.step;
            this.adjust(+this.currentValue - step);
            this.preventBlur = true;
        },
        onInput(rawValue) {
            if (this.readonly || this.disabled)
                return;
            const parsedValue = isNil(rawValue) ? '' : this.currentFormatter.parse(rawValue); // 根据输入调整 fix 精度
            const currentPrecision = (this.currentPrecision = this.getCurrentPrecision(parsedValue));
            const value = this.fix(parsedValue, currentPrecision);
            const valid = String(value) === String(parsedValue);
            if (valid)
                // 用于上下键
                this.currentValue = value;
            this.$emit('validate', { valid, value, rawValue });
        },
        onFocus(e) {
            this.$emit('focus', e, this);
        },
        onEnter(e) {
            const inputValue = this.$refs.input.currentValue;
            this.input(isNil(inputValue) ? inputValue : this.currentFormatter.parse(inputValue));
        },
        onBlur(e) {
            const inputValue = this.$refs.input.currentValue;
 
            this.input(isNil(inputValue) ? inputValue : this.currentFormatter.parse(inputValue));
            if (this.preventBlur)
                return (this.preventBlur = false);
            this.$emit('blur', e, this);
        },
        handleClickOutside() {
            if (this.hasFocus) {
                this.$emit('blur');
                this.hasFocus = false;
            }
        },
    },
};
</script>
 
<style module>
.root {
    width: var(--number-input-width);
    height: var(--number-input-height);
    background: var(--number-input-background);
    border: var(--number-input-border-width) solid var(--number-input-border-color);
    border-radius: var(--number-input-border-radius);
    color: var(--number-input-color);
}
.root:not([hide-buttons="true"]) {
    padding-right: 28px;
}
 
.root[button-display="bothEnds"]:not([hide-buttons="true"])  {
    text-align: center;
    padding: 0 calc(var(--number-input-both-ends-button-width) + 12px);
}
 
.root:hover {
    border-color: var(--number-input-border-color-hover);
}
 
.root[focus] {
    border-color: var(--number-input-border-color-focus);
    box-shadow: var(--number-input-box-shadow-focus);
}
 
.button {
    user-select: none;
    position: absolute;
    cursor: var(--cursor-pointer);
    text-align: center;
}
 
.root[button-display="tail"] .button {
    height: var(--number-input-button-height);
    line-height: var(--number-input-button-height);
    right: 0;
    border-left: 1px solid var(--number-input-border-color);
    padding: var(--number-input-button-padding);
    background: var(--number-input-button-background);
}
 
.root[button-display="bothEnds"] .button {
    width: var(--number-input-both-ends-button-width);
    height: var(--number-input-both-ends-button-height);
    line-height: var(--number-input-both-ends-button-height);
    background: var(--number-input-button-both-ends-background);
    top: 0;
}
 
.root[button-display="tail"] .button:hover {
    background: var(--number-input-button-background-hover);
}
 
.root[button-display="bothEnds"] .button:hover {
    background: var(--number-input-button-both-ends-background-hover);
}
 
.root[button-display="tail"] .button:focus {
    background: var(--number-input-button-background-focus);
    outline: var(--number-input-button-outline);
}
 
.root[button-display="bothEnds"] .button:focus {
    background: var(--number-input-button-both-ends-background-focus);
    outline: var(--number-input-button-both-ends-outline);
}
 
.root[button-display="tail"] .button:active {
    background: var(--number-input-button-background-active);
}
 
.root[button-display="bothEnds"] .button:active {
    background: var(--number-input-button-both-ends-background-active);
}
 
.root[button-display="tail"] .button[role="up"] {
    top: 0;
    border-bottom: 1px solid var(--number-input-border-color);
    border-top-right-radius: var(--number-input-button-border-radius);
}
 
.root[button-display="tail"] .button[role="down"] {
    bottom: 0;
    border-bottom-right-radius: var(--number-input-button-border-radius);
}
 
.root[button-display="tail"] .button[role="up"] {
    border-bottom: 1px solid var(--number-input-border-color);
    border-top-right-radius: var(--number-input-button-border-radius);
}
 
.root[button-display="tail"] .button[role="down"] {
    bottom: 0;
    border-bottom-right-radius: var(--number-input-button-border-radius);
}
 
.root[button-display="tail"] .button[role="up"]::before {
    icon-font: url("../i-icon.vue/icons/keyboard-arrow-up.svg");
}
 
.root[button-display="tail"] .button[role="down"]::before {
    icon-font: url("../i-icon.vue/icons/keyboard-arrow-down.svg");
}
 
.root[button-display="bothEnds"] .button[role="up"] {
    right: 0;
    border-left: 1px solid var(--number-input-border-color);
    border-top-right-radius: var(--number-input-button-border-radius);
    border-bottom-right-radius: var(--number-input-button-border-radius);
}
 
.root[button-display="bothEnds"] .button[role="down"] {
    left: 0;
    border-right: 1px solid var(--number-input-border-color);
    border-top-left-radius: var(--number-input-button-border-radius);
    border-bottom-left-radius: var(--number-input-button-border-radius);
}
 
.root[button-display="bothEnds"] .button::before {
    font-family: var(--font-family-zh-CN);
}
 
.root[button-display="bothEnds"] .button[role="up"]::before {
    content: "+";
}
 
.root[button-display="bothEnds"] .button[role="down"]::before {
    content: '-';
}
 
.button::before {
    width: 1em;
    display: inline-block;
    font-size: 16px;
}
 
.root[button-display="tail"] .button:hover,
.root[button-display="bothEnds"] .button:hover {
    color: var(--number-input-button-color-hover);
}
 
.root .button[disabled]:hover,
.root[disabled] .button:hover {
     color: var(--number-input-button-color-disabled);
}
 
.root[disabled] {
    background: var(--number-input-background-disabled);
    color: var(--number-input-color-disabled);
    border-color: var(--number-input-border-color-disabled);
}
 
.root[disabled] .button[role="up"],
.root[disabled] .button[role="down"] {
    border-color: var(--number-input-border-color-disabled);
}
 
.root[disabled][button-display="tail"] .button {
    background: var(--number-input-button-background-disabled);
}

.root[disabled][button-display="bothEnds"] .button {
    background: var(--number-input-button-both-ends-background-disabled);
}
 
.button {
    color: var(--number-input-button-color);
}
 
.root[disabled] .button, .button[disabled] {
    background: var(--number-input-button-background-disabled);
    color: var(--number-input-button-color-disabled);
    cursor: var(--cursor-not-allowed);
    opacity: 0.65;
}

.root[readonly] .button {
    background: var(--number-input-button-background);
    cursor: default;
}
.root[readonly]:hover,
.root[readonly][focus] {
    border-color: var(--number-input-border-color);
}
.root[readonly] .button:hover {
    color: var(--number-input-button-color);
}
.root[readonly][button-display="bothEnds"] .button:focus,
.root[readonly][button-display="bothEnds"] .button:hover,
.root[readonly][button-display="bothEnds"] .button:active {
    background: var(--number-input-button-background);
}
 
.root[size="mini"] .button , .root[height="mini"] .button {
    right: -1px;
    height: calc((100% - 1px) / 2);
    line-height: calc((100% / 2) + 4px);
}
 
.root[size*="huge"] .button , .root[height="huge"] .button {
    height: calc(var(--input-height-huge) / 2 - 1px);
    line-height: calc(var(--input-height-huge) / 2 - 1px);
}

.root[size="mini"] .button[role="up"] , .root[height="mini"] .button[role="up"]{
    height: calc((100% - 1px) / 2 + 1px);
}
 
.root[size="mini"] .button[role="down"] , .root[height="mini"] .button[role="down"] {
    bottom: 0;
}
 
.root[size="small"] .button[role="up"] , .root[height="small"] .button[role="up"]{
    height: calc((100% - 1px) / 2 + 1px);
    display: flex;
    align-items: center;
}
 
.root[size="small"] .button[role="down"] , .root[height="small"] .button[role="down"] {
    height: calc((100% - 1px) / 2 + 1px);
    display: flex;
    align-items: center;
}
 
/* normal */
.root[prefix] input {
    padding-left: 24px;
}
.root[prefix][clearable]:hover input,
.root[prefix][clearable][focus] input {
    padding-right: 24px !important;
}
.root[suffix] input {
    padding-right: 24px;
}
.root[suffix][clearable]:hover input,
.root[suffix][clearable][focus] input {
    padding-right: 48px !important;
}
/* tail */
.root[button-display="tail"]:not([hide-buttons="true"]) input {
    padding-right: var(--input-suffix-padding-right);
}
.root[button-display="tail"]:not([hide-buttons="true"])[prefix][clearable]:hover input,
.root[button-display="tail"]:not([hide-buttons="true"])[prefix][clearable][focuse] input {
    padding-right: calc(var(--input-suffix-padding-right) + 24px) !important;
}
.root[button-display="tail"]:not([hide-buttons="true"])[suffix] input {
    padding-right: calc(var(--input-suffix-padding-right) + 24px);
}
.root[button-display="tail"]:not([hide-buttons="true"])[suffix][clearable]:hover input,
.root[button-display="tail"]:not([hide-buttons="true"])[suffix][clearable][focus] input {
    padding-right: calc(var(--input-suffix-padding-right) + 48px) !important;
}
.root[button-display="tail"]:not([hide-buttons="true"]) [class^="u-input_suffix__"] {
    right: var(--input-suffix-padding-right);
}
 
/* bothEnds */
.root[button-display="bothEnds"]:not([hide-buttons="true"]) input {
    padding: 0 var(--number-input-both-ends-button-width);
}
.root[button-display="bothEnds"]:not([hide-buttons="true"])[prefix] input {
    padding-left: calc(var(--number-input-both-ends-button-width) + 24px);
}
.root[button-display="bothEnds"]:not([hide-buttons="true"])[prefix][clearable]:hover input,
.root[button-display="bothEnds"]:not([hide-buttons="true"])[prefix][clearable][focuse] input {
    padding-right: calc(var(--number-input-both-ends-button-width) + 24px) !important;
}
.root[button-display="bothEnds"]:not([hide-buttons="true"])[suffix] input {
    padding-right: calc(var(--number-input-both-ends-button-width) + 24px);
}
.root[button-display="bothEnds"]:not([hide-buttons="true"])[suffix][clearable]:hover input,
.root[button-display="bothEnds"]:not([hide-buttons="true"])[suffix][clearable][focus] input {
    padding-right: calc(var(--number-input-both-ends-button-width) + 48px) !important;
}
.root[button-display="bothEnds"]:not([hide-buttons="true"]) [class^="u-input_prefix__"] {
    left: calc(var(--number-input-both-ends-button-width) + 8px);
}
.root[button-display="bothEnds"]:not([hide-buttons="true"]) [class^="u-input_suffix__"] {
    right: calc(var(--number-input-both-ends-button-width) + 8px);
}
</style>