@chakra-ui/utils
Advanced tools
Comparing version 1.4.0 to 1.5.0
# Change Log | ||
## 1.5.0 | ||
### Minor Changes | ||
- [`a58b724e9`](https://github.com/chakra-ui/chakra-ui/commit/a58b724e9c8656044f866b658f378662f2a44b46) | ||
Thanks [@segunadebayo](https://github.com/segunadebayo)! - Add `withFlushSync` | ||
function wrapper to help resolve concurrent mode and onFocus state issues. | ||
> This is a temp fix until the issue is fixed in React. | ||
* [`b724a9dd9`](https://github.com/chakra-ui/chakra-ui/commit/b724a9dd9429d02c0b2c7f7deac66d3553100bdc) | ||
[#3674](https://github.com/chakra-ui/chakra-ui/pull/3674) Thanks | ||
[@codebender828](https://github.com/codebender828)! - Extract all React based | ||
utilities and types into `@chakra-ui/react-utils` | ||
## 1.4.0 | ||
@@ -4,0 +19,0 @@ |
@@ -11,3 +11,2 @@ "use strict"; | ||
exports.isCssVar = isCssVar; | ||
exports.isInputEvent = isInputEvent; | ||
exports.isRefObject = exports.__DEV__ = exports.isEmpty = exports.isNull = exports.isEmptyObject = exports.isObject = exports.isUndefined = exports.isDefined = exports.isEmptyArray = exports.isNotNumber = void 0; | ||
@@ -90,7 +89,2 @@ | ||
return /^var\(--.+\)$/.test(value); | ||
} // Event assertions | ||
function isInputEvent(value) { | ||
return value && isObject(value) && isObject(value.target); | ||
} // Empty assertions | ||
@@ -97,0 +91,0 @@ |
@@ -14,3 +14,2 @@ "use strict"; | ||
exports.closest = closest; | ||
exports.isRightClick = void 0; | ||
@@ -22,8 +21,2 @@ var _tabbable = require("./tabbable"); | ||
var isRightClick = function isRightClick(event) { | ||
return event.button !== 0; | ||
}; | ||
exports.isRightClick = isRightClick; | ||
function getAllFocusable(container) { | ||
@@ -30,0 +23,0 @@ var focusableEls = Array.from(container.querySelectorAll(focusableElSelector)); |
@@ -6,5 +6,3 @@ "use strict"; | ||
exports.getOwnerDocument = getOwnerDocument; | ||
exports.getRelatedTarget = getRelatedTarget; | ||
exports.canUseDOM = canUseDOM; | ||
exports.normalizeEventKey = normalizeEventKey; | ||
exports.getActiveElement = getActiveElement; | ||
@@ -27,6 +25,2 @@ exports.contains = contains; | ||
function getRelatedTarget(event) { | ||
return event.relatedTarget || event.nativeEvent.explicitOriginalTarget || document.activeElement; | ||
} | ||
function canUseDOM() { | ||
@@ -37,17 +31,4 @@ return !!(typeof window !== "undefined" && window.document && window.document.createElement); | ||
var isBrowser = canUseDOM(); | ||
/** | ||
* Get the normalized event key across all browsers | ||
* @param event keyboard event | ||
*/ | ||
exports.isBrowser = isBrowser; | ||
function normalizeEventKey(event) { | ||
var key = event.key, | ||
keyCode = event.keyCode; | ||
var isArrowKey = keyCode >= 37 && keyCode <= 40 && key.indexOf("Arrow") !== 0; | ||
var eventKey = isArrowKey ? "Arrow" + key : key; | ||
return eventKey; | ||
} | ||
var dataAttr = function dataAttr(condition) { | ||
@@ -54,0 +35,0 @@ return condition ? "" : undefined; |
@@ -77,10 +77,2 @@ "use strict"; | ||
var _reactHelpers = require("./react-helpers"); | ||
Object.keys(_reactHelpers).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _reactHelpers[key]) return; | ||
exports[key] = _reactHelpers[key]; | ||
}); | ||
var _cssBoxModel = require("css-box-model"); | ||
@@ -87,0 +79,0 @@ |
@@ -37,6 +37,2 @@ // Number assertions | ||
return /^var\(--.+\)$/.test(value); | ||
} // Event assertions | ||
export function isInputEvent(value) { | ||
return value && isObject(value) && isObject(value.target); | ||
} // Empty assertions | ||
@@ -43,0 +39,0 @@ |
import { isFocusable, isTabbable, isHTMLElement } from "./tabbable"; | ||
var focusableElList = ["input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", "embed", "iframe", "object", "a[href]", "area[href]", "button:not([disabled])", "[tabindex]", "audio[controls]", "video[controls]", "*[tabindex]:not([aria-disabled])", "*[contenteditable]"]; | ||
var focusableElSelector = focusableElList.join(); | ||
export var isRightClick = event => event.button !== 0; | ||
export function getAllFocusable(container) { | ||
@@ -6,0 +5,0 @@ var focusableEls = Array.from(container.querySelectorAll(focusableElSelector)); |
@@ -11,5 +11,2 @@ export function getOwnerWindow(node) { | ||
} | ||
export function getRelatedTarget(event) { | ||
return event.relatedTarget || event.nativeEvent.explicitOriginalTarget || document.activeElement; | ||
} | ||
export function canUseDOM() { | ||
@@ -19,16 +16,2 @@ return !!(typeof window !== "undefined" && window.document && window.document.createElement); | ||
export var isBrowser = canUseDOM(); | ||
/** | ||
* Get the normalized event key across all browsers | ||
* @param event keyboard event | ||
*/ | ||
export function normalizeEventKey(event) { | ||
var { | ||
key, | ||
keyCode | ||
} = event; | ||
var isArrowKey = keyCode >= 37 && keyCode <= 40 && key.indexOf("Arrow") !== 0; | ||
var eventKey = isArrowKey ? "Arrow" + key : key; | ||
return eventKey; | ||
} | ||
export var dataAttr = condition => condition ? "" : undefined; | ||
@@ -35,0 +18,0 @@ export var ariaAttr = condition => condition ? true : undefined; |
@@ -10,3 +10,2 @@ export * from "./function"; | ||
export * from "./assertion"; | ||
export * from "./react-helpers"; | ||
export * from "css-box-model"; | ||
@@ -13,0 +12,0 @@ export * from "./responsive"; |
@@ -43,1 +43,2 @@ export declare function getFirstItem<T>(array: T[]): T | undefined; | ||
export declare function getNextItemFromSearch<T>(items: T[], searchString: string, itemToString: (item: T) => string, currentItem: T): T | undefined; | ||
//# sourceMappingURL=array.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { ChangeEvent } from "react"; | ||
export declare function isNumber(value: any): value is number; | ||
@@ -16,3 +15,2 @@ export declare const isNotNumber: (value: any) => boolean; | ||
export declare function isCssVar(value: string): boolean; | ||
export declare function isInputEvent(value: any): value is ChangeEvent; | ||
export declare const isEmpty: (value: any) => boolean; | ||
@@ -23,1 +21,2 @@ export declare const __DEV__: boolean; | ||
}; | ||
//# sourceMappingURL=assertion.d.ts.map |
@@ -1,3 +0,1 @@ | ||
/// <reference types="react" /> | ||
export declare const isRightClick: <E extends MouseEvent | import("react").MouseEvent<Element, MouseEvent>>(event: E) => boolean; | ||
export declare function getAllFocusable<T extends HTMLElement>(container: T): T[]; | ||
@@ -13,1 +11,2 @@ export declare function getFirstFocusable<T extends HTMLElement>(container: T): T | null; | ||
export declare function closest<T extends HTMLElement>(element: T, selectors: string): Element | null; | ||
//# sourceMappingURL=dom-query.d.ts.map |
@@ -1,13 +0,6 @@ | ||
import * as React from "react"; | ||
import { Booleanish, EventKeys } from "./types"; | ||
import { Booleanish } from "./types"; | ||
export declare function getOwnerWindow(node?: HTMLElement | null): Window & typeof globalThis; | ||
export declare function getOwnerDocument(node?: HTMLElement | null): Document; | ||
export declare function getRelatedTarget<E extends FocusEvent | React.FocusEvent>(event: E): HTMLElement; | ||
export declare function canUseDOM(): boolean; | ||
export declare const isBrowser: boolean; | ||
/** | ||
* Get the normalized event key across all browsers | ||
* @param event keyboard event | ||
*/ | ||
export declare function normalizeEventKey(event: React.KeyboardEvent): EventKeys; | ||
export declare const dataAttr: (condition: boolean | undefined) => Booleanish; | ||
@@ -19,1 +12,2 @@ export declare const ariaAttr: (condition: boolean | undefined) => true | undefined; | ||
export declare function addDomEvent(target: EventTarget, eventName: string, handler: EventListener, options?: AddEventListenerOptions): () => void; | ||
//# sourceMappingURL=dom.d.ts.map |
@@ -17,1 +17,2 @@ import { FocusableElement, isActiveElement } from "./tabbable"; | ||
export declare function focus(element: FocusableElement | null, options?: ExtendedFocusOptions): number; | ||
//# sourceMappingURL=focus.d.ts.map |
@@ -10,1 +10,2 @@ import { AnyFunction, FunctionArguments } from "./types"; | ||
export declare const error: (this: any, ...args: any[]) => any; | ||
//# sourceMappingURL=function.d.ts.map |
@@ -10,3 +10,2 @@ export * from "./function"; | ||
export * from "./assertion"; | ||
export * from "./react-helpers"; | ||
export * from "css-box-model"; | ||
@@ -17,1 +16,2 @@ export * from "./responsive"; | ||
export * from "./user-agent"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -50,1 +50,2 @@ export declare const minSafeInteger: number; | ||
export declare function clampValue(value: number, min: number, max: number): number; | ||
//# sourceMappingURL=number.d.ts.map |
@@ -43,1 +43,2 @@ import type { Dict } from "./types"; | ||
export declare const getCSSVar: (theme: Dict, scale: string, value: any) => any; | ||
//# sourceMappingURL=object.d.ts.map |
@@ -25,1 +25,2 @@ /** | ||
export {}; | ||
//# sourceMappingURL=pointer-event.d.ts.map |
@@ -35,1 +35,2 @@ import { Dict } from "./types"; | ||
export declare const isCustomBreakpoint: (maybeBreakpoint: string) => boolean; | ||
//# sourceMappingURL=responsive.d.ts.map |
@@ -16,1 +16,2 @@ export declare const hasDisplayNone: (element: HTMLElement) => boolean; | ||
export declare function isTabbable(element?: HTMLElement | null): boolean; | ||
//# sourceMappingURL=tabbable.d.ts.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
export declare type Merge<T, P> = P & Omit<T, keyof P>; | ||
@@ -11,8 +10,5 @@ export declare type UnionStringArray<T extends Readonly<string[]>> = T[number]; | ||
export declare type Dict<T = any> = Record<string, T>; | ||
export declare type MaybeRenderProp<P> = React.ReactNode | ((props: P) => React.ReactNode); | ||
export declare type Booleanish = boolean | "true" | "false"; | ||
export declare type StringOrNumber = string | number; | ||
export declare type HTMLProps<T = any> = Omit<React.HTMLAttributes<T>, "color" | "width" | "height"> & React.RefAttributes<T>; | ||
export declare type PropGetter<T extends HTMLElement = any, P = {}> = (props?: Merge<HTMLProps<T>, P>, ref?: React.Ref<any> | React.RefObject<any>) => Merge<HTMLProps<T>, P>; | ||
export declare type EventKeys = "ArrowDown" | "ArrowUp" | "ArrowLeft" | "ArrowRight" | "Enter" | "Space" | "Tab" | "Backspace" | "Control" | "Meta" | "Home" | "End" | "PageDown" | "PageUp" | "Delete" | "Escape" | " " | "Shift"; | ||
export declare type EventKeyMap = Partial<Record<EventKeys, React.KeyboardEventHandler>>; | ||
//# sourceMappingURL=types.d.ts.map |
export declare function detectOS(string: string): boolean; | ||
export declare function detectBrowser(string: string): boolean; | ||
//# sourceMappingURL=user-agent.d.ts.map |
{ | ||
"name": "@chakra-ui/utils", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Common utilties and types for Chakra UI", | ||
@@ -47,12 +47,5 @@ "author": "Segun Adebayo <sage@adebayosegun.com>", | ||
"@types/lodash.mergewith": "4.6.6", | ||
"@types/object-assign": "4.0.30", | ||
"css-box-model": "1.2.1", | ||
"lodash.mergewith": "4.6.2" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.8.6" | ||
}, | ||
"devDependencies": { | ||
"react": "^17.0.1" | ||
} | ||
} |
# Utilities | ||
Shared utilities for various Chakra UI components | ||
Shared Vanilla TS/JS utilities for various Chakra UI components and packages. | ||
@@ -5,0 +5,0 @@ > **Note **: This package is intended for internal use by the Chakra UI |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
0
87
278399
2624
- Removed@types/object-assign@4.0.30
- Removed@types/object-assign@4.0.30(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.3.1(transitive)