Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yamada-ui/utils

Package Overview
Dependencies
Maintainers
0
Versions
506
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.1 to 1.5.2-dev-20240922184722

dist/chunk-CVXUYRXJ.mjs

2

dist/index.d.ts

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

export { funcAll, handlerAll, noop, runIfFunc } from './function.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 { AsyncFnReturn, AsyncState, AsyncStateRetry, FunctionReturningPromise, MaybeRenderProp, PromiseType, UseIsMountedProps, UseIsMountedReturn, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isSomeElement, 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';

@@ -111,2 +111,3 @@ "use strict";

isSafari: () => isSafari,
isSomeElement: () => isSomeElement,
isString: () => isString,

@@ -458,10 +459,35 @@ isTabbable: () => isTabbable,

}
function isSomeElement(child, type) {
var _a, _b;
if (child.type === type) return true;
if (!!child.__ui__ && !!type.__ui__) {
if (child.__ui__ === type.__ui__) return true;
}
const payload = child.type._payload;
if (!!((_a = payload == null ? void 0 : payload.value) == null ? void 0 : _a.__ui__) && !!type.__ui__) {
if (((_b = payload == null ? void 0 : payload.value) == null ? void 0 : _b.__ui__) === type.__ui__) return true;
}
return false;
}
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];
const child = children.find(
(child2) => types.some((type) => isSomeElement(child2, type))
);
if (child) {
return children.sort((a, b) => {
if (types.some((type) => isSomeElement(a, type))) {
return -1;
} else if (types.some((type) => isSomeElement(b, type))) {
return 1;
} else {
return 0;
}
});
} else {
return [void 0, ...children];
}
}
function includesChildren(children, ...types) {
return children.some((child) => {
if (types.some((type) => child.type === type)) return true;
if (types.some((type) => isSomeElement(child, type))) return true;
const children2 = getValidChildren(child.props.children);

@@ -472,6 +498,10 @@ return children2.length ? includesChildren(children2, ...types) : false;

function omitChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type !== type));
return children.filter(
(child) => types.every((type) => !isSomeElement(child, type))
);
}
function pickChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type === type));
return children.filter(
(child) => types.every((type) => isSomeElement(child, type))
);
}

@@ -1318,2 +1348,3 @@ function cx(...classNames) {

isSafari,
isSomeElement,
isString,

@@ -1320,0 +1351,0 @@ isTabbable,

@@ -22,2 +22,3 @@ import * as React from 'react';

declare function isValidElement(child: any): child is React.ReactNode;
declare function isSomeElement(child: any, type: any): boolean;
declare function findChildren(children: React.ReactElement[], ...types: (string | React.JSXElementConstructor<any>)[]): [React.ReactElement | undefined, ...React.ReactElement[]];

@@ -96,2 +97,2 @@ declare function includesChildren(children: React.ReactElement[], ...types: (string | React.JSXElementConstructor<any>)[]): boolean;

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 };
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, isSomeElement, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect };

@@ -41,2 +41,3 @@ "use strict";

isRefObject: () => isRefObject,
isSomeElement: () => isSomeElement,
isValidElement: () => isValidElement2,

@@ -135,10 +136,35 @@ mergeRefs: () => mergeRefs,

}
function isSomeElement(child, type) {
var _a, _b;
if (child.type === type) return true;
if (!!child.__ui__ && !!type.__ui__) {
if (child.__ui__ === type.__ui__) return true;
}
const payload = child.type._payload;
if (!!((_a = payload == null ? void 0 : payload.value) == null ? void 0 : _a.__ui__) && !!type.__ui__) {
if (((_b = payload == null ? void 0 : payload.value) == null ? void 0 : _b.__ui__) === type.__ui__) return true;
}
return false;
}
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];
const child = children.find(
(child2) => types.some((type) => isSomeElement(child2, type))
);
if (child) {
return children.sort((a, b) => {
if (types.some((type) => isSomeElement(a, type))) {
return -1;
} else if (types.some((type) => isSomeElement(b, type))) {
return 1;
} else {
return 0;
}
});
} else {
return [void 0, ...children];
}
}
function includesChildren(children, ...types) {
return children.some((child) => {
if (types.some((type) => child.type === type)) return true;
if (types.some((type) => isSomeElement(child, type))) return true;
const children2 = getValidChildren(child.props.children);

@@ -149,6 +175,10 @@ return children2.length ? includesChildren(children2, ...types) : false;

function omitChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type !== type));
return children.filter(
(child) => types.every((type) => !isSomeElement(child, type))
);
}
function pickChildren(children, ...types) {
return children.filter((child) => types.every((type) => child.type === type));
return children.filter(
(child) => types.every((type) => isSomeElement(child, type))
);
}

@@ -270,2 +300,3 @@ function cx(...classNames) {

isRefObject,
isSomeElement,
isValidElement,

@@ -272,0 +303,0 @@ mergeRefs,

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

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