Skip to content

Commit

Permalink
feat(math)!: move useClamp to @vueuse/math (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 10, 2022
1 parent 81d9225 commit 27125a1
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions meta/packages.ts
Expand Up @@ -32,9 +32,7 @@ export const packages: PackageManifest[] = [
name: 'math',
display: 'Math',
description: 'Math functions for VueUse',
author: 'Jacob Clevenger<https://github.com/wheatjs>',
external: [
'@vueuse/core',
'@vueuse/shared',
],
},
Expand Down
1 change: 0 additions & 1 deletion packages/core/index.ts
Expand Up @@ -17,7 +17,6 @@ export * from './useBreakpoints'
export * from './useBroadcastChannel'
export * from './useBrowserLocation'
export * from './useCached'
export * from './useClamp'
export * from './useClipboard'
export * from './useColorMode'
export * from './useConfirmDialog'
Expand Down
4 changes: 2 additions & 2 deletions packages/core/useOffsetPagination/index.ts
Expand Up @@ -2,7 +2,7 @@ import type { ComputedRef, Ref, UnwrapNestedRefs } from 'vue-demi'
import { computed, isRef, reactive, unref, watch } from 'vue-demi'
import { noop, syncRef } from '@vueuse/shared'
import type { MaybeRef } from '@vueuse/shared'
import { useClamp } from '../useClamp'
import { useClamp } from '../../math/useClamp'

export interface UseOffsetPaginationOptions {
/**
Expand Down Expand Up @@ -62,7 +62,7 @@ export function useOffsetPagination(options: UseOffsetPaginationOptions): UseOff
onPageCountChange = noop,
} = options

const currentPageSize = useClamp(pageSize, 1, Infinity)
const currentPageSize = computed(() => Math.min(unref(pageSize), 1))

const pageCount = computed(() => Math.ceil((unref(total)) / unref(currentPageSize)))

Expand Down
1 change: 1 addition & 0 deletions packages/math/index.ts
@@ -1,4 +1,5 @@
export * from './logicAnd'
export * from './logicNot'
export * from './logicOr'
export * from './useClamp'
export * from './useProjection'
4 changes: 2 additions & 2 deletions packages/math/package.json
@@ -1,8 +1,8 @@
{
"name": "@vueuse/math",
"version": "8.8.1",
"version": "8.9.1",
"description": "Math functions for VueUse",
"author": "Jacob Clevenger<https://github.com/wheatjs>",
"author": "Anthony Fu <https://github.com/antfu>",
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/math#readme",
Expand Down
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useClamp } from '@vueuse/core'
import { useClamp } from '@vueuse/math'
const min = ref(0)
const max = ref(10)
Expand Down
@@ -1,5 +1,5 @@
---
category: Utilities
category: '@Math'
---

# useClamp
Expand All @@ -9,7 +9,7 @@ Reactively clamp a value between two other values.
## Usage

```ts
import { useClamp } from '@vueuse/core'
import { useClamp } from '@vueuse/math'

const min = ref(0)
const max = ref(10)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 27125a1

Please sign in to comment.