well-waterfall 1.2.8 → 1.2.10

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/dist/util.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Waterfall } from 'types/waterfall';
3
3
  export declare function printDebug(debug: boolean, str: string, el: any): void;
4
4
  export declare function getUniqueClasses(targetElement: HTMLElement, comparisonElement: HTMLElement): string;
5
5
  export declare function parseString(el: HTMLElement, attrName: string, defaultValue?: string): string | undefined;
6
+ export declare function parseSlidesPerView(el: HTMLElement, attrName: string, defaultValue?: number): number | "auto" | undefined;
6
7
  export declare function parseAny(el: HTMLElement, attrName: string, defaultValue?: any): any | undefined;
7
8
  export declare function parseNumber(el: HTMLElement, attrName: string, defaultValue?: number): number | undefined;
8
9
  export declare function parseBoolean(el: HTMLElement, attrName: string, defaultValue?: boolean): boolean | undefined;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "well-waterfall",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "Create Swipers in Webflow with attributes",
5
- "main": "dist/index.umd.js",
6
- "module": "dist/index.es.js",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
11
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.es.js",
12
- "require": "./dist/index.umd.js"
12
+ "import": "./dist/index.js"
13
13
  }
14
14
  },
15
15
  "scripts": {
@@ -25,7 +25,7 @@
25
25
  "license": "ISC",
26
26
  "dependencies": {
27
27
  "fs": "^0.0.1-security",
28
- "swiper": "^11.2.10"
28
+ "swiper": "^14.0.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/jquery": "^3.5.32",
@@ -40,5 +40,9 @@
40
40
  "vite": "^7.1.2",
41
41
  "vite-plugin-css-injected-by-js": "^3.5.2",
42
42
  "vite-plugin-dts": "^4.5.4"
43
+ },
44
+ "allowScripts": {
45
+ "esbuild@0.28.1": true,
46
+ "fsevents@2.3.3": true
43
47
  }
44
48
  }
package/src/index.ts CHANGED
@@ -122,4 +122,3 @@ function initConfig(el: HTMLElement, index: number) {
122
122
  waterfalls.push({ name, swiper });
123
123
  }
124
124
  }
125
-
@@ -6,7 +6,7 @@ export const ATTR_WATERFALL_CONTENT = "waterfall-content";
6
6
  // Debug
7
7
  export const ATTR_DEBUG_MODE = "waterfall-debug-mode";
8
8
  export const ATTR_ADVANCED_DEBUG_MODE = "waterfall-advanced-debug-mode";
9
- // A11Y
9
+ // A11Y`
10
10
  export const ATTR_A11Y = "waterfall-a11y";
11
11
  export const ATTR_A11Y_CONTAINER_MESSAGE = "waterfall-a11y-container-message";
12
12
  export const ATTR_A11Y_CONTAINER_ROLE = "waterfall-a11y-container-role";
@@ -15,7 +15,7 @@ import {
15
15
  ATTR_SPACE_BETWEEN,
16
16
  ATTR_WIDTH,
17
17
  } from "lib/attributes";
18
- import { parseAny, parseBoolean, parseNumber, parseString } from "../util";
18
+ import { parseAny, parseBoolean, parseNumber, parseSlidesPerView, parseString } from "../util";
19
19
  import { SwiperOptions } from "swiper/types";
20
20
 
21
21
  export function layoutConfig(config: SwiperOptions, el: HTMLElement) {
@@ -33,7 +33,7 @@ export function layoutConfig(config: SwiperOptions, el: HTMLElement) {
33
33
  config.slidesPerGroup = parseNumber(el, ATTR_SLIDES_PER_GROUP, 1);
34
34
  config.slidesPerGroupAuto = parseBoolean(el, ATTR_SLIDES_PER_GROUP_AUTO, false);
35
35
  config.slidesPerGroupSkip = parseNumber(el, ATTR_SLIDES_PER_GROUP_SKIP, 0);
36
- config.slidesPerView = parseNumber(el, ATTR_SLIDES_PER_VIEW, 1);
36
+ config.slidesPerView = parseSlidesPerView(el, ATTR_SLIDES_PER_VIEW, 1);
37
37
  config.spaceBetween = parseNumber(el, ATTR_SPACE_BETWEEN, 0);
38
38
  config.width = parseNumber(el, ATTR_WIDTH);
39
39
  }
package/src/util.ts CHANGED
@@ -24,6 +24,22 @@ export function parseString(el: HTMLElement, attrName: string, defaultValue?: st
24
24
  return attrValue;
25
25
  }
26
26
 
27
+ export function parseSlidesPerView(
28
+ el: HTMLElement,
29
+ attrName: string,
30
+ defaultValue?: number,
31
+ ): number | "auto" | undefined {
32
+ const attrValue = el.getAttribute(attrName)?.trim();
33
+ if (!attrValue) return undefined;
34
+
35
+ if (attrValue.toLowerCase() === "auto") return "auto";
36
+
37
+ const parsedValue = Number(attrValue);
38
+ const validAndUnique = isNaN(parsedValue) || parsedValue === defaultValue;
39
+ if (validAndUnique) return undefined;
40
+ return parsedValue;
41
+ }
42
+
27
43
  export function parseAny(el: HTMLElement, attrName: string, defaultValue?: any): any | undefined {
28
44
  const attrValue = el.getAttribute(attrName)?.trim();
29
45
  if (!attrValue || attrValue === defaultValue) return undefined;
package/vite.config.ts CHANGED
@@ -15,8 +15,8 @@ export default defineConfig({
15
15
  lib: {
16
16
  entry: resolve(__dirname, 'src/index.ts'),
17
17
  name: 'Waterfall',
18
- formats: ['es', 'umd'],
19
- fileName: (format) => `index.${format}.js`
18
+ formats: ['es'],
19
+ fileName: () => `index.js`
20
20
  },
21
21
  outDir: 'dist',
22
22
  sourcemap: true,