motionrail 0.6.2 → 0.7.0

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 (40) hide show
  1. package/extensions/dots/dist/dots.es.js.map +1 -1
  2. package/extensions/dots/dist/dots.umd.js.map +1 -1
  3. package/frameworks/preact/dist/main.d.ts +1 -1
  4. package/frameworks/preact/dist/preact.es.js +5 -2
  5. package/frameworks/preact/dist/preact.es.js.map +1 -1
  6. package/frameworks/preact/dist/preact.umd.js +1 -1
  7. package/frameworks/preact/dist/preact.umd.js.map +1 -1
  8. package/frameworks/qwik/lib/main.qwik.cjs +11 -6
  9. package/frameworks/qwik/lib/main.qwik.mjs +12 -7
  10. package/frameworks/qwik/lib-types/entry.dev.d.ts +2 -0
  11. package/frameworks/qwik/lib-types/entry.ssr.d.ts +14 -0
  12. package/frameworks/qwik/lib-types/index.d.ts +1 -1
  13. package/frameworks/qwik/lib-types/main.d.ts +1 -1
  14. package/frameworks/qwik/lib-types/root.d.ts +2 -0
  15. package/frameworks/react/dist/react.es.js +13 -12
  16. package/frameworks/react/dist/react.es.js.map +1 -1
  17. package/frameworks/react/dist/react.umd.js +1 -1
  18. package/frameworks/react/dist/react.umd.js.map +1 -1
  19. package/frameworks/solid/dist/dev.js +11 -2
  20. package/frameworks/solid/dist/dev.jsx +6 -9
  21. package/frameworks/solid/dist/index.js +11 -2
  22. package/frameworks/solid/dist/index.jsx +6 -9
  23. package/frameworks/svelte/dist/index.d.ts +1 -1
  24. package/frameworks/svelte/dist/index.js +1 -1
  25. package/frameworks/svelte/dist/svelte.svelte +59 -56
  26. package/frameworks/svelte/dist/svelte.svelte.d.ts +2 -2
  27. package/frameworks/vue/dist/vue.es.js +22 -17
  28. package/frameworks/vue/dist/vue.es.js.map +1 -1
  29. package/frameworks/vue/dist/vue.umd.js +1 -1
  30. package/frameworks/vue/dist/vue.umd.js.map +1 -1
  31. package/frameworks/vue/dist/vue.vue.d.ts +2 -0
  32. package/main/dist/lib/main.d.ts +14 -2
  33. package/main/dist/lib/types.d.ts +1 -0
  34. package/main/dist/motionrail.d.ts +2 -2
  35. package/main/dist/motionrail.es.js +45 -24
  36. package/main/dist/motionrail.es.js.map +1 -1
  37. package/main/dist/motionrail.umd.js +4 -4
  38. package/main/dist/motionrail.umd.js.map +1 -1
  39. package/main/dist/style.css +1 -1
  40. package/package.json +9 -3
@@ -1 +1 @@
1
- {"version":3,"file":"dots.es.js","names":["dotsContainer: HTMLDivElement | null","dots: HTMLButtonElement[]"],"sources":["../src/dots.ts"],"sourcesContent":["import { MotionRail } from \"motionrail\";\nimport type { MotionRailExtension, MotionRailState } from \"motionrail\";\nimport \"./style.css\";\n\nexport function Dots(par?: {\n showIndex?: boolean;\n log?: boolean;\n}): MotionRailExtension {\n let dotsContainer: HTMLDivElement | null = null;\n const dots: HTMLButtonElement[] = [];\n const {\n showIndex = false,\n log = false,\n } = par || {};\n\n return {\n name: \"DotsExtension\",\n onInit(motionRail: MotionRail, state: MotionRailState) {\n const { totalItems } = state;\n\n if (totalItems === 0) {\n return;\n }\n\n dotsContainer = document.createElement(\"div\");\n\n dotsContainer.className = \"motionrail-dots\";\n\n for (let i = 0; i < totalItems; i++) {\n const dot = document.createElement(\"button\");\n dot.className = \"motionrail-dot\";\n dot.setAttribute(\"aria-label\", `Go to item ${i + 1}`);\n\n if (showIndex) {\n dot.textContent = (i + 1).toString();\n }\n\n dot.addEventListener(\"click\", () => {\n motionRail.scrollToIndex(i);\n });\n\n dots.push(dot);\n dotsContainer.appendChild(dot);\n }\n\n motionRail.element.appendChild(dotsContainer);\n },\n onUpdate(_motionRail: MotionRail, state: MotionRailState) {\n const { visibleItemIndexes, totalItems } = state;\n if (!dotsContainer) return;\n\n if (!totalItems) {\n dotsContainer.style.display = \"none\";\n return;\n }\n\n dotsContainer.style.removeProperty(\"display\");\n\n dots.forEach((dot, index) => {\n if (visibleItemIndexes.includes(index)) {\n dot.classList.add(\"motionrail-dot-active\");\n } else {\n dot.classList.remove(\"motionrail-dot-active\");\n }\n });\n\n if (visibleItemIndexes.length > 0) {\n const firstActiveDot = dots[visibleItemIndexes[0]];\n if (firstActiveDot) {\n const containerWidth = dotsContainer.offsetWidth;\n const dotLeft = firstActiveDot.offsetLeft;\n const dotWidth = firstActiveDot.offsetWidth;\n const scrollPosition = dotLeft - containerWidth / 2 + dotWidth / 2;\n\n dotsContainer.scrollTo({\n left: scrollPosition,\n behavior: \"smooth\",\n });\n }\n }\n\n if (log) {\n console.log(\"DotsExtension updated\", state);\n }\n },\n onDestroy(_motionRail: MotionRail, _state: MotionRailState) {\n dotsContainer?.remove();\n dots.length = 0;\n },\n };\n}\n"],"mappings":";AAIA,SAAgB,KAAK,GAGG;CACtB,IAAIA,IAAuC,MACrCC,IAA4B,EAAE,EAC9B,EACJ,eAAY,IACZ,SAAM,OACJ,KAAO,EAAE;AAEb,QAAO;EACL,MAAM;EACN,OAAO,GAAwB,GAAwB;GACrD,IAAM,EAAE,kBAAe;AAEnB,aAAe,GAMnB;IAFA,IAAgB,SAAS,cAAc,MAAM,EAE7C,EAAc,YAAY;AAE1B,SAAK,IAAI,IAAI,GAAG,IAAI,GAAY,KAAK;KACnC,IAAM,IAAM,SAAS,cAAc,SAAS;AAa5C,KAZA,EAAI,YAAY,kBAChB,EAAI,aAAa,cAAc,cAAc,IAAI,IAAI,EAEjD,MACF,EAAI,eAAe,IAAI,GAAG,UAAU,GAGtC,EAAI,iBAAiB,eAAe;AAClC,QAAW,cAAc,EAAE;OAC3B,EAEF,EAAK,KAAK,EAAI,EACd,EAAc,YAAY,EAAI;;AAGhC,MAAW,QAAQ,YAAY,EAAc;;;EAE/C,SAAS,GAAyB,GAAwB;GACxD,IAAM,EAAE,uBAAoB,kBAAe;AACtC,UAEL;QAAI,CAAC,GAAY;AACf,OAAc,MAAM,UAAU;AAC9B;;AAaF,QAVA,EAAc,MAAM,eAAe,UAAU,EAE7C,EAAK,SAAS,GAAK,MAAU;AAC3B,KAAI,EAAmB,SAAS,EAAM,GACpC,EAAI,UAAU,IAAI,wBAAwB,GAE1C,EAAI,UAAU,OAAO,wBAAwB;MAE/C,EAEE,EAAmB,SAAS,GAAG;KACjC,IAAM,IAAiB,EAAK,EAAmB;AAC/C,SAAI,GAAgB;MAClB,IAAM,IAAiB,EAAc,aAC/B,IAAU,EAAe,YACzB,IAAW,EAAe,aAC1B,IAAiB,IAAU,IAAiB,IAAI,IAAW;AAEjE,QAAc,SAAS;OACrB,MAAM;OACN,UAAU;OACX,CAAC;;;AAIN,IAAI,KACF,QAAQ,IAAI,yBAAyB,EAAM;;;EAG/C,UAAU,GAAyB,GAAyB;AAE1D,GADA,GAAe,QAAQ,EACvB,EAAK,SAAS;;EAEjB"}
1
+ {"version":3,"file":"dots.es.js","names":["dotsContainer: HTMLDivElement | null","dots: HTMLButtonElement[]"],"sources":["../src/dots.ts"],"sourcesContent":["import { MotionRail } from \"motionrail\";\nimport type { MotionRailExtension, MotionRailState } from \"motionrail\";\nimport \"./style.css\";\n\nexport function Dots(par?: {\n showIndex?: boolean;\n log?: boolean;\n}): MotionRailExtension {\n let dotsContainer: HTMLDivElement | null = null;\n const dots: HTMLButtonElement[] = [];\n const { showIndex = false, log = false } = par || {};\n\n return {\n name: \"DotsExtension\",\n onInit(motionRail: MotionRail, state: MotionRailState) {\n const { totalItems } = state;\n\n if (totalItems === 0) {\n return;\n }\n\n dotsContainer = document.createElement(\"div\");\n\n dotsContainer.className = \"motionrail-dots\";\n\n for (let i = 0; i < totalItems; i++) {\n const dot = document.createElement(\"button\");\n dot.className = \"motionrail-dot\";\n dot.setAttribute(\"aria-label\", `Go to item ${i + 1}`);\n\n if (showIndex) {\n dot.textContent = (i + 1).toString();\n }\n\n dot.addEventListener(\"click\", () => {\n motionRail.scrollToIndex(i);\n });\n\n dots.push(dot);\n dotsContainer.appendChild(dot);\n }\n\n motionRail.element.appendChild(dotsContainer);\n },\n onUpdate(_motionRail: MotionRail, state: MotionRailState) {\n const { visibleItemIndexes, totalItems } = state;\n if (!dotsContainer) return;\n\n if (!totalItems) {\n dotsContainer.style.display = \"none\";\n return;\n }\n\n dotsContainer.style.removeProperty(\"display\");\n\n dots.forEach((dot, index) => {\n if (visibleItemIndexes.includes(index)) {\n dot.classList.add(\"motionrail-dot-active\");\n } else {\n dot.classList.remove(\"motionrail-dot-active\");\n }\n });\n\n if (visibleItemIndexes.length > 0) {\n const firstActiveDot = dots[visibleItemIndexes[0]];\n if (firstActiveDot) {\n const containerWidth = dotsContainer.offsetWidth;\n const dotLeft = firstActiveDot.offsetLeft;\n const dotWidth = firstActiveDot.offsetWidth;\n const scrollPosition = dotLeft - containerWidth / 2 + dotWidth / 2;\n\n dotsContainer.scrollTo({\n left: scrollPosition,\n behavior: \"smooth\",\n });\n }\n }\n\n if (log) {\n console.log(\"DotsExtension updated\", state);\n }\n },\n onDestroy(_motionRail: MotionRail, _state: MotionRailState) {\n dotsContainer?.remove();\n dots.length = 0;\n },\n };\n}\n"],"mappings":";AAIA,SAAgB,KAAK,GAGG;CACtB,IAAIA,IAAuC,MACrCC,IAA4B,EAAE,EAC9B,EAAE,eAAY,IAAO,SAAM,OAAU,KAAO,EAAE;AAEpD,QAAO;EACL,MAAM;EACN,OAAO,GAAwB,GAAwB;GACrD,IAAM,EAAE,kBAAe;AAEnB,aAAe,GAMnB;IAFA,IAAgB,SAAS,cAAc,MAAM,EAE7C,EAAc,YAAY;AAE1B,SAAK,IAAI,IAAI,GAAG,IAAI,GAAY,KAAK;KACnC,IAAM,IAAM,SAAS,cAAc,SAAS;AAa5C,KAZA,EAAI,YAAY,kBAChB,EAAI,aAAa,cAAc,cAAc,IAAI,IAAI,EAEjD,MACF,EAAI,eAAe,IAAI,GAAG,UAAU,GAGtC,EAAI,iBAAiB,eAAe;AAClC,QAAW,cAAc,EAAE;OAC3B,EAEF,EAAK,KAAK,EAAI,EACd,EAAc,YAAY,EAAI;;AAGhC,MAAW,QAAQ,YAAY,EAAc;;;EAE/C,SAAS,GAAyB,GAAwB;GACxD,IAAM,EAAE,uBAAoB,kBAAe;AACtC,UAEL;QAAI,CAAC,GAAY;AACf,OAAc,MAAM,UAAU;AAC9B;;AAaF,QAVA,EAAc,MAAM,eAAe,UAAU,EAE7C,EAAK,SAAS,GAAK,MAAU;AAC3B,KAAI,EAAmB,SAAS,EAAM,GACpC,EAAI,UAAU,IAAI,wBAAwB,GAE1C,EAAI,UAAU,OAAO,wBAAwB;MAE/C,EAEE,EAAmB,SAAS,GAAG;KACjC,IAAM,IAAiB,EAAK,EAAmB;AAC/C,SAAI,GAAgB;MAClB,IAAM,IAAiB,EAAc,aAC/B,IAAU,EAAe,YACzB,IAAW,EAAe,aAC1B,IAAiB,IAAU,IAAiB,IAAI,IAAW;AAEjE,QAAc,SAAS;OACrB,MAAM;OACN,UAAU;OACX,CAAC;;;AAIN,IAAI,KACF,QAAQ,IAAI,yBAAyB,EAAM;;;EAG/C,UAAU,GAAyB,GAAyB;AAE1D,GADA,GAAe,QAAQ,EACvB,EAAK,SAAS;;EAEjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"dots.umd.js","names":["dotsContainer: HTMLDivElement | null","dots: HTMLButtonElement[]"],"sources":["../src/dots.ts"],"sourcesContent":["import { MotionRail } from \"motionrail\";\nimport type { MotionRailExtension, MotionRailState } from \"motionrail\";\nimport \"./style.css\";\n\nexport function Dots(par?: {\n showIndex?: boolean;\n log?: boolean;\n}): MotionRailExtension {\n let dotsContainer: HTMLDivElement | null = null;\n const dots: HTMLButtonElement[] = [];\n const {\n showIndex = false,\n log = false,\n } = par || {};\n\n return {\n name: \"DotsExtension\",\n onInit(motionRail: MotionRail, state: MotionRailState) {\n const { totalItems } = state;\n\n if (totalItems === 0) {\n return;\n }\n\n dotsContainer = document.createElement(\"div\");\n\n dotsContainer.className = \"motionrail-dots\";\n\n for (let i = 0; i < totalItems; i++) {\n const dot = document.createElement(\"button\");\n dot.className = \"motionrail-dot\";\n dot.setAttribute(\"aria-label\", `Go to item ${i + 1}`);\n\n if (showIndex) {\n dot.textContent = (i + 1).toString();\n }\n\n dot.addEventListener(\"click\", () => {\n motionRail.scrollToIndex(i);\n });\n\n dots.push(dot);\n dotsContainer.appendChild(dot);\n }\n\n motionRail.element.appendChild(dotsContainer);\n },\n onUpdate(_motionRail: MotionRail, state: MotionRailState) {\n const { visibleItemIndexes, totalItems } = state;\n if (!dotsContainer) return;\n\n if (!totalItems) {\n dotsContainer.style.display = \"none\";\n return;\n }\n\n dotsContainer.style.removeProperty(\"display\");\n\n dots.forEach((dot, index) => {\n if (visibleItemIndexes.includes(index)) {\n dot.classList.add(\"motionrail-dot-active\");\n } else {\n dot.classList.remove(\"motionrail-dot-active\");\n }\n });\n\n if (visibleItemIndexes.length > 0) {\n const firstActiveDot = dots[visibleItemIndexes[0]];\n if (firstActiveDot) {\n const containerWidth = dotsContainer.offsetWidth;\n const dotLeft = firstActiveDot.offsetLeft;\n const dotWidth = firstActiveDot.offsetWidth;\n const scrollPosition = dotLeft - containerWidth / 2 + dotWidth / 2;\n\n dotsContainer.scrollTo({\n left: scrollPosition,\n behavior: \"smooth\",\n });\n }\n }\n\n if (log) {\n console.log(\"DotsExtension updated\", state);\n }\n },\n onDestroy(_motionRail: MotionRail, _state: MotionRailState) {\n dotsContainer?.remove();\n dots.length = 0;\n },\n };\n}\n"],"mappings":"2QAIA,SAAgB,EAAK,EAGG,CACtB,IAAIA,EAAuC,KACrCC,EAA4B,EAAE,CAC9B,CACJ,YAAY,GACZ,MAAM,IACJ,GAAO,EAAE,CAEb,MAAO,CACL,KAAM,gBACN,OAAO,EAAwB,EAAwB,CACrD,GAAM,CAAE,cAAe,EAEnB,OAAe,EAMnB,CAFA,EAAgB,SAAS,cAAc,MAAM,CAE7C,EAAc,UAAY,kBAE1B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAY,IAAK,CACnC,IAAM,EAAM,SAAS,cAAc,SAAS,CAC5C,EAAI,UAAY,iBAChB,EAAI,aAAa,aAAc,cAAc,EAAI,IAAI,CAEjD,IACF,EAAI,aAAe,EAAI,GAAG,UAAU,EAGtC,EAAI,iBAAiB,YAAe,CAClC,EAAW,cAAc,EAAE,EAC3B,CAEF,EAAK,KAAK,EAAI,CACd,EAAc,YAAY,EAAI,CAGhC,EAAW,QAAQ,YAAY,EAAc,GAE/C,SAAS,EAAyB,EAAwB,CACxD,GAAM,CAAE,qBAAoB,cAAe,EACtC,KAEL,IAAI,CAAC,EAAY,CACf,EAAc,MAAM,QAAU,OAC9B,OAaF,GAVA,EAAc,MAAM,eAAe,UAAU,CAE7C,EAAK,SAAS,EAAK,IAAU,CACvB,EAAmB,SAAS,EAAM,CACpC,EAAI,UAAU,IAAI,wBAAwB,CAE1C,EAAI,UAAU,OAAO,wBAAwB,EAE/C,CAEE,EAAmB,OAAS,EAAG,CACjC,IAAM,EAAiB,EAAK,EAAmB,IAC/C,GAAI,EAAgB,CAClB,IAAM,EAAiB,EAAc,YAC/B,EAAU,EAAe,WACzB,EAAW,EAAe,YAC1B,EAAiB,EAAU,EAAiB,EAAI,EAAW,EAEjE,EAAc,SAAS,CACrB,KAAM,EACN,SAAU,SACX,CAAC,EAIF,GACF,QAAQ,IAAI,wBAAyB,EAAM,GAG/C,UAAU,EAAyB,EAAyB,CAC1D,GAAe,QAAQ,CACvB,EAAK,OAAS,GAEjB"}
1
+ {"version":3,"file":"dots.umd.js","names":["dotsContainer: HTMLDivElement | null","dots: HTMLButtonElement[]"],"sources":["../src/dots.ts"],"sourcesContent":["import { MotionRail } from \"motionrail\";\nimport type { MotionRailExtension, MotionRailState } from \"motionrail\";\nimport \"./style.css\";\n\nexport function Dots(par?: {\n showIndex?: boolean;\n log?: boolean;\n}): MotionRailExtension {\n let dotsContainer: HTMLDivElement | null = null;\n const dots: HTMLButtonElement[] = [];\n const { showIndex = false, log = false } = par || {};\n\n return {\n name: \"DotsExtension\",\n onInit(motionRail: MotionRail, state: MotionRailState) {\n const { totalItems } = state;\n\n if (totalItems === 0) {\n return;\n }\n\n dotsContainer = document.createElement(\"div\");\n\n dotsContainer.className = \"motionrail-dots\";\n\n for (let i = 0; i < totalItems; i++) {\n const dot = document.createElement(\"button\");\n dot.className = \"motionrail-dot\";\n dot.setAttribute(\"aria-label\", `Go to item ${i + 1}`);\n\n if (showIndex) {\n dot.textContent = (i + 1).toString();\n }\n\n dot.addEventListener(\"click\", () => {\n motionRail.scrollToIndex(i);\n });\n\n dots.push(dot);\n dotsContainer.appendChild(dot);\n }\n\n motionRail.element.appendChild(dotsContainer);\n },\n onUpdate(_motionRail: MotionRail, state: MotionRailState) {\n const { visibleItemIndexes, totalItems } = state;\n if (!dotsContainer) return;\n\n if (!totalItems) {\n dotsContainer.style.display = \"none\";\n return;\n }\n\n dotsContainer.style.removeProperty(\"display\");\n\n dots.forEach((dot, index) => {\n if (visibleItemIndexes.includes(index)) {\n dot.classList.add(\"motionrail-dot-active\");\n } else {\n dot.classList.remove(\"motionrail-dot-active\");\n }\n });\n\n if (visibleItemIndexes.length > 0) {\n const firstActiveDot = dots[visibleItemIndexes[0]];\n if (firstActiveDot) {\n const containerWidth = dotsContainer.offsetWidth;\n const dotLeft = firstActiveDot.offsetLeft;\n const dotWidth = firstActiveDot.offsetWidth;\n const scrollPosition = dotLeft - containerWidth / 2 + dotWidth / 2;\n\n dotsContainer.scrollTo({\n left: scrollPosition,\n behavior: \"smooth\",\n });\n }\n }\n\n if (log) {\n console.log(\"DotsExtension updated\", state);\n }\n },\n onDestroy(_motionRail: MotionRail, _state: MotionRailState) {\n dotsContainer?.remove();\n dots.length = 0;\n },\n };\n}\n"],"mappings":"2QAIA,SAAgB,EAAK,EAGG,CACtB,IAAIA,EAAuC,KACrCC,EAA4B,EAAE,CAC9B,CAAE,YAAY,GAAO,MAAM,IAAU,GAAO,EAAE,CAEpD,MAAO,CACL,KAAM,gBACN,OAAO,EAAwB,EAAwB,CACrD,GAAM,CAAE,cAAe,EAEnB,OAAe,EAMnB,CAFA,EAAgB,SAAS,cAAc,MAAM,CAE7C,EAAc,UAAY,kBAE1B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAY,IAAK,CACnC,IAAM,EAAM,SAAS,cAAc,SAAS,CAC5C,EAAI,UAAY,iBAChB,EAAI,aAAa,aAAc,cAAc,EAAI,IAAI,CAEjD,IACF,EAAI,aAAe,EAAI,GAAG,UAAU,EAGtC,EAAI,iBAAiB,YAAe,CAClC,EAAW,cAAc,EAAE,EAC3B,CAEF,EAAK,KAAK,EAAI,CACd,EAAc,YAAY,EAAI,CAGhC,EAAW,QAAQ,YAAY,EAAc,GAE/C,SAAS,EAAyB,EAAwB,CACxD,GAAM,CAAE,qBAAoB,cAAe,EACtC,KAEL,IAAI,CAAC,EAAY,CACf,EAAc,MAAM,QAAU,OAC9B,OAaF,GAVA,EAAc,MAAM,eAAe,UAAU,CAE7C,EAAK,SAAS,EAAK,IAAU,CACvB,EAAmB,SAAS,EAAM,CACpC,EAAI,UAAU,IAAI,wBAAwB,CAE1C,EAAI,UAAU,OAAO,wBAAwB,EAE/C,CAEE,EAAmB,OAAS,EAAG,CACjC,IAAM,EAAiB,EAAK,EAAmB,IAC/C,GAAI,EAAgB,CAClB,IAAM,EAAiB,EAAc,YAC/B,EAAU,EAAe,WACzB,EAAW,EAAe,YAC1B,EAAiB,EAAU,EAAiB,EAAI,EAAW,EAEjE,EAAc,SAAS,CACrB,KAAM,EACN,SAAU,SACX,CAAC,EAIF,GACF,QAAQ,IAAI,wBAAyB,EAAM,GAG/C,UAAU,EAAyB,EAAyB,CAC1D,GAAe,QAAQ,CACvB,EAAK,OAAS,GAEjB"}
@@ -1,6 +1,6 @@
1
1
  import type { JSX } from "preact";
2
2
  import { type MotionRailOptions } from "motionrail";
3
- export interface MotionRailProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'ref'> {
3
+ export interface MotionRailProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "ref"> {
4
4
  options?: MotionRailOptions;
5
5
  }
6
6
  declare function MotionRailPreact({ options, ...divProps }: MotionRailProps): JSX.Element;
@@ -3,18 +3,21 @@ import { MotionRail } from "motionrail";
3
3
  import { jsx } from "preact/jsx-runtime";
4
4
  function MotionRailPreact({ options: i, ...a }) {
5
5
  let o = useRef(null), s = useRef(null), { children: c, ...l } = a || {};
6
- return useEffect(() => {
6
+ useEffect(() => {
7
7
  if (o.current) return s.current = new MotionRail(o.current, i || {}), () => {
8
8
  s.current &&= (s.current.destroy(), null);
9
9
  };
10
10
  }, [i]), useEffect(() => {
11
11
  s.current && s.current.update();
12
- }, [c]), /* @__PURE__ */ jsx("div", {
12
+ }, [c]);
13
+ let u = i?.containerName ? { containerName: i.containerName } : void 0;
14
+ return /* @__PURE__ */ jsx("div", {
13
15
  ref: o,
14
16
  "data-motionrail": !0,
15
17
  ...l,
16
18
  children: /* @__PURE__ */ jsx("div", {
17
19
  "data-motionrail-scrollable": !0,
20
+ style: u,
18
21
  children: /* @__PURE__ */ jsx("div", {
19
22
  "data-motionrail-grid": !0,
20
23
  children: c
@@ -1 +1 @@
1
- {"version":3,"file":"preact.es.js","names":[],"sources":["../src/lib/main.tsx"],"sourcesContent":["import { useEffect, useRef } from \"preact/hooks\";\nimport type { JSX } from \"preact\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'ref'> {\n options?: MotionRailOptions;\n}\n\nfunction MotionRailPreact({ options, ...divProps }: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n return (\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div data-motionrail-scrollable>\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n );\n}\n\nexport { MotionRailPreact as MotionRail };\n"],"mappings":";;;AAWA,SAAS,iBAAiB,EAAE,YAAS,GAAG,KAA6B;CACnE,IAAM,IAAe,OAAuB,KAAK,EAC3C,IAAgB,OAA+B,KAAK,EACpD,EAAE,aAAU,GAAG,MAAiB,KAAY,EAAE;AAwBpD,QAtBA,gBAAgB;AACT,QAAa,QAOlB,QALA,EAAc,UAAU,IAAI,WAC1B,EAAa,SACb,KAAW,EAAE,CACd,QAEY;AACX,GAEE,EAAc,aADd,EAAc,QAAQ,SAAS,EACP;;IAG3B,CAAC,EAAQ,CAAC,EAEb,gBAAgB;AACd,EAAI,EAAc,WAChB,EAAc,QAAQ,QAAQ;IAE/B,CAAC,EAAS,CAAC,EAGZ,oBAAC,OAAA;EAAI,KAAK;EAAc,mBAAA;EAAgB,GAAI;YAC1C,oBAAC,OAAA;GAAI,8BAAA;aACH,oBAAC,OAAA;IAAI,wBAAA;IAAsB;KAAe;IACtC;GACF"}
1
+ {"version":3,"file":"preact.es.js","names":[],"sources":["../src/lib/main.tsx"],"sourcesContent":["import { useEffect, useRef } from \"preact/hooks\";\nimport type { JSX } from \"preact\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends Omit<\n JSX.HTMLAttributes<HTMLDivElement>,\n \"ref\"\n> {\n options?: MotionRailOptions;\n}\n\nfunction MotionRailPreact({ options, ...divProps }: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n // Compute style for scrollable div\n const scrollableStyle = options?.containerName\n ? { containerName: options.containerName }\n : undefined;\n return (\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div data-motionrail-scrollable style={scrollableStyle}>\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n );\n}\n\nexport { MotionRailPreact as MotionRail };\n"],"mappings":";;;AAcA,SAAS,iBAAiB,EAAE,YAAS,GAAG,KAA6B;CACnE,IAAM,IAAe,OAAuB,KAAK,EAC3C,IAAgB,OAA+B,KAAK,EACpD,EAAE,aAAU,GAAG,MAAiB,KAAY,EAAE;AAkBpD,CAhBA,gBAAgB;AACT,QAAa,QAOlB,QALA,EAAc,UAAU,IAAI,WAC1B,EAAa,SACb,KAAW,EAAE,CACd,QAEY;AACX,GAEE,EAAc,aADd,EAAc,QAAQ,SAAS,EACP;;IAG3B,CAAC,EAAQ,CAAC,EAEb,gBAAgB;AACd,EAAI,EAAc,WAChB,EAAc,QAAQ,QAAQ;IAE/B,CAAC,EAAS,CAAC;CAGd,IAAM,IAAkB,GAAS,gBAC7B,EAAE,eAAe,EAAQ,eAAe,GACxC,KAAA;AACJ,QACE,oBAAC,OAAA;EAAI,KAAK;EAAc,mBAAA;EAAgB,GAAI;YAC1C,oBAAC,OAAA;GAAI,8BAAA;GAA2B,OAAO;aACrC,oBAAC,OAAA;IAAI,wBAAA;IAAsB;KAAe;IACtC;GACF"}
@@ -1,2 +1,2 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`preact/hooks`),require(`motionrail`),require(`preact/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`preact/hooks`,`motionrail`,`preact/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MotionRailPreact={},e.PreactHooks,e.MotionRail,e.PreactJSXRuntime))})(this,function(e,t,n,r){function i({options:e,...i}){let a=(0,t.useRef)(null),o=(0,t.useRef)(null),{children:s,...c}=i||{};return(0,t.useEffect)(()=>{if(a.current)return o.current=new n.MotionRail(a.current,e||{}),()=>{o.current&&=(o.current.destroy(),null)}},[e]),(0,t.useEffect)(()=>{o.current&&o.current.update()},[s]),(0,r.jsx)(`div`,{ref:a,"data-motionrail":!0,...c,children:(0,r.jsx)(`div`,{"data-motionrail-scrollable":!0,children:(0,r.jsx)(`div`,{"data-motionrail-grid":!0,children:s})})})}e.MotionRail=i});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`preact/hooks`),require(`motionrail`),require(`preact/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`preact/hooks`,`motionrail`,`preact/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MotionRailPreact={},e.PreactHooks,e.MotionRail,e.PreactJSXRuntime))})(this,function(e,t,n,r){function i({options:e,...i}){let a=(0,t.useRef)(null),o=(0,t.useRef)(null),{children:s,...c}=i||{};(0,t.useEffect)(()=>{if(a.current)return o.current=new n.MotionRail(a.current,e||{}),()=>{o.current&&=(o.current.destroy(),null)}},[e]),(0,t.useEffect)(()=>{o.current&&o.current.update()},[s]);let l=e?.containerName?{containerName:e.containerName}:void 0;return(0,r.jsx)(`div`,{ref:a,"data-motionrail":!0,...c,children:(0,r.jsx)(`div`,{"data-motionrail-scrollable":!0,style:l,children:(0,r.jsx)(`div`,{"data-motionrail-grid":!0,children:s})})})}e.MotionRail=i});
2
2
  //# sourceMappingURL=preact.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preact.umd.js","names":[],"sources":["../src/lib/main.tsx"],"sourcesContent":["import { useEffect, useRef } from \"preact/hooks\";\nimport type { JSX } from \"preact\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'ref'> {\n options?: MotionRailOptions;\n}\n\nfunction MotionRailPreact({ options, ...divProps }: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n return (\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div data-motionrail-scrollable>\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n );\n}\n\nexport { MotionRailPreact as MotionRail };\n"],"mappings":"4YAWA,SAAS,EAAiB,CAAE,UAAS,GAAG,GAA6B,CACnE,IAAM,GAAA,EAAA,EAAA,QAAsC,KAAK,CAC3C,GAAA,EAAA,EAAA,QAA+C,KAAK,CACpD,CAAE,WAAU,GAAG,GAAiB,GAAY,EAAE,CAwBpD,OAtBA,EAAA,EAAA,eAAgB,CACT,KAAa,QAOlB,MALA,GAAc,QAAU,IAAI,EAAA,WAC1B,EAAa,QACb,GAAW,EAAE,CACd,KAEY,CACX,AAEE,EAAc,WADd,EAAc,QAAQ,SAAS,CACP,QAG3B,CAAC,EAAQ,CAAC,EAEb,EAAA,EAAA,eAAgB,CACV,EAAc,SAChB,EAAc,QAAQ,QAAQ,EAE/B,CAAC,EAAS,CAAC,EAGZ,EAAA,EAAA,KAAC,MAAA,CAAI,IAAK,EAAc,kBAAA,GAAgB,GAAI,YAC1C,EAAA,EAAA,KAAC,MAAA,CAAI,6BAAA,aACH,EAAA,EAAA,KAAC,MAAA,CAAI,uBAAA,GAAsB,YAAe,EACtC,EACF"}
1
+ {"version":3,"file":"preact.umd.js","names":[],"sources":["../src/lib/main.tsx"],"sourcesContent":["import { useEffect, useRef } from \"preact/hooks\";\nimport type { JSX } from \"preact\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends Omit<\n JSX.HTMLAttributes<HTMLDivElement>,\n \"ref\"\n> {\n options?: MotionRailOptions;\n}\n\nfunction MotionRailPreact({ options, ...divProps }: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n // Compute style for scrollable div\n const scrollableStyle = options?.containerName\n ? { containerName: options.containerName }\n : undefined;\n return (\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div data-motionrail-scrollable style={scrollableStyle}>\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n );\n}\n\nexport { MotionRailPreact as MotionRail };\n"],"mappings":"4YAcA,SAAS,EAAiB,CAAE,UAAS,GAAG,GAA6B,CACnE,IAAM,GAAA,EAAA,EAAA,QAAsC,KAAK,CAC3C,GAAA,EAAA,EAAA,QAA+C,KAAK,CACpD,CAAE,WAAU,GAAG,GAAiB,GAAY,EAAE,EAEpD,EAAA,EAAA,eAAgB,CACT,KAAa,QAOlB,MALA,GAAc,QAAU,IAAI,EAAA,WAC1B,EAAa,QACb,GAAW,EAAE,CACd,KAEY,CACX,AAEE,EAAc,WADd,EAAc,QAAQ,SAAS,CACP,QAG3B,CAAC,EAAQ,CAAC,EAEb,EAAA,EAAA,eAAgB,CACV,EAAc,SAChB,EAAc,QAAQ,QAAQ,EAE/B,CAAC,EAAS,CAAC,CAGd,IAAM,EAAkB,GAAS,cAC7B,CAAE,cAAe,EAAQ,cAAe,CACxC,IAAA,GACJ,OACE,EAAA,EAAA,KAAC,MAAA,CAAI,IAAK,EAAc,kBAAA,GAAgB,GAAI,YAC1C,EAAA,EAAA,KAAC,MAAA,CAAI,6BAAA,GAA2B,MAAO,YACrC,EAAA,EAAA,KAAC,MAAA,CAAI,uBAAA,GAAsB,YAAe,EACtC,EACF"}
@@ -3,16 +3,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
4
  const qwik = require("@builder.io/qwik");
5
5
  const motionrail = require("motionrail");
6
- const MotionRail = qwik.component$(({ options, ...divProps }) => {
6
+ const MotionRail = qwik.component$((props) => {
7
+ const { options, ...divProps } = props;
8
+ const { onChange, ...restOptions } = options || {};
7
9
  const containerRef = qwik.useSignal();
8
10
  const motionRailRef = qwik.useSignal(null);
9
- const optionsStore = qwik.useStore({
10
- value: void 0
11
- });
12
- optionsStore.value = options;
13
11
  qwik.useVisibleTask$(({ cleanup }) => {
14
12
  if (!containerRef.value) return;
15
- motionRailRef.value = new motionrail.MotionRail(containerRef.value, qwik.noSerialize(optionsStore.value) || {});
13
+ motionRailRef.value = new motionrail.MotionRail(containerRef.value, restOptions);
14
+ if (onChange && motionRailRef.value) {
15
+ motionRailRef.value.setOnChange(onChange);
16
+ }
16
17
  cleanup(() => {
17
18
  if (motionRailRef.value) {
18
19
  motionRailRef.value.destroy();
@@ -20,12 +21,16 @@ const MotionRail = qwik.component$(({ options, ...divProps }) => {
20
21
  }
21
22
  });
22
23
  });
24
+ const scrollableStyle = options?.containerName ? {
25
+ containerName: options.containerName
26
+ } : void 0;
23
27
  return /* @__PURE__ */ jsxRuntime.jsx("div", {
24
28
  ref: containerRef,
25
29
  "data-motionrail": true,
26
30
  ...divProps,
27
31
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
28
32
  "data-motionrail-scrollable": true,
33
+ style: scrollableStyle,
29
34
  children: /* @__PURE__ */ jsxRuntime.jsx("div", {
30
35
  "data-motionrail-grid": true,
31
36
  children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
@@ -1,16 +1,17 @@
1
1
  import { jsx } from "@builder.io/qwik/jsx-runtime";
2
- import { component$, useSignal, useStore, useVisibleTask$, noSerialize, Slot } from "@builder.io/qwik";
2
+ import { component$, useSignal, useVisibleTask$, Slot } from "@builder.io/qwik";
3
3
  import { MotionRail as MotionRail$1 } from "motionrail";
4
- const MotionRail = component$(({ options, ...divProps }) => {
4
+ const MotionRail = component$((props) => {
5
+ const { options, ...divProps } = props;
6
+ const { onChange, ...restOptions } = options || {};
5
7
  const containerRef = useSignal();
6
8
  const motionRailRef = useSignal(null);
7
- const optionsStore = useStore({
8
- value: void 0
9
- });
10
- optionsStore.value = options;
11
9
  useVisibleTask$(({ cleanup }) => {
12
10
  if (!containerRef.value) return;
13
- motionRailRef.value = new MotionRail$1(containerRef.value, noSerialize(optionsStore.value) || {});
11
+ motionRailRef.value = new MotionRail$1(containerRef.value, restOptions);
12
+ if (onChange && motionRailRef.value) {
13
+ motionRailRef.value.setOnChange(onChange);
14
+ }
14
15
  cleanup(() => {
15
16
  if (motionRailRef.value) {
16
17
  motionRailRef.value.destroy();
@@ -18,12 +19,16 @@ const MotionRail = component$(({ options, ...divProps }) => {
18
19
  }
19
20
  });
20
21
  });
22
+ const scrollableStyle = options?.containerName ? {
23
+ containerName: options.containerName
24
+ } : void 0;
21
25
  return /* @__PURE__ */ jsx("div", {
22
26
  ref: containerRef,
23
27
  "data-motionrail": true,
24
28
  ...divProps,
25
29
  children: /* @__PURE__ */ jsx("div", {
26
30
  "data-motionrail-scrollable": true,
31
+ style: scrollableStyle,
27
32
  children: /* @__PURE__ */ jsx("div", {
28
33
  "data-motionrail-grid": true,
29
34
  children: /* @__PURE__ */ jsx(Slot, {})
@@ -0,0 +1,2 @@
1
+ import { type RenderOptions } from "@builder.io/qwik";
2
+ export default function (opts: RenderOptions): Promise<import("@builder.io/qwik").RenderResult>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WHAT IS THIS FILE?
3
+ *
4
+ * SSR entry point, in all cases the application is rendered outside the browser, this
5
+ * entry point will be the common one.
6
+ *
7
+ * - Server (express, cloudflare...)
8
+ * - npm run start
9
+ * - npm run preview
10
+ * - npm run build
11
+ *
12
+ */
13
+ import { type RenderToStreamOptions } from "@builder.io/qwik/server";
14
+ export default function (opts: RenderToStreamOptions): Promise<import("@builder.io/qwik/server").RenderToStreamResult>;
@@ -1 +1 @@
1
- export { MotionRail } from './main';
1
+ export { MotionRail } from "./main";
@@ -1,4 +1,4 @@
1
- import { type MotionRailOptions } from "motionrail";
1
+ import type { MotionRailOptions } from "motionrail";
2
2
  export interface MotionRailProps {
3
3
  options?: MotionRailOptions;
4
4
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("@builder.io/qwik").JSXOutput;
2
+ export default _default;
@@ -1,27 +1,28 @@
1
1
  "use client";
2
2
  import { useEffect, useRef } from "react";
3
3
  import { MotionRail } from "motionrail";
4
- import { jsx } from "react/jsx-runtime";
5
- function MotionRailReact({ options: i, ref: a, divRef: o, ...s }) {
6
- let c = useRef(null), l = useRef(null), { children: u, ...d } = s || {};
4
+ import { Fragment, jsx } from "react/jsx-runtime";
5
+ function MotionRailReact({ options: a, ref: o, divRef: s, ...c }) {
6
+ let l = useRef(null), u = useRef(null), { children: d, ...f } = c || {};
7
7
  return useEffect(() => {
8
- if (c.current) return l.current = new MotionRail(c.current, i || {}), a && (a.current = l.current), o && (o.current = c.current), () => {
9
- l.current &&= (l.current.destroy(), null);
8
+ if (l.current) return u.current = new MotionRail(l.current, a || {}), o && (o.current = u.current), s && (s.current = l.current), () => {
9
+ u.current &&= (u.current.destroy(), null);
10
10
  };
11
- }, [i]), useEffect(() => {
12
- l.current && l.current.update();
13
- }, [u]), /* @__PURE__ */ jsx("div", {
14
- ref: c,
11
+ }, [a]), useEffect(() => {
12
+ u.current && u.current.update();
13
+ }, [d]), /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", {
14
+ ref: l,
15
15
  "data-motionrail": !0,
16
- ...d,
16
+ ...f,
17
17
  children: /* @__PURE__ */ jsx("div", {
18
18
  "data-motionrail-scrollable": !0,
19
+ style: { containerName: a?.containerName },
19
20
  children: /* @__PURE__ */ jsx("div", {
20
21
  "data-motionrail-grid": !0,
21
- children: u
22
+ children: d
22
23
  })
23
24
  })
24
- });
25
+ }) });
25
26
  }
26
27
  export { MotionRailReact as MotionRail };
27
28
 
@@ -1 +1 @@
1
- {"version":3,"file":"react.es.js","names":[],"sources":["../src/main.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type MutableRefObject } from \"react\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends React.HTMLAttributes<HTMLDivElement> {\n ref?: MutableRefObject<MotionRailClass | null>;\n divRef?: MutableRefObject<HTMLDivElement | null>;\n options?: MotionRailOptions;\n}\n\nfunction MotionRailReact({ options, ref, divRef, ...divProps }: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n if (ref) {\n ref.current = motionRailRef.current;\n }\n\n if (divRef) {\n divRef.current = containerRef.current;\n }\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n return (\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div data-motionrail-scrollable>\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n );\n}\n\nexport { MotionRailReact as MotionRail };\n"],"mappings":";;;;AAcA,SAAS,gBAAgB,EAAE,YAAS,QAAK,WAAQ,GAAG,KAA6B;CAC/E,IAAM,IAAe,OAAuB,KAAK,EAC3C,IAAgB,OAA+B,KAAK,EACpD,EAAE,aAAU,GAAG,MAAiB,KAAY,EAAE;AA+BpD,QA7BA,gBAAgB;AACT,QAAa,QAclB,QAZA,EAAc,UAAU,IAAI,WAC1B,EAAa,SACb,KAAW,EAAE,CACd,EACG,MACF,EAAI,UAAU,EAAc,UAG1B,MACF,EAAO,UAAU,EAAa,gBAGnB;AACX,GAEE,EAAc,aADd,EAAc,QAAQ,SAAS,EACP;;IAG3B,CAAC,EAAQ,CAAC,EAEb,gBAAgB;AACd,EAAI,EAAc,WAChB,EAAc,QAAQ,QAAQ;IAE/B,CAAC,EAAS,CAAC,EAGZ,oBAAC,OAAA;EAAI,KAAK;EAAc,mBAAA;EAAgB,GAAI;YAC1C,oBAAC,OAAA;GAAI,8BAAA;aACH,oBAAC,OAAA;IAAI,wBAAA;IAAsB;KAAe;IACtC;GACF"}
1
+ {"version":3,"file":"react.es.js","names":[],"sources":["../src/main.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type MutableRefObject } from \"react\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends React.HTMLAttributes<HTMLDivElement> {\n ref?: MutableRefObject<MotionRailClass | null>;\n divRef?: MutableRefObject<HTMLDivElement | null>;\n options?: MotionRailOptions;\n}\n\nfunction MotionRailReact({\n options,\n ref,\n divRef,\n ...divProps\n}: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n if (ref) {\n ref.current = motionRailRef.current;\n }\n\n if (divRef) {\n divRef.current = containerRef.current;\n }\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n return (\n <>\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div\n data-motionrail-scrollable\n style={{ containerName: options?.containerName }}\n >\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n </>\n );\n}\n\nexport { MotionRailReact as MotionRail };\n"],"mappings":";;;;AAcA,SAAS,gBAAgB,EACvB,YACA,QACA,WACA,GAAG,KACe;CAClB,IAAM,IAAe,OAAuB,KAAK,EAC3C,IAAgB,OAA+B,KAAK,EACpD,EAAE,aAAU,GAAG,MAAiB,KAAY,EAAE;AA+BpD,QA7BA,gBAAgB;AACT,QAAa,QAclB,QAZA,EAAc,UAAU,IAAI,WAC1B,EAAa,SACb,KAAW,EAAE,CACd,EACG,MACF,EAAI,UAAU,EAAc,UAG1B,MACF,EAAO,UAAU,EAAa,gBAGnB;AACX,GAEE,EAAc,aADd,EAAc,QAAQ,SAAS,EACP;;IAG3B,CAAC,EAAQ,CAAC,EAEb,gBAAgB;AACd,EAAI,EAAc,WAChB,EAAc,QAAQ,QAAQ;IAE/B,CAAC,EAAS,CAAC,EAGZ,oBAAA,UAAA,EAAA,UACE,oBAAC,OAAA;EAAI,KAAK;EAAc,mBAAA;EAAgB,GAAI;YAC1C,oBAAC,OAAA;GACC,8BAAA;GACA,OAAO,EAAE,eAAe,GAAS,eAAe;aAEhD,oBAAC,OAAA;IAAI,wBAAA;IAAsB;KAAe;IACtC;GACF,EAAA,CACL"}
@@ -1,2 +1,2 @@
1
- "use client";(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`motionrail`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`motionrail`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MotionRailReact={},e.React,e.MotionRail,e.React))})(this,function(e,t,n,r){function i({options:e,ref:i,divRef:a,...o}){let s=(0,t.useRef)(null),c=(0,t.useRef)(null),{children:l,...u}=o||{};return(0,t.useEffect)(()=>{if(s.current)return c.current=new n.MotionRail(s.current,e||{}),i&&(i.current=c.current),a&&(a.current=s.current),()=>{c.current&&=(c.current.destroy(),null)}},[e]),(0,t.useEffect)(()=>{c.current&&c.current.update()},[l]),(0,r.jsx)(`div`,{ref:s,"data-motionrail":!0,...u,children:(0,r.jsx)(`div`,{"data-motionrail-scrollable":!0,children:(0,r.jsx)(`div`,{"data-motionrail-grid":!0,children:l})})})}e.MotionRail=i});
1
+ "use client";(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`motionrail`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`motionrail`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MotionRailReact={},e.React,e.MotionRail,e.React))})(this,function(e,t,n,r){function i({options:e,ref:i,divRef:a,...o}){let s=(0,t.useRef)(null),c=(0,t.useRef)(null),{children:l,...u}=o||{};return(0,t.useEffect)(()=>{if(s.current)return c.current=new n.MotionRail(s.current,e||{}),i&&(i.current=c.current),a&&(a.current=s.current),()=>{c.current&&=(c.current.destroy(),null)}},[e]),(0,t.useEffect)(()=>{c.current&&c.current.update()},[l]),(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(`div`,{ref:s,"data-motionrail":!0,...u,children:(0,r.jsx)(`div`,{"data-motionrail-scrollable":!0,style:{containerName:e?.containerName},children:(0,r.jsx)(`div`,{"data-motionrail-grid":!0,children:l})})})})}e.MotionRail=i});
2
2
  //# sourceMappingURL=react.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.umd.js","names":[],"sources":["../src/main.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type MutableRefObject } from \"react\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends React.HTMLAttributes<HTMLDivElement> {\n ref?: MutableRefObject<MotionRailClass | null>;\n divRef?: MutableRefObject<HTMLDivElement | null>;\n options?: MotionRailOptions;\n}\n\nfunction MotionRailReact({ options, ref, divRef, ...divProps }: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n if (ref) {\n ref.current = motionRailRef.current;\n }\n\n if (divRef) {\n divRef.current = containerRef.current;\n }\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n return (\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div data-motionrail-scrollable>\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n );\n}\n\nexport { MotionRailReact as MotionRail };\n"],"mappings":"uXAcA,SAAS,EAAgB,CAAE,UAAS,MAAK,SAAQ,GAAG,GAA6B,CAC/E,IAAM,GAAA,EAAA,EAAA,QAAsC,KAAK,CAC3C,GAAA,EAAA,EAAA,QAA+C,KAAK,CACpD,CAAE,WAAU,GAAG,GAAiB,GAAY,EAAE,CA+BpD,OA7BA,EAAA,EAAA,eAAgB,CACT,KAAa,QAclB,MAZA,GAAc,QAAU,IAAI,EAAA,WAC1B,EAAa,QACb,GAAW,EAAE,CACd,CACG,IACF,EAAI,QAAU,EAAc,SAG1B,IACF,EAAO,QAAU,EAAa,aAGnB,CACX,AAEE,EAAc,WADd,EAAc,QAAQ,SAAS,CACP,QAG3B,CAAC,EAAQ,CAAC,EAEb,EAAA,EAAA,eAAgB,CACV,EAAc,SAChB,EAAc,QAAQ,QAAQ,EAE/B,CAAC,EAAS,CAAC,EAGZ,EAAA,EAAA,KAAC,MAAA,CAAI,IAAK,EAAc,kBAAA,GAAgB,GAAI,YAC1C,EAAA,EAAA,KAAC,MAAA,CAAI,6BAAA,aACH,EAAA,EAAA,KAAC,MAAA,CAAI,uBAAA,GAAsB,YAAe,EACtC,EACF"}
1
+ {"version":3,"file":"react.umd.js","names":[],"sources":["../src/main.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type MutableRefObject } from \"react\";\nimport {\n MotionRail as MotionRailClass,\n type MotionRailOptions,\n} from \"motionrail\";\n\nexport interface MotionRailProps extends React.HTMLAttributes<HTMLDivElement> {\n ref?: MutableRefObject<MotionRailClass | null>;\n divRef?: MutableRefObject<HTMLDivElement | null>;\n options?: MotionRailOptions;\n}\n\nfunction MotionRailReact({\n options,\n ref,\n divRef,\n ...divProps\n}: MotionRailProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const motionRailRef = useRef<MotionRailClass | null>(null);\n const { children, ...restDivProps } = divProps || {};\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n motionRailRef.current = new MotionRailClass(\n containerRef.current,\n options || {},\n );\n if (ref) {\n ref.current = motionRailRef.current;\n }\n\n if (divRef) {\n divRef.current = containerRef.current;\n }\n\n return () => {\n if (motionRailRef.current) {\n motionRailRef.current.destroy();\n motionRailRef.current = null;\n }\n };\n }, [options]);\n\n useEffect(() => {\n if (motionRailRef.current) {\n motionRailRef.current.update();\n }\n }, [children]);\n\n return (\n <>\n <div ref={containerRef} data-motionrail {...restDivProps}>\n <div\n data-motionrail-scrollable\n style={{ containerName: options?.containerName }}\n >\n <div data-motionrail-grid>{children}</div>\n </div>\n </div>\n </>\n );\n}\n\nexport { MotionRailReact as MotionRail };\n"],"mappings":"uXAcA,SAAS,EAAgB,CACvB,UACA,MACA,SACA,GAAG,GACe,CAClB,IAAM,GAAA,EAAA,EAAA,QAAsC,KAAK,CAC3C,GAAA,EAAA,EAAA,QAA+C,KAAK,CACpD,CAAE,WAAU,GAAG,GAAiB,GAAY,EAAE,CA+BpD,OA7BA,EAAA,EAAA,eAAgB,CACT,KAAa,QAclB,MAZA,GAAc,QAAU,IAAI,EAAA,WAC1B,EAAa,QACb,GAAW,EAAE,CACd,CACG,IACF,EAAI,QAAU,EAAc,SAG1B,IACF,EAAO,QAAU,EAAa,aAGnB,CACX,AAEE,EAAc,WADd,EAAc,QAAQ,SAAS,CACP,QAG3B,CAAC,EAAQ,CAAC,EAEb,EAAA,EAAA,eAAgB,CACV,EAAc,SAChB,EAAc,QAAQ,QAAQ,EAE/B,CAAC,EAAS,CAAC,EAGZ,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,UACE,EAAA,EAAA,KAAC,MAAA,CAAI,IAAK,EAAc,kBAAA,GAAgB,GAAI,YAC1C,EAAA,EAAA,KAAC,MAAA,CACC,6BAAA,GACA,MAAO,CAAE,cAAe,GAAS,cAAe,WAEhD,EAAA,EAAA,KAAC,MAAA,CAAI,uBAAA,GAAsB,YAAe,EACtC,EACF,CAAA,CACL"}
@@ -1,4 +1,4 @@
1
- import { template, use, spread, insert } from 'solid-js/web';
1
+ import { template, use, spread, insert, effect, style } from 'solid-js/web';
2
2
  import { children, onMount, createEffect, onCleanup } from 'solid-js';
3
3
  import { MotionRail } from 'motionrail';
4
4
 
@@ -24,12 +24,21 @@ function MotionRailSolid(props) {
24
24
  motionRailInstance = null;
25
25
  }
26
26
  });
27
+ const {
28
+ options,
29
+ children: children$1,
30
+ ...restProps
31
+ } = props;
32
+ const scrollableStyle = options?.containerName ? {
33
+ containerName: options.containerName
34
+ } : void 0;
27
35
  return (() => {
28
36
  var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
29
37
  var _ref$ = containerRef;
30
38
  typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
31
- spread(_el$, props, false, true);
39
+ spread(_el$, restProps, false, true);
32
40
  insert(_el$3, resolved);
41
+ effect((_$p) => style(_el$2, scrollableStyle, _$p));
33
42
  return _el$;
34
43
  })();
35
44
  }
@@ -1,18 +1,13 @@
1
1
  // src/index.tsx
2
2
  import { onMount, onCleanup, createEffect, children as resolveChildren } from "solid-js";
3
- import {
4
- MotionRail as MotionRailClass
5
- } from "motionrail";
3
+ import { MotionRail as MotionRailClass } from "motionrail";
6
4
  function MotionRailSolid(props) {
7
5
  let containerRef;
8
6
  let motionRailInstance = null;
9
7
  const resolved = resolveChildren(() => props.children);
10
8
  onMount(() => {
11
9
  if (!containerRef) return;
12
- motionRailInstance = new MotionRailClass(
13
- containerRef,
14
- props.options || {}
15
- );
10
+ motionRailInstance = new MotionRailClass(containerRef, props.options || {});
16
11
  });
17
12
  createEffect(() => {
18
13
  resolved();
@@ -26,8 +21,10 @@ function MotionRailSolid(props) {
26
21
  motionRailInstance = null;
27
22
  }
28
23
  });
29
- return <div ref={containerRef} data-motionrail {...props}>
30
- <div data-motionrail-scrollable>
24
+ const { options, children, ...restProps } = props;
25
+ const scrollableStyle = options?.containerName ? { containerName: options.containerName } : void 0;
26
+ return <div ref={containerRef} data-motionrail {...restProps}>
27
+ <div data-motionrail-scrollable style={scrollableStyle}>
31
28
  <div data-motionrail-grid>{resolved()}</div>
32
29
  </div>
33
30
  </div>;
@@ -1,4 +1,4 @@
1
- import { template, use, spread, insert } from 'solid-js/web';
1
+ import { template, use, spread, insert, effect, style } from 'solid-js/web';
2
2
  import { children, onMount, createEffect, onCleanup } from 'solid-js';
3
3
  import { MotionRail } from 'motionrail';
4
4
 
@@ -24,12 +24,21 @@ function MotionRailSolid(props) {
24
24
  motionRailInstance = null;
25
25
  }
26
26
  });
27
+ const {
28
+ options,
29
+ children: children$1,
30
+ ...restProps
31
+ } = props;
32
+ const scrollableStyle = options?.containerName ? {
33
+ containerName: options.containerName
34
+ } : void 0;
27
35
  return (() => {
28
36
  var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
29
37
  var _ref$ = containerRef;
30
38
  typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
31
- spread(_el$, props, false, true);
39
+ spread(_el$, restProps, false, true);
32
40
  insert(_el$3, resolved);
41
+ effect((_$p) => style(_el$2, scrollableStyle, _$p));
33
42
  return _el$;
34
43
  })();
35
44
  }
@@ -1,18 +1,13 @@
1
1
  // src/index.tsx
2
2
  import { onMount, onCleanup, createEffect, children as resolveChildren } from "solid-js";
3
- import {
4
- MotionRail as MotionRailClass
5
- } from "motionrail";
3
+ import { MotionRail as MotionRailClass } from "motionrail";
6
4
  function MotionRailSolid(props) {
7
5
  let containerRef;
8
6
  let motionRailInstance = null;
9
7
  const resolved = resolveChildren(() => props.children);
10
8
  onMount(() => {
11
9
  if (!containerRef) return;
12
- motionRailInstance = new MotionRailClass(
13
- containerRef,
14
- props.options || {}
15
- );
10
+ motionRailInstance = new MotionRailClass(containerRef, props.options || {});
16
11
  });
17
12
  createEffect(() => {
18
13
  resolved();
@@ -26,8 +21,10 @@ function MotionRailSolid(props) {
26
21
  motionRailInstance = null;
27
22
  }
28
23
  });
29
- return <div ref={containerRef} data-motionrail {...props}>
30
- <div data-motionrail-scrollable>
24
+ const { options, children, ...restProps } = props;
25
+ const scrollableStyle = options?.containerName ? { containerName: options.containerName } : void 0;
26
+ return <div ref={containerRef} data-motionrail {...restProps}>
27
+ <div data-motionrail-scrollable style={scrollableStyle}>
31
28
  <div data-motionrail-grid>{resolved()}</div>
32
29
  </div>
33
30
  </div>;
@@ -1,2 +1,2 @@
1
- import Svelte from "./svelte.svelte";
1
+ import Svelte from './svelte.svelte';
2
2
  export { Svelte as MotionRail };
@@ -1,2 +1,2 @@
1
- import Svelte from "./svelte.svelte";
1
+ import Svelte from './svelte.svelte';
2
2
  export { Svelte as MotionRail };
@@ -1,61 +1,64 @@
1
1
  <script lang="ts">
2
- import { onMount, onDestroy } from "svelte";
3
- import { MotionRail as MotionRailClass } from "motionrail";
4
- import type { MotionRailOptions } from "motionrail";
5
-
6
- export let options: MotionRailOptions = {};
7
- export let instance: MotionRailClass | null = null;
8
- export let container: HTMLDivElement | undefined = undefined;
9
-
10
- let containerRef: HTMLDivElement;
11
- let motionRailInstance: MotionRailClass | null = null;
12
- let slotObserver: MutationObserver | null = null;
13
-
14
- $: instance = motionRailInstance;
15
- $: container = containerRef;
16
-
17
- onMount(() => {
18
- if (!containerRef) return;
19
-
20
- motionRailInstance = new MotionRailClass(containerRef, options);
21
-
22
- const gridElement = containerRef.querySelector('[data-motionrail-grid]');
23
- if (gridElement) {
24
- slotObserver = new MutationObserver(() => {
25
- if (motionRailInstance) {
26
- motionRailInstance.update();
27
- }
28
- });
29
- slotObserver.observe(gridElement, {
30
- childList: true,
31
- subtree: true,
32
- });
33
- }
34
- });
35
-
36
- $: if (motionRailInstance && options) {
37
- if (containerRef) {
38
- motionRailInstance.destroy();
39
- motionRailInstance = new MotionRailClass(containerRef, options);
40
- }
41
- }
42
-
43
- onDestroy(() => {
44
- if (slotObserver) {
45
- slotObserver.disconnect();
46
- slotObserver = null;
47
- }
48
- if (motionRailInstance) {
49
- motionRailInstance.destroy();
50
- motionRailInstance = null;
51
- }
52
- });
2
+ import { onMount, onDestroy } from 'svelte';
3
+ import { MotionRail as MotionRailClass } from 'motionrail';
4
+ import type { MotionRailOptions } from 'motionrail';
5
+
6
+ export let options: MotionRailOptions = {};
7
+ export let instance: MotionRailClass | null = null;
8
+ export let container: HTMLDivElement | undefined = undefined;
9
+
10
+ let containerRef: HTMLDivElement;
11
+ let motionRailInstance: MotionRailClass | null = null;
12
+ let slotObserver: MutationObserver | null = null;
13
+
14
+ $: instance = motionRailInstance;
15
+ $: container = containerRef;
16
+
17
+ onMount(() => {
18
+ if (!containerRef) return;
19
+
20
+ motionRailInstance = new MotionRailClass(containerRef, options);
21
+
22
+ const gridElement = containerRef.querySelector('[data-motionrail-grid]');
23
+ if (gridElement) {
24
+ slotObserver = new MutationObserver(() => {
25
+ if (motionRailInstance) {
26
+ motionRailInstance.update();
27
+ }
28
+ });
29
+ slotObserver.observe(gridElement, {
30
+ childList: true,
31
+ subtree: true
32
+ });
33
+ }
34
+ });
35
+
36
+ $: if (motionRailInstance && options) {
37
+ if (containerRef) {
38
+ motionRailInstance.destroy();
39
+ motionRailInstance = new MotionRailClass(containerRef, options);
40
+ }
41
+ }
42
+
43
+ onDestroy(() => {
44
+ if (slotObserver) {
45
+ slotObserver.disconnect();
46
+ slotObserver = null;
47
+ }
48
+ if (motionRailInstance) {
49
+ motionRailInstance.destroy();
50
+ motionRailInstance = null;
51
+ }
52
+ });
53
53
  </script>
54
54
 
55
55
  <div bind:this={containerRef} data-motionrail {...$$restProps}>
56
- <div data-motionrail-scrollable>
57
- <div data-motionrail-grid>
58
- <slot />
59
- </div>
60
- </div>
56
+ <div
57
+ data-motionrail-scrollable
58
+ style={options?.containerName ? `container-name: ${options.containerName};` : undefined}
59
+ >
60
+ <div data-motionrail-grid>
61
+ <slot />
62
+ </div>
63
+ </div>
61
64
  </div>
@@ -1,5 +1,5 @@
1
- import { MotionRail as MotionRailClass } from "motionrail";
2
- import type { MotionRailOptions } from "motionrail";
1
+ import { MotionRail as MotionRailClass } from 'motionrail';
2
+ import type { MotionRailOptions } from 'motionrail';
3
3
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
4
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
5
5
  $$bindings?: Bindings;