kuinetic 0.2.4 → 0.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 +2 -2
- package/dist/esm/advanced/index.mjs +1 -1
- package/dist/esm/{chunk-EHS45PIK.mjs → chunk-4QKMEDM4.mjs} +4978 -832
- package/dist/esm/{chunk-FASAEQDR.mjs → chunk-7NW4OLOC.mjs} +506 -29
- package/dist/esm/{chunk-MZQG2VMG.mjs → chunk-DAVDOYOS.mjs} +92 -495
- package/dist/esm/{chunk-AEQGC2KM.mjs → chunk-EDFJTT5B.mjs} +2 -1
- package/dist/esm/core/index.mjs +3 -3
- package/dist/esm/effects/index.mjs +3 -3
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/notes/index.mjs +276 -5
- package/dist/kuinetic.advanced.js +2 -1
- package/dist/kuinetic.advanced.min.js +1 -1
- package/dist/kuinetic.all.js +5047 -856
- package/dist/kuinetic.all.min.js +2 -2
- package/dist/kuinetic.css +1106 -61
- package/dist/kuinetic.js +5046 -855
- package/dist/kuinetic.min.css +1 -1
- package/dist/kuinetic.min.js +1 -1
- package/dist/kuinetic.notes.js +1 -1
- package/dist/types/advanced/shaders.d.ts +1 -1
- package/dist/types/core/channels.d.ts +1 -1
- package/dist/types/core/easing.d.ts +9 -0
- package/dist/types/core/effect-context.d.ts +5 -0
- package/dist/types/core/element-config.d.ts +2 -0
- package/dist/types/core/flip.d.ts +25 -1
- package/dist/types/core/gesture.d.ts +5 -0
- package/dist/types/core/image-flight.d.ts +23 -0
- package/dist/types/core/js-effect-preparer.d.ts +3 -1
- package/dist/types/core/owned-styles.d.ts +2 -1
- package/dist/types/core/params.d.ts +1 -1
- package/dist/types/core/parse.d.ts +1 -0
- package/dist/types/core/registry.d.ts +1 -1
- package/dist/types/core/types.d.ts +11 -1
- package/dist/types/effects/auto-motion.d.ts +8 -0
- package/dist/types/effects/carousel/archive.d.ts +18 -0
- package/dist/types/effects/carousel/coast.d.ts +7 -0
- package/dist/types/effects/carousel/deck.d.ts +26 -2
- package/dist/types/effects/carousel/drag.d.ts +19 -7
- package/dist/types/effects/carousel/glide.d.ts +89 -0
- package/dist/types/effects/carousel/line.d.ts +10 -0
- package/dist/types/effects/carousel/row-copies.d.ts +10 -0
- package/dist/types/effects/carousel/row.d.ts +3 -0
- package/dist/types/effects/carousel/shape-fit.d.ts +46 -0
- package/dist/types/effects/carousel/sources.d.ts +26 -0
- package/dist/types/effects/carousel/sphere.d.ts +23 -0
- package/dist/types/effects/carousel/stack.d.ts +2 -1
- package/dist/types/effects/catalog/confetti.d.ts +2 -0
- package/dist/types/effects/catalog/cursor-trail.d.ts +2 -0
- package/dist/types/effects/catalog/curtains.d.ts +2 -0
- package/dist/types/effects/catalog/image-flight.d.ts +2 -0
- package/dist/types/effects/catalog/line-boil.d.ts +2 -0
- package/dist/types/effects/catalog/number-tokens.d.ts +5 -0
- package/dist/types/effects/catalog/numbers-shared.d.ts +3 -4
- package/dist/types/effects/catalog/text-shared.d.ts +13 -6
- package/dist/types/effects/catalog/typewriter-scatter.d.ts +5 -0
- package/dist/types/effects/catalog/view-transitions.d.ts +32 -1
- package/dist/types/effects/catalog/wobble.d.ts +2 -0
- package/dist/types/effects/gestures/drag-options.d.ts +17 -0
- package/dist/types/effects/layout/departures.d.ts +21 -0
- package/dist/types/effects/motion-path/fit.d.ts +4 -0
- package/dist/types/effects/scroll-mechanics/progress-output.d.ts +9 -0
- package/dist/types/effects/step-marking.d.ts +7 -4
- package/dist/types/effects/svg/morph-loop.d.ts +5 -0
- package/dist/types/effects/svg/text-path.d.ts +2 -0
- package/dist/types/effects/three-d/cube.d.ts +2 -0
- package/dist/types/effects/tween/index.d.ts +2 -1
- package/dist/types/effects/tween/properties.d.ts +1 -1
- package/dist/types/effects/tween/toggle.d.ts +6 -0
- package/dist/types/notes/effects.d.ts +1 -0
- package/dist/types/notes/index.d.ts +11 -0
- package/dist/types/notes/showcase.d.ts +1 -0
- package/dist/types/showcase/lightbox-flight.d.ts +11 -0
- package/dist/types/showcase/modal-shell.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createLedgerSet
|
|
3
|
+
} from "./chunk-EDFJTT5B.mjs";
|
|
4
|
+
|
|
1
5
|
// src/core/target.ts
|
|
2
6
|
function selectorBreadth(selector, doc) {
|
|
3
7
|
try {
|
|
@@ -548,16 +552,16 @@ function defaultObserverFactory() {
|
|
|
548
552
|
function onlyBoundLate(name, claims) {
|
|
549
553
|
const authorising = authorisingActivations(name);
|
|
550
554
|
if (!authorising.includes("enter")) return false;
|
|
551
|
-
const suits = (
|
|
552
|
-
if (!claims.some((
|
|
553
|
-
return claims.every((
|
|
555
|
+
const suits = (claim2) => authorising.some((named) => claim2.supported.includes(named));
|
|
556
|
+
if (!claims.some((claim2) => claim2.entrance && suits(claim2))) return false;
|
|
557
|
+
return claims.every((claim2) => suits(claim2) || claim2.supported.includes("load"));
|
|
554
558
|
}
|
|
555
559
|
function warnAboutActivation(request) {
|
|
556
560
|
warnUnsupported(request);
|
|
557
561
|
warnUnknownEvents(request);
|
|
558
562
|
}
|
|
559
563
|
function warnUnsupported({ el, spec, supported, claims, reporter }) {
|
|
560
|
-
const declaredAny = supported.length > 0 || (claims?.some((
|
|
564
|
+
const declaredAny = supported.length > 0 || (claims?.some((claim2) => claim2.supported.length > 0) ?? false);
|
|
561
565
|
if (!declaredAny) return;
|
|
562
566
|
const shared = supported.length > 0 ? supported.join(", ") : "none in common across the composed effects";
|
|
563
567
|
for (const name of spec.names) {
|
|
@@ -2364,7 +2368,7 @@ function isAcceptable(value, type) {
|
|
|
2364
2368
|
const grammars = grammarsFor(type);
|
|
2365
2369
|
if (grammars.some((grammar) => PATTERNS[grammar]?.test(value))) return true;
|
|
2366
2370
|
if (!grammars.some((grammar) => CALC_TYPES.has(grammar))) return false;
|
|
2367
|
-
return
|
|
2371
|
+
return (value.startsWith("calc(") || value.startsWith("var(")) && nextCalcToken(value, 0, value.length) === value.length;
|
|
2368
2372
|
}
|
|
2369
2373
|
function describeType(spec) {
|
|
2370
2374
|
if (spec.type === "angle|keyword") {
|
|
@@ -2381,8 +2385,8 @@ function isSameOriginPath(value) {
|
|
|
2381
2385
|
function checkNumericConstraints(value, spec) {
|
|
2382
2386
|
if (!BOUNDED_TYPES.has(spec.type)) return { value, ok: true };
|
|
2383
2387
|
const numeric = Number(value);
|
|
2384
|
-
|
|
2385
|
-
if (
|
|
2388
|
+
const rejection = checkConcreteNumber(numeric, spec);
|
|
2389
|
+
if (rejection) return rejection;
|
|
2386
2390
|
if (spec.minimum !== void 0 && numeric < spec.minimum) {
|
|
2387
2391
|
return reject(spec, `expected at least ${spec.minimum}`);
|
|
2388
2392
|
}
|
|
@@ -2391,32 +2395,48 @@ function checkNumericConstraints(value, spec) {
|
|
|
2391
2395
|
}
|
|
2392
2396
|
return { value, ok: true };
|
|
2393
2397
|
}
|
|
2398
|
+
function checkConcreteNumber(numeric, spec) {
|
|
2399
|
+
if (spec.finite && !Number.isFinite(numeric)) return reject(spec, "expected a finite number");
|
|
2400
|
+
if (spec.integer && !Number.isInteger(numeric)) return reject(spec, "expected an integer");
|
|
2401
|
+
if (hasUnresolvedBounds(numeric, spec)) {
|
|
2402
|
+
return reject(spec, "expected a number for numeric bounds");
|
|
2403
|
+
}
|
|
2404
|
+
return null;
|
|
2405
|
+
}
|
|
2406
|
+
function hasUnresolvedBounds(numeric, spec) {
|
|
2407
|
+
return Number.isNaN(numeric) && (spec.minimum !== void 0 || spec.maximum !== void 0);
|
|
2408
|
+
}
|
|
2394
2409
|
function reject(spec, reason) {
|
|
2395
2410
|
return { value: spec.default, ok: false, reason };
|
|
2396
2411
|
}
|
|
2397
|
-
function
|
|
2398
|
-
if (!value.startsWith("calc(") || !value.endsWith(")")) return false;
|
|
2399
|
-
const end = value.length - 1;
|
|
2400
|
-
let index = "calc(".length;
|
|
2412
|
+
function consumeCalcBody(value, index, end) {
|
|
2401
2413
|
while (index < end) {
|
|
2414
|
+
if (value[index] === ")") return index + 1;
|
|
2402
2415
|
index = nextCalcToken(value, index, end);
|
|
2403
|
-
if (index < 0) return
|
|
2416
|
+
if (index < 0) return -1;
|
|
2404
2417
|
}
|
|
2405
|
-
return
|
|
2418
|
+
return -1;
|
|
2406
2419
|
}
|
|
2407
2420
|
function nextCalcToken(value, index, end) {
|
|
2408
2421
|
if (value.startsWith("var(", index)) return consumeVar(value, index, end);
|
|
2422
|
+
if (value.startsWith("calc(", index)) {
|
|
2423
|
+
const start = index + "calc(".length;
|
|
2424
|
+
const close = consumeCalcBody(value, start, end);
|
|
2425
|
+
return close > 0 && isWellFormedCalc(value, start, close - 1) ? close : -1;
|
|
2426
|
+
}
|
|
2409
2427
|
return CALC_CHARACTER.test(value[index]) ? index + 1 : -1;
|
|
2410
2428
|
}
|
|
2411
2429
|
function consumeVar(value, start, end) {
|
|
2412
|
-
const
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2430
|
+
const nameStart = start + "var(".length;
|
|
2431
|
+
let index = nameStart;
|
|
2432
|
+
while (index < end && value[index] !== "," && value[index] !== ")") index++;
|
|
2433
|
+
if (index === end || !CUSTOM_PROPERTY_NAME.test(value.slice(nameStart, index).trim())) return -1;
|
|
2434
|
+
if (value[index] === ")") return index + 1;
|
|
2435
|
+
return consumeCalcBody(value, index + 1, end);
|
|
2416
2436
|
}
|
|
2417
|
-
function isWellFormedCalc(value) {
|
|
2418
|
-
|
|
2419
|
-
return
|
|
2437
|
+
function isWellFormedCalc(value, start, end) {
|
|
2438
|
+
while (end > start && /\s/.test(value[end - 1])) end--;
|
|
2439
|
+
return end > start && !/[+\-*/]/.test(value[end - 1]);
|
|
2420
2440
|
}
|
|
2421
2441
|
function resolveParams(authored, schema, warn) {
|
|
2422
2442
|
const out = {};
|
|
@@ -2430,9 +2450,9 @@ function resolveParams(authored, schema, warn) {
|
|
|
2430
2450
|
const result = validate(raw, spec);
|
|
2431
2451
|
if (!result.ok) {
|
|
2432
2452
|
warn(`parameter "${key}": ${result.reason} \u2014 got "${raw}", using default "${spec.default}"`);
|
|
2433
|
-
|
|
2453
|
+
} else if (spec.cssProperty) {
|
|
2454
|
+
out[spec.cssProperty] = cssValueFor(result.value, spec, key, warn);
|
|
2434
2455
|
}
|
|
2435
|
-
out[spec.cssProperty] = cssValueFor(result.value, spec, key, warn);
|
|
2436
2456
|
}
|
|
2437
2457
|
return out;
|
|
2438
2458
|
}
|
|
@@ -2555,6 +2575,450 @@ function readEffectParams(authored, schema, warn, timing = {}) {
|
|
|
2555
2575
|
return createParams(readParams(authored, schema, warn), timing);
|
|
2556
2576
|
}
|
|
2557
2577
|
|
|
2578
|
+
// src/core/stagger-keys.ts
|
|
2579
|
+
var GROUP_KEY_NAMES = ["cascade", "spread", "order", "cols", "along"];
|
|
2580
|
+
function collectKeys(lookup) {
|
|
2581
|
+
const keys = {};
|
|
2582
|
+
for (const name of GROUP_KEY_NAMES) {
|
|
2583
|
+
const value = lookup(name);
|
|
2584
|
+
if (value !== void 0) keys[name] = value;
|
|
2585
|
+
}
|
|
2586
|
+
return Object.keys(keys).length > 0 ? keys : void 0;
|
|
2587
|
+
}
|
|
2588
|
+
function elementStaggerKeys(parsed) {
|
|
2589
|
+
return collectKeys((name) => parsed[name]);
|
|
2590
|
+
}
|
|
2591
|
+
function staggerKeysFor(scoped, elementWide) {
|
|
2592
|
+
return collectKeys((name) => scoped?.[name] ?? elementWide?.[name]);
|
|
2593
|
+
}
|
|
2594
|
+
function isGroupedKeys(keys) {
|
|
2595
|
+
return keys?.cascade !== void 0 || keys?.spread !== void 0 || keys?.order !== void 0;
|
|
2596
|
+
}
|
|
2597
|
+
var TARGET_GROUP_HOSTS = /* @__PURE__ */ new WeakMap();
|
|
2598
|
+
function claimTargetGroupHost(host) {
|
|
2599
|
+
TARGET_GROUP_HOSTS.set(host, (TARGET_GROUP_HOSTS.get(host) ?? 0) + 1);
|
|
2600
|
+
let released = false;
|
|
2601
|
+
return () => {
|
|
2602
|
+
if (released) return;
|
|
2603
|
+
released = true;
|
|
2604
|
+
const remaining = TARGET_GROUP_HOSTS.get(host) - 1;
|
|
2605
|
+
if (remaining > 0) TARGET_GROUP_HOSTS.set(host, remaining);
|
|
2606
|
+
else TARGET_GROUP_HOSTS.delete(host);
|
|
2607
|
+
};
|
|
2608
|
+
}
|
|
2609
|
+
function isTargetGroupHost(el) {
|
|
2610
|
+
return TARGET_GROUP_HOSTS.has(el);
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
// src/core/stagger-config.ts
|
|
2614
|
+
var FROM_KEYWORDS = /* @__PURE__ */ new Set(["start", "end", "center", "edges", "random"]);
|
|
2615
|
+
var ORDER_KEYS = /* @__PURE__ */ new Set(["from", "order"]);
|
|
2616
|
+
var SPREAD_KEY = "spread";
|
|
2617
|
+
var COLS_KEY = "cols";
|
|
2618
|
+
var AXIS_KEYS = /* @__PURE__ */ new Set(["axis", "along"]);
|
|
2619
|
+
var AXIS_VALUES = /* @__PURE__ */ new Set(["x", "y"]);
|
|
2620
|
+
var ORIGIN_RE = /^(\d+(?:\.\d+)?|\.\d+)\/(\d+(?:\.\d+)?|\.\d+)$/;
|
|
2621
|
+
var COLS_RE = /^\d{1,9}$/;
|
|
2622
|
+
var PAIR_RE = /^([a-zA-Z-]+):(.*)$/;
|
|
2623
|
+
var INDEX_RE = /^-?\d{1,9}$/;
|
|
2624
|
+
function parseStaggerTokens(value, warnings) {
|
|
2625
|
+
const config = { from: "start" };
|
|
2626
|
+
const seen = { from: false, spread: false, cols: false, along: false };
|
|
2627
|
+
for (const token of splitTopLevel(value, " ", warnings)) {
|
|
2628
|
+
const pair = PAIR_RE.exec(token);
|
|
2629
|
+
if (pair) applyStaggerPair(pair[1], pair[2], { config, seen, warnings });
|
|
2630
|
+
else config.step = keepFirstStep(config.step, token, warnings);
|
|
2631
|
+
}
|
|
2632
|
+
return { config, sawFrom: seen.from };
|
|
2633
|
+
}
|
|
2634
|
+
function applyStaggerPair(key, raw, state) {
|
|
2635
|
+
const slot = slotFor(key);
|
|
2636
|
+
if (slot === void 0) {
|
|
2637
|
+
state.warnings.push(
|
|
2638
|
+
`unrecognised key "${key}" in data-kui-stagger \u2014 expected a time step, "spread:", "cols:", "along:", "from:" or "order:"`
|
|
2639
|
+
);
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
if (claim(slot, raw, state, key)) ASSIGN[slot](raw, state, key);
|
|
2643
|
+
}
|
|
2644
|
+
function slotFor(key) {
|
|
2645
|
+
if (key === SPREAD_KEY) return "spread";
|
|
2646
|
+
if (key === COLS_KEY) return "cols";
|
|
2647
|
+
if (AXIS_KEYS.has(key)) return "along";
|
|
2648
|
+
if (ORDER_KEYS.has(key)) return "from";
|
|
2649
|
+
return void 0;
|
|
2650
|
+
}
|
|
2651
|
+
var ASSIGN = {
|
|
2652
|
+
spread: (raw, state) => {
|
|
2653
|
+
state.config.spread = raw.trim();
|
|
2654
|
+
},
|
|
2655
|
+
cols: (raw, state) => {
|
|
2656
|
+
state.config.cols = parseCols(raw, state.warnings);
|
|
2657
|
+
},
|
|
2658
|
+
along: (raw, state, key) => {
|
|
2659
|
+
state.config.along = parseAxis(raw, state.warnings, key);
|
|
2660
|
+
},
|
|
2661
|
+
from: (raw, state, key) => {
|
|
2662
|
+
state.config.from = parseFrom(raw, state.warnings, key);
|
|
2663
|
+
}
|
|
2664
|
+
};
|
|
2665
|
+
function claim(slot, raw, state, spelling) {
|
|
2666
|
+
if (state.seen[slot]) {
|
|
2667
|
+
state.warnings.push(`duplicate "${spelling}:" in data-kui-stagger \u2014 "${raw}" ignored`);
|
|
2668
|
+
return false;
|
|
2669
|
+
}
|
|
2670
|
+
state.seen[slot] = true;
|
|
2671
|
+
return true;
|
|
2672
|
+
}
|
|
2673
|
+
function parseCols(raw, warnings) {
|
|
2674
|
+
const value = raw.trim();
|
|
2675
|
+
if (value === "auto") return "auto";
|
|
2676
|
+
if (COLS_RE.test(value) && Number(value) > 0) return Number(value);
|
|
2677
|
+
warnings.push(`unrecognised "cols:${raw}" \u2014 expected a column count or "auto"`);
|
|
2678
|
+
return void 0;
|
|
2679
|
+
}
|
|
2680
|
+
function parseAxis(raw, warnings, key) {
|
|
2681
|
+
const value = raw.trim();
|
|
2682
|
+
if (AXIS_VALUES.has(value)) return value;
|
|
2683
|
+
warnings.push(`unrecognised "${key}:${raw}" \u2014 expected x or y`);
|
|
2684
|
+
return void 0;
|
|
2685
|
+
}
|
|
2686
|
+
function resolveStaggerConfig(attribute, source, warnings = []) {
|
|
2687
|
+
const inline = inlineGroupKeys(source);
|
|
2688
|
+
if (attribute === null && inline === void 0) return void 0;
|
|
2689
|
+
return resolveStaggerConfigFrom(attribute, inline, warnings);
|
|
2690
|
+
}
|
|
2691
|
+
function resolveStaggerConfigFrom(attribute, inline, warnings = []) {
|
|
2692
|
+
if (attribute === null && inline === void 0) return void 0;
|
|
2693
|
+
const { config: longhand, sawFrom } = parseStaggerTokens(attribute ?? "", warnings);
|
|
2694
|
+
return oneStepMode(screenStep(mergeInline(longhand, sawFrom, inline ?? {}, warnings), warnings), warnings);
|
|
2695
|
+
}
|
|
2696
|
+
function oneStepMode(config, warnings) {
|
|
2697
|
+
if (config.spread === void 0 || config.step === void 0) return config;
|
|
2698
|
+
warnings.push(
|
|
2699
|
+
`stagger step "${config.step}" is ignored \u2014 "spread:${config.spread}" already budgets the whole group, and the step is what it divides out`
|
|
2700
|
+
);
|
|
2701
|
+
const budgeted = { ...config };
|
|
2702
|
+
delete budgeted.step;
|
|
2703
|
+
return budgeted;
|
|
2704
|
+
}
|
|
2705
|
+
function inlineGroupKeys(source) {
|
|
2706
|
+
if (!hasGroupKey(source)) return void 0;
|
|
2707
|
+
const { cascade, spread, order, cols, along } = parse(source);
|
|
2708
|
+
const keys = { cascade, spread, order, cols, along };
|
|
2709
|
+
return Object.values(keys).some((value) => value !== void 0) ? keys : void 0;
|
|
2710
|
+
}
|
|
2711
|
+
function screenStep(config, warnings) {
|
|
2712
|
+
const screened = { ...config };
|
|
2713
|
+
if (!keepValue("step", config.step, warnings)) delete screened.step;
|
|
2714
|
+
if (!keepValue("spread", config.spread, warnings)) delete screened.spread;
|
|
2715
|
+
return screened;
|
|
2716
|
+
}
|
|
2717
|
+
function keepValue(label, value, warnings) {
|
|
2718
|
+
if (value === void 0) return false;
|
|
2719
|
+
if (isSafeCssValue(value)) return true;
|
|
2720
|
+
warnings.push(`stagger ${label} "${value}" contains disallowed CSS syntax \u2014 ignored`);
|
|
2721
|
+
return false;
|
|
2722
|
+
}
|
|
2723
|
+
function mergeInline(longhand, sawFrom, inline, warnings) {
|
|
2724
|
+
const config = { ...longhand };
|
|
2725
|
+
if (inline.cascade !== void 0) {
|
|
2726
|
+
warnOverride("stagger step", longhand.step, inline.cascade, warnings);
|
|
2727
|
+
config.step = inline.cascade;
|
|
2728
|
+
}
|
|
2729
|
+
if (inline.spread !== void 0) {
|
|
2730
|
+
warnOverride("stagger budget", longhand.spread, inline.spread, warnings);
|
|
2731
|
+
config.spread = inline.spread;
|
|
2732
|
+
}
|
|
2733
|
+
mergeInlineGrid(config, longhand, inline, warnings);
|
|
2734
|
+
if (inline.order !== void 0) {
|
|
2735
|
+
const order = parseFrom(inline.order, warnings, "order");
|
|
2736
|
+
warnOverride("stagger order", sawFrom ? longhand.from : void 0, order, warnings);
|
|
2737
|
+
config.from = order;
|
|
2738
|
+
}
|
|
2739
|
+
return config;
|
|
2740
|
+
}
|
|
2741
|
+
function mergeInlineGrid(config, longhand, inline, warnings) {
|
|
2742
|
+
if (inline.cols !== void 0) {
|
|
2743
|
+
const cols = parseCols(inline.cols, warnings);
|
|
2744
|
+
warnOverride("stagger columns", longhand.cols, cols, warnings);
|
|
2745
|
+
if (cols !== void 0) config.cols = cols;
|
|
2746
|
+
}
|
|
2747
|
+
if (inline.along !== void 0) {
|
|
2748
|
+
const along = parseAxis(inline.along, warnings, "along");
|
|
2749
|
+
warnOverride("stagger axis", longhand.along, along, warnings);
|
|
2750
|
+
if (along !== void 0) config.along = along;
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
function hasGroupKey(source) {
|
|
2754
|
+
return GROUP_KEY_PREFIXES.some((prefix) => source.includes(prefix));
|
|
2755
|
+
}
|
|
2756
|
+
var GROUP_KEY_PREFIXES = [
|
|
2757
|
+
"cascade:",
|
|
2758
|
+
"spread:",
|
|
2759
|
+
"order:",
|
|
2760
|
+
"cols:",
|
|
2761
|
+
"along:"
|
|
2762
|
+
];
|
|
2763
|
+
function warnOverride(label, previous, next, warnings) {
|
|
2764
|
+
if (previous === void 0 || next === void 0 || previous === next) return;
|
|
2765
|
+
warnings.push(
|
|
2766
|
+
`conflicting ${label}: data-kui-stagger says "${String(previous)}", data-kui says "${String(next)}" \u2014 data-kui wins`
|
|
2767
|
+
);
|
|
2768
|
+
}
|
|
2769
|
+
function keepFirstStep(current, token, warnings) {
|
|
2770
|
+
if (current === void 0) return token;
|
|
2771
|
+
warnings.push(`extra token "${token}" in data-kui-stagger (expected one time step)`);
|
|
2772
|
+
return current;
|
|
2773
|
+
}
|
|
2774
|
+
function parseFrom(raw, warnings, key = "from") {
|
|
2775
|
+
const value = raw.trim();
|
|
2776
|
+
if (FROM_KEYWORDS.has(value)) return value;
|
|
2777
|
+
if (INDEX_RE.test(value)) return Number(value);
|
|
2778
|
+
const origin = ORIGIN_RE.exec(value);
|
|
2779
|
+
if (origin) return { x: clamp012(Number(origin[1]), value, warnings), y: clamp012(Number(origin[2]), value, warnings) };
|
|
2780
|
+
warnings.push(
|
|
2781
|
+
`unrecognised "${key}:${raw}" \u2014 expected start, end, center, edges, random, a child index, or an "x/y" point in a grid`
|
|
2782
|
+
);
|
|
2783
|
+
return "start";
|
|
2784
|
+
}
|
|
2785
|
+
function clamp012(value, source, warnings) {
|
|
2786
|
+
if (value >= 0 && value <= 1) return value;
|
|
2787
|
+
warnings.push(`stagger order "${source}" is outside the grid (0 to 1 on each axis) \u2014 clamped`);
|
|
2788
|
+
return Math.min(Math.max(value, 0), 1);
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
// src/core/stagger.ts
|
|
2792
|
+
var RANK_PRECISION = 1e3;
|
|
2793
|
+
var RANDOM_SALT = 2654435761;
|
|
2794
|
+
var COUNT_SALT = 2246822507;
|
|
2795
|
+
var MIX_A = 569420461;
|
|
2796
|
+
var MIX_B = 1935289751;
|
|
2797
|
+
function resolveStep(config, maxRank) {
|
|
2798
|
+
if (config.spread === void 0) return config.step;
|
|
2799
|
+
if (maxRank <= 0) return "0ms";
|
|
2800
|
+
return `calc((${config.spread}) / ${String(maxRank)})`;
|
|
2801
|
+
}
|
|
2802
|
+
function staggerRanks(count, from, warnings = [], layout) {
|
|
2803
|
+
if (count <= 0) return [];
|
|
2804
|
+
if (from === "random") return randomRanks(count);
|
|
2805
|
+
if (layout) return gridRanks(count, from, layout, warnings);
|
|
2806
|
+
if (typeof from === "object") {
|
|
2807
|
+
warnings.push(
|
|
2808
|
+
`stagger order "${String(from.x)}/${String(from.y)}" is a point in a grid, but this group has no "cols:" \u2014 add one, or name an edge with start/end/center/edges`
|
|
2809
|
+
);
|
|
2810
|
+
return staggerRanks(count, "start", warnings);
|
|
2811
|
+
}
|
|
2812
|
+
const last = count - 1;
|
|
2813
|
+
if (from === "edges") {
|
|
2814
|
+
return Array.from({ length: count }, (_, index) => Math.min(index, last - index));
|
|
2815
|
+
}
|
|
2816
|
+
const origin = originOf(from, last, warnings);
|
|
2817
|
+
return Array.from({ length: count }, (_, index) => Math.floor(Math.abs(index - origin)));
|
|
2818
|
+
}
|
|
2819
|
+
function originOf(from, last, warnings) {
|
|
2820
|
+
if (from === "start") return 0;
|
|
2821
|
+
if (from === "end") return last;
|
|
2822
|
+
if (from === "center") return last / 2;
|
|
2823
|
+
return clampIndex(from, last, warnings);
|
|
2824
|
+
}
|
|
2825
|
+
function clampIndex(index, last, warnings) {
|
|
2826
|
+
if (index < 0 || index > last) {
|
|
2827
|
+
warnings.push(`stagger order "${String(index)}" is outside the group (0 to ${String(last)}) \u2014 clamped`);
|
|
2828
|
+
}
|
|
2829
|
+
return Math.min(Math.max(index, 0), last);
|
|
2830
|
+
}
|
|
2831
|
+
function gridRanks(count, from, layout, warnings) {
|
|
2832
|
+
const cols = Math.min(Math.max(1, layout.cols), count);
|
|
2833
|
+
const rows = Math.ceil(count / cols);
|
|
2834
|
+
if (from === "edges") {
|
|
2835
|
+
const inward = gridRanks(count, "center", layout, warnings);
|
|
2836
|
+
let furthest = 0;
|
|
2837
|
+
for (const rank of inward) furthest = Math.max(furthest, rank);
|
|
2838
|
+
return inward.map((rank) => round2(furthest - rank));
|
|
2839
|
+
}
|
|
2840
|
+
const origin = gridOrigin(from, { cols, rows, last: count - 1 }, warnings);
|
|
2841
|
+
return Array.from({ length: count }, (_, index) => {
|
|
2842
|
+
const dx = index % cols - origin.x;
|
|
2843
|
+
const dy = Math.floor(index / cols) - origin.y;
|
|
2844
|
+
if (layout.along === "x") return round2(Math.abs(dx));
|
|
2845
|
+
if (layout.along === "y") return round2(Math.abs(dy));
|
|
2846
|
+
return round2(Math.hypot(dx, dy));
|
|
2847
|
+
});
|
|
2848
|
+
}
|
|
2849
|
+
function gridOrigin(from, grid, warnings) {
|
|
2850
|
+
const { cols, rows, last } = grid;
|
|
2851
|
+
if (typeof from === "object") return { x: from.x * (cols - 1), y: from.y * (rows - 1) };
|
|
2852
|
+
if (from === "start") return { x: 0, y: 0 };
|
|
2853
|
+
if (from === "end") return { x: cols - 1, y: rows - 1 };
|
|
2854
|
+
if (from === "center") return { x: (cols - 1) / 2, y: (rows - 1) / 2 };
|
|
2855
|
+
const index = clampIndex(from, last, warnings);
|
|
2856
|
+
return { x: index % cols, y: Math.floor(index / cols) };
|
|
2857
|
+
}
|
|
2858
|
+
function round2(value) {
|
|
2859
|
+
return Math.round(value * RANK_PRECISION) / RANK_PRECISION;
|
|
2860
|
+
}
|
|
2861
|
+
function randomRanks(count) {
|
|
2862
|
+
const order = Array.from({ length: count }, (_, index) => index);
|
|
2863
|
+
order.sort((a, b) => scatterKey(a, count) - scatterKey(b, count));
|
|
2864
|
+
const ranks = new Array(count);
|
|
2865
|
+
for (const [rank, index] of order.entries()) ranks[index] = rank;
|
|
2866
|
+
return ranks;
|
|
2867
|
+
}
|
|
2868
|
+
function scatterKey(index, count) {
|
|
2869
|
+
let hash = (Math.imul(index, RANDOM_SALT) ^ Math.imul(count, COUNT_SALT)) >>> 0;
|
|
2870
|
+
hash ^= hash >>> 16;
|
|
2871
|
+
hash = Math.imul(hash, MIX_A) >>> 0;
|
|
2872
|
+
hash ^= hash >>> 15;
|
|
2873
|
+
hash = Math.imul(hash, MIX_B) >>> 0;
|
|
2874
|
+
hash ^= hash >>> 15;
|
|
2875
|
+
return hash >>> 0;
|
|
2876
|
+
}
|
|
2877
|
+
function indexStaggerGroup(group, reporter) {
|
|
2878
|
+
const warnings = [];
|
|
2879
|
+
const ledgers = reopenLedger(group);
|
|
2880
|
+
const config = resolveStaggerConfig(
|
|
2881
|
+
group.getAttribute(ATTR.stagger),
|
|
2882
|
+
group.getAttribute(ATTR.source) ?? "",
|
|
2883
|
+
warnings
|
|
2884
|
+
) ?? { from: "start" };
|
|
2885
|
+
const children = animatedChildren(group);
|
|
2886
|
+
const ranks = staggerRanks(children.length, config.from, warnings, resolveLayout(config, children, warnings));
|
|
2887
|
+
let maxRank = 0;
|
|
2888
|
+
for (const [index, child] of children.entries()) {
|
|
2889
|
+
const rank = ranks[index];
|
|
2890
|
+
ledgers.style(child).set("--kui-i", String(rank));
|
|
2891
|
+
GROUP_OF_CHILD.set(child, group);
|
|
2892
|
+
if (rank > maxRank) maxRank = rank;
|
|
2893
|
+
}
|
|
2894
|
+
const step = resolveStep(config, maxRank);
|
|
2895
|
+
if (step) ledgers.style(group).set("--kui-stagger", step);
|
|
2896
|
+
ledgers.style(group).set("--kui-stagger-count", String(round2(maxRank + 1)));
|
|
2897
|
+
for (const warning of warnings) reporter?.warn(warning, group);
|
|
2898
|
+
}
|
|
2899
|
+
var GROUP_LEDGERS = /* @__PURE__ */ new WeakMap();
|
|
2900
|
+
var GROUP_OF_CHILD = /* @__PURE__ */ new WeakMap();
|
|
2901
|
+
function restageAfterRemoval(removed, reporter) {
|
|
2902
|
+
const groups = /* @__PURE__ */ new Set();
|
|
2903
|
+
for (const el of removed) {
|
|
2904
|
+
const group = GROUP_OF_CHILD.get(el);
|
|
2905
|
+
if (group) groups.add(group);
|
|
2906
|
+
}
|
|
2907
|
+
for (const group of groups) indexStaggerGroup(group, reporter);
|
|
2908
|
+
}
|
|
2909
|
+
function reopenLedger(group) {
|
|
2910
|
+
GROUP_LEDGERS.get(group)?.restore();
|
|
2911
|
+
const ledgers = createLedgerSet(group);
|
|
2912
|
+
GROUP_LEDGERS.set(group, ledgers);
|
|
2913
|
+
return ledgers;
|
|
2914
|
+
}
|
|
2915
|
+
function releaseStaggerGroup(group) {
|
|
2916
|
+
GROUP_LEDGERS.get(group)?.restore();
|
|
2917
|
+
GROUP_LEDGERS.delete(group);
|
|
2918
|
+
}
|
|
2919
|
+
function releaseStagger(root) {
|
|
2920
|
+
const selector = `[${ATTR.stagger}], [${ATTR.source}]`;
|
|
2921
|
+
if (root instanceof Element && root.matches(selector)) releaseStaggerGroup(root);
|
|
2922
|
+
for (const el of root.querySelectorAll(selector)) releaseStaggerGroup(el);
|
|
2923
|
+
}
|
|
2924
|
+
function restageAround(el, reporter) {
|
|
2925
|
+
restageOne(el, reporter);
|
|
2926
|
+
const parent = el.parentElement;
|
|
2927
|
+
if (parent) restageOne(parent, reporter);
|
|
2928
|
+
}
|
|
2929
|
+
function restageOne(el, reporter) {
|
|
2930
|
+
if (declaresGroup(el)) indexStaggerGroup(el, reporter);
|
|
2931
|
+
else releaseStaggerGroup(el);
|
|
2932
|
+
}
|
|
2933
|
+
function indexTargetGroup(request) {
|
|
2934
|
+
const { host, matches, styleOf, keys, reporter } = request;
|
|
2935
|
+
const warnings = [];
|
|
2936
|
+
const attribute = host.getAttribute(ATTR.stagger);
|
|
2937
|
+
const config = (keys ? resolveStaggerConfigFrom(attribute, keys, warnings) : resolveStaggerConfig(attribute, host.getAttribute(ATTR.source) ?? "", warnings)) ?? { from: "start" };
|
|
2938
|
+
const maxRank = rankBuckets(bucketByParent(matches), config, styleOf, warnings);
|
|
2939
|
+
const step = resolveStep(config, maxRank);
|
|
2940
|
+
if (step) styleOf(host).set("--kui-stagger", step);
|
|
2941
|
+
styleOf(host).set("--kui-stagger-count", String(round2(maxRank + 1)));
|
|
2942
|
+
for (const warning of warnings) reporter?.warn(warning, host);
|
|
2943
|
+
}
|
|
2944
|
+
function bucketByParent(matches) {
|
|
2945
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
2946
|
+
for (const match of matches) {
|
|
2947
|
+
const siblings = byParent.get(match.parentElement);
|
|
2948
|
+
if (siblings) siblings.push(match);
|
|
2949
|
+
else byParent.set(match.parentElement, [match]);
|
|
2950
|
+
}
|
|
2951
|
+
return byParent;
|
|
2952
|
+
}
|
|
2953
|
+
function rankBuckets(byParent, config, styleOf, warnings) {
|
|
2954
|
+
let maxRank = 0;
|
|
2955
|
+
for (const siblings of byParent.values()) {
|
|
2956
|
+
const layout = resolveLayout(config, siblings, warnings);
|
|
2957
|
+
const ranks = staggerRanks(siblings.length, config.from, warnings, layout);
|
|
2958
|
+
for (const [index, match] of siblings.entries()) {
|
|
2959
|
+
const rank = ranks[index];
|
|
2960
|
+
styleOf(match).set("--kui-i", String(rank));
|
|
2961
|
+
if (rank > maxRank) maxRank = rank;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
return maxRank;
|
|
2965
|
+
}
|
|
2966
|
+
function resolveLayout(config, members, warnings) {
|
|
2967
|
+
if (config.cols === void 0) {
|
|
2968
|
+
if (config.along !== void 0) {
|
|
2969
|
+
warnings.push(
|
|
2970
|
+
`"along:${config.along}" names an axis of a grid this group has not declared \u2014 add "cols:" (a column count, or "auto")`
|
|
2971
|
+
);
|
|
2972
|
+
}
|
|
2973
|
+
return void 0;
|
|
2974
|
+
}
|
|
2975
|
+
const cols = config.cols === "auto" ? measureColumns(members, warnings) : config.cols;
|
|
2976
|
+
if (cols === void 0) return void 0;
|
|
2977
|
+
return config.along === void 0 ? { cols } : { cols, along: config.along };
|
|
2978
|
+
}
|
|
2979
|
+
function measureColumns(members, warnings) {
|
|
2980
|
+
if (members.length < 2) return 1;
|
|
2981
|
+
const lefts = [];
|
|
2982
|
+
let laidOut = false;
|
|
2983
|
+
for (const member of members) {
|
|
2984
|
+
const box = member.getBoundingClientRect();
|
|
2985
|
+
if (box.width !== 0 || box.height !== 0) laidOut = true;
|
|
2986
|
+
lefts.push(box.left);
|
|
2987
|
+
}
|
|
2988
|
+
if (!laidOut) {
|
|
2989
|
+
warnings.push(
|
|
2990
|
+
`"cols:auto" could not measure this group \u2014 none of its children have been laid out yet (display:none, or detached), so the stagger falls back to DOM order`
|
|
2991
|
+
);
|
|
2992
|
+
return void 0;
|
|
2993
|
+
}
|
|
2994
|
+
const direction = Math.sign(lefts[1] - lefts[0]);
|
|
2995
|
+
if (direction === 0) return 1;
|
|
2996
|
+
let cols = 1;
|
|
2997
|
+
for (let index = 1; index < lefts.length; index++) {
|
|
2998
|
+
if (Math.sign(lefts[index] - lefts[index - 1]) !== direction) break;
|
|
2999
|
+
cols = index + 1;
|
|
3000
|
+
}
|
|
3001
|
+
return cols;
|
|
3002
|
+
}
|
|
3003
|
+
function animatedChildren(group) {
|
|
3004
|
+
const children = [];
|
|
3005
|
+
for (const child of group.children) {
|
|
3006
|
+
if (child.hasAttribute(ATTR.source)) children.push(child);
|
|
3007
|
+
}
|
|
3008
|
+
return children;
|
|
3009
|
+
}
|
|
3010
|
+
function applyStagger(root, reporter) {
|
|
3011
|
+
const selector = `[${ATTR.stagger}], [${ATTR.source}]`;
|
|
3012
|
+
if (root instanceof Element && root.matches(selector)) restageOne(root, reporter);
|
|
3013
|
+
for (const group of root.querySelectorAll(selector)) restageOne(group, reporter);
|
|
3014
|
+
}
|
|
3015
|
+
function declaresGroup(el) {
|
|
3016
|
+
if (el.hasAttribute(ATTR.define)) return false;
|
|
3017
|
+
if (isTargetGroupHost(el)) return false;
|
|
3018
|
+
if (el.hasAttribute(ATTR.stagger)) return true;
|
|
3019
|
+
return resolveStaggerConfig(null, el.getAttribute(ATTR.source) ?? "") !== void 0;
|
|
3020
|
+
}
|
|
3021
|
+
|
|
2558
3022
|
// src/core/scroll-scheduler.ts
|
|
2559
3023
|
function defaultDeps() {
|
|
2560
3024
|
const raf = globalThis.requestAnimationFrame;
|
|
@@ -2735,7 +3199,7 @@ function defaultIsScrollable(win) {
|
|
|
2735
3199
|
return vertical || horizontal;
|
|
2736
3200
|
};
|
|
2737
3201
|
}
|
|
2738
|
-
function
|
|
3202
|
+
function clamp013(value) {
|
|
2739
3203
|
if (Number.isNaN(value)) return 0;
|
|
2740
3204
|
return Math.min(1, Math.max(0, value));
|
|
2741
3205
|
}
|
|
@@ -2899,10 +3363,11 @@ function deferredInstance(setup) {
|
|
|
2899
3363
|
running = setup();
|
|
2900
3364
|
if (typeof running === "function" || "continuous" in running) return;
|
|
2901
3365
|
const work = running.finished;
|
|
2902
|
-
finished = new Promise((
|
|
2903
|
-
settle =
|
|
3366
|
+
finished = new Promise((resolve2) => {
|
|
3367
|
+
settle = resolve2;
|
|
2904
3368
|
});
|
|
2905
|
-
|
|
3369
|
+
const resolve = settle;
|
|
3370
|
+
void work.then(() => resolve?.());
|
|
2906
3371
|
},
|
|
2907
3372
|
cancel: teardown,
|
|
2908
3373
|
finish() {
|
|
@@ -2977,6 +3442,7 @@ export {
|
|
|
2977
3442
|
defaultSpringDeps,
|
|
2978
3443
|
cssEasingValue,
|
|
2979
3444
|
waapiEasingValue,
|
|
3445
|
+
customEasing,
|
|
2980
3446
|
resolvePlayback,
|
|
2981
3447
|
repeatCount,
|
|
2982
3448
|
isInfiniteRepeat,
|
|
@@ -2990,7 +3456,7 @@ export {
|
|
|
2990
3456
|
SUBTREE_CHANNEL,
|
|
2991
3457
|
inertInstance,
|
|
2992
3458
|
SEGMENT_HOIST_KEYS,
|
|
2993
|
-
|
|
3459
|
+
EASING_KEYWORDS,
|
|
2994
3460
|
parseActivationAttribute,
|
|
2995
3461
|
parse,
|
|
2996
3462
|
assignOnce,
|
|
@@ -3005,7 +3471,6 @@ export {
|
|
|
3005
3471
|
emitLifecycle,
|
|
3006
3472
|
validate,
|
|
3007
3473
|
decimalNumber,
|
|
3008
|
-
isSafeCssValue,
|
|
3009
3474
|
isSameOriginPath,
|
|
3010
3475
|
resolveParams,
|
|
3011
3476
|
ABSOLUTE_BASIS,
|
|
@@ -3014,9 +3479,20 @@ export {
|
|
|
3014
3479
|
readEffectTiming,
|
|
3015
3480
|
effectDurationMs,
|
|
3016
3481
|
readEffectParams,
|
|
3482
|
+
elementStaggerKeys,
|
|
3483
|
+
staggerKeysFor,
|
|
3484
|
+
isGroupedKeys,
|
|
3485
|
+
claimTargetGroupHost,
|
|
3486
|
+
staggerRanks,
|
|
3487
|
+
restageAfterRemoval,
|
|
3488
|
+
releaseStagger,
|
|
3489
|
+
restageAround,
|
|
3490
|
+
indexTargetGroup,
|
|
3491
|
+
applyStagger,
|
|
3017
3492
|
createScrollScheduler,
|
|
3493
|
+
windowScrollRoot,
|
|
3018
3494
|
createRootResolver,
|
|
3019
|
-
|
|
3495
|
+
clamp013 as clamp01,
|
|
3020
3496
|
createMeasureCache,
|
|
3021
3497
|
TIME_SCALE_ATTR,
|
|
3022
3498
|
timeScaleOf,
|
|
@@ -3024,6 +3500,7 @@ export {
|
|
|
3024
3500
|
continuousSetup,
|
|
3025
3501
|
deferredInstance,
|
|
3026
3502
|
deferPrepare,
|
|
3503
|
+
createJsInstance,
|
|
3027
3504
|
ALL_TIMING_TOKENS,
|
|
3028
3505
|
declareTimingContract,
|
|
3029
3506
|
inheritTimingContract,
|