@studiometa/js-toolkit 3.6.0-beta.0 → 3.6.0-beta.1

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.
Files changed (170) hide show
  1. package/Base/Base.js.map +2 -2
  2. package/Base/types.d.ts +3 -3
  3. package/Base/utils.js.map +2 -2
  4. package/README.md +10 -0
  5. package/decorators/withBreakpointManager.d.ts +1 -1
  6. package/decorators/withBreakpointManager.js.map +1 -1
  7. package/decorators/withBreakpointObserver.d.ts +1 -1
  8. package/decorators/withBreakpointObserver.js.map +1 -1
  9. package/decorators/withDrag.d.ts +1 -1
  10. package/decorators/withDrag.js.map +1 -1
  11. package/decorators/withExtraConfig.d.ts +1 -1
  12. package/decorators/withExtraConfig.js.map +1 -1
  13. package/decorators/withFreezedOptions.d.ts +1 -1
  14. package/decorators/withFreezedOptions.js.map +1 -1
  15. package/decorators/withGroup.js.map +2 -2
  16. package/decorators/withIntersectionObserver.d.ts +1 -1
  17. package/decorators/withIntersectionObserver.js.map +1 -1
  18. package/decorators/withMountOnMediaQuery.d.ts +1 -1
  19. package/decorators/withMountOnMediaQuery.js.map +1 -1
  20. package/decorators/withMountWhenInView.d.ts +1 -1
  21. package/decorators/withMountWhenInView.js.map +1 -1
  22. package/decorators/withMutation.d.ts +1 -1
  23. package/decorators/withMutation.js.map +1 -1
  24. package/decorators/withRelativePointer.d.ts +1 -1
  25. package/decorators/withRelativePointer.js.map +1 -1
  26. package/decorators/withResponsiveOptions.d.ts +1 -1
  27. package/decorators/withResponsiveOptions.js.map +1 -1
  28. package/decorators/withScrolledInView/withScrolledInView.d.ts +1 -1
  29. package/decorators/withScrolledInView/withScrolledInView.js.map +1 -1
  30. package/helpers/createApp.d.ts +1 -1
  31. package/helpers/createApp.js +1 -4
  32. package/helpers/createApp.js.map +2 -2
  33. package/helpers/getClosestParent.d.ts +1 -1
  34. package/helpers/getClosestParent.js.map +1 -1
  35. package/helpers/getDirectChildren.d.ts +2 -2
  36. package/helpers/getDirectChildren.js.map +1 -1
  37. package/helpers/getInstanceFromElement.d.ts +1 -1
  38. package/helpers/getInstanceFromElement.js.map +1 -1
  39. package/helpers/importOnInteraction.d.ts +1 -1
  40. package/helpers/importOnInteraction.js.map +1 -1
  41. package/helpers/importOnMediaQuery.d.ts +1 -1
  42. package/helpers/importOnMediaQuery.js.map +1 -1
  43. package/helpers/importWhenIdle.d.ts +1 -1
  44. package/helpers/importWhenIdle.js.map +1 -1
  45. package/helpers/importWhenPrefersMotion.d.ts +1 -1
  46. package/helpers/importWhenPrefersMotion.js.map +1 -1
  47. package/helpers/importWhenVisible.d.ts +1 -1
  48. package/helpers/importWhenVisible.js.map +1 -1
  49. package/helpers/queryComponent.js.map +2 -2
  50. package/package.json +1 -1
  51. package/services/DragService.d.ts +1 -1
  52. package/services/DragService.js.map +1 -1
  53. package/services/KeyService.d.ts +1 -1
  54. package/services/KeyService.js.map +1 -1
  55. package/services/LoadService.d.ts +1 -1
  56. package/services/LoadService.js.map +1 -1
  57. package/services/MutationService.d.ts +1 -1
  58. package/services/MutationService.js.map +1 -1
  59. package/services/PointerService.d.ts +1 -1
  60. package/services/PointerService.js.map +1 -1
  61. package/services/RafService.d.ts +1 -1
  62. package/services/RafService.js.map +1 -1
  63. package/services/ResizeService.d.ts +1 -1
  64. package/services/ResizeService.js.map +1 -1
  65. package/services/ScrollService.d.ts +1 -1
  66. package/services/ScrollService.js.map +1 -1
  67. package/utils/cache.d.ts +1 -1
  68. package/utils/cache.js.map +1 -1
  69. package/utils/collide/boundingRectToCircle.d.ts +1 -1
  70. package/utils/collide/boundingRectToCircle.js.map +1 -1
  71. package/utils/collide/collideCircleCircle.d.ts +1 -1
  72. package/utils/collide/collideCircleCircle.js.map +1 -1
  73. package/utils/collide/collideCircleRect.d.ts +1 -1
  74. package/utils/collide/collideCircleRect.js.map +1 -1
  75. package/utils/collide/collidePointCircle.d.ts +1 -1
  76. package/utils/collide/collidePointCircle.js.map +1 -1
  77. package/utils/collide/collidePointRect.d.ts +1 -1
  78. package/utils/collide/collidePointRect.js.map +1 -1
  79. package/utils/collide/collideRectRect.d.ts +1 -1
  80. package/utils/collide/collideRectRect.js.map +1 -1
  81. package/utils/css/animate.d.ts +1 -1
  82. package/utils/css/animate.js +2 -6
  83. package/utils/css/animate.js.map +2 -2
  84. package/utils/css/classes.d.ts +3 -3
  85. package/utils/css/classes.js.map +1 -1
  86. package/utils/css/getOffsetSizes.d.ts +1 -1
  87. package/utils/css/getOffsetSizes.js.map +1 -1
  88. package/utils/css/matrix.d.ts +1 -1
  89. package/utils/css/matrix.js.map +1 -1
  90. package/utils/css/styles.d.ts +2 -2
  91. package/utils/css/styles.js.map +1 -1
  92. package/utils/css/transform.d.ts +1 -1
  93. package/utils/css/transform.js.map +1 -1
  94. package/utils/css/transition.d.ts +1 -1
  95. package/utils/css/transition.js.map +1 -1
  96. package/utils/debounce.d.ts +1 -1
  97. package/utils/debounce.js.map +1 -1
  98. package/utils/history.d.ts +3 -3
  99. package/utils/history.js.map +1 -1
  100. package/utils/is.d.ts +10 -10
  101. package/utils/is.js.map +1 -1
  102. package/utils/loadElement.d.ts +5 -5
  103. package/utils/loadElement.js.map +1 -1
  104. package/utils/math/clamp.d.ts +1 -1
  105. package/utils/math/clamp.js.map +1 -1
  106. package/utils/math/clamp01.d.ts +1 -1
  107. package/utils/math/clamp01.js.map +1 -1
  108. package/utils/math/createEases.d.ts +2 -2
  109. package/utils/math/createEases.js.map +1 -1
  110. package/utils/math/createRange.d.ts +1 -1
  111. package/utils/math/createRange.js.map +1 -1
  112. package/utils/math/damp.d.ts +1 -1
  113. package/utils/math/damp.js.map +2 -2
  114. package/utils/math/inertiaFinalValue.d.ts +1 -1
  115. package/utils/math/inertiaFinalValue.js.map +1 -1
  116. package/utils/math/lerp.d.ts +1 -1
  117. package/utils/math/lerp.js.map +1 -1
  118. package/utils/math/map.d.ts +1 -1
  119. package/utils/math/map.js.map +1 -1
  120. package/utils/math/round.d.ts +1 -1
  121. package/utils/math/round.js.map +1 -1
  122. package/utils/math/wrap.d.ts +1 -1
  123. package/utils/math/wrap.js.map +1 -1
  124. package/utils/memo.d.ts +1 -1
  125. package/utils/memo.js.map +1 -1
  126. package/utils/memoize.d.ts +1 -1
  127. package/utils/memoize.js.map +1 -1
  128. package/utils/nextFrame.d.ts +1 -1
  129. package/utils/nextFrame.js.map +1 -1
  130. package/utils/nextMicrotask.d.ts +1 -1
  131. package/utils/nextMicrotask.js.map +1 -1
  132. package/utils/nextTick.d.ts +1 -1
  133. package/utils/nextTick.js.map +1 -1
  134. package/utils/random.d.ts +3 -3
  135. package/utils/random.js.map +1 -1
  136. package/utils/scheduler.d.ts +2 -2
  137. package/utils/scheduler.js.map +1 -1
  138. package/utils/scrollTo.d.ts +1 -1
  139. package/utils/scrollTo.js.map +1 -1
  140. package/utils/storage/createStorage.js +1 -5
  141. package/utils/storage/createStorage.js.map +2 -2
  142. package/utils/storage/createUrlSearchParamsProvider.js.map +2 -2
  143. package/utils/storage/getGlobalStorage.js.map +2 -2
  144. package/utils/storage/index.js.map +2 -2
  145. package/utils/string/changeCase.d.ts +6 -6
  146. package/utils/string/changeCase.js.map +1 -1
  147. package/utils/string/withLeadingCharacters.d.ts +1 -1
  148. package/utils/string/withLeadingCharacters.js.map +1 -1
  149. package/utils/string/withLeadingSlash.d.ts +1 -1
  150. package/utils/string/withLeadingSlash.js.map +1 -1
  151. package/utils/string/withTrailingCharacters.d.ts +1 -1
  152. package/utils/string/withTrailingCharacters.js.map +1 -1
  153. package/utils/string/withTrailingSlash.d.ts +1 -1
  154. package/utils/string/withTrailingSlash.js.map +1 -1
  155. package/utils/string/withoutLeadingCharacters.d.ts +1 -1
  156. package/utils/string/withoutLeadingCharacters.js.map +1 -1
  157. package/utils/string/withoutLeadingCharactersRecursive.d.ts +1 -1
  158. package/utils/string/withoutLeadingCharactersRecursive.js.map +1 -1
  159. package/utils/string/withoutLeadingSlash.d.ts +1 -1
  160. package/utils/string/withoutLeadingSlash.js.map +1 -1
  161. package/utils/string/withoutTrailingCharacters.d.ts +1 -1
  162. package/utils/string/withoutTrailingCharacters.js.map +1 -1
  163. package/utils/string/withoutTrailingCharactersRecursive.d.ts +1 -1
  164. package/utils/string/withoutTrailingCharactersRecursive.js.map +1 -1
  165. package/utils/string/withoutTrailingSlash.d.ts +1 -1
  166. package/utils/string/withoutTrailingSlash.js.map +1 -1
  167. package/utils/throttle.d.ts +1 -1
  168. package/utils/throttle.js.map +1 -1
  169. package/utils/trapFocus.d.ts +2 -2
  170. package/utils/trapFocus.js.map +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/services/RafService.ts"],
4
- "sourcesContent": ["import type { ServiceInterface } from './AbstractService.js';\nimport { AbstractService } from './AbstractService.js';\nimport { domScheduler } from '../utils/scheduler.js';\nimport { isFunction } from '../utils/is.js';\n\nexport interface RafServiceProps {\n time: DOMHighResTimeStamp;\n delta: number;\n}\n\nexport type RafServiceInterface = ServiceInterface<RafServiceProps>;\n\nexport class RafService extends AbstractService<RafServiceProps> {\n /**\n * @private\n */\n isTicking = false;\n\n /**\n * @private\n */\n scheduler = domScheduler;\n\n props: RafServiceProps = {\n time: performance.now(),\n delta: 0,\n };\n\n trigger(props: RafServiceProps) {\n this.scheduler.read(() => {\n const writeQueue: Array<(props: RafServiceProps) => unknown> = [];\n\n for (const callback of this.callbacks.values()) {\n const render = callback(props) as ((props: RafServiceProps) => unknown) | void;\n if (isFunction(render)) {\n writeQueue.push(render);\n }\n }\n\n if (writeQueue.length > 0) {\n this.scheduler.write(() => {\n for (let i = 0; i < writeQueue.length; i++) {\n writeQueue[i](props);\n }\n });\n }\n });\n }\n\n loop() {\n const time = performance.now();\n this.props.delta = time - this.props.time;\n this.props.time = time;\n this.trigger(this.props);\n\n if (!this.isTicking) {\n return;\n }\n\n requestAnimationFrame(() => this.loop());\n }\n\n init() {\n this.isTicking = true;\n requestAnimationFrame(() => this.loop());\n }\n\n kill() {\n this.isTicking = false;\n }\n}\n\n/**\n * Use the RequestAnimationFrame (raf) service.\n * @link https://js-toolkit.studiometa.dev/api/services/useRaf.html\n*/\nexport function useRaf(): RafServiceInterface {\n return RafService.getInstance();\n}\n"],
4
+ "sourcesContent": ["import type { ServiceInterface } from './AbstractService.js';\nimport { AbstractService } from './AbstractService.js';\nimport { domScheduler } from '../utils/scheduler.js';\nimport { isFunction } from '../utils/is.js';\n\nexport interface RafServiceProps {\n time: DOMHighResTimeStamp;\n delta: number;\n}\n\nexport type RafServiceInterface = ServiceInterface<RafServiceProps>;\n\nexport class RafService extends AbstractService<RafServiceProps> {\n /**\n * @private\n */\n isTicking = false;\n\n /**\n * @private\n */\n scheduler = domScheduler;\n\n props: RafServiceProps = {\n time: performance.now(),\n delta: 0,\n };\n\n trigger(props: RafServiceProps) {\n this.scheduler.read(() => {\n const writeQueue: Array<(props: RafServiceProps) => unknown> = [];\n\n for (const callback of this.callbacks.values()) {\n const render = callback(props) as ((props: RafServiceProps) => unknown) | void;\n if (isFunction(render)) {\n writeQueue.push(render);\n }\n }\n\n if (writeQueue.length > 0) {\n this.scheduler.write(() => {\n for (let i = 0; i < writeQueue.length; i++) {\n writeQueue[i](props);\n }\n });\n }\n });\n }\n\n loop() {\n const time = performance.now();\n this.props.delta = time - this.props.time;\n this.props.time = time;\n this.trigger(this.props);\n\n if (!this.isTicking) {\n return;\n }\n\n requestAnimationFrame(() => this.loop());\n }\n\n init() {\n this.isTicking = true;\n requestAnimationFrame(() => this.loop());\n }\n\n kill() {\n this.isTicking = false;\n }\n}\n\n/**\n * Use the RequestAnimationFrame (raf) service.\n * @link https://js-toolkit.studiometa.dev/api/services/useRaf.html\n */\nexport function useRaf(): RafServiceInterface {\n return RafService.getInstance();\n}\n"],
5
5
  "mappings": "AACA,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AASpB,MAAM,mBAAmB,gBAAiC;AAAA;AAAA;AAAA;AAAA,EAI/D,YAAY;AAAA;AAAA;AAAA;AAAA,EAKZ,YAAY;AAAA,EAEZ,QAAyB;AAAA,IACvB,MAAM,YAAY,IAAI;AAAA,IACtB,OAAO;AAAA,EACT;AAAA,EAEA,QAAQ,OAAwB;AAC9B,SAAK,UAAU,KAAK,MAAM;AACxB,YAAM,aAAyD,CAAC;AAEhE,iBAAW,YAAY,KAAK,UAAU,OAAO,GAAG;AAC9C,cAAM,SAAS,SAAS,KAAK;AAC7B,YAAI,WAAW,MAAM,GAAG;AACtB,qBAAW,KAAK,MAAM;AAAA,QACxB;AAAA,MACF;AAEA,UAAI,WAAW,SAAS,GAAG;AACzB,aAAK,UAAU,MAAM,MAAM;AACzB,mBAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,uBAAW,CAAC,EAAE,KAAK;AAAA,UACrB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,OAAO;AACL,UAAM,OAAO,YAAY,IAAI;AAC7B,SAAK,MAAM,QAAQ,OAAO,KAAK,MAAM;AACrC,SAAK,MAAM,OAAO;AAClB,SAAK,QAAQ,KAAK,KAAK;AAEvB,QAAI,CAAC,KAAK,WAAW;AACnB;AAAA,IACF;AAEA,0BAAsB,MAAM,KAAK,KAAK,CAAC;AAAA,EACzC;AAAA,EAEA,OAAO;AACL,SAAK,YAAY;AACjB,0BAAsB,MAAM,KAAK,KAAK,CAAC;AAAA,EACzC;AAAA,EAEA,OAAO;AACL,SAAK,YAAY;AAAA,EACnB;AACF;AAMO,SAAS,SAA8B;AAC5C,SAAO,WAAW,YAAY;AAChC;",
6
6
  "names": []
7
7
  }
@@ -26,5 +26,5 @@ export declare class ResizeService<T extends Features['breakpoints'] = Features[
26
26
  /**
27
27
  * Use the resize service.
28
28
  * @link https://js-toolkit.studiometa.dev/api/services/useResize.html
29
- */
29
+ */
30
30
  export declare function useResize<T extends Features['breakpoints'] = Features['breakpoints']>(breakpoints?: T): ResizeServiceInterface<T>;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/services/ResizeService.ts"],
4
- "sourcesContent": ["import type { ServiceConfig, ServiceInterface } from './AbstractService.js';\nimport { AbstractService } from './AbstractService.js';\nimport type { Features } from '../Base/features.js';\nimport { features } from '../Base/features.js';\nimport { debounce } from '../utils/debounce.js';\nimport { cache } from '../utils/cache.js';\n\nexport interface ResizeServiceProps<U extends Features['breakpoints'] = Features['breakpoints']> {\n width: number;\n height: number;\n ratio: number;\n orientation: 'square' | 'landscape' | 'portrait';\n breakpoint: keyof U;\n breakpoints: Array<keyof U>;\n activeBreakpoints: Record<keyof U, boolean>;\n}\n\nexport type ResizeServiceInterface<U extends Features['breakpoints'] = Features['breakpoints']> =\n ServiceInterface<ResizeServiceProps<U>>;\n\nexport class ResizeService<\n T extends Features['breakpoints'] = Features['breakpoints'],\n> extends AbstractService<ResizeServiceProps<T>> {\n static config: ServiceConfig = [[() => window, [['resize']]]];\n\n breakpoints: T;\n\n props: ResizeServiceProps<T> = {\n width: window.innerWidth,\n height: window.innerHeight,\n ratio: window.innerWidth / window.innerHeight,\n orientation: 'square',\n get breakpoint() {\n return Object.keys(this.activeBreakpoints)\n .toReversed()\n .find((name) => this.activeBreakpoints[name]);\n },\n get breakpoints() {\n return Object.keys(this.activeBreakpoints);\n },\n activeBreakpoints: {} as Record<keyof T, boolean>,\n };\n\n constructor(breakpoints: T) {\n super();\n this.breakpoints = breakpoints;\n\n Object.defineProperty(this.props, 'activeBreakpoints', {\n get: () => {\n const activeBreakpoints = {};\n\n for (const [name, breakpoint] of Object.entries(\n this.breakpoints ?? features.get('breakpoints'),\n )) {\n activeBreakpoints[name] = cache(\n [this, window.innerWidth, window.innerHeight, breakpoint],\n () => window.matchMedia(`(min-width: ${breakpoint})`).matches,\n );\n }\n\n return activeBreakpoints as Record<keyof T, boolean>;\n },\n });\n }\n\n /**\n * Update props.\n */\n updateProps(): ResizeServiceProps<T> {\n const { props } = this;\n\n props.width = window.innerWidth;\n props.height = window.innerHeight;\n props.ratio = window.innerWidth / window.innerHeight;\n props.orientation = 'square';\n\n if (props.ratio > 1) {\n props.orientation = 'landscape';\n }\n\n if (props.ratio < 1) {\n props.orientation = 'portrait';\n }\n\n return props;\n }\n\n onResizeDebounce = debounce(() => {\n this.trigger(this.updateProps());\n }, 100);\n\n handleEvent() {\n this.onResizeDebounce();\n }\n}\n\n/**\n * Use the resize service.\n * @link https://js-toolkit.studiometa.dev/api/services/useResize.html\n*/\nexport function useResize<T extends Features['breakpoints'] = Features['breakpoints']>(\n breakpoints?: T,\n): ResizeServiceInterface<T> {\n return ResizeService.getInstance([breakpoints], breakpoints);\n}\n"],
4
+ "sourcesContent": ["import type { ServiceConfig, ServiceInterface } from './AbstractService.js';\nimport { AbstractService } from './AbstractService.js';\nimport type { Features } from '../Base/features.js';\nimport { features } from '../Base/features.js';\nimport { debounce } from '../utils/debounce.js';\nimport { cache } from '../utils/cache.js';\n\nexport interface ResizeServiceProps<U extends Features['breakpoints'] = Features['breakpoints']> {\n width: number;\n height: number;\n ratio: number;\n orientation: 'square' | 'landscape' | 'portrait';\n breakpoint: keyof U;\n breakpoints: Array<keyof U>;\n activeBreakpoints: Record<keyof U, boolean>;\n}\n\nexport type ResizeServiceInterface<U extends Features['breakpoints'] = Features['breakpoints']> =\n ServiceInterface<ResizeServiceProps<U>>;\n\nexport class ResizeService<\n T extends Features['breakpoints'] = Features['breakpoints'],\n> extends AbstractService<ResizeServiceProps<T>> {\n static config: ServiceConfig = [[() => window, [['resize']]]];\n\n breakpoints: T;\n\n props: ResizeServiceProps<T> = {\n width: window.innerWidth,\n height: window.innerHeight,\n ratio: window.innerWidth / window.innerHeight,\n orientation: 'square',\n get breakpoint() {\n return Object.keys(this.activeBreakpoints)\n .toReversed()\n .find((name) => this.activeBreakpoints[name]);\n },\n get breakpoints() {\n return Object.keys(this.activeBreakpoints);\n },\n activeBreakpoints: {} as Record<keyof T, boolean>,\n };\n\n constructor(breakpoints: T) {\n super();\n this.breakpoints = breakpoints;\n\n Object.defineProperty(this.props, 'activeBreakpoints', {\n get: () => {\n const activeBreakpoints = {};\n\n for (const [name, breakpoint] of Object.entries(\n this.breakpoints ?? features.get('breakpoints'),\n )) {\n activeBreakpoints[name] = cache(\n [this, window.innerWidth, window.innerHeight, breakpoint],\n () => window.matchMedia(`(min-width: ${breakpoint})`).matches,\n );\n }\n\n return activeBreakpoints as Record<keyof T, boolean>;\n },\n });\n }\n\n /**\n * Update props.\n */\n updateProps(): ResizeServiceProps<T> {\n const { props } = this;\n\n props.width = window.innerWidth;\n props.height = window.innerHeight;\n props.ratio = window.innerWidth / window.innerHeight;\n props.orientation = 'square';\n\n if (props.ratio > 1) {\n props.orientation = 'landscape';\n }\n\n if (props.ratio < 1) {\n props.orientation = 'portrait';\n }\n\n return props;\n }\n\n onResizeDebounce = debounce(() => {\n this.trigger(this.updateProps());\n }, 100);\n\n handleEvent() {\n this.onResizeDebounce();\n }\n}\n\n/**\n * Use the resize service.\n * @link https://js-toolkit.studiometa.dev/api/services/useResize.html\n */\nexport function useResize<T extends Features['breakpoints'] = Features['breakpoints']>(\n breakpoints?: T,\n): ResizeServiceInterface<T> {\n return ResizeService.getInstance([breakpoints], breakpoints);\n}\n"],
5
5
  "mappings": "AACA,SAAS,uBAAuB;AAEhC,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAef,MAAM,sBAEH,gBAAuC;AAAA,EAC/C,OAAO,SAAwB,CAAC,CAAC,MAAM,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAAA,EAE5D;AAAA,EAEA,QAA+B;AAAA,IAC7B,OAAO,OAAO;AAAA,IACd,QAAQ,OAAO;AAAA,IACf,OAAO,OAAO,aAAa,OAAO;AAAA,IAClC,aAAa;AAAA,IACb,IAAI,aAAa;AACf,aAAO,OAAO,KAAK,KAAK,iBAAiB,EACtC,WAAW,EACX,KAAK,CAAC,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Props> {
83
83
  * props();
84
84
  * ```
85
85
  * @link https://js-toolkit.studiometa.dev/api/services/useScroll.html
86
- */
86
+ */
87
87
  export declare function useScroll(): ScrollServiceInterface;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/services/ScrollService.ts"],
4
- "sourcesContent": ["import type { ServiceConfig, ServiceInterface } from './AbstractService.js';\nimport { AbstractService } from './AbstractService.js';\nimport { debounce } from '../utils/debounce.js';\nimport { PASSIVE_CAPTURE_EVENT_OPTIONS } from './utils.js';\nimport { nextTick } from '../utils/nextTick.js';\n\nexport interface ScrollServiceProps {\n x: number;\n y: number;\n changed: { x: boolean; y: boolean };\n changedX: boolean;\n changedY: boolean;\n last: { x: number; y: number };\n lastX: number;\n lastY: number;\n delta: { x: number; y: number };\n deltaX: number;\n deltaY: number;\n progress: { x: number; y: number };\n progressX: number;\n progressY: number;\n max: { x: number; y: number };\n maxX: number;\n maxY: number;\n direction: { x: 'LEFT' | 'RIGHT' | 'NONE'; y: 'UP' | 'DOWN' | 'NONE' };\n isUp: boolean;\n isRight: boolean;\n isDown: boolean;\n isLeft: boolean;\n}\n\nexport type ScrollServiceInterface = ServiceInterface<ScrollServiceProps>;\n\nexport class ScrollService extends AbstractService<ScrollServiceProps> {\n static config: ServiceConfig = [\n [() => document, [['scroll', PASSIVE_CAPTURE_EVENT_OPTIONS]]],\n [() => window, [['resize', PASSIVE_CAPTURE_EVENT_OPTIONS]]],\n ];\n\n /**\n * Cached scroll max values, updated on resize and first scroll.\n * @private\n */\n __maxX: number | null = null;\n __maxY: number | null = null;\n\n /**\n * Observe scroll container size changes that do not trigger window resize.\n * @private\n */\n __resizeObserver: ResizeObserver | null = null;\n\n props: ScrollServiceProps = {\n x: window.scrollX,\n y: window.scrollY,\n changed: {\n x: false,\n y: false,\n },\n changedX: false,\n changedY: false,\n last: {\n x: window.scrollX,\n y: window.scrollY,\n },\n lastX: window.scrollX,\n lastY: window.scrollY,\n delta: {\n x: 0,\n y: 0,\n },\n deltaX: 0,\n deltaY: 0,\n max: {\n x: document.scrollingElement.scrollWidth - window.innerWidth,\n y: document.scrollingElement.scrollHeight - window.innerHeight,\n },\n maxX: document.scrollingElement.scrollWidth - window.innerWidth,\n maxY: document.scrollingElement.scrollHeight - window.innerHeight,\n progress: {\n x: 0,\n y: 0,\n },\n progressX: 0,\n progressY: 0,\n direction: {\n x: 'NONE',\n y: 'NONE',\n },\n isUp: false,\n isRight: false,\n isDown: false,\n isLeft: false,\n };\n\n updateProps(): ScrollServiceProps {\n const { props } = this;\n const yLast = props.y;\n const xLast = props.x;\n\n props.y = window.scrollY;\n props.x = window.scrollX;\n props.changed.x = props.changedX = props.x !== xLast;\n props.changed.y = props.changedY = props.y !== yLast;\n props.last.x = props.lastX = xLast;\n props.last.y = props.lastY = yLast;\n props.delta.x = props.deltaX = props.x - xLast;\n props.delta.y = props.deltaY = props.y - yLast;\n if (this.__maxX === null || this.__maxY === null) {\n this.__updateMaxValues();\n }\n props.max.x = props.maxX = this.__maxX;\n props.max.y = props.maxY = this.__maxY;\n props.progress.x = props.progressX = props.max.x === 0 ? 1 : props.x / props.max.x;\n props.progress.y = props.progressY = props.max.y === 0 ? 1 : props.y / props.max.y;\n props.isUp = props.y < yLast;\n props.isRight = props.x > xLast;\n props.isDown = props.y > yLast;\n props.isLeft = props.x < xLast;\n /* eslint-disable no-nested-ternary */\n props.direction.x = props.isRight ? 'RIGHT' : props.isLeft ? 'LEFT' : 'NONE';\n props.direction.y = props.isDown ? 'DOWN' : props.isUp ? 'UP' : 'NONE';\n /* eslint-enable no-nested-ternary */\n\n return props;\n }\n\n update(trigger = true) {\n nextTick(() => this.updateProps()).then(() => {\n if (trigger) {\n this.trigger(this.props);\n }\n });\n }\n\n onScrollDebounced = debounce(() => {\n this.update();\n }, 100);\n\n /**\n * Update cached max scroll values on resize.\n * @private\n */\n __updateMaxValues() {\n this.__maxX = document.scrollingElement.scrollWidth - window.innerWidth;\n this.__maxY = document.scrollingElement.scrollHeight - window.innerHeight;\n }\n\n /**\n * Scroll and resize handler.\n */\n handleEvent(event: Event) {\n if (event.type === 'resize') {\n this.__updateMaxValues();\n this.update(false);\n return;\n }\n\n this.update();\n this.onScrollDebounced();\n }\n\n init() {\n super.init();\n\n if (typeof ResizeObserver === 'function' && document.scrollingElement) {\n this.__resizeObserver = new ResizeObserver(() => {\n this.__updateMaxValues();\n });\n this.__resizeObserver.observe(document.scrollingElement);\n }\n }\n\n kill() {\n this.__resizeObserver?.disconnect();\n this.__resizeObserver = null;\n super.kill();\n }\n}\n\n/**\n * Use the scroll service.\n *\n * ```js\n * import { useScroll } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useScroll();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n * @link https://js-toolkit.studiometa.dev/api/services/useScroll.html\n*/\nexport function useScroll(): ScrollServiceInterface {\n return ScrollService.getInstance();\n}\n"],
4
+ "sourcesContent": ["import type { ServiceConfig, ServiceInterface } from './AbstractService.js';\nimport { AbstractService } from './AbstractService.js';\nimport { debounce } from '../utils/debounce.js';\nimport { PASSIVE_CAPTURE_EVENT_OPTIONS } from './utils.js';\nimport { nextTick } from '../utils/nextTick.js';\n\nexport interface ScrollServiceProps {\n x: number;\n y: number;\n changed: { x: boolean; y: boolean };\n changedX: boolean;\n changedY: boolean;\n last: { x: number; y: number };\n lastX: number;\n lastY: number;\n delta: { x: number; y: number };\n deltaX: number;\n deltaY: number;\n progress: { x: number; y: number };\n progressX: number;\n progressY: number;\n max: { x: number; y: number };\n maxX: number;\n maxY: number;\n direction: { x: 'LEFT' | 'RIGHT' | 'NONE'; y: 'UP' | 'DOWN' | 'NONE' };\n isUp: boolean;\n isRight: boolean;\n isDown: boolean;\n isLeft: boolean;\n}\n\nexport type ScrollServiceInterface = ServiceInterface<ScrollServiceProps>;\n\nexport class ScrollService extends AbstractService<ScrollServiceProps> {\n static config: ServiceConfig = [\n [() => document, [['scroll', PASSIVE_CAPTURE_EVENT_OPTIONS]]],\n [() => window, [['resize', PASSIVE_CAPTURE_EVENT_OPTIONS]]],\n ];\n\n /**\n * Cached scroll max values, updated on resize and first scroll.\n * @private\n */\n __maxX: number | null = null;\n __maxY: number | null = null;\n\n /**\n * Observe scroll container size changes that do not trigger window resize.\n * @private\n */\n __resizeObserver: ResizeObserver | null = null;\n\n props: ScrollServiceProps = {\n x: window.scrollX,\n y: window.scrollY,\n changed: {\n x: false,\n y: false,\n },\n changedX: false,\n changedY: false,\n last: {\n x: window.scrollX,\n y: window.scrollY,\n },\n lastX: window.scrollX,\n lastY: window.scrollY,\n delta: {\n x: 0,\n y: 0,\n },\n deltaX: 0,\n deltaY: 0,\n max: {\n x: document.scrollingElement.scrollWidth - window.innerWidth,\n y: document.scrollingElement.scrollHeight - window.innerHeight,\n },\n maxX: document.scrollingElement.scrollWidth - window.innerWidth,\n maxY: document.scrollingElement.scrollHeight - window.innerHeight,\n progress: {\n x: 0,\n y: 0,\n },\n progressX: 0,\n progressY: 0,\n direction: {\n x: 'NONE',\n y: 'NONE',\n },\n isUp: false,\n isRight: false,\n isDown: false,\n isLeft: false,\n };\n\n updateProps(): ScrollServiceProps {\n const { props } = this;\n const yLast = props.y;\n const xLast = props.x;\n\n props.y = window.scrollY;\n props.x = window.scrollX;\n props.changed.x = props.changedX = props.x !== xLast;\n props.changed.y = props.changedY = props.y !== yLast;\n props.last.x = props.lastX = xLast;\n props.last.y = props.lastY = yLast;\n props.delta.x = props.deltaX = props.x - xLast;\n props.delta.y = props.deltaY = props.y - yLast;\n if (this.__maxX === null || this.__maxY === null) {\n this.__updateMaxValues();\n }\n props.max.x = props.maxX = this.__maxX;\n props.max.y = props.maxY = this.__maxY;\n props.progress.x = props.progressX = props.max.x === 0 ? 1 : props.x / props.max.x;\n props.progress.y = props.progressY = props.max.y === 0 ? 1 : props.y / props.max.y;\n props.isUp = props.y < yLast;\n props.isRight = props.x > xLast;\n props.isDown = props.y > yLast;\n props.isLeft = props.x < xLast;\n /* eslint-disable no-nested-ternary */\n props.direction.x = props.isRight ? 'RIGHT' : props.isLeft ? 'LEFT' : 'NONE';\n props.direction.y = props.isDown ? 'DOWN' : props.isUp ? 'UP' : 'NONE';\n /* eslint-enable no-nested-ternary */\n\n return props;\n }\n\n update(trigger = true) {\n nextTick(() => this.updateProps()).then(() => {\n if (trigger) {\n this.trigger(this.props);\n }\n });\n }\n\n onScrollDebounced = debounce(() => {\n this.update();\n }, 100);\n\n /**\n * Update cached max scroll values on resize.\n * @private\n */\n __updateMaxValues() {\n this.__maxX = document.scrollingElement.scrollWidth - window.innerWidth;\n this.__maxY = document.scrollingElement.scrollHeight - window.innerHeight;\n }\n\n /**\n * Scroll and resize handler.\n */\n handleEvent(event: Event) {\n if (event.type === 'resize') {\n this.__updateMaxValues();\n this.update(false);\n return;\n }\n\n this.update();\n this.onScrollDebounced();\n }\n\n init() {\n super.init();\n\n if (typeof ResizeObserver === 'function' && document.scrollingElement) {\n this.__resizeObserver = new ResizeObserver(() => {\n this.__updateMaxValues();\n });\n this.__resizeObserver.observe(document.scrollingElement);\n }\n }\n\n kill() {\n this.__resizeObserver?.disconnect();\n this.__resizeObserver = null;\n super.kill();\n }\n}\n\n/**\n * Use the scroll service.\n *\n * ```js\n * import { useScroll } from '@studiometa/js-toolkit/services';\n * const { add, remove, props } = useScroll();\n * add(key, (props) => {});\n * remove(key);\n * props();\n * ```\n * @link https://js-toolkit.studiometa.dev/api/services/useScroll.html\n */\nexport function useScroll(): ScrollServiceInterface {\n return ScrollService.getInstance();\n}\n"],
5
5
  "mappings": "AACA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,qCAAqC;AAC9C,SAAS,gBAAgB;AA6BlB,MAAM,sBAAsB,gBAAoC;AAAA,EACrE,OAAO,SAAwB;AAAA,IAC7B,CAAC,MAAM,UAAU,CAAC,CAAC,UAAU,6BAA6B,CAAC,CAAC;AAAA,IAC5D,CAAC,MAAM,QAAQ,CAAC,CAAC,UAAU,6B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U;AAC3B,WAAK,kBAAkB;AACvB,WAAK,OAAO,KAAK;AACjB;AAAA,IACF;AAEA,SAAK,OAAO;AACZ,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAEA,OAAO;AACL,UAAM,KAAK;AAEX,QAAI,OAAO,mBAAmB,cAAc,SAAS,kBAAkB;AACrE,WAAK,mBAAmB,IAAI,eAAe,MAAM;AAC/C,aAAK,kBAAkB;AAAA,MACzB,CAAC;AACD,WAAK,iBAAiB,QAAQ,SAAS,gBAAgB;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,OAAO;AACL,SAAK,kBAAkB,WAAW;AAClC,SAAK,mBAAmB;AACxB,UAAM,KAAK;AAAA,EACb;AACF;AAcO,SAAS,YAAoC;AAClD,SAAO,cAAc,YAAY;AACnC;",
6
6
  "names": []
7
7
  }
package/utils/cache.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Cache the result of a callback in map instances.
3
3
  * @link https://js-toolkit.studiometa.dev/utils/cache.html
4
- */
4
+ */
5
5
  export declare function cache<T extends any>(keys: any | any[], callback: () => T): T;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../packages/js-toolkit/utils/cache.ts"],
4
- "sourcesContent": ["import { isArray } from './is.js';\n\n/**\n * Cache the result of a callback in map instances.\n * @link https://js-toolkit.studiometa.dev/utils/cache.html\n*/\nexport function cache<T extends any>(keys: any | any[], callback: () => T): T {\n const normalizedKeys = isArray(keys) ? keys : [keys];\n let value = (globalThis.__JS_TOOLKIT_CACHE__ ??= new Map());\n let index = 1;\n\n for (const key of normalizedKeys) {\n if (!value.has(key)) {\n const newValue = index === normalizedKeys.length ? callback() : new Map();\n value.set(key, newValue);\n }\n\n value = value.get(key);\n index += 1;\n }\n\n return value as T;\n}\n"],
4
+ "sourcesContent": ["import { isArray } from './is.js';\n\n/**\n * Cache the result of a callback in map instances.\n * @link https://js-toolkit.studiometa.dev/utils/cache.html\n */\nexport function cache<T extends any>(keys: any | any[], callback: () => T): T {\n const normalizedKeys = isArray(keys) ? keys : [keys];\n let value = (globalThis.__JS_TOOLKIT_CACHE__ ??= new Map());\n let index = 1;\n\n for (const key of normalizedKeys) {\n if (!value.has(key)) {\n const newValue = index === normalizedKeys.length ? callback() : new Map();\n value.set(key, newValue);\n }\n\n value = value.get(key);\n index += 1;\n }\n\n return value as T;\n}\n"],
5
5
  "mappings": "AAAA,SAAS,eAAe;AAMjB,SAAS,MAAqB,MAAmB,UAAsB;AAC5E,QAAM,iBAAiB,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AACnD,MAAI,QAAS,WAAW,yBAAyB,oBAAI,IAAI;AACzD,MAAI,QAAQ;AAEZ,aAAW,OAAO,gBAAgB;AAChC,QAAI,CAAC,MAAM,IAAI,GAAG,GAAG;AACnB,YAAM,WAAW,UAAU,eAAe,SAAS,SAAS,IAAI,oBAAI,IAAI;AACxE,YAAM,IAAI,KAAK,QAAQ;AAAA,IACzB;AAEA,YAAQ,MAAM,IAAI,GAAG;AACrB,aAAS;AAAA,EACX;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -11,7 +11,7 @@
11
11
  * @param {boolean} force Force usage of non-square DOMElements
12
12
  * @return {Circle} Circle object that can be used in collides functions
13
13
  * @link https://js-toolkit.studiometa.dev/utils/collision/boundingRectToCircle.html
14
- */
14
+ */
15
15
  export declare function boundingRectToCircle({ x, y, width, height }: {
16
16
  height: any;
17
17
  width: any;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/collide/boundingRectToCircle.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Convert clientRect to a formatted circle object\n *\n * @param {Partial<DOMRect>} domRect DOMRect of a square DOMElement\n * @param {boolean} force Force usage of non-square DOMElements\n * @return {Circle} Circle object that can be used in collides functions\n * @link https://js-toolkit.studiometa.dev/utils/collision/boundingRectToCircle.html\n*/\nexport function boundingRectToCircle({ x, y, width, height }, force = false) {\n if (width !== height && !force) {\n throw new Error('Initial DOMElement is not a square. Please use the force mode.');\n }\n return {\n x: x + width / 2,\n y: y + height / 2,\n radius: (width + height) / 4,\n };\n}\n"],
4
+ "sourcesContent": ["/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Convert clientRect to a formatted circle object\n *\n * @param {Partial<DOMRect>} domRect DOMRect of a square DOMElement\n * @param {boolean} force Force usage of non-square DOMElements\n * @return {Circle} Circle object that can be used in collides functions\n * @link https://js-toolkit.studiometa.dev/utils/collision/boundingRectToCircle.html\n */\nexport function boundingRectToCircle({ x, y, width, height }, force = false) {\n if (width !== height && !force) {\n throw new Error('Initial DOMElement is not a square. Please use the force mode.');\n }\n return {\n x: x + width / 2,\n y: y + height / 2,\n radius: (width + height) / 4,\n };\n}\n"],
5
5
  "mappings": "AAeO,SAAS,qBAAqB,EAAE,GAAG,GAAG,OAAO,OAAO,GAAG,QAAQ,OAAO;AAC3E,MAAI,UAAU,UAAU,CAAC,OAAO;AAC9B,UAAM,IAAI,MAAM,gEAAgE;AAAA,EAClF;AACA,SAAO;AAAA,IACL,GAAG,IAAI,QAAQ;AAAA,IACf,GAAG,IAAI,SAAS;AAAA,IAChB,SAAS,QAAQ,UAAU;AAAA,EAC7B;AACF;",
6
6
  "names": []
7
7
  }
@@ -12,5 +12,5 @@
12
12
  * @param {Circle} circle2 Circle 2
13
13
  * @return {boolean} Are the sides of one circle touching the other ?
14
14
  * @link https://js-toolkit.studiometa.dev/utils/collision/collideCircleCircle.html
15
- */
15
+ */
16
16
  export declare function collideCircleCircle(circle1: any, circle2: any): boolean;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/collide/collideCircleCircle.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with another.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-circle.php\n *\n * @param {Circle} circle1 Circle 1\n * @param {Circle} circle2 Circle 2\n * @return {boolean} Are the sides of one circle touching the other ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collideCircleCircle.html\n*/\nexport function collideCircleCircle(circle1, circle2) {\n // get distance between the circle's centers\n // use the Pythagorean Theorem to compute the distance\n const distX = circle1.x - circle2.x;\n const distY = circle1.y - circle2.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the sum of the circle's\n // radii, the circles are touching!\n if (distance <= circle1.radius + circle2.radius) {\n return true;\n }\n return false;\n}\n"],
4
+ "sourcesContent": ["/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with another.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-circle.php\n *\n * @param {Circle} circle1 Circle 1\n * @param {Circle} circle2 Circle 2\n * @return {boolean} Are the sides of one circle touching the other ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collideCircleCircle.html\n */\nexport function collideCircleCircle(circle1, circle2) {\n // get distance between the circle's centers\n // use the Pythagorean Theorem to compute the distance\n const distX = circle1.x - circle2.x;\n const distY = circle1.y - circle2.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the sum of the circle's\n // radii, the circles are touching!\n if (distance <= circle1.radius + circle2.radius) {\n return true;\n }\n return false;\n}\n"],
5
5
  "mappings": "AAgBO,SAAS,oBAAoB,SAAS,SAAS;AAGpD,QAAM,QAAQ,QAAQ,IAAI,QAAQ;AAClC,QAAM,QAAQ,QAAQ,IAAI,QAAQ;AAClC,QAAM,WAAW,KAAK,KAAK,QAAQ,QAAQ,QAAQ,KAAK;AAIxD,MAAI,YAAY,QAAQ,SAAS,QAAQ,QAAQ;AAC/C,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -19,5 +19,5 @@
19
19
  * @param {Rect} rect Rectangle
20
20
  * @return {boolean} Are the sides of the circle touching the rectangle ?
21
21
  * @link https://js-toolkit.studiometa.dev/utils/collision/collideCircleRect.html
22
- */
22
+ */
23
23
  export declare function collideCircleRect(circle: any, rect: any): boolean;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/collide/collideCircleRect.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-rect.php\n *\n * @param {Circle} circle Circle\n * @param {Rect} rect Rectangle\n * @return {boolean} Are the sides of the circle touching the rectangle ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collideCircleRect.html\n*/\nexport function collideCircleRect(circle, rect) {\n // temporary variables to set edges for testing\n let testX = circle.x;\n let testY = circle.y;\n\n // which edge is closest?\n if (circle.x < rect.x) {\n testX = rect.x; // test left edge\n } else if (circle.x > rect.x + rect.width) {\n testX = rect.x + rect.width; // right edge\n }\n\n if (circle.y < rect.y) {\n testY = rect.y; // top edge\n } else if (circle.y > rect.y + rect.height) {\n testY = rect.y + rect.height; // bottom edge\n }\n\n // get distance from closest edges\n const distX = circle.x - testX;\n const distY = circle.y - testY;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the radius, collision!\n if (distance <= circle.radius) {\n return true;\n }\n return false;\n}\n"],
4
+ "sourcesContent": ["/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a circle collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/circle-rect.php\n *\n * @param {Circle} circle Circle\n * @param {Rect} rect Rectangle\n * @return {boolean} Are the sides of the circle touching the rectangle ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collideCircleRect.html\n */\nexport function collideCircleRect(circle, rect) {\n // temporary variables to set edges for testing\n let testX = circle.x;\n let testY = circle.y;\n\n // which edge is closest?\n if (circle.x < rect.x) {\n testX = rect.x; // test left edge\n } else if (circle.x > rect.x + rect.width) {\n testX = rect.x + rect.width; // right edge\n }\n\n if (circle.y < rect.y) {\n testY = rect.y; // top edge\n } else if (circle.y > rect.y + rect.height) {\n testY = rect.y + rect.height; // bottom edge\n }\n\n // get distance from closest edges\n const distX = circle.x - testX;\n const distY = circle.y - testY;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the radius, collision!\n if (distance <= circle.radius) {\n return true;\n }\n return false;\n}\n"],
5
5
  "mappings": "AAwBO,SAAS,kBAAkB,QAAQ,MAAM;AAE9C,MAAI,QAAQ,OAAO;AACnB,MAAI,QAAQ,OAAO;AAGnB,MAAI,OAAO,IAAI,KAAK,GAAG;AACrB,YAAQ,KAAK;AAAA,EACf,WAAW,OAAO,IAAI,KAAK,IAAI,KAAK,OAAO;AACzC,YAAQ,KAAK,IAAI,KAAK;AAAA,EACxB;AAEA,MAAI,OAAO,IAAI,KAAK,GAAG;AACrB,YAAQ,KAAK;AAAA,EACf,WAAW,OAAO,IAAI,KAAK,IAAI,KAAK,QAAQ;AAC1C,YAAQ,KAAK,IAAI,KAAK;AAAA,EACxB;AAGA,QAAM,QAAQ,OAAO,IAAI;AACzB,QAAM,QAAQ,OAAO,IAAI;AACzB,QAAM,WAAW,KAAK,KAAK,QAAQ,QAAQ,QAAQ,KAAK;AAGxD,MAAI,YAAY,OAAO,QAAQ;AAC7B,WAAO;AAAA,EACT;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -17,5 +17,5 @@
17
17
  * @param {Circle} circle Circle
18
18
  * @return {boolean} Is the point inside the circle's bounds ?
19
19
  * @link https://js-toolkit.studiometa.dev/utils/collision/collidePointCircle.html
20
- */
20
+ */
21
21
  export declare function collidePointCircle(point: any, circle: any): boolean;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/collide/collidePointCircle.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Point\n * @property {number} x Point's x position\n * @property {number} y Point's y position\n */\n\n/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a point is inside a circle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-circle.php\n *\n * @param {Point} point Point\n * @param {Circle} circle Circle\n * @return {boolean} Is the point inside the circle's bounds ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collidePointCircle.html\n*/\nexport function collidePointCircle(point, circle) {\n // get distance between the point and circle's center\n // using the Pythagorean Theorem\n const distX = point.x - circle.x;\n const distY = point.y - circle.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the circle's\n // radius the point is inside!\n return distance <= circle.radius;\n}\n"],
4
+ "sourcesContent": ["/**\n * @typedef {Object} Point\n * @property {number} x Point's x position\n * @property {number} y Point's y position\n */\n\n/**\n * @typedef {Object} Circle\n * @property {number} x Circle's x position\n * @property {number} y Circle's y position\n * @property {number} radius Circle's radius\n */\n\n/**\n * Test if a point is inside a circle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-circle.php\n *\n * @param {Point} point Point\n * @param {Circle} circle Circle\n * @return {boolean} Is the point inside the circle's bounds ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collidePointCircle.html\n */\nexport function collidePointCircle(point, circle) {\n // get distance between the point and circle's center\n // using the Pythagorean Theorem\n const distX = point.x - circle.x;\n const distY = point.y - circle.y;\n const distance = Math.sqrt(distX * distX + distY * distY);\n\n // if the distance is less than the circle's\n // radius the point is inside!\n return distance <= circle.radius;\n}\n"],
5
5
  "mappings": "AAsBO,SAAS,mBAAmB,OAAO,QAAQ;AAGhD,QAAM,QAAQ,MAAM,IAAI,OAAO;AAC/B,QAAM,QAAQ,MAAM,IAAI,OAAO;AAC/B,QAAM,WAAW,KAAK,KAAK,QAAQ,QAAQ,QAAQ,KAAK;AAIxD,SAAO,YAAY,OAAO;AAC5B;",
6
6
  "names": []
7
7
  }
@@ -18,5 +18,5 @@
18
18
  * @param {Rect} rect Rectangle
19
19
  * @return {boolean} Is the point inside the rectangle's bounds ?
20
20
  * @link https://js-toolkit.studiometa.dev/utils/collision/collidePointRect.html
21
- */
21
+ */
22
22
  export declare function collidePointRect(point: any, rect: any): boolean;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/collide/collidePointRect.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Point\n * @property {number} x Point's x position\n * @property {number} y Point's y position\n */\n\n/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * Test if a point collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-rect.php\n *\n * @param {Point} point Point\n * @param {Rect} rect Rectangle\n * @return {boolean} Is the point inside the rectangle's bounds ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collidePointRect.html\n*/\nexport function collidePointRect(point, rect) {\n return (\n point.x >= rect.x && // right of the left edge AND\n point.x <= rect.x + rect.width && // left of the right edge AND\n point.y >= rect.y && // below the top AND\n point.y <= rect.y + rect.height // above the bottom\n );\n}\n"],
4
+ "sourcesContent": ["/**\n * @typedef {Object} Point\n * @property {number} x Point's x position\n * @property {number} y Point's y position\n */\n\n/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * Test if a point collides with a rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/point-rect.php\n *\n * @param {Point} point Point\n * @param {Rect} rect Rectangle\n * @return {boolean} Is the point inside the rectangle's bounds ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collidePointRect.html\n */\nexport function collidePointRect(point, rect) {\n return (\n point.x >= rect.x && // right of the left edge AND\n point.x <= rect.x + rect.width && // left of the right edge AND\n point.y >= rect.y && // below the top AND\n point.y <= rect.y + rect.height // above the bottom\n );\n}\n"],
5
5
  "mappings": "AAuBO,SAAS,iBAAiB,OAAO,MAAM;AAC5C,SACE,MAAM,KAAK,KAAK;AAAA,EAChB,MAAM,KAAK,KAAK,IAAI,KAAK;AAAA,EACzB,MAAM,KAAK,KAAK;AAAA,EAChB,MAAM,KAAK,KAAK,IAAI,KAAK;AAE7B;",
6
6
  "names": []
7
7
  }
@@ -13,5 +13,5 @@
13
13
  * @param {Rect} rect2 Rectangle 2
14
14
  * @return {boolean} Are the sides of one rectangle touching the other ?
15
15
  * @link https://js-toolkit.studiometa.dev/utils/collision/collideRectRect.html
16
- */
16
+ */
17
17
  export declare function collideRectRect(rect1: any, rect2: any): boolean;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/collide/collideRectRect.ts"],
4
- "sourcesContent": ["/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * Test if a rectangle collides with another rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/rect-rect.php\n *\n * @param {Rect} rect1 Rectangle 1\n * @param {Rect} rect2 Rectangle 2\n * @return {boolean} Are the sides of one rectangle touching the other ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collideRectRect.html\n*/\nexport function collideRectRect(rect1, rect2) {\n return (\n rect1.x + rect1.width >= rect2.x && // rect1 right edge past rect2 left AND\n rect1.x <= rect2.x + rect2.width && // rect1 left edge past rect2 right AND\n rect1.y + rect1.height >= rect2.y && // rect1 top edge past rect2 bottom AND\n rect1.y <= rect2.y + rect2.height // rect1 bottom edge past rect2 top\n );\n}\n"],
4
+ "sourcesContent": ["/**\n * @typedef {Object} Rect\n * @property {number} x Rectangle's x position\n * @property {number} y Rectangle's y position\n * @property {number} width Rectangle's width\n * @property {number} height Rectangle's height\n */\n\n/**\n * Test if a rectangle collides with another rectangle.\n * Inspired by http://www.jeffreythompson.org/collision-detection/rect-rect.php\n *\n * @param {Rect} rect1 Rectangle 1\n * @param {Rect} rect2 Rectangle 2\n * @return {boolean} Are the sides of one rectangle touching the other ?\n * @link https://js-toolkit.studiometa.dev/utils/collision/collideRectRect.html\n */\nexport function collideRectRect(rect1, rect2) {\n return (\n rect1.x + rect1.width >= rect2.x && // rect1 right edge past rect2 left AND\n rect1.x <= rect2.x + rect2.width && // rect1 left edge past rect2 right AND\n rect1.y + rect1.height >= rect2.y && // rect1 top edge past rect2 bottom AND\n rect1.y <= rect2.y + rect2.height // rect1 bottom edge past rect2 top\n );\n}\n"],
5
5
  "mappings": "AAiBO,SAAS,gBAAgB,OAAO,OAAO;AAC5C,SACE,MAAM,IAAI,MAAM,SAAS,MAAM;AAAA,EAC/B,MAAM,KAAK,MAAM,IAAI,MAAM;AAAA,EAC3B,MAAM,IAAI,MAAM,UAAU,MAAM;AAAA,EAChC,MAAM,KAAK,MAAM,IAAI,MAAM;AAE/B;",
6
6
  "names": []
7
7
  }
@@ -41,6 +41,6 @@ export type Animate = Tween;
41
41
  /**
42
42
  * Animate one or more elements.
43
43
  * @link https://js-toolkit.studiometa.dev/utils/css/animate.html
44
- */
44
+ */
45
45
  export declare function animate(elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>, keyframes: Keyframe[], options?: AnimateOptions): Animate;
46
46
  export {};
@@ -111,9 +111,7 @@ function compileSegment(from, to) {
111
111
  };
112
112
  }
113
113
  function renderSegment(element, segment, progress) {
114
- const easedProgress = segment.easing(
115
- map(progress, segment.fromOffset, segment.toOffset, 0, 1)
116
- );
114
+ const easedProgress = segment.easing(map(progress, segment.fromOffset, segment.toOffset, 0, 1));
117
115
  scheduler.read(() => {
118
116
  for (let i = 0; i < segment.dynamicTranslates.length; i++) {
119
117
  const dynamic = segment.dynamicTranslates[i];
@@ -259,9 +257,7 @@ function animate(elementOrElements, keyframes, options = {}) {
259
257
  if (newProgress !== void 0) {
260
258
  const newTime = lerp(0, duration, newProgress);
261
259
  for (let i = 0; i < controls.length; i++) {
262
- const controlProgress = clamp01(
263
- map(newTime, timings[i][1], timings[i][2], 0, 1)
264
- );
260
+ const controlProgress = clamp01(map(newTime, timings[i][1], timings[i][2], 0, 1));
265
261
  controls[i].progress(controlProgress);
266
262
  }
267
263
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/css/animate.ts"],
4
- "sourcesContent": ["import { clamp01, lerp, map } from '../math/index.js';\nimport { isFunction } from '../is.js';\nimport { domScheduler as scheduler } from '../scheduler.js';\nimport { tween, normalizeEase } from '../tween.js';\nimport { eachElements } from './utils.js';\nimport { startsWith } from '../string/index.js';\nimport type { TransformProps } from './transform.js';\nimport type { EasingFunction } from '../math/index.js';\nimport type { BezierCurve, Tween, TweenOptions } from '../tween.js';\n\nexport type CSSCustomPropertyName = `--${string}`;\n\ntype KeyframeTransforms<Type> = {\n [Property in keyof Type]: number | [number, string];\n};\n\nexport type Keyframe = Partial<\n KeyframeTransforms<TransformProps> & {\n opacity: number;\n transformOrigin: string;\n easing: EasingFunction | BezierCurve;\n offset: number;\n [key: CSSCustomPropertyName]: number;\n }\n>;\n\nexport type NormalizedKeyframe = Keyframe & {\n easing: EasingFunction;\n offset: number;\n vars: string[];\n};\n\n\n/**\n * A pre-compiled segment between two keyframes.\n * All constant parts (deltas, offsets, writers) are resolved once at creation.\n * The render loop only does multiply-add and string concatenation.\n */\ninterface CompiledSegment {\n fromOffset: number;\n toOffset: number;\n easing: EasingFunction;\n /** Parallel arrays for transform properties (structure-of-arrays layout) */\n transformStarts: number[];\n transformDeltas: number[];\n transformCssFunctions: string[];\n transformUnits: string[];\n /** Whether translate3d is needed */\n hasTranslate: boolean;\n /** Indices into transformStarts/transformDeltas for x, y, z axes */\n translateAxisIndices: number[];\n /** The index where non-translate transforms start in the parallel arrays */\n simpleTransformStart: number;\n /** Translate properties that need element size for CSS unit conversion at render time */\n dynamicTranslates: Array<{\n index: number;\n from: number | [number, string];\n to: number | [number, string];\n sizeRef: string;\n }>;\n /** Opacity: pre-computed start and delta, or null if not animated */\n opacityStart: number;\n opacityDelta: number;\n hasOpacity: boolean;\n /** CSS custom properties: parallel arrays */\n customPropertyNames: string[];\n customPropertyStarts: number[];\n customPropertyDeltas: number[];\n /** Transform origin for this segment, or false */\n transformOrigin: string | false;\n}\n\nexport interface AnimateOptions extends Omit<TweenOptions, 'duration'> {\n /**\n * The duration of the tween, in seconds.\n * When using multiple targets, it can be a function which will be\n * called with the current target and its index and should return\n * the duration in seconds for this element.\n *\n * Defaults to `1`.\n */\n duration?: number | ((target: HTMLElement, index: number) => number);\n /**\n * Delay between the start of each target animation, in seconds.\n * When using multiple targets, it can be a function which will be called\n * with the current target and its index and should return the delay\n * in seconds for this element's tween.\n *\n * Defaults to `0`.\n */\n stagger?: number | ((target: HTMLElement, index: number) => number);\n}\n\nexport type Animate = Tween;\n\nlet id = 0;\nconst running = new WeakMap();\n\nconst CSSUnitConverter = {\n '%': (value: number, size: number) => (value * size) / 100,\n vh: (value: number) => (value * window.innerHeight) / 100,\n vw: (value: number) => (value * window.innerWidth) / 100,\n vmin: (value: number) => (value * Math.min(window.innerWidth, window.innerHeight)) / 100,\n vmax: (value: number) => (value * Math.max(window.innerWidth, window.innerHeight)) / 100,\n};\n\n/**\n * Resolve a keyframe value that may have a CSS unit (e.g. [50, '%']).\n */\nfunction resolveUnitValue(val: number | [number, string], elementSize: number): number {\n if (typeof val === 'number') {\n return val;\n }\n\n if (!val[1] || !CSSUnitConverter[val[1]]) {\n return val[0];\n }\n\n return CSSUnitConverter[val[1]](val[0], elementSize);\n}\n\n/**\n * Non-translate transform property definitions: [keyframeProp, cssFn, unit, defaultValue].\n */\nconst SIMPLE_TRANSFORM_DEFS: ReadonlyArray<\n readonly [string, string, string, number]\n> = [\n ['rotate', 'rotate', 'deg', 0],\n ['rotateX', 'rotateX', 'deg', 0],\n ['rotateY', 'rotateY', 'deg', 0],\n ['rotateZ', 'rotateZ', 'deg', 0],\n ['scale', 'scale', '', 1],\n ['scaleX', 'scaleX', '', 1],\n ['scaleY', 'scaleY', '', 1],\n ['scaleZ', 'scaleZ', '', 1],\n ['skew', 'skew', 'deg', 0],\n ['skewX', 'skewX', 'deg', 0],\n ['skewY', 'skewY', 'deg', 0],\n];\n\n/**\n * Translate axis definitions: [keyframeProp, defaultValue, sizeRef].\n * These are grouped into a single translate3d() call during rendering.\n */\nconst TRANSLATE_DEFS: ReadonlyArray<\n readonly [string, number, string]\n> = [\n ['x', 0, 'offsetWidth'],\n ['y', 0, 'offsetHeight'],\n ['z', 0, 'offsetWidth'],\n];\n\n/**\n * Compile a pair of keyframes into a pre-computed segment.\n * All constant work (deltas, property filtering) is done here once.\n */\nfunction compileSegment(\n from: NormalizedKeyframe,\n to: NormalizedKeyframe,\n): CompiledSegment {\n const transformStarts: number[] = [];\n const transformDeltas: number[] = [];\n const transformCssFunctions: string[] = [];\n const transformUnits: string[] = [];\n const dynamicTranslates: CompiledSegment['dynamicTranslates'] = [];\n\n // Translate axes: grouped into translate3d(x, y, z) during rendering.\n // We track indices into the parallel arrays for x, y, z.\n let hasTranslate = false;\n const translateAxisIndices: number[] = [];\n\n for (const [prop, defaultValue, sizeRef] of TRANSLATE_DEFS) {\n const propertyExists = from[prop] !== undefined || to[prop] !== undefined;\n if (propertyExists) hasTranslate = true;\n\n const fromValue = from[prop] ?? defaultValue;\n const toValue = to[prop] ?? defaultValue;\n const arrayIndex = transformStarts.length;\n translateAxisIndices.push(arrayIndex);\n\n // Placeholder CSS function/unit \u2014 not used for translate (special rendering)\n transformCssFunctions.push('');\n transformUnits.push('px');\n\n if (typeof fromValue !== 'number' || typeof toValue !== 'number') {\n transformStarts.push(0);\n transformDeltas.push(0);\n dynamicTranslates.push({ index: arrayIndex, from: fromValue, to: toValue, sizeRef });\n } else {\n transformStarts.push(fromValue);\n transformDeltas.push(toValue - fromValue);\n }\n }\n\n // Non-translate transforms: each gets its own CSS function\n for (const [prop, cssFunction, unit, defaultValue] of SIMPLE_TRANSFORM_DEFS) {\n if (from[prop] === undefined && to[prop] === undefined) continue;\n\n const startValue = (from[prop] as number) ?? defaultValue;\n transformCssFunctions.push(cssFunction);\n transformUnits.push(unit);\n transformStarts.push(startValue);\n transformDeltas.push(((to[prop] as number) ?? defaultValue) - startValue);\n }\n\n // Opacity\n const hasOpacity = from.opacity !== undefined || to.opacity !== undefined;\n const opacityStart = hasOpacity ? (from.opacity ?? 1) : 0;\n const opacityDelta = hasOpacity ? (to.opacity ?? 1) - opacityStart : 0;\n\n // CSS custom properties\n const customPropertyNames: string[] = [];\n const customPropertyStarts: number[] = [];\n const customPropertyDeltas: number[] = [];\n if (from.vars && to.vars) {\n for (const name of from.vars) {\n const startValue = from[name] as number;\n const endValue = (to[name] as number | undefined) ?? startValue;\n customPropertyNames.push(name);\n customPropertyStarts.push(startValue);\n customPropertyDeltas.push(endValue - startValue);\n }\n }\n\n return {\n fromOffset: from.offset,\n toOffset: to.offset,\n easing: to.easing,\n transformStarts,\n transformDeltas,\n transformCssFunctions,\n transformUnits,\n hasTranslate,\n translateAxisIndices,\n simpleTransformStart: TRANSLATE_DEFS.length,\n dynamicTranslates,\n hasOpacity,\n opacityStart,\n opacityDelta,\n customPropertyNames,\n customPropertyStarts,\n customPropertyDeltas,\n transformOrigin: to.transformOrigin !== undefined ? to.transformOrigin : false,\n };\n}\n\n/**\n * Render an element using a pre-compiled segment and a progress value.\n * The hot path: only multiply-add, string concatenation, and DOM writes.\n */\nfunction renderSegment(\n element: HTMLElement,\n segment: CompiledSegment,\n progress: number,\n) {\n const easedProgress = segment.easing(\n map(progress, segment.fromOffset, segment.toOffset, 0, 1),\n );\n\n scheduler.read(() => {\n // Resolve dynamic (CSS-unit) transforms that need element size\n for (let i = 0; i < segment.dynamicTranslates.length; i++) {\n const dynamic = segment.dynamicTranslates[i];\n const elementSize = element[dynamic.sizeRef];\n const startValue = resolveUnitValue(dynamic.from, elementSize);\n segment.transformStarts[dynamic.index] = startValue;\n segment.transformDeltas[dynamic.index] = resolveUnitValue(dynamic.to, elementSize) - startValue;\n }\n\n // Build transform string: translate3d grouped, then individual transforms\n let transformValue = '';\n\n if (segment.hasTranslate) {\n const xIndex = segment.translateAxisIndices[0];\n const yIndex = segment.translateAxisIndices[1];\n const zIndex = segment.translateAxisIndices[2];\n const x = segment.transformStarts[xIndex] + segment.transformDeltas[xIndex] * easedProgress;\n const y = segment.transformStarts[yIndex] + segment.transformDeltas[yIndex] * easedProgress;\n const z = segment.transformStarts[zIndex] + segment.transformDeltas[zIndex] * easedProgress;\n transformValue += `translate3d(${x}px, ${y}px, ${z}px) `;\n }\n\n for (let i = segment.simpleTransformStart; i < segment.transformStarts.length; i++) {\n const value = segment.transformStarts[i] + segment.transformDeltas[i] * easedProgress;\n transformValue += `${segment.transformCssFunctions[i]}(${value}${segment.transformUnits[i]}) `;\n }\n\n // Compute opacity\n let opacity: false | number | string = false;\n if (segment.hasOpacity) {\n opacity = segment.opacityStart + segment.opacityDelta * easedProgress;\n } else if (element.style.opacity) {\n opacity = '';\n }\n\n // Compute transform origin\n let transformOrigin: false | string = false;\n if (segment.transformOrigin !== false) {\n transformOrigin = segment.transformOrigin;\n } else if (element.style.transformOrigin) {\n transformOrigin = '';\n }\n\n // Compute CSS custom properties\n const hasCustomProperties = segment.customPropertyNames.length > 0;\n\n scheduler.write(() => {\n if (opacity !== false) {\n // @ts-ignore\n element.style.opacity = opacity;\n }\n if (transformOrigin !== false) {\n element.style.transformOrigin = transformOrigin;\n }\n if (hasCustomProperties) {\n for (let i = 0; i < segment.customPropertyNames.length; i++) {\n element.style.setProperty(\n segment.customPropertyNames[i],\n (segment.customPropertyStarts[i] + segment.customPropertyDeltas[i] * easedProgress).toString(),\n );\n }\n }\n element.style.transform = transformValue;\n });\n });\n}\n\n/**\n * Animate an element.\n */\nfunction singleAnimate(\n element: HTMLElement,\n keyframes: Keyframe[],\n options: TweenOptions = {},\n): Animate {\n const keyframesCount = keyframes.length - 1;\n const normalizedKeyframes = keyframes.map(\n (keyframe, index): NormalizedKeyframe => ({\n ...keyframe,\n offset: keyframe.offset ?? index / keyframesCount,\n easing: normalizeEase(keyframe.easing),\n vars: Object.keys(keyframe).filter((key) => startsWith(key, '--')),\n }),\n );\n\n // Compile keyframe pairs into pre-computed segments (stage 1: partial evaluation)\n const segments: CompiledSegment[] = [];\n for (let i = 1; i < normalizedKeyframes.length; i++) {\n segments.push(compileSegment(normalizedKeyframes[i - 1], normalizedKeyframes[i]));\n }\n\n if (!running.has(element)) {\n running.set(element, new Map());\n }\n\n const key = `animate-${id}`;\n id += 1;\n\n /**\n * Set the progress value.\n */\n function callback(progress: number) {\n let segmentIndex = 0;\n while (\n segmentIndex < segments.length - 1 &&\n segments[segmentIndex].toOffset <= progress &&\n segments[segmentIndex].toOffset !== 1\n ) {\n segmentIndex += 1;\n }\n\n renderSegment(element, segments[segmentIndex], progress);\n }\n\n const controls = tween(callback, {\n ...options,\n onStart(progress) {\n if (isFunction(options.onStart)) {\n options.onStart(progress);\n }\n // Stop running instances\n const runningKeys = running.get(element);\n for (const [runningKey, runningPause] of runningKeys.entries()) {\n runningPause();\n runningKeys.delete(runningKey);\n }\n runningKeys.set(key, controls.pause);\n running.set(element, runningKeys);\n },\n });\n\n return controls;\n}\n\ntype Duration = number;\ntype Delay = number;\ntype DurationWithDelay = number;\n\n/**\n * Animate one or more elements.\n * @link https://js-toolkit.studiometa.dev/utils/css/animate.html\n*/\nexport function animate(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n keyframes: Keyframe[],\n options: AnimateOptions = {},\n): Animate {\n if (elementOrElements instanceof HTMLElement) {\n return singleAnimate(elementOrElements, keyframes, {\n ...options,\n duration: isFunction(options.duration)\n ? options.duration(elementOrElements, 0)\n : options.duration,\n });\n }\n\n const stagger = options.stagger ?? 0;\n const staggerIsFunction = isFunction(stagger);\n const durationFn = isFunction(options.duration) ? options.duration : null;\n const progressFn = isFunction(options.onProgress) ? options.onProgress : null;\n const progresses: number[] = [];\n const timings: [Duration, Delay, DurationWithDelay][] = [];\n let duration = 0;\n let progressSum = 0;\n let elementCount = 0;\n\n const controls = eachElements(elementOrElements, (element, index) => {\n const delay = staggerIsFunction ? stagger(element, index) : stagger * index;\n const itemOptions = { ...options, delay } as TweenOptions;\n\n if (durationFn) {\n itemOptions.duration = durationFn(element, index);\n } else if (itemOptions.duration === undefined) {\n itemOptions.duration = 1;\n }\n\n timings[index] = [itemOptions.duration, delay, itemOptions.duration + delay];\n\n if (timings[index][2] > duration) {\n // eslint-disable-next-line prefer-destructuring\n duration = timings[index][2];\n }\n\n progresses[index] = 0;\n elementCount = index + 1;\n itemOptions.onProgress = (itemProgress) => {\n progressSum += itemProgress - progresses[index];\n progresses[index] = itemProgress;\n if (progressFn) {\n progressFn(progressSum / elementCount);\n }\n };\n\n return singleAnimate(element, keyframes, itemOptions);\n });\n\n function forAll(key: string) {\n for (const control of controls) {\n control[key]();\n }\n }\n\n function progress(newProgress?: number) {\n if (newProgress !== undefined) {\n const newTime = lerp(0, duration, newProgress);\n for (let i = 0; i < controls.length; i++) {\n const controlProgress = clamp01(\n map(newTime, timings[i][1], timings[i][2], 0, 1),\n );\n controls[i].progress(controlProgress);\n }\n }\n\n return progressSum / elementCount;\n }\n\n return {\n start: () => forAll('start'),\n pause: () => forAll('pause'),\n finish: () => forAll('finish'),\n play: () => forAll('play'),\n progress,\n };\n}\n"],
5
- "mappings": "AAAA,SAAS,SAAS,MAAM,WAAW;AACnC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB,iBAAiB;AAC1C,SAAS,OAAO,qBAAqB;AACrC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AA0F3B,IAAI,KAAK;AACT,MAAM,UAAU,oBAAI,QAAQ;AAE5B,MAAM,mBAAmB;AAAA,EACvB,KAAK,CAAC,OAAe,SAAkB,QAAQ,OAAQ;AAAA,EACvD,IAAI,CAAC,UAAmB,QAAQ,OAAO,cAAe;AAAA,EACtD,IAAI,CAAC,UAAmB,QAAQ,OAAO,aAAc;AAAA,EACrD,MAAM,CAAC,UAAmB,QAAQ,KAAK,IAAI,OAAO,YAAY,OAAO,WAAW,IAAK;AAAA,EACrF,MAAM,CAAC,UAAmB,QAAQ,KAAK,IAAI,OAAO,YAAY,OAAO,WAAW,IAAK;AACvF;AAKA,SAAS,iBAAiB,KAAgC,aAA6B;AACrF,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,CAAC,GAAG;AACxC,WAAO,IAAI,CAAC;AAAA,EACd;AAEA,SAAO,iBAAiB,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,WAAW;AACrD;AAKA,MAAM,wBAEF;AAAA,EACF,CAAC,UAAU,UAAU,OAAO,CAAC;AAAA,EAC7B,CAAC,WAAW,WAAW,OAAO,CAAC;AAAA,EAC/B,CAAC,WAAW,WAAW,OAAO,CAAC;AAAA,EAC/B,CAAC,WAAW,WAAW,OAAO,CAAC;AAAA,EAC/B,CAAC,SA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,IAC7B,MAAM,MAAM,OAAO,MAAM;AAAA,IACzB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { clamp01, lerp, map } from '../math/index.js';\nimport { isFunction } from '../is.js';\nimport { domScheduler as scheduler } from '../scheduler.js';\nimport { tween, normalizeEase } from '../tween.js';\nimport { eachElements } from './utils.js';\nimport { startsWith } from '../string/index.js';\nimport type { TransformProps } from './transform.js';\nimport type { EasingFunction } from '../math/index.js';\nimport type { BezierCurve, Tween, TweenOptions } from '../tween.js';\n\nexport type CSSCustomPropertyName = `--${string}`;\n\ntype KeyframeTransforms<Type> = {\n [Property in keyof Type]: number | [number, string];\n};\n\nexport type Keyframe = Partial<\n KeyframeTransforms<TransformProps> & {\n opacity: number;\n transformOrigin: string;\n easing: EasingFunction | BezierCurve;\n offset: number;\n [key: CSSCustomPropertyName]: number;\n }\n>;\n\nexport type NormalizedKeyframe = Keyframe & {\n easing: EasingFunction;\n offset: number;\n vars: string[];\n};\n\n/**\n * A pre-compiled segment between two keyframes.\n * All constant parts (deltas, offsets, writers) are resolved once at creation.\n * The render loop only does multiply-add and string concatenation.\n */\ninterface CompiledSegment {\n fromOffset: number;\n toOffset: number;\n easing: EasingFunction;\n /** Parallel arrays for transform properties (structure-of-arrays layout) */\n transformStarts: number[];\n transformDeltas: number[];\n transformCssFunctions: string[];\n transformUnits: string[];\n /** Whether translate3d is needed */\n hasTranslate: boolean;\n /** Indices into transformStarts/transformDeltas for x, y, z axes */\n translateAxisIndices: number[];\n /** The index where non-translate transforms start in the parallel arrays */\n simpleTransformStart: number;\n /** Translate properties that need element size for CSS unit conversion at render time */\n dynamicTranslates: Array<{\n index: number;\n from: number | [number, string];\n to: number | [number, string];\n sizeRef: string;\n }>;\n /** Opacity: pre-computed start and delta, or null if not animated */\n opacityStart: number;\n opacityDelta: number;\n hasOpacity: boolean;\n /** CSS custom properties: parallel arrays */\n customPropertyNames: string[];\n customPropertyStarts: number[];\n customPropertyDeltas: number[];\n /** Transform origin for this segment, or false */\n transformOrigin: string | false;\n}\n\nexport interface AnimateOptions extends Omit<TweenOptions, 'duration'> {\n /**\n * The duration of the tween, in seconds.\n * When using multiple targets, it can be a function which will be\n * called with the current target and its index and should return\n * the duration in seconds for this element.\n *\n * Defaults to `1`.\n */\n duration?: number | ((target: HTMLElement, index: number) => number);\n /**\n * Delay between the start of each target animation, in seconds.\n * When using multiple targets, it can be a function which will be called\n * with the current target and its index and should return the delay\n * in seconds for this element's tween.\n *\n * Defaults to `0`.\n */\n stagger?: number | ((target: HTMLElement, index: number) => number);\n}\n\nexport type Animate = Tween;\n\nlet id = 0;\nconst running = new WeakMap();\n\nconst CSSUnitConverter = {\n '%': (value: number, size: number) => (value * size) / 100,\n vh: (value: number) => (value * window.innerHeight) / 100,\n vw: (value: number) => (value * window.innerWidth) / 100,\n vmin: (value: number) => (value * Math.min(window.innerWidth, window.innerHeight)) / 100,\n vmax: (value: number) => (value * Math.max(window.innerWidth, window.innerHeight)) / 100,\n};\n\n/**\n * Resolve a keyframe value that may have a CSS unit (e.g. [50, '%']).\n */\nfunction resolveUnitValue(val: number | [number, string], elementSize: number): number {\n if (typeof val === 'number') {\n return val;\n }\n\n if (!val[1] || !CSSUnitConverter[val[1]]) {\n return val[0];\n }\n\n return CSSUnitConverter[val[1]](val[0], elementSize);\n}\n\n/**\n * Non-translate transform property definitions: [keyframeProp, cssFn, unit, defaultValue].\n */\nconst SIMPLE_TRANSFORM_DEFS: ReadonlyArray<readonly [string, string, string, number]> = [\n ['rotate', 'rotate', 'deg', 0],\n ['rotateX', 'rotateX', 'deg', 0],\n ['rotateY', 'rotateY', 'deg', 0],\n ['rotateZ', 'rotateZ', 'deg', 0],\n ['scale', 'scale', '', 1],\n ['scaleX', 'scaleX', '', 1],\n ['scaleY', 'scaleY', '', 1],\n ['scaleZ', 'scaleZ', '', 1],\n ['skew', 'skew', 'deg', 0],\n ['skewX', 'skewX', 'deg', 0],\n ['skewY', 'skewY', 'deg', 0],\n];\n\n/**\n * Translate axis definitions: [keyframeProp, defaultValue, sizeRef].\n * These are grouped into a single translate3d() call during rendering.\n */\nconst TRANSLATE_DEFS: ReadonlyArray<readonly [string, number, string]> = [\n ['x', 0, 'offsetWidth'],\n ['y', 0, 'offsetHeight'],\n ['z', 0, 'offsetWidth'],\n];\n\n/**\n * Compile a pair of keyframes into a pre-computed segment.\n * All constant work (deltas, property filtering) is done here once.\n */\nfunction compileSegment(from: NormalizedKeyframe, to: NormalizedKeyframe): CompiledSegment {\n const transformStarts: number[] = [];\n const transformDeltas: number[] = [];\n const transformCssFunctions: string[] = [];\n const transformUnits: string[] = [];\n const dynamicTranslates: CompiledSegment['dynamicTranslates'] = [];\n\n // Translate axes: grouped into translate3d(x, y, z) during rendering.\n // We track indices into the parallel arrays for x, y, z.\n let hasTranslate = false;\n const translateAxisIndices: number[] = [];\n\n for (const [prop, defaultValue, sizeRef] of TRANSLATE_DEFS) {\n const propertyExists = from[prop] !== undefined || to[prop] !== undefined;\n if (propertyExists) hasTranslate = true;\n\n const fromValue = from[prop] ?? defaultValue;\n const toValue = to[prop] ?? defaultValue;\n const arrayIndex = transformStarts.length;\n translateAxisIndices.push(arrayIndex);\n\n // Placeholder CSS function/unit \u2014 not used for translate (special rendering)\n transformCssFunctions.push('');\n transformUnits.push('px');\n\n if (typeof fromValue !== 'number' || typeof toValue !== 'number') {\n transformStarts.push(0);\n transformDeltas.push(0);\n dynamicTranslates.push({ index: arrayIndex, from: fromValue, to: toValue, sizeRef });\n } else {\n transformStarts.push(fromValue);\n transformDeltas.push(toValue - fromValue);\n }\n }\n\n // Non-translate transforms: each gets its own CSS function\n for (const [prop, cssFunction, unit, defaultValue] of SIMPLE_TRANSFORM_DEFS) {\n if (from[prop] === undefined && to[prop] === undefined) continue;\n\n const startValue = (from[prop] as number) ?? defaultValue;\n transformCssFunctions.push(cssFunction);\n transformUnits.push(unit);\n transformStarts.push(startValue);\n transformDeltas.push(((to[prop] as number) ?? defaultValue) - startValue);\n }\n\n // Opacity\n const hasOpacity = from.opacity !== undefined || to.opacity !== undefined;\n const opacityStart = hasOpacity ? (from.opacity ?? 1) : 0;\n const opacityDelta = hasOpacity ? (to.opacity ?? 1) - opacityStart : 0;\n\n // CSS custom properties\n const customPropertyNames: string[] = [];\n const customPropertyStarts: number[] = [];\n const customPropertyDeltas: number[] = [];\n if (from.vars && to.vars) {\n for (const name of from.vars) {\n const startValue = from[name] as number;\n const endValue = (to[name] as number | undefined) ?? startValue;\n customPropertyNames.push(name);\n customPropertyStarts.push(startValue);\n customPropertyDeltas.push(endValue - startValue);\n }\n }\n\n return {\n fromOffset: from.offset,\n toOffset: to.offset,\n easing: to.easing,\n transformStarts,\n transformDeltas,\n transformCssFunctions,\n transformUnits,\n hasTranslate,\n translateAxisIndices,\n simpleTransformStart: TRANSLATE_DEFS.length,\n dynamicTranslates,\n hasOpacity,\n opacityStart,\n opacityDelta,\n customPropertyNames,\n customPropertyStarts,\n customPropertyDeltas,\n transformOrigin: to.transformOrigin !== undefined ? to.transformOrigin : false,\n };\n}\n\n/**\n * Render an element using a pre-compiled segment and a progress value.\n * The hot path: only multiply-add, string concatenation, and DOM writes.\n */\nfunction renderSegment(element: HTMLElement, segment: CompiledSegment, progress: number) {\n const easedProgress = segment.easing(map(progress, segment.fromOffset, segment.toOffset, 0, 1));\n\n scheduler.read(() => {\n // Resolve dynamic (CSS-unit) transforms that need element size\n for (let i = 0; i < segment.dynamicTranslates.length; i++) {\n const dynamic = segment.dynamicTranslates[i];\n const elementSize = element[dynamic.sizeRef];\n const startValue = resolveUnitValue(dynamic.from, elementSize);\n segment.transformStarts[dynamic.index] = startValue;\n segment.transformDeltas[dynamic.index] =\n resolveUnitValue(dynamic.to, elementSize) - startValue;\n }\n\n // Build transform string: translate3d grouped, then individual transforms\n let transformValue = '';\n\n if (segment.hasTranslate) {\n const xIndex = segment.translateAxisIndices[0];\n const yIndex = segment.translateAxisIndices[1];\n const zIndex = segment.translateAxisIndices[2];\n const x = segment.transformStarts[xIndex] + segment.transformDeltas[xIndex] * easedProgress;\n const y = segment.transformStarts[yIndex] + segment.transformDeltas[yIndex] * easedProgress;\n const z = segment.transformStarts[zIndex] + segment.transformDeltas[zIndex] * easedProgress;\n transformValue += `translate3d(${x}px, ${y}px, ${z}px) `;\n }\n\n for (let i = segment.simpleTransformStart; i < segment.transformStarts.length; i++) {\n const value = segment.transformStarts[i] + segment.transformDeltas[i] * easedProgress;\n transformValue += `${segment.transformCssFunctions[i]}(${value}${segment.transformUnits[i]}) `;\n }\n\n // Compute opacity\n let opacity: false | number | string = false;\n if (segment.hasOpacity) {\n opacity = segment.opacityStart + segment.opacityDelta * easedProgress;\n } else if (element.style.opacity) {\n opacity = '';\n }\n\n // Compute transform origin\n let transformOrigin: false | string = false;\n if (segment.transformOrigin !== false) {\n transformOrigin = segment.transformOrigin;\n } else if (element.style.transformOrigin) {\n transformOrigin = '';\n }\n\n // Compute CSS custom properties\n const hasCustomProperties = segment.customPropertyNames.length > 0;\n\n scheduler.write(() => {\n if (opacity !== false) {\n // @ts-ignore\n element.style.opacity = opacity;\n }\n if (transformOrigin !== false) {\n element.style.transformOrigin = transformOrigin;\n }\n if (hasCustomProperties) {\n for (let i = 0; i < segment.customPropertyNames.length; i++) {\n element.style.setProperty(\n segment.customPropertyNames[i],\n (\n segment.customPropertyStarts[i] +\n segment.customPropertyDeltas[i] * easedProgress\n ).toString(),\n );\n }\n }\n element.style.transform = transformValue;\n });\n });\n}\n\n/**\n * Animate an element.\n */\nfunction singleAnimate(\n element: HTMLElement,\n keyframes: Keyframe[],\n options: TweenOptions = {},\n): Animate {\n const keyframesCount = keyframes.length - 1;\n const normalizedKeyframes = keyframes.map(\n (keyframe, index): NormalizedKeyframe => ({\n ...keyframe,\n offset: keyframe.offset ?? index / keyframesCount,\n easing: normalizeEase(keyframe.easing),\n vars: Object.keys(keyframe).filter((key) => startsWith(key, '--')),\n }),\n );\n\n // Compile keyframe pairs into pre-computed segments (stage 1: partial evaluation)\n const segments: CompiledSegment[] = [];\n for (let i = 1; i < normalizedKeyframes.length; i++) {\n segments.push(compileSegment(normalizedKeyframes[i - 1], normalizedKeyframes[i]));\n }\n\n if (!running.has(element)) {\n running.set(element, new Map());\n }\n\n const key = `animate-${id}`;\n id += 1;\n\n /**\n * Set the progress value.\n */\n function callback(progress: number) {\n let segmentIndex = 0;\n while (\n segmentIndex < segments.length - 1 &&\n segments[segmentIndex].toOffset <= progress &&\n segments[segmentIndex].toOffset !== 1\n ) {\n segmentIndex += 1;\n }\n\n renderSegment(element, segments[segmentIndex], progress);\n }\n\n const controls = tween(callback, {\n ...options,\n onStart(progress) {\n if (isFunction(options.onStart)) {\n options.onStart(progress);\n }\n // Stop running instances\n const runningKeys = running.get(element);\n for (const [runningKey, runningPause] of runningKeys.entries()) {\n runningPause();\n runningKeys.delete(runningKey);\n }\n runningKeys.set(key, controls.pause);\n running.set(element, runningKeys);\n },\n });\n\n return controls;\n}\n\ntype Duration = number;\ntype Delay = number;\ntype DurationWithDelay = number;\n\n/**\n * Animate one or more elements.\n * @link https://js-toolkit.studiometa.dev/utils/css/animate.html\n */\nexport function animate(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n keyframes: Keyframe[],\n options: AnimateOptions = {},\n): Animate {\n if (elementOrElements instanceof HTMLElement) {\n return singleAnimate(elementOrElements, keyframes, {\n ...options,\n duration: isFunction(options.duration)\n ? options.duration(elementOrElements, 0)\n : options.duration,\n });\n }\n\n const stagger = options.stagger ?? 0;\n const staggerIsFunction = isFunction(stagger);\n const durationFn = isFunction(options.duration) ? options.duration : null;\n const progressFn = isFunction(options.onProgress) ? options.onProgress : null;\n const progresses: number[] = [];\n const timings: [Duration, Delay, DurationWithDelay][] = [];\n let duration = 0;\n let progressSum = 0;\n let elementCount = 0;\n\n const controls = eachElements(elementOrElements, (element, index) => {\n const delay = staggerIsFunction ? stagger(element, index) : stagger * index;\n const itemOptions = { ...options, delay } as TweenOptions;\n\n if (durationFn) {\n itemOptions.duration = durationFn(element, index);\n } else if (itemOptions.duration === undefined) {\n itemOptions.duration = 1;\n }\n\n timings[index] = [itemOptions.duration, delay, itemOptions.duration + delay];\n\n if (timings[index][2] > duration) {\n // eslint-disable-next-line prefer-destructuring\n duration = timings[index][2];\n }\n\n progresses[index] = 0;\n elementCount = index + 1;\n itemOptions.onProgress = (itemProgress) => {\n progressSum += itemProgress - progresses[index];\n progresses[index] = itemProgress;\n if (progressFn) {\n progressFn(progressSum / elementCount);\n }\n };\n\n return singleAnimate(element, keyframes, itemOptions);\n });\n\n function forAll(key: string) {\n for (const control of controls) {\n control[key]();\n }\n }\n\n function progress(newProgress?: number) {\n if (newProgress !== undefined) {\n const newTime = lerp(0, duration, newProgress);\n for (let i = 0; i < controls.length; i++) {\n const controlProgress = clamp01(map(newTime, timings[i][1], timings[i][2], 0, 1));\n controls[i].progress(controlProgress);\n }\n }\n\n return progressSum / elementCount;\n }\n\n return {\n start: () => forAll('start'),\n pause: () => forAll('pause'),\n finish: () => forAll('finish'),\n play: () => forAll('play'),\n progress,\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,SAAS,MAAM,WAAW;AACnC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB,iBAAiB;AAC1C,SAAS,OAAO,qBAAqB;AACrC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAyF3B,IAAI,KAAK;AACT,MAAM,UAAU,oBAAI,QAAQ;AAE5B,MAAM,mBAAmB;AAAA,EACvB,KAAK,CAAC,OAAe,SAAkB,QAAQ,OAAQ;AAAA,EACvD,IAAI,CAAC,UAAmB,QAAQ,OAAO,cAAe;AAAA,EACtD,IAAI,CAAC,UAAmB,QAAQ,OAAO,aAAc;AAAA,EACrD,MAAM,CAAC,UAAmB,QAAQ,KAAK,IAAI,OAAO,YAAY,OAAO,WAAW,IAAK;AAAA,EACrF,MAAM,CAAC,UAAmB,QAAQ,KAAK,IAAI,OAAO,YAAY,OAAO,WAAW,IAAK;AACvF;AAKA,SAAS,iBAAiB,K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AACtC,QAAI,gBAAgB,QAAW;AAC7B,YAAM,UAAU,KAAK,GAAG,UAAU,WAAW;AAC7C,eAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;AACxC,cAAM,kBAAkB,QAAQ,IAAI,SAAS,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;AAChF,iBAAS,CAAC,EAAE,SAAS,eAAe;AAAA,MACtC;AAAA,IACF;AAEA,WAAO,cAAc;AAAA,EACvB;AAEA,SAAO;AAAA,IACL,OAAO,MAAM,OAAO,OAAO;AAAA,IAC3B,OAAO,MAAM,OAAO,OAAO;AAAA,IAC3B,QAAQ,MAAM,OAAO,QAAQ;AAAA,IAC7B,MAAM,MAAM,OAAO,MAAM;AAAA,IACzB;AAAA,EACF;AACF;",
6
6
  "names": ["key"]
7
7
  }
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * Add class names to an element.
3
3
  * @link https://js-toolkit.studiometa.dev/utils/css/addClass.html
4
- */
4
+ */
5
5
  export declare function add(element: Element | Element[] | NodeListOf<Element>, classNames: string | string[]): void;
6
6
  /**
7
7
  * Remove class names from an element.
8
8
  * @link https://js-toolkit.studiometa.dev/utils/css/removeClass.html
9
- */
9
+ */
10
10
  export declare function remove(element: Element | Element[] | NodeListOf<Element>, classNames: string | string[]): void;
11
11
  /**
12
12
  * Toggle class names from an element.
13
13
  * @link https://js-toolkit.studiometa.dev/utils/css/toggleClass.html
14
- */
14
+ */
15
15
  export declare function toggle(element: Element | Element[] | NodeListOf<Element>, classNames: string | string[], force?: boolean): void;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/css/classes.ts"],
4
- "sourcesContent": ["import { isArray } from '../is.js';\n// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\n/**\n * Manage a list of classes as string on an element.\n */\nfunction setClasses(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n method: 'add' | 'remove' | 'toggle',\n forceToggle?: boolean,\n) {\n if (!element || !classNames) {\n return;\n }\n\n const normalizedClassNames = isArray(classNames)\n ? classNames\n : classNames.split(' ').filter((className) => className);\n\n if (method !== 'toggle') {\n eachElements(element, (el) => el.classList[method](...normalizedClassNames));\n } else {\n for (const className of normalizedClassNames)\n eachElements(element, (el) => el.classList[method](className, forceToggle));\n }\n}\n\n/**\n * Add class names to an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/addClass.html\n*/\nexport function add(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n) {\n setClasses(element, classNames, 'add');\n}\n\n/**\n * Remove class names from an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/removeClass.html\n*/\nexport function remove(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n) {\n setClasses(element, classNames, 'remove');\n}\n\n/**\n * Toggle class names from an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/toggleClass.html\n*/\nexport function toggle(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n force?: boolean,\n) {\n setClasses(element, classNames, 'toggle', force);\n}\n"],
4
+ "sourcesContent": ["import { isArray } from '../is.js';\n// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\n/**\n * Manage a list of classes as string on an element.\n */\nfunction setClasses(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n method: 'add' | 'remove' | 'toggle',\n forceToggle?: boolean,\n) {\n if (!element || !classNames) {\n return;\n }\n\n const normalizedClassNames = isArray(classNames)\n ? classNames\n : classNames.split(' ').filter((className) => className);\n\n if (method !== 'toggle') {\n eachElements(element, (el) => el.classList[method](...normalizedClassNames));\n } else {\n for (const className of normalizedClassNames)\n eachElements(element, (el) => el.classList[method](className, forceToggle));\n }\n}\n\n/**\n * Add class names to an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/addClass.html\n */\nexport function add(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n) {\n setClasses(element, classNames, 'add');\n}\n\n/**\n * Remove class names from an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/removeClass.html\n */\nexport function remove(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n) {\n setClasses(element, classNames, 'remove');\n}\n\n/**\n * Toggle class names from an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/toggleClass.html\n */\nexport function toggle(\n element: Element | Element[] | NodeListOf<Element>,\n classNames: string | string[],\n force?: boolean,\n) {\n setClasses(element, classNames, 'toggle', force);\n}\n"],
5
5
  "mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,oBAAoB;AAK7B,SAAS,WACP,SACA,YACA,QACA,aACA;AACA,MAAI,CAAC,WAAW,CAAC,YAAY;AAC3B;AAAA,EACF;AAEA,QAAM,uBAAuB,QAAQ,UAAU,IAC3C,aACA,WAAW,MAAM,GAAG,EAAE,OAAO,CAAC,cAAc,SAAS;AAEzD,MAAI,WAAW,UAAU;AACvB,iBAAa,SAAS,CAAC,OAAO,GAAG,UAAU,MAAM,EAAE,GAAG,oBAAoB,CAAC;AAAA,EAC7E,OAAO;AACL,eAAW,aAAa;AACtB,mBAAa,SAAS,CAAC,OAAO,GAAG,UAAU,MAAM,EAAE,WAAW,WAAW,CAAC;AAAA,EAC9E;AACF;AAMO,SAAS,IACd,SACA,YACA;AACA,aAAW,SAAS,YAAY,KAAK;AACvC;AAMO,SAAS,OACd,SACA,YACA;AACA,aAAW,SAAS,YAAY,QAAQ;AAC1C;AAMO,SAAS,OACd,SACA,YACA,OACA;AACA,aAAW,SAAS,YAAY,UAAU,KAAK;AACjD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Get a `DOMRect` like `Object` for an element, without its transforms.
3
3
  * @link https://js-toolkit.studiometa.dev/utils/css/getOffsetSizes.html
4
- */
4
+ */
5
5
  export declare function getOffsetSizes(element: HTMLElement): {
6
6
  x: number;
7
7
  y: number;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/css/getOffsetSizes.ts"],
4
- "sourcesContent": ["/**\n * Get a `DOMRect` like `Object` for an element, without its transforms.\n * @link https://js-toolkit.studiometa.dev/utils/css/getOffsetSizes.html\n*/\nexport function getOffsetSizes(element: HTMLElement) {\n let parent = element;\n let x = -window.scrollX;\n let y = -window.scrollY;\n\n while (parent) {\n x += parent.offsetLeft;\n y += parent.offsetTop;\n // @ts-ignore\n parent = parent.offsetParent;\n }\n\n const width = element.offsetWidth;\n const height = element.offsetHeight;\n\n return {\n x,\n y,\n width,\n height,\n top: y,\n right: width + x,\n bottom: height + y,\n left: x,\n };\n}\n"],
4
+ "sourcesContent": ["/**\n * Get a `DOMRect` like `Object` for an element, without its transforms.\n * @link https://js-toolkit.studiometa.dev/utils/css/getOffsetSizes.html\n */\nexport function getOffsetSizes(element: HTMLElement) {\n let parent = element;\n let x = -window.scrollX;\n let y = -window.scrollY;\n\n while (parent) {\n x += parent.offsetLeft;\n y += parent.offsetTop;\n // @ts-ignore\n parent = parent.offsetParent;\n }\n\n const width = element.offsetWidth;\n const height = element.offsetHeight;\n\n return {\n x,\n y,\n width,\n height,\n top: y,\n right: width + x,\n bottom: height + y,\n left: x,\n };\n}\n"],
5
5
  "mappings": "AAIO,SAAS,eAAe,SAAsB;AACnD,MAAI,SAAS;AACb,MAAI,IAAI,CAAC,OAAO;AAChB,MAAI,IAAI,CAAC,OAAO;AAEhB,SAAO,QAAQ;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAEZ,aAAS,OAAO;AAAA,EAClB;AAEA,QAAM,QAAQ,QAAQ;AACtB,QAAM,SAAS,QAAQ;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,OAAO,QAAQ;AAAA,IACf,QAAQ,SAAS;AAAA,IACjB,MAAM;AAAA,EACR;AACF;",
6
6
  "names": []
7
7
  }
@@ -23,6 +23,6 @@ type MatrixTransform = {
23
23
  * // matrix(0.5, 0, 0, 0.5, 0, 0)
24
24
  * ```
25
25
  * @link https://js-toolkit.studiometa.dev/utils/css/matrix.html
26
- */
26
+ */
27
27
  export declare function matrix(transform?: MatrixTransform): string;
28
28
  export {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/css/matrix.ts"],
4
- "sourcesContent": ["type MatrixTransform = {\n scaleX?: number;\n scaleY?: number;\n skewX?: number;\n skewY?: number;\n translateX?: number;\n translateY?: number;\n};\n\n/**\n * Format a CSS transform matrix with the given values.\n *\n * @param {Object} transform\n * @param {number} [transform.scaleX=1] The scale on the x axis.\n * @param {number} [transform.scaleY=1] The scale on the y axis.\n * @param {number} [transform.skewX=0] The skew on the x axis.\n * @param {number} [transform.skewY=0] The skew on the y axis.\n * @param {number} [transform.translateX=0] The translate on the x axis.\n * @param {number} [transform.translateY=0] The translate on the y axis.\n * @return {string} A formatted CSS matrix transform.\n * @example\n * ```js\n * matrix({ scaleX: 0.5, scaleY: 0.5 });\n * // matrix(0.5, 0, 0, 0.5, 0, 0)\n * ```\n * @link https://js-toolkit.studiometa.dev/utils/css/matrix.html\n*/\nexport function matrix(transform?: MatrixTransform): string {\n // eslint-disable-next-line no-param-reassign\n transform = transform || {};\n return `matrix(${transform.scaleX ?? 1}, ${transform.skewY ?? 0}, ${transform.skewX ?? 0}, ${\n transform.scaleY ?? 1\n }, ${transform.translateX ?? 0}, ${transform.translateY ?? 0})`;\n}\n"],
4
+ "sourcesContent": ["type MatrixTransform = {\n scaleX?: number;\n scaleY?: number;\n skewX?: number;\n skewY?: number;\n translateX?: number;\n translateY?: number;\n};\n\n/**\n * Format a CSS transform matrix with the given values.\n *\n * @param {Object} transform\n * @param {number} [transform.scaleX=1] The scale on the x axis.\n * @param {number} [transform.scaleY=1] The scale on the y axis.\n * @param {number} [transform.skewX=0] The skew on the x axis.\n * @param {number} [transform.skewY=0] The skew on the y axis.\n * @param {number} [transform.translateX=0] The translate on the x axis.\n * @param {number} [transform.translateY=0] The translate on the y axis.\n * @return {string} A formatted CSS matrix transform.\n * @example\n * ```js\n * matrix({ scaleX: 0.5, scaleY: 0.5 });\n * // matrix(0.5, 0, 0, 0.5, 0, 0)\n * ```\n * @link https://js-toolkit.studiometa.dev/utils/css/matrix.html\n */\nexport function matrix(transform?: MatrixTransform): string {\n // eslint-disable-next-line no-param-reassign\n transform = transform || {};\n return `matrix(${transform.scaleX ?? 1}, ${transform.skewY ?? 0}, ${transform.skewX ?? 0}, ${\n transform.scaleY ?? 1\n }, ${transform.translateX ?? 0}, ${transform.translateY ?? 0})`;\n}\n"],
5
5
  "mappings": "AA2BO,SAAS,OAAO,WAAqC;AAE1D,cAAY,aAAa,CAAC;AAC1B,SAAO,UAAU,UAAU,UAAU,CAAC,KAAK,UAAU,SAAS,CAAC,KAAK,UAAU,SAAS,CAAC,KACtF,UAAU,UAAU,CACtB,KAAK,UAAU,cAAc,CAAC,KAAK,UAAU,cAAc,CAAC;AAC9D;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Add styles to an element.
3
3
  * @link https://js-toolkit.studiometa.dev/utils/css/addStyle.html
4
- */
4
+ */
5
5
  export declare function add(elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>, styles: Partial<CSSStyleDeclaration>): void;
6
6
  /**
7
7
  * Remove class names from an element.
8
8
  * @link https://js-toolkit.studiometa.dev/utils/css/removeStyle.html
9
- */
9
+ */
10
10
  export declare function remove(elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>, styles: Partial<CSSStyleDeclaration>): void;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/css/styles.ts"],
4
- "sourcesContent": ["import { isObject } from '../is.js';\n// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\n/**\n * Manage a list of style properties on an element.\n */\nfunction setStyles(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n styles: Partial<CSSStyleDeclaration>,\n method: 'add' | 'remove' = 'add',\n) {\n if (!elementOrElements || !styles || !isObject(styles)) {\n return;\n }\n\n eachElements(elementOrElements, (el) => {\n for (const [prop, value] of Object.entries(styles)) {\n el.style[prop] = method === 'add' ? value : '';\n }\n });\n}\n\n/**\n * Add styles to an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/addStyle.html\n*/\nexport function add(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n styles: Partial<CSSStyleDeclaration>,\n) {\n setStyles(elementOrElements, styles);\n}\n\n/**\n * Remove class names from an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/removeStyle.html\n*/\nexport function remove(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n styles: Partial<CSSStyleDeclaration>,\n) {\n setStyles(elementOrElements, styles, 'remove');\n}\n"],
4
+ "sourcesContent": ["import { isObject } from '../is.js';\n// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\n/**\n * Manage a list of style properties on an element.\n */\nfunction setStyles(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n styles: Partial<CSSStyleDeclaration>,\n method: 'add' | 'remove' = 'add',\n) {\n if (!elementOrElements || !styles || !isObject(styles)) {\n return;\n }\n\n eachElements(elementOrElements, (el) => {\n for (const [prop, value] of Object.entries(styles)) {\n el.style[prop] = method === 'add' ? value : '';\n }\n });\n}\n\n/**\n * Add styles to an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/addStyle.html\n */\nexport function add(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n styles: Partial<CSSStyleDeclaration>,\n) {\n setStyles(elementOrElements, styles);\n}\n\n/**\n * Remove class names from an element.\n * @link https://js-toolkit.studiometa.dev/utils/css/removeStyle.html\n */\nexport function remove(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n styles: Partial<CSSStyleDeclaration>,\n) {\n setStyles(elementOrElements, styles, 'remove');\n}\n"],
5
5
  "mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,oBAAoB;AAK7B,SAAS,UACP,mBACA,QACA,SAA2B,OAC3B;AACA,MAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,SAAS,MAAM,GAAG;AACtD;AAAA,EACF;AAEA,eAAa,mBAAmB,CAAC,OAAO;AACtC,eAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,SAAG,MAAM,IAAI,IAAI,WAAW,QAAQ,QAAQ;AAAA,IAC9C;AAAA,EACF,CAAC;AACH;AAMO,SAAS,IACd,mBACA,QACA;AACA,YAAU,mBAAmB,MAAM;AACrC;AAMO,SAAS,OACd,mBACA,QACA;AACA,YAAU,mBAAmB,QAAQ,QAAQ;AAC/C;",
6
6
  "names": []
7
7
  }
@@ -18,5 +18,5 @@ export declare const TRANSFORM_PROPS: string[];
18
18
  /**
19
19
  * Generate a CSS transform.
20
20
  * @link https://js-toolkit.studiometa.dev/utils/css/transform.html
21
- */
21
+ */
22
22
  export declare function transform(elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>, props: TransformProps): string;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../packages/js-toolkit/utils/css/transform.ts"],
4
- "sourcesContent": ["// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\nexport type TransformProps = Partial<{\n x: number;\n y: number;\n z: number;\n rotate: number;\n rotateX: number;\n rotateY: number;\n rotateZ: number;\n scale: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n skew: number;\n skewX: number;\n skewY: number;\n}>;\n\nexport const TRANSFORM_PROPS = [\n 'x',\n 'y',\n 'z',\n 'rotate',\n 'rotateX',\n 'rotateY',\n 'rotateZ',\n 'scale',\n 'scaleX',\n 'scaleY',\n 'scaleZ',\n 'skew',\n 'skewX',\n 'skewY',\n];\n\n/**\n * Generate a CSS transform.\n * @link https://js-toolkit.studiometa.dev/utils/css/transform.html\n*/\nexport function transform(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n props: TransformProps,\n): string {\n if (!elementOrElements) return\n\n let value = '';\n\n if (props.x !== undefined || props.y !== undefined || props.z !== undefined) {\n value += `translate3d(${props.x ?? 0}px, ${props.y ?? 0}px, ${props.z ?? 0}px) `;\n }\n\n if (props.rotate !== undefined) {\n value += `rotate(${props.rotate}deg) `;\n } else {\n if (props.rotateX !== undefined) {\n value += `rotateX(${props.rotateX}deg) `;\n }\n\n if (props.rotateY !== undefined) {\n value += `rotateY(${props.rotateY}deg) `;\n }\n\n if (props.rotateZ !== undefined) {\n value += `rotateZ(${props.rotateZ}deg) `;\n }\n }\n\n if (props.scale !== undefined) {\n value += `scale(${props.scale}) `;\n } else {\n if (props.scaleX !== undefined) {\n value += `scaleX(${props.scaleX}) `;\n }\n\n if (props.scaleY !== undefined) {\n value += `scaleY(${props.scaleY}) `;\n }\n\n if (props.scaleZ !== undefined) {\n value += `scaleZ(${props.scaleZ}) `;\n }\n }\n\n if (props.skew !== undefined) {\n value += `skew(${props.skew}deg) `;\n } else {\n if (props.skewX !== undefined) {\n value += `skewX(${props.skewX}deg) `;\n }\n\n if (props.skewY !== undefined) {\n value += `skewY(${props.skewY}deg) `;\n }\n }\n\n eachElements(elementOrElements, (element) => {\n element.style.transform = value;\n });\n return value;\n}\n"],
4
+ "sourcesContent": ["// eslint-disable-next-line import/extensions\nimport { eachElements } from './utils.js';\n\nexport type TransformProps = Partial<{\n x: number;\n y: number;\n z: number;\n rotate: number;\n rotateX: number;\n rotateY: number;\n rotateZ: number;\n scale: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n skew: number;\n skewX: number;\n skewY: number;\n}>;\n\nexport const TRANSFORM_PROPS = [\n 'x',\n 'y',\n 'z',\n 'rotate',\n 'rotateX',\n 'rotateY',\n 'rotateZ',\n 'scale',\n 'scaleX',\n 'scaleY',\n 'scaleZ',\n 'skew',\n 'skewX',\n 'skewY',\n];\n\n/**\n * Generate a CSS transform.\n * @link https://js-toolkit.studiometa.dev/utils/css/transform.html\n */\nexport function transform(\n elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>,\n props: TransformProps,\n): string {\n if (!elementOrElements) return;\n\n let value = '';\n\n if (props.x !== undefined || props.y !== undefined || props.z !== undefined) {\n value += `translate3d(${props.x ?? 0}px, ${props.y ?? 0}px, ${props.z ?? 0}px) `;\n }\n\n if (props.rotate !== undefined) {\n value += `rotate(${props.rotate}deg) `;\n } else {\n if (props.rotateX !== undefined) {\n value += `rotateX(${props.rotateX}deg) `;\n }\n\n if (props.rotateY !== undefined) {\n value += `rotateY(${props.rotateY}deg) `;\n }\n\n if (props.rotateZ !== undefined) {\n value += `rotateZ(${props.rotateZ}deg) `;\n }\n }\n\n if (props.scale !== undefined) {\n value += `scale(${props.scale}) `;\n } else {\n if (props.scaleX !== undefined) {\n value += `scaleX(${props.scaleX}) `;\n }\n\n if (props.scaleY !== undefined) {\n value += `scaleY(${props.scaleY}) `;\n }\n\n if (props.scaleZ !== undefined) {\n value += `scaleZ(${props.scaleZ}) `;\n }\n }\n\n if (props.skew !== undefined) {\n value += `skew(${props.skew}deg) `;\n } else {\n if (props.skewX !== undefined) {\n value += `skewX(${props.skewX}deg) `;\n }\n\n if (props.skewY !== undefined) {\n value += `skewY(${props.skewY}deg) `;\n }\n }\n\n eachElements(elementOrElements, (element) => {\n element.style.transform = value;\n });\n return value;\n}\n"],
5
5
  "mappings": "AACA,SAAS,oBAAoB;AAmBtB,MAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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}
@@ -16,5 +16,5 @@ export declare function setClassesOrStyles(element: HTMLElement, classesOrStyles
16
16
  * @param {string} endMode Whether to remove or keep the `to` classes/styles
17
17
  * @return {Promise<void>} A promise resolving at the end of the transition.
18
18
  * @link https://js-toolkit.studiometa.dev/utils/css/transition.html
19
- */
19
+ */
20
20
  export declare function transition(elementOrElements: HTMLElement | HTMLElement[] | NodeListOf<HTMLElement>, name: string | TransitionStyles, endMode?: 'keep' | 'remove'): Promise<void>;