Skip to content

Commit

Permalink
chore: replace deprecated vueuse API (#189)
Browse files Browse the repository at this point in the history
Co-authored-by: jd-solanki <jdsolanki0001@gmail.com>
  • Loading branch information
IcetCode and jd-solanki committed Jun 22, 2023
1 parent aceb118 commit c212222
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions packages/anu-vue/src/composables/useCheckbox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { MaybeRefOrGetter } from '@vueuse/core'
import type { ComponentObjectPropsOptions, PropType } from 'vue'
import { toValue } from 'vue'

export type CheckboxModelValue = null | string | number | boolean | unknown[]

Expand Down Expand Up @@ -59,12 +60,12 @@ export function useCheckbox<Name extends string>(
cycleIndeterminate: MaybeRefOrGetter<boolean> = false,
) {
const handleModelValueChange = () => {
const _cycleIndeterminate = resolveUnref(cycleIndeterminate)
const _modelValue = resolveUnref(modelValue)
const _cycleIndeterminate = toValue(cycleIndeterminate)
const _modelValue = toValue(modelValue)

const _checkedValue = resolveUnref(checkedValue)
const _uncheckedValue = resolveUnref(uncheckedValue)
const _indeterminateValue = resolveUnref(indeterminateValue)
const _checkedValue = toValue(checkedValue)
const _uncheckedValue = toValue(uncheckedValue)
const _indeterminateValue = toValue(indeterminateValue)

const cycleInitialValue = Array.isArray(_modelValue)
? (_modelValue.includes(_checkedValue) ? _checkedValue : _uncheckedValue)
Expand Down Expand Up @@ -96,8 +97,8 @@ export function useCheckbox<Name extends string>(

const isChecked = computed({
get: () => {
const _modelValue = resolveUnref(modelValue)
const _checkedValue = resolveUnref(checkedValue)
const _modelValue = toValue(modelValue)
const _checkedValue = toValue(checkedValue)

if (Array.isArray(_modelValue))
return _modelValue.includes(_checkedValue)
Expand All @@ -108,8 +109,8 @@ export function useCheckbox<Name extends string>(
})

const isIndeterminate = computed(() => {
const _modelValue = resolveUnref(modelValue)
const _indeterminateValue = resolveUnref(indeterminateValue)
const _modelValue = toValue(modelValue)
const _indeterminateValue = toValue(indeterminateValue)

if (Array.isArray(_modelValue))
return _modelValue.includes(_indeterminateValue)
Expand Down
4 changes: 2 additions & 2 deletions packages/anu-vue/src/composables/useConfigurable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MaybeRef } from '@vueuse/core'
import { resolveUnref } from '@vueuse/core'
import { toValue } from '@vueuse/core'
import { computed } from 'vue'

// 鈩癸笍 We might need generic here in future
Expand All @@ -12,7 +12,7 @@ export type ConfigurableValue = undefined | ContentType | [ContentType, ClassAtt

export function useConfigurable(value: MaybeRef<ConfigurableValue>) {
return computed(() => {
const _value = resolveUnref(value)
const _value = toValue(value)

const [content, classes, attrs] = _value === undefined
? []
Expand Down
6 changes: 3 additions & 3 deletions packages/anu-vue/src/composables/useTypographyColor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MaybeRefOrGetter } from '@vueuse/core'
import { resolveUnref } from '@vueuse/core'
import { toValue } from '@vueuse/core'
import type { ColorProp } from './useProps'
import { colord } from '@/utils/colord'
import { isThemeColor } from '@/composables/useColor'
Expand Down Expand Up @@ -43,8 +43,8 @@ export function useTypographyColor(color: MaybeRefOrGetter<ColorProp | null>, va
const typographyClasses = ref<string[]>([])
const typographyStyles = ref<string[]>([])

const _color = resolveUnref(color)
const _variant = resolveUnref(variant)
const _color = toValue(color)
const _variant = toValue(variant)
const _isThemeColor = isThemeColor(_color)

watch([() => color, () => variant], () => {
Expand Down

0 comments on commit c212222

Please sign in to comment.