@yamada-ui/utils
Advanced tools
Comparing version 1.5.4-dev-20241018141555 to 1.5.4-dev-20241021014813
@@ -8,3 +8,3 @@ export { filterEmpty } from './array.js'; | ||
export { funcAll, handlerAll, noop, runIfFunc } from './function.js'; | ||
export { Dict, Length, Merge, MergeIfDefined, ObjectLiteral, Path, Primitive, Replace, StringLiteral, Union } from './index.types.js'; | ||
export { Dict, Length, Merge, ObjectLiteral, Path, Primitive, Replace, StringLiteral, Union } from './index.types.js'; | ||
export { interopDefault } from './module.js'; | ||
@@ -14,3 +14,3 @@ export { clampNumber, countDecimal, percentToValue, roundNumberToStep, toNumber, toPrecision, valueToPercent } from './number.js'; | ||
export { AsyncFnReturn, AsyncState, AsyncStateRetry, FunctionReturningPromise, MaybeRenderProp, PromiseType, UseIsMountedProps, UseIsMountedReturn, assignRef, createContext, createId, cx, findChild, findChildren, getValidChildren, includesChildren, isRefObject, isSomeElement, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.js'; | ||
export { antonym, escape, toCamelCase, toKebabCase, toPascalCase, toTitleCase } from './string.js'; | ||
export { antonym, escape, toCamelCase, toKebabCase, toPascalCase, toTitleCase, transformSize } from './string.js'; | ||
import 'react'; |
@@ -155,2 +155,3 @@ "use strict"; | ||
toTitleCase: () => toTitleCase, | ||
transformSize: () => transformSize, | ||
transparentizeColor: () => transparentizeColor, | ||
@@ -1268,2 +1269,35 @@ useAsync: () => useAsync, | ||
} | ||
var sizeMap = [ | ||
"9xs", | ||
"8xs", | ||
"7xs", | ||
"6xs", | ||
"5xs", | ||
"4xs", | ||
"3xs", | ||
"2xs", | ||
"xs", | ||
"sm", | ||
"md", | ||
"normal", | ||
"lg", | ||
"xl", | ||
"2xl", | ||
"3xl", | ||
"4xl", | ||
"5xl", | ||
"6xl", | ||
"7xl", | ||
"8xl", | ||
"9xl" | ||
]; | ||
function transformSize(token, value, omitTokens = ["normal"]) { | ||
if (!token) return void 0; | ||
let resolvedSizeMap = sizeMap; | ||
if (omitTokens) | ||
resolvedSizeMap = sizeMap.filter((size2) => !omitTokens.includes(size2)); | ||
const index = resolvedSizeMap.indexOf(token); | ||
const size = resolvedSizeMap[index + value]; | ||
return size != null ? size : token; | ||
} | ||
function toCamelCase(value) { | ||
@@ -1405,2 +1439,3 @@ return value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()); | ||
toTitleCase, | ||
transformSize, | ||
transparentizeColor, | ||
@@ -1407,0 +1442,0 @@ useAsync, |
@@ -16,4 +16,3 @@ type Primitive = bigint | boolean | null | number | string | symbol | undefined; | ||
type Merge<Y, M> = M & Omit<Y, keyof M>; | ||
type MergeIfDefined<Y, M> = M extends undefined ? Y : Merge<Y, M>; | ||
export type { Dict, Length, Merge, MergeIfDefined, ObjectLiteral, Path, Primitive, Replace, StringLiteral, Union }; | ||
export type { Dict, Length, Merge, ObjectLiteral, Path, Primitive, Replace, StringLiteral, Union }; |
@@ -5,2 +5,3 @@ import { StringLiteral } from './index.types.js'; | ||
declare function antonym(value: string): string; | ||
declare function transformSize(token: string | undefined, value: number, omitTokens?: null | string[]): string | undefined; | ||
declare function toCamelCase(value: StringLiteral): string; | ||
@@ -11,2 +12,2 @@ declare function toPascalCase(value: StringLiteral): string; | ||
export { antonym, escape, toCamelCase, toKebabCase, toPascalCase, toTitleCase }; | ||
export { antonym, escape, toCamelCase, toKebabCase, toPascalCase, toTitleCase, transformSize }; |
@@ -28,3 +28,4 @@ "use strict"; | ||
toPascalCase: () => toPascalCase, | ||
toTitleCase: () => toTitleCase | ||
toTitleCase: () => toTitleCase, | ||
transformSize: () => transformSize | ||
}); | ||
@@ -73,2 +74,35 @@ module.exports = __toCommonJS(string_exports); | ||
} | ||
var sizeMap = [ | ||
"9xs", | ||
"8xs", | ||
"7xs", | ||
"6xs", | ||
"5xs", | ||
"4xs", | ||
"3xs", | ||
"2xs", | ||
"xs", | ||
"sm", | ||
"md", | ||
"normal", | ||
"lg", | ||
"xl", | ||
"2xl", | ||
"3xl", | ||
"4xl", | ||
"5xl", | ||
"6xl", | ||
"7xl", | ||
"8xl", | ||
"9xl" | ||
]; | ||
function transformSize(token, value, omitTokens = ["normal"]) { | ||
if (!token) return void 0; | ||
let resolvedSizeMap = sizeMap; | ||
if (omitTokens) | ||
resolvedSizeMap = sizeMap.filter((size2) => !omitTokens.includes(size2)); | ||
const index = resolvedSizeMap.indexOf(token); | ||
const size = resolvedSizeMap[index + value]; | ||
return size != null ? size : token; | ||
} | ||
function toCamelCase(value) { | ||
@@ -93,4 +127,5 @@ return value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()); | ||
toPascalCase, | ||
toTitleCase | ||
toTitleCase, | ||
transformSize | ||
}); | ||
//# sourceMappingURL=string.js.map |
{ | ||
"name": "@yamada-ui/utils", | ||
"version": "1.5.4-dev-20241018141555", | ||
"version": "1.5.4-dev-20241021014813", | ||
"description": "Yamada UI utils", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
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
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
425271
5517