epicmaxco / vuestic-ui

Vuestic UI is an open-source Vue 3 component library designed for rapid development, easy maintenance, and high accessibility. Maintained by Epicmax (@epicmaxco).
https://vuestic.dev
MIT License
3.52k stars 340 forks source link

Make types for components accessible to import #4342

Open fallenfreq opened 4 months ago

fallenfreq commented 4 months ago

Is your feature request related to a problem? Please describe.

Currently when you add rules to components such as VaDateInput or VaSelect, the internal types that Vuestic uses are not accessible to import. This means you need to use any which is not good practice. In the example bellow, any should really be DateInputModelValue.

  <VaDateInput
    v-model="form.birthDate"
    :rules="[(v: any) => validateBirthday(v)]"
    label="Birth Date"
    manual-input
    clearable
  />

SelectableOption is available as SelectOption but this is a little confusing when you follow what your IDE is telling you that you need.

  <VaSelect
    v-model="form.country"
    :options="countries"
    :rules="[
      (v: SelectOption) => v || 'Field is required',
      (v: SelectOption) =>
        v && typeof v === 'object' && v.value === 'ua'
          ? 'Delivery currently unavailable in your country'
          : undefined
    ]"
    label="Country"
  />

It would also be convenient if these types used generics so that you didn't need to check for the type as you can see in the example above. DateInputModelValue is similar in that it could be Date, Date[], { start: Date, end: Date }.

Describe the solution you'd like

These types at the very minimum need to be re-exported so they are accessible to import. It would also be convenient if they used generics to prevent having to do type narrowing.