@styleflow.app/flowpress-astro-core 1.0.0-beta.42 → 1.0.0-beta.44
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/CHANGELOG.md +14 -0
- package/README.md +15 -2
- package/dist/astro/blocks/CarouselBlock.astro +64 -94
- package/dist/astro/native/carousel.css +323 -0
- package/dist/astro/native/query-carousel.d.ts +2 -1
- package/dist/astro/native/query-carousel.d.ts.map +1 -1
- package/dist/astro/native/query-carousel.js.map +1 -1
- package/dist/astro/native/query-carousel.ts +8 -4
- package/dist/build-cache.d.ts.map +1 -1
- package/dist/build-cache.js +2 -1
- package/dist/build-cache.js.map +1 -1
- package/dist/carousel.d.ts +56 -6
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +183 -27
- package/dist/carousel.js.map +1 -1
- package/dist/client.d.ts +11 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +46 -3
- package/dist/client.js.map +1 -1
- package/dist/env.d.ts +12 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +33 -0
- package/dist/env.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,11 +3,15 @@ import type { FlowpressBlock, FlowpressBlockRendererProps } from "../../index.js
|
|
|
3
3
|
import type { LoopTemplateData } from "./query-loop.js";
|
|
4
4
|
type SfCarouselAttributes = Record<string, any>;
|
|
5
5
|
|
|
6
|
+
type Responsive<Name extends string> = `${Name}${"Base" | "Sm" | "Md" | "Lg" | "Xl" | "2xl"}`;
|
|
7
|
+
|
|
6
8
|
export type QueryCarouselSettings = Pick<SfCarouselAttributes,
|
|
7
|
-
"ariaLabel" | "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"ariaLabel" | Responsive<"itemsPerView"> | Responsive<"slideWidth"> | Responsive<"peek"> |
|
|
10
|
+
"focus" | "itemsPerMove" | "gap" | "slideAspectRatio" | "equalHeight" | "effect" | "loop" |
|
|
11
|
+
"rewind" | "startIndex" | "speed" | "drag" | "dragFree" | "keyboard" | "wheel" |
|
|
12
|
+
"showArrows" | "arrowsPosition" | "arrowsPositionMobile" | "arrowsShape" | "arrowsSize" |
|
|
13
|
+
"showPagination" | "paginationStyle" | "paginationPosition" | "controlsTone" |
|
|
14
|
+
"controlsIntensity" | "autoplay" | "autoplayInterval" | "pauseOnHover" | "pauseOnFocus"
|
|
11
15
|
> & { enabled: boolean };
|
|
12
16
|
|
|
13
17
|
export interface QueryCarouselData extends LoopTemplateData {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-cache.d.ts","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"build-cache.d.ts","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAKzD,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAsDjH"}
|
package/dist/build-cache.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
3
3
|
import { lstat, readFile, rename, writeFile, unlink, mkdir, rmdir } from "node:fs/promises";
|
|
4
4
|
import { setTimeout as delay } from "node:timers/promises";
|
|
5
5
|
import { isAbsolute, join } from "node:path";
|
|
6
|
+
import { FLOWPRESS_BUILD_STORE_LOCK_MS } from "./env.js";
|
|
6
7
|
const inFlight = new Map();
|
|
7
8
|
export async function createBuildRequestStore(options) {
|
|
8
9
|
const { directory, endpoint, revision } = options;
|
|
@@ -29,7 +30,7 @@ export async function createBuildRequestStore(options) {
|
|
|
29
30
|
return pending;
|
|
30
31
|
const result = (async () => {
|
|
31
32
|
const lock = file + ".lock";
|
|
32
|
-
const deadline = Date.now() +
|
|
33
|
+
const deadline = Date.now() + FLOWPRESS_BUILD_STORE_LOCK_MS;
|
|
33
34
|
while (true) {
|
|
34
35
|
try {
|
|
35
36
|
await mkdir(lock, { mode: 0o700 });
|
package/dist/build-cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-cache.js","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"build-cache.js","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;AAQrD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAmC;IAC/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AAM,SAAS,GAAG,IAAI,GAAG,GAAG,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;oBACrD,IAAI,CAAC;wBACH,MAAM,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBACxF,MAAM,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;oBAChC,CAAC;4BAAS,CAAC;wBACT,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;oBAC1C,CAAC;oBACD,OAAO,KAAK,CAAC;gBACb,CAAC;wBAAS,CAAC;oBAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;gBAAC,CAAC;YAClC,CAAC,CAAC,EAAE,CAAC;YACL,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC;gBAAC,OAAO,MAAM,MAAM,CAAC;YAAC,CAAC;oBAAS,CAAC;gBAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** Node-only, private store shared by the safelist and Astro build processes. */\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { lstat, readFile, rename, writeFile, unlink, mkdir, rmdir } from \"node:fs/promises\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { isAbsolute, join } from \"node:path\";\nimport type { FlowpressRequestStore } from \"./client.js\";\nimport { FLOWPRESS_BUILD_STORE_LOCK_MS } from \"./env.js\";\n\nconst inFlight = new Map<string, Promise<unknown>>();\n\nexport interface FlowpressBuildStoreOptions {\n directory: string;\n endpoint: string;\n revision: string;\n}\n\nexport async function createBuildRequestStore(options: FlowpressBuildStoreOptions): Promise<FlowpressRequestStore> {\n const { directory, endpoint, revision } = options;\n if (!isAbsolute(directory) || !/^[a-f0-9]{32}$/.test(revision)) {\n throw new Error(\"A build request store requires a private absolute directory and content revision.\");\n }\n const stat = await lstat(directory);\n if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077)) {\n throw new Error(\"The build request directory must be private and cannot be a symlink.\");\n }\n const metadata = JSON.parse(await readFile(join(directory, \"session.json\"), \"utf8\"));\n if (metadata.schemaVersion !== 1 || metadata.endpoint !== endpoint || metadata.revision !== revision) {\n throw new Error(\"The build request store belongs to another backend or revision.\");\n }\n return {\n async getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T> {\n const identity = JSON.parse(key) as { endpoint?: string };\n if (identity.endpoint !== endpoint) throw new Error(\"Cross-backend build cache access refused.\");\n const digest = createHash(\"sha256\").update(key).digest(\"hex\");\n const file = join(directory, digest + \".json\");\n const pending = inFlight.get(file);\n if (pending) return pending as Promise<T>;\n const result = (async (): Promise<T> => {\n const lock = file + \".lock\";\n const deadline = Date.now() + FLOWPRESS_BUILD_STORE_LOCK_MS;\n while (true) {\n try { await mkdir(lock, { mode: 0o700 }); break; }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (Date.now() > deadline) throw new Error(\"Timed out waiting for another build process. Discard this attempt.\");\n await delay(20);\n }\n }\n try {\n try {\n const cached = JSON.parse(await readFile(file, \"utf8\"));\n if (cached.key === key && Object.hasOwn(cached, \"value\")) return cached.value as T;\n } catch (error) {\n if (!(error instanceof SyntaxError) && (error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n const value = await load();\n const temporary = file + \".\" + randomUUID() + \".tmp\";\n try {\n await writeFile(temporary, JSON.stringify({ key, value }), { mode: 0o600, flag: \"wx\" });\n await rename(temporary, file);\n } finally {\n await unlink(temporary).catch(() => {});\n }\n return value;\n } finally { await rmdir(lock); }\n })();\n inFlight.set(file, result);\n try { return await result; } finally { inFlight.delete(file); }\n }\n };\n}\n"]}
|
package/dist/carousel.d.ts
CHANGED
|
@@ -1,22 +1,72 @@
|
|
|
1
1
|
import type { Options } from "@splidejs/splide";
|
|
2
|
-
declare const
|
|
2
|
+
export declare const CAROUSEL_BREAKPOINTS: readonly ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
3
|
+
export type CarouselBreakpoint = (typeof CAROUSEL_BREAKPOINTS)[number];
|
|
4
|
+
declare const ARROWS_POSITIONS: readonly ["top", "top-end", "sides", "edges", "outside", "bottom", "bottom-end"];
|
|
5
|
+
declare const ARROWS_MOBILE_POSITIONS: readonly ["same", "bottom", "hidden"];
|
|
6
|
+
declare const ARROWS_SHAPES: readonly ["circle", "rounded", "square"];
|
|
7
|
+
declare const ARROWS_SIZES: readonly ["sm", "md", "lg"];
|
|
8
|
+
declare const PAGINATION_STYLES: readonly ["dots", "bars", "fraction"];
|
|
9
|
+
declare const PAGINATION_POSITIONS: readonly ["below", "overlay"];
|
|
10
|
+
/** Peek keyword aligned with the StyleFlow container padding. */
|
|
11
|
+
export declare const CAROUSEL_CONTAINER_PEEK = "var(--sf-layout-container-comfortable-padding-x, 2rem)";
|
|
3
12
|
export interface FlowpressCarouselSettings {
|
|
4
13
|
ariaLabel: string;
|
|
5
|
-
itemsPerView: Record<
|
|
14
|
+
itemsPerView: Record<CarouselBreakpoint, number>;
|
|
15
|
+
/** Fixed slide width per breakpoint; "" sizes slides from `itemsPerView`. */
|
|
16
|
+
slideWidth: Record<CarouselBreakpoint, string>;
|
|
17
|
+
/** Visible part of the neighbouring slides per breakpoint, as a CSS length ("0" for none). */
|
|
18
|
+
peek: Record<CarouselBreakpoint, string>;
|
|
19
|
+
focus: "start" | "center";
|
|
6
20
|
itemsPerMove: number;
|
|
7
21
|
gap: number;
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
slideAspectRatio: string;
|
|
23
|
+
equalHeight: boolean;
|
|
24
|
+
effect: "slide" | "fade";
|
|
25
|
+
loop: boolean;
|
|
26
|
+
rewind: boolean;
|
|
27
|
+
startIndex: number;
|
|
28
|
+
speed: number;
|
|
10
29
|
drag: boolean;
|
|
30
|
+
dragFree: boolean;
|
|
11
31
|
keyboard: boolean;
|
|
32
|
+
wheel: boolean;
|
|
33
|
+
showArrows: boolean;
|
|
34
|
+
arrowsPosition: (typeof ARROWS_POSITIONS)[number];
|
|
35
|
+
arrowsPositionMobile: (typeof ARROWS_MOBILE_POSITIONS)[number];
|
|
36
|
+
arrowsShape: (typeof ARROWS_SHAPES)[number];
|
|
37
|
+
arrowsSize: (typeof ARROWS_SIZES)[number];
|
|
38
|
+
showPagination: boolean;
|
|
39
|
+
paginationStyle: (typeof PAGINATION_STYLES)[number];
|
|
40
|
+
paginationPosition: (typeof PAGINATION_POSITIONS)[number];
|
|
41
|
+
/** StyleFlow tone and intensity of the controls' background; "" keeps the carousel's context. */
|
|
42
|
+
controlsTone: string;
|
|
43
|
+
controlsIntensity: string;
|
|
12
44
|
autoplay: boolean;
|
|
13
45
|
autoplayInterval: number;
|
|
14
46
|
pauseOnHover: boolean;
|
|
15
47
|
pauseOnFocus: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
48
|
+
}
|
|
49
|
+
export interface FlowpressCarouselLayout {
|
|
50
|
+
/** Custom properties for the carousel root, read by the shared carousel stylesheet. */
|
|
51
|
+
style: Record<string, string>;
|
|
52
|
+
/** `data-*` attributes for the carousel root. */
|
|
53
|
+
data: Record<string, string>;
|
|
18
54
|
}
|
|
19
55
|
export declare function carouselSettings(attributes: Record<string, unknown>): FlowpressCarouselSettings;
|
|
56
|
+
/** CSS length of a peek setting. */
|
|
57
|
+
export declare function carouselPeekLength(peek: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Splide options. Options for settings that keep their previous defaults are left out, so a
|
|
60
|
+
* carousel saved with the original contract mounts with exactly the options it had before.
|
|
61
|
+
*/
|
|
20
62
|
export declare function carouselOptions(settings: FlowpressCarouselSettings): Options;
|
|
63
|
+
/**
|
|
64
|
+
* Static geometry shared by the frontend before Splide mounts and by the block editor: the same
|
|
65
|
+
* slide widths, peeks and centring Splide applies at rest. Percentages in `slide` and `shift`
|
|
66
|
+
* resolve against the list, those in `edge` against the carousel root.
|
|
67
|
+
*/
|
|
68
|
+
export declare function carouselLayout(settings: FlowpressCarouselSettings): FlowpressCarouselLayout;
|
|
69
|
+
/** Inline `style` text of a layout. */
|
|
70
|
+
export declare function carouselStyleText(layout: FlowpressCarouselLayout): string;
|
|
21
71
|
export {};
|
|
22
72
|
//# sourceMappingURL=carousel.d.ts.map
|
package/dist/carousel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,
|
|
1
|
+
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,eAAO,MAAM,oBAAoB,kDAAmD,CAAC;AACrF,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAWvE,QAAA,MAAM,gBAAgB,kFAAmF,CAAC;AAC1G,QAAA,MAAM,uBAAuB,uCAAwC,CAAC;AACtE,QAAA,MAAM,aAAa,0CAA2C,CAAC;AAC/D,QAAA,MAAM,YAAY,6BAA8B,CAAC;AACjD,QAAA,MAAM,iBAAiB,uCAAwC,CAAC;AAChE,QAAA,MAAM,oBAAoB,+BAAgC,CAAC;AAG3D,iEAAiE;AACjE,eAAO,MAAM,uBAAuB,2DAA2D,CAAC;AAEhG,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACjD,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC,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CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAsED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,yBAAyB,CAyD3B;AAED,oCAAoC;AACpC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAgBD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAyD5E;AAID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,yBAAyB,GAAG,uBAAuB,CAmD3F;AAED,uCAAuC;AACvC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAEzE"}
|
package/dist/carousel.js
CHANGED
|
@@ -1,27 +1,74 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
export const CAROUSEL_BREAKPOINTS = ["base", "sm", "md", "lg", "xl", "2xl"];
|
|
2
|
+
/** Splide breakpoints (min-width, px); the static CSS uses the same values in rem. */
|
|
3
|
+
const BREAKPOINT_WIDTHS = {
|
|
4
|
+
sm: 640,
|
|
5
|
+
md: 768,
|
|
6
|
+
lg: 1024,
|
|
7
|
+
xl: 1280,
|
|
8
|
+
"2xl": 1536
|
|
9
|
+
};
|
|
10
|
+
const ARROWS_POSITIONS = ["top", "top-end", "sides", "edges", "outside", "bottom", "bottom-end"];
|
|
11
|
+
const ARROWS_MOBILE_POSITIONS = ["same", "bottom", "hidden"];
|
|
12
|
+
const ARROWS_SHAPES = ["circle", "rounded", "square"];
|
|
13
|
+
const ARROWS_SIZES = ["sm", "md", "lg"];
|
|
14
|
+
const PAGINATION_STYLES = ["dots", "bars", "fraction"];
|
|
15
|
+
const PAGINATION_POSITIONS = ["below", "overlay"];
|
|
16
|
+
const ASPECT_RATIOS = ["1/1", "4/5", "3/4", "2/3", "4/3", "3/2", "16/9", "21/9"];
|
|
17
|
+
/** Peek keyword aligned with the StyleFlow container padding. */
|
|
18
|
+
export const CAROUSEL_CONTAINER_PEEK = "var(--sf-layout-container-comfortable-padding-x, 2rem)";
|
|
19
|
+
function boundedNumber(value, fallback, min, max, decimals = 0) {
|
|
3
20
|
if (value === "" || value === null || value === undefined || value === "inherit") {
|
|
4
21
|
return fallback;
|
|
5
22
|
}
|
|
6
23
|
const numeric = Number(value);
|
|
24
|
+
const factor = 10 ** decimals;
|
|
7
25
|
return Number.isFinite(numeric)
|
|
8
|
-
? Math.min(max, Math.max(min, Math.round(numeric)))
|
|
26
|
+
? Math.min(max, Math.max(min, Math.round(numeric * factor) / factor))
|
|
9
27
|
: fallback;
|
|
10
28
|
}
|
|
11
29
|
function booleanValue(value, fallback) {
|
|
12
30
|
return typeof value === "boolean" ? value : fallback;
|
|
13
31
|
}
|
|
32
|
+
function choice(value, choices, fallback) {
|
|
33
|
+
return choices.includes(value) ? value : fallback;
|
|
34
|
+
}
|
|
35
|
+
function token(value) {
|
|
36
|
+
return typeof value === "string" && /^[a-z0-9-]+$/.test(value) && value !== "inherit" ? value : "";
|
|
37
|
+
}
|
|
38
|
+
const suffix = (breakpoint) => breakpoint === "base"
|
|
39
|
+
? "Base"
|
|
40
|
+
: breakpoint === "2xl"
|
|
41
|
+
? "2xl"
|
|
42
|
+
: breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);
|
|
43
|
+
const isLength = (value) => typeof value === "string" && /^(?:0|\d+(?:\.\d+)?(?:rem|px|%|vw))$/.test(value);
|
|
44
|
+
/**
|
|
45
|
+
* Resolves a responsive string field: an empty value inherits from the smaller breakpoint and an
|
|
46
|
+
* invalid one does too. `reset` (if given) is the value that clears an inherited setting.
|
|
47
|
+
*/
|
|
48
|
+
function responsiveStrings(attributes, name, base, accept, reset) {
|
|
49
|
+
const values = {};
|
|
50
|
+
let inherited = base;
|
|
51
|
+
for (const breakpoint of CAROUSEL_BREAKPOINTS) {
|
|
52
|
+
const raw = attributes[`${name}${suffix(breakpoint)}`];
|
|
53
|
+
const value = reset !== undefined && raw === reset
|
|
54
|
+
? ""
|
|
55
|
+
: accept(raw)
|
|
56
|
+
? raw
|
|
57
|
+
: breakpoint === "base"
|
|
58
|
+
? base
|
|
59
|
+
: inherited;
|
|
60
|
+
values[breakpoint] = value;
|
|
61
|
+
inherited = value;
|
|
62
|
+
}
|
|
63
|
+
return values;
|
|
64
|
+
}
|
|
65
|
+
const isPeek = (value) => value === "container" || isLength(value);
|
|
14
66
|
export function carouselSettings(attributes) {
|
|
15
67
|
const defaults = { base: 1, sm: 1, md: 2, lg: 3, xl: 3, "2xl": 3 };
|
|
16
68
|
const values = {};
|
|
17
69
|
let inherited = defaults.base;
|
|
18
|
-
for (const breakpoint of
|
|
19
|
-
const
|
|
20
|
-
? "Base"
|
|
21
|
-
: breakpoint === "2xl"
|
|
22
|
-
? "2xl"
|
|
23
|
-
: breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);
|
|
24
|
-
const raw = attributes[`itemsPerView${suffix}`];
|
|
70
|
+
for (const breakpoint of CAROUSEL_BREAKPOINTS) {
|
|
71
|
+
const raw = attributes[`itemsPerView${suffix(breakpoint)}`];
|
|
25
72
|
const fallback = breakpoint !== "base" && (raw === "" || raw === "inherit")
|
|
26
73
|
? inherited
|
|
27
74
|
: breakpoint === "base"
|
|
@@ -29,41 +76,95 @@ export function carouselSettings(attributes) {
|
|
|
29
76
|
: breakpoint === "md" || breakpoint === "lg"
|
|
30
77
|
? defaults[breakpoint]
|
|
31
78
|
: inherited;
|
|
32
|
-
const value = boundedNumber(raw, fallback, 1, 12);
|
|
79
|
+
const value = boundedNumber(raw, fallback, 1, 12, 2);
|
|
33
80
|
values[breakpoint] = value;
|
|
34
81
|
inherited = value;
|
|
35
82
|
}
|
|
36
83
|
const ariaLabel = typeof attributes.ariaLabel === "string"
|
|
37
84
|
? attributes.ariaLabel.trim()
|
|
38
85
|
: "";
|
|
86
|
+
const aspect = attributes.slideAspectRatio;
|
|
39
87
|
return {
|
|
40
88
|
ariaLabel: ariaLabel || "Carosello",
|
|
41
89
|
itemsPerView: values,
|
|
90
|
+
slideWidth: responsiveStrings(attributes, "slideWidth", "", isLength, "auto"),
|
|
91
|
+
peek: responsiveStrings(attributes, "peek", "0", isPeek),
|
|
92
|
+
focus: choice(attributes.focus, ["start", "center"], "start"),
|
|
42
93
|
itemsPerMove: boundedNumber(attributes.itemsPerMove, 1, 1, 12),
|
|
43
94
|
gap: boundedNumber(attributes.gap, 24, 0, 128),
|
|
44
|
-
|
|
45
|
-
|
|
95
|
+
slideAspectRatio: ASPECT_RATIOS.includes(aspect) ? String(aspect) : "",
|
|
96
|
+
equalHeight: booleanValue(attributes.equalHeight, false),
|
|
97
|
+
effect: choice(attributes.effect, ["slide", "fade"], "slide"),
|
|
98
|
+
loop: booleanValue(attributes.loop, false),
|
|
99
|
+
rewind: booleanValue(attributes.rewind, false),
|
|
100
|
+
startIndex: boundedNumber(attributes.startIndex, 0, 0, 99),
|
|
101
|
+
speed: boundedNumber(attributes.speed, 400, 0, 5000),
|
|
46
102
|
drag: booleanValue(attributes.drag, true),
|
|
103
|
+
dragFree: booleanValue(attributes.dragFree, false),
|
|
47
104
|
keyboard: booleanValue(attributes.keyboard, true),
|
|
105
|
+
wheel: booleanValue(attributes.wheel, false),
|
|
106
|
+
showArrows: booleanValue(attributes.showArrows, true),
|
|
107
|
+
arrowsPosition: choice(attributes.arrowsPosition, ARROWS_POSITIONS, "top"),
|
|
108
|
+
arrowsPositionMobile: choice(attributes.arrowsPositionMobile, ARROWS_MOBILE_POSITIONS, "same"),
|
|
109
|
+
arrowsShape: choice(attributes.arrowsShape, ARROWS_SHAPES, "circle"),
|
|
110
|
+
arrowsSize: choice(attributes.arrowsSize, ARROWS_SIZES, "md"),
|
|
111
|
+
showPagination: booleanValue(attributes.showPagination, true),
|
|
112
|
+
paginationStyle: choice(attributes.paginationStyle, PAGINATION_STYLES, "dots"),
|
|
113
|
+
paginationPosition: choice(attributes.paginationPosition, PAGINATION_POSITIONS, "below"),
|
|
114
|
+
controlsTone: token(attributes.controlsTone),
|
|
115
|
+
controlsIntensity: token(attributes.controlsIntensity),
|
|
48
116
|
autoplay: booleanValue(attributes.autoplay, false),
|
|
49
117
|
autoplayInterval: boundedNumber(attributes.autoplayInterval, 5000, 1000, 60000),
|
|
50
118
|
pauseOnHover: booleanValue(attributes.pauseOnHover, true),
|
|
51
|
-
pauseOnFocus: booleanValue(attributes.pauseOnFocus, true)
|
|
52
|
-
loop: booleanValue(attributes.loop, false),
|
|
53
|
-
speed: boundedNumber(attributes.speed, 400, 0, 5000)
|
|
119
|
+
pauseOnFocus: booleanValue(attributes.pauseOnFocus, true)
|
|
54
120
|
};
|
|
55
121
|
}
|
|
122
|
+
/** CSS length of a peek setting. */
|
|
123
|
+
export function carouselPeekLength(peek) {
|
|
124
|
+
return peek === "container" ? CAROUSEL_CONTAINER_PEEK : peek;
|
|
125
|
+
}
|
|
126
|
+
function perPage(settings, breakpoint) {
|
|
127
|
+
return settings.effect === "fade" ? 1 : settings.itemsPerView[breakpoint];
|
|
128
|
+
}
|
|
129
|
+
function fixedWidth(settings, breakpoint) {
|
|
130
|
+
return settings.effect === "fade" ? "" : settings.slideWidth[breakpoint];
|
|
131
|
+
}
|
|
132
|
+
function padding(settings, breakpoint) {
|
|
133
|
+
const peek = settings.effect === "fade" ? "0" : carouselPeekLength(settings.peek[breakpoint]);
|
|
134
|
+
if (peek === "0")
|
|
135
|
+
return { left: 0, right: 0 };
|
|
136
|
+
return settings.focus === "center" ? { left: peek, right: peek } : { left: 0, right: peek };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Splide options. Options for settings that keep their previous defaults are left out, so a
|
|
140
|
+
* carousel saved with the original contract mounts with exactly the options it had before.
|
|
141
|
+
*/
|
|
56
142
|
export function carouselOptions(settings) {
|
|
143
|
+
const fade = settings.effect === "fade";
|
|
144
|
+
const usesWidth = CAROUSEL_BREAKPOINTS.some((breakpoint) => fixedWidth(settings, breakpoint) !== "");
|
|
145
|
+
const usesPadding = CAROUSEL_BREAKPOINTS.some((breakpoint) => padding(settings, breakpoint).right !== 0);
|
|
146
|
+
const sizing = (breakpoint) => ({
|
|
147
|
+
perPage: perPage(settings, breakpoint),
|
|
148
|
+
...(usesWidth ? { fixedWidth: fixedWidth(settings, breakpoint) || 0 } : {}),
|
|
149
|
+
...(usesPadding ? { padding: padding(settings, breakpoint) } : {})
|
|
150
|
+
});
|
|
151
|
+
const breakpoints = Object.fromEntries(Object.entries(BREAKPOINT_WIDTHS)
|
|
152
|
+
.map(([breakpoint, width]) => [width, sizing(breakpoint)]));
|
|
57
153
|
return {
|
|
58
154
|
label: settings.ariaLabel,
|
|
59
|
-
type: settings.loop ? "loop" : "slide",
|
|
60
|
-
|
|
155
|
+
type: fade ? "fade" : settings.loop ? "loop" : "slide",
|
|
156
|
+
...sizing("base"),
|
|
61
157
|
perMove: settings.itemsPerMove,
|
|
62
158
|
gap: `${settings.gap}px`,
|
|
159
|
+
...(settings.focus === "center" && !fade ? { focus: "center", trimSpace: false } : {}),
|
|
160
|
+
...(settings.rewind || (fade && settings.loop) ? { rewind: true } : {}),
|
|
161
|
+
...(settings.startIndex > 0 ? { start: settings.startIndex } : {}),
|
|
63
162
|
arrows: settings.showArrows,
|
|
64
|
-
pagination: settings.showPagination,
|
|
65
|
-
drag: settings.drag,
|
|
163
|
+
pagination: settings.showPagination && settings.paginationStyle !== "fraction",
|
|
164
|
+
drag: settings.drag && settings.dragFree ? "free" : settings.drag,
|
|
165
|
+
...(settings.drag && settings.dragFree ? { snap: true } : {}),
|
|
66
166
|
keyboard: settings.keyboard ? "focused" : false,
|
|
167
|
+
...(settings.wheel ? { wheel: true } : {}),
|
|
67
168
|
autoplay: settings.autoplay,
|
|
68
169
|
interval: settings.autoplayInterval,
|
|
69
170
|
pauseOnHover: settings.pauseOnHover,
|
|
@@ -71,13 +172,7 @@ export function carouselOptions(settings) {
|
|
|
71
172
|
speed: settings.speed,
|
|
72
173
|
live: true,
|
|
73
174
|
mediaQuery: "min",
|
|
74
|
-
breakpoints
|
|
75
|
-
640: { perPage: settings.itemsPerView.sm },
|
|
76
|
-
768: { perPage: settings.itemsPerView.md },
|
|
77
|
-
1024: { perPage: settings.itemsPerView.lg },
|
|
78
|
-
1280: { perPage: settings.itemsPerView.xl },
|
|
79
|
-
1536: { perPage: settings.itemsPerView["2xl"] }
|
|
80
|
-
},
|
|
175
|
+
breakpoints,
|
|
81
176
|
reducedMotion: {
|
|
82
177
|
speed: 0,
|
|
83
178
|
rewindSpeed: 0,
|
|
@@ -99,4 +194,65 @@ export function carouselOptions(settings) {
|
|
|
99
194
|
}
|
|
100
195
|
};
|
|
101
196
|
}
|
|
197
|
+
const GAP = "var(--flowpress-carousel-gap)";
|
|
198
|
+
/**
|
|
199
|
+
* Static geometry shared by the frontend before Splide mounts and by the block editor: the same
|
|
200
|
+
* slide widths, peeks and centring Splide applies at rest. Percentages in `slide` and `shift`
|
|
201
|
+
* resolve against the list, those in `edge` against the carousel root.
|
|
202
|
+
*/
|
|
203
|
+
export function carouselLayout(settings) {
|
|
204
|
+
const style = {
|
|
205
|
+
"--flowpress-carousel-gap": `${settings.gap}px`
|
|
206
|
+
};
|
|
207
|
+
for (const breakpoint of CAROUSEL_BREAKPOINTS) {
|
|
208
|
+
const count = perPage(settings, breakpoint);
|
|
209
|
+
const width = fixedWidth(settings, breakpoint);
|
|
210
|
+
const { left, right } = padding(settings, breakpoint);
|
|
211
|
+
const start = left === 0 ? "0px" : String(left);
|
|
212
|
+
const end = right === 0 ? "0px" : String(right);
|
|
213
|
+
const slide = width || `calc((100% + ${GAP}) / ${count} - ${GAP})`;
|
|
214
|
+
const centre = settings.focus === "center" && settings.effect !== "fade";
|
|
215
|
+
const offset = settings.startIndex > 0
|
|
216
|
+
? ` - ${settings.startIndex} * (${slide} + ${GAP})`
|
|
217
|
+
: "";
|
|
218
|
+
// Width of the list once the root's peeks are removed, as a root percentage.
|
|
219
|
+
const list = `(100% - ${start} - ${end})`;
|
|
220
|
+
const rootSlide = width || `((${list} + ${GAP}) / ${count} - ${GAP})`;
|
|
221
|
+
style[`--flowpress-carousel-${breakpoint}`] = String(count);
|
|
222
|
+
style[`--flowpress-carousel-slide-${breakpoint}`] = slide;
|
|
223
|
+
style[`--flowpress-carousel-peek-start-${breakpoint}`] = start;
|
|
224
|
+
style[`--flowpress-carousel-peek-end-${breakpoint}`] = end;
|
|
225
|
+
style[`--flowpress-carousel-shift-${breakpoint}`] = centre || offset
|
|
226
|
+
? `calc(${centre ? `(100% - ${slide}) / 2` : "0px"}${offset})`
|
|
227
|
+
: "0px";
|
|
228
|
+
style[`--flowpress-carousel-edge-${breakpoint}`] = centre
|
|
229
|
+
? `calc(${start} + (${list} - ${rootSlide}) / 2 - ${GAP})`
|
|
230
|
+
: `calc(${end} - ${GAP})`;
|
|
231
|
+
}
|
|
232
|
+
if (settings.slideAspectRatio)
|
|
233
|
+
style["--flowpress-carousel-aspect"] = settings.slideAspectRatio;
|
|
234
|
+
if (settings.controlsTone) {
|
|
235
|
+
style["--flowpress-carousel-control-bg"] =
|
|
236
|
+
`var(--sf-color-${settings.controlsTone}-${settings.controlsIntensity || "base"}-default-background)`;
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
style,
|
|
240
|
+
data: {
|
|
241
|
+
"data-focus": settings.effect === "fade" ? "start" : settings.focus,
|
|
242
|
+
"data-effect": settings.effect,
|
|
243
|
+
"data-arrows": settings.arrowsPosition,
|
|
244
|
+
"data-arrows-mobile": settings.arrowsPositionMobile,
|
|
245
|
+
"data-arrows-shape": settings.arrowsShape,
|
|
246
|
+
"data-arrows-size": settings.arrowsSize,
|
|
247
|
+
"data-pagination": settings.paginationStyle,
|
|
248
|
+
"data-pagination-position": settings.paginationPosition,
|
|
249
|
+
...(settings.slideAspectRatio ? { "data-aspect": "" } : {}),
|
|
250
|
+
...(settings.equalHeight ? { "data-equal-height": "" } : {})
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/** Inline `style` text of a layout. */
|
|
255
|
+
export function carouselStyleText(layout) {
|
|
256
|
+
return Object.entries(layout.style).map(([name, value]) => `${name}:${value}`).join(";");
|
|
257
|
+
}
|
|
102
258
|
//# sourceMappingURL=carousel.js.map
|
package/dist/carousel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AAmBrE,SAAS,aAAa,CACpB,KAAc,EACd,QAAgB,EAChB,GAAW,EACX,GAAW;IAEX,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC7B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,QAAiB;IACrD,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,U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YAC3B,KAAK,EAAE,oBAAoB;YAC3B,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,gBAAgB;YACvB,QAAQ,EAAE,WAAW;YACrB,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,iCAAiC;YACzC,UAAU,EAAE,UAAU;SACvB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Options } from \"@splidejs/splide\";\n\nconst BREAKPOINTS = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n\nexport interface FlowpressCarouselSettings {\n ariaLabel: string;\n itemsPerView: Record<(typeof BREAKPOINTS)[number], number>;\n itemsPerMove: number;\n gap: number;\n showArrows: boolean;\n showPagination: boolean;\n drag: boolean;\n keyboard: boolean;\n autoplay: boolean;\n autoplayInterval: number;\n pauseOnHover: boolean;\n pauseOnFocus: boolean;\n loop: boolean;\n speed: number;\n}\n\nfunction boundedNumber(\n value: unknown,\n fallback: number,\n min: number,\n max: number\n): number {\n if (value === \"\" || value === null || value === undefined || value === \"inherit\") {\n return fallback;\n }\n const numeric = Number(value);\n return Number.isFinite(numeric)\n ? Math.min(max, Math.max(min, Math.round(numeric)))\n : fallback;\n}\n\nfunction booleanValue(value: unknown, fallback: boolean): boolean {\n return typeof value === \"boolean\" ? value : fallback;\n}\n\nexport function carouselSettings(\n attributes: Record<string, unknown>\n): FlowpressCarouselSettings {\n const defaults = { base: 1, sm: 1, md: 2, lg: 3, xl: 3, \"2xl\": 3 };\n const values = {} as FlowpressCarouselSettings[\"itemsPerView\"];\n let inherited = defaults.base;\n for (const breakpoint of BREAKPOINTS) {\n const suffix = breakpoint === \"base\"\n ? \"Base\"\n : breakpoint === \"2xl\"\n ? \"2xl\"\n : breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);\n const raw = attributes[`itemsPerView${suffix}`];\n const fallback = breakpoint !== \"base\" && (raw === \"\" || raw === \"inherit\")\n ? inherited\n : breakpoint === \"base\"\n ? defaults.base\n : breakpoint === \"md\" || breakpoint === \"lg\"\n ? defaults[breakpoint]\n : inherited;\n const value = boundedNumber(\n raw,\n fallback,\n 1,\n 12\n );\n values[breakpoint] = value;\n inherited = value;\n }\n\n const ariaLabel = typeof attributes.ariaLabel === \"string\"\n ? attributes.ariaLabel.trim()\n : \"\";\n\n return {\n ariaLabel: ariaLabel || \"Carosello\",\n itemsPerView: values,\n itemsPerMove: boundedNumber(attributes.itemsPerMove, 1, 1, 12),\n gap: boundedNumber(attributes.gap, 24, 0, 128),\n showArrows: booleanValue(attributes.showArrows, true),\n showPagination: booleanValue(attributes.showPagination, true),\n drag: booleanValue(attributes.drag, true),\n keyboard: booleanValue(attributes.keyboard, true),\n autoplay: booleanValue(attributes.autoplay, false),\n autoplayInterval: boundedNumber(attributes.autoplayInterval, 5000, 1000, 60000),\n pauseOnHover: booleanValue(attributes.pauseOnHover, true),\n pauseOnFocus: booleanValue(attributes.pauseOnFocus, true),\n loop: booleanValue(attributes.loop, false),\n speed: boundedNumber(attributes.speed, 400, 0, 5000)\n };\n}\n\nexport function carouselOptions(settings: FlowpressCarouselSettings): Options {\n return {\n label: settings.ariaLabel,\n type: settings.loop ? \"loop\" : \"slide\",\n perPage: settings.itemsPerView.base,\n perMove: settings.itemsPerMove,\n gap: `${settings.gap}px`,\n arrows: settings.showArrows,\n pagination: settings.showPagination,\n drag: settings.drag,\n keyboard: settings.keyboard ? \"focused\" : false,\n autoplay: settings.autoplay,\n interval: settings.autoplayInterval,\n pauseOnHover: settings.pauseOnHover,\n pauseOnFocus: settings.pauseOnFocus,\n speed: settings.speed,\n live: true,\n mediaQuery: \"min\",\n breakpoints: {\n 640: { perPage: settings.itemsPerView.sm },\n 768: { perPage: settings.itemsPerView.md },\n 1024: { perPage: settings.itemsPerView.lg },\n 1280: { perPage: settings.itemsPerView.xl },\n 1536: { perPage: settings.itemsPerView[\"2xl\"] }\n },\n reducedMotion: {\n speed: 0,\n rewindSpeed: 0,\n autoplay: \"pause\"\n },\n i18n: {\n prev: \"Slide precedente\",\n next: \"Slide successiva\",\n first: \"Vai alla prima slide\",\n last: \"Vai all'ultima slide\",\n slideX: \"Vai alla slide %s\",\n pageX: \"Vai alla pagina %s\",\n play: \"Avvia autoplay\",\n pause: \"Pausa autoplay\",\n carousel: \"carosello\",\n slide: \"slide\",\n select: \"Seleziona una slide da mostrare\",\n slideLabel: \"%s di %s\"\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"carousel.js","sourceRoot":"","sources":["../src/carousel.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAU,CAAC;AAGrF,sFAAsF;AACtF,MAAM,iBAAiB,GAAwD;IAC7E,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AAC1G,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AACtE,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAC;AAC/D,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AACjD,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAU,CAAC;AAChE,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,SAAS,CAAU,CAAC;AAC3D,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAE1F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I,QAAQ,CAAC,iBAAiB,IAAI,MAAM,sBAAsB,CAAC;IAC1G,CAAC;IAED,OAAO;QACL,KAAK;QACL,IAAI,EAAE;YACJ,YAAY,EAAE,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK;YACnE,aAAa,EAAE,QAAQ,CAAC,MAAM;YAC9B,aAAa,EAAE,QAAQ,CAAC,cAAc;YACtC,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB;YACnD,mBAAmB,EAAE,QAAQ,CAAC,WAAW;YACzC,kBAAkB,EAAE,QAAQ,CAAC,UAAU;YACvC,iBAAiB,EAAE,QAAQ,CAAC,eAAe;YAC3C,0BAA0B,EAAE,QAAQ,CAAC,kBAAkB;YACvD,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7D;KACF,CAAC;AACJ,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,iBAAiB,CAAC,MAA+B;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import type { Options } from \"@splidejs/splide\";\n\nexport const CAROUSEL_BREAKPOINTS = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\nexport type CarouselBreakpoint = (typeof CAROUSEL_BREAKPOINTS)[number];\n\n/** Splide breakpoints (min-width, px); the static CSS uses the same values in rem. */\nconst BREAKPOINT_WIDTHS: Record<Exclude<CarouselBreakpoint, \"base\">, number> = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536\n};\n\nconst ARROWS_POSITIONS = [\"top\", \"top-end\", \"sides\", \"edges\", \"outside\", \"bottom\", \"bottom-end\"] as const;\nconst ARROWS_MOBILE_POSITIONS = [\"same\", \"bottom\", \"hidden\"] as const;\nconst ARROWS_SHAPES = [\"circle\", \"rounded\", \"square\"] as const;\nconst ARROWS_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nconst PAGINATION_STYLES = [\"dots\", \"bars\", \"fraction\"] as const;\nconst PAGINATION_POSITIONS = [\"below\", \"overlay\"] as const;\nconst ASPECT_RATIOS = [\"1/1\", \"4/5\", \"3/4\", \"2/3\", \"4/3\", \"3/2\", \"16/9\", \"21/9\"] as const;\n\n/** Peek keyword aligned with the StyleFlow container padding. */\nexport const CAROUSEL_CONTAINER_PEEK = \"var(--sf-layout-container-comfortable-padding-x, 2rem)\";\n\nexport interface FlowpressCarouselSettings {\n ariaLabel: string;\n itemsPerView: Record<CarouselBreakpoint, number>;\n /** Fixed slide width per breakpoint; \"\" sizes slides from `itemsPerView`. */\n slideWidth: Record<CarouselBreakpoint, string>;\n /** Visible part of the neighbouring slides per breakpoint, as a CSS length (\"0\" for none). */\n peek: Record<CarouselBreakpoint, string>;\n focus: \"start\" | \"center\";\n itemsPerMove: number;\n gap: number;\n slideAspectRatio: string;\n equalHeight: boolean;\n effect: \"slide\" | \"fade\";\n loop: boolean;\n rewind: boolean;\n startIndex: number;\n speed: number;\n drag: boolean;\n dragFree: boolean;\n keyboard: boolean;\n wheel: boolean;\n showArrows: boolean;\n arrowsPosition: (typeof ARROWS_POSITIONS)[number];\n arrowsPositionMobile: (typeof ARROWS_MOBILE_POSITIONS)[number];\n arrowsShape: (typeof ARROWS_SHAPES)[number];\n arrowsSize: (typeof ARROWS_SIZES)[number];\n showPagination: boolean;\n paginationStyle: (typeof PAGINATION_STYLES)[number];\n paginationPosition: (typeof PAGINATION_POSITIONS)[number];\n /** StyleFlow tone and intensity of the controls' background; \"\" keeps the carousel's context. */\n controlsTone: string;\n controlsIntensity: string;\n autoplay: boolean;\n autoplayInterval: number;\n pauseOnHover: boolean;\n pauseOnFocus: boolean;\n}\n\nexport interface FlowpressCarouselLayout {\n /** Custom properties for the carousel root, read by the shared carousel stylesheet. */\n style: Record<string, string>;\n /** `data-*` attributes for the carousel root. */\n data: Record<string, string>;\n}\n\nfunction boundedNumber(\n value: unknown,\n fallback: number,\n min: number,\n max: number,\n decimals = 0\n): number {\n if (value === \"\" || value === null || value === undefined || value === \"inherit\") {\n return fallback;\n }\n const numeric = Number(value);\n const factor = 10 ** decimals;\n return Number.isFinite(numeric)\n ? Math.min(max, Math.max(min, Math.round(numeric * factor) / factor))\n : fallback;\n}\n\nfunction booleanValue(value: unknown, fallback: boolean): boolean {\n return typeof value === \"boolean\" ? value : fallback;\n}\n\nfunction choice<T extends string>(value: unknown, choices: readonly T[], fallback: T): T {\n return choices.includes(value as T) ? (value as T) : fallback;\n}\n\nfunction token(value: unknown): string {\n return typeof value === \"string\" && /^[a-z0-9-]+$/.test(value) && value !== \"inherit\" ? value : \"\";\n}\n\nconst suffix = (breakpoint: CarouselBreakpoint) => breakpoint === \"base\"\n ? \"Base\"\n : breakpoint === \"2xl\"\n ? \"2xl\"\n : breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1);\n\nconst isLength = (value: unknown): value is string =>\n typeof value === \"string\" && /^(?:0|\\d+(?:\\.\\d+)?(?:rem|px|%|vw))$/.test(value);\n\n/**\n * Resolves a responsive string field: an empty value inherits from the smaller breakpoint and an\n * invalid one does too. `reset` (if given) is the value that clears an inherited setting.\n */\nfunction responsiveStrings(\n attributes: Record<string, unknown>,\n name: string,\n base: string,\n accept: (value: unknown) => value is string,\n reset?: string\n): Record<CarouselBreakpoint, string> {\n const values = {} as Record<CarouselBreakpoint, string>;\n let inherited = base;\n for (const breakpoint of CAROUSEL_BREAKPOINTS) {\n const raw = attributes[`${name}${suffix(breakpoint)}`];\n const value = reset !== undefined && raw === reset\n ? \"\"\n : accept(raw)\n ? raw\n : breakpoint === \"base\"\n ? base\n : inherited;\n values[breakpoint] = value;\n inherited = value;\n }\n return values;\n}\n\nconst isPeek = (value: unknown): value is string => value === \"container\" || isLength(value);\n\nexport function carouselSettings(\n attributes: Record<string, unknown>\n): FlowpressCarouselSettings {\n const defaults = { base: 1, sm: 1, md: 2, lg: 3, xl: 3, \"2xl\": 3 };\n const values = {} as FlowpressCarouselSettings[\"itemsPerView\"];\n let inherited = defaults.base;\n for (const breakpoint of CAROUSEL_BREAKPOINTS) {\n const raw = attributes[`itemsPerView${suffix(breakpoint)}`];\n const fallback = breakpoint !== \"base\" && (raw === \"\" || raw === \"inherit\")\n ? inherited\n : breakpoint === \"base\"\n ? defaults.base\n : breakpoint === \"md\" || breakpoint === \"lg\"\n ? defaults[breakpoint]\n : inherited;\n const value = boundedNumber(raw, fallback, 1, 12, 2);\n values[breakpoint] = value;\n inherited = value;\n }\n\n const ariaLabel = typeof attributes.ariaLabel === \"string\"\n ? attributes.ariaLabel.trim()\n : \"\";\n const aspect = attributes.slideAspectRatio;\n\n return {\n ariaLabel: ariaLabel || \"Carosello\",\n itemsPerView: values,\n slideWidth: responsiveStrings(attributes, \"slideWidth\", \"\", isLength, \"auto\"),\n peek: responsiveStrings(attributes, \"peek\", \"0\", isPeek),\n focus: choice(attributes.focus, [\"start\", \"center\"] as const, \"start\"),\n itemsPerMove: boundedNumber(attributes.itemsPerMove, 1, 1, 12),\n gap: boundedNumber(attributes.gap, 24, 0, 128),\n slideAspectRatio: ASPECT_RATIOS.includes(aspect as never) ? String(aspect) : \"\",\n equalHeight: booleanValue(attributes.equalHeight, false),\n effect: choice(attributes.effect, [\"slide\", \"fade\"] as const, \"slide\"),\n loop: booleanValue(attributes.loop, false),\n rewind: booleanValue(attributes.rewind, false),\n startIndex: boundedNumber(attributes.startIndex, 0, 0, 99),\n speed: boundedNumber(attributes.speed, 400, 0, 5000),\n drag: booleanValue(attributes.drag, true),\n dragFree: booleanValue(attributes.dragFree, false),\n keyboard: booleanValue(attributes.keyboard, true),\n wheel: booleanValue(attributes.wheel, false),\n showArrows: booleanValue(attributes.showArrows, true),\n arrowsPosition: choice(attributes.arrowsPosition, ARROWS_POSITIONS, \"top\"),\n arrowsPositionMobile: choice(attributes.arrowsPositionMobile, ARROWS_MOBILE_POSITIONS, \"same\"),\n arrowsShape: choice(attributes.arrowsShape, ARROWS_SHAPES, \"circle\"),\n arrowsSize: choice(attributes.arrowsSize, ARROWS_SIZES, \"md\"),\n showPagination: booleanValue(attributes.showPagination, true),\n paginationStyle: choice(attributes.paginationStyle, PAGINATION_STYLES, \"dots\"),\n paginationPosition: choice(attributes.paginationPosition, PAGINATION_POSITIONS, \"below\"),\n controlsTone: token(attributes.controlsTone),\n controlsIntensity: token(attributes.controlsIntensity),\n autoplay: booleanValue(attributes.autoplay, false),\n autoplayInterval: boundedNumber(attributes.autoplayInterval, 5000, 1000, 60000),\n pauseOnHover: booleanValue(attributes.pauseOnHover, true),\n pauseOnFocus: booleanValue(attributes.pauseOnFocus, true)\n };\n}\n\n/** CSS length of a peek setting. */\nexport function carouselPeekLength(peek: string): string {\n return peek === \"container\" ? CAROUSEL_CONTAINER_PEEK : peek;\n}\n\nfunction perPage(settings: FlowpressCarouselSettings, breakpoint: CarouselBreakpoint): number {\n return settings.effect === \"fade\" ? 1 : settings.itemsPerView[breakpoint];\n}\n\nfunction fixedWidth(settings: FlowpressCarouselSettings, breakpoint: CarouselBreakpoint): string {\n return settings.effect === \"fade\" ? \"\" : settings.slideWidth[breakpoint];\n}\n\nfunction padding(settings: FlowpressCarouselSettings, breakpoint: CarouselBreakpoint) {\n const peek = settings.effect === \"fade\" ? \"0\" : carouselPeekLength(settings.peek[breakpoint]);\n if (peek === \"0\") return { left: 0, right: 0 };\n return settings.focus === \"center\" ? { left: peek, right: peek } : { left: 0, right: peek };\n}\n\n/**\n * Splide options. Options for settings that keep their previous defaults are left out, so a\n * carousel saved with the original contract mounts with exactly the options it had before.\n */\nexport function carouselOptions(settings: FlowpressCarouselSettings): Options {\n const fade = settings.effect === \"fade\";\n const usesWidth = CAROUSEL_BREAKPOINTS.some((breakpoint) => fixedWidth(settings, breakpoint) !== \"\");\n const usesPadding = CAROUSEL_BREAKPOINTS.some((breakpoint) => padding(settings, breakpoint).right !== 0);\n const sizing = (breakpoint: CarouselBreakpoint) => ({\n perPage: perPage(settings, breakpoint),\n ...(usesWidth ? { fixedWidth: fixedWidth(settings, breakpoint) || 0 } : {}),\n ...(usesPadding ? { padding: padding(settings, breakpoint) } : {})\n });\n const breakpoints = Object.fromEntries(\n (Object.entries(BREAKPOINT_WIDTHS) as Array<[Exclude<CarouselBreakpoint, \"base\">, number]>)\n .map(([breakpoint, width]) => [width, sizing(breakpoint)])\n );\n\n return {\n label: settings.ariaLabel,\n type: fade ? \"fade\" : settings.loop ? \"loop\" : \"slide\",\n ...sizing(\"base\"),\n perMove: settings.itemsPerMove,\n gap: `${settings.gap}px`,\n ...(settings.focus === \"center\" && !fade ? { focus: \"center\" as const, trimSpace: false } : {}),\n ...(settings.rewind || (fade && settings.loop) ? { rewind: true } : {}),\n ...(settings.startIndex > 0 ? { start: settings.startIndex } : {}),\n arrows: settings.showArrows,\n pagination: settings.showPagination && settings.paginationStyle !== \"fraction\",\n drag: settings.drag && settings.dragFree ? \"free\" : settings.drag,\n ...(settings.drag && settings.dragFree ? { snap: true } : {}),\n keyboard: settings.keyboard ? \"focused\" : false,\n ...(settings.wheel ? { wheel: true } : {}),\n autoplay: settings.autoplay,\n interval: settings.autoplayInterval,\n pauseOnHover: settings.pauseOnHover,\n pauseOnFocus: settings.pauseOnFocus,\n speed: settings.speed,\n live: true,\n mediaQuery: \"min\",\n breakpoints,\n reducedMotion: {\n speed: 0,\n rewindSpeed: 0,\n autoplay: \"pause\"\n },\n i18n: {\n prev: \"Slide precedente\",\n next: \"Slide successiva\",\n first: \"Vai alla prima slide\",\n last: \"Vai all'ultima slide\",\n slideX: \"Vai alla slide %s\",\n pageX: \"Vai alla pagina %s\",\n play: \"Avvia autoplay\",\n pause: \"Pausa autoplay\",\n carousel: \"carosello\",\n slide: \"slide\",\n select: \"Seleziona una slide da mostrare\",\n slideLabel: \"%s di %s\"\n }\n };\n}\n\nconst GAP = \"var(--flowpress-carousel-gap)\";\n\n/**\n * Static geometry shared by the frontend before Splide mounts and by the block editor: the same\n * slide widths, peeks and centring Splide applies at rest. Percentages in `slide` and `shift`\n * resolve against the list, those in `edge` against the carousel root.\n */\nexport function carouselLayout(settings: FlowpressCarouselSettings): FlowpressCarouselLayout {\n const style: Record<string, string> = {\n \"--flowpress-carousel-gap\": `${settings.gap}px`\n };\n for (const breakpoint of CAROUSEL_BREAKPOINTS) {\n const count = perPage(settings, breakpoint);\n const width = fixedWidth(settings, breakpoint);\n const { left, right } = padding(settings, breakpoint);\n const start = left === 0 ? \"0px\" : String(left);\n const end = right === 0 ? \"0px\" : String(right);\n const slide = width || `calc((100% + ${GAP}) / ${count} - ${GAP})`;\n const centre = settings.focus === \"center\" && settings.effect !== \"fade\";\n const offset = settings.startIndex > 0\n ? ` - ${settings.startIndex} * (${slide} + ${GAP})`\n : \"\";\n // Width of the list once the root's peeks are removed, as a root percentage.\n const list = `(100% - ${start} - ${end})`;\n const rootSlide = width || `((${list} + ${GAP}) / ${count} - ${GAP})`;\n\n style[`--flowpress-carousel-${breakpoint}`] = String(count);\n style[`--flowpress-carousel-slide-${breakpoint}`] = slide;\n style[`--flowpress-carousel-peek-start-${breakpoint}`] = start;\n style[`--flowpress-carousel-peek-end-${breakpoint}`] = end;\n style[`--flowpress-carousel-shift-${breakpoint}`] = centre || offset\n ? `calc(${centre ? `(100% - ${slide}) / 2` : \"0px\"}${offset})`\n : \"0px\";\n style[`--flowpress-carousel-edge-${breakpoint}`] = centre\n ? `calc(${start} + (${list} - ${rootSlide}) / 2 - ${GAP})`\n : `calc(${end} - ${GAP})`;\n }\n if (settings.slideAspectRatio) style[\"--flowpress-carousel-aspect\"] = settings.slideAspectRatio;\n if (settings.controlsTone) {\n style[\"--flowpress-carousel-control-bg\"] =\n `var(--sf-color-${settings.controlsTone}-${settings.controlsIntensity || \"base\"}-default-background)`;\n }\n\n return {\n style,\n data: {\n \"data-focus\": settings.effect === \"fade\" ? \"start\" : settings.focus,\n \"data-effect\": settings.effect,\n \"data-arrows\": settings.arrowsPosition,\n \"data-arrows-mobile\": settings.arrowsPositionMobile,\n \"data-arrows-shape\": settings.arrowsShape,\n \"data-arrows-size\": settings.arrowsSize,\n \"data-pagination\": settings.paginationStyle,\n \"data-pagination-position\": settings.paginationPosition,\n ...(settings.slideAspectRatio ? { \"data-aspect\": \"\" } : {}),\n ...(settings.equalHeight ? { \"data-equal-height\": \"\" } : {})\n }\n };\n}\n\n/** Inline `style` text of a layout. */\nexport function carouselStyleText(layout: FlowpressCarouselLayout): string {\n return Object.entries(layout.style).map(([name, value]) => `${name}:${value}`).join(\";\");\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -11,9 +11,17 @@ export interface FlowpressGraphqlIssue {
|
|
|
11
11
|
export interface FlowpressRequestStore {
|
|
12
12
|
getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T>;
|
|
13
13
|
}
|
|
14
|
+
export declare const DEFAULT_GRAPHQL_TIMEOUT_MS = 15000;
|
|
15
|
+
export declare const DEFAULT_GRAPHQL_RETRIES = 1;
|
|
16
|
+
export declare const DEFAULT_GRAPHQL_RETRY_DELAY_MS = 1000;
|
|
14
17
|
export interface FlowpressClientOptions {
|
|
15
18
|
endpoint: string;
|
|
19
|
+
/** Per-attempt limit; every retry gets a fresh timer. */
|
|
16
20
|
timeoutMs?: number;
|
|
21
|
+
/** Extra attempts for queries after a timeout, network error or 429/502/503/504. */
|
|
22
|
+
retries?: number;
|
|
23
|
+
/** First backoff; it doubles on every further retry. */
|
|
24
|
+
retryDelayMs?: number;
|
|
17
25
|
headers?: Record<string, string>;
|
|
18
26
|
debug?: boolean;
|
|
19
27
|
requestStore?: FlowpressRequestStore;
|
|
@@ -28,6 +36,8 @@ export declare class FlowpressGraphqlError extends Error {
|
|
|
28
36
|
export declare class FlowpressClient {
|
|
29
37
|
readonly endpoint: string;
|
|
30
38
|
readonly timeoutMs: number;
|
|
39
|
+
readonly retries: number;
|
|
40
|
+
readonly retryDelayMs: number;
|
|
31
41
|
readonly headers: Record<string, string>;
|
|
32
42
|
readonly debug: boolean;
|
|
33
43
|
readonly requestStore: FlowpressRequestStore | undefined;
|
|
@@ -35,6 +45,7 @@ export declare class FlowpressClient {
|
|
|
35
45
|
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
36
46
|
getContentRevision(): Promise<string>;
|
|
37
47
|
private requestUncached;
|
|
48
|
+
private requestOnce;
|
|
38
49
|
getCapabilities(): Promise<FlowpressCapabilities>;
|
|
39
50
|
getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null>;
|
|
40
51
|
getRoutes(locale?: string): Promise<FlowpressRoute[]>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE;QACX,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAOD,6FAA6F;AAC7F,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,C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