@vectoriox/iox-ui 5.162.0 → 5.164.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 (47) hide show
  1. package/actions-core/index.d.ts +171 -3
  2. package/assist-core/index.d.ts +3 -2
  3. package/composite-core/index.d.ts +195 -3
  4. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +243 -2
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -5
  7. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +413 -163
  9. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  10. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +456 -27
  11. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  12. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +140 -1
  13. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  14. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +83 -23
  15. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  16. package/fesm2022/vectoriox-iox-ui.mjs +387 -11
  17. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  18. package/generation-core/index.d.ts +87 -12
  19. package/harness-core/index.d.ts +132 -2
  20. package/index.d.ts +108 -3
  21. package/package.json +1 -1
  22. package/scene-core/index.d.ts +45 -13
  23. package/src/actions-core/popup-arrival.ts +328 -0
  24. package/src/actions-core/public-api.ts +1 -0
  25. package/src/assist-core/media-generate.ts +6 -5
  26. package/src/composite-core/composite-kinds.ts +9 -0
  27. package/src/composite-core/popup.ts +285 -0
  28. package/src/composite-core/public-api.ts +1 -0
  29. package/src/generation-core/ai-run.ts +65 -2
  30. package/src/generation-core/check-layout.ts +34 -4
  31. package/src/generation-core/compose-layout.ts +211 -10
  32. package/src/generation-core/compose-site.ts +2 -0
  33. package/src/generation-core/layout-drawers.ts +106 -0
  34. package/src/generation-core/layout-fingerprint.ts +3 -0
  35. package/src/generation-core/layout-language.ts +4 -0
  36. package/src/generation-core/layout-space.ts +3 -2
  37. package/src/generation-core/layout-wire.ts +15 -3
  38. package/src/generation-core/patterns.ts +4 -0
  39. package/src/generation-core/pictures.ts +4 -3
  40. package/src/generation-core/site-spec.generated.ts +57 -5
  41. package/src/harness-core/business-types.ts +2 -0
  42. package/src/harness-core/harness-spec.generated.ts +83 -0
  43. package/src/harness-core/popup-stance.ts +111 -0
  44. package/src/harness-core/public-api.ts +1 -0
  45. package/src/scene-core/scene.ts +3 -0
  46. package/src/scene-core/scroll-driver.ts +97 -25
  47. package/styles/iox-design.css +141 -2
@@ -1,4 +1,6 @@
1
- import { AccordionRole, DisclosureRole, TabsRole, SegmentedRole, SLIDE_TO_ROW, CompositeItemAction } from '@vectoriox/iox-ui/composite-core';
1
+ import { AccordionRole, DisclosureRole, TabsRole, SegmentedRole, SLIDE_TO_ROW, CompositeItemAction, PopupKind, PopupTrait, POPUP_KIND_ARRIVAL, PopupArrive, POPUP_KIND_MIX, PopupAgain, popupFormOf, PopupForm } from '@vectoriox/iox-ui/composite-core';
2
+ import { CHECKOUT_PATH } from '@vectoriox/iox-ui/commerce-core';
3
+ import { ACCOUNT_PATH } from '@vectoriox/iox-ui/identity-core';
2
4
 
3
5
  /**
4
6
  * The ONE descriptor shape for everything an author can put in an ordered action list —
@@ -577,6 +579,245 @@ function revealFrom(dialog, opener) {
577
579
  }, () => { view.getComputedStyle(dialog).getPropertyValue('clip-path'); });
578
580
  }
579
581
 
582
+ /**
583
+ * WHEN A SELF-ARRIVING OVERLAY MAY SHOW (popups-plan.md §4–§5, PU-D4…PU-D9, PU-D17) — the ONE planner. The engine's runtime
584
+ * only reports state and obeys; the builder's canvas never asks it (a popup never arrives on the canvas, PU-D14).
585
+ *
586
+ * overlayTurn(state) → 'preloader' | 'consent' | 'popup:<id>' | 'none'
587
+ * 1. a first visit's preloader is showing → nothing else
588
+ * 2. the consent debt is unpaid → the banner only (a popup never opens over or before it)
589
+ * 3. any dialog, drawer, cart, sign-in or lightbox is open → wait
590
+ * 4. the route is quiet → no popup
591
+ * 5. a popup already arrived in this page view → no second one
592
+ * 6. otherwise the first DUE popup (page before global, then tree order) → its clock starts NOW
593
+ *
594
+ * A popup's clock starts when its TURN starts — `time` counts from then, `scroll` needs a scroll after it. The consent
595
+ * banner's own arrival (AW2 `arrive.delay`: the first scroll or 6 s) is planned here too (`planConsentArrival`), so every
596
+ * self-arriving overlay has one arrival rule. Memory (PU-D6/PU-D7): localStorage, no identifier, never sent — Necessary.
597
+ * Pure and framework-free: no DOM, no clock (`now` is passed in).
598
+ *
599
+ * The numbers are the contract's (layout.mjs POPUP `rules`; generation-core's popup spec holds them equal).
600
+ */
601
+ /** POPUP `rules` — mirrored, held equal to the contract by generation-core's spec. */
602
+ const POPUP_RULES = Object.freeze({
603
+ minSeconds: 3,
604
+ scrollScreens: 0.5,
605
+ timeSeconds: 8,
606
+ leavingAfterSeconds: 10,
607
+ phoneLeavingSeconds: 25,
608
+ phoneMaxHeight: 0.3,
609
+ memoryDays: 30,
610
+ reducedFadeMs: 200,
611
+ exitRatio: 0.55,
612
+ durationByAnimated: Object.freeze({ still: 200, subtle: 350, standard: 450, lively: 550, expressive: 600 }),
613
+ quietRoutes: Object.freeze(['checkout', 'order', 'account', 'sign-in', 'legal', 'not-found', 'recover', 'unsubscribe']),
614
+ });
615
+ /** AW2 (CONSENT `rules.delayMs`): the banner's `arrive.delay` — the first scroll, or this many ms. */
616
+ const CONSENT_DELAY_MS = 6000;
617
+ // ── the order ─────────────────────────────────────────────────────────────────────────────────────────────────────────
618
+ var OverlayTurnKind;
619
+ (function (OverlayTurnKind) {
620
+ OverlayTurnKind["Preloader"] = "preloader";
621
+ OverlayTurnKind["Consent"] = "consent";
622
+ OverlayTurnKind["None"] = "none";
623
+ })(OverlayTurnKind || (OverlayTurnKind = {}));
624
+ const POPUP_TURN_PREFIX = 'popup:';
625
+ /** Whose turn it is (§4b). */
626
+ function overlayTurn(state) {
627
+ if (state.preloaderShowing)
628
+ return OverlayTurnKind.Preloader;
629
+ if (state.consentOwed)
630
+ return OverlayTurnKind.Consent;
631
+ if (state.otherOverlayOpen || state.quietRoute || state.popupArrivedThisView)
632
+ return OverlayTurnKind.None;
633
+ const first = state.due[0];
634
+ return first ? `${POPUP_TURN_PREFIX}${first}` : OverlayTurnKind.None;
635
+ }
636
+ /** The popup id of a turn, or null. */
637
+ function popupOfTurn(turn) {
638
+ return turn.startsWith(POPUP_TURN_PREFIX) ? turn.slice(POPUP_TURN_PREFIX.length) : null;
639
+ }
640
+ /** The first path segments that are quiet: commerce's fixed checkout (its order, recover and unsubscribe links live under
641
+ * it) and the buyer's account (where a buyer signs in). */
642
+ const QUIET_SEGMENTS = [CHECKOUT_PATH, ACCOUNT_PATH];
643
+ /** PU-D9: a popup never arrives here. */
644
+ function isQuietRoute(route) {
645
+ if (route.legal || route.notFound)
646
+ return true;
647
+ const first = (route.path ?? '').split('?')[0].split('#')[0].split('/').filter(Boolean)[0] ?? '';
648
+ return QUIET_SEGMENTS.includes(first.toLowerCase());
649
+ }
650
+ // ── arrival ───────────────────────────────────────────────────────────────────────────────────────────────────────────
651
+ /** The trigger a planned arrival waits on. `now` = at once (the consent banner's `arrive.load`); `never` = only a button. */
652
+ var ArrivalTrigger;
653
+ (function (ArrivalTrigger) {
654
+ ArrivalTrigger["Now"] = "now";
655
+ ArrivalTrigger["Scroll"] = "scroll";
656
+ ArrivalTrigger["Time"] = "time";
657
+ ArrivalTrigger["ScrollOrTime"] = "scrollOrTime";
658
+ ArrivalTrigger["Never"] = "never";
659
+ })(ArrivalTrigger || (ArrivalTrigger = {}));
660
+ const num = (v) => {
661
+ const n = typeof v === 'number' ? v : typeof v === 'string' && v.trim() ? Number(v) : NaN;
662
+ return Number.isFinite(n) && n >= 0 ? n : null;
663
+ };
664
+ /**
665
+ * A popup's arrival from its traits (PU-D5): its kind's defaults where a trait is unset; `time` never under 3 s; `leaving`
666
+ * — until PU2b draws it — and on a phone always, arrives by time (`phoneLeavingSeconds`); `button` never arrives by itself.
667
+ */
668
+ function planPopupArrival(get, _env) {
669
+ const kind = Object.values(PopupKind).includes(String(get(PopupTrait.Kind))) ? get(PopupTrait.Kind) : PopupKind.Offer;
670
+ const defaults = POPUP_KIND_ARRIVAL[kind];
671
+ const asked = String(get(PopupTrait.Arrive) ?? '');
672
+ const arrive = Object.values(PopupArrive).includes(asked) ? asked : POPUP_KIND_MIX[kind].arrive;
673
+ const pageShare = num(get(PopupTrait.PageShare)) ?? (num(get(PopupTrait.Screens)) === null ? defaults.pageShare ?? null : null);
674
+ const screens = pageShare !== null ? null : num(get(PopupTrait.Screens)) ?? defaults.screens ?? POPUP_RULES.scrollScreens;
675
+ const seconds = (fallback) => Math.max(POPUP_RULES.minSeconds, num(get(PopupTrait.Seconds)) ?? defaults.seconds ?? fallback);
676
+ switch (arrive) {
677
+ case PopupArrive.Button: return { trigger: ArrivalTrigger.Never, screens: null, pageShare: null, seconds: null };
678
+ case PopupArrive.Scroll: return { trigger: ArrivalTrigger.Scroll, screens, pageShare, seconds: null };
679
+ case PopupArrive.Time: return { trigger: ArrivalTrigger.Time, screens: null, pageShare: null, seconds: seconds(POPUP_RULES.timeSeconds) };
680
+ // PU2b draws `leaving` for a fine pointer; until then — and on a phone, always — it arrives by time.
681
+ case PopupArrive.Leaving: return { trigger: ArrivalTrigger.Time, screens: null, pageShare: null, seconds: Math.max(POPUP_RULES.minSeconds, POPUP_RULES.phoneLeavingSeconds) };
682
+ default: return { trigger: ArrivalTrigger.ScrollOrTime, screens, pageShare, seconds: seconds(POPUP_RULES.timeSeconds) };
683
+ }
684
+ }
685
+ /** AW2 / PU-D17: the consent banner's arrival — `load` at once, `delay` on the first real scroll or after 6 s. */
686
+ function planConsentArrival(arrive) {
687
+ return arrive === 'delay'
688
+ ? { trigger: ArrivalTrigger.ScrollOrTime, screens: 0, pageShare: null, seconds: CONSENT_DELAY_MS / 1000 }
689
+ : { trigger: ArrivalTrigger.Now, screens: null, pageShare: null, seconds: null };
690
+ }
691
+ function scrolledEnough(plan, p) {
692
+ if (!(p.scrolledPx > 0))
693
+ return false; // a real scroll, after the turn started
694
+ if (plan.pageShare !== null) {
695
+ const room = p.pageHeight - p.viewportHeight;
696
+ return room <= 0 || p.scrollY / room >= plan.pageShare;
697
+ }
698
+ return p.scrolledPx >= (plan.screens ?? 0) * p.viewportHeight;
699
+ }
700
+ /** True once the planned arrival has happened. */
701
+ function arrivalFired(plan, p) {
702
+ switch (plan.trigger) {
703
+ case ArrivalTrigger.Now: return true;
704
+ case ArrivalTrigger.Never: return false;
705
+ case ArrivalTrigger.Scroll: return scrolledEnough(plan, p);
706
+ case ArrivalTrigger.Time: return p.visibleSeconds >= (plan.seconds ?? Infinity);
707
+ default: return scrolledEnough(plan, p) || p.visibleSeconds >= (plan.seconds ?? Infinity);
708
+ }
709
+ }
710
+ const POPUP_MEMORY_PREFIX = 'iox-popup';
711
+ /** `iox-popup:<site scope>:<popup node id>` — no identifier of the visitor. */
712
+ function popupMemoryKey(scope, popupId) {
713
+ return `${POPUP_MEMORY_PREFIX}:${scope || '-'}:${popupId}`;
714
+ }
715
+ /** Where it is kept: `visit` → the tab's session; `days` / `once` → the browser. The runtime falls back to the session,
716
+ * then to this page view, when one is refused. */
717
+ var PopupMemoryStore;
718
+ (function (PopupMemoryStore) {
719
+ PopupMemoryStore["Local"] = "local";
720
+ PopupMemoryStore["Session"] = "session";
721
+ })(PopupMemoryStore || (PopupMemoryStore = {}));
722
+ function popupMemoryStore(again) {
723
+ return again === PopupAgain.Visit ? PopupMemoryStore.Session : PopupMemoryStore.Local;
724
+ }
725
+ function encodePopupMemory(memory) {
726
+ return JSON.stringify({ v: memory.v, closedAt: memory.closedAt, acted: memory.acted });
727
+ }
728
+ /** Tolerant: anything that is not a well-formed memory reads as none (a browser holding garbage still gets the popup). */
729
+ function decodePopupMemory(raw) {
730
+ if (!raw)
731
+ return null;
732
+ try {
733
+ const o = JSON.parse(raw);
734
+ if (!o || typeof o !== 'object')
735
+ return null;
736
+ const v = Number(o.v), closedAt = Number(o.closedAt);
737
+ if (!Number.isFinite(v) || !Number.isFinite(closedAt) || closedAt < 0)
738
+ return null;
739
+ return { v, closedAt, acted: o.acted === true };
740
+ }
741
+ catch {
742
+ return null;
743
+ }
744
+ }
745
+ /** A popup's version (`popupVersion`, default 1). */
746
+ function popupVersionOf(get) {
747
+ const n = num(get(PopupTrait.Version));
748
+ return n !== null && n >= 1 ? Math.floor(n) : 1;
749
+ }
750
+ const DAY_MS = 86_400_000;
751
+ /** True while a remembered close keeps the popup away (any version older than the popup's is forgotten). */
752
+ function memoryKeepsAway(memory, get, now) {
753
+ if (!memory || memory.v < popupVersionOf(get))
754
+ return false;
755
+ if (memory.acted)
756
+ return true; // never again after the visitor acts — until the owner changes it
757
+ const again = String(get(PopupTrait.Again) ?? '') || POPUP_KIND_MIX[get(PopupTrait.Kind) ?? PopupKind.Offer]?.again;
758
+ if (again === PopupAgain.Once || again === PopupAgain.Visit)
759
+ return true; // a visit's memory dies with the session
760
+ const days = num(get(PopupTrait.Days)) ?? POPUP_RULES.memoryDays;
761
+ return now - memory.closedAt < days * DAY_MS;
762
+ }
763
+ // ── dates (PU-D18) ────────────────────────────────────────────────────────────────────────────────────────────────────
764
+ /** The visitor's day, `YYYY-MM-DD`, on THEIR clock (never UTC — a popup "until 30 November" ends at their midnight). */
765
+ function visitorDay(now) {
766
+ const p = (n) => String(n).padStart(2, '0');
767
+ return `${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())}`;
768
+ }
769
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
770
+ /** Inside its dates (whole days, both ends included); no dates = always. A malformed date is ignored. */
771
+ function popupWithinDates(get, now) {
772
+ const day = visitorDay(now);
773
+ const from = String(get(PopupTrait.ShowFrom) ?? '').trim(), until = String(get(PopupTrait.ShowUntil) ?? '').trim();
774
+ if (DAY_RE.test(from) && day < from)
775
+ return false;
776
+ if (DAY_RE.test(until) && day > until)
777
+ return false;
778
+ return true;
779
+ }
780
+ /** Ended: its last day is past (the engine leaves it out of the raw SSR; Home warns). Days compare on the given clock. */
781
+ function popupEnded(get, now) {
782
+ const until = String(get(PopupTrait.ShowUntil) ?? '').trim();
783
+ return DAY_RE.test(until) && visitorDay(now) > until;
784
+ }
785
+ // ── due ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
786
+ var PopupNotDue;
787
+ (function (PopupNotDue) {
788
+ /** Only a button opens it. */
789
+ PopupNotDue["Button"] = "button";
790
+ /** Outside its dates. */
791
+ PopupNotDue["Dates"] = "dates";
792
+ /** A remembered close (or the visitor acted). */
793
+ PopupNotDue["Memory"] = "memory";
794
+ })(PopupNotDue || (PopupNotDue = {}));
795
+ /** May this popup arrive by itself now? null = due; else why not. */
796
+ function popupDue(get, memory, now) {
797
+ if (String(get(PopupTrait.Arrive) ?? '') === PopupArrive.Button)
798
+ return PopupNotDue.Button;
799
+ if (!popupWithinDates(get, now))
800
+ return PopupNotDue.Dates;
801
+ if (memoryKeepsAway(memory, get, now.getTime()))
802
+ return PopupNotDue.Memory;
803
+ return null;
804
+ }
805
+ // ── presentation ──────────────────────────────────────────────────────────────────────────────────────────────────────
806
+ /** How it opens on THIS device (PU-D2, PU-D10): `centred` is a modal on a laptop only — on a phone it is the corner card. */
807
+ function popupFormOn(get, env) {
808
+ const form = popupFormOf(get(PopupTrait.Kind), get(PopupTrait.Form));
809
+ return env.phone && form === PopupForm.Centred ? PopupForm.Corner : form;
810
+ }
811
+ /** §6: the factor the `popup-dur-*` tokens are scaled by for the look's How animated (the token holds Standard). */
812
+ function popupMotionScale(level) {
813
+ const table = POPUP_RULES.durationByAnimated;
814
+ return Math.round(((table[level ?? ''] ?? table['standard']) / table['standard']) * 1000) / 1000;
815
+ }
816
+ /** Still moves nothing: the popup fades (§6). */
817
+ function popupFadesOnly(level) {
818
+ return level === 'still';
819
+ }
820
+
580
821
  /**
581
822
  * @vectoriox/iox-ui/actions-core — the shared, FRAMEWORK-FREE action vocabulary.
582
823
  *
@@ -592,5 +833,5 @@ function revealFrom(dialog, opener) {
592
833
  * Generated bundle index. Do not edit.
593
834
  */
594
835
 
595
- export { ACCOUNT_ACTION_TYPES, BEHAVIOUR_ACTION_TYPES, CONSENT_ACTION_TYPES, COUNT_UP_TRIGGERS, DIALOG_ACTION_TYPE_SET, DIALOG_CLOSING_ATTRIBUTE, DIALOG_EXIT_TIMEOUT_MS, DIALOG_OPENER_ACTION_TYPES, DIALOG_OPENER_TRIGGER, DIALOG_SELECTOR, ELEMENT_ACTION_DESCRIPTORS, ELEMENT_ACTION_GROUP_ORDER, FORM_SUBMIT_ACTION_DESCRIPTORS, ITEM_ACTION_TYPES, OpenerAttribute, POPOVER_ACTION_TYPE_SET, POPOVER_NODE_TYPE, POPOVER_OPENER_ACTION_TYPES, RevealOriginProperty, SCROLL_PROGRESS_TRIGGER, SERVER_ELEMENT_ACTION_TYPES, SHOP_ACTION_TYPES, SHOP_ENTITLEMENT, TOAST_ACTION_TYPES, actionOfferedUnder, addableActions, cancelExit, closeDialogAnimated, dialogDomId, dialogOpenerAttributes, dialogOpenersSelector, dialogTogglesClosed, focusDialogSheet, groupedElementActions, holdClosedWhile, isExiting, itemActionOf, nodeIdOfDialogDomId, nodeIdOfPopoverDomId, openedDialogId, openedPopoverId, openedTargetId, opensAtClickedItem, popoverDomId, popoverOpenerAttributes, popoverOpenersSelector, resolveActionAvailability, revealFrom, revealOrigin, revealOriginStyle, runExitMotion };
836
+ export { ACCOUNT_ACTION_TYPES, ArrivalTrigger, BEHAVIOUR_ACTION_TYPES, CONSENT_ACTION_TYPES, CONSENT_DELAY_MS, COUNT_UP_TRIGGERS, DIALOG_ACTION_TYPE_SET, DIALOG_CLOSING_ATTRIBUTE, DIALOG_EXIT_TIMEOUT_MS, DIALOG_OPENER_ACTION_TYPES, DIALOG_OPENER_TRIGGER, DIALOG_SELECTOR, ELEMENT_ACTION_DESCRIPTORS, ELEMENT_ACTION_GROUP_ORDER, FORM_SUBMIT_ACTION_DESCRIPTORS, ITEM_ACTION_TYPES, OpenerAttribute, OverlayTurnKind, POPOVER_ACTION_TYPE_SET, POPOVER_NODE_TYPE, POPOVER_OPENER_ACTION_TYPES, POPUP_MEMORY_PREFIX, POPUP_RULES, POPUP_TURN_PREFIX, PopupMemoryStore, PopupNotDue, RevealOriginProperty, SCROLL_PROGRESS_TRIGGER, SERVER_ELEMENT_ACTION_TYPES, SHOP_ACTION_TYPES, SHOP_ENTITLEMENT, TOAST_ACTION_TYPES, actionOfferedUnder, addableActions, arrivalFired, cancelExit, closeDialogAnimated, decodePopupMemory, dialogDomId, dialogOpenerAttributes, dialogOpenersSelector, dialogTogglesClosed, encodePopupMemory, focusDialogSheet, groupedElementActions, holdClosedWhile, isExiting, isQuietRoute, itemActionOf, memoryKeepsAway, nodeIdOfDialogDomId, nodeIdOfPopoverDomId, openedDialogId, openedPopoverId, openedTargetId, opensAtClickedItem, overlayTurn, planConsentArrival, planPopupArrival, popoverDomId, popoverOpenerAttributes, popoverOpenersSelector, popupDue, popupEnded, popupFadesOnly, popupFormOn, popupMemoryKey, popupMemoryStore, popupMotionScale, popupOfTurn, popupVersionOf, popupWithinDates, resolveActionAvailability, revealFrom, revealOrigin, revealOriginStyle, runExitMotion, visitorDay };
596
837
  //# sourceMappingURL=vectoriox-iox-ui-actions-core.mjs.map