@nextui-org/shared-utils
Advanced tools
Comparing version 0.0.0-dev-v2-20231103151341 to 0.0.0-dev-v2-20240416125016
@@ -24,3 +24,4 @@ type Args<T extends Function> = T extends (...args: infer R) => any ? R : never; | ||
}; | ||
declare function objectToDeps(obj: Extractable): string; | ||
export { callAll, callAllHandlers, capitalize, extractProperty, getUniqueID, removeEvents }; | ||
export { callAll, callAllHandlers, capitalize, extractProperty, getUniqueID, objectToDeps, removeEvents }; |
@@ -28,2 +28,3 @@ "use strict"; | ||
getUniqueID: () => getUniqueID, | ||
objectToDeps: () => objectToDeps, | ||
removeEvents: () => removeEvents | ||
@@ -70,2 +71,12 @@ }); | ||
} | ||
function objectToDeps(obj) { | ||
if (!obj || typeof obj !== "object") { | ||
return ""; | ||
} | ||
try { | ||
return JSON.stringify(obj); | ||
} catch (e) { | ||
return ""; | ||
} | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -78,3 +89,4 @@ 0 && (module.exports = { | ||
getUniqueID, | ||
objectToDeps, | ||
removeEvents | ||
}); |
@@ -6,6 +6,5 @@ export { Dict, __DEV__, __TEST__, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isFunction, isNumeric, isObject } from './assertion.js'; | ||
export { getMargin } from './dimensions.js'; | ||
export { callAll, callAllHandlers, capitalize, extractProperty, getUniqueID, removeEvents } from './functions.js'; | ||
export { clampPercentage, range } from './numbers.js'; | ||
export { callAll, callAllHandlers, capitalize, extractProperty, getUniqueID, objectToDeps, removeEvents } from './functions.js'; | ||
export { clamp, clampPercentage, range } from './numbers.js'; | ||
export { warn } from './console.js'; | ||
export { Timer } from './types.js'; | ||
import 'react'; |
@@ -29,2 +29,3 @@ "use strict"; | ||
capitalize: () => capitalize, | ||
clamp: () => clamp, | ||
clampPercentage: () => clampPercentage, | ||
@@ -49,2 +50,3 @@ cleanObject: () => cleanObject, | ||
isObject: () => isObject, | ||
objectToDeps: () => objectToDeps, | ||
omitObject: () => omitObject, | ||
@@ -270,2 +272,12 @@ range: () => range, | ||
} | ||
function objectToDeps(obj) { | ||
if (!obj || typeof obj !== "object") { | ||
return ""; | ||
} | ||
try { | ||
return JSON.stringify(obj); | ||
} catch (e) { | ||
return ""; | ||
} | ||
} | ||
@@ -277,2 +289,5 @@ // src/numbers.ts | ||
} | ||
function clamp(value, min, max) { | ||
return Math.min(Math.max(value, min), max); | ||
} | ||
function clampPercentage(value, max = 100) { | ||
@@ -305,2 +320,3 @@ return Math.min(Math.max(value, 0), max); | ||
capitalize, | ||
clamp, | ||
clampPercentage, | ||
@@ -325,2 +341,3 @@ cleanObject, | ||
isObject, | ||
objectToDeps, | ||
omitObject, | ||
@@ -327,0 +344,0 @@ range, |
@@ -8,4 +8,19 @@ /** | ||
declare function range(start: number, end: number): number[]; | ||
/** | ||
* Clamps a value between a minimum and maximum range. | ||
* | ||
* @param value - The value to be clamped. | ||
* @param min - The minimum value of the range. | ||
* @param max - The maximum value of the range. | ||
* @returns The clamped value. | ||
*/ | ||
declare function clamp(value: number, min: number, max: number): number; | ||
/** | ||
* Clamps a value between 0 and a maximum value. | ||
* @param value - The value to clamp. | ||
* @param max - The maximum value to clamp to. Defaults to 100. | ||
* @returns The clamped value. | ||
*/ | ||
declare function clampPercentage(value: number, max?: number): number; | ||
export { clampPercentage, range }; | ||
export { clamp, clampPercentage, range }; |
@@ -23,2 +23,3 @@ "use strict"; | ||
__export(numbers_exports, { | ||
clamp: () => clamp, | ||
clampPercentage: () => clampPercentage, | ||
@@ -32,2 +33,5 @@ range: () => range | ||
} | ||
function clamp(value, min, max) { | ||
return Math.min(Math.max(value, min), max); | ||
} | ||
function clampPercentage(value, max = 100) { | ||
@@ -38,4 +42,5 @@ return Math.min(Math.max(value, 0), max); | ||
0 && (module.exports = { | ||
clamp, | ||
clampPercentage, | ||
range | ||
}); |
@@ -1,3 +0,2 @@ | ||
import { Key } from 'react'; | ||
type Key = string | number; | ||
interface MergeObject { | ||
@@ -4,0 +3,0 @@ [key: string]: any; |
{ | ||
"name": "@nextui-org/shared-utils", | ||
"version": "0.0.0-dev-v2-20231103151341", | ||
"version": "0.0.0-dev-v2-20240416125016", | ||
"description": "A set of NextUI utilities", | ||
@@ -27,5 +27,2 @@ "keywords": [ | ||
}, | ||
"peerDependencies": { | ||
"react": ">=18" | ||
}, | ||
"clean-package": "../../../clean-package.config.json", | ||
@@ -52,3 +49,3 @@ "tsup": { | ||
"build": "tsup src --dts", | ||
"dev": "yarn build:fast -- --watch", | ||
"dev": "pnpm build:fast --watch", | ||
"clean": "rimraf dist .turbo", | ||
@@ -55,0 +52,0 @@ "typecheck": "tsc --noEmit", |
@@ -21,5 +21,5 @@ # @nextui-org/system | ||
## Licence | ||
## License | ||
This project is licensed under the terms of the | ||
[MIT license](https://github.com/nextui-org/nextui/blob/master/LICENSE). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41731
0
1467