@yamada-ui/utils 2.3.0 → 2.4.0-dev-20261125051132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/event.cjs +5 -1
- package/dist/cjs/event.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -3
- package/dist/esm/event.js +5 -2
- package/dist/esm/event.js.map +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/types/array.d.ts +1 -2
- package/dist/types/assertion.d.ts +1 -2
- package/dist/types/calc.d.ts +1 -2
- package/dist/types/color.d.ts +1 -2
- package/dist/types/dom.d.ts +1 -2
- package/dist/types/event.d.ts +2 -2
- package/dist/types/function.d.ts +1 -2
- package/dist/types/i18n.d.ts +1 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.type.d.ts +1 -2
- package/dist/types/module.d.ts +1 -2
- package/dist/types/number.d.ts +1 -2
- package/dist/types/object.d.ts +1 -2
- package/dist/types/string.d.ts +1 -2
- package/package.json +3 -3
package/dist/cjs/event.cjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const require_assertion = require("./assertion.cjs");
|
|
2
|
-
const require_function = require("./function.cjs");
|
|
3
2
|
const require_dom = require("./dom.cjs");
|
|
3
|
+
const require_function = require("./function.cjs");
|
|
4
4
|
// src/event.ts
|
|
5
|
+
function isComposing(ev) {
|
|
6
|
+
return "isComposing" in ev && ev.isComposing === true || "keyCode" in ev && ev.keyCode === 229;
|
|
7
|
+
}
|
|
5
8
|
function isMouseEvent(ev) {
|
|
6
9
|
const win = getEventWindow(ev);
|
|
7
10
|
if (typeof win.PointerEvent !== "undefined" && ev instanceof win.PointerEvent) return !!(ev.pointerType === "mouse");
|
|
@@ -90,6 +93,7 @@ exports.focusTransfer = focusTransfer;
|
|
|
90
93
|
exports.focusTrap = focusTrap;
|
|
91
94
|
exports.getEventPoint = getEventPoint;
|
|
92
95
|
exports.getEventWindow = getEventWindow;
|
|
96
|
+
exports.isComposing = isComposing;
|
|
93
97
|
exports.isMouseEvent = isMouseEvent;
|
|
94
98
|
exports.isMultiTouchEvent = isMultiTouchEvent;
|
|
95
99
|
exports.isTouchEvent = isTouchEvent;
|
package/dist/cjs/event.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.cjs","names":["noop","isShadowRoot","getDocument","getTabbableElementEdges","getActiveElement","isFunction","getNextTabbableElement"],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getActiveElement,\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\n isShadowRoot,\n} from \"./dom\"\nimport { noop } from \"./function\"\n\nexport type AnyPointerEvent = MouseEvent | PointerEvent | TouchEvent\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport function isMouseEvent(ev: any): ev is MouseEvent {\n const win = getEventWindow(ev)\n\n if (typeof win.PointerEvent !== \"undefined\" && ev instanceof win.PointerEvent)\n return !!(ev.pointerType === \"mouse\")\n\n return ev instanceof win.MouseEvent\n}\n\nexport function isTouchEvent(ev: AnyPointerEvent): ev is TouchEvent {\n return !!(ev as TouchEvent).touches\n}\n\nexport function isMultiTouchEvent(ev: AnyPointerEvent): boolean {\n return isTouchEvent(ev) && ev.touches.length > 1\n}\n\nexport function getEventWindow(ev: Event): typeof globalThis {\n return ((ev as UIEvent).view ?? window) as unknown as typeof globalThis\n}\n\nexport function pointFromTouch(\n e: TouchEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n const point = e.touches[0] || e.changedTouches[0]\n\n return { x: point?.[`${type}X`] ?? 0, y: point?.[`${type}Y`] ?? 0 }\n}\n\nexport function pointFromMouse(\n point: MouseEvent | PointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return {\n x: point[`${type}X`],\n y: point[`${type}Y`],\n }\n}\n\nexport function getEventPoint(\n ev: AnyPointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type)\n}\n\nexport interface EventMap\n extends\n DocumentEventMap,\n GlobalEventHandlersEventMap,\n WindowEventMap,\n FontFaceSetEventMap {}\n\nexport type EventType = keyof EventMap\n\nexport function addDomEvent<Y extends EventType>(\n target: EventTarget,\n type: Y,\n cb: (ev: EventMap[Y]) => void,\n options?: AddEventListenerOptions | boolean,\n) {\n target.addEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n\n return () => {\n target.removeEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n }\n}\n\nexport function focusTrap(\n el: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n if (!el) return noop\n\n const rootNode = el.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(el)\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n\n if (ev.shiftKey) {\n if (getActiveElement(root) === firstTabbable) elToFocus = lastTabbable\n } else {\n if (getActiveElement(root) === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(el, \"keydown\", onKeyDown, true)\n}\n\nexport function focusTransfer(\n el: HTMLElement | null,\n target?: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n const targetRootNode = target?.getRootNode()\n const doc = getDocument(el)\n const tabbableRoot = isShadowRoot(targetRootNode) ? targetRootNode : doc.body\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n const nextTabbable = getNextTabbableElement(tabbableRoot, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n const activeElement = getActiveElement(doc)\n\n if (ev.shiftKey) {\n if (nextTabbable === activeElement) {\n if (activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (activeElement === firstTabbable || noTabbableEls) {\n if (activeElement !== target) elToFocus = target\n }\n } else {\n if (activeElement === target) {\n if (activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (activeElement === lastTabbable || noTabbableEls) {\n if (activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;AAiBA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,EAAE;CAE7B,IAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,cAC/D,OAAO,CAAC,EAAE,GAAG,gBAAgB;CAE/B,OAAO,cAAc,IAAI;AAC3B;AAEA,SAAgB,aAAa,IAAuC;CAClE,OAAO,CAAC,CAAE,GAAkB;AAC9B;AAEA,SAAgB,kBAAkB,IAA8B;CAC9D,OAAO,aAAa,EAAE,KAAK,GAAG,QAAQ,SAAS;AACjD;AAEA,SAAgB,eAAe,IAA8B;CAC3D,OAAS,GAAe,QAAQ;AAClC;AAEA,SAAgB,eACd,GACA,OAA0B,UACnB;CACP,MAAM,QAAQ,EAAE,QAAQ,MAAM,EAAE,eAAe;CAE/C,OAAO;EAAE,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG,GAAG,QAAQ,GAAG,KAAK,OAAO;CAAE;AACpE;AAEA,SAAgB,eACd,OACA,OAA0B,UACnB;CACP,OAAO;EACL,GAAG,MAAM,GAAG,KAAK;EACjB,GAAG,MAAM,GAAG,KAAK;CACnB;AACF;AAEA,SAAgB,cACd,IACA,OAA0B,UACnB;CACP,OAAO,aAAa,EAAE,IAAI,eAAe,IAAI,IAAI,IAAI,eAAe,IAAI,IAAI;AAC9E;AAWA,SAAgB,YACd,QACA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AC3C,IAAI,kBAAkB,iBAAiB,eACxC;QAAA,kBAAkB,QAAQ,YAAY;GAAA;EAE9C,OACE,IAAI,kBAAkB,QAChB;OAAA,kBAAkB,eAAe,YAAY;EAAA,OAC5C,IAAI,kBAAkB,gBAAgB,eACvC;OAAA,kBAAkB,cAAc,YAAY;EAAA;EAIpD,IAAI,CAAC,WAAW;EAEhB,GAAG,eAAe;EAElB,IAAIC,kBAAAA,WAAW,OAAO,GAAG,QAAQ,SAAS;OACrC,UAAU,MAAM;CACvB;CAEA,OAAO,YAAY,KAAK,WAAW,WAAW,IAAI;AACpD"}
|
|
1
|
+
{"version":3,"file":"event.cjs","names":["noop","isShadowRoot","getDocument","getTabbableElementEdges","getActiveElement","isFunction","getNextTabbableElement"],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getActiveElement,\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\n isShadowRoot,\n} from \"./dom\"\nimport { noop } from \"./function\"\n\nexport type AnyPointerEvent = MouseEvent | PointerEvent | TouchEvent\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport function isComposing(ev: Event): boolean {\n return (\n (\"isComposing\" in ev && ev.isComposing === true) ||\n (\"keyCode\" in ev && ev.keyCode === 229)\n )\n}\n\nexport function isMouseEvent(ev: any): ev is MouseEvent {\n const win = getEventWindow(ev)\n\n if (typeof win.PointerEvent !== \"undefined\" && ev instanceof win.PointerEvent)\n return !!(ev.pointerType === \"mouse\")\n\n return ev instanceof win.MouseEvent\n}\n\nexport function isTouchEvent(ev: AnyPointerEvent): ev is TouchEvent {\n return !!(ev as TouchEvent).touches\n}\n\nexport function isMultiTouchEvent(ev: AnyPointerEvent): boolean {\n return isTouchEvent(ev) && ev.touches.length > 1\n}\n\nexport function getEventWindow(ev: Event): typeof globalThis {\n return ((ev as UIEvent).view ?? window) as unknown as typeof globalThis\n}\n\nexport function pointFromTouch(\n e: TouchEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n const point = e.touches[0] || e.changedTouches[0]\n\n return { x: point?.[`${type}X`] ?? 0, y: point?.[`${type}Y`] ?? 0 }\n}\n\nexport function pointFromMouse(\n point: MouseEvent | PointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return {\n x: point[`${type}X`],\n y: point[`${type}Y`],\n }\n}\n\nexport function getEventPoint(\n ev: AnyPointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type)\n}\n\nexport interface EventMap\n extends\n DocumentEventMap,\n GlobalEventHandlersEventMap,\n WindowEventMap,\n FontFaceSetEventMap {}\n\nexport type EventType = keyof EventMap\n\nexport function addDomEvent<Y extends EventType>(\n target: EventTarget,\n type: Y,\n cb: (ev: EventMap[Y]) => void,\n options?: AddEventListenerOptions | boolean,\n) {\n target.addEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n\n return () => {\n target.removeEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n }\n}\n\nexport function focusTrap(\n el: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n if (!el) return noop\n\n const rootNode = el.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(el)\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n\n if (ev.shiftKey) {\n if (getActiveElement(root) === firstTabbable) elToFocus = lastTabbable\n } else {\n if (getActiveElement(root) === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(el, \"keydown\", onKeyDown, true)\n}\n\nexport function focusTransfer(\n el: HTMLElement | null,\n target?: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n const targetRootNode = target?.getRootNode()\n const doc = getDocument(el)\n const tabbableRoot = isShadowRoot(targetRootNode) ? targetRootNode : doc.body\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n const nextTabbable = getNextTabbableElement(tabbableRoot, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n const activeElement = getActiveElement(doc)\n\n if (ev.shiftKey) {\n if (nextTabbable === activeElement) {\n if (activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (activeElement === firstTabbable || noTabbableEls) {\n if (activeElement !== target) elToFocus = target\n }\n } else {\n if (activeElement === target) {\n if (activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (activeElement === lastTabbable || noTabbableEls) {\n if (activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;AAiBA,SAAgB,YAAY,IAAoB;CAC9C,OACG,iBAAiB,MAAM,GAAG,gBAAgB,QAC1C,aAAa,MAAM,GAAG,YAAY;AAEvC;AAEA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,EAAE;CAE7B,IAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,cAC/D,OAAO,CAAC,EAAE,GAAG,gBAAgB;CAE/B,OAAO,cAAc,IAAI;AAC3B;AAEA,SAAgB,aAAa,IAAuC;CAClE,OAAO,CAAC,CAAE,GAAkB;AAC9B;AAEA,SAAgB,kBAAkB,IAA8B;CAC9D,OAAO,aAAa,EAAE,KAAK,GAAG,QAAQ,SAAS;AACjD;AAEA,SAAgB,eAAe,IAA8B;CAC3D,OAAS,GAAe,QAAQ;AAClC;AAEA,SAAgB,eACd,GACA,OAA0B,U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AAM,eAAeD,YAAAA,aAAa,cAAc,IAAI,iBAAiB,IAAI;CAEzE,SAAS,UAAU,IAAmB;EACpC,IAAI,GAAG,QAAQ,OAAO;EAEtB,IAAI,YAA4C;EAEhD,MAAM,CAAC,eAAe,gBAAgBE,YAAAA,wBAAwB,IAAI,KAAK;EACvE,MAAM,eAAeG,YAAAA,uBAAuB,cAAc,MAAM;EAChE,MAAM,gBAAgB,CAAC,iBAAiB,CAAC;EACzC,MAAM,gBAAgBF,YAAAA,iBAAiB,GAAG;EAE1C,IAAI,GAAG,UAAU;GACf,IAAI,iBAAiB,eACf;QAAA,kBAAkB,cAAc,YAAY;GAAA,OAC3C,IAAI,kBAAkB,iBAAiB,eACxC;QAAA,kBAAkB,QAAQ,YAAY;GAAA;EAE9C,OACE,IAAI,kBAAkB,QAChB;OAAA,kBAAkB,eAAe,YAAY;EAAA,OAC5C,IAAI,kBAAkB,gBAAgB,eACvC;OAAA,kBAAkB,cAAc,YAAY;EAAA;EAIpD,IAAI,CAAC,WAAW;EAEhB,GAAG,eAAe;EAElB,IAAIC,kBAAAA,WAAW,OAAO,GAAG,QAAQ,SAAS;OACrC,UAAU,MAAM;CACvB;CAEA,OAAO,YAAY,KAAK,WAAW,WAAW,IAAI;AACpD"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_assertion = require("./assertion.cjs");
|
|
3
2
|
const require_array = require("./array.cjs");
|
|
3
|
+
const require_assertion = require("./assertion.cjs");
|
|
4
4
|
const require_calc = require("./calc.cjs");
|
|
5
5
|
const require_color = require("./color.cjs");
|
|
6
|
-
const require_function = require("./function.cjs");
|
|
7
|
-
const require_string = require("./string.cjs");
|
|
8
6
|
const require_dom = require("./dom.cjs");
|
|
9
7
|
const require_event = require("./event.cjs");
|
|
8
|
+
const require_function = require("./function.cjs");
|
|
10
9
|
const require_i18n = require("./i18n.cjs");
|
|
11
10
|
const require_module = require("./module.cjs");
|
|
12
11
|
const require_number = require("./number.cjs");
|
|
13
12
|
const require_object = require("./object.cjs");
|
|
13
|
+
const require_string = require("./string.cjs");
|
|
14
14
|
exports.COLOR_SCHEMES = require_color.COLOR_SCHEMES;
|
|
15
15
|
exports.DEFAULT_COLOR_SCHEMES = require_color.DEFAULT_COLOR_SCHEMES;
|
|
16
16
|
exports.SEMANTIC_COLOR_SCHEMES = require_color.SEMANTIC_COLOR_SCHEMES;
|
|
@@ -75,6 +75,7 @@ exports.isArray = require_assertion.isArray;
|
|
|
75
75
|
exports.isBoolean = require_assertion.isBoolean;
|
|
76
76
|
exports.isBooleanish = require_assertion.isBooleanish;
|
|
77
77
|
exports.isChrome = require_dom.isChrome;
|
|
78
|
+
exports.isComposing = require_event.isComposing;
|
|
78
79
|
exports.isDate = require_assertion.isDate;
|
|
79
80
|
exports.isDisabledElement = require_dom.isDisabledElement;
|
|
80
81
|
exports.isDocument = require_dom.isDocument;
|
package/dist/esm/event.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { isFunction } from "./assertion.js";
|
|
2
|
-
import { noop } from "./function.js";
|
|
3
2
|
import { getActiveElement, getDocument, getNextTabbableElement, getTabbableElementEdges, isShadowRoot } from "./dom.js";
|
|
3
|
+
import { noop } from "./function.js";
|
|
4
4
|
// src/event.ts
|
|
5
|
+
function isComposing(ev) {
|
|
6
|
+
return "isComposing" in ev && ev.isComposing === true || "keyCode" in ev && ev.keyCode === 229;
|
|
7
|
+
}
|
|
5
8
|
function isMouseEvent(ev) {
|
|
6
9
|
const win = getEventWindow(ev);
|
|
7
10
|
if (typeof win.PointerEvent !== "undefined" && ev instanceof win.PointerEvent) return !!(ev.pointerType === "mouse");
|
|
@@ -85,6 +88,6 @@ function focusTransfer(el, target, onFocus) {
|
|
|
85
88
|
}
|
|
86
89
|
return addDomEvent(doc, "keydown", onKeyDown, true);
|
|
87
90
|
}
|
|
88
|
-
export { addDomEvent, focusTransfer, focusTrap, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };
|
|
91
|
+
export { addDomEvent, focusTransfer, focusTrap, getEventPoint, getEventWindow, isComposing, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch };
|
|
89
92
|
|
|
90
93
|
//# sourceMappingURL=event.js.map
|
package/dist/esm/event.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","names":[],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getActiveElement,\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\n isShadowRoot,\n} from \"./dom\"\nimport { noop } from \"./function\"\n\nexport type AnyPointerEvent = MouseEvent | PointerEvent | TouchEvent\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport function isMouseEvent(ev: any): ev is MouseEvent {\n const win = getEventWindow(ev)\n\n if (typeof win.PointerEvent !== \"undefined\" && ev instanceof win.PointerEvent)\n return !!(ev.pointerType === \"mouse\")\n\n return ev instanceof win.MouseEvent\n}\n\nexport function isTouchEvent(ev: AnyPointerEvent): ev is TouchEvent {\n return !!(ev as TouchEvent).touches\n}\n\nexport function isMultiTouchEvent(ev: AnyPointerEvent): boolean {\n return isTouchEvent(ev) && ev.touches.length > 1\n}\n\nexport function getEventWindow(ev: Event): typeof globalThis {\n return ((ev as UIEvent).view ?? window) as unknown as typeof globalThis\n}\n\nexport function pointFromTouch(\n e: TouchEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n const point = e.touches[0] || e.changedTouches[0]\n\n return { x: point?.[`${type}X`] ?? 0, y: point?.[`${type}Y`] ?? 0 }\n}\n\nexport function pointFromMouse(\n point: MouseEvent | PointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return {\n x: point[`${type}X`],\n y: point[`${type}Y`],\n }\n}\n\nexport function getEventPoint(\n ev: AnyPointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type)\n}\n\nexport interface EventMap\n extends\n DocumentEventMap,\n GlobalEventHandlersEventMap,\n WindowEventMap,\n FontFaceSetEventMap {}\n\nexport type EventType = keyof EventMap\n\nexport function addDomEvent<Y extends EventType>(\n target: EventTarget,\n type: Y,\n cb: (ev: EventMap[Y]) => void,\n options?: AddEventListenerOptions | boolean,\n) {\n target.addEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n\n return () => {\n target.removeEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n }\n}\n\nexport function focusTrap(\n el: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n if (!el) return noop\n\n const rootNode = el.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(el)\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n\n if (ev.shiftKey) {\n if (getActiveElement(root) === firstTabbable) elToFocus = lastTabbable\n } else {\n if (getActiveElement(root) === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(el, \"keydown\", onKeyDown, true)\n}\n\nexport function focusTransfer(\n el: HTMLElement | null,\n target?: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n const targetRootNode = target?.getRootNode()\n const doc = getDocument(el)\n const tabbableRoot = isShadowRoot(targetRootNode) ? targetRootNode : doc.body\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n const nextTabbable = getNextTabbableElement(tabbableRoot, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n const activeElement = getActiveElement(doc)\n\n if (ev.shiftKey) {\n if (nextTabbable === activeElement) {\n if (activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (activeElement === firstTabbable || noTabbableEls) {\n if (activeElement !== target) elToFocus = target\n }\n } else {\n if (activeElement === target) {\n if (activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (activeElement === lastTabbable || noTabbableEls) {\n if (activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;AAiBA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,EAAE;CAE7B,IAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,cAC/D,OAAO,CAAC,EAAE,GAAG,gBAAgB;CAE/B,OAAO,cAAc,IAAI;AAC3B;AAEA,SAAgB,aAAa,IAAuC;CAClE,OAAO,CAAC,CAAE,GAAkB;AAC9B;AAEA,SAAgB,kBAAkB,IAA8B;CAC9D,OAAO,aAAa,EAAE,KAAK,GAAG,QAAQ,SAAS;AACjD;AAEA,SAAgB,eAAe,IAA8B;CAC3D,OAAS,GAAe,QAAQ;AAClC;AAEA,SAAgB,eACd,GACA,OAA0B,UACnB;CACP,MAAM,QAAQ,EAAE,QAAQ,MAAM,EAAE,eAAe;CAE/C,OAAO;EAAE,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG,GAAG,QAAQ,GAAG,KAAK,OAAO;CAAE;AACpE;AAEA,SAAgB,eACd,OACA,OAA0B,UACnB;CACP,OAAO;EACL,GAAG,MAAM,GAAG,KAAK;EACjB,GAAG,MAAM,GAAG,KAAK;CACnB;AACF;AAEA,SAAgB,cACd,IACA,OAA0B,UACnB;CACP,OAAO,aAAa,EAAE,IAAI,eAAe,IAAI,IAAI,I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Q,YAAY;GAAA;EAE9C,OACE,IAAI,kBAAkB,QAChB;OAAA,kBAAkB,eAAe,YAAY;EAAA,OAC5C,IAAI,kBAAkB,gBAAgB,eACvC;OAAA,kBAAkB,cAAc,YAAY;EAAA;EAIpD,IAAI,CAAC,WAAW;EAEhB,GAAG,eAAe;EAElB,IAAI,WAAW,OAAO,GAAG,QAAQ,SAAS;OACrC,UAAU,MAAM;CACvB;CAEA,OAAO,YAAY,KAAK,WAAW,WAAW,IAAI;AACpD"}
|
|
1
|
+
{"version":3,"file":"event.js","names":[],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getActiveElement,\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\n isShadowRoot,\n} from \"./dom\"\nimport { noop } from \"./function\"\n\nexport type AnyPointerEvent = MouseEvent | PointerEvent | TouchEvent\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport function isComposing(ev: Event): boolean {\n return (\n (\"isComposing\" in ev && ev.isComposing === true) ||\n (\"keyCode\" in ev && ev.keyCode === 229)\n )\n}\n\nexport function isMouseEvent(ev: any): ev is MouseEvent {\n const win = getEventWindow(ev)\n\n if (typeof win.PointerEvent !== \"undefined\" && ev instanceof win.PointerEvent)\n return !!(ev.pointerType === \"mouse\")\n\n return ev instanceof win.MouseEvent\n}\n\nexport function isTouchEvent(ev: AnyPointerEvent): ev is TouchEvent {\n return !!(ev as TouchEvent).touches\n}\n\nexport function isMultiTouchEvent(ev: AnyPointerEvent): boolean {\n return isTouchEvent(ev) && ev.touches.length > 1\n}\n\nexport function getEventWindow(ev: Event): typeof globalThis {\n return ((ev as UIEvent).view ?? window) as unknown as typeof globalThis\n}\n\nexport function pointFromTouch(\n e: TouchEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n const point = e.touches[0] || e.changedTouches[0]\n\n return { x: point?.[`${type}X`] ?? 0, y: point?.[`${type}Y`] ?? 0 }\n}\n\nexport function pointFromMouse(\n point: MouseEvent | PointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return {\n x: point[`${type}X`],\n y: point[`${type}Y`],\n }\n}\n\nexport function getEventPoint(\n ev: AnyPointerEvent,\n type: \"client\" | \"page\" = \"client\",\n): Point {\n return isTouchEvent(ev) ? pointFromTouch(ev, type) : pointFromMouse(ev, type)\n}\n\nexport interface EventMap\n extends\n DocumentEventMap,\n GlobalEventHandlersEventMap,\n WindowEventMap,\n FontFaceSetEventMap {}\n\nexport type EventType = keyof EventMap\n\nexport function addDomEvent<Y extends EventType>(\n target: EventTarget,\n type: Y,\n cb: (ev: EventMap[Y]) => void,\n options?: AddEventListenerOptions | boolean,\n) {\n target.addEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n\n return () => {\n target.removeEventListener(\n type,\n cb as EventListenerOrEventListenerObject,\n options,\n )\n }\n}\n\nexport function focusTrap(\n el: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n if (!el) return noop\n\n const rootNode = el.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(el)\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n\n if (ev.shiftKey) {\n if (getActiveElement(root) === firstTabbable) elToFocus = lastTabbable\n } else {\n if (getActiveElement(root) === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(el, \"keydown\", onKeyDown, true)\n}\n\nexport function focusTransfer(\n el: HTMLElement | null,\n target?: HTMLElement | null,\n onFocus?: (elToFocus: HTMLElement) => void,\n) {\n const targetRootNode = target?.getRootNode()\n const doc = getDocument(el)\n const tabbableRoot = isShadowRoot(targetRootNode) ? targetRootNode : doc.body\n\n function onKeyDown(ev: KeyboardEvent) {\n if (ev.key !== \"Tab\") return\n\n let elToFocus: HTMLElement | null | undefined = null\n\n const [firstTabbable, lastTabbable] = getTabbableElementEdges(el, false)\n const nextTabbable = getNextTabbableElement(tabbableRoot, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n const activeElement = getActiveElement(doc)\n\n if (ev.shiftKey) {\n if (nextTabbable === activeElement) {\n if (activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (activeElement === firstTabbable || noTabbableEls) {\n if (activeElement !== target) elToFocus = target\n }\n } else {\n if (activeElement === target) {\n if (activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (activeElement === lastTabbable || noTabbableEls) {\n if (activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) onFocus(elToFocus)\n else elToFocus.focus()\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;AAiBA,SAAgB,YAAY,IAAoB;CAC9C,OACG,iBAAiB,MAAM,GAAG,gBAAgB,QAC1C,aAAa,MAAM,GAAG,YAAY;AAEvC;AAEA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,EAAE;CAE7B,IAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,cAC/D,OAAO,CAAC,EAAE,GAAG,gBAAgB;CAE/B,OAAO,cAAc,IAAI;AAC3B;AAEA,SAAgB,aAAa,IAAuC;CAClE,OAAO,CAAC,CAAE,GAAkB;AAC9B;AAEA,SAAgB,kBAAkB,IAA8B;CAC9D,OAAO,aAAa,EAAE,KAAK,GAAG,QAAQ,SAAS;AACjD;AAEA,SAAgB,eAAe,IAA8B;CAC3D,OAAS,GAAe,QAAQ;AAClC;AAEA,SAAgB,eACd,GACA,OAA0B,UACnB;CACP,MAAM,QAAQ,EAAE,QAAQ,MAAM,EAAE,eAAe;CAE/C,OAAO;EAAE,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG,GAAG,QAAQ,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BAAuB,cAAc,MAAM;EAChE,MAAM,gBAAgB,CAAC,iBAAiB,CAAC;EACzC,MAAM,gBAAgB,iBAAiB,GAAG;EAE1C,IAAI,GAAG,UAAU;GACf,IAAI,iBAAiB,eACf;QAAA,kBAAkB,cAAc,YAAY;GAAA,OAC3C,IAAI,kBAAkB,iBAAiB,eACxC;QAAA,kBAAkB,QAAQ,YAAY;GAAA;EAE9C,OACE,IAAI,kBAAkB,QAChB;OAAA,kBAAkB,eAAe,YAAY;EAAA,OAC5C,IAAI,kBAAkB,gBAAgB,eACvC;OAAA,kBAAkB,cAAc,YAAY;EAAA;EAIpD,IAAI,CAAC,WAAW;EAEhB,GAAG,eAAe;EAElB,IAAI,WAAW,OAAO,GAAG,QAAQ,SAAS;OACrC,UAAU,MAAM;CACvB;CAEA,OAAO,YAAY,KAAK,WAAW,WAAW,IAAI;AACpD"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { cast, is, isArray, isBoolean, isBooleanish, isDate, isEmpty, isEmptyObject, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isRegExp, isString, isUndefined, isUnit } from "./assertion.js";
|
|
2
1
|
import { filterEmpty, toArray } from "./array.js";
|
|
2
|
+
import { cast, is, isArray, isBoolean, isBooleanish, isDate, isEmpty, isEmptyObject, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isRegExp, isString, isUndefined, isUnit } from "./assertion.js";
|
|
3
3
|
import { calc } from "./calc.js";
|
|
4
4
|
import { COLOR_SCHEMES, DEFAULT_COLOR_SCHEMES, SEMANTIC_COLOR_SCHEMES, TONES, alphaToHex, calcFormat, convertColor, getAlpha, hslaTo, hsvTo, parseToHsla, parseToHsv, parseToRgba, rgbaTo, sameColor } from "./color.js";
|
|
5
|
-
import { fnAll, handlerAll, noop, runIfFn, wait } from "./function.js";
|
|
6
|
-
import { antonym, bem, cx, escape, isSize, match, toCamelCase, toKebabCase, toPascalCase, toTitleCase, transformSize } from "./string.js";
|
|
7
5
|
import { ariaAttr, contains, createdDom, dataAttr, getActiveElement, getDocument, getDocumentElement, getFirstFocusableElement, getFirstTabbableElement, getFocusableElements, getLastTabbableElement, getNextTabbableElement, getNodeName, getParentNode, getPlatform, getPx, getTabIndex, getTabbableElementEdges, getTabbableElements, getUserAgent, getWindow, isActiveElement, isAndroid, isApple, isChrome, isDisabledElement, isDocument, isEditableElement, isFirefox, isFocusableElement, isFrame, isHTMLElement, isHiddenElement, isIPad, isIPhone, isInputElement, isIos, isMac, isNode, isSafari, isShadowRoot, isTabbableElement, isTouchDevice, isTruthyDataAttr, isVisibleElement, isVisualViewport, isWebKit, isWindow, platform, scrollLock, setAttribute, setStyle, userAgent, uuid, vendor } from "./dom.js";
|
|
8
|
-
import { addDomEvent, focusTransfer, focusTrap, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch } from "./event.js";
|
|
6
|
+
import { addDomEvent, focusTransfer, focusTrap, getEventPoint, getEventWindow, isComposing, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch } from "./event.js";
|
|
7
|
+
import { fnAll, handlerAll, noop, runIfFn, wait } from "./function.js";
|
|
9
8
|
import { isRtl } from "./i18n.js";
|
|
10
9
|
import { interopDefault } from "./module.js";
|
|
11
10
|
import { clampNumber, countDecimal, percentToValue, roundNumberToStep, toNumber, toPrecision, valueToPercent } from "./number.js";
|
|
12
11
|
import { extractFlatObject, extractObject, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, has, memoizeObject, merge, objectKeys, omitObject, pickObject, replaceObject, splitObject, wrapWithKey } from "./object.js";
|
|
13
|
-
|
|
12
|
+
import { antonym, bem, cx, escape, isSize, match, toCamelCase, toKebabCase, toPascalCase, toTitleCase, transformSize } from "./string.js";
|
|
13
|
+
export { COLOR_SCHEMES, DEFAULT_COLOR_SCHEMES, SEMANTIC_COLOR_SCHEMES, TONES, addDomEvent, alphaToHex, antonym, ariaAttr, bem, calc, calcFormat, cast, clampNumber, contains, convertColor, countDecimal, createdDom, cx, dataAttr, escape, extractFlatObject, extractObject, filterEmpty, filterObject, filterUndefined, flattenObject, fnAll, focusTransfer, focusTrap, getActiveElement, getAlpha, getDocument, getDocumentElement, getEventPoint, getEventWindow, getFirstFocusableElement, getFirstTabbableElement, getFocusableElements, getLastTabbableElement, getMemoizedObject, getNextTabbableElement, getNodeName, getObject, getParentNode, getPlatform, getPx, getTabIndex, getTabbableElementEdges, getTabbableElements, getUserAgent, getWindow, handlerAll, has, hslaTo, hsvTo, interopDefault, is, isActiveElement, isAndroid, isApple, isArray, isBoolean, isBooleanish, isChrome, isComposing, isDate, isDisabledElement, isDocument, isEditableElement, isEmpty, isEmptyObject, isFirefox, isFocusableElement, isFrame, isFunction, isHTMLElement, isHiddenElement, isIPad, isIPhone, isInputElement, isIos, isMac, isMouseEvent, isMultiTouchEvent, isNode, isNotNumber, isNull, isNumber, isNumeric, isObject, isRegExp, isRtl, isSafari, isShadowRoot, isSize, isString, isTabbableElement, isTouchDevice, isTouchEvent, isTruthyDataAttr, isUndefined, isUnit, isVisibleElement, isVisualViewport, isWebKit, isWindow, match, memoizeObject, merge, noop, objectKeys, omitObject, parseToHsla, parseToHsv, parseToRgba, percentToValue, pickObject, platform, pointFromMouse, pointFromTouch, replaceObject, rgbaTo, roundNumberToStep, runIfFn, sameColor, scrollLock, setAttribute, setStyle, splitObject, toArray, toCamelCase, toKebabCase, toNumber, toPascalCase, toPrecision, toTitleCase, transformSize, userAgent, uuid, valueToPercent, vendor, wait, wrapWithKey };
|
package/dist/types/array.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export declare function filterEmpty<Y>(array: Y[]): Exclude<Y, null | undefined>[];
|
|
2
|
-
export declare function toArray<Y>(mixedArray: Y): Y extends any[] ? Exclude<Y[number], null | undefined>[] : Exclude<Y, null | undefined>[];
|
|
3
|
-
//# sourceMappingURL=array.d.ts.map
|
|
2
|
+
export declare function toArray<Y>(mixedArray: Y): Y extends any[] ? Exclude<Y[number], null | undefined>[] : Exclude<Y, null | undefined>[];
|
|
@@ -16,5 +16,4 @@ export declare function isEmpty(value: any): boolean;
|
|
|
16
16
|
export declare function isEmptyObject(value: any): boolean;
|
|
17
17
|
export declare function isFunction<Y extends Function = Function>(value: any): value is Y;
|
|
18
18
|
export declare function isUnit(value: any): boolean;
|
|
19
|
-
export declare function cast<Y>(value: any): Y;
|
|
20
|
-
//# sourceMappingURL=assertion.d.ts.map
|
|
19
|
+
export declare function cast<Y>(value: any): Y;
|
package/dist/types/calc.d.ts
CHANGED
package/dist/types/color.d.ts
CHANGED
|
@@ -36,5 +36,4 @@ export declare function hsvTo([h, s, v, a]: [number, number, number, number?], f
|
|
|
36
36
|
export declare function hsvTo([h, s, v, a]: [number, number, number, number?], fallback?: string): {
|
|
37
37
|
(format?: ColorFormat): string | undefined;
|
|
38
38
|
};
|
|
39
|
-
export declare function sameColor(color: string | undefined, comparison: string | undefined): boolean;
|
|
40
|
-
//# sourceMappingURL=color.d.ts.map
|
|
39
|
+
export declare function sameColor(color: string | undefined, comparison: string | undefined): boolean;
|
package/dist/types/dom.d.ts
CHANGED
|
@@ -56,5 +56,4 @@ export declare function setStyle(el: HTMLElement | null | undefined, style: Part
|
|
|
56
56
|
[key: `--${string}`]: number | string;
|
|
57
57
|
}>): () => void;
|
|
58
58
|
export declare function scrollLock(el: Document | Element | Node | null | undefined | Window): (() => void) | undefined;
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=dom.d.ts.map
|
|
59
|
+
export {};
|
package/dist/types/event.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface Point {
|
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
}
|
|
6
|
+
export declare function isComposing(ev: Event): boolean;
|
|
6
7
|
export declare function isMouseEvent(ev: any): ev is MouseEvent;
|
|
7
8
|
export declare function isTouchEvent(ev: AnyPointerEvent): ev is TouchEvent;
|
|
8
9
|
export declare function isMultiTouchEvent(ev: AnyPointerEvent): boolean;
|
|
@@ -14,5 +15,4 @@ export interface EventMap extends DocumentEventMap, GlobalEventHandlersEventMap,
|
|
|
14
15
|
export type EventType = keyof EventMap;
|
|
15
16
|
export declare function addDomEvent<Y extends EventType>(target: EventTarget, type: Y, cb: (ev: EventMap[Y]) => void, options?: AddEventListenerOptions | boolean): () => void;
|
|
16
17
|
export declare function focusTrap(el: HTMLElement | null, onFocus?: (elToFocus: HTMLElement) => void): () => void;
|
|
17
|
-
export declare function focusTransfer(el: HTMLElement | null, target?: HTMLElement | null, onFocus?: (elToFocus: HTMLElement) => void): () => void;
|
|
18
|
-
//# sourceMappingURL=event.d.ts.map
|
|
18
|
+
export declare function focusTransfer(el: HTMLElement | null, target?: HTMLElement | null, onFocus?: (elToFocus: HTMLElement) => void): () => void;
|
package/dist/types/function.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ export declare const noop: () => void;
|
|
|
2
2
|
export declare const wait: (ms?: number) => Promise<void>;
|
|
3
3
|
export declare function runIfFn<Y, U extends any[]>(valOrFn: ((...args: U) => Y) | Y, ...args: U): Y;
|
|
4
4
|
export declare function handlerAll<Y extends (ev?: any, ...args: any[]) => void>(...fns: (null | undefined | Y)[]): (ev?: Y extends ((ev: infer R, ...args: any[]) => any) ? R : never, ...args: Y extends ((ev: any, ...args: infer R) => any) ? R : never) => void;
|
|
5
|
-
export declare function fnAll<Y extends (...args: any[]) => any>(...fns: (null | undefined | Y)[]): (...args: Y extends ((...args: infer R) => any) ? R : never) => void;
|
|
6
|
-
//# sourceMappingURL=function.d.ts.map
|
|
5
|
+
export declare function fnAll<Y extends (...args: any[]) => any>(...fns: (null | undefined | Y)[]): (...args: Y extends ((...args: infer R) => any) ? R : never) => void;
|
package/dist/types/i18n.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function isRtl(_locale: string): boolean;
|
|
2
|
-
//# sourceMappingURL=i18n.d.ts.map
|
|
1
|
+
export declare function isRtl(_locale: string): boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { filterEmpty, toArray } from "./array.js";
|
|
2
|
-
import { AnyString, Booleanish, DeepMerge, DeepPartial, Dict, FunctionOf, FunctionOrValue, Length, Merge, Path, Prettify, Primitive, ToFunction, Value } from "./index.type.js";
|
|
3
2
|
import { cast, is, isArray, isBoolean, isBooleanish, isDate, isEmpty, isEmptyObject, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isRegExp, isString, isUndefined, isUnit } from "./assertion.js";
|
|
4
3
|
import { calc } from "./calc.js";
|
|
5
4
|
import { COLOR_SCHEMES, ColorFormat, DEFAULT_COLOR_SCHEMES, SEMANTIC_COLOR_SCHEMES, TONES, alphaToHex, calcFormat, convertColor, getAlpha, hslaTo, hsvTo, parseToHsla, parseToHsv, parseToRgba, rgbaTo, sameColor } from "./color.js";
|
|
6
5
|
import { ariaAttr, contains, createdDom, dataAttr, getActiveElement, getDocument, getDocumentElement, getFirstFocusableElement, getFirstTabbableElement, getFocusableElements, getLastTabbableElement, getNextTabbableElement, getNodeName, getParentNode, getPlatform, getPx, getTabIndex, getTabbableElementEdges, getTabbableElements, getUserAgent, getWindow, isActiveElement, isAndroid, isApple, isChrome, isDisabledElement, isDocument, isEditableElement, isFirefox, isFocusableElement, isFrame, isHTMLElement, isHiddenElement, isIPad, isIPhone, isInputElement, isIos, isMac, isNode, isSafari, isShadowRoot, isTabbableElement, isTouchDevice, isTruthyDataAttr, isVisibleElement, isVisualViewport, isWebKit, isWindow, platform, scrollLock, setAttribute, setStyle, userAgent, uuid, vendor } from "./dom.js";
|
|
7
|
-
import { AnyPointerEvent, EventMap, EventType, Point, addDomEvent, focusTransfer, focusTrap, getEventPoint, getEventWindow, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch } from "./event.js";
|
|
6
|
+
import { AnyPointerEvent, EventMap, EventType, Point, addDomEvent, focusTransfer, focusTrap, getEventPoint, getEventWindow, isComposing, isMouseEvent, isMultiTouchEvent, isTouchEvent, pointFromMouse, pointFromTouch } from "./event.js";
|
|
8
7
|
import { fnAll, handlerAll, noop, runIfFn, wait } from "./function.js";
|
|
9
8
|
import { isRtl } from "./i18n.js";
|
|
9
|
+
import { AnyString, Booleanish, DeepMerge, DeepPartial, Dict, FunctionOf, FunctionOrValue, Length, Merge, Path, Prettify, Primitive, ToFunction, Value } from "./index.type.js";
|
|
10
10
|
import { interopDefault } from "./module.js";
|
|
11
11
|
import { clampNumber, countDecimal, percentToValue, roundNumberToStep, toNumber, toPrecision, valueToPercent } from "./number.js";
|
|
12
12
|
import { FlattenObjectOptions, HasOptions, MergeOptions, extractFlatObject, extractObject, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, has, memoizeObject, merge, objectKeys, omitObject, pickObject, replaceObject, splitObject, wrapWithKey } from "./object.js";
|
|
13
13
|
import { antonym, bem, cx, escape, isSize, match, toCamelCase, toKebabCase, toPascalCase, toTitleCase, transformSize } from "./string.js";
|
|
14
|
-
export { AnyPointerEvent, type AnyString, type Booleanish, COLOR_SCHEMES, ColorFormat, DEFAULT_COLOR_SCHEMES, type DeepMerge, type DeepPartial, type Dict, EventMap, EventType, FlattenObjectOptions, type FunctionOf, type FunctionOrValue, HasOptions, type Length, type Merge, MergeOptions, type Path, Point, type Prettify, type Primitive, SEMANTIC_COLOR_SCHEMES, TONES, type ToFunction, type Value, addDomEvent, alphaToHex, antonym, ariaAttr, bem, calc, calcFormat, cast, clampNumber, contains, convertColor, countDecimal, createdDom, cx, dataAttr, escape, extractFlatObject, extractObject, filterEmpty, filterObject, filterUndefined, flattenObject, fnAll, focusTransfer, focusTrap, getActiveElement, getAlpha, getDocument, getDocumentElement, getEventPoint, getEventWindow, getFirstFocusableElement, getFirstTabbableElement, getFocusableElements, getLastTabbableElement, getMemoizedObject, getNextTabbableElement, getNodeName, getObject, getParentNode, getPlatform, getPx, getTabIndex, getTabbableElementEdges, getTabbableElements, getUserAgent, getWindow, handlerAll, has, hslaTo, hsvTo, interopDefault, is, isActiveElement, isAndroid, isApple, isArray, isBoolean, isBooleanish, isChrome, isDate, isDisabledElement, isDocument, isEditableElement, isEmpty, isEmptyObject, isFirefox, isFocusableElement, isFrame, isFunction, isHTMLElement, isHiddenElement, isIPad, isIPhone, isInputElement, isIos, isMac, isMouseEvent, isMultiTouchEvent, isNode, isNotNumber, isNull, isNumber, isNumeric, isObject, isRegExp, isRtl, isSafari, isShadowRoot, isSize, isString, isTabbableElement, isTouchDevice, isTouchEvent, isTruthyDataAttr, isUndefined, isUnit, isVisibleElement, isVisualViewport, isWebKit, isWindow, match, memoizeObject, merge, noop, objectKeys, omitObject, parseToHsla, parseToHsv, parseToRgba, percentToValue, pickObject, platform, pointFromMouse, pointFromTouch, replaceObject, rgbaTo, roundNumberToStep, runIfFn, sameColor, scrollLock, setAttribute, setStyle, splitObject, toArray, toCamelCase, toKebabCase, toNumber, toPascalCase, toPrecision, toTitleCase, transformSize, userAgent, uuid, valueToPercent, vendor, wait, wrapWithKey };
|
|
14
|
+
export { AnyPointerEvent, type AnyString, type Booleanish, COLOR_SCHEMES, ColorFormat, DEFAULT_COLOR_SCHEMES, type DeepMerge, type DeepPartial, type Dict, EventMap, EventType, FlattenObjectOptions, type FunctionOf, type FunctionOrValue, HasOptions, type Length, type Merge, MergeOptions, type Path, Point, type Prettify, type Primitive, SEMANTIC_COLOR_SCHEMES, TONES, type ToFunction, type Value, addDomEvent, alphaToHex, antonym, ariaAttr, bem, calc, calcFormat, cast, clampNumber, contains, convertColor, countDecimal, createdDom, cx, dataAttr, escape, extractFlatObject, extractObject, filterEmpty, filterObject, filterUndefined, flattenObject, fnAll, focusTransfer, focusTrap, getActiveElement, getAlpha, getDocument, getDocumentElement, getEventPoint, getEventWindow, getFirstFocusableElement, getFirstTabbableElement, getFocusableElements, getLastTabbableElement, getMemoizedObject, getNextTabbableElement, getNodeName, getObject, getParentNode, getPlatform, getPx, getTabIndex, getTabbableElementEdges, getTabbableElements, getUserAgent, getWindow, handlerAll, has, hslaTo, hsvTo, interopDefault, is, isActiveElement, isAndroid, isApple, isArray, isBoolean, isBooleanish, isChrome, isComposing, isDate, isDisabledElement, isDocument, isEditableElement, isEmpty, isEmptyObject, isFirefox, isFocusableElement, isFrame, isFunction, isHTMLElement, isHiddenElement, isIPad, isIPhone, isInputElement, isIos, isMac, isMouseEvent, isMultiTouchEvent, isNode, isNotNumber, isNull, isNumber, isNumeric, isObject, isRegExp, isRtl, isSafari, isShadowRoot, isSize, isString, isTabbableElement, isTouchDevice, isTouchEvent, isTruthyDataAttr, isUndefined, isUnit, isVisibleElement, isVisualViewport, isWebKit, isWindow, match, memoizeObject, merge, noop, objectKeys, omitObject, parseToHsla, parseToHsv, parseToRgba, percentToValue, pickObject, platform, pointFromMouse, pointFromTouch, replaceObject, rgbaTo, roundNumberToStep, runIfFn, sameColor, scrollLock, setAttribute, setStyle, splitObject, toArray, toCamelCase, toKebabCase, toNumber, toPascalCase, toPrecision, toTitleCase, transformSize, userAgent, uuid, valueToPercent, vendor, wait, wrapWithKey };
|
|
@@ -15,5 +15,4 @@ export type Length<Y extends any[]> = Y["length"];
|
|
|
15
15
|
export type Merge<Y, M> = M & Omit<Y, keyof M>;
|
|
16
16
|
export type DeepMerge<Y, M> = Y extends any[] | Primitive ? M : Y extends object ? M extends object ? { [D in keyof M | keyof Y]: D extends keyof M ? D extends keyof Y ? DeepMerge<Y[D], M[D]> : M[D] : D extends keyof Y ? Y[D] : never; } : M : M;
|
|
17
17
|
export type DeepPartial<Y> = Y extends any[] | Primitive ? Y : { [P in keyof Y]?: DeepPartial<Y[P]>; };
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=index.type.d.ts.map
|
|
18
|
+
export {};
|
package/dist/types/module.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function interopDefault<Y>(module: Y): Y;
|
|
2
|
-
//# sourceMappingURL=module.d.ts.map
|
|
1
|
+
export declare function interopDefault<Y>(module: Y): Y;
|
package/dist/types/number.d.ts
CHANGED
|
@@ -4,5 +4,4 @@ export declare function countDecimal(n: number): number;
|
|
|
4
4
|
export declare function roundNumberToStep(n: number, from: number, step: number): string;
|
|
5
5
|
export declare function valueToPercent(n: number, min: number, max: number): number;
|
|
6
6
|
export declare function percentToValue(n: number, min: number, max: number): number;
|
|
7
|
-
export declare function clampNumber(n: number, min: number, max: number): number;
|
|
8
|
-
//# sourceMappingURL=number.d.ts.map
|
|
7
|
+
export declare function clampNumber(n: number, min: number, max: number): number;
|
package/dist/types/object.d.ts
CHANGED
|
@@ -32,5 +32,4 @@ export declare function memoizeObject(func: typeof getObject): <Y>(obj: Dict, pa
|
|
|
32
32
|
export declare const getMemoizedObject: <Y>(obj: Dict, path: number | string, fallback?: any) => Y;
|
|
33
33
|
export declare function wrapWithKey<Y>(obj: Y, key?: string): Y | {
|
|
34
34
|
[key]: Y;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=object.d.ts.map
|
|
35
|
+
};
|
package/dist/types/string.d.ts
CHANGED
|
@@ -13,5 +13,4 @@ export declare function toPascalCase(value: AnyString): string;
|
|
|
13
13
|
export declare function toKebabCase(value: AnyString): string;
|
|
14
14
|
export declare function toTitleCase(value: AnyString): string;
|
|
15
15
|
export declare function bem(block: string, element?: string, modifier?: string): string;
|
|
16
|
-
export declare function match(value: string, query: string, strategy?: "contains" | "endsWith" | "equals" | "startsWith"): boolean;
|
|
17
|
-
//# sourceMappingURL=string.d.ts.map
|
|
16
|
+
export declare function match(value: string, query: string, strategy?: "contains" | "endsWith" | "equals" | "startsWith"): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0-dev-20261125051132",
|
|
5
5
|
"description": "The utilities for Yamada UI projects",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"utils",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"color2k": "^2.0.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@vitest/browser": "^
|
|
37
|
-
"@vitest/browser-playwright": "^
|
|
36
|
+
"@vitest/browser": "^5.1.0",
|
|
37
|
+
"@vitest/browser-playwright": "^5.1.0",
|
|
38
38
|
"@yamada-ui/workspace": "1.0.0",
|
|
39
39
|
"playwright": "1.64.1",
|
|
40
40
|
"react": "^19.3.1"
|