Socket
Socket
Sign inDemoInstall

@yamada-ui/utils

Package Overview
Dependencies
Maintainers
1
Versions
429
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yamada-ui/utils - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1-dev-20240917033401

dist/chunk-2AWPBKLQ.mjs

2

dist/array.d.ts

@@ -1,3 +0,3 @@

declare const filterEmpty: <T extends any[]>(array: T) => any[];
declare function filterEmpty<T extends any[]>(array: T): any[];
export { filterEmpty };

@@ -26,3 +26,5 @@ "use strict";

module.exports = __toCommonJS(array_exports);
var filterEmpty = (array) => array.filter((value) => value != null);
function filterEmpty(array) {
return array.filter((value) => value != null);
}
// Annotate the CommonJS export names for ESM import in node:

@@ -29,0 +31,0 @@ 0 && (module.exports = {

import { Dict } from './index.types.js';
declare const is: (x: any, y: any) => boolean;
declare const isNumber: (value: any) => value is number;
declare const isNotNumber: (value: any) => boolean;
declare const isNumeric: (value: any) => boolean;
declare const isString: (value: any) => value is string;
declare const isBoolean: (value: any) => value is boolean;
declare const isUndefined: (value: any) => value is undefined;
declare const isNull: (value: any) => value is null;
declare const isObject: <T extends Dict>(value: any) => value is T;
declare const isArray: <T extends any[]>(value: any) => value is T;
declare const isEmpty: (value: any) => boolean;
declare const isFunction: <T extends Function = Function>(value: any) => value is T;
declare const isUnit: (value: any) => boolean;
declare const cast: <T>(value: any) => T;
declare function is(x: any, y: any): boolean;
declare function isNumber(value: any): value is number;
declare function isNotNumber(value: any): boolean;
declare function isNumeric(value: any): boolean;
declare function isString(value: any): value is string;
declare function isBoolean(value: any): value is boolean;
declare function isUndefined(value: any): value is undefined;
declare function isNull(value: any): value is null;
declare function isObject<T extends Dict>(value: any): value is T;
declare function isArray<T extends any[]>(value: any): value is T;
declare function isEmpty(value: any): boolean;
declare function isFunction<T extends Function = Function>(value: any): value is T;
declare function isUnit(value: any): boolean;
declare function cast<T>(value: any): T;
export { cast, is, isArray, isBoolean, isEmpty, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isString, isUndefined, isUnit };

@@ -39,18 +39,46 @@ "use strict";

module.exports = __toCommonJS(assertion_exports);
var is = (x, y) => x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
var isNumber = (value) => typeof value === "number";
var isNotNumber = (value) => typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value);
var isNumeric = (value) => !isNaN(parseFloat(String(value))) && isFinite(Number(value)) && /^-?\d*\.?\d+$/.test(String(value));
var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
var isBoolean = (value) => typeof value === "boolean";
var isUndefined = (value) => typeof value === "undefined" && value === void 0;
var isNull = (value) => value === null;
var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
var isArray = (value) => Array.isArray(value);
var isEmpty = (value) => !isArray(value) || !value.length || value.every((v) => v == null);
var isFunction = (value) => typeof value === "function";
var isUnit = (value) => /[0-9].*(em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cm|mm|Q|in|pc|pt|px|%|cqw|cqh|cqi|cqb|cqmin|cqmax)$/.test(
value
);
var cast = (value) => value;
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
}
function isNumber(value) {
return typeof value === "number";
}
function isNotNumber(value) {
return typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value);
}
function isNumeric(value) {
return !isNaN(parseFloat(String(value))) && isFinite(Number(value)) && /^-?\d*\.?\d+$/.test(String(value));
}
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
function isBoolean(value) {
return typeof value === "boolean";
}
function isUndefined(value) {
return typeof value === "undefined" && value === void 0;
}
function isNull(value) {
return value === null;
}
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
}
function isArray(value) {
return Array.isArray(value);
}
function isEmpty(value) {
return !isArray(value) || !value.length || value.every((v) => v == null);
}
function isFunction(value) {
return typeof value === "function";
}
function isUnit(value) {
return /[0-9].*(em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cm|mm|Q|in|pc|pt|px|%|cqw|cqh|cqi|cqb|cqmin|cqmax)$/.test(
value
);
}
function cast(value) {
return value;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -57,0 +85,0 @@ 0 && (module.exports = {

type Operand = string | number;
type Calc = {
declare function add(...args: Operand[]): string;
declare function subtract(...args: Operand[]): string;
declare function multiply(...args: Operand[]): string;
declare function divide(...args: Operand[]): string;
declare function negate(value: Operand): string;
interface Calc {
add: (...args: Operand[]) => Calc;

@@ -9,11 +14,11 @@ subtract: (...args: Operand[]) => Calc;

toString: () => string;
};
}
declare const calc: ((x: Operand) => Calc) & {
add: (...args: Operand[]) => string;
subtract: (...args: Operand[]) => string;
multiply: (...args: Operand[]) => string;
divide: (...args: Operand[]) => string;
negate: (value: Operand) => string;
add: typeof add;
subtract: typeof subtract;
multiply: typeof multiply;
divide: typeof divide;
negate: typeof negate;
};
export { type Operand, calc };

@@ -26,12 +26,22 @@ "use strict";

module.exports = __toCommonJS(calc_exports);
var toExpression = (operator, ...args) => args.join(` ${operator} `).replace(/calc/g, "");
var add = (...args) => `calc(${toExpression("+", ...args)})`;
var subtract = (...args) => `calc(${toExpression("-", ...args)})`;
var multiply = (...args) => `calc(${toExpression("*", ...args)})`;
var divide = (...args) => `calc(${toExpression("/", ...args)})`;
var negate = (value) => {
function toExpression(operator, ...args) {
return args.join(` ${operator} `).replace(/calc/g, "");
}
function add(...args) {
return `calc(${toExpression("+", ...args)})`;
}
function subtract(...args) {
return `calc(${toExpression("-", ...args)})`;
}
function multiply(...args) {
return `calc(${toExpression("*", ...args)})`;
}
function divide(...args) {
return `calc(${toExpression("/", ...args)})`;
}
function negate(value) {
if (value != null && !isNaN(parseFloat(value.toString())))
return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
return multiply(value, -1);
};
}
var calc = Object.assign(

@@ -38,0 +48,0 @@ (x) => ({

@@ -11,29 +11,29 @@ import { StringLiteral, Dict } from './index.types.js';

declare const TONES: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
declare const isGray: (colorScheme: string) => colorScheme is "gray" | "neutral";
declare const isAccessible: (colorScheme: string) => colorScheme is "yellow" | "lime" | "cyan";
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare const randomColor: ({ string, colors, }?: {
declare function isGray(colorScheme: string): colorScheme is "gray" | "neutral";
declare function isAccessible(colorScheme: string): colorScheme is "yellow" | "lime" | "cyan";
declare function getColor(color: string, fallback?: string): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare function lightenColor(color: string, amount: number): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare function darkenColor(color: string, amount: number): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare function tintColor(color: string, amount: number): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare function shadeColor(color: string, amount: number): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare function transparentizeColor(color: string, alpha: number): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => string;
declare function randomColor({ string, colors, }?: {
string?: string;
colors?: string[];
}) => string;
declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => "light" | "dark";
declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
declare const convertColor: (color: string, fallback?: string) => (format: ColorFormat) => string | undefined;
declare const calcFormat: (color: string) => ColorFormat;
declare const getAlpha: (color: string) => number;
declare const alphaToHex: (a: number) => string;
declare const parseToRgba: (color: string, fallback?: string) => [number, number, number, number] | undefined;
declare const parseToHsla: (color: string, fallback?: string) => [number, number, number, number] | undefined;
declare const parseToHsv: (color: string, fallback?: string) => [number, number, number, number];
declare const rgbaTo: ([r, g, b, a]: [number, number, number, number], fallback?: string) => (format?: ColorFormat) => string | undefined;
declare const hslaTo: ([h, s, l, a]: [number, number, number, number], fallback?: string) => (format?: ColorFormat) => string | undefined;
declare const hsvTo: ([h, s, v, a]: [number, number, number, number?], fallback?: string) => (format?: ColorFormat) => string | undefined;
declare const sameColor: (color: string | undefined, comparison: string | undefined) => boolean;
}): string;
declare function isTone(color: string): (theme?: Dict, colorMode?: ColorMode, breakpoint?: Breakpoint) => "light" | "dark";
declare function isLight(color: string): (theme?: Dict, colorMode?: ColorMode) => boolean;
declare function isDark(color: string): (theme?: Dict, colorMode?: ColorMode) => boolean;
declare function convertColor(color: string, fallback?: string): (format: ColorFormat) => string | undefined;
declare function calcFormat(color: string): ColorFormat;
declare function getAlpha(color: string): number;
declare function alphaToHex(a: number): string;
declare function parseToRgba(color: string, fallback?: string): [number, number, number, number] | undefined;
declare function parseToHsla(color: string, fallback?: string): [number, number, number, number] | undefined;
declare function parseToHsv(color: string, fallback?: string): [number, number, number, number];
declare function rgbaTo([r, g, b, a]: [number, number, number, number], fallback?: string): (format?: ColorFormat) => string | undefined;
declare function hslaTo([h, s, l, a]: [number, number, number, number], fallback?: string): (format?: ColorFormat) => string | undefined;
declare function hsvTo([h, s, v, a]: [number, number, number, number?], fallback?: string): (format?: ColorFormat) => string | undefined;
declare function sameColor(color: string | undefined, comparison: string | undefined): boolean;
export { COLOR_SCHEMES, type ColorFormat, type ColorScheme, SEMANTIC_COLOR_SCHEMES, type SemanticColorScheme, TONES, alphaToHex, calcFormat, convertColor, darkenColor, getAlpha, getColor, hslaTo, hsvTo, isAccessible, isDark, isGray, isLight, isTone, lightenColor, parseToHsla, parseToHsv, parseToRgba, randomColor, rgbaTo, sameColor, shadeColor, tintColor, transparentizeColor };

@@ -64,10 +64,20 @@ "use strict";

// src/assertion.ts
var isNumber = (value) => typeof value === "number";
var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
var isUndefined = (value) => typeof value === "undefined" && value === void 0;
var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
var isArray = (value) => Array.isArray(value);
function isNumber(value) {
return typeof value === "number";
}
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
function isUndefined(value) {
return typeof value === "undefined" && value === void 0;
}
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
}
function isArray(value) {
return Array.isArray(value);
}
// src/object.ts
var getObject = (obj, path, fallback, i) => {
function getObject(obj, path, fallback, i) {
const k = isString(path) ? path.split(/\[(.*?)\]|\./).filter(Boolean) : [path];

@@ -79,6 +89,6 @@ for (i = 0; i < k.length; i += 1) {

return obj === void 0 ? fallback : obj;
};
var memoizeObject = (func) => {
}
function memoizeObject(func) {
const cache = /* @__PURE__ */ new WeakMap();
const memoizedFunc = (obj, path, fallback, i) => {
function memoizedFunc(obj, path, fallback, i) {
if (isUndefined(obj)) return func(obj, path, fallback);

@@ -91,5 +101,5 @@ if (!cache.has(obj)) cache.set(obj, /* @__PURE__ */ new Map());

return value;
};
}
return memoizedFunc;
};
}
var getMemoizedObject = memoizeObject(getObject);

@@ -143,63 +153,79 @@

];
var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
var getColor = (color, fallback = "#000000") => (theme = {}, colorMode = "light", breakpoint = "base") => {
var _a, _b, _c, _d, _e, _f;
const [token, tone] = color.split(".");
if (tone) {
const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _c : [];
if (relatedToken) color = `${relatedToken}.${tone}`;
} else {
const [, relatedColor] = (_f = Object.entries((_e = (_d = theme.semantics) == null ? void 0 : _d.colors) != null ? _e : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _f : [];
if (relatedColor) color = relatedColor;
}
const hex = getMemoizedObject(
theme,
`colors.${color}`,
color
);
try {
if (isArray(hex)) {
return c.toHex(String(hex[colorMode !== "dark" ? 0 : 1]));
} else if (isObject(hex)) {
return c.toHex(String(hex[breakpoint]));
function isGray(colorScheme) {
return colorScheme === "gray" || colorScheme === "neutral";
}
function isAccessible(colorScheme) {
return colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
}
function getColor(color, fallback = "#000000") {
return function(theme = {}, colorMode = "light", breakpoint = "base") {
var _a, _b, _c, _d, _e, _f;
const [token, tone] = color.split(".");
if (tone) {
const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _c : [];
if (relatedToken) color = `${relatedToken}.${tone}`;
} else {
return c.toHex(String(hex));
const [, relatedColor] = (_f = Object.entries((_e = (_d = theme.semantics) == null ? void 0 : _d.colors) != null ? _e : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _f : [];
if (relatedColor) color = relatedColor;
}
} catch {
const hex = getMemoizedObject(
theme,
`colors.${color}`,
color
);
try {
return c.toHex(fallback);
if (isArray(hex)) {
return c.toHex(String(hex[colorMode !== "dark" ? 0 : 1]));
} else if (isObject(hex)) {
return c.toHex(String(hex[breakpoint]));
} else {
return c.toHex(String(hex));
}
} catch {
return "#000000";
try {
return c.toHex(fallback);
} catch {
return "#000000";
}
}
}
};
var lightenColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.lighten(raw, amount / 100));
};
var darkenColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.darken(raw, amount / 100));
};
var tintColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#fff", amount / 100));
};
var shadeColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#000", amount / 100));
};
var transparentizeColor = (color, alpha) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.transparentize(raw, 1 - alpha);
};
var randomColor = ({
};
}
function lightenColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.lighten(raw, amount / 100));
};
}
function darkenColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.darken(raw, amount / 100));
};
}
function tintColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#fff", amount / 100));
};
}
function shadeColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#000", amount / 100));
};
}
function transparentizeColor(color, alpha) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.transparentize(raw, 1 - alpha);
};
}
function randomColor({
string,
colors
} = {}) => {
} = {}) {
const fallback = randomHex();

@@ -210,5 +236,7 @@ if (string && colors) return randomColorFromList(string, colors);

return fallback;
};
var randomHex = () => `#${Math.floor(Math.random() * 16777215).toString(16).padEnd(6, "0")}`;
var randomColorFromString = (str) => {
}
function randomHex() {
return `#${Math.floor(Math.random() * 16777215).toString(16).padEnd(6, "0")}`;
}
function randomColorFromString(str) {
let hash = 0;

@@ -226,4 +254,4 @@ if (str.length === 0) return hash.toString();

return color;
};
var randomColorFromList = (str, list) => {
}
function randomColorFromList(str, list) {
let index = 0;

@@ -237,48 +265,62 @@ if (str.length === 0) return list[0];

return list[index];
};
var randomFromList = (list) => list[Math.floor(Math.random() * list.length)];
var getBrightness = (color) => {
}
function randomFromList(list) {
return list[Math.floor(Math.random() * list.length)];
}
function getBrightness(color) {
const [r, g, b] = c.parseToRgba(color);
return (r * 299 + g * 587 + b * 114) / 1e3;
};
var isTone = (color) => (theme, colorMode, breakpoint) => {
const raw = theme ? getColor(color)(theme, colorMode, breakpoint) : color;
const brightness = getBrightness(raw);
const isDark2 = brightness < 128;
return isDark2 ? "dark" : "light";
};
var isLight = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) === "dark";
var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) === "light";
var convertColor = (color, fallback) => (format) => {
try {
const isAlpha = format.endsWith("a");
if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
if (format.startsWith("hex")) {
let hexa = c.toHex(color);
if (isAlpha) {
if (hexa.length === 7) hexa += "ff";
}
function isTone(color) {
return function(theme, colorMode, breakpoint) {
const raw = theme ? getColor(color)(theme, colorMode, breakpoint) : color;
const brightness = getBrightness(raw);
const isDark2 = brightness < 128;
return isDark2 ? "dark" : "light";
};
}
function isLight(color) {
return function(theme, colorMode) {
return isTone(color)(theme, colorMode) === "dark";
};
}
function isDark(color) {
return function(theme, colorMode) {
return isTone(color)(theme, colorMode) === "light";
};
}
function convertColor(color, fallback) {
return function(format) {
try {
const isAlpha = format.endsWith("a");
if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
if (format.startsWith("hex")) {
let hexa = c.toHex(color);
if (isAlpha) {
if (hexa.length === 7) hexa += "ff";
} else {
hexa = hexa.replace(/(?<=^#([0-9a-fA-F]{6}))[0-9a-fA-F]{2}$/, "");
}
return hexa;
} else if (format.startsWith("hsl")) {
let hsla2 = c.toHsla(color);
if (!isAlpha) {
hsla2 = hsla2.replace(/hsla/, "hsl");
hsla2 = hsla2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return hsla2;
} else {
hexa = hexa.replace(/(?<=^#([0-9a-fA-F]{6}))[0-9a-fA-F]{2}$/, "");
let rgba2 = c.toRgba(color);
if (!isAlpha) {
rgba2 = rgba2.replace(/rgba/, "rgb");
rgba2 = rgba2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return rgba2;
}
return hexa;
} else if (format.startsWith("hsl")) {
let hsla2 = c.toHsla(color);
if (!isAlpha) {
hsla2 = hsla2.replace(/hsla/, "hsl");
hsla2 = hsla2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return hsla2;
} else {
let rgba2 = c.toRgba(color);
if (!isAlpha) {
rgba2 = rgba2.replace(/rgba/, "rgb");
rgba2 = rgba2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return rgba2;
} catch {
if (fallback) return convertColor(fallback)(format);
}
} catch {
if (fallback) return convertColor(fallback)(format);
}
};
var calcFormat = (color) => {
};
}
function calcFormat(color) {
if (color.startsWith("hsl")) {

@@ -291,10 +333,12 @@ return color.startsWith("hsla") ? "hsla" : "hsl";

}
};
var getAlpha = (color) => c.parseToRgba(color)[3];
var alphaToHex = (a) => {
}
function getAlpha(color) {
return c.parseToRgba(color)[3];
}
function alphaToHex(a) {
if (0 > a) a = 0;
if (1 < a) a = 1;
return Math.round(a * 255).toString(16).padStart(2, "0");
};
var parseToRgba2 = (color, fallback) => {
}
function parseToRgba2(color, fallback) {
try {

@@ -306,4 +350,4 @@ if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;

}
};
var parseToHsla2 = (color, fallback) => {
}
function parseToHsla2(color, fallback) {
try {

@@ -315,4 +359,4 @@ if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;

}
};
var parseToHsv = (color, fallback) => {
}
function parseToHsv(color, fallback) {
var _a;

@@ -341,39 +385,49 @@ let [r, g, b, a] = (_a = parseToRgba2(color, fallback)) != null ? _a : [255, 255, 255, 1];

return [h, s, v, a];
};
var rgbaTo = ([r, g, b, a], fallback) => (format = "hex") => convertColor(c.rgba(r, g, b, a), fallback)(format);
var hslaTo = ([h, s, l, a], fallback) => (format = "hex") => convertColor(c.hsla(h, s, l, a), fallback)(format);
var hsvTo = ([h, s, v, a], fallback) => (format = "hex") => {
h = h / 60;
let rgb = [v, v, v];
let i = Math.floor(h);
let f = h - i;
let p = v * (1 - s);
let q = v * (1 - s * f);
let t = v * (1 - s * (1 - f));
switch (i) {
case 0:
case 6:
rgb = [v, t, p];
break;
case 1:
rgb = [q, v, p];
break;
case 2:
rgb = [p, v, t];
break;
case 3:
rgb = [p, q, v];
break;
case 4:
rgb = [t, p, v];
break;
case 5:
rgb = [v, p, q];
break;
}
let color = `rgb(${rgb.map((v2) => Math.round(v2 * 255)).join(", ")})`;
if (isNumber(a)) color = color.replace(/\)$/, `, ${a})`);
return convertColor(color, fallback)(format);
};
var sameColor = (color, comparison) => {
}
function rgbaTo([r, g, b, a], fallback) {
return function(format = "hex") {
return convertColor(c.rgba(r, g, b, a), fallback)(format);
};
}
function hslaTo([h, s, l, a], fallback) {
return function(format = "hex") {
return convertColor(c.hsla(h, s, l, a), fallback)(format);
};
}
function hsvTo([h, s, v, a], fallback) {
return function(format = "hex") {
h = h / 60;
let rgb = [v, v, v];
let i = Math.floor(h);
let f = h - i;
let p = v * (1 - s);
let q = v * (1 - s * f);
let t = v * (1 - s * (1 - f));
switch (i) {
case 0:
case 6:
rgb = [v, t, p];
break;
case 1:
rgb = [q, v, p];
break;
case 2:
rgb = [p, v, t];
break;
case 3:
rgb = [p, q, v];
break;
case 4:
rgb = [t, p, v];
break;
case 5:
rgb = [v, p, q];
break;
}
let color = `rgb(${rgb.map((v2) => Math.round(v2 * 255)).join(", ")})`;
if (isNumber(a)) color = color.replace(/\)$/, `, ${a})`);
return convertColor(color, fallback)(format);
};
}
function sameColor(color, comparison) {
var _a, _b;

@@ -385,3 +439,3 @@ if (!color) return false;

return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
};
}
// Annotate the CommonJS export names for ESM import in node:

@@ -388,0 +442,0 @@ 0 && (module.exports = {

import React__default from 'react';
declare const createdDom: () => boolean;
declare const getPlatform: () => string;
declare const vendor: (v: RegExp) => boolean;
declare const platform: (v: RegExp) => boolean;
declare const isMac: () => boolean;
declare const isApple: () => boolean;
declare const isSafari: () => boolean;
declare const isElement: (el: any) => el is Element;
declare const isHTMLElement: (el: any) => el is HTMLElement;
declare const isHidden: (el: HTMLElement) => boolean;
declare const isDisabled: (el: HTMLElement) => boolean;
declare const hasTabIndex: (el: HTMLElement) => boolean;
declare const isContentEditable: (el: HTMLElement) => boolean;
declare const isContains: (parent: HTMLElement | null, child: HTMLElement | null) => boolean | undefined;
declare const getPx: (value: string | number | undefined) => number;
declare const getEventRelatedTarget: (ev: React__default.FocusEvent | React__default.MouseEvent) => HTMLElement | null;
declare function createdDom(): boolean;
declare function getPlatform(): string;
declare function vendor(v: RegExp): boolean;
declare function platform(v: RegExp): boolean;
declare function isMac(): boolean;
declare function isApple(): boolean;
declare function isSafari(): boolean;
declare function isElement(el: any): el is Element;
declare function isHTMLElement(el: any): el is HTMLElement;
declare function isHidden(el: HTMLElement): boolean;
declare function isDisabled(el: HTMLElement): boolean;
declare function hasTabIndex(el: HTMLElement): boolean;
declare function isContentEditable(el: HTMLElement): boolean;
declare function isContains(parent: HTMLElement | null, child: HTMLElement | null): boolean | undefined;
declare function getPx(value: string | number | undefined): number;
declare function getEventRelatedTarget(ev: React__default.FocusEvent | React__default.MouseEvent): HTMLElement | null;
type Booleanish = boolean | "true" | "false";
declare const dataAttr: (condition: boolean | undefined) => Booleanish;
declare const ariaAttr: (condition: boolean | undefined) => boolean | undefined;
type FocusableElement = {
declare function dataAttr(condition: boolean | undefined): Booleanish;
declare function ariaAttr(condition: boolean | undefined): boolean | undefined;
interface FocusableElement {
focus: (options?: FocusOptions) => void;
};
declare const getAllFocusable: <T extends HTMLElement>(container: T) => T[];
declare const isFocusable: (el: HTMLElement) => boolean;
declare const hasNegativeTabIndex: (el: HTMLElement) => boolean;
declare const isTabbable: (el?: HTMLElement | null) => boolean;
declare const isTouchDevice: () => boolean;
declare const getOwnerWindow: (node?: Element | null) => Window & typeof globalThis;
declare const getOwnerDocument: (el?: Element | null) => Document;
declare const getActiveElement: (el?: HTMLElement) => HTMLElement;
declare const isActiveElement: (el: HTMLElement) => boolean;
}
declare function getAllFocusable<T extends HTMLElement>(container: T): T[];
declare function isFocusable(el: HTMLElement): boolean;
declare function hasNegativeTabIndex(el: HTMLElement): boolean;
declare function isTabbable(el?: HTMLElement | null): boolean;
declare function isTouchDevice(): boolean;
declare function getOwnerWindow(node?: Element | null): Window & typeof globalThis;
declare function getOwnerDocument(el?: Element | null): Document;
declare function getActiveElement(el?: HTMLElement): HTMLElement;
declare function isActiveElement(el: HTMLElement): boolean;
export { type FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, getPx, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, isTouchDevice, platform, vendor };

@@ -54,18 +54,36 @@ "use strict";

// src/assertion.ts
var isNumber = (value) => typeof value === "number";
var isUndefined = (value) => typeof value === "undefined" && value === void 0;
function isNumber(value) {
return typeof value === "number";
}
function isUndefined(value) {
return typeof value === "undefined" && value === void 0;
}
// src/dom.ts
var createdDom = () => !!(typeof window !== "undefined" && window.document && window.document.createElement);
var getPlatform = () => {
function createdDom() {
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
}
function getPlatform() {
var _a, _b;
return (_b = (_a = navigator.userAgentData) == null ? void 0 : _a.platform) != null ? _b : navigator.platform;
};
var vendor = (v) => createdDom() && v.test(navigator.vendor);
var platform = (v) => createdDom() && v.test(getPlatform());
var isMac = () => platform(/^mac/i);
var isApple = () => platform(/mac|iphone|ipad|ipod/i);
var isSafari = () => isApple() && vendor(/apple/i);
var isElement = (el) => el != null && typeof el == "object" && "nodeType" in el && el.nodeType === Node.ELEMENT_NODE;
var isHTMLElement = (el) => {
}
function vendor(v) {
return createdDom() && v.test(navigator.vendor);
}
function platform(v) {
return createdDom() && v.test(getPlatform());
}
function isMac() {
return platform(/^mac/i);
}
function isApple() {
return platform(/mac|iphone|ipad|ipod/i);
}
function isSafari() {
return isApple() && vendor(/apple/i);
}
function isElement(el) {
return el != null && typeof el == "object" && "nodeType" in el && el.nodeType === Node.ELEMENT_NODE;
}
function isHTMLElement(el) {
var _a;

@@ -75,18 +93,24 @@ if (!isElement(el)) return false;

return el instanceof win.HTMLElement;
};
var isHidden = (el) => {
}
function isHidden(el) {
if (el.parentElement && isHidden(el.parentElement)) return true;
return el.hidden;
};
var isDisabled = (el) => Boolean(el.getAttribute("disabled")) === true || Boolean(el.getAttribute("data-disabled")) === true || Boolean(el.getAttribute("aria-disabled")) === true;
var isVisible = (el) => el.offsetWidth > 0 && el.offsetHeight > 0;
var hasTabIndex = (el) => el.hasAttribute("tabindex");
var isContentEditable = (el) => {
}
function isDisabled(el) {
return Boolean(el.getAttribute("disabled")) === true || Boolean(el.getAttribute("data-disabled")) === true || Boolean(el.getAttribute("aria-disabled")) === true;
}
function isVisible(el) {
return el.offsetWidth > 0 && el.offsetHeight > 0;
}
function hasTabIndex(el) {
return el.hasAttribute("tabindex");
}
function isContentEditable(el) {
const value = el.getAttribute("contenteditable");
return value !== "false" && value != null;
};
var isContains = (parent, child) => {
}
function isContains(parent, child) {
return parent === child || (parent == null ? void 0 : parent.contains(child));
};
var getPx = (value) => {
}
function getPx(value) {
if (isNumber(value)) return value;

@@ -103,9 +127,13 @@ if (isUndefined(value)) return 0;

return parseFloat(value) * fontSize;
};
var getEventRelatedTarget = (ev) => {
}
function getEventRelatedTarget(ev) {
var _a;
return (_a = ev.relatedTarget) != null ? _a : ev.currentTarget.ownerDocument.activeElement;
};
var dataAttr = (condition) => condition ? "" : void 0;
var ariaAttr = (condition) => condition ? true : void 0;
}
function dataAttr(condition) {
return condition ? "" : void 0;
}
function ariaAttr(condition) {
return condition ? true : void 0;
}
var focusableElList = [

@@ -128,3 +156,3 @@ "input:not(:disabled):not([disabled])",

var focusableElSelector = focusableElList.join();
var getAllFocusable = (container) => {
function getAllFocusable(container) {
const focusableEls = Array.from(

@@ -135,4 +163,4 @@ container.querySelectorAll(focusableElSelector)

return focusableEls.filter((el) => isFocusable(el) && isVisible(el));
};
var isFocusable = (el) => {
}
function isFocusable(el) {
if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) {

@@ -152,15 +180,25 @@ return false;

return hasTabIndex(el);
};
var hasNegativeTabIndex = (el) => hasTabIndex(el) && el.tabIndex === -1;
var isTabbable = (el) => el ? isHTMLElement(el) && isFocusable(el) && !hasNegativeTabIndex(el) : false;
var isTouchDevice = () => "ontouchstart" in window;
var getOwnerWindow = (node) => {
}
function hasNegativeTabIndex(el) {
return hasTabIndex(el) && el.tabIndex === -1;
}
function isTabbable(el) {
return el ? isHTMLElement(el) && isFocusable(el) && !hasNegativeTabIndex(el) : false;
}
function isTouchDevice() {
return "ontouchstart" in window;
}
function getOwnerWindow(node) {
var _a, _b;
return (_b = (_a = getOwnerDocument(node)) == null ? void 0 : _a.defaultView) != null ? _b : window;
};
var getOwnerDocument = (el) => isElement(el) ? el.ownerDocument : document;
var getActiveElement = (el) => getOwnerDocument(el).activeElement;
var isActiveElement = (el) => {
}
function getOwnerDocument(el) {
return isElement(el) ? el.ownerDocument : document;
}
function getActiveElement(el) {
return getOwnerDocument(el).activeElement;
}
function isActiveElement(el) {
return getActiveElement(el) === el;
};
}
// Annotate the CommonJS export names for ESM import in node:

@@ -167,0 +205,0 @@ 0 && (module.exports = {

type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent;
type PointType = "page" | "client";
type Point = {
interface Point {
x: number;
y: number;
};
type PointerEventInfo = {
}
interface PointerEventInfo {
point: Point;
};
}
type MixedEventListener = (e: AnyPointerEvent, info: PointerEventInfo) => void;
declare const isMouseEvent: (ev: any) => ev is MouseEvent;
declare const isTouchEvent: (ev: AnyPointerEvent) => ev is TouchEvent;
declare const isMultiTouchEvent: (ev: AnyPointerEvent) => boolean;
declare const getEventWindow: (ev: Event) => typeof globalThis;
declare const pointFromTouch: (e: TouchEvent, type?: PointType) => {
declare function isMouseEvent(ev: any): ev is MouseEvent;
declare function isTouchEvent(ev: AnyPointerEvent): ev is TouchEvent;
declare function isMultiTouchEvent(ev: AnyPointerEvent): boolean;
declare function getEventWindow(ev: Event): typeof globalThis;
declare function pointFromTouch(e: TouchEvent, type?: PointType): {
x: number;
y: number;
};
declare const pointFromMouse: (point: MouseEvent | PointerEvent, type?: PointType) => {
declare function pointFromMouse(point: MouseEvent | PointerEvent, type?: PointType): {
x: number;
y: number;
};
declare const getEventPoint: (ev: AnyPointerEvent, type?: PointType) => {
declare function getEventPoint(ev: AnyPointerEvent, type?: PointType): {
x: number;
y: number;
};
declare const addDomEvent: (target: EventTarget, type: string, cb: EventListener, options?: AddEventListenerOptions) => () => void;
declare const addPointerEvent: (target: EventTarget, type: string, cb: MixedEventListener, options?: AddEventListenerOptions) => () => void;
declare function addDomEvent(target: EventTarget, type: string, cb: EventListener, options?: AddEventListenerOptions): () => void;
declare function addPointerEvent(target: EventTarget, type: string, cb: MixedEventListener, options?: AddEventListenerOptions): () => void;
export { type AnyPointerEvent, type MixedEventListener, type Point, type PointType, type PointerEventInfo, addDomEvent, addPointerEvent, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };

@@ -34,3 +34,3 @@ "use strict";

module.exports = __toCommonJS(event_exports);
var isMouseEvent = (ev) => {
function isMouseEvent(ev) {
const win = getEventWindow(ev);

@@ -40,19 +40,27 @@ if (typeof win.PointerEvent !== "undefined" && ev instanceof win.PointerEvent)

return ev instanceof win.MouseEvent;
};
var isTouchEvent = (ev) => !!ev.touches;
var isMultiTouchEvent = (ev) => isTouchEvent(ev) && ev.touches.length > 1;
var getEventWindow = (ev) => {
}
function isTouchEvent(ev) {
return !!ev.touches;
}
function isMultiTouchEvent(ev) {
return isTouchEvent(ev) && ev.touches.length > 1;
}
function getEventWindow(ev) {
var _a;
return (_a = ev.view) != null ? _a : window;
};
var pointFromTouch = (e, type = "page") => {
}
function pointFromTouch(e, type = "page") {
const point = e.touches[0] || e.changedTouches[0];
return { x: point[`${type}X`], y: point[`${type}Y`] };
};
var pointFromMouse = (point, type = "page") => ({
x: point[`${type}X`],
y: point[`${type}Y`]
});
var getEventPoint = (ev, type = "page") => isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type);
var addDomEvent = (target, type, cb, options) => {
}
function pointFromMouse(point, type = "page") {
return {
x: point[`${type}X`],
y: point[`${type}Y`]
};
}
function getEventPoint(ev, type = "page") {
return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type);
}
function addDomEvent(target, type, cb, options) {
target.addEventListener(type, cb, options);

@@ -62,13 +70,19 @@ return () => {

};
};
var filter = (cb) => (ev) => {
const isMouse = isMouseEvent(ev);
if (!isMouse || isMouse && ev.button === 0) cb(ev);
};
var wrap = (cb, filterPrimary = false) => {
const listener = (ev) => cb(ev, { point: getEventPoint(ev) });
}
function filter(cb) {
return function(ev) {
const isMouse = isMouseEvent(ev);
if (!isMouse || isMouse && ev.button === 0) cb(ev);
};
}
function wrap(cb, filterPrimary = false) {
function listener(ev) {
return cb(ev, { point: getEventPoint(ev) });
}
const fn = filterPrimary ? filter(listener) : listener;
return fn;
};
var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
}
function addPointerEvent(target, type, cb, options) {
return addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
}
// Annotate the CommonJS export names for ESM import in node:

@@ -75,0 +89,0 @@ 0 && (module.exports = {

declare const noop: () => void;
declare const runIfFunc: <T, U extends Array<any>>(valOrFunc: T | ((...funcArgs: U) => T), ...args: U) => T;
declare const handlerAll: <T extends (event: any, ...args: any[]) => void>(...funcs: (T | undefined)[]) => (event: T extends (event: infer R, ...args: any[]) => any ? R : never, ...args: T extends (event: any, ...args: infer R) => any ? R : never) => void;
declare const funcAll: <T extends (...args: any[]) => any>(...funcs: (T | undefined)[]) => (...args: T extends (...args: infer R) => any ? R : never) => void;
declare function runIfFunc<T, U extends any[]>(valOrFunc: T | ((...funcArgs: U) => T), ...args: U): T;
declare function handlerAll<T extends (event: any, ...args: any[]) => void>(...funcs: (T | undefined)[]): (event: T extends (event: infer R, ...args: any[]) => any ? R : never, ...args: T extends (event: any, ...args: infer R) => any ? R : never) => void;
declare function funcAll<T extends (...args: any[]) => any>(...funcs: (T | undefined)[]): (...args: T extends (...args: infer R) => any ? R : never) => void;
export { funcAll, handlerAll, noop, runIfFunc };

@@ -31,3 +31,5 @@ "use strict";

// src/assertion.ts
var isFunction = (value) => typeof value === "function";
function isFunction(value) {
return typeof value === "function";
}

@@ -37,10 +39,18 @@ // src/function.ts

};
var runIfFunc = (valOrFunc, ...args) => isFunction(valOrFunc) ? valOrFunc(...args) : valOrFunc;
var handlerAll = (...funcs) => (event, ...args) => {
funcs.some((func) => {
func == null ? void 0 : func(event, ...args);
return event == null ? void 0 : event.defaultPrevented;
});
};
var funcAll = (...funcs) => (...args) => funcs.forEach((func) => func == null ? void 0 : func(...args));
function runIfFunc(valOrFunc, ...args) {
return isFunction(valOrFunc) ? valOrFunc(...args) : valOrFunc;
}
function handlerAll(...funcs) {
return function(event, ...args) {
funcs.some((func) => {
func == null ? void 0 : func(event, ...args);
return event == null ? void 0 : event.defaultPrevented;
});
};
}
function funcAll(...funcs) {
return function(...args) {
return funcs.forEach((func) => func == null ? void 0 : func(...args));
};
}
// Annotate the CommonJS export names for ESM import in node:

@@ -47,0 +57,0 @@ 0 && (module.exports = {

@@ -5,3 +5,3 @@ export { Dict, Length, Merge, MergeIfDefined, ObjectLiteral, Path, Primitive, StringLiteral, Union } from './index.types.js';

export { funcAll, handlerAll, noop, runIfFunc } from './function.js';
export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionReturningPromise, MaybeRenderProp, PromiseType, PropGetter, RequiredPropGetter, UseIsMountedProps, UseIsMountedReturn, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.js';
export { AsyncFnReturn, AsyncState, AsyncStateRetry, FunctionReturningPromise, MaybeRenderProp, PromiseType, UseIsMountedProps, UseIsMountedReturn, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.js';
export { FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, getPx, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, isTouchDevice, platform, vendor } from './dom.js';

@@ -8,0 +8,0 @@ export { antonym, escape, toCamelCase, toKebabCase, toTitleCase } from './string.js';

@@ -167,21 +167,49 @@ "use strict";

// src/assertion.ts
var is = (x, y) => x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
var isNumber = (value) => typeof value === "number";
var isNotNumber = (value) => typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value);
var isNumeric = (value) => !isNaN(parseFloat(String(value))) && isFinite(Number(value)) && /^-?\d*\.?\d+$/.test(String(value));
var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
var isBoolean = (value) => typeof value === "boolean";
var isUndefined = (value) => typeof value === "undefined" && value === void 0;
var isNull = (value) => value === null;
var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
var isArray = (value) => Array.isArray(value);
var isEmpty = (value) => !isArray(value) || !value.length || value.every((v) => v == null);
var isFunction = (value) => typeof value === "function";
var isUnit = (value) => /[0-9].*(em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cm|mm|Q|in|pc|pt|px|%|cqw|cqh|cqi|cqb|cqmin|cqmax)$/.test(
value
);
var cast = (value) => value;
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
}
function isNumber(value) {
return typeof value === "number";
}
function isNotNumber(value) {
return typeof value !== "number" || Number.isNaN(value) || !Number.isFinite(value);
}
function isNumeric(value) {
return !isNaN(parseFloat(String(value))) && isFinite(Number(value)) && /^-?\d*\.?\d+$/.test(String(value));
}
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
function isBoolean(value) {
return typeof value === "boolean";
}
function isUndefined(value) {
return typeof value === "undefined" && value === void 0;
}
function isNull(value) {
return value === null;
}
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
}
function isArray(value) {
return Array.isArray(value);
}
function isEmpty(value) {
return !isArray(value) || !value.length || value.every((v) => v == null);
}
function isFunction(value) {
return typeof value === "function";
}
function isUnit(value) {
return /[0-9].*(em|rem|ex|rex|cap|rcap|ch|rch|ic|ric|lh|rlh|vw|svw|lvw|dvw|vh|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax|cm|mm|Q|in|pc|pt|px|%|cqw|cqh|cqi|cqb|cqmin|cqmax)$/.test(
value
);
}
function cast(value) {
return value;
}
// src/object.ts
var omitObjectHelper = (obj, path) => {
function omitObjectHelper(obj, path) {
if (!path.length) return obj;

@@ -200,4 +228,4 @@ const [primaryKey, ...restKeys] = path;

return obj;
};
var omitObject = (obj, keys) => {
}
function omitObject(obj, keys) {
return keys.reduce((prev, key) => {

@@ -207,18 +235,20 @@ const path = isString(key) ? key.split(".") : [];

}, obj);
};
var pickObject = (obj, keys, fallbackValue = "__fallback") => keys.reduce((prev, key) => {
const path = isString(key) ? key.split(".") : [];
if (!path.length) return prev;
const value = getMemoizedObject(obj, key, fallbackValue);
if (value === fallbackValue) return prev;
prev = merge(
prev,
path.reduceRight(
(prev2, key2) => ({ [key2]: key2 === path.at(-1) ? value : prev2 }),
{}
)
);
return prev;
}, {});
var splitObject = (obj, keys) => {
}
function pickObject(obj, keys, fallbackValue = "__fallback") {
return keys.reduce((prev, key) => {
const path = isString(key) ? key.split(".") : [];
if (!path.length) return prev;
const value = getMemoizedObject(obj, key, fallbackValue);
if (value === fallbackValue) return prev;
prev = merge(
prev,
path.reduceRight(
(prev2, key2) => ({ [key2]: key2 === path.at(-1) ? value : prev2 }),
{}
)
);
return prev;
}, {});
}
function splitObject(obj, keys) {
const picked = {};

@@ -234,4 +264,4 @@ const omitted = {};

return [picked, omitted];
};
var filterObject = (obj, func) => {
}
function filterObject(obj, func) {
const result = {};

@@ -243,5 +273,7 @@ Object.entries(obj).forEach(([key, value]) => {

return result;
};
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
var merge = (target, source, mergeArray = false) => {
}
function filterUndefined(obj) {
return filterObject(obj, (_, val) => val !== null && val !== void 0);
}
function merge(target, source, mergeArray = false) {
let result = Object.assign({}, target);

@@ -265,4 +297,4 @@ if (isObject(source)) {

return result;
};
var flattenObject = (obj, { maxDepth, omitKeys, separator, shouldProcess } = {}) => {
}
function flattenObject(obj, { maxDepth, omitKeys, separator, shouldProcess } = {}) {
maxDepth != null ? maxDepth : maxDepth = Infinity;

@@ -289,9 +321,13 @@ omitKeys != null ? omitKeys : omitKeys = [];

}, {});
};
var objectFromEntries = (entries) => entries.reduce((result, [key, value]) => {
result[key] = value;
return result;
}, {});
var keysFormObject = (obj) => Object.keys(obj);
var replaceObject = (objOrArray, callBack) => {
}
function objectFromEntries(entries) {
return entries.reduce((result, [key, value]) => {
result[key] = value;
return result;
}, {});
}
function keysFormObject(obj) {
return Object.keys(obj);
}
function replaceObject(objOrArray, callBack) {
if (isArray(objOrArray)) {

@@ -307,4 +343,4 @@ return objOrArray.map(callBack);

}
};
var getObject = (obj, path, fallback, i) => {
}
function getObject(obj, path, fallback, i) {
const k = isString(path) ? path.split(/\[(.*?)\]|\./).filter(Boolean) : [path];

@@ -316,6 +352,6 @@ for (i = 0; i < k.length; i += 1) {

return obj === void 0 ? fallback : obj;
};
var memoizeObject = (func) => {
}
function memoizeObject(func) {
const cache = /* @__PURE__ */ new WeakMap();
const memoizedFunc = (obj, path, fallback, i) => {
function memoizedFunc(obj, path, fallback, i) {
if (isUndefined(obj)) return func(obj, path, fallback);

@@ -328,7 +364,7 @@ if (!cache.has(obj)) cache.set(obj, /* @__PURE__ */ new Map());

return value;
};
}
return memoizedFunc;
};
}
var getMemoizedObject = memoizeObject(getObject);
var assignAfter = (target, ...sources) => {
function assignAfter(target, ...sources) {
if (target == null)

@@ -346,3 +382,3 @@ throw new TypeError("Cannot convert undefined or null to object");

return result;
};
}

@@ -352,14 +388,22 @@ // src/function.ts

};
var runIfFunc = (valOrFunc, ...args) => isFunction(valOrFunc) ? valOrFunc(...args) : valOrFunc;
var handlerAll = (...funcs) => (event, ...args) => {
funcs.some((func) => {
func == null ? void 0 : func(event, ...args);
return event == null ? void 0 : event.defaultPrevented;
});
};
var funcAll = (...funcs) => (...args) => funcs.forEach((func) => func == null ? void 0 : func(...args));
function runIfFunc(valOrFunc, ...args) {
return isFunction(valOrFunc) ? valOrFunc(...args) : valOrFunc;
}
function handlerAll(...funcs) {
return function(event, ...args) {
funcs.some((func) => {
func == null ? void 0 : func(event, ...args);
return event == null ? void 0 : event.defaultPrevented;
});
};
}
function funcAll(...funcs) {
return function(...args) {
return funcs.forEach((func) => func == null ? void 0 : func(...args));
};
}
// src/react.tsx
var React = __toESM(require("react"));
var createContext2 = ({
function createContext2({
strict = true,

@@ -369,3 +413,3 @@ errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider",

defaultValue
} = {}) => {
} = {}) {
const Context = React.createContext(defaultValue);

@@ -389,12 +433,11 @@ Context.displayName = name;

];
};
}
var useSafeLayoutEffect = Boolean(globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : React.useEffect;
var useUnmountEffect = (callback) => (
// eslint-disable-next-line react-hooks/exhaustive-deps
React.useEffect(() => () => callback(), [])
);
var useIsMounted = ({
function useUnmountEffect(callback) {
return React.useEffect(() => () => callback(), []);
}
function useIsMounted({
rerender = false,
delay = 0
} = {}) => {
} = {}) {
const isMountedRef = React.useRef(false);

@@ -419,20 +462,36 @@ const [isMounted, setIsMounted] = React.useState(false);

return [React.useCallback(() => isMountedRef.current, []), isMounted];
};
var getValidChildren = (children) => React.Children.toArray(children).filter(
(child) => React.isValidElement(child)
);
var isValidElement2 = (child) => React.isValidElement(child) || isString(child) || isNumber(child);
var findChildren = (children, ...types) => children.find((child) => types.some((type) => child.type === type)) ? children.sort(
(a, b) => types.some((type) => a.type === type) ? -1 : types.some((type) => b.type === type) ? 1 : 0
) : [void 0, ...children];
var includesChildren = (children, ...types) => children.some((child) => {
if (types.some((type) => child.type === type)) return true;
const children2 = getValidChildren(child.props.children);
return children2.length ? includesChildren(children2, ...types) : false;
});
var omitChildren = (children, ...types) => children.filter((child) => types.every((type) => child.type !== type));
var pickChildren = (children, ...types) => children.filter((child) => types.every((type) => child.type === type));
var cx = (...classNames) => classNames.filter(Boolean).join(" ");
var isRefObject = (val) => isObject(val) && "current" in val;
var assignRef = (ref, value) => {
}
function getValidChildren(children) {
return React.Children.toArray(children).filter(
(child) => React.isValidElement(child)
);
}
function isValidElement2(child) {
return React.isValidElement(child) || isString(child) || isNumber(child);
}
function findChildren(children, ...types) {
return children.find((child) => types.some((type) => child.type === type)) ? children.sort(
(a, b) => types.some((type) => a.type === type) ? -1 : types.some((type) => b.type === type) ? 1 : 0
) : [void 0, ...children];
}
function includesChildren(children, ...types) {
return children.some((child) => {
if (types.some((type) => child.type === type)) return true;
const children2 = getValidChildren(child.props.children);
return children2.length ? includesChildren(children2, ...types) : false;
});
}
function omitChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type !== type));
}
function pickChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type === type));
}
function cx(...classNames) {
return classNames.filter(Boolean).join(" ");
}
function isRefObject(val) {
return isObject(val) && "current" in val;
}
function assignRef(ref, value) {
if (ref == null) return;

@@ -448,10 +507,14 @@ if (typeof ref === "function") {

}
};
var mergeRefs = (...refs) => (node) => {
refs.forEach((ref) => {
assignRef(ref, node);
});
};
var useMergeRefs = (...refs) => React.useMemo(() => mergeRefs(...refs), [refs]);
var useCallbackRef = (callback, deps = []) => {
}
function mergeRefs(...refs) {
return function(node) {
return refs.forEach((ref) => {
assignRef(ref, node);
});
};
}
function useMergeRefs(...refs) {
return React.useMemo(() => mergeRefs(...refs), [refs]);
}
function useCallbackRef(callback, deps = []) {
const callbackRef = React.useRef(callback);

@@ -468,4 +531,4 @@ React.useEffect(() => {

);
};
var useUpdateEffect = (callback, deps) => {
}
function useUpdateEffect(callback, deps) {
const renderCycleRef = React.useRef(false);

@@ -485,4 +548,4 @@ const effectCycleRef = React.useRef(false);

}, []);
};
var useAsync = (func, deps = []) => {
}
function useAsync(func, deps = []) {
const [state, callback] = useAsyncFunc(func, deps, { loading: true });

@@ -493,4 +556,4 @@ React.useEffect(() => {

return state;
};
var useAsyncFunc = (func, deps = [], initialState = { loading: false }) => {
}
function useAsyncFunc(func, deps = [], initialState = { loading: false }) {
const lastCallId = React.useRef(0);

@@ -521,4 +584,4 @@ const [isMounted] = useIsMounted();

return [state, callback];
};
var useAsyncRetry = (func, deps = []) => {
}
function useAsyncRetry(func, deps = []) {
const [attempt, setAttempt] = React.useState(0);

@@ -532,19 +595,35 @@ const state = useAsync(func, [...deps, attempt]);

return { ...state, retry };
};
}
var createIdCounter = 0;
var createId = (prefix) => `${prefix}-${++createIdCounter}-${(/* @__PURE__ */ new Date()).getTime()}`;
function createId(prefix) {
return `${prefix}-${++createIdCounter}-${(/* @__PURE__ */ new Date()).getTime()}`;
}
// src/dom.ts
var createdDom = () => !!(typeof window !== "undefined" && window.document && window.document.createElement);
var getPlatform = () => {
function createdDom() {
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
}
function getPlatform() {
var _a, _b;
return (_b = (_a = navigator.userAgentData) == null ? void 0 : _a.platform) != null ? _b : navigator.platform;
};
var vendor = (v) => createdDom() && v.test(navigator.vendor);
var platform = (v) => createdDom() && v.test(getPlatform());
var isMac = () => platform(/^mac/i);
var isApple = () => platform(/mac|iphone|ipad|ipod/i);
var isSafari = () => isApple() && vendor(/apple/i);
var isElement = (el) => el != null && typeof el == "object" && "nodeType" in el && el.nodeType === Node.ELEMENT_NODE;
var isHTMLElement = (el) => {
}
function vendor(v) {
return createdDom() && v.test(navigator.vendor);
}
function platform(v) {
return createdDom() && v.test(getPlatform());
}
function isMac() {
return platform(/^mac/i);
}
function isApple() {
return platform(/mac|iphone|ipad|ipod/i);
}
function isSafari() {
return isApple() && vendor(/apple/i);
}
function isElement(el) {
return el != null && typeof el == "object" && "nodeType" in el && el.nodeType === Node.ELEMENT_NODE;
}
function isHTMLElement(el) {
var _a;

@@ -554,18 +633,24 @@ if (!isElement(el)) return false;

return el instanceof win.HTMLElement;
};
var isHidden = (el) => {
}
function isHidden(el) {
if (el.parentElement && isHidden(el.parentElement)) return true;
return el.hidden;
};
var isDisabled = (el) => Boolean(el.getAttribute("disabled")) === true || Boolean(el.getAttribute("data-disabled")) === true || Boolean(el.getAttribute("aria-disabled")) === true;
var isVisible = (el) => el.offsetWidth > 0 && el.offsetHeight > 0;
var hasTabIndex = (el) => el.hasAttribute("tabindex");
var isContentEditable = (el) => {
}
function isDisabled(el) {
return Boolean(el.getAttribute("disabled")) === true || Boolean(el.getAttribute("data-disabled")) === true || Boolean(el.getAttribute("aria-disabled")) === true;
}
function isVisible(el) {
return el.offsetWidth > 0 && el.offsetHeight > 0;
}
function hasTabIndex(el) {
return el.hasAttribute("tabindex");
}
function isContentEditable(el) {
const value = el.getAttribute("contenteditable");
return value !== "false" && value != null;
};
var isContains = (parent, child) => {
}
function isContains(parent, child) {
return parent === child || (parent == null ? void 0 : parent.contains(child));
};
var getPx = (value) => {
}
function getPx(value) {
if (isNumber(value)) return value;

@@ -582,9 +667,13 @@ if (isUndefined(value)) return 0;

return parseFloat(value) * fontSize;
};
var getEventRelatedTarget = (ev) => {
}
function getEventRelatedTarget(ev) {
var _a;
return (_a = ev.relatedTarget) != null ? _a : ev.currentTarget.ownerDocument.activeElement;
};
var dataAttr = (condition) => condition ? "" : void 0;
var ariaAttr = (condition) => condition ? true : void 0;
}
function dataAttr(condition) {
return condition ? "" : void 0;
}
function ariaAttr(condition) {
return condition ? true : void 0;
}
var focusableElList = [

@@ -607,3 +696,3 @@ "input:not(:disabled):not([disabled])",

var focusableElSelector = focusableElList.join();
var getAllFocusable = (container) => {
function getAllFocusable(container) {
const focusableEls = Array.from(

@@ -614,4 +703,4 @@ container.querySelectorAll(focusableElSelector)

return focusableEls.filter((el) => isFocusable(el) && isVisible(el));
};
var isFocusable = (el) => {
}
function isFocusable(el) {
if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) {

@@ -631,19 +720,31 @@ return false;

return hasTabIndex(el);
};
var hasNegativeTabIndex = (el) => hasTabIndex(el) && el.tabIndex === -1;
var isTabbable = (el) => el ? isHTMLElement(el) && isFocusable(el) && !hasNegativeTabIndex(el) : false;
var isTouchDevice = () => "ontouchstart" in window;
var getOwnerWindow = (node) => {
}
function hasNegativeTabIndex(el) {
return hasTabIndex(el) && el.tabIndex === -1;
}
function isTabbable(el) {
return el ? isHTMLElement(el) && isFocusable(el) && !hasNegativeTabIndex(el) : false;
}
function isTouchDevice() {
return "ontouchstart" in window;
}
function getOwnerWindow(node) {
var _a, _b;
return (_b = (_a = getOwnerDocument(node)) == null ? void 0 : _a.defaultView) != null ? _b : window;
};
var getOwnerDocument = (el) => isElement(el) ? el.ownerDocument : document;
var getActiveElement = (el) => getOwnerDocument(el).activeElement;
var isActiveElement = (el) => {
}
function getOwnerDocument(el) {
return isElement(el) ? el.ownerDocument : document;
}
function getActiveElement(el) {
return getOwnerDocument(el).activeElement;
}
function isActiveElement(el) {
return getActiveElement(el) === el;
};
}
// src/string.ts
var escape = (value, replaceValue = "") => value.replace(/\s+/g, replaceValue);
var antonym = (value) => {
function escape(value, replaceValue = "") {
return value.replace(/\s+/g, replaceValue);
}
function antonym(value) {
switch (value) {

@@ -685,18 +786,34 @@ case "top":

}
};
var toCamelCase = (value) => value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()).replace(/^(.)/, (_, val) => val.toUpperCase());
var toKebabCase = (value) => value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase().replace(/^-/, "");
var toTitleCase = (value) => value.replace(/([A-Z])/g, " $1").replace(/[_-](.)/g, (_, val) => ` ${val.toUpperCase()}`).replace(/^./, (str) => str.toUpperCase()).trim();
}
function toCamelCase(value) {
return value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()).replace(/^(.)/, (_, val) => val.toUpperCase());
}
function toKebabCase(value) {
return value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase().replace(/^-/, "");
}
function toTitleCase(value) {
return value.replace(/([A-Z])/g, " $1").replace(/[_-](.)/g, (_, val) => ` ${val.toUpperCase()}`).replace(/^./, (str) => str.toUpperCase()).trim();
}
// src/calc.ts
var toExpression = (operator, ...args) => args.join(` ${operator} `).replace(/calc/g, "");
var add = (...args) => `calc(${toExpression("+", ...args)})`;
var subtract = (...args) => `calc(${toExpression("-", ...args)})`;
var multiply = (...args) => `calc(${toExpression("*", ...args)})`;
var divide = (...args) => `calc(${toExpression("/", ...args)})`;
var negate = (value) => {
function toExpression(operator, ...args) {
return args.join(` ${operator} `).replace(/calc/g, "");
}
function add(...args) {
return `calc(${toExpression("+", ...args)})`;
}
function subtract(...args) {
return `calc(${toExpression("-", ...args)})`;
}
function multiply(...args) {
return `calc(${toExpression("*", ...args)})`;
}
function divide(...args) {
return `calc(${toExpression("/", ...args)})`;
}
function negate(value) {
if (value != null && !isNaN(parseFloat(value.toString())))
return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
return multiply(value, -1);
};
}
var calc = Object.assign(

@@ -767,63 +884,79 @@ (x) => ({

];
var isGray = (colorScheme) => colorScheme === "gray" || colorScheme === "neutral";
var isAccessible = (colorScheme) => colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
var getColor = (color, fallback = "#000000") => (theme = {}, colorMode = "light", breakpoint = "base") => {
var _a, _b, _c, _d, _e, _f;
const [token, tone] = color.split(".");
if (tone) {
const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _c : [];
if (relatedToken) color = `${relatedToken}.${tone}`;
} else {
const [, relatedColor] = (_f = Object.entries((_e = (_d = theme.semantics) == null ? void 0 : _d.colors) != null ? _e : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _f : [];
if (relatedColor) color = relatedColor;
}
const hex = getMemoizedObject(
theme,
`colors.${color}`,
color
);
try {
if (isArray(hex)) {
return c.toHex(String(hex[colorMode !== "dark" ? 0 : 1]));
} else if (isObject(hex)) {
return c.toHex(String(hex[breakpoint]));
function isGray(colorScheme) {
return colorScheme === "gray" || colorScheme === "neutral";
}
function isAccessible(colorScheme) {
return colorScheme === "yellow" || colorScheme === "cyan" || colorScheme === "lime";
}
function getColor(color, fallback = "#000000") {
return function(theme = {}, colorMode = "light", breakpoint = "base") {
var _a, _b, _c, _d, _e, _f;
const [token, tone] = color.split(".");
if (tone) {
const [, relatedToken] = (_c = Object.entries((_b = (_a = theme.semantics) == null ? void 0 : _a.colorSchemes) != null ? _b : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _c : [];
if (relatedToken) color = `${relatedToken}.${tone}`;
} else {
return c.toHex(String(hex));
const [, relatedColor] = (_f = Object.entries((_e = (_d = theme.semantics) == null ? void 0 : _d.colors) != null ? _e : {}).find(
([semanticToken]) => token === semanticToken
)) != null ? _f : [];
if (relatedColor) color = relatedColor;
}
} catch {
const hex = getMemoizedObject(
theme,
`colors.${color}`,
color
);
try {
return c.toHex(fallback);
if (isArray(hex)) {
return c.toHex(String(hex[colorMode !== "dark" ? 0 : 1]));
} else if (isObject(hex)) {
return c.toHex(String(hex[breakpoint]));
} else {
return c.toHex(String(hex));
}
} catch {
return "#000000";
try {
return c.toHex(fallback);
} catch {
return "#000000";
}
}
}
};
var lightenColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.lighten(raw, amount / 100));
};
var darkenColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.darken(raw, amount / 100));
};
var tintColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#fff", amount / 100));
};
var shadeColor = (color, amount) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#000", amount / 100));
};
var transparentizeColor = (color, alpha) => (theme, colorMode, breakpoint) => {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.transparentize(raw, 1 - alpha);
};
var randomColor = ({
};
}
function lightenColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.lighten(raw, amount / 100));
};
}
function darkenColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.darken(raw, amount / 100));
};
}
function tintColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#fff", amount / 100));
};
}
function shadeColor(color, amount) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.toHex(c.mix(raw, "#000", amount / 100));
};
}
function transparentizeColor(color, alpha) {
return function(theme, colorMode, breakpoint) {
const raw = getColor(color, color)(theme, colorMode, breakpoint);
return c.transparentize(raw, 1 - alpha);
};
}
function randomColor({
string,
colors
} = {}) => {
} = {}) {
const fallback = randomHex();

@@ -834,5 +967,7 @@ if (string && colors) return randomColorFromList(string, colors);

return fallback;
};
var randomHex = () => `#${Math.floor(Math.random() * 16777215).toString(16).padEnd(6, "0")}`;
var randomColorFromString = (str) => {
}
function randomHex() {
return `#${Math.floor(Math.random() * 16777215).toString(16).padEnd(6, "0")}`;
}
function randomColorFromString(str) {
let hash = 0;

@@ -850,4 +985,4 @@ if (str.length === 0) return hash.toString();

return color;
};
var randomColorFromList = (str, list) => {
}
function randomColorFromList(str, list) {
let index = 0;

@@ -861,48 +996,62 @@ if (str.length === 0) return list[0];

return list[index];
};
var randomFromList = (list) => list[Math.floor(Math.random() * list.length)];
var getBrightness = (color) => {
}
function randomFromList(list) {
return list[Math.floor(Math.random() * list.length)];
}
function getBrightness(color) {
const [r, g, b] = c.parseToRgba(color);
return (r * 299 + g * 587 + b * 114) / 1e3;
};
var isTone = (color) => (theme, colorMode, breakpoint) => {
const raw = theme ? getColor(color)(theme, colorMode, breakpoint) : color;
const brightness = getBrightness(raw);
const isDark2 = brightness < 128;
return isDark2 ? "dark" : "light";
};
var isLight = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) === "dark";
var isDark = (color) => (theme, colorMode) => isTone(color)(theme, colorMode) === "light";
var convertColor = (color, fallback) => (format) => {
try {
const isAlpha = format.endsWith("a");
if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
if (format.startsWith("hex")) {
let hexa = c.toHex(color);
if (isAlpha) {
if (hexa.length === 7) hexa += "ff";
}
function isTone(color) {
return function(theme, colorMode, breakpoint) {
const raw = theme ? getColor(color)(theme, colorMode, breakpoint) : color;
const brightness = getBrightness(raw);
const isDark2 = brightness < 128;
return isDark2 ? "dark" : "light";
};
}
function isLight(color) {
return function(theme, colorMode) {
return isTone(color)(theme, colorMode) === "dark";
};
}
function isDark(color) {
return function(theme, colorMode) {
return isTone(color)(theme, colorMode) === "light";
};
}
function convertColor(color, fallback) {
return function(format) {
try {
const isAlpha = format.endsWith("a");
if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;
if (format.startsWith("hex")) {
let hexa = c.toHex(color);
if (isAlpha) {
if (hexa.length === 7) hexa += "ff";
} else {
hexa = hexa.replace(/(?<=^#([0-9a-fA-F]{6}))[0-9a-fA-F]{2}$/, "");
}
return hexa;
} else if (format.startsWith("hsl")) {
let hsla2 = c.toHsla(color);
if (!isAlpha) {
hsla2 = hsla2.replace(/hsla/, "hsl");
hsla2 = hsla2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return hsla2;
} else {
hexa = hexa.replace(/(?<=^#([0-9a-fA-F]{6}))[0-9a-fA-F]{2}$/, "");
let rgba2 = c.toRgba(color);
if (!isAlpha) {
rgba2 = rgba2.replace(/rgba/, "rgb");
rgba2 = rgba2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return rgba2;
}
return hexa;
} else if (format.startsWith("hsl")) {
let hsla2 = c.toHsla(color);
if (!isAlpha) {
hsla2 = hsla2.replace(/hsla/, "hsl");
hsla2 = hsla2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return hsla2;
} else {
let rgba2 = c.toRgba(color);
if (!isAlpha) {
rgba2 = rgba2.replace(/rgba/, "rgb");
rgba2 = rgba2.replace(/,\s*\d+(\.\d+)?\)$/, ")");
}
return rgba2;
} catch {
if (fallback) return convertColor(fallback)(format);
}
} catch {
if (fallback) return convertColor(fallback)(format);
}
};
var calcFormat = (color) => {
};
}
function calcFormat(color) {
if (color.startsWith("hsl")) {

@@ -915,10 +1064,12 @@ return color.startsWith("hsla") ? "hsla" : "hsl";

}
};
var getAlpha = (color) => c.parseToRgba(color)[3];
var alphaToHex = (a) => {
}
function getAlpha(color) {
return c.parseToRgba(color)[3];
}
function alphaToHex(a) {
if (0 > a) a = 0;
if (1 < a) a = 1;
return Math.round(a * 255).toString(16).padStart(2, "0");
};
var parseToRgba2 = (color, fallback) => {
}
function parseToRgba2(color, fallback) {
try {

@@ -930,4 +1081,4 @@ if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;

}
};
var parseToHsla2 = (color, fallback) => {
}
function parseToHsla2(color, fallback) {
try {

@@ -939,4 +1090,4 @@ if (/^[0-9a-fA-F]{6}$/.test(color)) color = "#" + color;

}
};
var parseToHsv = (color, fallback) => {
}
function parseToHsv(color, fallback) {
var _a;

@@ -965,39 +1116,49 @@ let [r, g, b, a] = (_a = parseToRgba2(color, fallback)) != null ? _a : [255, 255, 255, 1];

return [h, s, v, a];
};
var rgbaTo = ([r, g, b, a], fallback) => (format = "hex") => convertColor(c.rgba(r, g, b, a), fallback)(format);
var hslaTo = ([h, s, l, a], fallback) => (format = "hex") => convertColor(c.hsla(h, s, l, a), fallback)(format);
var hsvTo = ([h, s, v, a], fallback) => (format = "hex") => {
h = h / 60;
let rgb = [v, v, v];
let i = Math.floor(h);
let f = h - i;
let p = v * (1 - s);
let q = v * (1 - s * f);
let t = v * (1 - s * (1 - f));
switch (i) {
case 0:
case 6:
rgb = [v, t, p];
break;
case 1:
rgb = [q, v, p];
break;
case 2:
rgb = [p, v, t];
break;
case 3:
rgb = [p, q, v];
break;
case 4:
rgb = [t, p, v];
break;
case 5:
rgb = [v, p, q];
break;
}
let color = `rgb(${rgb.map((v2) => Math.round(v2 * 255)).join(", ")})`;
if (isNumber(a)) color = color.replace(/\)$/, `, ${a})`);
return convertColor(color, fallback)(format);
};
var sameColor = (color, comparison) => {
}
function rgbaTo([r, g, b, a], fallback) {
return function(format = "hex") {
return convertColor(c.rgba(r, g, b, a), fallback)(format);
};
}
function hslaTo([h, s, l, a], fallback) {
return function(format = "hex") {
return convertColor(c.hsla(h, s, l, a), fallback)(format);
};
}
function hsvTo([h, s, v, a], fallback) {
return function(format = "hex") {
h = h / 60;
let rgb = [v, v, v];
let i = Math.floor(h);
let f = h - i;
let p = v * (1 - s);
let q = v * (1 - s * f);
let t = v * (1 - s * (1 - f));
switch (i) {
case 0:
case 6:
rgb = [v, t, p];
break;
case 1:
rgb = [q, v, p];
break;
case 2:
rgb = [p, v, t];
break;
case 3:
rgb = [p, q, v];
break;
case 4:
rgb = [t, p, v];
break;
case 5:
rgb = [v, p, q];
break;
}
let color = `rgb(${rgb.map((v2) => Math.round(v2 * 255)).join(", ")})`;
if (isNumber(a)) color = color.replace(/\)$/, `, ${a})`);
return convertColor(color, fallback)(format);
};
}
function sameColor(color, comparison) {
var _a, _b;

@@ -1009,13 +1170,15 @@ if (!color) return false;

return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
};
}
// src/array.ts
var filterEmpty = (array) => array.filter((value) => value != null);
function filterEmpty(array) {
return array.filter((value) => value != null);
}
// src/number.ts
var toNumber = (n) => {
function toNumber(n) {
const num = parseFloat(n);
return typeof num !== "number" || Number.isNaN(num) ? 0 : num;
};
var toPrecision = (n, precision) => {
}
function toPrecision(n, precision) {
n = toNumber(n);

@@ -1025,4 +1188,4 @@ const scale = 10 ** (precision != null ? precision : 10);

return precision ? n.toFixed(precision) : n.toString();
};
var countDecimal = (n) => {
}
function countDecimal(n) {
if (!Number.isFinite(n)) return 0;

@@ -1036,14 +1199,20 @@ let e = 1;

return p;
};
var roundNumberToStep = (n, from, step) => {
}
function roundNumberToStep(n, from, step) {
const nextValue = Math.round((n - from) / step) * step + from;
const precision = countDecimal(step);
return toPrecision(nextValue, precision);
};
var valueToPercent = (n, min, max) => (n - min) * 100 / (max - min);
var percentToValue = (n, min, max) => (max - min) * n + min;
var clampNumber = (n, min, max) => Math.min(Math.max(n, min), max);
}
function valueToPercent(n, min, max) {
return (n - min) * 100 / (max - min);
}
function percentToValue(n, min, max) {
return (max - min) * n + min;
}
function clampNumber(n, min, max) {
return Math.min(Math.max(n, min), max);
}
// src/event.ts
var isMouseEvent = (ev) => {
function isMouseEvent(ev) {
const win = getEventWindow(ev);

@@ -1053,19 +1222,27 @@ if (typeof win.PointerEvent !== "undefined" && ev instanceof win.PointerEvent)

return ev instanceof win.MouseEvent;
};
var isTouchEvent = (ev) => !!ev.touches;
var isMultiTouchEvent = (ev) => isTouchEvent(ev) && ev.touches.length > 1;
var getEventWindow = (ev) => {
}
function isTouchEvent(ev) {
return !!ev.touches;
}
function isMultiTouchEvent(ev) {
return isTouchEvent(ev) && ev.touches.length > 1;
}
function getEventWindow(ev) {
var _a;
return (_a = ev.view) != null ? _a : window;
};
var pointFromTouch = (e, type = "page") => {
}
function pointFromTouch(e, type = "page") {
const point = e.touches[0] || e.changedTouches[0];
return { x: point[`${type}X`], y: point[`${type}Y`] };
};
var pointFromMouse = (point, type = "page") => ({
x: point[`${type}X`],
y: point[`${type}Y`]
});
var getEventPoint = (ev, type = "page") => isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type);
var addDomEvent = (target, type, cb, options) => {
}
function pointFromMouse(point, type = "page") {
return {
x: point[`${type}X`],
y: point[`${type}Y`]
};
}
function getEventPoint(ev, type = "page") {
return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type);
}
function addDomEvent(target, type, cb, options) {
target.addEventListener(type, cb, options);

@@ -1075,16 +1252,24 @@ return () => {

};
};
var filter = (cb) => (ev) => {
const isMouse = isMouseEvent(ev);
if (!isMouse || isMouse && ev.button === 0) cb(ev);
};
var wrap = (cb, filterPrimary = false) => {
const listener = (ev) => cb(ev, { point: getEventPoint(ev) });
}
function filter(cb) {
return function(ev) {
const isMouse = isMouseEvent(ev);
if (!isMouse || isMouse && ev.button === 0) cb(ev);
};
}
function wrap(cb, filterPrimary = false) {
function listener(ev) {
return cb(ev, { point: getEventPoint(ev) });
}
const fn = filterPrimary ? filter(listener) : listener;
return fn;
};
var addPointerEvent = (target, type, cb, options) => addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
}
function addPointerEvent(target, type, cb, options) {
return addDomEvent(target, type, wrap(cb, type === "pointerdown"), options);
}
// src/module.ts
var interopDefault = (module2) => module2.default || module2;
function interopDefault(module2) {
return module2.default || module2;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -1091,0 +1276,0 @@ 0 && (module.exports = {

@@ -6,4 +6,7 @@ type Primitive = null | undefined | string | number | boolean | symbol | bigint;

}[keyof T];
type Dict<T = any> = Record<string, T>;
type ObjectLiteral = {};
interface Dict<T = any> {
[key: string]: T;
}
interface ObjectLiteral {
}
type StringLiteral = string & {};

@@ -10,0 +13,0 @@ type Union<T> = T | StringLiteral;

@@ -1,3 +0,3 @@

declare const interopDefault: <T extends unknown>(module: T) => T;
declare function interopDefault<T>(module: T): T;
export { interopDefault };

@@ -26,3 +26,5 @@ "use strict";

module.exports = __toCommonJS(module_exports);
var interopDefault = (module2) => module2.default || module2;
function interopDefault(module2) {
return module2.default || module2;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -29,0 +31,0 @@ 0 && (module.exports = {

@@ -1,9 +0,9 @@

declare const toNumber: (n: any) => number;
declare const toPrecision: (n: number, precision?: number) => string;
declare const countDecimal: (n: number) => number;
declare const roundNumberToStep: (n: number, from: number, step: number) => string;
declare const valueToPercent: (n: number, min: number, max: number) => number;
declare const percentToValue: (n: number, min: number, max: number) => number;
declare const clampNumber: (n: number, min: number, max: number) => number;
declare function toNumber(n: any): number;
declare function toPrecision(n: number, precision?: number): string;
declare function countDecimal(n: number): number;
declare function roundNumberToStep(n: number, from: number, step: number): string;
declare function valueToPercent(n: number, min: number, max: number): number;
declare function percentToValue(n: number, min: number, max: number): number;
declare function clampNumber(n: number, min: number, max: number): number;
export { clampNumber, countDecimal, percentToValue, roundNumberToStep, toNumber, toPrecision, valueToPercent };

@@ -32,7 +32,7 @@ "use strict";

module.exports = __toCommonJS(number_exports);
var toNumber = (n) => {
function toNumber(n) {
const num = parseFloat(n);
return typeof num !== "number" || Number.isNaN(num) ? 0 : num;
};
var toPrecision = (n, precision) => {
}
function toPrecision(n, precision) {
n = toNumber(n);

@@ -42,4 +42,4 @@ const scale = 10 ** (precision != null ? precision : 10);

return precision ? n.toFixed(precision) : n.toString();
};
var countDecimal = (n) => {
}
function countDecimal(n) {
if (!Number.isFinite(n)) return 0;

@@ -53,11 +53,17 @@ let e = 1;

return p;
};
var roundNumberToStep = (n, from, step) => {
}
function roundNumberToStep(n, from, step) {
const nextValue = Math.round((n - from) / step) * step + from;
const precision = countDecimal(step);
return toPrecision(nextValue, precision);
};
var valueToPercent = (n, min, max) => (n - min) * 100 / (max - min);
var percentToValue = (n, min, max) => (max - min) * n + min;
var clampNumber = (n, min, max) => Math.min(Math.max(n, min), max);
}
function valueToPercent(n, min, max) {
return (n - min) * 100 / (max - min);
}
function percentToValue(n, min, max) {
return (max - min) * n + min;
}
function clampNumber(n, min, max) {
return Math.min(Math.max(n, min), max);
}
// Annotate the CommonJS export names for ESM import in node:

@@ -64,0 +70,0 @@ 0 && (module.exports = {

import { Dict } from './index.types.js';
declare const omitObject: <Y extends Dict, M extends keyof Y = keyof Y, D extends unknown = unknown>(obj: Y, keys: M[] | readonly M[]) => D extends unknown ? Omit<Y, M> : D;
declare const pickObject: <Y extends Dict, M extends keyof Y = keyof Y, D extends unknown = unknown>(obj: Y, keys: M[] | readonly M[], fallbackValue?: string) => D extends unknown ? { [H in M]: Y[H]; } : D;
declare const splitObject: <Y extends Dict, M extends keyof Y>(obj: Y, keys: M[] | readonly M[]) => [{ [P in M]: Y[P]; }, Omit<Y, M>];
declare const filterObject: <Y extends Dict, M extends Dict>(obj: Y, func: (key: keyof Y, value: Y[keyof Y], obj: Y) => boolean) => M;
declare const filterUndefined: <Y extends Dict>(obj: Y) => Y;
declare const merge: <Y extends Dict>(target: any, source: any, mergeArray?: boolean) => Y;
type FlattenObjectOptions = {
declare function omitObject<Y extends Dict, M extends keyof Y = keyof Y, D = any>(obj: Y, keys: M[] | readonly M[]): D extends unknown ? Omit<Y, M> : D;
declare function pickObject<Y extends Dict, M extends keyof Y = keyof Y, D = any>(obj: Y, keys: M[] | readonly M[], fallbackValue?: string): D extends unknown ? { [H in M]: Y[H]; } : D;
declare function splitObject<Y extends Dict, M extends keyof Y>(obj: Y, keys: M[] | readonly M[]): [{ [P in M]: Y[P]; }, Omit<Y, M>];
declare function filterObject<Y extends Dict, M extends Dict>(obj: Y, func: (key: keyof Y, value: Y[keyof Y], obj: Y) => boolean): M;
declare function filterUndefined<Y extends Dict>(obj: Y): Y;
declare function merge<Y extends Dict>(target: any, source: any, mergeArray?: boolean): Y;
interface FlattenObjectOptions {
maxDepth?: number;

@@ -14,12 +14,16 @@ omitKeys?: string[];

shouldProcess?: (obj: any) => boolean;
}
declare function flattenObject<Y extends Dict>(obj: any, { maxDepth, omitKeys, separator, shouldProcess }?: FlattenObjectOptions): Y;
declare function objectFromEntries<Y extends Dict>(entries: any[][]): Y;
declare function keysFormObject<Y extends object>(obj: Y): (keyof Y)[];
declare function replaceObject<Y = any>(objOrArray: Y, callBack: (value: any) => any): Y;
declare function getObject(obj: Dict, path: string | number, fallback?: any, i?: number): any;
declare function memoizeObject(func: typeof getObject): <Y>(obj: Dict, path: string | number, fallback?: any, i?: number) => Y;
declare const getMemoizedObject: <Y>(obj: Dict, path: string | number, fallback?: any, i?: number) => Y;
declare function assignAfter(target: {
[key: string]: any;
}, ...sources: any[]): {
[key: string]: unknown;
};
declare const flattenObject: <Y extends Dict>(obj: any, { maxDepth, omitKeys, separator, shouldProcess }?: FlattenObjectOptions) => Y;
declare const objectFromEntries: <Y extends Dict>(entries: any[][]) => Y;
declare const keysFormObject: <Y extends Dict>(obj: Y) => (keyof Y)[];
declare const replaceObject: <Y extends unknown>(objOrArray: Y, callBack: (value: any) => any) => Y;
declare const getObject: (obj: Dict, path: string | number, fallback?: any, i?: number) => any;
declare const memoizeObject: (func: typeof getObject) => <Y extends unknown = any>(obj: Dict, path: string | number, fallback?: any, i?: number) => Y;
declare const getMemoizedObject: <Y extends unknown = any>(obj: Dict, path: string | number, fallback?: any, i?: number) => Y;
declare const assignAfter: (target: Record<string, any>, ...sources: any[]) => Record<string, unknown>;
export { type FlattenObjectOptions, assignAfter, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, keysFormObject, memoizeObject, merge, objectFromEntries, omitObject, pickObject, replaceObject, splitObject };

@@ -41,10 +41,20 @@ "use strict";

// src/assertion.ts
var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
var isUndefined = (value) => typeof value === "undefined" && value === void 0;
var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
var isArray = (value) => Array.isArray(value);
var isFunction = (value) => typeof value === "function";
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
function isUndefined(value) {
return typeof value === "undefined" && value === void 0;
}
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
}
function isArray(value) {
return Array.isArray(value);
}
function isFunction(value) {
return typeof value === "function";
}
// src/object.ts
var omitObjectHelper = (obj, path) => {
function omitObjectHelper(obj, path) {
if (!path.length) return obj;

@@ -63,4 +73,4 @@ const [primaryKey, ...restKeys] = path;

return obj;
};
var omitObject = (obj, keys) => {
}
function omitObject(obj, keys) {
return keys.reduce((prev, key) => {

@@ -70,18 +80,20 @@ const path = isString(key) ? key.split(".") : [];

}, obj);
};
var pickObject = (obj, keys, fallbackValue = "__fallback") => keys.reduce((prev, key) => {
const path = isString(key) ? key.split(".") : [];
if (!path.length) return prev;
const value = getMemoizedObject(obj, key, fallbackValue);
if (value === fallbackValue) return prev;
prev = merge(
prev,
path.reduceRight(
(prev2, key2) => ({ [key2]: key2 === path.at(-1) ? value : prev2 }),
{}
)
);
return prev;
}, {});
var splitObject = (obj, keys) => {
}
function pickObject(obj, keys, fallbackValue = "__fallback") {
return keys.reduce((prev, key) => {
const path = isString(key) ? key.split(".") : [];
if (!path.length) return prev;
const value = getMemoizedObject(obj, key, fallbackValue);
if (value === fallbackValue) return prev;
prev = merge(
prev,
path.reduceRight(
(prev2, key2) => ({ [key2]: key2 === path.at(-1) ? value : prev2 }),
{}
)
);
return prev;
}, {});
}
function splitObject(obj, keys) {
const picked = {};

@@ -97,4 +109,4 @@ const omitted = {};

return [picked, omitted];
};
var filterObject = (obj, func) => {
}
function filterObject(obj, func) {
const result = {};

@@ -106,5 +118,7 @@ Object.entries(obj).forEach(([key, value]) => {

return result;
};
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
var merge = (target, source, mergeArray = false) => {
}
function filterUndefined(obj) {
return filterObject(obj, (_, val) => val !== null && val !== void 0);
}
function merge(target, source, mergeArray = false) {
let result = Object.assign({}, target);

@@ -128,4 +142,4 @@ if (isObject(source)) {

return result;
};
var flattenObject = (obj, { maxDepth, omitKeys, separator, shouldProcess } = {}) => {
}
function flattenObject(obj, { maxDepth, omitKeys, separator, shouldProcess } = {}) {
maxDepth != null ? maxDepth : maxDepth = Infinity;

@@ -152,9 +166,13 @@ omitKeys != null ? omitKeys : omitKeys = [];

}, {});
};
var objectFromEntries = (entries) => entries.reduce((result, [key, value]) => {
result[key] = value;
return result;
}, {});
var keysFormObject = (obj) => Object.keys(obj);
var replaceObject = (objOrArray, callBack) => {
}
function objectFromEntries(entries) {
return entries.reduce((result, [key, value]) => {
result[key] = value;
return result;
}, {});
}
function keysFormObject(obj) {
return Object.keys(obj);
}
function replaceObject(objOrArray, callBack) {
if (isArray(objOrArray)) {

@@ -170,4 +188,4 @@ return objOrArray.map(callBack);

}
};
var getObject = (obj, path, fallback, i) => {
}
function getObject(obj, path, fallback, i) {
const k = isString(path) ? path.split(/\[(.*?)\]|\./).filter(Boolean) : [path];

@@ -179,6 +197,6 @@ for (i = 0; i < k.length; i += 1) {

return obj === void 0 ? fallback : obj;
};
var memoizeObject = (func) => {
}
function memoizeObject(func) {
const cache = /* @__PURE__ */ new WeakMap();
const memoizedFunc = (obj, path, fallback, i) => {
function memoizedFunc(obj, path, fallback, i) {
if (isUndefined(obj)) return func(obj, path, fallback);

@@ -191,7 +209,7 @@ if (!cache.has(obj)) cache.set(obj, /* @__PURE__ */ new Map());

return value;
};
}
return memoizedFunc;
};
}
var getMemoizedObject = memoizeObject(getObject);
var assignAfter = (target, ...sources) => {
function assignAfter(target, ...sources) {
if (target == null)

@@ -209,3 +227,3 @@ throw new TypeError("Cannot convert undefined or null to object");

return result;
};
}
// Annotate the CommonJS export names for ESM import in node:

@@ -212,0 +230,0 @@ 0 && (module.exports = {

import * as React from 'react';
import { MergeIfDefined } from './index.types.js';
type DOMElement = Element & HTMLOrSVGElement;
type DOMAttributes<Y = DOMElement> = React.HTMLAttributes<Y> & React.AriaAttributes & React.DOMAttributes<Y> & {
id?: string;
role?: React.AriaRole;
tabIndex?: number;
style?: React.CSSProperties;
};
type PropGetter<Y = undefined, M = DOMAttributes> = (props?: MergeIfDefined<DOMAttributes, Y>, ref?: React.Ref<any>) => M & React.RefAttributes<any>;
type RequiredPropGetter<Y = undefined, M = DOMAttributes> = (props: MergeIfDefined<DOMAttributes, Y>, ref?: React.Ref<any>) => M & React.RefAttributes<any>;
type MaybeRenderProp<Y> = React.ReactNode | ((props: Y) => React.ReactNode);
type Options<ContextType extends any = any> = {
interface Options<ContextType extends any = any> {
strict?: boolean;

@@ -19,28 +9,28 @@ errorMessage?: string;

defaultValue?: ContextType;
};
}
type CreateContextReturn<T> = [React.Provider<T>, () => T, React.Context<T>];
declare const createContext: <ContextType extends unknown = any>({ strict, errorMessage, name, defaultValue, }?: Options<ContextType>) => CreateContextReturn<ContextType>;
declare function createContext<ContextType extends any = any>({ strict, errorMessage, name, defaultValue, }?: Options<ContextType>): CreateContextReturn<ContextType>;
declare const useSafeLayoutEffect: typeof React.useLayoutEffect;
declare const useUnmountEffect: (callback: () => void) => void;
type UseIsMountedProps = {
declare function useUnmountEffect(callback: () => void): void;
interface UseIsMountedProps {
rerender?: boolean;
delay?: number;
};
declare const useIsMounted: ({ rerender, delay, }?: UseIsMountedProps) => [() => boolean, boolean];
}
declare function useIsMounted({ rerender, delay, }?: UseIsMountedProps): [() => boolean, boolean];
type UseIsMountedReturn = ReturnType<typeof useIsMounted>;
declare const getValidChildren: (children: React.ReactNode) => React.ReactElement[];
declare const isValidElement: (child: any) => child is React.ReactNode;
declare const findChildren: (children: React.ReactElement<any, string | React.JSXElementConstructor<any>>[], ...types: (string | React.JSXElementConstructor<any>)[]) => [React.ReactElement | undefined, ...React.ReactElement[]];
declare const includesChildren: (children: React.ReactElement<any, string | React.JSXElementConstructor<any>>[], ...types: (string | React.JSXElementConstructor<any>)[]) => boolean;
declare const omitChildren: (children: React.ReactElement<any, string | React.JSXElementConstructor<any>>[], ...types: (string | React.JSXElementConstructor<any>)[]) => React.ReactElement[];
declare const pickChildren: (children: React.ReactElement<any, string | React.JSXElementConstructor<any>>[], ...types: (string | React.JSXElementConstructor<any>)[]) => React.ReactElement[];
declare const cx: (...classNames: (string | undefined)[]) => string;
declare function getValidChildren(children: React.ReactNode): React.ReactElement[];
declare function isValidElement(child: any): child is React.ReactNode;
declare function findChildren(children: React.ReactElement[], ...types: (string | React.JSXElementConstructor<any>)[]): [React.ReactElement | undefined, ...React.ReactElement[]];
declare function includesChildren(children: React.ReactElement[], ...types: (string | React.JSXElementConstructor<any>)[]): boolean;
declare function omitChildren(children: React.ReactElement[], ...types: (string | React.JSXElementConstructor<any>)[]): React.ReactElement[];
declare function pickChildren(children: React.ReactElement[], ...types: (string | React.JSXElementConstructor<any>)[]): React.ReactElement[];
declare function cx(...classNames: (string | undefined)[]): string;
type ReactRef<T> = React.Ref<T> | React.MutableRefObject<T> | React.LegacyRef<T>;
declare const isRefObject: (val: any) => val is {
declare function isRefObject(val: any): val is {
current: any;
};
declare const assignRef: <T extends unknown = any>(ref: ReactRef<T> | undefined, value: T) => void;
declare const mergeRefs: <T extends unknown = any>(...refs: (ReactRef<T> | null | undefined)[]) => (node: T | null) => void;
declare const useMergeRefs: <T extends unknown = any>(...refs: (ReactRef<T> | undefined)[]) => (node: T | null) => void;
declare const useCallbackRef: <T extends (...args: any[]) => any>(callback: T | undefined, deps?: React.DependencyList) => T;
declare function assignRef<T extends any = any>(ref: ReactRef<T> | undefined, value: T): void;
declare function mergeRefs<T extends any = any>(...refs: (ReactRef<T> | null | undefined)[]): (node: T | null) => void;
declare function useMergeRefs<T extends any = any>(...refs: (ReactRef<T> | undefined)[]): (node: T | null) => void;
declare function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined, deps?: React.DependencyList): T;
/**

@@ -51,3 +41,3 @@ * `useUpdateEffect` is a custom hook that skips side effects on the initial render, and only runs them when the dependency array changes.

*/
declare const useUpdateEffect: (callback: React.EffectCallback, deps: React.DependencyList) => void;
declare function useUpdateEffect(callback: React.EffectCallback, deps: React.DependencyList): void;
type FunctionReturningPromise = (...args: any[]) => Promise<any>;

@@ -59,3 +49,3 @@ /**

*/
declare const useAsync: <T extends FunctionReturningPromise>(func: T, deps?: React.DependencyList) => StateFromFunctionReturningPromise<T>;
declare function useAsync<T extends FunctionReturningPromise>(func: T, deps?: React.DependencyList): StateFromFunctionReturningPromise<T>;
type AsyncState<T> = {

@@ -81,7 +71,7 @@ loading: boolean;

type AsyncFnReturn<T extends FunctionReturningPromise = FunctionReturningPromise> = [StateFromFunctionReturningPromise<T>, T];
declare const useAsyncFunc: <T extends FunctionReturningPromise>(func: T, deps?: React.DependencyList, initialState?: StateFromFunctionReturningPromise<T>) => AsyncFnReturn<T>;
declare function useAsyncFunc<T extends FunctionReturningPromise>(func: T, deps?: React.DependencyList, initialState?: StateFromFunctionReturningPromise<T>): AsyncFnReturn<T>;
type AsyncStateRetry<T> = AsyncState<T> & {
retry(): void;
};
declare const useAsyncRetry: <T>(func: () => Promise<T>, deps?: React.DependencyList) => {
declare function useAsyncRetry<T>(func: () => Promise<T>, deps?: React.DependencyList): {
retry: () => void;

@@ -107,4 +97,4 @@ loading: boolean;

};
declare const createId: (prefix: string) => string;
declare function createId(prefix: string): string;
export { type AsyncFnReturn, type AsyncState, type AsyncStateRetry, type DOMAttributes, type FunctionReturningPromise, type MaybeRenderProp, type PromiseType, type PropGetter, type RequiredPropGetter, type UseIsMountedProps, type UseIsMountedReturn, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };
export { type AsyncFnReturn, type AsyncState, type AsyncStateRetry, type FunctionReturningPromise, type MaybeRenderProp, type PromiseType, type UseIsMountedProps, type UseIsMountedReturn, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };

@@ -59,9 +59,17 @@ "use strict";

// src/assertion.ts
var isNumber = (value) => typeof value === "number";
var isString = (value) => Object.prototype.toString.call(value) === "[object String]";
var isObject = (value) => value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
var isArray = (value) => Array.isArray(value);
function isNumber(value) {
return typeof value === "number";
}
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
function isObject(value) {
return value !== null && (typeof value === "object" || typeof value === "function") && !isArray(value);
}
function isArray(value) {
return Array.isArray(value);
}
// src/react.tsx
var createContext2 = ({
function createContext2({
strict = true,

@@ -71,3 +79,3 @@ errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider",

defaultValue
} = {}) => {
} = {}) {
const Context = React.createContext(defaultValue);

@@ -91,12 +99,11 @@ Context.displayName = name;

];
};
}
var useSafeLayoutEffect = Boolean(globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : React.useEffect;
var useUnmountEffect = (callback) => (
// eslint-disable-next-line react-hooks/exhaustive-deps
React.useEffect(() => () => callback(), [])
);
var useIsMounted = ({
function useUnmountEffect(callback) {
return React.useEffect(() => () => callback(), []);
}
function useIsMounted({
rerender = false,
delay = 0
} = {}) => {
} = {}) {
const isMountedRef = React.useRef(false);

@@ -121,20 +128,36 @@ const [isMounted, setIsMounted] = React.useState(false);

return [React.useCallback(() => isMountedRef.current, []), isMounted];
};
var getValidChildren = (children) => React.Children.toArray(children).filter(
(child) => React.isValidElement(child)
);
var isValidElement2 = (child) => React.isValidElement(child) || isString(child) || isNumber(child);
var findChildren = (children, ...types) => children.find((child) => types.some((type) => child.type === type)) ? children.sort(
(a, b) => types.some((type) => a.type === type) ? -1 : types.some((type) => b.type === type) ? 1 : 0
) : [void 0, ...children];
var includesChildren = (children, ...types) => children.some((child) => {
if (types.some((type) => child.type === type)) return true;
const children2 = getValidChildren(child.props.children);
return children2.length ? includesChildren(children2, ...types) : false;
});
var omitChildren = (children, ...types) => children.filter((child) => types.every((type) => child.type !== type));
var pickChildren = (children, ...types) => children.filter((child) => types.every((type) => child.type === type));
var cx = (...classNames) => classNames.filter(Boolean).join(" ");
var isRefObject = (val) => isObject(val) && "current" in val;
var assignRef = (ref, value) => {
}
function getValidChildren(children) {
return React.Children.toArray(children).filter(
(child) => React.isValidElement(child)
);
}
function isValidElement2(child) {
return React.isValidElement(child) || isString(child) || isNumber(child);
}
function findChildren(children, ...types) {
return children.find((child) => types.some((type) => child.type === type)) ? children.sort(
(a, b) => types.some((type) => a.type === type) ? -1 : types.some((type) => b.type === type) ? 1 : 0
) : [void 0, ...children];
}
function includesChildren(children, ...types) {
return children.some((child) => {
if (types.some((type) => child.type === type)) return true;
const children2 = getValidChildren(child.props.children);
return children2.length ? includesChildren(children2, ...types) : false;
});
}
function omitChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type !== type));
}
function pickChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type === type));
}
function cx(...classNames) {
return classNames.filter(Boolean).join(" ");
}
function isRefObject(val) {
return isObject(val) && "current" in val;
}
function assignRef(ref, value) {
if (ref == null) return;

@@ -150,10 +173,14 @@ if (typeof ref === "function") {

}
};
var mergeRefs = (...refs) => (node) => {
refs.forEach((ref) => {
assignRef(ref, node);
});
};
var useMergeRefs = (...refs) => React.useMemo(() => mergeRefs(...refs), [refs]);
var useCallbackRef = (callback, deps = []) => {
}
function mergeRefs(...refs) {
return function(node) {
return refs.forEach((ref) => {
assignRef(ref, node);
});
};
}
function useMergeRefs(...refs) {
return React.useMemo(() => mergeRefs(...refs), [refs]);
}
function useCallbackRef(callback, deps = []) {
const callbackRef = React.useRef(callback);

@@ -170,4 +197,4 @@ React.useEffect(() => {

);
};
var useUpdateEffect = (callback, deps) => {
}
function useUpdateEffect(callback, deps) {
const renderCycleRef = React.useRef(false);

@@ -187,4 +214,4 @@ const effectCycleRef = React.useRef(false);

}, []);
};
var useAsync = (func, deps = []) => {
}
function useAsync(func, deps = []) {
const [state, callback] = useAsyncFunc(func, deps, { loading: true });

@@ -195,4 +222,4 @@ React.useEffect(() => {

return state;
};
var useAsyncFunc = (func, deps = [], initialState = { loading: false }) => {
}
function useAsyncFunc(func, deps = [], initialState = { loading: false }) {
const lastCallId = React.useRef(0);

@@ -223,4 +250,4 @@ const [isMounted] = useIsMounted();

return [state, callback];
};
var useAsyncRetry = (func, deps = []) => {
}
function useAsyncRetry(func, deps = []) {
const [attempt, setAttempt] = React.useState(0);

@@ -234,5 +261,7 @@ const state = useAsync(func, [...deps, attempt]);

return { ...state, retry };
};
}
var createIdCounter = 0;
var createId = (prefix) => `${prefix}-${++createIdCounter}-${(/* @__PURE__ */ new Date()).getTime()}`;
function createId(prefix) {
return `${prefix}-${++createIdCounter}-${(/* @__PURE__ */ new Date()).getTime()}`;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -239,0 +268,0 @@ 0 && (module.exports = {

import { StringLiteral } from './index.types.js';
declare const escape: (value: string, replaceValue?: string) => string;
declare const antonym: (value: string) => string;
declare const toCamelCase: (value: StringLiteral) => string;
declare const toKebabCase: (value: StringLiteral) => string;
declare const toTitleCase: (value: StringLiteral) => string;
declare function escape(value: string, replaceValue?: string): string;
declare function antonym(value: string): string;
declare function toCamelCase(value: StringLiteral): string;
declare function toKebabCase(value: StringLiteral): string;
declare function toTitleCase(value: StringLiteral): string;
export { antonym, escape, toCamelCase, toKebabCase, toTitleCase };

@@ -30,4 +30,6 @@ "use strict";

module.exports = __toCommonJS(string_exports);
var escape = (value, replaceValue = "") => value.replace(/\s+/g, replaceValue);
var antonym = (value) => {
function escape(value, replaceValue = "") {
return value.replace(/\s+/g, replaceValue);
}
function antonym(value) {
switch (value) {

@@ -69,6 +71,12 @@ case "top":

}
};
var toCamelCase = (value) => value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()).replace(/^(.)/, (_, val) => val.toUpperCase());
var toKebabCase = (value) => value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase().replace(/^-/, "");
var toTitleCase = (value) => value.replace(/([A-Z])/g, " $1").replace(/[_-](.)/g, (_, val) => ` ${val.toUpperCase()}`).replace(/^./, (str) => str.toUpperCase()).trim();
}
function toCamelCase(value) {
return value.toLowerCase().replace(/[_-](.)/g, (_, val) => val.toUpperCase()).replace(/^(.)/, (_, val) => val.toUpperCase());
}
function toKebabCase(value) {
return value.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase().replace(/^-/, "");
}
function toTitleCase(value) {
return value.replace(/([A-Z])/g, " $1").replace(/[_-](.)/g, (_, val) => ` ${val.toUpperCase()}`).replace(/^./, (str) => str.toUpperCase()).trim();
}
// Annotate the CommonJS export names for ESM import in node:

@@ -75,0 +83,0 @@ 0 && (module.exports = {

{
"name": "@yamada-ui/utils",
"version": "1.5.0",
"version": "1.5.1-dev-20240917033401",
"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

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

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc