@macrulez/masonry-kit-nuxt 0.1.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.
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/module.d.ts +26 -0
- package/dist/module.js +36 -0
- package/dist/module.js.map +1 -0
- package/dist/runtime/plugin.d.ts +5 -0
- package/dist/runtime/plugin.js +11 -0
- package/dist/runtime/plugin.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Danil Lisin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# **Masonry Kit Nuxt**
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Nuxt module wrapping
|
|
6
|
+
[`@macrulez/masonry-kit-vue`](https://www.npmjs.com/package/@macrulez/masonry-kit-vue):
|
|
7
|
+
auto-imported `<MasonryGrid>`/`useMasonry`, a universal plugin that
|
|
8
|
+
seeds their option defaults from your `nuxt.config.ts`, and no manual
|
|
9
|
+
`<ClientOnly>` wrapping needed — the component is already SSR-safe on
|
|
10
|
+
its own, rendering a CSS `columns` approximation until it can measure
|
|
11
|
+
for real.
|
|
12
|
+
|
|
13
|
+
Part of the [masonry-kit](https://github.com/macrulezru/masonry-kit)
|
|
14
|
+
monorepo.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Auto-imports `<MasonryGrid>` and `useMasonry`** — no explicit `import` anywhere in your app
|
|
21
|
+
- **Module options forwarded through `runtimeConfig`** — `direction`, `columns`, `rows`, `minLaneSize`, `gap`, `placement`, `animate`, `transitionDuration`, `transitionEasing`, `ssrColumns`, set once in `nuxt.config.ts` and applied everywhere
|
|
22
|
+
- **A universal (server + client) plugin seeds those defaults** — most option defaults only matter once the engine exists client-side, but `ssrColumns` is read directly by `<MasonryGrid>`'s render function, which runs during SSR too — so the plugin isn't `.client`-only
|
|
23
|
+
- **No `<ClientOnly>` needed anywhere** — `<MasonryGrid>` renders a CSS `columns` approximation server-side and switches to the real transform-based layout the moment it measures on the client, in the same frame
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## When you'd reach for this
|
|
28
|
+
|
|
29
|
+
You're already on Nuxt and want `<MasonryGrid>`/`useMasonry` wired up with zero manual setup — auto-imports, and one place to configure defaults instead of passing the same options at every call site.
|
|
30
|
+
|
|
31
|
+
- **Passing the same `gap`/`columns` to every single `<MasonryGrid>` on the site gets old** — Set them once in `nuxt.config.ts` and every instance that doesn't override them picks up your project's defaults automatically.
|
|
32
|
+
- **You'd rather not remember to import `<MasonryGrid>` in every component** — Auto-imports mean it's just available, the same way Nuxt's own built-ins are.
|
|
33
|
+
- **A team member reaches for `<ClientOnly>` out of habit** — There's nothing to wrap; the component already renders a safe SSR approximation and swaps to the real layout after hydration on its own.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @macrulez/masonry-kit-nuxt
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// nuxt.config.ts
|
|
45
|
+
export default defineNuxtConfig({
|
|
46
|
+
modules: ['@macrulez/masonry-kit-nuxt'],
|
|
47
|
+
masonry: {
|
|
48
|
+
columns: 'auto',
|
|
49
|
+
minLaneSize: 240,
|
|
50
|
+
gap: 16,
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Requires Nuxt `^3.9.0 || ^4.0.0`.
|
|
56
|
+
|
|
57
|
+
### Quick start
|
|
58
|
+
|
|
59
|
+
Once the module is registered, just use the component — no imports:
|
|
60
|
+
|
|
61
|
+
```vue
|
|
62
|
+
<template>
|
|
63
|
+
<!-- <MasonryGrid>/useMasonry are auto-imported -->
|
|
64
|
+
<MasonryGrid :items="items">
|
|
65
|
+
<template #item="{ item }">
|
|
66
|
+
<MyCard :data="item" />
|
|
67
|
+
</template>
|
|
68
|
+
</MasonryGrid>
|
|
69
|
+
</template>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
See
|
|
73
|
+
[`@macrulez/masonry-kit-vue`'s README](https://www.npmjs.com/package/@macrulez/masonry-kit-vue)
|
|
74
|
+
for the full `<MasonryGrid>`/`useMasonry` API — props, slots, `sortable`, virtualization, and more.
|
|
75
|
+
|
|
76
|
+
### More examples
|
|
77
|
+
|
|
78
|
+
#### What the module does
|
|
79
|
+
|
|
80
|
+
1. **Auto-imports** `<MasonryGrid>` and `useMasonry` from `@macrulez/masonry-kit-vue` — no explicit `import` needed in your components.
|
|
81
|
+
2. **Forwards module options** (`direction`, `columns`, `rows`, `minLaneSize`, `gap`, `placement`, `animate`, `transitionDuration`, `transitionEasing`, `ssrColumns`) into `runtimeConfig.public.masonry`.
|
|
82
|
+
3. **Registers a universal plugin** that reads that runtime config and calls `setMasonryDefaults(...)` — so every `<MasonryGrid>`/`useMasonry` use that doesn't pass its own `options` picks up your configured defaults.
|
|
83
|
+
|
|
84
|
+
#### Module options
|
|
85
|
+
|
|
86
|
+
| Option | Falls through to |
|
|
87
|
+
| -------------------- | ------------------------------------------------------- |
|
|
88
|
+
| `direction` | core's own default (`'vertical'`) when unset |
|
|
89
|
+
| `columns` / `rows` | core's own default (`'auto'`) when unset |
|
|
90
|
+
| `minLaneSize` | core's own default (`240`) when unset |
|
|
91
|
+
| `gap` | core's own default (`16`/`16`) when unset |
|
|
92
|
+
| `placement` | core's own default (`'balanced'`) when unset |
|
|
93
|
+
| `animate` | core's own default (`true`) when unset |
|
|
94
|
+
| `transitionDuration` | core's own default (`250`) when unset |
|
|
95
|
+
| `transitionEasing` | core's own default when unset |
|
|
96
|
+
| `ssrColumns` | `columns`/`rows` (if concrete), else a conservative `2` |
|
|
97
|
+
|
|
98
|
+
None of these are hardcoded in the module itself — an option you don't set stays `undefined` all the way through to `@macrulez/masonry-kit-core`'s own default, so a future change to core's default keeps applying automatically for Nuxt consumers too.
|
|
99
|
+
|
|
100
|
+
#### Overriding defaults per instance
|
|
101
|
+
|
|
102
|
+
Module options are the _fallback_, not a ceiling — any `<MasonryGrid :options="...">` prop still wins for that one instance:
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<template>
|
|
106
|
+
<MasonryGrid :items="items" :options="{ columns: 2 }">
|
|
107
|
+
<!-- uses 2 columns here, regardless of the module-wide default -->
|
|
108
|
+
<template #item="{ item }">
|
|
109
|
+
<MyCard :data="item" />
|
|
110
|
+
</template>
|
|
111
|
+
</MasonryGrid>
|
|
112
|
+
</template>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Documentation & links
|
|
118
|
+
|
|
119
|
+
- 📖 **Full documentation:** [npm.vuecraft.ru/en/packages/masonry-kit](https://npm.vuecraft.ru/en/packages/masonry-kit/guide/nuxt-module.html)
|
|
120
|
+
- 🌐 **VueCraft:** [vuecraft.ru/en](https://vuecraft.ru/en)
|
|
121
|
+
- 👤 **Author:** [macrulez.ru/en](https://macrulez.ru/en)
|
|
122
|
+
- 💻 **GitHub:** [macrulezru/masonry-kit/packages/nuxt](https://github.com/macrulezru/masonry-kit/tree/master/packages/nuxt)
|
|
123
|
+
- 📦 **NPM:** [@macrulez/masonry-kit-nuxt](https://www.npmjs.com/package/@macrulez/masonry-kit-nuxt)
|
|
124
|
+
- 🐛 **Issues:** [github.com/macrulezru/masonry-kit/issues](https://github.com/macrulezru/masonry-kit/issues)
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 💖 Support the project
|
|
135
|
+
|
|
136
|
+
Open source takes time and effort. If this library saves you time or brings value, consider supporting further development.
|
|
137
|
+
|
|
138
|
+
<a href="https://donate.cryptocloud.plus/M6O34NIN" target="_blank">
|
|
139
|
+
<img src="https://img.shields.io/badge/Donate-CryptoCloud-8A2BE2?style=for-the-badge&logo=cryptocurrency&logoColor=white" alt="Donate via CryptoCloud">
|
|
140
|
+
</a>
|
|
141
|
+
|
|
142
|
+
Thank you for being part of this journey. ❤️
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
import { LaneSpec } from '@macrulez/masonry-kit-vue';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
/** Falls through to @macrulez/masonry-kit-core's own default ('vertical') when unset. */
|
|
6
|
+
direction?: 'vertical' | 'horizontal';
|
|
7
|
+
columns?: LaneSpec;
|
|
8
|
+
rows?: LaneSpec;
|
|
9
|
+
/** Falls through to @macrulez/masonry-kit-core's own default (240) when unset. */
|
|
10
|
+
minLaneSize?: number;
|
|
11
|
+
gap?: number | {
|
|
12
|
+
main?: number;
|
|
13
|
+
cross?: number;
|
|
14
|
+
};
|
|
15
|
+
placement?: 'balanced' | 'ordered';
|
|
16
|
+
/** Falls through to @macrulez/masonry-kit-core's own default (true) when unset. */
|
|
17
|
+
animate?: boolean;
|
|
18
|
+
/** Falls through to @macrulez/masonry-kit-core's own default (250) when unset. */
|
|
19
|
+
transitionDuration?: number;
|
|
20
|
+
transitionEasing?: string;
|
|
21
|
+
/** CSS-columns SSR fallback (§4.4). Falls through to `columns`/`rows` (if concrete), else a conservative default of 2, when unset. */
|
|
22
|
+
ssrColumns?: number;
|
|
23
|
+
}
|
|
24
|
+
declare const masonryKitModule: NuxtModule<ModuleOptions>;
|
|
25
|
+
|
|
26
|
+
export { type ModuleOptions, masonryKitModule as default };
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/module.ts
|
|
2
|
+
import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
3
|
+
var masonryKitModule = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@macrulez/masonry-kit-nuxt",
|
|
6
|
+
configKey: "masonry"
|
|
7
|
+
},
|
|
8
|
+
// No `defaults` here on purpose: an option the user didn't set in
|
|
9
|
+
// nuxt.config.ts must stay `undefined` all the way through to
|
|
10
|
+
// @macrulez/masonry-kit-core's own defaults — hardcoding one here would
|
|
11
|
+
// silently shadow it, making a change to core's default look like it does
|
|
12
|
+
// nothing for a Nuxt consumer.
|
|
13
|
+
setup(options, nuxt) {
|
|
14
|
+
const resolver = createResolver(import.meta.url);
|
|
15
|
+
addComponent({ name: "MasonryGrid", export: "MasonryGrid", filePath: "@macrulez/masonry-kit-vue" });
|
|
16
|
+
addImports({ name: "useMasonry", from: "@macrulez/masonry-kit-vue" });
|
|
17
|
+
nuxt.options.runtimeConfig.public.masonry = {
|
|
18
|
+
direction: options.direction,
|
|
19
|
+
columns: options.columns,
|
|
20
|
+
rows: options.rows,
|
|
21
|
+
minLaneSize: options.minLaneSize,
|
|
22
|
+
gap: options.gap,
|
|
23
|
+
placement: options.placement,
|
|
24
|
+
animate: options.animate,
|
|
25
|
+
transitionDuration: options.transitionDuration,
|
|
26
|
+
transitionEasing: options.transitionEasing,
|
|
27
|
+
ssrColumns: options.ssrColumns
|
|
28
|
+
};
|
|
29
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
var module_default = masonryKitModule;
|
|
33
|
+
export {
|
|
34
|
+
module_default as default
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/module.ts"],"sourcesContent":["import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type { LaneSpec } from '@macrulez/masonry-kit-vue'\n\nexport interface ModuleOptions {\n /** Falls through to @macrulez/masonry-kit-core's own default ('vertical') when unset. */\n direction?: 'vertical' | 'horizontal'\n columns?: LaneSpec\n rows?: LaneSpec\n /** Falls through to @macrulez/masonry-kit-core's own default (240) when unset. */\n minLaneSize?: number\n gap?: number | { main?: number; cross?: number }\n placement?: 'balanced' | 'ordered'\n /** Falls through to @macrulez/masonry-kit-core's own default (true) when unset. */\n animate?: boolean\n /** Falls through to @macrulez/masonry-kit-core's own default (250) when unset. */\n transitionDuration?: number\n transitionEasing?: string\n /** CSS-columns SSR fallback (§4.4). Falls through to `columns`/`rows` (if concrete), else a conservative default of 2, when unset. */\n ssrColumns?: number\n}\n\nconst masonryKitModule: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@macrulez/masonry-kit-nuxt',\n configKey: 'masonry',\n },\n // No `defaults` here on purpose: an option the user didn't set in\n // nuxt.config.ts must stay `undefined` all the way through to\n // @macrulez/masonry-kit-core's own defaults — hardcoding one here would\n // silently shadow it, making a change to core's default look like it does\n // nothing for a Nuxt consumer.\n setup(options, nuxt) {\n const resolver = createResolver(import.meta.url)\n\n addComponent({ name: 'MasonryGrid', export: 'MasonryGrid', filePath: '@macrulez/masonry-kit-vue' })\n addImports({ name: 'useMasonry', from: '@macrulez/masonry-kit-vue' })\n\n nuxt.options.runtimeConfig.public.masonry = {\n direction: options.direction,\n columns: options.columns,\n rows: options.rows,\n minLaneSize: options.minLaneSize,\n gap: options.gap,\n placement: options.placement,\n animate: options.animate,\n transitionDuration: options.transitionDuration,\n transitionEasing: options.transitionEasing,\n ssrColumns: options.ssrColumns,\n }\n\n // Universal plugin (server + client) — most of these are only consulted\n // once the engine exists client-side (onMounted), but `ssrColumns`\n // (§4.4) is read directly by <MasonryGrid>'s render function, which also\n // runs during SSR, so the defaults need to be seeded there too.\n addPlugin(resolver.resolve('./runtime/plugin'))\n },\n})\n\nexport default masonryKitModule\n"],"mappings":";AAAA,SAAS,cAAc,YAAY,WAAW,gBAAgB,wBAAwB;AAsBtF,IAAM,mBAA8C,iBAAgC;AAAA,EAClF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAAS,MAAM;AACnB,UAAM,WAAW,eAAe,YAAY,GAAG;AAE/C,iBAAa,EAAE,MAAM,eAAe,QAAQ,eAAe,UAAU,4BAA4B,CAAC;AAClG,eAAW,EAAE,MAAM,cAAc,MAAM,4BAA4B,CAAC;AAEpE,SAAK,QAAQ,cAAc,OAAO,UAAU;AAAA,MAC1C,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,MACjB,MAAM,QAAQ;AAAA,MACd,aAAa,QAAQ;AAAA,MACrB,KAAK,QAAQ;AAAA,MACb,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,MACjB,oBAAoB,QAAQ;AAAA,MAC5B,kBAAkB,QAAQ;AAAA,MAC1B,YAAY,QAAQ;AAAA,IACtB;AAMA,cAAU,SAAS,QAAQ,kBAAkB,CAAC;AAAA,EAChD;AACF,CAAC;AAED,IAAO,iBAAQ;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/runtime/plugin.ts
|
|
2
|
+
import { setMasonryDefaults } from "@macrulez/masonry-kit-vue";
|
|
3
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
|
|
4
|
+
var plugin_default = defineNuxtPlugin(() => {
|
|
5
|
+
const config = useRuntimeConfig().public.masonry;
|
|
6
|
+
if (config) setMasonryDefaults(config);
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
plugin_default as default
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/plugin.ts"],"sourcesContent":["import { setMasonryDefaults, type MasonryDefaults } from '@macrulez/masonry-kit-vue'\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\n\n// Universal (runs on both server and client), not `.client`-suffixed:\n// `ssrColumns` (§4.4) is read directly by <MasonryGrid>'s render function,\n// which runs during SSR too.\nexport default defineNuxtPlugin(() => {\n const config = useRuntimeConfig().public.masonry as MasonryDefaults | undefined\n if (config) setMasonryDefaults(config)\n})\n"],"mappings":";AAAA,SAAS,0BAAgD;AACzD,SAAS,kBAAkB,wBAAwB;AAKnD,IAAO,iBAAQ,iBAAiB,MAAM;AACpC,QAAM,SAAS,iBAAiB,EAAE,OAAO;AACzC,MAAI,OAAQ,oBAAmB,MAAM;AACvC,CAAC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@macrulez/masonry-kit-nuxt",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Nuxt module wrapping @macrulez/masonry-kit-vue: auto-imported <MasonryGrid> and useMasonry, module options for default layout behavior",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/module.js",
|
|
11
|
+
"module": "./dist/module.js",
|
|
12
|
+
"types": "./dist/module.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/module.d.ts",
|
|
16
|
+
"import": "./dist/module.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"nuxt": "^3.9.0 || ^4.0.0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@nuxt/kit": "^4.5.2",
|
|
28
|
+
"@macrulez/masonry-kit-vue": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@nuxt/schema": "^4.5.2",
|
|
32
|
+
"nuxt": "^4.5.2",
|
|
33
|
+
"tsup": "^8.3.5",
|
|
34
|
+
"typescript": "^5.6.3",
|
|
35
|
+
"vitest": "^2.1.8"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"dev": "tsup --watch",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:watch": "vitest",
|
|
42
|
+
"typecheck": "tsc --noEmit"
|
|
43
|
+
}
|
|
44
|
+
}
|