@chakra-ui/shared-utils
Advanced tools
Comparing version 0.0.0-dev-20220818130906 to 0.0.0-dev-20220818145526
@@ -23,7 +23,13 @@ "use strict"; | ||
__export(src_exports, { | ||
callAllHandlers: () => callAllHandlers, | ||
cx: () => cx, | ||
isObject: () => isObject | ||
isObject: () => isObject, | ||
runIfFn: () => runIfFn, | ||
warn: () => warn | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var cx = (...classNames) => classNames.filter(Boolean).join(" "); | ||
function isDev() { | ||
return process.env.NODE_ENV !== "production"; | ||
} | ||
function isObject(value) { | ||
@@ -33,6 +39,27 @@ const type = typeof value; | ||
} | ||
var warn = (options) => { | ||
const { condition, message } = options; | ||
if (condition && isDev()) { | ||
console.warn(message); | ||
} | ||
}; | ||
function runIfFn(valueOrFn, ...args) { | ||
return isFunction(valueOrFn) ? valueOrFn(...args) : valueOrFn; | ||
} | ||
function callAllHandlers(...fns) { | ||
return function func(event) { | ||
fns.some((fn) => { | ||
fn == null ? void 0 : fn(event); | ||
return event == null ? void 0 : event.defaultPrevented; | ||
}); | ||
}; | ||
} | ||
var isFunction = (value) => typeof value === "function"; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
callAllHandlers, | ||
cx, | ||
isObject | ||
isObject, | ||
runIfFn, | ||
warn | ||
}); |
@@ -0,4 +1,13 @@ | ||
declare type FunctionArguments<T extends Function> = T extends (...args: infer R) => any ? R : never; | ||
declare const cx: (...classNames: any[]) => string; | ||
declare function isObject(value: any): value is Record<string, any>; | ||
declare type MessageOptions = { | ||
condition: boolean; | ||
message: string; | ||
}; | ||
declare const warn: (options: MessageOptions) => void; | ||
declare function runIfFn<T, U>(valueOrFn: T | ((...fnArgs: U[]) => T), ...args: U[]): T; | ||
declare function callAllHandlers<T extends (event: any) => void>(...fns: (T | undefined)[]): (event: FunctionArguments<T>[0]) => void; | ||
export { cx, isObject }; | ||
export { callAllHandlers, cx, isObject, runIfFn, warn }; |
// src/index.ts | ||
var cx = (...classNames) => classNames.filter(Boolean).join(" "); | ||
function isDev() { | ||
return process.env.NODE_ENV !== "production"; | ||
} | ||
function isObject(value) { | ||
@@ -7,5 +10,26 @@ const type = typeof value; | ||
} | ||
var warn = (options) => { | ||
const { condition, message } = options; | ||
if (condition && isDev()) { | ||
console.warn(message); | ||
} | ||
}; | ||
function runIfFn(valueOrFn, ...args) { | ||
return isFunction(valueOrFn) ? valueOrFn(...args) : valueOrFn; | ||
} | ||
function callAllHandlers(...fns) { | ||
return function func(event) { | ||
fns.some((fn) => { | ||
fn == null ? void 0 : fn(event); | ||
return event == null ? void 0 : event.defaultPrevented; | ||
}); | ||
}; | ||
} | ||
var isFunction = (value) => typeof value === "function"; | ||
export { | ||
callAllHandlers, | ||
cx, | ||
isObject | ||
isObject, | ||
runIfFn, | ||
warn | ||
}; |
{ | ||
"name": "@chakra-ui/shared-utils", | ||
"version": "0.0.0-dev-20220818130906", | ||
"version": "0.0.0-dev-20220818145526", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
5991
107