vue-snap 1.2.0 → 1.3.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/README.md CHANGED
@@ -31,6 +31,7 @@ The idea behind this plugin is to create a fully responsive and well-optimized c
31
31
  - **No calculations or heavy logic** – performance-first approach
32
32
  - **Fully responsive** – most customization is handled via CSS (e.g. number of visible slides)
33
33
  - **ESM bundle with tree-shaking** – dead code is automatically eliminated
34
+ - **TypeScript support** – ships with bundled type declarations out of the box
34
35
  - **SSR support** – works with frameworks like Nuxt.js 🎉 [More here](https://github.com/bartdominiak/vue-snap/tree/master/examples)
35
36
  - **Vue 3 support** 🎉 [More here](#installation--usage)
36
37
  - **Modern browser support** – compatible with all common browsers [More here](https://caniuse.com/css-snappoints)
@@ -52,7 +53,7 @@ import { createApp } from 'vue'
52
53
  import App from './App.vue'
53
54
 
54
55
  import VueSnap from 'vue-snap'
55
- import 'vue-snap/dist/vue-snap.css'
56
+ import 'vue-snap/style.css'
56
57
 
57
58
  const myApp = createApp(App)
58
59
 
@@ -64,7 +65,7 @@ myApp.mount('#app')
64
65
 
65
66
  ```js
66
67
  import { Carousel, Slide } from 'vue-snap'
67
- import 'vue-snap/dist/vue-snap.css'
68
+ import 'vue-snap/style.css'
68
69
 
69
70
  export default {
70
71
  components: {
@@ -0,0 +1,53 @@
1
+ interface CarouselProps {
2
+ tag?: string;
3
+ hideArrowsOnBound?: boolean;
4
+ autoplay?: boolean;
5
+ autoplayInterval?: number;
6
+ i18n?: {
7
+ slideLeft: string;
8
+ slideRight: string;
9
+ };
10
+ }
11
+ declare var __VLS_9: {}, __VLS_11: {
12
+ changeSlide: (direction: number) => void;
13
+ isBoundLeft: boolean;
14
+ isBoundRight: boolean;
15
+ };
16
+ type __VLS_Slots = {} & {
17
+ default?: (props: typeof __VLS_9) => any;
18
+ } & {
19
+ arrows?: (props: typeof __VLS_11) => any;
20
+ };
21
+ declare const __VLS_base: import('vue').DefineComponent<CarouselProps, {
22
+ changeSlide: (direction: number) => void;
23
+ goToSlide: (index: number) => void;
24
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
25
+ mounted: (...args: any[]) => void;
26
+ slideChange: (...args: any[]) => void;
27
+ leftBound: (...args: any[]) => void;
28
+ rightBound: (...args: any[]) => void;
29
+ autoplay: (...args: any[]) => void;
30
+ }, string, import('vue').PublicProps, Readonly<CarouselProps> & Readonly<{
31
+ onMounted?: ((...args: any[]) => any) | undefined;
32
+ onSlideChange?: ((...args: any[]) => any) | undefined;
33
+ onLeftBound?: ((...args: any[]) => any) | undefined;
34
+ onRightBound?: ((...args: any[]) => any) | undefined;
35
+ onAutoplay?: ((...args: any[]) => any) | undefined;
36
+ }>, {
37
+ autoplay: boolean;
38
+ autoplayInterval: number;
39
+ tag: string;
40
+ hideArrowsOnBound: boolean;
41
+ i18n: {
42
+ slideLeft: string;
43
+ slideRight: string;
44
+ };
45
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
46
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
47
+ declare const _default: typeof __VLS_export;
48
+ export default _default;
49
+ type __VLS_WithSlots<T, S> = T & {
50
+ new (): {
51
+ $slots: S;
52
+ };
53
+ };
@@ -0,0 +1,31 @@
1
+ declare var __VLS_9: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_9) => any;
4
+ };
5
+ declare const __VLS_base: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
6
+ /**
7
+ * Custom tag
8
+ */
9
+ tag: {
10
+ type: StringConstructor;
11
+ default: string;
12
+ };
13
+ }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
14
+ /**
15
+ * Custom tag
16
+ */
17
+ tag: {
18
+ type: StringConstructor;
19
+ default: string;
20
+ };
21
+ }>> & Readonly<{}>, {
22
+ tag: string;
23
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
24
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
25
+ declare const _default: typeof __VLS_export;
26
+ export default _default;
27
+ type __VLS_WithSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
@@ -0,0 +1,8 @@
1
+ import { App } from 'vue';
2
+ import { default as Carousel } from './components/Carousel.vue';
3
+ import { default as Slide } from './components/Slide.vue';
4
+ export declare const VueSnap: {
5
+ install: (app: App) => void;
6
+ };
7
+ export { Carousel, Slide };
8
+ export default VueSnap;
@@ -0,0 +1,21 @@
1
+ import { Ref } from 'vue';
2
+ type CarouselEmits = {
3
+ (e: 'mounted', value: boolean): void;
4
+ (e: 'slideChange', index: number): void;
5
+ (e: 'leftBound', value: boolean): void;
6
+ (e: 'rightBound', value: boolean): void;
7
+ (e: 'autoplay', value: boolean): void;
8
+ };
9
+ type AutoplayOptions = {
10
+ autoplay: Ref<boolean>;
11
+ autoplayInterval: Ref<number>;
12
+ };
13
+ export declare function useCarousel(emit: CarouselEmits, vsWrapper: Ref<HTMLElement | null>, { autoplay, autoplayInterval }: AutoplayOptions): {
14
+ goToSlide: (index: number) => void;
15
+ changeSlide: (direction: number) => void;
16
+ isBoundLeft: Ref<boolean, boolean>;
17
+ isBoundRight: Ref<boolean, boolean>;
18
+ pauseAutoplay: () => void;
19
+ resumeAutoplay: () => void;
20
+ };
21
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const isClient: boolean;
2
+ export declare const approximatelyEqual: (v1: number, v2: number, epsilon?: number) => boolean;
3
+ export declare function debounce<T extends (...args: unknown[]) => void>(fn: T, wait: number): {
4
+ (...args: Parameters<T>): void;
5
+ cancel: () => void;
6
+ };
package/package.json CHANGED
@@ -1,19 +1,25 @@
1
1
  {
2
2
  "name": "vue-snap",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "Lightweight Carousel based on CSS Scroll Snap",
6
6
  "main": "dist/vue-snap.umd.js",
7
7
  "module": "dist/vue-snap.es.js",
8
8
  "unpkg": "dist/vue-snap.js",
9
+ "types": "dist/entry.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
9
13
  "engines": {
10
14
  "node": ">=22"
11
15
  },
12
16
  "exports": {
13
17
  ".": {
18
+ "types": "./dist/entry.d.ts",
14
19
  "import": "./dist/vue-snap.es.js",
15
20
  "require": "./dist/vue-snap.umd.js"
16
21
  },
22
+ "./style.css": "./dist/vue-snap.css",
17
23
  "./dist/vue-snap.css": "./dist/vue-snap.css"
18
24
  },
19
25
  "scripts": {
@@ -50,6 +56,7 @@
50
56
  "sass-embedded": "^1.100.0",
51
57
  "typescript": "5",
52
58
  "vite": "^8.1.4",
59
+ "vite-plugin-dts": "^5.0.3",
53
60
  "vue-tsc": "^3.3.7"
54
61
  }
55
62
  }
@@ -1,44 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(pnpm --version)",
5
- "Bash(pnpm add *)",
6
- "Bash(pnpm remove *)",
7
- "Bash(npx biome *)",
8
- "Bash(curl -s https://biomejs.dev/schemas/2.5.3/schema.json)",
9
- "Bash(python3 -c ' *)",
10
- "Bash(python3 *)",
11
- "Bash(pnpm lint *)",
12
- "Bash(echo \"exit=$?\")",
13
- "Bash(npx vue-tsc *)",
14
- "Bash(pnpm run *)",
15
- "Bash(pnpm install *)",
16
- "Bash(node -e \"console.log\\(require.resolve\\('vue-snap/package.json'\\)\\)\")",
17
- "Bash(node -e ' *)",
18
- "Bash(bun --version)",
19
- "Bash(bun add *)",
20
- "Bash(bun run *)",
21
- "Bash(gh pr *)",
22
- "Bash(git fetch *)",
23
- "Bash(git rev-list *)",
24
- "Bash(bunx vue-tsc *)",
25
- "Bash(open *)",
26
- "Bash(bun x *)",
27
- "Bash(git add *)",
28
- "Bash(git commit -m ' *)",
29
- "Bash(git branch *)",
30
- "Bash(git checkout *)",
31
- "Bash(git reset *)",
32
- "Bash(git -C /Users/bartek/Sites/vue-snap log --oneline -5 -- index.html)",
33
- "Bash(curl -sI http://localhost:8123/index.html)",
34
- "Bash(curl -sI http://localhost:8123/dist/vue-snap.js)",
35
- "Bash(pkill -f \"http-server -p 8123\")",
36
- "Bash(git -C /Users/bartek/Sites/vue-snap status)",
37
- "Bash(curl -s http://localhost:5173/)",
38
- "Skill(run)",
39
- "Bash(command -v chromium-cli)",
40
- "Bash(bunx --help)",
41
- "Bash(pkill -f \"vite\")"
42
- ]
43
- }
44
- }
package/CHANGELOG.md DELETED
@@ -1,281 +0,0 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ## [1.2.0] - 2026-07-09
10
-
11
- ### Fixed
12
- - Carousel boundary events (`leftBound`/`rightBound`) now fire once, edge-triggered, instead of repeatedly on every scroll tick
13
- - `changeSlide`/`goToSlide` no longer emit a duplicate `slideChange` for the same navigation
14
-
15
- ### Changed
16
- - Migrated examples to Bun
17
- - Replaced ESLint with Biome
18
-
19
- ## [1.1.0] - 2025-06-21
20
- ## Updated
21
- - Refactored core logic into a custom useCarousel hook
22
- - Removed unnecessary logic (e.g. resize events, lodash/debounce)
23
- - Simplified and optimized carousel calculations
24
- - Minified entire carousel bundle to just 4KB
25
-
26
- ## [1.0.3] - 2025-06-15
27
-
28
- ### Fixed
29
- - Package.json import/export destination files
30
-
31
- ## [1.0.2] - 2025-06-15
32
-
33
- ### Fixed
34
- - Package.json import/export destination files
35
-
36
- ## [1.0.1] - 2025-06-15
37
-
38
- ### Fixed
39
- - Package.json import/export destination files
40
-
41
- ## [1.0.0] - 2025-06-15
42
-
43
- ### Added
44
- - Vitepress docs
45
- ### Fixed
46
- - Github Workflow Pipeline
47
- ### Removed
48
- - Rollup configs
49
- - Storybook
50
-
51
- ## [0.7.1] - 2021-05-07
52
-
53
- ### Added
54
- - Mounted event
55
- ### Fixed
56
- - Prevent duplicated event page trigger
57
-
58
- ## [0.7.0] - 2021-02-08
59
- ### Removed
60
- - maxPages and its calculation (#55)
61
-
62
- ### Updated
63
- - Replace changeSlide with simpler goToSlide, for consistent behavior with exposed go-to-page API + removal of dependent method that is not in use anymore (#55)
64
- - Split getting current page index from setting it, supporting passing the index from outside, for example goToSlide method, so in some cases the index will change, even if there was no scroll event. (#55)
65
-
66
- ### Fixed
67
- - Fix support for calculating a proper current slide index, when there is nothing left to scroll (#55)
68
-
69
- ## [0.6.7] - 2021-02-08
70
- ### Added
71
- - Go to slide API (#54)
72
-
73
- ## [0.6.6] - 2020-12-06
74
- ### Updated
75
- - Rollback rollup-plugin-vue(6.0.0 => 5.1.9)
76
-
77
- ## [0.6.5] - 2020-12-05
78
- ### Updated
79
- - Dependencies
80
-
81
- ## [0.6.4] - 2020-11-29
82
- ### Added
83
- - changeSlide, BoundLeft, BoundRight inside slot-scope
84
-
85
- ## [0.6.3] - 2020-11-23
86
- ### Updated
87
- - elementScrollBy function name (#47)
88
- - Dependencies
89
-
90
- ## [0.6.2] - 2020-11-01
91
- ### Fixed
92
- - Slide children method
93
-
94
- ## [0.6.1] - 2020-09-24
95
- ### Updated
96
- - Yarn lock file
97
-
98
- ## [0.6.0] - 2020-09-24
99
- ### Removed
100
- - Removed maximum node version range (#41)
101
- - Node version max range (#41)
102
-
103
- ### Added
104
- - Added dynamic tag support (#41)
105
- - Added i18n support with proper validation (#41)
106
- - Reset list-style CSS (#41)
107
-
108
- ## [0.5.2] - 2020-09-21
109
- ### Updated
110
- - Rollup configs
111
- - Vue@2 and Vue@3 examples
112
- - Docs
113
- - Dependencies
114
- - TravisCI Config (Auto-deploy only Vue@2 version)
115
-
116
- ## [0.5.1] - 2020-09-17
117
- ### Updated
118
- - Docs
119
-
120
- ## [0.5.0] - 2020-09-17
121
- ### Added
122
- - Emit page and bound events (#35)
123
- - Slot/Props/Event descriptions
124
-
125
- ### Updated
126
- - seamless-scroll-polyfill (1.1.0 => 1.2.1)
127
- - Stories markups
128
-
129
- ## [0.4.0] - 2020-09-15
130
- ### Added
131
- - Ability to disable arrows and arrowsOnBound (#30)
132
-
133
- ### Fixed
134
- - Created onResizefn/onScrollFn variables to avoid memory leaks (#28)
135
- - Improve bound calculation precision (#28)
136
- - Avoiding undefined ref (#28)
137
- - Decrease MutationObserver scope only to vsWrapper
138
-
139
- ### Updated
140
- - Renamed Navigation slot to Arrows (#30)
141
-
142
- ## [0.3.4] - 2020-09-15
143
- ### Fixed
144
- - seamless-scroll-polyfill(^1.1.0 => 1.1.0)
145
-
146
- ## [0.3.3] - 2020-09-15
147
- ### Fixed
148
- - TravisCI Config with proper ENV variables
149
-
150
- ## [0.3.2] - 2020-09-15
151
- ### Added
152
- - Automated travis deployment
153
-
154
- ## [0.3.1] - 2020-09-14
155
- ### Updated
156
- - TravisCI configs
157
-
158
- ## [0.3.0] - 2020-09-05
159
- ### Added
160
- - Dynamic slides support (#25)
161
-
162
- ### Updated
163
- - Dependencies
164
-
165
- ## [0.2.0] - 2020-08-29
166
- ### Added
167
- - VueLazy lib
168
-
169
- ### Updated
170
- - Dependencies
171
-
172
- ### Deleted
173
- - Static height in wrapper (#22)
174
- - Old directives
175
-
176
- ## [0.1.0-beta.9] - 2020-08-26
177
- ### Updated
178
- - Dependencies
179
-
180
- ### Added
181
- - Missing type for button arrows (#21)
182
-
183
- ## [0.1.0-beta.8] - 2020-07-12
184
- ### Deleted
185
- - develop branch
186
-
187
- ### Updated
188
- - trigger deployment only on tag release
189
-
190
- ## [0.1.0-beta.7] - 2020-07-12
191
- ### Updated
192
- - changed spread to Array.from (reduce bundle size)
193
-
194
- ## [0.1.0-beta.6] - 2020-07-12
195
- ### Fixed
196
- - storybook typo
197
-
198
- ## [0.1.0-beta.5] - 2020-07-12
199
- ### Added
200
- - storybook-static folder to .npmignore
201
-
202
- ## [0.1.0-beta.4] - 2020-07-12
203
- ### Fixed
204
- - tag typo
205
-
206
- ## [0.1.0-beta.3] - 2020-07-12
207
- ### Added
208
- - non-regular slide widths Support (#16)
209
- - SSR Support (#13)
210
- - Event optimisation with debounce
211
- - Reorganize methods, and load only on need (like Events: Scroll, Resize, or on init)
212
-
213
- ### Updated
214
- - docs with new installation proccess
215
-
216
- ### Moved
217
- - rollup configs to seperate folders
218
-
219
- ## [0.1.0-beta.2] - 2020-06-24
220
- ### Added
221
- - Rollup init
222
-
223
- ### Deleted
224
- - Webpack configs
225
-
226
- ## [0.1.0-beta.1] - 2020-06-17
227
- ### Fixed
228
- - Docs: example relative url
229
-
230
- ### Added
231
- - seamless-scroll-polyfill package
232
-
233
- ### Deleted
234
- - Docs: removed example url
235
- - scss-loader and reduce final bundle size
236
- - comments in final bundle
237
-
238
- ### Moved
239
- - Vue as peerDependency
240
-
241
- ## [0.1.0-alpha.8] - 2020-06-14
242
- ### Fixed
243
- - Docs: Workaround for non-supported SSR plugin
244
-
245
- ## [0.1.0-alpha.7] - 2020-06-14
246
- ### Added
247
- - Docs: Intersection-observer polyfill
248
-
249
- ### Fixed
250
- - Docs: taking VueSnap from dist folder (compiled version)
251
-
252
- ## [0.1.0-alpha.6] - 2020-06-14
253
- ### Added
254
- - Scroll Smooth polyfill (#11)
255
-
256
- ## [0.1.0-alpha.5] - 2020-06-14
257
- ### Added
258
- - Lazyload support
259
- - Lazyload examples to docs and storybook
260
-
261
- ## [0.1.0-alpha.4] - 2020-06-13
262
- ### Added
263
- - Examples to docs
264
- - Babel presets
265
-
266
- ## [0.1.0-alpha.3] - 2020-06-13
267
- ### Added
268
- - docs & storybook deployment
269
-
270
- ## [0.1.0-alpha.2] - 2020-06-13
271
- ### Added
272
- - initialize eslint #8
273
- - initilize git hooks (husky) #8
274
- - initialize VuePress #6
275
- - Storybook Addons (docs, a11y, actions, knobs, viewport, storysource) #2
276
- - props/slots preview #2
277
- - initilize travis #7
278
-
279
- ## [0.1.0-alpha.1] - 2020-06-12
280
- ### Added
281
- - Project init
package/CLAUDE.md DELETED
@@ -1,31 +0,0 @@
1
- ## Core Philosophy
2
- Write simple, readable, lightweight code. Prefer clarity over cleverness. Avoid overhead and premature complexity.
3
-
4
- ## Functions
5
- - Use pure functions; avoid mutating state.
6
- - Keep functions small with a single responsibility — one function does one thing.
7
- - Make functions modular and standalone (no hidden dependencies on outer state).
8
- - Use guard clauses (early return) to keep nesting shallow.
9
- - Flatten asynchronous code with async/await over nested promise chains.
10
-
11
- ## Readability
12
- - Name things clearly — descriptive names over comments. Code should read as self-documenting.
13
- - Comment the *why*, not the *what*. Skip comments that just restate the code.
14
- - Avoid magic numbers — extract them into named constants.
15
- - Prefer composition over deep nesting; flat is readable.
16
- - Keep a consistent style; let a formatter (Prettier/Biome) handle it automatically.
17
-
18
- ## State & Data
19
- - No magic numbers/strings — name them as constants. Function-specific → top of the function; shared → top of the module.
20
- - Immutability by default — `const` over `let`; return new objects instead of mutating.
21
- - Validate inputs at boundaries; handle errors explicitly and fail fast.
22
- - Never swallow errors silently.
23
-
24
- ## Architecture
25
- - Modern, fast, lightweight — avoid library overhead.
26
- - Prefer native/stdlib solutions first.
27
- - Only add a dependency for genuinely complex, well-tested problems (e.g. date parsing, crypto). Don't reinvent those.
28
- - Avoid premature abstraction — don't add layers, config, or generics until a real second use case exists.
29
- - Split code into modules by concern; don't put everything in one file.
30
- - Heuristic: split when a file exceeds ~200 lines or mixes responsibilities.
31
- - No dead code — delete unused code instead of commenting it out (version control remembers).
package/biome.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/2.5.3/schema.json",
3
- "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
4
- "files": { "includes": ["**", "!!**/dist"] },
5
- "formatter": { "enabled": true, "indentStyle": "space", "indentWidth": 2 },
6
- "linter": {
7
- "enabled": true,
8
- "rules": {
9
- "recommended": true,
10
- "style": {}
11
- },
12
- "domains": {
13
- "vue": "recommended"
14
- }
15
- },
16
- "javascript": { "formatter": { "quoteStyle": "single" } },
17
- "assist": {
18
- "enabled": true,
19
- "actions": { "source": { "organizeImports": "on" } }
20
- }
21
- }