@yamada-ui/utils 2.0.5 → 2.0.6-dev-20260216073817

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.
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
15
19
  }
16
20
  return to;
17
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"event.cjs","names":["noop","getDocument","elToFocus: HTMLElement | null | undefined","getTabbableElementEdges","isFunction","getNextTabbableElement"],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\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 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 doc = 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 (doc.activeElement === firstTabbable) elToFocus = lastTabbable\n } else {\n if (doc.activeElement === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\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 doc = getDocument(el)\n const body = 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(body, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n\n if (ev.shiftKey) {\n if (nextTabbable === doc.activeElement) {\n if (doc.activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (doc.activeElement === firstTabbable || noTabbableEls) {\n if (doc.activeElement !== target) elToFocus = target\n }\n } else {\n if (doc.activeElement === target) {\n if (doc.activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (doc.activeElement === lastTabbable || noTabbableEls) {\n if (doc.activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,GAAG;AAE9B,KAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,aAC/D,QAAO,CAAC,EAAE,GAAG,gBAAgB;AAE/B,QAAO,cAAc,IAAI;;AAG3B,SAAgB,aAAa,IAAuC;AAClE,QAAO,CAAC,CAAE,GAAkB;;AAG9B,SAAgB,kBAAkB,IAA8B;AAC9D,QAAO,aAAa,GAAG,IAAI,GAAG,QAAQ,SAAS;;AAGjD,SAA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gBAAgBC,oCAAwB,IAAI,MAAM;EACxE,MAAM,eAAeE,mCAAuB,MAAM,OAAO;EACzD,MAAM,gBAAgB,CAAC,iBAAiB,CAAC;AAEzC,MAAI,GAAG,UACL;OAAI,iBAAiB,IAAI,eACvB;QAAI,IAAI,kBAAkB,aAAc,aAAY;cAC3C,IAAI,kBAAkB,iBAAiB,eAChD;QAAI,IAAI,kBAAkB,OAAQ,aAAY;;aAG5C,IAAI,kBAAkB,QACxB;OAAI,IAAI,kBAAkB,cAAe,aAAY;aAC5C,IAAI,kBAAkB,gBAAgB,eAC/C;OAAI,IAAI,kBAAkB,aAAc,aAAY;;AAIxD,MAAI,CAAC,UAAW;AAEhB,KAAG,gBAAgB;AAEnB,MAAID,6BAAW,QAAQ,CACrB,SAAQ,UAAU;MAElB,WAAU,OAAO;;AAIrB,QAAO,YAAY,KAAK,WAAW,WAAW,KAAK"}
1
+ {"version":3,"file":"event.cjs","names":["noop","getDocument","elToFocus: HTMLElement | null | undefined","getTabbableElementEdges","isFunction","getNextTabbableElement"],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\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 doc = 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 (doc.activeElement === firstTabbable) elToFocus = lastTabbable\n } else {\n if (doc.activeElement === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\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 doc = getDocument(el)\n const body = 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(body, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n\n if (ev.shiftKey) {\n if (nextTabbable === doc.activeElement) {\n if (doc.activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (doc.activeElement === firstTabbable || noTabbableEls) {\n if (doc.activeElement !== target) elToFocus = target\n }\n } else {\n if (doc.activeElement === target) {\n if (doc.activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (doc.activeElement === lastTabbable || noTabbableEls) {\n if (doc.activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,GAAG;AAE9B,KAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,aAC/D,QAAO,CAAC,EAAE,GAAG,gBAAgB;AAE/B,QAAO,cAAc,IAAI;;AAG3B,SAAgB,aAAa,IAAuC;AAClE,QAAO,CAAC,CAAE,GAAkB;;AAG9B,SAAgB,kBAAkB,IAA8B;AAC9D,QAAO,aAAa,GAAG,IAAI,GAAG,QAAQ,SAAS;;AAGjD,SAAgB,eAAe,IAA8B;AAC3D,QAAS,GAAe,QAAQ;;AAGlC,SAAgB,eACd,GACA,OAA0B,UACnB;CACP,MAAM,QAAQ,EAAE,QAAQ,MAAM,EAAE,eAAe;AAE/C,QAAO;EAAE,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG;;AA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;QAAI,IAAI,kBAAkB,OAAQ,aAAY;;aAG5C,IAAI,kBAAkB,QACxB;OAAI,IAAI,kBAAkB,cAAe,aAAY;aAC5C,IAAI,kBAAkB,gBAAgB,eAC/C;OAAI,IAAI,kBAAkB,aAAc,aAAY;;AAIxD,MAAI,CAAC,UAAW;AAEhB,KAAG,gBAAgB;AAEnB,MAAID,6BAAW,QAAQ,CACrB,SAAQ,UAAU;MAElB,WAAU,OAAO;;AAIrB,QAAO,YAAY,KAAK,WAAW,WAAW,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","names":["elToFocus: HTMLElement | null | undefined"],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\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 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 doc = 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 (doc.activeElement === firstTabbable) elToFocus = lastTabbable\n } else {\n if (doc.activeElement === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\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 doc = getDocument(el)\n const body = 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(body, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n\n if (ev.shiftKey) {\n if (nextTabbable === doc.activeElement) {\n if (doc.activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (doc.activeElement === firstTabbable || noTabbableEls) {\n if (doc.activeElement !== target) elToFocus = target\n }\n } else {\n if (doc.activeElement === target) {\n if (doc.activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (doc.activeElement === lastTabbable || noTabbableEls) {\n if (doc.activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,GAAG;AAE9B,KAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,aAC/D,QAAO,CAAC,EAAE,GAAG,gBAAgB;AAE/B,QAAO,cAAc,IAAI;;AAG3B,SAAgB,aAAa,IAAuC;AAClE,QAAO,CAAC,CAAE,GAAkB;;AAG9B,SAAgB,kBAAkB,IAA8B;AAC9D,QAAO,aAAa,GAAG,IAAI,GAAG,QAAQ,SAAS;;AAGjD,SAAgB,eAAe,IAA8B;AAC3D,QAAS,GAAe,QAAQ;;AAGlC,SAAgB,eACd,GACA,OAA0B,UACnB;CACP,MAAM,QAAQ,EAAE,QAAQ,MAAM,EAAE,eAAe;AAE/C,QAAO;EAAE,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG;;AAGrE,SAAgB,eACd,OACA,OAA0B,UACnB;AACP,QAAO;EACL,GAAG,MAAM,GAAG,KAAK;EACjB,GAAG,MAAM,GAAG,KAAK;EAClB;;AAGH,SAAgB,cACd,IACA,OAA0B,UACnB;AACP,QAAO,aAAa,GAAG,GAAG,eAAe,IAAI,KAAK,GAAG,eAAe,IAAI,KAAK;;AAW/E,SAAgB,YACd,QACA,MACA,IACA,SACA;AAC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AAO;;AAIrB,QAAO,YAAY,KAAK,WAAW,WAAW,KAAK"}
1
+ {"version":3,"file":"event.js","names":["elToFocus: HTMLElement | null | undefined"],"sources":["../../src/event.ts"],"sourcesContent":["import { isFunction } from \"./assertion\"\nimport {\n getDocument,\n getNextTabbableElement,\n getTabbableElementEdges,\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 doc = 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 (doc.activeElement === firstTabbable) elToFocus = lastTabbable\n } else {\n if (doc.activeElement === lastTabbable) elToFocus = firstTabbable\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\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 doc = getDocument(el)\n const body = 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(body, target)\n const noTabbableEls = !firstTabbable && !lastTabbable\n\n if (ev.shiftKey) {\n if (nextTabbable === doc.activeElement) {\n if (doc.activeElement !== lastTabbable) elToFocus = lastTabbable\n } else if (doc.activeElement === firstTabbable || noTabbableEls) {\n if (doc.activeElement !== target) elToFocus = target\n }\n } else {\n if (doc.activeElement === target) {\n if (doc.activeElement !== firstTabbable) elToFocus = firstTabbable\n } else if (doc.activeElement === lastTabbable || noTabbableEls) {\n if (doc.activeElement !== nextTabbable) elToFocus = nextTabbable\n }\n }\n\n if (!elToFocus) return\n\n ev.preventDefault()\n\n if (isFunction(onFocus)) {\n onFocus(elToFocus)\n } else {\n elToFocus.focus()\n }\n }\n\n return addDomEvent(doc, \"keydown\", onKeyDown, true)\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,IAA2B;CACtD,MAAM,MAAM,eAAe,GAAG;AAE9B,KAAI,OAAO,IAAI,iBAAiB,eAAe,cAAc,IAAI,aAC/D,QAAO,CAAC,EAAE,GAAG,gBAAgB;AAE/B,QAAO,cAAc,IAAI;;AAG3B,SAAgB,aAAa,IAAuC;AAClE,QAAO,CAAC,CAAE,GAAkB;;AAG9B,SAAgB,kBAAkB,IAA8B;AAC9D,QAAO,aAAa,GAAG,IAAI,GAAG,QAAQ,SAAS;;AAGjD,SAAgB,eAAe,IAA8B;AAC3D,QAAS,GAAe,QAAQ;;AAGlC,SAAgB,eACd,GACA,OAA0B,UACnB;CACP,MAAM,QAAQ,EAAE,QAAQ,MAAM,EAAE,eAAe;AAE/C,QAAO;EAAE,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG,GAAG,QAAQ,GAAG,KAAK,OAAO;EAAG;;AAGrE,SAAgB,eACd,OACA,OAA0B,UACnB;AACP,QAAO;EACL,GAAG,MAAM,GAAG,KAAK;EACjB,GAAG,MAAM,GAAG,KAAK;EAClB;;AAGH,SAAgB,cACd,IACA,OAA0B,UACnB;AACP,QAAO,aAAa,GAAG,GAAG,eAAe,IAAI,KAAK,GAAG,eAAe,IAAI,KAAK;;AAY/E,SAAgB,YACd,QACA,MACA,IACA,SACA;AACA,QAAO,iBACL,MACA,IACA,QACD;AAED,cAAa;AACX,SAAO,oBACL,MACA,IACA,QACD;;;AAIL,SAAgB,UACd,IACA,SACA;AACA,KAAI,CAAC,GAAI,QAAO;CAEhB,MAAM,MAAM,YAAY,GAAG;CAE3B,SAAS,UAAU,IAAmB;AACpC,MAAI,GAAG,QAAQ,MAAO;EAEtB,IAAIA,YAA4C;EAEhD,MAAM,CAAC,eAAe,gBAAgB,wBAAwB,IAAI,MAAM;AAExE,MAAI,GAAG,UACL;OAAI,IAAI,kBAAkB,cAAe,aAAY;aAEjD,IAAI,kBAAkB,aAAc,aAAY;AAGtD,MAAI,CAAC,UAAW;AAEhB,KAAG,gBAAgB;AAEnB,MAAI,WAAW,QAAQ,CACrB,SAAQ,UAAU;MAElB,WAAU,OAAO;;AAIrB,QAAO,YAAY,IAAI,WAAW,WAAW,KAAK;;AAGpD,SAAgB,cACd,IACA,QACA,SACA;CACA,MAAM,MAAM,YAAY,GAAG;CAC3B,MAAM,OAAO,IAAI;CAEjB,SAAS,UAAU,IAAmB;AACpC,MAAI,GAAG,QAAQ,MAAO;EAEtB,IAAIA,YAA4C;EAEhD,MAAM,CAAC,eAAe,gBAAgB,wBAAwB,IAAI,MAAM;EACxE,MAAM,eAAe,uBAAuB,MAAM,OAAO;EACzD,MAAM,gBAAgB,CAAC,iBAAiB,CAAC;AAEzC,MAAI,GAAG,UACL;OAAI,iBAAiB,IAAI,eACvB;QAAI,IAAI,kBAAkB,aAAc,aAAY;cAC3C,IAAI,kBAAkB,iBAAiB,eAChD;QAAI,IAAI,kBAAkB,OAAQ,aAAY;;aAG5C,IAAI,kBAAkB,QACxB;OAAI,IAAI,kBAAkB,cAAe,aAAY;aAC5C,IAAI,kBAAkB,gBAAgB,eAC/C;OAAI,IAAI,kBAAkB,aAAc,aAAY;;AAIxD,MAAI,CAAC,UAAW;AAEhB,KAAG,gBAAgB;AAEnB,MAAI,WAAW,QAAQ,CACrB,SAAQ,UAAU;MAElB,WAAU,OAAO;;AAIrB,QAAO,YAAY,KAAK,WAAW,WAAW,KAAK"}
@@ -2,7 +2,7 @@
2
2
  type ColorFormat = "hex" | "hexa" | "hsl" | "hsla" | "rgb" | "rgba";
3
3
  declare const SEMANTIC_COLOR_SCHEMES: readonly ["mono", "primary", "secondary", "info", "success", "warning", "danger", "error", "link"];
4
4
  declare const DEFAULT_COLOR_SCHEMES: readonly ["gray", "red", "rose", "pink", "flashy", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia"];
5
- declare const COLOR_SCHEMES: ("error" | "mono" | "primary" | "secondary" | "info" | "success" | "warning" | "danger" | "link" | "gray" | "red" | "rose" | "pink" | "flashy" | "orange" | "amber" | "yellow" | "lime" | "green" | "emerald" | "teal" | "cyan" | "sky" | "blue" | "indigo" | "violet" | "purple" | "fuchsia")[];
5
+ declare const COLOR_SCHEMES: ("mono" | "primary" | "secondary" | "info" | "success" | "warning" | "danger" | "error" | "link" | "gray" | "red" | "rose" | "pink" | "flashy" | "orange" | "amber" | "yellow" | "lime" | "green" | "emerald" | "teal" | "cyan" | "sky" | "blue" | "indigo" | "violet" | "purple" | "fuchsia")[];
6
6
  declare const TONES: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
7
7
  declare function convertColor(color: string, fallback: string): {
8
8
  (format: ColorFormat): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yamada-ui/utils",
3
3
  "type": "module",
4
- "version": "2.0.5",
4
+ "version": "2.0.6-dev-20260216073817",
5
5
  "description": "The utilities for Yamada UI projects",
6
6
  "keywords": [
7
7
  "utils",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "clean-package": "2.2.0",
37
- "react": "^19.2.3"
37
+ "react": "^19.2.4"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": ">=19"