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

feat(math)!: move useClamp to @vueuse/math #1810

Merged
merged 1 commit into from Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.