Skip to content

Commit

Permalink
refactor: make filterProps faster
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Nov 7, 2023
1 parent 3247521 commit a36dfb8
Show file tree
Hide file tree
Showing 39 changed files with 91 additions and 73 deletions.
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VAppBar/VAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const VAppBar = genericComponent<VToolbarSlots>()({
})

useRender(() => {
const [toolbarProps] = VToolbar.filterProps(props)
const toolbarProps = VToolbar.filterProps(props)

return (
<VToolbar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export const VAutocomplete = genericComponent<new <
slots['no-data']
)
const isDirty = model.value.length > 0
const [textFieldProps] = VTextField.filterProps(props)
const textFieldProps = VTextField.filterProps(props)

return (
<VTextField
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VBadge/VBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { makeTransitionProps, MaybeTransition } from '@/composables/transition'

// Utilities
import { toRef } from 'vue'
import { genericComponent, pick, propsFactory, useRender } from '@/util'
import { genericComponent, pickWithRest, propsFactory, useRender } from '@/util'

export type VBadgeSlots = {
default: never
Expand Down Expand Up @@ -85,7 +85,7 @@ export const VBadge = genericComponent<VBadgeSlots>()({
: value <= +props.max ? value
: `${props.max}+`

const [badgeAttrs, attrs] = pick(ctx.attrs as Record<string, any>, [
const [badgeAttrs, attrs] = pickWithRest(ctx.attrs as Record<string, any>, [
'aria-atomic',
'aria-label',
'aria-live',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const VBottomSheet = genericComponent<OverlaySlots>()({
const isActive = useProxiedModel(props, 'modelValue')

useRender(() => {
const [dialogProps] = VDialog.filterProps(props)
const dialogProps = VDialog.filterProps(props)

return (
<VDialog
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VBtnToggle/VBtnToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const VBtnToggle = genericComponent<VBtnToggleSlots>()({
const { isSelected, next, prev, select, selected } = useGroup(props, VBtnToggleSymbol)

useRender(() => {
const [btnGroupProps] = VBtnGroup.filterProps(props)
const btnGroupProps = VBtnGroup.filterProps(props)

return (
<VBtnGroup
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VCarousel/VCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const VCarousel = genericComponent<VCarouselSlots>()({
}

useRender(() => {
const [windowProps] = VWindow.filterProps(props)
const windowProps = VWindow.filterProps(props)

return (
<VWindow
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VCarousel/VCarouselItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const VCarouselItem = genericComponent<VImgSlots>()({

setup (props, { slots, attrs }) {
useRender(() => {
const [imgProps] = VImg.filterProps(props)
const [windowItemProps] = VWindowItem.filterProps(props)
const imgProps = VImg.filterProps(props)
const windowItemProps = VWindowItem.filterProps(props)

return (
<VWindowItem
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VCheckbox/VCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export const VCheckbox = genericComponent<VCheckboxSlots>()({

useRender(() => {
const [rootAttrs, controlAttrs] = filterInputAttrs(attrs)
const [inputProps, _1] = VInput.filterProps(props)
const [checkboxProps, _2] = VCheckboxBtn.filterProps(props)
const inputProps = VInput.filterProps(props)
const checkboxProps = VCheckboxBtn.filterProps(props)

return (
<VInput
Expand Down
14 changes: 7 additions & 7 deletions packages/vuetify/src/components/VCheckbox/VCheckboxBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ export const VCheckboxBtn = genericComponent<VSelectionControlSlots>()({
})

useRender(() => {
const controlProps = omit(VSelectionControl.filterProps(props)[0], ['modelValue'])
const controlProps = omit(VSelectionControl.filterProps(props), ['modelValue'])
return (
<VSelectionControl
{ ...controlProps }
v-model={ model.value }
class={[
'v-checkbox-btn',
props.class,
]}
style={ props.style }
class={[
'v-checkbox-btn',
props.class,
]}
style={ props.style }
type="checkbox"
onUpdate:modelValue={ onChange }
falseIcon={ falseIcon.value }
trueIcon={ trueIcon.value }
aria-checked={ indeterminate.value ? 'mixed' : undefined }
aria-checked={ indeterminate.value ? 'mixed' : undefined }
v-slots={ slots }
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const VColorPicker = defineComponent({
})

useRender(() => {
const [sheetProps] = VSheet.filterProps(props)
const sheetProps = VSheet.filterProps(props)

return (
<VSheet
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VCombobox/VCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export const VCombobox = genericComponent<new <
slots['no-data']
)
const isDirty = model.value.length > 0
const [textFieldProps] = VTextField.filterProps(props)
const textFieldProps = VTextField.filterProps(props)

return (
<VTextField
Expand Down
8 changes: 4 additions & 4 deletions packages/vuetify/src/components/VDataTable/VDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ export const VDataTable = genericComponent<VDataTableSlots>()({
}))

useRender(() => {
const [dataTableFooterProps] = VDataTableFooter.filterProps(props)
const [dataTableHeadersProps] = VDataTableHeaders.filterProps(props)
const [dataTableRowsProps] = VDataTableRows.filterProps(props)
const [tableProps] = VTable.filterProps(props)
const dataTableFooterProps = VDataTableFooter.filterProps(props)
const dataTableHeadersProps = VDataTableHeaders.filterProps(props)
const dataTableRowsProps = VDataTableRows.filterProps(props)
const tableProps = VTable.filterProps(props)

return (
<VTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ export const VDataTableServer = genericComponent<VDataTableSlots>()({
}))

useRender(() => {
const [dataTableFooterProps] = VDataTableFooter.filterProps(props)
const [dataTableHeadersProps] = VDataTableHeaders.filterProps(props)
const [dataTableRowsProps] = VDataTableRows.filterProps(props)
const [tableProps] = VTable.filterProps(props)
const dataTableFooterProps = VDataTableFooter.filterProps(props)
const dataTableHeadersProps = VDataTableHeaders.filterProps(props)
const dataTableRowsProps = VDataTableRows.filterProps(props)
const tableProps = VTable.filterProps(props)

return (
<VTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export const VDataTableVirtual = genericComponent<VDataTableVirtualSlots>()({
}))

useRender(() => {
const [dataTableHeadersProps] = VDataTableHeaders.filterProps(props)
const [dataTableRowsProps] = VDataTableRows.filterProps(props)
const [tableProps] = VTable.filterProps(props)
const dataTableHeadersProps = VDataTableHeaders.filterProps(props)
const dataTableRowsProps = VDataTableRows.filterProps(props)
const tableProps = VTable.filterProps(props)

return (
<VTable
Expand Down
12 changes: 6 additions & 6 deletions packages/vuetify/src/components/VDatePicker/VDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ export const VDatePicker = genericComponent<new <T, Multiple extends boolean = f
})

useRender(() => {
const [pickerProps] = VPicker.filterProps(props)
const [datePickerControlsProps] = VDatePickerControls.filterProps(props)
const [datePickerHeaderProps] = VDatePickerHeader.filterProps(props)
const [datePickerMonthProps] = VDatePickerMonth.filterProps(props)
const [datePickerMonthsProps] = VDatePickerMonths.filterProps(omit(props, ['modelValue']))
const [datePickerYearsProps] = VDatePickerYears.filterProps(omit(props, ['modelValue']))
const pickerProps = VPicker.filterProps(props)
const datePickerControlsProps = VDatePickerControls.filterProps(props)
const datePickerHeaderProps = VDatePickerHeader.filterProps(props)
const datePickerMonthProps = VDatePickerMonth.filterProps(props)
const datePickerMonthsProps = omit(VDatePickerMonths.filterProps(props), ['modelValue'])
const datePickerYearsProps = omit(VDatePickerYears.filterProps(props), ['modelValue'])

return (
<VPicker
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VDialog/VDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const VDialog = genericComponent<OverlaySlots>()({
)

useRender(() => {
const [overlayProps] = VOverlay.filterProps(props)
const overlayProps = VOverlay.filterProps(props)

return (
<VOverlay
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VFileInput/VFileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ export const VFileInput = genericComponent<VFileInputSlots>()({
const hasCounter = !!(slots.counter || props.counter)
const hasDetails = !!(hasCounter || slots.details)
const [rootAttrs, inputAttrs] = filterInputAttrs(attrs)
const [{ modelValue: _, ...inputProps }] = VInput.filterProps(props)
const [fieldProps] = filterFieldProps(props)
const { modelValue: _, ...inputProps } = VInput.filterProps(props)
const fieldProps = filterFieldProps(props)

return (
<VInput
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VImg/VImg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export const VImg = genericComponent<VImgSlots>()({
}

useRender(() => {
const [responsiveProps] = VResponsive.filterProps(props)
const responsiveProps = VResponsive.filterProps(props)
return (
<VResponsive
class={[
Expand Down
6 changes: 4 additions & 2 deletions packages/vuetify/src/components/VList/VList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { makeVariantProps } from '@/composables/variant'

// Utilities
import { computed, ref, shallowRef, toRef } from 'vue'
import { focusChild, genericComponent, getPropertyFromItem, pick, propsFactory, useRender } from '@/util'
import { focusChild, genericComponent, getPropertyFromItem, omit, propsFactory, useRender } from '@/util'

// Types
import type { PropType } from 'vue'
Expand All @@ -43,7 +43,9 @@ function transformItem (props: ItemProps & { itemType: string }, item: any): Int
const title = isPrimitive(item) ? item : getPropertyFromItem(item, props.itemTitle)
const value = getPropertyFromItem(item, props.itemValue, undefined)
const children = getPropertyFromItem(item, props.itemChildren)
const itemProps = props.itemProps === true ? pick(item, ['children'])[1] : getPropertyFromItem(item, props.itemProps)
const itemProps = props.itemProps === true
? omit(item, ['children'])
: getPropertyFromItem(item, props.itemProps)

const _props = {
title,
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VList/VListChildren.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const VListChildren = genericComponent<new <T extends InternalListItem>(
title: slots.title ? (slotProps: any) => slots.title?.({ ...slotProps, item }) : undefined,
}

const [listGroupProps, _1] = VListGroup.filterProps(itemProps)
const listGroupProps = VListGroup.filterProps(itemProps)

return children ? (
<VListGroup
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VMenu/VMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const VMenu = genericComponent<OverlaySlots>()({
)

useRender(() => {
const [overlayProps] = VOverlay.filterProps(props)
const overlayProps = VOverlay.filterProps(props)

return (
<VOverlay
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VRadioGroup/VRadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export const VRadioGroup = genericComponent<VRadioGroupSlots>()({

useRender(() => {
const [rootAttrs, controlAttrs] = filterInputAttrs(attrs)
const [inputProps, _1] = VInput.filterProps(props)
const [controlProps, _2] = VSelectionControl.filterProps(props)
const inputProps = VInput.filterProps(props)
const controlProps = VSelectionControl.filterProps(props)
const label = slots.label
? slots.label({
label: props.label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const VRangeSlider = genericComponent<VSliderSlots>()({
const trackStop = computed(() => position(model.value[1]))

useRender(() => {
const [inputProps, _] = VInput.filterProps(props)
const inputProps = VInput.filterProps(props)
const hasPrepend = !!(props.label || slots.label || slots.prepend)

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VSelect/VSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export const VSelect = genericComponent<new <
slots['no-data']
)
const isDirty = model.value.length > 0
const [textFieldProps] = VTextField.filterProps(props)
const textFieldProps = VTextField.filterProps(props)

const placeholder = isDirty || (
!isFocused.value &&
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VSlider/VSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const VSlider = genericComponent<VSliderSlots>()({
const trackStop = computed(() => position(model.value))

useRender(() => {
const [inputProps, _] = VInput.filterProps(props)
const inputProps = VInput.filterProps(props)
const hasPrepend = !!(props.label || slots.label || slots.prepend)

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VSnackbar/VSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const VSnackbar = genericComponent<VSnackbarSlots>()({
}

useRender(() => {
const [overlayProps] = VOverlay.filterProps(props)
const overlayProps = VOverlay.filterProps(props)
const hasContent = !!(slots.default || slots.text || props.text)

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VStepper/VStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const VStepper = genericComponent<VStepperSlots>()({
})

useRender(() => {
const [sheetProps] = VSheet.filterProps(props)
const sheetProps = VSheet.filterProps(props)

const hasHeader = !!(slots.header || props.items.length)
const hasWindow = props.items.length > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const VStepperWindow = genericComponent()({
})

useRender(() => {
const [windowProps] = VWindow.filterProps(props)
const windowProps = VWindow.filterProps(props)

return (
<VWindow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const VStepperWindowItem = genericComponent()({

setup (props, { slots }) {
useRender(() => {
const [windowItemProps] = VWindowItem.filterProps(props)
const windowItemProps = VWindowItem.filterProps(props)

return (
<VWindowItem
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VSwitch/VSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export const VSwitch = genericComponent<VSwitchSlots>()({

useRender(() => {
const [rootAttrs, controlAttrs] = filterInputAttrs(attrs)
const [inputProps, _1] = VInput.filterProps(props)
const [controlProps, _2] = VSelectionControl.filterProps(props)
const inputProps = VInput.filterProps(props)
const controlProps = VSelectionControl.filterProps(props)

return (
<VInput
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VTabs/VTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const VTab = genericComponent()({
}

useRender(() => {
const [btnProps] = VBtn.filterProps(props)
const btnProps = VBtn.filterProps(props)

return (
<VBtn
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VTabs/VTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const VTabs = genericComponent()({
})

useRender(() => {
const [slideGroupProps] = VSlideGroup.filterProps(props)
const slideGroupProps = VSlideGroup.filterProps(props)

return (
<VSlideGroup
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VTextField/VTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export const VTextField = genericComponent<VTextFieldSlots>()({
const hasCounter = !!(slots.counter || (props.counter !== false && props.counter != null))
const hasDetails = !!(hasCounter || slots.details)
const [rootAttrs, inputAttrs] = filterInputAttrs(attrs)
const [{ modelValue: _, ...inputProps }] = VInput.filterProps(props)
const [fieldProps] = filterFieldProps(props)
const { modelValue: _, ...inputProps } = VInput.filterProps(props)
const fieldProps = filterFieldProps(props)

return (
<VInput
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VTextarea/VTextarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ export const VTextarea = genericComponent<VTextareaSlots>()({
const hasCounter = !!(slots.counter || props.counter || props.counterValue)
const hasDetails = !!(hasCounter || slots.details)
const [rootAttrs, inputAttrs] = filterInputAttrs(attrs)
const [{ modelValue: _, ...inputProps }] = VInput.filterProps(props)
const [fieldProps] = filterFieldProps(props)
const { modelValue: _, ...inputProps } = VInput.filterProps(props)
const fieldProps = filterFieldProps(props)

return (
<VInput
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VTooltip/VTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const VTooltip = genericComponent<OverlaySlots>()({
)

useRender(() => {
const [overlayProps] = VOverlay.filterProps(props)
const overlayProps = VOverlay.filterProps(props)

return (
<VOverlay
Expand Down
Loading

0 comments on commit a36dfb8

Please sign in to comment.