Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VNumberInput): use VTextField as the base component #19714

Merged
merged 2 commits into from
May 6, 2024

Conversation

yuwu9145
Copy link
Member

@yuwu9145 yuwu9145 commented Apr 29, 2024

type="number" input has been removed, number-input should be really just a wrapper having number features on top of VTextField.

This approach reuses VTextFi19757eld features

fixes #19659
fixes #19757

Description

Markup:

<template>
  <v-app>
    <v-container>
      <v-form fast-fail @submit.prevent>
        <v-text-field
          v-model="msg"
          :rules="[v => v.length > 3 || 'min length 3'      ]"
        />
        <v-number-input
          v-model="value"
          :rules="[v => v > 3        || 'value must be > 3' ]"
        />
        <v-btn type="submit" text="test validate and error messages" />
      </v-form>
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'

  const msg = ref('ms')
  const value = ref(1)
</script>

Regression check playground

<template>
  <v-app>
    <v-select
      v-model="fieldVariant"
      label="Variants"
      :items="['underlined', 'outlined', 'filled', 'solo', 'solo-inverted', 'solo-filled', 'plain']"
    />
    <h1>{{ numberInputValue }}</h1>
    <v-number-input
      v-model="numberInputValue"
      :variant="fieldVariant"
    />
    <div class="ma-4 pa-4">
      <v-number-input
        v-model="numberInputValue"
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="stacked"
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="split"
        :variant="fieldVariant"
      />
    </div>
    <div class="ma-4 pa-4">
      <h1>Reverse</h1>
      <v-number-input
        v-model="numberInputValue"
        reverse
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="stacked"
        reverse
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="split"
        reverse
        :variant="fieldVariant"
      />
    </div>
    <div class="ma-4 pa-4">
      <h1>inset</h1>
      <v-number-input
        v-model="numberInputValue"
        inset
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="stacked"
        inset
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="split"
        inset
        :variant="fieldVariant"
      />
    </div>
    <div class="ma-4 pa-4">
      <h1>Reverse Inset</h1>
      <v-number-input
        v-model="numberInputValue"
        reverse
        inset
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="stacked"
        reverse
        inset
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        control-variant="split"
        reverse
        inset
        :variant="fieldVariant"
      />
    </div>
    <div class="ma-4 pa-4">
      <h1>Hide Input</h1>
      <v-number-input
        v-model="numberInputValue"
        hide-input
        :variant="fieldVariant"
      />
      <v-number-input
        v-model="numberInputValue"
        inset
        hide-input
        :variant="fieldVariant"
      />
    </div>
    <div class="ma-4 pa-4">
      <h1>Control slots</h1>
      <v-number-input
        v-model="numberInputValue"
        :variant="fieldVariant"
        reverse
      >
        <template v-slot:increment="{ click }">
          <v-btn
            color="red"
            @click="click"
          />
        </template>
        <template v-slot:decrement="{ click }">
          <v-btn
            color="green"
            @click="click"
          />
        </template>
      </v-number-input>
    </div>
    <div class="ma-4 pa-4">
      <h1>Native html attributes support</h1>
      <h4>max (100)</h4>
      <v-number-input
        :max="100"
        :min="10"
        :model-value="120"
        :variant="fieldVariant"
      />
      <h4>min (10)</h4>
      <v-number-input
        :max="100"
        :min="10"
        :model-value="6"
        :variant="fieldVariant"
      />
      <h4>step (5)</h4>
      <v-number-input
        :max="100"
        :min="10"
        :step="5"
        :model-value="70"
        :variant="fieldVariant"
      />
    </div>
    <div class="ma-4 pa-4">
      <h1>VInput/VField props</h1>
      <h4>disabled</h4>
      <v-number-input
        :max="100"
        :min="10"
        disabled
        :variant="fieldVariant"
      />
      <h4>hint</h4>
      <v-number-input
        hint="Enter your password to access this website"
        :variant="fieldVariant"
      />
      <h4>label</h4>
      <v-number-input
        label="test label"
        :variant="fieldVariant"
      />
      <h4>Density</h4>
      <v-number-input
        :variant="fieldVariant"
        density="default"
      />
      <v-number-input
        :variant="fieldVariant"
        density="comfortable"
      />
      <v-number-input
        :variant="fieldVariant"
        density="compact"
      />
      <h4>Loading</h4>
      <v-number-input
        :variant="fieldVariant"
        loading
        color="blue"
      >
      </v-number-input>
    </div>
  </v-app>
</template>

<script setup lang="ts">
  import { template } from 'cypress/types/lodash';
import { computed, ref } from 'vue'
  const fieldVariant = ref('outlined')
  const numberInputValue = ref(120)
  const progress = computed(() => Math.min(100, 5 * 10))
</script>

@MajesticPotatoe MajesticPotatoe added T: bug Functionality that does not work as intended/expected C: VNumberInput labels Apr 30, 2024
@yuwu9145 yuwu9145 marked this pull request as ready for review May 3, 2024 11:05
@yuwu9145 yuwu9145 requested a review from a team May 3, 2024 11:05
@yuwu9145
Copy link
Member Author

yuwu9145 commented May 3, 2024

Extra eyes on regressions are welcome

@johnleider johnleider merged commit 53d6bb9 into master May 6, 2024
17 of 18 checks passed
@johnleider johnleider deleted the refactor-v-number-input branch May 6, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VNumberInput T: bug Functionality that does not work as intended/expected
Projects
None yet
3 participants