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

build: replace fast-deep-equal with dequal #1473

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/radix-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@
"vue": ">= 3.2.0"
},
"dependencies": {
"@floating-ui/dom": "^1.6.7",
"@floating-ui/vue": "^1.1.0",
"@internationalized/date": "^3.5.4",
"@internationalized/number": "^3.5.3",
"@tanstack/vue-virtual": "^3.8.1",
"@floating-ui/dom": "^1.6.12",
"@floating-ui/vue": "^1.1.5",
"@internationalized/date": "^3.6.0",
"@internationalized/number": "^3.6.0",
"@tanstack/vue-virtual": "^3.10.9",
"@vueuse/core": "^10.11.0",
"@vueuse/shared": "^10.11.0",
"aria-hidden": "^1.2.4",
"defu": "^6.1.4",
"fast-deep-equal": "^3.1.3",
"dequal": "^2.0.3",
"nanoid": "^5.0.7"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/radix-vue/src/Combobox/ComboboxItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
Primitive,
} from '@/Primitive'
import { CollectionItem } from '@/Collection'
import isEqual from 'fast-deep-equal'
import { dequal } from 'dequal'

const props = defineProps<ComboboxItemProps<T>>()
const emits = defineEmits<ComboboxItemEmits<T>>()
Expand All @@ -53,18 +53,18 @@ const { forwardRef } = useForwardExpose()

const isSelected = computed(() =>
rootContext.multiple.value && Array.isArray(rootContext.modelValue.value)
? rootContext.modelValue.value?.some(val => isEqual(val, props.value))
: isEqual(rootContext.modelValue?.value, props.value),
? rootContext.modelValue.value?.some(val => dequal(val, props.value))
: dequal(rootContext.modelValue?.value, props.value),
)

const isFocused = computed(() => isEqual(rootContext.selectedValue.value, props.value))
const isFocused = computed(() => dequal(rootContext.selectedValue.value, props.value))
const textId = useId(undefined, 'radix-vue-combobox-item')
const optionId = useId(undefined, 'radix-vue-combobox-option')

const isInOption = computed(() =>
rootContext.isUserInputted.value
? rootContext.searchTerm.value === ''
|| !!rootContext.filteredOptions.value.find(i => isEqual(i, props.value))
|| !!rootContext.filteredOptions.value.find(i => dequal(i, props.value))
: true)

async function handleSelect(ev: SelectEvent<T>) {
Expand Down
8 changes: 4 additions & 4 deletions packages/radix-vue/src/Combobox/ComboboxRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import { PopperRoot } from '@/Popper'
import { Primitive } from '@/Primitive'
import { useVModel } from '@vueuse/core'
import { VisuallyHiddenInput } from '@/VisuallyHidden'
import isEqual from 'fast-deep-equal'
import { dequal } from 'dequal'

const props = withDefaults(defineProps<ComboboxRootProps<T>>(), {
open: undefined,
Expand Down Expand Up @@ -154,7 +154,7 @@ async function onOpenChange(val: boolean) {

function onValueChange(val: T) {
if (Array.isArray(modelValue.value) && multiple.value) {
const index = modelValue.value.findIndex(i => isEqual(i, val))
const index = modelValue.value.findIndex(i => dequal(i, val))
const modelArray = [...modelValue.value]
index === -1 ? modelArray.push(val) : modelArray.splice(index, 1)
modelValue.value = modelArray
Expand Down Expand Up @@ -208,9 +208,9 @@ function resetSearchTerm() {
}
}

const activeIndex = computed(() => filteredOptions.value.findIndex(i => isEqual(i, selectedValue.value)))
const activeIndex = computed(() => filteredOptions.value.findIndex(i => dequal(i, selectedValue.value)))
const selectedElement = computed(() => {
return reactiveItems.value.find(i => isEqual(i.value, selectedValue.value))?.ref
return reactiveItems.value.find(i => dequal(i.value, selectedValue.value))?.ref
})

const stringifiedModelValue = computed(() => JSON.stringify(modelValue.value))
Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Listbox/ListboxVirtualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defineSlots<{
default: (props: {
option: T
virtualizer: Virtualizer<Element | Window, Element>
virtualItem: VirtualItem<Element>
virtualItem: VirtualItem
}) => any
}>()

Expand Down
4 changes: 2 additions & 2 deletions packages/radix-vue/src/Listbox/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isEqual from 'fast-deep-equal'
import { dequal } from 'dequal'

export function queryCheckedElement(parentEl: HTMLElement | null) {
return parentEl?.querySelector('[data-state=checked]') as HTMLElement | null
Expand Down Expand Up @@ -26,5 +26,5 @@ export function compare<T>(value?: T, currentValue?: T, comparator?: string | ((
if (typeof comparator === 'string')
return value?.[comparator as keyof T] === currentValue?.[comparator as keyof T]

return isEqual(value, currentValue)
return dequal(value, currentValue)
}
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Tree/TreeVirtualizer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defineSlots<{
default: (props: {
item: FlattenedItem<Record<string, any>>
virtualizer: Virtualizer<Element | Window, Element>
virtualItem: VirtualItem<Element>
virtualItem: VirtualItem
}) => any
}>()

Expand Down
6 changes: 3 additions & 3 deletions packages/radix-vue/src/shared/arrays.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isEqual from 'fast-deep-equal'
import { dequal } from 'dequal'

/**
* The function `areEqual` compares two arrays and returns true if they are equal in length and have
Expand Down Expand Up @@ -55,8 +55,8 @@ export function chunk<T>(arr: T[], size: number): T[][] {
* found in the input array, an empty array is returned.
*/
export function findValuesBetween<T>(array: T[], start: T, end: T) {
const startIndex = array.findIndex(i => isEqual(i, start))
const endIndex = array.findIndex(i => isEqual(i, end))
const startIndex = array.findIndex(i => dequal(i, start))
const endIndex = array.findIndex(i => dequal(i, end))
if (startIndex === -1 || endIndex === -1)
return []

Expand Down
Loading
Loading