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.
Files changed (74) hide show
  1. package/README.md +2 -2
  2. package/dist/esm/advanced/index.mjs +1 -1
  3. package/dist/esm/{chunk-EHS45PIK.mjs → chunk-4QKMEDM4.mjs} +4978 -832
  4. package/dist/esm/{chunk-FASAEQDR.mjs → chunk-7NW4OLOC.mjs} +506 -29
  5. package/dist/esm/{chunk-MZQG2VMG.mjs → chunk-DAVDOYOS.mjs} +92 -495
  6. package/dist/esm/{chunk-AEQGC2KM.mjs → chunk-EDFJTT5B.mjs} +2 -1
  7. package/dist/esm/core/index.mjs +3 -3
  8. package/dist/esm/effects/index.mjs +3 -3
  9. package/dist/esm/index.mjs +4 -4
  10. package/dist/esm/notes/index.mjs +276 -5
  11. package/dist/kuinetic.advanced.js +2 -1
  12. package/dist/kuinetic.advanced.min.js +1 -1
  13. package/dist/kuinetic.all.js +5047 -856
  14. package/dist/kuinetic.all.min.js +2 -2
  15. package/dist/kuinetic.css +1106 -61
  16. package/dist/kuinetic.js +5046 -855
  17. package/dist/kuinetic.min.css +1 -1
  18. package/dist/kuinetic.min.js +1 -1
  19. package/dist/kuinetic.notes.js +1 -1
  20. package/dist/types/advanced/shaders.d.ts +1 -1
  21. package/dist/types/core/channels.d.ts +1 -1
  22. package/dist/types/core/easing.d.ts +9 -0
  23. package/dist/types/core/effect-context.d.ts +5 -0
  24. package/dist/types/core/element-config.d.ts +2 -0
  25. package/dist/types/core/flip.d.ts +25 -1
  26. package/dist/types/core/gesture.d.ts +5 -0
  27. package/dist/types/core/image-flight.d.ts +23 -0
  28. package/dist/types/core/js-effect-preparer.d.ts +3 -1
  29. package/dist/types/core/owned-styles.d.ts +2 -1
  30. package/dist/types/core/params.d.ts +1 -1
  31. package/dist/types/core/parse.d.ts +1 -0
  32. package/dist/types/core/registry.d.ts +1 -1
  33. package/dist/types/core/types.d.ts +11 -1
  34. package/dist/types/effects/auto-motion.d.ts +8 -0
  35. package/dist/types/effects/carousel/archive.d.ts +18 -0
  36. package/dist/types/effects/carousel/coast.d.ts +7 -0
  37. package/dist/types/effects/carousel/deck.d.ts +26 -2
  38. package/dist/types/effects/carousel/drag.d.ts +19 -7
  39. package/dist/types/effects/carousel/glide.d.ts +89 -0
  40. package/dist/types/effects/carousel/line.d.ts +10 -0
  41. package/dist/types/effects/carousel/row-copies.d.ts +10 -0
  42. package/dist/types/effects/carousel/row.d.ts +3 -0
  43. package/dist/types/effects/carousel/shape-fit.d.ts +46 -0
  44. package/dist/types/effects/carousel/sources.d.ts +26 -0
  45. package/dist/types/effects/carousel/sphere.d.ts +23 -0
  46. package/dist/types/effects/carousel/stack.d.ts +2 -1
  47. package/dist/types/effects/catalog/confetti.d.ts +2 -0
  48. package/dist/types/effects/catalog/cursor-trail.d.ts +2 -0
  49. package/dist/types/effects/catalog/curtains.d.ts +2 -0
  50. package/dist/types/effects/catalog/image-flight.d.ts +2 -0
  51. package/dist/types/effects/catalog/line-boil.d.ts +2 -0
  52. package/dist/types/effects/catalog/number-tokens.d.ts +5 -0
  53. package/dist/types/effects/catalog/numbers-shared.d.ts +3 -4
  54. package/dist/types/effects/catalog/text-shared.d.ts +13 -6
  55. package/dist/types/effects/catalog/typewriter-scatter.d.ts +5 -0
  56. package/dist/types/effects/catalog/view-transitions.d.ts +32 -1
  57. package/dist/types/effects/catalog/wobble.d.ts +2 -0
  58. package/dist/types/effects/gestures/drag-options.d.ts +17 -0
  59. package/dist/types/effects/layout/departures.d.ts +21 -0
  60. package/dist/types/effects/motion-path/fit.d.ts +4 -0
  61. package/dist/types/effects/scroll-mechanics/progress-output.d.ts +9 -0
  62. package/dist/types/effects/step-marking.d.ts +7 -4
  63. package/dist/types/effects/svg/morph-loop.d.ts +5 -0
  64. package/dist/types/effects/svg/text-path.d.ts +2 -0
  65. package/dist/types/effects/three-d/cube.d.ts +2 -0
  66. package/dist/types/effects/tween/index.d.ts +2 -1
  67. package/dist/types/effects/tween/properties.d.ts +1 -1
  68. package/dist/types/effects/tween/toggle.d.ts +6 -0
  69. package/dist/types/notes/effects.d.ts +1 -0
  70. package/dist/types/notes/index.d.ts +11 -0
  71. package/dist/types/notes/showcase.d.ts +1 -0
  72. package/dist/types/showcase/lightbox-flight.d.ts +11 -0
  73. package/dist/types/showcase/modal-shell.d.ts +5 -0
  74. package/package.json +1 -1
@@ -2,12 +2,15 @@ import {
2
2
  ALL_TIMING_TOKENS,
3
3
  ATTR,
4
4
  BREAKPOINT_NAMES,
5
+ EASING_KEYWORDS,
5
6
  KUI_EVENT,
6
7
  Registry,
7
8
  SEGMENT_HOIST_KEYS,
9
+ applyStagger,
8
10
  applyToggleVerb,
9
11
  assignOnce,
10
12
  breakpointsIn,
13
+ claimTargetGroupHost,
11
14
  control,
12
15
  createActivationBinder,
13
16
  createCssInstance,
@@ -15,15 +18,18 @@ import {
15
18
  createRootResolver,
16
19
  createScrollScheduler,
17
20
  cssEasingValue,
21
+ customEasing,
18
22
  decimalNumber,
19
23
  directionValue,
24
+ elementStaggerKeys,
20
25
  emitLifecycle,
21
26
  gateMatches,
22
27
  gatedAnimationName,
23
28
  gatesOverlap,
29
+ indexTargetGroup,
30
+ isGroupedKeys,
24
31
  isInfiniteRepeat,
25
32
  isOneShot,
26
- isSafeCssValue,
27
33
  parse,
28
34
  parseActivationAttribute,
29
35
  parseToggleActions,
@@ -32,12 +38,15 @@ import {
32
38
  queryScoped,
33
39
  readEffectParams,
34
40
  readEffectTiming,
41
+ releaseStagger,
35
42
  repeatCount,
36
43
  resolveActivationSpec,
37
44
  resolveParams,
38
45
  resolvePlayback,
46
+ restageAfterRemoval,
47
+ restageAround,
39
48
  selectorBreadth,
40
- splitTopLevel,
49
+ staggerKeysFor,
41
50
  startKindOf,
42
51
  suggest,
43
52
  timingContractOf,
@@ -46,10 +55,10 @@ import {
46
55
  validate,
47
56
  warnAboutActivation,
48
57
  warnAboutToggleActions
49
- } from "./chunk-FASAEQDR.mjs";
58
+ } from "./chunk-7NW4OLOC.mjs";
50
59
  import {
51
60
  createLedgerSet
52
- } from "./chunk-AEQGC2KM.mjs";
61
+ } from "./chunk-EDFJTT5B.mjs";
53
62
 
54
63
  // src/core/bundles.ts
55
64
  var HOIST_KEYS = ["activation", "timeline", "threshold", "rm", "func"];
@@ -349,12 +358,17 @@ var CHANNEL_COMPOSITION = {
349
358
  function additiveChannels(channels) {
350
359
  return channels.length > 0 && channels.every((channel) => CHANNEL_COMPOSITION[channel] === "add");
351
360
  }
361
+ function contestsChannel(a, b, contested) {
362
+ return gatesOverlap(a.gate, b.gate) && !independentPhases(a, b) && a.channels.some((channel) => contested.has(channel) && b.channels.includes(channel));
363
+ }
352
364
  function additiveResolution(claims, conflicts) {
353
365
  if (conflicts.some((conflict) => conflict.effects[0] === conflict.effects[1])) return void 0;
354
366
  const contested = new Set(conflicts.map((conflict) => conflict.channel));
355
367
  const involved = /* @__PURE__ */ new Set();
356
- claims.forEach((claim2, index) => {
357
- if (claim2.channels.some((channel) => contested.has(channel))) involved.add(index);
368
+ claims.forEach((claim, index) => {
369
+ if (claims.some(
370
+ (other, otherIndex) => otherIndex !== index && contestsChannel(claim, other, contested)
371
+ )) involved.add(index);
358
372
  });
359
373
  for (const index of involved) if (!claims[index].additive) return void 0;
360
374
  return involved;
@@ -362,29 +376,29 @@ function additiveResolution(claims, conflicts) {
362
376
  function findConflicts(claims) {
363
377
  const conflicts = [];
364
378
  const seen = /* @__PURE__ */ new Map();
365
- for (const claim2 of claims) {
366
- for (const channel of claim2.channels) {
379
+ for (const claim of claims) {
380
+ for (const channel of claim.channels) {
367
381
  const claimants = seen.get(channel) ?? [];
368
382
  const clash = claimants.find(
369
383
  // Same effect name twice in one list claims the channel against itself; still a conflict,
370
384
  // and a more likely author typo than a deliberate choice. Phase cannot exempt that pair
371
385
  // either, because a phase is only ever independent of a *different* one.
372
- (other) => gatesOverlap(other.gate, claim2.gate) && !independentPhases(other, claim2)
386
+ (other) => gatesOverlap(other.gate, claim.gate) && !independentPhases(other, claim)
373
387
  );
374
- if (clash) conflicts.push({ channel, effects: [clash.name, claim2.name] });
375
- claimants.push(claim2);
388
+ if (clash) conflicts.push({ channel, effects: [clash.name, claim.name] });
389
+ claimants.push(claim);
376
390
  seen.set(channel, claimants);
377
391
  }
378
392
  }
379
393
  return conflicts;
380
394
  }
381
395
  function deliveryClobbers(claims) {
382
- const stylesheet = claims.filter((claim2) => claim2.delivery === "stylesheet-animation");
396
+ const stylesheet = claims.filter((claim) => claim.delivery === "stylesheet-animation");
383
397
  if (stylesheet.length === 0) return [];
384
- const inline = claims.find((claim2) => claim2.inlineAnimation && !claim2.delivery);
398
+ const inline = claims.find((claim) => claim.inlineAnimation && !claim.delivery);
385
399
  if (!inline) return [];
386
400
  return stylesheet.map(
387
- (claim2) => `"${inline.name}" writes an inline animation, which outranks the stylesheet rule "${claim2.name}" delivers its motion from`
401
+ (claim) => `"${inline.name}" writes an inline animation, which outranks the stylesheet rule "${claim.name}" delivers its motion from`
388
402
  );
389
403
  }
390
404
  function describeConflicts(conflicts) {
@@ -589,7 +603,7 @@ function pushTrack(tracks, entry, step) {
589
603
  function pushTransitions(segments, owners, entry, warnings) {
590
604
  const { spec, resolved } = entry;
591
605
  const { preset, primitive } = resolved;
592
- for (const segment of preset.transitions ?? []) {
606
+ for (const segment of [...preset.transitions ?? [], ...entry.variant?.transitions ?? []]) {
593
607
  const previousOwner = owners.get(segment.property);
594
608
  if (previousOwner !== void 0 && previousOwner !== preset.name) {
595
609
  warnings.push(
@@ -664,10 +678,19 @@ function resolveConfig(attributes, parsed) {
664
678
  // `actions:` refines `on:` and has only the inline spelling.
665
679
  ...parsed.actions === void 0 ? {} : { actions: parseToggleActions(parsed.actions) },
666
680
  timeline: TIMELINES.has(head) ? head : "time",
667
- range: rest.join(" "),
681
+ ...timelineOptions(rest),
668
682
  threshold: parsed.threshold ?? attributes.threshold ?? "0%"
669
683
  };
670
684
  }
685
+ function timelineOptions(tokens) {
686
+ const timelineAxis = /^(block|inline|x|y)$/.test(tokens[0] ?? "") ? tokens.shift() : void 0;
687
+ const timelineName = /^--[\w-]+$/.test(tokens[0] ?? "") ? tokens.shift() : void 0;
688
+ return {
689
+ range: tokens.join(" "),
690
+ ...timelineAxis ? { timelineAxis } : {},
691
+ ...timelineName ? { timelineName } : {}
692
+ };
693
+ }
671
694
  function resolveTimelineHead(raw, fallback) {
672
695
  if (raw === void 0) return fallback;
673
696
  const [head] = raw.trim().split(/\s+/);
@@ -685,7 +708,9 @@ function resolveGroupConfig(base, hoists) {
685
708
  if (hoists.timeline !== void 0) {
686
709
  const [head = "time", ...rest] = hoists.timeline.trim().split(/\s+/);
687
710
  config.timeline = TIMELINES.has(head) ? head : base.timeline;
688
- config.range = rest.join(" ");
711
+ delete config.timelineAxis;
712
+ delete config.timelineName;
713
+ Object.assign(config, timelineOptions(rest));
689
714
  }
690
715
  if (hoists.threshold !== void 0) config.threshold = hoists.threshold;
691
716
  return config;
@@ -701,9 +726,9 @@ function sourceFromLonghand({
701
726
  // src/core/host-facts.ts
702
727
  var RM_RANK = { shorten: 0, crossfade: 1, disable: 2 };
703
728
  function resolveDefaultActivation(claims) {
704
- const declared = claims.map((claim2) => claim2.defaultActivation);
729
+ const declared = claims.map((claim) => claim.defaultActivation);
705
730
  const firstWins = declared.find((value) => value !== void 0);
706
- const entrance = claims.findIndex((claim2) => claim2.phase === "entrance");
731
+ const entrance = claims.findIndex((claim) => claim.phase === "entrance");
707
732
  if (firstWins === void 0 || entrance === -1) return firstWins;
708
733
  return declared[entrance] ?? "enter";
709
734
  }
@@ -1037,7 +1062,7 @@ function buildPlan(entries, timeline, unknown, warnings) {
1037
1062
  const { preset, primitive } = entry.resolved;
1038
1063
  const step = entry.step;
1039
1064
  plan.fxNames.push(preset.name);
1040
- plan.reducedMotion = strictestPolicy(plan.reducedMotion, primitive.reducedMotion);
1065
+ plan.reducedMotion = strictestPolicy(plan.reducedMotion, entry.variant?.reducedMotion ?? primitive.reducedMotion);
1041
1066
  activations = intersect(activations, primitive.supportedActivations);
1042
1067
  plan.activationClaims.push({
1043
1068
  supported: primitive.supportedActivations,
@@ -1051,7 +1076,7 @@ function buildPlan(entries, timeline, unknown, warnings) {
1051
1076
  resolveParams(authoredParams(entry), schemaFor(entry), (m) => warnings.push(m))
1052
1077
  );
1053
1078
  if (primitive.renderer === "css-keyframes") pushTrack(tracks, entry, step);
1054
- else plan.jsEffects.push(positioned(entry, step));
1079
+ if (primitive.renderer !== "css-keyframes" || entry.variant?.prepare) plan.jsEffects.push(positioned(entry, step));
1055
1080
  pushTransitions(transitionSegments, transitionOwners, entry, warnings);
1056
1081
  }
1057
1082
  Object.assign(plan.declarations, declarationsFor(tracks, timeline));
@@ -1235,7 +1260,7 @@ function planStyles(input) {
1235
1260
  }
1236
1261
  function timelineMode(plan, config, capabilities) {
1237
1262
  const scrubbed = config.timeline === "pin" && plan.supportedTimelines.includes("pin");
1238
- const useNativeTimeline = !scrubbed && supportsTimeline(config.timeline, capabilities) && plan.supportedTimelines.includes(config.timeline);
1263
+ const useNativeTimeline = !scrubbed && supportsTimeline(config.timeline, capabilities) && (!config.timelineName || capabilities.scrollTimelineName) && plan.supportedTimelines.includes(config.timeline);
1239
1264
  return { scrubbed, useNativeTimeline };
1240
1265
  }
1241
1266
  function transitionProperty(plan) {
@@ -1244,7 +1269,7 @@ function transitionProperty(plan) {
1244
1269
  function timelineProperties(config, capabilities, useNativeTimeline) {
1245
1270
  if (!useNativeTimeline) return {};
1246
1271
  const properties = {
1247
- "animation-timeline": config.timeline === "scroll" ? "scroll()" : "view()"
1272
+ "animation-timeline": config.timelineName ?? `${config.timeline}(${config.timelineAxis ?? ""})`
1248
1273
  };
1249
1274
  if (capabilities.animationRange) {
1250
1275
  properties["animation-range"] = config.range || (config.timeline === "scroll" ? "0% 100%" : "entry 0% cover 60%");
@@ -1275,41 +1300,6 @@ function effectiveActivation(config) {
1275
1300
  return config.activation;
1276
1301
  }
1277
1302
 
1278
- // src/core/stagger-keys.ts
1279
- var GROUP_KEY_NAMES = ["cascade", "spread", "order", "cols", "along"];
1280
- function collectKeys(lookup) {
1281
- const keys = {};
1282
- for (const name of GROUP_KEY_NAMES) {
1283
- const value = lookup(name);
1284
- if (value !== void 0) keys[name] = value;
1285
- }
1286
- return Object.keys(keys).length > 0 ? keys : void 0;
1287
- }
1288
- function elementStaggerKeys(parsed) {
1289
- return collectKeys((name) => parsed[name]);
1290
- }
1291
- function staggerKeysFor(scoped, elementWide) {
1292
- return collectKeys((name) => scoped?.[name] ?? elementWide?.[name]);
1293
- }
1294
- function isGroupedKeys(keys) {
1295
- return keys?.cascade !== void 0 || keys?.spread !== void 0 || keys?.order !== void 0;
1296
- }
1297
- var TARGET_GROUP_HOSTS = /* @__PURE__ */ new WeakMap();
1298
- function claimTargetGroupHost(host) {
1299
- TARGET_GROUP_HOSTS.set(host, (TARGET_GROUP_HOSTS.get(host) ?? 0) + 1);
1300
- let released = false;
1301
- return () => {
1302
- if (released) return;
1303
- released = true;
1304
- const remaining = TARGET_GROUP_HOSTS.get(host) - 1;
1305
- if (remaining > 0) TARGET_GROUP_HOSTS.set(host, remaining);
1306
- else TARGET_GROUP_HOSTS.delete(host);
1307
- };
1308
- }
1309
- function isTargetGroupHost(el) {
1310
- return TARGET_GROUP_HOSTS.has(el);
1311
- }
1312
-
1313
1303
  // src/core/derived/group-gate.ts
1314
1304
  function groupGateOwner(port, context, target) {
1315
1305
  const keys = staggerKeysFor(target.hoists, elementStaggerKeys(context.parsed));
@@ -1358,415 +1348,6 @@ function bindGroups(port, host) {
1358
1348
  }
1359
1349
  }
1360
1350
 
1361
- // src/core/stagger-config.ts
1362
- var FROM_KEYWORDS = /* @__PURE__ */ new Set(["start", "end", "center", "edges", "random"]);
1363
- var ORDER_KEYS = /* @__PURE__ */ new Set(["from", "order"]);
1364
- var SPREAD_KEY = "spread";
1365
- var COLS_KEY = "cols";
1366
- var AXIS_KEYS = /* @__PURE__ */ new Set(["axis", "along"]);
1367
- var AXIS_VALUES = /* @__PURE__ */ new Set(["x", "y"]);
1368
- var ORIGIN_RE = /^(\d+(?:\.\d+)?|\.\d+)\/(\d+(?:\.\d+)?|\.\d+)$/;
1369
- var COLS_RE = /^\d{1,9}$/;
1370
- var PAIR_RE = /^([a-zA-Z-]+):(.*)$/;
1371
- var INDEX_RE = /^-?\d{1,9}$/;
1372
- function parseStaggerTokens(value, warnings) {
1373
- const config = { from: "start" };
1374
- const seen = { from: false, spread: false, cols: false, along: false };
1375
- for (const token of splitTopLevel(value, " ", warnings)) {
1376
- const pair = PAIR_RE.exec(token);
1377
- if (pair) applyStaggerPair(pair[1], pair[2], { config, seen, warnings });
1378
- else config.step = keepFirstStep(config.step, token, warnings);
1379
- }
1380
- return { config, sawFrom: seen.from };
1381
- }
1382
- function applyStaggerPair(key, raw, state) {
1383
- const slot = slotFor(key);
1384
- if (slot === void 0) {
1385
- state.warnings.push(
1386
- `unrecognised key "${key}" in data-kui-stagger \u2014 expected a time step, "spread:", "cols:", "along:", "from:" or "order:"`
1387
- );
1388
- return;
1389
- }
1390
- if (claim(slot, raw, state, key)) ASSIGN[slot](raw, state, key);
1391
- }
1392
- function slotFor(key) {
1393
- if (key === SPREAD_KEY) return "spread";
1394
- if (key === COLS_KEY) return "cols";
1395
- if (AXIS_KEYS.has(key)) return "along";
1396
- if (ORDER_KEYS.has(key)) return "from";
1397
- return void 0;
1398
- }
1399
- var ASSIGN = {
1400
- spread: (raw, state) => {
1401
- state.config.spread = raw.trim();
1402
- },
1403
- cols: (raw, state) => {
1404
- state.config.cols = parseCols(raw, state.warnings);
1405
- },
1406
- along: (raw, state, key) => {
1407
- state.config.along = parseAxis(raw, state.warnings, key);
1408
- },
1409
- from: (raw, state, key) => {
1410
- state.config.from = parseFrom(raw, state.warnings, key);
1411
- }
1412
- };
1413
- function claim(slot, raw, state, spelling) {
1414
- if (state.seen[slot]) {
1415
- state.warnings.push(`duplicate "${spelling}:" in data-kui-stagger \u2014 "${raw}" ignored`);
1416
- return false;
1417
- }
1418
- state.seen[slot] = true;
1419
- return true;
1420
- }
1421
- function parseCols(raw, warnings) {
1422
- const value = raw.trim();
1423
- if (value === "auto") return "auto";
1424
- if (COLS_RE.test(value) && Number(value) > 0) return Number(value);
1425
- warnings.push(`unrecognised "cols:${raw}" \u2014 expected a column count or "auto"`);
1426
- return void 0;
1427
- }
1428
- function parseAxis(raw, warnings, key) {
1429
- const value = raw.trim();
1430
- if (AXIS_VALUES.has(value)) return value;
1431
- warnings.push(`unrecognised "${key}:${raw}" \u2014 expected x or y`);
1432
- return void 0;
1433
- }
1434
- function resolveStaggerConfig(attribute, source, warnings = []) {
1435
- const inline = inlineGroupKeys(source);
1436
- if (attribute === null && inline === void 0) return void 0;
1437
- return resolveStaggerConfigFrom(attribute, inline, warnings);
1438
- }
1439
- function resolveStaggerConfigFrom(attribute, inline, warnings = []) {
1440
- if (attribute === null && inline === void 0) return void 0;
1441
- const { config: longhand, sawFrom } = parseStaggerTokens(attribute ?? "", warnings);
1442
- return oneStepMode(screenStep(mergeInline(longhand, sawFrom, inline ?? {}, warnings), warnings), warnings);
1443
- }
1444
- function oneStepMode(config, warnings) {
1445
- if (config.spread === void 0 || config.step === void 0) return config;
1446
- warnings.push(
1447
- `stagger step "${config.step}" is ignored \u2014 "spread:${config.spread}" already budgets the whole group, and the step is what it divides out`
1448
- );
1449
- const budgeted = { ...config };
1450
- delete budgeted.step;
1451
- return budgeted;
1452
- }
1453
- function inlineGroupKeys(source) {
1454
- if (!hasGroupKey(source)) return void 0;
1455
- const { cascade, spread, order, cols, along } = parse(source);
1456
- const keys = { cascade, spread, order, cols, along };
1457
- return Object.values(keys).some((value) => value !== void 0) ? keys : void 0;
1458
- }
1459
- function screenStep(config, warnings) {
1460
- const screened = { ...config };
1461
- if (!keepValue("step", config.step, warnings)) delete screened.step;
1462
- if (!keepValue("spread", config.spread, warnings)) delete screened.spread;
1463
- return screened;
1464
- }
1465
- function keepValue(label, value, warnings) {
1466
- if (value === void 0) return false;
1467
- if (isSafeCssValue(value)) return true;
1468
- warnings.push(`stagger ${label} "${value}" contains disallowed CSS syntax \u2014 ignored`);
1469
- return false;
1470
- }
1471
- function mergeInline(longhand, sawFrom, inline, warnings) {
1472
- const config = { ...longhand };
1473
- if (inline.cascade !== void 0) {
1474
- warnOverride("stagger step", longhand.step, inline.cascade, warnings);
1475
- config.step = inline.cascade;
1476
- }
1477
- if (inline.spread !== void 0) {
1478
- warnOverride("stagger budget", longhand.spread, inline.spread, warnings);
1479
- config.spread = inline.spread;
1480
- }
1481
- mergeInlineGrid(config, longhand, inline, warnings);
1482
- if (inline.order !== void 0) {
1483
- const order = parseFrom(inline.order, warnings, "order");
1484
- warnOverride("stagger order", sawFrom ? longhand.from : void 0, order, warnings);
1485
- config.from = order;
1486
- }
1487
- return config;
1488
- }
1489
- function mergeInlineGrid(config, longhand, inline, warnings) {
1490
- if (inline.cols !== void 0) {
1491
- const cols = parseCols(inline.cols, warnings);
1492
- warnOverride("stagger columns", longhand.cols, cols, warnings);
1493
- if (cols !== void 0) config.cols = cols;
1494
- }
1495
- if (inline.along !== void 0) {
1496
- const along = parseAxis(inline.along, warnings, "along");
1497
- warnOverride("stagger axis", longhand.along, along, warnings);
1498
- if (along !== void 0) config.along = along;
1499
- }
1500
- }
1501
- function hasGroupKey(source) {
1502
- return GROUP_KEY_PREFIXES.some((prefix) => source.includes(prefix));
1503
- }
1504
- var GROUP_KEY_PREFIXES = [
1505
- "cascade:",
1506
- "spread:",
1507
- "order:",
1508
- "cols:",
1509
- "along:"
1510
- ];
1511
- function warnOverride(label, previous, next, warnings) {
1512
- if (previous === void 0 || next === void 0 || previous === next) return;
1513
- warnings.push(
1514
- `conflicting ${label}: data-kui-stagger says "${String(previous)}", data-kui says "${String(next)}" \u2014 data-kui wins`
1515
- );
1516
- }
1517
- function keepFirstStep(current, token, warnings) {
1518
- if (current === void 0) return token;
1519
- warnings.push(`extra token "${token}" in data-kui-stagger (expected one time step)`);
1520
- return current;
1521
- }
1522
- function parseFrom(raw, warnings, key = "from") {
1523
- const value = raw.trim();
1524
- if (FROM_KEYWORDS.has(value)) return value;
1525
- if (INDEX_RE.test(value)) return Number(value);
1526
- const origin = ORIGIN_RE.exec(value);
1527
- if (origin) return { x: clamp01(Number(origin[1]), value, warnings), y: clamp01(Number(origin[2]), value, warnings) };
1528
- warnings.push(
1529
- `unrecognised "${key}:${raw}" \u2014 expected start, end, center, edges, random, a child index, or an "x/y" point in a grid`
1530
- );
1531
- return "start";
1532
- }
1533
- function clamp01(value, source, warnings) {
1534
- if (value >= 0 && value <= 1) return value;
1535
- warnings.push(`stagger order "${source}" is outside the grid (0 to 1 on each axis) \u2014 clamped`);
1536
- return Math.min(Math.max(value, 0), 1);
1537
- }
1538
-
1539
- // src/core/stagger.ts
1540
- var RANK_PRECISION = 1e3;
1541
- var RANDOM_SALT = 2654435761;
1542
- var COUNT_SALT = 2246822507;
1543
- var MIX_A = 569420461;
1544
- var MIX_B = 1935289751;
1545
- function resolveStep(config, maxRank) {
1546
- if (config.spread === void 0) return config.step;
1547
- if (maxRank <= 0) return "0ms";
1548
- return `calc((${config.spread}) / ${String(maxRank)})`;
1549
- }
1550
- function staggerRanks(count, from, warnings = [], layout) {
1551
- if (count <= 0) return [];
1552
- if (from === "random") return randomRanks(count);
1553
- if (layout) return gridRanks(count, from, layout, warnings);
1554
- if (typeof from === "object") {
1555
- warnings.push(
1556
- `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`
1557
- );
1558
- return staggerRanks(count, "start", warnings);
1559
- }
1560
- const last = count - 1;
1561
- if (from === "edges") {
1562
- return Array.from({ length: count }, (_, index) => Math.min(index, last - index));
1563
- }
1564
- const origin = originOf(from, last, warnings);
1565
- return Array.from({ length: count }, (_, index) => Math.floor(Math.abs(index - origin)));
1566
- }
1567
- function originOf(from, last, warnings) {
1568
- if (from === "start") return 0;
1569
- if (from === "end") return last;
1570
- if (from === "center") return last / 2;
1571
- return clampIndex(from, last, warnings);
1572
- }
1573
- function clampIndex(index, last, warnings) {
1574
- if (index < 0 || index > last) {
1575
- warnings.push(`stagger order "${String(index)}" is outside the group (0 to ${String(last)}) \u2014 clamped`);
1576
- }
1577
- return Math.min(Math.max(index, 0), last);
1578
- }
1579
- function gridRanks(count, from, layout, warnings) {
1580
- const cols = Math.min(Math.max(1, layout.cols), count);
1581
- const rows = Math.ceil(count / cols);
1582
- if (from === "edges") {
1583
- const inward = gridRanks(count, "center", layout, warnings);
1584
- let furthest = 0;
1585
- for (const rank of inward) furthest = Math.max(furthest, rank);
1586
- return inward.map((rank) => round(furthest - rank));
1587
- }
1588
- const origin = gridOrigin(from, { cols, rows, last: count - 1 }, warnings);
1589
- return Array.from({ length: count }, (_, index) => {
1590
- const dx = index % cols - origin.x;
1591
- const dy = Math.floor(index / cols) - origin.y;
1592
- if (layout.along === "x") return round(Math.abs(dx));
1593
- if (layout.along === "y") return round(Math.abs(dy));
1594
- return round(Math.hypot(dx, dy));
1595
- });
1596
- }
1597
- function gridOrigin(from, grid, warnings) {
1598
- const { cols, rows, last } = grid;
1599
- if (typeof from === "object") return { x: from.x * (cols - 1), y: from.y * (rows - 1) };
1600
- if (from === "start") return { x: 0, y: 0 };
1601
- if (from === "end") return { x: cols - 1, y: rows - 1 };
1602
- if (from === "center") return { x: (cols - 1) / 2, y: (rows - 1) / 2 };
1603
- const index = clampIndex(from, last, warnings);
1604
- return { x: index % cols, y: Math.floor(index / cols) };
1605
- }
1606
- function round(value) {
1607
- return Math.round(value * RANK_PRECISION) / RANK_PRECISION;
1608
- }
1609
- function randomRanks(count) {
1610
- const order = Array.from({ length: count }, (_, index) => index);
1611
- order.sort((a, b) => scatterKey(a, count) - scatterKey(b, count));
1612
- const ranks = new Array(count);
1613
- for (const [rank, index] of order.entries()) ranks[index] = rank;
1614
- return ranks;
1615
- }
1616
- function scatterKey(index, count) {
1617
- let hash = (Math.imul(index, RANDOM_SALT) ^ Math.imul(count, COUNT_SALT)) >>> 0;
1618
- hash ^= hash >>> 16;
1619
- hash = Math.imul(hash, MIX_A) >>> 0;
1620
- hash ^= hash >>> 15;
1621
- hash = Math.imul(hash, MIX_B) >>> 0;
1622
- hash ^= hash >>> 15;
1623
- return hash >>> 0;
1624
- }
1625
- function indexStaggerGroup(group, reporter) {
1626
- const warnings = [];
1627
- const ledgers = reopenLedger(group);
1628
- const config = resolveStaggerConfig(
1629
- group.getAttribute(ATTR.stagger),
1630
- group.getAttribute(ATTR.source) ?? "",
1631
- warnings
1632
- ) ?? { from: "start" };
1633
- const children = animatedChildren(group);
1634
- const ranks = staggerRanks(children.length, config.from, warnings, resolveLayout(config, children, warnings));
1635
- let maxRank = 0;
1636
- for (const [index, child] of children.entries()) {
1637
- const rank = ranks[index];
1638
- ledgers.style(child).set("--kui-i", String(rank));
1639
- GROUP_OF_CHILD.set(child, group);
1640
- if (rank > maxRank) maxRank = rank;
1641
- }
1642
- const step = resolveStep(config, maxRank);
1643
- if (step) ledgers.style(group).set("--kui-stagger", step);
1644
- ledgers.style(group).set("--kui-stagger-count", String(round(maxRank + 1)));
1645
- for (const warning of warnings) reporter?.warn(warning, group);
1646
- }
1647
- var GROUP_LEDGERS = /* @__PURE__ */ new WeakMap();
1648
- var GROUP_OF_CHILD = /* @__PURE__ */ new WeakMap();
1649
- function restageAfterRemoval(removed, reporter) {
1650
- const groups = /* @__PURE__ */ new Set();
1651
- for (const el of removed) {
1652
- const group = GROUP_OF_CHILD.get(el);
1653
- if (group) groups.add(group);
1654
- }
1655
- for (const group of groups) indexStaggerGroup(group, reporter);
1656
- }
1657
- function reopenLedger(group) {
1658
- GROUP_LEDGERS.get(group)?.restore();
1659
- const ledgers = createLedgerSet(group);
1660
- GROUP_LEDGERS.set(group, ledgers);
1661
- return ledgers;
1662
- }
1663
- function releaseStaggerGroup(group) {
1664
- GROUP_LEDGERS.get(group)?.restore();
1665
- GROUP_LEDGERS.delete(group);
1666
- }
1667
- function releaseStagger(root) {
1668
- const selector = `[${ATTR.stagger}], [${ATTR.source}]`;
1669
- if (root instanceof Element && root.matches(selector)) releaseStaggerGroup(root);
1670
- for (const el of root.querySelectorAll(selector)) releaseStaggerGroup(el);
1671
- }
1672
- function restageAround(el, reporter) {
1673
- restageOne(el, reporter);
1674
- const parent = el.parentElement;
1675
- if (parent) restageOne(parent, reporter);
1676
- }
1677
- function restageOne(el, reporter) {
1678
- if (declaresGroup(el)) indexStaggerGroup(el, reporter);
1679
- else releaseStaggerGroup(el);
1680
- }
1681
- function indexTargetGroup(request) {
1682
- const { host, matches, styleOf, keys, reporter } = request;
1683
- const warnings = [];
1684
- const attribute = host.getAttribute(ATTR.stagger);
1685
- const config = (keys ? resolveStaggerConfigFrom(attribute, keys, warnings) : resolveStaggerConfig(attribute, host.getAttribute(ATTR.source) ?? "", warnings)) ?? { from: "start" };
1686
- const maxRank = rankBuckets(bucketByParent(matches), config, styleOf, warnings);
1687
- const step = resolveStep(config, maxRank);
1688
- if (step) styleOf(host).set("--kui-stagger", step);
1689
- styleOf(host).set("--kui-stagger-count", String(round(maxRank + 1)));
1690
- for (const warning of warnings) reporter?.warn(warning, host);
1691
- }
1692
- function bucketByParent(matches) {
1693
- const byParent = /* @__PURE__ */ new Map();
1694
- for (const match of matches) {
1695
- const siblings = byParent.get(match.parentElement);
1696
- if (siblings) siblings.push(match);
1697
- else byParent.set(match.parentElement, [match]);
1698
- }
1699
- return byParent;
1700
- }
1701
- function rankBuckets(byParent, config, styleOf, warnings) {
1702
- let maxRank = 0;
1703
- for (const siblings of byParent.values()) {
1704
- const layout = resolveLayout(config, siblings, warnings);
1705
- const ranks = staggerRanks(siblings.length, config.from, warnings, layout);
1706
- for (const [index, match] of siblings.entries()) {
1707
- const rank = ranks[index];
1708
- styleOf(match).set("--kui-i", String(rank));
1709
- if (rank > maxRank) maxRank = rank;
1710
- }
1711
- }
1712
- return maxRank;
1713
- }
1714
- function resolveLayout(config, members, warnings) {
1715
- if (config.cols === void 0) {
1716
- if (config.along !== void 0) {
1717
- warnings.push(
1718
- `"along:${config.along}" names an axis of a grid this group has not declared \u2014 add "cols:" (a column count, or "auto")`
1719
- );
1720
- }
1721
- return void 0;
1722
- }
1723
- const cols = config.cols === "auto" ? measureColumns(members, warnings) : config.cols;
1724
- if (cols === void 0) return void 0;
1725
- return config.along === void 0 ? { cols } : { cols, along: config.along };
1726
- }
1727
- function measureColumns(members, warnings) {
1728
- if (members.length < 2) return 1;
1729
- const lefts = [];
1730
- let laidOut = false;
1731
- for (const member of members) {
1732
- const box = member.getBoundingClientRect();
1733
- if (box.width !== 0 || box.height !== 0) laidOut = true;
1734
- lefts.push(box.left);
1735
- }
1736
- if (!laidOut) {
1737
- warnings.push(
1738
- `"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`
1739
- );
1740
- return void 0;
1741
- }
1742
- const direction = Math.sign(lefts[1] - lefts[0]);
1743
- if (direction === 0) return 1;
1744
- let cols = 1;
1745
- for (let index = 1; index < lefts.length; index++) {
1746
- if (Math.sign(lefts[index] - lefts[index - 1]) !== direction) break;
1747
- cols = index + 1;
1748
- }
1749
- return cols;
1750
- }
1751
- function animatedChildren(group) {
1752
- const children = [];
1753
- for (const child of group.children) {
1754
- if (child.hasAttribute(ATTR.source)) children.push(child);
1755
- }
1756
- return children;
1757
- }
1758
- function applyStagger(root, reporter) {
1759
- const selector = `[${ATTR.stagger}], [${ATTR.source}]`;
1760
- if (root instanceof Element && root.matches(selector)) restageOne(root, reporter);
1761
- for (const group of root.querySelectorAll(selector)) restageOne(group, reporter);
1762
- }
1763
- function declaresGroup(el) {
1764
- if (el.hasAttribute(ATTR.define)) return false;
1765
- if (isTargetGroupHost(el)) return false;
1766
- if (el.hasAttribute(ATTR.stagger)) return true;
1767
- return resolveStaggerConfig(null, el.getAttribute(ATTR.source) ?? "") !== void 0;
1768
- }
1769
-
1770
1351
  // src/core/derived/diagnostics.ts
1771
1352
  var ANCESTOR_WALK_BOUND = 64;
1772
1353
  function describe(el) {
@@ -2009,35 +1590,35 @@ function matchGateOwner(port, context, targets) {
2009
1590
  const grouped = targets.some((target) => groupGateOwner(port, context, target) !== void 0);
2010
1591
  return grouped ? context.host : void 0;
2011
1592
  }
2012
- function recordClaim(port, context, claim2) {
1593
+ function recordClaim(port, context, claim) {
2013
1594
  const { book } = port;
2014
- book.hosts.set(claim2.match, context.host);
1595
+ book.hosts.set(claim.match, context.host);
2015
1596
  const derived = book.derived.get(context.host) ?? /* @__PURE__ */ new Set();
2016
- derived.add(claim2.match);
1597
+ derived.add(claim.match);
2017
1598
  book.derived.set(context.host, derived);
2018
1599
  const live = book.groups.get(context.host) ?? [];
2019
- for (const target of claim2.targets) {
2020
- live.find((group) => group.target === target)?.members.push(claim2.match);
1600
+ for (const target of claim.targets) {
1601
+ live.find((group) => group.target === target)?.members.push(claim.match);
2021
1602
  }
2022
1603
  }
2023
- function installClaim(port, context, claim2) {
1604
+ function installClaim(port, context, claim) {
2024
1605
  port.install({
2025
- el: claim2.match,
2026
- fingerprint: `${context.fingerprint}\0${matchKey(claim2.targets)}`,
2027
- parsed: { specs: claim2.target.specs, warnings: [] },
2028
- config: claim2.config,
2029
- document: { targets: [{ ...claim2.target, selector: "", scope: "self" }], warnings: [] },
1606
+ el: claim.match,
1607
+ fingerprint: `${context.fingerprint}\0${matchKey(claim.targets)}`,
1608
+ parsed: { specs: claim.target.specs, warnings: [] },
1609
+ config: claim.config,
1610
+ document: { targets: [{ ...claim.target, selector: "", scope: "self" }], warnings: [] },
2030
1611
  host: context.host,
2031
- gateOwner: matchGateOwner(port, context, claim2.targets)
1612
+ gateOwner: matchGateOwner(port, context, claim.targets)
2032
1613
  });
2033
- recordClaim(port, context, claim2);
1614
+ recordClaim(port, context, claim);
2034
1615
  }
2035
1616
  function installDerivedMatches(port, context, claims, cache = /* @__PURE__ */ new Map()) {
2036
1617
  const installed = [];
2037
1618
  for (const [match, targets] of claims) {
2038
- const claim2 = resolveClaim(port, context, { match, targets }, cache);
2039
- installClaim(port, context, claim2);
2040
- installed.push(claim2.match);
1619
+ const claim = resolveClaim(port, context, { match, targets }, cache);
1620
+ installClaim(port, context, claim);
1621
+ installed.push(claim.match);
2041
1622
  }
2042
1623
  return installed;
2043
1624
  }
@@ -2226,10 +1807,11 @@ function sequencedTiming(entry, warn) {
2226
1807
  }
2227
1808
  function createJsEffectPreparer(options) {
2228
1809
  const { scheduler, rootResolver, capabilities, reporter, respectReducedMotion } = options;
2229
- function contextFor(el, signal, ledger) {
1810
+ function contextFor(el, { signal, ledger, timeline, cancel }) {
2230
1811
  const doc = el.ownerDocument;
2231
1812
  return {
2232
1813
  doc,
1814
+ timeline,
2233
1815
  win: doc.defaultView ?? globalThis,
2234
1816
  scheduler,
2235
1817
  rootFor: rootResolver,
@@ -2238,22 +1820,23 @@ function createJsEffectPreparer(options) {
2238
1820
  warn: (message) => reporter.warn(message, el),
2239
1821
  reducedMotion: respectReducedMotion && capabilities.reducedMotion,
2240
1822
  signal,
1823
+ cancel,
2241
1824
  style: ledger
2242
1825
  };
2243
1826
  }
2244
1827
  return {
2245
- prepare({ el, plan, signal, ledger }) {
1828
+ prepare({ el, plan, signal, ledger, timeline = "time", cancel }) {
2246
1829
  const instances = [];
2247
1830
  if (plan.jsEffects.length === 0) return instances;
2248
- const ctx = contextFor(el, signal, ledger);
1831
+ const ctx = contextFor(el, { signal, ledger, timeline, cancel });
2249
1832
  for (const entry of plan.jsEffects) {
2250
1833
  const { spec, resolved } = entry;
2251
- const prepare = resolved.primitive.prepare;
1834
+ const prepare = entry.variant?.prepare ?? resolved.primitive.prepare;
2252
1835
  if (!prepare) continue;
2253
1836
  const warn = (message) => reporter.warn(message, el);
2254
1837
  const params = readEffectParams(
2255
1838
  { ...resolved.preset.params, ...authoredParams(entry) },
2256
- resolved.primitive.parameters,
1839
+ schemaFor(entry),
2257
1840
  warn,
2258
1841
  sequencedTiming(entry, warn)
2259
1842
  );
@@ -2644,7 +2227,7 @@ var Animator = class {
2644
2227
  timeline: config.timeline,
2645
2228
  fxNames: document2.targets.flatMap((target) => target.plan.fxNames),
2646
2229
  jsEffectNames: document2.targets.flatMap(
2647
- (target) => target.plan.jsEffects.map((entry) => entry.spec.name)
2230
+ (target) => target.plan.jsEffects.filter((entry) => entry.resolved.primitive.renderer !== "css-keyframes").map((entry) => entry.spec.name)
2648
2231
  ),
2649
2232
  progressDriven: elementStylePlan.gate === "scrubbed" || elementStylePlan.gate === "native-timeline",
2650
2233
  instances: [],
@@ -2668,6 +2251,7 @@ var Animator = class {
2668
2251
  elementHasCssAnimation
2669
2252
  };
2670
2253
  for (const group of groups) this.installGroup(group, context);
2254
+ warnNamedEasings(el, state.specs, this.reporter);
2671
2255
  this.openGate({ el, state, stylePlan: elementStylePlan, config, plan: groups[0].target.plan });
2672
2256
  }
2673
2257
  /**
@@ -2768,10 +2352,12 @@ var Animator = class {
2768
2352
  }
2769
2353
  state.instances.push(
2770
2354
  ...this.jsEffectPreparer.prepare({
2355
+ timeline: context.config.timeline,
2771
2356
  el: match,
2772
2357
  plan: target.plan,
2773
2358
  signal: context.signal,
2774
- ledger: matchLedger
2359
+ ledger: matchLedger,
2360
+ cancel: () => this.cancel(match)
2775
2361
  })
2776
2362
  );
2777
2363
  }
@@ -2966,7 +2552,10 @@ var Animator = class {
2966
2552
  this.turnAround(el, state);
2967
2553
  return;
2968
2554
  }
2969
- if (state.status === "running") return;
2555
+ if (state.status === "running") {
2556
+ if (!state.instances.some((instance) => instance.replaceOnActivate)) return;
2557
+ this.cancelOne(el);
2558
+ }
2970
2559
  state.releaseActivation?.();
2971
2560
  state.releaseActivation = void 0;
2972
2561
  this.writeStatus(el, state, "running");
@@ -2978,9 +2567,9 @@ var Animator = class {
2978
2567
  this.syncHost(state);
2979
2568
  return;
2980
2569
  }
2570
+ this.settleWhen({ el, state, run }, started, "finished");
2981
2571
  this.emit(el, state, KUI_EVENT.start, "activated");
2982
2572
  this.syncHost(state);
2983
- this.settleWhen({ el, state, run }, started, "finished");
2984
2573
  }
2985
2574
  /**
2986
2575
  * Play an element's effects back out.
@@ -3008,8 +2597,7 @@ var Animator = class {
3008
2597
  if (!state) return;
3009
2598
  if (state.status !== "running" && state.status !== "finished") return;
3010
2599
  if (state.direction === "reverse") return;
3011
- const reversible = state.instances.filter(isDirectional);
3012
- if (reversible.length < state.instances.length) {
2600
+ if (state.instances.some((instance) => !instance.setupOnly && !isDirectional(instance))) {
3013
2601
  this.reporter.warn(
3014
2602
  "effect cannot play backwards, so the exit half of this activation does nothing for it (JS-rendered effects have no playhead \u2014 see EffectInstance.reverse)",
3015
2603
  el
@@ -3438,7 +3026,16 @@ function defaultRootResolver(root) {
3438
3026
  return createRootResolver({ win });
3439
3027
  }
3440
3028
  function isDirectional(instance) {
3441
- return instance.play !== void 0 && instance.reverse !== void 0;
3029
+ return !instance.setupOnly && instance.play !== void 0 && instance.reverse !== void 0;
3030
+ }
3031
+ function warnNamedEasings(el, specs, reporter) {
3032
+ const names = new Set(specs.flatMap((spec) => [spec.easing, spec.params.ease]));
3033
+ for (const name of names) {
3034
+ if (!name || EASING_KEYWORDS.has(name) || name.includes("(")) continue;
3035
+ if (!customEasing(name, el)) {
3036
+ reporter.warn(`easing "${name}" has no --kui-ease-${name} definition \u2014 using ease-out`, el);
3037
+ }
3038
+ }
3442
3039
  }
3443
3040
  function runQuietly(cleanup) {
3444
3041
  try {